Freeciv-3.2: /fast/freeciv/nightly/S3_2/client/gui-qt/menu.cpp Source File

Freeciv-3.2

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