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 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 /*
23  * This code is based on the CRAB engine
24  *
25  * Copyright (c) Arvind Raja Yadav
26  *
27  * Licensed under MIT
28  *
29  */
30 
31 #ifndef CRAB_MAP_H
32 #define CRAB_MAP_H
33 
34 #include "crab/event/GameEventInfo.h"
35 #include "crab/ui/ImageData.h"
36 #include "crab/ui/mapbutton.h"
37 #include "crab/ui/MapData.h"
38 #include "crab/ui/MapMarkerMenu.h"
39 #include "crab/ui/StateButton.h"
40 #include "crab/ui/ToggleButton.h"
41 
42 namespace Crab {
43 
44 namespace pyrodactyl {
45 namespace ui {
46 class Map {
47  // We have multiple world maps, each with their own data
49 
50  // Index of the currently visible map
51  uint _cur;
52 
53  // The currently loaded map background image
54  pyrodactyl::image::Image _imgBg, _imgOverlay;
55 
56  // The position at which map image has to be drawn
57  Element _pos;
58 
59  // Foreground image of the map
60  ImageData _fg;
61 
62  // size = Dimensions of the map image
63  // mouse = The current coordinates of the mouse
64  // vel = The speed at which the map is moving
65  Vector2i _size, _mouse, _vel;
66 
67  // The reference speed of the camera movement
68  int _speed;
69 
70  // The pan toggle is used when the mouse is down and moving simultaneously
71  // overlay = true if we are showing a more detailed world map
72  bool _pan, _overlay;
73 
74  // The camera size and position for the map
75  // Bounds is the area we draw the map elements for
76  Rect _camera, _bounds;
77 
78  // The button to toggle between showing the overlay or not
79  ToggleButton _buOverlay;
80 
81  // All data for drawing map markers
82  MapMarkerMenu _marker;
83 
84  // The map name is drawn here
85  HoverInfo _title;
86 
87  // The buttons for scrolling the map (only visible if there is area to scroll)
88  ButtonMenu _scroll;
89 
90  // The menu for fast travel locations
91  MapButtonMenu _travel;
92 
93  void calcBounds() {
94  _bounds.x = _pos.x;
95  _bounds.y = _pos.y;
96  _bounds.w = _camera.w;
97  _bounds.h = _camera.h;
98  }
99 
100 public:
101  // The currently selected location
102  Common::String _curLoc;
103 
104  // The coordinates of the player's current location
105  Vector2i _playerPos;
106 
107  Map() {
108  _speed = 1;
109  _pan = false;
110  _cur = 0;
111  _overlay = true;
112  }
113 
114  ~Map() {
115  _imgBg.deleteImage();
116  _imgOverlay.deleteImage();
117  }
118 
119  void load(const Common::Path &filename, pyrodactyl::event::Info &info);
120 
121  void draw(pyrodactyl::event::Info &info);
122  bool handleEvents(pyrodactyl::event::Info &info, const Common::Event &event);
123  void internalEvents(pyrodactyl::event::Info &info);
124 
125  void center(const Vector2i &pos);
126  void move(const Common::Event &event);
127  void validate();
128 
129  void revealAdd(const int &id, const Rect &area);
130  void destAdd(const Common::String &name, const int &x, const int &y);
131  void destDel(const Common::String &name);
132  void selectDest(const Common::String &name);
133 
134  void update(pyrodactyl::event::Info &info);
135  void setImage(const uint &val, const bool &force = false);
136 
137  void saveState(rapidxml::xml_document<> &doc, rapidxml::xml_node<char> *root);
138  void loadState(rapidxml::xml_node<char> *node);
139 
140  void setUI();
141 };
142 } // End of namespace ui
143 } // End of namespace pyrodactyl
144 
145 } // End of namespace Crab
146 
147 #endif // CRAB_MAP_H
Definition: str.h:59
Definition: Rectangle.h:42
Definition: array.h:52
Definition: ImageData.h:40
Definition: path.h:52
Definition: map.h:46
Definition: GameEventInfo.h:44
Definition: element.h:42
Definition: Image.h:51
Definition: events.h:199
Definition: moveeffect.h:37
Definition: MapMarkerMenu.h:41
Definition: ToggleButton.h:42
Definition: HoverInfo.h:41