ScummVM API documentation
MapMarkerMenu.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_MAPMARKERMENU_H
32#define CRAB_MAPMARKERMENU_H
33
34#include "crab/ui/menu.h"
35#include "crab/ui/StateButton.h"
36
37namespace Crab {
38
39namespace pyrodactyl {
40namespace ui {
42 // The reference map marker
43 StateButton _ref;
44
45 // The menu containing all the map markers
47
48 // The offset at which every map marker is drawn (used to compensate for icon design width)
49 struct {
50 Vector2i _marker, _player;
51 } _offset;
52
53 // The button for the player's current position
54 Button _player;
55
56public:
57 MapMarkerMenu() {}
59
60 void addButton(const Common::String &name, const int &x, const int &y) {
62 b.init(_ref, x, y);
63 b._tooltip._text = name;
64 _menu._element.push_back(b);
65 }
66
67 void clear() {
68 _menu._element.clear();
69 }
70
71 void assignPaths() {
72 _menu.assignPaths();
73 }
74
75 void selectDest(const Common::String &name) {
76 for (auto &i : _menu._element)
77 i.state(i._tooltip._text == name);
78 }
79
80 void erase(const Common::String &name) {
81 for (auto i = _menu._element.begin(); i != _menu._element.end(); ++i) {
82 if (i->_tooltip._text == name) {
83 _menu._element.erase(i);
84 assignPaths();
85 break;
86 }
87 }
88 }
89
90 void load(rapidxml::xml_node<char> *node);
91
92 void draw(const Element &pos, const Vector2i &player_pos, const Rect &camera);
93
94 void handleEvents(const Element &pos, const Vector2i &playerPos, const Rect &camera, const Common::Event &event);
95
96 void internalEvents(const Element &pos, const Vector2i &playerPos, const Rect &camera, Rect bounds);
97
98 void setUI();
99};
100} // End of namespace ui
101} // End of namespace pyrodactyl
102
103} // End of namespace Crab
104
105#endif // CRAB_MAPMARKERMENU_H
Definition: str.h:59
Definition: button.h:86
Definition: element.h:42
Definition: MapMarkerMenu.h:41
Definition: menu.h:47
Definition: StateButton.h:66
Definition: events.h:218
Definition: Rectangle.h:42