tiles.rc syntax: allow inheriting of another tile's images/attributes
To inherit, just put the name of tile you want to inherit from in parenthesis at the beginning of the specification. E.g. road-1-1 (road) roads/1-1 (road-north)(road-south) will define a tile named "road-1-1", which first starts with all the images and properties of tile "road" and then layers on top of that the 'road/1-1' image, and then sets the 'road-north' and 'road-south' flags. git-svn-id: https://micropolis.googlecode.com/svn/trunk/micropolis-java@754 d9718cc8-9f43-0410-858b-315f434eb58c
This commit is contained in:
parent
103999e578
commit
22c0edc7c1
3 changed files with 16 additions and 6 deletions
|
@ -47,7 +47,7 @@ public class MakeTiles
|
|||
String rawSpec = recipe.getProperty(Integer.toString(i));
|
||||
assert rawSpec != null;
|
||||
|
||||
TileSpec tileSpec = TileSpec.parse(i, rawSpec);
|
||||
TileSpec tileSpec = TileSpec.parse(i, rawSpec, recipe);
|
||||
FrameSpec ref = parseFrameSpec(tileSpec);
|
||||
drawTo(ref, gr, 0, TILE_SIZE*i);
|
||||
}
|
||||
|
|
|
@ -20,10 +20,10 @@ public class TileSpec
|
|||
this.images = new ArrayList<String>();
|
||||
}
|
||||
|
||||
public static TileSpec parse(int tileNumber, String inStr)
|
||||
public static TileSpec parse(int tileNumber, String inStr, Properties tilesRc)
|
||||
{
|
||||
TileSpec ts = new TileSpec(tileNumber);
|
||||
ts.load(inStr);
|
||||
ts.load(inStr, tilesRc);
|
||||
return ts;
|
||||
}
|
||||
|
||||
|
@ -43,7 +43,7 @@ public class TileSpec
|
|||
return images.toArray(new String[0]);
|
||||
}
|
||||
|
||||
protected void load(String inStr)
|
||||
protected void load(String inStr, Properties tilesRc)
|
||||
{
|
||||
Scanner in = new Scanner(inStr);
|
||||
|
||||
|
@ -58,7 +58,17 @@ public class TileSpec
|
|||
v = in.readAttributeValue();
|
||||
}
|
||||
in.eatChar(')');
|
||||
attributes.put(k, v);
|
||||
|
||||
if (!attributes.containsKey(k)) {
|
||||
attributes.put(k, v);
|
||||
String sup = tilesRc.getProperty(k);
|
||||
if (sup != null) {
|
||||
load(sup, tilesRc);
|
||||
}
|
||||
}
|
||||
else {
|
||||
attributes.put(k, v);
|
||||
}
|
||||
}
|
||||
|
||||
else if (in.peekChar() == '|' || in.peekChar() == ',') {
|
||||
|
|
|
@ -37,7 +37,7 @@ public class Tiles
|
|||
continue;
|
||||
}
|
||||
|
||||
tiles[i] = TileSpec.parse(i, rawSpec);
|
||||
tiles[i] = TileSpec.parse(i, rawSpec, tilesRc);
|
||||
}
|
||||
|
||||
for (int i = 0; i < tiles.length; i++) {
|
||||
|
|
Reference in a new issue