ScummVM API documentation
map.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 n redistribute it and/or
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 ULTIMA_SHARED_MAPS_MAP_H
23#define ULTIMA_SHARED_MAPS_MAP_H
24
25#include "common/array.h"
26#include "common/serializer.h"
27#include "ultima/shared/core/rect.h"
28#include "ultima/shared/maps/map_base.h"
29#include "ultima/shared/maps/map_widget.h"
30#include "ultima/shared/maps/map_tile.h"
31
32
33namespace Ultima {
34namespace Shared {
35
36class Game;
37
38namespace Maps {
39
40#define REGISTER_WIDGET(NAME) if (name == #NAME) return new Widgets::NAME(_game, this)
41#define DECLARE_WIDGET(NAME) const char *getClassName() const override { return #NAME; }
42
46class Map {
47protected:
48 MapBase *_mapArea;
49public:
53 Map() : _mapArea(nullptr) {}
54
58 virtual ~Map() {}
59
63 virtual void load(MapId mapId);
64
68 virtual void clear();
69
74
79 assert(_mapArea);
80 return _mapArea->createWidget(name);
81 }
82
86 void getTileAt(const Point &pt, MapTile *tile, bool includePlayer = true) {
87 assert(_mapArea);
88 return _mapArea->getTileAt(pt, tile, includePlayer);
89 }
90
94 void setTileAt(const Point &pt, uint tileId) {
95 assert(_mapArea);
96 return _mapArea->setTileAt(pt, tileId);
97 }
98
102 Point getViewportPosition(const Point &viewportSize) {
103 assert(_mapArea);
104 return _mapArea->getViewportPosition(viewportSize);
105 }
106
110 size_t width() const {
111 assert(_mapArea);
112 return _mapArea->width();
113 }
114
118 size_t height() const {
119 assert(_mapArea);
120 return _mapArea->height();
121 }
122
127 assert(_mapArea);
128 return _mapArea->getPosition();
129 }
130
134 void setPosition(const Point &pt) {
135 assert(_mapArea);
136 _mapArea->setPosition(pt);
137 }
138
142 Direction getDirection() const {
143 assert(_mapArea);
144 return _mapArea->getDirection();
145 }
146
150 void setDirection(Direction dir) {
151 assert(_mapArea);
152 _mapArea->setDirection(dir);
153 }
154
159 assert(_mapArea);
160 return _mapArea->getDirectionDelta();
161 }
162
167 assert(_mapArea);
168 return _mapArea->getDeltaPosition(delta);
169 }
170
174 void shiftViewport(const Point &delta) {
175 assert(_mapArea);
176 _mapArea->shiftViewport(delta);
177 }
178
184 assert(_mapArea);
185 return _mapArea->_tilesPerOrigTile;
186 }
187
192 assert(_mapArea);
193 return _mapArea->_name;
194 }
195
200 assert(_mapArea);
201 return _mapArea->_playerWidget;
202 }
203
208 bool changeLevel(int delta) {
209 assert(_mapArea);
210 return _mapArea->changeLevel(delta);
211 }
212
216 uint getLevel() const {
217 assert(_mapArea);
218 return _mapArea->getLevel();
219 }
220
224 bool isMapWrapped() const {
225 assert(_mapArea);
226 return _mapArea->isMapWrapped();
227 }
228
232 void update() {
233 assert(_mapArea);
234 return _mapArea->update();
235 }
236
240 void castSpell(uint spellId) {
241 assert(_mapArea);
242 _mapArea->castSpell(spellId);
243 }
244};
245
246} // End of namespace Maps
247} // End of namespace Shared
248} // End of namespace Ultima
249
250#endif
Definition: serializer.h:80
Definition: str.h:59
Definition: map_base.h:47
virtual uint getLevel() const
Definition: map_base.h:204
virtual void shiftViewport(const Point &delta)
size_t height() const
Definition: map_base.h:224
size_t width() const
Definition: map_base.h:219
void setPosition(const Point &pt)
virtual Point getViewportPosition(const Point &viewportSize)
void setDirection(Direction dir)
virtual MapWidget * createWidget(const Common::String &name)=0
virtual void setTileAt(const Point &pt, uint tileId)
virtual void getTileAt(const Point &pt, MapTile *tile, bool includePlayer=true)
virtual Point getDeltaPosition(const Point &delta)
Direction getDirection() const
virtual void castSpell(uint spell)=0
virtual bool isMapWrapped() const
Definition: map_base.h:209
virtual bool changeLevel(int delta)
Definition: map_base.h:199
Definition: map.h:46
Point getPosition() const
Definition: map.h:126
void getTileAt(const Point &pt, MapTile *tile, bool includePlayer=true)
Definition: map.h:86
Map()
Definition: map.h:53
void setDirection(Direction dir)
Definition: map.h:150
virtual void load(MapId mapId)
Point getViewportPosition(const Point &viewportSize)
Definition: map.h:102
uint getLevel() const
Definition: map.h:216
size_t width() const
Definition: map.h:110
MapWidget * createWidget(const Common::String &name)
Definition: map.h:78
size_t height() const
Definition: map.h:118
void castSpell(uint spellId)
Definition: map.h:240
void shiftViewport(const Point &delta)
Definition: map.h:174
void update()
Definition: map.h:232
Direction getDirection() const
Definition: map.h:142
virtual ~Map()
Definition: map.h:58
MapWidget * getPlayerWidget() const
Definition: map.h:199
virtual void synchronize(Common::Serializer &s)
Point getTilesPerOrigTile() const
Definition: map.h:183
Common::String getName() const
Definition: map.h:191
bool changeLevel(int delta)
Definition: map.h:208
bool isMapWrapped() const
Definition: map.h:224
void setPosition(const Point &pt)
Definition: map.h:134
Point getDeltaPosition(const Point &delta)
Definition: map.h:166
void setTileAt(const Point &pt, uint tileId)
Definition: map.h:94
Point getDirectionDelta() const
Definition: map.h:158
Definition: map_tile.h:36
Definition: map_widget.h:50
Definition: rect.h:144