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

Freeciv-3.3

Loading...
Searching...
No Matches
menu.cpp
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#ifdef HAVE_CONFIG_H
15#include <fc_config.h>
16#endif
17
18// Qt
19#include <QActionGroup>
20#include <QApplication>
21#include <QFileDialog>
22#include <QMainWindow>
23#include <QMessageBox>
24#include <QScrollArea>
25#include <QStandardPaths>
26#include <QVBoxLayout>
27
28// utility
29#include "string_vector.h"
30
31// common
32#include "game.h"
33#include "government.h"
34#include "goto.h"
35#include "name_translation.h"
36#include "road.h"
37#include "unit.h"
38
39// client
40#include "connectdlg_common.h"
41#include "control.h"
42#include "helpdata.h"
43
44// gui-qt
45#include "fc_client.h"
46#include "chatline.h"
47#include "cityrep.h"
48#include "dialogs.h"
49#include "gotodlg.h"
50#include "gui_main.h"
51#include "hudwidget.h"
52#include "mapctrl.h"
53#include "messagedlg.h"
54#include "plrdlg.h"
55#include "ratesdlg.h"
56#include "repodlgs.h"
57#include "shortcuts.h"
58#include "spaceshipdlg.h"
59#include "sprite.h"
60
61#include "menu.h"
62
63static void enable_interface(bool enable);
64
65/**********************************************************************/
68trade_city::trade_city(struct city *pcity)
69{
70 city = pcity;
71 tile = nullptr;
72 trade_num = 0;
73 poss_trade_num = 0;
74}
75
76/**********************************************************************/
79trade_generator::trade_generator()
80{
81 hover_city = false;
82}
83
84/**********************************************************************/
87 void trade_generator::add_all_cities()
88{
89 int i, s;
90 struct city *pcity;
91 struct player *pplayer = client_player();
92
93 clear_trade_planing();
94 s = city_list_size(pplayer->cities);
95 if (s == 0) {
96 return;
97 }
98 for (i = 0; i < s; i++) {
99 pcity = city_list_get(pplayer->cities, i);
100 add_city(pcity);
101 }
102}
103
104/**********************************************************************/
107 void trade_generator::clear_trade_planing()
108{
109 struct city *pcity;
110 trade_city *tc;
111
112 foreach(pcity, virtual_cities) {
113 destroy_city_virtual(pcity);
114 }
115 virtual_cities.clear();
116 foreach(tc, cities) {
117 delete tc;
118 }
119 cities.clear();
120 lines.clear();
121 gui()->mapview_wdg->repaint();
122}
123
124/**********************************************************************/
127 void trade_generator::add_city(struct city *pcity)
128{
129 trade_city *tc = new trade_city(pcity);
130
131 cities.append(tc);
132 gui()->infotab->chtwdg->append(QString(_("Adding city %1 to trade planning"))
133 .arg(tc->city->name));
134}
135
136/**********************************************************************/
139 void trade_generator::add_tile(struct tile *ptile)
140{
141 struct city *pcity;
142 trade_city *tc;
143
144 pcity = tile_city(ptile);
145
146 foreach (tc, cities) {
147 if (pcity != nullptr) {
148 if (tc->city == pcity) {
149 remove_city(pcity);
150 return;
151 }
152 }
153 if (tc->city->tile == ptile) {
154 remove_virtual_city(ptile);
155 return;
156 }
157 }
158
159 if (pcity != nullptr) {
160 add_city(pcity);
161 return;
162 }
163
164 pcity = create_city_virtual(client_player(), ptile, "Virtual");
165 add_city(pcity);
166 virtual_cities.append(pcity);
167}
168
169/**********************************************************************/
172 void trade_generator::remove_city(struct city* pcity)
173{
174 trade_city *tc;
175
176 foreach (tc, cities) {
177 if (tc->city->tile == pcity->tile) {
178 cities.removeAll(tc);
179 gui()->infotab->chtwdg->append(
180 QString(_("Removing city %1 from trade planning"))
181 .arg(tc->city->name));
182 return;
183 }
184 }
185}
186
187/**********************************************************************/
190 void trade_generator::remove_virtual_city(tile *ptile)
191{
192 struct city *c;
193 trade_city *tc;
194
195 foreach (c, virtual_cities) {
196 if (c->tile == ptile) {
197 virtual_cities.removeAll(c);
198 gui()->infotab->chtwdg->append(
199 QString(_("Removing city %1 from trade planning")).arg(c->name));
200 }
201 }
202
203 foreach (tc, cities) {
204 if (tc->city->tile == ptile) {
205 cities.removeAll(tc);
206 return;
207 }
208 }
209}
210
211/**********************************************************************/
216 void trade_generator::calculate_inner(trade_city *tc)
217{
218 trade_city *ttc;
219
220 foreach (ttc, cities) {
221 if (!have_cities_trade_route(tc->city, ttc->city)
222 && can_establish_trade_route(tc->city, ttc->city, GOODS_HIGH_PRIORITY)) {
223 tc->poss_trade_num++;
224 tc->pos_cities.append(ttc->city);
225 }
226 tc->over_max = tc->trade_num + tc->poss_trade_num
227 - max_trade_routes(tc->city);
228 }
229}
230
231/**********************************************************************/
234 void trade_generator::calculate()
235{
236 trade_city *tc;
237 int i;
238 bool tdone;
239 int count = cities.size();
240 int *cities_ids = (int *)fc_malloc(sizeof(int) * count);
241 trade_city **cities_order = (trade_city **)fc_malloc(sizeof(trade_city *) * count);
242
243 for (i = 0; i < 100; i++) {
244 int n;
245
246 tdone = true;
247
248 for (n = 0; n < count; n++) {
249 cities_ids[n] = n;
250 cities_order[n] = cities[n];
251 }
252 array_shuffle(cities_ids, count);
253
254 cities.clear();
255 for (n = 0; n < count; n++) {
256 cities.append(cities_order[cities_ids[n]]);
257 }
258
259 lines.clear();
260 foreach (tc, cities) {
261 tc->pos_cities.clear();
262 tc->new_tr_cities.clear();
263 tc->curr_tr_cities.clear();
264 }
265 foreach (tc, cities) {
266 tc->trade_num = city_num_trade_routes(tc->city);
267 tc->poss_trade_num = 0;
268 tc->pos_cities.clear();
269 tc->new_tr_cities.clear();
270 tc->curr_tr_cities.clear();
271 tc->done = false;
272 calculate_inner(tc);
273 }
274
275 find_certain_routes();
276 discard();
277 find_certain_routes();
278
279 foreach (tc, cities) {
280 if (!tc->done) {
281 tdone = false;
282 }
283 }
284 if (tdone) {
285 break;
286 }
287 }
288 foreach (tc, cities) {
289 if (!tc->done) {
290 char text[1024];
291 fc_snprintf(text, sizeof(text),
292 PL_("City %s - 1 free trade route.",
293 "City %s - %d free trade routes.",
294 max_trade_routes(tc->city) - tc->trade_num),
295 city_link(tc->city),
296 max_trade_routes(tc->city) - tc->trade_num);
297 output_window_append(ftc_client, text);
298 }
299 }
300
301 free(cities_ids);
302 free(cities_order);
303
304 gui()->mapview_wdg->repaint();
305}
306
307/**********************************************************************/
311 int trade_generator::find_over_max(struct city *pcity = nullptr)
312{
313 trade_city *tc;
314 int max = 0;
315
316 foreach (tc, cities) {
317 if (pcity != tc->city) {
318 max = qMax(max, tc->over_max);
319 }
320 }
321 return max;
322}
323
324/**********************************************************************/
327 trade_city* trade_generator::find_most_free()
328{
329 trade_city *tc;
330 trade_city *rc = nullptr;
331 int max = 0;
332
333 foreach (tc, cities) {
334 if (max < tc->over_max) {
335 max = tc->over_max;
336 rc = tc;
337 }
338 }
339 return rc;
340}
341
342/**********************************************************************/
345 void trade_generator::discard()
346{
347 trade_city *tc;
348 int j = 5;
349
350 for (int i = j; i > -j; i--) {
351 while ((tc = find_most_free())) {
352 if (!discard_one(tc)) {
353 if (!discard_any(tc, i)) {
354 break;
355 }
356 }
357 }
358 }
359}
360
361/**********************************************************************/
364 void trade_generator::discard_trade(trade_city* tc, trade_city* ttc)
365{
366 tc->pos_cities.removeOne(ttc->city);
367 ttc->pos_cities.removeOne(tc->city);
368 tc->poss_trade_num--;
369 ttc->poss_trade_num--;
370 tc->over_max--;
371 ttc->over_max--;
372 check_if_done(tc, ttc);
373}
374
375/**********************************************************************/
378 bool trade_generator::discard_one(trade_city *tc)
379{
380 int best = 0;
381 int current_candidate = 0;
382 int best_id;
383 trade_city *ttc;
384
385 for (int i = cities.size() - 1 ; i >= 0; i--) {
386 ttc = cities.at(i);
387 current_candidate = ttc->over_max;
388 if (current_candidate > best) {
389 best_id = i;
390 }
391 }
392 if (best == 0) {
393 return false;
394 }
395
396 ttc = cities.at(best_id);
397 discard_trade(tc, ttc);
398 return true;
399}
400
401/**********************************************************************/
404 bool trade_generator::discard_any(trade_city* tc, int freeroutes)
405{
406 trade_city *ttc;
407
408 for (int i = cities.size() - 1 ; i >= 0; i--) {
409 ttc = cities.at(i);
410 if (tc->pos_cities.contains(ttc->city)
411 && ttc->pos_cities.contains(tc->city)
412 && ttc->over_max > freeroutes) {
413 discard_trade(tc, ttc);
414 return true;
415 }
416 }
417 return false;
418}
419
420/**********************************************************************/
425 void trade_generator::find_certain_routes_inner(trade_city *tc)
426{
427 trade_city *ttc;
428
429 foreach (ttc, cities) {
430 if (ttc->done || ttc->over_max > 0
431 || tc == ttc || tc->done || tc->over_max > 0) {
432 continue;
433 }
434 if (tc->pos_cities.contains(ttc->city)
435 && ttc->pos_cities.contains(tc->city)) {
436 struct qtiles gilles;
437
438 tc->pos_cities.removeOne(ttc->city);
439 ttc->pos_cities.removeOne(tc->city);
440 tc->poss_trade_num--;
441 ttc->poss_trade_num--;
442 tc->new_tr_cities.append(ttc->city);
443 ttc->new_tr_cities.append(ttc->city);
444 tc->trade_num++;
445 ttc->trade_num++;
446 tc->over_max--;
447 ttc->over_max--;
448 check_if_done(tc, ttc);
449 gilles.t1 = tc->city->tile;
450 gilles.t2 = ttc->city->tile;
451 gilles.autocaravan = nullptr;
452 lines.append(gilles);
453 }
454 }
455}
456
457/**********************************************************************/
460 void trade_generator::find_certain_routes()
461{
462 trade_city *tc;
463
464 foreach (tc, cities) {
465 if (tc->done || tc->over_max > 0) {
466 continue;
467 }
468 find_certain_routes_inner(tc);
469 }
470}
471
472/**********************************************************************/
475 void trade_generator::check_if_done(trade_city* tc1, trade_city* tc2)
476{
477 if (tc1->trade_num == max_trade_routes(tc1->city)) {
478 tc1->done = true;
479 }
480 if (tc2->trade_num == max_trade_routes(tc2->city)) {
481 tc2->done = true;
482 }
483}
484
485/**********************************************************************/
488qfc_units_list::qfc_units_list()
489{
490}
491
492/**********************************************************************/
495 void qfc_units_list::add(qfc_delayed_unit_item* fui)
496{
497 unit_list.append(fui);
498}
499
500/**********************************************************************/
503 void qfc_units_list::clear()
504{
505 unit_list.clear();
506}
507
508/**********************************************************************/
512 void real_menus_init(void)
513{
514 if (!game.client.ruleset_ready) {
515 return;
516 }
517 gui()->menu_bar->clear();
518 gui()->menu_bar->setup_menus();
519
520 gov_menu::create_all();
521
522 // A new ruleset may have been loaded.
523 go_act_menu::reset_all();
524}
525
526/**********************************************************************/
530 void real_menus_update(void)
531{
532 if (C_S_RUNNING <= client_state()) {
533 gui()->menuBar()->setVisible(true);
534 if (!is_waiting_turn_change()) {
535 gui()->menu_bar->menus_sensitive();
536 gui()->menu_bar->update_airlift_menu();
537 gui()->menu_bar->update_roads_menu();
538 gui()->menu_bar->update_bases_menu();
539 gov_menu::update_all();
540 go_act_menu::update_all();
541 gui()->unitinfo_wdg->update_actions(nullptr);
542 }
543 } else {
544 gui()->menuBar()->setVisible(false);
545 }
546}
547
548/**********************************************************************/
553 static const char *get_tile_change_menu_text(struct tile *ptile,
554 enum unit_activity activity)
555{
556 struct tile *newtile = tile_virtual_new(ptile);
557 const char *text;
558
559 tile_apply_activity(newtile, activity, nullptr);
560 text = tile_get_info_text(newtile, FALSE, 0);
561 tile_virtual_destroy(newtile);
562
563 return text;
564}
565
566/**********************************************************************/
569gov_menu::gov_menu(QWidget* parent) :
570 QMenu(_("Government"), parent)
571{
572 // Register ourselves to get updates for free.
573 instances << this;
574 setAttribute(Qt::WA_TranslucentBackground);
575}
576
577/**********************************************************************/
580gov_menu::~gov_menu()
581{
582 qDeleteAll(actions);
583 instances.remove(this);
584}
585
586/**********************************************************************/
589 void gov_menu::create() {
590 QAction *action;
591 struct government *gov, *revol_gov;
592 int gov_count, i;
593
594 // Clear any content
595 foreach(action, QWidget::actions()) {
596 removeAction(action);
597 action->deleteLater();
598 }
599 actions.clear();
600
601 gov_count = government_count();
602 actions.reserve(gov_count + 1);
603 action = addAction(_("Revolution..."));
604 connect(action, &QAction::triggered, this, &gov_menu::revolution);
605 actions.append(action);
606
607 addSeparator();
608
609 // Add an action for each government. There is no icon yet.
610 revol_gov = game.government_during_revolution;
611 for (i = 0; i < gov_count; ++i) {
612 gov = government_by_number(i);
613 if (gov != revol_gov) { // Skip revolution goverment
614 // Defeat keyboard shortcut mnemonics
615 action = addAction(QString(government_name_translation(gov))
616 .replace("&", "&&"));
617 // We need to keep track of the gov <-> action mapping to be able to
618 // set enabled/disabled depending on available govs.
619 actions.append(action);
620 QObject::connect(action, &QAction::triggered, [this,i]() {
621 change_gov(i);
622 });
623 }
624 }
625}
626
627/**********************************************************************/
630 void gov_menu::update()
631{
632 struct government *gov, *revol_gov;
633 struct sprite *sprite;
634 int gov_count, i, j;
635
636 gov_count = government_count();
637 revol_gov = game.government_during_revolution;
638 for (i = 0, j = 0; i < gov_count; i++) {
639 gov = government_by_number(i);
640 if (gov != revol_gov) { // Skip revolution goverment
641 sprite = get_government_sprite(tileset, gov);
642 if (sprite != nullptr) {
643 actions[j + 1]->setIcon(QIcon(*(sprite->pm)));
644 }
645 actions[j + 1]->setEnabled(
646 can_change_to_government(client_player(), gov));
647 j++;
648 } else {
649 actions[0]->setEnabled(!client_is_observer()
650 && untargeted_revolution_allowed());
651 }
652 }
653}
654
655/**********************************************************************/
658 void gov_menu::revolution()
659{
660 popup_revolution_dialog();
661}
662
663/**********************************************************************/
666 void gov_menu::change_gov(int target_gov)
667{
668 popup_revolution_dialog(government_by_number(target_gov));
669}
670
671/**************************************************************************
672 Keeps track of all gov_menu instances.
673**************************************************************************/
674 QSet<gov_menu *> gov_menu::instances = QSet<gov_menu *>();
675
676/**********************************************************************/
679 void gov_menu::create_all()
680{
681 foreach (gov_menu *m, instances) {
682 m->create();
683 }
684}
685
686/**********************************************************************/
689 void gov_menu::update_all()
690{
691 foreach (gov_menu *m, instances) {
692 m->update();
693 }
694}
695
696/**********************************************************************/
699go_act_menu::go_act_menu(QWidget *parent)
700 : QMenu(_("Go to and..."), parent)
701{
702 // Will need auto updates etc.
703 instances << this;
704}
705
706/**********************************************************************/
709go_act_menu::~go_act_menu()
710{
711 // Updates are no longer needed.
712 instances.remove(this);
713}
714
715/**********************************************************************/
718 void go_act_menu::reset()
719{
720 // Clear menu item to action ID mapping.
721 items.clear();
722
723 // Remove the menu items
724 clear();
725}
726
727/**********************************************************************/
730 void go_act_menu::create()
731{
732 QAction *item;
733 int tgt_kind_group;
734
735 // Group goto and perform action menu items by target kind.
736 for (tgt_kind_group = 0; tgt_kind_group < ATK_COUNT; tgt_kind_group++) {
737 action_noninternal_iterate(act_id) {
738 struct action *paction = action_by_number(act_id);
739 QString action_name = (QString(action_name_translation(paction))
740 .replace("&", "&&"));
741
742 if (action_id_get_actor_kind(act_id) != AAK_UNIT) {
743 // This action isn't performed by an unit.
744 continue;
745 }
746
747 if (action_id_get_target_kind(act_id) != tgt_kind_group) {
748 // Wrong group.
749 continue;
750 }
751
752 if (action_id_has_complex_target(act_id)) {
753 QMenu *sub_target_menu = addMenu(action_name);
754 items.insert(sub_target_menu->menuAction(), act_id);
755
756#define CREATE_SUB_ITEM(_menu_, _act_id_, _sub_tgt_id_, _sub_tgt_name_) \
757 { \
758 QAction *_sub_item_ = _menu_->addAction(_sub_tgt_name_); \
759 int _sub_target_id_ = _sub_tgt_id_; \
760 QObject::connect(_sub_item_, &QAction::triggered, \
761 [this, _act_id_, _sub_target_id_]() { \
762 start_go_act(_act_id_, _sub_target_id_); \
763 }); \
764 }
765
766 switch (action_get_sub_target_kind(paction)) {
767 case ASTK_BUILDING:
768 improvement_iterate(pimpr) {
769 CREATE_SUB_ITEM(sub_target_menu, act_id,
770 improvement_number(pimpr),
771 improvement_name_translation(pimpr));
772 } improvement_iterate_end;
773 break;
774 case ASTK_TECH:
775 advance_iterate(ptech) {
776 CREATE_SUB_ITEM(sub_target_menu, act_id,
777 advance_number(ptech),
778 advance_name_translation(ptech));
779 } advance_iterate_end;
780 break;
781 case ASTK_EXTRA:
782 case ASTK_EXTRA_NOT_THERE:
783 extra_type_iterate(pextra) {
784 if (!actres_creates_extra(paction->result, pextra)
785 && !actres_removes_extra(paction->result, pextra)) {
786 // Not relevant
787 continue;
788 }
789
790 CREATE_SUB_ITEM(sub_target_menu, act_id,
791 extra_number(pextra),
792 extra_name_translation(pextra));
793 } extra_type_iterate_end;
794 break;
795 case ASTK_NONE:
796 // Should not be here.
797 fc_assert(action_get_sub_target_kind(paction) != ASTK_NONE);
798 break;
799 case ASTK_COUNT:
800 // Should not exits
801 fc_assert(action_get_sub_target_kind(paction) != ASTK_COUNT);
802 break;
803 }
804 continue;
805 }
806
807#define ADD_OLD_SHORTCUT(wanted_action_id, sc_id) \
808 if (act_id == wanted_action_id) { \
809 item->setShortcut(QKeySequence(shortcut_to_string( \
810 fc_shortcuts::sc()->get_shortcut(sc_id)))); \
811 }
812
813 /* Create and add the menu item. It will be hidden or shown based on
814 * unit type. */
815 item = addAction(action_name);
816 items.insert(item, act_id);
817
818 /* Add the keyboard shortcuts for "Go to and..." menu items that
819 * existed independently before the "Go to and..." menu arrived. */
820 ADD_OLD_SHORTCUT(ACTION_FOUND_CITY, SC_GOBUILDCITY);
821 ADD_OLD_SHORTCUT(ACTION_JOIN_CITY, SC_GOJOINCITY);
822 ADD_OLD_SHORTCUT(ACTION_NUKE, SC_NUKE);
823
824 QObject::connect(item, &QAction::triggered, [this,act_id]() {
825 start_go_act(act_id, NO_TARGET);
826 });
827 } action_noninternal_iterate_end;
828 }
829}
830
831/**********************************************************************/
834 void go_act_menu::update()
835{
836 bool can_do_something = false;
837
838 if (!actions_are_ready()) {
839 // Nothing to do.
840 return;
841 }
842
843 if (items.isEmpty()) {
844 // The goto and act menu needs menu items.
845 create();
846 }
847
848 /* Enable a menu item if it is theoretically possible that one of the
849 * selected units can perform it. Checking if the action can be performed
850 * at the current tile is pointless since it should be performed at the
851 * target tile. */
852 foreach(QAction *item, items.keys()) {
853 if (units_can_do_action(get_units_in_focus(),
854 items.value(item), TRUE)) {
855 item->setVisible(true);
856 can_do_something = true;
857 } else {
858 item->setVisible(false);
859 }
860 }
861
862 if (can_do_something) {
863 // At least one menu item is enabled for one of the selected units.
864 setEnabled(true);
865 } else {
866 // No menu item is enabled any of the selected units.
867 setEnabled(false);
868 }
869}
870
871/**********************************************************************/
874 void go_act_menu::start_go_act(int act_id, int sub_tgt_id)
875{
876 request_unit_goto(ORDER_PERFORM_ACTION, act_id, sub_tgt_id);
877}
878
879/**************************************************************************
880 Store all goto and act menu items so they can be updated etc
881**************************************************************************/
882 QSet<go_act_menu *> go_act_menu::instances;
883
884/**********************************************************************/
887 void go_act_menu::reset_all()
888{
889 foreach (go_act_menu *m, instances) {
890 m->reset();
891 }
892}
893
894/**********************************************************************/
897 void go_act_menu::update_all()
898{
899 foreach (go_act_menu *m, instances) {
900 m->update();
901 }
902}
903
904/**********************************************************************/
907 struct tile *mr_menu::find_last_unit_pos(unit *punit, int pos)
908{
909 qfc_delayed_unit_item *fui;
910 struct tile *ptile = nullptr;
911 struct unit *zunit;
912 struct unit *qunit;
913
914 int i = 0;
915 qunit = punit;
916 foreach (fui, units_list.unit_list) {
917 zunit = unit_list_find(client_player()->units, fui->id);
918 i++;
919 if (i >= pos) {
920 punit = qunit;
921 return ptile;
922 }
923 if (zunit == nullptr) {
924 continue;
925 }
926
927 if (punit == zunit) { // Unit found
928 /* Unit was ordered to attack city so it might stay in
929 front of that city */
930 if (is_non_allied_city_tile(fui->ptile, unit_owner(punit))) {
931 ptile = tile_before_end_path(punit, fui->ptile);
932 if (ptile == nullptr) {
933 ptile = fui->ptile;
934 }
935 } else {
936 ptile = fui->ptile;
937 }
938 // Unit found in transport
939 } else if (unit_contained_in(punit, zunit)) {
940 ptile = fui->ptile;
941 }
942 }
943 return nullptr;
944}
945
946/**********************************************************************/
949mr_menu::mr_menu() : QMenuBar()
950{
951}
952
953/**********************************************************************/
958 void mr_menu::setup_menus()
959{
960 QAction *act;
961 QMenu *sub_menu;
962 QMenu *main_menu;
963 QList<QMenu*> menus;
964 int i;
965
966 delayed_order = false;
967 airlift_type_id = 0;
968 quick_airlifting = false;
969
970 // Game Menu
971 main_menu = this->addMenu(_("Game"));
972
973#ifdef __APPLE__
974 // On Mac, Qt would try to move menu entry named just "Options" to
975 // application menu, but as this is submenu and not an action
976 // 1) It would fail to appear in the destination
977 // 2) It's impossible to override the behavior with QAction::menuRule()
978 // We add an invisible character for the string comparison to fail.
979 sub_menu = main_menu->addMenu(QString("\u200B") + _("Options"));
980#else // __APPLE__
981 sub_menu = main_menu->addMenu(_("Options"));
982#endif // __APPLE__
983
984 act = sub_menu->addAction(_("Set local options"));
985 connect(act, &QAction::triggered, this, &mr_menu::local_options);
986 act = sub_menu->addAction(_("Server Options"));
987 connect(act, &QAction::triggered, this, &mr_menu::server_options);
988 act = sub_menu->addAction(_("Messages"));
989 connect(act, &QAction::triggered, this, &mr_menu::messages_options);
990 act = sub_menu->addAction(_("Shortcuts"));
991 connect(act, &QAction::triggered, this, &mr_menu::shortcut_options);
992 act = sub_menu->addAction(_("Load another tileset"));
993 connect(act, &QAction::triggered, this, &mr_menu::tileset_custom_load);
994 act = sub_menu->addAction(_("Save Options Now"));
995 act->setIcon(style()->standardIcon(QStyle::SP_DialogSaveButton));
996 connect(act, &QAction::triggered, this, &mr_menu::save_options_now);
997 act = sub_menu->addAction(_("Save Options on Exit"));
998 act->setCheckable(true);
999 act->setChecked(gui_options.save_options_on_exit);
1000 main_menu->addSeparator();
1001 act = main_menu->addAction(_("Save Game"));
1002 act->setShortcut(QKeySequence(tr("Ctrl+s")));
1003 act->setIcon(style()->standardIcon(QStyle::SP_DialogSaveButton));
1004 menu_list.insert(SAVE, act);
1005 connect(act, &QAction::triggered, this, &mr_menu::save_game);
1006 act = main_menu->addAction(_("Save Game As..."));
1007 menu_list.insert(SAVE, act);
1008 act->setIcon(style()->standardIcon(QStyle::SP_DialogSaveButton));
1009 connect(act, &QAction::triggered, this, &mr_menu::save_game_as);
1010 act = main_menu->addAction(_("Save Map to Image"));
1011 connect(act, &QAction::triggered, this, &mr_menu::save_image);
1012 main_menu->addSeparator();
1013 act = main_menu->addAction(_("Leave game"));
1014 act->setIcon(style()->standardIcon(QStyle::SP_DialogDiscardButton));
1015 connect(act, &QAction::triggered, this, &mr_menu::back_to_menu);
1016 act = main_menu->addAction(_("Quit"));
1017 act->setIcon(style()->standardIcon(QStyle::SP_TitleBarCloseButton));
1018 connect(act, &QAction::triggered, this, &mr_menu::quit_game);
1019
1020 // View Menu
1021 main_menu = this->addMenu(Q_("?verb:View"));
1022 act = main_menu->addAction(_("Center View"));
1023 act->setShortcut(QKeySequence(shortcut_to_string(
1024 fc_shortcuts::sc()->get_shortcut(SC_CENTER_VIEW))));
1025 connect(act, &QAction::triggered, this, &mr_menu::slot_center_view);
1026 main_menu->addSeparator();
1027 act = main_menu->addAction(_("Fullscreen"));
1028 act->setShortcut(QKeySequence(shortcut_to_string(
1029 fc_shortcuts::sc()->get_shortcut(SC_FULLSCREEN))));
1030 act->setCheckable(true);
1031 act->setChecked(gui_options.gui_qt_fullscreen);
1032 connect(act, &QAction::triggered, this, &mr_menu::slot_fullscreen);
1033 main_menu->addSeparator();
1034 minimap_status = main_menu->addAction(_("Minimap"));
1035 minimap_status->setCheckable(true);
1036 minimap_status->setShortcut(QKeySequence(shortcut_to_string(
1037 fc_shortcuts::sc()->get_shortcut(SC_MINIMAP))));
1038 minimap_status->setChecked(true);
1039 connect(minimap_status, &QAction::triggered, this,
1040 &mr_menu::slot_minimap_view);
1041 osd_status = main_menu->addAction(_("Show new turn information"));
1042 osd_status->setCheckable(true);
1043 osd_status->setChecked(gui()->qt_settings.show_new_turn_text);
1044 connect(osd_status, &QAction::triggered, this,
1045 &mr_menu::slot_show_new_turn_text);
1046 btlog_status = main_menu->addAction(_("Show combat detailed information"));
1047 btlog_status->setCheckable(true);
1048 btlog_status->setChecked(gui()->qt_settings.show_battle_log);
1049 connect(btlog_status, &QAction::triggered, this, &mr_menu::slot_battlelog);
1050 lock_status = main_menu->addAction(_("Lock interface"));
1051 lock_status->setCheckable(true);
1052 lock_status->setShortcut(QKeySequence(shortcut_to_string(
1053 fc_shortcuts::sc()->get_shortcut(SC_IFACE_LOCK))));
1054 lock_status->setChecked(false);
1055 connect(lock_status, &QAction::triggered, this, &mr_menu::slot_lock);
1056 connect(minimap_status, &QAction::triggered, this, &mr_menu::slot_lock);
1057 main_menu->addSeparator();
1058 act = main_menu->addAction(_("Zoom in"));
1059 act->setShortcut(QKeySequence(shortcut_to_string(
1060 fc_shortcuts::sc()->get_shortcut(SC_ZOOM_IN))));
1061 connect(act, &QAction::triggered, this, &mr_menu::zoom_in);
1062 act = main_menu->addAction(_("Zoom default"));
1063 act->setShortcut(QKeySequence(shortcut_to_string(
1064 fc_shortcuts::sc()->get_shortcut(SC_ZOOM_RESET))));
1065 connect(act, &QAction::triggered, this, &mr_menu::zoom_reset);
1066 act = main_menu->addAction(_("Zoom out"));
1067 act->setShortcut(QKeySequence(shortcut_to_string(
1068 fc_shortcuts::sc()->get_shortcut(SC_ZOOM_OUT))));
1069 connect(act, &QAction::triggered, this, &mr_menu::zoom_out);
1070 scale_fonts_status = main_menu->addAction(_("Scale fonts"));
1071 connect(scale_fonts_status, &QAction::triggered, this,
1072 &mr_menu::zoom_scale_fonts);
1073 scale_fonts_status->setCheckable(true);
1074 scale_fonts_status->setChecked(true);
1075 main_menu->addSeparator();
1076 act = main_menu->addAction(_("City Outlines"));
1077 act->setCheckable(true);
1078 act->setChecked(gui_options.draw_city_outlines);
1079 connect(act, &QAction::triggered, this, &mr_menu::slot_city_outlines);
1080 act = main_menu->addAction(_("City Output"));
1081 act->setCheckable(true);
1082 act->setChecked(gui_options.draw_city_output);
1083 act->setShortcut(QKeySequence(shortcut_to_string(
1084 fc_shortcuts::sc()->get_shortcut(SC_CITY_OUTPUT))));
1085 connect(act, &QAction::triggered, this, &mr_menu::slot_city_output);
1086 act = main_menu->addAction(_("Map Grid"));
1087 act->setShortcut(QKeySequence(shortcut_to_string(
1088 fc_shortcuts::sc()->get_shortcut(SC_MAP_GRID))));
1089 act->setCheckable(true);
1090 act->setChecked(gui_options.draw_map_grid);
1091 connect(act, &QAction::triggered, this, &mr_menu::slot_map_grid);
1092 act = main_menu->addAction(_("National Borders"));
1093 act->setCheckable(true);
1094 act->setChecked(gui_options.draw_borders);
1095 act->setShortcut(QKeySequence(shortcut_to_string(
1096 fc_shortcuts::sc()->get_shortcut(SC_NAT_BORDERS))));
1097 connect(act, &QAction::triggered, this, &mr_menu::slot_borders);
1098 act = main_menu->addAction(_("Native Tiles"));
1099 act->setCheckable(true);
1100 act->setChecked(gui_options.draw_native);
1101 act->setShortcut(QKeySequence(tr("ctrl+shift+n")));
1102 connect(act, &QAction::triggered, this, &mr_menu::slot_native_tiles);
1103 act = main_menu->addAction(_("City Full Bar"));
1104 act->setCheckable(true);
1105 act->setShortcut(QKeySequence(shortcut_to_string(
1106 fc_shortcuts::sc()->get_shortcut(SC_SHOW_FULLBAR))));
1107 act->setChecked(gui_options.draw_full_citybar);
1108 connect(act, &QAction::triggered, this, &mr_menu::slot_fullbar);
1109 act = main_menu->addAction(_("City Names"));
1110 act->setCheckable(true);
1111 act->setChecked(gui_options.draw_city_names);
1112 act->setShortcut(QKeySequence(shortcut_to_string(
1113 fc_shortcuts::sc()->get_shortcut(SC_CITY_NAMES))));
1114 connect(act, &QAction::triggered, this, &mr_menu::slot_city_names);
1115 act = main_menu->addAction(_("City Growth"));
1116 act->setCheckable(true);
1117 act->setChecked(gui_options.draw_city_growth);
1118 act->setShortcut(QKeySequence(tr("ctrl+o")));
1119 connect(act, &QAction::triggered, this, &mr_menu::slot_city_growth);
1120 act = main_menu->addAction(_("City Production"));
1121 act->setCheckable(true);
1122 act->setChecked(gui_options.draw_city_productions);
1123 act->setShortcut(QKeySequence(shortcut_to_string(
1124 fc_shortcuts::sc()->get_shortcut(SC_CITY_PROD))));
1125 connect(act, &QAction::triggered, this, &mr_menu::slot_city_production);
1126 act = main_menu->addAction(_("City Buy Cost"));
1127 act->setCheckable(true);
1128 act->setChecked(gui_options.draw_city_buycost);
1129 connect(act, &QAction::triggered, this, &mr_menu::slot_city_buycost);
1130 act = main_menu->addAction(_("City Trade Routes"));
1131 act->setCheckable(true);
1132 act->setChecked(gui_options.draw_city_trade_routes);
1133 act->setShortcut(QKeySequence(shortcut_to_string(
1134 fc_shortcuts::sc()->get_shortcut(SC_TRADE_ROUTES))));
1135 connect(act, &QAction::triggered, this, &mr_menu::slot_city_trade_routes);
1136 act = main_menu->addAction(_("Unit Stack Size"));
1137 act->setCheckable(true);
1138 act->setChecked(gui_options.draw_unit_stack_size);
1139 act->setShortcut(QKeySequence(shortcut_to_string(
1140 fc_shortcuts::sc()->get_shortcut(SC_STACK_SIZE))));
1141 connect(act, &QAction::triggered, this, &mr_menu::slot_stack_size);
1142
1143 // Select Menu
1144 main_menu = this->addMenu(_("Select"));
1145 act = main_menu->addAction(_("Single Unit (Unselect Others)"));
1146 act->setShortcut(QKeySequence(tr("shift+z")));
1147 menu_list.insert(STANDARD, act);
1148 connect(act, &QAction::triggered, this, &mr_menu::slot_select_one);
1149 act = main_menu->addAction(_("All On Tile"));
1150 act->setShortcut(QKeySequence(tr("v")));
1151 menu_list.insert(STANDARD, act);
1152 connect(act, &QAction::triggered, this, &mr_menu::slot_select_all_tile);
1153 main_menu->addSeparator();
1154 act = main_menu->addAction(_("Same Type on Tile"));
1155 act->setShortcut(QKeySequence(tr("shift+v")));
1156 menu_list.insert(STANDARD, act);
1157 connect(act, &QAction::triggered, this, &mr_menu::slot_select_same_tile);
1158 act = main_menu->addAction(_("Same Type on Continent"));
1159 act->setShortcut(QKeySequence(tr("shift+c")));
1160 menu_list.insert(STANDARD, act);
1161 connect(act, &QAction::triggered, this,
1162 &mr_menu::slot_select_same_continent);
1163 act = main_menu->addAction(_("Same Type Everywhere"));
1164 act->setShortcut(QKeySequence(tr("shift+x")));
1165 menu_list.insert(STANDARD, act);
1166 connect(act, &QAction::triggered, this,
1167 &mr_menu::slot_select_same_everywhere);
1168 main_menu->addSeparator();
1169 act = main_menu->addAction(_("Wait"));
1170 act->setShortcut(QKeySequence(shortcut_to_string(
1171 fc_shortcuts::sc()->get_shortcut(SC_WAIT))));
1172 menu_list.insert(STANDARD, act);
1173 connect(act, &QAction::triggered, this, &mr_menu::slot_wait);
1174 act = main_menu->addAction(_("Done"));
1175 act->setShortcut(QKeySequence(shortcut_to_string(
1176 fc_shortcuts::sc()->get_shortcut(SC_DONE_MOVING))));
1177 menu_list.insert(STANDARD, act);
1178 connect(act, &QAction::triggered, this, &mr_menu::slot_done_moving);
1179
1180 act = main_menu->addAction(_("Advanced unit selection"));
1181 act->setShortcut(QKeySequence(tr("ctrl+e")));
1182 menu_list.insert(NOT_4_OBS, act);
1183 connect(act, &QAction::triggered, this, &mr_menu::slot_unit_filter);
1184
1185 // Unit Menu
1186 main_menu = this->addMenu(_("Unit"));
1187 act = main_menu->addAction(_("Go to Tile"));
1188 act->setShortcut(QKeySequence(shortcut_to_string(
1189 fc_shortcuts::sc()->get_shortcut(SC_GOTO))));
1190 menu_list.insert(STANDARD, act);
1191 connect(act, &QAction::triggered, this, &mr_menu::slot_unit_goto);
1192
1193 // The goto and act sub menu is handled as a separate object.
1194 main_menu->addMenu(new go_act_menu(this));
1195
1196 act = main_menu->addAction(_("Go to Nearest City"));
1197 act->setShortcut(QKeySequence(tr("shift+g")));
1198 menu_list.insert(GOTO_CITY, act);
1199 connect(act, &QAction::triggered, this, &mr_menu::slot_return_to_city);
1200 act = main_menu->addAction(_("Go to/Airlift to City..."));
1201 act->setShortcut(QKeySequence(shortcut_to_string(
1202 fc_shortcuts::sc()->get_shortcut(SC_GOTOAIRLIFT))));
1203 menu_list.insert(AIRLIFT, act);
1204 connect(act, &QAction::triggered, this, &mr_menu::slot_airlift);
1205 main_menu->addSeparator();
1206 act = main_menu->addAction(_("Auto Explore"));
1207 menu_list.insert(EXPLORE, act);
1208 act->setShortcut(QKeySequence(shortcut_to_string(
1209 fc_shortcuts::sc()->get_shortcut(SC_AUTOEXPLORE))));
1210 connect(act, &QAction::triggered, this, &mr_menu::slot_unit_explore);
1211 act = main_menu->addAction(_("Patrol"));
1212 menu_list.insert(STANDARD, act);
1213 act->setEnabled(false);
1214 act->setShortcut(QKeySequence(shortcut_to_string(
1215 fc_shortcuts::sc()->get_shortcut(SC_PATROL))));
1216 connect(act, &QAction::triggered, this, &mr_menu::slot_patrol);
1217 main_menu->addSeparator();
1218 act = main_menu->addAction(_("Sentry"));
1219 act->setShortcut(QKeySequence(shortcut_to_string(
1220 fc_shortcuts::sc()->get_shortcut(SC_SENTRY))));
1221 menu_list.insert(SENTRY, act);
1222 connect(act, &QAction::triggered, this, &mr_menu::slot_unit_sentry);
1223 act = main_menu->addAction(_("Unsentry All On Tile"));
1224 act->setShortcut(QKeySequence(shortcut_to_string(
1225 fc_shortcuts::sc()->get_shortcut(SC_UNSENTRY_TILE))));
1226 menu_list.insert(WAKEUP, act);
1227 connect(act, &QAction::triggered, this, &mr_menu::slot_unsentry);
1228 main_menu->addSeparator();
1229 act = main_menu->addAction(_("Load"));
1230 act->setShortcut(QKeySequence(shortcut_to_string(
1231 fc_shortcuts::sc()->get_shortcut(SC_BOARD))));
1232 menu_list.insert(BOARD, act);
1233 connect(act, &QAction::triggered, this, &mr_menu::slot_board);
1234 act = main_menu->addAction(_("Unload"));
1235 act->setShortcut(QKeySequence(shortcut_to_string(
1236 fc_shortcuts::sc()->get_shortcut(SC_DEBOARD))));
1237 menu_list.insert(DEBOARD, act);
1238 connect(act, &QAction::triggered, this, &mr_menu::slot_deboard);
1239 act = main_menu->addAction(_("Unload All From Transporter"));
1240 act->setShortcut(QKeySequence(tr("shift+t")));
1241 menu_list.insert(TRANSPORTER, act);
1242 connect(act, &QAction::triggered, this, &mr_menu::slot_unload_all);
1243 main_menu->addSeparator();
1244
1245 // Defeat keyboard shortcut mnemonics
1246 act = main_menu->addAction(QString(action_id_name_translation(ACTION_HOME_CITY))
1247 .replace("&", "&&"));
1248 menu_list.insert(HOMECITY, act);
1249 act->setShortcut(QKeySequence(shortcut_to_string(
1250 fc_shortcuts::sc()->get_shortcut(SC_SETHOME))));
1251 connect(act, &QAction::triggered, this, &mr_menu::slot_set_home);
1252 act = main_menu->addAction(_("Upgrade"));
1253 act->setShortcut(QKeySequence(shortcut_to_string(
1254 fc_shortcuts::sc()->get_shortcut(SC_UPGRADE_UNIT))));
1255 menu_list.insert(UPGRADE, act);
1256 connect(act, &QAction::triggered, this, &mr_menu::slot_upgrade);
1257 act = main_menu->addAction(_("Convert"));
1258 act->setShortcut(QKeySequence(tr("shift+o")));
1259 menu_list.insert(CONVERT, act);
1260 connect(act, &QAction::triggered, this, &mr_menu::slot_convert);
1261 act = main_menu->addAction(_("Disband"));
1262 act->setShortcut(QKeySequence(tr("shift+d")));
1263 menu_list.insert(DISBAND, act);
1264 connect(act, &QAction::triggered, this, &mr_menu::slot_disband);
1265
1266 // Combat Menu
1267 main_menu = this->addMenu(_("Combat"));
1268 act = main_menu->addAction(_("Fortify Unit"));
1269 menu_list.insert(FORTIFY, act);
1270 act->setShortcut(QKeySequence(shortcut_to_string(
1271 fc_shortcuts::sc()->get_shortcut(SC_FORTIFY))));
1272 connect(act, &QAction::triggered, this, &mr_menu::slot_unit_fortify);
1273 act = main_menu->addAction(QString(Q_(terrain_control.gui_type_base0))
1274 .replace("&", "&&"));
1275 menu_list.insert(FORTRESS, act);
1276 act->setShortcut(QKeySequence(tr("shift+f")));
1277 connect(act, &QAction::triggered, this, &mr_menu::slot_unit_fortress);
1278 act = main_menu->addAction(QString(Q_(terrain_control.gui_type_base1))
1279 .replace("&", "&&"));
1280 menu_list.insert(AIRBASE, act);
1281 act->setShortcut(QKeySequence(tr("shift+e")));
1282 connect(act, &QAction::triggered, this, &mr_menu::slot_unit_airbase);
1283 bases_menu = main_menu->addMenu(_("Build Base"));
1284 main_menu->addSeparator();
1285 act = main_menu->addAction(_("Paradrop"));
1286 menu_list.insert(PARADROP, act);
1287 act->setShortcut(QKeySequence(shortcut_to_string(
1288 fc_shortcuts::sc()->get_shortcut(SC_PARADROP))));
1289 connect(act, &QAction::triggered, this, &mr_menu::slot_paradrop);
1290 act = main_menu->addAction(_("Pillage"));
1291 menu_list.insert(PILLAGE, act);
1292 act->setShortcut(QKeySequence(tr("shift+p")));
1293 connect(act, &QAction::triggered, this, &mr_menu::slot_pillage);
1294 // TRANS: Menu item to bring up the action selection dialog.
1295 act = main_menu->addAction(_("Do..."));
1296 menu_list.insert(ORDER_DIPLOMAT_DLG, act);
1297 act->setShortcut(QKeySequence(shortcut_to_string(
1298 fc_shortcuts::sc()->get_shortcut(SC_DO))));
1299 connect(act, &QAction::triggered, this, &mr_menu::slot_action);
1300
1301 // Work Menu
1302 main_menu = this->addMenu(_("Work"));
1303 act = main_menu->addAction(QString(action_id_name_translation(ACTION_FOUND_CITY))
1304 .replace("&", "&&"));
1305 act->setShortcut(QKeySequence(shortcut_to_string(
1306 fc_shortcuts::sc()->get_shortcut(SC_BUILDCITY))));
1307 menu_list.insert(BUILD, act);
1308 connect(act, &QAction::triggered, this, &mr_menu::slot_build_city);
1309 act = main_menu->addAction(_("Auto Worker"));
1310 act->setShortcut(QKeySequence(shortcut_to_string(
1311 fc_shortcuts::sc()->get_shortcut(SC_AUTOMATE))));
1312 menu_list.insert(AUTOWORKER, act);
1313 connect(act, &QAction::triggered, this, &mr_menu::slot_auto_worker);
1314 main_menu->addSeparator();
1315 act = main_menu->addAction(_("Build Road"));
1316 menu_list.insert(ROAD, act);
1317 act->setShortcut(QKeySequence(shortcut_to_string(
1318 fc_shortcuts::sc()->get_shortcut(SC_BUILDROAD))));
1319 connect(act, &QAction::triggered, this, &mr_menu::slot_build_road);
1320 roads_menu = main_menu->addMenu(_("Build Path"));
1321 act = main_menu->addAction(_("Build Irrigation"));
1322 act->setShortcut(QKeySequence(shortcut_to_string(
1323 fc_shortcuts::sc()->get_shortcut(SC_BUILDIRRIGATION))));
1324 menu_list.insert(IRRIGATION, act);
1325 connect(act, &QAction::triggered, this, &mr_menu::slot_build_irrigation);
1326 act = main_menu->addAction(_("Cultivate"));
1327 act->setShortcut(QKeySequence(shortcut_to_string(
1328 fc_shortcuts::sc()->get_shortcut(SC_CULTIVATE))));
1329 menu_list.insert(CULTIVATE, act);
1330 connect(act, &QAction::triggered, this, &mr_menu::slot_cultivate);
1331 act = main_menu->addAction(_("Build Mine"));
1332 act->setShortcut(QKeySequence(shortcut_to_string(
1333 fc_shortcuts::sc()->get_shortcut(SC_BUILDMINE))));
1334 menu_list.insert(MINE, act);
1335 connect(act, &QAction::triggered, this, &mr_menu::slot_build_mine);
1336 act = main_menu->addAction(_("Plant"));
1337 act->setShortcut(QKeySequence(shortcut_to_string(
1338 fc_shortcuts::sc()->get_shortcut(SC_PLANT))));
1339 menu_list.insert(PLANT, act);
1340 connect(act, &QAction::triggered, this, &mr_menu::slot_plant);
1341 main_menu->addSeparator();
1342 act = main_menu->addAction(_("Connect With Road"));
1343 act->setShortcut(QKeySequence(tr("ctrl+r")));
1344 menu_list.insert(CONNECT_ROAD, act);
1345 connect(act, &QAction::triggered, this, &mr_menu::slot_conn_road);
1346 act = main_menu->addAction(_("Connect With Railroad"));
1347 menu_list.insert(CONNECT_RAIL, act);
1348 act->setShortcut(QKeySequence(tr("ctrl+l")));
1349 connect(act, &QAction::triggered, this, &mr_menu::slot_conn_rail);
1350 act = main_menu->addAction(_("Connect With Maglev"));
1351 menu_list.insert(CONNECT_MAGLEV, act);
1352 act->setShortcut(QKeySequence(tr("ctrl+m")));
1353 connect(act, &QAction::triggered, this, &mr_menu::slot_conn_maglev);
1354 act = main_menu->addAction(_("Connect With Irrigation"));
1355 menu_list.insert(CONNECT_IRRIGATION, act);
1356 act->setShortcut(QKeySequence(tr("ctrl+i")));
1357 connect(act, &QAction::triggered, this, &mr_menu::slot_conn_irrigation);
1358 main_menu->addSeparator();
1359 act = main_menu->addAction(_("Transform Terrain"));
1360 menu_list.insert(TRANSFORM, act);
1361 act->setShortcut(QKeySequence(shortcut_to_string(
1362 fc_shortcuts::sc()->get_shortcut(SC_TRANSFORM))));
1363 connect(act, &QAction::triggered, this, &mr_menu::slot_transform);
1364 act = main_menu->addAction(_("Clean"));
1365 menu_list.insert(CLEAN, act);
1366 act->setShortcut(QKeySequence(shortcut_to_string(
1367 fc_shortcuts::sc()->get_shortcut(SC_CLEAN))));
1368 connect(act, &QAction::triggered, this, &mr_menu::slot_clean);
1369 act = main_menu->addAction(QString(action_id_name_translation(ACTION_HELP_WONDER))
1370 .replace("&", "&&"));
1371 act->setShortcut(QKeySequence(tr("b")));
1372 menu_list.insert(BUILD_WONDER, act);
1373 connect(act, &QAction::triggered, this, &mr_menu::slot_build_city);
1374 act = main_menu->addAction(QString(action_id_name_translation(ACTION_TRADE_ROUTE))
1375 .replace("&", "&&"));
1376 act->setShortcut(QKeySequence(tr("r")));
1377 menu_list.insert(ORDER_TRADE_ROUTE, act);
1378 connect(act, &QAction::triggered, this, &mr_menu::slot_build_road);
1379
1380 // Multiplayer Menu
1381 multiplayer_menu = this->addMenu(_("Multiplayer"));
1382 act = multiplayer_menu->addAction(_("Delayed Goto"));
1383 act->setShortcut(QKeySequence(tr("z")));
1384 connect(act, &QAction::triggered, this, &mr_menu::slot_delayed_goto);
1385 act = multiplayer_menu->addAction(_("Delayed Orders Execute"));
1386 act->setShortcut(QKeySequence(tr("ctrl+z")));
1387 connect(act, &QAction::triggered, this, &mr_menu::slot_execute_orders);
1388 act = multiplayer_menu->addAction(_("Clear Orders"));
1389 act->setShortcut(QKeySequence(tr("ctrl+shift+c")));
1390 connect(act, &QAction::triggered, this, &mr_menu::slot_orders_clear);
1391 act = multiplayer_menu->addAction(_("Add all cities to trade planning"));
1392 connect(act, &QAction::triggered, this, &mr_menu::slot_trade_add_all);
1393 act = multiplayer_menu->addAction(_("Calculate trade planning"));
1394 connect(act, &QAction::triggered, this, &mr_menu::slot_calculate);
1395 act = multiplayer_menu->addAction(_("Add/Remove City"));
1396 act->setShortcut(QKeySequence(tr("ctrl+t")));
1397 connect(act, &QAction::triggered, this, &mr_menu::slot_trade_city);
1398 act = multiplayer_menu->addAction(_("Clear Trade Planning"));
1399 connect(act, &QAction::triggered, this, &mr_menu::slot_clear_trade);
1400 act = multiplayer_menu->addAction(_("Automatic caravan"));
1401 menu_list.insert(AUTOTRADEROUTE, act);
1402 connect(act, &QAction::triggered, this, &mr_menu::slot_autocaravan);
1403 act->setShortcut(QKeySequence(tr("ctrl+j")));
1404 act = multiplayer_menu->addAction(_("Set/Unset rally point"));
1405 act->setShortcut(QKeySequence(tr("shift+s")));
1406 connect(act, &QAction::triggered, this, &mr_menu::slot_rally);
1407 act = multiplayer_menu->addAction(_("Quick Airlift"));
1408 act->setShortcut(QKeySequence(tr("ctrl+y")));
1409 connect(act, &QAction::triggered, this, &mr_menu::slot_quickairlift);
1410 airlift_type = new QActionGroup(this);
1411 airlift_menu = multiplayer_menu->addMenu(_("Unit type for quickairlifting"));
1412
1413 // Default diplo
1414 action_vs_city = new QActionGroup(this);
1415 action_vs_unit = new QActionGroup(this);
1416 action_unit_menu = multiplayer_menu->addMenu(_("Default action vs unit"));
1417
1418 act = action_unit_menu->addAction(_("Ask"));
1419 act->setCheckable(true);
1420 act->setChecked(true);
1421 act->setData(-1);
1422 action_vs_unit->addAction(act);
1423 connect(act, &QAction::triggered, this, &mr_menu::slot_action_vs_unit);
1424
1425 act = action_unit_menu->addAction(_("Bribe"));
1426 act->setCheckable(true);
1427 act->setChecked(false);
1428 act->setData(ACTION_SPY_BRIBE_UNIT);
1429 action_vs_unit->addAction(act);
1430 connect(act, &QAction::triggered, this, &mr_menu::slot_action_vs_unit);
1431
1432 act = action_unit_menu->addAction(_("Sabotage"));
1433 act->setCheckable(true);
1434 act->setChecked(false);
1435 act->setData(ACTION_SPY_SABOTAGE_UNIT);
1436 action_vs_unit->addAction(act);
1437 connect(act, &QAction::triggered, this, &mr_menu::slot_action_vs_unit);
1438
1439 act = action_unit_menu->addAction(_("Sabotage Unit Escape"));
1440 act->setCheckable(true);
1441 act->setChecked(false);
1442 act->setData(ACTION_SPY_SABOTAGE_UNIT_ESC);
1443 action_vs_unit->addAction(act);
1444 connect(act, &QAction::triggered, this, &mr_menu::slot_action_vs_unit);
1445
1446 action_city_menu = multiplayer_menu->addMenu(_("Default action vs city"));
1447 act = action_city_menu->addAction(_("Ask"));
1448 act->setCheckable(true);
1449 act->setChecked(true);
1450 act->setData(-1);
1451 action_vs_city->addAction(act);
1452 connect(act, &QAction::triggered, this, &mr_menu::slot_action_vs_city);
1453
1454 act = action_city_menu->addAction(_("Investigate city"));
1455 act->setCheckable(true);
1456 act->setChecked(false);
1457 act->setData(ACTION_SPY_INVESTIGATE_CITY);
1458 action_vs_city->addAction(act);
1459 connect(act, &QAction::triggered, this, &mr_menu::slot_action_vs_city);
1460
1461 act = action_city_menu->addAction(_("Investigate city (spends the unit)"));
1462 act->setCheckable(true);
1463 act->setChecked(false);
1464 act->setData(ACTION_INV_CITY_SPEND);
1465 action_vs_city->addAction(act);
1466 connect(act, &QAction::triggered, this, &mr_menu::slot_action_vs_city);
1467
1468 act = action_city_menu->addAction(_("Establish embassy"));
1469 act->setCheckable(true);
1470 act->setChecked(false);
1471 act->setData(ACTION_ESTABLISH_EMBASSY);
1472 action_vs_city->addAction(act);
1473 connect(act, &QAction::triggered, this, &mr_menu::slot_action_vs_city);
1474
1475 act = action_city_menu->addAction(_("Become Ambassador"));
1476 act->setCheckable(true);
1477 act->setChecked(false);
1478 act->setData(ACTION_ESTABLISH_EMBASSY_STAY);
1479 action_vs_city->addAction(act);
1480 connect(act, &QAction::triggered, this, &mr_menu::slot_action_vs_city);
1481
1482 act = action_city_menu->addAction(_("Steal technology"));
1483 act->setCheckable(true);
1484 act->setChecked(false);
1485 act->setData(ACTION_SPY_STEAL_TECH);
1486 action_vs_city->addAction(act);
1487 connect(act, &QAction::triggered, this, &mr_menu::slot_action_vs_city);
1488
1489 act = action_city_menu->addAction(_("Steal technology and escape"));
1490 act->setCheckable(true);
1491 act->setChecked(false);
1492 act->setData(ACTION_SPY_STEAL_TECH_ESC);
1493 action_vs_city->addAction(act);
1494 connect(act, &QAction::triggered, this, &mr_menu::slot_action_vs_city);
1495
1496 act = action_city_menu->addAction(_("Incite a revolt"));
1497 act->setCheckable(true);
1498 act->setChecked(false);
1499 act->setData(ACTION_SPY_INCITE_CITY);
1500 action_vs_city->addAction(act);
1501 connect(act, &QAction::triggered, this, &mr_menu::slot_action_vs_city);
1502
1503 act = action_city_menu->addAction(_("Incite a Revolt and Escape"));
1504 act->setCheckable(true);
1505 act->setChecked(false);
1506 act->setData(ACTION_SPY_INCITE_CITY_ESC);
1507 action_vs_city->addAction(act);
1508 connect(act, &QAction::triggered, this, &mr_menu::slot_action_vs_city);
1509
1510 act = action_city_menu->addAction(_("Poison city"));
1511 act->setCheckable(true);
1512 act->setChecked(false);
1513 act->setData(ACTION_SPY_POISON);
1514 action_vs_city->addAction(act);
1515 connect(act, &QAction::triggered, this, &mr_menu::slot_action_vs_city);
1516
1517 act = action_city_menu->addAction(_("Poison City Escape"));
1518 act->setCheckable(true);
1519 act->setChecked(false);
1520 act->setData(ACTION_SPY_POISON_ESC);
1521 action_vs_city->addAction(act);
1522 connect(act, &QAction::triggered, this, &mr_menu::slot_action_vs_city);
1523
1524 // Civilization menu
1525 main_menu = this->addMenu(_("Civilization"));
1526 act = main_menu->addAction(_("Tax Rates..."));
1527 menu_list.insert(NOT_4_OBS, act);
1528 connect(act, &QAction::triggered, this, &mr_menu::slot_popup_tax_rates);
1529 main_menu->addSeparator();
1530
1531 act = main_menu->addAction(_("Policies..."));
1532 menu_list.insert(MULTIPLIERS, act);
1533 connect(act, &QAction::triggered, this, &mr_menu::slot_popup_mult_rates);
1534 main_menu->addSeparator();
1535
1536 main_menu->addMenu(new class gov_menu(this));
1537 main_menu->addSeparator();
1538
1539 act = main_menu->addAction(Q_("?noun:View"));
1540 act->setShortcut(QKeySequence(tr("F1")));
1541 connect(act, &QAction::triggered, this, &mr_menu::slot_show_map);
1542
1543 act = main_menu->addAction(_("Units"));
1544 act->setShortcut(QKeySequence(tr("F2")));
1545 connect(act, &QAction::triggered, this, &mr_menu::slot_show_units_report);
1546
1547 act = main_menu->addAction(_("Nations"));
1548 act->setShortcut(QKeySequence(tr("F3")));
1549 connect(act, &QAction::triggered, this, &mr_menu::slot_show_nations);
1550
1551 act = main_menu->addAction(_("Cities"));
1552 act->setShortcut(QKeySequence(tr("F4")));
1553 connect(act, &QAction::triggered, this, &mr_menu::slot_show_cities);
1554
1555 act = main_menu->addAction(_("Economy"));
1556 act->setShortcut(QKeySequence(tr("F5")));
1557 connect(act, &QAction::triggered, this, &mr_menu::slot_show_eco_report);
1558
1559 act = main_menu->addAction(_("Research"));
1560 act->setShortcut(QKeySequence(tr("F6")));
1561 connect(act, &QAction::triggered, this, &mr_menu::slot_show_research_tab);
1562
1563 act = main_menu->addAction(_("Wonders of the World"));
1564 act->setShortcut(QKeySequence(tr("F7")));
1565 connect(act, &QAction::triggered, this, &mr_menu::slot_traveler);
1566
1567 act = main_menu->addAction(_("Top Cities"));
1568 act->setShortcut(QKeySequence(tr("F8")));
1569 menu_list.insert(TOP_CITIES, act);
1570 connect(act, &QAction::triggered, this, &mr_menu::slot_top_cities);
1571
1572 act = main_menu->addAction(_("Demographics"));
1573 act->setShortcut(QKeySequence(tr("F11")));
1574 connect(act, &QAction::triggered, this, &mr_menu::slot_demographics);
1575
1576 act = main_menu->addAction(_("Spaceship"));
1577 act->setShortcut(QKeySequence(tr("F12")));
1578 connect(act, &QAction::triggered, this, &mr_menu::slot_spaceship);
1579
1580 act = main_menu->addAction(_("Achievements"));
1581 connect(act, &QAction::triggered, this, &mr_menu::slot_achievements);
1582
1583 act = main_menu->addAction(_("Endgame report"));
1584 menu_list.insert(ENDGAME, act);
1585 connect(act, &QAction::triggered, this, &mr_menu::slot_endgame);
1586
1587 // Battle Groups Menu
1588 main_menu = this->addMenu(_("Battle Groups"));
1589
1590 act = main_menu->addAction(_("Select Battle Group 1"));
1591 act->setShortcut(QKeySequence(tr("Shift+F1")));
1592 connect(act, &QAction::triggered, this, &mr_menu::slot_bg1select);
1593
1594 act = main_menu->addAction(_("Assign Battle Group 1"));
1595 act->setShortcut(QKeySequence(tr("Ctrl+F1")));
1596 connect(act, &QAction::triggered, this, &mr_menu::slot_bg1assign);
1597
1598 act = main_menu->addAction(_("Append to Battle Group 1"));
1599 act->setShortcut(QKeySequence(tr("Ctrl+Shift+F1")));
1600 connect(act, &QAction::triggered, this, &mr_menu::slot_bg1append);
1601
1602 act = main_menu->addAction(_("Select Battle Group 2"));
1603 act->setShortcut(QKeySequence(tr("Shift+F2")));
1604 connect(act, &QAction::triggered, this, &mr_menu::slot_bg2select);
1605
1606 act = main_menu->addAction(_("Assign Battle Group 2"));
1607 act->setShortcut(QKeySequence(tr("Ctrl+F2")));
1608 connect(act, &QAction::triggered, this, &mr_menu::slot_bg2assign);
1609
1610 act = main_menu->addAction(_("Append to Battle Group 2"));
1611 act->setShortcut(QKeySequence(tr("Ctrl+Shift+F2")));
1612 connect(act, &QAction::triggered, this, &mr_menu::slot_bg2append);
1613
1614 act = main_menu->addAction(_("Select Battle Group 3"));
1615 act->setShortcut(QKeySequence(tr("Shift+F3")));
1616 connect(act, &QAction::triggered, this, &mr_menu::slot_bg3select);
1617
1618 act = main_menu->addAction(_("Assign Battle Group 3"));
1619 act->setShortcut(QKeySequence(tr("Ctrl+F3")));
1620 connect(act, &QAction::triggered, this, &mr_menu::slot_bg3assign);
1621
1622 act = main_menu->addAction(_("Append to Battle Group 3"));
1623 act->setShortcut(QKeySequence(tr("Ctrl+Shift+F3")));
1624 connect(act, &QAction::triggered, this, &mr_menu::slot_bg3append);
1625
1626 act = main_menu->addAction(_("Select Battle Group 4"));
1627 act->setShortcut(QKeySequence(tr("Shift+F4")));
1628 connect(act, &QAction::triggered, this, &mr_menu::slot_bg4select);
1629
1630 act = main_menu->addAction(_("Assign Battle Group 4"));
1631 act->setShortcut(QKeySequence(tr("Ctrl+F4")));
1632 connect(act, &QAction::triggered, this, &mr_menu::slot_bg4assign);
1633
1634 act = main_menu->addAction(_("Append to Battle Group 4"));
1635 act->setShortcut(QKeySequence(tr("Ctrl+Shift+F4")));
1636 connect(act, &QAction::triggered, this, &mr_menu::slot_bg4append);
1637
1638 // Help Menu
1639 main_menu = this->addMenu(_("Help"));
1640
1641 act = main_menu->addAction(Q_(HELP_OVERVIEW_ITEM));
1642 QObject::connect(act, &QAction::triggered, [this]() {
1643 slot_help(HELP_OVERVIEW_ITEM);
1644 });
1645
1646 act = main_menu->addAction(Q_(HELP_PLAYING_ITEM));
1647 QObject::connect(act, &QAction::triggered, [this]() {
1648 slot_help(HELP_PLAYING_ITEM);
1649 });
1650
1651 act = main_menu->addAction(Q_(HELP_TERRAIN_ITEM));
1652 QObject::connect(act, &QAction::triggered, [this]() {
1653 slot_help(HELP_TERRAIN_ITEM);
1654 });
1655
1656 act = main_menu->addAction(Q_(HELP_ECONOMY_ITEM));
1657 QObject::connect(act, &QAction::triggered, [this]() {
1658 slot_help(HELP_ECONOMY_ITEM);
1659 });
1660
1661 act = main_menu->addAction(Q_(HELP_CITIES_ITEM));
1662 QObject::connect(act, &QAction::triggered, [this]() {
1663 slot_help(HELP_CITIES_ITEM);
1664 });
1665
1666 act = main_menu->addAction(Q_(HELP_IMPROVEMENTS_ITEM));
1667 QObject::connect(act, &QAction::triggered, [this]() {
1668 slot_help(HELP_IMPROVEMENTS_ITEM);
1669 });
1670
1671 act = main_menu->addAction(Q_(HELP_WONDERS_ITEM));
1672 QObject::connect(act, &QAction::triggered, [this]() {
1673 slot_help(HELP_WONDERS_ITEM);
1674 });
1675
1676 act = main_menu->addAction(Q_(HELP_UNITS_ITEM));
1677 QObject::connect(act, &QAction::triggered, [this]() {
1678 slot_help(HELP_UNITS_ITEM);
1679 });
1680
1681 act = main_menu->addAction(Q_(HELP_COMBAT_ITEM));
1682 QObject::connect(act, &QAction::triggered, [this]() {
1683 slot_help(HELP_COMBAT_ITEM);
1684 });
1685
1686 act = main_menu->addAction(Q_(HELP_ZOC_ITEM));
1687 QObject::connect(act, &QAction::triggered, [this]() {
1688 slot_help(HELP_ZOC_ITEM);
1689 });
1690
1691 act = main_menu->addAction(Q_(HELP_GOVERNMENT_ITEM));
1692 QObject::connect(act, &QAction::triggered, [this]() {
1693 slot_help(HELP_GOVERNMENT_ITEM);
1694 });
1695
1696 act = main_menu->addAction(Q_(HELP_ECONOMY_ITEM));
1697 QObject::connect(act, &QAction::triggered, [this]() {
1698 slot_help(HELP_ECONOMY_ITEM);
1699 });
1700
1701 act = main_menu->addAction(Q_(HELP_DIPLOMACY_ITEM));
1702 QObject::connect(act, &QAction::triggered, [this]() {
1703 slot_help(HELP_DIPLOMACY_ITEM);
1704 });
1705
1706 act = main_menu->addAction(Q_(HELP_TECHS_ITEM));
1707 QObject::connect(act, &QAction::triggered, [this]() {
1708 slot_help(HELP_TECHS_ITEM);
1709 });
1710
1711 act = main_menu->addAction(Q_(HELP_SPACE_RACE_ITEM));
1712 QObject::connect(act, &QAction::triggered, [this]() {
1713 slot_help(HELP_SPACE_RACE_ITEM);
1714 });
1715
1716 act = main_menu->addAction(Q_(HELP_IMPROVEMENTS_ITEM));
1717 QObject::connect(act, &QAction::triggered, [this]() {
1718 slot_help(HELP_IMPROVEMENTS_ITEM);
1719 });
1720
1721 act = main_menu->addAction(Q_(HELP_RULESET_ITEM));
1722 QObject::connect(act, &QAction::triggered, [this]() {
1723 slot_help(HELP_RULESET_ITEM);
1724 });
1725
1726 act = main_menu->addAction(Q_(HELP_TILESET_ITEM));
1727 QObject::connect(act, &QAction::triggered, [this]() {
1728 slot_help(HELP_TILESET_ITEM);
1729 });
1730
1731 act = main_menu->addAction(Q_(HELP_MUSICSET_ITEM));
1732 QObject::connect(act, &QAction::triggered, [this]() {
1733 slot_help(HELP_MUSICSET_ITEM);
1734 });
1735
1736 act = main_menu->addAction(Q_(HELP_NATIONS_ITEM));
1737 QObject::connect(act, &QAction::triggered, [this]() {
1738 slot_help(HELP_NATIONS_ITEM);
1739 });
1740
1741 main_menu->addSeparator();
1742
1743 act = main_menu->addAction(Q_(HELP_CONNECTING_ITEM));
1744 QObject::connect(act, &QAction::triggered, [this]() {
1745 slot_help(HELP_CONNECTING_ITEM);
1746 });
1747
1748 act = main_menu->addAction(Q_(HELP_CONTROLS_ITEM));
1749 QObject::connect(act, &QAction::triggered, [this]() {
1750 slot_help(HELP_CONTROLS_ITEM);
1751 });
1752
1753 act = main_menu->addAction(Q_(HELP_CMA_ITEM));
1754 QObject::connect(act, &QAction::triggered, [this]() {
1755 slot_help(HELP_CMA_ITEM);
1756 });
1757
1758 act = main_menu->addAction(Q_(HELP_CHATLINE_ITEM));
1759 QObject::connect(act, &QAction::triggered, [this]() {
1760 slot_help(HELP_CHATLINE_ITEM);
1761 });
1762
1763 act = main_menu->addAction(Q_(HELP_WORKLIST_EDITOR_ITEM));
1764 QObject::connect(act, &QAction::triggered, [this]() {
1765 slot_help(HELP_WORKLIST_EDITOR_ITEM);
1766 });
1767
1768 main_menu->addSeparator();
1769
1770 act = main_menu->addAction(Q_(HELP_LANGUAGES_ITEM));
1771 QObject::connect(act, &QAction::triggered, [this]() {
1772 slot_help(HELP_LANGUAGES_ITEM);
1773 });
1774
1775 act = main_menu->addAction(Q_(HELP_COPYING_ITEM));
1776 QObject::connect(act, &QAction::triggered, [this]() {
1777 slot_help(HELP_COPYING_ITEM);
1778 });
1779
1780 act = main_menu->addAction(Q_(HELP_ABOUT_ITEM));
1781 QObject::connect(act, &QAction::triggered, [this]() {
1782 slot_help(HELP_ABOUT_ITEM);
1783 });
1784
1785 menus = this->findChildren<QMenu*>();
1786 for (i = 0; i < menus.count(); i++) {
1787 menus[i]->setAttribute(Qt::WA_TranslucentBackground);
1788 }
1789
1790 this->setVisible(false);
1791}
1792
1793/**********************************************************************/
1796 void mr_menu::set_tile_for_order(tile *ptile)
1797{
1798 for (int i = 0; i < units_list.nr_units; i++) {
1799 units_list.unit_list.at(units_list.unit_list.count() - i -1)->ptile = ptile;
1800 }
1801}
1802
1803/**********************************************************************/
1808 bool mr_menu::execute_shortcut_inner(const QMenu *m, QKeySequence seq)
1809{
1810 foreach (QAction *a, m->actions()) {
1811 if (a->shortcut() == seq && a->isEnabled()) {
1812 a->activate(QAction::Trigger);
1813 return TRUE;
1814 }
1815 }
1816
1817 return FALSE;
1818}
1819
1820/**********************************************************************/
1823 void mr_menu::execute_shortcut(int sid)
1824{
1825 QList<QMenu*> menus;
1826 QKeySequence seq;
1827 fc_shortcut *fcs;
1828
1829 if (sid == SC_GOTO) {
1830 gui()->mapview_wdg->menu_click = true;
1831 slot_unit_goto();
1832 return;
1833 }
1834 fcs = fc_shortcuts::sc()->get_shortcut(static_cast< shortcut_id>(sid));
1835 seq = QKeySequence(shortcut_to_string(fcs));
1836
1837 menus = findChildren<QMenu*>();
1838 foreach (const QMenu *m, menus) {
1839 if (execute_shortcut_inner(m, seq)) {
1840 return;
1841 }
1842 }
1843}
1844
1845/**********************************************************************/
1850 bool mr_menu::shortcut_exist_inner(const QMenu *m, QKeySequence seq,
1851 fc_shortcut *fcs, QString *ret)
1852{
1853 foreach (QAction *a, m->actions()) {
1854 if (a->shortcut() == seq && fcs->mouse == Qt::AllButtons) {
1855 *ret = a->text();
1856
1857 return TRUE;
1858 }
1859 }
1860
1861 return FALSE;
1862}
1863
1864/**********************************************************************/
1867 QString mr_menu::shortcut_exist(fc_shortcut *fcs)
1868{
1869 QList<QMenu*> menus;
1870 QKeySequence seq;
1871
1872 seq = QKeySequence(shortcut_to_string(fcs));
1873 menus = findChildren<QMenu *>();
1874 foreach (const QMenu *m, menus) {
1875 QString ret;
1876
1877 if (shortcut_exist_inner(m, seq, fcs, &ret)) {
1878 return ret;
1879 }
1880 }
1881
1882 return QString();
1883}
1884
1885/**********************************************************************/
1890 bool mr_menu::shortcut_2_menustring_inner(const QMenu *m, QKeySequence seq,
1891 QString *ret)
1892{
1893 foreach (QAction *a, m->actions()) {
1894 if (a->shortcut() == seq) {
1895 *ret = a->text() + " ("
1896 + a->shortcut().toString(QKeySequence::NativeText) + ")";
1897
1898 return TRUE;
1899 }
1900 }
1901
1902 return FALSE;
1903}
1904
1905/**********************************************************************/
1908 QString mr_menu::shortcut_2_menustring(int sid)
1909{
1910 QList<QMenu *> menus;
1911 QKeySequence seq;
1912 fc_shortcut *fcs;
1913
1914 fcs = fc_shortcuts::sc()->get_shortcut(static_cast< shortcut_id>(sid));
1915 seq = QKeySequence(shortcut_to_string(fcs));
1916
1917 menus = findChildren<QMenu *>();
1918 foreach (const QMenu *m, menus) {
1919 QString ret;
1920
1921 if (shortcut_2_menustring_inner(m, seq, &ret)) {
1922 return ret;
1923 }
1924 }
1925
1926 return QString();
1927}
1928
1929/**********************************************************************/
1932 void mr_menu::update_airlift_menu()
1933{
1934 Unit_type_id utype_id;
1935 QAction *act;
1936 struct player *pplayer;
1937
1938 airlift_menu->clear();
1939 if (client_is_observer()) {
1940 return;
1941 }
1942
1943 pplayer = client_player();
1944 unit_type_iterate(utype) {
1945 utype_id = utype_index(utype);
1946
1947 if (!can_player_build_unit_now(pplayer, utype)
1948 || !utype_can_do_action(utype, ACTION_AIRLIFT)) {
1949 continue;
1950 }
1951 if (!can_player_build_unit_now(pplayer, utype)
1952 && !has_player_unit_type(utype_id)) {
1953 continue;
1954 }
1955 // Defeat keyboard shortcut mnemonics
1956 act = airlift_menu->addAction(QString(utype_name_translation(utype))
1957 .replace("&", "&&"));
1958 act->setCheckable(true);
1959 act->setData(utype_id);
1960 if (airlift_type_id == utype_id) {
1961 act->setChecked(true);
1962 }
1963 connect(act, &QAction::triggered, this, &mr_menu::slot_quickairlift_set);
1964 airlift_type->addAction(act);
1965 } unit_type_iterate_end;
1966}
1967
1968/****************************************************************************
1969 Updates "build path" menu
1970****************************************************************************/
1971 void mr_menu::update_roads_menu()
1972{
1973 QAction *act;
1974 struct unit_list *punits = nullptr;
1975 bool enabled = false;
1976
1977 foreach(act, roads_menu->actions()) {
1978 removeAction(act);
1979 act->deleteLater();
1980 }
1981 roads_menu->clear();
1982 roads_menu->setDisabled(true);
1983 if (client_is_observer()) {
1984 return;
1985 }
1986
1987 punits = get_units_in_focus();
1988 extra_type_by_cause_iterate(EC_ROAD, pextra) {
1989 if (pextra->buildable) {
1990 int road_id;
1991
1992 // Defeat keyboard shortcut mnemonics
1993 act = roads_menu->addAction(QString(extra_name_translation(pextra))
1994 .replace("&", "&&"));
1995 road_id = pextra->id;
1996 act->setData(road_id);
1997 QObject::connect(act, &QAction::triggered, [this,road_id]() {
1998 slot_build_path(road_id);
1999 });
2000 if (can_units_do_activity_targeted_client(punits,
2001 ACTIVITY_GEN_ROAD, pextra)) {
2002 act->setEnabled(true);
2003 enabled = true;
2004 } else {
2005 act->setDisabled(true);
2006 }
2007 }
2008 } extra_type_by_cause_iterate_end;
2009
2010 if (enabled) {
2011 roads_menu->setEnabled(true);
2012 }
2013}
2014
2015/****************************************************************************
2016 Updates "build bases" menu
2017****************************************************************************/
2018 void mr_menu::update_bases_menu()
2019{
2020 QAction *act;
2021 struct unit_list *punits = nullptr;
2022 bool enabled = false;
2023
2024 foreach(act, bases_menu->actions()) {
2025 removeAction(act);
2026 act->deleteLater();
2027 }
2028 bases_menu->clear();
2029 bases_menu->setDisabled(true);
2030
2031 if (client_is_observer()) {
2032 return;
2033 }
2034
2035 punits = get_units_in_focus();
2036 extra_type_by_cause_iterate(EC_BASE, pextra) {
2037 if (pextra->buildable) {
2038 int base_id;
2039
2040 // Defeat keyboard shortcut mnemonics
2041 act = bases_menu->addAction(QString(extra_name_translation(pextra))
2042 .replace("&", "&&"));
2043 base_id = pextra->id;
2044 act->setData(base_id);
2045 QObject::connect(act, &QAction::triggered, [this,base_id]() {
2046 slot_build_base(base_id);
2047 });
2048 if (can_units_do_activity_targeted_client(punits, ACTIVITY_BASE, pextra)) {
2049 act->setEnabled(true);
2050 enabled = true;
2051 } else {
2052 act->setDisabled(true);
2053 }
2054 }
2055 } extra_type_by_cause_iterate_end;
2056
2057 if (enabled) {
2058 bases_menu->setEnabled(true);
2059 }
2060}
2061
2062/**********************************************************************/
2065 void mr_menu::menus_sensitive()
2066{
2067 QList <QAction * >values;
2068 QList <munit > keys;
2069 QMultiHash <munit, QAction *>::iterator i;
2070 struct unit_list *punits = nullptr;
2071 struct road_type *proad;
2072 struct extra_type *tgt;
2073 bool any_cities = false;
2074 bool city_on_tile = false;
2075 bool units_all_same_tile = true;
2076 const struct tile *ptile = nullptr;
2077 const struct unit_type *ptype = nullptr;
2078
2079 players_iterate(pplayer) {
2080 if (city_list_size(pplayer->cities)) {
2081 any_cities = true;
2082 break;
2083 }
2084 } players_iterate_end;
2085
2086 // Disable first all sensitive menus
2087 foreach(QAction *a, menu_list) {
2088 a->setEnabled(false);
2089 }
2090
2091 if (client_is_observer()) {
2092 multiplayer_menu->setDisabled(true);
2093 } else {
2094 multiplayer_menu->setDisabled(false);
2095 }
2096
2097 // Non unit menus
2098 keys = menu_list.keys();
2099 foreach (munit key, keys) {
2100 i = menu_list.find(key);
2101 while (i != menu_list.end() && i.key() == key) {
2102 switch (key) {
2103 case SAVE:
2104 if (can_client_access_hack() && C_S_RUNNING <= client_state()) {
2105 i.value()->setEnabled(true);
2106 }
2107 break;
2108 case NOT_4_OBS:
2109 if (!client_is_observer()) {
2110 i.value()->setEnabled(true);
2111 }
2112 break;
2113 case MULTIPLIERS:
2114 if (!client_is_observer() && multiplier_count() > 0) {
2115 i.value()->setEnabled(true);
2116 i.value()->setVisible(true);
2117 } else {
2118 i.value()->setVisible(false);
2119 }
2120 break;
2121 case ENDGAME:
2122 if (gui()->is_repo_dlg_open("END")) {
2123 i.value()->setEnabled(true);
2124 i.value()->setVisible(true);
2125 } else {
2126 i.value()->setVisible(false);
2127 }
2128 break;
2129 case TOP_CITIES:
2130 i.value()->setEnabled(game.info.top_cities_count > 0);
2131 if (game.info.top_cities_count > 0) {
2132 i.value()->setText(QString(PL_("Top %1 City", "Top %1 Cities",
2133 game.info.top_cities_count))
2134 .arg(game.info.top_cities_count));
2135 } else {
2136 i.value()->setText(QString(_("Top Cities")));
2137 }
2138 break;
2139 default:
2140 break;
2141 }
2142 i++;
2143 }
2144 }
2145
2146 if (!can_client_issue_orders() || get_num_units_in_focus() == 0) {
2147 return;
2148 }
2149
2150 punits = get_units_in_focus();
2151 unit_list_iterate(punits, punit) {
2152 if (tile_city(unit_tile(punit))) {
2153 city_on_tile = true;
2154 break;
2155 }
2156 } unit_list_iterate_end;
2157
2158 unit_list_iterate(punits, punit) {
2159 const struct unit_type *ntype;
2160
2161 fc_assert((ptile == nullptr) == (ptype == nullptr));
2162
2163 ntype = unit_type_get(punit);
2164
2165 // 'ntype == ptype' is correct check even when ptype is still nullptr
2166 if (ptile != nullptr && ntype == ptype && unit_tile(punit) != ptile) {
2167 units_all_same_tile = false;
2168 }
2169
2170 if (ptype == nullptr || ntype == ptype) {
2171 ptile = unit_tile(punit);
2172 ptype = ntype;
2173 }
2174 } unit_list_iterate_end;
2175
2176 keys = menu_list.keys();
2177 foreach(munit key, keys) {
2178 i = menu_list.find(key);
2179 while (i != menu_list.end() && i.key() == key) {
2180 switch (key) {
2181 case STANDARD:
2182 i.value()->setEnabled(true);
2183 break;
2184
2185 case EXPLORE:
2186 if (can_units_do_activity_client(punits, ACTIVITY_EXPLORE)) {
2187 i.value()->setEnabled(true);
2188 }
2189 break;
2190
2191 case BOARD:
2192 if (units_can_load(punits)) {
2193 i.value()->setEnabled(true);
2194 }
2195 break;
2196
2197 case DEBOARD:
2198 if (units_can_unload(&(wld.map), punits)) {
2199 i.value()->setEnabled(true);
2200 }
2201 break;
2202
2203 case TRANSPORTER:
2204 if (units_are_occupied(punits)) {
2205 i.value()->setEnabled(true);
2206 }
2207 break;
2208
2209 case CONVERT:
2210 if (units_can_convert(&(wld.map), punits)) {
2211 i.value()->setEnabled(true);
2212 }
2213 break;
2214
2215 case MINE:
2216 if (can_units_do_activity_client(punits, ACTIVITY_MINE)) {
2217 i.value()->setEnabled(true);
2218 }
2219
2220 if (units_all_same_tile) {
2221 if (units_have_type_flag(punits, UTYF_WORKERS, TRUE)) {
2222 struct extra_type *pextra = nullptr;
2223
2224 /* FIXME: this overloading doesn't work well with multiple focus
2225 * units. */
2226 unit_list_iterate(punits, builder) {
2227 pextra = next_extra_for_tile(unit_tile(builder), EC_MINE,
2228 unit_owner(builder), builder);
2229 if (pextra != nullptr) {
2230 break;
2231 }
2232 } unit_list_iterate_end;
2233
2234 if (pextra != nullptr) {
2235 i.value()->setText(
2236 // TRANS: Build mine of specific type
2237 QString(_("Build %1"))
2238 .arg(extra_name_translation(pextra))
2239 .replace("&", "&&"));
2240 } else {
2241 i.value()->setText(QString(_("Build Mine")));
2242 }
2243 } else {
2244 i.value()->setText(QString(_("Build Mine")));
2245 }
2246 }
2247 break;
2248
2249 case IRRIGATION:
2250 if (can_units_do_activity_client(punits, ACTIVITY_IRRIGATE)) {
2251 i.value()->setEnabled(true);
2252 }
2253 if (units_all_same_tile) {
2254 if (units_have_type_flag(punits, UTYF_WORKERS, TRUE)) {
2255 struct extra_type *pextra = nullptr;
2256
2257 /* FIXME: this overloading doesn't work well with multiple focus
2258 * units. */
2259 unit_list_iterate(punits, builder) {
2260 pextra = next_extra_for_tile(unit_tile(builder), EC_IRRIGATION,
2261 unit_owner(builder), builder);
2262 if (pextra != nullptr) {
2263 break;
2264 }
2265 } unit_list_iterate_end;
2266
2267 if (pextra != nullptr) {
2268 i.value()->setText(
2269 // TRANS: Build irrigation of specific type
2270 QString(_("Build %1"))
2271 .arg(extra_name_translation(pextra))
2272 .replace("&", "&&"));
2273 } else {
2274 i.value()->setText(QString(_("Build Irrigation")));
2275 }
2276 } else {
2277 i.value()->setText(QString(_("Build Irrigation")));
2278 }
2279 }
2280 break;
2281
2282 case CULTIVATE:
2283 if (can_units_do_activity_client(punits, ACTIVITY_CULTIVATE)) {
2284 i.value()->setEnabled(true);
2285 }
2286 if (units_all_same_tile) {
2287 struct unit *punit = unit_list_get(punits, 0);
2288 struct tile *atile = unit_tile(punit);
2289 struct terrain *pterrain = tile_terrain(atile);
2290
2291 if (pterrain->cultivate_result != T_NONE) {
2292 i.value()->setText(
2293 // TRANS: Transform terrain to specific type
2294 QString(_("Cultivate to %1"))
2295 .arg(QString(get_tile_change_menu_text(atile, ACTIVITY_CULTIVATE)))
2296 .replace("&", "&&"));
2297 } else {
2298 i.value()->setText(QString(_("Cultivate")));
2299 }
2300 } else {
2301 i.value()->setText(QString(_("Cultivate")));
2302 }
2303 break;
2304
2305 case PLANT:
2306 if (can_units_do_activity_client(punits, ACTIVITY_PLANT)) {
2307 i.value()->setEnabled(true);
2308 }
2309 if (units_all_same_tile) {
2310 struct unit *punit = unit_list_get(punits, 0);
2311 struct tile *atile = unit_tile(punit);
2312 struct terrain *pterrain = tile_terrain(atile);
2313
2314 if (pterrain->plant_result != T_NONE) {
2315 i.value()->setText(
2316 // TRANS: Transform terrain to specific type
2317 QString(_("Plant to %1"))
2318 .arg(QString(get_tile_change_menu_text(atile, ACTIVITY_PLANT)))
2319 .replace("&", "&&"));
2320 } else {
2321 i.value()->setText(QString(_("Plant")));
2322 }
2323 } else {
2324 i.value()->setText(QString(_("Plant")));
2325 }
2326 break;
2327
2328 case TRANSFORM:
2329 if (can_units_do_activity_client(punits, ACTIVITY_TRANSFORM)) {
2330 i.value()->setEnabled(true);
2331 } else {
2332 break;
2333 }
2334 if (units_all_same_tile) {
2335 struct unit *punit = unit_list_get(punits, 0);
2336 struct tile *atile = unit_tile(punit);
2337 struct terrain *pterrain = tile_terrain(atile);
2338
2339 if (pterrain->transform_result != T_NONE
2340 && pterrain->transform_result != pterrain) {
2341 i.value()->setText(
2342 // TRANS: Transform terrain to specific type
2343 QString(_("Transform to %1"))
2344 .arg(QString(get_tile_change_menu_text(atile, ACTIVITY_TRANSFORM)))
2345 .replace("&", "&&"));
2346 } else {
2347 i.value()->setText(_("Transform Terrain"));
2348 }
2349 }
2350 break;
2351
2352 case BUILD:
2353 if (can_units_do(punits, unit_can_add_or_build_city)) {
2354 i.value()->setEnabled(true);
2355 }
2356 if (city_on_tile
2357 && units_can_do_action(punits, ACTION_JOIN_CITY, true)) {
2358 i.value()->setText(
2359 QString(action_id_name_translation(ACTION_JOIN_CITY))
2360 .replace("&", "&&"));
2361 } else {
2362 i.value()->setText(
2363 QString(action_id_name_translation(ACTION_FOUND_CITY))
2364 .replace("&", "&&"));
2365 }
2366 break;
2367
2368 case ROAD:
2369 {
2370 struct extra_type *pextra = nullptr;
2371
2372 if (can_units_do_any_road(&(wld.map), punits)) {
2373 i.value()->setEnabled(true);
2374 }
2375 unit_list_iterate(punits, punit) {
2376 pextra = next_extra_for_tile(unit_tile(punit), EC_ROAD,
2377 unit_owner(punit), punit);
2378 if (pextra != nullptr) {
2379 break;
2380 }
2381 } unit_list_iterate_end;
2382
2383 if (pextra != nullptr) {
2384 i.value()->setText(
2385 // TRANS: Build road of specific type
2386 QString(_("Build %1"))
2387 .arg(extra_name_translation(pextra))
2388 .replace("&", "&&"));
2389 }
2390 }
2391 break;
2392
2393 case FORTIFY:
2394 if (can_units_do_activity_client(punits, ACTIVITY_FORTIFYING)) {
2395 i.value()->setEnabled(true);
2396 }
2397 break;
2398
2399 case FORTRESS:
2400 if (can_units_do_base_gui(punits, BASE_GUI_FORTRESS)) {
2401 i.value()->setEnabled(true);
2402 }
2403 break;
2404
2405 case AIRBASE:
2406 if (can_units_do_base_gui(punits, BASE_GUI_AIRBASE)) {
2407 i.value()->setEnabled(true);
2408 }
2409 break;
2410
2411 case CLEAN:
2412 if (can_units_do_activity_client(punits, ACTIVITY_CLEAN)) {
2413 i.value()->setEnabled(true);
2414 }
2415 break;
2416
2417 case SENTRY:
2418 if (can_units_do_activity_client(punits, ACTIVITY_SENTRY)) {
2419 i.value()->setEnabled(true);
2420 }
2421 break;
2422
2423 case PARADROP:
2424 if (can_units_do_on_map(&(wld.map), punits, can_unit_paradrop)) {
2425 i.value()->setEnabled(true);
2426 i.value()->setText(QString(action_id_name_translation(ACTION_PARADROP))
2427 .replace("&", "&&"));
2428 }
2429 break;
2430
2431 case PILLAGE:
2432 if (can_units_do_activity_client(punits, ACTIVITY_PILLAGE)) {
2433 i.value()->setEnabled(true);
2434 }
2435 break;
2436
2437 case HOMECITY:
2438 if (can_units_do(punits, can_unit_change_homecity)) {
2439 i.value()->setEnabled(true);
2440 }
2441 break;
2442
2443 case WAKEUP:
2444 if (units_have_activity_on_tile(punits, ACTIVITY_SENTRY)) {
2445 i.value()->setEnabled(true);
2446 }
2447 break;
2448
2449 case AUTOWORKER:
2450 if (can_units_do(punits, can_unit_do_autoworker)) {
2451 i.value()->setEnabled(true);
2452 }
2453 if (units_contain_cityfounder(punits)) {
2454 i.value()->setText(_("Auto Settler"));
2455 } else {
2456 i.value()->setText(_("Auto Worker"));
2457 }
2458 break;
2459 case CONNECT_ROAD:
2460 proad = road_by_gui_type(ROAD_GUI_ROAD);
2461 if (proad != nullptr) {
2462 tgt = road_extra_get(proad);
2463 } else {
2464 break;
2465 }
2466 if (can_units_do_connect(punits, ACTIVITY_GEN_ROAD, tgt)) {
2467 i.value()->setEnabled(true);
2468 }
2469 break;
2470
2471 case DISBAND:
2472 if (units_can_do_action(punits, ACTION_DISBAND_UNIT, true)) {
2473 i.value()->setEnabled(true);
2474 }
2475 break;
2476
2477 case CONNECT_RAIL:
2478 proad = road_by_gui_type(ROAD_GUI_RAILROAD);
2479 if (proad != nullptr) {
2480 tgt = road_extra_get(proad);
2481 } else {
2482 break;
2483 }
2484 if (can_units_do_connect(punits, ACTIVITY_GEN_ROAD, tgt)) {
2485 i.value()->setEnabled(true);
2486 }
2487 break;
2488
2489 case CONNECT_MAGLEV:
2490 proad = road_by_gui_type(ROAD_GUI_MAGLEV);
2491 if (proad != nullptr) {
2492 tgt = road_extra_get(proad);
2493 } else {
2494 break;
2495 }
2496 if (can_units_do_connect(punits, ACTIVITY_GEN_ROAD, tgt)) {
2497 i.value()->setEnabled(true);
2498 }
2499 break;
2500
2501 case CONNECT_IRRIGATION:
2502 {
2503 struct extra_type_list *extras = extra_type_list_by_cause(EC_IRRIGATION);
2504
2505 if (extra_type_list_size(extras) > 0) {
2506 struct extra_type *pextra;
2507
2508 pextra = extra_type_list_get(extra_type_list_by_cause(EC_IRRIGATION), 0);
2509 if (can_units_do_connect(punits, ACTIVITY_IRRIGATE, pextra)) {
2510 i.value()->setEnabled(true);
2511 }
2512 }
2513 }
2514 break;
2515
2516 case GOTO_CITY:
2517 if (any_cities) {
2518 i.value()->setEnabled(true);
2519 }
2520 break;
2521
2522 case AIRLIFT:
2523 if (any_cities) {
2524 i.value()->setEnabled(true);
2525 }
2526 break;
2527
2528 case BUILD_WONDER:
2529 i.value()->setText(
2530 QString(action_id_name_translation(ACTION_HELP_WONDER))
2531 .replace("&", "&&"));
2532 if (can_units_do(punits, unit_can_help_build_wonder_here)) {
2533 i.value()->setEnabled(true);
2534 }
2535 break;
2536
2537 case AUTOTRADEROUTE:
2538 if (units_can_do_action(punits, ACTION_TRADE_ROUTE, TRUE)) {
2539 i.value()->setEnabled(true);
2540 }
2541 break;
2542
2543 case ORDER_TRADE_ROUTE:
2544 i.value()->setText(
2545 QString(action_id_name_translation(ACTION_TRADE_ROUTE))
2546 .replace("&", "&&"));
2547 if (can_units_do(punits, unit_can_est_trade_route_here)) {
2548 i.value()->setEnabled(true);
2549 }
2550 break;
2551
2552 case ORDER_DIPLOMAT_DLG:
2553 if (units_can_do_action(punits, ACTION_ANY, TRUE)) {
2554 i.value()->setEnabled(true);
2555 }
2556 break;
2557
2558 case UPGRADE:
2559 if (units_can_upgrade(&(wld.map), punits)) {
2560 i.value()->setEnabled(true);
2561 }
2562 break;
2563 default:
2564 break;
2565 }
2566
2567 i++;
2568 }
2569 }
2570}
2571
2572/**********************************************************************/
2575 void mr_menu::slot_show_research_tab()
2576{
2577 qtg_science_report_dialog_popup(true);
2578}
2579
2580/**********************************************************************/
2583 void mr_menu::slot_spaceship()
2584{
2585 struct player *pplayer = client_player();
2586
2587 if (pplayer != nullptr) {
2588 popup_spaceship_dialog(pplayer);
2589 }
2590}
2591
2592/**********************************************************************/
2595 void mr_menu::slot_show_eco_report()
2596{
2597 economy_report_dialog_popup(false);
2598}
2599
2600/**********************************************************************/
2603 void mr_menu::slot_show_map()
2604{
2605 ::gui()->game_tab_widget->setCurrentIndex(0);
2606}
2607
2608/**********************************************************************/
2611 void mr_menu::slot_show_units_report()
2612{
2613 toggle_units_report(true);
2614}
2615
2616/**********************************************************************/
2619 void mr_menu::slot_show_nations()
2620{
2621 popup_players_dialog(false);
2622}
2623
2624/**********************************************************************/
2627 void mr_menu::slot_show_cities()
2628{
2629 city_report_dialog_popup(false);
2630}
2631
2632/**********************************************************************/
2635 void mr_menu::slot_build_city()
2636{
2637 unit_list_iterate(get_units_in_focus(), punit) {
2638 /* FIXME: this can provide different actions for different units...
2639 * not good! */
2640 /* Enable the button for adding to a city in all cases, so we
2641 get an eventual error message from the server if we try. */
2642 if (unit_can_add_or_build_city(punit)) {
2643 request_unit_build_city(punit);
2644 } else if (utype_can_do_action(unit_type_get(punit), ACTION_HELP_WONDER)) {
2645 request_unit_caravan_action(punit, ACTION_HELP_WONDER);
2646 }
2647 } unit_list_iterate_end;
2648}
2649
2650/**********************************************************************/
2653 void mr_menu::slot_clean()
2654{
2655 unit_list_iterate(get_units_in_focus(), punit) {
2656 struct extra_type *pextra;
2657
2658 pextra = prev_extra_in_tile(unit_tile(punit), ERM_CLEAN,
2659 unit_owner(punit), punit);
2660
2661 if (pextra != nullptr) {
2662 request_new_unit_activity_targeted(punit, ACTIVITY_CLEAN, pextra);
2663 }
2664 } unit_list_iterate_end;
2665}
2666
2667/**********************************************************************/
2670 void mr_menu::slot_conn_irrigation()
2671{
2672 struct extra_type_list *extras = extra_type_list_by_cause(EC_IRRIGATION);
2673
2674 if (extra_type_list_size(extras) > 0) {
2675 struct extra_type *pextra;
2676
2677 pextra = extra_type_list_get(extra_type_list_by_cause(EC_IRRIGATION), 0);
2678
2679 key_unit_connect(ACTIVITY_IRRIGATE, pextra);
2680 }
2681}
2682
2683/**********************************************************************/
2686 void mr_menu::slot_conn_rail()
2687{
2688 struct road_type *prail = road_by_gui_type(ROAD_GUI_RAILROAD);
2689
2690 if (prail != nullptr) {
2691 struct extra_type *tgt;
2692
2693 tgt = road_extra_get(prail);
2694 key_unit_connect(ACTIVITY_GEN_ROAD, tgt);
2695 }
2696}
2697
2698/**********************************************************************/
2701 void mr_menu::slot_conn_maglev()
2702{
2703 struct road_type *pmaglev = road_by_gui_type(ROAD_GUI_MAGLEV);
2704
2705 if (pmaglev != nullptr) {
2706 struct extra_type *tgt;
2707
2708 tgt = road_extra_get(pmaglev);
2709 key_unit_connect(ACTIVITY_GEN_ROAD, tgt);
2710 }
2711}
2712
2713/**********************************************************************/
2716 void mr_menu::slot_unit_fortress()
2717{
2718 key_unit_fortress();
2719}
2720
2721/**********************************************************************/
2724 void mr_menu::slot_unit_airbase()
2725{
2726 key_unit_airbase();
2727}
2728
2729/**********************************************************************/
2732 void mr_menu::slot_conn_road()
2733{
2734 struct road_type *proad = road_by_gui_type(ROAD_GUI_ROAD);
2735
2736 if (proad != nullptr) {
2737 struct extra_type *tgt;
2738
2739 tgt = road_extra_get(proad);
2740 key_unit_connect(ACTIVITY_GEN_ROAD, tgt);
2741 }
2742}
2743
2744/**********************************************************************/
2747 void mr_menu::slot_transform()
2748{
2749 key_unit_transform();
2750}
2751
2752/**********************************************************************/
2755 void mr_menu::slot_paradrop()
2756{
2757 unit_list_iterate(get_units_in_focus(), punit) {
2758 if (can_unit_paradrop(&(wld.map), punit)) {
2759 key_unit_paradrop();
2760 }
2761 } unit_list_iterate_end;
2762}
2763
2764/**********************************************************************/
2767 void mr_menu::slot_pillage()
2768{
2769 key_unit_pillage();
2770}
2771
2772/**********************************************************************/
2775 void mr_menu::slot_action()
2776{
2777 key_unit_action_select_tgt();
2778}
2779
2780/**********************************************************************/
2783 void mr_menu::slot_auto_worker()
2784{
2785 key_unit_auto_work();
2786}
2787
2788/**********************************************************************/
2791 void mr_menu::slot_build_road()
2792{
2793 unit_list_iterate(get_units_in_focus(), punit) {
2794 /* FIXME: this can provide different actions for different units...
2795 * not good! */
2796 struct extra_type *tgt = next_extra_for_tile(unit_tile(punit),
2797 EC_ROAD,
2798 unit_owner(punit),
2799 punit);
2800 bool building_road = false;
2801
2802 if (tgt != nullptr
2803 && can_unit_do_activity_targeted_client(punit, ACTIVITY_GEN_ROAD, tgt)) {
2804 request_new_unit_activity_targeted(punit, ACTIVITY_GEN_ROAD, tgt);
2805 building_road = true;
2806 }
2807
2808 if (!building_road && unit_can_est_trade_route_here(punit)) {
2809 request_unit_caravan_action(punit, ACTION_TRADE_ROUTE);
2810 }
2811 } unit_list_iterate_end;
2812}
2813
2814/**********************************************************************/
2817 void mr_menu::slot_build_irrigation()
2818{
2819 key_unit_irrigate();
2820}
2821
2822/**********************************************************************/
2825 void mr_menu::slot_cultivate()
2826{
2827 key_unit_cultivate();
2828}
2829
2830/**********************************************************************/
2833 void mr_menu::slot_build_mine()
2834{
2835 key_unit_mine();
2836}
2837
2838/**********************************************************************/
2841 void mr_menu::slot_plant()
2842{
2843 key_unit_plant();
2844}
2845
2846/**********************************************************************/
2849 void mr_menu::slot_unit_fortify()
2850{
2851 key_unit_fortify();
2852}
2853
2854/**********************************************************************/
2857 void mr_menu::slot_unit_sentry()
2858{
2859 key_unit_sentry();
2860}
2861
2862/**********************************************************************/
2865 void mr_menu::slot_convert()
2866{
2867 key_unit_convert();
2868}
2869
2870/**********************************************************************/
2873 void mr_menu::slot_disband()
2874{
2875 popup_disband_dialog(get_units_in_focus());
2876}
2877
2878/**********************************************************************/
2881 void mr_menu::slot_orders_clear()
2882{
2883 delayed_order = false;
2884 units_list.clear();
2885}
2886
2887/**********************************************************************/
2890 void mr_menu::slot_rally()
2891{
2892 gui()->rallies.hover_tile = false;
2893 gui()->rallies.hover_city = true;
2894}
2895
2896/**********************************************************************/
2899 void mr_menu::slot_trade_city()
2900{
2901 gui()->trade_gen.hover_city = true;
2902}
2903
2904/**********************************************************************/
2907 void mr_menu::slot_trade_add_all()
2908{
2909 gui()->trade_gen.add_all_cities();
2910}
2911
2912/**********************************************************************/
2915 void mr_menu::slot_calculate()
2916{
2917 gui()->trade_gen.calculate();
2918}
2919
2920/**********************************************************************/
2923 void mr_menu::slot_clear_trade()
2924{
2925 gui()->trade_gen.clear_trade_planing();
2926}
2927
2928/**********************************************************************/
2931 void mr_menu::slot_autocaravan()
2932{
2933 qtiles gilles;
2934 struct unit *punit;
2935 struct city *homecity;
2936 struct tile *home_tile;
2937 struct tile *dest_tile;
2938 bool sent = false;
2939
2940 punit = head_of_units_in_focus();
2941 homecity = game_city_by_number(punit->homecity);
2942 home_tile = homecity->tile;
2943 foreach(gilles, gui()->trade_gen.lines) {
2944 if ((gilles.t1 == home_tile || gilles.t2 == home_tile)
2945 && gilles.autocaravan == nullptr) {
2946 // Send caravan
2947 if (gilles.t1 == home_tile) {
2948 dest_tile = gilles.t2;
2949 } else {
2950 dest_tile = gilles.t1;
2951 }
2952 if (send_goto_tile(punit, dest_tile)) {
2953 int i;
2954 i = gui()->trade_gen.lines.indexOf(gilles);
2955 gilles = gui()->trade_gen.lines.takeAt(i);
2956 gilles.autocaravan = punit;
2957 gui()->trade_gen.lines.append(gilles);
2958 sent = true;
2959 break;
2960 }
2961 }
2962 }
2963
2964 if (!sent) {
2965 gui()->infotab->chtwdg->append(_("Didn't find any trade route"
2966 " to establish"));
2967 }
2968}
2969
2970/**********************************************************************/
2973 void mr_menu::slot_quickairlift_set()
2974{
2975 QVariant v;
2976 QAction *act;
2977
2978 act = qobject_cast<QAction *>(sender());
2979 v = act->data();
2980 airlift_type_id = v.toInt();
2981}
2982
2983/**********************************************************************/
2986 void mr_menu::slot_action_vs_unit()
2987{
2988 QAction *act;
2989
2990 act = qobject_cast<QAction *>(sender());
2991 qdef_act::action()->vs_unit_set(act->data().toInt());
2992}
2993
2994/**********************************************************************/
2997 void mr_menu::slot_action_vs_city()
2998{
2999 QAction *act;
3000
3001 act = qobject_cast<QAction *>(sender());
3002 qdef_act::action()->vs_city_set(act->data().toInt());
3003}
3004
3005/**********************************************************************/
3008 void mr_menu::slot_quickairlift()
3009{
3010 quick_airlifting = true;
3011}
3012
3013/**********************************************************************/
3016 void mr_menu::slot_delayed_goto()
3017{
3018 qfc_delayed_unit_item *unit_item;
3019 int i = 0;
3020 delay_order dg;
3021
3022 delayed_order = true;
3023 dg = D_GOTO;
3024
3025 struct unit_list *punits = get_units_in_focus();
3026 if (unit_list_size(punits) == 0) {
3027 return;
3028 }
3029 if (hover_state != HOVER_GOTO) {
3030 set_hover_state(punits, HOVER_GOTO, ACTIVITY_LAST, nullptr,
3031 NO_TARGET, NO_TARGET, ACTION_NONE, ORDER_LAST);
3032 enter_goto_state(punits);
3033 create_line_at_mouse_pos();
3034 control_mouse_cursor(nullptr);
3035 }
3036 unit_list_iterate(get_units_in_focus(), punit) {
3037 i++;
3038 unit_item = new qfc_delayed_unit_item(dg, punit->id);
3039 units_list.add(unit_item);
3040 units_list.nr_units = i;
3041 } unit_list_iterate_end;
3042}
3043
3044/**********************************************************************/
3047 void mr_menu::slot_execute_orders()
3048{
3049 qfc_delayed_unit_item *fui;
3050 struct unit *punit;
3051 struct tile *last_tile;
3052 struct tile *new_tile;
3053 int i = 0;
3054
3055 foreach (fui, units_list.unit_list) {
3056 i++;
3057 punit = unit_list_find(client_player()->units, fui->id);
3058 if (punit == nullptr) {
3059 continue;
3060 }
3061 last_tile = punit->tile;
3062 new_tile = find_last_unit_pos(punit, i);
3063 if (new_tile != nullptr) {
3064 punit->tile = new_tile;
3065 }
3066 if (is_tiles_adjacent(punit->tile, fui->ptile)) {
3067 request_move_unit_direction(punit,
3068 get_direction_for_step(&(wld.map),
3069 punit->tile,
3070 fui->ptile));
3071 } else {
3072 send_attack_tile(punit, fui->ptile);
3073 }
3074 punit->tile = last_tile;
3075 }
3076 units_list.clear();
3077}
3078
3079/**********************************************************************/
3082 void mr_menu::slot_board()
3083{
3084 unit_list_iterate(get_units_in_focus(), punit) {
3085 qtg_request_transport(punit, unit_tile(punit));
3086 } unit_list_iterate_end;
3087}
3088
3089/**********************************************************************/
3092 void mr_menu::slot_patrol()
3093{
3094 key_unit_patrol();
3095}
3096
3097/**********************************************************************/
3100 void mr_menu::slot_return_to_city()
3101{
3102 unit_list_iterate(get_units_in_focus(), punit) {
3103 request_unit_return(punit);
3104 } unit_list_iterate_end;
3105}
3106
3107/**********************************************************************/
3110 void mr_menu::slot_airlift()
3111{
3112 popup_goto_dialog();
3113}
3114
3115/**********************************************************************/
3118 void mr_menu::slot_set_home()
3119{
3120 key_unit_homecity();
3121}
3122
3123/**********************************************************************/
3126 void mr_menu::slot_deboard()
3127{
3128 unit_list_iterate(get_units_in_focus(), punit) {
3129 request_unit_unload(punit);
3130 } unit_list_iterate_end;
3131}
3132
3133/**********************************************************************/
3136 void mr_menu::slot_unload_all()
3137{
3138 key_unit_unload_all();
3139}
3140
3141/**********************************************************************/
3144 void mr_menu::slot_unsentry()
3145{
3146 key_unit_wakeup_others();
3147}
3148
3149/**********************************************************************/
3152 void mr_menu::slot_upgrade()
3153{
3154 popup_upgrade_dialog(get_units_in_focus());
3155}
3156
3157/**********************************************************************/
3160 void mr_menu::slot_unit_goto()
3161{
3162 key_unit_goto();
3163}
3164
3165/**********************************************************************/
3168 void mr_menu::slot_unit_explore()
3169{
3170 key_unit_auto_explore();
3171}
3172
3173/**********************************************************************/
3176 void mr_menu::slot_center_view()
3177{
3178 request_center_focus_unit();
3179}
3180
3181/**********************************************************************/
3184 void mr_menu::slot_lock()
3185{
3186 if (gui()->interface_locked) {
3187 enable_interface(false);
3188 } else {
3189 enable_interface(true);
3190 }
3191 gui()->interface_locked = !gui()->interface_locked;
3192}
3193
3194/**********************************************************************/
3197 void enable_interface(bool enable)
3198{
3199 QList<close_widget *> lc;
3200 QList<move_widget *> lm;
3201 QList<resize_widget *> lr;
3202 int i;
3203
3204 lc = gui()->findChildren<close_widget *>();
3205 lm = gui()->findChildren<move_widget *>();
3206 lr = gui()->findChildren<resize_widget *>();
3207
3208 for (i = 0; i < lc.size(); ++i) {
3209 lc.at(i)->setVisible(!enable);
3210 }
3211 for (i = 0; i < lm.size(); ++i) {
3212 lm.at(i)->setVisible(!enable);
3213 }
3214 for (i = 0; i < lr.size(); ++i) {
3215 lr.at(i)->setVisible(!enable);
3216 }
3217}
3218
3219/**********************************************************************/
3222 void mr_menu::slot_fullscreen()
3223{
3224 gui_options.gui_qt_fullscreen = !gui_options.gui_qt_fullscreen;
3225
3226 gui()->apply_fullscreen();
3227}
3228
3229/**********************************************************************/
3232 void mr_menu::slot_minimap_view()
3233{
3234 if (minimap_status->isChecked()) {
3235 ::gui()->minimapview_wdg->show();
3236 } else {
3237 ::gui()->minimapview_wdg->hide();
3238 }
3239}
3240
3241/**********************************************************************/
3244 void mr_menu::slot_show_new_turn_text()
3245{
3246 if (osd_status->isChecked()) {
3247 gui()->qt_settings.show_new_turn_text = true;
3248 } else {
3249 gui()->qt_settings.show_new_turn_text = false;
3250 }
3251}
3252
3253/**********************************************************************/
3256 void mr_menu::slot_battlelog()
3257{
3258 if (btlog_status->isChecked()) {
3259 gui()->qt_settings.show_battle_log = true;
3260 } else {
3261 gui()->qt_settings.show_battle_log = false;
3262 }
3263}
3264
3265/**********************************************************************/
3268 void mr_menu::slot_borders()
3269{
3270 key_map_borders_toggle();
3271}
3272
3273/**********************************************************************/
3276 void mr_menu::slot_native_tiles()
3277{
3278 key_map_native_toggle();
3279}
3280
3281/**********************************************************************/
3284 void mr_menu::slot_city_buycost()
3285{
3286 key_city_buycost_toggle();
3287}
3288
3289/**********************************************************************/
3292 void mr_menu::slot_city_growth()
3293{
3294 key_city_growth_toggle();
3295}
3296
3297/**********************************************************************/
3300 void mr_menu::zoom_in()
3301{
3302 gui()->map_scale = gui()->map_scale * 1.2f;
3303 tilespec_reread(tileset_basename(tileset), true, gui()->map_scale);
3304}
3305
3306/**********************************************************************/
3309 void mr_menu::zoom_reset()
3310{
3311 QFont *qf;
3312
3313 gui()->map_scale = 1.0f;
3314 qf = fc_font::instance()->get_font(fonts::city_names);
3315 qf->setPointSize(fc_font::instance()->city_fontsize);
3316 qf = fc_font::instance()->get_font(fonts::city_productions);
3317 qf->setPointSize(fc_font::instance()->prod_fontsize);
3318 tilespec_reread(tileset_basename(tileset), true, gui()->map_scale);
3319}
3320
3321/**********************************************************************/
3324 void mr_menu::zoom_scale_fonts()
3325{
3326 QFont *qf;
3327
3328 if (scale_fonts_status->isChecked()) {
3329 gui()->map_font_scale = true;
3330 } else {
3331 qf = fc_font::instance()->get_font(fonts::city_names);
3332 qf->setPointSize(fc_font::instance()->city_fontsize);
3333 qf = fc_font::instance()->get_font(fonts::city_productions);
3334 qf->setPointSize(fc_font::instance()->prod_fontsize);
3335 gui()->map_font_scale = false;
3336 }
3337 update_city_descriptions();
3338}
3339
3340/**********************************************************************/
3343 void mr_menu::zoom_out()
3344{
3345 gui()->map_scale = gui()->map_scale / 1.2f;
3346 tilespec_reread(tileset_basename(tileset), true, gui()->map_scale);
3347}
3348
3349/**********************************************************************/
3352 void mr_menu::slot_city_names()
3353{
3354 key_city_names_toggle();
3355}
3356
3357/**********************************************************************/
3360 void mr_menu::slot_city_outlines()
3361{
3362 key_city_outlines_toggle();
3363}
3364
3365/**********************************************************************/
3368 void mr_menu::slot_city_output()
3369{
3370 key_city_output_toggle();
3371}
3372
3373/**********************************************************************/
3376 void mr_menu::slot_city_production()
3377{
3378 key_city_productions_toggle();
3379}
3380
3381/**********************************************************************/
3384 void mr_menu::slot_city_trade_routes()
3385{
3386 key_city_trade_routes_toggle();
3387}
3388
3389/**********************************************************************/
3392 void mr_menu::slot_stack_size()
3393{
3394 key_unit_stack_size_toggle();
3395}
3396
3397/**********************************************************************/
3400 void mr_menu::slot_fullbar()
3401{
3402 key_city_full_bar_toggle();
3403}
3404
3405/**********************************************************************/
3408 void mr_menu::slot_map_grid()
3409{
3410 key_map_grid_toggle();
3411}
3412
3413/**********************************************************************/
3416 void mr_menu::slot_done_moving()
3417{
3418 key_unit_done();
3419}
3420
3421/**********************************************************************/
3424 void mr_menu::slot_select_all_tile()
3425{
3426 request_unit_select(get_units_in_focus(), SELTYPE_ALL, SELLOC_TILE);
3427}
3428
3429/**********************************************************************/
3432 void mr_menu::slot_select_one()
3433{
3434 request_unit_select(get_units_in_focus(), SELTYPE_SINGLE, SELLOC_TILE);
3435}
3436
3437/**********************************************************************/
3440 void mr_menu::slot_select_same_continent()
3441{
3442 if (!gui_options.unit_selection_clears_orders || confirm_disruptive_selection()) {
3443 request_unit_select(get_units_in_focus(), SELTYPE_SAME, SELLOC_CONT);
3444 }
3445}
3446
3447/**********************************************************************/
3450 void mr_menu::slot_select_same_everywhere()
3451{
3452 if (!gui_options.unit_selection_clears_orders || confirm_disruptive_selection()) {
3453 request_unit_select(get_units_in_focus(), SELTYPE_SAME, SELLOC_WORLD);
3454 }
3455}
3456
3457/**********************************************************************/
3460 void mr_menu::slot_select_same_tile()
3461{
3462 request_unit_select(get_units_in_focus(), SELTYPE_SAME, SELLOC_TILE);
3463}
3464
3465/**********************************************************************/
3468 void mr_menu::slot_wait()
3469{
3470 key_unit_wait();
3471}
3472
3473/**********************************************************************/
3476 void mr_menu::slot_unit_filter()
3477{
3478 unit_hud_selector *uhs;
3479
3480 uhs = new unit_hud_selector(gui()->central_wdg);
3481 uhs->show_me();
3482}
3483
3484/**********************************************************************/
3487 void mr_menu::slot_demographics()
3488{
3489 send_report_request(REPORT_DEMOGRAPHIC);
3490}
3491
3492/**********************************************************************/
3495 void mr_menu::slot_achievements()
3496{
3497 send_report_request(REPORT_ACHIEVEMENTS);
3498}
3499
3500/**********************************************************************/
3503 void mr_menu::slot_endgame()
3504{
3505 popup_endgame_report();
3506}
3507
3508/**********************************************************************/
3511 void mr_menu::slot_top_cities()
3512{
3513 send_report_request(REPORT_TOP_CITIES);
3514}
3515
3516/**********************************************************************/
3519 void mr_menu::slot_traveler()
3520{
3521 send_report_request(REPORT_WONDERS_OF_THE_WORLD_LONG);
3522}
3523
3524/**********************************************************************/
3527 void mr_menu::slot_bg1select()
3528{
3529 key_unit_select_battlegroup(0, FALSE);
3530}
3531
3532/**********************************************************************/
3535 void mr_menu::slot_bg1assign()
3536{
3537 key_unit_assign_battlegroup(0, FALSE);
3538}
3539
3540/**********************************************************************/
3543 void mr_menu::slot_bg1append()
3544{
3545 key_unit_assign_battlegroup(0, TRUE);
3546}
3547
3548/**********************************************************************/
3551 void mr_menu::slot_bg2select()
3552{
3553 key_unit_select_battlegroup(1, FALSE);
3554}
3555
3556/**********************************************************************/
3559 void mr_menu::slot_bg2assign()
3560{
3561 key_unit_assign_battlegroup(1, FALSE);
3562}
3563
3564/**********************************************************************/
3567 void mr_menu::slot_bg2append()
3568{
3569 key_unit_assign_battlegroup(1, TRUE);
3570}
3571
3572/**********************************************************************/
3575 void mr_menu::slot_bg3select()
3576{
3577 key_unit_select_battlegroup(2, FALSE);
3578}
3579
3580/**********************************************************************/
3583 void mr_menu::slot_bg3assign()
3584{
3585 key_unit_assign_battlegroup(2, FALSE);
3586}
3587
3588/**********************************************************************/
3591 void mr_menu::slot_bg3append()
3592{
3593 key_unit_assign_battlegroup(2, TRUE);
3594}
3595
3596/**********************************************************************/
3599 void mr_menu::slot_bg4select()
3600{
3601 key_unit_select_battlegroup(3, FALSE);
3602}
3603
3604/**********************************************************************/
3607 void mr_menu::slot_bg4assign()
3608{
3609 key_unit_assign_battlegroup(3, FALSE);
3610}
3611
3612/**********************************************************************/
3615 void mr_menu::slot_bg4append()
3616{
3617 key_unit_assign_battlegroup(3, TRUE);
3618}
3619
3620/**********************************************************************/
3623 void mr_menu::tileset_custom_load()
3624{
3625 QDialog *dialog = new QDialog(this);
3626 QLabel *label;
3627 QPushButton *but;
3628 QVBoxLayout *layout;
3629 const struct strvec *tlset_list;
3630 const struct option *poption;
3631 QStringList sl;
3632 QString s;
3633
3634 sl << "default_tileset_overhead_name" << "default_tileset_iso_name"
3635 << "default_tileset_hex_name" << "default_tileset_isohex_name";
3636 layout = new QVBoxLayout;
3637 dialog->setWindowTitle(_("Available tilesets"));
3638 label = new QLabel;
3639 label->setText(_("Some tilesets might not be compatible with current"
3640 " map topology!"));
3641 layout->addWidget(label);
3642
3643 foreach (s, sl) {
3644 QByteArray on_bytes;
3645
3646 on_bytes = s.toUtf8();
3647 poption = optset_option_by_name(client_optset, on_bytes.data());
3648 tlset_list = get_tileset_list(poption);
3649 strvec_iterate(tlset_list, value) {
3650 but = new QPushButton(value);
3651 connect(but, &QAbstractButton::clicked, this, &mr_menu::load_new_tileset);
3652 layout->addWidget(but);
3653 } strvec_iterate_end;
3654 }
3655 dialog->setSizeGripEnabled(true);
3656 dialog->setLayout(layout);
3657 dialog->show();
3658}
3659
3660/**********************************************************************/
3663 void mr_menu::load_new_tileset()
3664{
3665 QPushButton *but;
3666 QByteArray tn_bytes;
3667
3668 but = qobject_cast<QPushButton *>(sender());
3669 tn_bytes = but->text().toUtf8();
3670 tilespec_reread(tn_bytes.data(), true, 1.0f);
3671 gui()->map_scale = 1.0f;
3672 but->parentWidget()->close();
3673}
3674
3675/**********************************************************************/
3678 void mr_menu::calc_trade_routes()
3679{
3680 gui()->trade_gen.calculate();
3681}
3682
3683/**********************************************************************/
3686 void mr_menu::slot_popup_tax_rates()
3687{
3688 popup_rates_dialog();
3689}
3690
3691/**********************************************************************/
3694 void mr_menu::slot_popup_mult_rates()
3695{
3696 popup_multiplier_dialog();
3697}
3698
3699/**********************************************************************/
3702 void mr_menu::slot_help(const QString &topic)
3703{
3704 popup_help_dialog_typed(Q_(topic.toStdString().c_str()), HELP_ANY);
3705}
3706
3707/****************************************************************
3708 Actions "BUILD_PATH_*"
3709*****************************************************************/
3710 void mr_menu::slot_build_path(int id)
3711{
3712 unit_list_iterate(get_units_in_focus(), punit) {
3713 extra_type_by_cause_iterate(EC_ROAD, pextra) {
3714 if (pextra->buildable && pextra->id == id
3715 && can_unit_do_activity_targeted_client(punit, ACTIVITY_GEN_ROAD,
3716 pextra)) {
3717 request_new_unit_activity_targeted(punit, ACTIVITY_GEN_ROAD, pextra);
3718 }
3719 } extra_type_by_cause_iterate_end;
3720 } unit_list_iterate_end;
3721}
3722
3723/****************************************************************
3724 Actions "BUILD_BASE_*"
3725*****************************************************************/
3726 void mr_menu::slot_build_base(int id)
3727{
3728 unit_list_iterate(get_units_in_focus(), punit) {
3729 extra_type_by_cause_iterate(EC_BASE, pextra) {
3730 if (pextra->buildable && pextra->id == id
3731 && can_unit_do_activity_targeted_client(punit, ACTIVITY_BASE,
3732 pextra)) {
3733 request_new_unit_activity_targeted(punit, ACTIVITY_BASE, pextra);
3734 }
3735 } extra_type_by_cause_iterate_end;
3736 } unit_list_iterate_end;
3737}
3738
3739
3740
3741/**********************************************************************/
3744 void mr_menu::local_options()
3745{
3746 gui()->popup_client_options();
3747}
3748
3749/**********************************************************************/
3752 void mr_menu::shortcut_options()
3753{
3754 popup_shortcuts_dialog();
3755}
3756
3757/**********************************************************************/
3760 void mr_menu::server_options()
3761{
3762 gui()->pr_options->popup_server_options();
3763}
3764
3765/**********************************************************************/
3768 void mr_menu::messages_options()
3769{
3770 popup_messageopt_dialog();
3771}
3772
3773/**********************************************************************/
3776 void mr_menu::save_options_now()
3777{
3778 options_save(nullptr);
3779}
3780
3781/**********************************************************************/
3784 void mr_menu::quit_game()
3785{
3786 popup_quit_dialog();
3787}
3788
3789/**********************************************************************/
3792 void mr_menu::save_image()
3793{
3794 int current_width, current_height;
3795 int full_size_x, full_size_y;
3796 QString path, storage_path;
3797 hud_message_box *saved = new hud_message_box(gui()->central_wdg);
3798 bool map_saved;
3799 QString img_name;
3800
3801 full_size_x = (MAP_NATIVE_WIDTH + 2) * tileset_tile_width(tileset);
3802 full_size_y = (MAP_NATIVE_HEIGHT + 2) * tileset_tile_height(tileset);
3803 current_width = gui()->mapview_wdg->width();
3804 current_height = gui()->mapview_wdg->height();
3805 if (tileset_hex_width(tileset) > 0) {
3806 full_size_y = full_size_y * 11 / 20;
3807 } else if (tileset_is_isometric(tileset)) {
3808 full_size_y = full_size_y / 2;
3809 }
3810 map_canvas_resized(full_size_x, full_size_y);
3811 img_name = QString("Freeciv-Turn%1").arg(game.info.turn);
3812 if (client_has_player()) {
3813 img_name = img_name + "-"
3814 + QString(nation_plural_for_player(client_player()));
3815 }
3816 storage_path = freeciv_storage_dir();
3817 path = QStandardPaths::writableLocation(QStandardPaths::PicturesLocation);
3818 if (!storage_path.isEmpty() && QDir(storage_path).isReadable()) {
3819 img_name = storage_path + DIR_SEPARATOR + img_name;
3820 } else if (!path.isEmpty()) {
3821 img_name = path + DIR_SEPARATOR + img_name;
3822 } else {
3823 img_name = QStandardPaths::writableLocation(QStandardPaths::HomeLocation)
3824 + DIR_SEPARATOR + img_name;
3825 }
3826 map_saved = mapview.store->map_pixmap.save(img_name, "png");
3827 map_canvas_resized(current_width, current_height);
3828 saved->setStandardButtons(QMessageBox::Ok);
3829 saved->setDefaultButton(QMessageBox::Cancel);
3830 saved->setAttribute(Qt::WA_DeleteOnClose);
3831 if (map_saved) {
3832 saved->set_text_title("Image saved as:\n" + img_name, _("Success"));
3833 } else {
3834 saved->set_text_title(_("Failed to save image of the map"), _("Error"));
3835 }
3836 saved->show();
3837}
3838
3839/**********************************************************************/
3842 void mr_menu::save_game()
3843{
3844 send_save_game(nullptr);
3845}
3846
3847/**********************************************************************/
3850 void mr_menu::save_game_as()
3851{
3852 QString str;
3853 QString current_file;
3854 QString location;
3855
3856 strvec_iterate(get_save_dirs(), dirname) {
3857 location = dirname;
3858 // choose last location
3859 } strvec_iterate_end;
3860
3861 str = QString(_("Save Games"))
3862 + QString(" (*.sav *.sav.bz2 *.sav.gz *.sav.xz)");
3863 current_file = QFileDialog::getSaveFileName(gui()->central_wdg,
3864 _("Save Game As..."),
3865 location, str);
3866 if (!current_file.isEmpty()) {
3867 QByteArray cf_bytes;
3868
3869 cf_bytes = current_file.toUtf8();
3870 send_save_game(cf_bytes.data());
3871 }
3872}
3873
3874/**********************************************************************/
3877 void mr_menu::back_to_menu()
3878{
3879 hud_message_box *ask;
3880
3881 if (is_server_running()) {
3882 ask = new hud_message_box(gui()->central_wdg);
3883 ask->set_text_title(_("Leaving a local game will end it!"), "Leave game");
3884 ask->setStandardButtons(QMessageBox::Cancel | QMessageBox::Ok);
3885 ask->setDefaultButton(QMessageBox::Cancel);
3886 ask->setAttribute(Qt::WA_DeleteOnClose);
3887
3888 connect(ask, &hud_message_box::accepted, [=]() {
3889 if (client.conn.used) {
3890 disconnect_from_server(TRUE);
3891 }
3892 });
3893 ask->show();
3894 } else {
3895 disconnect_from_server(TRUE);
3896 }
3897}
3898
3899/**********************************************************************/
3902 bool mr_menu::confirm_disruptive_selection()
3903{
3904 hud_message_box* ask = new hud_message_box(gui()->central_wdg);
3905
3906 ask->setIcon(QMessageBox::Warning);
3907 ask->setStandardButtons(QMessageBox::Cancel | QMessageBox::Ok);
3908 ask->setDefaultButton(QMessageBox::Cancel);
3909 ask->setAttribute(Qt::WA_DeleteOnClose);
3910 return (ask->set_text_title(_("Selection will cancel current assignments!"),
3911 _("Confirm Disruptive Selection"), true)
3912 == QMessageBox::Ok);
3913}
3914
3915/**********************************************************************/
3918 void multiairlift(struct city *acity, Unit_type_id ut)
3919{
3920 struct tile *ptile;
3921
3922 city_list_iterate(client_player()->cities, pcity) {
3923 if (get_city_bonus(pcity, EFT_AIRLIFT) > 0) {
3924 ptile = city_tile(pcity);
3925 unit_list_iterate(ptile->units, punit) {
3926 if (punit->utype == utype_by_number(ut)) {
3927 request_unit_airlift(punit, acity);
3928 break;
3929 }
3930 } unit_list_iterate_end;
3931 }
3932 } city_list_iterate_end;
3933}
action_id_name_translation
const char * action_id_name_translation(action_id act_id)
Definition actions.c:1225
action_name_translation
const char * action_name_translation(const struct action *paction)
Definition actions.c:1205
action_get_sub_target_kind
enum action_sub_target_kind action_get_sub_target_kind(const struct action *paction)
Definition actions.c:1094
actions_are_ready
bool actions_are_ready(void)
Definition actions.c:931
action_noninternal_iterate_end
#define action_noninternal_iterate_end
Definition actions.h:231
action_by_number
static struct action * action_by_number(action_id act_id)
Definition actions.h:390
action_id_get_actor_kind
#define action_id_get_actor_kind(act_id)
Definition actions.h:403
ACTION_ANY
#define ACTION_ANY
Definition actions.h:52
action_noninternal_iterate
#define action_noninternal_iterate(_act_)
Definition actions.h:226
action_id_get_target_kind
#define action_id_get_target_kind(act_id)
Definition actions.h:407
action_id_has_complex_target
#define action_id_has_complex_target(act_id)
Definition actions.h:425
ACTION_NONE
#define ACTION_NONE
Definition actions.h:55
actres_removes_extra
bool actres_removes_extra(enum action_result result, const struct extra_type *pextra)
Definition actres.c:806
actres_creates_extra
bool actres_creates_extra(enum action_result result, const struct extra_type *pextra)
Definition actres.c:785
str
#define str
Definition astring.c:76
n
#define n
Definition astring.c:77
output_window_append
void output_window_append(const struct ft_color color, const char *featured_text)
Definition chatline_common.c:104
create_city_virtual
struct city * create_city_virtual(struct player *pplayer, struct tile *ptile, const char *name)
Definition city.c:3426
destroy_city_virtual
void destroy_city_virtual(struct city *pcity)
Definition city.c:3512
is_non_allied_city_tile
static bool is_non_allied_city_tile(const struct tile *ptile, const struct player *pplayer)
Definition city.h:763
city_list_iterate
#define city_list_iterate(citylist, pcity)
Definition city.h:508
city_tile
#define city_tile(_pcity_)
Definition city.h:564
city_list_iterate_end
#define city_list_iterate_end
Definition city.h:510
close_widget
Definition mapview.h:183
fc_font::instance
static fc_font * instance()
Definition fonts.cpp:41
fc_font::get_font
QFont * get_font(QString name)
Definition fonts.cpp:63
fc_shortcuts::sc
static fc_shortcuts * sc()
Definition shortcuts.cpp:278
fc_shortcuts::get_shortcut
fc_shortcut * get_shortcut(shortcut_id id)
Definition shortcuts.cpp:236
hud_message_box
Definition hudwidget.h:56
move_widget
Definition mapview.h:154
qdef_act::action
static qdef_act * action()
Definition dialogs.cpp:1042
qdef_act::vs_city_set
void vs_city_set(int i)
Definition dialogs.cpp:1064
qdef_act::vs_unit_set
void vs_unit_set(int i)
Definition dialogs.cpp:1072
qfc_delayed_unit_item
Definition menu.h:110
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
resize_widget
Definition mapview.h:136
trade_city
Definition menu.h:139
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::trade_city
trade_city(struct city *pcity)
Definition menu.cpp:68
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::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
unit_hud_selector
Definition hudwidget.h:248
unit_item
Definition citydlg.h:142
client_is_observer
bool client_is_observer(void)
Definition client_main.c:1091
client
struct civclient client
Definition client_main.c:153
client_state
enum client_states client_state(void)
Definition client_main.c:1034
is_waiting_turn_change
bool is_waiting_turn_change(void)
Definition client_main.c:1135
send_report_request
void send_report_request(enum report_type type)
Definition client_main.c:844
can_client_issue_orders
bool can_client_issue_orders(void)
Definition client_main.c:1272
client_has_player
bool client_has_player(void)
Definition client_main.c:1372
client_player
#define client_player()
Definition client_main.h:106
C_S_RUNNING
@ C_S_RUNNING
Definition client_main.h:47
can_units_do_connect
bool can_units_do_connect(struct unit_list *punits, enum unit_activity activity, struct extra_type *tgt)
Definition climisc.c:1231
disconnect_from_server
void disconnect_from_server(bool leaving_sound)
Definition clinet.c:306
incite_cost
char * incite_cost
Definition comments.c:74
REPORT_DEMOGRAPHIC
@ REPORT_DEMOGRAPHIC
Definition conn_types.h:53
REPORT_WONDERS_OF_THE_WORLD_LONG
@ REPORT_WONDERS_OF_THE_WORLD_LONG
Definition conn_types.h:51
REPORT_ACHIEVEMENTS
@ REPORT_ACHIEVEMENTS
Definition conn_types.h:54
REPORT_TOP_CITIES
@ REPORT_TOP_CITIES
Definition conn_types.h:52
send_save_game
void send_save_game(const char *filename)
Definition connectdlg_common.c:751
is_server_running
bool is_server_running(void)
Definition connectdlg_common.c:124
can_client_access_hack
bool can_client_access_hack(void)
Definition connectdlg_common.c:141
connectdlg_common.h
key_unit_sentry
void key_unit_sentry(void)
Definition control.c:3729
request_unit_airlift
void request_unit_airlift(struct unit *punit, struct city *pcity)
Definition control.c:1517
key_city_output_toggle
void key_city_output_toggle(void)
Definition control.c:3826
request_unit_return
void request_unit_return(struct unit *punit)
Definition control.c:1526
request_unit_caravan_action
void request_unit_caravan_action(struct unit *punit, action_id action)
Definition control.c:2196
key_unit_auto_explore
void key_unit_auto_explore(void)
Definition control.c:3550
key_unit_connect
void key_unit_connect(enum unit_activity activity, struct extra_type *tgt)
Definition control.c:3348
key_city_full_bar_toggle
void key_city_full_bar_toggle(void)
Definition control.c:3858
key_map_native_toggle
void key_map_native_toggle(void)
Definition control.c:3850
request_unit_goto
void request_unit_goto(enum unit_orders last_order, action_id act_id, int sub_tgt_id)
Definition control.c:1104
key_unit_paradrop
void key_unit_paradrop(void)
Definition control.c:3452
get_units_in_focus
struct unit_list * get_units_in_focus(void)
Definition control.c:177
request_center_focus_unit
void request_center_focus_unit(void)
Definition control.c:2723
key_city_productions_toggle
void key_city_productions_toggle(void)
Definition control.c:3892
key_unit_plant
void key_unit_plant(void)
Definition control.c:3669
key_unit_fortress
void key_unit_fortress(void)
Definition control.c:3597
key_unit_mine
void key_unit_mine(void)
Definition control.c:3661
key_unit_pillage
void key_unit_pillage(void)
Definition control.c:3681
request_unit_unload
void request_unit_unload(struct unit *pcargo)
Definition control.c:2167
request_new_unit_activity_targeted
void request_new_unit_activity_targeted(struct unit *punit, enum unit_activity act, struct extra_type *tgt)
Definition control.c:1912
key_unit_irrigate
void key_unit_irrigate(void)
Definition control.c:3641
request_unit_build_city
void request_unit_build_city(struct unit *punit)
Definition control.c:1791
key_unit_unload_all
void key_unit_unload_all(void)
Definition control.c:3490
key_city_outlines_toggle
void key_city_outlines_toggle(void)
Definition control.c:3818
key_unit_homecity
void key_unit_homecity(void)
Definition control.c:3614
set_hover_state
void set_hover_state(struct unit_list *punits, enum cursor_hover_state state, enum unit_activity activity, struct extra_type *tgt, int last_tgt, int last_sub_tgt, action_id action, enum unit_orders order)
Definition control.c:285
key_unit_patrol
void key_unit_patrol(void)
Definition control.c:3460
key_unit_wakeup_others
void key_unit_wakeup_others(void)
Definition control.c:3523
hover_state
enum cursor_hover_state hover_state
Definition control.c:89
key_unit_stack_size_toggle
void key_unit_stack_size_toggle(void)
Definition control.c:3909
key_unit_wait
void key_unit_wait(void)
Definition control.c:3515
key_unit_select_battlegroup
void key_unit_select_battlegroup(int battlegroup, bool append)
Definition control.c:3792
key_map_grid_toggle
void key_map_grid_toggle(void)
Definition control.c:3834
head_of_units_in_focus
struct unit * head_of_units_in_focus(void)
Definition control.c:405
key_city_growth_toggle
void key_city_growth_toggle(void)
Definition control.c:3875
key_unit_action_select_tgt
void key_unit_action_select_tgt(void)
Definition control.c:3379
key_city_buycost_toggle
void key_city_buycost_toggle(void)
Definition control.c:3884
get_num_units_in_focus
int get_num_units_in_focus(void)
Definition control.c:185
key_unit_transform
void key_unit_transform(void)
Definition control.c:3741
request_move_unit_direction
void request_move_unit_direction(struct unit *punit, int dir)
Definition control.c:1853
key_unit_done
void key_unit_done(void)
Definition control.c:3436
key_city_trade_routes_toggle
void key_city_trade_routes_toggle(void)
Definition control.c:3901
key_city_names_toggle
void key_city_names_toggle(void)
Definition control.c:3866
request_unit_select
void request_unit_select(struct unit_list *punits, enum unit_select_type_mode seltype, enum unit_select_location_mode selloc)
Definition control.c:1595
key_unit_auto_work
void key_unit_auto_work(void)
Definition control.c:3563
key_unit_airbase
void key_unit_airbase(void)
Definition control.c:3533
key_unit_goto
void key_unit_goto(void)
Definition control.c:3444
control_mouse_cursor
void control_mouse_cursor(struct tile *ptile)
Definition control.c:1189
key_unit_convert
void key_unit_convert(void)
Definition control.c:3575
key_unit_fortify
void key_unit_fortify(void)
Definition control.c:3585
key_unit_assign_battlegroup
void key_unit_assign_battlegroup(int battlegroup, bool append)
Definition control.c:3753
key_unit_cultivate
void key_unit_cultivate(void)
Definition control.c:3649
key_map_borders_toggle
void key_map_borders_toggle(void)
Definition control.c:3842
control.h
can_unit_do_activity_targeted_client
#define can_unit_do_activity_targeted_client(_punit_, _act_, _tgt_)
Definition control.h:43
can_units_do_activity_targeted_client
#define can_units_do_activity_targeted_client(_punits_, _act_, _tgt_)
Definition control.h:47
HOVER_GOTO
@ HOVER_GOTO
Definition control.h:27
can_units_do_activity_client
#define can_units_do_activity_client(_punits_, _act_)
Definition control.h:45
qtg_request_transport
bool qtg_request_transport(struct unit *pcargo, struct tile *ptile)
Definition dialogs.cpp:4872
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
get_city_bonus
int get_city_bonus(const struct city *pcity, enum effect_type effect_type)
Definition effects.c:842
next_extra_for_tile
struct extra_type * next_extra_for_tile(const struct tile *ptile, enum extra_cause cause, const struct player *pplayer, const struct unit *punit)
Definition extras.c:779
extra_number
int extra_number(const struct extra_type *pextra)
Definition extras.c:161
extra_type_list_by_cause
struct extra_type_list * extra_type_list_by_cause(enum extra_cause cause)
Definition extras.c:249
prev_extra_in_tile
struct extra_type * prev_extra_in_tile(const struct tile *ptile, enum extra_rmcause rmcause, const struct player *pplayer, const struct unit *punit)
Definition extras.c:804
extras
static struct extra_type extras[MAX_EXTRA_TYPES]
Definition extras.c:31
extra_name_translation
const char * extra_name_translation(const struct extra_type *pextra)
Definition extras.c:194
extra_type_iterate
#define extra_type_iterate(_p)
Definition extras.h:315
extra_type_iterate_end
#define extra_type_iterate_end
Definition extras.h:321
extra_type_by_cause_iterate_end
#define extra_type_by_cause_iterate_end
Definition extras.h:339
extra_type_by_cause_iterate
#define extra_type_by_cause_iterate(_cause, _extra)
Definition extras.h:333
fc_client.h
NO_TARGET
#define NO_TARGET
Definition fc_types.h:358
Unit_type_id
int Unit_type_id
Definition fc_types.h:386
Q_
#define Q_(String)
Definition fcintl.h:70
PL_
#define PL_(String1, String2, n)
Definition fcintl.h:71
_
#define _(String)
Definition fcintl.h:67
ftc_client
const struct ft_color ftc_client
Definition featured_text.c:78
city_link
const char * city_link(const struct city *pcity)
Definition featured_text.c:1076
game
struct civ_game game
Definition game.c:61
wld
struct world wld
Definition game.c:62
game_city_by_number
struct city * game_city_by_number(int id)
Definition game.c:106
game.h
tile_before_end_path
struct tile * tile_before_end_path(struct unit *punit, struct tile *ptile)
Definition goto.c:2023
send_attack_tile
bool send_attack_tile(struct unit *punit, struct tile *ptile)
Definition goto.c:1629
send_goto_tile
bool send_goto_tile(struct unit *punit, struct tile *ptile)
Definition goto.c:1559
enter_goto_state
void enter_goto_state(struct unit_list *punits)
Definition goto.c:1005
goto.h
government_name_translation
const char * government_name_translation(const struct government *pgovern)
Definition government.c:143
untargeted_revolution_allowed
bool untargeted_revolution_allowed(void)
Definition government.c:565
government_count
Government_type_id government_count(void)
Definition government.c:71
government_by_number
struct government * government_by_number(const Government_type_id gov)
Definition government.c:103
can_change_to_government
bool can_change_to_government(struct player *pplayer, const struct government *gov)
Definition government.c:166
government.h
layout
static PangoLayout * layout
Definition canvas.c:325
city_report_dialog_popup
void city_report_dialog_popup(bool raise)
Definition cityrep.c:292
popup_upgrade_dialog
void popup_upgrade_dialog(struct unit_list *punits)
Definition dialogs.c:1435
popup_disband_dialog
void popup_disband_dialog(struct unit_list *punits)
Definition dialogs.c:1473
pos
static struct tile * pos
Definition finddlg.c:53
popup_multiplier_dialog
void popup_multiplier_dialog(void)
Definition gamedlgs.c:383
popup_rates_dialog
void popup_rates_dialog(void)
Definition gamedlgs.c:533
popup_goto_dialog
void popup_goto_dialog(void)
Definition gotodlg.c:258
popup_quit_dialog
void popup_quit_dialog(void)
Definition gui_main.c:2372
popup_help_dialog_typed
void popup_help_dialog_typed(const char *item, enum help_page_type htype)
Definition helpdlg.c:196
create_line_at_mouse_pos
void create_line_at_mouse_pos(void)
Definition mapctrl.c:355
update_city_descriptions
void update_city_descriptions(void)
Definition mapview.c:488
get_tile_change_menu_text
static const char * get_tile_change_menu_text(struct tile *ptile, enum unit_activity activity)
Definition menu.c:2338
CREATE_SUB_ITEM
#define CREATE_SUB_ITEM(_sub_target_, _sub_target_key_, _sub_target_name_)
popup_messageopt_dialog
void popup_messageopt_dialog(void)
Definition messagedlg.c:51
popup_players_dialog
void popup_players_dialog(bool raise)
Definition plrdlg.c:91
economy_report_dialog_popup
void economy_report_dialog_popup(bool raise)
Definition repodlgs.c:1243
popup_spaceship_dialog
void popup_spaceship_dialog(struct player *pplayer)
Definition spaceshipdlg.c:146
delay_order
delay_order
Definition menu.h:82
D_GOTO
@ D_GOTO
Definition menu.h:83
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
enable
#define enable(id)
Definition widget.h:223
chatline.h
cityrep.h
popup_revolution_dialog
void popup_revolution_dialog(void)
Definition dialogs.c:112
dialogs.h
gotodlg.h
gui_main.h
mapctrl.h
menu.h
messagedlg.h
plrdlg.h
ratesdlg.h
repodlgs.h
spaceshipdlg.h
sprite.h
helpdata.h
HELP_MUSICSET_ITEM
#define HELP_MUSICSET_ITEM
HELP_CITIES_ITEM
#define HELP_CITIES_ITEM
HELP_TERRAIN_ITEM
#define HELP_TERRAIN_ITEM
HELP_LANGUAGES_ITEM
#define HELP_LANGUAGES_ITEM
HELP_CONNECTING_ITEM
#define HELP_CONNECTING_ITEM
HELP_TILESET_ITEM
#define HELP_TILESET_ITEM
HELP_CHATLINE_ITEM
#define HELP_CHATLINE_ITEM
HELP_RULESET_ITEM
#define HELP_RULESET_ITEM
HELP_GOVERNMENT_ITEM
#define HELP_GOVERNMENT_ITEM
HELP_ABOUT_ITEM
#define HELP_ABOUT_ITEM
HELP_PLAYING_ITEM
#define HELP_PLAYING_ITEM
HELP_IMPROVEMENTS_ITEM
#define HELP_IMPROVEMENTS_ITEM
HELP_UNITS_ITEM
#define HELP_UNITS_ITEM
HELP_ZOC_ITEM
#define HELP_ZOC_ITEM
HELP_WORKLIST_EDITOR_ITEM
#define HELP_WORKLIST_EDITOR_ITEM
HELP_WONDERS_ITEM
#define HELP_WONDERS_ITEM
HELP_COMBAT_ITEM
#define HELP_COMBAT_ITEM
HELP_SPACE_RACE_ITEM
#define HELP_SPACE_RACE_ITEM
HELP_COPYING_ITEM
#define HELP_COPYING_ITEM
HELP_OVERVIEW_ITEM
#define HELP_OVERVIEW_ITEM
HELP_NATIONS_ITEM
#define HELP_NATIONS_ITEM
HELP_TECHS_ITEM
#define HELP_TECHS_ITEM
HELP_DIPLOMACY_ITEM
#define HELP_DIPLOMACY_ITEM
HELP_ECONOMY_ITEM
#define HELP_ECONOMY_ITEM
HELP_ANY
@ HELP_ANY
Definition helpdlg_g.h:20
HELP_CMA_ITEM
#define HELP_CMA_ITEM
HELP_CONTROLS_ITEM
#define HELP_CONTROLS_ITEM
has_player_unit_type
bool has_player_unit_type(Unit_type_id utype)
Definition hudwidget.cpp:60
hudwidget.h
improvement_number
Impr_type_id improvement_number(const struct impr_type *pimprove)
Definition improvement.c:184
improvement_name_translation
const char * improvement_name_translation(const struct impr_type *pimprove)
Definition improvement.c:243
improvement_iterate_end
#define improvement_iterate_end
Definition improvement.h:205
improvement_iterate
#define improvement_iterate(_p)
Definition improvement.h:199
fc_assert
#define fc_assert(condition)
Definition log.h:176
get_direction_for_step
int get_direction_for_step(const struct civ_map *nmap, const struct tile *start_tile, const struct tile *end_tile)
Definition map.c:1362
is_tiles_adjacent
bool is_tiles_adjacent(const struct tile *tile0, const struct tile *tile1)
Definition map.c:941
terrain_control
struct terrain_misc terrain_control
Definition map.c:68
mapview
struct view mapview
Definition mapview_common.c:75
map_canvas_resized
bool map_canvas_resized(int width, int height)
Definition mapview_common.c:3564
fc_malloc
#define fc_malloc(sz)
Definition mem.h:34
ADD_OLD_SHORTCUT
#define ADD_OLD_SHORTCUT(wanted_action_id, sc_id)
enable_interface
static void enable_interface(bool enable)
Definition menu.cpp:3197
multiairlift
void multiairlift(struct city *acity, Unit_type_id ut)
Definition menu.cpp:3918
real_menus_init
void real_menus_init(void)
Definition menu.cpp:512
get_tile_change_menu_text
static const char * get_tile_change_menu_text(struct tile *ptile, enum unit_activity activity)
Definition menu.cpp:553
real_menus_update
void real_menus_update(void)
Definition menu.cpp:530
gui
static mpgui * gui
Definition mpgui_qt.cpp:52
multiplier_count
Multiplier_type_id multiplier_count(void)
Definition multipliers.c:88
name_translation.h
fonts::city_productions
const char *const city_productions
Definition fonts.h:33
fonts::city_names
const char *const city_names
Definition fonts.h:32
nation_plural_for_player
const char * nation_plural_for_player(const struct player *pplayer)
Definition nation.c:178
client_optset
const struct option_set * client_optset
Definition options.c:1315
options_save
void options_save(option_save_log_callback log_cb)
Definition options.c:6341
gui_options
struct client_options gui_options
Definition options.c:71
optset_option_by_name
struct option * optset_option_by_name(const struct option_set *poptset, const char *name)
Definition options.c:466
cities
struct city_list * cities
Definition packhand.c:119
popup_shortcuts_dialog
void popup_shortcuts_dialog()
Definition shortcuts.cpp:756
toggle_units_report
void toggle_units_report(bool)
Definition repodlgs.cpp:1872
players_iterate_end
#define players_iterate_end
Definition player.h:539
players_iterate
#define players_iterate(_pplayer)
Definition player.h:534
qtg_science_report_dialog_popup
void qtg_science_report_dialog_popup(bool raise)
Definition repodlgs.cpp:1660
popup_endgame_report
void popup_endgame_report()
Definition repodlgs.cpp:1778
road_extra_get
struct extra_type * road_extra_get(const struct road_type *proad)
Definition road.c:42
road_by_gui_type
struct road_type * road_by_gui_type(enum road_gui_type gui_type)
Definition road.c:180
road.h
get_save_dirs
const struct strvec * get_save_dirs(void)
Definition shared.c:934
array_shuffle
void array_shuffle(int *array, int n)
Definition shared.c:2008
freeciv_storage_dir
char * freeciv_storage_dir(void)
Definition shared.c:671
DIR_SEPARATOR
#define DIR_SEPARATOR
Definition shared.h:127
shortcut_to_string
QString shortcut_to_string(fc_shortcut *sc)
Definition shortcuts.cpp:184
shortcuts.h
shortcut_id
shortcut_id
Definition shortcuts.h:33
SC_PARADROP
@ SC_PARADROP
Definition shortcuts.h:95
SC_UPGRADE_UNIT
@ SC_UPGRADE_UNIT
Definition shortcuts.h:63
SC_BUILDIRRIGATION
@ SC_BUILDIRRIGATION
Definition shortcuts.h:67
SC_BUILDCITY
@ SC_BUILDCITY
Definition shortcuts.h:70
SC_DONE_MOVING
@ SC_DONE_MOVING
Definition shortcuts.h:57
SC_BUILDROAD
@ SC_BUILDROAD
Definition shortcuts.h:69
SC_UNSENTRY_TILE
@ SC_UNSENTRY_TILE
Definition shortcuts.h:61
SC_CULTIVATE
@ SC_CULTIVATE
Definition shortcuts.h:68
SC_DO
@ SC_DO
Definition shortcuts.h:62
SC_CENTER_VIEW
@ SC_CENTER_VIEW
Definition shortcuts.h:36
SC_SENTRY
@ SC_SENTRY
Definition shortcuts.h:71
SC_GOBUILDCITY
@ SC_GOBUILDCITY
Definition shortcuts.h:92
SC_NUKE
@ SC_NUKE
Definition shortcuts.h:76
SC_AUTOEXPLORE
@ SC_AUTOEXPLORE
Definition shortcuts.h:59
SC_SETHOME
@ SC_SETHOME
Definition shortcuts.h:64
SC_PLANT
@ SC_PLANT
Definition shortcuts.h:66
SC_BUILDMINE
@ SC_BUILDMINE
Definition shortcuts.h:65
SC_FULLSCREEN
@ SC_FULLSCREEN
Definition shortcuts.h:37
SC_TRADE_ROUTES
@ SC_TRADE_ROUTES
Definition shortcuts.h:54
SC_CITY_OUTPUT
@ SC_CITY_OUTPUT
Definition shortcuts.h:39
SC_TRANSFORM
@ SC_TRANSFORM
Definition shortcuts.h:75
SC_STACK_SIZE
@ SC_STACK_SIZE
Definition shortcuts.h:94
SC_FORTIFY
@ SC_FORTIFY
Definition shortcuts.h:72
SC_ZOOM_IN
@ SC_ZOOM_IN
Definition shortcuts.h:87
SC_GOJOINCITY
@ SC_GOJOINCITY
Definition shortcuts.h:93
SC_MAP_GRID
@ SC_MAP_GRID
Definition shortcuts.h:40
SC_MINIMAP
@ SC_MINIMAP
Definition shortcuts.h:38
SC_CITY_PROD
@ SC_CITY_PROD
Definition shortcuts.h:55
SC_PATROL
@ SC_PATROL
Definition shortcuts.h:60
SC_GOTO
@ SC_GOTO
Definition shortcuts.h:73
SC_GOTOAIRLIFT
@ SC_GOTOAIRLIFT
Definition shortcuts.h:58
SC_WAIT
@ SC_WAIT
Definition shortcuts.h:74
SC_IFACE_LOCK
@ SC_IFACE_LOCK
Definition shortcuts.h:80
SC_DEBOARD
@ SC_DEBOARD
Definition shortcuts.h:78
SC_ZOOM_RESET
@ SC_ZOOM_RESET
Definition shortcuts.h:91
SC_ZOOM_OUT
@ SC_ZOOM_OUT
Definition shortcuts.h:88
SC_AUTOMATE
@ SC_AUTOMATE
Definition shortcuts.h:81
SC_CITY_NAMES
@ SC_CITY_NAMES
Definition shortcuts.h:56
SC_BOARD
@ SC_BOARD
Definition shortcuts.h:77
SC_CLEAN
@ SC_CLEAN
Definition shortcuts.h:82
SC_NAT_BORDERS
@ SC_NAT_BORDERS
Definition shortcuts.h:41
SC_SHOW_FULLBAR
@ SC_SHOW_FULLBAR
Definition shortcuts.h:86
string_vector.h
strvec_iterate
#define strvec_iterate(psv, str)
Definition string_vector.h:61
strvec_iterate_end
#define strvec_iterate_end
Definition string_vector.h:68
action
Definition actions.h:106
canvas::map_pixmap
QPixmap map_pixmap
Definition canvas.h:25
city
Definition city.h:320
city::name
char * name
Definition city.h:321
city::tile
struct tile * tile
Definition city.h:322
civ_game::info
struct packet_game_info info
Definition game.h:89
civ_game::ruleset_ready
bool ruleset_ready
Definition game.h:117
civ_game::client
struct civ_game::@31::@34 client
civ_game::government_during_revolution
struct government * government_during_revolution
Definition game.h:94
civclient::conn
struct connection conn
Definition client_main.h:96
client_options::gui_qt_fullscreen
bool gui_qt_fullscreen
Definition options.h:443
client_options::draw_native
bool draw_native
Definition options.h:216
client_options::draw_city_output
bool draw_city_output
Definition options.h:195
client_options::draw_city_names
bool draw_city_names
Definition options.h:197
client_options::draw_city_productions
bool draw_city_productions
Definition options.h:199
client_options::draw_borders
bool draw_borders
Definition options.h:215
client_options::draw_city_buycost
bool draw_city_buycost
Definition options.h:200
client_options::draw_unit_stack_size
bool draw_unit_stack_size
Definition options.h:219
client_options::draw_city_trade_routes
bool draw_city_trade_routes
Definition options.h:201
client_options::unit_selection_clears_orders
bool unit_selection_clears_orders
Definition options.h:176
client_options::save_options_on_exit
bool save_options_on_exit
Definition options.h:125
client_options::draw_map_grid
bool draw_map_grid
Definition options.h:196
client_options::draw_city_growth
bool draw_city_growth
Definition options.h:198
client_options::draw_city_outlines
bool draw_city_outlines
Definition options.h:194
client_options::draw_full_citybar
bool draw_full_citybar
Definition options.h:217
connection::used
bool used
Definition connection.h:139
extra_type
Definition extras.h:88
fc_shortcut
Definition shortcuts.h:105
government
Definition government.h:52
item
Definition climisc.h:80
option
Definition options.c:514
packet_game_info::turn
int turn
Definition packets_gen.h:245
packet_game_info::top_cities_count
int top_cities_count
Definition packets_gen.h:249
player
Definition player.h:249
player::cities
struct city_list * cities
Definition player.h:281
qtiles
Definition menu.h:160
road_type
Definition road.h:71
sprite
Definition sprite.h:22
sprite::pm
QPixmap * pm
Definition sprite.h:25
strvec
Definition string_vector.c:29
terrain
Definition terrain.h:75
terrain::cultivate_result
struct terrain * cultivate_result
Definition terrain.h:108
terrain::plant_result
struct terrain * plant_result
Definition terrain.h:111
terrain::transform_result
struct terrain * transform_result
Definition terrain.h:122
tile
Definition tile.h:50
tile::units
struct unit_list * units
Definition tile.h:58
tileset
Definition tilespec.c:482
unit_type
Definition unittype.h:507
unit
Definition unit.h:140
unit::id
int id
Definition unit.h:147
unit::tile
struct tile * tile
Definition unit.h:142
unit::homecity
int homecity
Definition unit.h:148
unit::utype
const struct unit_type * utype
Definition unit.h:141
view::store
struct canvas * store
Definition mapview_common.h:42
world::map
struct civ_map map
Definition world_object.h:38
fc_snprintf
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:960
TRUE
#define TRUE
Definition support.h:46
FALSE
#define FALSE
Definition support.h:47
advance_name_translation
const char * advance_name_translation(const struct advance *padvance)
Definition tech.c:300
advance_number
Tech_type_id advance_number(const struct advance *padvance)
Definition tech.c:98
advance_iterate
#define advance_iterate(_p)
Definition tech.h:276
advance_iterate_end
#define advance_iterate_end
Definition tech.h:277
T_NONE
#define T_NONE
Definition terrain.h:61
tile_virtual_destroy
void tile_virtual_destroy(struct tile *vtile)
Definition tile.c:1035
tile_apply_activity
bool tile_apply_activity(struct tile *ptile, Activity_type_id act, struct extra_type *tgt)
Definition tile.c:681
tile_virtual_new
struct tile * tile_virtual_new(const struct tile *ptile)
Definition tile.c:981
tile_get_info_text
const char * tile_get_info_text(const struct tile *ptile, bool include_nuisances, int linebreaks)
Definition tile.c:771
tile_city
struct city * tile_city(const struct tile *ptile)
Definition tile.c:83
tile_terrain
#define tile_terrain(_tile)
Definition tile.h:111
get_government_sprite
struct sprite * get_government_sprite(const struct tileset *t, const struct government *gov)
Definition tilespec.c:6832
tileset_hex_width
int tileset_hex_width(const struct tileset *t)
Definition tilespec.c:722
get_tileset_list
const struct strvec * get_tileset_list(const struct option *poption)
Definition tilespec.c:1125
tileset_is_isometric
bool tileset_is_isometric(const struct tileset *t)
Definition tilespec.c:713
tileset_basename
const char * tileset_basename(const struct tileset *t)
Definition tilespec.c:705
tileset_tile_height
int tileset_tile_height(const struct tileset *t)
Definition tilespec.c:766
tileset_tile_width
int tileset_tile_width(const struct tileset *t)
Definition tilespec.c:754
tilespec_reread
bool tilespec_reread(const char *new_tileset_name, bool game_fully_initialized, float scale)
Definition tilespec.c:1376
city_num_trade_routes
int city_num_trade_routes(const struct city *pcity)
Definition traderoutes.c:392
max_trade_routes
unsigned max_trade_routes(const struct city *pcity)
Definition traderoutes.c:48
can_establish_trade_route
bool can_establish_trade_route(const struct city *pc1, const struct city *pc2, int priority)
Definition traderoutes.c:283
have_cities_trade_route
bool have_cities_trade_route(const struct city *pc1, const struct city *pc2)
Definition traderoutes.c:550
GOODS_HIGH_PRIORITY
#define GOODS_HIGH_PRIORITY
Definition traderoutes.h:184
can_unit_change_homecity
bool can_unit_change_homecity(const struct unit *punit)
Definition unit.c:509
unit_can_est_trade_route_here
bool unit_can_est_trade_route_here(const struct unit *punit)
Definition unit.c:287
unit_can_add_or_build_city
bool unit_can_add_or_build_city(const struct unit *punit)
Definition unit.c:475
unit_contained_in
bool unit_contained_in(const struct unit *pcargo, const struct unit *ptrans)
Definition unit.c:2578
unit_can_help_build_wonder_here
bool unit_can_help_build_wonder_here(const struct unit *punit)
Definition unit.c:261
can_unit_do_autoworker
bool can_unit_do_autoworker(const struct unit *punit)
Definition unit.c:630
can_unit_paradrop
bool can_unit_paradrop(const struct civ_map *nmap, const struct unit *punit)
Definition unit.c:847
unit.h
unit_tile
#define unit_tile(_pu)
Definition unit.h:397
ORDER_LAST
@ ORDER_LAST
Definition unit.h:50
ORDER_PERFORM_ACTION
@ ORDER_PERFORM_ACTION
Definition unit.h:48
unit_owner
#define unit_owner(_pu)
Definition unit.h:396
units_can_convert
bool units_can_convert(const struct civ_map *nmap, const struct unit_list *punits)
Definition unitlist.c:350
units_are_occupied
bool units_are_occupied(const struct unit_list *punits)
Definition unitlist.c:273
units_can_unload
bool units_can_unload(const struct civ_map *nmap, const struct unit_list *punits)
Definition unitlist.c:301
can_units_do_base_gui
bool can_units_do_base_gui(const struct unit_list *punits, enum base_gui_type base_gui)
Definition unitlist.c:180
units_contain_cityfounder
bool units_contain_cityfounder(const struct unit_list *punits)
Definition unitlist.c:217
can_units_do_any_road
bool can_units_do_any_road(const struct civ_map *nmap, const struct unit_list *punits)
Definition unitlist.c:161
unit_list_find
struct unit * unit_list_find(const struct unit_list *punitlist, int unit_id)
Definition unitlist.c:30
units_can_upgrade
bool units_can_upgrade(const struct civ_map *nmap, const struct unit_list *punits)
Definition unitlist.c:335
units_have_activity_on_tile
bool units_have_activity_on_tile(const struct unit_list *punits, enum unit_activity activity)
Definition unitlist.c:319
units_have_type_flag
bool units_have_type_flag(const struct unit_list *punits, enum unit_type_flag_id flag, bool has_flag)
Definition unitlist.c:202
can_units_do
bool can_units_do(const struct unit_list *punits, bool(can_fn)(const struct unit *punit))
Definition unitlist.c:95
units_can_do_action
bool units_can_do_action(const struct unit_list *punits, action_id act_id, bool can_do)
Definition unitlist.c:239
units_can_load
bool units_can_load(const struct unit_list *punits)
Definition unitlist.c:287
can_units_do_on_map
bool can_units_do_on_map(const struct civ_map *nmap, const struct unit_list *punits, bool(can_fn)(const struct civ_map *nmap, const struct unit *punit))
Definition unitlist.c:111
unit_list_iterate
#define unit_list_iterate(unitlist, punit)
Definition unitlist.h:31
unit_list_iterate_end
#define unit_list_iterate_end
Definition unitlist.h:33
unit_type_get
const struct unit_type * unit_type_get(const struct unit *punit)
Definition unittype.c:123
utype_by_number
struct unit_type * utype_by_number(const Unit_type_id id)
Definition unittype.c:112
utype_index
Unit_type_id utype_index(const struct unit_type *punittype)
Definition unittype.c:91
can_player_build_unit_now
bool can_player_build_unit_now(const struct player *p, const struct unit_type *punittype)
Definition unittype.c:2078
utype_name_translation
const char * utype_name_translation(const struct unit_type *punittype)
Definition unittype.c:1560
utype_can_do_action
bool utype_can_do_action(const struct unit_type *putype, const action_id act_id)
Definition unittype.c:371
unit_type_iterate
#define unit_type_iterate(_p)
Definition unittype.h:859
unit_type_iterate_end
#define unit_type_iterate_end
Definition unittype.h:866
MAP_NATIVE_WIDTH
#define MAP_NATIVE_WIDTH
Definition world_object.h:55
MAP_NATIVE_HEIGHT
#define MAP_NATIVE_HEIGHT
Definition world_object.h:56