From: Erik V. <eri...@xs...> - 2010-01-11 22:40:27
|
This may another one of those "I should not go there" type of questions. If so apologies in advance. Or I may be missing something obvious. At the moment I am learning the source of Rails via experimentation rather than intensive reading of the code. Feel free to ask any questions; however, I can't guarantee that the answer is always welcome. A tile for a given game is defined in three places: The per-game TileSet.xml seems reasonable as it has a list of the tiles in the given game, quantity of tiles, upgrade path, and which SVG picture to use. The per-game Tiles.xml has the same list of tiles but this time with the colour of the tile (not the actual color on the time but the color phase), how many cities and towns and their positions; values of the cities/towns and a list of how the track is laid out (e.g., from side 0 to side 2, from side 1 to side 5). The whole-rails SVG files have the graphics for each of the tiles. Now for a given tile the relationship of the tile's SVG file and the tile's entry in Tiles.xml is fixed. In other words I can not a take a tile in the Tiles.xml file and change its track layout from 'side 0 to side 2' to 'side 0 to side 3' and expect that the tile will show up properly. Instead it will retain it's SVG representation. Ditto if I try to change the number of cities or their position. So ... why not have a global Tiles.xml file with three items in it and reduce the duplication across the games? That would make the per-game Tiles.xml smaller and more readable (and thus easier to debug). And/or combine the reduced per-game Tiles.xml file into the TileSet.xml file thus reducing another source of duplication and error. 1. Why do we have separate TileSet.xml and Tiles.xml? TileSet.xml contains the game-specific tile properties, and Tiles.xml has the game-independent tile properties. The latter file is generated by rails.util.MakeGameTileSets (a stand-alone Java class/program) from TileSet.xml and the overall Tiles.xml file that has *all* tiles (this file and several other files that I'm going to mention are in directory 18xx/tiles of the CVS repository on Sourceforge). This program also checks TileSet.xml against Map.xml for consistency. 2. Why do we have separate XMLand SVG files? That is because we use an SVG renderer that understands SVG, whereas both I and the Java code I have written only understand XML. And I doubt if the twain will ever meet. 3. Where do Tiles.xml and the SVG files come from? Ultimately everything comes from a tile database named TileDesigner.18t created by Marco Rocci's TileDesigner program (see http://www.rails18xx.it/software.html). In the mean time I have added a lot of tiles to Marco's original tile set. From that database I export both the SVG tiles and an XML descriptive file called TileDesigner.xml. The SVG export is somewhat buggy. Originally Brett fixed that by a procedure that I don't have the details of. I have recently taken over and I'm now using a procedure described in the comments of a Perl script named CombineTiles.pl. That script builds the Rails SVG file set by combining parts from three sets of SVG files: - tiles with ID > 0 (layable tiles, the ID is printed on the tile). - tiles with ID <=0 (preprinted tiles, no ID on the tile; this is a separate export from TileDesigner) - special tiles that I have modified manually with Inkscape (such as the red off-board tiles -901 throught -903, which TileDesigner cannot create with "arrows". So for these tiles the XML does *not* exactly correspond with the SVG!). The XML export (TileDesigner.xml) is converted by another Java program/class named rails.util.ConvertTiles into the overall Tiles.xml that I mentioned before. I'm doing this conversion because I think that the latter format is better suitable for use in Rails. 4. Why is this procedure so complex? Well, we're doing the best we can with the limited knowledge and imperfect tools that we have. BTW#1: Is there any routine to display all of the SVG files? No. Only TileDesigner has everything. BTW#2: The README in the 'tiles' directory says that the XML files in said directory are not important. IMHO it should also say that the svg sub-directory is critically important. As you can imagine by my comment it took me a while to realize the importance of said directory It doesn't say that these aren't important, it only says that these are not [directly] used by Rails. These files in fact do form the basis of the per-game tile sets, as I hope I have explained well enough above. Erik |