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)
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 ***********************************************************************/
15 #include <fc_config.h>
19 #include <QApplication>
20 #include <QFileDialog>
21 #include <QMainWindow>
22 #include <QMessageBox>
23 #include <QScrollArea>
24 #include <QSignalMapper>
25 #include <QStandardPaths>
26 #include <QVBoxLayout>
29 #include "string_vector.h"
33 #include "government.h"
35 #include "name_translation.h"
40 #include "connectdlg_common.h"
45 #include "fc_client.h"
51 #include "hudwidget.h"
53 #include "messagedlg.h"
57 #include "shortcuts.h"
58 #include "spaceshipdlg.h"
63 extern QApplication
*qapp
;
65 static bool tradecity_rand(const trade_city
*t1
, const trade_city
*t2
);
66 static void enable_interface(bool enable
);
67 extern int last_center_enemy
;
68 extern int last_center_capital
;
69 extern int last_center_player_city
;
70 extern int last_center_enemy_city
;
71 /**************************************************************************
73 **************************************************************************/
79 last_center_enemy
= 0;
80 last_center_capital
= 0;
81 last_center_player_city
= 0;
82 last_center_enemy_city
= 0;
85 /**************************************************************************
86 Sends new built units to target tile
87 **************************************************************************/
88 void qfc_rally_list::run()
91 struct unit_list
*units
;
92 struct unit
*last_unit
;;
95 if (rally_list
.isEmpty()) {
99 foreach (rally
, rally_list
) {
103 if (rally
->pcity
->turn_last_built
== game
.info
.turn
- 1) {
104 units
= rally
->pcity
->units_supported
;
106 unit_list_iterate(units
, punit
) {
107 if (punit
->id
> max
) {
111 } unit_list_iterate_end
;
113 if (last_unit
&& rally
->pcity
->production
.kind
== VUT_UTYPE
) {
114 send_goto_tile(last_unit
, rally
->ptile
);
120 /**************************************************************************
122 **************************************************************************/
123 void qfc_rally_list::add(qfc_rally
* rally
)
125 rally_list
.append(rally
);
128 /**************************************************************************
129 Clears rally point. Returns false if rally was not set for that city.
130 **************************************************************************/
131 bool qfc_rally_list::clear(city
* rcity
)
135 foreach (rally
, rally_list
) {
136 if (rally
->pcity
== rcity
) {
137 rally_list
.removeAll(rally
);
146 /**************************************************************************
147 Constructor for trade city used to trade calculation
148 **************************************************************************/
149 trade_city::trade_city(struct city
*pcity
)
158 /**************************************************************************
159 Constructor for trade calculator
160 **************************************************************************/
161 trade_generator::trade_generator()
166 /**************************************************************************
167 Adds all cities to trade generator
168 **************************************************************************/
169 void trade_generator::add_all_cities()
173 clear_trade_planing();
174 s
= city_list_size(client
.conn
.playing
->cities
);
178 for (i
= 0; i
< s
; i
++) {
179 pcity
= city_list_get(client
.conn
.playing
->cities
, i
);
184 /**************************************************************************
185 Clears genrated routes, virtual cities, cities
186 **************************************************************************/
187 void trade_generator::clear_trade_planing()
191 foreach(pcity
, virtual_cities
) {
192 destroy_city_virtual(pcity
);
194 virtual_cities
.clear();
195 foreach(tc
, cities
) {
200 gui()->mapview_wdg
->repaint();
204 /**************************************************************************
205 Adds single city to trade generator
206 **************************************************************************/
207 void trade_generator::add_city(struct city
*pcity
)
209 trade_city
*tc
= new trade_city(pcity
);
211 gui()->infotab
->chtwdg
->append(QString(_("Adding city %1 to trade planning"))
212 .arg(tc
->city
->name
));
215 /**************************************************************************
216 Adds/removes tile to trade generator
217 **************************************************************************/
218 void trade_generator::add_tile(struct tile
*ptile
)
223 pcity
= tile_city(ptile
);
225 foreach (tc
, cities
) {
226 if (pcity
!= nullptr) {
227 if (tc
->city
== pcity
) {
232 if (tc
->city
->tile
== ptile
) {
233 remove_virtual_city(ptile
);
238 if (pcity
!= nullptr) {
243 pcity
= create_city_virtual(client_player(), ptile
, "Virtual");
245 virtual_cities
.append(pcity
);
248 /**************************************************************************
249 Removes single city from trade generator
250 **************************************************************************/
251 void trade_generator::remove_city(struct city
* pcity
)
255 foreach (tc
, cities
) {
256 if (tc
->city
->tile
== pcity
->tile
) {
257 cities
.removeAll(tc
);
258 gui()->infotab
->chtwdg
->append(
259 QString(_("Removing city %1 from trade planning"))
260 .arg(tc
->city
->name
));
266 /**************************************************************************
267 Removes virtual city from trade generator
268 **************************************************************************/
269 void trade_generator::remove_virtual_city(tile
*ptile
)
274 foreach (c
, virtual_cities
) {
275 if (c
->tile
== ptile
) {
276 virtual_cities
.removeAll(c
);
277 gui()->infotab
->chtwdg
->append(
278 QString(_("Removing city %1 from trade planning")).arg(c
->name
));
282 foreach (tc
, cities
) {
283 if (tc
->city
->tile
== ptile
) {
284 cities
.removeAll(tc
);
291 /**************************************************************************
292 Finds trade routes to establish
293 **************************************************************************/
294 void trade_generator::calculate()
301 for (i
= 0; i
< 100; i
++) {
303 qSort(cities
.begin(), cities
.end(), tradecity_rand
);
305 foreach (tc
, cities
) {
306 tc
->pos_cities
.clear();
307 tc
->new_tr_cities
.clear();
308 tc
->curr_tr_cities
.clear();
310 foreach (tc
, cities
) {
311 tc
->trade_num
= city_num_trade_routes(tc
->city
);
312 tc
->poss_trade_num
= 0;
313 tc
->pos_cities
.clear();
314 tc
->new_tr_cities
.clear();
315 tc
->curr_tr_cities
.clear();
317 foreach (ttc
, cities
) {
318 if (have_cities_trade_route(tc
->city
, ttc
->city
) == false
319 && can_establish_trade_route(tc
->city
, ttc
->city
)) {
320 tc
->poss_trade_num
++;
321 tc
->pos_cities
.append(ttc
->city
);
323 tc
->over_max
= tc
->trade_num
+ tc
->poss_trade_num
324 - max_trade_routes(tc
->city
);
328 find_certain_routes();
330 find_certain_routes();
332 foreach (tc
, cities
) {
341 foreach (tc
, cities
) {
344 fc_snprintf(text
, sizeof(text
),
345 PL_("City %s - 1 free trade route.",
346 "City %s - %d free trade routes.",
347 max_trade_routes(tc
->city
) - tc
->trade_num
),
349 max_trade_routes(tc
->city
) - tc
->trade_num
);
350 output_window_append(ftc_client
, text
);
354 gui()->mapview_wdg
->repaint();
357 /**************************************************************************
358 Finds highest number of trade routes over maximum for all cities,
360 **************************************************************************/
361 int trade_generator::find_over_max(struct city
*pcity
= nullptr)
366 foreach (tc
, cities
) {
367 if (pcity
!= tc
->city
) {
368 max
= qMax(max
, tc
->over_max
);
374 /**************************************************************************
375 Finds city with highest trade routes possible
376 **************************************************************************/
377 trade_city
* trade_generator::find_most_free()
380 trade_city
*rc
= nullptr;
383 foreach (tc
, cities
) {
384 if (max
< tc
->over_max
) {
392 /**************************************************************************
393 Drops all possible trade routes.
394 **************************************************************************/
395 void trade_generator::discard()
400 for (int i
= j
; i
> -j
; i
--) {
401 while ((tc
= find_most_free())) {
402 if (discard_one(tc
) == false) {
403 if (discard_any(tc
, i
) == false) {
411 /**************************************************************************
412 Drops trade routes between given cities
413 **************************************************************************/
414 void trade_generator::discard_trade(trade_city
* tc
, trade_city
* ttc
)
416 tc
->pos_cities
.removeOne(ttc
->city
);
417 ttc
->pos_cities
.removeOne(tc
->city
);
418 tc
->poss_trade_num
--;
419 ttc
->poss_trade_num
--;
422 check_if_done(tc
, ttc
);
425 /**************************************************************************
426 Drops one trade route for given city if possible
427 **************************************************************************/
428 bool trade_generator::discard_one(trade_city
*tc
)
431 int current_candidate
= 0;
435 for (int i
= cities
.size() - 1 ; i
>= 0; i
--) {
437 current_candidate
= ttc
->over_max
;
438 if (current_candidate
> best
) {
446 ttc
= cities
.at(best_id
);
447 discard_trade(tc
, ttc
);
452 /**************************************************************************
453 Drops all trade routes for given city
454 **************************************************************************/
455 bool trade_generator::discard_any(trade_city
* tc
, int freeroutes
)
459 for (int i
= cities
.size() - 1 ; i
>= 0; i
--) {
461 if (tc
->pos_cities
.contains(ttc
->city
)
462 && ttc
->pos_cities
.contains(tc
->city
)
463 && ttc
->over_max
> freeroutes
) {
464 discard_trade(tc
, ttc
);
471 /**************************************************************************
472 Helper function ato randomize list
473 **************************************************************************/
474 bool tradecity_rand(const trade_city
*t1
, const trade_city
*t2
)
476 return (qrand() % 2);
479 /**************************************************************************
480 Adds routes for cities which can only have maximum possible trade routes
481 **************************************************************************/
482 void trade_generator::find_certain_routes()
487 foreach (tc
, cities
) {
488 if (tc
->done
|| tc
->over_max
> 0) {
491 foreach (ttc
, cities
) {
492 if (ttc
->done
|| ttc
->over_max
> 0
493 || tc
== ttc
|| tc
->done
|| tc
->over_max
> 0) {
496 if (tc
->pos_cities
.contains(ttc
->city
)
497 && ttc
->pos_cities
.contains(tc
->city
)) {
498 struct qtiles gilles
;
499 tc
->pos_cities
.removeOne(ttc
->city
);
500 ttc
->pos_cities
.removeOne(tc
->city
);
501 tc
->poss_trade_num
--;
502 ttc
->poss_trade_num
--;
503 tc
->new_tr_cities
.append(ttc
->city
);
504 ttc
->new_tr_cities
.append(ttc
->city
);
509 check_if_done(tc
, ttc
);
510 gilles
.t1
= tc
->city
->tile
;
511 gilles
.t2
= ttc
->city
->tile
;
512 gilles
.autocaravan
= nullptr;
513 lines
.append(gilles
);
519 /**************************************************************************
520 Marks cities with full trade routes to finish searching
521 **************************************************************************/
522 void trade_generator::check_if_done(trade_city
* tc1
, trade_city
* tc2
)
524 if (tc1
->trade_num
== max_trade_routes(tc1
->city
)) {
527 if (tc2
->trade_num
== max_trade_routes(tc2
->city
)) {
532 /**************************************************************************
533 Constructor for units used in delayed orders
534 **************************************************************************/
535 qfc_units_list::qfc_units_list()
539 /**************************************************************************
540 Adds givent unit to list
541 **************************************************************************/
542 void qfc_units_list::add(qfc_delayed_unit_item
* fui
)
544 unit_list
.append(fui
);
547 /**************************************************************************
549 **************************************************************************/
550 void qfc_units_list::clear()
555 /**************************************************************************
556 Initialize menus (sensitivity, name, etc.) based on the
557 current state and current ruleset, etc. Call menus_update().
558 **************************************************************************/
559 void real_menus_init(void)
561 gui()->menu_bar
->clear();
562 gui()->menu_bar
->setup_menus();
564 gov_menu::create_all();
566 /* A new ruleset may have been loaded. */
567 go_act_menu::reset_all();
570 /**************************************************************************
571 Update all of the menus (sensitivity, name, etc.) based on the
573 **************************************************************************/
574 void real_menus_update(void)
576 if (C_S_RUNNING
<= client_state()) {
577 gui()->menuBar()->setVisible(true);
578 if (is_waiting_turn_change() == false) {
579 gui()->menu_bar
->menus_sensitive();
580 gui()->menu_bar
->update_airlift_menu();
581 gov_menu::update_all();
582 go_act_menu::update_all();
583 gui()->unitinfo_wdg
->update_actions(nullptr);
586 gui()->menuBar()->setVisible(false);
590 /****************************************************************************
591 Return the text for the tile, changed by the activity.
592 Should only be called for irrigation, mining, or transformation, and
593 only when the activity changes the base terrain type.
594 ****************************************************************************/
595 static const char *get_tile_change_menu_text(struct tile
*ptile
,
596 enum unit_activity activity
)
598 struct tile
*newtile
= tile_virtual_new(ptile
);
601 tile_apply_activity(newtile
, activity
, NULL
);
602 text
= tile_get_info_text(newtile
, FALSE
, 0);
603 tile_virtual_destroy(newtile
);
608 /****************************************************************************
609 Creates a new government menu.
610 ****************************************************************************/
611 gov_menu::gov_menu(QWidget
* parent
) :
612 QMenu(_("Government"), parent
),
613 gov_mapper(new QSignalMapper())
615 // Register ourselves to get updates for free.
617 setAttribute(Qt::WA_TranslucentBackground
);
620 /****************************************************************************
622 ****************************************************************************/
623 gov_menu::~gov_menu()
627 instances
.remove(this);
630 /****************************************************************************
631 Creates the menu once the government list is known.
632 ****************************************************************************/
633 void gov_menu::create() {
635 struct government
*gov
, *revol_gov
;
639 foreach(action
, QWidget::actions()) {
640 removeAction(action
);
641 action
->deleteLater();
644 gov_mapper
->deleteLater();
645 gov_mapper
= new QSignalMapper();
647 gov_count
= government_count();
648 actions
.reserve(gov_count
+ 1);
649 action
= addAction(_("Revolution..."));
650 connect(action
, &QAction::triggered
, this, &gov_menu::revolution
);
651 actions
.append(action
);
655 // Add an action for each government. There is no icon yet.
656 revol_gov
= game
.government_during_revolution
;
657 for (i
= 0; i
< gov_count
; ++i
) {
658 gov
= government_by_number(i
);
659 if (gov
!= revol_gov
) { // Skip revolution goverment
660 action
= addAction(government_name_translation(gov
));
661 // We need to keep track of the gov <-> action mapping to be able to
662 // set enabled/disabled depending on available govs.
663 actions
.append(action
);
664 connect(action
, SIGNAL(triggered()), gov_mapper
, SLOT(map()));
665 gov_mapper
->setMapping(action
, i
);
668 connect(gov_mapper
, SIGNAL(mapped(int)), this, SLOT(change_gov(int)));
671 /****************************************************************************
672 Updates the menu to take gov availability into account.
673 ****************************************************************************/
674 void gov_menu::update()
676 struct government
*gov
, *revol_gov
;
677 struct sprite
*sprite
;
680 gov_count
= government_count();
681 revol_gov
= game
.government_during_revolution
;
682 for (i
= 0, j
= 0; i
< gov_count
; ++i
) {
683 gov
= government_by_number(i
);
684 if (gov
!= revol_gov
) { // Skip revolution goverment
685 sprite
= get_government_sprite(tileset
, gov
);
686 if (sprite
!= NULL
) {
687 actions
[j
+ 1]->setIcon(QIcon(*(sprite
->pm
)));
689 actions
[j
+ 1]->setEnabled(
690 can_change_to_government(client
.conn
.playing
, gov
));
693 actions
[0]->setEnabled(!client_is_observer());
698 /****************************************************************************
699 Shows the dialog asking for confirmation before starting a revolution.
700 ****************************************************************************/
701 void gov_menu::revolution()
703 popup_revolution_dialog();
706 /****************************************************************************
707 Shows the dialog asking for confirmation before starting a revolution.
708 ****************************************************************************/
709 void gov_menu::change_gov(int target_gov
)
711 popup_revolution_dialog(government_by_number(target_gov
));
714 /****************************************************************************
715 Keeps track of all gov_menu instances.
716 ****************************************************************************/
717 QSet
<gov_menu
*> gov_menu::instances
= QSet
<gov_menu
*>();
719 /****************************************************************************
720 * Updates all gov_menu instances.
721 ****************************************************************************/
722 void gov_menu::create_all()
724 foreach (gov_menu
*m
, instances
) {
729 /****************************************************************************
730 Updates all gov_menu instances.
731 ****************************************************************************/
732 void gov_menu::update_all()
734 foreach (gov_menu
*m
, instances
) {
739 /**************************************************************************
740 Instantiate a new goto and act sub menu.
741 **************************************************************************/
742 go_act_menu::go_act_menu(QWidget
* parent
)
743 : QMenu(_("Go to and..."), parent
)
745 go_act_mapper
= new QSignalMapper(this);
747 /* Will need auto updates etc. */
751 /**************************************************************************
753 **************************************************************************/
754 go_act_menu::~go_act_menu()
756 /* Updates are no longer needed. */
757 instances
.remove(this);
760 /**************************************************************************
761 Reset the goto and act menu so it will be recreated.
762 **************************************************************************/
763 void go_act_menu::reset()
767 /* Clear out each existing menu item. */
768 foreach(action
, QWidget::actions()) {
769 removeAction(action
);
770 action
->deleteLater();
773 /* Clear menu item to action ID mapping. */
776 /* Reset the Qt signal mapper */
777 go_act_mapper
->deleteLater();
778 go_act_mapper
= new QSignalMapper(this);
781 /**************************************************************************
782 Fill the new goto and act sub menu with menu items.
783 **************************************************************************/
784 void go_act_menu::create()
789 /* Group goto and perform action menu items by target kind. */
790 for (tgt_kind_group
= 0; tgt_kind_group
< ATK_COUNT
; tgt_kind_group
++) {
791 action_iterate(action_id
) {
792 if (action_id_get_actor_kind(action_id
) != AAK_UNIT
) {
793 /* This action isn't performed by a unit. */
797 if (action_id_get_target_kind(action_id
) != tgt_kind_group
) {
802 if (action_requires_details(action_id
)) {
803 /* This menu doesn't support specifying a detailed target (think
804 * "Go to and..."->"Industrial Sabotage"->"City Walls") for the
809 if (action_id_distance_inside_max(action_id
, 2)) {
810 /* The order system doesn't support actions that can be done to a
811 * target that isn't at or next to the actor unit's tile.
813 * Full explanation in handle_unit_orders(). */
817 /* Create and add the menu item. It will be hidden or shown based on
819 item
= addAction(action_id_name_translation(action_id
));
820 items
.insert(item
, action_id
);
821 connect(item
, SIGNAL(triggered()),
822 go_act_mapper
, SLOT(map()));
823 go_act_mapper
->setMapping(item
, action_id
);
824 } action_iterate_end
;
827 connect(go_act_mapper
, SIGNAL(mapped(int)), this, SLOT(start_go_act(int)));
830 /**************************************************************************
831 Update the goto and act menu based on the selected unit(s)
832 **************************************************************************/
833 void go_act_menu::update()
835 bool can_do_something
= false;
837 if (!actions_are_ready()) {
842 if (items
.isEmpty()) {
843 /* The goto and act menu needs menu items. */
847 /* Enable a menu item if it is theoretically possible that one of the
848 * selected units can perform it. Checking if the action can be performed
849 * at the current tile is pointless since it should be performed at the
851 foreach(QAction
*item
, items
.keys()) {
852 if (units_can_do_action(get_units_in_focus(),
853 items
.value(item
), TRUE
)) {
854 item
->setVisible(true);
855 can_do_something
= true;
857 item
->setVisible(false);
861 if (can_do_something
) {
862 /* At least one menu item is enabled for one of the selected units. */
865 /* No menu item is enabled any of the selected units. */
870 /**************************************************************************
871 Activate the goto system
872 **************************************************************************/
873 void go_act_menu::start_go_act(int action_id
)
875 /* This menu doesn't support specifying a detailed target (think
876 * "Go to and..."->"Industrial Sabotage"->"City Walls") for the
878 fc_assert_ret_msg(!action_requires_details(action_id
),
879 "Underspecified target for %s.",
880 action_id_name_translation(action_id
));
882 request_unit_goto(ORDER_PERFORM_ACTION
, action_id
, EXTRA_NONE
);
885 /**************************************************************************
886 Store all goto and act menu items so they can be updated etc
887 **************************************************************************/
888 QSet
<go_act_menu
*> go_act_menu::instances
;
890 /**************************************************************************
891 Reset all goto and act menu instances.
892 **************************************************************************/
893 void go_act_menu::reset_all()
895 foreach (go_act_menu
*m
, instances
) {
900 /**************************************************************************
901 Update all goto and act menu instances
902 **************************************************************************/
903 void go_act_menu::update_all()
905 foreach (go_act_menu
*m
, instances
) {
911 /****************************************************************************
912 Predicts last unit position
913 ****************************************************************************/
914 struct tile
*mr_menu::find_last_unit_pos(unit
*punit
, int pos
)
916 qfc_delayed_unit_item
*fui
;
917 struct tile
*ptile
= nullptr;
923 foreach (fui
, units_list
.unit_list
) {
924 zunit
= unit_list_find(client_player()->units
, fui
->id
);
930 if (zunit
== nullptr) {
934 if (punit
== zunit
) { /* Unit found */
935 /* Unit was ordered to attack city so it might stay in
936 front of that city */
937 if (is_non_allied_city_tile(fui
->ptile
, unit_owner(punit
))) {
938 ptile
= tile_before_end_path(punit
, fui
->ptile
);
939 if (ptile
== nullptr) {
945 /* unit found in tranporter */
946 } else if (unit_contained_in(punit
, zunit
)) {
953 /****************************************************************************
954 Constructor for global menubar in gameview
955 ****************************************************************************/
956 mr_menu::mr_menu() : QMenuBar()
960 /****************************************************************************
961 Initializes menu system, and add custom enum(munit) for most of options
962 Notice that if you set option for QAction->setChecked(option) it will
963 check/uncheck automatically without any intervention
964 ****************************************************************************/
965 void mr_menu::setup_menus()
972 delayed_order
= false;
974 quick_airlifting
= false;
977 menu
= this->addMenu(_("Game"));
979 menu
= menu
->addMenu(_("Options"));
980 act
= menu
->addAction(_("Set local options"));
981 connect(act
, SIGNAL(triggered()), this, SLOT(local_options()));
982 act
= menu
->addAction(_("Server Options"));
983 connect(act
, SIGNAL(triggered()), this, SLOT(server_options()));
984 act
= menu
->addAction(_("Messages"));
985 connect(act
, SIGNAL(triggered()), this, SLOT(messages_options()));
986 act
= menu
->addAction(_("Shortcuts"));
987 connect(act
, SIGNAL(triggered()), this, SLOT(shortcut_options()));
988 act
= menu
->addAction(_("Load another tileset"));
989 connect(act
, SIGNAL(triggered()), this, SLOT(tileset_custom_load()));
990 act
= menu
->addAction(_("Save Options Now"));
991 act
->setIcon(style()->standardIcon(QStyle::SP_DialogSaveButton
));
992 connect(act
, SIGNAL(triggered()), this, SLOT(save_options_now()));
993 act
= menu
->addAction(_("Save Options on Exit"));
994 act
->setCheckable(true);
995 act
->setChecked(gui_options
.save_options_on_exit
);
997 menu
->addSeparator();
998 act
= menu
->addAction(_("Save Game"));
999 act
->setShortcut(QKeySequence(tr("Ctrl+s")));
1000 act
->setIcon(style()->standardIcon(QStyle::SP_DialogSaveButton
));
1001 menu_list
.insertMulti(SAVE
, act
);
1002 connect(act
, SIGNAL(triggered()), this, SLOT(save_game()));
1003 act
= menu
->addAction(_("Save Game As..."));
1004 menu_list
.insertMulti(SAVE
, act
);
1005 act
->setIcon(style()->standardIcon(QStyle::SP_DialogSaveButton
));
1006 connect(act
, SIGNAL(triggered()), this, SLOT(save_game_as()));
1007 act
= menu
->addAction(_("Save Map to Image"));
1008 connect(act
, SIGNAL(triggered()), this, SLOT(save_image()));
1009 menu
->addSeparator();
1010 act
= menu
->addAction(_("Leave game"));
1011 act
->setIcon(style()->standardIcon(QStyle::SP_DialogDiscardButton
));
1012 connect(act
, SIGNAL(triggered()), this, SLOT(back_to_menu()));
1013 act
= menu
->addAction(_("Quit"));
1014 act
->setIcon(style()->standardIcon(QStyle::SP_TitleBarCloseButton
));
1015 connect(act
, SIGNAL(triggered()), this, SLOT(quit_game()));
1018 menu
= this->addMenu(Q_("?verb:View"));
1019 act
= menu
->addAction(_("Center View"));
1020 act
->setShortcut(QKeySequence(shortcut_to_string(
1021 fc_shortcuts::sc()->get_shortcut(SC_CENTER_VIEW
))));
1022 connect(act
, SIGNAL(triggered()), this, SLOT(slot_center_view()));
1023 menu
->addSeparator();
1024 act
= menu
->addAction(_("Fullscreen"));
1025 act
->setShortcut(QKeySequence(shortcut_to_string(
1026 fc_shortcuts::sc()->get_shortcut(SC_FULLSCREEN
))));
1027 act
->setCheckable(true);
1028 act
->setChecked(gui_options
.gui_qt_fullscreen
);
1029 connect(act
, SIGNAL(triggered()), this, SLOT(slot_fullscreen()));
1030 menu
->addSeparator();
1031 minimap_status
= menu
->addAction(_("Minimap"));
1032 minimap_status
->setCheckable(true);
1033 minimap_status
->setShortcut(QKeySequence(shortcut_to_string(
1034 fc_shortcuts::sc()->get_shortcut(SC_MINIMAP
))));
1035 minimap_status
->setChecked(true);
1036 connect(minimap_status
, SIGNAL(triggered()), this,
1037 SLOT(slot_minimap_view()));
1038 osd_status
= menu
->addAction(_("Show new turn information"));
1039 osd_status
->setCheckable(true);
1040 osd_status
->setChecked(gui()->qt_settings
.show_new_turn_text
);
1041 connect(osd_status
, SIGNAL(triggered()), this,
1042 SLOT(slot_show_new_turn_text()));
1043 btlog_status
= menu
->addAction(_("Show combat detailed information"));
1044 btlog_status
->setCheckable(true);
1045 btlog_status
->setChecked(gui()->qt_settings
.show_battle_log
);
1046 connect(btlog_status
, SIGNAL(triggered()), this, SLOT(slot_battlelog()));
1047 lock_status
= menu
->addAction(_("Lock interface"));
1048 lock_status
->setCheckable(true);
1049 lock_status
->setShortcut(QKeySequence(shortcut_to_string(
1050 fc_shortcuts::sc()->get_shortcut(SC_IFACE_LOCK
))));
1051 lock_status
->setChecked(false);
1052 connect(lock_status
, SIGNAL(triggered()), this, SLOT(slot_lock()));
1053 connect(minimap_status
, SIGNAL(triggered()), this, SLOT(slot_lock()));
1054 menu
->addSeparator();
1055 act
= menu
->addAction(_("Zoom in"));
1056 act
->setShortcut(QKeySequence(shortcut_to_string(
1057 fc_shortcuts::sc()->get_shortcut(SC_ZOOM_IN
))));
1058 connect(act
, SIGNAL(triggered()), this, SLOT(zoom_in()));
1059 act
= menu
->addAction(_("Zoom out"));
1060 act
->setShortcut(QKeySequence(shortcut_to_string(
1061 fc_shortcuts::sc()->get_shortcut(SC_ZOOM_OUT
))));
1062 connect(act
, SIGNAL(triggered()), this, SLOT(zoom_out()));
1063 menu
->addSeparator();
1064 act
= menu
->addAction(_("City Outlines"));
1065 act
->setCheckable(true);
1066 act
->setChecked(gui_options
.draw_city_outlines
);
1067 connect(act
, SIGNAL(triggered()), this, SLOT(slot_city_outlines()));
1068 act
= menu
->addAction(_("City Output"));
1069 act
->setCheckable(true);
1070 act
->setChecked(gui_options
.draw_city_output
);
1071 act
->setShortcut(QKeySequence(shortcut_to_string(
1072 fc_shortcuts::sc()->get_shortcut(SC_CITY_OUTPUT
))));
1073 connect(act
, SIGNAL(triggered()), this, SLOT(slot_city_output()));
1074 act
= menu
->addAction(_("Map Grid"));
1075 act
->setShortcut(QKeySequence(shortcut_to_string(
1076 fc_shortcuts::sc()->get_shortcut(SC_MAP_GRID
))));
1077 act
->setCheckable(true);
1078 act
->setChecked(gui_options
.draw_map_grid
);
1079 connect(act
, SIGNAL(triggered()), this, SLOT(slot_map_grid()));
1080 act
= menu
->addAction(_("National Borders"));
1081 act
->setCheckable(true);
1082 act
->setChecked(gui_options
.draw_borders
);
1083 act
->setShortcut(QKeySequence(shortcut_to_string(
1084 fc_shortcuts::sc()->get_shortcut(SC_NAT_BORDERS
))));
1085 connect(act
, SIGNAL(triggered()), this, SLOT(slot_borders()));
1086 act
= menu
->addAction(_("Native Tiles"));
1087 act
->setCheckable(true);
1088 act
->setChecked(gui_options
.draw_native
);
1089 act
->setShortcut(QKeySequence(tr("ctrl+shift+n")));
1090 connect(act
, SIGNAL(triggered()), this, SLOT(slot_native_tiles()));
1091 act
= menu
->addAction(_("City Full Bar"));
1092 act
->setCheckable(true);
1093 act
->setShortcut(QKeySequence(shortcut_to_string(
1094 fc_shortcuts::sc()->get_shortcut(SC_SHOW_FULLBAR
))));
1095 act
->setChecked(gui_options
.draw_full_citybar
);
1096 connect(act
, SIGNAL(triggered()), this, SLOT(slot_fullbar()));
1097 act
= menu
->addAction(_("City Names"));
1098 act
->setCheckable(true);
1099 act
->setChecked(gui_options
.draw_city_names
);
1100 act
->setShortcut(QKeySequence(shortcut_to_string(
1101 fc_shortcuts::sc()->get_shortcut(SC_CITY_NAMES
))));
1102 connect(act
, SIGNAL(triggered()), this, SLOT(slot_city_names()));
1103 act
= menu
->addAction(_("City Growth"));
1104 act
->setCheckable(true);
1105 act
->setChecked(gui_options
.draw_city_growth
);
1106 act
->setShortcut(QKeySequence(tr("ctrl+r")));
1107 connect(act
, SIGNAL(triggered()), this, SLOT(slot_city_growth()));
1108 act
= menu
->addAction(_("City Production Levels"));
1109 act
->setCheckable(true);
1110 act
->setChecked(gui_options
.draw_city_productions
);
1111 act
->setShortcut(QKeySequence(shortcut_to_string(
1112 fc_shortcuts::sc()->get_shortcut(SC_CITY_PROD
))));
1113 connect(act
, SIGNAL(triggered()), this, SLOT(slot_city_production()));
1114 act
= menu
->addAction(_("City Buy Cost"));
1115 act
->setCheckable(true);
1116 act
->setChecked(gui_options
.draw_city_buycost
);
1117 connect(act
, SIGNAL(triggered()), this, SLOT(slot_city_buycost()));
1118 act
= menu
->addAction(_("City Traderoutes"));
1119 act
->setCheckable(true);
1120 act
->setChecked(gui_options
.draw_city_trade_routes
);
1121 act
->setShortcut(QKeySequence(shortcut_to_string(
1122 fc_shortcuts::sc()->get_shortcut(SC_TRADE_ROUTES
))));
1123 connect(act
, SIGNAL(triggered()), this, SLOT(slot_city_traderoutes()));
1126 menu
= this->addMenu(_("Select"));
1127 act
= menu
->addAction(_("Single Unit (Unselect Others)"));
1128 act
->setShortcut(QKeySequence(tr("shift+z")));
1129 menu_list
.insertMulti(STANDARD
, act
);
1130 connect(act
, SIGNAL(triggered()), this, SLOT(slot_select_one()));
1131 act
= menu
->addAction(_("All On Tile"));
1132 act
->setShortcut(QKeySequence(tr("v")));
1133 menu_list
.insertMulti(STANDARD
, act
);
1134 connect(act
, SIGNAL(triggered()), this, SLOT(slot_select_all_tile()));
1135 menu
->addSeparator();
1136 act
= menu
->addAction(_("Same Type on Tile"));
1137 act
->setShortcut(QKeySequence(tr("shift+v")));
1138 menu_list
.insertMulti(STANDARD
, act
);
1139 connect(act
, SIGNAL(triggered()), this, SLOT(slot_select_same_tile()));
1140 act
= menu
->addAction(_("Same Type on Continent"));
1141 act
->setShortcut(QKeySequence(tr("shift+c")));
1142 menu_list
.insertMulti(STANDARD
, act
);
1143 connect(act
, SIGNAL(triggered()), this,
1144 SLOT(slot_select_same_continent()));
1145 act
= menu
->addAction(_("Same Type Everywhere"));
1146 act
->setShortcut(QKeySequence(tr("shift+x")));
1147 menu_list
.insertMulti(STANDARD
, act
);
1148 connect(act
, SIGNAL(triggered()), this,
1149 SLOT(slot_select_same_everywhere()));
1150 menu
->addSeparator();
1151 act
= menu
->addAction(_("Wait"));
1152 act
->setShortcut(QKeySequence(shortcut_to_string(
1153 fc_shortcuts::sc()->get_shortcut(SC_WAIT
))));
1154 menu_list
.insertMulti(STANDARD
, act
);
1155 connect(act
, SIGNAL(triggered()), this, SLOT(slot_wait()));
1156 act
= menu
->addAction(_("Done"));
1157 act
->setShortcut(QKeySequence(shortcut_to_string(
1158 fc_shortcuts::sc()->get_shortcut(SC_DONE_MOVING
))));
1159 menu_list
.insertMulti(STANDARD
, act
);
1160 connect(act
, SIGNAL(triggered()), this, SLOT(slot_done_moving()));
1162 act
= menu
->addAction(_("Advanced unit selection"));
1163 act
->setShortcut(QKeySequence(tr("ctrl+e")));
1164 menu_list
.insertMulti(NOT_4_OBS
, act
);
1165 connect(act
, SIGNAL(triggered()), this, SLOT(slot_unit_filter()));
1169 menu
= this->addMenu(_("Unit"));
1170 act
= menu
->addAction(_("Go to Tile"));
1171 act
->setShortcut(QKeySequence(shortcut_to_string(
1172 fc_shortcuts::sc()->get_shortcut(SC_GOTO
))));
1173 menu_list
.insertMulti(STANDARD
, act
);
1174 connect(act
, SIGNAL(triggered()), this, SLOT(slot_unit_goto()));
1176 /* The goto and act sub menu is handled as a separate object. */
1177 menu
->addMenu(new go_act_menu());
1179 act
= menu
->addAction(_("Go to Nearest City"));
1180 act
->setShortcut(QKeySequence(tr("shift+g")));
1181 menu_list
.insertMulti(GOTO_CITY
, act
);
1182 connect(act
, SIGNAL(triggered()), this, SLOT(slot_return_to_city()));
1183 act
= menu
->addAction(_("Go to/Airlift to City..."));
1184 act
->setShortcut(QKeySequence(shortcut_to_string(
1185 fc_shortcuts::sc()->get_shortcut(SC_GOTOAIRLIFT
))));
1186 menu_list
.insertMulti(AIRLIFT
, act
);
1187 connect(act
, SIGNAL(triggered()), this, SLOT(slot_airlift()));
1188 menu
->addSeparator();
1189 act
= menu
->addAction(_("Auto Explore"));
1190 menu_list
.insertMulti(EXPLORE
, act
);
1191 act
->setShortcut(QKeySequence(shortcut_to_string(
1192 fc_shortcuts::sc()->get_shortcut(SC_AUTOEXPLORE
))));
1193 connect(act
, SIGNAL(triggered()), this, SLOT(slot_unit_explore()));
1194 act
= menu
->addAction(_("Patrol"));
1195 menu_list
.insertMulti(STANDARD
, act
);
1196 act
->setEnabled(false);
1197 act
->setShortcut(QKeySequence(shortcut_to_string(
1198 fc_shortcuts::sc()->get_shortcut(SC_PATROL
))));
1199 connect(act
, SIGNAL(triggered()), this, SLOT(slot_patrol()));
1200 menu
->addSeparator();
1201 act
= menu
->addAction(_("Sentry"));
1202 act
->setShortcut(QKeySequence(shortcut_to_string(
1203 fc_shortcuts::sc()->get_shortcut(SC_SENTRY
))));
1204 menu_list
.insertMulti(SENTRY
, act
);
1205 connect(act
, SIGNAL(triggered()), this, SLOT(slot_unit_sentry()));
1206 act
= menu
->addAction(_("Unsentry All On Tile"));
1207 act
->setShortcut(QKeySequence(shortcut_to_string(
1208 fc_shortcuts::sc()->get_shortcut(SC_UNSENTRY_TILE
))));
1209 menu_list
.insertMulti(WAKEUP
, act
);
1210 connect(act
, SIGNAL(triggered()), this, SLOT(slot_unsentry()));
1211 menu
->addSeparator();
1212 act
= menu
->addAction(_("Load"));
1213 act
->setShortcut(QKeySequence(shortcut_to_string(
1214 fc_shortcuts::sc()->get_shortcut(SC_LOAD
))));
1215 menu_list
.insertMulti(LOAD
, act
);
1216 connect(act
, SIGNAL(triggered()), this, SLOT(slot_load()));
1217 act
= menu
->addAction(_("Unload"));
1218 act
->setShortcut(QKeySequence(shortcut_to_string(
1219 fc_shortcuts::sc()->get_shortcut(SC_UNLOAD
))));
1220 menu_list
.insertMulti(UNLOAD
, act
);
1221 connect(act
, SIGNAL(triggered()), this, SLOT(slot_unload()));
1222 act
= menu
->addAction(_("Unload All From Transporter"));
1223 act
->setShortcut(QKeySequence(tr("shift+u")));
1224 menu_list
.insertMulti(TRANSPORTER
, act
);
1225 connect(act
, SIGNAL(triggered()), this, SLOT(slot_unload_all()));
1226 menu
->addSeparator();
1227 act
= menu
->addAction(action_id_name_translation(ACTION_HOME_CITY
));
1228 menu_list
.insertMulti(HOMECITY
, act
);
1229 act
->setShortcut(QKeySequence(shortcut_to_string(
1230 fc_shortcuts::sc()->get_shortcut(SC_SETHOME
))));
1231 connect(act
, SIGNAL(triggered()), this, SLOT(slot_set_home()));
1232 act
= menu
->addAction(_("Upgrade"));
1233 act
->setShortcut(QKeySequence(shortcut_to_string(
1234 fc_shortcuts::sc()->get_shortcut(SC_UPGRADE_UNIT
))));
1235 menu_list
.insertMulti(UPGRADE
, act
);
1236 connect(act
, SIGNAL(triggered()), this, SLOT(slot_upgrade()));
1237 act
= menu
->addAction(_("Convert"));
1238 act
->setShortcut(QKeySequence(tr("ctrl+o")));
1239 menu_list
.insertMulti(CONVERT
, act
);
1240 connect(act
, SIGNAL(triggered()), this, SLOT(slot_convert()));
1241 act
= menu
->addAction(_("Disband"));
1242 act
->setShortcut(QKeySequence(tr("shift+d")));
1243 menu_list
.insertMulti(DISBAND
, act
);
1244 connect(act
, SIGNAL(triggered()), this, SLOT(slot_disband()));
1247 menu
= this->addMenu(_("Combat"));
1248 act
= menu
->addAction(_("Fortify Unit"));
1249 menu_list
.insertMulti(FORTIFY
, act
);
1250 act
->setShortcut(QKeySequence(shortcut_to_string(
1251 fc_shortcuts::sc()->get_shortcut(SC_FORTIFY
))));
1252 connect(act
, SIGNAL(triggered()), this, SLOT(slot_unit_fortify()));
1253 act
= menu
->addAction(Q_(terrain_control
.gui_type_base0
));
1254 menu_list
.insertMulti(FORTRESS
, act
);
1255 act
->setShortcut(QKeySequence(tr("shift+f")));
1256 connect(act
, SIGNAL(triggered()), this, SLOT(slot_unit_fortress()));
1257 act
= menu
->addAction(Q_(terrain_control
.gui_type_base1
));
1258 menu_list
.insertMulti(AIRBASE
, act
);
1259 act
->setShortcut(QKeySequence(tr("shift+e")));
1260 connect(act
, SIGNAL(triggered()), this, SLOT(slot_unit_airbase()));
1261 menu
->addSeparator();
1262 act
= menu
->addAction(_("Pillage"));
1263 menu_list
.insertMulti(PILLAGE
, act
);
1264 act
->setShortcut(QKeySequence(tr("shift+p")));
1265 connect(act
, SIGNAL(triggered()), this, SLOT(slot_pillage()));
1266 /* TRANS: Menu item to bring up the action selection dialog. */
1267 act
= menu
->addAction(_("Do..."));
1268 menu_list
.insertMulti(ORDER_DIPLOMAT_DLG
, act
);
1269 act
->setShortcut(QKeySequence(shortcut_to_string(
1270 fc_shortcuts::sc()->get_shortcut(SC_DO
))));
1271 connect(act
, SIGNAL(triggered()), this, SLOT(slot_action()));
1272 act
= menu
->addAction(action_id_name_translation(ACTION_NUKE
));
1273 menu_list
.insertMulti(NUKE
, act
);
1274 act
->setShortcut(QKeySequence(shortcut_to_string(
1275 fc_shortcuts::sc()->get_shortcut(SC_NUKE
))));
1276 connect(act
, SIGNAL(triggered()), this, SLOT(slot_nuke()));
1279 menu
= this->addMenu(_("Work"));
1280 act
= menu
->addAction(action_id_name_translation(ACTION_FOUND_CITY
));
1281 act
->setShortcut(QKeySequence(shortcut_to_string(
1282 fc_shortcuts::sc()->get_shortcut(SC_BUILDCITY
))));
1283 menu_list
.insertMulti(BUILD
, act
);
1284 connect(act
, SIGNAL(triggered()), this, SLOT(slot_build_city()));
1285 act
= menu
->addAction(_("Go And Build City"));
1286 menu_list
.insertMulti(GO_AND_BUILD_CITY
, act
);
1287 act
->setShortcut(QKeySequence(tr("shift+b")));
1288 connect(act
, SIGNAL(triggered()), this, SLOT(slot_go_build_city()));
1289 act
= menu
->addAction(_("Go And Join City"));
1290 menu_list
.insertMulti(MIGRANT
, act
);
1291 act
->setShortcut(QKeySequence(tr("shift+j")));
1292 connect(act
, SIGNAL(triggered()), this, SLOT(slot_go_join_city()));
1293 act
= menu
->addAction(_("Auto Settler"));
1294 act
->setShortcut(QKeySequence(shortcut_to_string(
1295 fc_shortcuts::sc()->get_shortcut(SC_AUTOMATE
))));
1296 menu_list
.insertMulti(AUTOSETTLER
, act
);
1297 connect(act
, SIGNAL(triggered()), this, SLOT(slot_auto_settler()));
1298 menu
->addSeparator();
1299 act
= menu
->addAction(_("Build Road"));
1300 menu_list
.insertMulti(ROAD
, act
);
1301 act
->setShortcut(QKeySequence(shortcut_to_string(
1302 fc_shortcuts::sc()->get_shortcut(SC_BUILDROAD
))));
1303 connect(act
, SIGNAL(triggered()), this, SLOT(slot_build_road()));
1304 act
= menu
->addAction(_("Build Irrigation"));
1305 act
->setShortcut(QKeySequence(shortcut_to_string(
1306 fc_shortcuts::sc()->get_shortcut(SC_BUILDIRRIGATION
))));
1307 menu_list
.insertMulti(IRRIGATION
, act
);
1308 connect(act
, SIGNAL(triggered()), this, SLOT(slot_build_irrigation()));
1309 act
= menu
->addAction(_("Build Mine"));
1310 act
->setShortcut(QKeySequence(shortcut_to_string(
1311 fc_shortcuts::sc()->get_shortcut(SC_BUILDMINE
))));
1312 menu_list
.insertMulti(MINE
, act
);
1313 connect(act
, SIGNAL(triggered()), this, SLOT(slot_build_mine()));
1314 menu
->addSeparator();
1315 act
= menu
->addAction(_("Connect With Road"));
1316 act
->setShortcut(QKeySequence(tr("shift+r")));
1317 menu_list
.insertMulti(CONNECT_ROAD
, act
);
1318 connect(act
, SIGNAL(triggered()), this, SLOT(slot_conn_road()));
1319 act
= menu
->addAction(_("Connect With Railroad"));
1320 menu_list
.insertMulti(CONNECT_RAIL
, act
);
1321 act
->setShortcut(QKeySequence(tr("shift+l")));
1322 connect(act
, SIGNAL(triggered()), this, SLOT(slot_conn_rail()));
1323 act
= menu
->addAction(_("Connect With Irrigation"));
1324 menu_list
.insertMulti(CONNECT_IRRIGATION
, act
);
1325 act
->setShortcut(QKeySequence(tr("shift+i")));
1326 connect(act
, SIGNAL(triggered()), this, SLOT(slot_conn_irrigation()));
1327 menu
->addSeparator();
1328 act
= menu
->addAction(_("Transform Terrain"));
1329 menu_list
.insertMulti(TRANSFORM
, act
);
1330 act
->setShortcut(QKeySequence(shortcut_to_string(
1331 fc_shortcuts::sc()->get_shortcut(SC_TRANSFORM
))));
1332 connect(act
, SIGNAL(triggered()), this, SLOT(slot_transform()));
1333 act
= menu
->addAction(_("Clean Pollution"));
1334 menu_list
.insertMulti(POLLUTION
, act
);
1335 act
->setShortcut(QKeySequence(shortcut_to_string(
1336 fc_shortcuts::sc()->get_shortcut(SC_PARADROP
))));
1337 connect(act
, SIGNAL(triggered()), this, SLOT(slot_clean_pollution()));
1338 act
= menu
->addAction(_("Clean Nuclear Fallout"));
1339 menu_list
.insertMulti(FALLOUT
, act
);
1340 act
->setShortcut(QKeySequence(tr("n")));
1341 connect(act
, SIGNAL(triggered()), this, SLOT(slot_clean_fallout()));
1342 act
= menu
->addAction(action_id_name_translation(ACTION_HELP_WONDER
));
1343 act
->setShortcut(QKeySequence(tr("b")));
1344 menu_list
.insertMulti(BUILD_WONDER
, act
);
1345 connect(act
, SIGNAL(triggered()), this, SLOT(slot_build_city()));
1346 act
= menu
->addAction(action_id_name_translation(ACTION_TRADE_ROUTE
));
1347 act
->setShortcut(QKeySequence(tr("r")));
1348 menu_list
.insertMulti(ORDER_TRADEROUTE
, act
);
1349 connect(act
, SIGNAL(triggered()), this, SLOT(slot_build_road()));
1351 multiplayer_menu
= this->addMenu(_("Multiplayer"));
1352 act
= multiplayer_menu
->addAction(_("Delayed Goto"));
1353 act
->setShortcut(QKeySequence(tr("z")));
1354 connect(act
, SIGNAL(triggered()), this, SLOT(slot_delayed_goto()));
1355 act
= multiplayer_menu
->addAction(_("Delayed Orders Execute"));
1356 act
->setShortcut(QKeySequence(tr("ctrl+z")));
1357 connect(act
, SIGNAL(triggered()), this, SLOT(slot_execute_orders()));
1358 act
= multiplayer_menu
->addAction(_("Clear Orders"));
1359 act
->setShortcut(QKeySequence(tr("ctrl+shift+c")));
1360 connect(act
, SIGNAL(triggered()), this, SLOT(slot_orders_clear()));
1361 act
= multiplayer_menu
->addAction(_("Add all cities to trade planning"));
1362 connect(act
, SIGNAL(triggered()), this, SLOT(slot_trade_add_all()));
1363 act
= multiplayer_menu
->addAction(_("Calculate trade planning"));
1364 connect(act
, SIGNAL(triggered()), this, SLOT(slot_calculate()));
1365 act
= multiplayer_menu
->addAction(_("Add/Remove City"));
1366 act
->setShortcut(QKeySequence(tr("ctrl+t")));
1367 connect(act
, SIGNAL(triggered()), this, SLOT(slot_trade_city()));
1368 act
= multiplayer_menu
->addAction(_("Clear Trade Planning"));
1369 connect(act
, SIGNAL(triggered()), this, SLOT(slot_clear_trade()));
1370 act
= multiplayer_menu
->addAction(_("Automatic caravan"));
1371 menu_list
.insertMulti(AUTOTRADEROUTE
, act
);
1372 connect(act
, SIGNAL(triggered()), this, SLOT(slot_autocaravan()));
1373 act
->setShortcut(QKeySequence(tr("ctrl+j")));
1374 act
= multiplayer_menu
->addAction(_("Set/Unset rally point"));
1375 act
->setShortcut(QKeySequence(tr("shift+s")));
1376 connect(act
, SIGNAL(triggered()), this, SLOT(slot_rally()));
1377 act
= multiplayer_menu
->addAction(_("Quick Airlift"));
1378 act
->setShortcut(QKeySequence(tr("ctrl+y")));
1379 connect(act
, SIGNAL(triggered()), this, SLOT(slot_quickairlift()));
1380 airlift_type
= new QActionGroup(this);
1381 airlift_menu
= multiplayer_menu
->addMenu(_("Unit type for quickairlifting"));
1384 action_vs_city
= new QActionGroup(this);
1385 action_vs_unit
= new QActionGroup(this);
1386 action_unit_menu
= multiplayer_menu
->addMenu(_("Default action vs unit"));
1388 act
= action_unit_menu
->addAction(_("Ask"));
1389 act
->setCheckable(true);
1390 act
->setChecked(true);
1392 action_vs_unit
->addAction(act
);
1393 connect(act
, SIGNAL(triggered()), this, SLOT(slot_action_vs_unit()));
1395 act
= action_unit_menu
->addAction(_("Bribe"));
1396 act
->setCheckable(true);
1397 act
->setChecked(false);
1398 act
->setData(ACTION_SPY_BRIBE_UNIT
);
1399 action_vs_unit
->addAction(act
);
1400 connect(act
, SIGNAL(triggered()), this, SLOT(slot_action_vs_unit()));
1402 act
= action_unit_menu
->addAction(_("Sabotage"));
1403 act
->setCheckable(true);
1404 act
->setChecked(false);
1405 act
->setData(ACTION_SPY_SABOTAGE_UNIT
);
1406 action_vs_unit
->addAction(act
);
1407 connect(act
, SIGNAL(triggered()), this, SLOT(slot_action_vs_unit()));
1409 action_city_menu
= multiplayer_menu
->addMenu(_("Default action vs city"));
1410 act
= action_city_menu
->addAction(_("Ask"));
1411 act
->setCheckable(true);
1412 act
->setChecked(true);
1414 action_vs_city
->addAction(act
);
1415 connect(act
, SIGNAL(triggered()), this, SLOT(slot_action_vs_city()));
1417 act
= action_city_menu
->addAction(_("Investigate city"));
1418 act
->setCheckable(true);
1419 act
->setChecked(false);
1420 act
->setData(ACTION_SPY_INVESTIGATE_CITY
);
1421 action_vs_city
->addAction(act
);
1422 connect(act
, SIGNAL(triggered()), this, SLOT(slot_action_vs_city()));
1424 act
= action_city_menu
->addAction(_("Investigate city (spends the unit)"));
1425 act
->setCheckable(true);
1426 act
->setChecked(false);
1427 act
->setData(ACTION_INV_CITY_SPEND
);
1428 action_vs_city
->addAction(act
);
1429 connect(act
, SIGNAL(triggered()), this, SLOT(slot_action_vs_city()));
1431 act
= action_city_menu
->addAction(_("Establish embassy"));
1432 act
->setCheckable(true);
1433 act
->setChecked(false);
1434 act
->setData(ACTION_ESTABLISH_EMBASSY
);
1435 action_vs_city
->addAction(act
);
1436 connect(act
, SIGNAL(triggered()), this, SLOT(slot_action_vs_city()));
1438 act
= action_city_menu
->addAction(_("Become Ambassador"));
1439 act
->setCheckable(true);
1440 act
->setChecked(false);
1441 act
->setData(ACTION_ESTABLISH_EMBASSY_STAY
);
1442 action_vs_city
->addAction(act
);
1443 connect(act
, SIGNAL(triggered()), this, SLOT(slot_action_vs_city()));
1445 act
= action_city_menu
->addAction(_("Steal technology"));
1446 act
->setCheckable(true);
1447 act
->setChecked(false);
1448 act
->setData(ACTION_SPY_STEAL_TECH
);
1449 action_vs_city
->addAction(act
);
1450 connect(act
, SIGNAL(triggered()), this, SLOT(slot_action_vs_city()));
1452 act
= action_city_menu
->addAction(_("Incite a revolt"));
1453 act
->setCheckable(true);
1454 act
->setChecked(false);
1455 act
->setData(ACTION_SPY_INCITE_CITY
);
1456 action_vs_city
->addAction(act
);
1457 connect(act
, SIGNAL(triggered()), this, SLOT(slot_action_vs_city()));
1459 act
= action_city_menu
->addAction(_("Incite a Revolt and Escape"));
1460 act
->setCheckable(true);
1461 act
->setChecked(false);
1462 act
->setData(ACTION_SPY_INCITE_CITY_ESC
);
1463 action_vs_city
->addAction(act
);
1464 connect(act
, SIGNAL(triggered()), this, SLOT(slot_action_vs_city()));
1466 act
= action_city_menu
->addAction(_("Poison city"));
1467 act
->setCheckable(true);
1468 act
->setChecked(false);
1469 act
->setData(ACTION_SPY_POISON
);
1470 action_vs_city
->addAction(act
);
1471 connect(act
, SIGNAL(triggered()), this, SLOT(slot_action_vs_city()));
1473 /* Civilization menu */
1474 menu
= this->addMenu(_("Civilization"));
1475 act
= menu
->addAction(_("Tax Rates..."));
1476 menu_list
.insertMulti(NOT_4_OBS
, act
);
1477 connect(act
, SIGNAL(triggered()), this, SLOT(slot_popup_tax_rates()));
1478 menu
->addSeparator();
1480 act
= menu
->addAction(_("Policies..."));
1481 menu_list
.insertMulti(MULTIPLIERS
, act
);
1482 connect(act
, SIGNAL(triggered()), this, SLOT(slot_popup_mult_rates()));
1483 menu
->addSeparator();
1485 menu
->addMenu(new class gov_menu(this));
1486 menu
->addSeparator();
1488 act
= menu
->addAction(Q_("?noun:View"));
1489 act
->setShortcut(QKeySequence(tr("F1")));
1490 connect(act
, SIGNAL(triggered()), this, SLOT(slot_show_map()));
1492 act
= menu
->addAction(_("Units"));
1493 act
->setShortcut(QKeySequence(tr("F2")));
1494 connect(act
, SIGNAL(triggered()), this, SLOT(slot_show_units_report()));
1496 /* TRANS: Also menu item, but 'headers' should be good enough. */
1497 act
= menu
->addAction(Q_("?header:Players"));
1498 act
->setShortcut(QKeySequence(tr("F3")));
1499 connect(act
, SIGNAL(triggered()), this, SLOT(slot_show_nations()));
1501 act
= menu
->addAction(_("Cities"));
1502 act
->setShortcut(QKeySequence(tr("F4")));
1503 connect(act
, SIGNAL(triggered()), this, SLOT(slot_show_cities()));
1505 act
= menu
->addAction(_("Economy"));
1506 act
->setShortcut(QKeySequence(tr("F5")));
1507 connect(act
, SIGNAL(triggered()), this, SLOT(slot_show_eco_report()));
1509 act
= menu
->addAction(_("Research"));
1510 act
->setShortcut(QKeySequence(tr("F6")));
1511 connect(act
, SIGNAL(triggered()), this, SLOT(slot_show_research_tab()));
1513 act
= menu
->addAction(_("Wonders of the World"));
1514 act
->setShortcut(QKeySequence(tr("F7")));
1515 connect(act
, SIGNAL(triggered()), this, SLOT(slot_traveler()));
1517 act
= menu
->addAction(_("Top Five Cities"));
1518 act
->setShortcut(QKeySequence(tr("F8")));
1519 connect(act
, SIGNAL(triggered()), this, SLOT(slot_top_five()));
1521 act
= menu
->addAction(_("Demographics"));
1522 act
->setShortcut(QKeySequence(tr("F11")));
1523 connect(act
, SIGNAL(triggered()), this, SLOT(slot_demographics()));
1525 act
= menu
->addAction(_("Spaceship"));
1526 act
->setShortcut(QKeySequence(tr("F12")));
1527 connect(act
, SIGNAL(triggered()), this, SLOT(slot_spaceship()));
1529 act
= menu
->addAction(_("Achievements"));
1530 connect(act
, SIGNAL(triggered()), this, SLOT(slot_achievements()));
1532 act
= menu
->addAction(_("Endgame report"));
1533 menu_list
.insertMulti(ENDGAME
, act
);
1534 connect(act
, SIGNAL(triggered()), this, SLOT(slot_endgame()));
1537 menu
= this->addMenu(_("Help"));
1539 signal_help_mapper
= new QSignalMapper(this);
1540 connect(signal_help_mapper
, SIGNAL(mapped(const QString
&)),
1541 this, SLOT(slot_help(const QString
&)));
1543 act
= menu
->addAction(Q_(HELP_OVERVIEW_ITEM
));
1544 connect(act
, SIGNAL(triggered()), signal_help_mapper
, SLOT(map()));
1545 signal_help_mapper
->setMapping(act
, HELP_OVERVIEW_ITEM
);
1547 act
= menu
->addAction(Q_(HELP_PLAYING_ITEM
));
1548 connect(act
, SIGNAL(triggered()), signal_help_mapper
, SLOT(map()));
1549 signal_help_mapper
->setMapping(act
, HELP_PLAYING_ITEM
);
1551 act
= menu
->addAction(Q_(HELP_TERRAIN_ITEM
));
1552 connect(act
, SIGNAL(triggered()), signal_help_mapper
, SLOT(map()));
1553 signal_help_mapper
->setMapping(act
, HELP_TERRAIN_ITEM
);
1555 act
= menu
->addAction(Q_(HELP_ECONOMY_ITEM
));
1556 connect(act
, SIGNAL(triggered()), signal_help_mapper
, SLOT(map()));
1557 signal_help_mapper
->setMapping(act
, HELP_ECONOMY_ITEM
);
1559 act
= menu
->addAction(Q_(HELP_CITIES_ITEM
));
1560 connect(act
, SIGNAL(triggered()), signal_help_mapper
, SLOT(map()));
1561 signal_help_mapper
->setMapping(act
, HELP_CITIES_ITEM
);
1563 act
= menu
->addAction(Q_(HELP_IMPROVEMENTS_ITEM
));
1564 connect(act
, SIGNAL(triggered()), signal_help_mapper
, SLOT(map()));
1565 signal_help_mapper
->setMapping(act
, HELP_IMPROVEMENTS_ITEM
);
1567 act
= menu
->addAction(Q_(HELP_WONDERS_ITEM
));
1568 connect(act
, SIGNAL(triggered()), signal_help_mapper
, SLOT(map()));
1569 signal_help_mapper
->setMapping(act
, HELP_WONDERS_ITEM
);
1571 act
= menu
->addAction(Q_(HELP_UNITS_ITEM
));
1572 connect(act
, SIGNAL(triggered()), signal_help_mapper
, SLOT(map()));
1573 signal_help_mapper
->setMapping(act
, HELP_UNITS_ITEM
);
1575 act
= menu
->addAction(Q_(HELP_COMBAT_ITEM
));
1576 connect(act
, SIGNAL(triggered()), signal_help_mapper
, SLOT(map()));
1577 signal_help_mapper
->setMapping(act
, HELP_COMBAT_ITEM
);
1579 act
= menu
->addAction(Q_(HELP_ZOC_ITEM
));
1580 connect(act
, SIGNAL(triggered()), signal_help_mapper
, SLOT(map()));
1581 signal_help_mapper
->setMapping(act
, HELP_ZOC_ITEM
);
1583 act
= menu
->addAction(Q_(HELP_GOVERNMENT_ITEM
));
1584 connect(act
, SIGNAL(triggered()), signal_help_mapper
, SLOT(map()));
1585 signal_help_mapper
->setMapping(act
, HELP_GOVERNMENT_ITEM
);
1587 act
= menu
->addAction(Q_(HELP_ECONOMY_ITEM
));
1588 connect(act
, SIGNAL(triggered()), signal_help_mapper
, SLOT(map()));
1589 signal_help_mapper
->setMapping(act
, HELP_ECONOMY_ITEM
);
1591 act
= menu
->addAction(Q_(HELP_DIPLOMACY_ITEM
));
1592 connect(act
, SIGNAL(triggered()), signal_help_mapper
, SLOT(map()));
1593 signal_help_mapper
->setMapping(act
, HELP_DIPLOMACY_ITEM
);
1595 act
= menu
->addAction(Q_(HELP_TECHS_ITEM
));
1596 connect(act
, SIGNAL(triggered()), signal_help_mapper
, SLOT(map()));
1597 signal_help_mapper
->setMapping(act
, HELP_TECHS_ITEM
);
1599 act
= menu
->addAction(Q_(HELP_SPACE_RACE_ITEM
));
1600 connect(act
, SIGNAL(triggered()), signal_help_mapper
, SLOT(map()));
1601 signal_help_mapper
->setMapping(act
, HELP_SPACE_RACE_ITEM
);
1603 act
= menu
->addAction(Q_(HELP_IMPROVEMENTS_ITEM
));
1604 connect(act
, SIGNAL(triggered()), signal_help_mapper
, SLOT(map()));
1605 signal_help_mapper
->setMapping(act
, HELP_IMPROVEMENTS_ITEM
);
1607 act
= menu
->addAction(Q_(HELP_RULESET_ITEM
));
1608 connect(act
, SIGNAL(triggered()), signal_help_mapper
, SLOT(map()));
1609 signal_help_mapper
->setMapping(act
, HELP_RULESET_ITEM
);
1611 act
= menu
->addAction(Q_(HELP_NATIONS_ITEM
));
1612 connect(act
, SIGNAL(triggered()), signal_help_mapper
, SLOT(map()));
1613 signal_help_mapper
->setMapping(act
, HELP_NATIONS_ITEM
);
1615 menu
->addSeparator();
1617 act
= menu
->addAction(Q_(HELP_CONNECTING_ITEM
));
1618 connect(act
, SIGNAL(triggered()), signal_help_mapper
, SLOT(map()));
1619 signal_help_mapper
->setMapping(act
, HELP_CONNECTING_ITEM
);
1621 act
= menu
->addAction(Q_(HELP_CONTROLS_ITEM
));
1622 connect(act
, SIGNAL(triggered()), signal_help_mapper
, SLOT(map()));
1623 signal_help_mapper
->setMapping(act
, HELP_CONTROLS_ITEM
);
1625 act
= menu
->addAction(Q_(HELP_CMA_ITEM
));
1626 connect(act
, SIGNAL(triggered()), signal_help_mapper
, SLOT(map()));
1627 signal_help_mapper
->setMapping(act
, HELP_CMA_ITEM
);
1629 act
= menu
->addAction(Q_(HELP_CHATLINE_ITEM
));
1630 connect(act
, SIGNAL(triggered()), signal_help_mapper
, SLOT(map()));
1631 signal_help_mapper
->setMapping(act
, HELP_CHATLINE_ITEM
);
1633 act
= menu
->addAction(Q_(HELP_WORKLIST_EDITOR_ITEM
));
1634 connect(act
, SIGNAL(triggered()), signal_help_mapper
, SLOT(map()));
1635 signal_help_mapper
->setMapping(act
, HELP_WORKLIST_EDITOR_ITEM
);
1637 menu
->addSeparator();
1639 act
= menu
->addAction(Q_(HELP_LANGUAGES_ITEM
));
1640 connect(act
, SIGNAL(triggered()), signal_help_mapper
, SLOT(map()));
1641 signal_help_mapper
->setMapping(act
, HELP_LANGUAGES_ITEM
);
1643 act
= menu
->addAction(Q_(HELP_COPYING_ITEM
));
1644 connect(act
, SIGNAL(triggered()), signal_help_mapper
, SLOT(map()));
1645 signal_help_mapper
->setMapping(act
, HELP_COPYING_ITEM
);
1647 act
= menu
->addAction(Q_(HELP_ABOUT_ITEM
));
1648 connect(act
, SIGNAL(triggered()), signal_help_mapper
, SLOT(map()));
1649 signal_help_mapper
->setMapping(act
, HELP_ABOUT_ITEM
);
1651 menus
= this->findChildren
<QMenu
*>();
1652 for (i
= 0; i
< menus
.count(); i
++) {
1653 menus
[i
]->setAttribute(Qt::WA_TranslucentBackground
);
1655 this->setVisible(false);
1658 /****************************************************************************
1659 Sets given tile for delayed order
1660 ****************************************************************************/
1661 void mr_menu::set_tile_for_order(tile
*ptile
)
1663 for (int i
=0; i
< units_list
.nr_units
; i
++) {
1664 units_list
.unit_list
.at(units_list
.unit_list
.count() - i
-1)->ptile
= ptile
;
1668 /****************************************************************************
1669 Finds QAction bounded to given shortcut and triggers it
1670 ****************************************************************************/
1671 void mr_menu::execute_shortcut(int sid
)
1673 QList
<QMenu
*> menu_list
;
1677 if (sid
== SC_GOTO
) {
1678 gui()->mapview_wdg
->menu_click
= true;
1682 fcs
= fc_shortcuts::sc()->get_shortcut(static_cast<shortcut_id
>(sid
));
1683 seq
= QKeySequence(shortcut_to_string(fcs
));
1685 menu_list
= findChildren
<QMenu
*>();
1686 foreach (const QMenu
*m
, menu_list
) {
1687 foreach (QAction
*a
, m
->actions()) {
1688 if (a
->shortcut() == seq
&& a
->isEnabled()) {
1689 a
->activate(QAction::Trigger
);
1696 /****************************************************************************
1697 Returns string assigned to shortcut or empty string if doesnt exist
1698 ****************************************************************************/
1699 QString
mr_menu::shortcut_exist(fc_shortcut
*fcs
)
1701 QList
<QMenu
*> menu_list
;
1704 seq
= QKeySequence(shortcut_to_string(fcs
));
1705 menu_list
= findChildren
<QMenu
*>();
1706 foreach (const QMenu
*m
, menu_list
) {
1707 foreach (QAction
*a
, m
->actions()) {
1708 if (a
->shortcut() == seq
&& fcs
->mouse
== Qt::AllButtons
) {
1717 /****************************************************************************
1718 Returns string bounded to given shortcut
1719 ****************************************************************************/
1720 QString
mr_menu::shortcut_2_menustring(int sid
)
1722 QList
<QMenu
*> menu_list
;
1726 fcs
= fc_shortcuts::sc()->get_shortcut(static_cast<shortcut_id
>(sid
));
1727 seq
= QKeySequence(shortcut_to_string(fcs
));
1729 menu_list
= findChildren
<QMenu
*>();
1730 foreach (const QMenu
*m
, menu_list
) {
1731 foreach (QAction
*a
, m
->actions()) {
1732 if (a
->shortcut() == seq
) {
1733 return (a
->text() + " ("
1734 + a
->shortcut().toString(QKeySequence::NativeText
) + ")");
1741 /****************************************************************************
1742 Updates airlift menu
1743 ****************************************************************************/
1744 void mr_menu::update_airlift_menu()
1746 Unit_type_id utype_id
;
1749 airlift_menu
->clear();
1750 if (client_is_observer()) {
1753 unit_type_iterate(utype
) {
1754 utype_id
= utype_index(utype
);
1756 if (!can_player_build_unit_now(client
.conn
.playing
, utype
)
1757 || !utype_can_do_action(utype
, ACTION_AIRLIFT
)) {
1760 if (!can_player_build_unit_now(client
.conn
.playing
, utype
)
1761 && !has_player_unit_type(utype_id
)) {
1764 act
= airlift_menu
->addAction(utype_name_translation(utype
));
1765 act
->setCheckable(true);
1766 act
->setData(utype_id
);
1767 if (airlift_type_id
== utype_id
) {
1768 act
->setChecked(true);
1770 connect(act
, SIGNAL(triggered()), this, SLOT(slot_quickairlift_set()));
1771 airlift_type
->addAction(act
);
1772 } unit_type_iterate_end
;
1777 /****************************************************************************
1778 Enables/disables menu items and renames them depending on key in menu_list
1779 ****************************************************************************/
1780 void mr_menu::menus_sensitive()
1782 QList
<QAction
* >values
;
1783 QList
<munit
> keys
;
1784 QHash
<munit
, QAction
*>::iterator i
;
1785 struct unit_list
*punits
= NULL
;
1786 struct road_type
*proad
;
1787 struct extra_type
*tgt
;
1788 bool any_cities
= false;
1789 bool city_on_tile
= false;
1790 bool units_all_same_tile
= true;
1791 const struct tile
*ptile
= NULL
;
1792 struct terrain
*pterrain
;
1793 const struct unit_type
*ptype
= NULL
;
1795 players_iterate(pplayer
) {
1796 if (city_list_size(pplayer
->cities
)) {
1800 } players_iterate_end
;
1802 /** Disable first all sensitive menus */
1803 foreach(QAction
* a
, menu_list
) {
1804 a
->setEnabled(false);
1807 if (client_is_observer()) {
1808 multiplayer_menu
->setDisabled(true);
1810 multiplayer_menu
->setDisabled(false);
1813 /* Non unit menus */
1814 keys
= menu_list
.keys();
1815 foreach (munit key
, keys
) {
1816 i
= menu_list
.find(key
);
1817 while (i
!= menu_list
.end() && i
.key() == key
) {
1820 if (can_client_access_hack() && C_S_RUNNING
<= client_state()) {
1821 i
.value()->setEnabled(true);
1825 if (client_is_observer() == false) {
1826 i
.value()->setEnabled(true);
1830 if (client_is_observer() == false && multiplier_count() > 0) {
1831 i
.value()->setEnabled(true);
1832 i
.value()->setVisible(true);
1834 i
.value()->setVisible(false);
1838 if (gui()->is_repo_dlg_open("END")) {
1839 i
.value()->setEnabled(true);
1840 i
.value()->setVisible(true);
1842 i
.value()->setVisible(false);
1852 if (can_client_issue_orders() == false || get_num_units_in_focus() == 0) {
1856 punits
= get_units_in_focus();
1857 unit_list_iterate(punits
, punit
) {
1858 if (tile_city(unit_tile(punit
))) {
1859 city_on_tile
= true;
1862 } unit_list_iterate_end
;
1864 unit_list_iterate(punits
, punit
) {
1865 fc_assert((ptile
== NULL
) == (ptype
== NULL
));
1866 if (ptile
|| ptype
) {
1867 if (unit_tile(punit
) != ptile
) {
1868 units_all_same_tile
= false;
1870 if (unit_type_get(punit
) == ptype
) {
1871 ptile
= unit_tile(punit
);
1872 ptype
= unit_type_get(punit
);
1875 } unit_list_iterate_end
;
1877 keys
= menu_list
.keys();
1878 foreach(munit key
, keys
) {
1879 i
= menu_list
.find(key
);
1880 while (i
!= menu_list
.end() && i
.key() == key
) {
1883 i
.value()->setEnabled(true);
1887 if (can_units_do_activity(punits
, ACTIVITY_EXPLORE
)) {
1888 i
.value()->setEnabled(true);
1893 if (units_can_load(punits
)) {
1894 i
.value()->setEnabled(true);
1899 if (units_can_unload(punits
)) {
1900 i
.value()->setEnabled(true);
1905 if (units_are_occupied(punits
)) {
1906 i
.value()->setEnabled(true);
1911 if (units_can_convert(punits
)) {
1912 i
.value()->setEnabled(true);
1917 if (can_units_do_activity(punits
, ACTIVITY_MINE
)) {
1918 i
.value()->setEnabled(true);
1921 if (units_all_same_tile
) {
1922 struct unit
*punit
= unit_list_get(punits
, 0);
1924 pterrain
= tile_terrain(unit_tile(punit
));
1925 if (pterrain
->mining_result
!= T_NONE
1926 && pterrain
->mining_result
!= pterrain
) {
1928 QString(_("Transform to %1")).
1929 /* TRANS: Transfrom terrain to specific type */
1930 arg(QString(get_tile_change_menu_text
1931 (unit_tile(punit
), ACTIVITY_MINE
))));
1932 } else if (units_have_type_flag(punits
, UTYF_SETTLERS
, TRUE
)){
1933 struct extra_type
*pextra
= NULL
;
1935 /* FIXME: this overloading doesn't work well with multiple focus
1937 unit_list_iterate(punits
, builder
) {
1938 pextra
= next_extra_for_tile(unit_tile(builder
), EC_MINE
,
1939 unit_owner(builder
), builder
);
1940 if (pextra
!= NULL
) {
1943 } unit_list_iterate_end
;
1945 if (pextra
!= NULL
) {
1946 /* TRANS: Build mine of specific type */
1947 i
.value()->setText(QString(_("Build %1"))
1948 .arg(extra_name_translation(pextra
)));
1950 i
.value()->setText(QString(_("Build Mine")));
1953 i
.value()->setText(QString(_("Build Mine")));
1959 if (can_units_do_activity(punits
, ACTIVITY_IRRIGATE
)) {
1960 i
.value()->setEnabled(true);
1962 if (units_all_same_tile
) {
1963 struct unit
*punit
= unit_list_get(punits
, 0);
1965 pterrain
= tile_terrain(unit_tile(punit
));
1966 if (pterrain
->irrigation_result
!= T_NONE
1967 && pterrain
->irrigation_result
!= pterrain
) {
1968 i
.value()->setText(QString(_("Transform to %1")).
1969 /* TRANS: Transfrom terrain to specific type */
1970 arg(QString(get_tile_change_menu_text
1971 (unit_tile(punit
), ACTIVITY_IRRIGATE
))));
1972 } else if (units_have_type_flag(punits
, UTYF_SETTLERS
, TRUE
)){
1973 struct extra_type
*pextra
= NULL
;
1975 /* FIXME: this overloading doesn't work well with multiple focus
1977 unit_list_iterate(punits
, builder
) {
1978 pextra
= next_extra_for_tile(unit_tile(builder
), EC_IRRIGATION
,
1979 unit_owner(builder
), builder
);
1980 if (pextra
!= NULL
) {
1983 } unit_list_iterate_end
;
1985 if (pextra
!= NULL
) {
1986 /* TRANS: Build irrigation of specific type */
1987 i
.value()->setText(QString(_("Build %1"))
1988 .arg(extra_name_translation(pextra
)));
1990 i
.value()->setText(QString(_("Build Irrigation")));
1993 i
.value()->setText(QString(_("Build Irrigation")));
1999 if (can_units_do_activity(punits
, ACTIVITY_TRANSFORM
)) {
2000 i
.value()->setEnabled(true);
2004 if (units_all_same_tile
) {
2005 struct unit
*punit
= unit_list_get(punits
, 0);
2006 pterrain
= tile_terrain(unit_tile(punit
));
2007 punit
= unit_list_get(punits
, 0);
2008 pterrain
= tile_terrain(unit_tile(punit
));
2009 if (pterrain
->transform_result
!= T_NONE
2010 && pterrain
->transform_result
!= pterrain
) {
2011 i
.value()->setText(QString(_("Transform to %1")).
2012 /* TRANS: Transfrom terrain to specific type */
2013 arg(QString(get_tile_change_menu_text
2014 (unit_tile(punit
), ACTIVITY_TRANSFORM
))));
2016 i
.value()->setText(_("Transform Terrain"));
2022 if (can_units_do(punits
, unit_can_add_or_build_city
)) {
2023 i
.value()->setEnabled(true);
2026 && units_can_do_action(punits
, ACTION_JOIN_CITY
, true)) {
2027 i
.value()->setText(action_id_name_translation(ACTION_JOIN_CITY
));
2029 i
.value()->setText(action_id_name_translation(ACTION_FOUND_CITY
));
2035 char road_item
[500];
2036 struct extra_type
*pextra
= nullptr;
2038 if (can_units_do_any_road(punits
)) {
2039 i
.value()->setEnabled(true);
2041 unit_list_iterate(punits
, punit
) {
2042 pextra
= next_extra_for_tile(unit_tile(punit
), EC_ROAD
,
2043 unit_owner(punit
), punit
);
2044 if (pextra
!= nullptr) {
2047 } unit_list_iterate_end
;
2049 if (pextra
!= nullptr) {
2050 fc_snprintf(road_item
, sizeof(road_item
), _("Build %s"),
2051 extra_name_translation(pextra
));
2052 i
.value()->setText(road_item
);
2058 if (units_can_do_action(punits
, ACTION_JOIN_CITY
, true)) {
2059 i
.value()->setEnabled(true);
2064 if (can_units_do_activity(punits
, ACTIVITY_FORTIFYING
)) {
2065 i
.value()->setEnabled(true);
2070 if (can_units_do_base_gui(punits
, BASE_GUI_FORTRESS
)) {
2071 i
.value()->setEnabled(true);
2076 if (can_units_do_base_gui(punits
, BASE_GUI_AIRBASE
)) {
2077 i
.value()->setEnabled(true);
2082 if (can_units_do_activity(punits
, ACTIVITY_POLLUTION
)
2083 || can_units_do(punits
, can_unit_paradrop
)) {
2084 i
.value()->setEnabled(true);
2086 if (units_can_do_action(punits
, ACTION_PARADROP
, true)) {
2087 i
.value()->setText(action_id_name_translation(ACTION_PARADROP
));
2089 i
.value()->setText(_("Clean Pollution"));
2094 if (can_units_do_activity(punits
, ACTIVITY_FALLOUT
)) {
2095 i
.value()->setEnabled(true);
2100 if (can_units_do_activity(punits
, ACTIVITY_SENTRY
)) {
2101 i
.value()->setEnabled(true);
2106 if (can_units_do_activity(punits
, ACTIVITY_PILLAGE
)) {
2107 i
.value()->setEnabled(true);
2112 if (can_units_do(punits
, can_unit_change_homecity
)) {
2113 i
.value()->setEnabled(true);
2118 if (units_have_activity_on_tile(punits
, ACTIVITY_SENTRY
)) {
2119 i
.value()->setEnabled(true);
2124 if (can_units_do(punits
, can_unit_do_autosettlers
)) {
2125 i
.value()->setEnabled(true);
2127 if (units_contain_cityfounder(punits
)) {
2128 i
.value()->setText(_("Auto Settler"));
2130 i
.value()->setText(_("Auto Worker"));
2133 case GO_AND_BUILD_CITY
:
2134 if (units_contain_cityfounder(punits
)) {
2135 i
.value()->setEnabled(true);
2139 proad
= road_by_compat_special(ROCO_ROAD
);
2140 if (proad
!= NULL
) {
2141 tgt
= road_extra_get(proad
);
2145 if (can_units_do_connect(punits
, ACTIVITY_GEN_ROAD
, tgt
)) {
2146 i
.value()->setEnabled(true);
2151 if (units_can_do_action(punits
, ACTION_DISBAND_UNIT
, true)) {
2152 i
.value()->setEnabled(true);
2156 proad
= road_by_compat_special(ROCO_RAILROAD
);
2157 if (proad
!= NULL
) {
2158 tgt
= road_extra_get(proad
);
2162 if (can_units_do_connect(punits
, ACTIVITY_GEN_ROAD
, tgt
)) {
2163 i
.value()->setEnabled(true);
2167 case CONNECT_IRRIGATION
:
2169 struct extra_type_list
*extras
= extra_type_list_by_cause(EC_IRRIGATION
);
2171 if (extra_type_list_size(extras
) > 0) {
2172 struct extra_type
*pextra
;
2174 pextra
= extra_type_list_get(extra_type_list_by_cause(EC_IRRIGATION
), 0);
2175 if (can_units_do_connect(punits
, ACTIVITY_IRRIGATE
, pextra
)) {
2176 i
.value()->setEnabled(true);
2184 i
.value()->setEnabled(true);
2190 i
.value()->setEnabled(true);
2195 i
.value()->setText(action_id_name_translation(ACTION_HELP_WONDER
));
2196 if (can_units_do(punits
, unit_can_help_build_wonder_here
)) {
2197 i
.value()->setEnabled(true);
2201 case AUTOTRADEROUTE
:
2202 if (units_can_do_action(punits
, ACTION_TRADE_ROUTE
, TRUE
)) {
2203 i
.value()->setEnabled(true);
2207 case ORDER_TRADEROUTE
:
2208 i
.value()->setText(action_id_name_translation(ACTION_TRADE_ROUTE
));
2209 if (can_units_do(punits
, unit_can_est_trade_route_here
)) {
2210 i
.value()->setEnabled(true);
2214 case ORDER_DIPLOMAT_DLG
:
2215 if (units_can_do_action(punits
, ACTION_ANY
, TRUE
)) {
2216 i
.value()->setEnabled(true);
2221 i
.value()->setText(action_id_name_translation(ACTION_NUKE
));
2222 if (units_can_do_action(punits
, ACTION_NUKE
, TRUE
)) {
2223 i
.value()->setEnabled(true);
2228 if (units_can_upgrade(punits
)) {
2229 i
.value()->setEnabled(true);
2241 /***************************************************************************
2242 Slot for showing research tab
2243 ***************************************************************************/
2244 void mr_menu::slot_show_research_tab()
2246 science_report_dialog_popup(true);
2249 /***************************************************************************
2250 Slot for showing spaceship
2251 ***************************************************************************/
2252 void mr_menu::slot_spaceship()
2254 if (NULL
!= client
.conn
.playing
) {
2255 popup_spaceship_dialog(client
.conn
.playing
);
2259 /***************************************************************************
2260 Slot for showing economy tab
2261 ***************************************************************************/
2262 void mr_menu::slot_show_eco_report()
2264 economy_report_dialog_popup(false);
2267 /***************************************************************************
2268 Changes tab to mapview
2269 ***************************************************************************/
2270 void mr_menu::slot_show_map()
2272 ::gui()->game_tab_widget
->setCurrentIndex(0);
2275 /***************************************************************************
2276 Slot for showing units tab
2277 ***************************************************************************/
2278 void mr_menu::slot_show_units_report()
2280 toggle_units_report(true);
2283 /***************************************************************************
2284 Slot for showing nations report
2285 ***************************************************************************/
2286 void mr_menu::slot_show_nations()
2288 popup_players_dialog(false);
2291 /***************************************************************************
2292 Slot for showing cities report
2293 ***************************************************************************/
2294 void mr_menu::slot_show_cities()
2296 city_report_dialog_popup(false);
2299 /****************************************************************
2301 *****************************************************************/
2302 void mr_menu::slot_build_city()
2304 unit_list_iterate(get_units_in_focus(), punit
) {
2305 /* FIXME: this can provide different actions for different units...
2307 /* Enable the button for adding to a city in all cases, so we
2308 get an eventual error message from the server if we try. */
2309 if (unit_can_add_or_build_city(punit
)) {
2310 request_unit_build_city(punit
);
2311 } else if (utype_can_do_action(unit_type_get(punit
), ACTION_HELP_WONDER
)) {
2312 request_unit_caravan_action(punit
, ACTION_HELP_WONDER
);
2314 } unit_list_iterate_end
;
2317 /***************************************************************************
2318 Action "CLEAN FALLOUT"
2319 ***************************************************************************/
2320 void mr_menu::slot_clean_fallout()
2325 /***************************************************************************
2326 Action "CLEAN POLLUTION and PARADROP"
2327 ***************************************************************************/
2328 void mr_menu::slot_clean_pollution()
2330 unit_list_iterate(get_units_in_focus(), punit
) {
2331 /* FIXME: this can provide different actions for different units...
2333 struct extra_type
*pextra
;
2335 pextra
= prev_extra_in_tile(unit_tile(punit
), ERM_CLEANPOLLUTION
,
2336 unit_owner(punit
), punit
);
2337 if (pextra
!= NULL
) {
2338 request_new_unit_activity_targeted(punit
, ACTIVITY_POLLUTION
, pextra
);
2339 } else if (can_unit_paradrop(punit
)) {
2340 /* FIXME: This is getting worse, we use a key_unit_*() function
2341 * which assign the order for all units! Very bad! */
2342 key_unit_paradrop();
2344 } unit_list_iterate_end
;
2347 /***************************************************************************
2348 Action "CONNECT WITH IRRIGATION"
2349 ***************************************************************************/
2350 void mr_menu::slot_conn_irrigation()
2352 struct extra_type_list
*extras
= extra_type_list_by_cause(EC_IRRIGATION
);
2354 if (extra_type_list_size(extras
) > 0) {
2355 struct extra_type
*pextra
;
2357 pextra
= extra_type_list_get(extra_type_list_by_cause(EC_IRRIGATION
), 0);
2359 key_unit_connect(ACTIVITY_IRRIGATE
, pextra
);
2363 /***************************************************************************
2364 Action "CONNECT WITH RAILROAD"
2365 ***************************************************************************/
2366 void mr_menu::slot_conn_rail()
2368 struct road_type
*prail
= road_by_compat_special(ROCO_RAILROAD
);
2370 if (prail
!= NULL
) {
2371 struct extra_type
*tgt
;
2373 tgt
= road_extra_get(prail
);
2374 key_unit_connect(ACTIVITY_GEN_ROAD
, tgt
);
2378 /***************************************************************************
2379 Action "BUILD FORTRESS"
2380 ***************************************************************************/
2381 void mr_menu::slot_unit_fortress()
2383 key_unit_fortress();
2386 /***************************************************************************
2387 Action "BUILD AIRBASE"
2388 ***************************************************************************/
2389 void mr_menu::slot_unit_airbase()
2394 /***************************************************************************
2395 Action "CONNECT WITH ROAD"
2396 ***************************************************************************/
2397 void mr_menu::slot_conn_road()
2399 struct road_type
*proad
= road_by_compat_special(ROCO_ROAD
);
2401 if (proad
!= NULL
) {
2402 struct extra_type
*tgt
;
2404 tgt
= road_extra_get(proad
);
2405 key_unit_connect(ACTIVITY_GEN_ROAD
, tgt
);
2409 /***************************************************************************
2410 Action "GO TO AND BUILD CITY"
2411 ***************************************************************************/
2412 void mr_menu::slot_go_build_city()
2414 request_unit_goto(ORDER_PERFORM_ACTION
, ACTION_FOUND_CITY
, EXTRA_NONE
);
2417 /***************************************************************************
2418 Action "GO TO AND JOIN CITY"
2419 ***************************************************************************/
2420 void mr_menu::slot_go_join_city()
2422 request_unit_goto(ORDER_PERFORM_ACTION
, ACTION_JOIN_CITY
, EXTRA_NONE
);
2425 /***************************************************************************
2426 Action "TRANSFROM TERRAIN"
2427 ***************************************************************************/
2428 void mr_menu::slot_transform()
2430 key_unit_transform();
2433 /***************************************************************************
2435 ***************************************************************************/
2436 void mr_menu::slot_pillage()
2441 /***************************************************************************
2442 Do... the selected action
2443 ***************************************************************************/
2444 void mr_menu::slot_action()
2446 key_unit_action_select_tgt();
2449 /***************************************************************************
2451 ***************************************************************************/
2452 void mr_menu::slot_nuke()
2458 /****************************************************************
2459 Action "AUTO_SETTLER"
2460 *****************************************************************/
2461 void mr_menu::slot_auto_settler()
2463 key_unit_auto_settle();
2466 /****************************************************************
2468 *****************************************************************/
2469 void mr_menu::slot_build_road()
2471 unit_list_iterate(get_units_in_focus(), punit
) {
2472 /* FIXME: this can provide different actions for different units...
2474 struct extra_type
*tgt
= next_extra_for_tile(unit_tile(punit
),
2478 bool building_road
= false;
2481 && can_unit_do_activity_targeted(punit
, ACTIVITY_GEN_ROAD
, tgt
)) {
2482 request_new_unit_activity_targeted(punit
, ACTIVITY_GEN_ROAD
, tgt
);
2483 building_road
= true;
2486 if (!building_road
&& unit_can_est_trade_route_here(punit
)) {
2487 request_unit_caravan_action(punit
, ACTION_TRADE_ROUTE
);
2489 } unit_list_iterate_end
;
2492 /****************************************************************
2493 Action "BUILD_IRRIGATION"
2494 *****************************************************************/
2495 void mr_menu::slot_build_irrigation()
2497 key_unit_irrigate();
2500 /****************************************************************
2502 *****************************************************************/
2503 void mr_menu::slot_build_mine()
2507 /****************************************************************
2509 *****************************************************************/
2510 void mr_menu::slot_unit_fortify()
2515 /****************************************************************
2517 *****************************************************************/
2518 void mr_menu::slot_unit_sentry()
2523 /***************************************************************************
2525 ***************************************************************************/
2526 void mr_menu::slot_convert()
2531 /***************************************************************************
2532 Action "DISBAND UNIT"
2533 ***************************************************************************/
2534 void mr_menu::slot_disband()
2536 popup_disband_dialog(get_units_in_focus());
2539 /***************************************************************************
2540 Clears delayed orders
2541 ***************************************************************************/
2542 void mr_menu::slot_orders_clear()
2544 delayed_order
= false;
2548 /***************************************************************************
2549 Sets/unset rally point
2550 ***************************************************************************/
2551 void mr_menu::slot_rally()
2553 gui()->rallies
.hover_tile
= false;
2554 gui()->rallies
.hover_city
= true;
2557 /***************************************************************************
2558 Adds one city to trade planning
2559 ***************************************************************************/
2560 void mr_menu::slot_trade_city()
2562 gui()->trade_gen
.hover_city
= true;
2564 /***************************************************************************
2565 Adds all cities to trade planning
2566 ***************************************************************************/
2567 void mr_menu::slot_trade_add_all()
2569 gui()->trade_gen
.add_all_cities();
2572 /***************************************************************************
2573 Trade calculation slot
2574 ***************************************************************************/
2575 void mr_menu::slot_calculate()
2577 gui()->trade_gen
.calculate();
2580 /**************************************************************************
2581 Slot for clearing trade routes
2582 **************************************************************************/
2583 void mr_menu::slot_clear_trade()
2585 gui()->trade_gen
.clear_trade_planing();
2588 /***************************************************************************
2589 Sends automatic caravan
2590 ***************************************************************************/
2591 void mr_menu::slot_autocaravan()
2595 struct city
*homecity
;
2596 struct tile
*home_tile
;
2597 struct tile
*dest_tile
;
2600 punit
= head_of_units_in_focus();
2601 homecity
= game_city_by_number(punit
->homecity
);
2602 home_tile
= homecity
->tile
;
2603 foreach(gilles
, gui()->trade_gen
.lines
) {
2604 if ((gilles
.t1
== home_tile
|| gilles
.t2
== home_tile
)
2605 && gilles
.autocaravan
== nullptr) {
2607 if (gilles
.t1
== home_tile
) {
2608 dest_tile
= gilles
.t2
;
2610 dest_tile
= gilles
.t1
;
2612 if (send_goto_tile(punit
, dest_tile
)) {
2614 i
= gui()->trade_gen
.lines
.indexOf(gilles
);
2615 gilles
= gui()->trade_gen
.lines
.takeAt(i
);
2616 gilles
.autocaravan
= punit
;
2617 gui()->trade_gen
.lines
.append(gilles
);
2625 gui()->infotab
->chtwdg
->append(_("Didn't find any trade route"
2630 /**************************************************************************
2631 Slot for setting quick airlift
2632 **************************************************************************/
2633 void mr_menu::slot_quickairlift_set()
2638 act
= qobject_cast
<QAction
*>(sender());
2640 airlift_type_id
= v
.toInt();
2643 /**************************************************************************
2644 Slot for choosing default action vs unit
2645 **************************************************************************/
2646 void mr_menu::slot_action_vs_unit()
2650 act
= qobject_cast
<QAction
*>(sender());
2651 qdef_act::action()->vs_unit_set(act
->data().toInt());
2655 /**************************************************************************
2656 Slot for choosing default action vs city
2657 **************************************************************************/
2658 void mr_menu::slot_action_vs_city()
2662 act
= qobject_cast
<QAction
*>(sender());
2663 qdef_act::action()->vs_city_set(act
->data().toInt());
2666 /**************************************************************************
2667 Slot for quick airlifting
2668 **************************************************************************/
2669 void mr_menu::slot_quickairlift()
2671 quick_airlifting
= true;
2675 /***************************************************************************
2677 ***************************************************************************/
2678 void mr_menu::slot_delayed_goto()
2680 qfc_delayed_unit_item
*unit_item
;
2683 delayed_order
= true;
2686 struct unit_list
*punits
= get_units_in_focus();
2687 if (unit_list_size(punits
) == 0) {
2690 if (hover_state
!= HOVER_GOTO
) {
2691 set_hover_state(punits
, HOVER_GOTO
, ACTIVITY_LAST
, NULL
,
2692 EXTRA_NONE
, ACTION_NONE
, ORDER_LAST
);
2693 enter_goto_state(punits
);
2694 create_line_at_mouse_pos();
2695 control_mouse_cursor(NULL
);
2697 unit_list_iterate(get_units_in_focus(), punit
) {
2699 unit_item
= new qfc_delayed_unit_item(dg
, punit
->id
);
2700 units_list
.add(unit_item
);
2701 units_list
.nr_units
= i
;
2702 } unit_list_iterate_end
;
2705 /***************************************************************************
2706 Executes stored orders
2707 ***************************************************************************/
2708 void mr_menu::slot_execute_orders()
2710 qfc_delayed_unit_item
*fui
;
2712 struct tile
*last_tile
;
2713 struct tile
*new_tile
;
2716 foreach (fui
, units_list
.unit_list
) {
2718 punit
= unit_list_find(client_player()->units
, fui
->id
);
2719 if (punit
== nullptr) {
2722 last_tile
= punit
->tile
;
2723 new_tile
= find_last_unit_pos(punit
, i
);
2724 if (new_tile
!= nullptr) {
2725 punit
->tile
= new_tile
;
2727 if (is_tiles_adjacent(punit
->tile
, fui
->ptile
)) {
2728 request_move_unit_direction(punit
,
2729 get_direction_for_step(&(wld
.map
),
2733 send_attack_tile(punit
, fui
->ptile
);
2735 punit
->tile
= last_tile
;
2740 /***************************************************************************
2741 Action "LOAD INTO TRANSPORTER"
2742 ***************************************************************************/
2743 void mr_menu::slot_load()
2745 unit_list_iterate(get_units_in_focus(), punit
) {
2746 qtg_request_transport(punit
, unit_tile(punit
));
2747 } unit_list_iterate_end
;
2750 /***************************************************************************
2751 Action "UNIT PATROL"
2752 ***************************************************************************/
2753 void mr_menu::slot_patrol()
2758 /***************************************************************************
2759 Action "RETURN TO NEAREST CITY"
2760 ***************************************************************************/
2761 void mr_menu::slot_return_to_city()
2763 unit_list_iterate(get_units_in_focus(), punit
) {
2764 request_unit_return(punit
);
2765 } unit_list_iterate_end
;
2768 /***************************************************************************
2769 Action "GOTO/AIRLIFT TO CITY"
2770 ***************************************************************************/
2771 void mr_menu::slot_airlift()
2773 popup_goto_dialog();
2776 /***************************************************************************
2777 Action "SET HOMECITY"
2778 ***************************************************************************/
2779 void mr_menu::slot_set_home()
2781 key_unit_homecity();
2784 /***************************************************************************
2785 Action "UNLOAD FROM TRANSPORTED"
2786 ***************************************************************************/
2787 void mr_menu::slot_unload()
2789 unit_list_iterate(get_units_in_focus(), punit
) {
2790 request_unit_unload(punit
);
2791 } unit_list_iterate_end
;
2794 /***************************************************************************
2795 Action "UNLOAD ALL UNITS FROM TRANSPORTER"
2796 ***************************************************************************/
2797 void mr_menu::slot_unload_all()
2799 key_unit_unload_all();
2802 /***************************************************************************
2803 Action "UNSENTRY(WAKEUP) ALL UNITS"
2804 ***************************************************************************/
2805 void mr_menu::slot_unsentry()
2807 key_unit_wakeup_others();
2810 /***************************************************************************
2811 Action "UPGRADE UNITS"
2812 ***************************************************************************/
2813 void mr_menu::slot_upgrade()
2815 popup_upgrade_dialog(get_units_in_focus());
2818 /****************************************************************
2820 *****************************************************************/
2821 void mr_menu::slot_unit_goto()
2826 /****************************************************************
2828 *****************************************************************/
2829 void mr_menu::slot_unit_explore()
2831 key_unit_auto_explore();
2834 /****************************************************************
2835 Action "CENTER VIEW"
2836 *****************************************************************/
2837 void mr_menu::slot_center_view()
2839 request_center_focus_unit();
2842 /****************************************************************
2843 Action "Lock interface"
2844 *****************************************************************/
2845 void mr_menu::slot_lock()
2847 if (gui()->interface_locked
) {
2848 enable_interface(false);
2850 enable_interface(true);
2852 gui()->interface_locked
= !gui()->interface_locked
;
2855 /****************************************************************
2856 Helper function to hide/show widgets
2857 *****************************************************************/
2858 void enable_interface(bool enable
)
2860 QList
<close_widget
*> lc
;
2861 QList
<move_widget
*> lm
;
2862 QList
<resize_widget
*> lr
;
2865 lc
= gui()->findChildren
<close_widget
*>();
2866 lm
= gui()->findChildren
<move_widget
*>();
2867 lr
= gui()->findChildren
<resize_widget
*>();
2869 for (i
= 0; i
< lc
.size(); ++i
) {
2870 lc
.at(i
)->setVisible(!enable
);
2872 for (i
= 0; i
< lm
.size(); ++i
) {
2873 lm
.at(i
)->setVisible(!enable
);
2875 for (i
= 0; i
< lr
.size(); ++i
) {
2876 lr
.at(i
)->setVisible(!enable
);
2880 /***************************************************************************
2881 Action "SET FULLSCREEN"
2882 ***************************************************************************/
2883 void mr_menu::slot_fullscreen()
2885 if (!gui_options
.gui_qt_fullscreen
) {
2886 gui()->showFullScreen();
2887 gui()->game_tab_widget
->showFullScreen();
2889 // FIXME Doesnt return properly, probably something with sidebar
2890 gui()->showNormal();
2891 gui()->game_tab_widget
->showNormal();
2893 gui_options
.gui_qt_fullscreen
= !gui_options
.gui_qt_fullscreen
;
2896 /****************************************************************
2897 Action "VIEW/HIDE MINIMAP"
2898 *****************************************************************/
2899 void mr_menu::slot_minimap_view()
2901 if (minimap_status
->isChecked()) {
2902 ::gui()->minimapview_wdg
->show();
2904 ::gui()->minimapview_wdg
->hide();
2908 /****************************************************************
2909 Action "Show/Dont show new turn info"
2910 *****************************************************************/
2911 void mr_menu::slot_show_new_turn_text()
2913 if (osd_status
->isChecked()) {
2914 gui()->qt_settings
.show_new_turn_text
= true;
2916 gui()->qt_settings
.show_new_turn_text
= false;
2920 /****************************************************************
2921 Action "Show/Dont battle log"
2922 *****************************************************************/
2923 void mr_menu::slot_battlelog()
2925 if (btlog_status
->isChecked()) {
2926 gui()->qt_settings
.show_battle_log
= true;
2928 gui()->qt_settings
.show_battle_log
= false;
2932 /****************************************************************
2933 Action "SHOW BORDERS"
2934 *****************************************************************/
2935 void mr_menu::slot_borders()
2937 key_map_borders_toggle();
2940 /****************************************************************
2941 Action "SHOW NATIVE TILES"
2942 *****************************************************************/
2943 void mr_menu::slot_native_tiles()
2945 key_map_native_toggle();
2948 /***************************************************************************
2949 Action "SHOW BUY COST"
2950 ***************************************************************************/
2951 void mr_menu::slot_city_buycost()
2953 key_city_buycost_toggle();
2956 /***************************************************************************
2957 Action "SHOW CITY GROWTH"
2958 ***************************************************************************/
2959 void mr_menu::slot_city_growth()
2961 key_city_growth_toggle();
2964 /***************************************************************************
2965 Action "RELOAD ZOOMED IN TILESET"
2966 ***************************************************************************/
2967 void mr_menu::zoom_in()
2969 gui()->map_scale
= gui()->map_scale
* 1.2f
;
2970 tilespec_reread(tileset_basename(tileset
), true, gui()->map_scale
);
2973 /***************************************************************************
2974 Action "RELOAD ZOOMED OUT TILESET"
2975 ***************************************************************************/
2976 void mr_menu::zoom_out()
2978 gui()->map_scale
= gui()->map_scale
/ 1.2f
;
2979 tilespec_reread(tileset_basename(tileset
), true, gui()->map_scale
);
2982 /***************************************************************************
2983 Action "SHOW CITY NAMES"
2984 ***************************************************************************/
2985 void mr_menu::slot_city_names()
2987 key_city_names_toggle();
2990 /***************************************************************************
2991 Action "SHOW CITY OUTLINES"
2992 ***************************************************************************/
2993 void mr_menu::slot_city_outlines()
2995 key_city_outlines_toggle();
2998 /***************************************************************************
2999 Action "SHOW CITY OUTPUT"
3000 ***************************************************************************/
3001 void mr_menu::slot_city_output()
3003 key_city_output_toggle();
3006 /***************************************************************************
3007 Action "SHOW CITY PRODUCTION"
3008 ***************************************************************************/
3009 void mr_menu::slot_city_production()
3011 key_city_productions_toggle();
3014 /***************************************************************************
3015 Action "SHOW CITY TRADEROUTES"
3016 ***************************************************************************/
3017 void mr_menu::slot_city_traderoutes()
3019 key_city_trade_routes_toggle();
3022 /***************************************************************************
3023 Action "SHOW FULLBAR"
3024 ***************************************************************************/
3025 void mr_menu::slot_fullbar()
3027 key_city_full_bar_toggle();
3030 /***************************************************************************
3031 Action "SHOW MAP GRID"
3032 ***************************************************************************/
3033 void mr_menu::slot_map_grid()
3035 key_map_grid_toggle();
3038 /***************************************************************************
3039 Action "DONE MOVING"
3040 ***************************************************************************/
3041 void mr_menu::slot_done_moving()
3046 /***************************************************************************
3047 Action "SELECT ALL UNITS ON TILE"
3048 ***************************************************************************/
3049 void mr_menu::slot_select_all_tile()
3051 request_unit_select(get_units_in_focus(), SELTYPE_ALL
, SELLOC_TILE
);
3054 /***************************************************************************
3055 Action "SELECT ONE UNITS/DESELECT OTHERS"
3056 ***************************************************************************/
3057 void mr_menu::slot_select_one()
3059 request_unit_select(get_units_in_focus(), SELTYPE_SINGLE
, SELLOC_TILE
);
3062 /***************************************************************************
3063 Action "SELLECT SAME UNITS ON CONTINENT"
3064 ***************************************************************************/
3065 void mr_menu::slot_select_same_continent()
3067 request_unit_select(get_units_in_focus(), SELTYPE_SAME
, SELLOC_CONT
);
3070 /***************************************************************************
3071 Action "SELECT SAME TYPE EVERYWHERE"
3072 ***************************************************************************/
3073 void mr_menu::slot_select_same_everywhere()
3075 request_unit_select(get_units_in_focus(), SELTYPE_SAME
, SELLOC_WORLD
);
3078 /***************************************************************************
3079 Action "SELECT SAME TYPE ON TILE"
3080 ***************************************************************************/
3081 void mr_menu::slot_select_same_tile()
3083 request_unit_select(get_units_in_focus(), SELTYPE_SAME
, SELLOC_TILE
);
3087 /***************************************************************************
3089 ***************************************************************************/
3090 void mr_menu::slot_wait()
3095 /***************************************************************************
3097 ***************************************************************************/
3098 void mr_menu::slot_unit_filter()
3100 unit_hud_selector
*uhs
;
3101 uhs
= new unit_hud_selector(gui()->central_wdg
);
3106 /****************************************************************
3107 Action "SHOW DEMOGRAPGHICS REPORT"
3108 *****************************************************************/
3109 void mr_menu::slot_demographics()
3111 send_report_request(REPORT_DEMOGRAPHIC
);
3114 /****************************************************************
3115 Action "SHOW ACHIEVEMENTS REPORT"
3116 *****************************************************************/
3117 void mr_menu::slot_achievements()
3119 send_report_request(REPORT_ACHIEVEMENTS
);
3122 /****************************************************************
3123 Action "SHOW ENDGAME REPORT"
3124 *****************************************************************/
3125 void mr_menu::slot_endgame()
3127 popup_endgame_report();
3131 /****************************************************************
3132 Action "SHOW TOP FIVE CITIES"
3133 *****************************************************************/
3134 void mr_menu::slot_top_five()
3136 send_report_request(REPORT_TOP_5_CITIES
);
3139 /****************************************************************
3140 Action "SHOW WONDERS REPORT"
3141 *****************************************************************/
3142 void mr_menu::slot_traveler()
3144 send_report_request(REPORT_WONDERS_OF_THE_WORLD
);
3147 /****************************************************************
3148 Shows rulesets to load
3149 *****************************************************************/
3150 void mr_menu::tileset_custom_load()
3152 QDialog
*dialog
= new QDialog(this);
3155 QVBoxLayout
*layout
;
3156 const struct strvec
*tlset_list
;
3157 const struct option
*poption
;
3161 sl
<< "default_tileset_overhead_name" << "default_tileset_iso_name"
3162 << "default_tileset_hex_name" << "default_tileset_isohex_name";
3163 layout
= new QVBoxLayout
;
3164 dialog
->setWindowTitle(_("Available tilesets"));
3166 label
->setText(_("Some tilesets might be not compatible with current"
3168 layout
->addWidget(label
);
3171 poption
= optset_option_by_name(client_optset
, s
.toLocal8Bit().data());
3172 tlset_list
= get_tileset_list(poption
);
3173 strvec_iterate(tlset_list
, value
) {
3174 but
= new QPushButton(value
);
3175 connect(but
, SIGNAL(clicked()), this, SLOT(load_new_tileset()));
3176 layout
->addWidget(but
);
3177 } strvec_iterate_end
;
3179 dialog
->setSizeGripEnabled(true);
3180 dialog
->setLayout(layout
);
3184 /****************************************************************
3185 Slot for loading new tileset
3186 *****************************************************************/
3187 void mr_menu::load_new_tileset()
3191 but
= qobject_cast
<QPushButton
*>(sender());
3192 tilespec_reread(but
->text().toLocal8Bit().data(), true, 1.0f
);
3193 gui()->map_scale
= 1.0f
;
3194 but
->parentWidget()->close();
3197 /****************************************************************
3198 Action "Calculate trade routes"
3199 *****************************************************************/
3200 void mr_menu::calc_trade_routes()
3202 gui()->trade_gen
.calculate();
3205 /****************************************************************
3207 *****************************************************************/
3208 void mr_menu::slot_popup_tax_rates()
3210 popup_rates_dialog();
3213 /****************************************************************
3214 Action "MULTIPLERS RATES"
3215 *****************************************************************/
3216 void mr_menu::slot_popup_mult_rates()
3218 popup_multiplier_dialog();
3221 /****************************************************************
3223 *****************************************************************/
3224 void mr_menu::slot_help(const QString
&topic
)
3226 popup_help_dialog_typed(Q_(topic
.toStdString().c_str()), HELP_ANY
);
3229 /****************************************************************
3230 Invoke dialog with local options
3231 *****************************************************************/
3232 void mr_menu::local_options()
3234 gui()->popup_client_options();
3237 /****************************************************************
3238 Invoke dialog with shortcut options
3239 *****************************************************************/
3240 void mr_menu::shortcut_options()
3242 popup_shortcuts_dialog();
3246 /****************************************************************
3247 Invoke dialog with server options
3248 *****************************************************************/
3249 void mr_menu::server_options()
3251 gui()->pr_options
->popup_server_options();
3254 /****************************************************************
3255 Invoke dialog with server options
3256 *****************************************************************/
3257 void mr_menu::messages_options()
3259 popup_messageopt_dialog();
3262 /****************************************************************
3263 Menu Save Options Now
3264 *****************************************************************/
3265 void mr_menu::save_options_now()
3270 /***************************************************************************
3271 Invoke popup for quiting game
3272 ***************************************************************************/
3273 void mr_menu::quit_game()
3275 popup_quit_dialog();
3278 /***************************************************************************
3280 ***************************************************************************/
3281 void mr_menu::save_image()
3283 int current_width
, current_height
;
3284 int full_size_x
, full_size_y
;
3285 QString path
, storage_path
;
3286 hud_message_box
saved(gui()->central_wdg
);
3290 full_size_x
= (wld
.map
.xsize
+ 2) * tileset_tile_width(tileset
);
3291 full_size_y
= (wld
.map
.ysize
+ 2) * tileset_tile_height(tileset
);
3292 current_width
= gui()->mapview_wdg
->width();
3293 current_height
= gui()->mapview_wdg
->height();
3294 if (tileset_hex_width(tileset
) > 0) {
3295 full_size_y
= full_size_y
* 11 / 20;
3296 } else if (tileset_is_isometric(tileset
)) {
3297 full_size_y
= full_size_y
/ 2;
3299 map_canvas_resized(full_size_x
, full_size_y
);
3300 img_name
= QString("FreeCiv-Turn%1").arg(game
.info
.turn
);
3301 if (client_has_player() == true) {
3302 img_name
= img_name
+ "-"
3303 + QString(nation_plural_for_player(client_player()));
3305 storage_path
= freeciv_storage_dir();
3306 path
= QStandardPaths::writableLocation(QStandardPaths::PicturesLocation
);
3307 if (storage_path
.isEmpty() == false && QDir(storage_path
).isReadable()) {
3308 img_name
= storage_path
+ DIR_SEPARATOR
+ img_name
;
3309 } else if (path
.isEmpty() == false) {
3310 img_name
= path
+ DIR_SEPARATOR
+ img_name
;
3312 img_name
= QStandardPaths::writableLocation(QStandardPaths::HomeLocation
)
3313 + DIR_SEPARATOR
+ img_name
;
3315 map_saved
= mapview
.store
->map_pixmap
.save(img_name
, "png");
3316 map_canvas_resized(current_width
, current_height
);
3317 saved
.setStandardButtons(QMessageBox::Ok
);
3318 saved
.setDefaultButton(QMessageBox::Cancel
);
3320 saved
.set_text_title("Image saved as:\n" + img_name
, _("Succeess"));
3322 saved
.set_text_title(_("Failed to save image of the map"), _("Error"));
3327 /***************************************************************************
3329 ***************************************************************************/
3330 void mr_menu::save_game()
3332 send_save_game(NULL
);
3335 /***************************************************************************
3336 Menu Save Game As...
3337 ***************************************************************************/
3338 void mr_menu::save_game_as()
3341 QString current_file
;
3344 strvec_iterate(get_save_dirs(), dirname
) {
3346 // choose last location
3347 } strvec_iterate_end
;
3349 str
= QString(_("Save Games"))
3350 + QString(" (*.sav *.sav.bz2 *.sav.gz *.sav.xz)");
3351 current_file
= QFileDialog::getSaveFileName(gui()->central_wdg
,
3352 _("Save Game As..."),
3354 if (current_file
.isEmpty() == false) {
3355 send_save_game(current_file
.toLocal8Bit().data());
3359 /***************************************************************************
3361 ***************************************************************************/
3362 void mr_menu::back_to_menu()
3364 hud_message_box
ask(gui()->central_wdg
);
3367 if (is_server_running()) {
3368 ask
.set_text_title(_("Leaving a local game will end it!"), "Leave game");
3369 ask
.setStandardButtons(QMessageBox::Cancel
| QMessageBox::Ok
);
3370 ask
.setDefaultButton(QMessageBox::Cancel
);
3374 case QMessageBox::Cancel
:
3376 case QMessageBox::Ok
:
3377 if (client
.conn
.used
) {
3378 disconnect_from_server();
3383 disconnect_from_server();
3387 /***************************************************************************
3388 Airlift unit type to city acity from each city
3389 ***************************************************************************/
3390 void multiairlift(struct city
*acity
, Unit_type_id ut
)
3393 city_list_iterate(client
.conn
.playing
->cities
, pcity
) {
3394 if (get_city_bonus(pcity
, EFT_AIRLIFT
) > 0) {
3395 ptile
= city_tile(pcity
);
3396 unit_list_iterate(ptile
->units
, punit
) {
3397 if (punit
->utype
== utype_by_number(ut
)) {
3398 request_unit_airlift(punit
, acity
);
3401 } unit_list_iterate_end
;
3403 } city_list_iterate_end
;