Changed MisoSceneModel so that it knows about the view width and height.

It no longer stores base tiles that are not visable in the view,
in fact it stores the base tiles in an array almost half the size as the
fully expanded scene array, and this new smaller array is used everywhere:
when saving the scene, serializing it to the user, or saving it in
the database.
We must now use the getBaseTile() and setBaseTile() methods to access the
base tiles because they are stored in this compressed format.
Also removed the fringe layer completely from the MisoSceneModel.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@1369 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Ray Greenwell
2002-05-17 19:06:23 +00:00
parent ab242f4a71
commit bb6b0f56ca
7 changed files with 180 additions and 86 deletions
@@ -1,5 +1,5 @@
//
// $Id: EditableMisoScene.java,v 1.15 2002/04/27 18:41:14 mdb Exp $
// $Id: EditableMisoScene.java,v 1.16 2002/05/17 19:06:23 ray Exp $
package com.threerings.miso.scene.tools;
@@ -58,17 +58,6 @@ public interface EditableMisoScene
*/
public void setBaseTiles (Rectangle r, BaseTileSet set, int setId);
/**
* Updates the tile at the specified location in the fringe layer.
*
* @param x the x-coordinate of the tile to set.
* @param y the y-coordinate of the tile to set.
* @param tile the tile to set.
* @param fqTileId the fully-qualified tile id (@see
* TileUtil#getFQTileId}) of the new default base tile.
*/
public void setFringeTile (int x, int y, Tile tile, int fqTileId);
/**
* Addds an object tile to this scene.
*
@@ -90,11 +79,6 @@ public interface EditableMisoScene
*/
public void clearBaseTile (int x, int y);
/**
* Clears out the tile at the specified location in the fringe layer.
*/
public void clearFringeTile (int x, int y);
/**
* Clears out the specified tile from the object list.
*/
@@ -1,5 +1,5 @@
//
// $Id: EditableMisoSceneImpl.java,v 1.19 2002/05/03 04:12:48 mdb Exp $
// $Id: EditableMisoSceneImpl.java,v 1.20 2002/05/17 19:06:23 ray Exp $
package com.threerings.miso.scene.tools;
@@ -91,8 +91,8 @@ public class EditableMisoSceneImpl
try {
int index = _rando.nextInt(setcount);
_base.setTile(x, y, (BaseTile) set.getTile(index));
_model.baseTileIds[_model.width*y + x] =
TileUtil.getFQTileId(setId, index);
_model.setBaseTile(
x, y, TileUtil.getFQTileId(setId, index));
} catch (NoSuchTileException nste) {
// not going to happen
@@ -109,18 +109,10 @@ public class EditableMisoSceneImpl
public void setBaseTile (int x, int y, BaseTile tile, int fqTileId)
{
_base.setTile(x, y, tile);
_model.baseTileIds[_model.width*y + x] = fqTileId;
_model.setBaseTile(x, y, fqTileId);
_fringer.fringe(_model, _fringe, new Rectangle(x, y, 1, 1), _rando);
}
// documentation inherited
public void setFringeTile (int x, int y, Tile tile, int fqTileId)
{
_fringe.setTile(x, y, tile);
// update the model as well
_model.fringeTileIds[_model.width*y + x] = fqTileId;
}
// documentation inherited
public void addObjectTile (ObjectTile tile, int x, int y, int fqTileId)
{
@@ -148,14 +140,6 @@ public class EditableMisoSceneImpl
_defaultBaseTileSet, _defaultBaseTileSetId);
}
// documentation inherited
public void clearFringeTile (int x, int y)
{
_fringe.setTile(x, y, null);
// clear it out in the model
_model.fringeTileIds[_model.width*y + x] = 0;
}
// documentation inherited
public void removeObjectTile (ObjectTile tile)
{
@@ -1,5 +1,5 @@
//
// $Id: MisoSceneRuleSet.java,v 1.8 2002/05/16 02:25:19 ray Exp $
// $Id: MisoSceneRuleSet.java,v 1.9 2002/05/17 19:06:23 ray Exp $
package com.threerings.miso.scene.tools.xml;
@@ -9,6 +9,7 @@ import org.apache.commons.digester.RuleSetBase;
import com.samskivert.xml.CallMethodSpecialRule;
import com.samskivert.xml.SetFieldRule;
import com.threerings.miso.Log;
import com.threerings.miso.scene.MisoSceneModel;
/**
@@ -51,6 +52,10 @@ public class MisoSceneRuleSet extends RuleSetBase
new SetFieldRule(digester, "width"));
digester.addRule(_prefix + "/height",
new SetFieldRule(digester, "height"));
digester.addRule(_prefix + "/viewwidth",
new SetFieldRule(digester, "vwidth"));
digester.addRule(_prefix + "/viewheight",
new SetFieldRule(digester, "vheight"));
digester.addRule(_prefix + "/base",
new SetFieldRule(digester, "baseTileIds"));
digester.addRule(_prefix + "/object",
@@ -72,8 +77,13 @@ public class MisoSceneRuleSet extends RuleSetBase
model.objectActions = new String[1];
}
// and allocate the fringe tile layer
model.fringeTileIds = new int[model.baseTileIds.length];
// check to see if we've read in an old-style model.
// TODO: remove this someday after all our scenes are
// converted.
if (model.vwidth == 0) {
model.convertOldSchool(10, 12);
Log.info("Converted old-school MisoSceneModel.");
}
}
});
}
@@ -1,5 +1,5 @@
//
// $Id: MisoSceneWriter.java,v 1.6 2002/05/16 02:25:19 ray Exp $
// $Id: MisoSceneWriter.java,v 1.7 2002/05/17 19:06:23 ray Exp $
package com.threerings.miso.scene.tools.xml;
@@ -38,9 +38,10 @@ public class MisoSceneWriter
{
writer.dataElement("width", Integer.toString(model.width));
writer.dataElement("height", Integer.toString(model.height));
writer.dataElement("viewwidth", Integer.toString(model.vwidth));
writer.dataElement("viewheight", Integer.toString(model.vheight));
writer.dataElement("base",
StringUtil.toString(model.baseTileIds, "", ""));
// note that we don't write the fringe layer.
writer.dataElement("object",
StringUtil.toString(model.objectTileIds, "", ""));
writer.dataElement("actions",