forked from gecube/opencaesar3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gui_menu.hpp
295 lines (223 loc) · 6.04 KB
/
gui_menu.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
// This file is part of openCaesar3.
//
// openCaesar3 is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// openCaesar3 is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with openCaesar3. If not, see <http://www.gnu.org/licenses/>.
//
// Copyright 2012-2013 Gregoire Athanase, gathanase@gmail.com
#ifndef GUI_MENU_HPP
#define GUI_MENU_HPP
#include "gui_widget.hpp"
#include <string>
#include "picture.hpp"
#include "enums.hpp"
class City;
// the line at the top of the screen
class MenuBar : public WidgetGroup
{
public:
MenuBar();
void init( const unsigned int width, const unsigned int heigth );
// draw on screen
virtual void draw(const int dx, const int dy);
void updateLabels(const bool forceUpdate = false); // update labels, if needed
Picture& getBgPicture();
private:
City *_city;
int _population; // cached value
int _funds; // cached value
unsigned int _month; // cached value
TextIcon _populationLabel;
TextIcon _fundsLabel;
TextIcon _dateLabel;
Picture *_bgPicture;
};
// this is the main menu interface with all construction tools and the minimap
class Menu : public WidgetGroup
{
public:
Menu();
// draw on screen
virtual void draw(const int dx, const int dy);
// unselect button, if any
void unselect();
const Picture& getBgPicture() const;
const Picture& getBottomPicture() const;
const Picture& getRigthPicture() const;
private:
// init the given button with data. this button has 3 states
void set3Button(ImageButton &oButton, const WidgetEvent &event, const int pic_index);
// init the given button with data. this button has 4 states
void set4Button(ImageButton &oButton, const WidgetEvent &event, const int pic_index);
Picture* _bgPicture;
Picture* _btPicture;
Picture* _rigthPicture;
ImageIcon _midIcon;
//ImageIcon _bottomIcon;
ImageTextButton _menuButton;
ImageButton _minimizeButton;
ImageButton _senateButton;
ImageButton _empireButton;
ImageButton _missionButton;
ImageButton _northButton;
ImageButton _rotateLeftButton;
ImageButton _rotateRightButton;
ImageButton _messageButton;
ImageButton _disasterButton;
ImageButton _houseButton;
ImageButton _waterButton;
ImageButton _clearButton;
ImageButton _roadButton;
ImageButton _administrationButton;
ImageButton _entertainmentButton;
ImageButton _educationButton;
ImageButton _templeButton;
ImageButton _commerceButton;
ImageButton _securityButton;
ImageButton _healthButton;
ImageButton _engineerButton;
ImageButton _cancelButton;
ExclusiveButtonGroup _exclusiveButtonGroup;
};
// this is the sub menu with building choice. example: selected=water, submenu=(aqueduct, well, fountain, ...)
class BuildMenu : public WidgetGroup
{
public:
BuildMenu();
virtual void addButtons() = 0;
virtual ~BuildMenu();
void init();
static BuildMenu* getMenuInstance(const BuildMenuType menuType);
// draw on screen
virtual void draw(const int dx, const int dy);
void handleEvent(SDL_Event &event);
// add the subMenu in the menu.
void addSubmenuButton(const BuildMenuType menuType, const std::string &text);
// add the button in the menu.
void addBuildButton(const BuildingType buildingType);
// returns true if widget needs to be deleted
bool isDeleted() const;
void setDeleted();
protected:
bool _isDeleted; // true if needs to be deleted
BuildButton* _hoverButton;
};
class BuildMenu_water : public BuildMenu
{
public:
void addButtons();
};
class BuildMenu_security : public BuildMenu
{
public:
void addButtons();
};
class BuildMenu_education : public BuildMenu
{
public:
void addButtons();
};
class BuildMenu_health : public BuildMenu
{
public:
void addButtons();
};
class BuildMenu_engineering : public BuildMenu
{
public:
void addButtons();
};
class BuildMenu_administration : public BuildMenu
{
public:
void addButtons();
};
class BuildMenu_entertainment : public BuildMenu
{
public:
void addButtons();
};
class BuildMenu_commerce : public BuildMenu
{
public:
void addButtons();
};
class BuildMenu_farm : public BuildMenu
{
public:
void addButtons();
};
class BuildMenu_raw_factory : public BuildMenu
{
public:
void addButtons();
};
class BuildMenu_factory : public BuildMenu
{
public:
void addButtons();
};
class BuildMenu_religion: public BuildMenu
{
public:
void addButtons();
};
class BuildMenu_temple : public BuildMenu
{
public:
void addButtons();
};
class BuildMenu_bigtemple : public BuildMenu
{
public:
void addButtons();
};
// this is the menu with newGame/loadGame/quit choice
class StartMenu : public WidgetGroup
{
public:
StartMenu();
virtual ~StartMenu();
void init();
// draw on screen
virtual void draw(const int dx, const int dy);
// returns true if widget needs to be deleted
bool isDeleted() const;
void setDeleted();
protected:
bool _isDeleted; // true if needs to be deleted
TextButton* _hoverButton;
TextButton _newGameButton;
TextButton _loadGameButton;
TextButton _quitButton;
};
// this is the inGame menu with options/saveGame/quitGame choice
class InGameMenu : public WidgetGroup
{
public:
InGameMenu();
virtual ~InGameMenu();
void init();
// draw on screen
virtual void draw(const int dx, const int dy);
void handleEvent(SDL_Event &event);
// returns true if widget needs to be deleted
bool isDeleted() const;
void setDeleted();
protected:
bool _isDeleted; // true if needs to be deleted
TextButton* _hoverButton;
TextButton _optionsButton;
TextButton _saveGameButton;
TextButton _quitGameButton;
};
#endif