Freeciv21
Develop your civilization from humble roots to a global empire
menu.cpp
Go to the documentation of this file.
1 /*
2  Copyright (c) 1996-2023 Freeciv21 and Freeciv contributors. This file is
3  part of Freeciv21. Freeciv21 is free software: you can redistribute it
4  and/or modify it under the terms of the GNU General Public License as
5  published by the Free Software Foundation, either version 3 of the
6  License, or (at your option) any later version. You should have received
7  a copy of the GNU General Public License along with Freeciv21. If not,
8  see https://www.gnu.org/licenses/.
9  */
10 
11 #include "menu.h"
12 
13 // Qt
14 #include <QActionGroup>
15 #include <QApplication>
16 #include <QFileDialog>
17 #include <QMainWindow>
18 #include <QMenuBar>
19 #include <QMessageBox>
20 #include <QStandardPaths>
21 #include <QVBoxLayout>
22 
23 // utility
24 #include "fcintl.h"
25 // common
26 #include "fc_types.h"
27 #include "game.h"
28 #include "goto.h"
29 #include "government.h"
30 #include "helpdata.h"
31 #include "map.h"
32 #include "multipliers.h"
33 #include "road.h"
34 #include "tileset_options.h"
35 #include "unit.h"
36 // client
37 #include "audio/audio.h"
38 #include "citybar.h"
39 #include "cityrep_g.h"
40 #include "client_main.h"
41 #include "climisc.h"
42 #include "clinet.h"
43 #include "connectdlg_common.h"
44 #include "control.h"
45 #include "dialogs.h"
46 #include "fc_client.h"
47 #include "gotodlg.h"
48 #include "gui_main.h"
49 #include "helpdlg.h"
50 #include "hudwidget.h"
51 #include "mapctrl_g.h"
52 #include "messageoptions.h"
53 #include "messagewin.h"
54 #include "minimap.h"
55 #include "minimap_panel.h"
56 #include "page_game.h"
57 #include "page_pregame.h"
58 #include "qtg_cxxside.h"
59 #include "ratesdlg.h"
60 #include "ratesdlg_g.h"
61 #include "renderer.h"
62 #include "repodlgs_g.h"
63 #include "shortcuts.h"
64 #include "spaceshipdlg.h"
65 #include "tileset/sprite.h"
66 #include "tileset/tilespec.h"
67 #include "top_bar.h"
68 #include "unithudselector.h"
69 #include "views/view_map.h"
70 #include "views/view_map_common.h"
71 #include "views/view_nations.h"
72 #include "views/view_units.h"
73 
74 extern void popup_endgame_report();
75 static void enable_interface(bool enable);
76 
77 void option_dialog_popup(const char *name, const struct option_set *poptset);
78 
83 void real_menus_init(void)
84 {
85  if (!game.client.ruleset_ready) {
86  return;
87  }
88 
90 
92 
93  // A new ruleset may have been loaded.
95 }
96 
102 {
103  if (C_S_RUNNING <= client_state()) {
104  king()->menuBar()->setVisible(true);
105  if (!is_waiting_turn_change()) {
113  }
114  } else {
115  king()->menuBar()->setVisible(false);
116  }
117 }
118 
124 static const char *get_tile_change_menu_text(struct tile *ptile,
125  enum unit_activity activity)
126 {
127  struct tile *newtile = tile_virtual_new(ptile);
128  const char *text;
129 
130  tile_apply_activity(newtile, activity, nullptr);
131  text = tile_get_info_text(newtile, false, 0);
132  tile_virtual_destroy(newtile);
133 
134  return text;
135 }
136 
140 gov_menu::gov_menu(QWidget *parent) : QMenu(_("Government"), parent)
141 {
142  // Register ourselves to get updates for free.
143  instances << this;
144  setAttribute(Qt::WA_TranslucentBackground);
145 }
146 
151 {
152  qDeleteAll(actions);
153  instances.remove(this);
154 }
155 
160 {
161  QAction *action;
162  struct government *gov, *revol_gov;
163  int gov_count, i;
164 
165  // Clear any content
166  for (auto *action : qAsConst(actions)) {
167  removeAction(action);
168  action->deleteLater();
169  }
170  actions.clear();
171 
172  gov_count = government_count();
173  actions.reserve(gov_count + 1);
174  action = addAction(_("Revolution..."));
175  connect(action, &QAction::triggered, this, &gov_menu::revolution);
176  actions.append(action);
177 
178  addSeparator();
179 
180  // Add an action for each government. There is no icon yet.
182  for (i = 0; i < gov_count; ++i) {
183  gov = government_by_number(i);
184  if (gov != revol_gov) { // Skip revolution goverment
185  // Defeat keyboard shortcut mnemonics
186  action = addAction(QString(government_name_translation(gov)));
187  // We need to keep track of the gov <-> action mapping to be able to
188  // set enabled/disabled depending on available govs.
189  actions.append(action);
190  QObject::connect(action, &QAction::triggered,
191  [this, i]() { change_gov(i); });
192  }
193  }
194 }
195 
200 {
201  struct government *gov, *revol_gov;
202 
204  for (int i = 0, j = 0; i < actions.count(); ++i) {
205  gov = government_by_number(i);
206  if (gov != revol_gov) { // Skip revolution goverment
207  auto sprite = get_government_sprite(tileset, gov);
208  if (sprite != nullptr) {
209  actions[j + 1]->setIcon(QIcon(*sprite));
210  }
211  actions[j + 1]->setEnabled(
213  ++j;
214  } else {
215  actions[0]->setEnabled(!client_is_observer());
216  }
217  }
218 }
219 
224 {
226 }
227 
231 void gov_menu::change_gov(int target_gov)
232 {
234 }
235 
239 QSet<gov_menu *> gov_menu::instances = QSet<gov_menu *>();
240 
245 {
246  for (gov_menu *m : qAsConst(instances)) {
247  m->create();
248  }
249 }
250 
255 {
256  for (gov_menu *m : qAsConst(instances)) {
257  m->update();
258  }
259 }
260 
264 go_act_menu::go_act_menu(QWidget *parent) : QMenu(_("Goto And..."), parent)
265 {
266  // Will need auto updates etc.
267  instances << this;
268 }
269 
274 {
275  // Updates are no longer needed.
276  instances.remove(this);
277 }
278 
282 static void reset_menu_and_sub_menues(QMenu *menu)
283 {
284  QList<QAction *> actions = menu->actions();
285  // Delete each existing menu item.
286  for (auto *action : qAsConst(actions)) {
287  if (action->menu() != nullptr) {
288  // Delete the sub menu
290  action->menu()->deleteLater();
291  }
292 
293  menu->removeAction(action);
294  action->deleteLater();
295  }
296 }
297 
302 {
303  // Clear menu item to action ID mapping.
304  items.clear();
305 
306  // Remove the menu items
308 }
309 
314 {
315  QAction *item;
316  int tgt_kind_group;
317 
318  // Group goto and perform action menu items by target kind.
319  for (tgt_kind_group = 0; tgt_kind_group < ATK_COUNT; tgt_kind_group++) {
320  action_iterate(act_id)
321  {
322  struct action *paction = action_by_number(act_id);
323  QString action_name = (QString(action_name_translation(paction)));
324 
325  if (action_id_get_actor_kind(act_id) != AAK_UNIT) {
326  // This action isn't performed by a unit.
327  continue;
328  }
329 
330  if (action_id_get_target_kind(act_id) != tgt_kind_group) {
331  // Wrong group.
332  continue;
333  }
334 
335  if (action_id_has_complex_target(act_id)) {
336  QMenu *sub_target_menu = addMenu(action_name);
337  items.insert(sub_target_menu->menuAction(), act_id);
338 
339 #define CREATE_SUB_ITEM(_menu_, _act_id_, _sub_tgt_id_, _sub_tgt_name_) \
340  { \
341  QAction *_sub_item_ = _menu_->addAction(_sub_tgt_name_); \
342  int _sub_target_id_ = _sub_tgt_id_; \
343  QObject::connect(_sub_item_, &QAction::triggered, \
344  [this, _act_id_, _sub_target_id_]() { \
345  start_go_act(_act_id_, _sub_target_id_); \
346  }); \
347  }
348 
349  switch (action_get_sub_target_kind(paction)) {
350  case ASTK_BUILDING:
351  improvement_iterate(pimpr)
352  {
353  CREATE_SUB_ITEM(sub_target_menu, act_id,
354  improvement_number(pimpr),
356  }
358  break;
359  case ASTK_TECH:
360  advance_iterate(A_FIRST, ptech)
361  {
362  CREATE_SUB_ITEM(sub_target_menu, act_id, advance_number(ptech),
363  advance_name_translation(ptech));
364  }
366  break;
367  case ASTK_EXTRA:
368  case ASTK_EXTRA_NOT_THERE:
369  extra_type_iterate(pextra)
370  {
371  if (!(action_creates_extra(paction, pextra)
372  || action_removes_extra(paction, pextra))) {
373  // Not relevant
374  continue;
375  }
376 
377  CREATE_SUB_ITEM(sub_target_menu, act_id, extra_number(pextra),
378  extra_name_translation(pextra));
379  }
381  break;
382  case ASTK_NONE:
383  // Should not be here.
384  fc_assert(action_get_sub_target_kind(paction) != ASTK_NONE);
385  break;
386  case ASTK_COUNT:
387  // Should not exits
388  fc_assert(action_get_sub_target_kind(paction) != ASTK_COUNT);
389  break;
390  }
391  continue;
392  }
393 
394 #define ADD_OLD_SHORTCUT(wanted_action_id, sc_id) \
395  if (act_id == wanted_action_id) { \
396  fc_shortcuts::sc()->link_action(sc_id, item); \
397  }
398 
399  /* Create and add the menu item. It will be hidden or shown based on
400  * unit type. */
401  item = addAction(action_name);
402  items.insert(item, act_id);
403 
404  /* Add the keyboard shortcuts for "Go to and..." menu items that
405  * existed independently before the "Go to and..." menu arrived. */
406  ADD_OLD_SHORTCUT(ACTION_FOUND_CITY, SC_GOBUILDCITY);
407  ADD_OLD_SHORTCUT(ACTION_JOIN_CITY, SC_GOJOINCITY);
408  ADD_OLD_SHORTCUT(ACTION_NUKE, SC_NUKE);
409 
410  QObject::connect(item, &QAction::triggered, [this, act_id]() {
411  start_go_act(act_id, NO_TARGET);
412  });
413  }
415  }
416 }
417 
422 {
423  bool can_do_something = false;
424 
425  if (!actions_are_ready()) {
426  // Nothing to do.
427  return;
428  }
429 
430  if (items.isEmpty()) {
431  // The goto and act menu needs menu items.
432  create();
433  }
434 
435  /* Enable a menu item if it is theoretically possible that one of the
436  * selected units can perform it. Checking if the action can be performed
437  * at the current tile is pointless since it should be performed at the
438  * target tile. */
439  QList<QAction *> keys = items.keys();
440  for (QAction *item : qAsConst(keys)) {
441  if (units_can_do_action(get_units_in_focus(), items.value(item), true)) {
442  item->setVisible(true);
443  can_do_something = true;
444  } else {
445  item->setVisible(false);
446  }
447  }
448 
449  if (can_do_something) {
450  // At least one menu item is enabled for one of the selected units.
451  setEnabled(true);
452  } else {
453  // No menu item is enabled any of the selected units.
454  setEnabled(false);
455  }
456 }
457 
461 void go_act_menu::start_go_act(int act_id, int sub_tgt_id)
462 {
463  request_unit_goto(ORDER_PERFORM_ACTION, act_id, sub_tgt_id);
464 }
465 
469 QSet<go_act_menu *> go_act_menu::instances;
470 
475 {
476  for (go_act_menu *m : qAsConst(instances)) {
477  m->reset();
478  }
479 }
480 
485 {
486  for (go_act_menu *m : qAsConst(instances)) {
487  m->update();
488  }
489 }
490 
494 struct tile *mr_menu::find_last_unit_pos(unit *punit, int pos)
495 {
496  struct tile *ptile = nullptr;
497  struct unit *zunit;
498  struct unit *qunit;
499 
500  int i = 0;
501  qunit = punit;
502  for (const auto &fui : units_list) {
503  zunit = unit_list_find(client_player()->units, fui.id);
504  i++;
505  if (i >= pos) {
506  punit = qunit;
507  return ptile;
508  }
509  if (zunit == nullptr) {
510  continue;
511  }
512 
513  if (punit == zunit) { // Unit found
514  /* Unit was ordered to attack city so it might stay in
515  front of that city */
516  if (is_non_allied_city_tile(fui.ptile, unit_owner(punit))) {
517  ptile = tile_before_end_path(punit, fui.ptile);
518  if (ptile == nullptr) {
519  ptile = fui.ptile;
520  }
521  } else {
522  ptile = fui.ptile;
523  }
524  // unit found in tranporter
525  } else if (unit_contained_in(punit, zunit)) {
526  ptile = fui.ptile;
527  }
528  }
529  return nullptr;
530 }
531 
535 mr_menu::mr_menu() : QMenuBar() {}
536 
543 {
544  clear_menus();
545 
546  QAction *act;
547  QList<QMenu *> menus;
548  int i;
549 
550  delayed_order = false;
551  airlift_type_id = 0;
552  quick_airlifting = false;
553 
554  auto shortcuts = fc_shortcuts::sc();
555 
556  // Game Menu
557  menu = this->addMenu(_("Game"));
558  act = menu->addAction(_("Save Game"));
559  act->setShortcut(QKeySequence(tr("Ctrl+s")));
560  act->setIcon(style()->standardIcon(QStyle::SP_DialogSaveButton));
561  menu_list.insert(SAVE, act);
562  connect(act, &QAction::triggered, this, &mr_menu::save_game);
563  act = menu->addAction(_("Save Game As..."));
564  menu_list.insert(SAVE, act);
565  act->setIcon(style()->standardIcon(QStyle::SP_DialogSaveButton));
566  connect(act, &QAction::triggered, this, &mr_menu::save_game_as);
567  act = menu->addAction(_("Save Map to Image"));
568  connect(act, &QAction::triggered, this, &mr_menu::save_image);
569  menu->addSeparator();
570 
571  act = menu->addAction(_("Interface Options"));
572  connect(act, &QAction::triggered, this, &mr_menu::local_options);
573  act = menu->addAction(_("Game Options"));
574  connect(act, &QAction::triggered, this, &mr_menu::server_options);
575  act = menu->addAction(_("Message Options"));
576  connect(act, &QAction::triggered, this, &mr_menu::messages_options);
577  act = menu->addAction(_("Shortcut Options"));
578  connect(act, &QAction::triggered, this, &mr_menu::shortcut_options);
579  act = menu->addAction(_("Load Another Tileset"));
580  connect(act, &QAction::triggered, this, &mr_menu::tileset_custom_load);
581  act = menu->addAction(_("Add Modpacks"));
582  connect(act, &QAction::triggered, this, &mr_menu::add_modpacks);
583  tileset_options = menu->addAction(_("Tileset Options"));
584  connect(tileset_options, &QAction::triggered, this,
587  act = menu->addAction(_("Tileset Debugger"));
588  connect(act, &QAction::triggered, queen()->mapview_wdg,
590  act = menu->addAction(_("Save Options Now"));
591  act->setIcon(style()->standardIcon(QStyle::SP_DialogSaveButton));
592  connect(act, &QAction::triggered, this, &mr_menu::save_options_now);
593  act = menu->addAction(_("Save Options on Exit"));
594  act->setCheckable(true);
595  act->setChecked(gui_options->save_options_on_exit);
596  menu->addSeparator();
597 
598  act = menu->addAction(_("Leave Game"));
599  act->setIcon(style()->standardIcon(QStyle::SP_DialogDiscardButton));
600  connect(act, &QAction::triggered, this, &mr_menu::back_to_menu);
601  act = menu->addAction(_("Quit"));
602  act->setIcon(style()->standardIcon(QStyle::SP_TitleBarCloseButton));
603  connect(act, &QAction::triggered, this, &mr_menu::quit_game);
604 
605  // View Menu
606  menu = this->addMenu(Q_("?verb:View"));
607  act = menu->addAction(_("Center View"));
608  shortcuts->link_action(SC_CENTER_VIEW, act);
609  connect(act, &QAction::triggered, this, &mr_menu::slot_center_view);
610  menu->addSeparator();
611  act = menu->addAction(_("Fullscreen"));
612  shortcuts->link_action(SC_FULLSCREEN, act);
613  act->setCheckable(true);
614  act->setChecked(gui_options->gui_qt_fullscreen);
615  connect(act, &QAction::triggered, this, &mr_menu::slot_fullscreen);
616  menu->addSeparator();
617  minimap_status = menu->addAction(_("Minimap"));
618  minimap_status->setCheckable(true);
619  shortcuts->link_action(SC_MINIMAP, minimap_status);
620  minimap_status->setChecked(true);
621  connect(minimap_status, &QAction::triggered, queen()->minimap_panel,
623  osd_status = menu->addAction(_("Show New Turn Information"));
624  osd_status->setCheckable(true);
625  osd_status->setChecked(king()->qt_settings.show_new_turn_text);
626  connect(osd_status, &QAction::triggered, this,
628  btlog_status = menu->addAction(_("Show Combat Detailed Information"));
629  btlog_status->setCheckable(true);
630  btlog_status->setChecked(king()->qt_settings.show_battle_log);
631  connect(btlog_status, &QAction::triggered, this, &mr_menu::slot_battlelog);
632  lock_status = menu->addAction(_("Lock Interface"));
633  lock_status->setCheckable(true);
634  shortcuts->link_action(SC_IFACE_LOCK, lock_status);
635  lock_status->setChecked(false);
636  connect(lock_status, &QAction::triggered, this, &mr_menu::slot_lock);
637  menu->addSeparator();
638  act = menu->addAction(_("Zoom In"));
639  shortcuts->link_action(SC_ZOOM_IN, act);
640  connect(act, &QAction::triggered, queen()->mapview_wdg,
642  act = menu->addAction(_("Zoom Default"));
643  shortcuts->link_action(SC_ZOOM_RESET, act);
644  connect(act, &QAction::triggered, queen()->mapview_wdg,
646  act = menu->addAction(_("Zoom Out"));
647  shortcuts->link_action(SC_ZOOM_OUT, act);
648  connect(act, &QAction::triggered, queen()->mapview_wdg,
650  scale_fonts_status = menu->addAction(_("Scale Fonts"));
651  connect(scale_fonts_status, &QAction::triggered, this,
653  scale_fonts_status->setCheckable(true);
654  scale_fonts_status->setChecked(true);
655  menu->addSeparator();
656  action_citybar = new QActionGroup(this);
657  citybar_submenu = menu->addMenu(_("City Bar Style"));
658 
659  for (auto a : *citybar_painter::available_vector(nullptr)) {
660  act = citybar_submenu->addAction(a);
661  act->setCheckable(true);
662  act->setData(a);
663  action_citybar->addAction(act);
664  if (a == QString(gui_options->default_city_bar_style_name)) {
665  act->setChecked(true);
666  }
667  connect(act, &QAction::triggered, this, &mr_menu::slot_set_citybar);
668  }
669 
670  act = menu->addAction(_("City Outlines"));
671  act->setCheckable(true);
672  act->setChecked(gui_options->draw_city_outlines);
673  connect(act, &QAction::triggered, this, &mr_menu::slot_city_outlines);
674  act = menu->addAction(_("City Output"));
675  act->setCheckable(true);
676  act->setChecked(gui_options->draw_city_output);
677  shortcuts->link_action(SC_CITY_OUTPUT, act);
678  connect(act, &QAction::triggered, this, &mr_menu::slot_city_output);
679  act = menu->addAction(_("Map Grid"));
680  shortcuts->link_action(SC_MAP_GRID, act);
681  act->setCheckable(true);
682  act->setChecked(gui_options->draw_map_grid);
683  connect(act, &QAction::triggered, this, &mr_menu::slot_map_grid);
684  act = menu->addAction(_("National Borders"));
685  act->setCheckable(true);
686  act->setChecked(gui_options->draw_borders);
687  shortcuts->link_action(SC_NAT_BORDERS, act);
688  connect(act, &QAction::triggered, this, &mr_menu::slot_borders);
689  act = menu->addAction(_("Units"));
690  act->setCheckable(true);
691  act->setChecked(gui_options->draw_units);
692  connect(act, &QAction::toggled, this, [](bool checked) {
693  gui_options->draw_units = checked;
695  });
696  act = menu->addAction(_("Native Tiles"));
697  act->setCheckable(true);
698  act->setChecked(gui_options->draw_native);
699  act->setShortcut(QKeySequence(tr("ctrl+shift+n")));
700  connect(act, &QAction::triggered, this, &mr_menu::slot_native_tiles);
701  act = menu->addAction(_("City Names"));
702  act->setCheckable(true);
703  act->setChecked(gui_options->draw_city_names);
704  shortcuts->link_action(SC_CITY_NAMES, act);
705  connect(act, &QAction::triggered, this, &mr_menu::slot_city_names);
706  act = menu->addAction(_("City Growth"));
707  act->setCheckable(true);
708  act->setChecked(gui_options->draw_city_growth);
709  act->setShortcut(QKeySequence(tr("ctrl+o")));
710  connect(act, &QAction::triggered, this, &mr_menu::slot_city_growth);
711  act = menu->addAction(_("City Production Levels"));
712  act->setCheckable(true);
713  act->setChecked(gui_options->draw_city_productions);
714  shortcuts->link_action(SC_CITY_PROD, act);
715  connect(act, &QAction::triggered, this, &mr_menu::slot_city_production);
716  act = menu->addAction(_("City Buy Cost"));
717  act->setCheckable(true);
718  act->setChecked(gui_options->draw_city_buycost);
719  connect(act, &QAction::triggered, this, &mr_menu::slot_city_buycost);
720  act = menu->addAction(_("City Traderoutes"));
721  act->setCheckable(true);
722  act->setChecked(gui_options->draw_city_trade_routes);
723  shortcuts->link_action(SC_TRADE_ROUTES, act);
724  connect(act, &QAction::triggered, this, &mr_menu::slot_city_traderoutes);
725 
726  // Select Menu
727  menu = this->addMenu(_("Select"));
728  act = menu->addAction(_("Single Unit (Unselect Others)"));
729  act->setShortcut(QKeySequence(tr("shift+z")));
730  menu_list.insert(STANDARD, act);
731  connect(act, &QAction::triggered, this, &mr_menu::slot_select_one);
732  act = menu->addAction(_("All on Tile"));
733  act->setShortcut(QKeySequence(tr("v")));
734  menu_list.insert(STANDARD, act);
735  connect(act, &QAction::triggered, this, &mr_menu::slot_select_all_tile);
736  menu->addSeparator();
737  act = menu->addAction(_("Same Type on Tile"));
738  act->setShortcut(QKeySequence(tr("shift+v")));
739  menu_list.insert(STANDARD, act);
740  connect(act, &QAction::triggered, this, &mr_menu::slot_select_same_tile);
741  act = menu->addAction(_("Same Type on Continent"));
742  act->setShortcut(QKeySequence(tr("shift+c")));
743  menu_list.insert(STANDARD, act);
744  connect(act, &QAction::triggered, this,
746  act = menu->addAction(_("Same Type Everywhere"));
747  act->setShortcut(QKeySequence(tr("shift+x")));
748  menu_list.insert(STANDARD, act);
749  connect(act, &QAction::triggered, this,
751  menu->addSeparator();
752  act = menu->addAction(_("Wait"));
753  shortcuts->link_action(SC_WAIT, act);
754  menu_list.insert(STANDARD, act);
755  connect(act, &QAction::triggered, this, &mr_menu::slot_wait);
756  act = menu->addAction(_("Done"));
757  shortcuts->link_action(SC_DONE_MOVING, act);
758  menu_list.insert(STANDARD, act);
759  connect(act, &QAction::triggered, this, &mr_menu::slot_done_moving);
760 
761  act = menu->addAction(_("Advanced Unit Selection"));
762  act->setShortcut(QKeySequence(tr("ctrl+e")));
763  menu_list.insert(NOT_4_OBS, act);
764  connect(act, &QAction::triggered, this, &mr_menu::slot_unit_filter);
765 
766  // Unit Menu
767  menu = this->addMenu(_("Unit"));
768  act = menu->addAction(_("Go to Tile"));
769  shortcuts->link_action(SC_GOTO, act);
770  menu_list.insert(STANDARD, act);
771  connect(act, &QAction::triggered, this, &mr_menu::slot_unit_goto);
772 
773  // The goto and act sub menu is handled as a separate object.
774  menu->addMenu(new go_act_menu());
775 
776  act = menu->addAction(_("Go to Nearest City"));
777  act->setShortcut(QKeySequence(tr("shift+g")));
778  menu_list.insert(GOTO_CITY, act);
779  connect(act, &QAction::triggered, this, &request_units_return);
780  act = menu->addAction(_("Go to / Airlift to City..."));
781  shortcuts->link_action(SC_GOTOAIRLIFT, act);
782  menu_list.insert(AIRLIFT, act);
783  connect(act, &QAction::triggered, this, &mr_menu::slot_airlift);
784  menu->addSeparator();
785  act = menu->addAction(_("Auto Explore"));
786  menu_list.insert(EXPLORE, act);
787  shortcuts->link_action(SC_AUTOEXPLORE, act);
788  connect(act, &QAction::triggered, this, &mr_menu::slot_unit_explore);
789  act = menu->addAction(_("Patrol"));
790  menu_list.insert(STANDARD, act);
791  act->setEnabled(false);
792  shortcuts->link_action(SC_PATROL, act);
793  connect(act, &QAction::triggered, this, &mr_menu::slot_patrol);
794  menu->addSeparator();
795  act = menu->addAction(_("Sentry"));
796  shortcuts->link_action(SC_SENTRY, act);
797  menu_list.insert(SENTRY, act);
798  connect(act, &QAction::triggered, this, &mr_menu::slot_unit_sentry);
799  act = menu->addAction(_("Unsentry All on Tile"));
800  shortcuts->link_action(SC_UNSENTRY_TILE, act);
801  menu_list.insert(WAKEUP, act);
802  connect(act, &QAction::triggered, this, &mr_menu::slot_unsentry);
803  menu->addSeparator();
804  act = menu->addAction(_("Load"));
805  shortcuts->link_action(SC_LOAD, act);
806  menu_list.insert(LOAD, act);
807  connect(act, &QAction::triggered, this, &mr_menu::slot_load);
808  act = menu->addAction(_("Unload"));
809  shortcuts->link_action(SC_UNLOAD, act);
810  menu_list.insert(UNLOAD, act);
811  connect(act, &QAction::triggered, this, &mr_menu::slot_unload);
812  act = menu->addAction(_("Unload All From Transporter"));
813  act->setShortcut(QKeySequence(tr("shift+u")));
814  menu_list.insert(TRANSPORTER, act);
815  connect(act, &QAction::triggered, this, &mr_menu::slot_unload_all);
816  menu->addSeparator();
817  // Defeat keyboard shortcut mnemonics
818  act =
819  menu->addAction(QString(action_id_name_translation(ACTION_HOME_CITY)));
820  menu_list.insert(HOMECITY, act);
821  shortcuts->link_action(SC_SETHOME, act);
822  connect(act, &QAction::triggered, this, &mr_menu::slot_set_home);
823  act = menu->addAction(_("Upgrade Unit"));
824  shortcuts->link_action(SC_UPGRADE_UNIT, act);
825  menu_list.insert(UPGRADE, act);
826  connect(act, &QAction::triggered, this, &mr_menu::slot_upgrade);
827  act = menu->addAction(_("Convert Unit"));
828  act->setShortcut(QKeySequence(tr("ctrl+o")));
829  menu_list.insert(CONVERT, act);
830  connect(act, &QAction::triggered, this, &mr_menu::slot_convert);
831  act = menu->addAction(_("Disband Unit"));
832  act->setShortcut(QKeySequence(tr("shift+d")));
833  menu_list.insert(DISBAND, act);
834  connect(act, &QAction::triggered, this, &mr_menu::slot_disband);
835 
836  menu->addSeparator();
837  act = menu->addAction(_("Rename Unit"));
838  menu_list.insert(RENAME, act);
839  connect(act, &QAction::triggered, this, &mr_menu::slot_rename);
840 
841  // Combat Menu
842  menu = this->addMenu(_("Combat"));
843  act = menu->addAction(_("Fortify Unit"));
844  menu_list.insert(FORTIFY, act);
845  shortcuts->link_action(SC_FORTIFY, act);
846  connect(act, &QAction::triggered, this, &mr_menu::slot_unit_fortify);
847  act = menu->addAction(QString(Q_(terrain_control.gui_type_base0)));
848  menu_list.insert(FORTRESS, act);
849  act->setShortcut(QKeySequence(tr("shift+f")));
850  connect(act, &QAction::triggered, this, &mr_menu::slot_unit_fortress);
851  act = menu->addAction(QString(Q_(terrain_control.gui_type_base1)));
852  menu_list.insert(AIRBASE, act);
853  act->setShortcut(QKeySequence(tr("shift+e")));
854  connect(act, &QAction::triggered, this, &mr_menu::slot_unit_airbase);
855  bases_menu = menu->addMenu(_("Build Base"));
856  menu->addSeparator();
857  act = menu->addAction(_("Pillage"));
858  menu_list.insert(PILLAGE, act);
859  shortcuts->link_action(SC_PILLAGE, act);
860  connect(act, &QAction::triggered, this, &mr_menu::slot_pillage);
861  // TRANS: Menu item to bring up the action selection dialog.
862  act = menu->addAction(_("Do..."));
863  menu_list.insert(ORDER_DIPLOMAT_DLG, act);
864  shortcuts->link_action(SC_DO, act);
865  connect(act, &QAction::triggered, this, &mr_menu::slot_action);
866 
867  // Work Menu
868  menu = this->addMenu(_("Work"));
869  act = menu->addAction(
870  QString(action_id_name_translation(ACTION_FOUND_CITY)));
871  shortcuts->link_action(SC_BUILDCITY, act);
872  menu_list.insert(BUILD, act);
873  connect(act, &QAction::triggered, this, &mr_menu::slot_build_city);
874  act = menu->addAction(_("Auto Settler"));
875  shortcuts->link_action(SC_AUTOMATE, act);
876  menu_list.insert(AUTOSETTLER, act);
877  connect(act, &QAction::triggered, this, &mr_menu::slot_auto_settler);
878  menu->addSeparator();
879  act = menu->addAction(_("Build Road"));
880  menu_list.insert(ROAD, act);
881  shortcuts->link_action(SC_BUILDROAD, act);
882  connect(act, &QAction::triggered, this, &mr_menu::slot_build_road);
883  roads_menu = menu->addMenu(_("Build Path"));
884  act = menu->addAction(_("Build Irrigation"));
885  shortcuts->link_action(SC_BUILDIRRIGATION, act);
886  menu_list.insert(IRRIGATION, act);
887  connect(act, &QAction::triggered, this, &mr_menu::slot_build_irrigation);
888  act = menu->addAction(_("Cultivate"));
889  shortcuts->link_action(SC_CULTIVATE, act);
890  menu_list.insert(CULTIVATE, act);
891  connect(act, &QAction::triggered, this, &mr_menu::slot_cultivate);
892  act = menu->addAction(_("Build Mine"));
893  shortcuts->link_action(SC_BUILDMINE, act);
894  menu_list.insert(MINE, act);
895  connect(act, &QAction::triggered, this, &mr_menu::slot_build_mine);
896  act = menu->addAction(_("Plant"));
897  shortcuts->link_action(SC_PLANT, act);
898  menu_list.insert(PLANT, act);
899  connect(act, &QAction::triggered, this, &mr_menu::slot_plant);
900  menu->addSeparator();
901  act = menu->addAction(_("Connect with Road"));
902  act->setShortcut(QKeySequence(tr("ctrl+r")));
903  menu_list.insert(CONNECT_ROAD, act);
904  connect(act, &QAction::triggered, this, &mr_menu::slot_conn_road);
905  act = menu->addAction(_("Connect with Railroad"));
906  menu_list.insert(CONNECT_RAIL, act);
907  act->setShortcut(QKeySequence(tr("ctrl+l")));
908  connect(act, &QAction::triggered, this, &mr_menu::slot_conn_rail);
909  act = menu->addAction(_("Connect with Irrigation"));
910  menu_list.insert(CONNECT_IRRIGATION, act);
911  act->setShortcut(QKeySequence(tr("ctrl+i")));
912  connect(act, &QAction::triggered, this, &mr_menu::slot_conn_irrigation);
913  menu->addSeparator();
914  act = menu->addAction(_("Transform Terrain"));
915  menu_list.insert(TRANSFORM, act);
916  shortcuts->link_action(SC_TRANSFORM, act);
917  connect(act, &QAction::triggered, this, &mr_menu::slot_transform);
918  act = menu->addAction(_("Clean Pollution"));
919  menu_list.insert(POLLUTION, act);
920  shortcuts->link_action(SC_PARADROP, act);
921  connect(act, &QAction::triggered, this, &mr_menu::slot_clean_pollution);
922  act = menu->addAction(_("Clean Nuclear Fallout"));
923  menu_list.insert(FALLOUT, act);
924  shortcuts->link_action(SC_FALLOUT, act);
925  connect(act, &QAction::triggered, this, &mr_menu::slot_clean_fallout);
926  act = menu->addAction(
927  QString(action_id_name_translation(ACTION_HELP_WONDER)));
928  act->setShortcut(QKeySequence(tr("b")));
929  menu_list.insert(BUILD_WONDER, act);
930  connect(act, &QAction::triggered, this, &mr_menu::slot_build_city);
931  act = menu->addAction(
932  QString(action_id_name_translation(ACTION_TRADE_ROUTE)));
933  act->setShortcut(QKeySequence(tr("r")));
934  menu_list.insert(ORDER_TRADEROUTE, act);
935  connect(act, &QAction::triggered, this, &mr_menu::slot_build_road);
936 
937  multiplayer_menu = this->addMenu(_("Multiplayer"));
938  act = multiplayer_menu->addAction(_("Delayed Go To"));
939  act->setShortcut(QKeySequence(tr("z")));
940  connect(act, &QAction::triggered, this, &mr_menu::slot_delayed_goto);
941  act = multiplayer_menu->addAction(_("Delayed Orders Execute"));
942  act->setShortcut(QKeySequence(tr("ctrl+z")));
943  connect(act, &QAction::triggered, this, &mr_menu::slot_execute_orders);
944  act = multiplayer_menu->addAction(_("Clear Orders"));
945  act->setShortcut(QKeySequence(tr("ctrl+shift+c")));
946  connect(act, &QAction::triggered, this, &mr_menu::slot_orders_clear);
947  multiplayer_menu->addSeparator();
948  act = multiplayer_menu->addAction(_("Add All Cities to Trade Planning"));
949  connect(act, &QAction::triggered, this, &mr_menu::slot_trade_add_all);
950  act = multiplayer_menu->addAction(_("Calculate Trade Planning"));
951  connect(act, &QAction::triggered, this, &mr_menu::slot_calculate);
952  act = multiplayer_menu->addAction(_("Add / Remove City"));
953  act->setShortcut(QKeySequence(tr("ctrl+t")));
954  connect(act, &QAction::triggered, this, &mr_menu::slot_trade_city);
955  act = multiplayer_menu->addAction(_("Clear Trade Planning"));
956  connect(act, &QAction::triggered, this, &mr_menu::slot_clear_trade);
957  act = multiplayer_menu->addAction(_("Automatic Caravan"));
958  menu_list.insert(AUTOTRADEROUTE, act);
959  connect(act, &QAction::triggered, this, &mr_menu::slot_autocaravan);
960  act->setShortcut(QKeySequence(tr("ctrl+j")));
961  multiplayer_menu->addSeparator();
962  act = multiplayer_menu->addAction(_("Set / Unset Rally Point"));
963  act->setShortcut(QKeySequence(tr("shift+s")));
964  connect(act, &QAction::triggered, this, &mr_menu::slot_rally);
965  act = multiplayer_menu->addAction(_("Quick Airlift"));
966  act->setShortcut(QKeySequence(tr("ctrl+y")));
967  connect(act, &QAction::triggered, this, &mr_menu::slot_quickairlift);
968  airlift_type = new QActionGroup(this);
969  airlift_menu =
970  multiplayer_menu->addMenu(_("Unit Type for Quickairlifting"));
971 
972  // Default diplo
973  action_vs_city = new QActionGroup(this);
974  action_vs_unit = new QActionGroup(this);
975  action_unit_menu = multiplayer_menu->addMenu(_("Default Action vs Unit"));
976 
977  act = action_unit_menu->addAction(_("Ask"));
978  act->setCheckable(true);
979  act->setChecked(true);
980  act->setData(-1);
981  action_vs_unit->addAction(act);
982  connect(act, &QAction::triggered, this, &mr_menu::slot_action_vs_unit);
983 
984  act = action_unit_menu->addAction(_("Bribe"));
985  act->setCheckable(true);
986  act->setChecked(false);
987  act->setData(ACTION_SPY_BRIBE_UNIT);
988  action_vs_unit->addAction(act);
989  connect(act, &QAction::triggered, this, &mr_menu::slot_action_vs_unit);
990 
991  act = action_unit_menu->addAction(_("Sabotage"));
992  act->setCheckable(true);
993  act->setChecked(false);
994  act->setData(ACTION_SPY_SABOTAGE_UNIT);
995  action_vs_unit->addAction(act);
996  connect(act, &QAction::triggered, this, &mr_menu::slot_action_vs_unit);
997 
998  act = action_unit_menu->addAction(_("Sabotage Unit Escape"));
999  act->setCheckable(true);
1000  act->setChecked(false);
1001  act->setData(ACTION_SPY_SABOTAGE_UNIT_ESC);
1002  action_vs_unit->addAction(act);
1003  connect(act, &QAction::triggered, this, &mr_menu::slot_action_vs_unit);
1004 
1005  action_city_menu = multiplayer_menu->addMenu(_("Default Action vs City"));
1006  act = action_city_menu->addAction(_("Ask"));
1007  act->setCheckable(true);
1008  act->setChecked(true);
1009  act->setData(-1);
1010  action_vs_city->addAction(act);
1011  connect(act, &QAction::triggered, this, &mr_menu::slot_action_vs_city);
1012 
1013  act = action_city_menu->addAction(_("Investigate City"));
1014  act->setCheckable(true);
1015  act->setChecked(false);
1016  act->setData(ACTION_SPY_INVESTIGATE_CITY);
1017  action_vs_city->addAction(act);
1018  connect(act, &QAction::triggered, this, &mr_menu::slot_action_vs_city);
1019 
1020  act = action_city_menu->addAction(_("Investigate City (Spends the Unit)"));
1021  act->setCheckable(true);
1022  act->setChecked(false);
1023  act->setData(ACTION_INV_CITY_SPEND);
1024  action_vs_city->addAction(act);
1025  connect(act, &QAction::triggered, this, &mr_menu::slot_action_vs_city);
1026 
1027  act = action_city_menu->addAction(_("Establish Embassy"));
1028  act->setCheckable(true);
1029  act->setChecked(false);
1030  act->setData(ACTION_ESTABLISH_EMBASSY);
1031  action_vs_city->addAction(act);
1032  connect(act, &QAction::triggered, this, &mr_menu::slot_action_vs_city);
1033 
1034  act = action_city_menu->addAction(_("Become Ambassador"));
1035  act->setCheckable(true);
1036  act->setChecked(false);
1037  act->setData(ACTION_ESTABLISH_EMBASSY_STAY);
1038  action_vs_city->addAction(act);
1039  connect(act, &QAction::triggered, this, &mr_menu::slot_action_vs_city);
1040 
1041  act = action_city_menu->addAction(_("Steal Technology"));
1042  act->setCheckable(true);
1043  act->setChecked(false);
1044  act->setData(ACTION_SPY_STEAL_TECH);
1045  action_vs_city->addAction(act);
1046  connect(act, &QAction::triggered, this, &mr_menu::slot_action_vs_city);
1047 
1048  act = action_city_menu->addAction(_("Steal Technology and Escape"));
1049  act->setCheckable(true);
1050  act->setChecked(false);
1051  act->setData(ACTION_SPY_STEAL_TECH_ESC);
1052  action_vs_city->addAction(act);
1053  connect(act, &QAction::triggered, this, &mr_menu::slot_action_vs_city);
1054 
1055  act = action_city_menu->addAction(_("Incite a Revolt"));
1056  act->setCheckable(true);
1057  act->setChecked(false);
1058  act->setData(ACTION_SPY_INCITE_CITY);
1059  action_vs_city->addAction(act);
1060  connect(act, &QAction::triggered, this, &mr_menu::slot_action_vs_city);
1061 
1062  act = action_city_menu->addAction(_("Incite a Revolt and Escape"));
1063  act->setCheckable(true);
1064  act->setChecked(false);
1065  act->setData(ACTION_SPY_INCITE_CITY_ESC);
1066  action_vs_city->addAction(act);
1067  connect(act, &QAction::triggered, this, &mr_menu::slot_action_vs_city);
1068 
1069  act = action_city_menu->addAction(_("Poison City"));
1070  act->setCheckable(true);
1071  act->setChecked(false);
1072  act->setData(ACTION_SPY_POISON);
1073  action_vs_city->addAction(act);
1074  connect(act, &QAction::triggered, this, &mr_menu::slot_action_vs_city);
1075 
1076  act = action_city_menu->addAction(_("Poison City and Escape"));
1077  act->setCheckable(true);
1078  act->setChecked(false);
1079  act->setData(ACTION_SPY_POISON_ESC);
1080  action_vs_city->addAction(act);
1081  connect(act, &QAction::triggered, this, &mr_menu::slot_action_vs_city);
1082 
1083  // Civilization menu
1084  menu = this->addMenu(_("Civilization"));
1085  act = menu->addAction(_("National Budget..."));
1086  menu_list.insert(NOT_4_OBS, act);
1087  connect(act, &QAction::triggered, this, &mr_menu::slot_popup_tax_rates);
1088  menu->addSeparator();
1089 
1090  act = menu->addAction(_("Policies..."));
1091  menu_list.insert(MULTIPLIERS, act);
1092  connect(act, &QAction::triggered, this, &mr_menu::slot_popup_mult_rates);
1093  menu->addSeparator();
1094 
1095  menu->addMenu(new class gov_menu(this));
1096  menu->addSeparator();
1097 
1098  act = menu->addAction(Q_("?noun:Map View"));
1099  act->setShortcut(QKeySequence(tr("F1")));
1100  connect(act, &QAction::triggered, this, &mr_menu::slot_show_map);
1101 
1102  act = menu->addAction(_("Units View"));
1103  act->setShortcut(QKeySequence(tr("F2")));
1104  connect(act, &QAction::triggered, this, &top_bar_units_view);
1105 
1106  // TRANS: Also menu item, but 'headers' should be good enough.
1107  act = menu->addAction(Q_("?header:Nations View"));
1108  act->setShortcut(QKeySequence(tr("F3")));
1109  connect(act, &QAction::triggered, this, &popup_players_dialog);
1110 
1111  act = menu->addAction(_("Cities View"));
1112  act->setShortcut(QKeySequence(tr("F4")));
1113  connect(act, &QAction::triggered, this, &city_report_dialog_popup);
1114 
1115  act = menu->addAction(_("Economy View"));
1116  act->setShortcut(QKeySequence(tr("F5")));
1117  connect(act, &QAction::triggered, this, &economy_report_dialog_popup);
1118 
1119  act = menu->addAction(_("Research View"));
1120  act->setShortcut(QKeySequence(tr("F6")));
1121  connect(act, &QAction::triggered, this, &mr_menu::slot_show_research_tab);
1122 
1123  act = menu->addAction(_("Wonders of the World Report"));
1124  act->setShortcut(QKeySequence(tr("F7")));
1125  connect(act, &QAction::triggered, this, &mr_menu::slot_traveler);
1126 
1127  act = menu->addAction(_("Top Five Cities Report"));
1128  act->setShortcut(QKeySequence(tr("F8")));
1129  connect(act, &QAction::triggered, this, &mr_menu::slot_top_five);
1130 
1131  act = menu->addAction(_("Demographics Report"));
1132  act->setShortcut(QKeySequence(tr("F11")));
1133  connect(act, &QAction::triggered, this, &mr_menu::slot_demographics);
1134 
1135  act = menu->addAction(_("Spaceship View"));
1136  act->setShortcut(QKeySequence(tr("F12")));
1137  connect(act, &QAction::triggered, this, &mr_menu::slot_spaceship);
1138 
1139  act = menu->addAction(_("Achievements Report"));
1140  connect(act, &QAction::triggered, this, &mr_menu::slot_achievements);
1141 
1142  act = menu->addAction(_("Endgame Report"));
1143  menu_list.insert(ENDGAME, act);
1144  connect(act, &QAction::triggered, this, &mr_menu::slot_endgame);
1145 
1146  // Help Menu
1147  menu = this->addMenu(_("Help"));
1148 
1149  act = menu->addAction(Q_(HELP_OVERVIEW_ITEM));
1150  QObject::connect(act, &QAction::triggered,
1151  [this]() { slot_help(HELP_OVERVIEW_ITEM); });
1152 
1153  act = menu->addAction(Q_(HELP_PLAYING_ITEM));
1154  QObject::connect(act, &QAction::triggered,
1155  [this]() { slot_help(HELP_PLAYING_ITEM); });
1156 
1157  act = menu->addAction(Q_(HELP_TERRAIN_ITEM));
1158  QObject::connect(act, &QAction::triggered,
1159  [this]() { slot_help(HELP_TERRAIN_ITEM); });
1160 
1161  act = menu->addAction(Q_(HELP_ECONOMY_ITEM));
1162  QObject::connect(act, &QAction::triggered,
1163  [this]() { slot_help(HELP_ECONOMY_ITEM); });
1164 
1165  act = menu->addAction(Q_(HELP_CITIES_ITEM));
1166  QObject::connect(act, &QAction::triggered,
1167  [this]() { slot_help(HELP_CITIES_ITEM); });
1168 
1169  act = menu->addAction(Q_(HELP_IMPROVEMENTS_ITEM));
1170  QObject::connect(act, &QAction::triggered,
1171  [this]() { slot_help(HELP_IMPROVEMENTS_ITEM); });
1172 
1173  act = menu->addAction(Q_(HELP_WONDERS_ITEM));
1174  QObject::connect(act, &QAction::triggered,
1175  [this]() { slot_help(HELP_WONDERS_ITEM); });
1176 
1177  act = menu->addAction(Q_(HELP_UNITS_ITEM));
1178  QObject::connect(act, &QAction::triggered,
1179  [this]() { slot_help(HELP_UNITS_ITEM); });
1180 
1181  act = menu->addAction(Q_(HELP_COMBAT_ITEM));
1182  QObject::connect(act, &QAction::triggered,
1183  [this]() { slot_help(HELP_COMBAT_ITEM); });
1184 
1185  act = menu->addAction(Q_(HELP_ZOC_ITEM));
1186  QObject::connect(act, &QAction::triggered,
1187  [this]() { slot_help(HELP_ZOC_ITEM); });
1188 
1189  act = menu->addAction(Q_(HELP_GOVERNMENT_ITEM));
1190  QObject::connect(act, &QAction::triggered,
1191  [this]() { slot_help(HELP_GOVERNMENT_ITEM); });
1192 
1193  act = menu->addAction(Q_(HELP_EFFECTS_ITEM));
1194  QObject::connect(act, &QAction::triggered,
1195  [this]() { slot_help(HELP_EFFECTS_ITEM); });
1196 
1197  act = menu->addAction(Q_(HELP_DIPLOMACY_ITEM));
1198  QObject::connect(act, &QAction::triggered,
1199  [this]() { slot_help(HELP_DIPLOMACY_ITEM); });
1200 
1201  act = menu->addAction(Q_(HELP_TECHS_ITEM));
1202  QObject::connect(act, &QAction::triggered,
1203  [this]() { slot_help(HELP_TECHS_ITEM); });
1204 
1205  act = menu->addAction(Q_(HELP_SPACE_RACE_ITEM));
1206  QObject::connect(act, &QAction::triggered,
1207  [this]() { slot_help(HELP_SPACE_RACE_ITEM); });
1208 
1209  act = menu->addAction(Q_(HELP_TILESET_ITEM));
1210  QObject::connect(act, &QAction::triggered,
1211  [this]() { slot_help(HELP_TILESET_ITEM); });
1212 
1213  act = menu->addAction(Q_(HELP_RULESET_ITEM));
1214  QObject::connect(act, &QAction::triggered,
1215  [this]() { slot_help(HELP_RULESET_ITEM); });
1216 
1217  act = menu->addAction(Q_(HELP_NATIONS_ITEM));
1218  QObject::connect(act, &QAction::triggered,
1219  [this]() { slot_help(HELP_NATIONS_ITEM); });
1220 
1221  menu->addSeparator();
1222 
1223  act = menu->addAction(Q_(HELP_CONNECTING_ITEM));
1224  QObject::connect(act, &QAction::triggered,
1225  [this]() { slot_help(HELP_CONNECTING_ITEM); });
1226 
1227  act = menu->addAction(Q_(HELP_CONTROLS_ITEM));
1228  QObject::connect(act, &QAction::triggered,
1229  [this]() { slot_help(HELP_CONTROLS_ITEM); });
1230 
1231  act = menu->addAction(Q_(HELP_CMA_ITEM));
1232  QObject::connect(act, &QAction::triggered,
1233  [this]() { slot_help(HELP_CMA_ITEM); });
1234 
1235  act = menu->addAction(Q_(HELP_CHATLINE_ITEM));
1236  QObject::connect(act, &QAction::triggered,
1237  [this]() { slot_help(HELP_CHATLINE_ITEM); });
1238 
1239  act = menu->addAction(Q_(HELP_WORKLIST_EDITOR_ITEM));
1240  QObject::connect(act, &QAction::triggered,
1241  [this]() { slot_help(HELP_WORKLIST_EDITOR_ITEM); });
1242 
1243  menu->addSeparator();
1244 
1245  act = menu->addAction(Q_(HELP_LANGUAGES_ITEM));
1246  QObject::connect(act, &QAction::triggered,
1247  [this]() { slot_help(HELP_LANGUAGES_ITEM); });
1248 
1249  act = menu->addAction(Q_(HELP_COPYING_ITEM));
1250  QObject::connect(act, &QAction::triggered,
1251  [this]() { slot_help(HELP_COPYING_ITEM); });
1252 
1253  act = menu->addAction(Q_(HELP_ABOUT_ITEM));
1254  QObject::connect(act, &QAction::triggered,
1255  [this]() { slot_help(HELP_ABOUT_ITEM); });
1256 
1257  menus = this->findChildren<QMenu *>();
1258  for (i = 0; i < menus.count(); i++) {
1259  menus[i]->setAttribute(Qt::WA_TranslucentBackground);
1260  }
1261  this->setVisible(false);
1262  initialized = true;
1263 
1264  shortcuts->create_no_action_shortcuts(queen()->mapview_wdg);
1265 }
1266 
1271 {
1272  clear();
1273  menu_list.clear();
1274  for (const auto menu : king()->findChildren<QMenu *>()) {
1275  for (const auto action : menu->actions()) {
1276  // Don't delete submenu actions, they're managed by the submenus
1277  if (!action->menu()) {
1278  action->deleteLater();
1279  }
1280  }
1281  menu->deleteLater();
1282  }
1283 }
1284 
1289 {
1290  for (auto &fui : units_list) {
1291  fui.ptile = ptile;
1292  }
1293 }
1294 
1298 bool mr_menu::shortcut_exists(const fc_shortcut &fcs, QString &where)
1299 {
1300  if (fcs.type == fc_shortcut::mouse) {
1301  where = QString();
1302  return false;
1303  }
1304 
1305  for (const QMenu *m : findChildren<QMenu *>()) {
1306  for (const auto action : m->actions()) {
1307  if (action->shortcut() == fcs.keys) {
1308  where = m->title() + " > " + action->text();
1309  return true;
1310  }
1311  }
1312  }
1313 
1314  where = QString();
1315  return false;
1316 }
1317 
1322 {
1323  Unit_type_id utype_id;
1324  QAction *act;
1325 
1326  if (!initialized || !client.conn.playing) {
1327  return;
1328  }
1329  airlift_menu->clear();
1330  if (client_is_observer()) {
1331  return;
1332  }
1334  {
1335  utype_id = utype_index(utype);
1336 
1338  || !utype_can_do_action(utype, ACTION_AIRLIFT)) {
1339  continue;
1340  }
1342  && !has_player_unit_type(utype_id)) {
1343  continue;
1344  }
1345  // Defeat keyboard shortcut mnemonics
1346  act = airlift_menu->addAction(QString(utype_name_translation(utype)));
1347  act->setCheckable(true);
1348  act->setData(utype_id);
1349  if (airlift_type_id == utype_id) {
1350  act->setChecked(true);
1351  }
1352  connect(act, &QAction::triggered, this, &mr_menu::slot_quickairlift_set);
1353  airlift_type->addAction(act);
1354  }
1356 }
1357 
1362 {
1363  QAction *act;
1364  bool enabled = false;
1365 
1366  if (!initialized) {
1367  return;
1368  }
1369  QList<QAction *> actions = roads_menu->actions();
1370  for (auto *act : qAsConst(actions)) {
1371  removeAction(act);
1372  act->deleteLater();
1373  }
1374  roads_menu->clear();
1375  roads_menu->setDisabled(true);
1376  if (client_is_observer()) {
1377  return;
1378  }
1379 
1380  extra_type_by_cause_iterate(EC_ROAD, pextra)
1381  {
1382  if (pextra->buildable) {
1383  int road_id;
1384 
1385  // Defeat keyboard shortcut mnemonics
1386  act = roads_menu->addAction(QString(extra_name_translation(pextra)));
1387  road_id = pextra->id;
1388  act->setData(road_id);
1389  QObject::connect(act, &QAction::triggered,
1390  [this, road_id]() { slot_build_path(road_id); });
1392  ACTIVITY_GEN_ROAD, pextra)) {
1393  act->setEnabled(true);
1394  enabled = true;
1395  } else {
1396  act->setDisabled(true);
1397  }
1398  }
1399  }
1401 
1402  if (enabled) {
1403  roads_menu->setEnabled(true);
1404  }
1405 }
1406 
1411 {
1412  QAction *act;
1413  bool enabled = false;
1414  if (!initialized) {
1415  return;
1416  }
1417 
1418  QList<QAction *> actions = bases_menu->actions();
1419  for (auto *act : qAsConst(actions)) {
1420  removeAction(act);
1421  act->deleteLater();
1422  }
1423  bases_menu->clear();
1424  bases_menu->setDisabled(true);
1425 
1426  if (client_is_observer()) {
1427  return;
1428  }
1429 
1430  extra_type_by_cause_iterate(EC_BASE, pextra)
1431  {
1432  if (pextra->buildable) {
1433  int base_id;
1434 
1435  // Defeat keyboard shortcut mnemonics
1436  act = bases_menu->addAction(QString(extra_name_translation(pextra)));
1437  base_id = pextra->id;
1438  act->setData(base_id);
1439  QObject::connect(act, &QAction::triggered,
1440  [this, base_id]() { slot_build_base(base_id); });
1442  pextra)) {
1443  act->setEnabled(true);
1444  enabled = true;
1445  } else {
1446  act->setDisabled(true);
1447  }
1448  }
1449  }
1451 
1452  if (enabled) {
1453  bases_menu->setEnabled(true);
1454  }
1455 }
1456 
1457 // Make menus non dependent on unit sensitive
1459 {
1461  QList<munit> keys = menu_list.keys();
1462  for (munit key : qAsConst(keys)) {
1463  i = menu_list.find(key);
1464  while (i != menu_list.end() && i.key() == key) {
1465  switch (key) {
1466  case SAVE:
1468  i.value()->setEnabled(true);
1469  }
1470  break;
1471  case NOT_4_OBS:
1472  if (!client_is_observer()) {
1473  i.value()->setEnabled(true);
1474  }
1475  break;
1476  case MULTIPLIERS:
1477  if (!client_is_observer() && multiplier_count() > 0) {
1478  i.value()->setEnabled(true);
1479  i.value()->setVisible(true);
1480  } else {
1481  i.value()->setVisible(false);
1482  }
1483  break;
1484  case ENDGAME:
1485  if (queen()->isRepoDlgOpen(QStringLiteral("END"))) {
1486  i.value()->setEnabled(true);
1487  i.value()->setVisible(true);
1488  } else {
1489  i.value()->setVisible(false);
1490  }
1491  break;
1492  default:
1493  break;
1494  }
1495  i++;
1496  }
1497  }
1498 }
1499 
1500 static struct extra_type *next_extra(const std::vector<unit *> &punits,
1501  extra_cause cause)
1502 {
1503  struct extra_type *pextra = nullptr;
1504  /* FIXME: this overloading doesn't work well with multiple focus
1505  * units. */
1506  for (const auto builder : punits) {
1507  pextra = next_extra_for_tile(unit_tile(builder), cause,
1508  unit_owner(builder), builder);
1509  if (pextra != nullptr) {
1510  break;
1511  }
1512  }
1513  return pextra;
1514 }
1515 
1520 {
1521  QList<munit> keys;
1523  struct road_type *proad;
1524  struct extra_type *tgt;
1525  bool city_on_tile = false;
1526  bool units_all_same_tile;
1527  struct terrain *pterrain;
1528 
1529  if (!initialized) {
1530  return;
1531  }
1532 
1534  for (QAction *a : qAsConst(menu_list)) {
1535  a->setEnabled(false);
1536  }
1537 
1538  if (client_is_observer()) {
1539  multiplayer_menu->setDisabled(true);
1540  } else {
1541  multiplayer_menu->setDisabled(false);
1542  }
1543 
1545 
1547  return;
1548  }
1549 
1550  const auto &punits = get_units_in_focus();
1551  city_on_tile = any_unit_in_city(punits);
1552  units_all_same_tile = units_on_the_same_tile(punits);
1553 
1554  keys = menu_list.keys();
1555  for (munit key : qAsConst(keys)) {
1556  i = menu_list.find(key);
1557  while (i != menu_list.end() && i.key() == key) {
1558  switch (key) {
1559  case STANDARD:
1560  i.value()->setEnabled(true);
1561  break;
1562 
1563  case EXPLORE:
1564  if (can_units_do_activity(punits, ACTIVITY_EXPLORE)) {
1565  i.value()->setEnabled(true);
1566  }
1567  break;
1568 
1569  case LOAD:
1570  if (units_can_load(punits)) {
1571  i.value()->setEnabled(true);
1572  }
1573  break;
1574 
1575  case UNLOAD:
1576  if (units_can_unload(punits)) {
1577  i.value()->setEnabled(true);
1578  }
1579  break;
1580 
1581  case TRANSPORTER:
1582  if (units_are_occupied(punits)) {
1583  i.value()->setEnabled(true);
1584  }
1585  break;
1586 
1587  case CONVERT:
1588  if (units_can_convert(punits)) {
1589  i.value()->setEnabled(true);
1590  }
1591  break;
1592 
1593  case MINE:
1594  if (can_units_do_activity(punits, ACTIVITY_MINE)) {
1595  i.value()->setEnabled(true);
1596  }
1597 
1598  if (units_all_same_tile) {
1599  struct unit *punit = punits.front();
1600 
1601  pterrain = tile_terrain(unit_tile(punit));
1602 
1603  if (units_have_type_flag(punits, UTYF_SETTLERS, true)) {
1604  struct extra_type *pextra = next_extra(punits, EC_MINE);
1605 
1606  if (pextra != nullptr) {
1607  i.value()->setText(
1608  // TRANS: Build mine of specific type
1609  QString(_("Build %1"))
1610  .arg(extra_name_translation(pextra)));
1611  } else {
1612  i.value()->setText(QString(_("Build Mine")));
1613  }
1614  } else {
1615  i.value()->setText(QString(_("Build Mine")));
1616  }
1617  }
1618  break;
1619 
1620  case IRRIGATION:
1621  if (can_units_do_activity(punits, ACTIVITY_IRRIGATE)) {
1622  i.value()->setEnabled(true);
1623  }
1624  if (units_all_same_tile) {
1625  struct unit *punit = punits.front();
1626 
1627  pterrain = tile_terrain(unit_tile(punit));
1628 
1629  if (units_have_type_flag(punits, UTYF_SETTLERS, true)) {
1630  struct extra_type *pextra = next_extra(punits, EC_IRRIGATION);
1631 
1632  if (pextra != nullptr) {
1633  i.value()->setText(
1634  // TRANS: Build irrigation of specific type
1635  QString(_("Build %1"))
1636  .arg(extra_name_translation(pextra)));
1637  } else {
1638  i.value()->setText(QString(_("Build Irrigation")));
1639  }
1640  } else {
1641  i.value()->setText(QString(_("Build Irrigation")));
1642  }
1643  }
1644  break;
1645 
1646  case CULTIVATE:
1647  if (can_units_do_activity(punits, ACTIVITY_CULTIVATE)) {
1648  i.value()->setEnabled(true);
1649  }
1650  if (units_all_same_tile) {
1651  struct unit *punit = punits.front();
1652 
1653  pterrain = tile_terrain(unit_tile(punit));
1654  if (pterrain->irrigation_result != T_NONE
1655  && pterrain->irrigation_result != pterrain) {
1656  i.value()->setText(
1657  // TRANS: Transform terrain to specific type
1658  QString(_("Cultivate to %1"))
1659  .arg(QString(get_tile_change_menu_text(
1660  unit_tile(punit), ACTIVITY_CULTIVATE))));
1661  } else {
1662  i.value()->setText(QString(_("Cultivate")));
1663  }
1664  } else {
1665  i.value()->setText(QString(_("Cultivate")));
1666  }
1667  break;
1668 
1669  case PLANT:
1670  if (can_units_do_activity(punits, ACTIVITY_PLANT)) {
1671  i.value()->setEnabled(true);
1672  }
1673  if (units_all_same_tile) {
1674  struct unit *punit = punits.front();
1675 
1676  pterrain = tile_terrain(unit_tile(punit));
1677  if (pterrain->mining_result != T_NONE
1678  && pterrain->mining_result != pterrain) {
1679  i.value()->setText(
1680  // TRANS: Transform terrain to specific type
1681  QString(_("Plant to %1"))
1682  .arg(QString(get_tile_change_menu_text(
1683  unit_tile(punit), ACTIVITY_PLANT))));
1684  } else {
1685  i.value()->setText(QString(_("Plant")));
1686  }
1687  } else {
1688  i.value()->setText(QString(_("Plant")));
1689  }
1690  break;
1691 
1692  case TRANSFORM:
1693  if (can_units_do_activity(punits, ACTIVITY_TRANSFORM)) {
1694  i.value()->setEnabled(true);
1695  } else {
1696  break;
1697  }
1698  if (units_all_same_tile) {
1699  struct unit *punit = punits.front();
1700  pterrain = tile_terrain(unit_tile(punit));
1701  if (pterrain->transform_result != T_NONE
1702  && pterrain->transform_result != pterrain) {
1703  i.value()->setText(
1704  // TRANS: Transform terrain to specific type
1705  QString(_("Transform to %1"))
1706  .arg(QString(get_tile_change_menu_text(
1707  unit_tile(punit), ACTIVITY_TRANSFORM))));
1708  } else {
1709  i.value()->setText(_("Transform Terrain"));
1710  }
1711  }
1712  break;
1713 
1714  case BUILD:
1716  i.value()->setEnabled(true);
1717  }
1718  if (city_on_tile
1719  && units_can_do_action(punits, ACTION_JOIN_CITY, true)) {
1720  i.value()->setText(
1721  QString(action_id_name_translation(ACTION_JOIN_CITY)));
1722  } else {
1723  i.value()->setText(
1724  QString(action_id_name_translation(ACTION_FOUND_CITY)));
1725  }
1726  break;
1727 
1728  case ROAD: {
1729  struct extra_type *pextra = next_extra(punits, EC_ROAD);
1730 
1731  if (can_units_do_any_road(punits)) {
1732  i.value()->setEnabled(true);
1733  }
1734 
1735  if (pextra != nullptr) {
1736  i.value()->setText(
1737  // TRANS: Build road of specific type
1738  QString(_("Build %1")).arg(extra_name_translation(pextra)));
1739  }
1740  } break;
1741 
1742  case FORTIFY:
1743  if (can_units_do_activity(punits, ACTIVITY_FORTIFYING)) {
1744  i.value()->setEnabled(true);
1745  }
1746  break;
1747 
1748  case FORTRESS:
1749  if (can_units_do_base_gui(punits, BASE_GUI_FORTRESS)) {
1750  i.value()->setEnabled(true);
1751  }
1752  break;
1753 
1754  case AIRBASE:
1755  if (can_units_do_base_gui(punits, BASE_GUI_AIRBASE)) {
1756  i.value()->setEnabled(true);
1757  }
1758  break;
1759 
1760  case POLLUTION:
1761  if (can_units_do_activity(punits, ACTIVITY_POLLUTION)
1762  || can_units_do(punits, can_unit_paradrop)) {
1763  i.value()->setEnabled(true);
1764  }
1765  if (units_can_do_action(punits, ACTION_PARADROP, true)) {
1766  i.value()->setText(
1767  QString(action_id_name_translation(ACTION_PARADROP)));
1768  } else {
1769  i.value()->setText(_("Clean Pollution"));
1770  }
1771  break;
1772 
1773  case FALLOUT:
1774  if (can_units_do_activity(punits, ACTIVITY_FALLOUT)) {
1775  i.value()->setEnabled(true);
1776  }
1777  break;
1778 
1779  case SENTRY:
1780  if (can_units_do_activity(punits, ACTIVITY_SENTRY)) {
1781  i.value()->setEnabled(true);
1782  }
1783  break;
1784 
1785  case PILLAGE:
1786  if (can_units_do_activity(punits, ACTIVITY_PILLAGE)) {
1787  i.value()->setEnabled(true);
1788  }
1789  break;
1790 
1791  case HOMECITY:
1792  if (can_units_do(punits, can_unit_change_homecity)) {
1793  i.value()->setEnabled(true);
1794  }
1795  break;
1796 
1797  case WAKEUP:
1798  if (units_have_activity_on_tile(punits, ACTIVITY_SENTRY)) {
1799  i.value()->setEnabled(true);
1800  }
1801  break;
1802 
1803  case AUTOSETTLER:
1804  if (can_units_do(punits, can_unit_do_autosettlers)) {
1805  i.value()->setEnabled(true);
1806  }
1807  if (units_contain_cityfounder(punits)) {
1808  i.value()->setText(_("Auto Settler"));
1809  } else {
1810  i.value()->setText(_("Auto Worker"));
1811  }
1812  break;
1813  case CONNECT_ROAD:
1815  if (proad != nullptr) {
1816  tgt = road_extra_get(proad);
1817  } else {
1818  break;
1819  }
1820  if (can_units_do_connect(punits, ACTIVITY_GEN_ROAD, tgt)) {
1821  i.value()->setEnabled(true);
1822  }
1823  break;
1824 
1825  case DISBAND:
1826  if (units_can_do_action(punits, ACTION_DISBAND_UNIT, true)) {
1827  i.value()->setEnabled(true);
1828  }
1829  break;
1830 
1831  case RENAME:
1832  i.value()->setEnabled(get_num_units_in_focus() == 1);
1833  break;
1834 
1835  case CONNECT_RAIL:
1837  if (proad != nullptr) {
1838  tgt = road_extra_get(proad);
1839  } else {
1840  break;
1841  }
1842  if (can_units_do_connect(punits, ACTIVITY_GEN_ROAD, tgt)) {
1843  i.value()->setEnabled(true);
1844  }
1845  break;
1846 
1847  case CONNECT_IRRIGATION: {
1848  struct extra_type_list *extras =
1849  extra_type_list_by_cause(EC_IRRIGATION);
1850 
1851  if (extra_type_list_size(extras) > 0) {
1852  struct extra_type *pextra;
1853 
1854  pextra = extra_type_list_get(
1855  extra_type_list_by_cause(EC_IRRIGATION), 0);
1856  if (can_units_do_connect(punits, ACTIVITY_IRRIGATE, pextra)) {
1857  i.value()->setEnabled(true);
1858  }
1859  }
1860  } break;
1861 
1862  case GOTO_CITY:
1863  i.value()->setEnabled(true);
1864  break;
1865 
1866  case AIRLIFT:
1867  i.value()->setEnabled(true);
1868  break;
1869 
1870  case BUILD_WONDER:
1871  i.value()->setText(
1872  QString(action_id_name_translation(ACTION_HELP_WONDER)));
1874  i.value()->setEnabled(true);
1875  }
1876  break;
1877 
1878  case AUTOTRADEROUTE:
1879  if (units_can_do_action(punits, ACTION_TRADE_ROUTE, true)) {
1880  i.value()->setEnabled(true);
1881  }
1882  break;
1883 
1884  case ORDER_TRADEROUTE:
1885  i.value()->setText(
1886  QString(action_id_name_translation(ACTION_TRADE_ROUTE)));
1888  i.value()->setEnabled(true);
1889  }
1890  break;
1891 
1892  case ORDER_DIPLOMAT_DLG:
1893  if (units_can_do_action(punits, ACTION_ANY, true)) {
1894  i.value()->setEnabled(true);
1895  }
1896  break;
1897 
1898  case UPGRADE:
1899  if (units_can_upgrade(punits)) {
1900  i.value()->setEnabled(true);
1901  }
1902  break;
1903  default:
1904  break;
1905  }
1906 
1907  i++;
1908  }
1909  }
1910 }
1911 
1916 
1921 {
1922  if (nullptr != client.conn.playing) {
1924  }
1925 }
1926 
1931 
1936 {
1937  for (const auto punit : get_units_in_focus()) {
1938  /* FIXME: this can provide different actions for different units...
1939  * not good! */
1940  /* Enable the button for adding to a city in all cases, so we
1941  get an eventual error message from the server if we try. */
1942  if (unit_can_add_or_build_city(punit)) {
1943  request_unit_build_city(punit);
1944  } else if (utype_can_do_action(unit_type_get(punit),
1945  ACTION_HELP_WONDER)) {
1946  request_unit_caravan_action(punit, ACTION_HELP_WONDER);
1947  }
1948  }
1949 }
1950 
1955 
1960 {
1961  for (const auto punit : get_units_in_focus()) {
1962  /* FIXME: this can provide different actions for different units...
1963  * not good! */
1964  struct extra_type *pextra;
1965 
1966  pextra = prev_extra_in_tile(unit_tile(punit), ERM_CLEANPOLLUTION,
1967  unit_owner(punit), punit);
1968  if (pextra != nullptr) {
1969  request_new_unit_activity_targeted(punit, ACTIVITY_POLLUTION, pextra);
1970  } else if (can_unit_paradrop(punit)) {
1971  /* FIXME: This is getting worse, we use a key_unit_*() function
1972  * which assign the order for all units! Very bad! */
1974  }
1975  }
1976 }
1977 
1982 {
1983  struct extra_type_list *extras = extra_type_list_by_cause(EC_IRRIGATION);
1984 
1985  if (extra_type_list_size(extras) > 0) {
1986  struct extra_type *pextra;
1987 
1988  pextra = extra_type_list_get(extra_type_list_by_cause(EC_IRRIGATION), 0);
1989 
1990  key_unit_connect(ACTIVITY_IRRIGATE, pextra);
1991  }
1992 }
1993 
1998 {
2000 
2001  if (prail != nullptr) {
2002  struct extra_type *tgt;
2003 
2004  tgt = road_extra_get(prail);
2005  key_unit_connect(ACTIVITY_GEN_ROAD, tgt);
2006  }
2007 }
2008 
2013 
2018 
2023 {
2024  struct road_type *proad = road_by_compat_special(ROCO_ROAD);
2025 
2026  if (proad != nullptr) {
2027  struct extra_type *tgt;
2028 
2029  tgt = road_extra_get(proad);
2030  key_unit_connect(ACTIVITY_GEN_ROAD, tgt);
2031  }
2032 }
2033 
2038 
2043 
2048 
2053 
2058 {
2059  for (const auto punit : get_units_in_focus()) {
2060  /* FIXME: this can provide different actions for different units...
2061  * not good! */
2062  struct extra_type *tgt = next_extra_for_tile(unit_tile(punit), EC_ROAD,
2063  unit_owner(punit), punit);
2064  bool building_road = false;
2065 
2066  if (tgt != nullptr
2067  && can_unit_do_activity_targeted(punit, ACTIVITY_GEN_ROAD, tgt)) {
2068  request_new_unit_activity_targeted(punit, ACTIVITY_GEN_ROAD, tgt);
2069  building_road = true;
2070  }
2071 
2072  if (!building_road && unit_can_est_trade_route_here(punit)) {
2073  request_unit_caravan_action(punit, ACTION_TRADE_ROUTE);
2074  }
2075  }
2076 }
2077 
2082 
2087 
2092 
2097 
2102 
2107 
2112 
2117 
2122 {
2123  if (get_num_units_in_focus() != 1) {
2124  return;
2125  }
2126  for (const auto punit : get_units_in_focus()) {
2127  auto ask = new hud_input_box(king()->central_wdg);
2128 
2129  ask->set_text_title_definput(_("New unit name:"), _("Rename Unit"),
2130  punit->name);
2131  ask->setAttribute(Qt::WA_DeleteOnClose);
2132 
2133  int id = punit->id;
2134  connect(ask, &QDialog::accepted, [ask, id]() {
2135  // Unit might have been removed, make sure it's still there
2136  auto unit = game_unit_by_number(id);
2137  if (unit) {
2138  dsend_packet_unit_rename(&client.conn, id,
2139  ask->input_edit.text().toUtf8());
2140  }
2141  });
2142  ask->show();
2143  }
2144 }
2145 
2150 {
2151  delayed_order = false;
2152  units_list.clear();
2153 }
2154 
2159 {
2160  king()->rallies.hover_tile = false;
2161  king()->rallies.hover_city = true;
2162 }
2163 
2168 
2173 
2178 
2183 
2188 {
2189  struct unit *punit;
2190  struct city *homecity;
2191  struct tile *home_tile;
2192  struct tile *dest_tile;
2193  bool sent = false;
2194 
2195  punit = head_of_units_in_focus();
2196  homecity = game_city_by_number(punit->homecity);
2197  home_tile = homecity->tile;
2198  for (auto gilles : qAsConst(king()->trade_gen.lines)) {
2199  if ((gilles.t1 == home_tile || gilles.t2 == home_tile)
2200  && gilles.autocaravan == nullptr) {
2201  // send caravan
2202  if (gilles.t1 == home_tile) {
2203  dest_tile = gilles.t2;
2204  } else {
2205  dest_tile = gilles.t1;
2206  }
2207  if (send_goto_tile(punit, dest_tile)) {
2208  int i;
2209  i = king()->trade_gen.lines.indexOf(gilles);
2210  gilles = king()->trade_gen.lines.takeAt(i);
2211  gilles.autocaravan = punit;
2212  king()->trade_gen.lines.append(gilles);
2213  sent = true;
2214  break;
2215  }
2216  }
2217  }
2218 
2219  if (!sent) {
2220  queen()->chat->append(_("Didn't find any trade route to establish"));
2221  }
2222 }
2223 
2228 {
2229  QVariant v;
2230  QAction *act;
2231 
2232  act = qobject_cast<QAction *>(sender());
2233  v = act->data();
2234  airlift_type_id = v.toInt();
2235 }
2236 
2241 {
2242  QAction *act;
2243 
2244  act = qobject_cast<QAction *>(sender());
2245  qdef_act::action()->vs_unit_set(act->data().toInt());
2246 }
2247 
2252 {
2253  QAction *act;
2254 
2255  act = qobject_cast<QAction *>(sender());
2256  qdef_act::action()->vs_city_set(act->data().toInt());
2257 }
2258 
2263 
2268 {
2269  delay_order dg;
2270 
2271  delayed_order = true;
2272  dg = D_GOTO;
2273 
2274  const auto &focus = get_units_in_focus();
2275  if (focus.empty()) {
2276  return;
2277  }
2278  if (hover_state != HOVER_GOTO) {
2279  set_hover_state(focus, HOVER_GOTO, ACTIVITY_LAST, nullptr, NO_TARGET,
2281  enter_goto_state(focus);
2283  control_mouse_cursor(nullptr);
2284  }
2285  for (const auto punit : focus) {
2286  units_list.emplace_back(dg, punit->id);
2287  }
2288 }
2289 
2294 {
2295  struct unit *punit;
2296  struct tile *last_tile;
2297  struct tile *new_tile;
2298  int i = 0;
2299 
2300  for (const auto &fui : units_list) {
2301  i++;
2302  punit = unit_list_find(client_player()->units, fui.id);
2303  if (punit == nullptr) {
2304  continue;
2305  }
2306  last_tile = punit->tile;
2307  new_tile = find_last_unit_pos(punit, i);
2308  if (new_tile != nullptr) {
2309  punit->tile = new_tile;
2310  }
2311  if (is_tiles_adjacent(punit->tile, fui.ptile)) {
2313  punit, get_direction_for_step(&(wld.map), punit->tile, fui.ptile));
2314  } else {
2315  send_attack_tile(punit, fui.ptile);
2316  }
2317  punit->tile = last_tile;
2318  }
2319  units_list.clear();
2320 }
2321 
2326 {
2327  for (const auto punit : get_units_in_focus()) {
2328  request_transport(punit, unit_tile(punit));
2329  }
2330 }
2331 
2336 
2341 
2346 
2351 {
2352  for (const auto punit : get_units_in_focus()) {
2353  request_unit_unload(punit);
2354  }
2355 }
2356 
2361 
2366 
2371 
2376 
2381 
2386 
2391 {
2392  if (king()->interface_locked) {
2393  enable_interface(false);
2394  } else {
2395  enable_interface(true);
2396  }
2398 }
2399 
2403 void enable_interface(bool enable)
2404 {
2405  QList<close_widget *> lc;
2406  QList<move_widget *> lm;
2407  int i;
2408 
2409  lc = king()->findChildren<close_widget *>();
2410  lm = king()->findChildren<move_widget *>();
2411 
2412  for (i = 0; i < lc.size(); ++i) {
2413  lc.at(i)->setVisible(!enable);
2414  }
2415  for (i = 0; i < lm.size(); ++i) {
2416  lm.at(i)->setVisible(!enable);
2417  }
2418 }
2419 
2424 {
2427  king()->setWindowState(king()->windowState() | Qt::WindowFullScreen);
2428  } else {
2429  king()->setWindowState(king()->windowState() & ~Qt::WindowFullScreen);
2430  }
2431 }
2432 
2437 {
2438  king()->qt_settings.show_new_turn_text = osd_status->isChecked();
2439 }
2440 
2445 {
2446  king()->qt_settings.show_battle_log = btlog_status->isChecked();
2447 }
2448 
2453 
2458 
2463 
2468 
2473 {
2476 }
2477 
2482 
2487 
2492 {
2493  for (auto *a : action_citybar->actions()) {
2494  if (a->isChecked()) {
2496  qUtf8Printable(a->data().toString()),
2498  options_iterate(client_optset, poption)
2499  {
2500  if (QString(option_name(poption))
2501  == QLatin1String("default_city_bar_style_name")) {
2503  }
2504  }
2506  }
2507  }
2508 }
2509 
2514 
2519 
2524 
2529 
2534 
2539 {
2541 }
2542 
2547 {
2549 }
2550 
2555 {
2557 }
2558 
2563 {
2565 }
2566 
2571 {
2573 }
2574 
2579 
2584 {
2585  unit_hud_selector *uhs;
2586  uhs = new unit_hud_selector(king()->central_wdg);
2587  uhs->show_me();
2588 }
2589 
2594 {
2596 }
2597 
2602 {
2604 }
2605 
2610 
2615 
2620 {
2622 }
2623 
2628 {
2629  QDialog *dialog = new QDialog(this);
2630  QLabel *label;
2631  QPushButton *but;
2632  QVBoxLayout *layout;
2633  const struct option *poption;
2634  QStringList sl;
2635 
2636  sl << QStringLiteral("default_tileset_square_name")
2637  << QStringLiteral("default_tileset_hex_name")
2638  << QStringLiteral("default_tileset_isohex_name");
2639  layout = new QVBoxLayout;
2640  dialog->setWindowTitle(_("Available tilesets"));
2641  label = new QLabel;
2642  label->setText(_("Some tilesets might not be compatible with current"
2643  " map topology!"));
2644  layout->addWidget(label);
2645 
2646  // Gather the list of tilesets
2647  QStringList tilesets;
2648  for (auto const &s : qAsConst(sl)) {
2649  poption = optset_option_by_name(client_optset, qUtf8Printable(s));
2650  for (const auto &name : qAsConst(*get_tileset_list(poption))) {
2651  tilesets.append(name);
2652  }
2653  }
2654 
2655  // Remove duplicates
2656  tilesets.sort();
2657  tilesets.erase(std::unique(tilesets.begin(), tilesets.end()),
2658  tilesets.end());
2659 
2660  // Add the buttons
2661  for (const auto &name : qAsConst(tilesets)) {
2662  but = new QPushButton(name);
2663  connect(but, &QAbstractButton::clicked, this,
2665  layout->addWidget(but);
2666  }
2667  dialog->setSizeGripEnabled(true);
2668  dialog->setLayout(layout);
2669  dialog->show();
2670 }
2671 
2676 {
2677  auto dialog = new freeciv::tileset_options_dialog(tileset, this);
2678  dialog->show();
2679 }
2680 
2685 
2690 {
2691  QPushButton *but;
2692  QByteArray tn_bytes;
2693 
2694  but = qobject_cast<QPushButton *>(sender());
2695  tn_bytes = but->text().toLocal8Bit();
2696  tilespec_reread(tn_bytes.data(), true);
2697  queen()->mapview_wdg->set_scale(1.0);
2698  but->parentWidget()->close();
2699 }
2700 
2705 
2710 
2714 void mr_menu::slot_help(const QString &topic)
2715 {
2716  popup_help_dialog_typed(Q_(topic.toStdString().c_str()), HELP_ANY);
2717 }
2718 
2723 {
2724  for (const auto punit : get_units_in_focus()) {
2725  extra_type_by_cause_iterate(EC_ROAD, pextra)
2726  {
2727  if (pextra->buildable && pextra->id == id
2728  && can_unit_do_activity_targeted(punit, ACTIVITY_GEN_ROAD,
2729  pextra)) {
2730  request_new_unit_activity_targeted(punit, ACTIVITY_GEN_ROAD, pextra);
2731  }
2732  }
2734  }
2735 }
2736 
2741 {
2742  for (const auto punit : get_units_in_focus()) {
2743  extra_type_by_cause_iterate(EC_BASE, pextra)
2744  {
2745  if (pextra->buildable && pextra->id == id
2746  && can_unit_do_activity_targeted(punit, ACTIVITY_BASE, pextra)) {
2747  request_new_unit_activity_targeted(punit, ACTIVITY_BASE, pextra);
2748  }
2749  }
2751  }
2752 }
2753 
2757 bool mr_menu::event(QEvent *event)
2758 {
2759  if (event->type() == TilesetChanged) {
2761  }
2762  return QMenuBar::event(event);
2763 }
2764 
2769 
2774 
2779 {
2780  option_dialog_popup(_("Game Options"), server_optset);
2781 }
2782 
2787 
2792 
2797 
2802 {
2803  // Save the size of the map view
2804  QSize current = queen()->mapview_wdg->size();
2805 
2806  // The size of the image we want to render
2807  QSize full_size((wld.map.xsize + 2) * tileset_tile_width(tileset),
2810  full_size.rheight() /= 2;
2811  }
2812 
2813  auto renderer = new freeciv::renderer;
2814  renderer->set_viewport_size(full_size);
2815 
2816  // Wait for a fullscreen repaint_needed. It will come asynchronously.
2817  connect(
2819  [=](const QRegion &where) {
2820  // Maybe some other update sneaked in -- make sure to ignore it
2821  if (where.boundingRect().contains(QRect(QPoint(), full_size))) {
2822  // File path
2823  QString img_name =
2824  QStringLiteral("Freeciv21-Turn%1").arg(game.info.turn);
2825  if (client_has_player()) {
2826  img_name += QStringLiteral("-")
2828  }
2829 
2830  auto path = QStandardPaths::writableLocation(
2831  QStandardPaths::PicturesLocation);
2832  if (path.isEmpty() || !QDir(path).exists()) {
2833  path = QStandardPaths::writableLocation(
2834  QStandardPaths::HomeLocation);
2835  }
2836  if (path.isEmpty() || !QDir(path).exists()) {
2837  path = freeciv_storage_dir();
2838  }
2839  img_name =
2840  path + QStringLiteral("/") + img_name + QStringLiteral(".png");
2841 
2842  // Render
2843  auto pixmap = QPixmap(full_size);
2844  pixmap.fill(Qt::black);
2845 
2846  auto painter = QPainter(&pixmap);
2847  renderer->render(painter, QRect(pixmap.rect()));
2848  renderer->deleteLater();
2849 
2850  // Save
2851  bool map_saved = pixmap.save(img_name, "png");
2852 
2853  // Restore the old mapview size
2854  map_canvas_resized(current.width(), current.height());
2855 
2856  // Let the user know
2857  hud_message_box *saved = new hud_message_box(king()->central_wdg);
2858  saved->setStandardButtons(QMessageBox::Ok);
2859  saved->setDefaultButton(QMessageBox::Ok);
2860  saved->setAttribute(Qt::WA_DeleteOnClose);
2861  if (map_saved) {
2862  saved->set_text_title(_("Image saved as:\n") + img_name,
2863  _("Success"));
2864  } else {
2865  saved->set_text_title(_("Failed to save image of the map"),
2866  _("Error"));
2867  }
2868  saved->show();
2869  }
2870  });
2871 }
2872 
2877 
2882 {
2883  QString str;
2884  QString current_file;
2885  QString location;
2886 
2887  for (const auto &dirname : get_save_dirs()) {
2888  location = dirname;
2889  // choose last location
2890  }
2891 
2892  str = QString(_("Save Games"))
2893  + QStringLiteral(" (*.sav *.sav.bz2 *.sav.gz *.sav.xz *.sav.zst)");
2894  current_file = QFileDialog::getSaveFileName(
2895  king()->central_wdg, _("Save Game As..."), location, str);
2896  if (!current_file.isEmpty()) {
2897  QByteArray cf_bytes;
2898 
2899  cf_bytes = current_file.toLocal8Bit();
2900  send_save_game(cf_bytes.data());
2901  }
2902 }
2903 
2908 {
2909  hud_message_box *ask;
2910 
2911  if (is_server_running()) {
2912  ask = new hud_message_box(king()->central_wdg);
2913  ask->set_text_title(
2914  _("Do you want to leave the game?\n\nLeaving a single-player game "
2915  "will end it. Be sure to save first."),
2916  QStringLiteral("Leave Game"));
2917  ask->setStandardButtons(QMessageBox::No | QMessageBox::Yes);
2918  ask->setDefaultButton(QMessageBox::No);
2919  ask->button(QMessageBox::No)->setText(_("Keep Playing"));
2920  ask->button(QMessageBox::Yes)->setText(_("Leave"));
2921  ask->setAttribute(Qt::WA_DeleteOnClose);
2922 
2923  connect(ask, &hud_message_box::accepted, [=]() {
2924  if (client.conn.used) {
2925  disconnect_from_server();
2926  }
2927  });
2928  ask->show();
2929  } else {
2931  }
2932 }
2933 
2937 void multiairlift(struct city *acity, Unit_type_id ut)
2938 {
2939  struct tile *ptile;
2941  {
2942  if (get_city_bonus(pcity, EFT_AIRLIFT) > 0) {
2943  ptile = city_tile(pcity);
2944  unit_list_iterate(ptile->units, punit)
2945  {
2946  if (punit->utype == utype_by_number(ut)) {
2947  request_unit_airlift(punit, acity);
2948  break;
2949  }
2950  }
2952  }
2953  }
2955 }
bool action_removes_extra(const struct action *paction, const struct extra_type *pextra)
Returns TRUE iff the specified action can remove the specified extra.
Definition: actions.cpp:1732
static struct action * actions[MAX_NUM_ACTIONS]
Definition: actions.cpp:91
enum action_sub_target_kind action_get_sub_target_kind(const struct action *paction)
Get the sub target kind of an action.
Definition: actions.cpp:1209
const QString action_name_translation(const struct action *action)
Get the action name used when displaying the action in the UI.
Definition: actions.cpp:1353
bool actions_are_ready()
Returns TRUE iff the actions are initialized.
Definition: actions.cpp:1037
const QString action_id_name_translation(action_id act_id)
Get the action name used when displaying the action in the UI.
Definition: actions.cpp:1373
struct action * action_by_number(action_id act_id)
Return the action with the given id.
Definition: actions.cpp:1149
bool action_creates_extra(const struct action *paction, const struct extra_type *pextra)
Returns TRUE iff the specified action can create the specified extra.
Definition: actions.cpp:1649
#define action_iterate_end
Definition: actions.h:383
#define action_id_get_actor_kind(act_id)
Definition: actions.h:519
#define action_iterate(_act_)
Definition: actions.h:378
#define ACTION_ANY
Definition: actions.h:217
#define action_id_get_target_kind(act_id)
Definition: actions.h:522
#define action_id_has_complex_target(act_id)
Definition: actions.h:542
#define ACTION_NONE
Definition: actions.h:220
struct city * is_non_allied_city_tile(const struct tile *ptile, const struct player *pplayer)
Is there an non_allied city on this tile?
Definition: city.cpp:1968
struct tile * city_tile(const struct city *pcity)
Return the tile location of the city.
Definition: city.cpp:1095
#define city_list_iterate(citylist, pcity)
Definition: city.h:482
#define city_list_iterate_end
Definition: city.h:484
void city_report_dialog_popup()
Display the city report dialog.
void append(const QString &str)
Adds news string to chat_widget.
Definition: chatline.cpp:596
static void option_changed(option *opt)
Called by the option code when the option has changed.
Definition: citybar.cpp:286
static const QVector< QString > * available_vector(const option *)
Returns the list of all available city bar styles.
Definition: citybar.cpp:271
void load_modpack()
Load the modpack-installer from the start menu.
Definition: fc_client.cpp:695
bool interface_locked
Definition: fc_client.h:124
trade_generator trade_gen
Definition: fc_client.h:129
fc_settings qt_settings
Definition: fc_client.h:126
mr_menu * menu_bar
Definition: fc_client.h:127
qfc_rally_list rallies
Definition: fc_client.h:128
static fc_shortcuts * sc()
Returns given instance.
Definition: shortcuts.cpp:354
Renders the map on widgets.
Definition: renderer.h:20
void repaint_needed(const QRegion &where)
void set_viewport_size(const QSize &size)
Instructs the renderer to draw a viewport with a different size.
Definition: renderer.cpp:60
Lets the user toggle tileset options.
static void update_all()
Update all goto and act menu instances.
Definition: menu.cpp:484
go_act_menu(QWidget *parent=0)
Instantiate a new goto and act sub menu.
Definition: menu.cpp:264
~go_act_menu() override
Destructor.
Definition: menu.cpp:273
void start_go_act(int act_id, int sub_tgt_id)
Activate the goto system.
Definition: menu.cpp:461
void reset()
Reset the goto and act menu so it will be recreated.
Definition: menu.cpp:301
static QSet< go_act_menu * > instances
Store all goto and act menu items so they can be updated etc.
Definition: menu.h:135
void update()
Update the goto and act menu based on the selected unit(s)
Definition: menu.cpp:421
static void reset_all()
Reset all goto and act menu instances.
Definition: menu.cpp:474
void create()
Fill the new goto and act sub menu with menu items.
Definition: menu.cpp:313
QMap< QAction *, int > items
Definition: menu.h:137
Definition: menu.h:109
static QSet< gov_menu * > instances
Keeps track of all gov_menu instances.
Definition: menu.h:111
static void create_all()
Updates all gov_menu instances.
Definition: menu.cpp:244
void revolution()
Shows the dialog asking for confirmation before starting a revolution.
Definition: menu.cpp:223
QVector< QAction * > actions
Definition: menu.h:113
static void update_all()
Updates all gov_menu instances.
Definition: menu.cpp:254
void change_gov(int target_gov)
Shows the dialog asking for confirmation before starting a revolution.
Definition: menu.cpp:231
~gov_menu() override
Destructor.
Definition: menu.cpp:150
gov_menu(QWidget *parent=0)
Creates a new government menu.
Definition: menu.cpp:140
void create()
Creates the menu once the government list is known.
Definition: menu.cpp:159
void update()
Updates the menu to take gov availability into account.
Definition: menu.cpp:199
void set_text_title(const QString &s1, const QString &s2)
Sets text and title and shows message box.
Definition: hudwidget.cpp:117
void update_actions()
Update possible action for given units.
Definition: hudwidget.cpp:552
void zoom_out()
Zooms out by 20%.
Definition: view_map.cpp:243
void zoom_reset()
Resets the zoom level.
Definition: view_map.cpp:238
void show_debugger()
Opens the tileset debugger.
Definition: view_map.cpp:278
void set_scale(double scale, bool animate=true)
Sets the map scale.
Definition: view_map.cpp:253
void zoom_in()
Zooms in by 20%.
Definition: view_map.cpp:233
The panel at the bottom right of the game screen, holding the minimap and the Turn Done button.
Definition: minimap_panel.h:23
void set_minimap_visible(bool visible)
Shows or hides the minimap.
void slot_unit_sentry()
Action "SENTRY".
Definition: menu.cpp:2106
QActionGroup * action_vs_city
Definition: menu.h:166
void slot_traveler()
Action "SHOW WONDERS REPORT".
Definition: menu.cpp:2619
void slot_delayed_goto()
Delayed goto.
Definition: menu.cpp:2267
void slot_autocaravan()
Sends automatic caravan.
Definition: menu.cpp:2187
QMenu * multiplayer_menu
Definition: menu.h:162
void slot_build_irrigation()
Action "BUILD_IRRIGATION".
Definition: menu.cpp:2081
void slot_execute_orders()
Executes stored orders.
Definition: menu.cpp:2293
void update_bases_menu()
Updates "build bases" menu.
Definition: menu.cpp:1410
void tileset_custom_load()
Shows rulesets to load.
Definition: menu.cpp:2627
void update_roads_menu()
Updates "build path" menu.
Definition: menu.cpp:1361
void slot_calculate()
Trade calculation slot.
Definition: menu.cpp:2177
void slot_conn_road()
Action "CONNECT WITH ROAD".
Definition: menu.cpp:2022
void slot_conn_irrigation()
Action "CONNECT WITH IRRIGATION".
Definition: menu.cpp:1981
QMenu * bases_menu
Definition: menu.h:160
void clear_menus()
Clears all menus, making sure them and their actions are deleted.
Definition: menu.cpp:1270
QActionGroup * airlift_type
Definition: menu.h:165
void slot_quickairlift_set()
Slot for setting quick airlift.
Definition: menu.cpp:2227
void slot_battlelog()
Action "Show/Dont battle log".
Definition: menu.cpp:2444
void add_modpacks()
Slot for loading modpack installer.
Definition: menu.cpp:2684
void slot_trade_add_all()
Adds all cities to trade planning.
Definition: menu.cpp:2172
void update_airlift_menu()
Updates airlift menu.
Definition: menu.cpp:1321
void slot_transform()
Action "TRANSFROM TERRAIN".
Definition: menu.cpp:2037
void slot_action_vs_unit()
Slot for choosing default action vs unit.
Definition: menu.cpp:2240
void slot_achievements()
Action "SHOW ACHIEVEMENTS REPORT".
Definition: menu.cpp:2601
void slot_show_research_tab()
Slot for showing research tab.
Definition: menu.cpp:1915
void shortcut_options()
Invoke dialog with shortcut options.
Definition: menu.cpp:2773
void slot_city_output()
Action "SHOW CITY OUTPUT".
Definition: menu.cpp:2513
QMenu * airlift_menu
Definition: menu.h:159
QAction * osd_status
Definition: menu.h:188
void slot_unload_all()
Action "UNLOAD ALL UNITS FROM TRANSPORTER".
Definition: menu.cpp:2360
void slot_airlift()
Action "GOTO/AIRLIFT TO CITY".
Definition: menu.cpp:2340
void slot_select_same_continent()
Action "SELLECT SAME UNITS ON CONTINENT".
Definition: menu.cpp:2554
void slot_city_production()
Action "SHOW CITY PRODUCTION".
Definition: menu.cpp:2518
void slot_set_home()
Action "SET HOMECITY".
Definition: menu.cpp:2345
QAction * lock_status
Definition: menu.h:187
void slot_native_tiles()
Action "SHOW NATIVE TILES".
Definition: menu.cpp:2457
void slot_unit_explore()
Action "EXPLORE".
Definition: menu.cpp:2380
void slot_upgrade()
Action "UPGRADE UNITS".
Definition: menu.cpp:2370
bool shortcut_exists(const fc_shortcut &fcs, QString &where)
Returns string assigned to shortcut or empty string if doesnt exist.
Definition: menu.cpp:1298
bool event(QEvent *event) override
Reimplemented virtual function.
Definition: menu.cpp:2757
void slot_popup_mult_rates()
Action "MULTIPLERS RATES".
Definition: menu.cpp:2709
void slot_select_same_everywhere()
Action "SELECT SAME TYPE EVERYWHERE".
Definition: menu.cpp:2562
void slot_map_grid()
Action "SHOW MAP GRID".
Definition: menu.cpp:2528
void slot_unit_filter()
Shows units filter.
Definition: menu.cpp:2583
void show_tileset_options()
Slot for loading modpack installer.
Definition: menu.cpp:2675
void slot_clean_pollution()
Action "CLEAN POLLUTION and PARADROP".
Definition: menu.cpp:1959
void slot_done_moving()
Action "DONE MOVING".
Definition: menu.cpp:2533
void slot_city_buycost()
Action "SHOW BUY COST".
Definition: menu.cpp:2462
void slot_load()
Action "LOAD INTO TRANSPORTER".
Definition: menu.cpp:2325
void slot_action()
Do...
Definition: menu.cpp:2047
void slot_unload()
Action "UNLOAD FROM TRANSPORTED".
Definition: menu.cpp:2350
QMenu * roads_menu
Definition: menu.h:163
QAction * minimap_status
Definition: menu.h:185
void slot_select_all_tile()
Action "SELECT ALL UNITS ON TILE".
Definition: menu.cpp:2538
void save_game()
Menu Save Game.
Definition: menu.cpp:2876
struct tile * find_last_unit_pos(struct unit *punit, int pos)
Predicts last unit position.
Definition: menu.cpp:494
void save_image()
Menu Save Map Image.
Definition: menu.cpp:2801
void slot_pillage()
Action "PILLAGE".
Definition: menu.cpp:2042
void slot_center_view()
Action "CENTER VIEW".
Definition: menu.cpp:2385
void slot_build_mine()
Action "BUILD_MINE".
Definition: menu.cpp:2091
void server_options()
Invoke dialog with server options.
Definition: menu.cpp:2778
void load_new_tileset()
Slot for loading new tileset.
Definition: menu.cpp:2689
void slot_rename()
Action "RENAME UNIT".
Definition: menu.cpp:2121
std::vector< qfc_delayed_unit_item > units_list
Definition: menu.h:172
void set_tile_for_order(struct tile *ptile)
Sets given tile for delayed order.
Definition: menu.cpp:1288
void slot_fullscreen()
Action "SET FULLSCREEN".
Definition: menu.cpp:2423
void slot_top_five()
Action "SHOW TOP FIVE CITIES".
Definition: menu.cpp:2614
void slot_build_road()
Action "BUILD_ROAD".
Definition: menu.cpp:2057
QActionGroup * action_citybar
Definition: menu.h:168
void slot_unsentry()
Action "UNSENTRY(WAKEUP) ALL UNITS".
Definition: menu.cpp:2365
void slot_show_new_turn_text()
Action "Show/Dont show new turn info".
Definition: menu.cpp:2436
void local_options()
Invoke dialog with interface (local) options.
Definition: menu.cpp:2768
QMenu * menu
Definition: menu.h:161
bool delayed_order
Definition: menu.h:192
void slot_borders()
Action "SHOW BORDERS".
Definition: menu.cpp:2452
void slot_clear_trade()
Slot for clearing trade routes.
Definition: menu.cpp:2182
void zoom_scale_fonts()
Action "SCALE FONTS WHEN SCALING MAP".
Definition: menu.cpp:2472
void slot_conn_rail()
Action "CONNECT WITH RAILROAD".
Definition: menu.cpp:1997
void slot_select_same_tile()
Action "SELECT SAME TYPE ON TILE".
Definition: menu.cpp:2570
void slot_convert()
Action "CONVERT".
Definition: menu.cpp:2111
QMenu * action_unit_menu
Definition: menu.h:169
QMenu * citybar_submenu
Definition: menu.h:164
QActionGroup * action_vs_unit
Definition: menu.h:167
void slot_endgame()
Action "SHOW ENDGAME REPORT".
Definition: menu.cpp:2609
void slot_select_one()
Action "SELECT ONE UNITS/DESELECT OTHERS".
Definition: menu.cpp:2546
void menus_sensitive()
Enables/disables menu items and renames them depending on key in menu_list.
Definition: menu.cpp:1519
void slot_set_citybar()
Action "Citybar changed".
Definition: menu.cpp:2491
void messages_options()
Invoke dialog with messages options.
Definition: menu.cpp:2786
void slot_unit_goto()
Action "GOTO".
Definition: menu.cpp:2375
void slot_cultivate()
Action "CULTIVATE".
Definition: menu.cpp:2086
void slot_patrol()
Action "UNIT PATROL".
Definition: menu.cpp:2335
void slot_unit_fortress()
Action "BUILD FORTRESS".
Definition: menu.cpp:2012
void slot_wait()
Action "WAIT".
Definition: menu.cpp:2578
void slot_demographics()
Action "SHOW DEMOGRAPGHICS REPORT".
Definition: menu.cpp:2593
void slot_build_city()
Action "BUILD_CITY".
Definition: menu.cpp:1935
void slot_city_growth()
Action "SHOW CITY GROWTH".
Definition: menu.cpp:2467
void slot_rally()
Sets/unset rally point.
Definition: menu.cpp:2158
void slot_city_traderoutes()
Action "SHOW CITY TRADEROUTES".
Definition: menu.cpp:2523
void slot_plant()
Action "PLANT".
Definition: menu.cpp:2096
void slot_build_path(int id)
Actions "BUILD_PATH_*".
Definition: menu.cpp:2722
Unit_type_id airlift_type_id
Definition: menu.h:194
void slot_show_map()
Changes tab to mapview.
Definition: menu.cpp:1930
QAction * scale_fonts_status
Definition: menu.h:186
void slot_trade_city()
Adds one city to trade planning.
Definition: menu.cpp:2167
void quit_game()
Invoke popup for quiting game.
Definition: menu.cpp:2796
void slot_help(const QString &topic)
Actions "HELP_*".
Definition: menu.cpp:2714
void save_game_as()
Menu Save Game As...
Definition: menu.cpp:2881
bool quick_airlifting
Definition: menu.h:193
QAction * tileset_options
Definition: menu.h:184
void slot_spaceship()
Slot for showing spaceship.
Definition: menu.cpp:1920
QMultiHash< munit, QAction * > menu_list
Definition: menu.h:171
void slot_city_names()
Action "SHOW CITY NAMES".
Definition: menu.cpp:2481
void slot_clean_fallout()
Action "CLEAN FALLOUT".
Definition: menu.cpp:1954
QMenu * action_city_menu
Definition: menu.h:170
void save_options_now()
Menu Save Options Now.
Definition: menu.cpp:2791
QAction * btlog_status
Definition: menu.h:189
void slot_unit_fortify()
Action "FORTIFY".
Definition: menu.cpp:2101
void slot_quickairlift()
Slot for quick airlifting.
Definition: menu.cpp:2262
void slot_lock()
Action "Lock interface".
Definition: menu.cpp:2390
void back_to_menu()
Back to Main Menu.
Definition: menu.cpp:2907
void slot_popup_tax_rates()
Action "NATIONAL BUDGET".
Definition: menu.cpp:2704
void slot_auto_settler()
Action "AUTO_SETTLER".
Definition: menu.cpp:2052
void slot_build_base(int id)
Actions "BUILD_BASE_*".
Definition: menu.cpp:2740
void setup_menus()
Initializes menu system, and add custom enum(munit) for most of options Notice that if you set option...
Definition: menu.cpp:542
mr_menu()
Constructor for global menubar in gameview.
Definition: menu.cpp:535
void slot_action_vs_city()
Slot for choosing default action vs city.
Definition: menu.cpp:2251
void slot_disband()
Action "DISBAND UNIT".
Definition: menu.cpp:2116
bool initialized
Definition: menu.h:173
void slot_unit_airbase()
Action "BUILD AIRBASE".
Definition: menu.cpp:2017
void slot_city_outlines()
Action "SHOW CITY OUTLINES".
Definition: menu.cpp:2486
void slot_orders_clear()
Clears delayed orders.
Definition: menu.cpp:2149
void nonunit_sensitivity()
Definition: menu.cpp:1458
map_view * mapview_wdg
Definition: page_game.h:81
chat_widget * chat
Definition: page_game.h:80
hud_units * unitinfo_wdg
Definition: page_game.h:77
void popup_budget_dialog()
Popup (or raise) the (tax/science/luxury) rates selection dialog.
Definition: page_game.cpp:281
static qdef_act * action()
Returns instance of qdef_act.
Definition: dialogs.cpp:807
void vs_city_set(int i)
Sets default action vs city.
Definition: dialogs.cpp:827
void vs_unit_set(int i)
Sets default action vs unit.
Definition: dialogs.cpp:832
bool hover_city
Definition: menu.h:84
bool hover_tile
Definition: menu.h:83
void add_all_cities()
Adds all cities to trade generator.
void clear_trade_planing()
Clears genrated routes, virtual cities, cities.
QList< qtiles > lines
void calculate()
Finds trade routes to establish.
void show_me()
Shows and moves to center unit_hud_selector.
enum client_states client_state()
Return current client state.
bool client_has_player()
Either controlling or observing.
struct player * client_player()
Either controlling or observing.
struct civclient client
bool can_client_issue_orders()
Returns TRUE iff the client can issue orders (such as giving unit commands).
bool client_is_observer()
Returns whether client is observer.
void send_report_request(enum report_type type)
Send request for some report to server.
bool is_waiting_turn_change()
Are we in turn-change wait state?
@ C_S_RUNNING
Definition: client_main.h:43
bool can_units_do_connect(const std::vector< unit * > &units, enum unit_activity activity, struct extra_type *tgt)
Returns TRUE if any of the units can do the connect activity.
Definition: climisc.cpp:1056
void disconnect_from_server()
Get rid of server connection.
Definition: clinet.cpp:219
char * extras
Definition: comments.cpp:34
bool can_client_access_hack()
Returns TRUE if the client has hack access.
bool is_server_running()
The general chain of events:
void send_save_game(const char *filename)
Send server command to save game.
void request_unit_airlift(struct unit *punit, struct city *pcity)
Send unit airlift request to server.
Definition: control.cpp:1397
void key_unit_plant()
Handle user 'plant' input.
Definition: control.cpp:3107
std::vector< unit * > & get_units_in_focus()
Returns list of units currently in focus.
Definition: control.cpp:169
void key_unit_paradrop()
Handle user 'paradrop' input.
Definition: control.cpp:2901
void key_unit_goto()
Handle user 'unit goto' input.
Definition: control.cpp:2896
void key_unit_homecity()
Handle user 'change homecity' input.
Definition: control.cpp:3041
void request_unit_caravan_action(struct unit *punit, action_id action)
Send request to do caravan action - establishing traderoute or helping in wonder building - to server...
Definition: control.cpp:1988
void key_city_names_toggle()
Handle user 'toggle city names display' input.
Definition: control.cpp:3180
void key_unit_fallout()
Handle user 'clean fallout' input.
Definition: control.cpp:3004
void key_unit_mine()
Handle user 'build mine' input.
Definition: control.cpp:3102
void key_unit_done()
Handle user 'unit done' input.
Definition: control.cpp:2891
void key_unit_wait()
Handle user 'wait' input.
Definition: control.cpp:2937
void key_unit_connect(enum unit_activity activity, struct extra_type *tgt)
Handle user pressing key for 'Connect' command.
Definition: control.cpp:2802
void key_unit_auto_settle()
Call to request (from the server) that the focus unit is put into autosettler mode.
Definition: control.cpp:2982
void key_unit_irrigate()
Handle user 'irrigate' input.
Definition: control.cpp:3082
void key_city_trade_routes_toggle()
Handle client request to toggle drawing of trade route information by the city name for cities visibl...
Definition: control.cpp:3203
void key_unit_wakeup_others()
Handle user 'wakeup others' input.
Definition: control.cpp:2942
void request_unit_goto(enum unit_orders last_order, action_id act_id, int sub_tgt_id)
Do a goto with an order at the end (or ORDER_LAST).
Definition: control.cpp:995
void key_map_native_toggle()
Toggle native tiles on the mapview on/off based on a keypress.
Definition: control.cpp:3175
void key_unit_transform()
Handle user 'transform unit' input.
Definition: control.cpp:3143
void key_unit_unload_all()
Handle user 'unload all' input.
Definition: control.cpp:2911
void request_unit_unload(struct unit *pcargo)
Send a request to the server that the cargo be unloaded from its current transporter.
Definition: control.cpp:1962
void key_unit_sentry()
Handle user 'sentry' input.
Definition: control.cpp:3131
void request_new_unit_activity_targeted(struct unit *punit, enum unit_activity act, struct extra_type *tgt)
Send request for unit activity changing to server.
Definition: control.cpp:1721
void key_city_productions_toggle()
Handle user 'toggle city production display' input.
Definition: control.cpp:3197
void request_unit_build_city(struct unit *punit)
Player pressed 'b' or otherwise instructed unit to build or add to city.
Definition: control.cpp:1599
void key_unit_auto_explore()
Handle user 'autoexplore' input.
Definition: control.cpp:2969
void key_map_grid_toggle()
Handle user 'toggle map grid' input.
Definition: control.cpp:3165
void key_city_buycost_toggle()
Toggles the showing of the buy cost of the current production in the city descriptions.
Definition: control.cpp:3192
void key_unit_convert()
Unit convert key pressed or respective menu entry selected.
Definition: control.cpp:2994
void request_unit_select(const std::vector< unit * > &punits, enum unit_select_type_mode seltype, enum unit_select_location_mode selloc)
Select all units based on the given list of units and the selection modes.
Definition: control.cpp:1484
int get_num_units_in_focus()
Return the number of units currently in focus (0 or more).
Definition: control.cpp:174
void request_center_focus_unit()
Center to focus unit.
Definition: control.cpp:2254
void key_unit_patrol()
Handle user 'patrol' input.
Definition: control.cpp:2906
void key_city_output_toggle()
Toggle drawing of city output produced by workers of the city.
Definition: control.cpp:3160
void key_unit_fortify()
Handle user 'fortify' input.
Definition: control.cpp:3012
enum cursor_hover_state hover_state
Definition: control.cpp:82
void key_unit_cultivate()
Handle user 'cultivate' input.
Definition: control.cpp:3090
void key_city_outlines_toggle()
Toggle drawing of city outlines.
Definition: control.cpp:3155
void set_hover_state(const std::vector< unit * > &units, enum cursor_hover_state state, enum unit_activity activity, struct extra_type *tgt, int last_tgt, int last_sub_tgt, action_id action, enum unit_orders order)
Enter the given hover state.
Definition: control.cpp:272
void key_unit_action_select_tgt()
Have the user select what action the unit(s) in focus should perform to the targets at the tile the u...
Definition: control.cpp:2837
void request_move_unit_direction(struct unit *punit, int dir)
This function is called whenever the player pressed an arrow key.
Definition: control.cpp:1660
void request_units_return()
Return-and-recover for a particular unit.
Definition: control.cpp:1406
void control_mouse_cursor(struct tile *ptile)
Determines which mouse cursor should be used, according to hover_state, and the information gathered ...
Definition: control.cpp:1067
void key_unit_pillage()
Handle user 'pillage' input.
Definition: control.cpp:3119
void key_unit_fortress()
Handle user 'build base of class fortress' input.
Definition: control.cpp:3024
struct unit * head_of_units_in_focus()
Return head of focus units list.
Definition: control.cpp:387
void key_map_borders_toggle()
Toggle map borders on the mapview on/off based on a keypress.
Definition: control.cpp:3170
void key_city_growth_toggle()
Toggles the "show city growth turns" option by passing off the request to another function....
Definition: control.cpp:3186
void key_unit_airbase()
Handle user 'build base of class airbase' input.
Definition: control.cpp:2952
@ SELLOC_CONT
Definition: control.h:118
@ SELLOC_TILE
Definition: control.h:117
@ SELLOC_WORLD
Definition: control.h:119
@ HOVER_GOTO
Definition: control.h:20
@ SELTYPE_SINGLE
Definition: control.h:114
@ SELTYPE_ALL
Definition: control.h:114
@ SELTYPE_SAME
Definition: control.h:114
void popup_upgrade_dialog(const std::vector< unit * > &punits)
Popup dialog for upgrade units.
Definition: dialogs.cpp:3759
bool request_transport(struct unit *pcargo, struct tile *ptile)
Unit wants to get into some transport on given tile.
Definition: dialogs.cpp:3827
void popup_revolution_dialog(struct government *government)
Popup a dialog asking if the player wants to start a revolution.
Definition: dialogs.cpp:1071
void popup_disband_dialog(const std::vector< unit * > &punits)
Pops up a dialog to confirm disband of the unit(s).
Definition: dialogs.cpp:3395
int get_city_bonus(const struct city *pcity, enum effect_type effect_type, enum vision_layer vlayer)
Returns the effect bonus at a city.
Definition: effects.cpp:688
enum event_type event
Definition: events.cpp:68
int extra_number(const struct extra_type *pextra)
Return the extra id.
Definition: extras.cpp:132
const char * extra_name_translation(const struct extra_type *pextra)
Return the (translated) name of the extra type.
Definition: extras.cpp:165
struct extra_type * prev_extra_in_tile(const struct tile *ptile, enum extra_rmcause rmcause, const struct player *pplayer, const struct unit *punit)
Returns prev extra by cause that unit or player can remove from tile.
Definition: extras.cpp:732
struct extra_type_list * extra_type_list_by_cause(enum extra_cause cause)
Returns extra type for given cause.
Definition: extras.cpp:224
struct extra_type * next_extra_for_tile(const struct tile *ptile, enum extra_cause cause, const struct player *pplayer, const struct unit *punit)
Returns next extra by cause that unit or player can build to tile.
Definition: extras.cpp:687
#define extra_type_iterate(_p)
Definition: extras.h:279
#define extra_type_iterate_end
Definition: extras.h:285
#define extra_type_by_cause_iterate_end
Definition: extras.h:307
#define extra_type_by_cause_iterate(_cause, _extra)
Definition: extras.h:299
void popup_client_options()
Popups client options.
Definition: fc_client.cpp:546
class fc_client * king()
Return fc_client instance.
Definition: gui_main.cpp:58
#define NO_TARGET
Definition: fc_types.h:271
@ ROCO_RAILROAD
Definition: fc_types.h:1067
@ ROCO_ROAD
Definition: fc_types.h:1067
int Unit_type_id
Definition: fc_types.h:299
#define Q_(String)
Definition: fcintl.h:53
#define _(String)
Definition: fcintl.h:50
struct unit * game_unit_by_number(int id)
Find unit out of all units in game: now uses fast idex method, instead of looking through all units o...
Definition: game.cpp:112
struct civ_game game
Definition: game.cpp:47
struct world wld
Definition: game.cpp:48
struct city * game_city_by_number(int id)
Often used function to get a city pointer from a city ID.
Definition: game.cpp:103
bool send_attack_tile(struct unit *punit, struct tile *ptile)
Send orders for the unit to move it to the arbitrary tile and attack everything it approaches.
Definition: goto.cpp:694
void enter_goto_state(const std::vector< unit * > &units)
Enter the goto state: activate, prepare PF-template and add the initial part.
Definition: goto.cpp:247
struct tile * tile_before_end_path(struct unit *punit, struct tile *ptile)
Finds penultimate tile on path for given unit going to ptile.
Definition: goto.cpp:888
bool send_goto_tile(struct unit *punit, struct tile *ptile)
Send orders for the unit to move it to the arbitrary tile.
Definition: goto.cpp:630
void popup_goto_dialog(void)
Definition: gotodlg.cpp:338
struct government * government_by_number(const Government_type_id gov)
Return the government with the given index.
Definition: government.cpp:96
Government_type_id government_count()
Return the number of governments.
Definition: government.cpp:64
bool can_change_to_government(struct player *pplayer, const struct government *gov)
Can change to government if appropriate tech exists, and one of:
Definition: government.cpp:159
const char * government_name_translation(const struct government *pgovern)
Return the (translated) name of the given government.
Definition: government.cpp:136
void popup_quit_dialog()
Open dialog to confirm that user wants to quit client.
Definition: gui_main.cpp:293
#define HELP_CITIES_ITEM
Definition: helpdata.h:53
#define HELP_TERRAIN_ITEM
Definition: helpdata.h:60
#define HELP_LANGUAGES_ITEM
Definition: helpdata.h:43
#define HELP_CONNECTING_ITEM
Definition: helpdata.h:44
#define HELP_TILESET_ITEM
Definition: helpdata.h:50
#define HELP_CHATLINE_ITEM
Definition: helpdata.h:45
#define HELP_RULESET_ITEM
Definition: helpdata.h:49
#define HELP_GOVERNMENT_ITEM
Definition: helpdata.h:62
#define HELP_ABOUT_ITEM
Definition: helpdata.h:67
#define HELP_PLAYING_ITEM
Definition: helpdata.h:42
#define HELP_IMPROVEMENTS_ITEM
Definition: helpdata.h:54
#define HELP_EFFECTS_ITEM
Definition: helpdata.h:63
#define HELP_UNITS_ITEM
Definition: helpdata.h:55
#define HELP_ZOC_ITEM
Definition: helpdata.h:57
#define HELP_WORKLIST_EDITOR_ITEM
Definition: helpdata.h:46
#define HELP_WONDERS_ITEM
Definition: helpdata.h:61
#define HELP_COMBAT_ITEM
Definition: helpdata.h:56
#define HELP_SPACE_RACE_ITEM
Definition: helpdata.h:65
#define HELP_COPYING_ITEM
Definition: helpdata.h:66
#define HELP_OVERVIEW_ITEM
Definition: helpdata.h:41
#define HELP_NATIONS_ITEM
Definition: helpdata.h:51
#define HELP_TECHS_ITEM
Definition: helpdata.h:58
#define HELP_DIPLOMACY_ITEM
Definition: helpdata.h:64
#define HELP_ECONOMY_ITEM
Definition: helpdata.h:52
@ HELP_ANY
Definition: helpdata.h:21
#define HELP_CMA_ITEM
Definition: helpdata.h:47
#define HELP_CONTROLS_ITEM
Definition: helpdata.h:48
void popup_help_dialog_typed(const char *item, enum help_page_type htype)
Popup the help dialog to display help on the given string topic from the given section.
Definition: helpdlg.cpp:56
bool has_player_unit_type(Unit_type_id utype)
Returns true if player has any unit of unit_type.
Definition: hudwidget.cpp:51
Impr_type_id improvement_number(const struct impr_type *pimprove)
Return the improvement index.
const char * improvement_name_translation(const struct impr_type *pimprove)
Return the (translated) name of the given improvement.
#define improvement_iterate_end
Definition: improvement.h:199
#define improvement_iterate(_p)
Definition: improvement.h:193
const char * name
Definition: inputfile.cpp:118
#define fc_assert(condition)
Definition: log.h:89
int get_direction_for_step(const struct civ_map *nmap, const struct tile *start_tile, const struct tile *end_tile)
Return the direction which is needed for a step on the map from (start_x, start_y) to (end_x,...
Definition: map.cpp:1288
bool is_tiles_adjacent(const struct tile *tile0, const struct tile *tile1)
Are two tiles adjacent to each other.
Definition: map.cpp:878
struct terrain_misc terrain_control
Definition: map.cpp:40
void create_line_at_mouse_pos()
Draw a goto or patrol line at the current mouse position.
Definition: mapctrl.cpp:68
#define ADD_OLD_SHORTCUT(wanted_action_id, sc_id)
static const char * get_tile_change_menu_text(struct tile *ptile, enum unit_activity activity)
Return the text for the tile, changed by the activity.
Definition: menu.cpp:124
static void enable_interface(bool enable)
Helper function to hide/show widgets.
Definition: menu.cpp:2403
void multiairlift(struct city *acity, Unit_type_id ut)
Airlift unit type to city acity from each city.
Definition: menu.cpp:2937
#define CREATE_SUB_ITEM(_menu_, _act_id_, _sub_tgt_id_, _sub_tgt_name_)
void real_menus_init(void)
Initialize menus (sensitivity, name, etc.) based on the current state and current ruleset,...
Definition: menu.cpp:83
void option_dialog_popup(const char *name, const struct option_set *poptset)
Popup the option dialog for the option set.
Definition: optiondlg.cpp:722
void popup_endgame_report()
Popups endgame report to front if exists.
static void reset_menu_and_sub_menues(QMenu *menu)
Empty a menu of all its items and sub menues.
Definition: menu.cpp:282
static struct extra_type * next_extra(const std::vector< unit * > &punits, extra_cause cause)
Definition: menu.cpp:1500
void real_menus_update(void)
Update all of the menus (sensitivity, name, etc.) based on the current state.
Definition: menu.cpp:101
delay_order
Definition: menu.h:70
@ D_GOTO
Definition: menu.h:70
munit
used for indicating menu about current option - for renaming and enabling, disabling
Definition: menu.h:28
@ AIRLIFT
Definition: menu.h:58
@ CONNECT_RAIL
Definition: menu.h:55
@ TRANSFORM
Definition: menu.h:41
@ FORTIFY
Definition: menu.h:45
@ GOTO_CITY
Definition: menu.h:57
@ TRANSPORTER
Definition: menu.h:33
@ BUILD
Definition: menu.h:43
@ IRRIGATION
Definition: menu.h:39
@ UNLOAD
Definition: menu.h:32
@ CONNECT_IRRIGATION
Definition: menu.h:56
@ CONNECT_ROAD
Definition: menu.h:54
@ HOMECITY
Definition: menu.h:51
@ CONVERT
Definition: menu.h:36
@ PILLAGE
Definition: menu.h:42
@ FALLOUT
Definition: menu.h:49
@ BUILD_WONDER
Definition: menu.h:59
@ DISBAND
Definition: menu.h:34
@ NOT_4_OBS
Definition: menu.h:64
@ UPGRADE
Definition: menu.h:63
@ ORDER_TRADEROUTE
Definition: menu.h:61
@ SAVE
Definition: menu.h:67
@ MULTIPLIERS
Definition: menu.h:65
@ PLANT
Definition: menu.h:38
@ POLLUTION
Definition: menu.h:48
@ WAKEUP
Definition: menu.h:52
@ MINE
Definition: menu.h:37
@ LOAD
Definition: menu.h:31
@ SENTRY
Definition: menu.h:50
@ ORDER_DIPLOMAT_DLG
Definition: menu.h:62
@ EXPLORE
Definition: menu.h:30
@ STANDARD
Definition: menu.h:29
@ ROAD
Definition: menu.h:44
@ CULTIVATE
Definition: menu.h:40
@ AUTOSETTLER
Definition: menu.h:53
@ FORTRESS
Definition: menu.h:46
@ ENDGAME
Definition: menu.h:66
@ RENAME
Definition: menu.h:35
@ AUTOTRADEROUTE
Definition: menu.h:60
@ AIRBASE
Definition: menu.h:47
void popup_messageopt_dialog(void)
Popup a window to let the user edit their message options.
Multiplier_type_id multiplier_count()
Return number of loaded multipliers in the ruleset.
Definition: multipliers.cpp:85
const char * nation_plural_for_player(const struct player *pplayer)
Return the (translated) plural noun of the given nation of a player.
Definition: nation.cpp:155
const char * option_name(const struct option *poption)
Returns the name of the option.
Definition: options.cpp:300
const struct option_set * server_optset
Definition: options.cpp:2430
client_options * gui_options
Definition: options.cpp:74
const struct option_set * client_optset
Definition: options.cpp:860
struct option * optset_option_by_name(const struct option_set *poptset, const char *name)
Returns the option corresponding of the name in this option set.
Definition: options.cpp:110
void options_save(option_save_log_callback log_cb)
Save all options.
Definition: options.cpp:4496
#define options_iterate(poptset, poption)
Definition: options.h:292
#define options_iterate_end
Definition: options.h:297
@ REPORT_WONDERS_OF_THE_WORLD
Definition: packets.h:53
@ REPORT_DEMOGRAPHIC
Definition: packets.h:55
@ REPORT_TOP_5_CITIES
Definition: packets.h:54
@ REPORT_ACHIEVEMENTS
Definition: packets.h:56
pageGame * queen()
Return game instandce.
Definition: page_game.cpp:557
void popup_multiplier_dialog()
Popups multiplier dialog.
Definition: ratesdlg.cpp:261
void science_report_dialog_popup(bool raise)
Display the science report.
void economy_report_dialog_popup()
Display the economy report.
struct road_type * road_by_compat_special(enum road_compat compat)
Return road type represented by given compatibility special, or nullptr if special does not represent...
Definition: road.cpp:152
struct extra_type * road_extra_get(const struct road_type *proad)
Return extra that road is.
Definition: road.cpp:33
const QStringList & get_save_dirs()
Returns a list of save directory paths, in the order in which they should be searched.
Definition: shared.cpp:563
QString freeciv_storage_dir()
Returns string which gives freeciv storage dir.
Definition: shared.cpp:419
void popup_shortcuts_dialog()
Popups shortcut dialog.
Definition: shortcuts.cpp:737
@ SC_PARADROP
Definition: shortcuts.h:81
@ SC_UPGRADE_UNIT
Definition: shortcuts.h:62
@ SC_BUILDIRRIGATION
Definition: shortcuts.h:66
@ SC_BUILDCITY
Definition: shortcuts.h:69
@ SC_DONE_MOVING
Definition: shortcuts.h:56
@ SC_BUILDROAD
Definition: shortcuts.h:68
@ SC_UNSENTRY_TILE
Definition: shortcuts.h:60
@ SC_CULTIVATE
Definition: shortcuts.h:67
@ SC_DO
Definition: shortcuts.h:61
@ SC_CENTER_VIEW
Definition: shortcuts.h:35
@ SC_SENTRY
Definition: shortcuts.h:70
@ SC_GOBUILDCITY
Definition: shortcuts.h:91
@ SC_NUKE
Definition: shortcuts.h:75
@ SC_AUTOEXPLORE
Definition: shortcuts.h:58
@ SC_SETHOME
Definition: shortcuts.h:63
@ SC_PLANT
Definition: shortcuts.h:65
@ SC_BUILDMINE
Definition: shortcuts.h:64
@ SC_FULLSCREEN
Definition: shortcuts.h:36
@ SC_TRADE_ROUTES
Definition: shortcuts.h:53
@ SC_CITY_OUTPUT
Definition: shortcuts.h:38
@ SC_TRANSFORM
Definition: shortcuts.h:74
@ SC_LOAD
Definition: shortcuts.h:76
@ SC_FALLOUT
Definition: shortcuts.h:94
@ SC_FORTIFY
Definition: shortcuts.h:71
@ SC_ZOOM_IN
Definition: shortcuts.h:86
@ SC_GOJOINCITY
Definition: shortcuts.h:92
@ SC_MAP_GRID
Definition: shortcuts.h:39
@ SC_MINIMAP
Definition: shortcuts.h:37
@ SC_CITY_PROD
Definition: shortcuts.h:54
@ SC_PATROL
Definition: shortcuts.h:59
@ SC_GOTO
Definition: shortcuts.h:72
@ SC_UNLOAD
Definition: shortcuts.h:77
@ SC_GOTOAIRLIFT
Definition: shortcuts.h:57
@ SC_WAIT
Definition: shortcuts.h:73
@ SC_IFACE_LOCK
Definition: shortcuts.h:79
@ SC_ZOOM_RESET
Definition: shortcuts.h:90
@ SC_ZOOM_OUT
Definition: shortcuts.h:87
@ SC_AUTOMATE
Definition: shortcuts.h:80
@ SC_CITY_NAMES
Definition: shortcuts.h:55
@ SC_NAT_BORDERS
Definition: shortcuts.h:40
@ SC_PILLAGE
Definition: shortcuts.h:93
void popup_spaceship_dialog(struct player *pplayer)
Popup (or raise) the spaceship dialog for the given player.
Definition: city.h:291
struct tile * tile
Definition: city.h:293
struct civ_game::@28::@31 client
struct packet_game_info info
Definition: game.h:80
struct government * government_during_revolution
Definition: game.h:85
int xsize
Definition: map_types.h:73
int ysize
Definition: map_types.h:73
struct connection conn
Definition: client_main.h:89
bool gui_qt_fullscreen
Definition: options.h:164
bool draw_native
Definition: options.h:141
bool draw_city_output
Definition: options.h:121
bool draw_city_names
Definition: options.h:123
bool draw_city_productions
Definition: options.h:125
bool draw_borders
Definition: options.h:140
bool draw_city_buycost
Definition: options.h:126
bool draw_units
Definition: options.h:137
bool draw_city_trade_routes
Definition: options.h:127
bool save_options_on_exit
Definition: options.h:64
bool draw_map_grid
Definition: options.h:122
bool zoom_scale_fonts
Definition: options.h:143
bool draw_city_growth
Definition: options.h:124
bool draw_city_outlines
Definition: options.h:120
char default_city_bar_style_name[512]
Definition: options.h:58
struct player * playing
Definition: connection.h:142
bool show_battle_log
Definition: fc_client.h:59
bool show_new_turn_text
Definition: fc_client.h:58
type_id type
Definition: shortcuts.h:105
QKeySequence keys
Definition: shortcuts.h:106
Definition: climisc.h:66
Option set structure.
Definition: options.cpp:88
The base class for options.
Definition: options.cpp:209
struct city_list * cities
Definition: player.h:263
Definition: road.h:54
struct terrain * irrigation_result
Definition: terrain.h:200
struct terrain * mining_result
Definition: terrain.h:204
struct terrain * transform_result
Definition: terrain.h:210
Definition: tile.h:42
char * label
Definition: tile.h:57
struct unit_list * units
Definition: tile.h:50
Definition: unit.h:134
struct tile * tile
Definition: unit.h:136
int homecity
Definition: unit.h:142
const struct unit_type * utype
Definition: unit.h:135
struct civ_map map
Definition: world_object.h:21
size_t fc_strlcpy(char *dest, const char *src, size_t n)
fc_strlcpy() provides utf-8 version of (non-standard) function strlcpy() It is intended as more user-...
Definition: support.cpp:412
Tech_type_id advance_number(const struct advance *padvance)
Return the advance index.
Definition: tech.cpp:85
const char * advance_name_translation(const struct advance *padvance)
Return the (translated) name of the given advance/technology.
Definition: tech.cpp:274
#define advance_iterate(_start, _p)
Definition: tech.h:232
#define A_FIRST
Definition: tech.h:37
#define advance_iterate_end
Definition: tech.h:238
#define T_NONE
Definition: terrain.h:50
void tile_virtual_destroy(struct tile *vtile)
Frees all memory used by the virtual tile, including freeing virtual units in the tile's unit list an...
Definition: tile.cpp:1051
bool tile_apply_activity(struct tile *ptile, Activity_type_id act, struct extra_type *tgt)
Apply an activity (Activity_type_id, e.g., ACTIVITY_TRANSFORM) to a tile.
Definition: tile.cpp:701
const char * tile_get_info_text(const struct tile *ptile, bool include_nuisances, int linebreaks)
Return a (static) string with tile name describing terrain and extras of some categories.
Definition: tile.cpp:799
struct tile * tile_virtual_new(const struct tile *ptile)
Returns a virtual tile.
Definition: tile.cpp:997
#define tile_terrain(_tile)
Definition: tile.h:93
bool tilespec_reread(const QString &name, bool game_fully_initialized)
Read a new tilespec in from scratch.
Definition: tilespec.cpp:916
bool tileset_is_isometric(const struct tileset *t)
Return whether the current tileset is isometric.
Definition: tilespec.cpp:336
QEvent::Type TilesetChanged
An event type sent to all widgets when the current tileset changes.
Definition: tilespec.cpp:719
int tileset_tile_height(const struct tileset *t)
Return the tile height of the current tileset.
Definition: tilespec.cpp:383
const QPixmap * get_government_sprite(const struct tileset *t, const struct government *gov)
Return the sprite for the government.
Definition: tilespec.cpp:3404
const QVector< QString > * get_tileset_list(const struct option *poption)
Returns a static list of tilesets available on the system by searching all data directories for files...
Definition: tilespec.cpp:725
bool tileset_has_options(const struct tileset *t)
Checks if the tileset has any user-settable options.
Definition: tilespec.cpp:3772
int tileset_tile_width(const struct tileset *t)
Return the tile width of the current tileset.
Definition: tilespec.cpp:371
void top_bar_units_view()
Click for units view, allowing to close/open.
Definition: top_bar.cpp:602
void top_bar_show_map()
Callback to show map.
Definition: top_bar.cpp:448
bool can_unit_change_homecity(const struct unit *punit)
Return TRUE iff the unit can change homecity at its current location.
Definition: unit.cpp:430
bool unit_can_est_trade_route_here(const struct unit *punit)
Return TRUE iff this unit can be disbanded at its current location to provide a trade route from the ...
Definition: unit.cpp:267
bool can_unit_paradrop(const struct unit *punit)
Return whether the unit can be paradropped - that is, if the unit is in a friendly city or on an airb...
Definition: unit.cpp:772
bool unit_can_add_or_build_city(const struct unit *punit)
Return TRUE iff this unit can add to a current city or build a new city at its current location.
Definition: unit.cpp:399
bool unit_contained_in(const struct unit *pcargo, const struct unit *ptrans)
Returns whether 'pcargo' is transported by 'ptrans', either directly or indirectly.
Definition: unit.cpp:2274
bool can_unit_do_autosettlers(const struct unit *punit)
Return whether the unit can be put in auto-settler mode.
Definition: unit.cpp:548
bool unit_can_help_build_wonder_here(const struct unit *punit)
Return TRUE unless it is known to be imposible to disband this unit at its current position to get fu...
Definition: unit.cpp:243
bool can_unit_do_activity_targeted(const struct unit *punit, enum unit_activity activity, struct extra_type *target)
Return whether the unit can do the targeted activity at its current location.
Definition: unit.cpp:842
#define unit_tile(_pu)
Definition: unit.h:371
@ ORDER_LAST
Definition: unit.h:43
@ ORDER_PERFORM_ACTION
Definition: unit.h:41
#define unit_owner(_pu)
Definition: unit.h:370
bool units_can_load(const std::vector< unit * > &units)
Returns TRUE iff any of these units can load.
Definition: unitlist.cpp:247
bool can_units_do_base_gui(const std::vector< unit * > &units, enum base_gui_type base_gui)
Returns TRUE if any of the units can build base with given gui_type.
Definition: unitlist.cpp:159
bool can_units_do_any_road(const std::vector< unit * > &units)
Returns TRUE if any of the units can build any road.
Definition: unitlist.cpp:139
bool units_can_do_action(const std::vector< unit * > &units, action_id act_id, bool can_do)
If has_flag is true, returns true iff any of the units are able to do the specified action.
Definition: unitlist.cpp:218
bool any_unit_in_city(const std::vector< unit * > &units)
Definition: unitlist.cpp:321
bool can_units_do(const std::vector< unit * > &units, bool(can_fn)(const struct unit *punit))
Return TRUE if the function returns true for any of the units.
Definition: unitlist.cpp:89
bool can_units_do_activity_targeted(const std::vector< unit * > &units, enum unit_activity activity, struct extra_type *pextra)
Returns TRUE if any of the units can do the targeted activity.
Definition: unitlist.cpp:123
bool units_are_occupied(const std::vector< unit * > &units)
Return TRUE iff any of the units is a transporter that is occupied.
Definition: unitlist.cpp:233
bool units_can_unload(const std::vector< unit * > &units)
Return TRUE iff any of these units can unload.
Definition: unitlist.cpp:261
bool units_contain_cityfounder(const std::vector< unit * > &units)
Does the list contain any cityfounder units.
Definition: unitlist.cpp:196
bool can_units_do_activity(const std::vector< unit * > &units, enum unit_activity activity)
Returns TRUE if any of the units can do the activity.
Definition: unitlist.cpp:104
bool units_have_activity_on_tile(const std::vector< unit * > &units, enum unit_activity activity)
Return TRUE iff any of the units' tiles have the activity running on them.
Definition: unitlist.cpp:278
bool units_can_upgrade(const std::vector< unit * > &units)
Return TRUE iff any of the units can be upgraded to another unit type (for money)
Definition: unitlist.cpp:294
bool units_can_convert(const std::vector< unit * > &units)
Return TRUE iff any of the units can convert to another unit type.
Definition: unitlist.cpp:308
bool units_have_type_flag(const std::vector< unit * > &units, enum unit_type_flag_id flag, bool has_flag)
If has_flag is true, returns true iff any of the units have the flag.
Definition: unitlist.cpp:181
struct unit * unit_list_find(const struct unit_list *punitlist, int unit_id)
Look for a unit with the given ID in the unit list.
Definition: unitlist.cpp:24
bool units_on_the_same_tile(const std::vector< unit * > &units)
Definition: unitlist.cpp:332
#define unit_list_iterate(unitlist, punit)
Definition: unitlist.h:25
#define unit_list_iterate_end
Definition: unitlist.h:27
const struct unit_type * unit_type_get(const struct unit *punit)
Return the unit type for this unit.
Definition: unittype.cpp:114
struct unit_type * utype_by_number(const Unit_type_id id)
Return a pointer for the unit type struct for the given unit type id.
Definition: unittype.cpp:103
const char * utype_name_translation(const struct unit_type *punittype)
Return the (translated) name of the unit type.
Definition: unittype.cpp:1256
Unit_type_id utype_index(const struct unit_type *punittype)
Return the unit type index.
Definition: unittype.cpp:82
bool can_player_build_unit_now(const struct player *p, const struct unit_type *punittype)
Whether player can build given unit somewhere; returns FALSE if unit is obsolete.
Definition: unittype.cpp:1742
bool utype_can_do_action(const struct unit_type *putype, const action_id act_id)
Return TRUE iff units of the given type can do the specified generalized (ruleset defined) action ena...
Definition: unittype.cpp:386
#define unit_type_iterate(_p)
Definition: unittype.h:785
#define unit_type_iterate_end
Definition: unittype.h:791
void map_canvas_resized(int width, int height)
Called if the map in the GUI is resized.
void update_map_canvas_visible()
Schedules an update of (only) the visible part of the map at the next unqueue_mapview_update().
void popup_players_dialog()
Display the player list dialog.