1 // Copyright (C) 2007, 2008 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
18 #ifndef TILESTYLESET_H
19 #define TILESTYLESET_H
24 #include <sigc++/trackable.h>
26 #include "tilestyle.h"
31 * TileStyleSet is an array of tilestyles (the look of terrain tile objects).
32 * All of the TileStyles describe one of the many looks of a particular kind
33 * of Tile. e.g. `Forest'.
34 * Every TileStyleSet belongs to a Tile.
35 * The TileStyleSet images are located in on disk in the Tileset's directory.
37 //! This class manages a set of TileStyle objects.
38 class TileStyleSet : public sigc::trackable, public std::vector<TileStyle*>
42 //! The xml tag of this object in a tileset configuration file.
43 static std::string d_tag;
45 //! The default constructor.
48 //! The loading constuctor loads the TileStyleSet from the config file.
50 * Read the tileset.tile.tilestyleset XML entities in the tileset
53 * @param helper The opened tileset configuration file.
55 TileStyleSet(XML_Helper* helper);
63 //! Get the name of this tilestyleset.
65 * Returns the text loaded from a tileset.tile.tilestyles.d_name
66 * XML entity of the tileset configuration flie.
67 * This name refers to the filename that holds the imagery for this
68 * tilestyleset. It is a basename of the filename. It doesn't
69 * contain any slashes, or an ending file extension. eg. ".png".
71 std::string getName() const {return d_name;}
73 //! Return the subdirectory of this Tilestyleset.
74 std::string getSubDir() const {return d_dir;};
79 //! Set the name of this tilestyleset.
80 void setName(std::string name) {d_name = name;}
82 //! Set the subdirectory of where this Tilestyleset resides on disk.
83 void setSubDir(std::string dir) {d_dir = dir;};
86 //Methods that operate on the class data but do not modify the class.
88 //! Save a TileStyleSet to an opened tile configuration file.
90 * @param The opened XML tile configuration file.
92 bool save(XML_Helper *helper) const;
94 //! Return a list of all of the tilestyle types in this tilestyleset.
95 void getUniqueTileStyleTypes(std::list<TileStyle::Type> &types) const;
97 //! Check to see if this tilestyleset is usable in the game.
98 bool validate() const;
101 //Methods that operate on the class data and modify the class.
103 //! Instantiate the tilestyleset's images from the given file.
104 void instantiateImages(int tilesize, std::string image_filename);
106 //! Destroy the images associated with this tilestyleset.
107 void uninstantiateImages();
113 //! The name of the tilestyleset.
115 * This is the basename of the image that contains a row of
116 * cells where each cell is tilesize pixels high, and tilesize
117 * pixels wide. Each cell is another image of a tilestyle. There is
118 * one cell per TileStyle in this TileStyleSet.
119 * The tilesize comes from the TileStyleSet::instantiateImages
121 * The name does not contain a path, and does not contain an
122 * extension (e.g. .png). It must refer to a PNG file.
126 //! The directory of where the image file lives.
128 * @param This is a hack used for the tileset editor.
133 #endif // TILESTYLESET_H