1 // Copyright (C) 2007, 2008, 2009 Ben Asselstine
3 // This program is free software; you can redistribute it and/or modify
4 // it under the terms of the GNU General Public License as published by
5 // the Free Software Foundation; either version 3 of the License, or
6 // (at your option) any later version.
8 // This program is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 // GNU Library General Public License for more details.
13 // You should have received a copy of the GNU General Public License
14 // along with this program; if not, write to the Free Software
15 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
23 #include "xmlhelper.h"
26 //! Describes the look of a Tile.
28 * A TileStyle describes a single look of a Tile. It is responsible for
29 * keeping the id, the image, and the kind of style. The TileStyles for a
30 * given tile are defined in the Tileset configuration file.
31 * If the kind of tile is `forest', then the TileStyles are defined in
32 * individual tileset.tile.tilestyleset.tilestyle XML entities.
34 * There are many different images that can represent a kind of Tile.
35 * Only certain tiles look right when positioned beside each other. The
36 * correct styles are assigned by the GameMap::calculatePreferredStyle method.
37 * The id is important because it is referenced by the saved-game file
38 * (the lordsawar.map.styles XML entity).
40 * Every TileStyle belongs to a TileStyleSet, which belongs to a Tile.
41 * Every Maptile refers to a TileStyle.
46 //! The xml tag of this object in a tileset configuration file.
47 static std::string d_tag;
49 //! Describe terrain tile styles.
51 * All of the Tilestyle kinds can be described by using the
62 * Picture a terrain feature transitioning to grass on the outside
63 * of the ring and on the inside of the ring also.
64 * In the very center of the template is a single feature that
65 * transitions to grass on all sides.
140 OUTERBOTTOMCENTER = 5,
152 OUTERBOTTOMRIGHT = 6,
176 INNERMIDDLECENTER = 8,
188 OUTERMIDDLERIGHT = 9,
224 INNERBOTTOMLEFT = 12,
236 INNERBOTTOMRIGHT = 13,
238 * Visually it's the merging of positions 1 and 2.
249 TOPLEFTTOBOTTOMRIGHTDIAGONAL = 14,
251 * Visually it's the merging of positions 1 and 2.
262 BOTTOMLEFTTOTOPRIGHTDIAGONAL = 15,
266 //! Default constructor.
269 //! Loading constructor.
271 * Load the tileset.tile.tilestyles.tilestyle XML entities from the
272 * tileset configuration files.
274 TileStyle(XML_Helper* helper);
281 //! Get the id for this tilestyle.
283 * The id is unique among all other tilestyles in the Tileset.
285 guint32 getId() const {return d_id;}
287 //! Get the style type of this tile style.
288 Type getType() const {return d_type;}
290 //! Get the picture for tile style.
291 PixMask* getImage() const {return d_image;}
293 //! Get the name of the current style.
294 std::string getTypeName() const;
299 //! Set the style type of this tile style.
301 * @note This method is only used in the tileset editor.
303 void setType(Type type) {d_type = type;}
305 //! Set the id for this tilestyle.
306 void setId(guint32 id) {d_id = id;}
308 //! Set the image for the tilestyle.
309 void setImage(PixMask* image) {d_image = image;};
312 // Methods that operate on the class data but do not modify the class.
314 //! Save a TileStyle to an opened tile configuration file.
316 * @param The opened XML tile configuration file.
318 bool save(XML_Helper *helper);
322 //! Get the name of the TileStyle::Type in string form.
323 static std::string getTypeName(Type type);
325 //! Return the style type enumeration given the type name.
326 static TileStyle::Type typeNameToType(std::string name);
331 //! The image of this tilestyle.
334 //! The type of the tilestyle.
337 //! The unique id for this tilestyle.
339 * It must be unique among all other TileStyle objects in the
341 * This id shows up in the saved-game file in the lordsawar.map.styles
342 * XML entity as a hexidecimal number.
347 #endif // TILESTYLE_H