webperimental: killstack decides stack protects.
[freeciv.git] / client / gui-qt / menu.h
blob922c9a1b751c48ca3cd7325bf83e6b4ef1c098d8
1 /***********************************************************************
2 Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
6 any later version.
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12 ***********************************************************************/
14 #ifndef FC__MENU_H
15 #define FC__MENU_H
17 extern "C" {
18 #include "menu_g.h"
21 #ifdef HAVE_CONFIG_H
22 #include <fc_config.h>
23 #endif
25 // Qt
26 #include <QDialog>
27 #include <QMenuBar>
29 // client
30 #include "control.h"
32 class QLabel;
33 class QPushButton;
34 class QSignalMapper;
35 class QScrollArea;
36 struct fc_shortcut;
38 void qt_start_turn();
40 /** used for indicating menu about current option - for renaming
41 * and enabling, disabling */
42 enum munit {
43 STANDARD,
44 EXPLORE,
45 LOAD,
46 UNLOAD,
47 TRANSPORTER,
48 DISBAND,
49 CONVERT,
50 MINE,
51 IRRIGATION,
52 TRANSFORM,
53 PILLAGE,
54 BUILD,
55 ROAD,
56 FORTIFY,
57 FORTRESS,
58 AIRBASE,
59 POLLUTION,
60 FALLOUT,
61 SENTRY,
62 HOMECITY,
63 WAKEUP,
64 AUTOSETTLER,
65 CONNECT_ROAD,
66 CONNECT_RAIL,
67 CONNECT_IRRIGATION,
68 GOTO_CITY,
69 AIRLIFT,
70 BUILD_WONDER,
71 AUTOTRADEROUTE,
72 ORDER_TRADEROUTE,
73 ORDER_DIPLOMAT_DLG,
74 NUKE,
75 UPGRADE,
76 MIGRANT,
77 GO_AND_BUILD_CITY,
78 NOT_4_OBS,
79 MULTIPLIERS,
80 ENDGAME,
81 SAVE
84 enum delay_order{
85 D_GOTO,
86 D_NUKE,
87 D_PARADROP,
88 D_FORT
91 /**************************************************************************
92 Struct holding rally point for city
93 **************************************************************************/
94 struct qfc_rally
96 struct city *pcity;
97 struct tile *ptile;
100 /**************************************************************************
101 Class holding city list for rally points
102 **************************************************************************/
103 class qfc_rally_list
105 public:
106 qfc_rally_list() {
107 hover_tile = false;
108 hover_city = false;
110 void add(qfc_rally* rally);
111 bool clear(struct city *rcity);
112 QList<qfc_rally*> rally_list;
113 void run();
114 bool hover_tile;
115 bool hover_city;
116 struct city *rally_city;
119 void multiairlift(struct city *acity, Unit_type_id ut);
121 /**************************************************************************
122 Class representing one unit for delayed goto
123 **************************************************************************/
124 class qfc_delayed_unit_item
126 public:
127 qfc_delayed_unit_item(delay_order dg, int i) {
128 order = dg;
129 id = i;
130 ptile = nullptr;
132 delay_order order;
133 int id;
134 struct tile *ptile;
137 /**************************************************************************
138 Class holding unit list for delayed goto
139 **************************************************************************/
140 class qfc_units_list
142 public:
143 qfc_units_list();
144 void add(qfc_delayed_unit_item* fui);
145 void clear();
146 QList<qfc_delayed_unit_item*> unit_list;
147 int nr_units;
150 /**************************************************************************
151 Helper item for trade calculation
152 ***************************************************************************/
153 class trade_city
155 public:
156 trade_city(struct city *pcity);
158 bool done;
159 int over_max;
160 int poss_trade_num;
161 int trade_num; // already created + generated
162 QList<struct city *> curr_tr_cities;
163 QList<struct city *> new_tr_cities;
164 QList<struct city *> pos_cities;
165 struct city *city;
166 struct tile *tile;
170 /**************************************************************************
171 Struct of 2 tiles, used for drawing trade routes.
172 Also assigned caravan if it was sent
173 ***************************************************************************/
174 struct qtiles
176 struct tile *t1;
177 struct tile *t2;
178 struct unit *autocaravan;
180 bool operator==(const qtiles& a) const
182 return (t1 == a.t1 && t2 == a.t2 && autocaravan == a.autocaravan);
186 /**************************************************************************
187 Class trade generator, used for calulating possible trade routes
188 ***************************************************************************/
189 class trade_generator
191 public:
192 trade_generator();
194 bool hover_city;
195 QList<qtiles> lines;
196 QList<struct city *> virtual_cities;
197 QList<trade_city*> cities;
199 void add_all_cities();
200 void add_city(struct city *pcity);
201 void add_tile(struct tile *ptile);
202 void calculate();
203 void clear_trade_planing();
204 void remove_city(struct city *pcity);
205 void remove_virtual_city(struct tile *ptile);
207 private:
208 bool discard_any(trade_city *tc, int freeroutes);
209 bool discard_one(trade_city *tc);
210 int find_over_max(struct city *pcity);
211 trade_city* find_most_free();
212 void check_if_done(trade_city *tc1, trade_city *tc2);
213 void discard();
214 void discard_trade(trade_city *tc1, trade_city *tc2);
215 void find_certain_routes();
219 /****************************************************************************
220 Instantiable government menu.
221 ****************************************************************************/
222 class gov_menu : public QMenu
224 Q_OBJECT
225 static QSet<gov_menu *> instances;
227 QSignalMapper *gov_mapper;
228 QVector<QAction *> actions;
230 public:
231 gov_menu(QWidget* parent = 0);
232 virtual ~gov_menu();
234 static void create_all();
235 static void update_all();
237 public slots:
238 void revolution();
239 void change_gov(int target_gov);
241 void create();
242 void update();
245 /****************************************************************************
246 Go to and... menu.
247 ****************************************************************************/
248 class go_act_menu : public QMenu
250 Q_OBJECT
251 static QSet<go_act_menu *> instances;
253 QSignalMapper *go_act_mapper;
254 QMap<QAction *, int> items;
256 public:
257 go_act_menu(QWidget* parent = 0);
258 virtual ~go_act_menu();
260 static void reset_all();
261 static void update_all();
263 public slots:
264 void start_go_act(int action_id);
266 void reset();
267 void create();
268 void update();
271 /**************************************************************************
272 Class representing global menus in gameview
273 **************************************************************************/
274 class mr_menu : public QMenuBar
276 Q_OBJECT
277 QMenu *menu;
278 QMenu *airlift_menu;
279 QMenu *multiplayer_menu;
280 QActionGroup *airlift_type;
281 QActionGroup *action_vs_city;
282 QActionGroup *action_vs_unit;
283 QMenu *action_unit_menu;
284 QMenu *action_city_menu;
285 QHash<munit, QAction*> menu_list;
286 qfc_units_list units_list;
287 public:
288 mr_menu();
289 void setup_menus();
290 void menus_sensitive();
291 void update_airlift_menu();
292 void set_tile_for_order(struct tile *ptile);
293 void execute_shortcut(int sid);
294 QString shortcut_exist(fc_shortcut *fcs);
295 QString shortcut_2_menustring(int sid);
296 QAction *minimap_status;
297 QAction *lock_status;
298 QAction *osd_status;
299 QAction *btlog_status;
300 QAction *chat_status;
301 QAction *messages_status;
302 bool delayed_order;
303 bool quick_airlifting;
304 Unit_type_id airlift_type_id;
305 private slots:
306 /* game menu */
307 void local_options();
308 void shortcut_options();
309 void server_options();
310 void messages_options();
311 void save_options_now();
312 void save_game();
313 void save_game_as();
314 void save_image();
315 void tileset_custom_load();
316 void load_new_tileset();
317 void back_to_menu();
318 void quit_game();
320 /* help menu */
321 void slot_help(const QString &topic);
323 /*used by work menu*/
324 void slot_build_city();
325 void slot_go_build_city();
326 void slot_go_join_city();
327 void slot_auto_settler();
328 void slot_build_road();
329 void slot_build_irrigation();
330 void slot_build_mine();
331 void slot_conn_road();
332 void slot_conn_rail();
333 void slot_conn_irrigation();
334 void slot_transform();
335 void slot_clean_pollution();
336 void slot_clean_fallout();
338 /*used by unit menu */
339 void slot_unit_sentry();
340 void slot_unit_explore();
341 void slot_unit_goto();
342 void slot_airlift();
343 void slot_return_to_city();
344 void slot_patrol();
345 void slot_unsentry();
346 void slot_load();
347 void slot_unload();
348 void slot_unload_all();
349 void slot_set_home();
350 void slot_upgrade();
351 void slot_convert();
352 void slot_disband();
354 /*used by combat menu*/
355 void slot_unit_fortify();
356 void slot_unit_fortress();
357 void slot_unit_airbase();
358 void slot_pillage();
359 void slot_action();
360 void slot_nuke();
362 /*used by view menu*/
363 void slot_center_view();
364 void slot_minimap_view();
365 void slot_show_new_turn_text();
366 void slot_battlelog();
367 void slot_fullscreen();
368 void slot_lock();
369 void slot_city_outlines();
370 void slot_city_output();
371 void slot_map_grid();
372 void slot_borders();
373 void slot_fullbar();
374 void slot_native_tiles();
375 void slot_city_growth();
376 void slot_city_production();
377 void slot_city_buycost();
378 void slot_city_traderoutes();
379 void slot_city_names();
380 void zoom_in();
381 void zoom_out();
383 /*used by select menu */
384 void slot_select_one();
385 void slot_select_all_tile();
386 void slot_select_same_tile();
387 void slot_select_same_continent();
388 void slot_select_same_everywhere();
389 void slot_done_moving();
390 void slot_wait();
391 void slot_unit_filter();
393 /* used by multiplayer menu */
394 void slot_orders_clear();
395 void slot_execute_orders();
396 void slot_delayed_goto();
397 void slot_trade_add_all();
398 void slot_trade_city();
399 void slot_calculate();
400 void slot_clear_trade();
401 void slot_autocaravan();
402 void slot_rally();
403 void slot_quickairlift_set();
404 void slot_quickairlift();
405 void slot_action_vs_unit();
406 void slot_action_vs_city();
408 /*used by civilization menu */
409 void slot_show_map();
410 void calc_trade_routes();
411 void slot_popup_tax_rates();
412 void slot_popup_mult_rates();
413 void slot_show_eco_report();
414 void slot_show_units_report();
415 void slot_show_nations();
416 void slot_show_cities();
417 void slot_show_research_tab();
418 void slot_spaceship();
419 void slot_demographics();
420 void slot_achievements();
421 void slot_endgame();
422 void slot_top_five();
423 void slot_traveler();
425 private:
426 struct tile* find_last_unit_pos(struct unit* punit, int pos);
427 QSignalMapper *signal_help_mapper;
430 #endif /* FC__MENU_H */