ScummVM API documentation
map_widget.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 ULTIMA_SHARED_MAPS_MAP_WIDGET_H
23#define ULTIMA_SHARED_MAPS_MAP_WIDGET_H
24
25#include "common/events.h"
26#include "common/ptr.h"
27#include "common/serializer.h"
28#include "common/str.h"
29#include "ultima/shared/core/message_target.h"
30#include "ultima/shared/core/rect.h"
31
32namespace Ultima {
33namespace Shared {
34
35class Game;
36
37namespace Maps {
38
39enum Direction {
40 DIR_NONE = 0,
41 DIR_LEFT = 1, DIR_RIGHT = 2, DIR_UP = 3, DIR_DOWN = 4,
42 DIR_WEST = 1, DIR_EAST = 2, DIR_NORTH = 3, DIR_SOUTH = 4
43};
44
45class MapBase;
46
50class MapWidget : public MessageTarget {
51 DECLARE_MESSAGE_MAP;
52protected:
53 Game *_game; // Game reference
54 MapBase *_map; // Map reference
55public:
56 Point _position; // Position within the map
57 Direction _direction; // Direction
58 Common::String _name; // Name of widget
59public:
63 static Direction directionFromKey(Common::KeyCode keycode);
64public:
65 CLASSDEF;
66
70 MapWidget(Game *game, MapBase *map) : _game(game), _map(map), _direction(DIR_NONE) {}
71 MapWidget(Game *game, MapBase *map, const Point &pt, Direction dir = DIR_NONE) : _game(game), _map(map), _position(pt), _direction(dir) {}
72 MapWidget(Game *game, MapBase *map, const Common::String &name, const Point &pt, Direction dir = DIR_NONE) :
73 _game(game), _map(map), _name(name), _position(pt), _direction(dir) {}
74
78 ~MapWidget() override {}
79
83 virtual const char *getClassName() const { return nullptr; }
84
89
96 void addInfoMsg(const Common::String &text, bool newLine = true, bool replaceLine = false);
97
101 virtual uint getTileNum() const { return 0; }
102
106 virtual bool isBlocking() const { return true; }
107
113 virtual void update(bool isPreUpdate) {}
114
115 enum CanMove { UNSET = 0, YES = 1, NO = 2 };
116
120 virtual CanMove canMoveTo(const Point &destPos);
121
128 virtual void moveTo(const Point &destPos, Direction dir = DIR_NONE);
129};
130
132
133} // End of namespace Maps
134} // End of namespace Shared
135} // End of namespace Ultima
136
137#endif
Definition: serializer.h:80
Definition: ptr.h:159
Definition: str.h:59
Definition: game.h:42
Definition: map_base.h:47
Definition: map_widget.h:50
virtual CanMove canMoveTo(const Point &destPos)
virtual uint getTileNum() const
Definition: map_widget.h:101
~MapWidget() override
Definition: map_widget.h:78
virtual const char * getClassName() const
Definition: map_widget.h:83
virtual void update(bool isPreUpdate)
Definition: map_widget.h:113
virtual void synchronize(Common::Serializer &s)
MapWidget(Game *game, MapBase *map)
Definition: map_widget.h:70
virtual bool isBlocking() const
Definition: map_widget.h:106
virtual void moveTo(const Point &destPos, Direction dir=DIR_NONE)
static Direction directionFromKey(Common::KeyCode keycode)
void addInfoMsg(const Common::String &text, bool newLine=true, bool replaceLine=false)
Definition: message_target.h:97
Definition: rect.h:144