X-Git-Url: http://git.maemo.org/git/?p=lordsawar;a=blobdiff_plain;f=src%2Ftilestyleset.h;fp=src%2Ftilestyleset.h;h=4758624fab3f8bfd41080a7d6d3f8b49828427eb;hp=0000000000000000000000000000000000000000;hb=9eda00ff73353c55ecef6f82131166d5d4a85e29;hpb=3d34d4aa85a929f912464f71158396a388274f27 diff --git a/src/tilestyleset.h b/src/tilestyleset.h new file mode 100644 index 0000000..4758624 --- /dev/null +++ b/src/tilestyleset.h @@ -0,0 +1,135 @@ +// Copyright (C) 2007, 2008 Ben Asselstine +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Library General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +// 02110-1301, USA. + +#ifndef TILESTYLESET_H +#define TILESTYLESET_H + +#include +#include +#include +#include + +#include "tilestyle.h" + +class XML_Helper; + +/** + * TileStyleSet is an array of tilestyles (the look of terrain tile objects). + * All of the TileStyles describe one of the many looks of a particular kind + * of Tile. e.g. `Forest'. + * Every TileStyleSet belongs to a Tile. + * The TileStyleSet images are located in on disk in the Tileset's directory. + */ +//! This class manages a set of TileStyle objects. +class TileStyleSet : public sigc::trackable, public std::vector +{ + public: + + //! The xml tag of this object in a tileset configuration file. + static std::string d_tag; + + //! The default constructor. + TileStyleSet(); + + //! The loading constuctor loads the TileStyleSet from the config file. + /** + * Read the tileset.tile.tilestyleset XML entities in the tileset + * configuration file. + * + * @param helper The opened tileset configuration file. + */ + TileStyleSet(XML_Helper* helper); + + //! Destructor. + ~TileStyleSet(); + + + // Get Methods + + //! Get the name of this tilestyleset. + /** + * Returns the text loaded from a tileset.tile.tilestyles.d_name + * XML entity of the tileset configuration flie. + * This name refers to the filename that holds the imagery for this + * tilestyleset. It is a basename of the filename. It doesn't + * contain any slashes, or an ending file extension. eg. ".png". + */ + std::string getName() const {return d_name;} + + //! Return the subdirectory of this Tilestyleset. + std::string getSubDir() const {return d_dir;}; + + + // Set Methods + + //! Set the name of this tilestyleset. + void setName(std::string name) {d_name = name;} + + //! Set the subdirectory of where this Tilestyleset resides on disk. + void setSubDir(std::string dir) {d_dir = dir;}; + + + //Methods that operate on the class data but do not modify the class. + + //! Save a TileStyleSet to an opened tile configuration file. + /** + * @param The opened XML tile configuration file. + */ + bool save(XML_Helper *helper) const; + + //! Return a list of all of the tilestyle types in this tilestyleset. + void getUniqueTileStyleTypes(std::list &types) const; + + //! Check to see if this tilestyleset is usable in the game. + bool validate() const; + + + //Methods that operate on the class data and modify the class. + + //! Instantiate the tilestyleset's images from the given file. + void instantiateImages(int tilesize, std::string image_filename); + + //! Destroy the images associated with this tilestyleset. + void uninstantiateImages(); + + private: + + // DATA + + //! The name of the tilestyleset. + /** + * This is the basename of the image that contains a row of + * cells where each cell is tilesize pixels high, and tilesize + * pixels wide. Each cell is another image of a tilestyle. There is + * one cell per TileStyle in this TileStyleSet. + * The tilesize comes from the TileStyleSet::instantiateImages + * method. + * The name does not contain a path, and does not contain an + * extension (e.g. .png). It must refer to a PNG file. + */ + std::string d_name; + + //! The directory of where the image file lives. + /** + * @param This is a hack used for the tileset editor. + */ + std::string d_dir; +}; + +#endif // TILESTYLESET_H + +// End of file