initial commit, lordsawar source, slightly modified
[lordsawar] / src / SmallTile.h
1 // Copyright (C) 2008, 2009 Ben Asselstine
2 //
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.
7 //
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.
12 //
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 
16 //  02110-1301, USA.
17
18 #ifndef SMALLTILE_H
19 #define SMALLTILE_H
20
21 #include <gtkmm.h>
22 #include <string>
23
24 #include "xmlhelper.h"
25
26 //! Describes the appearance of a tile on the miniature map.
27 /** 
28  */
29 class SmallTile 
30 {
31     public:
32         //! The xml tag of this object in a tileset configuration file.
33         static std::string d_tag; 
34
35         //! The terrain tile's appearance as seen on the OverviewMap.
36         enum Pattern { 
37
38           //! The terrain feature is shown as a single solid colour.
39           SOLID = 0, 
40
41           //! The terrain feature is checkered with two alternating colours.
42           /**
43            * The stippled pattern looks something like this:
44            * @verbatim
45 xoxoxoxo
46 oxoxoxox
47 xoxoxoxo
48 oxoxoxox
49 @endverbatim
50            *
51            * It is currently used for Type::FOREST, and Type::HILLS.
52            */
53           STIPPLED = 1, 
54
55           //! The feature is random pixels with three different colours.
56           /**
57            * The random pattern looks something like this:
58            * @verbatim
59 xoexooxo
60 exoxxeox
61 xoeoxoxx
62 eoxeooex
63 @endverbatim
64            *
65            * It is currently used for Type::MOUNTAINS.
66            */
67           RANDOMIZED = 2, 
68
69           //! The feature is shaded on the bottom and on the left.
70           /**
71            * The sunken pattern looks something like this:
72            * @verbatim
73 xxxxxxxo
74 xxxxxxxo
75 xxxxxxxo
76 oooooooo
77 @endverbatim
78            *
79            * It is currently used for Type::WATER.
80            */
81           SUNKEN = 3,
82
83           //! The feature is shown as a 3 colour pattern.
84           /**
85            * The tablecloth pattern looks something like this:
86            * @verbatim
87 xexexexe
88 eoeoeoeo
89 xexexexe
90 eoeoeoeo
91 @endverbatim
92            *
93            * It is currently used for Type::SWAMP.
94            */
95           TABLECLOTH = 4,
96           DIAGONAL = 5, 
97           CROSSHATCH = 6, 
98           //! The feature is shaded on the top and on the left, and striped too.
99           /**
100            * The sunken striped pattern looks something like this:
101            * @verbatim
102 oooooooo
103 oeeeeeee
104 oxxxxxxx
105 oeeeeeee
106 @endverbatim
107            *
108            * It is currently used for Type::WATER.
109            */
110           SUNKEN_STRIPED = 7,
111         };
112                     
113
114         //! Default constructor.
115         SmallTile();
116
117         //! Loading constructor.
118         /**
119          * Loads the tileset.tile XML entities in the tileset configuration 
120          * files.
121          * */
122         SmallTile(XML_Helper* helper);
123
124         //! Destructor.
125         ~SmallTile();
126
127
128         // Get Methods
129
130         //! Get the colour associated with this tile for the smallmap.
131         Gdk::Color getColor() const {return d_color;}
132
133         //! Get the alternate colour associated with this tile's pattern.
134         /**
135          * This "second" colour gets used when SmallTile::Pattern is
136          * STIPPLED, RANDOMIZED, SUNKEN, or TABLECLOTH.
137          */
138         Gdk::Color getSecondColor() const {return d_second_color;}
139
140         //! Get another alternate colour associated with this tile's pattern.
141         /**
142          * This "third" colour gets used when SmallTile::Pattern is
143          * RANDOMIZED, DIAGONAL, CROSSHATCH, or TABLECLOTH.
144          */
145         Gdk::Color getThirdColor() const {return d_third_color;}
146
147         //! Get the pattern (solid, stippled, random) of this type.
148         Pattern getPattern() const {return d_pattern;}
149
150
151         // Set Methods
152
153         //! Set the colour associated with this tile for the smallmap.
154         void setColor(Gdk::Color clr) {d_color = clr;}
155
156         //! Set the alternate colour associated with this tile's pattern.
157         void setSecondColor(Gdk::Color color) {d_second_color = color;}
158
159         //! Set another alternate colour associated with this tile's pattern.
160         void setThirdColor(Gdk::Color color) {d_third_color = color;}
161
162         //! set the pattern (solid, stippled, random) of this type.
163         void setPattern(Pattern pattern) {d_pattern = pattern;}
164
165
166         // Methods that operate on class data but do not modify the class.
167
168         //! Save a SmallTile to an opened tile configuration file.
169         /**
170          * @param  The opened XML tile configuration file.
171          */
172         bool save(XML_Helper *helper) const;
173
174     private:
175
176         //! The general appearance of the terrain tile on the OverviewMap.
177         /**
178          * Equates to the tileset.tile.smallmap.d_pattern XML entities in the 
179          * tileset configuration file.
180          */
181         Pattern d_pattern;
182
183         //! First colour.
184         /**
185          * Equates to the following XML entities in the tileset configuration
186          * file:
187          * tileset.tile.smallmap.d_red 
188          * tileset.tile.smallmap.d_green
189          * tileset.tile.smallmap.d_blue
190          */
191         Gdk::Color d_color;
192
193         //! Second colour.
194         /**
195          * Only used when SmallTile::Pattern is one of: STIPPLED, 
196          * RANDOMIZED, SUNKEN, TABLECLOTH, DIAGONAL, or CROSSHATCH.
197          *
198          * Equates to the following XML entities in the tileset configuration
199          * file:
200          * tileset.tile.smallmap.d_2nd_red 
201          * tileset.tile.smallmap.d_2nd_green
202          * tileset.tile.smallmap.d_2nd_blue
203          */
204         Gdk::Color d_second_color;
205
206         //! Third colour.
207         /**
208          * Only used when Tile::Pattern is Tile::RANDOMIZED, or 
209          * Tile::TABLECLOTH.
210          *
211          * Equates to the following XML entities in the tileset configuration
212          * file:
213          * tileset.tile.smallmap.d_3rd_red 
214          * tileset.tile.smallmap.d_3rd_green
215          * tileset.tile.smallmap.d_3rd_blue
216          */
217         Gdk::Color d_third_color;
218
219 };
220
221 #endif // SMALLTILE_H
222
223 // End of file