14 #include <QActionGroup>
15 #include <QApplication>
16 #include <QFileDialog>
17 #include <QMainWindow>
19 #include <QMessageBox>
20 #include <QStandardPaths>
21 #include <QVBoxLayout>
104 king()->menuBar()->setVisible(
true);
115 king()->menuBar()->setVisible(
false);
125 enum unit_activity activity)
144 setAttribute(Qt::WA_TranslucentBackground);
173 actions.reserve(gov_count + 1);
174 action = addAction(
_(
"Revolution..."));
182 for (i = 0; i < gov_count; ++i) {
184 if (gov != revol_gov) {
190 QObject::connect(
action, &QAction::triggered,
204 for (
int i = 0, j = 0; i <
actions.count(); ++i) {
206 if (gov != revol_gov) {
208 if (sprite !=
nullptr) {
209 actions[j + 1]->setIcon(QIcon(*sprite));
284 QList<QAction *>
actions = menu->actions();
287 if (
action->menu() !=
nullptr) {
290 action->menu()->deleteLater();
293 menu->removeAction(
action);
319 for (tgt_kind_group = 0; tgt_kind_group < ATK_COUNT; tgt_kind_group++) {
336 QMenu *sub_target_menu = addMenu(action_name);
337 items.insert(sub_target_menu->menuAction(), act_id);
339 #define CREATE_SUB_ITEM(_menu_, _act_id_, _sub_tgt_id_, _sub_tgt_name_) \
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_); \
368 case ASTK_EXTRA_NOT_THERE:
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); \
401 item = addAction(action_name);
410 QObject::connect(
item, &QAction::triggered, [
this, act_id]() {
423 bool can_do_something =
false;
430 if (
items.isEmpty()) {
439 QList<QAction *> keys =
items.keys();
440 for (QAction *
item : qAsConst(keys)) {
442 item->setVisible(
true);
443 can_do_something =
true;
445 item->setVisible(
false);
449 if (can_do_something) {
496 struct tile *ptile =
nullptr;
509 if (zunit ==
nullptr) {
513 if (punit == zunit) {
518 if (ptile ==
nullptr) {
547 QList<QMenu *> menus;
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));
563 act =
menu->addAction(
_(
"Save Game As..."));
565 act->setIcon(style()->standardIcon(QStyle::SP_DialogSaveButton));
567 act =
menu->addAction(
_(
"Save Map to Image"));
569 menu->addSeparator();
571 act =
menu->addAction(
_(
"Interface Options"));
573 act =
menu->addAction(
_(
"Game Options"));
575 act =
menu->addAction(
_(
"Message Options"));
577 act =
menu->addAction(
_(
"Shortcut Options"));
579 act =
menu->addAction(
_(
"Load Another Tileset"));
581 act =
menu->addAction(
_(
"Add Modpacks"));
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));
593 act =
menu->addAction(
_(
"Save Options on Exit"));
594 act->setCheckable(
true);
596 menu->addSeparator();
598 act =
menu->addAction(
_(
"Leave Game"));
599 act->setIcon(style()->standardIcon(QStyle::SP_DialogDiscardButton));
601 act =
menu->addAction(
_(
"Quit"));
602 act->setIcon(style()->standardIcon(QStyle::SP_TitleBarCloseButton));
606 menu = this->addMenu(
Q_(
"?verb:View"));
607 act =
menu->addAction(
_(
"Center View"));
610 menu->addSeparator();
611 act =
menu->addAction(
_(
"Fullscreen"));
613 act->setCheckable(
true);
616 menu->addSeparator();
626 connect(
osd_status, &QAction::triggered,
this,
637 menu->addSeparator();
638 act =
menu->addAction(
_(
"Zoom In"));
640 connect(act, &QAction::triggered,
queen()->mapview_wdg,
642 act =
menu->addAction(
_(
"Zoom Default"));
644 connect(act, &QAction::triggered,
queen()->mapview_wdg,
646 act =
menu->addAction(
_(
"Zoom Out"));
648 connect(act, &QAction::triggered,
queen()->mapview_wdg,
655 menu->addSeparator();
661 act->setCheckable(
true);
665 act->setChecked(
true);
670 act =
menu->addAction(
_(
"City Outlines"));
671 act->setCheckable(
true);
674 act =
menu->addAction(
_(
"City Output"));
675 act->setCheckable(
true);
679 act =
menu->addAction(
_(
"Map Grid"));
681 act->setCheckable(
true);
684 act =
menu->addAction(
_(
"National Borders"));
685 act->setCheckable(
true);
689 act =
menu->addAction(
_(
"Units"));
690 act->setCheckable(
true);
692 connect(act, &QAction::toggled,
this, [](
bool checked) {
696 act =
menu->addAction(
_(
"Native Tiles"));
697 act->setCheckable(
true);
699 act->setShortcut(QKeySequence(tr(
"ctrl+shift+n")));
701 act =
menu->addAction(
_(
"City Names"));
702 act->setCheckable(
true);
706 act =
menu->addAction(
_(
"City Growth"));
707 act->setCheckable(
true);
709 act->setShortcut(QKeySequence(tr(
"ctrl+o")));
711 act =
menu->addAction(
_(
"City Production Levels"));
712 act->setCheckable(
true);
716 act =
menu->addAction(
_(
"City Buy Cost"));
717 act->setCheckable(
true);
720 act =
menu->addAction(
_(
"City Traderoutes"));
721 act->setCheckable(
true);
727 menu = this->addMenu(
_(
"Select"));
728 act =
menu->addAction(
_(
"Single Unit (Unselect Others)"));
729 act->setShortcut(QKeySequence(tr(
"shift+z")));
732 act =
menu->addAction(
_(
"All on Tile"));
733 act->setShortcut(QKeySequence(tr(
"v")));
736 menu->addSeparator();
737 act =
menu->addAction(
_(
"Same Type on Tile"));
738 act->setShortcut(QKeySequence(tr(
"shift+v")));
741 act =
menu->addAction(
_(
"Same Type on Continent"));
742 act->setShortcut(QKeySequence(tr(
"shift+c")));
744 connect(act, &QAction::triggered,
this,
746 act =
menu->addAction(
_(
"Same Type Everywhere"));
747 act->setShortcut(QKeySequence(tr(
"shift+x")));
749 connect(act, &QAction::triggered,
this,
751 menu->addSeparator();
752 act =
menu->addAction(
_(
"Wait"));
753 shortcuts->link_action(
SC_WAIT, act);
756 act =
menu->addAction(
_(
"Done"));
761 act =
menu->addAction(
_(
"Advanced Unit Selection"));
762 act->setShortcut(QKeySequence(tr(
"ctrl+e")));
767 menu = this->addMenu(
_(
"Unit"));
768 act =
menu->addAction(
_(
"Go to Tile"));
769 shortcuts->link_action(
SC_GOTO, act);
776 act =
menu->addAction(
_(
"Go to Nearest City"));
777 act->setShortcut(QKeySequence(tr(
"shift+g")));
780 act =
menu->addAction(
_(
"Go to / Airlift to City..."));
784 menu->addSeparator();
785 act =
menu->addAction(
_(
"Auto Explore"));
789 act =
menu->addAction(
_(
"Patrol"));
791 act->setEnabled(
false);
794 menu->addSeparator();
795 act =
menu->addAction(
_(
"Sentry"));
799 act =
menu->addAction(
_(
"Unsentry All on Tile"));
803 menu->addSeparator();
804 act =
menu->addAction(
_(
"Load"));
805 shortcuts->link_action(
SC_LOAD, act);
808 act =
menu->addAction(
_(
"Unload"));
812 act =
menu->addAction(
_(
"Unload All From Transporter"));
813 act->setShortcut(QKeySequence(tr(
"shift+u")));
816 menu->addSeparator();
823 act =
menu->addAction(
_(
"Upgrade Unit"));
827 act =
menu->addAction(
_(
"Convert Unit"));
828 act->setShortcut(QKeySequence(tr(
"ctrl+o")));
831 act =
menu->addAction(
_(
"Disband Unit"));
832 act->setShortcut(QKeySequence(tr(
"shift+d")));
836 menu->addSeparator();
837 act =
menu->addAction(
_(
"Rename Unit"));
842 menu = this->addMenu(
_(
"Combat"));
843 act =
menu->addAction(
_(
"Fortify Unit"));
849 act->setShortcut(QKeySequence(tr(
"shift+f")));
853 act->setShortcut(QKeySequence(tr(
"shift+e")));
856 menu->addSeparator();
857 act =
menu->addAction(
_(
"Pillage"));
862 act =
menu->addAction(
_(
"Do..."));
864 shortcuts->link_action(
SC_DO, act);
868 menu = this->addMenu(
_(
"Work"));
869 act =
menu->addAction(
874 act =
menu->addAction(
_(
"Auto Settler"));
878 menu->addSeparator();
879 act =
menu->addAction(
_(
"Build Road"));
884 act =
menu->addAction(
_(
"Build Irrigation"));
888 act =
menu->addAction(
_(
"Cultivate"));
892 act =
menu->addAction(
_(
"Build Mine"));
896 act =
menu->addAction(
_(
"Plant"));
897 shortcuts->link_action(
SC_PLANT, act);
900 menu->addSeparator();
901 act =
menu->addAction(
_(
"Connect with Road"));
902 act->setShortcut(QKeySequence(tr(
"ctrl+r")));
905 act =
menu->addAction(
_(
"Connect with Railroad"));
907 act->setShortcut(QKeySequence(tr(
"ctrl+l")));
909 act =
menu->addAction(
_(
"Connect with Irrigation"));
911 act->setShortcut(QKeySequence(tr(
"ctrl+i")));
913 menu->addSeparator();
914 act =
menu->addAction(
_(
"Transform Terrain"));
918 act =
menu->addAction(
_(
"Clean Pollution"));
922 act =
menu->addAction(
_(
"Clean Nuclear Fallout"));
926 act =
menu->addAction(
928 act->setShortcut(QKeySequence(tr(
"b")));
931 act =
menu->addAction(
933 act->setShortcut(QKeySequence(tr(
"r")));
939 act->setShortcut(QKeySequence(tr(
"z")));
942 act->setShortcut(QKeySequence(tr(
"ctrl+z")));
945 act->setShortcut(QKeySequence(tr(
"ctrl+shift+c")));
953 act->setShortcut(QKeySequence(tr(
"ctrl+t")));
960 act->setShortcut(QKeySequence(tr(
"ctrl+j")));
963 act->setShortcut(QKeySequence(tr(
"shift+s")));
966 act->setShortcut(QKeySequence(tr(
"ctrl+y")));
978 act->setCheckable(
true);
979 act->setChecked(
true);
985 act->setCheckable(
true);
986 act->setChecked(
false);
987 act->setData(ACTION_SPY_BRIBE_UNIT);
992 act->setCheckable(
true);
993 act->setChecked(
false);
994 act->setData(ACTION_SPY_SABOTAGE_UNIT);
999 act->setCheckable(
true);
1000 act->setChecked(
false);
1001 act->setData(ACTION_SPY_SABOTAGE_UNIT_ESC);
1007 act->setCheckable(
true);
1008 act->setChecked(
true);
1014 act->setCheckable(
true);
1015 act->setChecked(
false);
1016 act->setData(ACTION_SPY_INVESTIGATE_CITY);
1021 act->setCheckable(
true);
1022 act->setChecked(
false);
1023 act->setData(ACTION_INV_CITY_SPEND);
1028 act->setCheckable(
true);
1029 act->setChecked(
false);
1030 act->setData(ACTION_ESTABLISH_EMBASSY);
1035 act->setCheckable(
true);
1036 act->setChecked(
false);
1037 act->setData(ACTION_ESTABLISH_EMBASSY_STAY);
1042 act->setCheckable(
true);
1043 act->setChecked(
false);
1044 act->setData(ACTION_SPY_STEAL_TECH);
1049 act->setCheckable(
true);
1050 act->setChecked(
false);
1051 act->setData(ACTION_SPY_STEAL_TECH_ESC);
1056 act->setCheckable(
true);
1057 act->setChecked(
false);
1058 act->setData(ACTION_SPY_INCITE_CITY);
1063 act->setCheckable(
true);
1064 act->setChecked(
false);
1065 act->setData(ACTION_SPY_INCITE_CITY_ESC);
1070 act->setCheckable(
true);
1071 act->setChecked(
false);
1072 act->setData(ACTION_SPY_POISON);
1077 act->setCheckable(
true);
1078 act->setChecked(
false);
1079 act->setData(ACTION_SPY_POISON_ESC);
1084 menu = this->addMenu(
_(
"Civilization"));
1085 act =
menu->addAction(
_(
"National Budget..."));
1088 menu->addSeparator();
1090 act =
menu->addAction(
_(
"Policies..."));
1093 menu->addSeparator();
1096 menu->addSeparator();
1098 act =
menu->addAction(
Q_(
"?noun:Map View"));
1099 act->setShortcut(QKeySequence(tr(
"F1")));
1102 act =
menu->addAction(
_(
"Units View"));
1103 act->setShortcut(QKeySequence(tr(
"F2")));
1107 act =
menu->addAction(
Q_(
"?header:Nations View"));
1108 act->setShortcut(QKeySequence(tr(
"F3")));
1111 act =
menu->addAction(
_(
"Cities View"));
1112 act->setShortcut(QKeySequence(tr(
"F4")));
1115 act =
menu->addAction(
_(
"Economy View"));
1116 act->setShortcut(QKeySequence(tr(
"F5")));
1119 act =
menu->addAction(
_(
"Research View"));
1120 act->setShortcut(QKeySequence(tr(
"F6")));
1123 act =
menu->addAction(
_(
"Wonders of the World Report"));
1124 act->setShortcut(QKeySequence(tr(
"F7")));
1127 act =
menu->addAction(
_(
"Top Five Cities Report"));
1128 act->setShortcut(QKeySequence(tr(
"F8")));
1131 act =
menu->addAction(
_(
"Demographics Report"));
1132 act->setShortcut(QKeySequence(tr(
"F11")));
1135 act =
menu->addAction(
_(
"Spaceship View"));
1136 act->setShortcut(QKeySequence(tr(
"F12")));
1139 act =
menu->addAction(
_(
"Achievements Report"));
1142 act =
menu->addAction(
_(
"Endgame Report"));
1147 menu = this->addMenu(
_(
"Help"));
1150 QObject::connect(act, &QAction::triggered,
1154 QObject::connect(act, &QAction::triggered,
1158 QObject::connect(act, &QAction::triggered,
1162 QObject::connect(act, &QAction::triggered,
1166 QObject::connect(act, &QAction::triggered,
1170 QObject::connect(act, &QAction::triggered,
1174 QObject::connect(act, &QAction::triggered,
1178 QObject::connect(act, &QAction::triggered,
1182 QObject::connect(act, &QAction::triggered,
1186 QObject::connect(act, &QAction::triggered,
1190 QObject::connect(act, &QAction::triggered,
1194 QObject::connect(act, &QAction::triggered,
1198 QObject::connect(act, &QAction::triggered,
1202 QObject::connect(act, &QAction::triggered,
1206 QObject::connect(act, &QAction::triggered,
1210 QObject::connect(act, &QAction::triggered,
1214 QObject::connect(act, &QAction::triggered,
1218 QObject::connect(act, &QAction::triggered,
1221 menu->addSeparator();
1224 QObject::connect(act, &QAction::triggered,
1228 QObject::connect(act, &QAction::triggered,
1232 QObject::connect(act, &QAction::triggered,
1236 QObject::connect(act, &QAction::triggered,
1240 QObject::connect(act, &QAction::triggered,
1243 menu->addSeparator();
1246 QObject::connect(act, &QAction::triggered,
1250 QObject::connect(act, &QAction::triggered,
1254 QObject::connect(act, &QAction::triggered,
1257 menus = this->findChildren<QMenu *>();
1258 for (i = 0; i < menus.count(); i++) {
1259 menus[i]->setAttribute(Qt::WA_TranslucentBackground);
1261 this->setVisible(
false);
1264 shortcuts->create_no_action_shortcuts(
queen()->mapview_wdg);
1274 for (
const auto menu :
king()->findChildren<QMenu *>()) {
1281 menu->deleteLater();
1305 for (
const QMenu *m : findChildren<QMenu *>()) {
1306 for (
const auto action : m->actions()) {
1308 where = m->title() +
" > " +
action->text();
1347 act->setCheckable(
true);
1348 act->setData(utype_id);
1350 act->setChecked(
true);
1364 bool enabled =
false;
1370 for (
auto *act : qAsConst(
actions)) {
1382 if (pextra->buildable) {
1387 road_id = pextra->id;
1388 act->setData(road_id);
1389 QObject::connect(act, &QAction::triggered,
1392 ACTIVITY_GEN_ROAD, pextra)) {
1393 act->setEnabled(
true);
1396 act->setDisabled(
true);
1413 bool enabled =
false;
1419 for (
auto *act : qAsConst(
actions)) {
1432 if (pextra->buildable) {
1437 base_id = pextra->id;
1438 act->setData(base_id);
1439 QObject::connect(act, &QAction::triggered,
1443 act->setEnabled(
true);
1446 act->setDisabled(
true);
1462 for (
munit key : qAsConst(keys)) {
1464 while (i !=
menu_list.end() && i.key() == key) {
1468 i.value()->setEnabled(
true);
1473 i.value()->setEnabled(
true);
1478 i.value()->setEnabled(
true);
1479 i.value()->setVisible(
true);
1481 i.value()->setVisible(
false);
1485 if (
queen()->isRepoDlgOpen(QStringLiteral(
"END"))) {
1486 i.value()->setEnabled(
true);
1487 i.value()->setVisible(
true);
1489 i.value()->setVisible(
false);
1506 for (
const auto builder : punits) {
1509 if (pextra !=
nullptr) {
1525 bool city_on_tile =
false;
1526 bool units_all_same_tile;
1534 for (QAction *a : qAsConst(
menu_list)) {
1535 a->setEnabled(
false);
1555 for (
munit key : qAsConst(keys)) {
1557 while (i !=
menu_list.end() && i.key() == key) {
1560 i.value()->setEnabled(
true);
1565 i.value()->setEnabled(
true);
1571 i.value()->setEnabled(
true);
1577 i.value()->setEnabled(
true);
1583 i.value()->setEnabled(
true);
1589 i.value()->setEnabled(
true);
1595 i.value()->setEnabled(
true);
1598 if (units_all_same_tile) {
1599 struct unit *punit = punits.front();
1606 if (pextra !=
nullptr) {
1609 QString(
_(
"Build %1"))
1612 i.value()->setText(QString(
_(
"Build Mine")));
1615 i.value()->setText(QString(
_(
"Build Mine")));
1622 i.value()->setEnabled(
true);
1624 if (units_all_same_tile) {
1625 struct unit *punit = punits.front();
1632 if (pextra !=
nullptr) {
1635 QString(
_(
"Build %1"))
1638 i.value()->setText(QString(
_(
"Build Irrigation")));
1641 i.value()->setText(QString(
_(
"Build Irrigation")));
1648 i.value()->setEnabled(
true);
1650 if (units_all_same_tile) {
1651 struct unit *punit = punits.front();
1658 QString(
_(
"Cultivate to %1"))
1660 unit_tile(punit), ACTIVITY_CULTIVATE))));
1662 i.value()->setText(QString(
_(
"Cultivate")));
1665 i.value()->setText(QString(
_(
"Cultivate")));
1671 i.value()->setEnabled(
true);
1673 if (units_all_same_tile) {
1674 struct unit *punit = punits.front();
1681 QString(
_(
"Plant to %1"))
1685 i.value()->setText(QString(
_(
"Plant")));
1688 i.value()->setText(QString(
_(
"Plant")));
1694 i.value()->setEnabled(
true);
1698 if (units_all_same_tile) {
1699 struct unit *punit = punits.front();
1705 QString(
_(
"Transform to %1"))
1707 unit_tile(punit), ACTIVITY_TRANSFORM))));
1709 i.value()->setText(
_(
"Transform Terrain"));
1716 i.value()->setEnabled(
true);
1732 i.value()->setEnabled(
true);
1735 if (pextra !=
nullptr) {
1744 i.value()->setEnabled(
true);
1750 i.value()->setEnabled(
true);
1756 i.value()->setEnabled(
true);
1763 i.value()->setEnabled(
true);
1769 i.value()->setText(
_(
"Clean Pollution"));
1775 i.value()->setEnabled(
true);
1781 i.value()->setEnabled(
true);
1787 i.value()->setEnabled(
true);
1793 i.value()->setEnabled(
true);
1799 i.value()->setEnabled(
true);
1805 i.value()->setEnabled(
true);
1808 i.value()->setText(
_(
"Auto Settler"));
1810 i.value()->setText(
_(
"Auto Worker"));
1815 if (proad !=
nullptr) {
1821 i.value()->setEnabled(
true);
1827 i.value()->setEnabled(
true);
1837 if (proad !=
nullptr) {
1843 i.value()->setEnabled(
true);
1848 struct extra_type_list *
extras =
1851 if (extra_type_list_size(
extras) > 0) {
1854 pextra = extra_type_list_get(
1857 i.value()->setEnabled(
true);
1863 i.value()->setEnabled(
true);
1867 i.value()->setEnabled(
true);
1874 i.value()->setEnabled(
true);
1880 i.value()->setEnabled(
true);
1888 i.value()->setEnabled(
true);
1894 i.value()->setEnabled(
true);
1900 i.value()->setEnabled(
true);
1945 ACTION_HELP_WONDER)) {
1968 if (pextra !=
nullptr) {
1985 if (extra_type_list_size(
extras) > 0) {
2001 if (prail !=
nullptr) {
2026 if (proad !=
nullptr) {
2064 bool building_road =
false;
2069 building_road =
true;
2129 ask->set_text_title_definput(
_(
"New unit name:"),
_(
"Rename Unit"),
2131 ask->setAttribute(Qt::WA_DeleteOnClose);
2134 connect(ask, &QDialog::accepted, [ask,
id]() {
2139 ask->input_edit.text().toUtf8());
2190 struct city *homecity;
2191 struct tile *home_tile;
2192 struct tile *dest_tile;
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) {
2202 if (gilles.t1 == home_tile) {
2203 dest_tile = gilles.t2;
2205 dest_tile = gilles.t1;
2211 gilles.autocaravan = punit;
2232 act = qobject_cast<QAction *>(sender());
2244 act = qobject_cast<QAction *>(sender());
2255 act = qobject_cast<QAction *>(sender());
2275 if (focus.empty()) {
2285 for (
const auto punit : focus) {
2296 struct tile *last_tile;
2297 struct tile *new_tile;
2303 if (punit ==
nullptr) {
2306 last_tile = punit->
tile;
2308 if (new_tile !=
nullptr) {
2309 punit->
tile = new_tile;
2317 punit->
tile = last_tile;
2392 if (
king()->interface_locked) {
2405 QList<close_widget *> lc;
2406 QList<move_widget *> lm;
2412 for (i = 0; i < lc.size(); ++i) {
2413 lc.at(i)->setVisible(!enable);
2415 for (i = 0; i < lm.size(); ++i) {
2416 lm.at(i)->setVisible(!enable);
2427 king()->setWindowState(
king()->windowState() | Qt::WindowFullScreen);
2429 king()->setWindowState(
king()->windowState() & ~Qt::WindowFullScreen);
2494 if (a->isChecked()) {
2496 qUtf8Printable(a->data().toString()),
2501 == QLatin1String(
"default_city_bar_style_name")) {
2629 QDialog *dialog =
new QDialog(
this);
2632 QVBoxLayout *layout;
2633 const struct option *poption;
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"));
2642 label->setText(
_(
"Some tilesets might not be compatible with current"
2644 layout->addWidget(label);
2647 QStringList tilesets;
2648 for (
auto const &s : qAsConst(sl)) {
2651 tilesets.append(
name);
2657 tilesets.erase(std::unique(tilesets.begin(), tilesets.end()),
2661 for (
const auto &
name : qAsConst(tilesets)) {
2662 but =
new QPushButton(
name);
2663 connect(but, &QAbstractButton::clicked,
this,
2665 layout->addWidget(but);
2667 dialog->setSizeGripEnabled(
true);
2668 dialog->setLayout(layout);
2692 QByteArray tn_bytes;
2694 but = qobject_cast<QPushButton *>(sender());
2695 tn_bytes = but->text().toLocal8Bit();
2698 but->parentWidget()->close();
2727 if (pextra->buildable && pextra->id ==
id
2745 if (pextra->buildable && pextra->id ==
id
2810 full_size.rheight() /= 2;
2819 [=](
const QRegion &where) {
2821 if (where.boundingRect().contains(QRect(QPoint(), full_size))) {
2824 QStringLiteral(
"Freeciv21-Turn%1").arg(
game.
info.turn);
2826 img_name += QStringLiteral(
"-")
2830 auto path = QStandardPaths::writableLocation(
2831 QStandardPaths::PicturesLocation);
2832 if (path.isEmpty() || !QDir(path).exists()) {
2833 path = QStandardPaths::writableLocation(
2834 QStandardPaths::HomeLocation);
2836 if (path.isEmpty() || !QDir(path).exists()) {
2840 path + QStringLiteral(
"/") + img_name + QStringLiteral(
".png");
2843 auto pixmap = QPixmap(full_size);
2844 pixmap.fill(Qt::black);
2846 auto painter = QPainter(&pixmap);
2847 renderer->render(painter, QRect(pixmap.rect()));
2848 renderer->deleteLater();
2851 bool map_saved = pixmap.save(img_name,
"png");
2858 saved->setStandardButtons(QMessageBox::Ok);
2859 saved->setDefaultButton(QMessageBox::Ok);
2860 saved->setAttribute(Qt::WA_DeleteOnClose);
2884 QString current_file;
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;
2899 cf_bytes = current_file.toLocal8Bit();
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);
2923 connect(ask, &hud_message_box::accepted, [=]() {
2925 disconnect_from_server();
bool action_removes_extra(const struct action *paction, const struct extra_type *pextra)
Returns TRUE iff the specified action can remove the specified extra.
static struct action * actions[MAX_NUM_ACTIONS]
enum action_sub_target_kind action_get_sub_target_kind(const struct action *paction)
Get the sub target kind of an action.
const QString action_name_translation(const struct action *action)
Get the action name used when displaying the action in the UI.
bool actions_are_ready()
Returns TRUE iff the actions are initialized.
const QString action_id_name_translation(action_id act_id)
Get the action name used when displaying the action in the UI.
struct action * action_by_number(action_id act_id)
Return the action with the given id.
bool action_creates_extra(const struct action *paction, const struct extra_type *pextra)
Returns TRUE iff the specified action can create the specified extra.
#define action_iterate_end
#define action_id_get_actor_kind(act_id)
#define action_iterate(_act_)
#define action_id_get_target_kind(act_id)
#define action_id_has_complex_target(act_id)
struct city * is_non_allied_city_tile(const struct tile *ptile, const struct player *pplayer)
Is there an non_allied city on this tile?
struct tile * city_tile(const struct city *pcity)
Return the tile location of the city.
#define city_list_iterate(citylist, pcity)
#define city_list_iterate_end
void city_report_dialog_popup()
Display the city report dialog.
static void option_changed(option *opt)
Called by the option code when the option has changed.
static const QVector< QString > * available_vector(const option *)
Returns the list of all available city bar styles.
void load_modpack()
Load the modpack-installer from the start menu.
trade_generator trade_gen
static fc_shortcuts * sc()
Returns given instance.
Renders the map on widgets.
void repaint_needed(const QRegion &where)
void set_viewport_size(const QSize &size)
Instructs the renderer to draw a viewport with a different size.
Lets the user toggle tileset options.
void set_text_title(const QString &s1, const QString &s2)
Sets text and title and shows message box.
void update_actions()
Update possible action for given units.
void zoom_out()
Zooms out by 20%.
void zoom_reset()
Resets the zoom level.
void show_debugger()
Opens the tileset debugger.
void set_scale(double scale, bool animate=true)
Sets the map scale.
void zoom_in()
Zooms in by 20%.
The panel at the bottom right of the game screen, holding the minimap and the Turn Done button.
void set_minimap_visible(bool visible)
Shows or hides the minimap.
void popup_budget_dialog()
Popup (or raise) the (tax/science/luxury) rates selection dialog.
static qdef_act * action()
Returns instance of qdef_act.
void vs_city_set(int i)
Sets default action vs city.
void vs_unit_set(int i)
Sets default action vs unit.
void add_all_cities()
Adds all cities to trade generator.
void clear_trade_planing()
Clears genrated routes, virtual cities, cities.
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.
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?
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.
void disconnect_from_server()
Get rid of server connection.
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.
void key_unit_plant()
Handle user 'plant' input.
std::vector< unit * > & get_units_in_focus()
Returns list of units currently in focus.
void key_unit_paradrop()
Handle user 'paradrop' input.
void key_unit_goto()
Handle user 'unit goto' input.
void key_unit_homecity()
Handle user 'change homecity' input.
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...
void key_city_names_toggle()
Handle user 'toggle city names display' input.
void key_unit_fallout()
Handle user 'clean fallout' input.
void key_unit_mine()
Handle user 'build mine' input.
void key_unit_done()
Handle user 'unit done' input.
void key_unit_wait()
Handle user 'wait' input.
void key_unit_connect(enum unit_activity activity, struct extra_type *tgt)
Handle user pressing key for 'Connect' command.
void key_unit_auto_settle()
Call to request (from the server) that the focus unit is put into autosettler mode.
void key_unit_irrigate()
Handle user 'irrigate' input.
void key_city_trade_routes_toggle()
Handle client request to toggle drawing of trade route information by the city name for cities visibl...
void key_unit_wakeup_others()
Handle user 'wakeup others' input.
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).
void key_map_native_toggle()
Toggle native tiles on the mapview on/off based on a keypress.
void key_unit_transform()
Handle user 'transform unit' input.
void key_unit_unload_all()
Handle user 'unload all' input.
void request_unit_unload(struct unit *pcargo)
Send a request to the server that the cargo be unloaded from its current transporter.
void key_unit_sentry()
Handle user 'sentry' input.
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.
void key_city_productions_toggle()
Handle user 'toggle city production display' input.
void request_unit_build_city(struct unit *punit)
Player pressed 'b' or otherwise instructed unit to build or add to city.
void key_unit_auto_explore()
Handle user 'autoexplore' input.
void key_map_grid_toggle()
Handle user 'toggle map grid' input.
void key_city_buycost_toggle()
Toggles the showing of the buy cost of the current production in the city descriptions.
void key_unit_convert()
Unit convert key pressed or respective menu entry selected.
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.
int get_num_units_in_focus()
Return the number of units currently in focus (0 or more).
void request_center_focus_unit()
Center to focus unit.
void key_unit_patrol()
Handle user 'patrol' input.
void key_city_output_toggle()
Toggle drawing of city output produced by workers of the city.
void key_unit_fortify()
Handle user 'fortify' input.
enum cursor_hover_state hover_state
void key_unit_cultivate()
Handle user 'cultivate' input.
void key_city_outlines_toggle()
Toggle drawing of city outlines.
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.
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...
void request_move_unit_direction(struct unit *punit, int dir)
This function is called whenever the player pressed an arrow key.
void request_units_return()
Return-and-recover for a particular unit.
void control_mouse_cursor(struct tile *ptile)
Determines which mouse cursor should be used, according to hover_state, and the information gathered ...
void key_unit_pillage()
Handle user 'pillage' input.
void key_unit_fortress()
Handle user 'build base of class fortress' input.
struct unit * head_of_units_in_focus()
Return head of focus units list.
void key_map_borders_toggle()
Toggle map borders on the mapview on/off based on a keypress.
void key_city_growth_toggle()
Toggles the "show city growth turns" option by passing off the request to another function....
void key_unit_airbase()
Handle user 'build base of class airbase' input.
void popup_upgrade_dialog(const std::vector< unit * > &punits)
Popup dialog for upgrade units.
bool request_transport(struct unit *pcargo, struct tile *ptile)
Unit wants to get into some transport on given tile.
void popup_revolution_dialog(struct government *government)
Popup a dialog asking if the player wants to start a revolution.
void popup_disband_dialog(const std::vector< unit * > &punits)
Pops up a dialog to confirm disband of the unit(s).
int get_city_bonus(const struct city *pcity, enum effect_type effect_type, enum vision_layer vlayer)
Returns the effect bonus at a city.
void popup_client_options()
Popups client options.
class fc_client * king()
Return fc_client instance.
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...
struct city * game_city_by_number(int id)
Often used function to get a city pointer from a city ID.
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.
void enter_goto_state(const std::vector< unit * > &units)
Enter the goto state: activate, prepare PF-template and add the initial part.
struct tile * tile_before_end_path(struct unit *punit, struct tile *ptile)
Finds penultimate tile on path for given unit going to ptile.
bool send_goto_tile(struct unit *punit, struct tile *ptile)
Send orders for the unit to move it to the arbitrary tile.
void popup_goto_dialog(void)
struct government * government_by_number(const Government_type_id gov)
Return the government with the given index.
Government_type_id government_count()
Return the number of governments.
bool can_change_to_government(struct player *pplayer, const struct government *gov)
Can change to government if appropriate tech exists, and one of:
const char * government_name_translation(const struct government *pgovern)
Return the (translated) name of the given government.
void popup_quit_dialog()
Open dialog to confirm that user wants to quit client.
#define HELP_TERRAIN_ITEM
#define HELP_LANGUAGES_ITEM
#define HELP_CONNECTING_ITEM
#define HELP_TILESET_ITEM
#define HELP_CHATLINE_ITEM
#define HELP_RULESET_ITEM
#define HELP_GOVERNMENT_ITEM
#define HELP_PLAYING_ITEM
#define HELP_IMPROVEMENTS_ITEM
#define HELP_EFFECTS_ITEM
#define HELP_WORKLIST_EDITOR_ITEM
#define HELP_WONDERS_ITEM
#define HELP_SPACE_RACE_ITEM
#define HELP_COPYING_ITEM
#define HELP_OVERVIEW_ITEM
#define HELP_NATIONS_ITEM
#define HELP_DIPLOMACY_ITEM
#define HELP_ECONOMY_ITEM
#define HELP_CONTROLS_ITEM
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.
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
#define improvement_iterate(_p)
#define fc_assert(condition)
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,...
bool is_tiles_adjacent(const struct tile *tile0, const struct tile *tile1)
Are two tiles adjacent to each other.
struct terrain_misc terrain_control
void create_line_at_mouse_pos()
Draw a goto or patrol line at the current mouse position.
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.
const char * nation_plural_for_player(const struct player *pplayer)
Return the (translated) plural noun of the given nation of a player.
const char * option_name(const struct option *poption)
Returns the name of the option.
const struct option_set * server_optset
client_options * gui_options
const struct option_set * client_optset
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.
void options_save(option_save_log_callback log_cb)
Save all options.
#define options_iterate(poptset, poption)
#define options_iterate_end
@ REPORT_WONDERS_OF_THE_WORLD
pageGame * queen()
Return game instandce.
void popup_multiplier_dialog()
Popups multiplier dialog.
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...
struct extra_type * road_extra_get(const struct road_type *proad)
Return extra that road is.
const QStringList & get_save_dirs()
Returns a list of save directory paths, in the order in which they should be searched.
QString freeciv_storage_dir()
Returns string which gives freeciv storage dir.
void popup_shortcuts_dialog()
Popups shortcut dialog.
void popup_spaceship_dialog(struct player *pplayer)
Popup (or raise) the spaceship dialog for the given player.
struct civ_game::@28::@31 client
struct packet_game_info info
struct government * government_during_revolution
bool draw_city_productions
bool draw_city_trade_routes
bool save_options_on_exit
char default_city_bar_style_name[512]
The base class for options.
struct city_list * cities
struct terrain * irrigation_result
struct terrain * mining_result
struct terrain * transform_result
const struct unit_type * utype
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-...
Tech_type_id advance_number(const struct advance *padvance)
Return the advance index.
const char * advance_name_translation(const struct advance *padvance)
Return the (translated) name of the given advance/technology.
#define advance_iterate(_start, _p)
#define advance_iterate_end
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...
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.
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.
struct tile * tile_virtual_new(const struct tile *ptile)
Returns a virtual tile.
#define tile_terrain(_tile)
bool tilespec_reread(const QString &name, bool game_fully_initialized)
Read a new tilespec in from scratch.
bool tileset_is_isometric(const struct tileset *t)
Return whether the current tileset is isometric.
QEvent::Type TilesetChanged
An event type sent to all widgets when the current tileset changes.
int tileset_tile_height(const struct tileset *t)
Return the tile height of the current tileset.
const QPixmap * get_government_sprite(const struct tileset *t, const struct government *gov)
Return the sprite for the government.
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...
bool tileset_has_options(const struct tileset *t)
Checks if the tileset has any user-settable options.
int tileset_tile_width(const struct tileset *t)
Return the tile width of the current tileset.
void top_bar_units_view()
Click for units view, allowing to close/open.
void top_bar_show_map()
Callback to show map.
bool can_unit_change_homecity(const struct unit *punit)
Return TRUE iff the unit can change homecity at its current location.
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 ...
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...
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.
bool unit_contained_in(const struct unit *pcargo, const struct unit *ptrans)
Returns whether 'pcargo' is transported by 'ptrans', either directly or indirectly.
bool can_unit_do_autosettlers(const struct unit *punit)
Return whether the unit can be put in auto-settler mode.
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...
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.
bool units_can_load(const std::vector< unit * > &units)
Returns TRUE iff any of these units can load.
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.
bool can_units_do_any_road(const std::vector< unit * > &units)
Returns TRUE if any of the units can build any road.
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.
bool any_unit_in_city(const std::vector< unit * > &units)
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.
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.
bool units_are_occupied(const std::vector< unit * > &units)
Return TRUE iff any of the units is a transporter that is occupied.
bool units_can_unload(const std::vector< unit * > &units)
Return TRUE iff any of these units can unload.
bool units_contain_cityfounder(const std::vector< unit * > &units)
Does the list contain any cityfounder units.
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.
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.
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)
bool units_can_convert(const std::vector< unit * > &units)
Return TRUE iff any of the units can convert to another unit type.
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.
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.
bool units_on_the_same_tile(const std::vector< unit * > &units)
#define unit_list_iterate(unitlist, punit)
#define unit_list_iterate_end
const struct unit_type * unit_type_get(const struct unit *punit)
Return the unit type for this unit.
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.
const char * utype_name_translation(const struct unit_type *punittype)
Return the (translated) name of the unit type.
Unit_type_id utype_index(const struct unit_type *punittype)
Return the unit type index.
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.
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...
#define unit_type_iterate(_p)
#define unit_type_iterate_end
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.