24
29
#include "tilestyleset.h"
26
/** Class which describes the terrain
28
* Many tiles are put together to form a tileset. Thus, a tile describes a
29
* single terrain type. It keeps the name, movement points, type (grass, water
30
* etc.) as well as the images together.
33
class Tile : public std::vector<TileStyleSet*>
31
//! Describes a kind of tile that a Stack can traverse.
33
* Many tiles are put together to form a tileset. Thus, a tile describes a
34
* single terrain type. It keeps the name, movement points, type (grass, water
35
* etc.) and also keeps the images together.
37
* Each tile holds a list of TileStyleSet objects which hold a list of
38
* TileStyle objects. Each TileStyleSet holds a bunch of pictures of
39
* what this tile can look like. A TileStyle is a single picture.
40
* These TileStyle pictures are displayed on the BigMap using the MapRenderer.
42
* Tile objects are held in a Tileset object.
43
* Maptile objects refer to Tile objects.
45
class Tile : public std::list<TileStyleSet*>
36
//! Describe terrain types
37
enum Type { NONE = 0, GRASS = NONE, WATER = 1, FOREST = 2, HILLS = 4,
38
MOUNTAIN = 8, SWAMP = 16 };
39
enum Pattern { SOLID = 0, STIPPLED = 1, RANDOMIZED = 2, SUNKEN = 3,
48
//! Enumerate the kinds of terrain that a Stack can potentially move on.
50
//! Synomymous with GRASS.
52
//! Grassy plain. Flat. Open. Easy to pass through.
54
//! Lake, ocean, river, puddle, moat, or anything else watery.
56
//! Trees in great abundance, also includes shrubberies.
58
//! Hilly terrain, generally passable.
60
//! Very hilly terrain, generally not passable except by flight.
66
//! The terrain tile's appearance as seen on the OverviewMap.
69
//! The terrain feature is shown as a single solid colour.
72
//! The terrain feature is checkered with two alternating colours.
74
* The stippled pattern looks something like this:
82
* It is currently used for Type::FOREST, and Type::HILLS.
86
//! The feature is random pixels with three different colours.
88
* The random pattern looks something like this:
96
* It is currently used for Type::MOUNTAINS.
100
//! The feature is shaded on the bottom and on the left.
102
* The sunken pattern looks something like this:
110
* It is currently used for Type::WATER.
114
//! The feature is shown as a 3 colour pattern.
116
* The tablecloth pattern looks something like this:
124
* It is currently used for Type::SWAMP.
42
//! Loading constructor
130
//! Default constructor.
133
//! Loading constructor.
135
* Loads the tileset.tile XML entities in the tileset configuration
43
138
Tile(XML_Helper* helper);
47
143
//! Get the number of movement points needed to cross this tile
48
144
Uint32 getMoves() const {return d_moves;}
50
//! Get the color associated with this tile for the smallmap
146
//! Get the colour associated with this tile for the smallmap.
51
147
SDL_Color getColor() const {return d_color;}
52
//! Set the color associated with this tile for the smallmap
149
//! Set the colour associated with this tile for the smallmap.
53
150
void setColor(SDL_Color clr) {d_color = clr;}
55
//! Get the type (grass, hill,...) of this tile type
152
//! Get the type (grass, hill,...) of this tile type.
56
153
Type getType() const {return d_type;}
155
void setType(Type type) {d_type = type;}
58
//! Get the pattern (solid, stippled, random) of this type
157
static int getTypeIndexForType(Tile::Type type);
159
int getTypeIndex() {return getTypeIndexForType(d_type);}
161
void setTypeByIndex(int idx);
162
//! Get the pattern (solid, stippled, random) of this type.
59
163
Pattern getPattern() const {return d_pattern;}
60
//! set the pattern (solid, stippled, random) of this type
165
//! set the pattern (solid, stippled, random) of this type.
61
166
void setPattern(Pattern pattern) {d_pattern = pattern;}
168
//! Get the name of this kind of tile (used in the editor).
63
169
std::string getName() const {return d_name;}
65
//! Get the alternate color associated with this tile's pattern
66
//!This "second" colour gets stippled, or randomized, or sunken
171
//! Set the name of this kind of tile (used in the editor).
172
void setName(std::string name) {d_name = name;}
174
//! Get the alternate colour associated with this tile's pattern.
176
* This "second" colour gets used when Tile::Pattern is
177
* Tile::STIPPLED, Tile::RANDOMIZED, Tile::SUNKEN, or Tile::TABLECLOTH.
67
179
SDL_Color getSecondColor() const {return d_second_color;}
68
//! set the alternate color associated with this tile's pattern
181
//! Set the alternate colour associated with this tile's pattern.
69
182
void setSecondColor(SDL_Color color) {d_second_color = color;}
71
//! Get another alternate color associated with this tile's pattern
72
//!This "third" colour gets randomized, or sunken
184
//! Get another alternate colour associated with this tile's pattern.
186
* This "third" colour gets used when Tile::Pattern is
187
* Tile::RANDOMIZED, or Tile::TABLECLOTH.
73
189
SDL_Color getThirdColor() const {return d_third_color;}
74
//! set another alternate color associated with this tile's pattern
191
//! Set another alternate colour associated with this tile's pattern.
75
192
void setThirdColor(SDL_Color color) {d_third_color = color;}
194
//! Load the pictures associated with this tile.
196
* @param tileset The name of the tileset to load pictures for.
197
* @param tilesize The expected size of the tiles in the image.
77
199
void instantiatePixmaps(std::string tileset, Uint32 tilesize);
202
//! Save a Tile to an opened tile configuration file.
204
* @param The opened XML tile configuration file.
206
bool save(XML_Helper *helper);
208
//! Lookup a random tile style for this tile.
210
* Scan the TileStyles for this Tile for a TileStyle that matches
211
* the given style. When there is more than one TileStyle to choose
212
* from, randomly pick one from all of the matching TileStyle objects.
214
* @param style The kind of style we're looking for.
216
* @return A pointer to the matching TileStyle object, or NULL if no
217
* TileStyle could be found with that given style.
219
TileStyle *getRandomTileStyle (TileStyle::Type style);
223
//! The name of this kind of a tile.
225
* The name is taken from the tileset configuration file.
226
* This value doesn't change during gameplay.
227
* It used in the scenario editor, but not used in the game.
228
* Equates to the tileset.tile.d_name XML entities in the tileset
229
* configuration file.
81
231
std::string d_name;
82
Uint32 d_moves; // moves needed to walk over maptile
83
SDL_Color d_color; // color shown in the smallmap
233
//! The number of movement points required to cross this tile.
235
* If an Army unit cannot traverse the tile efficiently it pays
236
* this number of movement points to walk over this tile.
237
* This value doesn't change during gameplay.
238
* Equates to the tileset.tile.d_moves XML entities in the tileset
239
* configuration file.
243
//! The kind of terrain tile this instance represents.
245
* Equates to the tileset.tile.d_type XML entities in the tileset
246
* configuration file.
250
//! The general appearance of the terrain tile on the OverviewMap.
252
* Equates to the tileset.tile.smallmap.d_pattern XML entities in the
253
* tileset configuration file.
85
255
Pattern d_pattern;
86
SDL_Color d_second_color; // the extra pattern-related color
87
SDL_Color d_third_color; // another pattern-related color
259
* Equates to the following XML entities in the tileset configuration
261
* tileset.tile.smallmap.d_red
262
* tileset.tile.smallmap.d_green
263
* tileset.tile.smallmap.d_blue
269
* Only used when Tile::Pattern is one of: Tile::STIPPLED,
270
* Tile::RANDOMIZED, Tile::SUNKEN, or Tile::TABLECLOTH.
272
* Equates to the following XML entities in the tileset configuration
274
* tileset.tile.smallmap.d_2nd_red
275
* tileset.tile.smallmap.d_2nd_green
276
* tileset.tile.smallmap.d_2nd_blue
278
SDL_Color d_second_color;
282
* Only used when Tile::Pattern is Tile::RANDOMIZED, or
285
* Equates to the following XML entities in the tileset configuration
287
* tileset.tile.smallmap.d_3rd_red
288
* tileset.tile.smallmap.d_3rd_green
289
* tileset.tile.smallmap.d_3rd_blue
291
SDL_Color d_third_color;