Freeciv-3.1: /fast/freeciv/nightly/S3_1/client/gui-qt/menu.h Source File

Freeciv-3.1

Loading...
Searching...
No Matches
menu.h
Go to the documentation of this file.
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.
7
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***********************************************************************/
13
14#ifndef FC__MENU_H
15#define FC__MENU_H
16
17extern "C" {
18#include "menu_g.h"
19}
20
21#ifdef HAVE_CONFIG_H
22#include <fc_config.h>
23#endif
24
25// Qt
26#include <QDialog>
27#include <QMenuBar>
28
29// client
30#include "control.h"
31
32class QLabel;
33class QPushButton;
34class QScrollArea;
35struct fc_shortcut;
36
39 enum munit {
40 STANDARD,
41 EXPLORE,
42 BOARD,
43 DEBOARD,
44 TRANSPORTER,
45 DISBAND,
46 CONVERT,
47 MINE,
48 PLANT,
49 IRRIGATION,
50 CULTIVATE,
51 TRANSFORM,
52 PILLAGE,
53 BUILD,
54 ROAD,
55 FORTIFY,
56 FORTRESS,
57 AIRBASE,
58 POLLUTION,
59 FALLOUT,
60 SENTRY,
61 HOMECITY,
62 WAKEUP,
63 AUTOSETTLER,
64 CONNECT_ROAD,
65 CONNECT_RAIL,
66 CONNECT_MAGLEV,
67 CONNECT_IRRIGATION,
68 GOTO_CITY,
69 AIRLIFT,
70 BUILD_WONDER,
71 AUTOTRADEROUTE,
72 ORDER_TRADE_ROUTE,
73 ORDER_DIPLOMAT_DLG,
74 UPGRADE,
75 NOT_4_OBS,
76 MULTIPLIERS,
77 ENDGAME,
78 SAVE
79};
80
81 enum delay_order{
82 D_GOTO,
83 D_NUKE,
84 D_PARADROP,
85 D_FORT
86};
87
88/**************************************************************************
89 Class holding city list for rally points
90**************************************************************************/
91 class qfc_rally_list
92{
93public:
94 qfc_rally_list() {
95 hover_tile = false;
96 hover_city = false;
97 };
98 bool hover_tile;
99 bool hover_city;
100 struct city *rally_city;
101};
102
103void multiairlift(struct city *acity, Unit_type_id ut);
104
105/**************************************************************************
106 Class representing one unit for delayed goto
107**************************************************************************/
108 class qfc_delayed_unit_item
109{
110public:
111 qfc_delayed_unit_item(delay_order dg, int i) {
112 order = dg;
113 id = i;
114 ptile = nullptr;
115 }
116 delay_order order;
117 int id;
118 struct tile *ptile;
119};
120
121/**************************************************************************
122 Class holding unit list for delayed goto
123**************************************************************************/
124 class qfc_units_list
125{
126public:
127 qfc_units_list();
128 void add(qfc_delayed_unit_item* fui);
129 void clear();
130 QList<qfc_delayed_unit_item*> unit_list;
131 int nr_units;
132};
133
134/**************************************************************************
135 Helper item for trade calculation
136***************************************************************************/
137 class trade_city
138{
139public:
140 trade_city(struct city *pcity);
141
142 bool done;
143 int over_max;
144 int poss_trade_num;
145 unsigned trade_num; // already created + generated
146 QList<struct city *> curr_tr_cities;
147 QList<struct city *> new_tr_cities;
148 QList<struct city *> pos_cities;
149 struct city *city;
150 struct tile *tile;
151
152};
153
154/**************************************************************************
155 Struct of 2 tiles, used for drawing trade routes.
156 Also assigned caravan if it was sent
157***************************************************************************/
158 struct qtiles
159{
160 struct tile *t1;
161 struct tile *t2;
162 struct unit *autocaravan;
163
164 bool operator==(const qtiles& a) const
165 {
166 return (t1 == a.t1 && t2 == a.t2 && autocaravan == a.autocaravan);
167 }
168};
169
170/***************************************************************************
171 Class trade generator, used for calculating possible trade routes
172***************************************************************************/
173 class trade_generator
174{
175public:
176 trade_generator();
177
178 bool hover_city;
179 QList<qtiles> lines;
180 QList<struct city *> virtual_cities;
181 QList<trade_city*> cities;
182
183 void add_all_cities();
184 void add_city(struct city *pcity);
185 void add_tile(struct tile *ptile);
186 void calculate();
187 void clear_trade_planing();
188 void remove_city(struct city *pcity);
189 void remove_virtual_city(struct tile *ptile);
190
191private:
192 bool discard_any(trade_city *tc, int freeroutes);
193 bool discard_one(trade_city *tc);
194 int find_over_max(struct city *pcity);
195 trade_city *find_most_free();
196 void check_if_done(trade_city *tc1, trade_city *tc2);
197 void discard();
198 void discard_trade(trade_city *tc1, trade_city *tc2);
199 void find_certain_routes();
200 void find_certain_routes_inner(trade_city *tc);
201 void calculate_inner(trade_city *tc);
202};
203
204
205/****************************************************************************
206 Instantiable government menu.
207****************************************************************************/
208 class gov_menu : public QMenu
209{
210 Q_OBJECT
211 static QSet<gov_menu *> instances;
212
213 QVector<QAction *> actions;
214
215public:
216 gov_menu(QWidget* parent = 0);
217 virtual ~gov_menu();
218
219 static void create_all();
220 static void update_all();
221
222public slots:
223 void revolution();
224 void change_gov(int target_gov);
225
226 void create();
227 void update();
228};
229
230/****************************************************************************
231 Go to and... menu.
232****************************************************************************/
233 class go_act_menu : public QMenu
234{
235 Q_OBJECT
236 static QSet<go_act_menu *> instances;
237
238 QMap<QAction *, int> items;
239
240public:
241 go_act_menu(QWidget *parent = nullptr);
242 virtual ~go_act_menu();
243
244 static void reset_all();
245 static void update_all();
246
247public slots:
248 void start_go_act(int act_id, int sub_tgt_id);
249
250 void reset();
251 void create();
252 void update();
253};
254
255/**************************************************************************
256 Class representing global menus in gameview
257**************************************************************************/
258 class mr_menu : public QMenuBar
259{
260 Q_OBJECT
261 QMenu *airlift_menu;
262 QMenu *bases_menu;
263 QMenu *multiplayer_menu;
264 QMenu *roads_menu;
265 QActionGroup *airlift_type;
266 QActionGroup *action_vs_city;
267 QActionGroup *action_vs_unit;
268 QMenu *action_unit_menu;
269 QMenu *action_city_menu;
270 QMultiHash<munit, QAction*> menu_list;
271 qfc_units_list units_list;
272public:
273 mr_menu();
274 void setup_menus();
275 void menus_sensitive();
276 void update_airlift_menu();
277 void update_roads_menu();
278 void update_bases_menu();
279 void set_tile_for_order(struct tile *ptile);
280 void execute_shortcut(int sid);
281 QString shortcut_exist(fc_shortcut *fcs);
282 QString shortcut_2_menustring(int sid);
283 QAction *minimap_status;
284 QAction *scale_fonts_status;
285 QAction *lock_status;
286 QAction *osd_status;
287 QAction *btlog_status;
288 QAction *chat_status;
289 QAction *messages_status;
290 bool delayed_order;
291 bool quick_airlifting;
292 Unit_type_id airlift_type_id;
293private slots:
294 /* game menu */
295 void local_options();
296 void shortcut_options();
297 void server_options();
298 void messages_options();
299 void save_options_now();
300 void save_game();
301 void save_game_as();
302 void save_image();
303 void tileset_custom_load();
304 void load_new_tileset();
305 void back_to_menu();
306 bool confirm_disruptive_selection();
307 void quit_game();
308
309 /* help menu */
310 void slot_help(const QString &topic);
311
312 /*used by work menu*/
313 void slot_build_path(int id);
314 void slot_build_base(int id);
315 void slot_build_city();
316 void slot_auto_settler();
317 void slot_build_road();
318 void slot_build_irrigation();
319 void slot_cultivate();
320 void slot_build_mine();
321 void slot_plant();
322 void slot_conn_road();
323 void slot_conn_rail();
324 void slot_conn_maglev();
325 void slot_conn_irrigation();
326 void slot_transform();
327 void slot_clean_pollution();
328 void slot_clean_fallout();
329
330 /*used by unit menu */
331 void slot_unit_sentry();
332 void slot_unit_explore();
333 void slot_unit_goto();
334 void slot_airlift();
335 void slot_return_to_city();
336 void slot_patrol();
337 void slot_unsentry();
338 void slot_board();
339 void slot_deboard();
340 void slot_unload_all();
341 void slot_set_home();
342 void slot_upgrade();
343 void slot_convert();
344 void slot_disband();
345
346 /*used by combat menu*/
347 void slot_unit_fortify();
348 void slot_unit_fortress();
349 void slot_unit_airbase();
350 void slot_pillage();
351 void slot_action();
352
353 /*used by view menu*/
354 void slot_center_view();
355 void slot_minimap_view();
356 void slot_show_new_turn_text();
357 void slot_battlelog();
358 void slot_fullscreen();
359 void slot_lock();
360 void slot_city_outlines();
361 void slot_city_output();
362 void slot_map_grid();
363 void slot_borders();
364 void slot_fullbar();
365 void slot_native_tiles();
366 void slot_city_growth();
367 void slot_city_production();
368 void slot_city_buycost();
369 void slot_city_trade_routes();
370 void slot_stack_size();
371 void slot_city_names();
372 void zoom_in();
373 void zoom_scale_fonts();
374 void zoom_reset();
375 void zoom_out();
376
377 /*used by select menu */
378 void slot_select_one();
379 void slot_select_all_tile();
380 void slot_select_same_tile();
381 void slot_select_same_continent();
382 void slot_select_same_everywhere();
383 void slot_done_moving();
384 void slot_wait();
385 void slot_unit_filter();
386
387 /* used by multiplayer menu */
388 void slot_orders_clear();
389 void slot_execute_orders();
390 void slot_delayed_goto();
391 void slot_trade_add_all();
392 void slot_trade_city();
393 void slot_calculate();
394 void slot_clear_trade();
395 void slot_autocaravan();
396 void slot_rally();
397 void slot_quickairlift_set();
398 void slot_quickairlift();
399 void slot_action_vs_unit();
400 void slot_action_vs_city();
401
402 /*used by civilization menu */
403 void slot_show_map();
404 void calc_trade_routes();
405 void slot_popup_tax_rates();
406 void slot_popup_mult_rates();
407 void slot_show_eco_report();
408 void slot_show_units_report();
409 void slot_show_nations();
410 void slot_show_cities();
411 void slot_show_research_tab();
412 void slot_spaceship();
413 void slot_demographics();
414 void slot_achievements();
415 void slot_endgame();
416 void slot_top_five();
417 void slot_traveler();
418 void slot_bg1select();
419 void slot_bg1assign();
420 void slot_bg1append();
421 void slot_bg2select();
422 void slot_bg2assign();
423 void slot_bg2append();
424 void slot_bg3select();
425 void slot_bg3assign();
426 void slot_bg3append();
427 void slot_bg4select();
428 void slot_bg4assign();
429 void slot_bg4append();
430
431private:
432 struct tile *find_last_unit_pos(struct unit *punit, int pos);
433 bool execute_shortcut_inner(const QMenu *m, QKeySequence seq);
434 bool shortcut_exist_inner(const QMenu *m, QKeySequence seq,
435 fc_shortcut *fcs, QString *ret);
436 bool shortcut_2_menustring_inner(const QMenu *m, QKeySequence seq,
437 QString *ret);
438};
439
440#endif /* FC__MENU_H */
qfc_delayed_unit_item
Definition menu.h:109
qfc_delayed_unit_item::qfc_delayed_unit_item
qfc_delayed_unit_item(delay_order dg, int i)
Definition menu.h:111
qfc_delayed_unit_item::ptile
struct tile * ptile
Definition menu.h:118
qfc_delayed_unit_item::id
int id
Definition menu.h:117
qfc_delayed_unit_item::order
delay_order order
Definition menu.h:116
qfc_rally_list
Definition menu.h:92
qfc_rally_list::hover_city
bool hover_city
Definition menu.h:99
qfc_rally_list::hover_tile
bool hover_tile
Definition menu.h:98
qfc_rally_list::qfc_rally_list
qfc_rally_list()
Definition menu.h:94
qfc_rally_list::rally_city
struct city * rally_city
Definition menu.h:100
qfc_units_list
Definition menu.h:125
qfc_units_list::unit_list
QList< qfc_delayed_unit_item * > unit_list
Definition menu.h:130
qfc_units_list::add
void add(qfc_delayed_unit_item *fui)
Definition menu.cpp:493
qfc_units_list::nr_units
int nr_units
Definition menu.h:131
qfc_units_list::clear
void clear()
Definition menu.cpp:501
qfc_units_list::qfc_units_list
qfc_units_list()
Definition menu.cpp:486
trade_city
Definition menu.h:138
trade_city::tile
struct tile * tile
Definition menu.h:150
trade_city::done
bool done
Definition menu.h:142
trade_city::trade_num
unsigned trade_num
Definition menu.h:145
trade_city::poss_trade_num
int poss_trade_num
Definition menu.h:144
trade_city::pos_cities
QList< struct city * > pos_cities
Definition menu.h:148
trade_city::new_tr_cities
QList< struct city * > new_tr_cities
Definition menu.h:147
trade_city::over_max
int over_max
Definition menu.h:143
trade_city::curr_tr_cities
QList< struct city * > curr_tr_cities
Definition menu.h:146
trade_city::city
struct city * city
Definition menu.h:149
trade_generator
Definition menu.h:174
trade_generator::calculate_inner
void calculate_inner(trade_city *tc)
Definition menu.cpp:214
trade_generator::discard_one
bool discard_one(trade_city *tc)
Definition menu.cpp:376
trade_generator::add_city
void add_city(struct city *pcity)
Definition menu.cpp:125
trade_generator::find_certain_routes
void find_certain_routes()
Definition menu.cpp:458
trade_generator::cities
QList< trade_city * > cities
Definition menu.h:181
trade_generator::find_certain_routes_inner
void find_certain_routes_inner(trade_city *tc)
Definition menu.cpp:423
trade_generator::find_most_free
trade_city * find_most_free()
Definition menu.cpp:325
trade_generator::discard_trade
void discard_trade(trade_city *tc1, trade_city *tc2)
Definition menu.cpp:362
trade_generator::add_tile
void add_tile(struct tile *ptile)
Definition menu.cpp:137
trade_generator::trade_generator
trade_generator()
Definition menu.cpp:79
trade_generator::remove_virtual_city
void remove_virtual_city(struct tile *ptile)
Definition menu.cpp:188
trade_generator::hover_city
bool hover_city
Definition menu.h:178
trade_generator::add_all_cities
void add_all_cities()
Definition menu.cpp:87
trade_generator::clear_trade_planing
void clear_trade_planing()
Definition menu.cpp:105
trade_generator::discard
void discard()
Definition menu.cpp:343
trade_generator::remove_city
void remove_city(struct city *pcity)
Definition menu.cpp:170
trade_generator::lines
QList< qtiles > lines
Definition menu.h:179
trade_generator::discard_any
bool discard_any(trade_city *tc, int freeroutes)
Definition menu.cpp:402
trade_generator::check_if_done
void check_if_done(trade_city *tc1, trade_city *tc2)
Definition menu.cpp:473
trade_generator::virtual_cities
QList< struct city * > virtual_cities
Definition menu.h:180
trade_generator::find_over_max
int find_over_max(struct city *pcity)
Definition menu.cpp:309
trade_generator::calculate
void calculate()
Definition menu.cpp:232
control.h
punit
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit * punit
Definition dialogs_g.h:73
Unit_type_id
int Unit_type_id
Definition fc_types.h:352
pos
static struct tile * pos
Definition finddlg.c:53
delay_order
delay_order
Definition menu.h:81
D_NUKE
@ D_NUKE
Definition menu.h:83
D_FORT
@ D_FORT
Definition menu.h:85
D_PARADROP
@ D_PARADROP
Definition menu.h:84
D_GOTO
@ D_GOTO
Definition menu.h:82
multiairlift
void multiairlift(struct city *acity, Unit_type_id ut)
Definition menu.cpp:3925
munit
munit
Definition menu.h:39
AIRLIFT
@ AIRLIFT
Definition menu.h:69
CONNECT_RAIL
@ CONNECT_RAIL
Definition menu.h:65
TRANSFORM
@ TRANSFORM
Definition menu.h:51
FORTIFY
@ FORTIFY
Definition menu.h:55
GOTO_CITY
@ GOTO_CITY
Definition menu.h:68
TRANSPORTER
@ TRANSPORTER
Definition menu.h:44
BUILD
@ BUILD
Definition menu.h:53
IRRIGATION
@ IRRIGATION
Definition menu.h:49
CONNECT_IRRIGATION
@ CONNECT_IRRIGATION
Definition menu.h:67
CONNECT_ROAD
@ CONNECT_ROAD
Definition menu.h:64
HOMECITY
@ HOMECITY
Definition menu.h:61
CONVERT
@ CONVERT
Definition menu.h:46
PILLAGE
@ PILLAGE
Definition menu.h:52
FALLOUT
@ FALLOUT
Definition menu.h:59
BUILD_WONDER
@ BUILD_WONDER
Definition menu.h:70
DISBAND
@ DISBAND
Definition menu.h:45
DEBOARD
@ DEBOARD
Definition menu.h:43
NOT_4_OBS
@ NOT_4_OBS
Definition menu.h:75
UPGRADE
@ UPGRADE
Definition menu.h:74
SAVE
@ SAVE
Definition menu.h:78
MULTIPLIERS
@ MULTIPLIERS
Definition menu.h:76
PLANT
@ PLANT
Definition menu.h:48
ORDER_TRADE_ROUTE
@ ORDER_TRADE_ROUTE
Definition menu.h:72
POLLUTION
@ POLLUTION
Definition menu.h:58
WAKEUP
@ WAKEUP
Definition menu.h:62
MINE
@ MINE
Definition menu.h:47
SENTRY
@ SENTRY
Definition menu.h:60
ORDER_DIPLOMAT_DLG
@ ORDER_DIPLOMAT_DLG
Definition menu.h:73
EXPLORE
@ EXPLORE
Definition menu.h:41
STANDARD
@ STANDARD
Definition menu.h:40
ROAD
@ ROAD
Definition menu.h:54
CONNECT_MAGLEV
@ CONNECT_MAGLEV
Definition menu.h:66
CULTIVATE
@ CULTIVATE
Definition menu.h:50
AUTOSETTLER
@ AUTOSETTLER
Definition menu.h:63
BOARD
@ BOARD
Definition menu.h:42
FORTRESS
@ FORTRESS
Definition menu.h:56
ENDGAME
@ ENDGAME
Definition menu.h:77
AUTOTRADEROUTE
@ AUTOTRADEROUTE
Definition menu.h:71
AIRBASE
@ AIRBASE
Definition menu.h:57
menu_g.h
slots
struct player_slot * slots
Definition player.c:50
city
Definition city.h:309
fc_shortcut
Definition shortcuts.h:104
qtiles
Definition menu.h:159
qtiles::t1
struct tile * t1
Definition menu.h:160
qtiles::t2
struct tile * t2
Definition menu.h:161
qtiles::operator==
bool operator==(const qtiles &a) const
Definition menu.h:164
qtiles::autocaravan
struct unit * autocaravan
Definition menu.h:162
tile
Definition tile.h:49
unit
Definition unit.h:138