When we undo/redo in the editor, we need to ensure that our model switch gets propagated to the scene being held by the frame and info panel.

git-svn-id: svn+ssh://src.earth.threerings.net/vilya/trunk@902 c613c5cb-e716-0410-b11b-feb51c14d237
This commit is contained in:
Mike Thomas
2010-03-16 16:53:11 +00:00
parent e4e5990361
commit 28e24afd73
2 changed files with 26 additions and 2 deletions
@@ -55,8 +55,10 @@ import com.threerings.media.ManagedJFrame;
import com.threerings.miso.tile.BaseTileSet;
import com.threerings.whirled.data.AuxModel;
import com.threerings.whirled.tools.xml.SceneParser;
import com.threerings.stage.data.StageMisoSceneModel;
import com.threerings.stage.data.StageScene;
import com.threerings.stage.data.StageSceneModel;
import com.threerings.stage.tools.editor.util.EditorContext;
@@ -67,6 +69,7 @@ import com.threerings.stage.tools.xml.StageSceneWriter;
import static com.threerings.stage.Log.log;
public class EditorFrame extends ManagedJFrame
implements EditorScenePanel.SceneModelListener
{
public EditorFrame (StageSceneWriter writer)
{
@@ -191,7 +194,7 @@ public class EditorFrame extends ManagedJFrame
*/
protected EditorScenePanel createScenePanel ()
{
return new EditorScenePanel(_ctx, this, _model);
return new EditorScenePanel(_ctx, this, _model, this);
}
/**
@@ -307,6 +310,16 @@ public class EditorFrame extends ManagedJFrame
}
}
public void setMisoSceneModel (StageMisoSceneModel model)
{
AuxModel[] models = _scene.getSceneModel().auxModels;
for (int ii = 0; ii < models.length; ii++) {
if (models[ii] instanceof StageMisoSceneModel) {
models[ii] = model;
}
}
}
/**
* Creates a blank scene and configures the editor to begin editing
* it. Eventually this should make sure the user has a chance to save
@@ -89,13 +89,21 @@ import static com.threerings.stage.Log.log;
public class EditorScenePanel extends StageScenePanel
implements EditorModelListener, ChangeListener
{
public interface SceneModelListener
{
public void setMisoSceneModel (StageMisoSceneModel sceneModel);
}
/**
* Constructs the editor scene view panel.
*/
public EditorScenePanel (EditorContext ctx, JFrame frame, EditorModel model)
public EditorScenePanel (EditorContext ctx, JFrame frame, EditorModel model,
SceneModelListener sceneListener)
{
super(ctx, new Controller() { });
_sceneListener = sceneListener;
// keep these around for later
_ctx = ctx;
_frame = frame;
@@ -1164,6 +1172,7 @@ public class EditorScenePanel extends StageScenePanel
public void rollback () {
if (_list.size() > 0) {
_model = _list.removeFirst();
_sceneListener.setMisoSceneModel((StageMisoSceneModel)_model);
refreshScene();
}
}
@@ -1243,6 +1252,8 @@ public class EditorScenePanel extends StageScenePanel
protected UndoStack _undo = new UndoStack();
protected UndoStack _redo = new UndoStack();
protected SceneModelListener _sceneListener;
/** The triangle used to render a portal on-screen. */
protected static Polygon _locTri;