1 #pragma once
2 
3 /** Implements the GUI.
4 */
5 
6 namespace Gigalomania {
7 	class PanelPage;
8 	class Button;
9 	class ImageButton;
10 	class CycleButton;
11 }
12 
13 using namespace Gigalomania;
14 
15 class PlaceMenGameState;
16 class PlayingGameState;
17 class Invention;
18 
19 #include "common.h"
20 #include "panel.h"
21 
22 typedef void (ClickFunc) (void *data, int arg, bool m_left, bool m_middle, bool m_right);
23 
24 class OneMouseButtonPanel : public PanelPage {
25 	ClickFunc *clickFunc;
26 	void *data;
27 	int arg;
28     ImageButton *button_right;
29     ImageButton *button_left;
30 public:
31 	OneMouseButtonPanel(ClickFunc *clickFunc, void *data, int arg, PanelPage *caller_button);
32 
33 	virtual void input(int m_x,int m_y,bool m_left,bool m_middle,bool m_right,bool click);
34 };
35 
36 void processClick(ClickFunc *clickFunc, PanelPage *panel, void *data, int arg, PanelPage *caller_button, bool m_left, bool m_middle, bool m_right, bool click);
37 
38 class ChooseGameTypePanel : public MultiPanel {
39 	Button *button_tutorial;
40 	Button *button_singleisland;
41 	Button *button_allislands;
42 
43 public:
44 	ChooseGameTypePanel();
45 
46 	virtual void input(int m_x,int m_y,bool m_left,bool m_middle,bool m_right,bool click);
47 };
48 
49 class ChooseDifficultyPanel : public MultiPanel {
50 	Button *button_easy;
51 	Button *button_medium;
52 	Button *button_hard;
53 	Button *button_ultra;
54 
55 public:
56 	ChooseDifficultyPanel();
57 
58 	virtual void input(int m_x,int m_y,bool m_left,bool m_middle,bool m_right,bool click);
59 };
60 
61 class ChooseMenPanel : public MultiPanel {
62 	PlaceMenGameState *gamestate;
63 	Button *button_continue;
64 	CycleButton *button_sound;
65 	CycleButton *button_music;
66 	CycleButton *button_onemousebutton;
67 	CycleButton *button_disallow_nukes;
68 	Button *button_nextisland;
69 	Button *button_nextepoch;
70 	Button *button_options;
71 	Button *button_play;
72 #if defined(_WIN32) || defined(__ANDROID__)
73     Button *button_help;
74 #endif
75 	Button *button_quit;
76 	Button *button_new;
77 	Button *button_load;
78 	Button *button_save;
79 	Button *button_load_load[n_slots_c];
80 	Button *button_load_cancel;
81 	Button *button_save_save[n_slots_c];
82 	Button *button_save_cancel;
83 	PanelPage *button_nmen;
84 	Button *button_cancel;
85 	int n_men;
86 
87 	void setInfoText();
88 	void refreshLoadSaveButtons();
89 
90 	static void buttonNMenClick(void *data, int arg, bool m_left, bool m_middle, bool m_right);
91 public:
92 	enum State {
93 		STATE_CHOOSEISLAND = 0,
94 		STATE_CHOOSEMEN,
95 		STATE_OPTIONS,
96 		STATE_LOADGAME,
97 		STATE_SAVEGAME,
98 		N_STATES
99 	};
100 
101 	ChooseMenPanel(PlaceMenGameState *placeMenGameState);
102 
103 	virtual void draw();
104 	virtual void input(int m_x,int m_y,bool m_left,bool m_middle,bool m_right,bool click);
105 
getNMen()106 	int getNMen() const {
107 		return n_men;
108 	}
setNMen(int n_men)109 	void setNMen(int n_men) {
110 		this->n_men = n_men;
111 	}
112 };
113 
114 class GamePanel : public MultiPanel {
115 public:
116 	enum State {
117 		STATE_SECTORCONTROL = 0,
118 		STATE_DESIGN = 1,
119 		STATE_DEFENCE = 2,
120 		STATE_ATTACK = 3,
121 		STATE_ELEMENTSTOCKS = 4,
122 		STATE_BUILD = 5,
123 		STATE_SHIELD = 6,
124 		STATE_KNOWNDESIGNS = 7,
125 		STATE_DESIGNINFO = 8,
126 		STATE_FACTORY,
127 		N_STATES
128 	};
129 	enum MouseState {
130 		MOUSESTATE_NORMAL = 0,
131 		MOUSESTATE_DEPLOY_DEFENCE = 1,
132 		MOUSESTATE_DEPLOY_WEAPON = 2,
133 		MOUSESTATE_DEPLOY_SHIELD = 3,
134 		MOUSESTATE_SHUTDOWN = 4,
135 		N_MOUSESTATES
136 	};
137 private:
138 	PlayingGameState *gamestate;
139 	int client_player;
140 	//State state;
141 	MouseState mousestate;
142 	int deploy_shield;
143 	int deploy_defence;
144 	int deploy_weapon;
145 	Invention *designinfo;
146 
147 	ImageButton *button_design;
148 	PanelPage *button_ndesigners;
149 	ImageButton *button_shield;
150 	ImageButton *button_defence;
151 	ImageButton *button_attack;
152 	//ImageButton *button_elementstocks;
153 	int element_index[4];
154 	PanelPage *button_elements[4];
155 	PanelPage *button_nminers[4];
156 	ImageButton *button_build[N_BUILDINGS];
157 	PanelPage *button_nbuilders[N_BUILDINGS];
158 	ImageButton *button_knowndesigns;
159 	ImageButton *button_factory;
160 	PanelPage *button_nworkers;
161 
162 	ImageButton *button_bigdesign;
163 	ImageButton *button_designers;
164 	ImageButton *button_shields[4];
165 	ImageButton *button_defences[4];
166 	ImageButton *button_weapons[4];
167 
168 	ImageButton *button_bigshield;
169 	ImageButton *button_deploy_shields[4];
170 	ImageButton *button_shutdown;
171 
172 	ImageButton *button_bigdefence;
173 	ImageButton *button_deploy_defences[4];
174 
175 	ImageButton *button_bigattack;
176 	ImageButton *button_deploy_unarmedmen;
177 	ImageButton *button_deploy_attackers[4];
178 	ImageButton *button_return_attackers;
179 	Button *button_select_all;
180 
181 	ImageButton *button_bigelementstocks;
182 	PanelPage *button_elements2[4];
183 	PanelPage *button_nminers2[4];
184 
185 	ImageButton *button_bigbuild;
186 	ImageButton *button_nbuilders2[N_BUILDINGS];
187 
188 	ImageButton *button_bigknowndesigns;
189 	ImageButton *button_knownshields[4];
190 	ImageButton *button_knowndefences[4];
191 	ImageButton *button_knownweapons[4];
192 
193 	ImageButton *button_bigdesigninfo;
194 	ImageButton *button_trashdesign;
195 
196 	ImageButton *button_bigfactory;
197 	ImageButton *button_workers;
198 	ImageButton *button_famount;
199 	ImageButton *button_fshields[4];
200 	ImageButton *button_fdefences[4];
201 	ImageButton *button_fweapons[4];
202 
203 	void changeMiners(Id element,bool decrease,int n);
204 
205 	static void buttonNDesignersClick(void *data, int arg, bool m_left, bool m_middle, bool m_right);
206 	static void buttonNManufacturersClick(void *data, int arg, bool m_left, bool m_middle, bool m_right);
207 	static void buttonFAmountClick(void *data, int arg, bool m_left, bool m_middle, bool m_right);
208 	static void buttonNMinersClick(void *data, int arg, bool m_left, bool m_middle, bool m_right);
209 	static void buttonNBuildersClick(void *data, int arg, bool m_left, bool m_middle, bool m_right);
210 public:
211 	GamePanel(PlayingGameState *gamestate, int client_player);
212 	virtual ~GamePanel();
213 
214 	void setup();
215 	void refreshCanDesign();
216 	void refreshDesignInventions();
217 	void refreshManufactureInventions();
218 	void refreshDeployInventions();
219 	void refreshShutdown();
220 	void refresh();
221 	//void setState(State state);
222 	virtual void setPage(int page);
223 	MouseState getMouseState() const;
224 	void setMouseState(MouseState mousestate);
getDeployShield()225 	int getDeployShield() const {
226 		return deploy_shield;
227 	}
getDeployDefence()228 	int getDeployDefence() const {
229 		return deploy_defence;
230 	}
getDeployWeapon()231 	int getDeployWeapon() const {
232 		return deploy_weapon;
233 	}
234 	virtual void draw();
235 	virtual void input(int m_x,int m_y,bool m_left,bool m_middle,bool m_right,bool click);
236 };
237