ScummVM API documentation
tileset.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef ULTIMA4_MAP_TILESET_H
23 #define ULTIMA4_MAP_TILESET_H
24 
25 #include "ultima/ultima4/core/types.h"
26 #include "common/hash-str.h"
27 
28 namespace Ultima {
29 namespace Ultima4 {
30 
31 class ConfigElement;
32 class Tile;
33 class TileSets;
34 
36 
40 class TileRule {
41 public:
45  bool initFromConf(const ConfigElement &tileRuleConf);
46 
47  Common::String _name;
48  unsigned short _mask;
49  unsigned short _movementMask;
50  TileSpeed _speed;
51  TileEffect _effect;
52  int _walkOnDirs;
53  int _walkOffDirs;
54 };
55 
59 class Tileset {
60  friend class TileSets;
61 public:
64 public:
65  Tileset() : _totalFrames(0), _extends(nullptr) {}
66 
70  void load(const ConfigElement &tilesetConf);
71 
75  void unload();
76  void unloadImages();
77 
81  Tile *get(TileId id);
82 
86  Tile *getByName(const Common::String &name);
87 
91  Common::String getImageName() const;
92 
96  uint numTiles() const;
97 
101  uint numFrames() const;
102 
103 private:
104  Common::String _name;
105  TileIdMap _tiles;
106  uint _totalFrames;
107  Common::String _imageName;
108  Tileset *_extends;
109 
110  TileStrMap _nameMap;
111 };
112 
113 
117 class TileRules : public TileRuleMap {
118 public:
122  TileRules();
123 
127  ~TileRules();
128 
132  void load();
133 
137  TileRule *findByName(const Common::String &name);
138 };
139 
143 class TileSets : public Common::HashMap<Common::String, Tileset *> {
144 public:
148  TileSets();
149 
153  ~TileSets();
154 
159  void loadAll();
160 
164  void unloadAll();
165 
169  void unloadAllImages();
170 
174  Tileset *get(const Common::String &name);
175 
179  Tile *findTileByName(const Common::String &name);
180  Tile *findTileById(TileId id);
181 };
182 
183 extern TileRules *g_tileRules;
184 extern TileSets *g_tileSets;
185 
186 } // End of namespace Ultima4
187 } // End of namespace Ultima
188 
189 #endif
Definition: str.h:59
Definition: config.h:127
Definition: tileset.h:143
Definition: detection.h:27
Definition: hashmap.h:85
Definition: tileset.h:59
Definition: tileset.h:40
Definition: tile.h:65
Definition: tileset.h:117
bool initFromConf(const ConfigElement &tileRuleConf)