Freeciv-3.3: /fast/freeciv/nightly/main/client/gui-qt/menu.h Source File

Freeciv-3.3

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