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

Freeciv-3.1

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**************************************************************************/
672QSet<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 static void reset_menu_and_sub_menues(QMenu *menu)
717{
718 QAction *action;
719
720 /* Delete each existing menu item. */
721 foreach(action, menu->actions()) {
722 if (action->menu() != nullptr) {
723 /* Delete the sub menu */
724 reset_menu_and_sub_menues(action->menu());
725 action->menu()->deleteLater();
726 }
727
728 menu->removeAction(action);
729 action->deleteLater();
730 }
731}
732
733/**********************************************************************/
736 void go_act_menu::reset()
737{
738 /* Clear menu item to action ID mapping. */
739 items.clear();
740
741 /* Remove the menu items */
742 reset_menu_and_sub_menues(this);
743}
744
745/**********************************************************************/
748 void go_act_menu::create()
749{
750 QAction *item;
751 int tgt_kind_group;
752
753 /* Group goto and perform action menu items by target kind. */
754 for (tgt_kind_group = 0; tgt_kind_group < ATK_COUNT; tgt_kind_group++) {
755 action_iterate(act_id) {
756 struct action *paction = action_by_number(act_id);
757 QString action_name = (QString(action_name_translation(paction))
758 .replace("&", "&&"));
759
760 if (action_id_get_actor_kind(act_id) != AAK_UNIT) {
761 /* This action isn't performed by a unit. */
762 continue;
763 }
764
765 if (action_id_get_target_kind(act_id) != tgt_kind_group) {
766 /* Wrong group. */
767 continue;
768 }
769
770 if (action_id_has_complex_target(act_id)) {
771 QMenu *sub_target_menu = addMenu(action_name);
772 items.insert(sub_target_menu->menuAction(), act_id);
773
774#define CREATE_SUB_ITEM(_menu_, _act_id_, _sub_tgt_id_, _sub_tgt_name_) \
775 { \
776 QAction *_sub_item_ = _menu_->addAction(_sub_tgt_name_); \
777 int _sub_target_id_ = _sub_tgt_id_; \
778 QObject::connect(_sub_item_, &QAction::triggered, \
779 [this, _act_id_, _sub_target_id_]() { \
780 start_go_act(_act_id_, _sub_target_id_); \
781 }); \
782 }
783
784 switch (action_get_sub_target_kind(paction)) {
785 case ASTK_BUILDING:
786 improvement_iterate(pimpr) {
787 CREATE_SUB_ITEM(sub_target_menu, act_id,
788 improvement_number(pimpr),
789 improvement_name_translation(pimpr));
790 } improvement_iterate_end;
791 break;
792 case ASTK_TECH:
793 advance_iterate(A_FIRST, ptech) {
794 CREATE_SUB_ITEM(sub_target_menu, act_id,
795 advance_number(ptech),
796 advance_name_translation(ptech));
797 } advance_iterate_end;
798 break;
799 case ASTK_EXTRA:
800 case ASTK_EXTRA_NOT_THERE:
801 extra_type_iterate(pextra) {
802 if (!(action_creates_extra(paction, pextra)
803 || action_removes_extra(paction, pextra))) {
804 /* Not relevant */
805 continue;
806 }
807
808 CREATE_SUB_ITEM(sub_target_menu, act_id,
809 extra_number(pextra),
810 extra_name_translation(pextra));
811 } extra_type_iterate_end;
812 break;
813 case ASTK_NONE:
814 /* Should not be here. */
815 fc_assert(action_get_sub_target_kind(paction) != ASTK_NONE);
816 break;
817 case ASTK_COUNT:
818 /* Should not exits */
819 fc_assert(action_get_sub_target_kind(paction) != ASTK_COUNT);
820 break;
821 }
822 continue;
823 }
824
825#define ADD_OLD_SHORTCUT(wanted_action_id, sc_id) \
826 if (act_id == wanted_action_id) { \
827 item->setShortcut(QKeySequence(shortcut_to_string( \
828 fc_shortcuts::sc()->get_shortcut(sc_id)))); \
829 }
830
831 /* Create and add the menu item. It will be hidden or shown based on
832 * unit type. */
833 item = addAction(action_name);
834 items.insert(item, act_id);
835
836 /* Add the keyboard shortcuts for "Go to and..." menu items that
837 * existed independently before the "Go to and..." menu arrived. */
838 ADD_OLD_SHORTCUT(ACTION_FOUND_CITY, SC_GOBUILDCITY);
839 ADD_OLD_SHORTCUT(ACTION_JOIN_CITY, SC_GOJOINCITY);
840 ADD_OLD_SHORTCUT(ACTION_NUKE, SC_NUKE);
841
842 QObject::connect(item, &QAction::triggered, [this,act_id]() {
843 start_go_act(act_id, NO_TARGET);
844 });
845 } action_iterate_end;
846 }
847}
848
849/**********************************************************************/
852 void go_act_menu::update()
853{
854 bool can_do_something = false;
855
856 if (!actions_are_ready()) {
857 /* Nothing to do. */
858 return;
859 }
860
861 if (items.isEmpty()) {
862 /* The goto and act menu needs menu items. */
863 create();
864 }
865
866 /* Enable a menu item if it is theoretically possible that one of the
867 * selected units can perform it. Checking if the action can be performed
868 * at the current tile is pointless since it should be performed at the
869 * target tile. */
870 foreach(QAction *item, items.keys()) {
871 if (units_can_do_action(get_units_in_focus(),
872 items.value(item), TRUE)) {
873 item->setVisible(true);
874 can_do_something = true;
875 } else {
876 item->setVisible(false);
877 }
878 }
879
880 if (can_do_something) {
881 /* At least one menu item is enabled for one of the selected units. */
882 setEnabled(true);
883 } else {
884 /* No menu item is enabled any of the selected units. */
885 setEnabled(false);
886 }
887}
888
889/**********************************************************************/
892 void go_act_menu::start_go_act(int act_id, int sub_tgt_id)
893{
894 request_unit_goto(ORDER_PERFORM_ACTION, act_id, sub_tgt_id);
895}
896
897/**************************************************************************
898 Store all goto and act menu items so they can be updated etc
899**************************************************************************/
900QSet<go_act_menu *> go_act_menu::instances;
901
902/**********************************************************************/
905 void go_act_menu::reset_all()
906{
907 foreach (go_act_menu *m, instances) {
908 m->reset();
909 }
910}
911
912/**********************************************************************/
915 void go_act_menu::update_all()
916{
917 foreach (go_act_menu *m, instances) {
918 m->update();
919 }
920}
921
922/**********************************************************************/
925 struct tile *mr_menu::find_last_unit_pos(unit *punit, int pos)
926{
927 qfc_delayed_unit_item *fui;
928 struct tile *ptile = nullptr;
929 struct unit *zunit;
930 struct unit *qunit;
931
932 int i = 0;
933 qunit = punit;
934 foreach (fui, units_list.unit_list) {
935 zunit = unit_list_find(client_player()->units, fui->id);
936 i++;
937 if (i >= pos) {
938 punit = qunit;
939 return ptile;
940 }
941 if (zunit == nullptr) {
942 continue;
943 }
944
945 if (punit == zunit) { /* Unit found */
946 /* Unit was ordered to attack city so it might stay in
947 front of that city */
948 if (is_non_allied_city_tile(fui->ptile, unit_owner(punit))) {
949 ptile = tile_before_end_path(punit, fui->ptile);
950 if (ptile == nullptr) {
951 ptile = fui->ptile;
952 }
953 } else {
954 ptile = fui->ptile;
955 }
956 // Unit found in transport
957 } else if (unit_contained_in(punit, zunit)) {
958 ptile = fui->ptile;
959 }
960 }
961 return nullptr;
962}
963
964/**********************************************************************/
967mr_menu::mr_menu() : QMenuBar()
968{
969}
970
971/**********************************************************************/
976 void mr_menu::setup_menus()
977{
978 QAction *act;
979 QMenu *menu;
980 QMenu *pr;
981 QList<QMenu*> menus;
982 int i;
983
984 delayed_order = false;
985 airlift_type_id = 0;
986 quick_airlifting = false;
987
988 /* Game Menu */
989 menu = this->addMenu(_("Game"));
990 pr = menu;
991
992#ifdef __APPLE__
993 // On Mac, Qt would try to move menu entry named just "Options" to
994 // application menu, but as this is submenu and not an action
995 // 1) It would fail to appear in the destination
996 // 2) It's impossible to override the behavior with QAction::menuRule()
997 // We add an invisible character for the string comparison to fail.
998 menu = menu->addMenu(QString("\u200B") + _("Options"));
999#else // __APPLE__
1000 menu = menu->addMenu(_("Options"));
1001#endif // __APPLE__
1002
1003 act = menu->addAction(_("Set local options"));
1004 connect(act, &QAction::triggered, this, &mr_menu::local_options);
1005 act = menu->addAction(_("Server Options"));
1006 connect(act, &QAction::triggered, this, &mr_menu::server_options);
1007 act = menu->addAction(_("Messages"));
1008 connect(act, &QAction::triggered, this, &mr_menu::messages_options);
1009 act = menu->addAction(_("Shortcuts"));
1010 connect(act, &QAction::triggered, this, &mr_menu::shortcut_options);
1011 act = menu->addAction(_("Load another tileset"));
1012 connect(act, &QAction::triggered, this, &mr_menu::tileset_custom_load);
1013 act = menu->addAction(_("Save Options Now"));
1014 act->setIcon(style()->standardIcon(QStyle::SP_DialogSaveButton));
1015 connect(act, &QAction::triggered, this, &mr_menu::save_options_now);
1016 act = menu->addAction(_("Save Options on Exit"));
1017 act->setCheckable(true);
1018 act->setChecked(gui_options.save_options_on_exit);
1019 menu = pr;
1020 menu->addSeparator();
1021 act = menu->addAction(_("Save Game"));
1022 act->setShortcut(QKeySequence(tr("Ctrl+s")));
1023 act->setIcon(style()->standardIcon(QStyle::SP_DialogSaveButton));
1024 menu_list.insert(SAVE, act);
1025 connect(act, &QAction::triggered, this, &mr_menu::save_game);
1026 act = menu->addAction(_("Save Game As..."));
1027 menu_list.insert(SAVE, act);
1028 act->setIcon(style()->standardIcon(QStyle::SP_DialogSaveButton));
1029 connect(act, &QAction::triggered, this, &mr_menu::save_game_as);
1030 act = menu->addAction(_("Save Map to Image"));
1031 connect(act, &QAction::triggered, this, &mr_menu::save_image);
1032 menu->addSeparator();
1033 act = menu->addAction(_("Leave game"));
1034 act->setIcon(style()->standardIcon(QStyle::SP_DialogDiscardButton));
1035 connect(act, &QAction::triggered, this, &mr_menu::back_to_menu);
1036 act = menu->addAction(_("Quit"));
1037 act->setIcon(style()->standardIcon(QStyle::SP_TitleBarCloseButton));
1038 connect(act, &QAction::triggered, this, &mr_menu::quit_game);
1039
1040 /* View Menu */
1041 menu = this->addMenu(Q_("?verb:View"));
1042 act = menu->addAction(_("Center View"));
1043 act->setShortcut(QKeySequence(shortcut_to_string(
1044 fc_shortcuts::sc()->get_shortcut(SC_CENTER_VIEW))));
1045 connect(act, &QAction::triggered, this, &mr_menu::slot_center_view);
1046 menu->addSeparator();
1047 act = menu->addAction(_("Fullscreen"));
1048 act->setShortcut(QKeySequence(shortcut_to_string(
1049 fc_shortcuts::sc()->get_shortcut(SC_FULLSCREEN))));
1050 act->setCheckable(true);
1051 act->setChecked(gui_options.gui_qt_fullscreen);
1052 connect(act, &QAction::triggered, this, &mr_menu::slot_fullscreen);
1053 menu->addSeparator();
1054 minimap_status = menu->addAction(_("Minimap"));
1055 minimap_status->setCheckable(true);
1056 minimap_status->setShortcut(QKeySequence(shortcut_to_string(
1057 fc_shortcuts::sc()->get_shortcut(SC_MINIMAP))));
1058 minimap_status->setChecked(true);
1059 connect(minimap_status, &QAction::triggered, this,
1060 &mr_menu::slot_minimap_view);
1061 osd_status = menu->addAction(_("Show new turn information"));
1062 osd_status->setCheckable(true);
1063 osd_status->setChecked(gui()->qt_settings.show_new_turn_text);
1064 connect(osd_status, &QAction::triggered, this,
1065 &mr_menu::slot_show_new_turn_text);
1066 btlog_status = menu->addAction(_("Show combat detailed information"));
1067 btlog_status->setCheckable(true);
1068 btlog_status->setChecked(gui()->qt_settings.show_battle_log);
1069 connect(btlog_status, &QAction::triggered, this, &mr_menu::slot_battlelog);
1070 lock_status = menu->addAction(_("Lock interface"));
1071 lock_status->setCheckable(true);
1072 lock_status->setShortcut(QKeySequence(shortcut_to_string(
1073 fc_shortcuts::sc()->get_shortcut(SC_IFACE_LOCK))));
1074 lock_status->setChecked(false);
1075 connect(lock_status, &QAction::triggered, this, &mr_menu::slot_lock);
1076 connect(minimap_status, &QAction::triggered, this, &mr_menu::slot_lock);
1077 menu->addSeparator();
1078 act = menu->addAction(_("Zoom in"));
1079 act->setShortcut(QKeySequence(shortcut_to_string(
1080 fc_shortcuts::sc()->get_shortcut(SC_ZOOM_IN))));
1081 connect(act, &QAction::triggered, this, &mr_menu::zoom_in);
1082 act = menu->addAction(_("Zoom default"));
1083 act->setShortcut(QKeySequence(shortcut_to_string(
1084 fc_shortcuts::sc()->get_shortcut(SC_ZOOM_RESET))));
1085 connect(act, &QAction::triggered, this, &mr_menu::zoom_reset);
1086 act = menu->addAction(_("Zoom out"));
1087 act->setShortcut(QKeySequence(shortcut_to_string(
1088 fc_shortcuts::sc()->get_shortcut(SC_ZOOM_OUT))));
1089 connect(act, &QAction::triggered, this, &mr_menu::zoom_out);
1090 scale_fonts_status = menu->addAction(_("Scale fonts"));
1091 connect(scale_fonts_status, &QAction::triggered, this,
1092 &mr_menu::zoom_scale_fonts);
1093 scale_fonts_status->setCheckable(true);
1094 scale_fonts_status->setChecked(true);
1095 menu->addSeparator();
1096 act = menu->addAction(_("City Outlines"));
1097 act->setCheckable(true);
1098 act->setChecked(gui_options.draw_city_outlines);
1099 connect(act, &QAction::triggered, this, &mr_menu::slot_city_outlines);
1100 act = menu->addAction(_("City Output"));
1101 act->setCheckable(true);
1102 act->setChecked(gui_options.draw_city_output);
1103 act->setShortcut(QKeySequence(shortcut_to_string(
1104 fc_shortcuts::sc()->get_shortcut(SC_CITY_OUTPUT))));
1105 connect(act, &QAction::triggered, this, &mr_menu::slot_city_output);
1106 act = menu->addAction(_("Map Grid"));
1107 act->setShortcut(QKeySequence(shortcut_to_string(
1108 fc_shortcuts::sc()->get_shortcut(SC_MAP_GRID))));
1109 act->setCheckable(true);
1110 act->setChecked(gui_options.draw_map_grid);
1111 connect(act, &QAction::triggered, this, &mr_menu::slot_map_grid);
1112 act = menu->addAction(_("National Borders"));
1113 act->setCheckable(true);
1114 act->setChecked(gui_options.draw_borders);
1115 act->setShortcut(QKeySequence(shortcut_to_string(
1116 fc_shortcuts::sc()->get_shortcut(SC_NAT_BORDERS))));
1117 connect(act, &QAction::triggered, this, &mr_menu::slot_borders);
1118 act = menu->addAction(_("Native Tiles"));
1119 act->setCheckable(true);
1120 act->setChecked(gui_options.draw_native);
1121 act->setShortcut(QKeySequence(tr("ctrl+shift+n")));
1122 connect(act, &QAction::triggered, this, &mr_menu::slot_native_tiles);
1123 act = menu->addAction(_("City Full Bar"));
1124 act->setCheckable(true);
1125 act->setShortcut(QKeySequence(shortcut_to_string(
1126 fc_shortcuts::sc()->get_shortcut(SC_SHOW_FULLBAR))));
1127 act->setChecked(gui_options.draw_full_citybar);
1128 connect(act, &QAction::triggered, this, &mr_menu::slot_fullbar);
1129 act = menu->addAction(_("City Names"));
1130 act->setCheckable(true);
1131 act->setChecked(gui_options.draw_city_names);
1132 act->setShortcut(QKeySequence(shortcut_to_string(
1133 fc_shortcuts::sc()->get_shortcut(SC_CITY_NAMES))));
1134 connect(act, &QAction::triggered, this, &mr_menu::slot_city_names);
1135 act = menu->addAction(_("City Growth"));
1136 act->setCheckable(true);
1137 act->setChecked(gui_options.draw_city_growth);
1138 act->setShortcut(QKeySequence(tr("ctrl+o")));
1139 connect(act, &QAction::triggered, this, &mr_menu::slot_city_growth);
1140 act = menu->addAction(_("City Production"));
1141 act->setCheckable(true);
1142 act->setChecked(gui_options.draw_city_productions);
1143 act->setShortcut(QKeySequence(shortcut_to_string(
1144 fc_shortcuts::sc()->get_shortcut(SC_CITY_PROD))));
1145 connect(act, &QAction::triggered, this, &mr_menu::slot_city_production);
1146 act = menu->addAction(_("City Buy Cost"));
1147 act->setCheckable(true);
1148 act->setChecked(gui_options.draw_city_buycost);
1149 connect(act, &QAction::triggered, this, &mr_menu::slot_city_buycost);
1150 act = menu->addAction(_("City Trade Routes"));
1151 act->setCheckable(true);
1152 act->setChecked(gui_options.draw_city_trade_routes);
1153 act->setShortcut(QKeySequence(shortcut_to_string(
1154 fc_shortcuts::sc()->get_shortcut(SC_TRADE_ROUTES))));
1155 connect(act, &QAction::triggered, this, &mr_menu::slot_city_trade_routes);
1156 act = menu->addAction(_("Unit Stack Size"));
1157 act->setCheckable(true);
1158 act->setChecked(gui_options.draw_unit_stack_size);
1159 act->setShortcut(QKeySequence(shortcut_to_string(
1160 fc_shortcuts::sc()->get_shortcut(SC_STACK_SIZE))));
1161 connect(act, &QAction::triggered, this, &mr_menu::slot_stack_size);
1162
1163 /* Select Menu */
1164 menu = this->addMenu(_("Select"));
1165 act = menu->addAction(_("Single Unit (Unselect Others)"));
1166 act->setShortcut(QKeySequence(tr("shift+z")));
1167 menu_list.insert(STANDARD, act);
1168 connect(act, &QAction::triggered, this, &mr_menu::slot_select_one);
1169 act = menu->addAction(_("All On Tile"));
1170 act->setShortcut(QKeySequence(tr("v")));
1171 menu_list.insert(STANDARD, act);
1172 connect(act, &QAction::triggered, this, &mr_menu::slot_select_all_tile);
1173 menu->addSeparator();
1174 act = menu->addAction(_("Same Type on Tile"));
1175 act->setShortcut(QKeySequence(tr("shift+v")));
1176 menu_list.insert(STANDARD, act);
1177 connect(act, &QAction::triggered, this, &mr_menu::slot_select_same_tile);
1178 act = menu->addAction(_("Same Type on Continent"));
1179 act->setShortcut(QKeySequence(tr("shift+c")));
1180 menu_list.insert(STANDARD, act);
1181 connect(act, &QAction::triggered, this,
1182 &mr_menu::slot_select_same_continent);
1183 act = menu->addAction(_("Same Type Everywhere"));
1184 act->setShortcut(QKeySequence(tr("shift+x")));
1185 menu_list.insert(STANDARD, act);
1186 connect(act, &QAction::triggered, this,
1187 &mr_menu::slot_select_same_everywhere);
1188 menu->addSeparator();
1189 act = menu->addAction(_("Wait"));
1190 act->setShortcut(QKeySequence(shortcut_to_string(
1191 fc_shortcuts::sc()->get_shortcut(SC_WAIT))));
1192 menu_list.insert(STANDARD, act);
1193 connect(act, &QAction::triggered, this, &mr_menu::slot_wait);
1194 act = menu->addAction(_("Done"));
1195 act->setShortcut(QKeySequence(shortcut_to_string(
1196 fc_shortcuts::sc()->get_shortcut(SC_DONE_MOVING))));
1197 menu_list.insert(STANDARD, act);
1198 connect(act, &QAction::triggered, this, &mr_menu::slot_done_moving);
1199
1200 act = menu->addAction(_("Advanced unit selection"));
1201 act->setShortcut(QKeySequence(tr("ctrl+e")));
1202 menu_list.insert(NOT_4_OBS, act);
1203 connect(act, &QAction::triggered, this, &mr_menu::slot_unit_filter);
1204
1205 /* Unit Menu */
1206 menu = this->addMenu(_("Unit"));
1207 act = menu->addAction(_("Go to Tile"));
1208 act->setShortcut(QKeySequence(shortcut_to_string(
1209 fc_shortcuts::sc()->get_shortcut(SC_GOTO))));
1210 menu_list.insert(STANDARD, act);
1211 connect(act, &QAction::triggered, this, &mr_menu::slot_unit_goto);
1212
1213 // The goto and act sub menu is handled as a separate object.
1214 menu->addMenu(new go_act_menu(this));
1215
1216 act = menu->addAction(_("Go to Nearest City"));
1217 act->setShortcut(QKeySequence(tr("shift+g")));
1218 menu_list.insert(GOTO_CITY, act);
1219 connect(act, &QAction::triggered, this, &mr_menu::slot_return_to_city);
1220 act = menu->addAction(_("Go to/Airlift to City..."));
1221 act->setShortcut(QKeySequence(shortcut_to_string(
1222 fc_shortcuts::sc()->get_shortcut(SC_GOTOAIRLIFT))));
1223 menu_list.insert(AIRLIFT, act);
1224 connect(act, &QAction::triggered, this, &mr_menu::slot_airlift);
1225 menu->addSeparator();
1226 act = menu->addAction(_("Auto Explore"));
1227 menu_list.insert(EXPLORE, act);
1228 act->setShortcut(QKeySequence(shortcut_to_string(
1229 fc_shortcuts::sc()->get_shortcut(SC_AUTOEXPLORE))));
1230 connect(act, &QAction::triggered, this, &mr_menu::slot_unit_explore);
1231 act = menu->addAction(_("Patrol"));
1232 menu_list.insert(STANDARD, act);
1233 act->setEnabled(false);
1234 act->setShortcut(QKeySequence(shortcut_to_string(
1235 fc_shortcuts::sc()->get_shortcut(SC_PATROL))));
1236 connect(act, &QAction::triggered, this, &mr_menu::slot_patrol);
1237 menu->addSeparator();
1238 act = menu->addAction(_("Sentry"));
1239 act->setShortcut(QKeySequence(shortcut_to_string(
1240 fc_shortcuts::sc()->get_shortcut(SC_SENTRY))));
1241 menu_list.insert(SENTRY, act);
1242 connect(act, &QAction::triggered, this, &mr_menu::slot_unit_sentry);
1243 act = menu->addAction(_("Unsentry All On Tile"));
1244 act->setShortcut(QKeySequence(shortcut_to_string(
1245 fc_shortcuts::sc()->get_shortcut(SC_UNSENTRY_TILE))));
1246 menu_list.insert(WAKEUP, act);
1247 connect(act, &QAction::triggered, this, &mr_menu::slot_unsentry);
1248 menu->addSeparator();
1249 act = menu->addAction(_("Load"));
1250 act->setShortcut(QKeySequence(shortcut_to_string(
1251 fc_shortcuts::sc()->get_shortcut(SC_BOARD))));
1252 menu_list.insert(BOARD, act);
1253 connect(act, &QAction::triggered, this, &mr_menu::slot_board);
1254 act = menu->addAction(_("Unload"));
1255 act->setShortcut(QKeySequence(shortcut_to_string(
1256 fc_shortcuts::sc()->get_shortcut(SC_DEBOARD))));
1257 menu_list.insert(DEBOARD, act);
1258 connect(act, &QAction::triggered, this, &mr_menu::slot_deboard);
1259 act = menu->addAction(_("Unload All From Transporter"));
1260 act->setShortcut(QKeySequence(tr("shift+t")));
1261 menu_list.insert(TRANSPORTER, act);
1262 connect(act, &QAction::triggered, this, &mr_menu::slot_unload_all);
1263 menu->addSeparator();
1264 // Defeat keyboard shortcut mnemonics
1265 act = menu->addAction(QString(action_id_name_translation(ACTION_HOME_CITY))
1266 .replace("&", "&&"));
1267 menu_list.insert(HOMECITY, act);
1268 act->setShortcut(QKeySequence(shortcut_to_string(
1269 fc_shortcuts::sc()->get_shortcut(SC_SETHOME))));
1270 connect(act, &QAction::triggered, this, &mr_menu::slot_set_home);
1271 act = menu->addAction(_("Upgrade"));
1272 act->setShortcut(QKeySequence(shortcut_to_string(
1273 fc_shortcuts::sc()->get_shortcut(SC_UPGRADE_UNIT))));
1274 menu_list.insert(UPGRADE, act);
1275 connect(act, &QAction::triggered, this, &mr_menu::slot_upgrade);
1276 act = menu->addAction(_("Convert"));
1277 act->setShortcut(QKeySequence(tr("shift+o")));
1278 menu_list.insert(CONVERT, act);
1279 connect(act, &QAction::triggered, this, &mr_menu::slot_convert);
1280 act = menu->addAction(_("Disband"));
1281 act->setShortcut(QKeySequence(tr("shift+d")));
1282 menu_list.insert(DISBAND, act);
1283 connect(act, &QAction::triggered, this, &mr_menu::slot_disband);
1284
1285 /* Combat Menu */
1286 menu = this->addMenu(_("Combat"));
1287 act = menu->addAction(_("Fortify Unit"));
1288 menu_list.insert(FORTIFY, act);
1289 act->setShortcut(QKeySequence(shortcut_to_string(
1290 fc_shortcuts::sc()->get_shortcut(SC_FORTIFY))));
1291 connect(act, &QAction::triggered, this, &mr_menu::slot_unit_fortify);
1292 act = menu->addAction(QString(Q_(terrain_control.gui_type_base0))
1293 .replace("&", "&&"));
1294 menu_list.insert(FORTRESS, act);
1295 act->setShortcut(QKeySequence(tr("shift+f")));
1296 connect(act, &QAction::triggered, this, &mr_menu::slot_unit_fortress);
1297 act = menu->addAction(QString(Q_(terrain_control.gui_type_base1))
1298 .replace("&", "&&"));
1299 menu_list.insert(AIRBASE, act);
1300 act->setShortcut(QKeySequence(tr("shift+e")));
1301 connect(act, &QAction::triggered, this, &mr_menu::slot_unit_airbase);
1302 bases_menu = menu->addMenu(_("Build Base"));
1303 menu->addSeparator();
1304 act = menu->addAction(_("Pillage"));
1305 menu_list.insert(PILLAGE, act);
1306 act->setShortcut(QKeySequence(tr("shift+p")));
1307 connect(act, &QAction::triggered, this, &mr_menu::slot_pillage);
1308 /* TRANS: Menu item to bring up the action selection dialog. */
1309 act = menu->addAction(_("Do..."));
1310 menu_list.insert(ORDER_DIPLOMAT_DLG, act);
1311 act->setShortcut(QKeySequence(shortcut_to_string(
1312 fc_shortcuts::sc()->get_shortcut(SC_DO))));
1313 connect(act, &QAction::triggered, this, &mr_menu::slot_action);
1314
1315 /* Work Menu */
1316 menu = this->addMenu(_("Work"));
1317 act = menu->addAction(QString(action_id_name_translation(ACTION_FOUND_CITY))
1318 .replace("&", "&&"));
1319 act->setShortcut(QKeySequence(shortcut_to_string(
1320 fc_shortcuts::sc()->get_shortcut(SC_BUILDCITY))));
1321 menu_list.insert(BUILD, act);
1322 connect(act, &QAction::triggered, this, &mr_menu::slot_build_city);
1323 act = menu->addAction(_("Auto Settler"));
1324 act->setShortcut(QKeySequence(shortcut_to_string(
1325 fc_shortcuts::sc()->get_shortcut(SC_AUTOMATE))));
1326 menu_list.insert(AUTOSETTLER, act);
1327 connect(act, &QAction::triggered, this, &mr_menu::slot_auto_settler);
1328 menu->addSeparator();
1329 act = menu->addAction(_("Build Road"));
1330 menu_list.insert(ROAD, act);
1331 act->setShortcut(QKeySequence(shortcut_to_string(
1332 fc_shortcuts::sc()->get_shortcut(SC_BUILDROAD))));
1333 connect(act, &QAction::triggered, this, &mr_menu::slot_build_road);
1334 roads_menu = menu->addMenu(_("Build Path"));
1335 act = menu->addAction(_("Build Irrigation"));
1336 act->setShortcut(QKeySequence(shortcut_to_string(
1337 fc_shortcuts::sc()->get_shortcut(SC_BUILDIRRIGATION))));
1338 menu_list.insert(IRRIGATION, act);
1339 connect(act, &QAction::triggered, this, &mr_menu::slot_build_irrigation);
1340 act = menu->addAction(_("Cultivate"));
1341 act->setShortcut(QKeySequence(shortcut_to_string(
1342 fc_shortcuts::sc()->get_shortcut(SC_CULTIVATE))));
1343 menu_list.insert(CULTIVATE, act);
1344 connect(act, &QAction::triggered, this, &mr_menu::slot_cultivate);
1345 act = menu->addAction(_("Build Mine"));
1346 act->setShortcut(QKeySequence(shortcut_to_string(
1347 fc_shortcuts::sc()->get_shortcut(SC_BUILDMINE))));
1348 menu_list.insert(MINE, act);
1349 connect(act, &QAction::triggered, this, &mr_menu::slot_build_mine);
1350 act = menu->addAction(_("Plant"));
1351 act->setShortcut(QKeySequence(shortcut_to_string(
1352 fc_shortcuts::sc()->get_shortcut(SC_PLANT))));
1353 menu_list.insert(PLANT, act);
1354 connect(act, &QAction::triggered, this, &mr_menu::slot_plant);
1355 menu->addSeparator();
1356 act = menu->addAction(_("Connect With Road"));
1357 act->setShortcut(QKeySequence(tr("ctrl+r")));
1358 menu_list.insert(CONNECT_ROAD, act);
1359 connect(act, &QAction::triggered, this, &mr_menu::slot_conn_road);
1360 act = menu->addAction(_("Connect With Railroad"));
1361 menu_list.insert(CONNECT_RAIL, act);
1362 act->setShortcut(QKeySequence(tr("ctrl+l")));
1363 connect(act, &QAction::triggered, this, &mr_menu::slot_conn_rail);
1364 act = menu->addAction(_("Connect With Maglev"));
1365 menu_list.insert(CONNECT_MAGLEV, act);
1366 act->setShortcut(QKeySequence(tr("ctrl+m")));
1367 connect(act, &QAction::triggered, this, &mr_menu::slot_conn_maglev);
1368 act = menu->addAction(_("Connect With Irrigation"));
1369 menu_list.insert(CONNECT_IRRIGATION, act);
1370 act->setShortcut(QKeySequence(tr("ctrl+i")));
1371 connect(act, &QAction::triggered, this, &mr_menu::slot_conn_irrigation);
1372 menu->addSeparator();
1373 act = menu->addAction(_("Transform Terrain"));
1374 menu_list.insert(TRANSFORM, act);
1375 act->setShortcut(QKeySequence(shortcut_to_string(
1376 fc_shortcuts::sc()->get_shortcut(SC_TRANSFORM))));
1377 connect(act, &QAction::triggered, this, &mr_menu::slot_transform);
1378 act = menu->addAction(_("Clean Pollution"));
1379 menu_list.insert(POLLUTION, act);
1380 act->setShortcut(QKeySequence(shortcut_to_string(
1381 fc_shortcuts::sc()->get_shortcut(SC_PARADROP))));
1382 connect(act, &QAction::triggered, this, &mr_menu::slot_clean_pollution);
1383 act = menu->addAction(_("Clean Nuclear Fallout"));
1384 menu_list.insert(FALLOUT, act);
1385 act->setShortcut(QKeySequence(tr("n")));
1386 connect(act, &QAction::triggered, this, &mr_menu::slot_clean_fallout);
1387 act = menu->addAction(QString(action_id_name_translation(ACTION_HELP_WONDER))
1388 .replace("&", "&&"));
1389 act->setShortcut(QKeySequence(tr("b")));
1390 menu_list.insert(BUILD_WONDER, act);
1391 connect(act, &QAction::triggered, this, &mr_menu::slot_build_city);
1392 act = menu->addAction(QString(action_id_name_translation(ACTION_TRADE_ROUTE))
1393 .replace("&", "&&"));
1394 act->setShortcut(QKeySequence(tr("r")));
1395 menu_list.insert(ORDER_TRADE_ROUTE, act);
1396 connect(act, &QAction::triggered, this, &mr_menu::slot_build_road);
1397
1398 // Multiplayer Menu
1399 multiplayer_menu = this->addMenu(_("Multiplayer"));
1400 act = multiplayer_menu->addAction(_("Delayed Goto"));
1401 act->setShortcut(QKeySequence(tr("z")));
1402 connect(act, &QAction::triggered, this, &mr_menu::slot_delayed_goto);
1403 act = multiplayer_menu->addAction(_("Delayed Orders Execute"));
1404 act->setShortcut(QKeySequence(tr("ctrl+z")));
1405 connect(act, &QAction::triggered, this, &mr_menu::slot_execute_orders);
1406 act = multiplayer_menu->addAction(_("Clear Orders"));
1407 act->setShortcut(QKeySequence(tr("ctrl+shift+c")));
1408 connect(act, &QAction::triggered, this, &mr_menu::slot_orders_clear);
1409 act = multiplayer_menu->addAction(_("Add all cities to trade planning"));
1410 connect(act, &QAction::triggered, this, &mr_menu::slot_trade_add_all);
1411 act = multiplayer_menu->addAction(_("Calculate trade planning"));
1412 connect(act, &QAction::triggered, this, &mr_menu::slot_calculate);
1413 act = multiplayer_menu->addAction(_("Add/Remove City"));
1414 act->setShortcut(QKeySequence(tr("ctrl+t")));
1415 connect(act, &QAction::triggered, this, &mr_menu::slot_trade_city);
1416 act = multiplayer_menu->addAction(_("Clear Trade Planning"));
1417 connect(act, &QAction::triggered, this, &mr_menu::slot_clear_trade);
1418 act = multiplayer_menu->addAction(_("Automatic caravan"));
1419 menu_list.insert(AUTOTRADEROUTE, act);
1420 connect(act, &QAction::triggered, this, &mr_menu::slot_autocaravan);
1421 act->setShortcut(QKeySequence(tr("ctrl+j")));
1422 act = multiplayer_menu->addAction(_("Set/Unset rally point"));
1423 act->setShortcut(QKeySequence(tr("shift+s")));
1424 connect(act, &QAction::triggered, this, &mr_menu::slot_rally);
1425 act = multiplayer_menu->addAction(_("Quick Airlift"));
1426 act->setShortcut(QKeySequence(tr("ctrl+y")));
1427 connect(act, &QAction::triggered, this, &mr_menu::slot_quickairlift);
1428 airlift_type = new QActionGroup(this);
1429 airlift_menu = multiplayer_menu->addMenu(_("Unit type for quickairlifting"));
1430
1431 /* Default diplo */
1432 action_vs_city = new QActionGroup(this);
1433 action_vs_unit = new QActionGroup(this);
1434 action_unit_menu = multiplayer_menu->addMenu(_("Default action vs unit"));
1435
1436 act = action_unit_menu->addAction(_("Ask"));
1437 act->setCheckable(true);
1438 act->setChecked(true);
1439 act->setData(-1);
1440 action_vs_unit->addAction(act);
1441 connect(act, &QAction::triggered, this, &mr_menu::slot_action_vs_unit);
1442
1443 act = action_unit_menu->addAction(_("Bribe"));
1444 act->setCheckable(true);
1445 act->setChecked(false);
1446 act->setData(ACTION_SPY_BRIBE_UNIT);
1447 action_vs_unit->addAction(act);
1448 connect(act, &QAction::triggered, this, &mr_menu::slot_action_vs_unit);
1449
1450 act = action_unit_menu->addAction(_("Sabotage"));
1451 act->setCheckable(true);
1452 act->setChecked(false);
1453 act->setData(ACTION_SPY_SABOTAGE_UNIT);
1454 action_vs_unit->addAction(act);
1455 connect(act, &QAction::triggered, this, &mr_menu::slot_action_vs_unit);
1456
1457 act = action_unit_menu->addAction(_("Sabotage Unit Escape"));
1458 act->setCheckable(true);
1459 act->setChecked(false);
1460 act->setData(ACTION_SPY_SABOTAGE_UNIT_ESC);
1461 action_vs_unit->addAction(act);
1462 connect(act, &QAction::triggered, this, &mr_menu::slot_action_vs_unit);
1463
1464 action_city_menu = multiplayer_menu->addMenu(_("Default action vs city"));
1465 act = action_city_menu->addAction(_("Ask"));
1466 act->setCheckable(true);
1467 act->setChecked(true);
1468 act->setData(-1);
1469 action_vs_city->addAction(act);
1470 connect(act, &QAction::triggered, this, &mr_menu::slot_action_vs_city);
1471
1472 act = action_city_menu->addAction(_("Investigate city"));
1473 act->setCheckable(true);
1474 act->setChecked(false);
1475 act->setData(ACTION_SPY_INVESTIGATE_CITY);
1476 action_vs_city->addAction(act);
1477 connect(act, &QAction::triggered, this, &mr_menu::slot_action_vs_city);
1478
1479 act = action_city_menu->addAction(_("Investigate city (spends the unit)"));
1480 act->setCheckable(true);
1481 act->setChecked(false);
1482 act->setData(ACTION_INV_CITY_SPEND);
1483 action_vs_city->addAction(act);
1484 connect(act, &QAction::triggered, this, &mr_menu::slot_action_vs_city);
1485
1486 act = action_city_menu->addAction(_("Establish embassy"));
1487 act->setCheckable(true);
1488 act->setChecked(false);
1489 act->setData(ACTION_ESTABLISH_EMBASSY);
1490 action_vs_city->addAction(act);
1491 connect(act, &QAction::triggered, this, &mr_menu::slot_action_vs_city);
1492
1493 act = action_city_menu->addAction(_("Become Ambassador"));
1494 act->setCheckable(true);
1495 act->setChecked(false);
1496 act->setData(ACTION_ESTABLISH_EMBASSY_STAY);
1497 action_vs_city->addAction(act);
1498 connect(act, &QAction::triggered, this, &mr_menu::slot_action_vs_city);
1499
1500 act = action_city_menu->addAction(_("Steal technology"));
1501 act->setCheckable(true);
1502 act->setChecked(false);
1503 act->setData(ACTION_SPY_STEAL_TECH);
1504 action_vs_city->addAction(act);
1505 connect(act, &QAction::triggered, this, &mr_menu::slot_action_vs_city);
1506
1507 act = action_city_menu->addAction(_("Steal technology and escape"));
1508 act->setCheckable(true);
1509 act->setChecked(false);
1510 act->setData(ACTION_SPY_STEAL_TECH_ESC);
1511 action_vs_city->addAction(act);
1512 connect(act, &QAction::triggered, this, &mr_menu::slot_action_vs_city);
1513
1514 act = action_city_menu->addAction(_("Incite a revolt"));
1515 act->setCheckable(true);
1516 act->setChecked(false);
1517 act->setData(ACTION_SPY_INCITE_CITY);
1518 action_vs_city->addAction(act);
1519 connect(act, &QAction::triggered, this, &mr_menu::slot_action_vs_city);
1520
1521 act = action_city_menu->addAction(_("Incite a Revolt and Escape"));
1522 act->setCheckable(true);
1523 act->setChecked(false);
1524 act->setData(ACTION_SPY_INCITE_CITY_ESC);
1525 action_vs_city->addAction(act);
1526 connect(act, &QAction::triggered, this, &mr_menu::slot_action_vs_city);
1527
1528 act = action_city_menu->addAction(_("Poison city"));
1529 act->setCheckable(true);
1530 act->setChecked(false);
1531 act->setData(ACTION_SPY_POISON);
1532 action_vs_city->addAction(act);
1533 connect(act, &QAction::triggered, this, &mr_menu::slot_action_vs_city);
1534
1535 act = action_city_menu->addAction(_("Poison City Escape"));
1536 act->setCheckable(true);
1537 act->setChecked(false);
1538 act->setData(ACTION_SPY_POISON_ESC);
1539 action_vs_city->addAction(act);
1540 connect(act, &QAction::triggered, this, &mr_menu::slot_action_vs_city);
1541
1542 /* Civilization menu */
1543 menu = this->addMenu(_("Civilization"));
1544 act = menu->addAction(_("Tax Rates..."));
1545 menu_list.insert(NOT_4_OBS, act);
1546 connect(act, &QAction::triggered, this, &mr_menu::slot_popup_tax_rates);
1547 menu->addSeparator();
1548
1549 act = menu->addAction(_("Policies..."));
1550 menu_list.insert(MULTIPLIERS, act);
1551 connect(act, &QAction::triggered, this, &mr_menu::slot_popup_mult_rates);
1552 menu->addSeparator();
1553
1554 menu->addMenu(new class gov_menu(this));
1555 menu->addSeparator();
1556
1557 act = menu->addAction(Q_("?noun:View"));
1558 act->setShortcut(QKeySequence(tr("F1")));
1559 connect(act, &QAction::triggered, this, &mr_menu::slot_show_map);
1560
1561 act = menu->addAction(_("Units"));
1562 act->setShortcut(QKeySequence(tr("F2")));
1563 connect(act, &QAction::triggered, this, &mr_menu::slot_show_units_report);
1564
1565 act = menu->addAction(_("Nations"));
1566 act->setShortcut(QKeySequence(tr("F3")));
1567 connect(act, &QAction::triggered, this, &mr_menu::slot_show_nations);
1568
1569 act = menu->addAction(_("Cities"));
1570 act->setShortcut(QKeySequence(tr("F4")));
1571 connect(act, &QAction::triggered, this, &mr_menu::slot_show_cities);
1572
1573 act = menu->addAction(_("Economy"));
1574 act->setShortcut(QKeySequence(tr("F5")));
1575 connect(act, &QAction::triggered, this, &mr_menu::slot_show_eco_report);
1576
1577 act = menu->addAction(_("Research"));
1578 act->setShortcut(QKeySequence(tr("F6")));
1579 connect(act, &QAction::triggered, this, &mr_menu::slot_show_research_tab);
1580
1581 act = menu->addAction(_("Wonders of the World"));
1582 act->setShortcut(QKeySequence(tr("F7")));
1583 connect(act, &QAction::triggered, this, &mr_menu::slot_traveler);
1584
1585 act = menu->addAction(_("Top Five Cities"));
1586 act->setShortcut(QKeySequence(tr("F8")));
1587 connect(act, &QAction::triggered, this, &mr_menu::slot_top_five);
1588
1589 act = menu->addAction(_("Demographics"));
1590 act->setShortcut(QKeySequence(tr("F11")));
1591 connect(act, &QAction::triggered, this, &mr_menu::slot_demographics);
1592
1593 act = menu->addAction(_("Spaceship"));
1594 act->setShortcut(QKeySequence(tr("F12")));
1595 connect(act, &QAction::triggered, this, &mr_menu::slot_spaceship);
1596
1597 act = menu->addAction(_("Achievements"));
1598 connect(act, &QAction::triggered, this, &mr_menu::slot_achievements);
1599
1600 act = menu->addAction(_("Endgame report"));
1601 menu_list.insert(ENDGAME, act);
1602 connect(act, &QAction::triggered, this, &mr_menu::slot_endgame);
1603
1604 // Battle Groups Menu
1605 menu = this->addMenu(_("Battle Groups"));
1606
1607 act = menu->addAction(_("Select Battle Group 1"));
1608 act->setShortcut(QKeySequence(tr("Shift+F1")));
1609 connect(act, &QAction::triggered, this, &mr_menu::slot_bg1select);
1610
1611 act = menu->addAction(_("Assign Battle Group 1"));
1612 act->setShortcut(QKeySequence(tr("Ctrl+F1")));
1613 connect(act, &QAction::triggered, this, &mr_menu::slot_bg1assign);
1614
1615 act = menu->addAction(_("Append to Battle Group 1"));
1616 act->setShortcut(QKeySequence(tr("Ctrl+Shift+F1")));
1617 connect(act, &QAction::triggered, this, &mr_menu::slot_bg1append);
1618
1619 act = menu->addAction(_("Select Battle Group 2"));
1620 act->setShortcut(QKeySequence(tr("Shift+F2")));
1621 connect(act, &QAction::triggered, this, &mr_menu::slot_bg2select);
1622
1623 act = menu->addAction(_("Assign Battle Group 2"));
1624 act->setShortcut(QKeySequence(tr("Ctrl+F2")));
1625 connect(act, &QAction::triggered, this, &mr_menu::slot_bg2assign);
1626
1627 act = menu->addAction(_("Append to Battle Group 2"));
1628 act->setShortcut(QKeySequence(tr("Ctrl+Shift+F2")));
1629 connect(act, &QAction::triggered, this, &mr_menu::slot_bg2append);
1630
1631 act = menu->addAction(_("Select Battle Group 3"));
1632 act->setShortcut(QKeySequence(tr("Shift+F3")));
1633 connect(act, &QAction::triggered, this, &mr_menu::slot_bg3select);
1634
1635 act = menu->addAction(_("Assign Battle Group 3"));
1636 act->setShortcut(QKeySequence(tr("Ctrl+F3")));
1637 connect(act, &QAction::triggered, this, &mr_menu::slot_bg3assign);
1638
1639 act = menu->addAction(_("Append to Battle Group 3"));
1640 act->setShortcut(QKeySequence(tr("Ctrl+Shift+F3")));
1641 connect(act, &QAction::triggered, this, &mr_menu::slot_bg3append);
1642
1643 act = menu->addAction(_("Select Battle Group 4"));
1644 act->setShortcut(QKeySequence(tr("Shift+F4")));
1645 connect(act, &QAction::triggered, this, &mr_menu::slot_bg4select);
1646
1647 act = menu->addAction(_("Assign Battle Group 4"));
1648 act->setShortcut(QKeySequence(tr("Ctrl+F4")));
1649 connect(act, &QAction::triggered, this, &mr_menu::slot_bg4assign);
1650
1651 act = menu->addAction(_("Append to Battle Group 4"));
1652 act->setShortcut(QKeySequence(tr("Ctrl+Shift+F4")));
1653 connect(act, &QAction::triggered, this, &mr_menu::slot_bg4append);
1654
1655 // Help Menu
1656 menu = this->addMenu(_("Help"));
1657
1658 act = menu->addAction(Q_(HELP_OVERVIEW_ITEM));
1659 QObject::connect(act, &QAction::triggered, [this]() {
1660 slot_help(HELP_OVERVIEW_ITEM);
1661 });
1662
1663 act = menu->addAction(Q_(HELP_PLAYING_ITEM));
1664 QObject::connect(act, &QAction::triggered, [this]() {
1665 slot_help(HELP_PLAYING_ITEM);
1666 });
1667
1668 act = menu->addAction(Q_(HELP_TERRAIN_ITEM));
1669 QObject::connect(act, &QAction::triggered, [this]() {
1670 slot_help(HELP_TERRAIN_ITEM);
1671 });
1672
1673 act = menu->addAction(Q_(HELP_ECONOMY_ITEM));
1674 QObject::connect(act, &QAction::triggered, [this]() {
1675 slot_help(HELP_ECONOMY_ITEM);
1676 });
1677
1678 act = menu->addAction(Q_(HELP_CITIES_ITEM));
1679 QObject::connect(act, &QAction::triggered, [this]() {
1680 slot_help(HELP_CITIES_ITEM);
1681 });
1682
1683 act = menu->addAction(Q_(HELP_IMPROVEMENTS_ITEM));
1684 QObject::connect(act, &QAction::triggered, [this]() {
1685 slot_help(HELP_IMPROVEMENTS_ITEM);
1686 });
1687
1688 act = menu->addAction(Q_(HELP_WONDERS_ITEM));
1689 QObject::connect(act, &QAction::triggered, [this]() {
1690 slot_help(HELP_WONDERS_ITEM);
1691 });
1692
1693 act = menu->addAction(Q_(HELP_UNITS_ITEM));
1694 QObject::connect(act, &QAction::triggered, [this]() {
1695 slot_help(HELP_UNITS_ITEM);
1696 });
1697
1698 act = menu->addAction(Q_(HELP_COMBAT_ITEM));
1699 QObject::connect(act, &QAction::triggered, [this]() {
1700 slot_help(HELP_COMBAT_ITEM);
1701 });
1702
1703 act = menu->addAction(Q_(HELP_ZOC_ITEM));
1704 QObject::connect(act, &QAction::triggered, [this]() {
1705 slot_help(HELP_ZOC_ITEM);
1706 });
1707
1708 act = menu->addAction(Q_(HELP_GOVERNMENT_ITEM));
1709 QObject::connect(act, &QAction::triggered, [this]() {
1710 slot_help(HELP_GOVERNMENT_ITEM);
1711 });
1712
1713 act = menu->addAction(Q_(HELP_ECONOMY_ITEM));
1714 QObject::connect(act, &QAction::triggered, [this]() {
1715 slot_help(HELP_ECONOMY_ITEM);
1716 });
1717
1718 act = menu->addAction(Q_(HELP_DIPLOMACY_ITEM));
1719 QObject::connect(act, &QAction::triggered, [this]() {
1720 slot_help(HELP_DIPLOMACY_ITEM);
1721 });
1722
1723 act = menu->addAction(Q_(HELP_TECHS_ITEM));
1724 QObject::connect(act, &QAction::triggered, [this]() {
1725 slot_help(HELP_TECHS_ITEM);
1726 });
1727
1728 act = menu->addAction(Q_(HELP_SPACE_RACE_ITEM));
1729 QObject::connect(act, &QAction::triggered, [this]() {
1730 slot_help(HELP_SPACE_RACE_ITEM);
1731 });
1732
1733 act = menu->addAction(Q_(HELP_IMPROVEMENTS_ITEM));
1734 QObject::connect(act, &QAction::triggered, [this]() {
1735 slot_help(HELP_IMPROVEMENTS_ITEM);
1736 });
1737
1738 act = menu->addAction(Q_(HELP_RULESET_ITEM));
1739 QObject::connect(act, &QAction::triggered, [this]() {
1740 slot_help(HELP_RULESET_ITEM);
1741 });
1742
1743 act = menu->addAction(Q_(HELP_TILESET_ITEM));
1744 QObject::connect(act, &QAction::triggered, [this]() {
1745 slot_help(HELP_TILESET_ITEM);
1746 });
1747
1748 act = menu->addAction(Q_(HELP_NATIONS_ITEM));
1749 QObject::connect(act, &QAction::triggered, [this]() {
1750 slot_help(HELP_NATIONS_ITEM);
1751 });
1752
1753 menu->addSeparator();
1754
1755 act = menu->addAction(Q_(HELP_CONNECTING_ITEM));
1756 QObject::connect(act, &QAction::triggered, [this]() {
1757 slot_help(HELP_CONNECTING_ITEM);
1758 });
1759
1760 act = menu->addAction(Q_(HELP_CONTROLS_ITEM));
1761 QObject::connect(act, &QAction::triggered, [this]() {
1762 slot_help(HELP_CONTROLS_ITEM);
1763 });
1764
1765 act = menu->addAction(Q_(HELP_CMA_ITEM));
1766 QObject::connect(act, &QAction::triggered, [this]() {
1767 slot_help(HELP_CMA_ITEM);
1768 });
1769
1770 act = menu->addAction(Q_(HELP_CHATLINE_ITEM));
1771 QObject::connect(act, &QAction::triggered, [this]() {
1772 slot_help(HELP_CHATLINE_ITEM);
1773 });
1774
1775 act = menu->addAction(Q_(HELP_WORKLIST_EDITOR_ITEM));
1776 QObject::connect(act, &QAction::triggered, [this]() {
1777 slot_help(HELP_WORKLIST_EDITOR_ITEM);
1778 });
1779
1780 menu->addSeparator();
1781
1782 act = menu->addAction(Q_(HELP_LANGUAGES_ITEM));
1783 QObject::connect(act, &QAction::triggered, [this]() {
1784 slot_help(HELP_LANGUAGES_ITEM);
1785 });
1786
1787 act = menu->addAction(Q_(HELP_COPYING_ITEM));
1788 QObject::connect(act, &QAction::triggered, [this]() {
1789 slot_help(HELP_COPYING_ITEM);
1790 });
1791
1792 act = menu->addAction(Q_(HELP_ABOUT_ITEM));
1793 QObject::connect(act, &QAction::triggered, [this]() {
1794 slot_help(HELP_ABOUT_ITEM);
1795 });
1796
1797 menus = this->findChildren<QMenu*>();
1798 for (i = 0; i < menus.count(); i++) {
1799 menus[i]->setAttribute(Qt::WA_TranslucentBackground);
1800 }
1801 this->setVisible(false);
1802}
1803
1804/**********************************************************************/
1807 void mr_menu::set_tile_for_order(tile *ptile)
1808{
1809 for (int i=0; i < units_list.nr_units; i++) {
1810 units_list.unit_list.at(units_list.unit_list.count() - i -1)->ptile = ptile;
1811 }
1812}
1813
1814/**********************************************************************/
1819 bool mr_menu::execute_shortcut_inner(const QMenu *m, QKeySequence seq)
1820{
1821 foreach (QAction *a, m->actions()) {
1822 if (a->shortcut() == seq && a->isEnabled()) {
1823 a->activate(QAction::Trigger);
1824 return TRUE;
1825 }
1826 }
1827
1828 return FALSE;
1829}
1830
1831/**********************************************************************/
1834 void mr_menu::execute_shortcut(int sid)
1835{
1836 QList<QMenu*> menus;
1837 QKeySequence seq;
1838 fc_shortcut *fcs;
1839
1840 if (sid == SC_GOTO) {
1841 gui()->mapview_wdg->menu_click = true;
1842 slot_unit_goto();
1843 return;
1844 }
1845 fcs = fc_shortcuts::sc()->get_shortcut(static_cast< shortcut_id>(sid));
1846 seq = QKeySequence(shortcut_to_string(fcs));
1847
1848 menus = findChildren<QMenu*>();
1849 foreach (const QMenu *m, menus) {
1850 if (execute_shortcut_inner(m, seq)) {
1851 return;
1852 }
1853 }
1854}
1855
1856/**********************************************************************/
1861 bool mr_menu::shortcut_exist_inner(const QMenu *m, QKeySequence seq,
1862 fc_shortcut *fcs, QString *ret)
1863{
1864 foreach (QAction *a, m->actions()) {
1865 if (a->shortcut() == seq && fcs->mouse == Qt::AllButtons) {
1866 *ret = a->text();
1867
1868 return TRUE;
1869 }
1870 }
1871
1872 return FALSE;
1873}
1874
1875/**********************************************************************/
1878QString mr_menu::shortcut_exist(fc_shortcut *fcs)
1879{
1880 QList<QMenu*> menus;
1881 QKeySequence seq;
1882
1883 seq = QKeySequence(shortcut_to_string(fcs));
1884 menus = findChildren<QMenu *>();
1885 foreach (const QMenu *m, menus) {
1886 QString ret;
1887
1888 if (shortcut_exist_inner(m, seq, fcs, &ret)) {
1889 return ret;
1890 }
1891 }
1892
1893 return QString();
1894}
1895
1896/**********************************************************************/
1901 bool mr_menu::shortcut_2_menustring_inner(const QMenu *m, QKeySequence seq,
1902 QString *ret)
1903{
1904 foreach (QAction *a, m->actions()) {
1905 if (a->shortcut() == seq) {
1906 *ret = a->text() + " ("
1907 + a->shortcut().toString(QKeySequence::NativeText) + ")";
1908
1909 return TRUE;
1910 }
1911 }
1912
1913 return FALSE;
1914}
1915
1916/**********************************************************************/
1919QString mr_menu::shortcut_2_menustring(int sid)
1920{
1921 QList<QMenu *> menus;
1922 QKeySequence seq;
1923 fc_shortcut *fcs;
1924
1925 fcs = fc_shortcuts::sc()->get_shortcut(static_cast< shortcut_id>(sid));
1926 seq = QKeySequence(shortcut_to_string(fcs));
1927
1928 menus = findChildren<QMenu *>();
1929 foreach (const QMenu *m, menus) {
1930 QString ret;
1931
1932 if (shortcut_2_menustring_inner(m, seq, &ret)) {
1933 return ret;
1934 }
1935 }
1936
1937 return QString();
1938}
1939
1940/**********************************************************************/
1943 void mr_menu::update_airlift_menu()
1944{
1945 Unit_type_id utype_id;
1946 QAction *act;
1947
1948 airlift_menu->clear();
1949 if (client_is_observer()) {
1950 return;
1951 }
1952 unit_type_iterate(utype) {
1953 utype_id = utype_index(utype);
1954
1955 if (!can_player_build_unit_now(client.conn.playing, utype)
1956 || !utype_can_do_action(utype, ACTION_AIRLIFT)) {
1957 continue;
1958 }
1959 if (!can_player_build_unit_now(client.conn.playing, utype)
1960 && !has_player_unit_type(utype_id)) {
1961 continue;
1962 }
1963 // Defeat keyboard shortcut mnemonics
1964 act = airlift_menu->addAction(QString(utype_name_translation(utype))
1965 .replace("&", "&&"));
1966 act->setCheckable(true);
1967 act->setData(utype_id);
1968 if (airlift_type_id == utype_id) {
1969 act->setChecked(true);
1970 }
1971 connect(act, &QAction::triggered, this, &mr_menu::slot_quickairlift_set);
1972 airlift_type->addAction(act);
1973 } unit_type_iterate_end;
1974}
1975
1976/****************************************************************************
1977 Updates "build path" menu
1978****************************************************************************/
1979 void mr_menu::update_roads_menu()
1980{
1981 QAction *act;
1982 struct unit_list *punits = nullptr;
1983 bool enabled = false;
1984
1985 foreach(act, roads_menu->actions()) {
1986 removeAction(act);
1987 act->deleteLater();
1988 }
1989 roads_menu->clear();
1990 roads_menu->setDisabled(true);
1991 if (client_is_observer()) {
1992 return;
1993 }
1994
1995 punits = get_units_in_focus();
1996 extra_type_by_cause_iterate(EC_ROAD, pextra) {
1997 if (pextra->buildable) {
1998 int road_id;
1999
2000 // Defeat keyboard shortcut mnemonics
2001 act = roads_menu->addAction(QString(extra_name_translation(pextra))
2002 .replace("&", "&&"));
2003 road_id = pextra->id;
2004 act->setData(road_id);
2005 QObject::connect(act, &QAction::triggered, [this,road_id]() {
2006 slot_build_path(road_id);
2007 });
2008 if (can_units_do_activity_targeted_client(punits,
2009 ACTIVITY_GEN_ROAD, pextra)) {
2010 act->setEnabled(true);
2011 enabled = true;
2012 } else {
2013 act->setDisabled(true);
2014 }
2015 }
2016 } extra_type_by_cause_iterate_end;
2017
2018 if (enabled) {
2019 roads_menu->setEnabled(true);
2020 }
2021}
2022
2023/****************************************************************************
2024 Updates "build bases" menu
2025****************************************************************************/
2026 void mr_menu::update_bases_menu()
2027{
2028 QAction *act;
2029 struct unit_list *punits = nullptr;
2030 bool enabled = false;
2031
2032 foreach(act, bases_menu->actions()) {
2033 removeAction(act);
2034 act->deleteLater();
2035 }
2036 bases_menu->clear();
2037 bases_menu->setDisabled(true);
2038
2039 if (client_is_observer()) {
2040 return;
2041 }
2042
2043 punits = get_units_in_focus();
2044 extra_type_by_cause_iterate(EC_BASE, pextra) {
2045 if (pextra->buildable) {
2046 int base_id;
2047
2048 // Defeat keyboard shortcut mnemonics
2049 act = bases_menu->addAction(QString(extra_name_translation(pextra))
2050 .replace("&", "&&"));
2051 base_id = pextra->id;
2052 act->setData(base_id);
2053 QObject::connect(act, &QAction::triggered, [this,base_id]() {
2054 slot_build_base(base_id);
2055 });
2056 if (can_units_do_activity_targeted_client(punits, ACTIVITY_BASE, pextra)) {
2057 act->setEnabled(true);
2058 enabled = true;
2059 } else {
2060 act->setDisabled(true);
2061 }
2062 }
2063 } extra_type_by_cause_iterate_end;
2064
2065 if (enabled) {
2066 bases_menu->setEnabled(true);
2067 }
2068}
2069
2070/**********************************************************************/
2073 void mr_menu::menus_sensitive()
2074{
2075 QList <QAction * >values;
2076 QList <munit > keys;
2077 QMultiHash <munit, QAction *>::iterator i;
2078 struct unit_list *punits = nullptr;
2079 struct road_type *proad;
2080 struct extra_type *tgt;
2081 bool any_cities = false;
2082 bool city_on_tile = false;
2083 bool units_all_same_tile = true;
2084 const struct tile *ptile = NULL;
2085 const struct unit_type *ptype = NULL;
2086
2087 players_iterate(pplayer) {
2088 if (city_list_size(pplayer->cities)) {
2089 any_cities = true;
2090 break;
2091 }
2092 } players_iterate_end;
2093
2095 foreach(QAction *a, menu_list) {
2096 a->setEnabled(false);
2097 }
2098
2099 if (client_is_observer()) {
2100 multiplayer_menu->setDisabled(true);
2101 } else {
2102 multiplayer_menu->setDisabled(false);
2103 }
2104
2105 /* Non unit menus */
2106 keys = menu_list.keys();
2107 foreach (munit key, keys) {
2108 i = menu_list.find(key);
2109 while (i != menu_list.end() && i.key() == key) {
2110 switch (key) {
2111 case SAVE:
2112 if (can_client_access_hack() && C_S_RUNNING <= client_state()) {
2113 i.value()->setEnabled(true);
2114 }
2115 break;
2116 case NOT_4_OBS:
2117 if (!client_is_observer()) {
2118 i.value()->setEnabled(true);
2119 }
2120 break;
2121 case MULTIPLIERS:
2122 if (!client_is_observer() && multiplier_count() > 0) {
2123 i.value()->setEnabled(true);
2124 i.value()->setVisible(true);
2125 } else {
2126 i.value()->setVisible(false);
2127 }
2128 break;
2129 case ENDGAME:
2130 if (gui()->is_repo_dlg_open("END")) {
2131 i.value()->setEnabled(true);
2132 i.value()->setVisible(true);
2133 } else {
2134 i.value()->setVisible(false);
2135 }
2136 break;
2137 default:
2138 break;
2139 }
2140 i++;
2141 }
2142 }
2143
2144 if (!can_client_issue_orders() || get_num_units_in_focus() == 0) {
2145 return;
2146 }
2147
2148 punits = get_units_in_focus();
2149 unit_list_iterate(punits, punit) {
2150 if (tile_city(unit_tile(punit))) {
2151 city_on_tile = true;
2152 break;
2153 }
2154 } unit_list_iterate_end;
2155
2156 unit_list_iterate(punits, punit) {
2157 const struct unit_type *ntype;
2158
2159 fc_assert((ptile == NULL) == (ptype == NULL));
2160
2161 ntype = unit_type_get(punit);
2162
2163 // 'ntype == ptype' is correct check even when ptype is still nullptr
2164 if (ptile != nullptr && ntype == ptype && unit_tile(punit) != ptile) {
2165 units_all_same_tile = false;
2166 }
2167
2168 if (ptype == nullptr || ntype == ptype) {
2169 ptile = unit_tile(punit);
2170 ptype = ntype;
2171 }
2172 } unit_list_iterate_end;
2173
2174 keys = menu_list.keys();
2175 foreach(munit key, keys) {
2176 i = menu_list.find(key);
2177 while (i != menu_list.end() && i.key() == key) {
2178 switch (key) {
2179 case STANDARD:
2180 i.value()->setEnabled(true);
2181 break;
2182
2183 case EXPLORE:
2184 if (can_units_do_activity_client(punits, ACTIVITY_EXPLORE)) {
2185 i.value()->setEnabled(true);
2186 }
2187 break;
2188
2189 case BOARD:
2190 if (units_can_load(punits)) {
2191 i.value()->setEnabled(true);
2192 }
2193 break;
2194
2195 case DEBOARD:
2196 if (units_can_unload(punits)) {
2197 i.value()->setEnabled(true);
2198 }
2199 break;
2200
2201 case TRANSPORTER:
2202 if (units_are_occupied(punits)) {
2203 i.value()->setEnabled(true);
2204 }
2205 break;
2206
2207 case CONVERT:
2208 if (units_can_convert(&(wld.map), punits)) {
2209 i.value()->setEnabled(true);
2210 }
2211 break;
2212
2213 case MINE:
2214 if (can_units_do_activity_client(punits, ACTIVITY_MINE)) {
2215 i.value()->setEnabled(true);
2216 }
2217
2218 if (units_all_same_tile) {
2219 if (units_have_type_flag(punits, UTYF_SETTLERS, TRUE)) {
2220 struct extra_type *pextra = NULL;
2221
2222 /* FIXME: this overloading doesn't work well with multiple focus
2223 * units. */
2224 unit_list_iterate(punits, builder) {
2225 pextra = next_extra_for_tile(unit_tile(builder), EC_MINE,
2226 unit_owner(builder), builder);
2227 if (pextra != NULL) {
2228 break;
2229 }
2230 } unit_list_iterate_end;
2231
2232 if (pextra != NULL) {
2233 i.value()->setText(
2234 /* TRANS: Build mine of specific type */
2235 QString(_("Build %1"))
2236 .arg(extra_name_translation(pextra))
2237 .replace("&", "&&"));
2238 } else {
2239 i.value()->setText(QString(_("Build Mine")));
2240 }
2241 } else {
2242 i.value()->setText(QString(_("Build Mine")));
2243 }
2244 }
2245 break;
2246
2247 case IRRIGATION:
2248 if (can_units_do_activity_client(punits, ACTIVITY_IRRIGATE)) {
2249 i.value()->setEnabled(true);
2250 }
2251 if (units_all_same_tile) {
2252 if (units_have_type_flag(punits, UTYF_SETTLERS, TRUE)) {
2253 struct extra_type *pextra = NULL;
2254
2255 /* FIXME: this overloading doesn't work well with multiple focus
2256 * units. */
2257 unit_list_iterate(punits, builder) {
2258 pextra = next_extra_for_tile(unit_tile(builder), EC_IRRIGATION,
2259 unit_owner(builder), builder);
2260 if (pextra != NULL) {
2261 break;
2262 }
2263 } unit_list_iterate_end;
2264
2265 if (pextra != NULL) {
2266 i.value()->setText(
2267 /* TRANS: Build irrigation of specific type */
2268 QString(_("Build %1"))
2269 .arg(extra_name_translation(pextra))
2270 .replace("&", "&&"));
2271 } else {
2272 i.value()->setText(QString(_("Build Irrigation")));
2273 }
2274 } else {
2275 i.value()->setText(QString(_("Build Irrigation")));
2276 }
2277 }
2278 break;
2279
2280 case CULTIVATE:
2281 if (can_units_do_activity_client(punits, ACTIVITY_CULTIVATE)) {
2282 i.value()->setEnabled(true);
2283 }
2284 if (units_all_same_tile) {
2285 struct unit *punit = unit_list_get(punits, 0);
2286 struct tile *atile = unit_tile(punit);
2287 struct terrain *pterrain = tile_terrain(atile);
2288
2289 if (pterrain->cultivate_result != T_NONE) {
2290 i.value()->setText(
2291 /* TRANS: Transform terrain to specific type */
2292 QString(_("Cultivate to %1"))
2293 .arg(QString(get_tile_change_menu_text(atile, ACTIVITY_CULTIVATE)))
2294 .replace("&", "&&"));
2295 } else {
2296 i.value()->setText(QString(_("Cultivate")));
2297 }
2298 } else {
2299 i.value()->setText(QString(_("Cultivate")));
2300 }
2301 break;
2302
2303 case PLANT:
2304 if (can_units_do_activity_client(punits, ACTIVITY_PLANT)) {
2305 i.value()->setEnabled(true);
2306 }
2307 if (units_all_same_tile) {
2308 struct unit *punit = unit_list_get(punits, 0);
2309 struct tile *atile = unit_tile(punit);
2310 struct terrain *pterrain = tile_terrain(atile);
2311
2312 if (pterrain->plant_result != T_NONE) {
2313 i.value()->setText(
2314 /* TRANS: Transform terrain to specific type */
2315 QString(_("Plant to %1"))
2316 .arg(QString(get_tile_change_menu_text(atile, ACTIVITY_PLANT)))
2317 .replace("&", "&&"));
2318 } else {
2319 i.value()->setText(QString(_("Plant")));
2320 }
2321 } else {
2322 i.value()->setText(QString(_("Plant")));
2323 }
2324 break;
2325
2326 case TRANSFORM:
2327 if (can_units_do_activity_client(punits, ACTIVITY_TRANSFORM)) {
2328 i.value()->setEnabled(true);
2329 } else {
2330 break;
2331 }
2332 if (units_all_same_tile) {
2333 struct unit *punit = unit_list_get(punits, 0);
2334 struct tile *atile = unit_tile(punit);
2335 struct terrain *pterrain = tile_terrain(atile);
2336
2337 if (pterrain->transform_result != T_NONE
2338 && pterrain->transform_result != pterrain) {
2339 i.value()->setText(
2340 /* TRANS: Transform terrain to specific type */
2341 QString(_("Transform to %1"))
2342 .arg(QString(get_tile_change_menu_text(atile, ACTIVITY_TRANSFORM)))
2343 .replace("&", "&&"));
2344 } else {
2345 i.value()->setText(_("Transform Terrain"));
2346 }
2347 }
2348 break;
2349
2350 case BUILD:
2351 if (can_units_do(punits, unit_can_add_or_build_city)) {
2352 i.value()->setEnabled(true);
2353 }
2354 if (city_on_tile
2355 && units_can_do_action(punits, ACTION_JOIN_CITY, true)) {
2356 i.value()->setText(
2357 QString(action_id_name_translation(ACTION_JOIN_CITY))
2358 .replace("&", "&&"));
2359 } else {
2360 i.value()->setText(
2361 QString(action_id_name_translation(ACTION_FOUND_CITY))
2362 .replace("&", "&&"));
2363 }
2364 break;
2365
2366 case ROAD:
2367 {
2368 struct extra_type *pextra = nullptr;
2369
2370 if (can_units_do_any_road(&(wld.map), punits)) {
2371 i.value()->setEnabled(true);
2372 }
2373 unit_list_iterate(punits, punit) {
2374 pextra = next_extra_for_tile(unit_tile(punit), EC_ROAD,
2375 unit_owner(punit), punit);
2376 if (pextra != nullptr) {
2377 break;
2378 }
2379 } unit_list_iterate_end;
2380
2381 if (pextra != nullptr) {
2382 i.value()->setText(
2383 /* TRANS: Build road of specific type */
2384 QString(_("Build %1"))
2385 .arg(extra_name_translation(pextra))
2386 .replace("&", "&&"));
2387 }
2388 }
2389 break;
2390
2391 case FORTIFY:
2392 if (can_units_do_activity_client(punits, ACTIVITY_FORTIFYING)) {
2393 i.value()->setEnabled(true);
2394 }
2395 break;
2396
2397 case FORTRESS:
2398 if (can_units_do_base_gui(punits, BASE_GUI_FORTRESS)) {
2399 i.value()->setEnabled(true);
2400 }
2401 break;
2402
2403 case AIRBASE:
2404 if (can_units_do_base_gui(punits, BASE_GUI_AIRBASE)) {
2405 i.value()->setEnabled(true);
2406 }
2407 break;
2408
2409 case POLLUTION:
2410 if (can_units_do_activity_client(punits, ACTIVITY_POLLUTION)
2411 || can_units_do_on_map(&(wld.map), punits, can_unit_paradrop)) {
2412 i.value()->setEnabled(true);
2413 }
2414 if (units_can_do_action_with_result(punits, ACTRES_PARADROP,
2415 true)
2416 || units_can_do_action_with_result(punits,
2417 ACTRES_PARADROP_CONQUER,
2418 true)) {
2419 i.value()->setText(
2420 QString(action_id_name_translation(ACTION_PARADROP))
2421 .replace("&", "&&"));
2422 } else {
2423 i.value()->setText(_("Clean Pollution"));
2424 }
2425 break;
2426
2427 case FALLOUT:
2428 if (can_units_do_activity_client(punits, ACTIVITY_FALLOUT)) {
2429 i.value()->setEnabled(true);
2430 }
2431 break;
2432
2433 case SENTRY:
2434 if (can_units_do_activity_client(punits, ACTIVITY_SENTRY)) {
2435 i.value()->setEnabled(true);
2436 }
2437 break;
2438
2439 case PILLAGE:
2440 if (can_units_do_activity_client(punits, ACTIVITY_PILLAGE)) {
2441 i.value()->setEnabled(true);
2442 }
2443 break;
2444
2445 case HOMECITY:
2446 if (can_units_do(punits, can_unit_change_homecity)) {
2447 i.value()->setEnabled(true);
2448 }
2449 break;
2450
2451 case WAKEUP:
2452 if (units_have_activity_on_tile(punits, ACTIVITY_SENTRY)) {
2453 i.value()->setEnabled(true);
2454 }
2455 break;
2456
2457 case AUTOSETTLER:
2458 if (can_units_do(punits, can_unit_do_autosettlers)) {
2459 i.value()->setEnabled(true);
2460 }
2461 if (units_contain_cityfounder(punits)) {
2462 i.value()->setText(_("Auto Settler"));
2463 } else {
2464 i.value()->setText(_("Auto Worker"));
2465 }
2466 break;
2467 case CONNECT_ROAD:
2468 proad = road_by_gui_type(ROAD_GUI_ROAD);
2469 if (proad != NULL) {
2470 tgt = road_extra_get(proad);
2471 } else {
2472 break;
2473 }
2474 if (can_units_do_connect(punits, ACTIVITY_GEN_ROAD, tgt)) {
2475 i.value()->setEnabled(true);
2476 }
2477 break;
2478
2479 case DISBAND:
2480 if (units_can_do_action(punits, ACTION_DISBAND_UNIT, true)) {
2481 i.value()->setEnabled(true);
2482 }
2483 break;
2484
2485 case CONNECT_RAIL:
2486 proad = road_by_gui_type(ROAD_GUI_RAILROAD);
2487 if (proad != NULL) {
2488 tgt = road_extra_get(proad);
2489 } else {
2490 break;
2491 }
2492 if (can_units_do_connect(punits, ACTIVITY_GEN_ROAD, tgt)) {
2493 i.value()->setEnabled(true);
2494 }
2495 break;
2496
2497 case CONNECT_MAGLEV:
2498 proad = road_by_gui_type(ROAD_GUI_MAGLEV);
2499 if (proad != NULL) {
2500 tgt = road_extra_get(proad);
2501 } else {
2502 break;
2503 }
2504 if (can_units_do_connect(punits, ACTIVITY_GEN_ROAD, tgt)) {
2505 i.value()->setEnabled(true);
2506 }
2507 break;
2508
2509 case CONNECT_IRRIGATION:
2510 {
2511 struct extra_type_list *extras = extra_type_list_by_cause(EC_IRRIGATION);
2512
2513 if (extra_type_list_size(extras) > 0) {
2514 struct extra_type *pextra;
2515
2516 pextra = extra_type_list_get(extra_type_list_by_cause(EC_IRRIGATION), 0);
2517 if (can_units_do_connect(punits, ACTIVITY_IRRIGATE, pextra)) {
2518 i.value()->setEnabled(true);
2519 }
2520 }
2521 }
2522 break;
2523
2524 case GOTO_CITY:
2525 if (any_cities) {
2526 i.value()->setEnabled(true);
2527 }
2528 break;
2529
2530 case AIRLIFT:
2531 if (any_cities) {
2532 i.value()->setEnabled(true);
2533 }
2534 break;
2535
2536 case BUILD_WONDER:
2537 i.value()->setText(
2538 QString(action_id_name_translation(ACTION_HELP_WONDER))
2539 .replace("&", "&&"));
2540 if (can_units_do(punits, unit_can_help_build_wonder_here)) {
2541 i.value()->setEnabled(true);
2542 }
2543 break;
2544
2545 case AUTOTRADEROUTE:
2546 if (units_can_do_action(punits, ACTION_TRADE_ROUTE, TRUE)) {
2547 i.value()->setEnabled(true);
2548 }
2549 break;
2550
2551 case ORDER_TRADE_ROUTE:
2552 i.value()->setText(
2553 QString(action_id_name_translation(ACTION_TRADE_ROUTE))
2554 .replace("&", "&&"));
2555 if (can_units_do(punits, unit_can_est_trade_route_here)) {
2556 i.value()->setEnabled(true);
2557 }
2558 break;
2559
2560 case ORDER_DIPLOMAT_DLG:
2561 if (units_can_do_action(punits, ACTION_ANY, TRUE)) {
2562 i.value()->setEnabled(true);
2563 }
2564 break;
2565
2566 case UPGRADE:
2567 if (units_can_upgrade(&(wld.map), punits)) {
2568 i.value()->setEnabled(true);
2569 }
2570 break;
2571 default:
2572 break;
2573 }
2574
2575 i++;
2576 }
2577 }
2578}
2579
2580/**********************************************************************/
2583 void mr_menu::slot_show_research_tab()
2584{
2585 science_report_dialog_popup(true);
2586}
2587
2588/**********************************************************************/
2591 void mr_menu::slot_spaceship()
2592{
2593 if (NULL != client.conn.playing) {
2594 popup_spaceship_dialog(client.conn.playing);
2595 }
2596}
2597
2598/**********************************************************************/
2601 void mr_menu::slot_show_eco_report()
2602{
2603 economy_report_dialog_popup(false);
2604}
2605
2606/**********************************************************************/
2609 void mr_menu::slot_show_map()
2610{
2611 ::gui()->game_tab_widget->setCurrentIndex(0);
2612}
2613
2614/**********************************************************************/
2617 void mr_menu::slot_show_units_report()
2618{
2619 toggle_units_report(true);
2620}
2621
2622/**********************************************************************/
2625 void mr_menu::slot_show_nations()
2626{
2627 popup_players_dialog(false);
2628}
2629
2630/**********************************************************************/
2633 void mr_menu::slot_show_cities()
2634{
2635 city_report_dialog_popup(false);
2636}
2637
2638/**********************************************************************/
2641 void mr_menu::slot_build_city()
2642{
2643 unit_list_iterate(get_units_in_focus(), punit) {
2644 /* FIXME: this can provide different actions for different units...
2645 * not good! */
2646 /* Enable the button for adding to a city in all cases, so we
2647 get an eventual error message from the server if we try. */
2648 if (unit_can_add_or_build_city(punit)) {
2649 request_unit_build_city(punit);
2650 } else if (utype_can_do_action(unit_type_get(punit), ACTION_HELP_WONDER)) {
2651 request_unit_caravan_action(punit, ACTION_HELP_WONDER);
2652 }
2653 } unit_list_iterate_end;
2654}
2655
2656/**********************************************************************/
2659 void mr_menu::slot_clean_fallout()
2660{
2661 key_unit_fallout();
2662}
2663
2664/**********************************************************************/
2667 void mr_menu::slot_clean_pollution()
2668{
2669 unit_list_iterate(get_units_in_focus(), punit) {
2670 /* FIXME: this can provide different actions for different units...
2671 * not good! */
2672 struct extra_type *pextra;
2673
2674 pextra = prev_extra_in_tile(unit_tile(punit), ERM_CLEANPOLLUTION,
2675 unit_owner(punit), punit);
2676 if (pextra != NULL) {
2677 request_new_unit_activity_targeted(punit, ACTIVITY_POLLUTION, pextra);
2678 } else if (can_unit_paradrop(&(wld.map), punit)) {
2679 /* FIXME: This is getting worse, we use a key_unit_*() function
2680 * which assign the order for all units! Very bad! */
2681 key_unit_paradrop();
2682 }
2683 } unit_list_iterate_end;
2684}
2685
2686/**********************************************************************/
2689 void mr_menu::slot_conn_irrigation()
2690{
2691 struct extra_type_list *extras = extra_type_list_by_cause(EC_IRRIGATION);
2692
2693 if (extra_type_list_size(extras) > 0) {
2694 struct extra_type *pextra;
2695
2696 pextra = extra_type_list_get(extra_type_list_by_cause(EC_IRRIGATION), 0);
2697
2698 key_unit_connect(ACTIVITY_IRRIGATE, pextra);
2699 }
2700}
2701
2702/**********************************************************************/
2705 void mr_menu::slot_conn_rail()
2706{
2707 struct road_type *prail = road_by_gui_type(ROAD_GUI_RAILROAD);
2708
2709 if (prail != NULL) {
2710 struct extra_type *tgt;
2711
2712 tgt = road_extra_get(prail);
2713 key_unit_connect(ACTIVITY_GEN_ROAD, tgt);
2714 }
2715}
2716
2717/**********************************************************************/
2720 void mr_menu::slot_conn_maglev()
2721{
2722 struct road_type *pmaglev = road_by_gui_type(ROAD_GUI_MAGLEV);
2723
2724 if (pmaglev != NULL) {
2725 struct extra_type *tgt;
2726
2727 tgt = road_extra_get(pmaglev);
2728 key_unit_connect(ACTIVITY_GEN_ROAD, tgt);
2729 }
2730}
2731
2732/**********************************************************************/
2735 void mr_menu::slot_unit_fortress()
2736{
2737 key_unit_fortress();
2738}
2739
2740/**********************************************************************/
2743 void mr_menu::slot_unit_airbase()
2744{
2745 key_unit_airbase();
2746}
2747
2748/**********************************************************************/
2751 void mr_menu::slot_conn_road()
2752{
2753 struct road_type *proad = road_by_gui_type(ROAD_GUI_ROAD);
2754
2755 if (proad != NULL) {
2756 struct extra_type *tgt;
2757
2758 tgt = road_extra_get(proad);
2759 key_unit_connect(ACTIVITY_GEN_ROAD, tgt);
2760 }
2761}
2762
2763/**********************************************************************/
2766 void mr_menu::slot_transform()
2767{
2768 key_unit_transform();
2769}
2770
2771/**********************************************************************/
2774 void mr_menu::slot_pillage()
2775{
2776 key_unit_pillage();
2777}
2778
2779/**********************************************************************/
2782 void mr_menu::slot_action()
2783{
2784 key_unit_action_select_tgt();
2785}
2786
2787/**********************************************************************/
2790 void mr_menu::slot_auto_settler()
2791{
2792 key_unit_auto_settle();
2793}
2794
2795/**********************************************************************/
2798 void mr_menu::slot_build_road()
2799{
2800 unit_list_iterate(get_units_in_focus(), punit) {
2801 /* FIXME: this can provide different actions for different units...
2802 * not good! */
2803 struct extra_type *tgt = next_extra_for_tile(unit_tile(punit),
2804 EC_ROAD,
2805 unit_owner(punit),
2806 punit);
2807 bool building_road = false;
2808
2809 if (tgt != NULL
2810 && can_unit_do_activity_targeted_client(punit, ACTIVITY_GEN_ROAD, tgt)) {
2811 request_new_unit_activity_targeted(punit, ACTIVITY_GEN_ROAD, tgt);
2812 building_road = true;
2813 }
2814
2815 if (!building_road && unit_can_est_trade_route_here(punit)) {
2816 request_unit_caravan_action(punit, ACTION_TRADE_ROUTE);
2817 }
2818 } unit_list_iterate_end;
2819}
2820
2821/**********************************************************************/
2824 void mr_menu::slot_build_irrigation()
2825{
2826 key_unit_irrigate();
2827}
2828
2829/**********************************************************************/
2832 void mr_menu::slot_cultivate()
2833{
2834 key_unit_cultivate();
2835}
2836
2837/**********************************************************************/
2840 void mr_menu::slot_build_mine()
2841{
2842 key_unit_mine();
2843}
2844
2845/**********************************************************************/
2848 void mr_menu::slot_plant()
2849{
2850 key_unit_plant();
2851}
2852
2853/**********************************************************************/
2856 void mr_menu::slot_unit_fortify()
2857{
2858 key_unit_fortify();
2859}
2860
2861/**********************************************************************/
2864 void mr_menu::slot_unit_sentry()
2865{
2866 key_unit_sentry();
2867}
2868
2869/**********************************************************************/
2872 void mr_menu::slot_convert()
2873{
2874 key_unit_convert();
2875}
2876
2877/**********************************************************************/
2880 void mr_menu::slot_disband()
2881{
2882 popup_disband_dialog(get_units_in_focus());
2883}
2884
2885/**********************************************************************/
2888 void mr_menu::slot_orders_clear()
2889{
2890 delayed_order = false;
2891 units_list.clear();
2892}
2893
2894/**********************************************************************/
2897 void mr_menu::slot_rally()
2898{
2899 gui()->rallies.hover_tile = false;
2900 gui()->rallies.hover_city = true;
2901}
2902
2903/**********************************************************************/
2906 void mr_menu::slot_trade_city()
2907{
2908 gui()->trade_gen.hover_city = true;
2909}
2910
2911/**********************************************************************/
2914 void mr_menu::slot_trade_add_all()
2915{
2916 gui()->trade_gen.add_all_cities();
2917}
2918
2919/**********************************************************************/
2922 void mr_menu::slot_calculate()
2923{
2924 gui()->trade_gen.calculate();
2925}
2926
2927/**********************************************************************/
2930 void mr_menu::slot_clear_trade()
2931{
2932 gui()->trade_gen.clear_trade_planing();
2933}
2934
2935/**********************************************************************/
2938 void mr_menu::slot_autocaravan()
2939{
2940 qtiles gilles;
2941 struct unit *punit;
2942 struct city *homecity;
2943 struct tile *home_tile;
2944 struct tile *dest_tile;
2945 bool sent = false;
2946
2947 punit = head_of_units_in_focus();
2948 homecity = game_city_by_number(punit->homecity);
2949 home_tile = homecity->tile;
2950 foreach(gilles, gui()->trade_gen.lines) {
2951 if ((gilles.t1 == home_tile || gilles.t2 == home_tile)
2952 && gilles.autocaravan == nullptr) {
2953 /* send caravan */
2954 if (gilles.t1 == home_tile) {
2955 dest_tile = gilles.t2;
2956 } else {
2957 dest_tile = gilles.t1;
2958 }
2959 if (send_goto_tile(punit, dest_tile)) {
2960 int i;
2961 i = gui()->trade_gen.lines.indexOf(gilles);
2962 gilles = gui()->trade_gen.lines.takeAt(i);
2963 gilles.autocaravan = punit;
2964 gui()->trade_gen.lines.append(gilles);
2965 sent = true;
2966 break;
2967 }
2968 }
2969 }
2970
2971 if (!sent) {
2972 gui()->infotab->chtwdg->append(_("Didn't find any trade route"
2973 " to establish"));
2974 }
2975}
2976
2977/**********************************************************************/
2980 void mr_menu::slot_quickairlift_set()
2981{
2982 QVariant v;
2983 QAction *act;
2984
2985 act = qobject_cast<QAction *>(sender());
2986 v = act->data();
2987 airlift_type_id = v.toInt();
2988}
2989
2990/**********************************************************************/
2993 void mr_menu::slot_action_vs_unit()
2994{
2995 QAction *act;
2996
2997 act = qobject_cast<QAction *>(sender());
2998 qdef_act::action()->vs_unit_set(act->data().toInt());
2999}
3000
3001/**********************************************************************/
3004 void mr_menu::slot_action_vs_city()
3005{
3006 QAction *act;
3007
3008 act = qobject_cast<QAction *>(sender());
3009 qdef_act::action()->vs_city_set(act->data().toInt());
3010}
3011
3012/**********************************************************************/
3015 void mr_menu::slot_quickairlift()
3016{
3017 quick_airlifting = true;
3018}
3019
3020/**********************************************************************/
3023 void mr_menu::slot_delayed_goto()
3024{
3025 qfc_delayed_unit_item *unit_item;
3026 int i = 0;
3027 delay_order dg;
3028
3029 delayed_order = true;
3030 dg = D_GOTO;
3031
3032 struct unit_list *punits = get_units_in_focus();
3033 if (unit_list_size(punits) == 0) {
3034 return;
3035 }
3036 if (hover_state != HOVER_GOTO) {
3037 set_hover_state(punits, HOVER_GOTO, ACTIVITY_LAST, NULL,
3038 NO_TARGET, NO_TARGET, ACTION_NONE, ORDER_LAST);
3039 enter_goto_state(punits);
3040 create_line_at_mouse_pos();
3041 control_mouse_cursor(NULL);
3042 }
3043 unit_list_iterate(get_units_in_focus(), punit) {
3044 i++;
3045 unit_item = new qfc_delayed_unit_item(dg, punit->id);
3046 units_list.add(unit_item);
3047 units_list.nr_units = i;
3048 } unit_list_iterate_end;
3049}
3050
3051/**********************************************************************/
3054 void mr_menu::slot_execute_orders()
3055{
3056 qfc_delayed_unit_item *fui;
3057 struct unit *punit;
3058 struct tile *last_tile;
3059 struct tile *new_tile;
3060 int i = 0;
3061
3062 foreach (fui, units_list.unit_list) {
3063 i++;
3064 punit = unit_list_find(client_player()->units, fui->id);
3065 if (punit == nullptr) {
3066 continue;
3067 }
3068 last_tile = punit->tile;
3069 new_tile = find_last_unit_pos(punit, i);
3070 if (new_tile != nullptr) {
3071 punit->tile = new_tile;
3072 }
3073 if (is_tiles_adjacent(punit->tile, fui->ptile)) {
3074 request_move_unit_direction(punit,
3075 get_direction_for_step(&(wld.map),
3076 punit->tile,
3077 fui->ptile));
3078 } else {
3079 send_attack_tile(punit, fui->ptile);
3080 }
3081 punit->tile = last_tile;
3082 }
3083 units_list.clear();
3084}
3085
3086/**********************************************************************/
3089 void mr_menu::slot_board()
3090{
3091 unit_list_iterate(get_units_in_focus(), punit) {
3092 qtg_request_transport(punit, unit_tile(punit));
3093 } unit_list_iterate_end;
3094}
3095
3096/**********************************************************************/
3099 void mr_menu::slot_patrol()
3100{
3101 key_unit_patrol();
3102}
3103
3104/**********************************************************************/
3107 void mr_menu::slot_return_to_city()
3108{
3109 unit_list_iterate(get_units_in_focus(), punit) {
3110 request_unit_return(punit);
3111 } unit_list_iterate_end;
3112}
3113
3114/**********************************************************************/
3117 void mr_menu::slot_airlift()
3118{
3119 popup_goto_dialog();
3120}
3121
3122/**********************************************************************/
3125 void mr_menu::slot_set_home()
3126{
3127 key_unit_homecity();
3128}
3129
3130/**********************************************************************/
3133 void mr_menu::slot_deboard()
3134{
3135 unit_list_iterate(get_units_in_focus(), punit) {
3136 request_unit_unload(punit);
3137 } unit_list_iterate_end;
3138}
3139
3140/**********************************************************************/
3143 void mr_menu::slot_unload_all()
3144{
3145 key_unit_unload_all();
3146}
3147
3148/**********************************************************************/
3151 void mr_menu::slot_unsentry()
3152{
3153 key_unit_wakeup_others();
3154}
3155
3156/**********************************************************************/
3159 void mr_menu::slot_upgrade()
3160{
3161 popup_upgrade_dialog(get_units_in_focus());
3162}
3163
3164/**********************************************************************/
3167 void mr_menu::slot_unit_goto()
3168{
3169 key_unit_goto();
3170}
3171
3172/**********************************************************************/
3175 void mr_menu::slot_unit_explore()
3176{
3177 key_unit_auto_explore();
3178}
3179
3180/**********************************************************************/
3183 void mr_menu::slot_center_view()
3184{
3185 request_center_focus_unit();
3186}
3187
3188/**********************************************************************/
3191 void mr_menu::slot_lock()
3192{
3193 if (gui()->interface_locked) {
3194 enable_interface(false);
3195 } else {
3196 enable_interface(true);
3197 }
3198 gui()->interface_locked = !gui()->interface_locked;
3199}
3200
3201/**********************************************************************/
3204 void enable_interface(bool enable)
3205{
3206 QList<close_widget *> lc;
3207 QList<move_widget *> lm;
3208 QList<resize_widget *> lr;
3209 int i;
3210
3211 lc = gui()->findChildren<close_widget *>();
3212 lm = gui()->findChildren<move_widget *>();
3213 lr = gui()->findChildren<resize_widget *>();
3214
3215 for (i = 0; i < lc.size(); ++i) {
3216 lc.at(i)->setVisible(!enable);
3217 }
3218 for (i = 0; i < lm.size(); ++i) {
3219 lm.at(i)->setVisible(!enable);
3220 }
3221 for (i = 0; i < lr.size(); ++i) {
3222 lr.at(i)->setVisible(!enable);
3223 }
3224}
3225
3226/**********************************************************************/
3229 void mr_menu::slot_fullscreen()
3230{
3231 gui_options.gui_qt_fullscreen = !gui_options.gui_qt_fullscreen;
3232
3233 gui()->apply_fullscreen();
3234}
3235
3236/**********************************************************************/
3239 void mr_menu::slot_minimap_view()
3240{
3241 if (minimap_status->isChecked()) {
3242 ::gui()->minimapview_wdg->show();
3243 } else {
3244 ::gui()->minimapview_wdg->hide();
3245 }
3246}
3247
3248/**********************************************************************/
3251 void mr_menu::slot_show_new_turn_text()
3252{
3253 if (osd_status->isChecked()) {
3254 gui()->qt_settings.show_new_turn_text = true;
3255 } else {
3256 gui()->qt_settings.show_new_turn_text = false;
3257 }
3258}
3259
3260/**********************************************************************/
3263 void mr_menu::slot_battlelog()
3264{
3265 if (btlog_status->isChecked()) {
3266 gui()->qt_settings.show_battle_log = true;
3267 } else {
3268 gui()->qt_settings.show_battle_log = false;
3269 }
3270}
3271
3272/**********************************************************************/
3275 void mr_menu::slot_borders()
3276{
3277 key_map_borders_toggle();
3278}
3279
3280/**********************************************************************/
3283 void mr_menu::slot_native_tiles()
3284{
3285 key_map_native_toggle();
3286}
3287
3288/**********************************************************************/
3291 void mr_menu::slot_city_buycost()
3292{
3293 key_city_buycost_toggle();
3294}
3295
3296/**********************************************************************/
3299 void mr_menu::slot_city_growth()
3300{
3301 key_city_growth_toggle();
3302}
3303
3304/**********************************************************************/
3307 void mr_menu::zoom_in()
3308{
3309 gui()->map_scale = gui()->map_scale * 1.2f;
3310 tilespec_reread(tileset_basename(tileset), true, gui()->map_scale);
3311}
3312
3313/**********************************************************************/
3316 void mr_menu::zoom_reset()
3317{
3318 QFont *qf;
3319
3320 gui()->map_scale = 1.0f;
3321 qf = fc_font::instance()->get_font(fonts::city_names);
3322 qf->setPointSize(fc_font::instance()->city_fontsize);
3323 qf = fc_font::instance()->get_font(fonts::city_productions);
3324 qf->setPointSize(fc_font::instance()->prod_fontsize);
3325 tilespec_reread(tileset_basename(tileset), true, gui()->map_scale);
3326}
3327
3328/**********************************************************************/
3331 void mr_menu::zoom_scale_fonts()
3332{
3333 QFont *qf;
3334
3335 if (scale_fonts_status->isChecked()) {
3336 gui()->map_font_scale = true;
3337 } else {
3338 qf = fc_font::instance()->get_font(fonts::city_names);
3339 qf->setPointSize(fc_font::instance()->city_fontsize);
3340 qf = fc_font::instance()->get_font(fonts::city_productions);
3341 qf->setPointSize(fc_font::instance()->prod_fontsize);
3342 gui()->map_font_scale = false;
3343 }
3344 update_city_descriptions();
3345}
3346
3347
3348/**********************************************************************/
3351 void mr_menu::zoom_out()
3352{
3353 gui()->map_scale = gui()->map_scale / 1.2f;
3354 tilespec_reread(tileset_basename(tileset), true, gui()->map_scale);
3355}
3356
3357/**********************************************************************/
3360 void mr_menu::slot_city_names()
3361{
3362 key_city_names_toggle();
3363}
3364
3365/**********************************************************************/
3368 void mr_menu::slot_city_outlines()
3369{
3370 key_city_outlines_toggle();
3371}
3372
3373/**********************************************************************/
3376 void mr_menu::slot_city_output()
3377{
3378 key_city_output_toggle();
3379}
3380
3381/**********************************************************************/
3384 void mr_menu::slot_city_production()
3385{
3386 key_city_productions_toggle();
3387}
3388
3389/**********************************************************************/
3392 void mr_menu::slot_city_trade_routes()
3393{
3394 key_city_trade_routes_toggle();
3395}
3396
3397/**********************************************************************/
3400 void mr_menu::slot_stack_size()
3401{
3402 key_unit_stack_size_toggle();
3403}
3404
3405/**********************************************************************/
3408 void mr_menu::slot_fullbar()
3409{
3410 key_city_full_bar_toggle();
3411}
3412
3413/**********************************************************************/
3416 void mr_menu::slot_map_grid()
3417{
3418 key_map_grid_toggle();
3419}
3420
3421/**********************************************************************/
3424 void mr_menu::slot_done_moving()
3425{
3426 key_unit_done();
3427}
3428
3429/**********************************************************************/
3432 void mr_menu::slot_select_all_tile()
3433{
3434 request_unit_select(get_units_in_focus(), SELTYPE_ALL, SELLOC_TILE);
3435}
3436
3437/**********************************************************************/
3440 void mr_menu::slot_select_one()
3441{
3442 request_unit_select(get_units_in_focus(), SELTYPE_SINGLE, SELLOC_TILE);
3443}
3444
3445/**********************************************************************/
3448 void mr_menu::slot_select_same_continent()
3449{
3450 if (!gui_options.unit_selection_clears_orders || confirm_disruptive_selection()) {
3451 request_unit_select(get_units_in_focus(), SELTYPE_SAME, SELLOC_CONT);
3452 }
3453}
3454
3455/**********************************************************************/
3458 void mr_menu::slot_select_same_everywhere()
3459{
3460 if (!gui_options.unit_selection_clears_orders || confirm_disruptive_selection()) {
3461 request_unit_select(get_units_in_focus(), SELTYPE_SAME, SELLOC_WORLD);
3462 }
3463}
3464
3465/**********************************************************************/
3468 void mr_menu::slot_select_same_tile()
3469{
3470 request_unit_select(get_units_in_focus(), SELTYPE_SAME, SELLOC_TILE);
3471}
3472
3473/**********************************************************************/
3476 void mr_menu::slot_wait()
3477{
3478 key_unit_wait();
3479}
3480
3481/**********************************************************************/
3484 void mr_menu::slot_unit_filter()
3485{
3486 unit_hud_selector *uhs;
3487 uhs = new unit_hud_selector(gui()->central_wdg);
3488 uhs->show_me();
3489}
3490
3491/**********************************************************************/
3494 void mr_menu::slot_demographics()
3495{
3496 send_report_request(REPORT_DEMOGRAPHIC);
3497}
3498
3499/**********************************************************************/
3502 void mr_menu::slot_achievements()
3503{
3504 send_report_request(REPORT_ACHIEVEMENTS);
3505}
3506
3507/**********************************************************************/
3510 void mr_menu::slot_endgame()
3511{
3512 popup_endgame_report();
3513}
3514
3515/**********************************************************************/
3518 void mr_menu::slot_top_five()
3519{
3520 send_report_request(REPORT_TOP_5_CITIES);
3521}
3522
3523/**********************************************************************/
3526 void mr_menu::slot_traveler()
3527{
3528 send_report_request(REPORT_WONDERS_OF_THE_WORLD);
3529}
3530
3531/**********************************************************************/
3534 void mr_menu::slot_bg1select()
3535{
3536 key_unit_select_battlegroup(0, FALSE);
3537}
3538
3539/**********************************************************************/
3542 void mr_menu::slot_bg1assign()
3543{
3544 key_unit_assign_battlegroup(0, FALSE);
3545}
3546
3547/**********************************************************************/
3550 void mr_menu::slot_bg1append()
3551{
3552 key_unit_assign_battlegroup(0, TRUE);
3553}
3554
3555/**********************************************************************/
3558 void mr_menu::slot_bg2select()
3559{
3560 key_unit_select_battlegroup(1, FALSE);
3561}
3562
3563/**********************************************************************/
3566 void mr_menu::slot_bg2assign()
3567{
3568 key_unit_assign_battlegroup(1, FALSE);
3569}
3570
3571/**********************************************************************/
3574 void mr_menu::slot_bg2append()
3575{
3576 key_unit_assign_battlegroup(1, TRUE);
3577}
3578
3579/**********************************************************************/
3582 void mr_menu::slot_bg3select()
3583{
3584 key_unit_select_battlegroup(2, FALSE);
3585}
3586
3587/**********************************************************************/
3590 void mr_menu::slot_bg3assign()
3591{
3592 key_unit_assign_battlegroup(2, FALSE);
3593}
3594
3595/**********************************************************************/
3598 void mr_menu::slot_bg3append()
3599{
3600 key_unit_assign_battlegroup(2, TRUE);
3601}
3602
3603/**********************************************************************/
3606 void mr_menu::slot_bg4select()
3607{
3608 key_unit_select_battlegroup(3, FALSE);
3609}
3610
3611/**********************************************************************/
3614 void mr_menu::slot_bg4assign()
3615{
3616 key_unit_assign_battlegroup(3, FALSE);
3617}
3618
3619/**********************************************************************/
3622 void mr_menu::slot_bg4append()
3623{
3624 key_unit_assign_battlegroup(3, TRUE);
3625}
3626
3627/**********************************************************************/
3630 void mr_menu::tileset_custom_load()
3631{
3632 QDialog *dialog = new QDialog(this);
3633 QLabel *label;
3634 QPushButton *but;
3635 QVBoxLayout *layout;
3636 const struct strvec *tlset_list;
3637 const struct option *poption;
3638 QStringList sl;
3639 QString s;
3640
3641 sl << "default_tileset_overhead_name" << "default_tileset_iso_name"
3642 << "default_tileset_hex_name" << "default_tileset_isohex_name";
3643 layout = new QVBoxLayout;
3644 dialog->setWindowTitle(_("Available tilesets"));
3645 label = new QLabel;
3646 label->setText(_("Some tilesets might not be compatible with current"
3647 " map topology!"));
3648 layout->addWidget(label);
3649
3650 foreach (s, sl) {
3651 QByteArray on_bytes;
3652
3653 on_bytes = s.toUtf8();
3654 poption = optset_option_by_name(client_optset, on_bytes.data());
3655 tlset_list = get_tileset_list(poption);
3656 strvec_iterate(tlset_list, value) {
3657 but = new QPushButton(value);
3658 connect(but, &QAbstractButton::clicked, this, &mr_menu::load_new_tileset);
3659 layout->addWidget(but);
3660 } strvec_iterate_end;
3661 }
3662 dialog->setSizeGripEnabled(true);
3663 dialog->setLayout(layout);
3664 dialog->show();
3665}
3666
3667/**********************************************************************/
3670 void mr_menu::load_new_tileset()
3671{
3672 QPushButton *but;
3673 QByteArray tn_bytes;
3674
3675 but = qobject_cast<QPushButton *>(sender());
3676 tn_bytes = but->text().toUtf8();
3677 tilespec_reread(tn_bytes.data(), true, 1.0f);
3678 gui()->map_scale = 1.0f;
3679 but->parentWidget()->close();
3680}
3681
3682/**********************************************************************/
3685 void mr_menu::calc_trade_routes()
3686{
3687 gui()->trade_gen.calculate();
3688}
3689
3690/**********************************************************************/
3693 void mr_menu::slot_popup_tax_rates()
3694{
3695 popup_rates_dialog();
3696}
3697
3698/**********************************************************************/
3701 void mr_menu::slot_popup_mult_rates()
3702{
3703 popup_multiplier_dialog();
3704}
3705
3706/**********************************************************************/
3709 void mr_menu::slot_help(const QString &topic)
3710{
3711 popup_help_dialog_typed(Q_(topic.toStdString().c_str()), HELP_ANY);
3712}
3713
3714/****************************************************************
3715 Actions "BUILD_PATH_*"
3716*****************************************************************/
3717 void mr_menu::slot_build_path(int id)
3718{
3719 unit_list_iterate(get_units_in_focus(), punit) {
3720 extra_type_by_cause_iterate(EC_ROAD, pextra) {
3721 if (pextra->buildable && pextra->id == id
3722 && can_unit_do_activity_targeted_client(punit, ACTIVITY_GEN_ROAD,
3723 pextra)) {
3724 request_new_unit_activity_targeted(punit, ACTIVITY_GEN_ROAD, pextra);
3725 }
3726 } extra_type_by_cause_iterate_end;
3727 } unit_list_iterate_end;
3728}
3729
3730/****************************************************************
3731 Actions "BUILD_BASE_*"
3732*****************************************************************/
3733 void mr_menu::slot_build_base(int id)
3734{
3735 unit_list_iterate(get_units_in_focus(), punit) {
3736 extra_type_by_cause_iterate(EC_BASE, pextra) {
3737 if (pextra->buildable && pextra->id == id
3738 && can_unit_do_activity_targeted_client(punit, ACTIVITY_BASE,
3739 pextra)) {
3740 request_new_unit_activity_targeted(punit, ACTIVITY_BASE, pextra);
3741 }
3742 } extra_type_by_cause_iterate_end;
3743 } unit_list_iterate_end;
3744}
3745
3746
3747
3748/**********************************************************************/
3751 void mr_menu::local_options()
3752{
3753 gui()->popup_client_options();
3754}
3755
3756/**********************************************************************/
3759 void mr_menu::shortcut_options()
3760{
3761 popup_shortcuts_dialog();
3762}
3763
3764/**********************************************************************/
3767 void mr_menu::server_options()
3768{
3769 gui()->pr_options->popup_server_options();
3770}
3771
3772/**********************************************************************/
3775 void mr_menu::messages_options()
3776{
3777 popup_messageopt_dialog();
3778}
3779
3780/**********************************************************************/
3783 void mr_menu::save_options_now()
3784{
3785 options_save(NULL);
3786}
3787
3788/**********************************************************************/
3791 void mr_menu::quit_game()
3792{
3793 popup_quit_dialog();
3794}
3795
3796/**********************************************************************/
3799 void mr_menu::save_image()
3800{
3801 int current_width, current_height;
3802 int full_size_x, full_size_y;
3803 QString path, storage_path;
3804 hud_message_box *saved = new hud_message_box(gui()->central_wdg);
3805 bool map_saved;
3806 QString img_name;
3807
3808 full_size_x = (wld.map.xsize + 2) * tileset_tile_width(tileset);
3809 full_size_y = (wld.map.ysize + 2) * tileset_tile_height(tileset);
3810 current_width = gui()->mapview_wdg->width();
3811 current_height = gui()->mapview_wdg->height();
3812 if (tileset_hex_width(tileset) > 0) {
3813 full_size_y = full_size_y * 11 / 20;
3814 } else if (tileset_is_isometric(tileset)) {
3815 full_size_y = full_size_y / 2;
3816 }
3817 map_canvas_resized(full_size_x, full_size_y);
3818 img_name = QString("Freeciv-Turn%1").arg(game.info.turn);
3819 if (client_has_player()) {
3820 img_name = img_name + "-"
3821 + QString(nation_plural_for_player(client_player()));
3822 }
3823 storage_path = freeciv_storage_dir();
3824 path = QStandardPaths::writableLocation(QStandardPaths::PicturesLocation);
3825 if (!storage_path.isEmpty() && QDir(storage_path).isReadable()) {
3826 img_name = storage_path + DIR_SEPARATOR + img_name;
3827 } else if (!path.isEmpty()) {
3828 img_name = path + DIR_SEPARATOR + img_name;
3829 } else {
3830 img_name = QStandardPaths::writableLocation(QStandardPaths::HomeLocation)
3831 + DIR_SEPARATOR + img_name;
3832 }
3833 map_saved = mapview.store->map_pixmap.save(img_name, "png");
3834 map_canvas_resized(current_width, current_height);
3835 saved->setStandardButtons(QMessageBox::Ok);
3836 saved->setDefaultButton(QMessageBox::Cancel);
3837 saved->setAttribute(Qt::WA_DeleteOnClose);
3838 if (map_saved) {
3839 saved->set_text_title("Image saved as:\n" + img_name, _("Success"));
3840 } else {
3841 saved->set_text_title(_("Failed to save image of the map"), _("Error"));
3842 }
3843 saved->show();
3844}
3845
3846/**********************************************************************/
3849 void mr_menu::save_game()
3850{
3851 send_save_game(NULL);
3852}
3853
3854/**********************************************************************/
3857 void mr_menu::save_game_as()
3858{
3859 QString str;
3860 QString current_file;
3861 QString location;
3862
3863 strvec_iterate(get_save_dirs(), dirname) {
3864 location = dirname;
3865 // choose last location
3866 } strvec_iterate_end;
3867
3868 str = QString(_("Save Games"))
3869 + QString(" (*.sav *.sav.bz2 *.sav.gz *.sav.xz)");
3870 current_file = QFileDialog::getSaveFileName(gui()->central_wdg,
3871 _("Save Game As..."),
3872 location, str);
3873 if (!current_file.isEmpty()) {
3874 QByteArray cf_bytes;
3875
3876 cf_bytes = current_file.toUtf8();
3877 send_save_game(cf_bytes.data());
3878 }
3879}
3880
3881/**********************************************************************/
3884 void mr_menu::back_to_menu()
3885{
3886 hud_message_box *ask;
3887
3888 if (is_server_running()) {
3889 ask = new hud_message_box(gui()->central_wdg);
3890 ask->set_text_title(_("Leaving a local game will end it!"), "Leave game");
3891 ask->setStandardButtons(QMessageBox::Cancel | QMessageBox::Ok);
3892 ask->setDefaultButton(QMessageBox::Cancel);
3893 ask->setAttribute(Qt::WA_DeleteOnClose);
3894
3895 connect(ask, &hud_message_box::accepted, [=]() {
3896 if (client.conn.used) {
3897 disconnect_from_server();
3898 }
3899 });
3900 ask->show();
3901 } else {
3902 disconnect_from_server();
3903 }
3904}
3905
3906/**********************************************************************/
3909 bool mr_menu::confirm_disruptive_selection()
3910{
3911 hud_message_box* ask = new hud_message_box(gui()->central_wdg);
3912
3913 ask->setIcon(QMessageBox::Warning);
3914 ask->setStandardButtons(QMessageBox::Cancel | QMessageBox::Ok);
3915 ask->setDefaultButton(QMessageBox::Cancel);
3916 ask->setAttribute(Qt::WA_DeleteOnClose);
3917 return (ask->set_text_title(_("Selection will cancel current assignments!"),
3918 _("Confirm Disruptive Selection"), true)
3919 == QMessageBox::Ok);
3920}
3921
3922/**********************************************************************/
3925 void multiairlift(struct city *acity, Unit_type_id ut)
3926{
3927 struct tile *ptile;
3928 city_list_iterate(client.conn.playing->cities, pcity) {
3929 if (get_city_bonus(pcity, EFT_AIRLIFT) > 0) {
3930 ptile = city_tile(pcity);
3931 unit_list_iterate(ptile->units, punit) {
3932 if (punit->utype == utype_by_number(ut)) {
3933 request_unit_airlift(punit, acity);
3934 break;
3935 }
3936 } unit_list_iterate_end;
3937 }
3938 } city_list_iterate_end;
3939}
action_removes_extra
bool action_removes_extra(const struct action *paction, const struct extra_type *pextra)
Definition actions.c:2312
action_name_translation
const char * action_name_translation(const struct action *action)
Definition actions.c:1890
action_id_name_translation
const char * action_id_name_translation(action_id act_id)
Definition actions.c:1910
action_get_sub_target_kind
enum action_sub_target_kind action_get_sub_target_kind(const struct action *paction)
Definition actions.c:1751
actions_are_ready
bool actions_are_ready(void)
Definition actions.c:1583
action_creates_extra
bool action_creates_extra(const struct action *paction, const struct extra_type *pextra)
Definition actions.c:2224
action_by_number
static struct action * action_by_number(action_id act_id)
Definition actions.h:638
action_iterate_end
#define action_iterate_end
Definition actions.h:472
action_id_get_actor_kind
#define action_id_get_actor_kind(act_id)
Definition actions.h:651
action_iterate
#define action_iterate(_act_)
Definition actions.h:467
ACTION_ANY
#define ACTION_ANY
Definition actions.h:290
action_id_get_target_kind
#define action_id_get_target_kind(act_id)
Definition actions.h:655
action_id_has_complex_target
#define action_id_has_complex_target(act_id)
Definition actions.h:673
ACTION_NONE
#define ACTION_NONE
Definition actions.h:293
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:3339
destroy_city_virtual
void destroy_city_virtual(struct city *pcity)
Definition city.c:3415
is_non_allied_city_tile
static bool is_non_allied_city_tile(const struct tile *ptile, const struct player *pplayer)
Definition city.h:741
city_list_iterate
#define city_list_iterate(citylist, pcity)
Definition city.h:488
city_tile
#define city_tile(_pcity_)
Definition city.h:544
city_list_iterate_end
#define city_list_iterate_end
Definition city.h:490
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:277
fc_shortcuts::get_shortcut
fc_shortcut * get_shortcut(shortcut_id id)
Definition shortcuts.cpp:235
hud_message_box
Definition hudwidget.h:56
hud_message_box::set_text_title
int set_text_title(QString s1, QString s2, bool return_exec=false)
Definition hudwidget.cpp:126
move_widget
Definition mapview.h:154
qdef_act::action
static qdef_act * action()
Definition dialogs.cpp:1019
qdef_act::vs_city_set
void vs_city_set(int i)
Definition dialogs.cpp:1041
qdef_act::vs_unit_set
void vs_unit_set(int i)
Definition dialogs.cpp:1049
qfc_delayed_unit_item
Definition menu.h:109
qfc_delayed_unit_item::ptile
struct tile * ptile
Definition menu.h:118
qfc_delayed_unit_item::id
int id
Definition menu.h:117
qfc_units_list::unit_list
QList< qfc_delayed_unit_item * > unit_list
Definition menu.h:130
qfc_units_list::add
void add(qfc_delayed_unit_item *fui)
Definition menu.cpp:493
qfc_units_list::nr_units
int nr_units
Definition menu.h:131
qfc_units_list::clear
void clear()
Definition menu.cpp:501
qfc_units_list::qfc_units_list
qfc_units_list()
Definition menu.cpp:486
resize_widget
Definition mapview.h:136
trade_city
Definition menu.h:138
trade_city::done
bool done
Definition menu.h:142
trade_city::trade_num
unsigned trade_num
Definition menu.h:145
trade_city::poss_trade_num
int poss_trade_num
Definition menu.h:144
trade_city::pos_cities
QList< struct city * > pos_cities
Definition menu.h:148
trade_city::new_tr_cities
QList< struct city * > new_tr_cities
Definition menu.h:147
trade_city::over_max
int over_max
Definition menu.h:143
trade_city::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:146
trade_city::city
struct city * city
Definition menu.h:149
trade_generator::calculate_inner
void calculate_inner(trade_city *tc)
Definition menu.cpp:214
trade_generator::discard_one
bool discard_one(trade_city *tc)
Definition menu.cpp:376
trade_generator::add_city
void add_city(struct city *pcity)
Definition menu.cpp:125
trade_generator::find_certain_routes
void find_certain_routes()
Definition menu.cpp:458
trade_generator::cities
QList< trade_city * > cities
Definition menu.h:181
trade_generator::find_certain_routes_inner
void find_certain_routes_inner(trade_city *tc)
Definition menu.cpp:423
trade_generator::find_most_free
trade_city * find_most_free()
Definition menu.cpp:325
trade_generator::discard_trade
void discard_trade(trade_city *tc1, trade_city *tc2)
Definition menu.cpp:362
trade_generator::add_tile
void add_tile(struct tile *ptile)
Definition menu.cpp:137
trade_generator::trade_generator
trade_generator()
Definition menu.cpp:79
trade_generator::remove_virtual_city
void remove_virtual_city(struct tile *ptile)
Definition menu.cpp:188
trade_generator::hover_city
bool hover_city
Definition menu.h:178
trade_generator::add_all_cities
void add_all_cities()
Definition menu.cpp:87
trade_generator::clear_trade_planing
void clear_trade_planing()
Definition menu.cpp:105
trade_generator::discard
void discard()
Definition menu.cpp:343
trade_generator::remove_city
void remove_city(struct city *pcity)
Definition menu.cpp:170
trade_generator::lines
QList< qtiles > lines
Definition menu.h:179
trade_generator::discard_any
bool discard_any(trade_city *tc, int freeroutes)
Definition menu.cpp:402
trade_generator::check_if_done
void check_if_done(trade_city *tc1, trade_city *tc2)
Definition menu.cpp:473
trade_generator::virtual_cities
QList< struct city * > virtual_cities
Definition menu.h:180
trade_generator::find_over_max
int find_over_max(struct city *pcity)
Definition menu.cpp:309
trade_generator::calculate
void calculate()
Definition menu.cpp:232
unit_hud_selector
Definition hudwidget.h:248
unit_hud_selector::show_me
void show_me()
Definition hudwidget.cpp:1439
unit_item
Definition citydlg.h:142
client_is_observer
bool client_is_observer(void)
Definition client_main.c:1086
client
struct civclient client
Definition client_main.c:149
client_state
enum client_states client_state(void)
Definition client_main.c:1029
is_waiting_turn_change
bool is_waiting_turn_change(void)
Definition client_main.c:1129
send_report_request
void send_report_request(enum report_type type)
Definition client_main.c:839
can_client_issue_orders
bool can_client_issue_orders(void)
Definition client_main.c:1265
client_has_player
bool client_has_player(void)
Definition client_main.c:1365
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:1224
disconnect_from_server
void disconnect_from_server(void)
Definition clinet.c:305
send_save_game
void send_save_game(const char *filename)
Definition connectdlg_common.c:741
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:3607
request_unit_airlift
void request_unit_airlift(struct unit *punit, struct city *pcity)
Definition control.c:1512
key_city_output_toggle
void key_city_output_toggle(void)
Definition control.c:3704
request_unit_return
void request_unit_return(struct unit *punit)
Definition control.c:1521
request_unit_caravan_action
void request_unit_caravan_action(struct unit *punit, action_id action)
Definition control.c:2121
key_unit_auto_explore
void key_unit_auto_explore(void)
Definition control.c:3383
key_unit_auto_settle
void key_unit_auto_settle(void)
Definition control.c:3396
key_unit_connect
void key_unit_connect(enum unit_activity activity, struct extra_type *tgt)
Definition control.c:3189
key_city_full_bar_toggle
void key_city_full_bar_toggle(void)
Definition control.c:3736
key_map_native_toggle
void key_map_native_toggle(void)
Definition control.c:3728
request_unit_goto
void request_unit_goto(enum unit_orders last_order, action_id act_id, int sub_tgt_id)
Definition control.c:1103
key_unit_paradrop
void key_unit_paradrop(void)
Definition control.c:3293
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:2610
key_city_productions_toggle
void key_city_productions_toggle(void)
Definition control.c:3770
key_unit_plant
void key_unit_plant(void)
Definition control.c:3529
key_unit_fortress
void key_unit_fortress(void)
Definition control.c:3438
key_unit_mine
void key_unit_mine(void)
Definition control.c:3521
key_unit_pillage
void key_unit_pillage(void)
Definition control.c:3541
request_unit_unload
void request_unit_unload(struct unit *pcargo)
Definition control.c:2092
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:1837
key_unit_irrigate
void key_unit_irrigate(void)
Definition control.c:3501
request_unit_build_city
void request_unit_build_city(struct unit *punit)
Definition control.c:1714
key_unit_unload_all
void key_unit_unload_all(void)
Definition control.c:3323
key_city_outlines_toggle
void key_city_outlines_toggle(void)
Definition control.c:3696
key_unit_homecity
void key_unit_homecity(void)
Definition control.c:3455
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:3301
key_unit_wakeup_others
void key_unit_wakeup_others(void)
Definition control.c:3356
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:3787
key_unit_wait
void key_unit_wait(void)
Definition control.c:3348
key_unit_select_battlegroup
void key_unit_select_battlegroup(int battlegroup, bool append)
Definition control.c:3670
key_map_grid_toggle
void key_map_grid_toggle(void)
Definition control.c:3712
head_of_units_in_focus
struct unit * head_of_units_in_focus(void)
Definition control.c:406
key_city_growth_toggle
void key_city_growth_toggle(void)
Definition control.c:3753
key_unit_action_select_tgt
void key_unit_action_select_tgt(void)
Definition control.c:3220
key_unit_fallout
void key_unit_fallout(void)
Definition control.c:3418
key_city_buycost_toggle
void key_city_buycost_toggle(void)
Definition control.c:3762
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:3619
request_move_unit_direction
void request_move_unit_direction(struct unit *punit, int dir)
Definition control.c:1777
key_unit_done
void key_unit_done(void)
Definition control.c:3277
key_city_trade_routes_toggle
void key_city_trade_routes_toggle(void)
Definition control.c:3779
key_city_names_toggle
void key_city_names_toggle(void)
Definition control.c:3744
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:1590
key_unit_airbase
void key_unit_airbase(void)
Definition control.c:3366
key_unit_goto
void key_unit_goto(void)
Definition control.c:3285
control_mouse_cursor
void control_mouse_cursor(struct tile *ptile)
Definition control.c:1188
key_unit_convert
void key_unit_convert(void)
Definition control.c:3408
key_unit_fortify
void key_unit_fortify(void)
Definition control.c:3426
key_unit_assign_battlegroup
void key_unit_assign_battlegroup(int battlegroup, bool append)
Definition control.c:3631
key_unit_cultivate
void key_unit_cultivate(void)
Definition control.c:3509
key_map_borders_toggle
void key_map_borders_toggle(void)
Definition control.c:3720
control.h
can_unit_do_activity_targeted_client
#define can_unit_do_activity_targeted_client(_punit_, _act_, _tgt_)
Definition control.h:42
can_units_do_activity_targeted_client
#define can_units_do_activity_targeted_client(_punits_, _act_, _tgt_)
Definition control.h:46
HOVER_GOTO
@ HOVER_GOTO
Definition control.h:27
can_units_do_activity_client
#define can_units_do_activity_client(_punits_, _act_)
Definition control.h:44
qtg_request_transport
bool qtg_request_transport(struct unit *pcargo, struct tile *ptile)
Definition dialogs.cpp:4758
punit
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit * punit
Definition dialogs_g.h:73
get_city_bonus
int get_city_bonus(const struct city *pcity, enum effect_type effect_type)
Definition effects.c:789
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:740
extra_number
int extra_number(const struct extra_type *pextra)
Definition extras.c:153
extra_type_list_by_cause
struct extra_type_list * extra_type_list_by_cause(enum extra_cause cause)
Definition extras.c:241
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:765
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:186
extra_type_iterate
#define extra_type_iterate(_p)
Definition extras.h:291
extra_type_iterate_end
#define extra_type_iterate_end
Definition extras.h:297
extra_type_by_cause_iterate_end
#define extra_type_by_cause_iterate_end
Definition extras.h:315
extra_type_by_cause_iterate
#define extra_type_by_cause_iterate(_cause, _extra)
Definition extras.h:309
fc_client.h
NO_TARGET
#define NO_TARGET
Definition fc_types.h:324
Unit_type_id
int Unit_type_id
Definition fc_types.h:352
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:57
wld
struct world wld
Definition game.c:58
game_city_by_number
struct city * game_city_by_number(int id)
Definition game.c:102
game.h
tile_before_end_path
struct tile * tile_before_end_path(struct unit *punit, struct tile *ptile)
Definition goto.c:2012
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:998
goto.h
government_name_translation
const char * government_name_translation(const struct government *pgovern)
Definition government.c:142
untargeted_revolution_allowed
bool untargeted_revolution_allowed(void)
Definition government.c:564
government_count
Government_type_id government_count(void)
Definition government.c:70
government_by_number
struct government * government_by_number(const Government_type_id gov)
Definition government.c:102
can_change_to_government
bool can_change_to_government(struct player *pplayer, const struct government *gov)
Definition government.c:165
government.h
layout
static PangoLayout * layout
Definition canvas.c:331
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:1444
popup_disband_dialog
void popup_disband_dialog(struct unit_list *punits)
Definition dialogs.c:1482
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:257
popup_quit_dialog
void popup_quit_dialog(void)
Definition gui_main.c:2154
popup_help_dialog_typed
void popup_help_dialog_typed(const char *item, enum help_page_type htype)
Definition helpdlg.c:195
create_line_at_mouse_pos
void create_line_at_mouse_pos(void)
Definition mapctrl.c:347
update_city_descriptions
void update_city_descriptions(void)
Definition mapview.c:470
get_tile_change_menu_text
static const char * get_tile_change_menu_text(struct tile *ptile, enum unit_activity activity)
Definition menu.c:2302
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:1242
popup_spaceship_dialog
void popup_spaceship_dialog(struct player *pplayer)
Definition spaceshipdlg.c:146
delay_order
delay_order
Definition menu.h:81
D_GOTO
@ D_GOTO
Definition menu.h:82
munit
munit
Definition menu.h:39
AIRLIFT
@ AIRLIFT
Definition menu.h:69
CONNECT_RAIL
@ CONNECT_RAIL
Definition menu.h:65
TRANSFORM
@ TRANSFORM
Definition menu.h:51
FORTIFY
@ FORTIFY
Definition menu.h:55
GOTO_CITY
@ GOTO_CITY
Definition menu.h:68
TRANSPORTER
@ TRANSPORTER
Definition menu.h:44
BUILD
@ BUILD
Definition menu.h:53
IRRIGATION
@ IRRIGATION
Definition menu.h:49
CONNECT_IRRIGATION
@ CONNECT_IRRIGATION
Definition menu.h:67
CONNECT_ROAD
@ CONNECT_ROAD
Definition menu.h:64
HOMECITY
@ HOMECITY
Definition menu.h:61
CONVERT
@ CONVERT
Definition menu.h:46
PILLAGE
@ PILLAGE
Definition menu.h:52
FALLOUT
@ FALLOUT
Definition menu.h:59
BUILD_WONDER
@ BUILD_WONDER
Definition menu.h:70
DISBAND
@ DISBAND
Definition menu.h:45
DEBOARD
@ DEBOARD
Definition menu.h:43
NOT_4_OBS
@ NOT_4_OBS
Definition menu.h:75
UPGRADE
@ UPGRADE
Definition menu.h:74
SAVE
@ SAVE
Definition menu.h:78
MULTIPLIERS
@ MULTIPLIERS
Definition menu.h:76
PLANT
@ PLANT
Definition menu.h:48
ORDER_TRADE_ROUTE
@ ORDER_TRADE_ROUTE
Definition menu.h:72
POLLUTION
@ POLLUTION
Definition menu.h:58
WAKEUP
@ WAKEUP
Definition menu.h:62
MINE
@ MINE
Definition menu.h:47
SENTRY
@ SENTRY
Definition menu.h:60
ORDER_DIPLOMAT_DLG
@ ORDER_DIPLOMAT_DLG
Definition menu.h:73
EXPLORE
@ EXPLORE
Definition menu.h:41
STANDARD
@ STANDARD
Definition menu.h:40
ROAD
@ ROAD
Definition menu.h:54
CONNECT_MAGLEV
@ CONNECT_MAGLEV
Definition menu.h:66
CULTIVATE
@ CULTIVATE
Definition menu.h:50
AUTOSETTLER
@ AUTOSETTLER
Definition menu.h:63
BOARD
@ BOARD
Definition menu.h:42
FORTRESS
@ FORTRESS
Definition menu.h:56
ENDGAME
@ ENDGAME
Definition menu.h:77
AUTOTRADEROUTE
@ AUTOTRADEROUTE
Definition menu.h:71
AIRBASE
@ AIRBASE
Definition menu.h:57
chatline.h
cityrep.h
popup_revolution_dialog
void popup_revolution_dialog(void)
Definition dialogs.c:109
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_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:182
improvement_name_translation
const char * improvement_name_translation(const struct impr_type *pimprove)
Definition improvement.c:241
improvement_iterate_end
#define improvement_iterate_end
Definition improvement.h:211
improvement_iterate
#define improvement_iterate(_p)
Definition improvement.h:205
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:1345
is_tiles_adjacent
bool is_tiles_adjacent(const struct tile *tile0, const struct tile *tile1)
Definition map.c:929
terrain_control
struct terrain_misc terrain_control
Definition map.c:69
mapview
struct view mapview
Definition mapview_common.c:74
map_canvas_resized
bool map_canvas_resized(int width, int height)
Definition mapview_common.c:3593
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:3204
multiairlift
void multiairlift(struct city *acity, Unit_type_id ut)
Definition menu.cpp:3925
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
reset_menu_and_sub_menues
static void reset_menu_and_sub_menues(QMenu *menu)
Definition menu.cpp:716
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:177
client_optset
const struct option_set * client_optset
Definition options.c:1255
options_save
void options_save(option_save_log_callback log_cb)
Definition options.c:6053
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:406
REPORT_WONDERS_OF_THE_WORLD
@ REPORT_WONDERS_OF_THE_WORLD
Definition packets.h:74
REPORT_DEMOGRAPHIC
@ REPORT_DEMOGRAPHIC
Definition packets.h:76
REPORT_TOP_5_CITIES
@ REPORT_TOP_5_CITIES
Definition packets.h:75
REPORT_ACHIEVEMENTS
@ REPORT_ACHIEVEMENTS
Definition packets.h:77
popup_shortcuts_dialog
void popup_shortcuts_dialog()
Definition shortcuts.cpp:755
toggle_units_report
void toggle_units_report(bool)
Definition repodlgs.cpp:1861
players_iterate_end
#define players_iterate_end
Definition player.h:535
players_iterate
#define players_iterate(_pplayer)
Definition player.h:530
popup_endgame_report
void popup_endgame_report()
Definition repodlgs.cpp:1768
road_extra_get
struct extra_type * road_extra_get(const struct road_type *proad)
Definition road.c:42
road_by_gui_type
struct road_type * road_by_gui_type(enum road_gui_type gui_type)
Definition road.c:180
road.h
get_save_dirs
const struct strvec * get_save_dirs(void)
Definition shared.c:934
array_shuffle
void array_shuffle(int *array, int n)
Definition shared.c:1997
freeciv_storage_dir
char * freeciv_storage_dir(void)
Definition shared.c:672
DIR_SEPARATOR
#define DIR_SEPARATOR
Definition shared.h:127
shortcut_to_string
QString shortcut_to_string(fc_shortcut *sc)
Definition shortcuts.cpp:183
shortcuts.h
shortcut_id
shortcut_id
Definition shortcuts.h:33
SC_PARADROP
@ SC_PARADROP
Definition shortcuts.h:82
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_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:379
canvas::map_pixmap
QPixmap map_pixmap
Definition canvas.h:25
city
Definition city.h:309
city::name
char * name
Definition city.h:310
city::tile
struct tile * tile
Definition city.h:311
civ_game::info
struct packet_game_info info
Definition game.h:89
civ_game::client
struct civ_game::@30::@33 client
civ_game::ruleset_ready
bool ruleset_ready
Definition game.h:116
civ_game::government_during_revolution
struct government * government_during_revolution
Definition game.h:94
civ_map::xsize
int xsize
Definition map_types.h:77
civ_map::ysize
int ysize
Definition map_types.h:77
civclient::conn
struct connection conn
Definition client_main.h:96
client_options::gui_qt_fullscreen
bool gui_qt_fullscreen
Definition options.h:386
client_options::draw_native
bool draw_native
Definition options.h:207
client_options::draw_city_output
bool draw_city_output
Definition options.h:186
client_options::draw_city_names
bool draw_city_names
Definition options.h:188
client_options::draw_city_productions
bool draw_city_productions
Definition options.h:190
client_options::draw_borders
bool draw_borders
Definition options.h:206
client_options::draw_city_buycost
bool draw_city_buycost
Definition options.h:191
client_options::draw_unit_stack_size
bool draw_unit_stack_size
Definition options.h:210
client_options::draw_city_trade_routes
bool draw_city_trade_routes
Definition options.h:192
client_options::unit_selection_clears_orders
bool unit_selection_clears_orders
Definition options.h:168
client_options::save_options_on_exit
bool save_options_on_exit
Definition options.h:121
client_options::draw_map_grid
bool draw_map_grid
Definition options.h:187
client_options::draw_city_growth
bool draw_city_growth
Definition options.h:189
client_options::draw_city_outlines
bool draw_city_outlines
Definition options.h:185
client_options::draw_full_citybar
bool draw_full_citybar
Definition options.h:208
connection::playing
struct player * playing
Definition connection.h:156
connection::used
bool used
Definition connection.h:144
extra_type
Definition extras.h:85
fc_shortcut
Definition shortcuts.h:104
fc_shortcut::mouse
Qt::MouseButton mouse
Definition shortcuts.h:107
government
Definition government.h:52
item
Definition climisc.h:80
option
Definition options.c:454
packet_game_info::turn
int turn
Definition packets_gen.h:241
player::cities
struct city_list * cities
Definition player.h:281
qtiles
Definition menu.h:159
qtiles::t1
struct tile * t1
Definition menu.h:160
qtiles::t2
struct tile * t2
Definition menu.h:161
qtiles::autocaravan
struct unit * autocaravan
Definition menu.h:162
road_type
Definition road.h:75
sprite
Definition sprite.h:22
sprite::pm
QPixmap * pm
Definition sprite.h:25
strvec
Definition string_vector.c:29
terrain
Definition terrain.h:176
terrain::cultivate_result
struct terrain * cultivate_result
Definition terrain.h:203
terrain::plant_result
struct terrain * plant_result
Definition terrain.h:206
terrain::transform_result
struct terrain * transform_result
Definition terrain.h:217
tile
Definition tile.h:49
tile::units
struct unit_list * units
Definition tile.h:57
tileset
Definition tilespec.c:459
unit_type
Definition unittype.h:481
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:969
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(_start, _p)
Definition tech.h:264
A_FIRST
#define A_FIRST
Definition tech.h:44
advance_iterate_end
#define advance_iterate_end
Definition tech.h:270
T_NONE
#define T_NONE
Definition terrain.h:56
tile_virtual_destroy
void tile_virtual_destroy(struct tile *vtile)
Definition tile.c:1018
tile_apply_activity
bool tile_apply_activity(struct tile *ptile, Activity_type_id act, struct extra_type *tgt)
Definition tile.c:658
tile_virtual_new
struct tile * tile_virtual_new(const struct tile *ptile)
Definition tile.c:966
tile_get_info_text
const char * tile_get_info_text(const struct tile *ptile, bool include_nuisances, int linebreaks)
Definition tile.c:756
tile_city
struct city * tile_city(const struct tile *ptile)
Definition tile.c:83
tile_terrain
#define tile_terrain(_tile)
Definition tile.h:109
get_government_sprite
struct sprite * get_government_sprite(const struct tileset *t, const struct government *gov)
Definition tilespec.c:6508
tileset_hex_width
int tileset_hex_width(const struct tileset *t)
Definition tilespec.c:684
get_tileset_list
const struct strvec * get_tileset_list(const struct option *poption)
Definition tilespec.c:1047
tileset_is_isometric
bool tileset_is_isometric(const struct tileset *t)
Definition tilespec.c:675
tileset_basename
const char * tileset_basename(const struct tileset *t)
Definition tilespec.c:667
tileset_tile_height
int tileset_tile_height(const struct tileset *t)
Definition tilespec.c:728
tileset_tile_width
int tileset_tile_width(const struct tileset *t)
Definition tilespec.c:716
tilespec_reread
bool tilespec_reread(const char *new_tileset_name, bool game_fully_initialized, float scale)
Definition tilespec.c:1299
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:532
can_unit_change_homecity
bool can_unit_change_homecity(const struct unit *punit)
Definition unit.c:464
unit_can_est_trade_route_here
bool unit_can_est_trade_route_here(const struct unit *punit)
Definition unit.c:289
unit_can_add_or_build_city
bool unit_can_add_or_build_city(const struct unit *punit)
Definition unit.c:430
unit_contained_in
bool unit_contained_in(const struct unit *pcargo, const struct unit *ptrans)
Definition unit.c:2506
can_unit_do_autosettlers
bool can_unit_do_autosettlers(const struct unit *punit)
Definition unit.c:583
unit_can_help_build_wonder_here
bool unit_can_help_build_wonder_here(const struct unit *punit)
Definition unit.c:263
can_unit_paradrop
bool can_unit_paradrop(const struct civ_map *nmap, const struct unit *punit)
Definition unit.c:827
unit.h
unit_tile
#define unit_tile(_pu)
Definition unit.h:388
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:387
units_can_convert
bool units_can_convert(const struct civ_map *nmap, const struct unit_list *punits)
Definition unitlist.c:353
units_are_occupied
bool units_are_occupied(const struct unit_list *punits)
Definition unitlist.c:277
units_can_do_action_with_result
bool units_can_do_action_with_result(const struct unit_list *punits, enum action_result result, bool can_do)
Definition unitlist.c:262
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:184
units_contain_cityfounder
bool units_contain_cityfounder(const struct unit_list *punits)
Definition unitlist.c:221
can_units_do_any_road
bool can_units_do_any_road(const struct civ_map *nmap, const struct unit_list *punits)
Definition unitlist.c:165
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:338
units_can_unload
bool units_can_unload(const struct unit_list *punits)
Definition unitlist.c:305
units_have_activity_on_tile
bool units_have_activity_on_tile(const struct unit_list *punits, enum unit_activity activity)
Definition unitlist.c:322
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:206
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:243
units_can_load
bool units_can_load(const struct unit_list *punits)
Definition unitlist.c:291
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:2131
utype_name_translation
const char * utype_name_translation(const struct unit_type *punittype)
Definition unittype.c:1612
utype_can_do_action
bool utype_can_do_action(const struct unit_type *putype, const action_id act_id)
Definition unittype.c:443
unit_type_iterate
#define unit_type_iterate(_p)
Definition unittype.h:838
unit_type_iterate_end
#define unit_type_iterate_end
Definition unittype.h:845
enable
#define enable(id)
Definition widget.h:223