//
// $Id: SampleController.java,v 1.7 2002/07/12 04:27:03 mdb Exp $

package com.whomever.sample.client;

import com.threerings.crowd.client.PlaceView;
import com.threerings.crowd.data.PlaceObject;

import com.threerings.parlor.game.client.GameController;
import com.threerings.toybox.data.ToyBoxGameConfig;
import com.threerings.toybox.util.ToyBoxContext;

import com.whomever.sample.data.SampleObject;

/**
 * Manages the client side mechanics of a Sample game.
 */
public class SampleController extends GameController
{
    /** The name of the command posted by the "Back to lobby" button in
     * the side bar. */
    public static final String BACK_TO_LOBBY = "BackToLobby";

    // documentation inherited
    protected void didInit ()
    {
        super.didInit();

        // cast our context
        _ctx = (ToyBoxContext)super._ctx;
    }

    // documentation inherited
    protected PlaceView createPlaceView ()
    {
        // this is called in our super class constructor, which means that
        // our casted _ctx reference is not yet initialized
        _panel = new SamplePanel((ToyBoxContext)super._ctx,
                                 (ToyBoxGameConfig)_config, this);
        return _panel;
    }

    // documentation inherited
    public void willEnterPlace (PlaceObject plobj)
    {
        super.willEnterPlace(plobj);

        // this method is called when we enter the game "room"

        // get a casted reference to our game object
        _sampobj = (SampleObject)plobj;
    }

    // documentation inherited
    public void didLeavePlace (PlaceObject plobj)
    {
        super.didLeavePlace(plobj);

        // this method is called when we leave the game "room"
    }

    /**
     * This method is called automatically by the controller system when
     * the player clicks the button that was configured with the {@link
     * #BACK_TO_LOBBY} action and the special {@link #DISPATCHER} which
     * does the necessary reflection magic.
     */
    public void handleBackToLobby (Object source)
    {
        _ctx.getLocationDirector().moveBack();
    }

    // documentation inherited
    protected void gameDidStart ()
    {
        super.gameDidStart();

        // here we can set up anything that should happen at the start of
        // the game
    }

    // documentation inherited
    protected void gameDidEnd ()
    {
        super.gameDidEnd();

        // here we can clear out anything that needs to be cleared out at
        // the end of a game
    }

    /** Provides access to various client services. */
    protected ToyBoxContext _ctx;

    /** Our game panel. */
    protected SamplePanel _panel;

    /** Our game distributed object. */
    protected SampleObject _sampobj;
}

@@ -191,16 +191,63 @@
 eObject;
+%0Aimport com.threerings.crowd.util.CrowdContext;
 %0A%0Aimport
@@ -969,150 +969,31 @@
 ew (
-)%0A    %7B%0A        // this is called in our super class constructor, which means that%0A        // our casted _ctx reference is not yet initialized
+CrowdContext ctx)%0A    %7B
 %0A   
@@ -1037,23 +1037,16 @@
 Context)
-super._
 ctx,%0A   

Use the new non-deprecated createPlaceView().