Freeciv-3.3
Loading...
Searching...
No Matches
dialogs.cpp
Go to the documentation of this file.
1/***********************************************************************
2 Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
6 any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12***********************************************************************/
13
14#ifdef HAVE_CONFIG_H
15#include <fc_config.h>
16#endif
17
18// Qt
19#include <QApplication>
20#include <QButtonGroup>
21#include <QComboBox>
22#include <QGroupBox>
23#include <QHeaderView>
24#include <QImage>
25#include <QMessageBox>
26#include <QMouseEvent>
27#include <QPainter>
28#include <QPainterPath>
29#include <QRadioButton>
30#include <QRect>
31#include <QTableWidgetItem>
32#include <QTextEdit>
33#include <QVBoxLayout>
34#include <QWindow>
35#include <QtMath>
36
37// utility
38#include "astring.h"
39
40// common
41#include "actions.h"
42#include "city.h"
43#include "game.h"
44#include "government.h"
45#include "improvement.h"
46#include "movement.h"
47#include "nation.h"
48#include "research.h"
49#include "sex.h"
50
51// client
52#include "audio.h"
53#include "chatline_common.h"
54#include "client_main.h"
55#include "control.h"
56#include "helpdata.h"
57#include "packhand.h"
58#include "svgflag.h"
59#include "text.h"
60#include "tilespec.h"
61
62// gui-qt
63#include "dialogs.h"
64#include "fc_client.h"
65#include "gui_main.h"
66#include "hudwidget.h"
67#include "qtg_cxxside.h"
68#include "sprite.h"
69
70// Locations for non action enabler controlled buttons.
71#define BUTTON_WAIT (ACTION_COUNT + 1)
72#define BUTTON_CANCEL (BUTTON_WAIT + 1)
73#define BUTTON_COUNT (BUTTON_CANCEL + 1)
74
76extern void popdown_players_report();
77extern void popdown_economy_report();
78extern void popdown_units_report();
79extern void popdown_science_report();
80extern void popdown_city_report();
81extern void popdown_endgame_report();
82
83static void spy_request_strike_bld_list(QVariant data1, QVariant data2);
84static void diplomat_incite(QVariant data1, QVariant data2);
85static void diplomat_incite_escape(QVariant data1, QVariant data2);
86static void spy_request_sabotage_list(QVariant data1, QVariant data2);
87static void spy_request_sabotage_esc_list(QVariant data1, QVariant data2);
88static void spy_sabotage(QVariant data1, QVariant data2);
89static void spy_steal(QVariant data1, QVariant data2);
90static void spy_steal_esc(QVariant data1, QVariant data2);
91static void spy_steal_something(QVariant data1, QVariant data2);
92static void diplomat_steal(QVariant data1, QVariant data2);
93static void diplomat_steal_esc(QVariant data1, QVariant data2);
94static void spy_poison(QVariant data1, QVariant data2);
95static void spy_poison_esc(QVariant data1, QVariant data2);
96static void spy_spread_plague(QVariant data1, QVariant data2);
97static void spy_steal_gold(QVariant data1, QVariant data2);
98static void spy_steal_gold_esc(QVariant data1, QVariant data2);
99static void spy_steal_maps(QVariant data1, QVariant data2);
100static void spy_steal_maps_esc(QVariant data1, QVariant data2);
101static void spy_escape(QVariant data1, QVariant data2);
102static void spy_nuke_city(QVariant data1, QVariant data2);
103static void spy_nuke_city_esc(QVariant data1, QVariant data2);
104static void nuke_city(QVariant data1, QVariant data2);
105static void destroy_city(QVariant data1, QVariant data2);
106static void diplomat_embassy(QVariant data1, QVariant data2);
107static void spy_embassy(QVariant data1, QVariant data2);
108static void spy_sabotage_unit(QVariant data1, QVariant data2);
109static void spy_sabotage_unit_esc(QVariant data1, QVariant data2);
110static void spy_investigate(QVariant data1, QVariant data2);
111static void diplomat_investigate(QVariant data1, QVariant data2);
112static void diplomat_sabotage(QVariant data1, QVariant data2);
113static void diplomat_sabotage_esc(QVariant data1, QVariant data2);
114static void diplomat_bribe_unit(QVariant data1, QVariant data2);
115static void diplomat_bribe_stack(QVariant data1, QVariant data2);
116static void spy_attack(QVariant data1, QVariant data2);
117static void caravan_marketplace(QVariant data1, QVariant data2);
118static void caravan_establish_trade(QVariant data1, QVariant data2);
119static void caravan_help_build(QVariant data1, QVariant data2);
120static void unit_disband_recover(QVariant data1, QVariant data2);
121static void capture_units(QVariant data1, QVariant data2);
122static void nuke_units(QVariant data1, QVariant data2);
123static void collect_ransom(QVariant data1, QVariant data2);
124static void wipe_units(QVariant data1, QVariant data2);
125static void expel_unit(QVariant data1, QVariant data2);
126static void bombard(QVariant data1, QVariant data2);
127static void bombard2(QVariant data1, QVariant data2);
128static void bombard3(QVariant data1, QVariant data2);
129static void bombard4(QVariant data1, QVariant data2);
130static void bombard_lethal(QVariant data1, QVariant data2);
131static void bombard_lethal2(QVariant data1, QVariant data2);
132static void found_city(QVariant data1, QVariant data2);
133static void transform_terrain(QVariant data1, QVariant data2);
134static void transform_terrain2(QVariant data1, QVariant data2);
135static void cultivate(QVariant data1, QVariant data2);
136static void cultivate2(QVariant data1, QVariant data2);
137static void plant(QVariant data1, QVariant data2);
138static void plant2(QVariant data1, QVariant data2);
139static void pillage(QVariant data1, QVariant data2);
140static void pillage2(QVariant data1, QVariant data2);
141static void clean(QVariant data1, QVariant data2);
142static void clean2(QVariant data1, QVariant data2);
143static void road(QVariant data1, QVariant data2);
144static void road2(QVariant data1, QVariant data2);
145static void base(QVariant data1, QVariant data2);
146static void base2(QVariant data1, QVariant data2);
147static void mine(QVariant data1, QVariant data2);
148static void mine2(QVariant data1, QVariant data2);
149static void irrigate(QVariant data1, QVariant data2);
150static void irrigate2(QVariant data1, QVariant data2);
151static void nuke(QVariant data1, QVariant data2);
152static void attack(QVariant data1, QVariant data2);
153static void attack2(QVariant data1, QVariant data2);
154static void suicide_attack(QVariant data1, QVariant data2);
155static void suicide_attack2(QVariant data1, QVariant data2);
156static void paradrop(QVariant data1, QVariant data2);
157static void paradrop_conquer(QVariant data1, QVariant data2);
158static void paradrop_frighten(QVariant data1, QVariant data2);
159static void paradrop_frighten_conquer(QVariant data1, QVariant data2);
160static void paradrop_enter(QVariant data1, QVariant data2);
161static void paradrop_enter_conquer(QVariant data1, QVariant data2);
162static void teleport(QVariant data1, QVariant data2);
163static void teleport2(QVariant data1, QVariant data2);
164static void teleport3(QVariant data1, QVariant data2);
165static void teleport_conquer(QVariant data1, QVariant data2);
166static void teleport_frighten(QVariant data1, QVariant data2);
167static void teleport_frighten_conquer(QVariant data1, QVariant data2);
168static void teleport_enter(QVariant data1, QVariant data2);
169static void teleport_enter_conquer(QVariant data1, QVariant data2);
170static void disembark1(QVariant data1, QVariant data2);
171static void disembark2(QVariant data1, QVariant data2);
172static void disembark3(QVariant data1, QVariant data2);
173static void disembark4(QVariant data1, QVariant data2);
174static void enter_hut(QVariant data1, QVariant data2);
175static void enter_hut2(QVariant data1, QVariant data2);
176static void enter_hut3(QVariant data1, QVariant data2);
177static void enter_hut4(QVariant data1, QVariant data2);
178static void frighten_hut(QVariant data1, QVariant data2);
179static void frighten_hut2(QVariant data1, QVariant data2);
180static void frighten_hut3(QVariant data1, QVariant data2);
181static void frighten_hut4(QVariant data1, QVariant data2);
182static void regular_move(QVariant data1, QVariant data2);
183static void regular_move2(QVariant data1, QVariant data2);
184static void regular_move3(QVariant data1, QVariant data2);
185static void convert_unit(QVariant data1, QVariant data2);
186static void fortify(QVariant data1, QVariant data2);
187static void fortify2(QVariant data1, QVariant data2);
188static void disband_unit(QVariant data1, QVariant data2);
189static void homeless(QVariant data1, QVariant data2);
190static void join_city(QVariant data1, QVariant data2);
191static void unit_home_city(QVariant data1, QVariant data2);
192static void unit_upgrade(QVariant data1, QVariant data2);
193static void airlift(QVariant data1, QVariant data2);
194static void conquer_city_shrink(QVariant data1, QVariant data2);
195static void conquer_city_shrink2(QVariant data1, QVariant data2);
196static void conquer_city_shrink3(QVariant data1, QVariant data2);
197static void conquer_city_shrink4(QVariant data1, QVariant data2);
198static void conquer_extras(QVariant data1, QVariant data2);
199static void conquer_extras2(QVariant data1, QVariant data2);
200static void conquer_extras3(QVariant data1, QVariant data2);
201static void conquer_extras4(QVariant data1, QVariant data2);
202static void heal_unit(QVariant data1, QVariant data2);
203static void heal_unit2(QVariant data1, QVariant data2);
204static void transport_board(QVariant data1, QVariant data2);
205static void transport_board2(QVariant data1, QVariant data2);
206static void transport_board3(QVariant data1, QVariant data2);
207static void transport_embark(QVariant data1, QVariant data2);
208static void transport_embark2(QVariant data1, QVariant data2);
209static void transport_embark3(QVariant data1, QVariant data2);
210static void transport_embark4(QVariant data1, QVariant data2);
211static void transport_deboard(QVariant data1, QVariant data2);
212static void transport_unload(QVariant data1, QVariant data2);
213static void transport_load(QVariant data1, QVariant data2);
214static void transport_load2(QVariant data1, QVariant data2);
215static void transport_load3(QVariant data1, QVariant data2);
216static void keep_moving(QVariant data1, QVariant data2);
217static void pillage_something(QVariant data1, QVariant data2);
218static void action_entry(choice_dialog *cd,
219 action_id act,
220 const struct act_prob *act_probs,
221 const char *custom,
222 QVariant data1, QVariant data2);
223
224
225static bool is_showing_pillage_dialog = false;
227static bool is_race_dialog_open = false;
228
229/* Information used in action selection follow up questions. Can't be
230 * stored in the action selection dialog since it is closed before the
231 * follow up question is asked. */
233
234/* Don't remove a unit's action decision want or move on to the next actor
235 unit that wants a decision in the current unit selection. */
236static bool did_not_decide = false;
237
238extern char forced_tileset_name[512];
240
241/***********************************************************************/
246{
248
249 // Unit acting against a city target.
291
292 // Unit acting against a unit target.
311
312 // Unit acting against all units at a tile.
324
325 // Unit acting against a tile.
382
383 // Unit acting against all tile extras.
388
389 // Unit acting with no target except itself.
395
396 return action_function;
397}
398
399/* Mapping from an action to the function to call when its button is
400 * pushed. */
402
403/***********************************************************************/
408{
409 titlebar_height = 0;
410 moving_now = false;
411 setSizeGripEnabled(true);
413}
414
415/***********************************************************************/
419{
420 raise();
421}
422
423/***********************************************************************/
427{
429
430 QPainter p(this);
433 QStyle *style = this->style();
434 QRect active_area = this->rect();
437
438 qpal.setColor(QPalette::Active, QPalette::ToolTipText, Qt::white);
439 tbar_opt.initFrom(this);
440 titlebar_height = style->pixelMetric(QStyle::PM_TitleBarHeight,
441 &tbar_opt, this) + 2;
442 close_pix = close_pix.scaledToHeight(titlebar_height);
443 tbar_opt.rect = QRect(0, 0, this->width(), titlebar_height);
444 text_rect = QRect(0, 0, this->width() - close_pix.width() , titlebar_height);
445 close_rect = QRect(this->width() - close_pix.width(), 0, this->width(),
447 tbar_opt.titleBarState = this->windowState();
448 tbar_opt.text = tbar_opt.fontMetrics.elidedText(this->windowTitle(),
449 Qt::ElideRight,
450 text_rect.width());
451 style->drawComplexControl(QStyle::CC_TitleBar, &tbar_opt, &p, this);
452 style->drawItemText(&p, text_rect, Qt::AlignCenter, qpal,
453 true, tbar_opt.text, QPalette::ToolTipText);
454 style->drawItemPixmap(&p, close_rect, Qt::AlignLeft,
455 close_pix.scaledToHeight(titlebar_height));
456
457 active_area.setTopLeft(QPoint(0, titlebar_height));
458 this->setContentsMargins(0, titlebar_height, 0, 0);
459 win_opt.initFrom(this);
460 win_opt.rect = active_area;
461 style->drawPrimitive(QStyle::PE_Widget, &win_opt, &p, this);
462}
463
464/***********************************************************************/
473
474/***********************************************************************/
478{
479 QPoint pos = event->pos();
480 int x = pos.x();
481 int y = pos.y();
482
483 if (y <= titlebar_height
484 && x <= width() - close_pix.width()) {
485 point = mevent_gpos(event) - geometry().topLeft();
486 moving_now = true;
487 setCursor(Qt::SizeAllCursor);
488 } else if (y <= titlebar_height
489 && x > width() - close_pix.width()) {
490 close();
491 }
492}
493
494/***********************************************************************/
498{
499 moving_now = false;
500 setCursor(Qt::ArrowCursor);
501}
502
503/***********************************************************************/
507 QWidget *parent) : qfc_dialog(parent)
508{
509 int i;
513 QPixmap *pix;
514 QHeaderView *header;
515 QSize size;
517 QLabel *ns_label;
518
519 setAttribute(Qt::WA_DeleteOnClose);
520 is_race_dialog_open = true;
522 selected_nation_tabs = new QTableWidget;
523 nation_tabs = new QTableWidget();
524 styles = new QTableWidget;
525 ok_button = new QPushButton;
527 ns_label = new QLabel;
528 tplayer = pplayer;
529
530 selected_nation = -1;
531 selected_style = -1;
532 setWindowTitle(_("Select Nation"));
533 selected_nation_tabs->setRowCount(0);
534 selected_nation_tabs->setColumnCount(1);
535 selected_nation_tabs->setSelectionMode(QAbstractItemView::SingleSelection);
536 selected_nation_tabs->verticalHeader()->setVisible(false);
537 selected_nation_tabs->horizontalHeader()->setVisible(false);
538 selected_nation_tabs->setProperty("showGrid", "true");
539 selected_nation_tabs->setEditTriggers(QAbstractItemView::NoEditTriggers);
540 selected_nation_tabs->setShowGrid(false);
541 selected_nation_tabs->setAlternatingRowColors(true);
542
543 nation_tabs->setRowCount(0);
544 nation_tabs->setColumnCount(1);
545 nation_tabs->setSelectionMode(QAbstractItemView::SingleSelection);
546 nation_tabs->verticalHeader()->setVisible(false);
547 nation_tabs->horizontalHeader()->setVisible(false);
548 nation_tabs->setProperty("showGrid", "true");
549 nation_tabs->setEditTriggers(QAbstractItemView::NoEditTriggers);
550 nation_tabs->setShowGrid(false);
551 ns_label->setText(_("Nation Set:"));
552 styles->setRowCount(0);
553 styles->setColumnCount(2);
554 styles->setSelectionMode(QAbstractItemView::SingleSelection);
555 styles->verticalHeader()->setVisible(false);
556 styles->horizontalHeader()->setVisible(false);
557 styles->setProperty("showGrid", "false");
558 styles->setProperty("selectionBehavior", "SelectRows");
559 styles->setEditTriggers(QAbstractItemView::NoEditTriggers);
560 styles->setShowGrid(false);
561
563 no_name = new QGroupBox(parent);
567 sex_buttons->addButton(is_male, SEX_MALE);
569 sex_buttons->addButton(is_female, SEX_FEMALE);
570
571 leader_name->setEditable(true);
572 qgroupbox_layout->addWidget(leader_name, 1, 0, 1, 2);
573 qgroupbox_layout->addWidget(is_male, 2, 1);
574 qgroupbox_layout->addWidget(is_female, 2, 0);
577 no_name->setLayout(qgroupbox_layout);
578
580 description->setReadOnly(true);
581 description->setPlainText(_("Choose nation"));
582 no_name->setTitle(_("Your leader name"));
583
584 // Fill styles, no need to update them later
585
588
589 if (i >= 0) {
591 styles->insertRow(i);
593 item->setData(Qt::DecorationRole, *pix);
594 item->setData(Qt::UserRole, style_number(pstyle));
595 size.setWidth(pix->width());
596 size.setHeight(pix->height());
597 item->setSizeHint(size);
598 styles->setItem(i, 0, item);
601 styles->setItem(i, 1, item);
602 }
604
605 header = styles->horizontalHeader();
606 header->setSectionResizeMode(QHeaderView::Stretch);
607 header->resizeSections(QHeaderView::ResizeToContents);
608 header = styles->verticalHeader();
609 header->resizeSections(QHeaderView::ResizeToContents);
614 // Create nation sets
615 refresh();
616
617 connect(styles->selectionModel(),
619 const QItemSelection &)),
621 connect(selected_nation_tabs->selectionModel(),
623 const QItemSelection &)),
626 SLOT(leader_selected(int)));
627 connect(leader_name->lineEdit(), &QLineEdit::returnPressed,
630 SLOT(nationset_changed(int)));
631 connect(nation_tabs->selectionModel(),
633 const QItemSelection &)),
635
636 ok_button = new QPushButton;
637 ok_button->setText(_("Cancel"));
638 connect(ok_button, &QAbstractButton::pressed, this, &races_dialog::cancel_pressed);
639 main_layout->addWidget(ok_button, 8, 2, 1, 1);
640 random_button = new QPushButton;
641 random_button->setText(_("Random"));
642 connect(random_button, &QAbstractButton::pressed, this, &races_dialog::random_pressed);
643 main_layout->addWidget(random_button, 8, 0, 1, 1);
644 ok_button = new QPushButton;
645 ok_button->setText(_("Ok"));
646 connect(ok_button, &QAbstractButton::pressed, this, &races_dialog::ok_pressed);
647 main_layout->addWidget(ok_button, 8, 3, 1, 1);
648 main_layout->addWidget(no_name, 0, 3, 2, 1);
649 if (nation_set_count() > 1) {
650 main_layout->addWidget(ns_label, 0, 0, 1, 1);
651 main_layout->addWidget(qnation_set, 0, 1, 1, 1);
652 main_layout->addWidget(nation_tabs, 1, 0, 5, 2);
653 } else {
654 main_layout->addWidget(nation_tabs, 0, 0, 6, 2);
655 }
656 main_layout->addWidget(styles, 2, 3, 4, 1);
657 main_layout->addWidget(description, 6, 0, 2, 4);
658 main_layout->addWidget(selected_nation_tabs, 0, 2, 6, 1);
659
661 set_index(-99);
662
663 if (C_S_RUNNING == client_state()) {
664 title = _("Edit Nation");
665 } else if (pplayer != nullptr && pplayer == client_player()) {
666 title = _("What Nation Will You Be?");
667 } else {
668 title = _("Pick Nation");
669 }
670
673}
674
675/***********************************************************************/
682
683/***********************************************************************/
687{
688 struct nation_group *group;
690 QHeaderView *header;
691 int i;
692 int count;
693
694 nation_tabs->clearContents();
695 nation_tabs->setRowCount(0);
696 nation_tabs->insertRow(0);
698 item->setText(_("All nations"));
699 item->setData(Qt::UserRole, -99);
700 nation_tabs->setItem(0, 0, item);
701
702 for (i = 1; i < nation_group_count() + 1; i++) {
703 group = nation_group_by_number(i - 1);
704 if (is_nation_group_hidden(group)) {
705 continue;
706 }
707 count = 0;
708 // Checking if group is empty
709 nations_iterate(pnation) {
710 if (!is_nation_playable(pnation)
711 || !is_nation_pickable(pnation)
712 || !nation_is_in_group(pnation, group)) {
713 continue;
714 }
715 count ++;
717 if (count == 0) {
718 continue;
719 }
720 nation_tabs->insertRow(i);
722 item->setData(Qt::UserRole, i - 1);
723 item->setText(nation_group_name_translation(group));
724 nation_tabs->setItem(i, 0, item);
725 }
726 header = nation_tabs->horizontalHeader();
727 header->resizeSections(QHeaderView::Stretch);
728 header = nation_tabs->verticalHeader();
729 header->resizeSections(QHeaderView::ResizeToContents);
730 set_index(-99);
731}
732
733/***********************************************************************/
737{
738 struct option *popt;
739 struct nation_set *s;
740
742 if (popt) {
744 qnation_set->setCurrentIndex(nation_set_index(s));
745 qnation_set->setToolTip(_(nation_set_description(s)));
746 }
747}
748
749/***********************************************************************/
753{
754 QModelIndexList indexes = selected.indexes();
755 QModelIndex index ;
756
757 if (indexes.isEmpty()) {
758 return;
759 }
760
761 index = indexes.at(0);
762 set_index(index.row());
763}
764
765/***********************************************************************/
770{
772 QPixmap *pix;
773 QFont f;
774 struct nation_group *group;
775 int i;
776 struct sprite *s;
777 QHeaderView *header;
778 bool svg = is_svg_flag_enabled();
779
780 selected_nation_tabs->clearContents();
781 selected_nation_tabs->setRowCount(0);
782
783 last_index = 0;
784 i = nation_tabs->currentRow();
785 if (i != -1) {
786 item = nation_tabs->item(i, 0);
787 index = item->data(Qt::UserRole).toInt();
788 }
789
790 group = nation_group_by_number(index);
791 i = 0;
792 nations_iterate(pnation) {
793 if (!is_nation_playable(pnation)
794 || !is_nation_pickable(pnation)) {
795 continue;
796 }
797 if (!nation_is_in_group(pnation, group) && index != -99) {
798 continue;
799 }
801 selected_nation_tabs->insertRow(i);
802 s = get_nation_flag_sprite(tileset, pnation);
803 if (pnation->player) {
804 f = item->font();
805 f.setStrikeOut(true);
806 item->setFont(f);
807 }
808 pix = s->pm;
809 if (svg) {
810 item->setData(Qt::DecorationRole, (*pix).scaledToHeight(50));
811 } else {
812 item->setData(Qt::DecorationRole, *pix);
813 }
814 item->setData(Qt::UserRole, nation_number(pnation));
815 item->setText(nation_adjective_translation(pnation));
816 selected_nation_tabs->setItem(i, 0, item);
818
819 selected_nation_tabs->sortByColumn(0, Qt::AscendingOrder);
820 header = selected_nation_tabs->horizontalHeader();
821 header->resizeSections(QHeaderView::Stretch);
822 header = selected_nation_tabs->verticalHeader();
823 header->resizeSections(QHeaderView::ResizeToContents);
824}
825
826/***********************************************************************/
830{
831 char buf[4096];
832 QModelIndex index ;
834 QModelIndexList indexes = selected.indexes();
835 QString str;
837 int style, ind;
838
839 if (indexes.isEmpty()) {
840 return;
841 }
842
843 index = indexes.at(0);
844 if (indexes.isEmpty()) {
845 return;
846 }
847 qvar = index.data(Qt::UserRole);
848 selected_nation = qvar.toInt();
849
851 description->setPlainText(buf);
852 leader_name->clear();
853 if (client.conn.playing == tplayer) {
854 leader_name->addItem(client.conn.playing->name, true);
855 }
858 str = QString::fromUtf8(nation_leader_name(pleader));
861
862 // Select style for nation
863
865 qvar = qvar.fromValue<int>(style);
866
867 for (ind = 0; ind < styles->rowCount(); ind++) {
868 item = styles->item(ind, 0);
869
870 if (item->data(Qt::UserRole) == qvar) {
871 styles->selectRow(ind);
872 }
873 }
874}
875
876/***********************************************************************/
880{
881 QModelIndex index ;
883 QModelIndexList indexes = selected.indexes();
884
885 if (indexes.isEmpty()) {
886 return;
887 }
888
889 index = indexes.at(0);
890 qvar = index.data(Qt::UserRole);
891 selected_style = qvar.toInt();
892}
893
894/***********************************************************************/
898{
899 if (leader_name->itemData(index).toBool()) {
900 is_male->setChecked(true);
901 is_female->setChecked(false);
902 } else {
903 is_male->setChecked(false);
904 is_female->setChecked(true);
905 }
906}
907
908/***********************************************************************/
913{
915 struct player *natplr;
916
917 if (selected_nation == -1) {
918 return;
919 }
920
921 if (selected_style == -1) {
922 output_window_append(ftc_client, _("You must select your style."));
923 return;
924 }
925
926 if (leader_name->currentText().length() == 0) {
927 output_window_append(ftc_client, _("You must type a legal name."));
928 return;
929 }
930
932 if (natplr != nullptr && natplr != client_player()) {
934 _("Nation has been chosen by other player"));
935 return;
936 }
937
938 ln_bytes = leader_name->currentText().toUtf8();
940 selected_nation, sex_buttons->checkedId(),
941 ln_bytes.data(),
943 close();
944 deleteLater();
945}
946
947/***********************************************************************/
951 const char *lines, QWidget *parent)
952 : fcwidget()
953{
954 int x, y;
956
957 setAttribute(Qt::WA_DeleteOnClose);
958 setCursor(Qt::ArrowCursor);
960 setFrameStyle(QFrame::Box);
961 cw = new close_widget(this);
962 cw->put_to_corner();
963
967 qlist = qlines.split("\n");
968 small_font = *fc_font::instance()->get_font("gui_qt_font_notify_label");
969 x = 0;
970 y = 0;
971 calc_size(x, y);
972 resize(x, y);
973 gui()->mapview_wdg->find_place(gui()->mapview_wdg->width() - x - 4, 4,
974 x, y, x, y, 0);
975 move(x, y);
976 was_destroyed = false;
977
978}
979
980/***********************************************************************/
984{
985 QString s, q;
986 int i;
990
991 for (i = 0; i < qlist.size(); ++i) {
992 s = qlist.at(i);
993 q = q + s;
994 if (i < qlist.size() - 1) {
995 q = q + QChar('\n');
996 }
997 }
998 capt_bytes = qcaption.toUtf8();
999 hl_bytes = qheadline.toUtf8();
1000 qb_bytes = q.toUtf8();
1002 hl_bytes.data(),
1003 qb_bytes.data());
1004 close();
1005 destroy();
1006}
1007
1008/***********************************************************************/
1012{
1014 int i;
1015 QStringList str_list;
1016
1017 str_list = qlist;
1018 str_list << qcaption << qheadline;
1019
1020 for (i = 0; i < str_list.count(); i++) {
1021 x = qMax(x, fm.horizontalAdvance(str_list.at(i)));
1022 y = y + 3 + fm.height();
1023 }
1024 x = x + 15;
1025}
1026
1027/***********************************************************************/
1031{
1032 QPainter painter(this);
1033 QPainterPath path;
1034 QPen pen;
1036 int i;
1037
1038 pen.setWidth(1);
1039 pen.setColor(palette().color(QPalette::Text));
1040 painter.setFont(small_font);
1041 painter.setPen(pen);
1042 painter.drawText(10, fm.height() + 3, qcaption);
1043 painter.drawText(10, 2 * fm.height() + 6, qheadline);
1044 for (i = 0; i < qlist.count(); i++) {
1045 painter.drawText(10, 3 + (fm.height() + 3) * (i + 3), qlist[i]);
1046 }
1047 cw->put_to_corner();
1048}
1049
1050/***********************************************************************/
1054{
1055 cursor = mevent_gpos(event) - geometry().topLeft();
1056
1057 if (event->button() == Qt::RightButton) {
1058 was_destroyed = true;
1059 close();
1060 }
1061}
1062
1063/***********************************************************************/
1067{
1069
1070 setCursor(Qt::SizeAllCursor);
1071}
1072
1073/***********************************************************************/
1077{
1078 setCursor(Qt::ArrowCursor);
1079}
1080
1081/***********************************************************************/
1085{
1086 was_destroyed = true;
1087 destroy();
1088}
1089
1090/***********************************************************************/
1096{
1097 was_destroyed = true;
1098 destroy();
1099}
1100
1101/***********************************************************************/
1105{
1106 vs_city = -1;
1107 vs_unit = -1;
1108}
1109
1110/***********************************************************************/
1114{
1115 if (!m_instance) {
1116 m_instance = new qdef_act;
1117 }
1118 return m_instance;
1119}
1120
1121/***********************************************************************/
1125{
1126 if (m_instance) {
1127 delete m_instance;
1128 m_instance = 0;
1129 }
1130}
1131
1132/***********************************************************************/
1136{
1137 vs_city = i;
1138}
1139
1140/***********************************************************************/
1144{
1145 vs_unit = i;
1146}
1147
1148/***********************************************************************/
1152{
1153 return vs_city;
1154}
1155
1156/***********************************************************************/
1160{
1161 return vs_unit;
1162}
1163
1164/***********************************************************************/
1168{
1169 delete this;
1170}
1171
1172/***********************************************************************/
1176{
1178 false, "", 0);
1179 delete this;
1180}
1181
1182/***********************************************************************/
1185notify_goto::notify_goto(const char *headline, const char *lines,
1186 const struct text_tag_list *tags, tile *ptile,
1187 QWidget *parent): QMessageBox(parent)
1188{
1190 setAttribute(Qt::WA_DeleteOnClose);
1191 goto_but = this->addButton(_("Goto Location"), QMessageBox::ActionRole);
1192 goto_but->setIcon(fc_icons::instance()->get_icon("go-up"));
1193 inspect_but = this->addButton(_("Inspect City"), QMessageBox::ActionRole);
1194 inspect_but->setIcon(fc_icons::instance()->get_icon("plus"));
1195
1196 close_but = this->addButton(QMessageBox::Close);
1197 gtile = ptile;
1198 if (!gtile) {
1199 goto_but->setVisible(false);
1200 inspect_but->setVisible(false);
1201 } else {
1202 struct city *pcity = tile_city(gtile);
1203 inspect_but->setVisible(pcity != nullptr
1205 }
1207 qlines = lines;
1208 qlines.replace("\n", " ");
1209 setText(qlines);
1210 connect(goto_but, &QAbstractButton::pressed, this, &notify_goto::goto_tile);
1211 connect(inspect_but, &QAbstractButton::pressed, this, &notify_goto::inspect_city);
1212 connect(close_but, &QAbstractButton::pressed, this, &QWidget::close);
1213 show();
1214}
1215
1216/***********************************************************************/
1220{
1222 close();
1223}
1224
1225/***********************************************************************/
1229{
1230 struct city *pcity = tile_city(gtile);
1231 if (pcity) {
1233 }
1234 close();
1235}
1236
1237/***********************************************************************/
1241{
1242 QString rule_name;
1244 const char *rn;
1245 struct option *poption = optset_option_by_name(server_optset, "nationset");
1246
1247 rule_name = qnation_set->currentData().toString();
1248 rn_bytes = rule_name.toUtf8(); /* Hold QByteArray in a variable to
1249 * extend its, and data() buffer's,
1250 * lifetime */
1251 rn = rn_bytes.data();
1255 }
1256}
1257
1258/***********************************************************************/
1263void popup_notify_goto_dialog(const char *headline, const char *lines,
1264 const struct text_tag_list *tags,
1265 struct tile *ptile)
1266{
1267 notify_goto *ask = new notify_goto(headline, lines, tags, ptile,
1268 gui()->central_wdg);
1269 ask->show();
1270}
1271
1272/***********************************************************************/
1275void popup_connect_msg(const char *headline, const char *message)
1276{
1277 QMessageBox *msg = new QMessageBox(gui()->central_wdg);
1278
1279 msg->setText(message);
1280 msg->setStandardButtons(QMessageBox::Ok);
1281 msg->setWindowTitle(headline);
1282 msg->setAttribute(Qt::WA_DeleteOnClose);
1283 msg->show();
1284}
1285
1286/***********************************************************************/
1289void popup_notify_dialog(const char *caption, const char *headline,
1290 const char *lines)
1291{
1293 gui()->mapview_wdg);
1294 nd->show();
1295}
1296
1297/***********************************************************************/
1300void popup_races_dialog(struct player *pplayer)
1301{
1302 if (!is_race_dialog_open) {
1303 race_dialog = new races_dialog(pplayer, gui()->central_wdg);
1304 is_race_dialog_open = true;
1305 race_dialog->show();
1306 }
1307 race_dialog->showNormal();
1308}
1309
1310/***********************************************************************/
1315{
1316 if (is_race_dialog_open) {
1317 race_dialog->close();
1318 is_race_dialog_open = false;
1319 }
1320}
1321
1322/***********************************************************************/
1326{
1327 if (ptile != nullptr
1328 && (unit_list_size(ptile->units) > 1
1329 || (unit_list_size(ptile->units) == 1 && tile_city(ptile)))) {
1330 gui()->toggle_unit_sel_widget(ptile);
1331 }
1332}
1333
1334/***********************************************************************/
1338{
1339 gui()->update_unit_sel();
1340}
1341
1342/***********************************************************************/
1351
1352/***********************************************************************/
1355void races_update_pickable(bool nationset_change)
1356{
1357 if (is_race_dialog_open) {
1359 }
1360}
1361
1362/***********************************************************************/
1367{
1368 if (is_race_dialog_open) {
1370 }
1371}
1372
1373/***********************************************************************/
1377{
1380 = (gov != nullptr ? government_number(gov) : G_LAST);
1381
1383 ask = new hud_message_box(gui()->central_wdg);
1384 ask->setStandardButtons(QMessageBox::Cancel | QMessageBox::Ok);
1385 ask->setDefaultButton(QMessageBox::Cancel);
1386 ask->set_text_title(_("You say you wanna revolution?"),
1387 _("Revolution!"));
1388 ask->setAttribute(Qt::WA_DeleteOnClose);
1389 QObject::connect(ask, &hud_message_box::accepted, [=]() {
1390 if (government_id == G_LAST) {
1391 revolution_response(nullptr);
1392 } else {
1394
1395 if (government) {
1397 }
1398 }
1399 });
1400 ask->show();
1401 } else {
1403 }
1404}
1405
1406/***********************************************************************/
1419
1420/***********************************************************************/
1427
1428/***********************************************************************/
1436
1437/***********************************************************************/
1445
1446/***********************************************************************/
1453
1454/***********************************************************************/
1461
1462/***********************************************************************/
1466 QWidget *parent,
1467 void (*run_on_close_in)(int)): QWidget(parent)
1468{
1469 QLabel *l = new QLabel(text);
1470
1471 setProperty("themed_choice", true);
1472 layout = new QVBoxLayout(this);
1474
1475 layout->addWidget(l);
1476 setWindowFlags(Qt::Dialog);
1478 setAttribute(Qt::WA_DeleteOnClose);
1479 gui()->set_diplo_dialog(this);
1480
1492
1493 targeted_unit = nullptr;
1494 // No buttons are added yet.
1495 for (int i = 0; i < BUTTON_COUNT; i++) {
1496 action_button_map << nullptr;
1497 }
1498}
1499
1500/***********************************************************************/
1504{
1505 buttons_list.clear();
1506 action_button_map.clear();
1507 gui()->set_diplo_dialog(nullptr);
1508
1509 if (run_on_close) {
1511 run_on_close = nullptr;
1512 }
1513}
1514
1515/***********************************************************************/
1519{
1521
1524 struct canvas *pix;
1525 QPushButton *next, *prev;
1526 unit_skip = new QHBoxLayout;
1527 next = new QPushButton();
1528 next->setIcon(fc_icons::instance()->get_icon("city-right"));
1529 next->setIconSize(QSize(32, 32));
1530 next->setFixedSize(QSize(36, 36));
1531 prev = new QPushButton();
1532 prev->setIcon(fc_icons::instance()->get_icon("city-left"));
1533 prev->setIconSize(QSize(32, 32));
1534 prev->setFixedSize(QSize(36, 36));
1535 target_unit_button = new QPushButton;
1538 pix->map_pixmap.fill(Qt::transparent);
1539 put_unit(targeted_unit, pix, 1.0, 0, 0);
1540 target_unit_button->setIcon(QIcon(pix->map_pixmap));
1541 qtg_canvas_free(pix);
1542 target_unit_button->setIconSize(QSize(96, 96));
1543 target_unit_button->setFixedSize(QSize(100, 100));
1544 unit_skip->addStretch(100);
1545 unit_skip->addWidget(prev, Qt::AlignCenter);
1546 unit_skip->addWidget(target_unit_button, Qt::AlignCenter);
1547 unit_skip->addWidget(next, Qt::AlignCenter);
1548 layout->addLayout(unit_skip);
1549 unit_skip->addStretch(100);
1550 connect(prev, &QAbstractButton::clicked, this, &choice_dialog::prev_unit);
1551 connect(next, &QAbstractButton::clicked, this, &choice_dialog::next_unit);
1552 }
1553
1555}
1556
1557/***********************************************************************/
1561 QVariant data2, QString tool_tip = "",
1562 const int button_id = -1)
1563{
1565 data1, data2);
1566 int action = buttons_list.count();
1567
1568 QObject::connect(button, &QPushButton::clicked,
1571 });
1572
1573 buttons_list.append(button);
1574
1575 if (!tool_tip.isEmpty()) {
1576 button->setToolTip(tool_tip);
1577 }
1578
1579 if (0 <= button_id) {
1580 // The id is valid.
1581 action_button_map[button_id] = button;
1582 }
1583
1584 layout->addWidget(button);
1585}
1586
1587/***********************************************************************/
1591{
1592 QPoint p;
1593
1594 p = mapFromGlobal(QCursor::pos());
1595 p.setY(p.y()-this->height());
1596 p.setX(p.x()-this->width());
1597 move(p);
1598 show();
1599}
1600
1601/***********************************************************************/
1608
1609/***********************************************************************/
1613{
1614 if (id < 0) {
1615 fc_assert_msg(0 <= id, "Invalid button ID.");
1616 return nullptr;
1617 }
1618
1619 return action_button_map[id];
1620}
1621
1622/***********************************************************************/
1626{
1629
1631 if (action == -1) {
1632 return false;
1633 }
1634 func = af_map[action];
1635
1636 func(q1, q2);
1637 return true;
1638}
1639
1640/***********************************************************************/
1644{
1647
1649 if (action == -1) {
1650 return false;
1651 }
1652 func = af_map[action];
1653 func(q1, q2);
1654 return true;
1655}
1656
1657/***********************************************************************/
1661{
1662 struct tile *ptile;
1663 struct unit *new_target = nullptr;
1664 bool break_next = false;
1665 bool first = true;
1666 struct canvas *pix;
1667
1668 if (targeted_unit == nullptr) {
1669 return;
1670 }
1671
1672 ptile = targeted_unit->tile;
1673
1674 unit_list_iterate(ptile->units, ptgt) {
1675 if (first) {
1676 new_target = ptgt;
1677 first = false;
1678 }
1679 if (break_next) {
1680 new_target = ptgt;
1681 break;
1682 }
1683 if (ptgt == targeted_unit) {
1684 break_next = true;
1685 }
1690 pix->map_pixmap.fill(Qt::transparent);
1691 put_unit(targeted_unit, pix, 1.0, 0, 0);
1692 target_unit_button->setIcon(QIcon(pix->map_pixmap));
1693 qtg_canvas_free(pix);
1694 switch_target();
1695}
1696
1697/***********************************************************************/
1701{
1702 struct tile *ptile;
1703 struct unit *new_target = nullptr;
1704 struct canvas *pix;
1705 if (targeted_unit == nullptr) {
1706 return;
1707 }
1708
1709 ptile = targeted_unit->tile;
1710 unit_list_iterate(ptile->units, ptgt) {
1711 if ((ptgt == targeted_unit) && new_target != nullptr) {
1712 break;
1713 }
1714 new_target = ptgt;
1719 pix->map_pixmap.fill(Qt::transparent);
1720 put_unit(targeted_unit, pix, 1.0, 0, 0);
1721 target_unit_button->setIcon(QIcon(pix->map_pixmap));
1722 qtg_canvas_free(pix);
1723 switch_target();
1724}
1725
1726/***********************************************************************/
1730{
1731 if (targeted_unit == nullptr) {
1732 return;
1733 }
1734 unit_skip->setParent(nullptr);
1739 : nullptr),
1740 act_probs);
1741 layout->addLayout(unit_skip);
1742}
1743
1744/***********************************************************************/
1748{
1749 if (targeted_unit == nullptr) {
1750 return;
1751 }
1752
1753 unit_skip->setParent(nullptr);
1755 unit_id,
1760 layout->addLayout(unit_skip);
1761}
1762
1763/***********************************************************************/
1767{
1769 pfcn_void func = button->getFunc();
1770
1771 func(button->getData1(), button->getData2());
1772 close();
1773}
1774
1775/***********************************************************************/
1784{
1785 // Store the data in the stack.
1786 last_buttons_stack.append(button);
1787
1788 /* Temporary remove the button so it will end up below buttons added
1789 * before unstack_all_buttons() is called. */
1790 layout->removeWidget(button);
1791
1792 // Synchronize the list with the layout.
1793 buttons_list.removeAll(button);
1794}
1795
1796/***********************************************************************/
1801{
1802 while (!last_buttons_stack.isEmpty()) {
1803 Choice_dialog_button *button = last_buttons_stack.takeLast();
1804
1805 // Reinsert the button below the other buttons.
1806 buttons_list.append(button);
1807 layout->addWidget(button);
1808 }
1809}
1810
1811/***********************************************************************/
1814static void caravan_marketplace(QVariant data1, QVariant data2)
1815{
1816 int actor_unit_id = data1.toInt();
1817 int target_city_id = data2.toInt();
1818
1819 if (game_unit_by_number(actor_unit_id) != nullptr
1820 && game_city_by_number(target_city_id) != nullptr) {
1822 target_city_id, 0, "");
1823 }
1824}
1825
1826/***********************************************************************/
1830{
1831 int actor_unit_id = data1.toInt();
1832 int target_city_id = data2.toInt();
1833
1834 if (game_unit_by_number(actor_unit_id) != nullptr
1835 && game_city_by_number(target_city_id) != nullptr) {
1837 target_city_id, 0, "");
1838 }
1839}
1840
1841/***********************************************************************/
1844static void caravan_help_build(QVariant data1, QVariant data2)
1845{
1846 int caravan_id = data1.toInt();
1847 int caravan_target_id = data2.toInt();
1848
1849 if (game_unit_by_number(caravan_id) != nullptr
1850 && game_city_by_number(caravan_target_id) != nullptr) {
1853 }
1854}
1855
1856/***********************************************************************/
1859static void unit_disband_recover(QVariant data1, QVariant data2)
1860{
1861 int actor_id = data1.toInt();
1862 int tgt_city_id = data2.toInt();
1863
1864 if (game_unit_by_number(actor_id) != nullptr
1865 && game_city_by_number(tgt_city_id) != nullptr) {
1867 actor_id, tgt_city_id, 0, "");
1868 }
1869}
1870
1871/***********************************************************************/
1874static void unit_home_city(QVariant data1, QVariant data2)
1875{
1876 int actor_id = data1.toInt();
1877 int tgt_city_id = data2.toInt();
1878
1879 if (game_unit_by_number(actor_id) != nullptr
1880 && game_city_by_number(tgt_city_id) != nullptr) {
1882 actor_id, tgt_city_id, 0, "");
1883 }
1884}
1885
1886/***********************************************************************/
1889static void unit_upgrade(QVariant data1, QVariant data2)
1890{
1891 struct unit *punit;
1892
1893 int actor_id = data1.toInt();
1894 int tgt_city_id = data2.toInt();
1895
1896 if ((punit = game_unit_by_number(actor_id)) != nullptr
1897 && game_city_by_number(tgt_city_id) != nullptr) {
1898 struct unit_list *as_list;
1899
1904 }
1905}
1906
1907/***********************************************************************/
1910static void airlift(QVariant data1, QVariant data2)
1911{
1912 int actor_id = data1.toInt();
1913 int tgt_city_id = data2.toInt();
1914
1915 if (game_unit_by_number(actor_id) != nullptr
1916 && game_city_by_number(tgt_city_id) != nullptr) {
1918 actor_id, tgt_city_id, 0, "");
1919 }
1920}
1921
1922/***********************************************************************/
1925static void conquer_city_shrink(QVariant data1, QVariant data2)
1926{
1927 int actor_id = data1.toInt();
1928 int tgt_city_id = data2.toInt();
1929
1930 if (game_unit_by_number(actor_id) != nullptr
1931 && game_city_by_number(tgt_city_id) != nullptr) {
1933 actor_id, tgt_city_id, 0, "");
1934 }
1935}
1936
1937/***********************************************************************/
1940static void conquer_city_shrink2(QVariant data1, QVariant data2)
1941{
1942 int actor_id = data1.toInt();
1943 int tgt_city_id = data2.toInt();
1944
1945 if (game_unit_by_number(actor_id) != nullptr
1946 && game_city_by_number(tgt_city_id) != nullptr) {
1948 actor_id, tgt_city_id, 0, "");
1949 }
1950}
1951
1952/***********************************************************************/
1955static void conquer_city_shrink3(QVariant data1, QVariant data2)
1956{
1957 int actor_id = data1.toInt();
1958 int tgt_city_id = data2.toInt();
1959
1960 if (game_unit_by_number(actor_id) != nullptr
1961 && game_city_by_number(tgt_city_id) != nullptr) {
1963 actor_id, tgt_city_id, 0, "");
1964 }
1965}
1966
1967/***********************************************************************/
1970static void conquer_city_shrink4(QVariant data1, QVariant data2)
1971{
1972 int actor_id = data1.toInt();
1973 int tgt_city_id = data2.toInt();
1974
1975 if (game_unit_by_number(actor_id) != nullptr
1976 && game_city_by_number(tgt_city_id) != nullptr) {
1978 actor_id, tgt_city_id, 0, "");
1979 }
1980}
1981
1982/***********************************************************************/
1985static void conquer_extras(QVariant data1, QVariant data2)
1986{
1987 int actor_id = data1.toInt();
1988 int target_id = data2.toInt();
1989
1990 if (game_unit_by_number(actor_id) != nullptr) {
1992 actor_id, target_id, 0, "");
1993 }
1994}
1995
1996/***********************************************************************/
1999static void conquer_extras2(QVariant data1, QVariant data2)
2000{
2001 int actor_id = data1.toInt();
2002 int target_id = data2.toInt();
2003
2004 if (game_unit_by_number(actor_id) != nullptr) {
2006 actor_id, target_id, 0, "");
2007 }
2008}
2009
2010/***********************************************************************/
2013static void conquer_extras3(QVariant data1, QVariant data2)
2014{
2015 int actor_id = data1.toInt();
2016 int target_id = data2.toInt();
2017
2018 if (game_unit_by_number(actor_id) != nullptr) {
2020 actor_id, target_id, 0, "");
2021 }
2022}
2023
2024/***********************************************************************/
2027static void conquer_extras4(QVariant data1, QVariant data2)
2028{
2029 int actor_id = data1.toInt();
2030 int target_id = data2.toInt();
2031
2032 if (game_unit_by_number(actor_id) != nullptr) {
2034 actor_id, target_id, 0, "");
2035 }
2036}
2037
2038/***********************************************************************/
2041static void act_sel_wait(QVariant data1, QVariant data2)
2042{
2043 key_unit_wait();
2044}
2045
2046/***********************************************************************/
2049static void keep_moving(QVariant data1, QVariant data2)
2050{
2051}
2052
2053/***********************************************************************/
2057{
2058 if (!gov) {
2060 } else {
2062 }
2063}
2064
2065/***********************************************************************/
2070{
2072 /* The client isn't waiting for information for any unanswered follow
2073 * up questions. */
2074
2075 struct unit *actor_unit;
2076
2078 /* The action selection dialog wasn't closed because the actor unit
2079 * was lost. */
2080
2081 // The probabilities didn't just disappear, right?
2084
2086 }
2087
2088 // The action selection process is over, at least for now.
2090
2091 if (did_not_decide) {
2092 /* The action selection dialog was closed but the player didn't
2093 * decide what the unit should do. */
2094
2095 // Reset so the next action selection dialog does the right thing.
2096 did_not_decide = false;
2097 } else {
2098 // An action, or no action at all, was selected.
2101 }
2102 }
2103}
2104
2105/***********************************************************************/
2109static void diplomat_queue_handle_secondary(int actor_id)
2110{
2111 // Stop waiting. Move on to the next queued unit.
2114}
2115
2116/**********************************************************************/
2123{
2124 // Stop assuming the answer to a follow up question will arrive.
2126}
2127
2128/***********************************************************************/
2133 struct city *target_city,
2134 struct unit *target_unit,
2135 struct tile *target_tile,
2136 struct extra_type *target_extra,
2137 const struct act_prob *act_probs)
2138{
2139 struct astring title = ASTRING_INIT, text = ASTRING_INIT;
2141 qtiles caras;
2142 QVariant qv1, qv2;
2144 struct city *actor_homecity;
2147
2150
2151 foreach (caras, gui()->trade_gen.lines) {
2152 if (caras.autocaravan == actor_unit) {
2153 int i;
2154
2155 if (game_unit_by_number(actor_unit->id) != nullptr
2156 && game_city_by_number(target_city->id) != nullptr) {
2158 target_city->id, 0, "");
2161 i = gui()->trade_gen.lines.indexOf(caras);
2162 gui()->trade_gen.lines.takeAt(i);
2163
2164 return;
2165 }
2166 }
2167 }
2168 if (target_city
2172
2173 return;
2174 }
2175
2176 if (target_unit
2180
2181 return;
2182 }
2183 /* Could be caused by the server failing to reply to a request for more
2184 * information or a bug in the client code. */
2186 "Diplomat queue problem. Is another diplomat window open?");
2187
2188 // No extra input is required as no action has been chosen yet.
2190
2192
2193 astr_set(&title,
2194 // TRANS: %s is a unit name, e.g., Spy
2195 _("Choose Your %s's Strategy"),
2197
2198 if (target_city != nullptr && actor_homecity != nullptr) {
2199 astr_set(&text,
2200 _("Your %s from %s reaches the city of %s.\nWhat now?"),
2204 } else if (target_city != nullptr) {
2205 astr_set(&text,
2206 _("Your %s has arrived at %s.\nWhat is your command?"),
2209 } else if (target_unit != nullptr) {
2211
2212 if (owner != nullptr) {
2213 astr_set(&text,
2214 // TRANS: Your Spy is ready to act against Roman Freight.
2215 _("Your %s is ready to act against %s %s."),
2219 } else {
2220 // Flagless target
2221 astr_set(&text,
2222 // TRANS: Your Spy is ready to act against Freight.
2223 _("Your %s is ready to act against %s."),
2226 }
2227 } else {
2228 fc_assert_msg(target_unit != nullptr
2229 || target_city != nullptr
2230 || target_tile != nullptr,
2231 "No target specified.");
2232
2233 astr_set(&text,
2234 // TRANS: %s is a unit name, e.g., Diplomat, Spy
2235 _("Your %s is waiting for your command."),
2237 }
2238
2239 cd = gui()->get_diplo_dialog();
2240 if ((cd != nullptr) && cd->targeted_unit != nullptr) {
2241 cd->update_dialog(act_probs);
2242 return;
2243 }
2244 cd = new choice_dialog(astr_str(&title), astr_str(&text),
2245 gui()->game_tab_widget,
2247 qv1 = actor_unit->id;
2248
2249 cd->unit_id = actor_unit->id;
2250
2251 cd->target_id[ATK_SELF] = cd->unit_id;
2252
2253 if (target_city) {
2254 cd->target_id[ATK_CITY] = target_city->id;
2255 } else {
2256 cd->target_id[ATK_CITY] = IDENTITY_NUMBER_ZERO;
2257 }
2258
2259 if (target_unit) {
2260 cd->target_id[ATK_UNIT] = target_unit->id;
2261 } else {
2262 cd->target_id[ATK_UNIT] = IDENTITY_NUMBER_ZERO;
2263 }
2264
2265 if (target_tile) {
2266 cd->target_id[ATK_STACK] = tile_index(target_tile);
2267 } else {
2268 cd->target_id[ATK_STACK] = TILE_INDEX_NONE;
2269 }
2270
2271 if (target_tile) {
2272 cd->target_id[ATK_TILE] = tile_index(target_tile);
2273 } else {
2274 cd->target_id[ATK_TILE] = TILE_INDEX_NONE;
2275 }
2276
2277 if (target_tile) {
2278 cd->target_id[ATK_EXTRAS] = tile_index(target_tile);
2279 } else {
2280 cd->target_id[ATK_EXTRAS] = TILE_INDEX_NONE;
2281 }
2282
2283 // No target building or target tech supplied. (Feb 2020)
2284 cd->sub_target_id[ASTK_BUILDING] = B_LAST;
2285 cd->sub_target_id[ASTK_TECH] = A_UNSET;
2286
2287 if (target_extra) {
2288 cd->sub_target_id[ASTK_EXTRA] = extra_number(target_extra);
2290 } else {
2291 cd->sub_target_id[ASTK_EXTRA] = EXTRA_NONE;
2292 cd->sub_target_id[ASTK_EXTRA_NOT_THERE] = EXTRA_NONE;
2293 }
2294
2295 // Unit acting against a city
2296
2297 // Set the correct target for the following actions.
2298 qv2 = cd->target_id[ATK_CITY];
2299
2300 action_iterate(act) {
2305 act_probs[act],
2306 actor_unit,
2307 target_city),
2308 qv1, qv2);
2309 }
2311
2312 // Unit acting against another unit
2313
2314 // Set the correct target for the following actions.
2315 qv2 = cd->target_id[ATK_UNIT];
2316
2317 action_iterate(act) {
2322 act_probs[act],
2323 actor_unit,
2324 target_city),
2325 qv1, qv2);
2326 }
2328
2329 // Unit acting against all units at a tile
2330
2331 // Set the correct target for the following actions.
2332 qv2 = cd->target_id[ATK_STACK];
2333
2334 action_iterate(act) {
2339 act_probs[act],
2340 actor_unit,
2341 target_city),
2342 qv1, qv2);
2343 }
2345
2346 // Unit acting against a tile.
2347
2348 // Set the correct target for the following actions.
2349 qv2 = cd->target_id[ATK_TILE];
2350
2351 action_iterate(act) {
2356 act_probs[act],
2357 actor_unit,
2358 target_city),
2359 qv1, qv2);
2360 }
2362
2363 // Unit acting against a tile's extras.
2364
2365 // Set the correct target for the following actions.
2366 qv2 = cd->target_id[ATK_EXTRAS];
2367
2368 action_iterate(act) {
2373 act_probs[act],
2374 actor_unit,
2375 target_city),
2376 qv1, qv2);
2377 }
2379
2380 // Unit acting against itself
2381
2382 // Set the correct target for the following actions.
2383 qv2 = cd->target_id[ATK_SELF];
2384
2385 action_iterate(act) {
2390 act_probs[act],
2391 actor_unit,
2392 target_city),
2393 qv1, qv2);
2394 }
2396
2398 cd->add_item(QString(_("&Wait")), func, qv1, qv2,
2399 "", BUTTON_WAIT);
2400
2401 func = keep_moving;
2402 cd->add_item(QString(_("Do nothing")), func, qv1, qv2,
2403 "", BUTTON_CANCEL);
2404
2405 cd->set_layout();
2406 cd->show_me();
2407
2408 // Give follow up questions access to action probabilities.
2410 action_iterate(act) {
2413
2414 astr_free(&title);
2415 astr_free(&text);
2416}
2417
2418/***********************************************************************/
2423{
2424 /* Don't add an action mapping here unless the non targeted version is
2425 * selectable in the targeted version's target selection dialog. */
2426 switch ((enum gen_action)tgt_action_id) {
2432 return ACTION_SPY_STEAL_TECH;
2435 default:
2436 // No non targeted version found.
2437 return ACTION_NONE;
2438 }
2439}
2440
2441/**********************************************************************/
2446{
2447 /* Don't add an action mapping here unless the non targeted version is
2448 * selectable in the targeted version's target selection dialog. */
2449 switch ((enum gen_action)tgt_action_id) {
2456 default:
2457 // No non targeted version found.
2458 return ACTION_NONE;
2459 }
2460}
2461
2462/***********************************************************************/
2466 action_id act,
2467 const struct act_prob *act_probs,
2468 const char *custom,
2469 QVariant data1, QVariant data2)
2470{
2471 QString title;
2473
2474 if (!af_map.contains(act)) {
2475 /* The Qt client doesn't support ordering this action from the
2476 * action selection dialog. */
2477 return;
2478 }
2479
2480 // Don't show disabled actions.
2481 if (!action_prob_possible(act_probs[act])) {
2482 return;
2483 }
2484
2486 act_probs[act],
2487 custom));
2488
2490 act_probs[act]));
2491
2492 cd->add_item(title, af_map[act], data1, data2, tool_tip, act);
2493}
2494
2495/***********************************************************************/
2499 action_id act,
2500 const struct act_prob *act_probs,
2501 const char *custom,
2502 QVariant data1, QVariant data2)
2503{
2504 QString title;
2506
2507 /* An action that just became impossible has its button disabled.
2508 * An action that became possible again must be re-enabled. */
2509 button->setEnabled(action_prob_possible(act_probs[act]));
2510 button->setData1(data1);
2511 button->setData2(data2);
2512 // The probability may have changed.
2514 act_probs[act],
2515 custom));
2516
2518 act_probs[act]));
2519
2520 button->setText(title);
2521 button->setToolTip(tool_tip);
2522}
2523
2524/***********************************************************************/
2527static void disband_unit(QVariant data1, QVariant data2)
2528{
2529 int actor_id = data1.toInt();
2530 int target_id = data2.toInt();
2531
2533 target_id, 0, "");
2534}
2535
2536/***********************************************************************/
2539static void fortify(QVariant data1, QVariant data2)
2540{
2541 int actor_id = data1.toInt();
2542 int target_id = data2.toInt();
2543
2544 if (game_unit_by_number(actor_id) != nullptr) {
2546 target_id, 0, "");
2547 }
2548}
2549
2550/***********************************************************************/
2553static void fortify2(QVariant data1, QVariant data2)
2554{
2555 int actor_id = data1.toInt();
2556 int target_id = data2.toInt();
2557
2558 if (game_unit_by_number(actor_id) != nullptr) {
2560 target_id, 0, "");
2561 }
2562}
2563
2564/***********************************************************************/
2567static void convert_unit(QVariant data1, QVariant data2)
2568{
2569 int actor_id = data1.toInt();
2570 int target_id = data2.toInt();
2571
2573 target_id, 0, "");
2574}
2575
2576/***********************************************************************/
2579static void homeless(QVariant data1, QVariant data2)
2580{
2581 int actor_id = data1.toInt();
2582 int target_id = data2.toInt();
2583
2584 if (game_unit_by_number(actor_id) != nullptr) {
2586 target_id, 0, "");
2587 }
2588}
2589
2590/***********************************************************************/
2593static void diplomat_bribe_unit(QVariant data1, QVariant data2)
2594{
2595 int diplomat_id = data1.toInt();
2596 int diplomat_target_id = data2.toInt();
2597
2598 if (game_unit_by_number(diplomat_id) != nullptr
2599 && game_unit_by_number(diplomat_target_id) != nullptr) {
2600 // Wait for the server's reply before moving on to the next queued diplomat.
2602
2605 }
2606}
2607
2608/***********************************************************************/
2611static void diplomat_bribe_stack(QVariant data1, QVariant data2)
2612{
2613 int diplomat_id = data1.toInt();
2614 int diplomat_target_id = data2.toInt();
2615
2616 if (game_unit_by_number(diplomat_id) != nullptr) {
2617 // Wait for the server's reply before moving on to the next queued diplomat.
2619
2622 }
2623}
2624
2625/***********************************************************************/
2628static void spy_sabotage_unit(QVariant data1, QVariant data2)
2629{
2630 int diplomat_id = data1.toInt();
2631 int diplomat_target_id = data2.toInt();
2632
2634 diplomat_target_id, 0, "");
2635}
2636
2637/***********************************************************************/
2640static void spy_sabotage_unit_esc(QVariant data1, QVariant data2)
2641{
2642 int diplomat_id = data1.toInt();
2643 int diplomat_target_id = data2.toInt();
2644
2646 diplomat_target_id, 0, "");
2647}
2648
2649/***********************************************************************/
2652static void heal_unit(QVariant data1, QVariant data2)
2653{
2654 int actor_id = data1.toInt();
2655 int target_id = data2.toInt();
2656
2657 request_do_action(ACTION_HEAL_UNIT, actor_id, target_id, 0, "");
2658}
2659
2660/***********************************************************************/
2663static void heal_unit2(QVariant data1, QVariant data2)
2664{
2665 int actor_id = data1.toInt();
2666 int target_id = data2.toInt();
2667
2668 request_do_action(ACTION_HEAL_UNIT2, actor_id, target_id, 0, "");
2669}
2670
2671/***********************************************************************/
2674static void transport_board(QVariant data1, QVariant data2)
2675{
2676 int actor_id = data1.toInt();
2677 int target_id = data2.toInt();
2678
2679 request_do_action(ACTION_TRANSPORT_BOARD, actor_id, target_id, 0, "");
2680}
2681
2682/***********************************************************************/
2685static void transport_board2(QVariant data1, QVariant data2)
2686{
2687 int actor_id = data1.toInt();
2688 int target_id = data2.toInt();
2689
2690 request_do_action(ACTION_TRANSPORT_BOARD2, actor_id, target_id, 0, "");
2691}
2692
2693/***********************************************************************/
2696static void transport_board3(QVariant data1, QVariant data2)
2697{
2698 int actor_id = data1.toInt();
2699 int target_id = data2.toInt();
2700
2701 request_do_action(ACTION_TRANSPORT_BOARD3, actor_id, target_id, 0, "");
2702}
2703
2704/***********************************************************************/
2707static void transport_embark(QVariant data1, QVariant data2)
2708{
2709 int actor_id = data1.toInt();
2710 int target_id = data2.toInt();
2711
2712 request_do_action(ACTION_TRANSPORT_EMBARK, actor_id, target_id, 0, "");
2713}
2714
2715/***********************************************************************/
2718static void transport_embark2(QVariant data1, QVariant data2)
2719{
2720 int actor_id = data1.toInt();
2721 int target_id = data2.toInt();
2722
2723 request_do_action(ACTION_TRANSPORT_EMBARK2, actor_id, target_id, 0, "");
2724}
2725
2726/***********************************************************************/
2729static void transport_embark3(QVariant data1, QVariant data2)
2730{
2731 int actor_id = data1.toInt();
2732 int target_id = data2.toInt();
2733
2734 request_do_action(ACTION_TRANSPORT_EMBARK3, actor_id, target_id, 0, "");
2735}
2736
2737/***********************************************************************/
2740static void transport_embark4(QVariant data1, QVariant data2)
2741{
2742 int actor_id = data1.toInt();
2743 int target_id = data2.toInt();
2744
2745 request_do_action(ACTION_TRANSPORT_EMBARK4, actor_id, target_id, 0, "");
2746}
2747
2748/***********************************************************************/
2751static void transport_unload(QVariant data1, QVariant data2)
2752{
2753 int actor_id = data1.toInt();
2754 int target_id = data2.toInt();
2755
2756 request_do_action(ACTION_TRANSPORT_UNLOAD, actor_id, target_id, 0, "");
2757}
2758
2759/***********************************************************************/
2762static void transport_load(QVariant data1, QVariant data2)
2763{
2764 int actor_id = data1.toInt();
2765 int target_id = data2.toInt();
2766
2767 request_do_action(ACTION_TRANSPORT_LOAD, actor_id, target_id, 0, "");
2768}
2769
2770/***********************************************************************/
2773static void transport_load2(QVariant data1, QVariant data2)
2774{
2775 int actor_id = data1.toInt();
2776 int target_id = data2.toInt();
2777
2778 request_do_action(ACTION_TRANSPORT_LOAD2, actor_id, target_id, 0, "");
2779}
2780
2781/***********************************************************************/
2784static void transport_load3(QVariant data1, QVariant data2)
2785{
2786 int actor_id = data1.toInt();
2787 int target_id = data2.toInt();
2788
2789 request_do_action(ACTION_TRANSPORT_LOAD3, actor_id, target_id, 0, "");
2790}
2791
2792/***********************************************************************/
2795static void transport_deboard(QVariant data1, QVariant data2)
2796{
2797 int actor_id = data1.toInt();
2798 int target_id = data2.toInt();
2799
2800 request_do_action(ACTION_TRANSPORT_DEBOARD, actor_id, target_id, 0, "");
2801}
2802
2803/***********************************************************************/
2806static void disembark1(QVariant data1, QVariant data2)
2807{
2808 int actor_id = data1.toInt();
2809 int target_id = data2.toInt();
2810
2811 if (game_unit_by_number(actor_id) != nullptr
2812 && index_to_tile(&(wld.map), target_id) != nullptr) {
2814 actor_id, target_id, 0, "");
2815 }
2816}
2817
2818/***********************************************************************/
2821static void disembark2(QVariant data1, QVariant data2)
2822{
2823 int actor_id = data1.toInt();
2824 int target_id = data2.toInt();
2825
2826 if (game_unit_by_number(actor_id) != nullptr
2827 && index_to_tile(&(wld.map), target_id) != nullptr) {
2829 actor_id, target_id, 0, "");
2830 }
2831}
2832
2833/***********************************************************************/
2836static void disembark3(QVariant data1, QVariant data2)
2837{
2838 int actor_id = data1.toInt();
2839 int target_id = data2.toInt();
2840
2841 if (game_unit_by_number(actor_id) != nullptr
2842 && index_to_tile(&(wld.map), target_id) != nullptr) {
2844 actor_id, target_id, 0, "");
2845 }
2846}
2847
2848/***********************************************************************/
2851static void disembark4(QVariant data1, QVariant data2)
2852{
2853 int actor_id = data1.toInt();
2854 int target_id = data2.toInt();
2855
2856 if (game_unit_by_number(actor_id) != nullptr
2857 && index_to_tile(&(wld.map), target_id) != nullptr) {
2859 actor_id, target_id, 0, "");
2860 }
2861}
2862
2863/***********************************************************************/
2866static void enter_hut(QVariant data1, QVariant data2)
2867{
2868 int actor_id = data1.toInt();
2869 int target_id = data2.toInt();
2870
2871 if (game_unit_by_number(actor_id) != nullptr
2872 && index_to_tile(&(wld.map), target_id) != nullptr) {
2874 actor_id, target_id, 0, "");
2875 }
2876}
2877
2878/***********************************************************************/
2881static void enter_hut2(QVariant data1, QVariant data2)
2882{
2883 int actor_id = data1.toInt();
2884 int target_id = data2.toInt();
2885
2886 if (game_unit_by_number(actor_id) != nullptr
2887 && index_to_tile(&(wld.map), target_id) != nullptr) {
2889 actor_id, target_id, 0, "");
2890 }
2891}
2892
2893/***********************************************************************/
2896static void enter_hut3(QVariant data1, QVariant data2)
2897{
2898 int actor_id = data1.toInt();
2899 int target_id = data2.toInt();
2900
2901 if (game_unit_by_number(actor_id) != nullptr
2902 && index_to_tile(&(wld.map), target_id) != nullptr) {
2904 actor_id, target_id, 0, "");
2905 }
2906}
2907
2908/***********************************************************************/
2911static void enter_hut4(QVariant data1, QVariant data2)
2912{
2913 int actor_id = data1.toInt();
2914 int target_id = data2.toInt();
2915
2916 if (game_unit_by_number(actor_id) != nullptr
2917 && index_to_tile(&(wld.map), target_id) != nullptr) {
2919 actor_id, target_id, 0, "");
2920 }
2921}
2922
2923/***********************************************************************/
2926static void frighten_hut(QVariant data1, QVariant data2)
2927{
2928 int actor_id = data1.toInt();
2929 int target_id = data2.toInt();
2930
2931 if (game_unit_by_number(actor_id) != nullptr
2932 && index_to_tile(&(wld.map), target_id) != nullptr) {
2934 actor_id, target_id, 0, "");
2935 }
2936}
2937
2938/***********************************************************************/
2941static void frighten_hut2(QVariant data1, QVariant data2)
2942{
2943 int actor_id = data1.toInt();
2944 int target_id = data2.toInt();
2945
2946 if (game_unit_by_number(actor_id) != nullptr
2947 && index_to_tile(&(wld.map), target_id) != nullptr) {
2949 actor_id, target_id, 0, "");
2950 }
2951}
2952
2953/***********************************************************************/
2956static void frighten_hut3(QVariant data1, QVariant data2)
2957{
2958 int actor_id = data1.toInt();
2959 int target_id = data2.toInt();
2960
2961 if (game_unit_by_number(actor_id) != nullptr
2962 && index_to_tile(&(wld.map), target_id) != nullptr) {
2964 actor_id, target_id, 0, "");
2965 }
2966}
2967
2968/***********************************************************************/
2971static void frighten_hut4(QVariant data1, QVariant data2)
2972{
2973 int actor_id = data1.toInt();
2974 int target_id = data2.toInt();
2975
2976 if (game_unit_by_number(actor_id) != nullptr
2977 && index_to_tile(&(wld.map), target_id) != nullptr) {
2979 actor_id, target_id, 0, "");
2980 }
2981}
2982
2983/**********************************************************************/
2986static void nuke_units(QVariant data1, QVariant data2)
2987{
2988 int actor_id = data1.toInt();
2989 int target_id = data2.toInt();
2990
2992 target_id, 0, "");
2993}
2994
2995/**********************************************************************/
2998static void collect_ransom(QVariant data1, QVariant data2)
2999{
3000 int actor_id = data1.toInt();
3001 int target_id = data2.toInt();
3002
3004 target_id, 0, "");
3005}
3006
3007/**********************************************************************/
3010static void spy_attack(QVariant data1, QVariant data2)
3011{
3012 int actor_id = data1.toInt();
3013 int target_id = data2.toInt();
3014
3016 target_id, 0, "");
3017}
3018
3019/**********************************************************************/
3022static void wipe_units(QVariant data1, QVariant data2)
3023{
3024 int actor_id = data1.toInt();
3025 int target_id = data2.toInt();
3026
3028 target_id, 0, "");
3029}
3030
3031/**********************************************************************/
3034static void capture_units(QVariant data1, QVariant data2)
3035{
3036 int actor_id = data1.toInt();
3037 int target_id = data2.toInt();
3038
3040 target_id, 0, "");
3041}
3042
3043/***********************************************************************/
3046static void expel_unit(QVariant data1, QVariant data2)
3047{
3048 int actor_id = data1.toInt();
3049 int target_id = data2.toInt();
3050
3052 target_id, 0, "");
3053}
3054
3055/***********************************************************************/
3058static void bombard(QVariant data1, QVariant data2)
3059{
3060 int actor_id = data1.toInt();
3061 int target_id = data2.toInt();
3062
3064 target_id, 0, "");
3065}
3066
3067/***********************************************************************/
3070static void bombard2(QVariant data1, QVariant data2)
3071{
3072 int actor_id = data1.toInt();
3073 int target_id = data2.toInt();
3074
3076 target_id, 0, "");
3077}
3078
3079/***********************************************************************/
3082static void bombard3(QVariant data1, QVariant data2)
3083{
3084 int actor_id = data1.toInt();
3085 int target_id = data2.toInt();
3086
3088 target_id, 0, "");
3089}
3090
3091/***********************************************************************/
3094static void bombard4(QVariant data1, QVariant data2)
3095{
3096 int actor_id = data1.toInt();
3097 int target_id = data2.toInt();
3098
3100 target_id, 0, "");
3101}
3102
3103/***********************************************************************/
3106static void bombard_lethal(QVariant data1, QVariant data2)
3107{
3108 int actor_id = data1.toInt();
3109 int target_id = data2.toInt();
3110
3112 target_id, 0, "");
3113}
3114
3115/***********************************************************************/
3118static void bombard_lethal2(QVariant data1, QVariant data2)
3119{
3120 int actor_id = data1.toInt();
3121 int target_id = data2.toInt();
3122
3124 target_id, 0, "");
3125}
3126
3127/***********************************************************************/
3130static void found_city(QVariant data1, QVariant data2)
3131{
3132 int actor_id = data1.toInt();
3133
3135 actor_id);
3136}
3137
3138/***********************************************************************/
3141static void transform_terrain(QVariant data1, QVariant data2)
3142{
3143 int actor_id = data1.toInt();
3144 int target_id = data2.toInt();
3145
3146 if (game_unit_by_number(actor_id) != nullptr
3147 && index_to_tile(&(wld.map), target_id) != nullptr) {
3149 actor_id, target_id, 0, "");
3150 }
3151}
3152
3153/***********************************************************************/
3156static void transform_terrain2(QVariant data1, QVariant data2)
3157{
3158 int actor_id = data1.toInt();
3159 int target_id = data2.toInt();
3160
3161 if (game_unit_by_number(actor_id) != nullptr
3162 && index_to_tile(&(wld.map), target_id) != nullptr) {
3164 actor_id, target_id, 0, "");
3165 }
3166}
3167
3168/***********************************************************************/
3171static void cultivate(QVariant data1, QVariant data2)
3172{
3173 int actor_id = data1.toInt();
3174 int target_id = data2.toInt();
3175
3176 if (game_unit_by_number(actor_id) != nullptr
3177 && index_to_tile(&(wld.map), target_id) != nullptr) {
3179 actor_id, target_id, 0, "");
3180 }
3181}
3182
3183/***********************************************************************/
3186static void cultivate2(QVariant data1, QVariant data2)
3187{
3188 int actor_id = data1.toInt();
3189 int target_id = data2.toInt();
3190
3191 if (game_unit_by_number(actor_id) != nullptr
3192 && index_to_tile(&(wld.map), target_id) != nullptr) {
3194 actor_id, target_id, 0, "");
3195 }
3196}
3197
3198/***********************************************************************/
3201static void plant(QVariant data1, QVariant data2)
3202{
3203 int actor_id = data1.toInt();
3204 int target_id = data2.toInt();
3205
3206 if (game_unit_by_number(actor_id) != nullptr
3207 && index_to_tile(&(wld.map), target_id) != nullptr) {
3209 actor_id, target_id, 0, "");
3210 }
3211}
3212
3213/***********************************************************************/
3216static void plant2(QVariant data1, QVariant data2)
3217{
3218 int actor_id = data1.toInt();
3219 int target_id = data2.toInt();
3220
3221 if (game_unit_by_number(actor_id) != nullptr
3222 && index_to_tile(&(wld.map), target_id) != nullptr) {
3224 actor_id, target_id, 0, "");
3225 }
3226}
3227
3228/***********************************************************************/
3231static void pillage(QVariant data1, QVariant data2)
3232{
3233 int actor_id = data1.toInt();
3234 int target_id = data2.toInt();
3235
3236 if (game_unit_by_number(actor_id) != nullptr
3237 && index_to_tile(&(wld.map), target_id) != nullptr) {
3239 actor_id, target_id,
3240 /* FIXME: will cause problems if more than
3241 * one action selection dialog at a time
3242 * becomes supported. */
3244 "");
3245 }
3246}
3247
3248/***********************************************************************/
3251static void pillage2(QVariant data1, QVariant data2)
3252{
3253 int actor_id = data1.toInt();
3254 int target_id = data2.toInt();
3255
3256 if (game_unit_by_number(actor_id) != nullptr
3257 && index_to_tile(&(wld.map), target_id) != nullptr) {
3259 actor_id, target_id,
3260 /* FIXME: will cause problems if more than
3261 * one action selection dialog at a time
3262 * becomes supported. */
3264 "");
3265 }
3266}
3267
3268/***********************************************************************/
3271static void clean(QVariant data1, QVariant data2)
3272{
3273 int actor_id = data1.toInt();
3274 int target_id = data2.toInt();
3275
3276 if (game_unit_by_number(actor_id) != nullptr
3277 && index_to_tile(&(wld.map), target_id) != nullptr) {
3279 actor_id, target_id,
3280 /* FIXME: will cause problems if more than
3281 * one action selection dialog at a time
3282 * becomes supported. */
3284 "");
3285 }
3286}
3287
3288/***********************************************************************/
3291static void clean2(QVariant data1, QVariant data2)
3292{
3293 int actor_id = data1.toInt();
3294 int target_id = data2.toInt();
3295
3296 if (game_unit_by_number(actor_id) != nullptr
3297 && index_to_tile(&(wld.map), target_id) != nullptr) {
3299 actor_id, target_id,
3300 /* FIXME: will cause problems if more than
3301 * one action selection dialog at a time
3302 * becomes supported. */
3304 "");
3305 }
3306}
3307
3308/***********************************************************************/
3311static void road(QVariant data1, QVariant data2)
3312{
3313 int actor_id = data1.toInt();
3314 int target_id = data2.toInt();
3315
3316 if (game_unit_by_number(actor_id) != nullptr
3317 && index_to_tile(&(wld.map), target_id) != nullptr
3320 actor_id, target_id,
3321 /* FIXME: will cause problems if more than
3322 * one action selection dialog at a time
3323 * becomes supported. */
3325 "");
3326 }
3327}
3328
3329/***********************************************************************/
3332static void road2(QVariant data1, QVariant data2)
3333{
3334 int actor_id = data1.toInt();
3335 int target_id = data2.toInt();
3336
3337 if (game_unit_by_number(actor_id) != nullptr
3338 && index_to_tile(&(wld.map), target_id) != nullptr
3341 actor_id, target_id,
3342 /* FIXME: will cause problems if more than
3343 * one action selection dialog at a time
3344 * becomes supported. */
3346 "");
3347 }
3348}
3349
3350/***********************************************************************/
3353static void base(QVariant data1, QVariant data2)
3354{
3355 int actor_id = data1.toInt();
3356 int target_id = data2.toInt();
3357
3358 if (game_unit_by_number(actor_id) != nullptr
3359 && index_to_tile(&(wld.map), target_id) != nullptr
3362 actor_id, target_id,
3363 /* FIXME: will cause problems if more than
3364 * one action selection dialog at a time
3365 * becomes supported. */
3367 "");
3368 }
3369}
3370
3371/***********************************************************************/
3374static void base2(QVariant data1, QVariant data2)
3375{
3376 int actor_id = data1.toInt();
3377 int target_id = data2.toInt();
3378
3379 if (game_unit_by_number(actor_id) != nullptr
3380 && index_to_tile(&(wld.map), target_id) != nullptr
3383 actor_id, target_id,
3384 /* FIXME: will cause problems if more than
3385 * one action selection dialog at a time
3386 * becomes supported. */
3388 "");
3389 }
3390}
3391
3392/***********************************************************************/
3395static void mine(QVariant data1, QVariant data2)
3396{
3397 int actor_id = data1.toInt();
3398 int target_id = data2.toInt();
3399
3400 if (game_unit_by_number(actor_id) != nullptr
3401 && index_to_tile(&(wld.map), target_id) != nullptr
3404 actor_id, target_id,
3405 /* FIXME: will cause problems if more than
3406 * one action selection dialog at a time
3407 * becomes supported. */
3409 "");
3410 }
3411}
3412
3413/***********************************************************************/
3416static void mine2(QVariant data1, QVariant data2)
3417{
3418 int actor_id = data1.toInt();
3419 int target_id = data2.toInt();
3420
3421 if (game_unit_by_number(actor_id) != nullptr
3422 && index_to_tile(&(wld.map), target_id) != nullptr
3425 actor_id, target_id,
3426 /* FIXME: will cause problems if more than
3427 * one action selection dialog at a time
3428 * becomes supported. */
3430 "");
3431 }
3432}
3433
3434/***********************************************************************/
3437static void irrigate(QVariant data1, QVariant data2)
3438{
3439 int actor_id = data1.toInt();
3440 int target_id = data2.toInt();
3441
3442 if (game_unit_by_number(actor_id) != nullptr
3443 && index_to_tile(&(wld.map), target_id) != nullptr
3446 actor_id, target_id,
3447 /* FIXME: will cause problems if more than
3448 * one action selection dialog at a time
3449 * becomes supported. */
3451 "");
3452 }
3453}
3454
3455/***********************************************************************/
3458static void irrigate2(QVariant data1, QVariant data2)
3459{
3460 int actor_id = data1.toInt();
3461 int target_id = data2.toInt();
3462
3463 if (game_unit_by_number(actor_id) != nullptr
3464 && index_to_tile(&(wld.map), target_id) != nullptr
3467 actor_id, target_id,
3468 /* FIXME: will cause problems if more than
3469 * one action selection dialog at a time
3470 * becomes supported. */
3472 "");
3473 }
3474}
3475
3476/***********************************************************************/
3479static void nuke(QVariant data1, QVariant data2)
3480{
3481 int diplomat_id = data1.toInt();
3482 int diplomat_target_id = data2.toInt();
3483
3484 if (game_unit_by_number(diplomat_id) != nullptr
3485 && index_to_tile(&(wld.map), diplomat_target_id) != nullptr) {
3488 }
3489}
3490
3491/***********************************************************************/
3494static void attack(QVariant data1, QVariant data2)
3495{
3496 int diplomat_id = data1.toInt();
3497 int diplomat_target_id = data2.toInt();
3498
3499 if (game_unit_by_number(diplomat_id) != nullptr
3500 && index_to_tile(&(wld.map), diplomat_target_id) != nullptr) {
3503 }
3504}
3505
3506/***********************************************************************/
3509static void attack2(QVariant data1, QVariant data2)
3510{
3511 int diplomat_id = data1.toInt();
3512 int diplomat_target_id = data2.toInt();
3513
3514 if (game_unit_by_number(diplomat_id) != nullptr
3515 && index_to_tile(&(wld.map), diplomat_target_id) != nullptr) {
3518 }
3519}
3520
3521/***********************************************************************/
3524static void suicide_attack(QVariant data1, QVariant data2)
3525{
3526 int diplomat_id = data1.toInt();
3527 int diplomat_target_id = data2.toInt();
3528
3529 if (game_unit_by_number(diplomat_id) != nullptr
3530 && index_to_tile(&(wld.map), diplomat_target_id) != nullptr) {
3533 }
3534}
3535
3536/***********************************************************************/
3539static void suicide_attack2(QVariant data1, QVariant data2)
3540{
3541 int diplomat_id = data1.toInt();
3542 int diplomat_target_id = data2.toInt();
3543
3544 if (game_unit_by_number(diplomat_id) != nullptr
3545 && index_to_tile(&(wld.map), diplomat_target_id) != nullptr) {
3548 }
3549}
3550
3551/***********************************************************************/
3554static void paradrop(QVariant data1, QVariant data2)
3555{
3556 int actor_id = data1.toInt();
3557 int target_id = data2.toInt();
3558
3559 if (game_unit_by_number(actor_id) != nullptr
3560 && index_to_tile(&(wld.map), target_id) != nullptr) {
3562 actor_id, target_id, 0, "");
3563 }
3564}
3565
3566/***********************************************************************/
3569static void teleport(QVariant data1, QVariant data2)
3570{
3571 int actor_id = data1.toInt();
3572 int target_id = data2.toInt();
3573
3574 if (game_unit_by_number(actor_id) != nullptr
3575 && index_to_tile(&(wld.map), target_id) != nullptr) {
3577 actor_id, target_id, 0, "");
3578 }
3579}
3580
3581/***********************************************************************/
3584static void teleport2(QVariant data1, QVariant data2)
3585{
3586 int actor_id = data1.toInt();
3587 int target_id = data2.toInt();
3588
3589 if (game_unit_by_number(actor_id) != nullptr
3590 && index_to_tile(&(wld.map), target_id) != nullptr) {
3592 actor_id, target_id, 0, "");
3593 }
3594}
3595
3596/***********************************************************************/
3599static void teleport3(QVariant data1, QVariant data2)
3600{
3601 int actor_id = data1.toInt();
3602 int target_id = data2.toInt();
3603
3604 if (game_unit_by_number(actor_id) != nullptr
3605 && index_to_tile(&(wld.map), target_id) != nullptr) {
3607 actor_id, target_id, 0, "");
3608 }
3609}
3610
3611/***********************************************************************/
3614static void paradrop_conquer(QVariant data1, QVariant data2)
3615{
3616 int actor_id = data1.toInt();
3617 int target_id = data2.toInt();
3618
3619 if (game_unit_by_number(actor_id) != nullptr
3620 && index_to_tile(&(wld.map), target_id) != nullptr) {
3622 actor_id, target_id, 0, "");
3623 }
3624}
3625
3626/***********************************************************************/
3629static void teleport_conquer(QVariant data1, QVariant data2)
3630{
3631 int actor_id = data1.toInt();
3632 int target_id = data2.toInt();
3633
3634 if (game_unit_by_number(actor_id) != nullptr
3635 && index_to_tile(&(wld.map), target_id) != nullptr) {
3637 actor_id, target_id, 0, "");
3638 }
3639}
3640
3641/***********************************************************************/
3644static void paradrop_frighten(QVariant data1, QVariant data2)
3645{
3646 int actor_id = data1.toInt();
3647 int target_id = data2.toInt();
3648
3649 if (game_unit_by_number(actor_id) != nullptr
3650 && index_to_tile(&(wld.map), target_id) != nullptr) {
3652 actor_id, target_id, 0, "");
3653 }
3654}
3655
3656/***********************************************************************/
3659static void teleport_frighten(QVariant data1, QVariant data2)
3660{
3661 int actor_id = data1.toInt();
3662 int target_id = data2.toInt();
3663
3664 if (game_unit_by_number(actor_id) != nullptr
3665 && index_to_tile(&(wld.map), target_id) != nullptr) {
3667 actor_id, target_id, 0, "");
3668 }
3669}
3670
3671/***********************************************************************/
3675{
3676 int actor_id = data1.toInt();
3677 int target_id = data2.toInt();
3678
3679 if (game_unit_by_number(actor_id) != nullptr
3680 && index_to_tile(&(wld.map), target_id) != nullptr) {
3682 actor_id, target_id, 0, "");
3683 }
3684}
3685
3686/***********************************************************************/
3690{
3691 int actor_id = data1.toInt();
3692 int target_id = data2.toInt();
3693
3694 if (game_unit_by_number(actor_id) != nullptr
3695 && index_to_tile(&(wld.map), target_id) != nullptr) {
3697 actor_id, target_id, 0, "");
3698 }
3699}
3700
3701/***********************************************************************/
3704static void paradrop_enter(QVariant data1, QVariant data2)
3705{
3706 int actor_id = data1.toInt();
3707 int target_id = data2.toInt();
3708
3709 if (game_unit_by_number(actor_id) != nullptr
3710 && index_to_tile(&(wld.map), target_id) != nullptr) {
3712 actor_id, target_id, 0, "");
3713 }
3714}
3715
3716/***********************************************************************/
3719static void teleport_enter(QVariant data1, QVariant data2)
3720{
3721 int actor_id = data1.toInt();
3722 int target_id = data2.toInt();
3723
3724 if (game_unit_by_number(actor_id) != nullptr
3725 && index_to_tile(&(wld.map), target_id) != nullptr) {
3727 actor_id, target_id, 0, "");
3728 }
3729}
3730
3731/***********************************************************************/
3735{
3736 int actor_id = data1.toInt();
3737 int target_id = data2.toInt();
3738
3739 if (game_unit_by_number(actor_id) != nullptr
3740 && index_to_tile(&(wld.map), target_id) != nullptr) {
3742 actor_id, target_id, 0, "");
3743 }
3744}
3745
3746/***********************************************************************/
3750{
3751 int actor_id = data1.toInt();
3752 int target_id = data2.toInt();
3753
3754 if (game_unit_by_number(actor_id) != nullptr
3755 && index_to_tile(&(wld.map), target_id) != nullptr) {
3757 actor_id, target_id, 0, "");
3758 }
3759}
3760
3761/***********************************************************************/
3764static void join_city(QVariant data1, QVariant data2)
3765{
3766 int actor_id = data1.toInt();
3767 int target_id = data2.toInt();
3768
3769 if (game_unit_by_number(actor_id) != nullptr
3770 && game_city_by_number(target_id) != nullptr) {
3772 actor_id, target_id, 0, "");
3773 }
3774}
3775
3776/***********************************************************************/
3779static void spy_steal_shared(QVariant data1, QVariant data2,
3780 action_id act_id)
3781{
3782 QString str;
3783 QVariant qv1;
3785 int diplomat_id = data1.toInt();
3786 int diplomat_target_id = data2.toInt();
3789 struct player *pvictim = nullptr;
3792
3793 cd = gui()->get_diplo_dialog();
3794 if (cd != nullptr) {
3795 cd->close();
3796 }
3797
3798 if (pvcity == nullptr) {
3799 return;
3800 }
3801
3802 // Wait for the player's reply before moving on to the next queued diplomat.
3804
3806
3807 struct astring stra = ASTRING_INIT;
3808 cd = new choice_dialog(_("Steal"), _("Steal Technology"),
3809 gui()->game_tab_widget,
3811
3812 // Put both actor and target city in qv1 since qv2 is taken
3815 actor_and_target.append(act_id);
3816 qv1 = QVariant::fromValue(actor_and_target);
3817
3818 struct player *pplayer = client_player();
3819 const struct research *presearch = research_get(pplayer);
3820 const struct research *vresearch = research_get(pvictim);
3821
3828 // Defeat keyboard shortcut mnemonics
3830 .replace("&", "&&");
3831 cd->add_item(str, func, qv1, i);
3832 }
3834
3836 get_non_targeted_action_id(act_id)])) {
3837 astr_set(&stra, _("At %s's Discretion"),
3840 str = QString(astr_str(&stra)).replace("&", "&&");
3841 cd->add_item(str, func, qv1, A_UNSET);
3842 }
3843
3844 cd->set_layout();
3845 cd->show_me();
3846
3847 astr_free(&stra);
3848}
3849
3850/***********************************************************************/
3853static void spy_steal(QVariant data1, QVariant data2)
3854{
3856}
3857
3858/***********************************************************************/
3861static void spy_steal_esc(QVariant data1, QVariant data2)
3862{
3864}
3865
3866/***********************************************************************/
3869static void spy_steal_something(QVariant data1, QVariant data2)
3870{
3871 int diplomat_id = data1.toList().at(0).toInt();
3872 int diplomat_target_id = data1.toList().at(1).toInt();
3873 action_id act_id = data1.toList().at(2).toInt();
3874
3875 if (game_unit_by_number(diplomat_id) != nullptr
3876 && game_city_by_number(diplomat_target_id) != nullptr) {
3877 if (data2.toInt() == A_UNSET) {
3878 // This is the untargeted version.
3880 diplomat_id, diplomat_target_id, data2.toInt(), "");
3881 } else {
3882 // This is the targeted version.
3884 diplomat_target_id, data2.toInt(), "");
3885 }
3886 }
3887}
3888
3889/***********************************************************************/
3893{
3894 int actor_id = data1.toInt();
3895 int target_id = data2.toInt();
3896
3897 if (game_unit_by_number(actor_id) != nullptr
3898 && game_city_by_number(target_id) != nullptr) {
3899 // Wait for the server's reply before moving on to the next queued diplomat.
3901
3902 request_action_details(ACTION_STRIKE_BUILDING, actor_id, target_id);
3903 }
3904}
3905
3906/***********************************************************************/
3910{
3911 int diplomat_id = data1.toInt();
3912 int diplomat_target_id = data2.toInt();
3913
3914 if (game_unit_by_number(diplomat_id) != nullptr
3915 && game_city_by_number(diplomat_target_id) != nullptr) {
3916 // Wait for the server's reply before moving on to the next queued diplomat.
3918
3921 }
3922}
3923
3924/***********************************************************************/
3928{
3929 int diplomat_id = data1.toInt();
3930 int diplomat_target_id = data2.toInt();
3931
3932 if (game_unit_by_number(diplomat_id) != nullptr
3933 && game_city_by_number(diplomat_target_id) != nullptr) {
3934 /* Wait for the server's reply before moving on to the next queued
3935 * diplomat. */
3937
3940 }
3941}
3942
3943/***********************************************************************/
3946static void spy_poison(QVariant data1, QVariant data2)
3947{
3948 int diplomat_id = data1.toInt();
3949 int diplomat_target_id = data2.toInt();
3950
3951 if (game_unit_by_number(diplomat_id) != nullptr
3952 && game_city_by_number(diplomat_target_id) != nullptr) {
3955 }
3956}
3957
3958/***********************************************************************/
3961static void spy_poison_esc(QVariant data1, QVariant data2)
3962{
3963 int diplomat_id = data1.toInt();
3964 int diplomat_target_id = data2.toInt();
3965
3966 if (game_unit_by_number(diplomat_id) != nullptr
3967 && game_city_by_number(diplomat_target_id) != nullptr) {
3970 }
3971}
3972
3973/***********************************************************************/
3976static void spy_spread_plague(QVariant data1, QVariant data2)
3977{
3978 int diplomat_id = data1.toInt();
3979 int diplomat_target_id = data2.toInt();
3980
3981 if (game_unit_by_number(diplomat_id) != nullptr
3982 && game_city_by_number(diplomat_target_id) != nullptr) {
3985 }
3986}
3987
3988/***********************************************************************/
3991static void spy_nuke_city(QVariant data1, QVariant data2)
3992{
3993 int diplomat_id = data1.toInt();
3994 int diplomat_target_id = data2.toInt();
3995
3996 if (game_unit_by_number(diplomat_id) != nullptr
3997 && game_city_by_number(diplomat_target_id) != nullptr) {
4000 }
4001}
4002
4003/***********************************************************************/
4006static void spy_nuke_city_esc(QVariant data1, QVariant data2)
4007{
4008 int diplomat_id = data1.toInt();
4009 int diplomat_target_id = data2.toInt();
4010
4011 if (game_unit_by_number(diplomat_id) != nullptr
4012 && game_city_by_number(diplomat_target_id) != nullptr) {
4015 }
4016}
4017
4018/***********************************************************************/
4021static void nuke_city(QVariant data1, QVariant data2)
4022{
4023 int actor_id = data1.toInt();
4024 int target_id = data2.toInt();
4025
4026 if (game_unit_by_number(actor_id) != nullptr
4027 && game_city_by_number(target_id) != nullptr) {
4029 actor_id, target_id, 0, "");
4030 }
4031}
4032
4033/***********************************************************************/
4036static void destroy_city(QVariant data1, QVariant data2)
4037{
4038 int diplomat_id = data1.toInt();
4039 int diplomat_target_id = data2.toInt();
4040
4041 if (game_unit_by_number(diplomat_id) != nullptr
4042 && game_city_by_number(diplomat_target_id) != nullptr) {
4045 }
4046}
4047
4048/***********************************************************************/
4051static void spy_steal_gold(QVariant data1, QVariant data2)
4052{
4053 int diplomat_id = data1.toInt();
4054 int diplomat_target_id = data2.toInt();
4055
4056 if (game_unit_by_number(diplomat_id) != nullptr
4057 && game_city_by_number(diplomat_target_id) != nullptr) {
4060 }
4061}
4062
4063/***********************************************************************/
4066static void spy_steal_gold_esc(QVariant data1, QVariant data2)
4067{
4068 int diplomat_id = data1.toInt();
4069 int diplomat_target_id = data2.toInt();
4070
4071 if (game_unit_by_number(diplomat_id) != nullptr
4072 && game_city_by_number(diplomat_target_id) != nullptr) {
4075 }
4076}
4077
4078/***********************************************************************/
4081static void spy_steal_maps(QVariant data1, QVariant data2)
4082{
4083 int diplomat_id = data1.toInt();
4084 int diplomat_target_id = data2.toInt();
4085
4086 if (game_unit_by_number(diplomat_id) != nullptr
4087 && game_city_by_number(diplomat_target_id) != nullptr) {
4090 }
4091}
4092
4093/***********************************************************************/
4096static void spy_steal_maps_esc(QVariant data1, QVariant data2)
4097{
4098 int diplomat_id = data1.toInt();
4099 int diplomat_target_id = data2.toInt();
4100
4101 if (game_unit_by_number(diplomat_id) != nullptr
4102 && game_city_by_number(diplomat_target_id) != nullptr) {
4105 }
4106}
4107
4108/***********************************************************************/
4111static void spy_escape(QVariant data1, QVariant data2)
4112{
4113 int diplomat_id = data1.toInt();
4114 int diplomat_target_id = data2.toInt();
4115
4116 if (game_unit_by_number(diplomat_id) != nullptr
4117 && game_city_by_number(diplomat_target_id) != nullptr) {
4120 }
4121}
4122
4123/***********************************************************************/
4126static void spy_embassy(QVariant data1, QVariant data2)
4127{
4128 int diplomat_id = data1.toInt();
4129 int diplomat_target_id = data2.toInt();
4130
4131 if (game_unit_by_number(diplomat_id) != nullptr
4132 && game_city_by_number(diplomat_target_id) != nullptr) {
4134 diplomat_target_id, 0, "");
4135 }
4136}
4137
4138/***********************************************************************/
4141static void diplomat_embassy(QVariant data1, QVariant data2)
4142{
4143 int diplomat_id = data1.toInt();
4144 int diplomat_target_id = data2.toInt();
4145
4146 if (game_unit_by_number(diplomat_id) != nullptr
4147 && game_city_by_number(diplomat_target_id) != nullptr) {
4149 diplomat_target_id, 0, "");
4150 }
4151}
4152
4153/***********************************************************************/
4156static void spy_investigate(QVariant data1, QVariant data2)
4157{
4158 int diplomat_id = data1.toInt();
4159 int diplomat_target_id = data2.toInt();
4160
4162 && game_unit_by_number(diplomat_id) != nullptr) {
4164 diplomat_target_id, 0, "");
4165 }
4166}
4167
4168/***********************************************************************/
4171static void diplomat_investigate(QVariant data1, QVariant data2)
4172{
4173 int diplomat_id = data1.toInt();
4174 int diplomat_target_id = data2.toInt();
4175
4177 && game_unit_by_number(diplomat_id) != nullptr) {
4179 diplomat_target_id, 0, "");
4180 }
4181}
4182
4183/***********************************************************************/
4186static void diplomat_sabotage(QVariant data1, QVariant data2)
4187{
4188 int diplomat_id = data1.toInt();
4189 int diplomat_target_id = data2.toInt();
4190
4191 if (game_unit_by_number(diplomat_id) != nullptr
4192 && game_city_by_number(diplomat_target_id) != nullptr) {
4194 diplomat_target_id, B_LAST + 1, "");
4195 }
4196}
4197
4198/***********************************************************************/
4201static void diplomat_sabotage_esc(QVariant data1, QVariant data2)
4202{
4203 int diplomat_id = data1.toInt();
4204 int diplomat_target_id = data2.toInt();
4205
4206 if (game_unit_by_number(diplomat_id) != nullptr
4207 && game_city_by_number(diplomat_target_id) != nullptr) {
4209 diplomat_target_id, B_LAST + 1, "");
4210 }
4211}
4212
4213/***********************************************************************/
4216static void diplomat_steal(QVariant data1, QVariant data2)
4217{
4218 int diplomat_id = data1.toInt();
4219 int diplomat_target_id = data2.toInt();
4220
4221 if (game_unit_by_number(diplomat_id) != nullptr
4222 && game_city_by_number(diplomat_target_id) != nullptr) {
4225 }
4226}
4227
4228/***********************************************************************/
4231static void diplomat_steal_esc(QVariant data1, QVariant data2)
4232{
4233 int diplomat_id = data1.toInt();
4234 int diplomat_target_id = data2.toInt();
4235
4236 if (game_unit_by_number(diplomat_id) != nullptr
4237 && game_city_by_number(diplomat_target_id) != nullptr) {
4240 }
4241}
4242
4243/***********************************************************************/
4246static void diplomat_incite(QVariant data1, QVariant data2)
4247{
4248 int diplomat_id = data1.toInt();
4249 int diplomat_target_id = data2.toInt();
4250
4251 if (game_unit_by_number(diplomat_id) != nullptr
4252 && game_city_by_number(diplomat_target_id) != nullptr) {
4253 // Wait for the server's reply before moving on to the next queued diplomat.
4255
4258 }
4259}
4260
4261/***********************************************************************/
4265{
4266 int diplomat_id = data1.toInt();
4267 int diplomat_target_id = data2.toInt();
4268
4269 if (game_unit_by_number(diplomat_id) != nullptr
4270 && game_city_by_number(diplomat_target_id) != nullptr) {
4271 // Wait for the server's reply before moving on to the next queued diplomat.
4273
4276 }
4277}
4278
4279/***********************************************************************/
4282static void regular_move(QVariant data1, QVariant data2)
4283{
4284 int actor_id = data1.toInt();
4285 int target_id = data2.toInt();
4286
4287 if (game_unit_by_number(actor_id) != nullptr
4288 && index_to_tile(&(wld.map), target_id) != nullptr) {
4290 actor_id, target_id, 0, "");
4291 }
4292}
4293
4294/***********************************************************************/
4297static void regular_move2(QVariant data1, QVariant data2)
4298{
4299 int actor_id = data1.toInt();
4300 int target_id = data2.toInt();
4301
4302 if (game_unit_by_number(actor_id) != nullptr
4303 && index_to_tile(&(wld.map), target_id) != nullptr) {
4305 actor_id, target_id, 0, "");
4306 }
4307}
4308
4309/***********************************************************************/
4312static void regular_move3(QVariant data1, QVariant data2)
4313{
4314 int actor_id = data1.toInt();
4315 int target_id = data2.toInt();
4316
4317 if (game_unit_by_number(actor_id) != nullptr
4318 && index_to_tile(&(wld.map), target_id) != nullptr) {
4320 actor_id, target_id, 0, "");
4321 }
4322}
4323
4324/***********************************************************************/
4328void popup_incite_dialog(struct unit *actor, struct city *tcity, int cost,
4329 const struct action *paction)
4330{
4331 char buf[1024];
4332 char buf2[1024];
4333 int diplomat_id = actor->id;
4334 int diplomat_target_id = tcity->id;
4335 const int act_id = paction->id;
4336
4337 // Should be set before sending request to the server.
4339
4340 fc_snprintf(buf, ARRAY_SIZE(buf), PL_("Treasury contains %d gold.",
4341 "Treasury contains %d gold.",
4342 client_player()->economic.gold),
4343 client_player()->economic.gold);
4344
4346 hud_message_box *impossible = new hud_message_box(gui()->central_wdg);
4347
4349 _("You can't incite a revolt in %s."), city_name_get(tcity));
4350 impossible->set_text_title(buf2, "!");
4351 impossible->setStandardButtons(QMessageBox::Ok);
4352 impossible->setAttribute(Qt::WA_DeleteOnClose);
4353 impossible->show();
4354 } else if (cost <= client_player()->economic.gold) {
4355 hud_message_box *ask = new hud_message_box(gui()->central_wdg);
4356
4358 PL_("Incite a revolt for %d gold?\n%s",
4359 "Incite a revolt for %d gold?\n%s", cost), cost, buf);
4360 ask->setStandardButtons(QMessageBox::Cancel | QMessageBox::Ok);
4361 ask->setDefaultButton(QMessageBox::Cancel);
4362 ask->set_text_title(buf2, _("Incite a Revolt!"));
4363 ask->setAttribute(Qt::WA_DeleteOnClose);
4364 QObject::connect(ask, &hud_message_box::accepted, [=]() {
4367 });
4368 ask->show();
4369 return;
4370 } else {
4371 hud_message_box *too_much = new hud_message_box(gui()->central_wdg);
4372
4374 PL_("Inciting a revolt costs %d gold.\n%s",
4375 "Inciting a revolt costs %d gold.\n%s", cost), cost,
4376 buf);
4377 too_much->set_text_title(buf2, "!");
4378 too_much->setStandardButtons(QMessageBox::Ok);
4379 too_much->setAttribute(Qt::WA_DeleteOnClose);
4380 too_much->show();
4381 }
4382
4384}
4385
4386/***********************************************************************/
4390void popup_bribe_unit_dialog(struct unit *actor, struct unit *tunit, int cost,
4391 const struct action *paction)
4392{
4393 hud_message_box *ask = new hud_message_box(gui()->central_wdg);
4394 char buf[1024];
4395 char buf2[1024];
4396 int diplomat_id = actor->id;
4397 int diplomat_target_id = tunit->id;
4398 const int act_id = paction->id;
4399
4400 // Should be set before sending request to the server.
4402
4403 fc_snprintf(buf, ARRAY_SIZE(buf), PL_("Treasury contains %d gold.",
4404 "Treasury contains %d gold.",
4405 client_player()->economic.gold),
4406 client_player()->economic.gold);
4407
4408 if (cost <= client_player()->economic.gold) {
4409 fc_snprintf(buf2, ARRAY_SIZE(buf2), PL_("Bribe unit for %d gold?\n%s",
4410 "Bribe unit for %d gold?\n%s",
4411 cost), cost, buf);
4412 ask->set_text_title(buf2, _("Bribe Enemy Unit"));
4413 ask->setStandardButtons(QMessageBox::Cancel | QMessageBox::Ok);
4414 ask->setDefaultButton(QMessageBox::Cancel);
4415 ask->setAttribute(Qt::WA_DeleteOnClose);
4416 QObject::connect(ask, &hud_message_box::accepted, [=]() {
4419 });
4420 ask->show();
4421 return;
4422 } else {
4424 PL_("Bribing the unit costs %d gold.\n%s",
4425 "Bribing the unit costs %d gold.\n%s", cost), cost, buf);
4426 ask->set_text_title(buf2, _("Traitors Demand Too Much!"));
4427 ask->setAttribute(Qt::WA_DeleteOnClose);
4428 ask->show();
4429 }
4430
4432}
4433
4434/***********************************************************************/
4439 const struct action *paction)
4440{
4441 hud_message_box *ask = new hud_message_box(gui()->central_wdg);
4442 char buf[1024];
4443 char buf2[1024];
4444 int diplomat_id = actor->id;
4445 int diplomat_target_id = ttile->index;
4446 const int act_id = paction->id;
4447
4448 // Should be set before sending request to the server.
4450
4451 fc_snprintf(buf, ARRAY_SIZE(buf), PL_("Treasury contains %d gold.",
4452 "Treasury contains %d gold.",
4453 client_player()->economic.gold),
4454 client_player()->economic.gold);
4455
4456 if (cost <= client_player()->economic.gold) {
4457 fc_snprintf(buf2, ARRAY_SIZE(buf2), PL_("Bribe unit stack for %d gold?\n%s",
4458 "Bribe unit stack for %d gold?\n%s",
4459 cost), cost, buf);
4460 ask->set_text_title(buf2, _("Bribe Enemy Stack"));
4461 ask->setStandardButtons(QMessageBox::Cancel | QMessageBox::Ok);
4462 ask->setDefaultButton(QMessageBox::Cancel);
4463 ask->setAttribute(Qt::WA_DeleteOnClose);
4464 QObject::connect(ask, &hud_message_box::accepted, [=]() {
4467 });
4468 ask->show();
4469 return;
4470 } else {
4472 PL_("Bribing the unit stack costs %d gold.\n%s",
4473 "Bribing the unit stack costs %d gold.\n%s", cost), cost, buf);
4474 ask->set_text_title(buf2, _("Traitors Demand Too Much!"));
4475 ask->setAttribute(Qt::WA_DeleteOnClose);
4476 ask->show();
4477 }
4478
4480}
4481
4482/***********************************************************************/
4485static void pillage_something(QVariant data1, QVariant data2)
4486{
4487 int punit_id;
4488 int what;
4489 struct unit *punit;
4490 struct extra_type *target;
4491
4492 what = data1.toInt();
4493 punit_id = data2.toInt();
4495 if (punit) {
4496 target = extra_by_number(what);
4498 }
4500}
4501
4502/***********************************************************************/
4505static void spy_sabotage(QVariant data1, QVariant data2)
4506{
4507 int diplomat_id = data1.toList().at(0).toInt();
4508 int diplomat_target_id = data1.toList().at(1).toInt();
4509 action_id act_id = data1.toList().at(2).toInt();
4510
4511 if (game_unit_by_number(diplomat_id) != nullptr
4512 && game_city_by_number(diplomat_target_id) != nullptr) {
4513 if (data2.toInt() == B_LAST) {
4514 // This is the untargeted version.
4516 diplomat_id, diplomat_target_id, data2.toInt(),
4517 "");
4518 } else if (data2.toInt() == -1) {
4519 // This is the city production version.
4521 diplomat_id, diplomat_target_id, data2.toInt(),
4522 "");
4523 } else {
4524 // This is the targeted version.
4526 diplomat_target_id, data2.toInt(), "");
4527 }
4528 }
4529}
4530
4531/***********************************************************************/
4536 const struct action *paction)
4537{
4538 QString str;
4539 QVariant qv1, qv2;
4540 int diplomat_id = actor->id;
4541 int diplomat_target_id = tcity->id;
4544 int nr = 0;
4545 struct astring stra = ASTRING_INIT;
4547
4548 if (paction->result == ACTRES_STRIKE_BUILDING) {
4549 cd = new choice_dialog(_("Strike"),
4550 _("Select Improvement to Strike"),
4551 gui()->game_tab_widget,
4553 } else {
4554 cd = new choice_dialog(_("Sabotage"),
4555 _("Select Improvement to Sabotage"),
4556 gui()->game_tab_widget,
4558 }
4559 cd->unit_id = diplomat_id;
4560
4561 // Should be set before sending request to the server.
4563
4564 // Put both actor, target city and action in qv1 since qv2 is taken
4567 actor_and_target.append(paction->id);
4568 qv1 = QVariant::fromValue(actor_and_target);
4569
4572 paction->id)])) {
4574 cd->add_item(QString(_("City Production")), func, qv1, -1);
4575 }
4576
4577 city_built_iterate(tcity, pimprove) {
4578 if (pimprove->sabotage > 0) {
4580 // Defeat keyboard shortcut mnemonics
4582 .replace("&", "&&");
4583 qv2 = nr;
4584 cd->add_item(str, func, qv1, improvement_number(pimprove));
4585 nr++;
4586 }
4588
4591 astr_set(&stra, _("At %s's Discretion"),
4594 str = QString(astr_str(&stra)).replace("&", "&&");
4595 cd->add_item(str, func, qv1, B_LAST);
4596 }
4597
4598 cd->set_layout();
4599 cd->show_me();
4600 astr_free(&stra);
4601}
4602
4603/***********************************************************************/
4608{
4609 QString str;
4610 QVariant qv1, qv2;
4613 struct extra_type *tgt;
4614
4616 return;
4617 }
4618 cd = new choice_dialog(_("What To Pillage"), _("Select what to pillage:"),
4619 gui()->game_tab_widget);
4620 qv2 = punit->id;
4621 while ((tgt = get_preferred_pillage(extras))) {
4622 int what;
4623
4624 what = extra_index(tgt);
4625 BV_CLR(extras, what);
4626
4628 // Defeat keyboard shortcut mnemonics
4629 str = QString(extra_name_translation(tgt)).replace("&", "&&");
4630 qv1 = what;
4631 cd->add_item(str, func, qv1, qv2);
4632 }
4633 cd->set_layout();
4634 cd->show_me();
4635}
4636
4637/***********************************************************************/
4641 QWidget *parent) : hud_message_box(parent)
4642{
4643 QString str;
4644 QPushButton *pb;
4645
4646 setAttribute(Qt::WA_DeleteOnClose);
4647 setModal(false);
4652
4653 str = QString(PL_("Are you sure you want to disband that %1 unit?",
4654 "Are you sure you want to disband those %1 units?",
4656 pb = addButton(_("Yes"), QMessageBox::AcceptRole);
4657 addButton(_("No"), QMessageBox::RejectRole);
4658 set_text_title(str, _("Disband units"));
4660 connect(pb, &QAbstractButton::clicked, this, &disband_box::disband_clicked);
4661}
4662
4663/***********************************************************************/
4674
4675/***********************************************************************/
4682
4683/***********************************************************************/
4686void popup_disband_dialog(struct unit_list *punits)
4687{
4688 disband_box *ask = new disband_box(punits, gui()->central_wdg);
4689 ask->show();
4690}
4691
4692/***********************************************************************/
4697{
4698 hud_message_box *ask = new hud_message_box(gui()->central_wdg);
4699 QString text;
4700 QString title;
4701
4702 title = QString(_("Modpack suggests using %1 tileset."))
4704 text = QString("It might not work with other tilesets.\n"
4705 "You are currently using tileset %1.")
4707 ask->addButton(_("Keep current tileset"), QMessageBox::RejectRole);
4708 ask->addButton(_("Load tileset"), QMessageBox::AcceptRole);
4709 ask->set_text_title(text, title);
4710 ask->setAttribute(Qt::WA_DeleteOnClose);
4711
4712 QObject::connect(ask, &hud_message_box::accepted, [=]() {
4715 gui()->map_scale)) {
4717 _("Can't load requested tileset."));
4718 }
4719 });
4720 ask->show();
4721}
4722
4723/***********************************************************************/
4728{
4729 hud_message_box *ask = new hud_message_box(gui()->central_wdg);
4730 QString text;
4731 QString title;
4732
4733 title = QString(_("Modpack suggests using %1 soundset."))
4735 text = QString("It might not work with other tilesets.\n"
4736 "You are currently using soundset %1.")
4737 .arg(sound_set_name);
4738 ask->addButton(_("Keep current soundset"), QMessageBox::RejectRole);
4739 ask->addButton(_("Load soundset"), QMessageBox::AcceptRole);
4740 ask->set_text_title(text, title);
4741 ask->setAttribute(Qt::WA_DeleteOnClose);
4742 QObject::connect(ask, &hud_message_box::accepted, [=]() {
4744 });
4745 ask->show();
4746}
4747
4748/***********************************************************************/
4753{
4754 hud_message_box *ask = new hud_message_box(gui()->central_wdg);
4755 QString text;
4756 QString title;
4757
4758 title = QString(_("Modpack suggests using %1 musicset."))
4760 text = QString("It might not work with other tilesets.\n"
4761 "You are currently using musicset %1.")
4762 .arg(music_set_name);
4763 ask->addButton(_("Keep current musicset"), QMessageBox::RejectRole);
4764 ask->addButton(_("Load musicset"), QMessageBox::AcceptRole);
4765 ask->set_text_title(text, title);
4766 ask->setAttribute(Qt::WA_DeleteOnClose);
4767 QObject::connect(ask, &hud_message_box::accepted, [=]() {
4769 });
4770 ask->show();
4771}
4772
4773/***********************************************************************/
4778{
4779 // PORTME
4780 return false;
4781}
4782
4783/***********************************************************************/
4787{
4789 int i;
4790
4791 nd_list = gui()->mapview_wdg->findChildren<notify_dialog *>();
4792 for (i = 0; i < nd_list.count(); i++) {
4793 nd_list[i]->restart();
4794 delete nd_list[i];
4795 }
4796}
4797
4798/***********************************************************************/
4803{
4804 int i;
4807 goto_dialog *gtd;
4808
4809 QApplication::alert(gui()->central_wdg);
4810 cd_list = gui()->game_tab_widget->findChildren <choice_dialog *>();
4811 for (i = 0; i < cd_list.count(); i++) {
4812 cd_list[i]->close();
4813 }
4814 nd_list = gui()->game_tab_widget->findChildren <notify_dialog *>();
4815 for (i = 0; i < nd_list.count(); i++) {
4816 nd_list[i]->close();
4817 }
4818
4827 gui()->popdown_unit_sel();
4828
4829 gtd = gui()->gtd;
4830
4831 if (gtd != nullptr) {
4832 gtd->close_dlg();
4833 }
4834}
4835
4836/***********************************************************************/
4842{
4843 choice_dialog *cd = gui()->get_diplo_dialog();
4844
4845 if (cd != nullptr) {
4846 return cd->unit_id;
4847 } else {
4848 return IDENTITY_NUMBER_ZERO;
4849 }
4850}
4851
4852/***********************************************************************/
4859{
4860 choice_dialog *cd = gui()->get_diplo_dialog();
4861
4862 if (cd != nullptr) {
4863 return cd->target_id[ATK_CITY];
4864 } else {
4865 return IDENTITY_NUMBER_ZERO;
4866 }
4867}
4868
4869/***********************************************************************/
4876{
4877 choice_dialog *cd = gui()->get_diplo_dialog();
4878
4879 if (cd != nullptr) {
4880 return cd->target_id[ATK_TILE];
4881 } else {
4882 return TILE_INDEX_NONE;
4883 }
4884}
4885
4886/**********************************************************************/
4893{
4894 choice_dialog *cd = gui()->get_diplo_dialog();
4895
4896 if (cd != nullptr) {
4897 return cd->sub_target_id[ASTK_EXTRA];
4898 } else {
4899 return EXTRA_NONE;
4900 }
4901}
4902
4903/***********************************************************************/
4910{
4911 choice_dialog *cd = gui()->get_diplo_dialog();
4912
4913 if (cd != nullptr) {
4914 return cd->target_id[ATK_UNIT];
4915 } else {
4916 return IDENTITY_NUMBER_ZERO;
4917 }
4918}
4919
4920/***********************************************************************/
4924 struct city *target_city,
4925 struct unit *target_unit,
4926 struct tile *target_tile,
4927 struct extra_type *target_extra,
4928 const struct act_prob *act_probs)
4929{
4932 Choice_dialog_button *cancel_button;
4933 QVariant qv1, qv2;
4934
4935 asd = gui()->get_diplo_dialog();
4936 if (asd == nullptr) {
4937 fc_assert_msg(asd != nullptr,
4938 "The action selection dialog should have been open");
4939 return;
4940 }
4941
4944 "The action selection dialog is for another actor unit.");
4945 }
4946
4947 // Put the actor id in qv1.
4948 qv1 = actor_unit->id;
4949
4950 cancel_button = asd->get_identified_button(BUTTON_CANCEL);
4951 if (cancel_button != nullptr) {
4952 /* Temporary remove the Cancel button so it won't end up above
4953 * any added buttons. */
4954 asd->stack_button(cancel_button);
4955 }
4956
4957 wait_button = asd->get_identified_button(BUTTON_WAIT);
4958 if (wait_button != nullptr) {
4959 /* Temporary remove the Wait button so it won't end up above
4960 * any added buttons. */
4961 asd->stack_button(wait_button);
4962 }
4963
4964 action_iterate(act) {
4965 const char *custom;
4966
4967 if (action_id_get_actor_kind(act) != AAK_UNIT) {
4968 // Not relevant.
4969 continue;
4970 }
4971
4973 act_probs[act],
4974 actor_unit,
4975 target_city);
4976
4977 // Put the target id in qv2.
4978 switch (action_id_get_target_kind(act)) {
4979 case ATK_UNIT:
4980 if (target_unit != nullptr) {
4981 qv2 = target_unit->id;
4982 } else {
4984 || target_unit != nullptr,
4985 "Action enabled against non existing unit!");
4986
4988 }
4989 break;
4990 case ATK_CITY:
4991 if (target_city != nullptr) {
4992 qv2 = target_city->id;
4993 } else {
4995 || target_city != nullptr,
4996 "Action enabled against non existing city!");
4997
4999 }
5000 break;
5001 case ATK_TILE:
5002 case ATK_EXTRAS:
5003 case ATK_STACK:
5004 if (target_tile != nullptr) {
5006 } else {
5008 || target_tile != nullptr,
5009 "Action enabled against all units on "
5010 "non existing tile!");
5011
5013 }
5014 break;
5015 case ATK_SELF:
5016 qv2 = actor_unit->id;
5017 break;
5018 case ATK_COUNT:
5020 "Bad target kind");
5021 continue;
5022 }
5023
5024 if (asd->get_identified_button(act)) {
5025 // Update the existing button.
5026 action_entry_update(asd->get_identified_button(act),
5027 act, act_probs, custom,
5028 qv1, qv2);
5029 } else {
5030 // Add the button (unless its probability is 0).
5032 qv1, qv2);
5033 }
5035
5036 if (wait_button != nullptr || cancel_button != nullptr) {
5037 /* Reinsert the non action buttons below any potential
5038 * buttons recently added. */
5039 asd->unstack_all_buttons();
5040 }
5041}
5042
5043/***********************************************************************/
5047{
5049
5050 cd = gui()->get_diplo_dialog();
5051 if (cd != nullptr) {
5052 did_not_decide = true;
5053 cd->close();
5054 }
5055}
5056
5057/***********************************************************************/
5063
5064/***********************************************************************/
5067void show_tileset_error(bool fatal, const char *tset_name, const char *msg)
5068{
5069 QWidget *parent;
5070 fc_client *std_gui = gui();
5071
5072 if (std_gui != nullptr) {
5073 parent = std_gui->central_wdg;
5074 } else {
5075 parent = nullptr;
5076 }
5077
5078 if (std_gui != nullptr || fatal) {
5079 char buf[1024];
5080 QMessageBox *ask = new QMessageBox(parent);
5081
5082 if (tset_name != nullptr) {
5083 fc_snprintf(buf, sizeof(buf),
5084 _("Tileset \"%s\" problem, it's probably incompatible with "
5085 "the ruleset:\n%s"), tset_name, msg);
5086 } else {
5087 fc_snprintf(buf, sizeof(buf),
5088 _("Tileset problem, it's probably incompatible with "
5089 "the ruleset:\n%s"), msg);
5090 }
5091
5092 ask->setText(buf);
5093 ask->setStandardButtons(QMessageBox::Ok);
5094 ask->setWindowTitle(_("Tileset error"));
5095
5096 if (std_gui != nullptr && !fatal) {
5097 ask->setAttribute(Qt::WA_DeleteOnClose);
5098 ask->show();
5099 } else {
5100 ask->exec();
5101 }
5102 }
5103}
5104
5105/***********************************************************************/
5108void popup_upgrade_dialog(struct unit_list *punits)
5109{
5110 char buf[512];
5112 QString title;
5114
5115 if (!punits || unit_list_size(punits) == 0) {
5116 return;
5117 }
5118
5119 ask = new hud_message_box(gui()->central_wdg);
5120
5121 punit_ids = new QVector<int>();
5123 punit_ids->push_back(punit->id);
5125
5126 if (!get_units_upgrade_info(buf, sizeof(buf), punits)) {
5127 title = _("Upgrade Unit!");
5128 ask->setStandardButtons(QMessageBox::Ok);
5129 } else {
5130 title = _("Upgrade Obsolete Units");
5131 ask->setStandardButtons(QMessageBox::Cancel | QMessageBox::Ok);
5132 ask->setDefaultButton(QMessageBox::Cancel);
5133 }
5134 ask->set_text_title(buf, title);
5135 ask->setAttribute(Qt::WA_DeleteOnClose);
5136 QObject::connect(ask, &hud_message_box::accepted, [=]() {
5137 std::unique_ptr<QVector<int>> uptr(punit_ids);
5138 struct unit *punit;
5139
5140 for (int id : *uptr) {
5142 if (punit) {
5144 }
5145 }
5146 });
5147 ask->show();
5148}
5149
5150/***********************************************************************/
5154{
5155 QPoint p, final_p;
5156
5158 utile = ptile;
5159 pix = nullptr;
5160 show_line = 0;
5161 highlight_num = -1;
5162 ufont.setItalic(true);
5164 update_units();
5165 h_pix = nullptr;
5166 create_pixmap();
5167 p = mapFromGlobal(QCursor::pos());
5168 cw = new close_widget(this);
5169 setMouseTracking(true);
5170 final_p.setX(p.x());
5171 final_p.setY(p.y());
5172 if (p.x() + width() > parentWidget()->width()) {
5173 final_p.setX(parentWidget()->width() - width());
5174 }
5175 if (p.y() - height() < 0) {
5176 final_p.setY(height());
5177 }
5178 move(final_p.x(), final_p.y() - height());
5179 setFocus();
5180 /* Build fails with qt5 connect style for static functions
5181 * Qt5.2 so dont update */
5182 QTimer::singleShot(10, this, SLOT(update_img()));
5183}
5184
5185/***********************************************************************/
5189{
5190 delete h_pix;
5191 delete pix;
5192 delete cw;
5193}
5194
5195/***********************************************************************/
5199{
5200 int a;
5201 int x, y, i;
5204 QImage img;
5206 QPainter p;
5207 QPen pen;
5208 QPixmap pixc;
5209 QPixmap *pixp;
5211 QRect crop;
5212 struct canvas *unit_pixmap;
5213 struct unit *punit;
5214 float isosize;
5215
5216 if (pix != nullptr) {
5217 delete pix;
5218 pix = nullptr;
5219 };
5220 isosize = 0.7;
5222 isosize = 0.5;
5223 }
5224
5225 update_units();
5226 if (unit_list.count() > 0) {
5230 } else {
5233 }
5234 more = false;
5235 if (h_pix != nullptr) {
5236 delete h_pix;
5237 }
5238 h_pix = new QPixmap(item_size.width(), item_size.height());
5239 h_pix->fill(palette().color(QPalette::HighlightedText));
5240 if (unit_count < 5) {
5241 row_count = 1;
5242 pix = new QPixmap((unit_list.size()) * item_size.width(),
5243 item_size.height());
5244 } else if (unit_count < 9) {
5245 row_count = 2;
5246 pix = new QPixmap(4 * item_size.width(), 2 * item_size.height());
5247 } else {
5248 row_count = 3;
5249 if (unit_count > 12) {
5250 more = true;
5251 }
5252 pix = new QPixmap(4 * item_size.width(), 3 * item_size.height());
5253 }
5254 pix->fill(Qt::transparent);
5255 foreach(punit, unit_list) {
5258 unit_pixmap->map_pixmap.fill(Qt::transparent);
5259 put_unit(punit, unit_pixmap, 1.0, 0, 0);
5260 img = unit_pixmap->map_pixmap.toImage();
5262 cropped_img = img.copy(crop);
5266 Qt::KeepAspectRatio,
5267 Qt::SmoothTransformation);
5268 } else {
5271 Qt::KeepAspectRatio,
5272 Qt::SmoothTransformation);
5273 }
5274 pixc = QPixmap::fromImage(img);
5275 pixp = new QPixmap(pixc);
5276 pix_list.push_back(pixp);
5278 }
5279 a = qMin(item_size.width() / 4, 12);
5280 x = 0, y = -item_size.height(), i = -1;
5281 p.begin(pix);
5282 ufont.setPixelSize(a);
5283 p.setFont(ufont);
5284 pen.setColor(palette().color(QPalette::Text));
5285 p.setPen(pen);
5286
5287 while (!pix_list.isEmpty()) {
5288 tmp_pix = pix_list.takeFirst();
5289 i++;
5290 if (i % 4 == 0) {
5291 x = 0;
5292 y = y + item_size.height();
5293 }
5294 punit = unit_list.at(i);
5295 Q_ASSERT(punit != nullptr);
5296
5297 if (i == highlight_num) {
5298 p.drawPixmap(x, y, *h_pix);
5299 p.drawPixmap(x, y, *tmp_pix);
5300 } else {
5301 p.drawPixmap(x, y, *tmp_pix);
5302 }
5303
5305 int rate, f;
5306 QString str;
5307
5309 f = ((punit->fuel) - 1);
5312 str = str + "(" + QString(move_points_text((rate * f)
5313 + punit->moves_left, false)) + ")";
5314 }
5315 // TRANS: MP = Movement points
5316 str = QString(_("MP:")) + str;
5317 p.drawText(x, y + item_size.height() - 4, str);
5318 }
5319
5320 x = x + item_size.width();
5321 delete tmp_pix;
5322 }
5323 p.end();
5324 setFixedWidth(pix->width() + 20);
5325 setFixedHeight(pix->height() + 2 * (fm.height() + 6));
5326 qDeleteAll(pix_list.begin(), pix_list.end());
5327 }
5328}
5329
5330/***********************************************************************/
5334{
5335 int a, b;
5336 int old_h;
5338 QPoint pos = event->pos();
5339 int x = pos.x();
5340 int y = pos.y();
5341
5343 highlight_num = -1;
5344 if (x > width() - 11
5345 || y > height() - fm.height() - 5
5346 || y < fm.height() + 3 || x < 11) {
5347 // Do nothing if mouse is on border, just skip next if
5348 } else if (row_count > 0) {
5349 a = (x - 10) / item_size.width();
5350 b = (y - fm.height() - 3) / item_size.height();
5351 highlight_num = b * 4 + a;
5352 }
5353 if (old_h != highlight_num) {
5354 create_pixmap();
5355 update();
5356 }
5357}
5358
5359/***********************************************************************/
5365{
5366 struct unit *punit;
5367 if (event->button() == Qt::RightButton) {
5368 was_destroyed = true;
5369 close();
5370 destroy();
5371 }
5372 if (event->button() == Qt::LeftButton && highlight_num != -1) {
5373 update_units();
5374 if (highlight_num >= unit_list.count()) {
5375 return;
5376 }
5379 was_destroyed = true;
5380 close();
5381 destroy();
5382 }
5383}
5384
5385/***********************************************************************/
5390{
5391 create_pixmap();
5392 update();
5393}
5394
5395/***********************************************************************/
5399{
5401 int h, i;
5402 int *f_size;
5403 QPen pen;
5404 QString str, str2;
5405 struct unit *punit;
5406 int point_size = info_font.pointSize();
5407 int pixel_size = info_font.pixelSize();
5408
5409 if (point_size < 0) {
5410 f_size = &pixel_size;
5411 } else {
5412 f_size = &point_size;
5413 }
5414 if (highlight_num != -1 && highlight_num < unit_list.count()) {
5415 struct astring addition = ASTRING_INIT;
5416
5419
5420 // TRANS: HP - hit points
5421 str2 = QString(_("%1 HP:%2/%3")).arg(QString(astr_str(&addition)),
5422 QString::number(punit->hp),
5423 QString::number(unit_type_get(punit)->hp));
5425 }
5426 str = QString(PL_("%1 unit", "%1 units",
5428 .arg(unit_list_size(utile->units));
5429 for (i = *f_size; i > 4; i--) {
5430 if (point_size < 0) {
5431 info_font.setPixelSize(i);
5432 } else {
5433 info_font.setPointSize(i);
5434 }
5436 if (10 + qfm.horizontalAdvance(str2) < width()) {
5437 break;
5438 }
5439 }
5440 h = fm.height();
5441 if (pix != nullptr) {
5442 painter->drawPixmap(10, h + 3, *pix);
5443 pen.setColor(palette().color(QPalette::Text));
5444 painter->setPen(pen);
5445 painter->setFont(info_font);
5446 painter->drawText(10, h, str);
5447 if (highlight_num != -1 && highlight_num < unit_list.count()) {
5448 painter->drawText(10, height() - 5, str2);
5449 }
5450 // Draw scroll
5451 if (more) {
5452 int maxl = ((unit_count - 1) / 4) + 1;
5453 float page_height = 3.0f / maxl;
5454 float page_start = (static_cast<float>(show_line)) / maxl;
5455 pen.setColor(palette().color(QPalette::HighlightedText));
5456 painter->setBrush(palette().color(QPalette::HighlightedText).darker());
5457 painter->setPen(palette().color(QPalette::HighlightedText).darker());
5458 painter->drawRect(pix->width() + 10, h, 8, h + pix->height());
5459 painter->setPen(pen);
5460 painter->drawRoundedRect(pix->width() + 10,
5461 h + page_start * pix->height(),
5462 8, h + page_height * pix->height(), 2, 2);
5463 }
5464 }
5465 if (point_size < 0) {
5466 info_font.setPixelSize(*f_size);
5467 } else {
5468 info_font.setPointSize(*f_size);
5469 }
5470 cw->put_to_corner();
5471}
5472
5473/***********************************************************************/
5477{
5479
5480 painter.begin(this);
5481 paint(&painter, event);
5482 painter.end();
5483}
5484
5485/***********************************************************************/
5490{
5491 was_destroyed = true;
5492 close();
5493 destroy();
5494}
5495
5496/***********************************************************************/
5500{
5501 int i = 1;
5502 struct unit_list *punit_list;
5503
5504 unit_count = 0;
5505 if (utile == nullptr) {
5506 struct unit *punit = head_of_units_in_focus();
5507 if (punit) {
5509 }
5510 }
5511 unit_list.clear();
5512 if (utile != nullptr) {
5514 if (punit_list != nullptr) {
5516 unit_count++;
5517 if (i > show_line * 4)
5518 unit_list.push_back(punit);
5519 i++;
5521 }
5522 }
5523 if (unit_list.count() == 0) {
5524 close();
5525 }
5526}
5527
5528/***********************************************************************/
5532{
5533 gui()->mapview_wdg->setFocus();
5534 QWidget::closeEvent(event);
5535}
5536
5537/***********************************************************************/
5541{
5542 int nr;
5543
5544 if (!more && utile == nullptr) {
5545 return;
5546 }
5547 nr = qCeil(static_cast<qreal>(unit_list_size(utile->units)) / 4) - 3;
5548 if (event->angleDelta().y() < 0) {
5549 show_line++;
5551 } else {
5552 show_line--;
5553 show_line = qMax(0, show_line);
5554 }
5555 update_units();
5556 create_pixmap();
5557 update();
5558 event->accept();
5559}
5560
5561/***********************************************************************/
5565{
5566 if (event->key() == Qt::Key_Escape) {
5567 was_destroyed = true;
5568 close();
5569 destroy();
5570 }
5571 QWidget::keyPressEvent(event);
5572}
5573
5574/***********************************************************************/
5581
5582/***********************************************************************/
5589
5590/***********************************************************************/
5595{
5596 // Just tell the client common code to handle this.
5597 return false;
5598}
5599
5600/***********************************************************************/
5603bool qtg_request_transport(struct unit *pcargo, struct tile *ptile)
5604{
5605 int tcount;
5607 struct unit_list *potential_transports = unit_list_new();
5608#ifndef FREECIV_NDEBUG
5610#endif
5611
5615 }
5617
5619
5620 if (tcount == 0) {
5621 fc_assert(best_transport == nullptr);
5623
5624 return false; // Unit was not handled here.
5625 } else if (tcount == 1) {
5626 // There's exactly one potential transport - use it automatically
5629
5631
5632 return true;
5633 }
5634
5635 hul = new hud_unit_loader(pcargo, ptile);
5636 hul->show_me();
5637 return true;
5638}
5639
5640/***********************************************************************/
5644void qtg_popup_combat_info(int attacker_unit_id, int defender_unit_id,
5645 int attacker_hp, int defender_hp,
5646 bool make_att_veteran, bool make_def_veteran)
5647{
5648 if (gui()->qt_settings.show_battle_log) {
5649 hud_unit_combat *huc = new hud_unit_combat(attacker_unit_id,
5650 defender_unit_id,
5651 attacker_hp, defender_hp,
5652 make_att_veteran,
5653 make_def_veteran,
5654 gui()->battlelog_wdg->scale,
5655 gui()->battlelog_wdg);
5656
5657 gui()->battlelog_wdg->add_combat_info(huc);
5658 gui()->battlelog_wdg->show();
5659 }
5660}
5661
5662/**********************************************************************/
5666 struct act_confirmation_data *data)
5667{
5668 hud_message_box *ask = new hud_message_box(gui()->central_wdg);
5669
5670 ask->setStandardButtons(QMessageBox::Cancel | QMessageBox::Ok);
5671 ask->setDefaultButton(QMessageBox::Cancel);
5672 ask->set_text_title(body, hdr);
5673 ask->setAttribute(Qt::WA_DeleteOnClose);
5674 QObject::connect(ask, &hud_message_box::accepted, [=]() {
5676 });
5677 QObject::connect(ask, &hud_message_box::rejected, [=]() {
5679 });
5680
5681 ask->show();
5682}
5683
5684/***********************************************************************/
5688 struct act_confirmation_data *data)
5689{
5691
5692 hdr = QString(_("Are you sure you want to do %1?")).
5694
5695 if (expl != nullptr) {
5697 }
5698
5700}
5701
5702/**********************************************************************/
5705void qtg_popup_image(const char *tag)
5706{
5707 struct sprite *spr = load_popup_sprite(tag);
5708
5709 if (spr != nullptr) {
5710 QDialog *win = new QDialog(gui());
5711 QVBoxLayout *layout = new QVBoxLayout(win);
5712 QPixmap *pm = new QPixmap(*spr->pm);
5713 QLabel *lbl = new QLabel;
5714 int width, height;
5715
5717 win->setFixedSize(width, height);
5718 lbl->setPixmap(*pm);
5719 layout->addWidget(lbl);
5720 win->setLayout(layout);
5721
5722 win->show();
5723
5725 } else {
5726 log_error(_("No image for tag \"%s\", requested by the server."), tag);
5727 }
5728}
const char * action_prepare_ui_name(action_id act_id, const char *mnemonic, const struct act_prob prob, const char *custom)
Definition actions.c:1312
const char * action_id_name_translation(action_id act_id)
Definition actions.c:1250
bool action_prob_possible(const struct act_prob probability)
Definition actions.c:5079
static struct action * action_by_number(action_id act_id)
Definition actions.h:400
#define action_iterate_end
Definition actions.h:218
#define action_id_get_actor_kind(act_id)
Definition actions.h:413
#define action_iterate(_act_)
Definition actions.h:214
#define action_id_get_target_kind(act_id)
Definition actions.h:417
#define ACTION_NONE
Definition actions.h:59
void astr_free(struct astring *astr)
Definition astring.c:148
void astr_set(struct astring *astr, const char *format,...)
Definition astring.c:251
#define str
Definition astring.c:76
static const char * astr_str(const struct astring *astr) fc__attribute((nonnull(1)))
Definition astring.h:93
#define ASTRING_INIT
Definition astring.h:44
void audio_restart(const char *soundset_name, const char *musicset_name)
Definition audio.c:376
#define BV_CLR(bv, bit)
Definition bitvector.h:94
QRect zealous_crop_rect(QImage &p)
Definition canvas.cpp:419
void qtg_canvas_free(struct canvas *store)
Definition canvas.cpp:48
struct canvas * qtg_canvas_create(int width, int height)
Definition canvas.cpp:36
struct canvas int int struct sprite int int int int height
Definition canvas_g.h:44
struct canvas int int struct sprite int int int width
Definition canvas_g.h:44
void output_window_append(const struct ft_color color, const char *featured_text)
const char * city_improvement_name_translation(const struct city *pcity, const struct impr_type *pimprove)
Definition city.c:663
const char * city_name_get(const struct city *pcity)
Definition city.c:1137
#define INCITE_IMPOSSIBLE_COST
Definition city.h:93
#define city_owner(_pcity_)
Definition city.h:560
#define city_built_iterate(_pcity, _p)
Definition city.h:831
#define city_built_iterate_end
Definition city.h:837
void qtg_real_city_dialog_popup(struct city *pcity)
Definition citydlg.cpp:3863
Choice_dialog_button(const QString title, pfcn_void func_in, QVariant data1_in, QVariant data2_in)
Definition dialogs.cpp:1409
void setData2(QVariant wariat)
Definition dialogs.cpp:1457
void setData1(QVariant wariat)
Definition dialogs.cpp:1449
pfcn_void getFunc()
Definition dialogs.cpp:1423
void stack_button(Choice_dialog_button *button)
Definition dialogs.cpp:1783
void prev_unit()
Definition dialogs.cpp:1700
QVBoxLayout * layout
Definition dialogs.h:263
struct unit * targeted_unit
Definition dialogs.h:286
void unstack_all_buttons()
Definition dialogs.cpp:1800
Choice_dialog_button * get_identified_button(const int id)
Definition dialogs.cpp:1612
QPushButton * target_unit_button
Definition dialogs.h:262
void set_layout()
Definition dialogs.cpp:1518
void update_dialog(const struct act_prob *act_probs)
Definition dialogs.cpp:1729
QList< Choice_dialog_button * > last_buttons_stack
Definition dialogs.h:266
void next_unit()
Definition dialogs.cpp:1660
QVBoxLayout * get_layout()
Definition dialogs.cpp:1604
QHBoxLayout * unit_skip
Definition dialogs.h:264
QList< Choice_dialog_button * > buttons_list
Definition dialogs.h:265
void(* run_on_close)(int)
Definition dialogs.h:268
choice_dialog(const QString title, const QString text, QWidget *parent=nullptr, void(*run_on_close_in)(int)=nullptr)
Definition dialogs.cpp:1465
int target_id[ATK_COUNT]
Definition dialogs.h:284
void switch_target()
Definition dialogs.cpp:1747
QList< Choice_dialog_button * > action_button_map
Definition dialogs.h:267
int sub_target_id[ASTK_COUNT]
Definition dialogs.h:285
void execute_action(const int action)
Definition dialogs.cpp:1766
void add_item(QString title, pfcn_void func, QVariant data1, QVariant data2, QString tool_tip, const int button_id)
Definition dialogs.cpp:1560
void put_to_corner()
Definition mapview.cpp:502
void disband_clicked()
Definition dialogs.cpp:4666
disband_box(struct unit_list *punits, QWidget *parent=0)
Definition dialogs.cpp:4640
struct unit_list * cpunits
Definition dialogs.h:97
choice_dialog * opened_dialog
Definition fc_client.h:218
choice_dialog * get_diplo_dialog()
Definition dialogs.cpp:5585
void set_diplo_dialog(choice_dialog *widget)
Definition dialogs.cpp:5577
static fc_font * instance()
Definition fonts.cpp:41
QFont * get_font(QString name)
Definition fonts.cpp:63
QPixmap * get_pixmap(const QString &id)
static fc_icons * instance()
bool was_destroyed
Definition mapview.h:176
void close_dlg()
Definition gotodlg.cpp:511
int set_text_title(QString s1, QString s2, bool return_exec=false)
QString qheadline
Definition dialogs.h:193
void restart()
Definition dialogs.cpp:983
close_widget * cw
Definition dialogs.h:189
void mouseReleaseEvent(QMouseEvent *event)
Definition dialogs.cpp:1076
QFont small_font
Definition dialogs.h:195
QString qcaption
Definition dialogs.h:192
notify_dialog(const char *caption, const char *headline, const char *lines, QWidget *parent=0)
Definition dialogs.cpp:950
void calc_size(int &x, int &y)
Definition dialogs.cpp:1011
void paintEvent(QPaintEvent *paint_event)
Definition dialogs.cpp:1030
QPoint cursor
Definition dialogs.h:196
void mouseMoveEvent(QMouseEvent *event)
Definition dialogs.cpp:1066
virtual void update_menu()
Definition dialogs.cpp:1084
void mousePressEvent(QMouseEvent *event)
Definition dialogs.cpp:1053
QStringList qlist
Definition dialogs.h:194
QPushButton * close_but
Definition dialogs.h:113
notify_goto(const char *headline, const char *lines, const struct text_tag_list *tags, struct tile *ptile, QWidget *parent)
Definition dialogs.cpp:1185
QPushButton * goto_but
Definition dialogs.h:111
void inspect_city()
Definition dialogs.cpp:1228
struct tile * gtile
Definition dialogs.h:114
QPushButton * inspect_but
Definition dialogs.h:112
void goto_tile()
Definition dialogs.cpp:1219
action_id vs_unit
Definition dialogs.h:60
static qdef_act * action()
Definition dialogs.cpp:1113
action_id vs_city_get()
Definition dialogs.cpp:1151
static qdef_act * m_instance
Definition dialogs.h:58
static void drop()
Definition dialogs.cpp:1124
action_id vs_city
Definition dialogs.h:59
void vs_city_set(int i)
Definition dialogs.cpp:1135
void vs_unit_set(int i)
Definition dialogs.cpp:1143
action_id vs_unit_get()
Definition dialogs.cpp:1159
QPoint point
Definition dialogs.h:81
void paintEvent(QPaintEvent *event)
Definition dialogs.cpp:426
QPixmap close_pix
Definition dialogs.h:83
void reactivate()
Definition dialogs.cpp:418
void mouseMoveEvent(QMouseEvent *event)
Definition dialogs.cpp:467
int titlebar_height
Definition dialogs.h:80
void mousePressEvent(QMouseEvent *event)
Definition dialogs.cpp:477
void mouseReleaseEvent(QMouseEvent *event)
Definition dialogs.cpp:497
qfc_dialog(QWidget *parent)
Definition dialogs.cpp:406
bool moving_now
Definition dialogs.h:82
int selected_style
Definition dialogs.h:164
QComboBox * leader_name
Definition dialogs.h:135
void random_pressed()
Definition dialogs.cpp:1175
int last_index
Definition dialogs.h:166
QTableWidget * selected_nation_tabs
Definition dialogs.h:134
QPushButton * random_button
Definition dialogs.h:143
void refresh()
Definition dialogs.cpp:686
void style_selected(const QItemSelection &selected)
Definition dialogs.cpp:879
void nationset_changed(int index)
Definition dialogs.cpp:1240
int selected_nation
Definition dialogs.h:163
void ok_pressed()
Definition dialogs.cpp:912
void leader_selected(int index)
Definition dialogs.cpp:897
QPushButton * ok_button
Definition dialogs.h:142
QTextEdit * description
Definition dialogs.h:141
void set_index(int index)
Definition dialogs.cpp:769
QComboBox * qnation_set
Definition dialogs.h:136
QRadioButton * is_male
Definition dialogs.h:138
QButtonGroup * sex_buttons
Definition dialogs.h:137
void update_nationset_combo()
Definition dialogs.cpp:736
QTableWidget * styles
Definition dialogs.h:140
void group_selected(const QItemSelection &selected)
Definition dialogs.cpp:752
struct player * tplayer
Definition dialogs.h:165
races_dialog(struct player *pplayer, QWidget *parent=0)
Definition dialogs.cpp:506
QRadioButton * is_female
Definition dialogs.h:139
QTableWidget * nation_tabs
Definition dialogs.h:132
QGridLayout * main_layout
Definition dialogs.h:131
void nation_selected(const QItemSelection &selected)
Definition dialogs.cpp:829
void cancel_pressed()
Definition dialogs.cpp:1167
QPixmap * h_pix
Definition dialogs.h:206
QFont ufont
Definition dialogs.h:210
QFont info_font
Definition dialogs.h:211
void closeEvent(QCloseEvent *event)
Definition dialogs.cpp:5531
void update_img()
Definition dialogs.cpp:5389
int show_line
Definition dialogs.h:233
void mouseMoveEvent(QMouseEvent *event)
Definition dialogs.cpp:5333
void paint(QPainter *painter, QPaintEvent *event)
Definition dialogs.cpp:5398
void update_menu()
Definition dialogs.cpp:5489
int highlight_num
Definition dialogs.h:234
QPixmap * pix
Definition dialogs.h:205
int row_count
Definition dialogs.h:212
QList< unit * > unit_list
Definition dialogs.h:208
units_select(struct tile *ptile, QWidget *parent)
Definition dialogs.cpp:5153
void update_units()
Definition dialogs.cpp:5499
tile * utile
Definition dialogs.h:220
int unit_count
Definition dialogs.h:235
QSize item_size
Definition dialogs.h:207
void paintEvent(QPaintEvent *event)
Definition dialogs.cpp:5476
void create_pixmap()
Definition dialogs.cpp:5198
void wheelEvent(QWheelEvent *event)
Definition dialogs.cpp:5540
void keyPressEvent(QKeyEvent *event)
Definition dialogs.cpp:5564
void mousePressEvent(QMouseEvent *event)
Definition dialogs.cpp:5364
close_widget * cw
Definition dialogs.h:213
char music_set_name[512]
bool client_is_global_observer(void)
struct civclient client
enum client_states client_state(void)
char sound_set_name[512]
#define client_player()
@ C_S_RUNNING
Definition client_main.h:47
void client_unit_init_act_prob_cache(struct unit *punit)
Definition climisc.c:1259
char * incite_cost
Definition comments.c:76
void action_selection_no_longer_in_progress(const int old_actor_id)
Definition control.c:1063
void request_unit_load(struct unit *pcargo, struct unit *ptrans, struct tile *ptile)
Definition control.c:2168
void unit_focus_set(struct unit *punit)
Definition control.c:518
void request_do_action(action_id action, int actor_id, int target_id, int sub_tgt, const char *name)
Definition control.c:1742
void request_unit_disband(struct unit *punit)
Definition control.c:2087
void request_action_details(action_id action, int actor_id, int target_id)
Definition control.c:1810
void request_new_unit_activity_targeted(struct unit *punit, enum unit_activity act, struct extra_type *tgt)
Definition control.c:1950
void action_confirmation(struct act_confirmation_data *data, bool confirm)
Definition control.c:1778
void action_decision_clear_want(const int old_actor_id)
Definition control.c:1092
void key_unit_wait(void)
Definition control.c:3554
struct unit * head_of_units_in_focus(void)
Definition control.c:410
void request_unit_upgrade(struct unit *punit)
Definition control.c:2118
void action_selection_next_in_focus(const int old_actor_id)
Definition control.c:1104
bool qtg_handmade_scenario_warning()
Definition dialogs.cpp:5594
static void mine2(QVariant data1, QVariant data2)
Definition dialogs.cpp:3416
static void attack(QVariant data1, QVariant data2)
Definition dialogs.cpp:3494
static void wipe_units(QVariant data1, QVariant data2)
Definition dialogs.cpp:3022
char forced_tileset_name[512]
static void bombard4(QVariant data1, QVariant data2)
Definition dialogs.cpp:3094
int action_selection_target_extra(void)
Definition dialogs.cpp:4892
static void suicide_attack2(QVariant data1, QVariant data2)
Definition dialogs.cpp:3539
static void destroy_city(QVariant data1, QVariant data2)
Definition dialogs.cpp:4036
static void spy_sabotage_unit(QVariant data1, QVariant data2)
Definition dialogs.cpp:2628
static void pillage(QVariant data1, QVariant data2)
Definition dialogs.cpp:3231
static void caravan_marketplace(QVariant data1, QVariant data2)
Definition dialogs.cpp:1814
static void clean(QVariant data1, QVariant data2)
Definition dialogs.cpp:3271
static void spy_steal_shared(QVariant data1, QVariant data2, action_id act_id)
Definition dialogs.cpp:3779
static void clean2(QVariant data1, QVariant data2)
Definition dialogs.cpp:3291
static void spy_sabotage(QVariant data1, QVariant data2)
Definition dialogs.cpp:4505
int action_selection_target_tile(void)
Definition dialogs.cpp:4875
static void teleport_enter(QVariant data1, QVariant data2)
Definition dialogs.cpp:3719
static void conquer_extras3(QVariant data1, QVariant data2)
Definition dialogs.cpp:2013
static void spy_investigate(QVariant data1, QVariant data2)
Definition dialogs.cpp:4156
static void act_sel_wait(QVariant data1, QVariant data2)
Definition dialogs.cpp:2041
static void nuke_units(QVariant data1, QVariant data2)
Definition dialogs.cpp:2986
int action_selection_actor_unit(void)
Definition dialogs.cpp:4841
static void capture_units(QVariant data1, QVariant data2)
Definition dialogs.cpp:3034
static void road(QVariant data1, QVariant data2)
Definition dialogs.cpp:3311
static bool is_race_dialog_open
Definition dialogs.cpp:227
static void transport_embark4(QVariant data1, QVariant data2)
Definition dialogs.cpp:2740
bool try_default_unit_action(QVariant q1, QVariant q2)
Definition dialogs.cpp:1625
static void fortify(QVariant data1, QVariant data2)
Definition dialogs.cpp:2539
static void teleport_frighten(QVariant data1, QVariant data2)
Definition dialogs.cpp:3659
static void transport_board(QVariant data1, QVariant data2)
Definition dialogs.cpp:2674
static void diplomat_bribe_unit(QVariant data1, QVariant data2)
Definition dialogs.cpp:2593
static void spy_sabotage_unit_esc(QVariant data1, QVariant data2)
Definition dialogs.cpp:2640
static void disband_unit(QVariant data1, QVariant data2)
Definition dialogs.cpp:2527
static void spy_steal_gold(QVariant data1, QVariant data2)
Definition dialogs.cpp:4051
void popdown_players_report()
Definition plrdlg.cpp:1197
static void conquer_city_shrink2(QVariant data1, QVariant data2)
Definition dialogs.cpp:1940
static void spy_escape(QVariant data1, QVariant data2)
Definition dialogs.cpp:4111
static void mine(QVariant data1, QVariant data2)
Definition dialogs.cpp:3395
void popup_musicset_suggestion_dialog(void)
Definition dialogs.cpp:4752
static void spy_steal_gold_esc(QVariant data1, QVariant data2)
Definition dialogs.cpp:4066
static void diplomat_embassy(QVariant data1, QVariant data2)
Definition dialogs.cpp:4141
void unit_select_dialog_popup(struct tile *ptile)
Definition dialogs.cpp:1325
void popup_upgrade_dialog(struct unit_list *punits)
Definition dialogs.cpp:5108
void update_nationset_combo()
Definition dialogs.cpp:1345
void action_selection_close(void)
Definition dialogs.cpp:5046
static void cultivate(QVariant data1, QVariant data2)
Definition dialogs.cpp:3171
static void paradrop_enter(QVariant data1, QVariant data2)
Definition dialogs.cpp:3704
void races_update_pickable(bool nationset_change)
Definition dialogs.cpp:1355
int action_selection_target_city(void)
Definition dialogs.cpp:4858
static void spy_steal_something(QVariant data1, QVariant data2)
Definition dialogs.cpp:3869
#define BUTTON_WAIT
Definition dialogs.cpp:71
void popup_notify_goto_dialog(const char *headline, const char *lines, const struct text_tag_list *tags, struct tile *ptile)
Definition dialogs.cpp:1263
static void spy_poison(QVariant data1, QVariant data2)
Definition dialogs.cpp:3946
static void transport_board2(QVariant data1, QVariant data2)
Definition dialogs.cpp:2685
void show_tech_gained_dialog(Tech_type_id tech)
Definition dialogs.cpp:5060
static void base(QVariant data1, QVariant data2)
Definition dialogs.cpp:3353
static void spy_nuke_city_esc(QVariant data1, QVariant data2)
Definition dialogs.cpp:4006
static void teleport(QVariant data1, QVariant data2)
Definition dialogs.cpp:3569
void popup_soundset_suggestion_dialog(void)
Definition dialogs.cpp:4727
static void enter_hut2(QVariant data1, QVariant data2)
Definition dialogs.cpp:2881
void popup_races_dialog(struct player *pplayer)
Definition dialogs.cpp:1300
static void expel_unit(QVariant data1, QVariant data2)
Definition dialogs.cpp:3046
static void paradrop_frighten(QVariant data1, QVariant data2)
Definition dialogs.cpp:3644
static void diplomat_sabotage(QVariant data1, QVariant data2)
Definition dialogs.cpp:4186
void popup_disband_dialog(struct unit_list *punits)
Definition dialogs.cpp:4686
static action_id get_non_targeted_action_id(action_id tgt_action_id)
Definition dialogs.cpp:2422
static void road2(QVariant data1, QVariant data2)
Definition dialogs.cpp:3332
static void homeless(QVariant data1, QVariant data2)
Definition dialogs.cpp:2579
static void caravan_help_build(QVariant data1, QVariant data2)
Definition dialogs.cpp:1844
void qtg_popup_image(const char *tag)
Definition dialogs.cpp:5705
static void bombard(QVariant data1, QVariant data2)
Definition dialogs.cpp:3058
void popup_bribe_stack_dialog(struct unit *actor, struct tile *ttile, int cost, const struct action *paction)
Definition dialogs.cpp:4438
void popdown_races_dialog(void)
Definition dialogs.cpp:1314
void popup_tileset_suggestion_dialog(void)
Definition dialogs.cpp:4696
void revolution_response(struct government *gov)
Definition dialogs.cpp:2056
void popdown_economy_report()
static void join_city(QVariant data1, QVariant data2)
Definition dialogs.cpp:3764
static void spy_request_sabotage_list(QVariant data1, QVariant data2)
Definition dialogs.cpp:3909
static void popup_act_confirmation_dialog(QString hdr, QString body, struct act_confirmation_data *data)
Definition dialogs.cpp:5665
static void unit_disband_recover(QVariant data1, QVariant data2)
Definition dialogs.cpp:1859
static void spy_steal(QVariant data1, QVariant data2)
Definition dialogs.cpp:3853
static void conquer_extras4(QVariant data1, QVariant data2)
Definition dialogs.cpp:2027
static void frighten_hut4(QVariant data1, QVariant data2)
Definition dialogs.cpp:2971
static void airlift(QVariant data1, QVariant data2)
Definition dialogs.cpp:1910
void popup_pillage_dialog(struct unit *punit, bv_extras extras)
Definition dialogs.cpp:4607
static void enter_hut3(QVariant data1, QVariant data2)
Definition dialogs.cpp:2896
static void transport_load3(QVariant data1, QVariant data2)
Definition dialogs.cpp:2784
static void spy_attack(QVariant data1, QVariant data2)
Definition dialogs.cpp:3010
static void bombard_lethal(QVariant data1, QVariant data2)
Definition dialogs.cpp:3106
static void plant(QVariant data1, QVariant data2)
Definition dialogs.cpp:3201
static void diplomat_bribe_stack(QVariant data1, QVariant data2)
Definition dialogs.cpp:2611
static void nuke(QVariant data1, QVariant data2)
Definition dialogs.cpp:3479
static void disembark2(QVariant data1, QVariant data2)
Definition dialogs.cpp:2821
static void plant2(QVariant data1, QVariant data2)
Definition dialogs.cpp:3216
static void transport_unload(QVariant data1, QVariant data2)
Definition dialogs.cpp:2751
void qtg_request_action_confirmation(const char *expl, struct act_confirmation_data *data)
Definition dialogs.cpp:5687
static void teleport_conquer(QVariant data1, QVariant data2)
Definition dialogs.cpp:3629
void action_selection_refresh(struct unit *actor_unit, struct city *target_city, struct unit *target_unit, struct tile *target_tile, struct extra_type *target_extra, const struct act_prob *act_probs)
Definition dialogs.cpp:4923
void popdown_science_report()
static void transport_load2(QVariant data1, QVariant data2)
Definition dialogs.cpp:2773
static void diplomat_steal(QVariant data1, QVariant data2)
Definition dialogs.cpp:4216
static void unit_upgrade(QVariant data1, QVariant data2)
Definition dialogs.cpp:1889
bool popup_theme_suggestion_dialog(const char *theme_name)
Definition dialogs.cpp:4777
static void enter_hut(QVariant data1, QVariant data2)
Definition dialogs.cpp:2866
static void spy_request_strike_bld_list(QVariant data1, QVariant data2)
Definition dialogs.cpp:3892
static void diplomat_incite_escape(QVariant data1, QVariant data2)
Definition dialogs.cpp:4264
static void pillage2(QVariant data1, QVariant data2)
Definition dialogs.cpp:3251
static void found_city(QVariant data1, QVariant data2)
Definition dialogs.cpp:3130
static void diplomat_investigate(QVariant data1, QVariant data2)
Definition dialogs.cpp:4171
void qtg_popup_combat_info(int attacker_unit_id, int defender_unit_id, int attacker_hp, int defender_hp, bool make_att_veteran, bool make_def_veteran)
Definition dialogs.cpp:5644
static void bombard3(QVariant data1, QVariant data2)
Definition dialogs.cpp:3082
static void transport_deboard(QVariant data1, QVariant data2)
Definition dialogs.cpp:2795
static void diplomat_incite(QVariant data1, QVariant data2)
Definition dialogs.cpp:4246
static void paradrop_conquer(QVariant data1, QVariant data2)
Definition dialogs.cpp:3614
void popdown_endgame_report()
static void diplomat_steal_esc(QVariant data1, QVariant data2)
Definition dialogs.cpp:4231
static void irrigate2(QVariant data1, QVariant data2)
Definition dialogs.cpp:3458
static void cultivate2(QVariant data1, QVariant data2)
Definition dialogs.cpp:3186
static void bombard_lethal2(QVariant data1, QVariant data2)
Definition dialogs.cpp:3118
static void frighten_hut3(QVariant data1, QVariant data2)
Definition dialogs.cpp:2956
static bool is_more_user_input_needed
Definition dialogs.cpp:232
static void bombard2(QVariant data1, QVariant data2)
Definition dialogs.cpp:3070
void popup_incite_dialog(struct unit *actor, struct city *tcity, int cost, const struct action *paction)
Definition dialogs.cpp:4328
static const QHash< action_id, pfcn_void > af_map_init(void)
Definition dialogs.cpp:245
void popdown_all_spaceships_dialogs()
static void nuke_city(QVariant data1, QVariant data2)
Definition dialogs.cpp:4021
static void transform_terrain2(QVariant data1, QVariant data2)
Definition dialogs.cpp:3156
void popup_connect_msg(const char *headline, const char *message)
Definition dialogs.cpp:1275
static void conquer_city_shrink(QVariant data1, QVariant data2)
Definition dialogs.cpp:1925
static void conquer_city_shrink3(QVariant data1, QVariant data2)
Definition dialogs.cpp:1955
static void diplomat_sabotage_esc(QVariant data1, QVariant data2)
Definition dialogs.cpp:4201
void popdown_units_report()
static void transport_embark2(QVariant data1, QVariant data2)
Definition dialogs.cpp:2718
static void spy_nuke_city(QVariant data1, QVariant data2)
Definition dialogs.cpp:3991
static void teleport_frighten_conquer(QVariant data1, QVariant data2)
Definition dialogs.cpp:3689
void unit_select_dialog_update_real(void *unused)
Definition dialogs.cpp:1337
static void spy_steal_esc(QVariant data1, QVariant data2)
Definition dialogs.cpp:3861
static void paradrop(QVariant data1, QVariant data2)
Definition dialogs.cpp:3554
static void suicide_attack(QVariant data1, QVariant data2)
Definition dialogs.cpp:3524
void races_toggles_set_sensitive(void)
Definition dialogs.cpp:1366
static void transport_load(QVariant data1, QVariant data2)
Definition dialogs.cpp:2762
static void fortify2(QVariant data1, QVariant data2)
Definition dialogs.cpp:2553
static action_id get_production_targeted_action_id(action_id tgt_action_id)
Definition dialogs.cpp:2445
static void paradrop_frighten_conquer(QVariant data1, QVariant data2)
Definition dialogs.cpp:3674
static void convert_unit(QVariant data1, QVariant data2)
Definition dialogs.cpp:2567
static void teleport2(QVariant data1, QVariant data2)
Definition dialogs.cpp:3584
static bool did_not_decide
Definition dialogs.cpp:236
static void spy_poison_esc(QVariant data1, QVariant data2)
Definition dialogs.cpp:3961
static void pillage_something(QVariant data1, QVariant data2)
Definition dialogs.cpp:4485
static void spy_request_sabotage_esc_list(QVariant data1, QVariant data2)
Definition dialogs.cpp:3927
void show_tileset_error(bool fatal, const char *tset_name, const char *msg)
Definition dialogs.cpp:5067
static void transform_terrain(QVariant data1, QVariant data2)
Definition dialogs.cpp:3141
static void attack2(QVariant data1, QVariant data2)
Definition dialogs.cpp:3509
#define BUTTON_CANCEL
Definition dialogs.cpp:72
static void conquer_extras(QVariant data1, QVariant data2)
Definition dialogs.cpp:1985
static void regular_move(QVariant data1, QVariant data2)
Definition dialogs.cpp:4282
static void heal_unit2(QVariant data1, QVariant data2)
Definition dialogs.cpp:2663
static void transport_board3(QVariant data1, QVariant data2)
Definition dialogs.cpp:2696
static void spy_embassy(QVariant data1, QVariant data2)
Definition dialogs.cpp:4126
static races_dialog * race_dialog
Definition dialogs.cpp:226
static void conquer_city_shrink4(QVariant data1, QVariant data2)
Definition dialogs.cpp:1970
static void teleport3(QVariant data1, QVariant data2)
Definition dialogs.cpp:3599
static void base2(QVariant data1, QVariant data2)
Definition dialogs.cpp:3374
static void frighten_hut2(QVariant data1, QVariant data2)
Definition dialogs.cpp:2941
static void conquer_extras2(QVariant data1, QVariant data2)
Definition dialogs.cpp:1999
static void regular_move2(QVariant data1, QVariant data2)
Definition dialogs.cpp:4297
static void frighten_hut(QVariant data1, QVariant data2)
Definition dialogs.cpp:2926
bool qtg_request_transport(struct unit *pcargo, struct tile *ptile)
Definition dialogs.cpp:5603
static void disembark4(QVariant data1, QVariant data2)
Definition dialogs.cpp:2851
int action_selection_target_unit(void)
Definition dialogs.cpp:4909
static void irrigate(QVariant data1, QVariant data2)
Definition dialogs.cpp:3437
static void transport_embark3(QVariant data1, QVariant data2)
Definition dialogs.cpp:2729
static void collect_ransom(QVariant data1, QVariant data2)
Definition dialogs.cpp:2998
static void heal_unit(QVariant data1, QVariant data2)
Definition dialogs.cpp:2652
void popdown_city_report()
Definition cityrep.cpp:1336
static void teleport_enter_conquer(QVariant data1, QVariant data2)
Definition dialogs.cpp:3749
static void regular_move3(QVariant data1, QVariant data2)
Definition dialogs.cpp:4312
static void paradrop_enter_conquer(QVariant data1, QVariant data2)
Definition dialogs.cpp:3734
static void unit_home_city(QVariant data1, QVariant data2)
Definition dialogs.cpp:1874
static void transport_embark(QVariant data1, QVariant data2)
Definition dialogs.cpp:2707
bool try_default_city_action(QVariant q1, QVariant q2)
Definition dialogs.cpp:1643
static void keep_moving(QVariant data1, QVariant data2)
Definition dialogs.cpp:2049
static void spy_steal_maps_esc(QVariant data1, QVariant data2)
Definition dialogs.cpp:4096
static void action_entry_update(Choice_dialog_button *button, action_id act, const struct act_prob *act_probs, const char *custom, QVariant data1, QVariant data2)
Definition dialogs.cpp:2498
static void disembark1(QVariant data1, QVariant data2)
Definition dialogs.cpp:2806
void restart_notify_dialogs()
Definition dialogs.cpp:4786
static void disembark3(QVariant data1, QVariant data2)
Definition dialogs.cpp:2836
static bool is_showing_pillage_dialog
Definition dialogs.cpp:225
static void spy_spread_plague(QVariant data1, QVariant data2)
Definition dialogs.cpp:3976
static void action_entry(choice_dialog *cd, action_id act, const struct act_prob *act_probs, const char *custom, QVariant data1, QVariant data2)
Definition dialogs.cpp:2465
static const QHash< action_id, pfcn_void > af_map
Definition dialogs.cpp:401
static void enter_hut4(QVariant data1, QVariant data2)
Definition dialogs.cpp:2911
static void caravan_establish_trade(QVariant data1, QVariant data2)
Definition dialogs.cpp:1829
void popdown_all_game_dialogs(void)
Definition dialogs.cpp:4802
static void spy_steal_maps(QVariant data1, QVariant data2)
Definition dialogs.cpp:4081
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id popup_bribe_unit_dialog
Definition dialogs_g.h:72
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit int const struct action *paction struct unit struct city const struct action *paction const char * expl
Definition dialogs_g.h:93
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit int const struct action *paction popup_sabotage_dialog
Definition dialogs_g.h:76
struct unit struct city struct unit * target_unit
Definition dialogs_g.h:55
popup_action_selection
Definition dialogs_g.h:54
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit * actor
Definition dialogs_g.h:72
struct unit * actor_unit
Definition dialogs_g.h:54
const char * caption
Definition dialogs_g.h:36
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs action_selection_no_longer_in_progress_gui_specific
Definition dialogs_g.h:68
const char const char * headline
Definition dialogs_g.h:37
popup_notify_dialog
Definition dialogs_g.h:36
struct unit struct city struct unit struct tile * target_tile
Definition dialogs_g.h:56
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit * punit
Definition dialogs_g.h:73
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit int const struct action *paction struct unit struct city * pcity
Definition dialogs_g.h:77
struct unit struct city * target_city
Definition dialogs_g.h:55
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit int cost
Definition dialogs_g.h:73
struct unit struct city struct unit struct tile struct extra_type * target_extra
Definition dialogs_g.h:56
int int id
Definition editgui_g.h:28
enum event_type event
Definition events.c:81
int extra_number(const struct extra_type *pextra)
Definition extras.c:161
struct extra_type * extra_by_number(int id)
Definition extras.c:183
static struct extra_type extras[MAX_EXTRA_TYPES]
Definition extras.c:31
const char * extra_name_translation(const struct extra_type *pextra)
Definition extras.c:194
#define extra_index(_e_)
Definition extras.h:183
#define EXTRA_NONE
Definition extras.h:85
int Tech_type_id
Definition fc_types.h:237
int action_id
Definition fc_types.h:249
int Government_type_id
Definition fc_types.h:241
#define IDENTITY_NUMBER_ZERO
Definition fc_types.h:93
#define PL_(String1, String2, n)
Definition fcintl.h:71
#define _(String)
Definition fcintl.h:67
const struct ft_color ftc_client
struct civ_game game
Definition game.c:61
struct world wld
Definition game.c:62
struct unit * game_unit_by_number(int id)
Definition game.c:115
struct city * game_city_by_number(int id)
Definition game.c:106
struct government * government_by_number(const Government_type_id gov)
Definition government.c:103
Government_type_id government_number(const struct government *pgovern)
Definition government.c:91
#define G_LAST
Definition government.h:48
int action_selection_target_extra(void)
static int actor_unit_id
static void diplomat_queue_handle_primary(void)
static void diplomat_queue_handle_secondary(void)
#define BUTTON_COUNT
void action_selection_refresh(struct unit *actor_unit, struct city *target_city, struct unit *target_unit, struct tile *target_tile, struct extra_type *target_extra, const struct act_prob *act_probs)
static PangoLayout * layout
Definition canvas.c:325
struct city * owner
Definition citydlg.c:226
static struct tile * pos
Definition finddlg.c:53
void popdown_help_dialog(void)
Definition helpdlg.c:186
const char * title
Definition repodlgs.c:1314
void(* pfcn_void)(QVariant, QVariant)
Definition dialogs.h:46
#define mevent_gpos(__ev__)
Definition gui_main.h:23
#define CAPTURE_DEFAULT_THIS
Definition gui_main.h:31
void nationset_changed(void)
Definition dialogs.c:3577
#define show(id)
Definition widget.h:235
void popup_revolution_dialog(void)
Definition dialogs.c:112
void helptext_nation(char *buf, size_t bufsz, struct nation_type *pnation, const char *user_text)
Definition helpdata.c:5084
Impr_type_id improvement_number(const struct impr_type *pimprove)
#define B_LAST
Definition improvement.h:42
get_token_fn_t func
Definition inputfile.c:128
#define fc_assert_msg(condition, message,...)
Definition log.h:182
#define fc_assert(condition)
Definition log.h:177
#define fc_assert_action(condition, action)
Definition log.h:188
@ LOG_ERROR
Definition log.h:31
#define log_error(message,...)
Definition log.h:104
struct tile * index_to_tile(const struct civ_map *imap, int mindex)
Definition map.c:471
void put_unit(const struct unit *punit, struct canvas *pcanvas, float zoom, int canvas_x, int canvas_y)
void center_tile_mapcanvas(const struct tile *ptile)
static const void * body(MD5_CTX *ctx, const void *data, unsigned long size)
Definition md5.c:121
#define FC_FREE(ptr)
Definition mem.h:41
const char * move_points_text(int mp, bool reduce)
Definition movement.c:1066
static mpgui * gui
Definition mpgui_qt.cpp:52
const char *const notify_label
Definition fonts.h:28
Nation_type_id nation_number(const struct nation_type *pnation)
Definition nation.c:486
bool nation_leader_is_male(const struct nation_leader *pleader)
Definition nation.c:290
const char * nation_adjective_for_player(const struct player *pplayer)
Definition nation.c:169
const char * nation_adjective_translation(const struct nation_type *pnation)
Definition nation.c:149
struct nation_type * nation_by_number(const Nation_type_id nation)
Definition nation.c:475
int nation_set_index(const struct nation_set *pset)
Definition nation.c:699
bool is_nation_pickable(const struct nation_type *nation)
Definition nation.c:188
const struct nation_leader_list * nation_leaders(const struct nation_type *pnation)
Definition nation.c:230
const char * nation_set_name_translation(const struct nation_set *pset)
Definition nation.c:818
bool is_nation_playable(const struct nation_type *nation)
Definition nation.c:200
bool nation_is_in_group(const struct nation_type *pnation, const struct nation_group *pgroup)
Definition nation.c:1099
const char * nation_set_description(const struct nation_set *pset)
Definition nation.c:828
const char * nation_group_name_translation(const struct nation_group *pgroup)
Definition nation.c:1090
int nation_set_count(void)
Definition nation.c:691
struct nation_group * nation_group_by_number(int id)
Definition nation.c:1004
struct nation_set * nation_set_by_rule_name(const char *name)
Definition nation.c:779
bool is_nation_group_hidden(struct nation_group *pgroup)
Definition nation.c:1057
struct nation_set * nation_set_by_setting_value(const char *setting)
Definition nation.c:859
const char * nation_leader_name(const struct nation_leader *pleader)
Definition nation.c:281
int nation_group_count(void)
Definition nation.c:935
const char * nation_set_rule_name(const struct nation_set *pset)
Definition nation.c:807
struct nation_style * style_of_nation(const struct nation_type *pnation)
Definition nation.c:672
#define nation_leader_list_iterate(leaderlist, pleader)
Definition nation.h:57
#define nation_sets_iterate_end
Definition nation.h:305
#define nation_sets_iterate(NAME_pset)
Definition nation.h:301
#define nations_iterate_end
Definition nation.h:336
#define nations_iterate(NAME_pnation)
Definition nation.h:333
#define nation_leader_list_iterate_end
Definition nation.h:59
const struct option_set * server_optset
Definition options.c:4077
bool option_str_set(struct option *poption, const char *str)
Definition options.c:937
const char * option_str_get(const struct option *poption)
Definition options.c:904
struct option * optset_option_by_name(const struct option_set *poptset, const char *name)
Definition options.c:442
#define REQEST_PLAYER_INITIATED
Definition packets.h:63
int dsend_packet_unit_get_actions(struct connection *pc, int actor_unit_id, int target_unit_id, int target_tile_id, int target_extra_id, int request_kind)
int dsend_packet_nation_select_req(struct connection *pc, int player_no, Nation_type_id nation_no, bool is_male, const char *name, int style)
int dsend_packet_city_name_suggestion_req(struct connection *pc, int unit_id)
void start_revolution(void)
Definition packhand.c:2405
void set_government_choice(struct government *government)
Definition packhand.c:2392
char * lines
Definition packhand.c:131
int player_number(const struct player *pplayer)
Definition player.c:837
const char * research_advance_name_translation(const struct research *presearch, Tech_type_id tech)
Definition research.c:273
struct research * research_get(const struct player *pplayer)
Definition research.c:128
enum tech_state research_invention_state(const struct research *presearch, Tech_type_id tech)
Definition research.c:619
bool research_invention_gettable(const struct research *presearch, const Tech_type_id tech, bool allow_holes)
Definition research.c:693
const char * sex_name_translation(sex_t kind)
Definition sex.c:60
@ SEX_FEMALE
Definition sex.h:22
@ SEX_MALE
Definition sex.h:23
#define ARRAY_SIZE(x)
Definition shared.h:85
size_t size
Definition specvec.h:72
struct sprite int int y
Definition sprite_g.h:31
struct sprite int x
Definition sprite_g.h:31
struct sprite int int int int struct sprite int int float bool smooth get_sprite_dimensions
Definition sprite_g.h:36
QPixmap map_pixmap
Definition canvas.h:25
Definition city.h:317
struct packet_ruleset_control control
Definition game.h:83
struct packet_game_info info
Definition game.h:89
struct connection conn
Definition client_main.h:96
Definition colors.h:21
struct player * playing
Definition connection.h:151
Definition mapimg.c:367
Definition climisc.h:82
struct universal item
Definition climisc.h:83
struct player * player
Definition nation.h:118
bool tech_steal_allow_holes
char preferred_soundset[MAX_LEN_NAME]
char preferred_tileset[MAX_LEN_NAME]
char preferred_musicset[MAX_LEN_NAME]
int revolution_finishes
Definition player.h:273
char name[MAX_LEN_NAME]
Definition player.h:251
Definition menu.h:161
QPixmap * pm
Definition sprite.h:25
Definition tile.h:50
int index
Definition tile.h:51
struct unit_list * units
Definition tile.h:58
int move_rate
Definition unittype.h:522
Definition unit.h:139
int moves_left
Definition unit.h:151
int id
Definition unit.h:146
int hp
Definition unit.h:152
int fuel
Definition unit.h:154
struct tile * tile
Definition unit.h:141
struct unit::@84::@86 client
struct act_prob * act_prob_cache
Definition unit.h:230
int homecity
Definition unit.h:147
struct civ_map map
const char * style_name_translation(const struct nation_style *pstyle)
Definition style.c:99
int style_number(const struct nation_style *pstyle)
Definition style.c:68
int basic_city_style_for_style(struct nation_style *pstyle)
Definition style.c:210
#define styles_iterate(_p)
Definition style.h:46
#define styles_iterate_end
Definition style.h:52
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:960
#define sz_strlcpy(dest, src)
Definition support.h:195
#define TRUE
Definition support.h:46
#define FALSE
Definition support.h:47
#define is_svg_flag_enabled()
Definition svgflag.h:30
#define advance_index_iterate_end
Definition tech.h:244
#define A_FIRST
Definition tech.h:44
#define A_UNSET
Definition tech.h:48
#define advance_index_iterate(_start, _index)
Definition tech.h:240
struct extra_type * get_preferred_pillage(bv_extras extras)
Definition terrain.c:549
bool get_units_upgrade_info(char *buf, size_t bufsz, struct unit_list *punits)
Definition text.c:1310
const char * get_act_sel_action_custom_text(struct action *paction, const struct act_prob prob, const struct unit *actor_unit, const struct city *target_city)
Definition text.c:1763
const char * act_sel_action_tool_tip(const struct action *paction, const struct act_prob prob)
Definition text.c:1868
struct city * tile_city(const struct tile *ptile)
Definition tile.c:83
#define tile_index(_pt_)
Definition tile.h:89
#define TILE_INDEX_NONE
Definition tile.h:48
int tileset_hex_width(const struct tileset *t)
Definition tilespec.c:747
int tileset_unit_width(const struct tileset *t)
Definition tilespec.c:823
int tileset_unit_height(const struct tileset *t)
Definition tilespec.c:831
struct sprite * load_popup_sprite(const char *tag)
Definition tilespec.c:7838
bool tileset_is_isometric(const struct tileset *t)
Definition tilespec.c:738
struct sprite * get_sample_city_sprite(const struct tileset *t, int style_idx)
Definition tilespec.c:7110
const char * tileset_basename(const struct tileset *t)
Definition tilespec.c:730
int tileset_hex_height(const struct tileset *t)
Definition tilespec.c:756
void unload_popup_sprite(const char *tag)
Definition tilespec.c:7846
struct sprite * get_nation_flag_sprite(const struct tileset *t, const struct nation_type *pnation)
Definition tilespec.c:7007
void tileset_error(enum log_level level, const char *tset_name, const char *format,...)
Definition tilespec.c:650
bool tilespec_reread(const char *new_tileset_name, bool game_fully_initialized, float scale)
Definition tilespec.c:1405
struct unit * transporter_for_unit_at(const struct unit *pcargo, const struct tile *ptile)
Definition unit.c:1985
bool could_unit_load(const struct unit *pcargo, const struct unit *ptrans)
Definition unit.c:742
bool unit_can_do_action(const struct unit *punit, const action_id act_id)
Definition unit.c:401
void unit_activity_astr(const struct unit *punit, struct astring *astr)
Definition unit.c:1210
#define unit_tile(_pu)
Definition unit.h:406
#define unit_owner(_pu)
Definition unit.h:405
#define unit_list_iterate(unitlist, punit)
Definition unitlist.h:31
#define unit_list_iterate_end
Definition unitlist.h:33
const struct unit_type * unit_type_get(const struct unit *punit)
Definition unittype.c:123
const char * unit_name_translation(const struct unit *punit)
Definition unittype.c:1573
#define utype_fuel(ptype)
Definition unittype.h:844