Freeciv-3.4
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 scout(QVariant data1, QVariant data2);
186static void convert_unit(QVariant data1, QVariant data2);
187static void fortify(QVariant data1, QVariant data2);
188static void fortify2(QVariant data1, QVariant data2);
189static void disband_unit(QVariant data1, QVariant data2);
190static void homeless(QVariant data1, QVariant data2);
191static void join_city(QVariant data1, QVariant data2);
192static void unit_home_city(QVariant data1, QVariant data2);
193static void unit_upgrade(QVariant data1, QVariant data2);
194static void airlift(QVariant data1, QVariant data2);
195static void conquer_city_shrink(QVariant data1, QVariant data2);
196static void conquer_city_shrink2(QVariant data1, QVariant data2);
197static void conquer_city_shrink3(QVariant data1, QVariant data2);
198static void conquer_city_shrink4(QVariant data1, QVariant data2);
199static void conquer_extras(QVariant data1, QVariant data2);
200static void conquer_extras2(QVariant data1, QVariant data2);
201static void conquer_extras3(QVariant data1, QVariant data2);
202static void conquer_extras4(QVariant data1, QVariant data2);
203static void heal_unit(QVariant data1, QVariant data2);
204static void heal_unit2(QVariant data1, QVariant data2);
205static void transport_board(QVariant data1, QVariant data2);
206static void transport_board2(QVariant data1, QVariant data2);
207static void transport_board3(QVariant data1, QVariant data2);
208static void transport_embark(QVariant data1, QVariant data2);
209static void transport_embark2(QVariant data1, QVariant data2);
210static void transport_embark3(QVariant data1, QVariant data2);
211static void transport_embark4(QVariant data1, QVariant data2);
212static void transport_deboard(QVariant data1, QVariant data2);
213static void transport_unload(QVariant data1, QVariant data2);
214static void transport_load(QVariant data1, QVariant data2);
215static void transport_load2(QVariant data1, QVariant data2);
216static void transport_load3(QVariant data1, QVariant data2);
217static void keep_moving(QVariant data1, QVariant data2);
218static void pillage_something(QVariant data1, QVariant data2);
219static void action_entry(choice_dialog *cd,
220 action_id act,
221 const struct act_prob *act_probs,
222 const char *custom,
223 QVariant data1, QVariant data2);
224
225
226static bool is_showing_pillage_dialog = false;
228static bool is_race_dialog_open = false;
229
230/* Information used in action selection follow up questions. Can't be
231 * stored in the action selection dialog since it is closed before the
232 * follow up question is asked. */
234
235/* Don't remove a unit's action decision want or move on to the next actor
236 unit that wants a decision in the current unit selection. */
237static bool did_not_decide = false;
238
239extern char forced_tileset_name[512];
241
242/***********************************************************************/
247{
249
250 // Unit acting against a city target.
292
293 // Unit acting against a unit target.
312
313 // Unit acting against all units at a tile.
325
326 // Unit acting against a tile.
384
385 // Unit acting against all tile extras.
390
391 // Unit acting with no target except itself.
397
398 return action_function;
399}
400
401/* Mapping from an action to the function to call when its button is
402 * pushed. */
404
405/***********************************************************************/
410{
411 titlebar_height = 0;
412 moving_now = false;
413 setSizeGripEnabled(true);
415}
416
417/***********************************************************************/
421{
422 raise();
423}
424
425/***********************************************************************/
429{
431
432 QPainter p(this);
435 QStyle *style = this->style();
436 QRect active_area = this->rect();
439
440 qpal.setColor(QPalette::Active, QPalette::ToolTipText, Qt::white);
441 tbar_opt.initFrom(this);
442 titlebar_height = style->pixelMetric(QStyle::PM_TitleBarHeight,
443 &tbar_opt, this) + 2;
444 close_pix = close_pix.scaledToHeight(titlebar_height);
445 tbar_opt.rect = QRect(0, 0, this->width(), titlebar_height);
446 text_rect = QRect(0, 0, this->width() - close_pix.width() , titlebar_height);
447 close_rect = QRect(this->width() - close_pix.width(), 0, this->width(),
449 tbar_opt.titleBarState = this->windowState();
450 tbar_opt.text = tbar_opt.fontMetrics.elidedText(this->windowTitle(),
451 Qt::ElideRight,
452 text_rect.width());
453 style->drawComplexControl(QStyle::CC_TitleBar, &tbar_opt, &p, this);
454 style->drawItemText(&p, text_rect, Qt::AlignCenter, qpal,
455 true, tbar_opt.text, QPalette::ToolTipText);
456 style->drawItemPixmap(&p, close_rect, Qt::AlignLeft,
457 close_pix.scaledToHeight(titlebar_height));
458
459 active_area.setTopLeft(QPoint(0, titlebar_height));
460 this->setContentsMargins(0, titlebar_height, 0, 0);
461 win_opt.initFrom(this);
462 win_opt.rect = active_area;
463 style->drawPrimitive(QStyle::PE_Widget, &win_opt, &p, this);
464}
465
466/***********************************************************************/
470{
471 if (moving_now) {
472 move(event->globalPosition().toPoint() - point);
473 }
474}
475
476/***********************************************************************/
480{
481 QPoint pos = event->pos();
482 int x = pos.x();
483 int y = pos.y();
484
485 if (y <= titlebar_height
486 && x <= width() - close_pix.width()) {
487 point = event->globalPosition().toPoint() - geometry().topLeft();
488 moving_now = true;
489 setCursor(Qt::SizeAllCursor);
490 } else if (y <= titlebar_height
491 && x > width() - close_pix.width()) {
492 close();
493 }
494}
495
496/***********************************************************************/
500{
501 moving_now = false;
502 setCursor(Qt::ArrowCursor);
503}
504
505/***********************************************************************/
509 QWidget *parent) : qfc_dialog(parent)
510{
511 int i;
515 QPixmap *pix;
516 QHeaderView *header;
517 QSize size;
519 QLabel *ns_label;
520
521 setAttribute(Qt::WA_DeleteOnClose);
522 is_race_dialog_open = true;
524 selected_nation_tabs = new QTableWidget;
525 nation_tabs = new QTableWidget();
526 styles = new QTableWidget;
527 ok_button = new QPushButton;
529 ns_label = new QLabel;
530 tplayer = pplayer;
531
532 selected_nation = -1;
533 selected_style = -1;
534 setWindowTitle(_("Select Nation"));
535 selected_nation_tabs->setRowCount(0);
536 selected_nation_tabs->setColumnCount(1);
537 selected_nation_tabs->setSelectionMode(QAbstractItemView::SingleSelection);
538 selected_nation_tabs->verticalHeader()->setVisible(false);
539 selected_nation_tabs->horizontalHeader()->setVisible(false);
540 selected_nation_tabs->setProperty("showGrid", "true");
541 selected_nation_tabs->setEditTriggers(QAbstractItemView::NoEditTriggers);
542 selected_nation_tabs->setShowGrid(false);
543 selected_nation_tabs->setAlternatingRowColors(true);
544
545 nation_tabs->setRowCount(0);
546 nation_tabs->setColumnCount(1);
547 nation_tabs->setSelectionMode(QAbstractItemView::SingleSelection);
548 nation_tabs->verticalHeader()->setVisible(false);
549 nation_tabs->horizontalHeader()->setVisible(false);
550 nation_tabs->setProperty("showGrid", "true");
551 nation_tabs->setEditTriggers(QAbstractItemView::NoEditTriggers);
552 nation_tabs->setShowGrid(false);
553 ns_label->setText(_("Nation Set:"));
554 styles->setRowCount(0);
555 styles->setColumnCount(2);
556 styles->setSelectionMode(QAbstractItemView::SingleSelection);
557 styles->verticalHeader()->setVisible(false);
558 styles->horizontalHeader()->setVisible(false);
559 styles->setProperty("showGrid", "false");
560 styles->setProperty("selectionBehavior", "SelectRows");
561 styles->setEditTriggers(QAbstractItemView::NoEditTriggers);
562 styles->setShowGrid(false);
563
565 no_name = new QGroupBox(parent);
569 sex_buttons->addButton(is_male, SEX_MALE);
571 sex_buttons->addButton(is_female, SEX_FEMALE);
572
573 leader_name->setEditable(true);
574 qgroupbox_layout->addWidget(leader_name, 1, 0, 1, 2);
575 qgroupbox_layout->addWidget(is_male, 2, 1);
576 qgroupbox_layout->addWidget(is_female, 2, 0);
579 no_name->setLayout(qgroupbox_layout);
580
582 description->setReadOnly(true);
583 description->setPlainText(_("Choose nation"));
584 no_name->setTitle(_("Your leader name"));
585
586 // Fill styles, no need to update them later
587
590
591 if (i >= 0) {
593 styles->insertRow(i);
595 item->setData(Qt::DecorationRole, *pix);
596 item->setData(Qt::UserRole, style_number(pstyle));
597 size.setWidth(pix->width());
598 size.setHeight(pix->height());
599 item->setSizeHint(size);
600 styles->setItem(i, 0, item);
603 styles->setItem(i, 1, item);
604 }
606
607 header = styles->horizontalHeader();
608 header->setSectionResizeMode(QHeaderView::Stretch);
609 header->resizeSections(QHeaderView::ResizeToContents);
610 header = styles->verticalHeader();
611 header->resizeSections(QHeaderView::ResizeToContents);
616 // Create nation sets
617 refresh();
618
619 connect(styles->selectionModel(),
621 const QItemSelection &)),
623 connect(selected_nation_tabs->selectionModel(),
625 const QItemSelection &)),
628 SLOT(leader_selected(int)));
629 connect(leader_name->lineEdit(), &QLineEdit::returnPressed,
632 SLOT(nationset_changed(int)));
633 connect(nation_tabs->selectionModel(),
635 const QItemSelection &)),
637
638 ok_button = new QPushButton;
639 ok_button->setText(_("Cancel"));
640 connect(ok_button, &QAbstractButton::pressed, this, &races_dialog::cancel_pressed);
641 main_layout->addWidget(ok_button, 8, 2, 1, 1);
642 random_button = new QPushButton;
643 random_button->setText(_("Random"));
644 connect(random_button, &QAbstractButton::pressed, this, &races_dialog::random_pressed);
645 main_layout->addWidget(random_button, 8, 0, 1, 1);
646 ok_button = new QPushButton;
647 ok_button->setText(_("Ok"));
648 connect(ok_button, &QAbstractButton::pressed, this, &races_dialog::ok_pressed);
649 main_layout->addWidget(ok_button, 8, 3, 1, 1);
650 main_layout->addWidget(no_name, 0, 3, 2, 1);
651 if (nation_set_count() > 1) {
652 main_layout->addWidget(ns_label, 0, 0, 1, 1);
653 main_layout->addWidget(qnation_set, 0, 1, 1, 1);
654 main_layout->addWidget(nation_tabs, 1, 0, 5, 2);
655 } else {
656 main_layout->addWidget(nation_tabs, 0, 0, 6, 2);
657 }
658 main_layout->addWidget(styles, 2, 3, 4, 1);
659 main_layout->addWidget(description, 6, 0, 2, 4);
660 main_layout->addWidget(selected_nation_tabs, 0, 2, 6, 1);
661
663 set_index(-99);
664
665 if (C_S_RUNNING == client_state()) {
666 title = _("Edit Nation");
667 } else if (pplayer != nullptr && pplayer == client_player()) {
668 title = _("What Nation Will You Be?");
669 } else {
670 title = _("Pick Nation");
671 }
672
675}
676
677/***********************************************************************/
684
685/***********************************************************************/
689{
690 struct nation_group *group;
692 QHeaderView *header;
693 int i;
694 int count;
695
696 nation_tabs->clearContents();
697 nation_tabs->setRowCount(0);
698 nation_tabs->insertRow(0);
700 item->setText(_("All nations"));
701 item->setData(Qt::UserRole, -99);
702 nation_tabs->setItem(0, 0, item);
703
704 for (i = 1; i < nation_group_count() + 1; i++) {
705 group = nation_group_by_number(i - 1);
706 if (is_nation_group_hidden(group)) {
707 continue;
708 }
709 count = 0;
710 // Checking if group is empty
711 nations_iterate(pnation) {
712 if (!is_nation_playable(pnation)
713 || !is_nation_pickable(pnation)
714 || !nation_is_in_group(pnation, group)) {
715 continue;
716 }
717 count ++;
719 if (count == 0) {
720 continue;
721 }
722 nation_tabs->insertRow(i);
724 item->setData(Qt::UserRole, i - 1);
725 item->setText(nation_group_name_translation(group));
726 nation_tabs->setItem(i, 0, item);
727 }
728 header = nation_tabs->horizontalHeader();
729 header->resizeSections(QHeaderView::Stretch);
730 header = nation_tabs->verticalHeader();
731 header->resizeSections(QHeaderView::ResizeToContents);
732 set_index(-99);
733}
734
735/***********************************************************************/
739{
740 struct option *popt;
741 struct nation_set *s;
742
744 if (popt) {
746 qnation_set->setCurrentIndex(nation_set_index(s));
747 qnation_set->setToolTip(_(nation_set_description(s)));
748 }
749}
750
751/***********************************************************************/
755{
756 QModelIndexList indexes = selected.indexes();
757 QModelIndex index ;
758
759 if (indexes.isEmpty()) {
760 return;
761 }
762
763 index = indexes.at(0);
764 set_index(index.row());
765}
766
767/***********************************************************************/
772{
774 QPixmap *pix;
775 QFont f;
776 struct nation_group *group;
777 int i;
778 struct sprite *s;
779 QHeaderView *header;
780 bool svg = is_svg_flag_enabled();
781
782 selected_nation_tabs->clearContents();
783 selected_nation_tabs->setRowCount(0);
784
785 last_index = 0;
786 i = nation_tabs->currentRow();
787 if (i != -1) {
788 item = nation_tabs->item(i, 0);
789 index = item->data(Qt::UserRole).toInt();
790 }
791
792 group = nation_group_by_number(index);
793 i = 0;
794 nations_iterate(pnation) {
795 if (!is_nation_playable(pnation)
796 || !is_nation_pickable(pnation)) {
797 continue;
798 }
799 if (!nation_is_in_group(pnation, group) && index != -99) {
800 continue;
801 }
803 selected_nation_tabs->insertRow(i);
804 s = get_nation_flag_sprite(tileset, pnation);
805 if (pnation->player) {
806 f = item->font();
807 f.setStrikeOut(true);
808 item->setFont(f);
809 }
810 pix = s->pm;
811 if (svg) {
812 item->setData(Qt::DecorationRole, (*pix).scaledToHeight(50));
813 } else {
814 item->setData(Qt::DecorationRole, *pix);
815 }
816 item->setData(Qt::UserRole, nation_number(pnation));
817 item->setText(nation_adjective_translation(pnation));
818 selected_nation_tabs->setItem(i, 0, item);
820
821 selected_nation_tabs->sortByColumn(0, Qt::AscendingOrder);
822 header = selected_nation_tabs->horizontalHeader();
823 header->resizeSections(QHeaderView::Stretch);
824 header = selected_nation_tabs->verticalHeader();
825 header->resizeSections(QHeaderView::ResizeToContents);
826}
827
828/***********************************************************************/
832{
833 char buf[4096];
834 QModelIndex index ;
836 QModelIndexList indexes = selected.indexes();
837 QString str;
839 int style, ind;
840
841 if (indexes.isEmpty()) {
842 return;
843 }
844
845 index = indexes.at(0);
846 if (indexes.isEmpty()) {
847 return;
848 }
849 qvar = index.data(Qt::UserRole);
850 selected_nation = qvar.toInt();
851
853 description->setPlainText(buf);
854 leader_name->clear();
855 if (client.conn.playing == tplayer) {
856 leader_name->addItem(client.conn.playing->name, true);
857 }
860 str = QString::fromUtf8(nation_leader_name(pleader));
863
864 // Select style for nation
865
867 qvar = qvar.fromValue<int>(style);
868
869 for (ind = 0; ind < styles->rowCount(); ind++) {
870 item = styles->item(ind, 0);
871
872 if (item->data(Qt::UserRole) == qvar) {
873 styles->selectRow(ind);
874 }
875 }
876}
877
878/***********************************************************************/
882{
883 QModelIndex index ;
885 QModelIndexList indexes = selected.indexes();
886
887 if (indexes.isEmpty()) {
888 return;
889 }
890
891 index = indexes.at(0);
892 qvar = index.data(Qt::UserRole);
893 selected_style = qvar.toInt();
894}
895
896/***********************************************************************/
900{
901 if (leader_name->itemData(index).toBool()) {
902 is_male->setChecked(true);
903 is_female->setChecked(false);
904 } else {
905 is_male->setChecked(false);
906 is_female->setChecked(true);
907 }
908}
909
910/***********************************************************************/
915{
917 struct player *natplr;
918
919 if (selected_nation == -1) {
920 return;
921 }
922
923 if (selected_style == -1) {
924 output_window_append(ftc_client, _("You must select your style."));
925 return;
926 }
927
928 if (leader_name->currentText().length() == 0) {
929 output_window_append(ftc_client, _("You must type a legal name."));
930 return;
931 }
932
934 if (natplr != nullptr && natplr != client_player()) {
936 _("Nation has been chosen by other player"));
937 return;
938 }
939
940 ln_bytes = leader_name->currentText().toUtf8();
942 selected_nation, sex_buttons->checkedId(),
943 ln_bytes.data(),
945 close();
946 deleteLater();
947}
948
949/***********************************************************************/
953 const char *lines, QWidget *parent)
954 : fcwidget()
955{
956 int x, y;
958
959 setAttribute(Qt::WA_DeleteOnClose);
960 setCursor(Qt::ArrowCursor);
962 setFrameStyle(QFrame::Box);
963 cw = new close_widget(this);
964 cw->put_to_corner();
965
969 qlist = qlines.split("\n");
970 small_font = *fc_font::instance()->get_font("gui_qt_font_notify_label");
971 x = 0;
972 y = 0;
973 calc_size(x, y);
974 resize(x, y);
975 gui()->mapview_wdg->find_place(gui()->mapview_wdg->width() - x - 4, 4,
976 x, y, x, y, 0);
977 move(x, y);
978 was_destroyed = false;
979
980}
981
982/***********************************************************************/
986{
987 QString s, q;
988 int i;
992
993 for (i = 0; i < qlist.size(); ++i) {
994 s = qlist.at(i);
995 q = q + s;
996 if (i < qlist.size() - 1) {
997 q = q + QChar('\n');
998 }
999 }
1000 capt_bytes = qcaption.toUtf8();
1001 hl_bytes = qheadline.toUtf8();
1002 qb_bytes = q.toUtf8();
1004 hl_bytes.data(),
1005 qb_bytes.data());
1006 close();
1007 destroy();
1008}
1009
1010/***********************************************************************/
1014{
1016 int i;
1017 QStringList str_list;
1018
1019 str_list = qlist;
1020 str_list << qcaption << qheadline;
1021
1022 for (i = 0; i < str_list.count(); i++) {
1023 x = qMax(x, fm.horizontalAdvance(str_list.at(i)));
1024 y = y + 3 + fm.height();
1025 }
1026 x = x + 15;
1027}
1028
1029/***********************************************************************/
1033{
1034 QPainter painter(this);
1035 QPainterPath path;
1036 QPen pen;
1038 int i;
1039
1040 pen.setWidth(1);
1041 pen.setColor(palette().color(QPalette::Text));
1042 painter.setFont(small_font);
1043 painter.setPen(pen);
1044 painter.drawText(10, fm.height() + 3, qcaption);
1045 painter.drawText(10, 2 * fm.height() + 6, qheadline);
1046 for (i = 0; i < qlist.count(); i++) {
1047 painter.drawText(10, 3 + (fm.height() + 3) * (i + 3), qlist[i]);
1048 }
1049 cw->put_to_corner();
1050}
1051
1052/***********************************************************************/
1056{
1057 cursor = event->globalPosition().toPoint() - geometry().topLeft();
1058
1059 if (event->button() == Qt::RightButton) {
1060 was_destroyed = true;
1061 close();
1062 }
1063}
1064
1065/***********************************************************************/
1069{
1070 move(event->globalPosition().toPoint() - cursor);
1071
1072 setCursor(Qt::SizeAllCursor);
1073}
1074
1075/***********************************************************************/
1079{
1080 setCursor(Qt::ArrowCursor);
1081}
1082
1083/***********************************************************************/
1087{
1088 was_destroyed = true;
1089 destroy();
1090}
1091
1092/***********************************************************************/
1098{
1099 was_destroyed = true;
1100 destroy();
1101}
1102
1103/***********************************************************************/
1107{
1108 vs_city = -1;
1109 vs_unit = -1;
1110}
1111
1112/***********************************************************************/
1116{
1117 if (!m_instance) {
1118 m_instance = new qdef_act;
1119 }
1120 return m_instance;
1121}
1122
1123/***********************************************************************/
1127{
1128 if (m_instance) {
1129 delete m_instance;
1130 m_instance = 0;
1131 }
1132}
1133
1134/***********************************************************************/
1138{
1139 vs_city = i;
1140}
1141
1142/***********************************************************************/
1146{
1147 vs_unit = i;
1148}
1149
1150/***********************************************************************/
1154{
1155 return vs_city;
1156}
1157
1158/***********************************************************************/
1162{
1163 return vs_unit;
1164}
1165
1166/***********************************************************************/
1170{
1171 delete this;
1172}
1173
1174/***********************************************************************/
1178{
1180 false, "", 0);
1181 delete this;
1182}
1183
1184/***********************************************************************/
1187notify_goto::notify_goto(const char *headline, const char *lines,
1188 const struct text_tag_list *tags, tile *ptile,
1189 QWidget *parent): QMessageBox(parent)
1190{
1192 setAttribute(Qt::WA_DeleteOnClose);
1193 goto_but = this->addButton(_("Goto Location"), QMessageBox::ActionRole);
1194 goto_but->setIcon(fc_icons::instance()->get_icon("go-up"));
1195 inspect_but = this->addButton(_("Inspect City"), QMessageBox::ActionRole);
1196 inspect_but->setIcon(fc_icons::instance()->get_icon("plus"));
1197
1198 close_but = this->addButton(QMessageBox::Close);
1199 gtile = ptile;
1200 if (!gtile) {
1201 goto_but->setVisible(false);
1202 inspect_but->setVisible(false);
1203 } else {
1204 struct city *pcity = tile_city(gtile);
1205 inspect_but->setVisible(pcity != nullptr
1207 }
1209 qlines = lines;
1210 qlines.replace("\n", " ");
1211 setText(qlines);
1212 connect(goto_but, &QAbstractButton::pressed, this, &notify_goto::goto_tile);
1213 connect(inspect_but, &QAbstractButton::pressed, this, &notify_goto::inspect_city);
1214 connect(close_but, &QAbstractButton::pressed, this, &QWidget::close);
1215 show();
1216}
1217
1218/***********************************************************************/
1222{
1224 close();
1225}
1226
1227/***********************************************************************/
1231{
1232 struct city *pcity = tile_city(gtile);
1233 if (pcity) {
1235 }
1236 close();
1237}
1238
1239/***********************************************************************/
1243{
1244 QString rule_name;
1246 const char *rn;
1247 struct option *poption = optset_option_by_name(server_optset, "nationset");
1248
1249 rule_name = qnation_set->currentData().toString();
1250 rn_bytes = rule_name.toUtf8(); /* Hold QByteArray in a variable to
1251 * extend its, and data() buffer's,
1252 * lifetime */
1253 rn = rn_bytes.data();
1257 }
1258}
1259
1260/***********************************************************************/
1265void popup_notify_goto_dialog(const char *headline, const char *lines,
1266 const struct text_tag_list *tags,
1267 struct tile *ptile)
1268{
1269 notify_goto *ask = new notify_goto(headline, lines, tags, ptile,
1270 gui()->central_wdg);
1271 ask->show();
1272}
1273
1274/***********************************************************************/
1277void popup_connect_msg(const char *headline, const char *message)
1278{
1279 QMessageBox *msg = new QMessageBox(gui()->central_wdg);
1280
1281 msg->setText(message);
1282 msg->setStandardButtons(QMessageBox::Ok);
1283 msg->setWindowTitle(headline);
1284 msg->setAttribute(Qt::WA_DeleteOnClose);
1285 msg->show();
1286}
1287
1288/***********************************************************************/
1291void popup_notify_dialog(const char *caption, const char *headline,
1292 const char *lines)
1293{
1295 gui()->mapview_wdg);
1296 nd->show();
1297}
1298
1299/***********************************************************************/
1302void popup_races_dialog(struct player *pplayer)
1303{
1304 if (!is_race_dialog_open) {
1305 race_dialog = new races_dialog(pplayer, gui()->central_wdg);
1306 is_race_dialog_open = true;
1307 race_dialog->show();
1308 }
1309 race_dialog->showNormal();
1310}
1311
1312/***********************************************************************/
1317{
1318 if (is_race_dialog_open) {
1319 race_dialog->close();
1320 is_race_dialog_open = false;
1321 }
1322}
1323
1324/***********************************************************************/
1328{
1329 if (ptile != nullptr
1330 && (unit_list_size(ptile->units) > 1
1331 || (unit_list_size(ptile->units) == 1 && tile_city(ptile)))) {
1332 gui()->toggle_unit_sel_widget(ptile);
1333 }
1334}
1335
1336/***********************************************************************/
1340{
1341 gui()->update_unit_sel();
1342}
1343
1344/***********************************************************************/
1353
1354/***********************************************************************/
1357void races_update_pickable(bool nationset_change)
1358{
1359 if (is_race_dialog_open) {
1361 }
1362}
1363
1364/***********************************************************************/
1369{
1370 if (is_race_dialog_open) {
1372 }
1373}
1374
1375/***********************************************************************/
1379{
1382 = (gov != nullptr ? government_number(gov) : G_LAST);
1383
1385 ask = new hud_message_box(gui()->central_wdg);
1386 ask->setStandardButtons(QMessageBox::Cancel | QMessageBox::Ok);
1387 ask->setDefaultButton(QMessageBox::Cancel);
1388 ask->set_text_title(_("You say you wanna revolution?"),
1389 _("Revolution!"));
1390 ask->setAttribute(Qt::WA_DeleteOnClose);
1391 QObject::connect(ask, &hud_message_box::accepted, [=]() {
1392 if (government_id == G_LAST) {
1393 revolution_response(nullptr);
1394 } else {
1396
1397 if (government) {
1399 }
1400 }
1401 });
1402 ask->show();
1403 } else {
1405 }
1406}
1407
1408/***********************************************************************/
1421
1422/***********************************************************************/
1429
1430/***********************************************************************/
1438
1439/***********************************************************************/
1447
1448/***********************************************************************/
1455
1456/***********************************************************************/
1463
1464/***********************************************************************/
1468 QWidget *parent,
1469 void (*run_on_close_in)(int)): QWidget(parent)
1470{
1471 QLabel *l = new QLabel(text);
1472
1473 setProperty("themed_choice", true);
1474 layout = new QVBoxLayout(this);
1476
1477 layout->addWidget(l);
1478 setWindowFlags(Qt::Dialog);
1480 setAttribute(Qt::WA_DeleteOnClose);
1481 gui()->set_diplo_dialog(this);
1482
1495
1496 targeted_unit = nullptr;
1497 // No buttons are added yet.
1498 for (int i = 0; i < BUTTON_COUNT; i++) {
1499 action_button_map << nullptr;
1500 }
1501}
1502
1503/***********************************************************************/
1507{
1508 buttons_list.clear();
1509 action_button_map.clear();
1510 gui()->set_diplo_dialog(nullptr);
1511
1512 if (run_on_close) {
1514 run_on_close = nullptr;
1515 }
1516}
1517
1518/***********************************************************************/
1522{
1524
1527 struct canvas *pix;
1528 QPushButton *next, *prev;
1529 unit_skip = new QHBoxLayout;
1530 next = new QPushButton();
1531 next->setIcon(fc_icons::instance()->get_icon("city-right"));
1532 next->setIconSize(QSize(32, 32));
1533 next->setFixedSize(QSize(36, 36));
1534 prev = new QPushButton();
1535 prev->setIcon(fc_icons::instance()->get_icon("city-left"));
1536 prev->setIconSize(QSize(32, 32));
1537 prev->setFixedSize(QSize(36, 36));
1538 target_unit_button = new QPushButton;
1541 pix->map_pixmap.fill(Qt::transparent);
1542 put_unit(targeted_unit, pix, 1.0, 0, 0);
1543 target_unit_button->setIcon(QIcon(pix->map_pixmap));
1544 qtg_canvas_free(pix);
1545 target_unit_button->setIconSize(QSize(96, 96));
1546 target_unit_button->setFixedSize(QSize(100, 100));
1547 unit_skip->addStretch(100);
1548 unit_skip->addWidget(prev, Qt::AlignCenter);
1549 unit_skip->addWidget(target_unit_button, Qt::AlignCenter);
1550 unit_skip->addWidget(next, Qt::AlignCenter);
1551 layout->addLayout(unit_skip);
1552 unit_skip->addStretch(100);
1553 connect(prev, &QAbstractButton::clicked, this, &choice_dialog::prev_unit);
1554 connect(next, &QAbstractButton::clicked, this, &choice_dialog::next_unit);
1555 }
1556
1558}
1559
1560/***********************************************************************/
1564 QVariant data2, QString tool_tip = "",
1565 const int button_id = -1)
1566{
1568 data1, data2);
1569 int action = buttons_list.count();
1570
1571 QObject::connect(button, &QPushButton::clicked,
1574 });
1575
1576 buttons_list.append(button);
1577
1578 if (!tool_tip.isEmpty()) {
1579 button->setToolTip(tool_tip);
1580 }
1581
1582 if (0 <= button_id) {
1583 // The id is valid.
1584 action_button_map[button_id] = button;
1585 }
1586
1587 layout->addWidget(button);
1588}
1589
1590/***********************************************************************/
1594{
1595 QPoint p;
1596
1597 p = mapFromGlobal(QCursor::pos());
1598 p.setY(p.y()-this->height());
1599 p.setX(p.x()-this->width());
1600 move(p);
1601 show();
1602}
1603
1604/***********************************************************************/
1611
1612/***********************************************************************/
1616{
1617 if (id < 0) {
1618 fc_assert_msg(0 <= id, "Invalid button ID.");
1619 return nullptr;
1620 }
1621
1622 return action_button_map[id];
1623}
1624
1625/***********************************************************************/
1629{
1632
1634 if (action == -1) {
1635 return false;
1636 }
1637 func = af_map[action];
1638
1639 func(q1, q2);
1640 return true;
1641}
1642
1643/***********************************************************************/
1647{
1650
1652 if (action == -1) {
1653 return false;
1654 }
1655 func = af_map[action];
1656 func(q1, q2);
1657 return true;
1658}
1659
1660/***********************************************************************/
1664{
1665 struct tile *ptile;
1666 struct unit *new_target = nullptr;
1667 bool break_next = false;
1668 bool first = true;
1669 struct canvas *pix;
1670
1671 if (targeted_unit == nullptr) {
1672 return;
1673 }
1674
1675 ptile = targeted_unit->tile;
1676
1677 unit_list_iterate(ptile->units, ptgt) {
1678 if (first) {
1679 new_target = ptgt;
1680 first = false;
1681 }
1682 if (break_next) {
1683 new_target = ptgt;
1684 break;
1685 }
1686 if (ptgt == targeted_unit) {
1687 break_next = true;
1688 }
1693 pix->map_pixmap.fill(Qt::transparent);
1694 put_unit(targeted_unit, pix, 1.0, 0, 0);
1695 target_unit_button->setIcon(QIcon(pix->map_pixmap));
1696 qtg_canvas_free(pix);
1697 switch_target();
1698}
1699
1700/***********************************************************************/
1704{
1705 struct tile *ptile;
1706 struct unit *new_target = nullptr;
1707 struct canvas *pix;
1708 if (targeted_unit == nullptr) {
1709 return;
1710 }
1711
1712 ptile = targeted_unit->tile;
1713 unit_list_iterate(ptile->units, ptgt) {
1714 if ((ptgt == targeted_unit) && new_target != nullptr) {
1715 break;
1716 }
1717 new_target = ptgt;
1722 pix->map_pixmap.fill(Qt::transparent);
1723 put_unit(targeted_unit, pix, 1.0, 0, 0);
1724 target_unit_button->setIcon(QIcon(pix->map_pixmap));
1725 qtg_canvas_free(pix);
1726 switch_target();
1727}
1728
1729/***********************************************************************/
1733{
1734 if (targeted_unit == nullptr) {
1735 return;
1736 }
1737 unit_skip->setParent(nullptr);
1742 : nullptr),
1743 act_probs);
1744 layout->addLayout(unit_skip);
1745}
1746
1747/***********************************************************************/
1751{
1752 if (targeted_unit == nullptr) {
1753 return;
1754 }
1755
1756 unit_skip->setParent(nullptr);
1758 unit_id,
1763 layout->addLayout(unit_skip);
1764}
1765
1766/***********************************************************************/
1770{
1772 pfcn_void func = button->getFunc();
1773
1774 func(button->getData1(), button->getData2());
1775 close();
1776}
1777
1778/***********************************************************************/
1787{
1788 // Store the data in the stack.
1789 last_buttons_stack.append(button);
1790
1791 /* Temporary remove the button so it will end up below buttons added
1792 * before unstack_all_buttons() is called. */
1793 layout->removeWidget(button);
1794
1795 // Synchronize the list with the layout.
1796 buttons_list.removeAll(button);
1797}
1798
1799/***********************************************************************/
1804{
1805 while (!last_buttons_stack.isEmpty()) {
1806 Choice_dialog_button *button = last_buttons_stack.takeLast();
1807
1808 // Reinsert the button below the other buttons.
1809 buttons_list.append(button);
1810 layout->addWidget(button);
1811 }
1812}
1813
1814/***********************************************************************/
1817static void caravan_marketplace(QVariant data1, QVariant data2)
1818{
1819 int actor_unit_id = data1.toInt();
1820 int target_city_id = data2.toInt();
1821
1822 if (game_unit_by_number(actor_unit_id) != nullptr
1823 && game_city_by_number(target_city_id) != nullptr) {
1825 target_city_id, 0, "");
1826 }
1827}
1828
1829/***********************************************************************/
1833{
1834 int actor_unit_id = data1.toInt();
1835 int target_city_id = data2.toInt();
1836
1837 if (game_unit_by_number(actor_unit_id) != nullptr
1838 && game_city_by_number(target_city_id) != nullptr) {
1840 target_city_id, 0, "");
1841 }
1842}
1843
1844/***********************************************************************/
1847static void caravan_help_build(QVariant data1, QVariant data2)
1848{
1849 int caravan_id = data1.toInt();
1850 int caravan_target_id = data2.toInt();
1851
1852 if (game_unit_by_number(caravan_id) != nullptr
1853 && game_city_by_number(caravan_target_id) != nullptr) {
1856 }
1857}
1858
1859/***********************************************************************/
1862static void unit_disband_recover(QVariant data1, QVariant data2)
1863{
1864 int actor_id = data1.toInt();
1865 int tgt_city_id = data2.toInt();
1866
1867 if (game_unit_by_number(actor_id) != nullptr
1868 && game_city_by_number(tgt_city_id) != nullptr) {
1870 actor_id, tgt_city_id, 0, "");
1871 }
1872}
1873
1874/***********************************************************************/
1877static void unit_home_city(QVariant data1, QVariant data2)
1878{
1879 int actor_id = data1.toInt();
1880 int tgt_city_id = data2.toInt();
1881
1882 if (game_unit_by_number(actor_id) != nullptr
1883 && game_city_by_number(tgt_city_id) != nullptr) {
1885 actor_id, tgt_city_id, 0, "");
1886 }
1887}
1888
1889/***********************************************************************/
1892static void unit_upgrade(QVariant data1, QVariant data2)
1893{
1894 struct unit *punit;
1895
1896 int actor_id = data1.toInt();
1897 int tgt_city_id = data2.toInt();
1898
1899 if ((punit = game_unit_by_number(actor_id)) != nullptr
1900 && game_city_by_number(tgt_city_id) != nullptr) {
1901 struct unit_list *as_list;
1902
1907 }
1908}
1909
1910/***********************************************************************/
1913static void airlift(QVariant data1, QVariant data2)
1914{
1915 int actor_id = data1.toInt();
1916 int tgt_city_id = data2.toInt();
1917
1918 if (game_unit_by_number(actor_id) != nullptr
1919 && game_city_by_number(tgt_city_id) != nullptr) {
1921 actor_id, tgt_city_id, 0, "");
1922 }
1923}
1924
1925/***********************************************************************/
1928static void conquer_city_shrink(QVariant data1, QVariant data2)
1929{
1930 int actor_id = data1.toInt();
1931 int tgt_city_id = data2.toInt();
1932
1933 if (game_unit_by_number(actor_id) != nullptr
1934 && game_city_by_number(tgt_city_id) != nullptr) {
1936 actor_id, tgt_city_id, 0, "");
1937 }
1938}
1939
1940/***********************************************************************/
1943static void conquer_city_shrink2(QVariant data1, QVariant data2)
1944{
1945 int actor_id = data1.toInt();
1946 int tgt_city_id = data2.toInt();
1947
1948 if (game_unit_by_number(actor_id) != nullptr
1949 && game_city_by_number(tgt_city_id) != nullptr) {
1951 actor_id, tgt_city_id, 0, "");
1952 }
1953}
1954
1955/***********************************************************************/
1958static void conquer_city_shrink3(QVariant data1, QVariant data2)
1959{
1960 int actor_id = data1.toInt();
1961 int tgt_city_id = data2.toInt();
1962
1963 if (game_unit_by_number(actor_id) != nullptr
1964 && game_city_by_number(tgt_city_id) != nullptr) {
1966 actor_id, tgt_city_id, 0, "");
1967 }
1968}
1969
1970/***********************************************************************/
1973static void conquer_city_shrink4(QVariant data1, QVariant data2)
1974{
1975 int actor_id = data1.toInt();
1976 int tgt_city_id = data2.toInt();
1977
1978 if (game_unit_by_number(actor_id) != nullptr
1979 && game_city_by_number(tgt_city_id) != nullptr) {
1981 actor_id, tgt_city_id, 0, "");
1982 }
1983}
1984
1985/***********************************************************************/
1988static void conquer_extras(QVariant data1, QVariant data2)
1989{
1990 int actor_id = data1.toInt();
1991 int target_id = data2.toInt();
1992
1993 if (game_unit_by_number(actor_id) != nullptr) {
1995 actor_id, target_id, 0, "");
1996 }
1997}
1998
1999/***********************************************************************/
2002static void conquer_extras2(QVariant data1, QVariant data2)
2003{
2004 int actor_id = data1.toInt();
2005 int target_id = data2.toInt();
2006
2007 if (game_unit_by_number(actor_id) != nullptr) {
2009 actor_id, target_id, 0, "");
2010 }
2011}
2012
2013/***********************************************************************/
2016static void conquer_extras3(QVariant data1, QVariant data2)
2017{
2018 int actor_id = data1.toInt();
2019 int target_id = data2.toInt();
2020
2021 if (game_unit_by_number(actor_id) != nullptr) {
2023 actor_id, target_id, 0, "");
2024 }
2025}
2026
2027/***********************************************************************/
2030static void conquer_extras4(QVariant data1, QVariant data2)
2031{
2032 int actor_id = data1.toInt();
2033 int target_id = data2.toInt();
2034
2035 if (game_unit_by_number(actor_id) != nullptr) {
2037 actor_id, target_id, 0, "");
2038 }
2039}
2040
2041/***********************************************************************/
2044static void act_sel_wait(QVariant data1, QVariant data2)
2045{
2046 key_unit_wait();
2047}
2048
2049/***********************************************************************/
2052static void keep_moving(QVariant data1, QVariant data2)
2053{
2054}
2055
2056/***********************************************************************/
2060{
2061 if (!gov) {
2063 } else {
2065 }
2066}
2067
2068/***********************************************************************/
2073{
2075 /* The client isn't waiting for information for any unanswered follow
2076 * up questions. */
2077
2078 struct unit *actor_unit;
2079
2081 /* The action selection dialog wasn't closed because the actor unit
2082 * was lost. */
2083
2084 // The probabilities didn't just disappear, right?
2087
2089 }
2090
2091 // The action selection process is over, at least for now.
2093
2094 if (did_not_decide) {
2095 /* The action selection dialog was closed but the player didn't
2096 * decide what the unit should do. */
2097
2098 // Reset so the next action selection dialog does the right thing.
2099 did_not_decide = false;
2100 } else {
2101 // An action, or no action at all, was selected.
2104 }
2105 }
2106}
2107
2108/***********************************************************************/
2112static void diplomat_queue_handle_secondary(int actor_id)
2113{
2114 // Stop waiting. Move on to the next queued unit.
2117}
2118
2119/**********************************************************************/
2126{
2127 // Stop assuming the answer to a follow up question will arrive.
2129}
2130
2131/***********************************************************************/
2136 struct city *target_city,
2137 struct unit *target_unit,
2138 struct tile *target_tile,
2139 struct extra_type *target_extra,
2140 const struct act_prob *act_probs)
2141{
2142 struct astring title = ASTRING_INIT, text = ASTRING_INIT;
2144 qtiles caras;
2145 QVariant qv1, qv2;
2147 struct city *actor_homecity;
2150
2153
2154 foreach (caras, gui()->trade_gen.lines) {
2155 if (caras.autocaravan == actor_unit) {
2156 int i;
2157
2158 if (game_unit_by_number(actor_unit->id) != nullptr
2159 && game_city_by_number(target_city->id) != nullptr) {
2161 target_city->id, 0, "");
2164 i = gui()->trade_gen.lines.indexOf(caras);
2165 gui()->trade_gen.lines.takeAt(i);
2166
2167 return;
2168 }
2169 }
2170 }
2171 if (target_city
2175
2176 return;
2177 }
2178
2179 if (target_unit
2183
2184 return;
2185 }
2186 /* Could be caused by the server failing to reply to a request for more
2187 * information or a bug in the client code. */
2189 "Diplomat queue problem. Is another diplomat window open?");
2190
2191 // No extra input is required as no action has been chosen yet.
2193
2195
2196 astr_set(&title,
2197 // TRANS: %s is a unit name, e.g., Spy
2198 _("Choose Your %s's Strategy"),
2200
2201 if (target_city != nullptr && actor_homecity != nullptr) {
2202 astr_set(&text,
2203 _("Your %s from %s reaches the city of %s.\nWhat now?"),
2207 } else if (target_city != nullptr) {
2208 astr_set(&text,
2209 _("Your %s has arrived at %s.\nWhat is your command?"),
2212 } else if (target_unit != nullptr) {
2214
2215 if (owner != nullptr) {
2216 astr_set(&text,
2217 // TRANS: Your Spy is ready to act against Roman Freight.
2218 _("Your %s is ready to act against %s %s."),
2222 } else {
2223 // Flagless target
2224 astr_set(&text,
2225 // TRANS: Your Spy is ready to act against Freight.
2226 _("Your %s is ready to act against %s."),
2229 }
2230 } else {
2231 fc_assert_msg(target_unit != nullptr
2232 || target_city != nullptr
2233 || target_tile != nullptr,
2234 "No target specified.");
2235
2236 astr_set(&text,
2237 // TRANS: %s is a unit name, e.g., Diplomat, Spy
2238 _("Your %s is waiting for your command."),
2240 }
2241
2242 cd = gui()->get_diplo_dialog();
2243 if ((cd != nullptr) && cd->targeted_unit != nullptr) {
2244 cd->update_dialog(act_probs);
2245 return;
2246 }
2247 cd = new choice_dialog(astr_str(&title), astr_str(&text),
2248 gui()->game_tab_widget,
2250 qv1 = actor_unit->id;
2251
2252 cd->unit_id = actor_unit->id;
2253
2254 cd->target_id[ATK_SELF] = cd->unit_id;
2255
2256 if (target_city) {
2257 cd->target_id[ATK_CITY] = target_city->id;
2258 } else {
2259 cd->target_id[ATK_CITY] = IDENTITY_NUMBER_ZERO;
2260 }
2261
2262 if (target_unit) {
2263 cd->target_id[ATK_UNIT] = target_unit->id;
2264 } else {
2265 cd->target_id[ATK_UNIT] = IDENTITY_NUMBER_ZERO;
2266 }
2267
2268 if (target_tile) {
2269 cd->target_id[ATK_STACK] = tile_index(target_tile);
2270 } else {
2271 cd->target_id[ATK_STACK] = TILE_INDEX_NONE;
2272 }
2273
2274 if (target_tile) {
2275 cd->target_id[ATK_TILE] = tile_index(target_tile);
2276 } else {
2277 cd->target_id[ATK_TILE] = TILE_INDEX_NONE;
2278 }
2279
2280 if (target_tile) {
2281 cd->target_id[ATK_EXTRAS] = tile_index(target_tile);
2282 } else {
2283 cd->target_id[ATK_EXTRAS] = TILE_INDEX_NONE;
2284 }
2285
2286 // No target building or target tech supplied. (Feb 2020)
2287 cd->sub_target_id[ASTK_BUILDING] = B_LAST;
2288 cd->sub_target_id[ASTK_TECH] = A_UNSET;
2289
2290 if (target_extra) {
2291 cd->sub_target_id[ASTK_EXTRA] = extra_number(target_extra);
2293 } else {
2294 cd->sub_target_id[ASTK_EXTRA] = EXTRA_NONE;
2295 cd->sub_target_id[ASTK_EXTRA_NOT_THERE] = EXTRA_NONE;
2296 }
2297
2298 // Unit acting against a city
2299
2300 // Set the correct target for the following actions.
2301 qv2 = cd->target_id[ATK_CITY];
2302
2303 action_iterate(act) {
2308 act_probs[act],
2309 actor_unit,
2310 target_city),
2311 qv1, qv2);
2312 }
2314
2315 // Unit acting against another unit
2316
2317 // Set the correct target for the following actions.
2318 qv2 = cd->target_id[ATK_UNIT];
2319
2320 action_iterate(act) {
2325 act_probs[act],
2326 actor_unit,
2327 target_city),
2328 qv1, qv2);
2329 }
2331
2332 // Unit acting against all units at a tile
2333
2334 // Set the correct target for the following actions.
2335 qv2 = cd->target_id[ATK_STACK];
2336
2337 action_iterate(act) {
2342 act_probs[act],
2343 actor_unit,
2344 target_city),
2345 qv1, qv2);
2346 }
2348
2349 // Unit acting against a tile.
2350
2351 // Set the correct target for the following actions.
2352 qv2 = cd->target_id[ATK_TILE];
2353
2354 action_iterate(act) {
2359 act_probs[act],
2360 actor_unit,
2361 target_city),
2362 qv1, qv2);
2363 }
2365
2366 // Unit acting against a tile's extras.
2367
2368 // Set the correct target for the following actions.
2369 qv2 = cd->target_id[ATK_EXTRAS];
2370
2371 action_iterate(act) {
2376 act_probs[act],
2377 actor_unit,
2378 target_city),
2379 qv1, qv2);
2380 }
2382
2383 // Unit acting against itself
2384
2385 // Set the correct target for the following actions.
2386 qv2 = cd->target_id[ATK_SELF];
2387
2388 action_iterate(act) {
2393 act_probs[act],
2394 actor_unit,
2395 target_city),
2396 qv1, qv2);
2397 }
2399
2401 cd->add_item(QString(_("&Wait")), func, qv1, qv2,
2402 "", BUTTON_WAIT);
2403
2404 func = keep_moving;
2405 cd->add_item(QString(_("Do nothing")), func, qv1, qv2,
2406 "", BUTTON_CANCEL);
2407
2408 cd->set_layout();
2409 cd->show_me();
2410
2411 // Give follow up questions access to action probabilities.
2413 action_iterate(act) {
2416
2417 astr_free(&title);
2418 astr_free(&text);
2419}
2420
2421/***********************************************************************/
2426{
2427 /* Don't add an action mapping here unless the non targeted version is
2428 * selectable in the targeted version's target selection dialog. */
2429 switch ((enum gen_action)tgt_action_id) {
2435 return ACTION_SPY_STEAL_TECH;
2438 default:
2439 // No non targeted version found.
2440 return ACTION_NONE;
2441 }
2442}
2443
2444/**********************************************************************/
2449{
2450 /* Don't add an action mapping here unless the non targeted version is
2451 * selectable in the targeted version's target selection dialog. */
2452 switch ((enum gen_action)tgt_action_id) {
2459 default:
2460 // No non targeted version found.
2461 return ACTION_NONE;
2462 }
2463}
2464
2465/***********************************************************************/
2469 action_id act,
2470 const struct act_prob *act_probs,
2471 const char *custom,
2472 QVariant data1, QVariant data2)
2473{
2474 QString title;
2476
2477 if (!af_map.contains(act)) {
2478 /* The Qt client doesn't support ordering this action from the
2479 * action selection dialog. */
2480 return;
2481 }
2482
2483 // Don't show disabled actions.
2484 if (!action_prob_possible(act_probs[act])) {
2485 return;
2486 }
2487
2489 act_probs[act],
2490 custom));
2491
2493 act_probs[act]));
2494
2495 cd->add_item(title, af_map[act], data1, data2, tool_tip, act);
2496}
2497
2498/***********************************************************************/
2502 action_id act,
2503 const struct act_prob *act_probs,
2504 const char *custom,
2505 QVariant data1, QVariant data2)
2506{
2507 QString title;
2509
2510 /* An action that just became impossible has its button disabled.
2511 * An action that became possible again must be re-enabled. */
2512 button->setEnabled(action_prob_possible(act_probs[act]));
2513 button->setData1(data1);
2514 button->setData2(data2);
2515 // The probability may have changed.
2517 act_probs[act],
2518 custom));
2519
2521 act_probs[act]));
2522
2523 button->setText(title);
2524 button->setToolTip(tool_tip);
2525}
2526
2527/***********************************************************************/
2530static void disband_unit(QVariant data1, QVariant data2)
2531{
2532 int actor_id = data1.toInt();
2533 int target_id = data2.toInt();
2534
2536 target_id, 0, "");
2537}
2538
2539/***********************************************************************/
2542static void fortify(QVariant data1, QVariant data2)
2543{
2544 int actor_id = data1.toInt();
2545 int target_id = data2.toInt();
2546
2547 if (game_unit_by_number(actor_id) != nullptr) {
2549 target_id, 0, "");
2550 }
2551}
2552
2553/***********************************************************************/
2556static void fortify2(QVariant data1, QVariant data2)
2557{
2558 int actor_id = data1.toInt();
2559 int target_id = data2.toInt();
2560
2561 if (game_unit_by_number(actor_id) != nullptr) {
2563 target_id, 0, "");
2564 }
2565}
2566
2567/***********************************************************************/
2570static void convert_unit(QVariant data1, QVariant data2)
2571{
2572 int actor_id = data1.toInt();
2573 int target_id = data2.toInt();
2574
2576 target_id, 0, "");
2577}
2578
2579/***********************************************************************/
2582static void homeless(QVariant data1, QVariant data2)
2583{
2584 int actor_id = data1.toInt();
2585 int target_id = data2.toInt();
2586
2587 if (game_unit_by_number(actor_id) != nullptr) {
2589 target_id, 0, "");
2590 }
2591}
2592
2593/***********************************************************************/
2596static void diplomat_bribe_unit(QVariant data1, QVariant data2)
2597{
2598 int diplomat_id = data1.toInt();
2599 int diplomat_target_id = data2.toInt();
2600
2601 if (game_unit_by_number(diplomat_id) != nullptr
2602 && game_unit_by_number(diplomat_target_id) != nullptr) {
2603 // Wait for the server's reply before moving on to the next queued diplomat.
2605
2608 }
2609}
2610
2611/***********************************************************************/
2614static void diplomat_bribe_stack(QVariant data1, QVariant data2)
2615{
2616 int diplomat_id = data1.toInt();
2617 int diplomat_target_id = data2.toInt();
2618
2619 if (game_unit_by_number(diplomat_id) != nullptr) {
2620 // Wait for the server's reply before moving on to the next queued diplomat.
2622
2625 }
2626}
2627
2628/***********************************************************************/
2631static void spy_sabotage_unit(QVariant data1, QVariant data2)
2632{
2633 int diplomat_id = data1.toInt();
2634 int diplomat_target_id = data2.toInt();
2635
2637 diplomat_target_id, 0, "");
2638}
2639
2640/***********************************************************************/
2643static void spy_sabotage_unit_esc(QVariant data1, QVariant data2)
2644{
2645 int diplomat_id = data1.toInt();
2646 int diplomat_target_id = data2.toInt();
2647
2649 diplomat_target_id, 0, "");
2650}
2651
2652/***********************************************************************/
2655static void heal_unit(QVariant data1, QVariant data2)
2656{
2657 int actor_id = data1.toInt();
2658 int target_id = data2.toInt();
2659
2660 request_do_action(ACTION_HEAL_UNIT, actor_id, target_id, 0, "");
2661}
2662
2663/***********************************************************************/
2666static void heal_unit2(QVariant data1, QVariant data2)
2667{
2668 int actor_id = data1.toInt();
2669 int target_id = data2.toInt();
2670
2671 request_do_action(ACTION_HEAL_UNIT2, actor_id, target_id, 0, "");
2672}
2673
2674/***********************************************************************/
2677static void transport_board(QVariant data1, QVariant data2)
2678{
2679 int actor_id = data1.toInt();
2680 int target_id = data2.toInt();
2681
2682 request_do_action(ACTION_TRANSPORT_BOARD, actor_id, target_id, 0, "");
2683}
2684
2685/***********************************************************************/
2688static void transport_board2(QVariant data1, QVariant data2)
2689{
2690 int actor_id = data1.toInt();
2691 int target_id = data2.toInt();
2692
2693 request_do_action(ACTION_TRANSPORT_BOARD2, actor_id, target_id, 0, "");
2694}
2695
2696/***********************************************************************/
2699static void transport_board3(QVariant data1, QVariant data2)
2700{
2701 int actor_id = data1.toInt();
2702 int target_id = data2.toInt();
2703
2704 request_do_action(ACTION_TRANSPORT_BOARD3, actor_id, target_id, 0, "");
2705}
2706
2707/***********************************************************************/
2710static void transport_embark(QVariant data1, QVariant data2)
2711{
2712 int actor_id = data1.toInt();
2713 int target_id = data2.toInt();
2714
2715 request_do_action(ACTION_TRANSPORT_EMBARK, actor_id, target_id, 0, "");
2716}
2717
2718/***********************************************************************/
2721static void transport_embark2(QVariant data1, QVariant data2)
2722{
2723 int actor_id = data1.toInt();
2724 int target_id = data2.toInt();
2725
2726 request_do_action(ACTION_TRANSPORT_EMBARK2, actor_id, target_id, 0, "");
2727}
2728
2729/***********************************************************************/
2732static void transport_embark3(QVariant data1, QVariant data2)
2733{
2734 int actor_id = data1.toInt();
2735 int target_id = data2.toInt();
2736
2737 request_do_action(ACTION_TRANSPORT_EMBARK3, actor_id, target_id, 0, "");
2738}
2739
2740/***********************************************************************/
2743static void transport_embark4(QVariant data1, QVariant data2)
2744{
2745 int actor_id = data1.toInt();
2746 int target_id = data2.toInt();
2747
2748 request_do_action(ACTION_TRANSPORT_EMBARK4, actor_id, target_id, 0, "");
2749}
2750
2751/***********************************************************************/
2754static void transport_unload(QVariant data1, QVariant data2)
2755{
2756 int actor_id = data1.toInt();
2757 int target_id = data2.toInt();
2758
2759 request_do_action(ACTION_TRANSPORT_UNLOAD, actor_id, target_id, 0, "");
2760}
2761
2762/***********************************************************************/
2765static void transport_load(QVariant data1, QVariant data2)
2766{
2767 int actor_id = data1.toInt();
2768 int target_id = data2.toInt();
2769
2770 request_do_action(ACTION_TRANSPORT_LOAD, actor_id, target_id, 0, "");
2771}
2772
2773/***********************************************************************/
2776static void transport_load2(QVariant data1, QVariant data2)
2777{
2778 int actor_id = data1.toInt();
2779 int target_id = data2.toInt();
2780
2781 request_do_action(ACTION_TRANSPORT_LOAD2, actor_id, target_id, 0, "");
2782}
2783
2784/***********************************************************************/
2787static void transport_load3(QVariant data1, QVariant data2)
2788{
2789 int actor_id = data1.toInt();
2790 int target_id = data2.toInt();
2791
2792 request_do_action(ACTION_TRANSPORT_LOAD3, actor_id, target_id, 0, "");
2793}
2794
2795/***********************************************************************/
2798static void transport_deboard(QVariant data1, QVariant data2)
2799{
2800 int actor_id = data1.toInt();
2801 int target_id = data2.toInt();
2802
2803 request_do_action(ACTION_TRANSPORT_DEBOARD, actor_id, target_id, 0, "");
2804}
2805
2806/***********************************************************************/
2809static void disembark1(QVariant data1, QVariant data2)
2810{
2811 int actor_id = data1.toInt();
2812 int target_id = data2.toInt();
2813
2814 if (game_unit_by_number(actor_id) != nullptr
2815 && index_to_tile(&(wld.map), target_id) != nullptr) {
2817 actor_id, target_id, 0, "");
2818 }
2819}
2820
2821/***********************************************************************/
2824static void disembark2(QVariant data1, QVariant data2)
2825{
2826 int actor_id = data1.toInt();
2827 int target_id = data2.toInt();
2828
2829 if (game_unit_by_number(actor_id) != nullptr
2830 && index_to_tile(&(wld.map), target_id) != nullptr) {
2832 actor_id, target_id, 0, "");
2833 }
2834}
2835
2836/***********************************************************************/
2839static void disembark3(QVariant data1, QVariant data2)
2840{
2841 int actor_id = data1.toInt();
2842 int target_id = data2.toInt();
2843
2844 if (game_unit_by_number(actor_id) != nullptr
2845 && index_to_tile(&(wld.map), target_id) != nullptr) {
2847 actor_id, target_id, 0, "");
2848 }
2849}
2850
2851/***********************************************************************/
2854static void disembark4(QVariant data1, QVariant data2)
2855{
2856 int actor_id = data1.toInt();
2857 int target_id = data2.toInt();
2858
2859 if (game_unit_by_number(actor_id) != nullptr
2860 && index_to_tile(&(wld.map), target_id) != nullptr) {
2862 actor_id, target_id, 0, "");
2863 }
2864}
2865
2866/***********************************************************************/
2869static void enter_hut(QVariant data1, QVariant data2)
2870{
2871 int actor_id = data1.toInt();
2872 int target_id = data2.toInt();
2873
2874 if (game_unit_by_number(actor_id) != nullptr
2875 && index_to_tile(&(wld.map), target_id) != nullptr) {
2877 actor_id, target_id, 0, "");
2878 }
2879}
2880
2881/***********************************************************************/
2884static void enter_hut2(QVariant data1, QVariant data2)
2885{
2886 int actor_id = data1.toInt();
2887 int target_id = data2.toInt();
2888
2889 if (game_unit_by_number(actor_id) != nullptr
2890 && index_to_tile(&(wld.map), target_id) != nullptr) {
2892 actor_id, target_id, 0, "");
2893 }
2894}
2895
2896/***********************************************************************/
2899static void enter_hut3(QVariant data1, QVariant data2)
2900{
2901 int actor_id = data1.toInt();
2902 int target_id = data2.toInt();
2903
2904 if (game_unit_by_number(actor_id) != nullptr
2905 && index_to_tile(&(wld.map), target_id) != nullptr) {
2907 actor_id, target_id, 0, "");
2908 }
2909}
2910
2911/***********************************************************************/
2914static void enter_hut4(QVariant data1, QVariant data2)
2915{
2916 int actor_id = data1.toInt();
2917 int target_id = data2.toInt();
2918
2919 if (game_unit_by_number(actor_id) != nullptr
2920 && index_to_tile(&(wld.map), target_id) != nullptr) {
2922 actor_id, target_id, 0, "");
2923 }
2924}
2925
2926/***********************************************************************/
2929static void frighten_hut(QVariant data1, QVariant data2)
2930{
2931 int actor_id = data1.toInt();
2932 int target_id = data2.toInt();
2933
2934 if (game_unit_by_number(actor_id) != nullptr
2935 && index_to_tile(&(wld.map), target_id) != nullptr) {
2937 actor_id, target_id, 0, "");
2938 }
2939}
2940
2941/***********************************************************************/
2944static void frighten_hut2(QVariant data1, QVariant data2)
2945{
2946 int actor_id = data1.toInt();
2947 int target_id = data2.toInt();
2948
2949 if (game_unit_by_number(actor_id) != nullptr
2950 && index_to_tile(&(wld.map), target_id) != nullptr) {
2952 actor_id, target_id, 0, "");
2953 }
2954}
2955
2956/***********************************************************************/
2959static void frighten_hut3(QVariant data1, QVariant data2)
2960{
2961 int actor_id = data1.toInt();
2962 int target_id = data2.toInt();
2963
2964 if (game_unit_by_number(actor_id) != nullptr
2965 && index_to_tile(&(wld.map), target_id) != nullptr) {
2967 actor_id, target_id, 0, "");
2968 }
2969}
2970
2971/***********************************************************************/
2974static void frighten_hut4(QVariant data1, QVariant data2)
2975{
2976 int actor_id = data1.toInt();
2977 int target_id = data2.toInt();
2978
2979 if (game_unit_by_number(actor_id) != nullptr
2980 && index_to_tile(&(wld.map), target_id) != nullptr) {
2982 actor_id, target_id, 0, "");
2983 }
2984}
2985
2986/**********************************************************************/
2989static void nuke_units(QVariant data1, QVariant data2)
2990{
2991 int actor_id = data1.toInt();
2992 int target_id = data2.toInt();
2993
2995 target_id, 0, "");
2996}
2997
2998/**********************************************************************/
3001static void collect_ransom(QVariant data1, QVariant data2)
3002{
3003 int actor_id = data1.toInt();
3004 int target_id = data2.toInt();
3005
3007 target_id, 0, "");
3008}
3009
3010/**********************************************************************/
3013static void spy_attack(QVariant data1, QVariant data2)
3014{
3015 int actor_id = data1.toInt();
3016 int target_id = data2.toInt();
3017
3019 target_id, 0, "");
3020}
3021
3022/**********************************************************************/
3025static void wipe_units(QVariant data1, QVariant data2)
3026{
3027 int actor_id = data1.toInt();
3028 int target_id = data2.toInt();
3029
3031 target_id, 0, "");
3032}
3033
3034/**********************************************************************/
3037static void capture_units(QVariant data1, QVariant data2)
3038{
3039 int actor_id = data1.toInt();
3040 int target_id = data2.toInt();
3041
3043 target_id, 0, "");
3044}
3045
3046/***********************************************************************/
3049static void expel_unit(QVariant data1, QVariant data2)
3050{
3051 int actor_id = data1.toInt();
3052 int target_id = data2.toInt();
3053
3055 target_id, 0, "");
3056}
3057
3058/***********************************************************************/
3061static void bombard(QVariant data1, QVariant data2)
3062{
3063 int actor_id = data1.toInt();
3064 int target_id = data2.toInt();
3065
3067 target_id, 0, "");
3068}
3069
3070/***********************************************************************/
3073static void bombard2(QVariant data1, QVariant data2)
3074{
3075 int actor_id = data1.toInt();
3076 int target_id = data2.toInt();
3077
3079 target_id, 0, "");
3080}
3081
3082/***********************************************************************/
3085static void bombard3(QVariant data1, QVariant data2)
3086{
3087 int actor_id = data1.toInt();
3088 int target_id = data2.toInt();
3089
3091 target_id, 0, "");
3092}
3093
3094/***********************************************************************/
3097static void bombard4(QVariant data1, QVariant data2)
3098{
3099 int actor_id = data1.toInt();
3100 int target_id = data2.toInt();
3101
3103 target_id, 0, "");
3104}
3105
3106/***********************************************************************/
3109static void bombard_lethal(QVariant data1, QVariant data2)
3110{
3111 int actor_id = data1.toInt();
3112 int target_id = data2.toInt();
3113
3115 target_id, 0, "");
3116}
3117
3118/***********************************************************************/
3121static void bombard_lethal2(QVariant data1, QVariant data2)
3122{
3123 int actor_id = data1.toInt();
3124 int target_id = data2.toInt();
3125
3127 target_id, 0, "");
3128}
3129
3130/***********************************************************************/
3133static void found_city(QVariant data1, QVariant data2)
3134{
3135 int actor_id = data1.toInt();
3136
3138 actor_id);
3139}
3140
3141/***********************************************************************/
3144static void transform_terrain(QVariant data1, QVariant data2)
3145{
3146 int actor_id = data1.toInt();
3147 int target_id = data2.toInt();
3148
3149 if (game_unit_by_number(actor_id) != nullptr
3150 && index_to_tile(&(wld.map), target_id) != nullptr) {
3152 actor_id, target_id, 0, "");
3153 }
3154}
3155
3156/***********************************************************************/
3159static void transform_terrain2(QVariant data1, QVariant data2)
3160{
3161 int actor_id = data1.toInt();
3162 int target_id = data2.toInt();
3163
3164 if (game_unit_by_number(actor_id) != nullptr
3165 && index_to_tile(&(wld.map), target_id) != nullptr) {
3167 actor_id, target_id, 0, "");
3168 }
3169}
3170
3171/***********************************************************************/
3174static void cultivate(QVariant data1, QVariant data2)
3175{
3176 int actor_id = data1.toInt();
3177 int target_id = data2.toInt();
3178
3179 if (game_unit_by_number(actor_id) != nullptr
3180 && index_to_tile(&(wld.map), target_id) != nullptr) {
3182 actor_id, target_id, 0, "");
3183 }
3184}
3185
3186/***********************************************************************/
3189static void cultivate2(QVariant data1, QVariant data2)
3190{
3191 int actor_id = data1.toInt();
3192 int target_id = data2.toInt();
3193
3194 if (game_unit_by_number(actor_id) != nullptr
3195 && index_to_tile(&(wld.map), target_id) != nullptr) {
3197 actor_id, target_id, 0, "");
3198 }
3199}
3200
3201/***********************************************************************/
3204static void plant(QVariant data1, QVariant data2)
3205{
3206 int actor_id = data1.toInt();
3207 int target_id = data2.toInt();
3208
3209 if (game_unit_by_number(actor_id) != nullptr
3210 && index_to_tile(&(wld.map), target_id) != nullptr) {
3212 actor_id, target_id, 0, "");
3213 }
3214}
3215
3216/***********************************************************************/
3219static void plant2(QVariant data1, QVariant data2)
3220{
3221 int actor_id = data1.toInt();
3222 int target_id = data2.toInt();
3223
3224 if (game_unit_by_number(actor_id) != nullptr
3225 && index_to_tile(&(wld.map), target_id) != nullptr) {
3227 actor_id, target_id, 0, "");
3228 }
3229}
3230
3231/***********************************************************************/
3234static void pillage(QVariant data1, QVariant data2)
3235{
3236 int actor_id = data1.toInt();
3237 int target_id = data2.toInt();
3238
3239 if (game_unit_by_number(actor_id) != nullptr
3240 && index_to_tile(&(wld.map), target_id) != nullptr) {
3242 actor_id, target_id,
3243 /* FIXME: will cause problems if more than
3244 * one action selection dialog at a time
3245 * becomes supported. */
3247 "");
3248 }
3249}
3250
3251/***********************************************************************/
3254static void pillage2(QVariant data1, QVariant data2)
3255{
3256 int actor_id = data1.toInt();
3257 int target_id = data2.toInt();
3258
3259 if (game_unit_by_number(actor_id) != nullptr
3260 && index_to_tile(&(wld.map), target_id) != nullptr) {
3262 actor_id, target_id,
3263 /* FIXME: will cause problems if more than
3264 * one action selection dialog at a time
3265 * becomes supported. */
3267 "");
3268 }
3269}
3270
3271/***********************************************************************/
3274static void clean(QVariant data1, QVariant data2)
3275{
3276 int actor_id = data1.toInt();
3277 int target_id = data2.toInt();
3278
3279 if (game_unit_by_number(actor_id) != nullptr
3280 && index_to_tile(&(wld.map), target_id) != nullptr) {
3282 actor_id, target_id,
3283 /* FIXME: will cause problems if more than
3284 * one action selection dialog at a time
3285 * becomes supported. */
3287 "");
3288 }
3289}
3290
3291/***********************************************************************/
3294static void clean2(QVariant data1, QVariant data2)
3295{
3296 int actor_id = data1.toInt();
3297 int target_id = data2.toInt();
3298
3299 if (game_unit_by_number(actor_id) != nullptr
3300 && index_to_tile(&(wld.map), target_id) != nullptr) {
3302 actor_id, target_id,
3303 /* FIXME: will cause problems if more than
3304 * one action selection dialog at a time
3305 * becomes supported. */
3307 "");
3308 }
3309}
3310
3311/***********************************************************************/
3314static void road(QVariant data1, QVariant data2)
3315{
3316 int actor_id = data1.toInt();
3317 int target_id = data2.toInt();
3318
3319 if (game_unit_by_number(actor_id) != nullptr
3320 && index_to_tile(&(wld.map), target_id) != nullptr
3323 actor_id, target_id,
3324 /* FIXME: will cause problems if more than
3325 * one action selection dialog at a time
3326 * becomes supported. */
3328 "");
3329 }
3330}
3331
3332/***********************************************************************/
3335static void road2(QVariant data1, QVariant data2)
3336{
3337 int actor_id = data1.toInt();
3338 int target_id = data2.toInt();
3339
3340 if (game_unit_by_number(actor_id) != nullptr
3341 && index_to_tile(&(wld.map), target_id) != nullptr
3344 actor_id, target_id,
3345 /* FIXME: will cause problems if more than
3346 * one action selection dialog at a time
3347 * becomes supported. */
3349 "");
3350 }
3351}
3352
3353/***********************************************************************/
3356static void base(QVariant data1, QVariant data2)
3357{
3358 int actor_id = data1.toInt();
3359 int target_id = data2.toInt();
3360
3361 if (game_unit_by_number(actor_id) != nullptr
3362 && index_to_tile(&(wld.map), target_id) != nullptr
3365 actor_id, target_id,
3366 /* FIXME: will cause problems if more than
3367 * one action selection dialog at a time
3368 * becomes supported. */
3370 "");
3371 }
3372}
3373
3374/***********************************************************************/
3377static void base2(QVariant data1, QVariant data2)
3378{
3379 int actor_id = data1.toInt();
3380 int target_id = data2.toInt();
3381
3382 if (game_unit_by_number(actor_id) != nullptr
3383 && index_to_tile(&(wld.map), target_id) != nullptr
3386 actor_id, target_id,
3387 /* FIXME: will cause problems if more than
3388 * one action selection dialog at a time
3389 * becomes supported. */
3391 "");
3392 }
3393}
3394
3395/***********************************************************************/
3398static void mine(QVariant data1, QVariant data2)
3399{
3400 int actor_id = data1.toInt();
3401 int target_id = data2.toInt();
3402
3403 if (game_unit_by_number(actor_id) != nullptr
3404 && index_to_tile(&(wld.map), target_id) != nullptr
3407 actor_id, target_id,
3408 /* FIXME: will cause problems if more than
3409 * one action selection dialog at a time
3410 * becomes supported. */
3412 "");
3413 }
3414}
3415
3416/***********************************************************************/
3419static void mine2(QVariant data1, QVariant data2)
3420{
3421 int actor_id = data1.toInt();
3422 int target_id = data2.toInt();
3423
3424 if (game_unit_by_number(actor_id) != nullptr
3425 && index_to_tile(&(wld.map), target_id) != nullptr
3428 actor_id, target_id,
3429 /* FIXME: will cause problems if more than
3430 * one action selection dialog at a time
3431 * becomes supported. */
3433 "");
3434 }
3435}
3436
3437/***********************************************************************/
3440static void irrigate(QVariant data1, QVariant data2)
3441{
3442 int actor_id = data1.toInt();
3443 int target_id = data2.toInt();
3444
3445 if (game_unit_by_number(actor_id) != nullptr
3446 && index_to_tile(&(wld.map), target_id) != nullptr
3449 actor_id, target_id,
3450 /* FIXME: will cause problems if more than
3451 * one action selection dialog at a time
3452 * becomes supported. */
3454 "");
3455 }
3456}
3457
3458/***********************************************************************/
3461static void irrigate2(QVariant data1, QVariant data2)
3462{
3463 int actor_id = data1.toInt();
3464 int target_id = data2.toInt();
3465
3466 if (game_unit_by_number(actor_id) != nullptr
3467 && index_to_tile(&(wld.map), target_id) != nullptr
3470 actor_id, target_id,
3471 /* FIXME: will cause problems if more than
3472 * one action selection dialog at a time
3473 * becomes supported. */
3475 "");
3476 }
3477}
3478
3479/***********************************************************************/
3482static void nuke(QVariant data1, QVariant data2)
3483{
3484 int diplomat_id = data1.toInt();
3485 int diplomat_target_id = data2.toInt();
3486
3487 if (game_unit_by_number(diplomat_id) != nullptr
3488 && index_to_tile(&(wld.map), diplomat_target_id) != nullptr) {
3491 }
3492}
3493
3494/***********************************************************************/
3497static void attack(QVariant data1, QVariant data2)
3498{
3499 int diplomat_id = data1.toInt();
3500 int diplomat_target_id = data2.toInt();
3501
3502 if (game_unit_by_number(diplomat_id) != nullptr
3503 && index_to_tile(&(wld.map), diplomat_target_id) != nullptr) {
3506 }
3507}
3508
3509/***********************************************************************/
3512static void attack2(QVariant data1, QVariant data2)
3513{
3514 int diplomat_id = data1.toInt();
3515 int diplomat_target_id = data2.toInt();
3516
3517 if (game_unit_by_number(diplomat_id) != nullptr
3518 && index_to_tile(&(wld.map), diplomat_target_id) != nullptr) {
3521 }
3522}
3523
3524/***********************************************************************/
3527static void suicide_attack(QVariant data1, QVariant data2)
3528{
3529 int diplomat_id = data1.toInt();
3530 int diplomat_target_id = data2.toInt();
3531
3532 if (game_unit_by_number(diplomat_id) != nullptr
3533 && index_to_tile(&(wld.map), diplomat_target_id) != nullptr) {
3536 }
3537}
3538
3539/***********************************************************************/
3542static void suicide_attack2(QVariant data1, QVariant data2)
3543{
3544 int diplomat_id = data1.toInt();
3545 int diplomat_target_id = data2.toInt();
3546
3547 if (game_unit_by_number(diplomat_id) != nullptr
3548 && index_to_tile(&(wld.map), diplomat_target_id) != nullptr) {
3551 }
3552}
3553
3554/***********************************************************************/
3557static void paradrop(QVariant data1, QVariant data2)
3558{
3559 int actor_id = data1.toInt();
3560 int target_id = data2.toInt();
3561
3562 if (game_unit_by_number(actor_id) != nullptr
3563 && index_to_tile(&(wld.map), target_id) != nullptr) {
3565 actor_id, target_id, 0, "");
3566 }
3567}
3568
3569/***********************************************************************/
3572static void teleport(QVariant data1, QVariant data2)
3573{
3574 int actor_id = data1.toInt();
3575 int target_id = data2.toInt();
3576
3577 if (game_unit_by_number(actor_id) != nullptr
3578 && index_to_tile(&(wld.map), target_id) != nullptr) {
3580 actor_id, target_id, 0, "");
3581 }
3582}
3583
3584/***********************************************************************/
3587static void teleport2(QVariant data1, QVariant data2)
3588{
3589 int actor_id = data1.toInt();
3590 int target_id = data2.toInt();
3591
3592 if (game_unit_by_number(actor_id) != nullptr
3593 && index_to_tile(&(wld.map), target_id) != nullptr) {
3595 actor_id, target_id, 0, "");
3596 }
3597}
3598
3599/***********************************************************************/
3602static void teleport3(QVariant data1, QVariant data2)
3603{
3604 int actor_id = data1.toInt();
3605 int target_id = data2.toInt();
3606
3607 if (game_unit_by_number(actor_id) != nullptr
3608 && index_to_tile(&(wld.map), target_id) != nullptr) {
3610 actor_id, target_id, 0, "");
3611 }
3612}
3613
3614/***********************************************************************/
3617static void paradrop_conquer(QVariant data1, QVariant data2)
3618{
3619 int actor_id = data1.toInt();
3620 int target_id = data2.toInt();
3621
3622 if (game_unit_by_number(actor_id) != nullptr
3623 && index_to_tile(&(wld.map), target_id) != nullptr) {
3625 actor_id, target_id, 0, "");
3626 }
3627}
3628
3629/***********************************************************************/
3632static void teleport_conquer(QVariant data1, QVariant data2)
3633{
3634 int actor_id = data1.toInt();
3635 int target_id = data2.toInt();
3636
3637 if (game_unit_by_number(actor_id) != nullptr
3638 && index_to_tile(&(wld.map), target_id) != nullptr) {
3640 actor_id, target_id, 0, "");
3641 }
3642}
3643
3644/***********************************************************************/
3647static void paradrop_frighten(QVariant data1, QVariant data2)
3648{
3649 int actor_id = data1.toInt();
3650 int target_id = data2.toInt();
3651
3652 if (game_unit_by_number(actor_id) != nullptr
3653 && index_to_tile(&(wld.map), target_id) != nullptr) {
3655 actor_id, target_id, 0, "");
3656 }
3657}
3658
3659/***********************************************************************/
3662static void teleport_frighten(QVariant data1, QVariant data2)
3663{
3664 int actor_id = data1.toInt();
3665 int target_id = data2.toInt();
3666
3667 if (game_unit_by_number(actor_id) != nullptr
3668 && index_to_tile(&(wld.map), target_id) != nullptr) {
3670 actor_id, target_id, 0, "");
3671 }
3672}
3673
3674/***********************************************************************/
3678{
3679 int actor_id = data1.toInt();
3680 int target_id = data2.toInt();
3681
3682 if (game_unit_by_number(actor_id) != nullptr
3683 && index_to_tile(&(wld.map), target_id) != nullptr) {
3685 actor_id, target_id, 0, "");
3686 }
3687}
3688
3689/***********************************************************************/
3693{
3694 int actor_id = data1.toInt();
3695 int target_id = data2.toInt();
3696
3697 if (game_unit_by_number(actor_id) != nullptr
3698 && index_to_tile(&(wld.map), target_id) != nullptr) {
3700 actor_id, target_id, 0, "");
3701 }
3702}
3703
3704/***********************************************************************/
3707static void paradrop_enter(QVariant data1, QVariant data2)
3708{
3709 int actor_id = data1.toInt();
3710 int target_id = data2.toInt();
3711
3712 if (game_unit_by_number(actor_id) != nullptr
3713 && index_to_tile(&(wld.map), target_id) != nullptr) {
3715 actor_id, target_id, 0, "");
3716 }
3717}
3718
3719/***********************************************************************/
3722static void teleport_enter(QVariant data1, QVariant data2)
3723{
3724 int actor_id = data1.toInt();
3725 int target_id = data2.toInt();
3726
3727 if (game_unit_by_number(actor_id) != nullptr
3728 && index_to_tile(&(wld.map), target_id) != nullptr) {
3730 actor_id, target_id, 0, "");
3731 }
3732}
3733
3734/***********************************************************************/
3738{
3739 int actor_id = data1.toInt();
3740 int target_id = data2.toInt();
3741
3742 if (game_unit_by_number(actor_id) != nullptr
3743 && index_to_tile(&(wld.map), target_id) != nullptr) {
3745 actor_id, target_id, 0, "");
3746 }
3747}
3748
3749/***********************************************************************/
3753{
3754 int actor_id = data1.toInt();
3755 int target_id = data2.toInt();
3756
3757 if (game_unit_by_number(actor_id) != nullptr
3758 && index_to_tile(&(wld.map), target_id) != nullptr) {
3760 actor_id, target_id, 0, "");
3761 }
3762}
3763
3764/***********************************************************************/
3767static void join_city(QVariant data1, QVariant data2)
3768{
3769 int actor_id = data1.toInt();
3770 int target_id = data2.toInt();
3771
3772 if (game_unit_by_number(actor_id) != nullptr
3773 && game_city_by_number(target_id) != nullptr) {
3775 actor_id, target_id, 0, "");
3776 }
3777}
3778
3779/***********************************************************************/
3782static void spy_steal_shared(QVariant data1, QVariant data2,
3783 action_id act_id)
3784{
3785 QString str;
3786 QVariant qv1;
3788 int diplomat_id = data1.toInt();
3789 int diplomat_target_id = data2.toInt();
3792 struct player *pvictim = nullptr;
3795
3796 cd = gui()->get_diplo_dialog();
3797 if (cd != nullptr) {
3798 cd->close();
3799 }
3800
3801 if (pvcity == nullptr) {
3802 return;
3803 }
3804
3805 // Wait for the player's reply before moving on to the next queued diplomat.
3807
3809
3810 struct astring stra = ASTRING_INIT;
3811 cd = new choice_dialog(_("Steal"), _("Steal Technology"),
3812 gui()->game_tab_widget,
3814
3815 // Put both actor and target city in qv1 since qv2 is taken
3818 actor_and_target.append(act_id);
3819 qv1 = QVariant::fromValue(actor_and_target);
3820
3821 struct player *pplayer = client_player();
3822 const struct research *presearch = research_get(pplayer);
3823 const struct research *vresearch = research_get(pvictim);
3824
3831 // Defeat keyboard shortcut mnemonics
3833 .replace("&", "&&");
3834 cd->add_item(str, func, qv1, i);
3835 }
3837
3839 get_non_targeted_action_id(act_id)])) {
3840 astr_set(&stra, _("At %s's Discretion"),
3843 str = QString(astr_str(&stra)).replace("&", "&&");
3844 cd->add_item(str, func, qv1, A_UNSET);
3845 }
3846
3847 cd->set_layout();
3848 cd->show_me();
3849
3850 astr_free(&stra);
3851}
3852
3853/***********************************************************************/
3856static void spy_steal(QVariant data1, QVariant data2)
3857{
3859}
3860
3861/***********************************************************************/
3864static void spy_steal_esc(QVariant data1, QVariant data2)
3865{
3867}
3868
3869/***********************************************************************/
3872static void spy_steal_something(QVariant data1, QVariant data2)
3873{
3874 int diplomat_id = data1.toList().at(0).toInt();
3875 int diplomat_target_id = data1.toList().at(1).toInt();
3876 action_id act_id = data1.toList().at(2).toInt();
3877
3878 if (game_unit_by_number(diplomat_id) != nullptr
3879 && game_city_by_number(diplomat_target_id) != nullptr) {
3880 if (data2.toInt() == A_UNSET) {
3881 // This is the untargeted version.
3883 diplomat_id, diplomat_target_id, data2.toInt(), "");
3884 } else {
3885 // This is the targeted version.
3887 diplomat_target_id, data2.toInt(), "");
3888 }
3889 }
3890}
3891
3892/***********************************************************************/
3896{
3897 int actor_id = data1.toInt();
3898 int target_id = data2.toInt();
3899
3900 if (game_unit_by_number(actor_id) != nullptr
3901 && game_city_by_number(target_id) != nullptr) {
3902 // Wait for the server's reply before moving on to the next queued diplomat.
3904
3905 request_action_details(ACTION_STRIKE_BUILDING, actor_id, target_id);
3906 }
3907}
3908
3909/***********************************************************************/
3913{
3914 int diplomat_id = data1.toInt();
3915 int diplomat_target_id = data2.toInt();
3916
3917 if (game_unit_by_number(diplomat_id) != nullptr
3918 && game_city_by_number(diplomat_target_id) != nullptr) {
3919 // Wait for the server's reply before moving on to the next queued diplomat.
3921
3924 }
3925}
3926
3927/***********************************************************************/
3931{
3932 int diplomat_id = data1.toInt();
3933 int diplomat_target_id = data2.toInt();
3934
3935 if (game_unit_by_number(diplomat_id) != nullptr
3936 && game_city_by_number(diplomat_target_id) != nullptr) {
3937 /* Wait for the server's reply before moving on to the next queued
3938 * diplomat. */
3940
3943 }
3944}
3945
3946/***********************************************************************/
3949static void spy_poison(QVariant data1, QVariant data2)
3950{
3951 int diplomat_id = data1.toInt();
3952 int diplomat_target_id = data2.toInt();
3953
3954 if (game_unit_by_number(diplomat_id) != nullptr
3955 && game_city_by_number(diplomat_target_id) != nullptr) {
3958 }
3959}
3960
3961/***********************************************************************/
3964static void spy_poison_esc(QVariant data1, QVariant data2)
3965{
3966 int diplomat_id = data1.toInt();
3967 int diplomat_target_id = data2.toInt();
3968
3969 if (game_unit_by_number(diplomat_id) != nullptr
3970 && game_city_by_number(diplomat_target_id) != nullptr) {
3973 }
3974}
3975
3976/***********************************************************************/
3979static void spy_spread_plague(QVariant data1, QVariant data2)
3980{
3981 int diplomat_id = data1.toInt();
3982 int diplomat_target_id = data2.toInt();
3983
3984 if (game_unit_by_number(diplomat_id) != nullptr
3985 && game_city_by_number(diplomat_target_id) != nullptr) {
3988 }
3989}
3990
3991/***********************************************************************/
3994static void spy_nuke_city(QVariant data1, QVariant data2)
3995{
3996 int diplomat_id = data1.toInt();
3997 int diplomat_target_id = data2.toInt();
3998
3999 if (game_unit_by_number(diplomat_id) != nullptr
4000 && game_city_by_number(diplomat_target_id) != nullptr) {
4003 }
4004}
4005
4006/***********************************************************************/
4009static void spy_nuke_city_esc(QVariant data1, QVariant data2)
4010{
4011 int diplomat_id = data1.toInt();
4012 int diplomat_target_id = data2.toInt();
4013
4014 if (game_unit_by_number(diplomat_id) != nullptr
4015 && game_city_by_number(diplomat_target_id) != nullptr) {
4018 }
4019}
4020
4021/***********************************************************************/
4024static void nuke_city(QVariant data1, QVariant data2)
4025{
4026 int actor_id = data1.toInt();
4027 int target_id = data2.toInt();
4028
4029 if (game_unit_by_number(actor_id) != nullptr
4030 && game_city_by_number(target_id) != nullptr) {
4032 actor_id, target_id, 0, "");
4033 }
4034}
4035
4036/***********************************************************************/
4039static void destroy_city(QVariant data1, QVariant data2)
4040{
4041 int diplomat_id = data1.toInt();
4042 int diplomat_target_id = data2.toInt();
4043
4044 if (game_unit_by_number(diplomat_id) != nullptr
4045 && game_city_by_number(diplomat_target_id) != nullptr) {
4048 }
4049}
4050
4051/***********************************************************************/
4054static void spy_steal_gold(QVariant data1, QVariant data2)
4055{
4056 int diplomat_id = data1.toInt();
4057 int diplomat_target_id = data2.toInt();
4058
4059 if (game_unit_by_number(diplomat_id) != nullptr
4060 && game_city_by_number(diplomat_target_id) != nullptr) {
4063 }
4064}
4065
4066/***********************************************************************/
4069static void spy_steal_gold_esc(QVariant data1, QVariant data2)
4070{
4071 int diplomat_id = data1.toInt();
4072 int diplomat_target_id = data2.toInt();
4073
4074 if (game_unit_by_number(diplomat_id) != nullptr
4075 && game_city_by_number(diplomat_target_id) != nullptr) {
4078 }
4079}
4080
4081/***********************************************************************/
4084static void spy_steal_maps(QVariant data1, QVariant data2)
4085{
4086 int diplomat_id = data1.toInt();
4087 int diplomat_target_id = data2.toInt();
4088
4089 if (game_unit_by_number(diplomat_id) != nullptr
4090 && game_city_by_number(diplomat_target_id) != nullptr) {
4093 }
4094}
4095
4096/***********************************************************************/
4099static void spy_steal_maps_esc(QVariant data1, QVariant data2)
4100{
4101 int diplomat_id = data1.toInt();
4102 int diplomat_target_id = data2.toInt();
4103
4104 if (game_unit_by_number(diplomat_id) != nullptr
4105 && game_city_by_number(diplomat_target_id) != nullptr) {
4108 }
4109}
4110
4111/***********************************************************************/
4114static void spy_escape(QVariant data1, QVariant data2)
4115{
4116 int diplomat_id = data1.toInt();
4117 int diplomat_target_id = data2.toInt();
4118
4119 if (game_unit_by_number(diplomat_id) != nullptr
4120 && game_city_by_number(diplomat_target_id) != nullptr) {
4123 }
4124}
4125
4126/***********************************************************************/
4129static void spy_embassy(QVariant data1, QVariant data2)
4130{
4131 int diplomat_id = data1.toInt();
4132 int diplomat_target_id = data2.toInt();
4133
4134 if (game_unit_by_number(diplomat_id) != nullptr
4135 && game_city_by_number(diplomat_target_id) != nullptr) {
4137 diplomat_target_id, 0, "");
4138 }
4139}
4140
4141/***********************************************************************/
4144static void diplomat_embassy(QVariant data1, QVariant data2)
4145{
4146 int diplomat_id = data1.toInt();
4147 int diplomat_target_id = data2.toInt();
4148
4149 if (game_unit_by_number(diplomat_id) != nullptr
4150 && game_city_by_number(diplomat_target_id) != nullptr) {
4152 diplomat_target_id, 0, "");
4153 }
4154}
4155
4156/***********************************************************************/
4159static void spy_investigate(QVariant data1, QVariant data2)
4160{
4161 int diplomat_id = data1.toInt();
4162 int diplomat_target_id = data2.toInt();
4163
4165 && game_unit_by_number(diplomat_id) != nullptr) {
4167 diplomat_target_id, 0, "");
4168 }
4169}
4170
4171/***********************************************************************/
4174static void diplomat_investigate(QVariant data1, QVariant data2)
4175{
4176 int diplomat_id = data1.toInt();
4177 int diplomat_target_id = data2.toInt();
4178
4180 && game_unit_by_number(diplomat_id) != nullptr) {
4182 diplomat_target_id, 0, "");
4183 }
4184}
4185
4186/***********************************************************************/
4189static void diplomat_sabotage(QVariant data1, QVariant data2)
4190{
4191 int diplomat_id = data1.toInt();
4192 int diplomat_target_id = data2.toInt();
4193
4194 if (game_unit_by_number(diplomat_id) != nullptr
4195 && game_city_by_number(diplomat_target_id) != nullptr) {
4197 diplomat_target_id, B_LAST + 1, "");
4198 }
4199}
4200
4201/***********************************************************************/
4204static void diplomat_sabotage_esc(QVariant data1, QVariant data2)
4205{
4206 int diplomat_id = data1.toInt();
4207 int diplomat_target_id = data2.toInt();
4208
4209 if (game_unit_by_number(diplomat_id) != nullptr
4210 && game_city_by_number(diplomat_target_id) != nullptr) {
4212 diplomat_target_id, B_LAST + 1, "");
4213 }
4214}
4215
4216/***********************************************************************/
4219static void diplomat_steal(QVariant data1, QVariant data2)
4220{
4221 int diplomat_id = data1.toInt();
4222 int diplomat_target_id = data2.toInt();
4223
4224 if (game_unit_by_number(diplomat_id) != nullptr
4225 && game_city_by_number(diplomat_target_id) != nullptr) {
4228 }
4229}
4230
4231/***********************************************************************/
4234static void diplomat_steal_esc(QVariant data1, QVariant data2)
4235{
4236 int diplomat_id = data1.toInt();
4237 int diplomat_target_id = data2.toInt();
4238
4239 if (game_unit_by_number(diplomat_id) != nullptr
4240 && game_city_by_number(diplomat_target_id) != nullptr) {
4243 }
4244}
4245
4246/***********************************************************************/
4249static void diplomat_incite(QVariant data1, QVariant data2)
4250{
4251 int diplomat_id = data1.toInt();
4252 int diplomat_target_id = data2.toInt();
4253
4254 if (game_unit_by_number(diplomat_id) != nullptr
4255 && game_city_by_number(diplomat_target_id) != nullptr) {
4256 // Wait for the server's reply before moving on to the next queued diplomat.
4258
4261 }
4262}
4263
4264/***********************************************************************/
4268{
4269 int diplomat_id = data1.toInt();
4270 int diplomat_target_id = data2.toInt();
4271
4272 if (game_unit_by_number(diplomat_id) != nullptr
4273 && game_city_by_number(diplomat_target_id) != nullptr) {
4274 // Wait for the server's reply before moving on to the next queued diplomat.
4276
4279 }
4280}
4281
4282/***********************************************************************/
4285static void regular_move(QVariant data1, QVariant data2)
4286{
4287 int actor_id = data1.toInt();
4288 int target_id = data2.toInt();
4289
4290 if (game_unit_by_number(actor_id) != nullptr
4291 && index_to_tile(&(wld.map), target_id) != nullptr) {
4293 actor_id, target_id, 0, "");
4294 }
4295}
4296
4297/***********************************************************************/
4300static void regular_move2(QVariant data1, QVariant data2)
4301{
4302 int actor_id = data1.toInt();
4303 int target_id = data2.toInt();
4304
4305 if (game_unit_by_number(actor_id) != nullptr
4306 && index_to_tile(&(wld.map), target_id) != nullptr) {
4308 actor_id, target_id, 0, "");
4309 }
4310}
4311
4312/***********************************************************************/
4315static void regular_move3(QVariant data1, QVariant data2)
4316{
4317 int actor_id = data1.toInt();
4318 int target_id = data2.toInt();
4319
4320 if (game_unit_by_number(actor_id) != nullptr
4321 && index_to_tile(&(wld.map), target_id) != nullptr) {
4323 actor_id, target_id, 0, "");
4324 }
4325}
4326
4327/***********************************************************************/
4330static void scout(QVariant data1, QVariant data2)
4331{
4332 int actor_id = data1.toInt();
4333 int target_id = data2.toInt();
4334
4335 if (game_unit_by_number(actor_id) != nullptr
4336 && index_to_tile(&(wld.map), target_id) != nullptr) {
4338 actor_id, target_id, 0, "");
4339 }
4340}
4341
4342/***********************************************************************/
4346void popup_incite_dialog(struct unit *actor, struct city *tcity, int cost,
4347 const struct action *paction)
4348{
4349 char buf[1024];
4350 char buf2[1024];
4351 int diplomat_id = actor->id;
4352 int diplomat_target_id = tcity->id;
4353 const int act_id = paction->id;
4354
4355 // Should be set before sending request to the server.
4357
4358 fc_snprintf(buf, ARRAY_SIZE(buf), PL_("Treasury contains %d gold.",
4359 "Treasury contains %d gold.",
4360 client_player()->economic.gold),
4361 client_player()->economic.gold);
4362
4364 hud_message_box *impossible = new hud_message_box(gui()->central_wdg);
4365
4367 _("You can't incite a revolt in %s."), city_name_get(tcity));
4368 impossible->set_text_title(buf2, "!");
4369 impossible->setStandardButtons(QMessageBox::Ok);
4370 impossible->setAttribute(Qt::WA_DeleteOnClose);
4371 impossible->show();
4372 } else if (cost <= client_player()->economic.gold) {
4373 hud_message_box *ask = new hud_message_box(gui()->central_wdg);
4374
4376 PL_("Incite a revolt for %d gold?\n%s",
4377 "Incite a revolt for %d gold?\n%s", cost), cost, buf);
4378 ask->setStandardButtons(QMessageBox::Cancel | QMessageBox::Ok);
4379 ask->setDefaultButton(QMessageBox::Cancel);
4380 ask->set_text_title(buf2, _("Incite a Revolt!"));
4381 ask->setAttribute(Qt::WA_DeleteOnClose);
4382 QObject::connect(ask, &hud_message_box::accepted, [=]() {
4385 });
4386 ask->show();
4387 return;
4388 } else {
4389 hud_message_box *too_much = new hud_message_box(gui()->central_wdg);
4390
4392 PL_("Inciting a revolt costs %d gold.\n%s",
4393 "Inciting a revolt costs %d gold.\n%s", cost), cost,
4394 buf);
4395 too_much->set_text_title(buf2, "!");
4396 too_much->setStandardButtons(QMessageBox::Ok);
4397 too_much->setAttribute(Qt::WA_DeleteOnClose);
4398 too_much->show();
4399 }
4400
4402}
4403
4404/***********************************************************************/
4408void popup_bribe_unit_dialog(struct unit *actor, struct unit *tunit, int cost,
4409 const struct action *paction)
4410{
4411 hud_message_box *ask = new hud_message_box(gui()->central_wdg);
4412 char buf[1024];
4413 char buf2[1024];
4414 int diplomat_id = actor->id;
4415 int diplomat_target_id = tunit->id;
4416 const int act_id = paction->id;
4417
4418 // Should be set before sending request to the server.
4420
4421 fc_snprintf(buf, ARRAY_SIZE(buf), PL_("Treasury contains %d gold.",
4422 "Treasury contains %d gold.",
4423 client_player()->economic.gold),
4424 client_player()->economic.gold);
4425
4426 if (cost <= client_player()->economic.gold) {
4427 fc_snprintf(buf2, ARRAY_SIZE(buf2), PL_("Bribe unit for %d gold?\n%s",
4428 "Bribe unit for %d gold?\n%s",
4429 cost), cost, buf);
4430 ask->set_text_title(buf2, _("Bribe Enemy Unit"));
4431 ask->setStandardButtons(QMessageBox::Cancel | QMessageBox::Ok);
4432 ask->setDefaultButton(QMessageBox::Cancel);
4433 ask->setAttribute(Qt::WA_DeleteOnClose);
4434 QObject::connect(ask, &hud_message_box::accepted, [=]() {
4437 });
4438 ask->show();
4439 return;
4440 } else {
4442 PL_("Bribing the unit costs %d gold.\n%s",
4443 "Bribing the unit costs %d gold.\n%s", cost), cost, buf);
4444 ask->set_text_title(buf2, _("Traitors Demand Too Much!"));
4445 ask->setAttribute(Qt::WA_DeleteOnClose);
4446 ask->show();
4447 }
4448
4450}
4451
4452/***********************************************************************/
4457 const struct action *paction)
4458{
4459 hud_message_box *ask = new hud_message_box(gui()->central_wdg);
4460 char buf[1024];
4461 char buf2[1024];
4462 int diplomat_id = actor->id;
4463 int diplomat_target_id = ttile->index;
4464 const int act_id = paction->id;
4465
4466 // Should be set before sending request to the server.
4468
4469 fc_snprintf(buf, ARRAY_SIZE(buf), PL_("Treasury contains %d gold.",
4470 "Treasury contains %d gold.",
4471 client_player()->economic.gold),
4472 client_player()->economic.gold);
4473
4474 if (cost <= client_player()->economic.gold) {
4475 fc_snprintf(buf2, ARRAY_SIZE(buf2), PL_("Bribe unit stack for %d gold?\n%s",
4476 "Bribe unit stack for %d gold?\n%s",
4477 cost), cost, buf);
4478 ask->set_text_title(buf2, _("Bribe Enemy Stack"));
4479 ask->setStandardButtons(QMessageBox::Cancel | QMessageBox::Ok);
4480 ask->setDefaultButton(QMessageBox::Cancel);
4481 ask->setAttribute(Qt::WA_DeleteOnClose);
4482 QObject::connect(ask, &hud_message_box::accepted, [=]() {
4485 });
4486 ask->show();
4487 return;
4488 } else {
4490 PL_("Bribing the unit stack costs %d gold.\n%s",
4491 "Bribing the unit stack costs %d gold.\n%s", cost), cost, buf);
4492 ask->set_text_title(buf2, _("Traitors Demand Too Much!"));
4493 ask->setAttribute(Qt::WA_DeleteOnClose);
4494 ask->show();
4495 }
4496
4498}
4499
4500/***********************************************************************/
4503static void pillage_something(QVariant data1, QVariant data2)
4504{
4505 int punit_id;
4506 int what;
4507 struct unit *punit;
4508 struct extra_type *target;
4509
4510 what = data1.toInt();
4511 punit_id = data2.toInt();
4513 if (punit) {
4514 target = extra_by_number(what);
4516 }
4518}
4519
4520/***********************************************************************/
4523static void spy_sabotage(QVariant data1, QVariant data2)
4524{
4525 int diplomat_id = data1.toList().at(0).toInt();
4526 int diplomat_target_id = data1.toList().at(1).toInt();
4527 action_id act_id = data1.toList().at(2).toInt();
4528
4529 if (game_unit_by_number(diplomat_id) != nullptr
4530 && game_city_by_number(diplomat_target_id) != nullptr) {
4531 if (data2.toInt() == B_LAST) {
4532 // This is the untargeted version.
4534 diplomat_id, diplomat_target_id, data2.toInt(),
4535 "");
4536 } else if (data2.toInt() == -1) {
4537 // This is the city production version.
4539 diplomat_id, diplomat_target_id, data2.toInt(),
4540 "");
4541 } else {
4542 // This is the targeted version.
4544 diplomat_target_id, data2.toInt(), "");
4545 }
4546 }
4547}
4548
4549/***********************************************************************/
4554 const struct action *paction)
4555{
4556 QString str;
4557 QVariant qv1, qv2;
4558 int diplomat_id = actor->id;
4559 int diplomat_target_id = tcity->id;
4562 int nr = 0;
4563 struct astring stra = ASTRING_INIT;
4565
4566 if (paction->result == ACTRES_STRIKE_BUILDING) {
4567 cd = new choice_dialog(_("Strike"),
4568 _("Select Improvement to Strike"),
4569 gui()->game_tab_widget,
4571 } else {
4572 cd = new choice_dialog(_("Sabotage"),
4573 _("Select Improvement to Sabotage"),
4574 gui()->game_tab_widget,
4576 }
4577
4578 // Should be set before sending request to the server.
4580
4581 // Put both actor, target city and action in qv1 since qv2 is taken
4584 actor_and_target.append(paction->id);
4585 qv1 = QVariant::fromValue(actor_and_target);
4586
4589 paction->id)])) {
4591 cd->add_item(QString(_("City Production")), func, qv1, -1);
4592 }
4593
4594 city_built_iterate(tcity, pimprove) {
4595 if (pimprove->sabotage > 0) {
4597 // Defeat keyboard shortcut mnemonics
4599 .replace("&", "&&");
4600 qv2 = nr;
4601 cd->add_item(str, func, qv1, improvement_number(pimprove));
4602 nr++;
4603 }
4605
4608 astr_set(&stra, _("At %s's Discretion"),
4611 str = QString(astr_str(&stra)).replace("&", "&&");
4612 cd->add_item(str, func, qv1, B_LAST);
4613 }
4614
4615 cd->set_layout();
4616 cd->show_me();
4617 astr_free(&stra);
4618}
4619
4620/***********************************************************************/
4625{
4626 QString str;
4627 QVariant qv1, qv2;
4630 struct extra_type *tgt;
4631
4633 return;
4634 }
4635 cd = new choice_dialog(_("What To Pillage"), _("Select what to pillage:"),
4636 gui()->game_tab_widget);
4637 qv2 = punit->id;
4638 while ((tgt = get_preferred_pillage(extras))) {
4639 int what;
4640
4641 what = extra_index(tgt);
4642 BV_CLR(extras, what);
4643
4645 // Defeat keyboard shortcut mnemonics
4646 str = QString(extra_name_translation(tgt)).replace("&", "&&");
4647 qv1 = what;
4648 cd->add_item(str, func, qv1, qv2);
4649 }
4650 cd->set_layout();
4651 cd->show_me();
4652}
4653
4654/***********************************************************************/
4658 QWidget *parent) : hud_message_box(parent)
4659{
4660 QString str;
4661 QPushButton *pb;
4662
4663 setAttribute(Qt::WA_DeleteOnClose);
4664 setModal(false);
4669
4670 str = QString(PL_("Are you sure you want to disband that %1 unit?",
4671 "Are you sure you want to disband those %1 units?",
4673 pb = addButton(_("Yes"), QMessageBox::AcceptRole);
4674 addButton(_("No"), QMessageBox::RejectRole);
4675 set_text_title(str, _("Disband units"));
4677 connect(pb, &QAbstractButton::clicked, this, &disband_box::disband_clicked);
4678}
4679
4680/***********************************************************************/
4691
4692/***********************************************************************/
4699
4700/***********************************************************************/
4703void popup_disband_dialog(struct unit_list *punits)
4704{
4705 disband_box *ask = new disband_box(punits, gui()->central_wdg);
4706 ask->show();
4707}
4708
4709/***********************************************************************/
4714{
4715 hud_message_box *ask = new hud_message_box(gui()->central_wdg);
4716 QString text;
4717 QString title;
4718
4719 title = QString(_("Modpack suggests using %1 tileset."))
4721 text = QString("It might not work with other tilesets.\n"
4722 "You are currently using tileset %1.")
4724 ask->addButton(_("Keep current tileset"), QMessageBox::RejectRole);
4725 ask->addButton(_("Load tileset"), QMessageBox::AcceptRole);
4726 ask->set_text_title(text, title);
4727 ask->setAttribute(Qt::WA_DeleteOnClose);
4728
4729 QObject::connect(ask, &hud_message_box::accepted, [=]() {
4732 gui()->map_scale)) {
4734 _("Can't load requested tileset."));
4735 }
4736 });
4737 ask->show();
4738}
4739
4740/***********************************************************************/
4745{
4746 hud_message_box *ask = new hud_message_box(gui()->central_wdg);
4747 QString text;
4748 QString title;
4749
4750 title = QString(_("Modpack suggests using %1 soundset."))
4752 text = QString("It might not work with other tilesets.\n"
4753 "You are currently using soundset %1.")
4754 .arg(sound_set_name);
4755 ask->addButton(_("Keep current soundset"), QMessageBox::RejectRole);
4756 ask->addButton(_("Load soundset"), QMessageBox::AcceptRole);
4757 ask->set_text_title(text, title);
4758 ask->setAttribute(Qt::WA_DeleteOnClose);
4759 QObject::connect(ask, &hud_message_box::accepted, [=]() {
4761 });
4762 ask->show();
4763}
4764
4765/***********************************************************************/
4770{
4771 hud_message_box *ask = new hud_message_box(gui()->central_wdg);
4772 QString text;
4773 QString title;
4774
4775 title = QString(_("Modpack suggests using %1 musicset."))
4777 text = QString("It might not work with other tilesets.\n"
4778 "You are currently using musicset %1.")
4779 .arg(music_set_name);
4780 ask->addButton(_("Keep current musicset"), QMessageBox::RejectRole);
4781 ask->addButton(_("Load musicset"), QMessageBox::AcceptRole);
4782 ask->set_text_title(text, title);
4783 ask->setAttribute(Qt::WA_DeleteOnClose);
4784 QObject::connect(ask, &hud_message_box::accepted, [=]() {
4786 });
4787 ask->show();
4788}
4789
4790/***********************************************************************/
4795{
4796 // PORTME
4797 return false;
4798}
4799
4800/***********************************************************************/
4804{
4806 int i;
4807
4808 nd_list = gui()->mapview_wdg->findChildren<notify_dialog *>();
4809 for (i = 0; i < nd_list.count(); i++) {
4810 nd_list[i]->restart();
4811 delete nd_list[i];
4812 }
4813}
4814
4815/***********************************************************************/
4820{
4821 int i;
4824 goto_dialog *gtd;
4825
4826 QApplication::alert(gui()->central_wdg);
4827 cd_list = gui()->game_tab_widget->findChildren <choice_dialog *>();
4828 for (i = 0; i < cd_list.count(); i++) {
4829 cd_list[i]->close();
4830 }
4831 nd_list = gui()->game_tab_widget->findChildren <notify_dialog *>();
4832 for (i = 0; i < nd_list.count(); i++) {
4833 nd_list[i]->close();
4834 }
4835
4844 gui()->popdown_unit_sel();
4845
4846 gtd = gui()->gtd;
4847
4848 if (gtd != nullptr) {
4849 gtd->close_dlg();
4850 }
4851}
4852
4853/***********************************************************************/
4859{
4860 choice_dialog *cd = gui()->get_diplo_dialog();
4861
4862 if (cd != nullptr) {
4863 return cd->unit_id;
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_CITY];
4881 } else {
4882 return IDENTITY_NUMBER_ZERO;
4883 }
4884}
4885
4886/***********************************************************************/
4893{
4894 choice_dialog *cd = gui()->get_diplo_dialog();
4895
4896 if (cd != nullptr) {
4897 return cd->target_id[ATK_TILE];
4898 } else {
4899 return TILE_INDEX_NONE;
4900 }
4901}
4902
4903/**********************************************************************/
4910{
4911 choice_dialog *cd = gui()->get_diplo_dialog();
4912
4913 if (cd != nullptr) {
4914 return cd->sub_target_id[ASTK_EXTRA];
4915 } else {
4916 return EXTRA_NONE;
4917 }
4918}
4919
4920/***********************************************************************/
4927{
4928 choice_dialog *cd = gui()->get_diplo_dialog();
4929
4930 if (cd != nullptr) {
4931 return cd->target_id[ATK_UNIT];
4932 } else {
4933 return IDENTITY_NUMBER_ZERO;
4934 }
4935}
4936
4937/***********************************************************************/
4941 struct city *target_city,
4942 struct unit *target_unit,
4943 struct tile *target_tile,
4944 struct extra_type *target_extra,
4945 const struct act_prob *act_probs)
4946{
4949 Choice_dialog_button *cancel_button;
4950 QVariant qv1, qv2;
4951
4952 asd = gui()->get_diplo_dialog();
4953 if (asd == nullptr) {
4954 fc_assert_msg(asd != nullptr,
4955 "The action selection dialog should have been open");
4956 return;
4957 }
4958
4961 "The action selection dialog is for another actor unit.");
4962 }
4963
4964 // Put the actor id in qv1.
4965 qv1 = actor_unit->id;
4966
4967 cancel_button = asd->get_identified_button(BUTTON_CANCEL);
4968 if (cancel_button != nullptr) {
4969 /* Temporary remove the Cancel button so it won't end up above
4970 * any added buttons. */
4971 asd->stack_button(cancel_button);
4972 }
4973
4974 wait_button = asd->get_identified_button(BUTTON_WAIT);
4975 if (wait_button != nullptr) {
4976 /* Temporary remove the Wait button so it won't end up above
4977 * any added buttons. */
4978 asd->stack_button(wait_button);
4979 }
4980
4981 action_iterate(act) {
4982 const char *custom;
4983
4984 if (action_id_get_actor_kind(act) != AAK_UNIT) {
4985 // Not relevant.
4986 continue;
4987 }
4988
4990 act_probs[act],
4991 actor_unit,
4992 target_city);
4993
4994 // Put the target id in qv2.
4995 switch (action_id_get_target_kind(act)) {
4996 case ATK_UNIT:
4997 if (target_unit != nullptr) {
4998 qv2 = target_unit->id;
4999 } else {
5001 || target_unit != nullptr,
5002 "Action enabled against non existing unit!");
5003
5005 }
5006 break;
5007 case ATK_CITY:
5008 if (target_city != nullptr) {
5009 qv2 = target_city->id;
5010 } else {
5012 || target_city != nullptr,
5013 "Action enabled against non existing city!");
5014
5016 }
5017 break;
5018 case ATK_TILE:
5019 case ATK_EXTRAS:
5020 case ATK_STACK:
5021 if (target_tile != nullptr) {
5023 } else {
5025 || target_tile != nullptr,
5026 "Action enabled against all units on "
5027 "non existing tile!");
5028
5030 }
5031 break;
5032 case ATK_SELF:
5033 qv2 = actor_unit->id;
5034 break;
5035 case ATK_COUNT:
5037 "Bad target kind");
5038 continue;
5039 }
5040
5041 if (asd->get_identified_button(act)) {
5042 // Update the existing button.
5043 action_entry_update(asd->get_identified_button(act),
5044 act, act_probs, custom,
5045 qv1, qv2);
5046 } else {
5047 // Add the button (unless its probability is 0).
5049 qv1, qv2);
5050 }
5052
5053 if (wait_button != nullptr || cancel_button != nullptr) {
5054 /* Reinsert the non action buttons below any potential
5055 * buttons recently added. */
5056 asd->unstack_all_buttons();
5057 }
5058}
5059
5060/***********************************************************************/
5064{
5066
5067 cd = gui()->get_diplo_dialog();
5068 if (cd != nullptr) {
5069 did_not_decide = true;
5070 cd->close();
5071 }
5072}
5073
5074/***********************************************************************/
5080
5081/***********************************************************************/
5084void show_tileset_error(bool fatal, const char *tset_name, const char *msg)
5085{
5086 QWidget *parent;
5087 fc_client *std_gui = gui();
5088
5089 if (std_gui != nullptr) {
5090 parent = std_gui->central_wdg;
5091 } else {
5092 parent = nullptr;
5093 }
5094
5095 if (std_gui != nullptr || fatal) {
5096 char buf[1024];
5097 QMessageBox *ask = new QMessageBox(parent);
5098
5099 if (tset_name != nullptr) {
5100 fc_snprintf(buf, sizeof(buf),
5101 _("Tileset \"%s\" problem, it's probably incompatible with "
5102 "the ruleset:\n%s"), tset_name, msg);
5103 } else {
5104 fc_snprintf(buf, sizeof(buf),
5105 _("Tileset problem, it's probably incompatible with "
5106 "the ruleset:\n%s"), msg);
5107 }
5108
5109 ask->setText(buf);
5110 ask->setStandardButtons(QMessageBox::Ok);
5111 ask->setWindowTitle(_("Tileset error"));
5112
5113 if (std_gui != nullptr && !fatal) {
5114 ask->setAttribute(Qt::WA_DeleteOnClose);
5115 ask->show();
5116 } else {
5117 ask->exec();
5118 }
5119 }
5120}
5121
5122/***********************************************************************/
5125void popup_upgrade_dialog(struct unit_list *punits)
5126{
5127 char buf[512];
5129 QString title;
5131
5132 if (!punits || unit_list_size(punits) == 0) {
5133 return;
5134 }
5135
5136 ask = new hud_message_box(gui()->central_wdg);
5137
5138 punit_ids = new QVector<int>();
5140 punit_ids->push_back(punit->id);
5142
5143 if (!get_units_upgrade_info(buf, sizeof(buf), punits)) {
5144 title = _("Upgrade Unit!");
5145 ask->setStandardButtons(QMessageBox::Ok);
5146 } else {
5147 title = _("Upgrade Obsolete Units");
5148 ask->setStandardButtons(QMessageBox::Cancel | QMessageBox::Ok);
5149 ask->setDefaultButton(QMessageBox::Cancel);
5150 }
5151 ask->set_text_title(buf, title);
5152 ask->setAttribute(Qt::WA_DeleteOnClose);
5153 QObject::connect(ask, &hud_message_box::accepted, [=]() {
5154 std::unique_ptr<QVector<int>> uptr(punit_ids);
5155 struct unit *punit;
5156
5157 for (int id : *uptr) {
5159 if (punit) {
5161 }
5162 }
5163 });
5164 ask->show();
5165}
5166
5167/***********************************************************************/
5171{
5172 QPoint p, final_p;
5173
5175 utile = ptile;
5176 pix = nullptr;
5177 show_line = 0;
5178 highlight_num = -1;
5179 ufont.setItalic(true);
5181 update_units();
5182 h_pix = nullptr;
5183 create_pixmap();
5184 p = mapFromGlobal(QCursor::pos());
5185 cw = new close_widget(this);
5186 setMouseTracking(true);
5187 final_p.setX(p.x());
5188 final_p.setY(p.y());
5189 if (p.x() + width() > parentWidget()->width()) {
5190 final_p.setX(parentWidget()->width() - width());
5191 }
5192 if (p.y() - height() < 0) {
5193 final_p.setY(height());
5194 }
5195 move(final_p.x(), final_p.y() - height());
5196 setFocus();
5197 /* Build fails with qt5 connect style for static functions
5198 * Qt5.2 so dont update */
5199 QTimer::singleShot(10, this, SLOT(update_img()));
5200}
5201
5202/***********************************************************************/
5206{
5207 delete h_pix;
5208 delete pix;
5209 delete cw;
5210}
5211
5212/***********************************************************************/
5216{
5217 int a;
5218 int x, y, i;
5221 QImage img;
5223 QPainter p;
5224 QPen pen;
5225 QPixmap pixc;
5226 QPixmap *pixp;
5228 QRect crop;
5229 struct canvas *unit_pixmap;
5230 struct unit *punit;
5231 float isosize;
5232
5233 if (pix != nullptr) {
5234 delete pix;
5235 pix = nullptr;
5236 };
5237 isosize = 0.7;
5239 isosize = 0.5;
5240 }
5241
5242 update_units();
5243 if (unit_list.count() > 0) {
5247 } else {
5250 }
5251 more = false;
5252 if (h_pix != nullptr) {
5253 delete h_pix;
5254 }
5255 h_pix = new QPixmap(item_size.width(), item_size.height());
5256 h_pix->fill(palette().color(QPalette::HighlightedText));
5257 if (unit_count < 5) {
5258 row_count = 1;
5259 pix = new QPixmap((unit_list.size()) * item_size.width(),
5260 item_size.height());
5261 } else if (unit_count < 9) {
5262 row_count = 2;
5263 pix = new QPixmap(4 * item_size.width(), 2 * item_size.height());
5264 } else {
5265 row_count = 3;
5266 if (unit_count > 12) {
5267 more = true;
5268 }
5269 pix = new QPixmap(4 * item_size.width(), 3 * item_size.height());
5270 }
5271 pix->fill(Qt::transparent);
5272 foreach(punit, unit_list) {
5275 unit_pixmap->map_pixmap.fill(Qt::transparent);
5276 put_unit(punit, unit_pixmap, 1.0, 0, 0);
5277 img = unit_pixmap->map_pixmap.toImage();
5279 cropped_img = img.copy(crop);
5283 Qt::KeepAspectRatio,
5284 Qt::SmoothTransformation);
5285 } else {
5288 Qt::KeepAspectRatio,
5289 Qt::SmoothTransformation);
5290 }
5291 pixc = QPixmap::fromImage(img);
5292 pixp = new QPixmap(pixc);
5293 pix_list.push_back(pixp);
5295 }
5296 a = qMin(item_size.width() / 4, 12);
5297 x = 0, y = -item_size.height(), i = -1;
5298 p.begin(pix);
5299 ufont.setPixelSize(a);
5300 p.setFont(ufont);
5301 pen.setColor(palette().color(QPalette::Text));
5302 p.setPen(pen);
5303
5304 while (!pix_list.isEmpty()) {
5305 tmp_pix = pix_list.takeFirst();
5306 i++;
5307 if (i % 4 == 0) {
5308 x = 0;
5309 y = y + item_size.height();
5310 }
5311 punit = unit_list.at(i);
5312 Q_ASSERT(punit != nullptr);
5313
5314 if (i == highlight_num) {
5315 p.drawPixmap(x, y, *h_pix);
5316 p.drawPixmap(x, y, *tmp_pix);
5317 } else {
5318 p.drawPixmap(x, y, *tmp_pix);
5319 }
5320
5322 int rate, f;
5323 QString str;
5324
5326 f = ((punit->fuel) - 1);
5329 str = str + "(" + QString(move_points_text((rate * f)
5330 + punit->moves_left, false)) + ")";
5331 }
5332 // TRANS: MP = Movement points
5333 str = QString(_("MP:")) + str;
5334 p.drawText(x, y + item_size.height() - 4, str);
5335 }
5336
5337 x = x + item_size.width();
5338 delete tmp_pix;
5339 }
5340 p.end();
5341 setFixedWidth(pix->width() + 20);
5342 setFixedHeight(pix->height() + 2 * (fm.height() + 6));
5343 qDeleteAll(pix_list.begin(), pix_list.end());
5344 }
5345}
5346
5347/***********************************************************************/
5351{
5352 int a, b;
5353 int old_h;
5355 QPoint pos = event->pos();
5356 int x = pos.x();
5357 int y = pos.y();
5358
5360 highlight_num = -1;
5361 if (x > width() - 11
5362 || y > height() - fm.height() - 5
5363 || y < fm.height() + 3 || x < 11) {
5364 // Do nothing if mouse is on border, just skip next if
5365 } else if (row_count > 0) {
5366 a = (x - 10) / item_size.width();
5367 b = (y - fm.height() - 3) / item_size.height();
5368 highlight_num = b * 4 + a;
5369 }
5370 if (old_h != highlight_num) {
5371 create_pixmap();
5372 update();
5373 }
5374}
5375
5376/***********************************************************************/
5382{
5383 struct unit *punit;
5384 if (event->button() == Qt::RightButton) {
5385 was_destroyed = true;
5386 close();
5387 destroy();
5388 }
5389 if (event->button() == Qt::LeftButton && highlight_num != -1) {
5390 update_units();
5391 if (highlight_num >= unit_list.count()) {
5392 return;
5393 }
5396 was_destroyed = true;
5397 close();
5398 destroy();
5399 }
5400}
5401
5402/***********************************************************************/
5407{
5408 create_pixmap();
5409 update();
5410}
5411
5412/***********************************************************************/
5416{
5418 int h, i;
5419 int *f_size;
5420 QPen pen;
5421 QString str, str2;
5422 struct unit *punit;
5423 int point_size = info_font.pointSize();
5424 int pixel_size = info_font.pixelSize();
5425
5426 if (point_size < 0) {
5427 f_size = &pixel_size;
5428 } else {
5429 f_size = &point_size;
5430 }
5431 if (highlight_num != -1 && highlight_num < unit_list.count()) {
5432 struct astring addition = ASTRING_INIT;
5433
5436
5437 // TRANS: HP - hit points
5438 str2 = QString(_("%1 HP:%2/%3")).arg(QString(astr_str(&addition)),
5439 QString::number(punit->hp),
5440 QString::number(unit_type_get(punit)->hp));
5442 }
5443 str = QString(PL_("%1 unit", "%1 units",
5445 .arg(unit_list_size(utile->units));
5446 for (i = *f_size; i > 4; i--) {
5447 if (point_size < 0) {
5448 info_font.setPixelSize(i);
5449 } else {
5450 info_font.setPointSize(i);
5451 }
5453 if (10 + qfm.horizontalAdvance(str2) < width()) {
5454 break;
5455 }
5456 }
5457 h = fm.height();
5458 if (pix != nullptr) {
5459 painter->drawPixmap(10, h + 3, *pix);
5460 pen.setColor(palette().color(QPalette::Text));
5461 painter->setPen(pen);
5462 painter->setFont(info_font);
5463 painter->drawText(10, h, str);
5464 if (highlight_num != -1 && highlight_num < unit_list.count()) {
5465 painter->drawText(10, height() - 5, str2);
5466 }
5467 // Draw scroll
5468 if (more) {
5469 int maxl = ((unit_count - 1) / 4) + 1;
5470 float page_height = 3.0f / maxl;
5471 float page_start = (static_cast<float>(show_line)) / maxl;
5472 pen.setColor(palette().color(QPalette::HighlightedText));
5473 painter->setBrush(palette().color(QPalette::HighlightedText).darker());
5474 painter->setPen(palette().color(QPalette::HighlightedText).darker());
5475 painter->drawRect(pix->width() + 10, h, 8, h + pix->height());
5476 painter->setPen(pen);
5477 painter->drawRoundedRect(pix->width() + 10,
5478 h + page_start * pix->height(),
5479 8, h + page_height * pix->height(), 2, 2);
5480 }
5481 }
5482 if (point_size < 0) {
5483 info_font.setPixelSize(*f_size);
5484 } else {
5485 info_font.setPointSize(*f_size);
5486 }
5487 cw->put_to_corner();
5488}
5489
5490/***********************************************************************/
5494{
5496
5497 painter.begin(this);
5498 paint(&painter, event);
5499 painter.end();
5500}
5501
5502/***********************************************************************/
5507{
5508 was_destroyed = true;
5509 close();
5510 destroy();
5511}
5512
5513/***********************************************************************/
5517{
5518 int i = 1;
5519 struct unit_list *punit_list;
5520
5521 unit_count = 0;
5522 if (utile == nullptr) {
5523 struct unit *punit = head_of_units_in_focus();
5524 if (punit) {
5526 }
5527 }
5528 unit_list.clear();
5529 if (utile != nullptr) {
5531 if (punit_list != nullptr) {
5533 unit_count++;
5534 if (i > show_line * 4)
5535 unit_list.push_back(punit);
5536 i++;
5538 }
5539 }
5540 if (unit_list.count() == 0) {
5541 close();
5542 }
5543}
5544
5545/***********************************************************************/
5549{
5550 gui()->mapview_wdg->setFocus();
5551 QWidget::closeEvent(event);
5552}
5553
5554/***********************************************************************/
5558{
5559 int nr;
5560
5561 if (!more && utile == nullptr) {
5562 return;
5563 }
5564 nr = qCeil(static_cast<qreal>(unit_list_size(utile->units)) / 4) - 3;
5565 if (event->angleDelta().y() < 0) {
5566 show_line++;
5568 } else {
5569 show_line--;
5570 show_line = qMax(0, show_line);
5571 }
5572 update_units();
5573 create_pixmap();
5574 update();
5575 event->accept();
5576}
5577
5578/***********************************************************************/
5582{
5583 if (event->key() == Qt::Key_Escape) {
5584 was_destroyed = true;
5585 close();
5586 destroy();
5587 }
5588 QWidget::keyPressEvent(event);
5589}
5590
5591/***********************************************************************/
5598
5599/***********************************************************************/
5606
5607/***********************************************************************/
5612{
5613 // Just tell the client common code to handle this.
5614 return false;
5615}
5616
5617/***********************************************************************/
5620bool qtg_request_transport(struct unit *pcargo, struct tile *ptile)
5621{
5622 int tcount;
5624 struct unit_list *potential_transports = unit_list_new();
5625#ifndef FREECIV_NDEBUG
5627#endif
5628
5632 }
5634
5636
5637 if (tcount == 0) {
5638 fc_assert(best_transport == nullptr);
5640
5641 return false; // Unit was not handled here.
5642 } else if (tcount == 1) {
5643 // There's exactly one potential transport - use it automatically
5646
5648
5649 return true;
5650 }
5651
5652 hul = new hud_unit_loader(pcargo, ptile);
5653 hul->show_me();
5654 return true;
5655}
5656
5657/***********************************************************************/
5661void qtg_popup_combat_info(int attacker_unit_id, int defender_unit_id,
5662 int attacker_hp, int defender_hp,
5663 bool make_att_veteran, bool make_def_veteran)
5664{
5665 if (gui()->qt_settings.show_battle_log) {
5666 hud_unit_combat *huc = new hud_unit_combat(attacker_unit_id,
5667 defender_unit_id,
5668 attacker_hp, defender_hp,
5669 make_att_veteran,
5670 make_def_veteran,
5671 gui()->battlelog_wdg->scale,
5672 gui()->battlelog_wdg);
5673
5674 gui()->battlelog_wdg->add_combat_info(huc);
5675 gui()->battlelog_wdg->show();
5676 }
5677}
5678
5679/**********************************************************************/
5683 struct act_confirmation_data *data)
5684{
5685 hud_message_box *ask = new hud_message_box(gui()->central_wdg);
5686
5687 ask->setStandardButtons(QMessageBox::Cancel | QMessageBox::Ok);
5688 ask->setDefaultButton(QMessageBox::Cancel);
5689 ask->set_text_title(body, hdr);
5690 ask->setAttribute(Qt::WA_DeleteOnClose);
5691 QObject::connect(ask, &hud_message_box::accepted, [=]() {
5693 });
5694 QObject::connect(ask, &hud_message_box::rejected, [=]() {
5696 });
5697
5698 ask->show();
5699}
5700
5701/***********************************************************************/
5705 struct act_confirmation_data *data)
5706{
5708
5709 hdr = QString(_("Are you sure you want to do %1?")).
5711
5712 if (expl != nullptr) {
5714 }
5715
5717}
5718
5719/**********************************************************************/
5722void qtg_popup_image(const char *tag)
5723{
5724 struct sprite *spr = load_popup_sprite(tag);
5725
5726 if (spr != nullptr) {
5727 QDialog *win = new QDialog(gui());
5728 QVBoxLayout *layout = new QVBoxLayout(win);
5729 QPixmap *pm = new QPixmap(*spr->pm);
5730 QLabel *lbl = new QLabel;
5731 int width, height;
5732
5734 win->setFixedSize(width, height);
5735 lbl->setPixmap(*pm);
5736 layout->addWidget(lbl);
5737 win->setLayout(layout);
5738
5739 win->show();
5740
5742 } else {
5743 log_error(_("No image for tag \"%s\", requested by the server."), tag);
5744 }
5745}
const char * action_prepare_ui_name(action_id act_id, const char *mnemonic, const struct act_prob prob, const char *custom)
Definition actions.c:1338
const char * action_id_name_translation(action_id act_id)
Definition actions.c:1276
bool action_prob_possible(const struct act_prob probability)
Definition actions.c:5327
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:378
#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:666
const char * city_name_get(const struct city *pcity)
Definition city.c:1157
#define INCITE_IMPOSSIBLE_COST
Definition city.h:94
#define city_owner(_pcity_)
Definition city.h:564
#define city_built_iterate(_pcity, _p)
Definition city.h:842
#define city_built_iterate_end
Definition city.h:848
void qtg_real_city_dialog_popup(struct city *pcity)
Definition citydlg.cpp:3868
Choice_dialog_button(const QString title, pfcn_void func_in, QVariant data1_in, QVariant data2_in)
Definition dialogs.cpp:1411
void setData2(QVariant wariat)
Definition dialogs.cpp:1459
void setData1(QVariant wariat)
Definition dialogs.cpp:1451
pfcn_void getFunc()
Definition dialogs.cpp:1425
void stack_button(Choice_dialog_button *button)
Definition dialogs.cpp:1786
void prev_unit()
Definition dialogs.cpp:1703
QVBoxLayout * layout
Definition dialogs.h:263
struct unit * targeted_unit
Definition dialogs.h:286
void unstack_all_buttons()
Definition dialogs.cpp:1803
Choice_dialog_button * get_identified_button(const int id)
Definition dialogs.cpp:1615
QPushButton * target_unit_button
Definition dialogs.h:262
void set_layout()
Definition dialogs.cpp:1521
void update_dialog(const struct act_prob *act_probs)
Definition dialogs.cpp:1732
QList< Choice_dialog_button * > last_buttons_stack
Definition dialogs.h:266
void next_unit()
Definition dialogs.cpp:1663
QVBoxLayout * get_layout()
Definition dialogs.cpp:1607
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:1467
int target_id[ATK_COUNT]
Definition dialogs.h:284
void switch_target()
Definition dialogs.cpp:1750
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:1769
void add_item(QString title, pfcn_void func, QVariant data1, QVariant data2, QString tool_tip, const int button_id)
Definition dialogs.cpp:1563
void put_to_corner()
Definition mapview.cpp:503
void disband_clicked()
Definition dialogs.cpp:4683
disband_box(struct unit_list *punits, QWidget *parent=0)
Definition dialogs.cpp:4657
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:5602
void set_diplo_dialog(choice_dialog *widget)
Definition dialogs.cpp:5594
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:985
close_widget * cw
Definition dialogs.h:189
void mouseReleaseEvent(QMouseEvent *event)
Definition dialogs.cpp:1078
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:952
void calc_size(int &x, int &y)
Definition dialogs.cpp:1013
void paintEvent(QPaintEvent *paint_event)
Definition dialogs.cpp:1032
QPoint cursor
Definition dialogs.h:196
void mouseMoveEvent(QMouseEvent *event)
Definition dialogs.cpp:1068
virtual void update_menu()
Definition dialogs.cpp:1086
void mousePressEvent(QMouseEvent *event)
Definition dialogs.cpp:1055
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:1187
QPushButton * goto_but
Definition dialogs.h:111
void inspect_city()
Definition dialogs.cpp:1230
struct tile * gtile
Definition dialogs.h:114
QPushButton * inspect_but
Definition dialogs.h:112
void goto_tile()
Definition dialogs.cpp:1221
action_id vs_unit
Definition dialogs.h:60
static qdef_act * action()
Definition dialogs.cpp:1115
action_id vs_city_get()
Definition dialogs.cpp:1153
static qdef_act * m_instance
Definition dialogs.h:58
static void drop()
Definition dialogs.cpp:1126
action_id vs_city
Definition dialogs.h:59
void vs_city_set(int i)
Definition dialogs.cpp:1137
void vs_unit_set(int i)
Definition dialogs.cpp:1145
action_id vs_unit_get()
Definition dialogs.cpp:1161
QPoint point
Definition dialogs.h:81
void paintEvent(QPaintEvent *event)
Definition dialogs.cpp:428
QPixmap close_pix
Definition dialogs.h:83
void reactivate()
Definition dialogs.cpp:420
void mouseMoveEvent(QMouseEvent *event)
Definition dialogs.cpp:469
int titlebar_height
Definition dialogs.h:80
void mousePressEvent(QMouseEvent *event)
Definition dialogs.cpp:479
void mouseReleaseEvent(QMouseEvent *event)
Definition dialogs.cpp:499
qfc_dialog(QWidget *parent)
Definition dialogs.cpp:408
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:1177
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:688
void style_selected(const QItemSelection &selected)
Definition dialogs.cpp:881
void nationset_changed(int index)
Definition dialogs.cpp:1242
int selected_nation
Definition dialogs.h:163
void ok_pressed()
Definition dialogs.cpp:914
void leader_selected(int index)
Definition dialogs.cpp:899
QPushButton * ok_button
Definition dialogs.h:142
QTextEdit * description
Definition dialogs.h:141
void set_index(int index)
Definition dialogs.cpp:771
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:738
QTableWidget * styles
Definition dialogs.h:140
void group_selected(const QItemSelection &selected)
Definition dialogs.cpp:754
struct player * tplayer
Definition dialogs.h:165
races_dialog(struct player *pplayer, QWidget *parent=0)
Definition dialogs.cpp:508
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:831
void cancel_pressed()
Definition dialogs.cpp:1169
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:5548
void update_img()
Definition dialogs.cpp:5406
int show_line
Definition dialogs.h:233
void mouseMoveEvent(QMouseEvent *event)
Definition dialogs.cpp:5350
void paint(QPainter *painter, QPaintEvent *event)
Definition dialogs.cpp:5415
void update_menu()
Definition dialogs.cpp:5506
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:5170
void update_units()
Definition dialogs.cpp:5516
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:5493
void create_pixmap()
Definition dialogs.cpp:5215
void wheelEvent(QWheelEvent *event)
Definition dialogs.cpp:5557
void keyPressEvent(QKeyEvent *event)
Definition dialogs.cpp:5581
void mousePressEvent(QMouseEvent *event)
Definition dialogs.cpp:5381
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:1264
char * incite_cost
Definition comments.c:77
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:5611
static void mine2(QVariant data1, QVariant data2)
Definition dialogs.cpp:3419
static void attack(QVariant data1, QVariant data2)
Definition dialogs.cpp:3497
static void wipe_units(QVariant data1, QVariant data2)
Definition dialogs.cpp:3025
char forced_tileset_name[512]
static void bombard4(QVariant data1, QVariant data2)
Definition dialogs.cpp:3097
int action_selection_target_extra(void)
Definition dialogs.cpp:4909
static void suicide_attack2(QVariant data1, QVariant data2)
Definition dialogs.cpp:3542
static void destroy_city(QVariant data1, QVariant data2)
Definition dialogs.cpp:4039
static void spy_sabotage_unit(QVariant data1, QVariant data2)
Definition dialogs.cpp:2631
static void pillage(QVariant data1, QVariant data2)
Definition dialogs.cpp:3234
static void caravan_marketplace(QVariant data1, QVariant data2)
Definition dialogs.cpp:1817
static void clean(QVariant data1, QVariant data2)
Definition dialogs.cpp:3274
static void spy_steal_shared(QVariant data1, QVariant data2, action_id act_id)
Definition dialogs.cpp:3782
static void clean2(QVariant data1, QVariant data2)
Definition dialogs.cpp:3294
static void spy_sabotage(QVariant data1, QVariant data2)
Definition dialogs.cpp:4523
int action_selection_target_tile(void)
Definition dialogs.cpp:4892
static void teleport_enter(QVariant data1, QVariant data2)
Definition dialogs.cpp:3722
static void conquer_extras3(QVariant data1, QVariant data2)
Definition dialogs.cpp:2016
static void spy_investigate(QVariant data1, QVariant data2)
Definition dialogs.cpp:4159
static void act_sel_wait(QVariant data1, QVariant data2)
Definition dialogs.cpp:2044
static void nuke_units(QVariant data1, QVariant data2)
Definition dialogs.cpp:2989
int action_selection_actor_unit(void)
Definition dialogs.cpp:4858
static void capture_units(QVariant data1, QVariant data2)
Definition dialogs.cpp:3037
static void road(QVariant data1, QVariant data2)
Definition dialogs.cpp:3314
static bool is_race_dialog_open
Definition dialogs.cpp:228
static void transport_embark4(QVariant data1, QVariant data2)
Definition dialogs.cpp:2743
bool try_default_unit_action(QVariant q1, QVariant q2)
Definition dialogs.cpp:1628
static void fortify(QVariant data1, QVariant data2)
Definition dialogs.cpp:2542
static void teleport_frighten(QVariant data1, QVariant data2)
Definition dialogs.cpp:3662
static void transport_board(QVariant data1, QVariant data2)
Definition dialogs.cpp:2677
static void diplomat_bribe_unit(QVariant data1, QVariant data2)
Definition dialogs.cpp:2596
static void spy_sabotage_unit_esc(QVariant data1, QVariant data2)
Definition dialogs.cpp:2643
static void disband_unit(QVariant data1, QVariant data2)
Definition dialogs.cpp:2530
static void spy_steal_gold(QVariant data1, QVariant data2)
Definition dialogs.cpp:4054
void popdown_players_report()
Definition plrdlg.cpp:1197
static void conquer_city_shrink2(QVariant data1, QVariant data2)
Definition dialogs.cpp:1943
static void spy_escape(QVariant data1, QVariant data2)
Definition dialogs.cpp:4114
static void mine(QVariant data1, QVariant data2)
Definition dialogs.cpp:3398
void popup_musicset_suggestion_dialog(void)
Definition dialogs.cpp:4769
static void spy_steal_gold_esc(QVariant data1, QVariant data2)
Definition dialogs.cpp:4069
static void diplomat_embassy(QVariant data1, QVariant data2)
Definition dialogs.cpp:4144
void unit_select_dialog_popup(struct tile *ptile)
Definition dialogs.cpp:1327
void popup_upgrade_dialog(struct unit_list *punits)
Definition dialogs.cpp:5125
void update_nationset_combo()
Definition dialogs.cpp:1347
void action_selection_close(void)
Definition dialogs.cpp:5063
static void cultivate(QVariant data1, QVariant data2)
Definition dialogs.cpp:3174
static void paradrop_enter(QVariant data1, QVariant data2)
Definition dialogs.cpp:3707
void races_update_pickable(bool nationset_change)
Definition dialogs.cpp:1357
int action_selection_target_city(void)
Definition dialogs.cpp:4875
static void spy_steal_something(QVariant data1, QVariant data2)
Definition dialogs.cpp:3872
#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:1265
static void spy_poison(QVariant data1, QVariant data2)
Definition dialogs.cpp:3949
static void transport_board2(QVariant data1, QVariant data2)
Definition dialogs.cpp:2688
void show_tech_gained_dialog(Tech_type_id tech)
Definition dialogs.cpp:5077
static void base(QVariant data1, QVariant data2)
Definition dialogs.cpp:3356
static void spy_nuke_city_esc(QVariant data1, QVariant data2)
Definition dialogs.cpp:4009
static void teleport(QVariant data1, QVariant data2)
Definition dialogs.cpp:3572
void popup_soundset_suggestion_dialog(void)
Definition dialogs.cpp:4744
static void enter_hut2(QVariant data1, QVariant data2)
Definition dialogs.cpp:2884
void popup_races_dialog(struct player *pplayer)
Definition dialogs.cpp:1302
static void expel_unit(QVariant data1, QVariant data2)
Definition dialogs.cpp:3049
static void paradrop_frighten(QVariant data1, QVariant data2)
Definition dialogs.cpp:3647
static void diplomat_sabotage(QVariant data1, QVariant data2)
Definition dialogs.cpp:4189
void popup_disband_dialog(struct unit_list *punits)
Definition dialogs.cpp:4703
static action_id get_non_targeted_action_id(action_id tgt_action_id)
Definition dialogs.cpp:2425
static void road2(QVariant data1, QVariant data2)
Definition dialogs.cpp:3335
static void homeless(QVariant data1, QVariant data2)
Definition dialogs.cpp:2582
static void caravan_help_build(QVariant data1, QVariant data2)
Definition dialogs.cpp:1847
void qtg_popup_image(const char *tag)
Definition dialogs.cpp:5722
static void scout(QVariant data1, QVariant data2)
Definition dialogs.cpp:4330
static void bombard(QVariant data1, QVariant data2)
Definition dialogs.cpp:3061
void popup_bribe_stack_dialog(struct unit *actor, struct tile *ttile, int cost, const struct action *paction)
Definition dialogs.cpp:4456
void popdown_races_dialog(void)
Definition dialogs.cpp:1316
void popup_tileset_suggestion_dialog(void)
Definition dialogs.cpp:4713
void revolution_response(struct government *gov)
Definition dialogs.cpp:2059
void popdown_economy_report()
static void join_city(QVariant data1, QVariant data2)
Definition dialogs.cpp:3767
static void spy_request_sabotage_list(QVariant data1, QVariant data2)
Definition dialogs.cpp:3912
static void popup_act_confirmation_dialog(QString hdr, QString body, struct act_confirmation_data *data)
Definition dialogs.cpp:5682
static void unit_disband_recover(QVariant data1, QVariant data2)
Definition dialogs.cpp:1862
static void spy_steal(QVariant data1, QVariant data2)
Definition dialogs.cpp:3856
static void conquer_extras4(QVariant data1, QVariant data2)
Definition dialogs.cpp:2030
static void frighten_hut4(QVariant data1, QVariant data2)
Definition dialogs.cpp:2974
static void airlift(QVariant data1, QVariant data2)
Definition dialogs.cpp:1913
void popup_pillage_dialog(struct unit *punit, bv_extras extras)
Definition dialogs.cpp:4624
static void enter_hut3(QVariant data1, QVariant data2)
Definition dialogs.cpp:2899
static void transport_load3(QVariant data1, QVariant data2)
Definition dialogs.cpp:2787
static void spy_attack(QVariant data1, QVariant data2)
Definition dialogs.cpp:3013
static void bombard_lethal(QVariant data1, QVariant data2)
Definition dialogs.cpp:3109
static void plant(QVariant data1, QVariant data2)
Definition dialogs.cpp:3204
static void diplomat_bribe_stack(QVariant data1, QVariant data2)
Definition dialogs.cpp:2614
static void nuke(QVariant data1, QVariant data2)
Definition dialogs.cpp:3482
static void disembark2(QVariant data1, QVariant data2)
Definition dialogs.cpp:2824
static void plant2(QVariant data1, QVariant data2)
Definition dialogs.cpp:3219
static void transport_unload(QVariant data1, QVariant data2)
Definition dialogs.cpp:2754
void qtg_request_action_confirmation(const char *expl, struct act_confirmation_data *data)
Definition dialogs.cpp:5704
static void teleport_conquer(QVariant data1, QVariant data2)
Definition dialogs.cpp:3632
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:4940
void popdown_science_report()
static void transport_load2(QVariant data1, QVariant data2)
Definition dialogs.cpp:2776
static void diplomat_steal(QVariant data1, QVariant data2)
Definition dialogs.cpp:4219
static void unit_upgrade(QVariant data1, QVariant data2)
Definition dialogs.cpp:1892
bool popup_theme_suggestion_dialog(const char *theme_name)
Definition dialogs.cpp:4794
static void enter_hut(QVariant data1, QVariant data2)
Definition dialogs.cpp:2869
static void spy_request_strike_bld_list(QVariant data1, QVariant data2)
Definition dialogs.cpp:3895
static void diplomat_incite_escape(QVariant data1, QVariant data2)
Definition dialogs.cpp:4267
static void pillage2(QVariant data1, QVariant data2)
Definition dialogs.cpp:3254
static void found_city(QVariant data1, QVariant data2)
Definition dialogs.cpp:3133
static void diplomat_investigate(QVariant data1, QVariant data2)
Definition dialogs.cpp:4174
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:5661
static void bombard3(QVariant data1, QVariant data2)
Definition dialogs.cpp:3085
static void transport_deboard(QVariant data1, QVariant data2)
Definition dialogs.cpp:2798
static void diplomat_incite(QVariant data1, QVariant data2)
Definition dialogs.cpp:4249
static void paradrop_conquer(QVariant data1, QVariant data2)
Definition dialogs.cpp:3617
void popdown_endgame_report()
static void diplomat_steal_esc(QVariant data1, QVariant data2)
Definition dialogs.cpp:4234
static void irrigate2(QVariant data1, QVariant data2)
Definition dialogs.cpp:3461
static void cultivate2(QVariant data1, QVariant data2)
Definition dialogs.cpp:3189
static void bombard_lethal2(QVariant data1, QVariant data2)
Definition dialogs.cpp:3121
static void frighten_hut3(QVariant data1, QVariant data2)
Definition dialogs.cpp:2959
static bool is_more_user_input_needed
Definition dialogs.cpp:233
static void bombard2(QVariant data1, QVariant data2)
Definition dialogs.cpp:3073
void popup_incite_dialog(struct unit *actor, struct city *tcity, int cost, const struct action *paction)
Definition dialogs.cpp:4346
static const QHash< action_id, pfcn_void > af_map_init(void)
Definition dialogs.cpp:246
void popdown_all_spaceships_dialogs()
static void nuke_city(QVariant data1, QVariant data2)
Definition dialogs.cpp:4024
static void transform_terrain2(QVariant data1, QVariant data2)
Definition dialogs.cpp:3159
void popup_connect_msg(const char *headline, const char *message)
Definition dialogs.cpp:1277
static void conquer_city_shrink(QVariant data1, QVariant data2)
Definition dialogs.cpp:1928
static void conquer_city_shrink3(QVariant data1, QVariant data2)
Definition dialogs.cpp:1958
static void diplomat_sabotage_esc(QVariant data1, QVariant data2)
Definition dialogs.cpp:4204
void popdown_units_report()
static void transport_embark2(QVariant data1, QVariant data2)
Definition dialogs.cpp:2721
static void spy_nuke_city(QVariant data1, QVariant data2)
Definition dialogs.cpp:3994
static void teleport_frighten_conquer(QVariant data1, QVariant data2)
Definition dialogs.cpp:3692
void unit_select_dialog_update_real(void *unused)
Definition dialogs.cpp:1339
static void spy_steal_esc(QVariant data1, QVariant data2)
Definition dialogs.cpp:3864
static void paradrop(QVariant data1, QVariant data2)
Definition dialogs.cpp:3557
static void suicide_attack(QVariant data1, QVariant data2)
Definition dialogs.cpp:3527
void races_toggles_set_sensitive(void)
Definition dialogs.cpp:1368
static void transport_load(QVariant data1, QVariant data2)
Definition dialogs.cpp:2765
static void fortify2(QVariant data1, QVariant data2)
Definition dialogs.cpp:2556
static action_id get_production_targeted_action_id(action_id tgt_action_id)
Definition dialogs.cpp:2448
static void paradrop_frighten_conquer(QVariant data1, QVariant data2)
Definition dialogs.cpp:3677
static void convert_unit(QVariant data1, QVariant data2)
Definition dialogs.cpp:2570
static void teleport2(QVariant data1, QVariant data2)
Definition dialogs.cpp:3587
static bool did_not_decide
Definition dialogs.cpp:237
static void spy_poison_esc(QVariant data1, QVariant data2)
Definition dialogs.cpp:3964
static void pillage_something(QVariant data1, QVariant data2)
Definition dialogs.cpp:4503
static void spy_request_sabotage_esc_list(QVariant data1, QVariant data2)
Definition dialogs.cpp:3930
void show_tileset_error(bool fatal, const char *tset_name, const char *msg)
Definition dialogs.cpp:5084
static void transform_terrain(QVariant data1, QVariant data2)
Definition dialogs.cpp:3144
static void attack2(QVariant data1, QVariant data2)
Definition dialogs.cpp:3512
#define BUTTON_CANCEL
Definition dialogs.cpp:72
static void conquer_extras(QVariant data1, QVariant data2)
Definition dialogs.cpp:1988
static void regular_move(QVariant data1, QVariant data2)
Definition dialogs.cpp:4285
static void heal_unit2(QVariant data1, QVariant data2)
Definition dialogs.cpp:2666
static void transport_board3(QVariant data1, QVariant data2)
Definition dialogs.cpp:2699
static void spy_embassy(QVariant data1, QVariant data2)
Definition dialogs.cpp:4129
static races_dialog * race_dialog
Definition dialogs.cpp:227
static void conquer_city_shrink4(QVariant data1, QVariant data2)
Definition dialogs.cpp:1973
static void teleport3(QVariant data1, QVariant data2)
Definition dialogs.cpp:3602
static void base2(QVariant data1, QVariant data2)
Definition dialogs.cpp:3377
static void frighten_hut2(QVariant data1, QVariant data2)
Definition dialogs.cpp:2944
static void conquer_extras2(QVariant data1, QVariant data2)
Definition dialogs.cpp:2002
static void regular_move2(QVariant data1, QVariant data2)
Definition dialogs.cpp:4300
static void frighten_hut(QVariant data1, QVariant data2)
Definition dialogs.cpp:2929
bool qtg_request_transport(struct unit *pcargo, struct tile *ptile)
Definition dialogs.cpp:5620
static void disembark4(QVariant data1, QVariant data2)
Definition dialogs.cpp:2854
int action_selection_target_unit(void)
Definition dialogs.cpp:4926
static void irrigate(QVariant data1, QVariant data2)
Definition dialogs.cpp:3440
static void transport_embark3(QVariant data1, QVariant data2)
Definition dialogs.cpp:2732
static void collect_ransom(QVariant data1, QVariant data2)
Definition dialogs.cpp:3001
static void heal_unit(QVariant data1, QVariant data2)
Definition dialogs.cpp:2655
void popdown_city_report()
Definition cityrep.cpp:1339
static void teleport_enter_conquer(QVariant data1, QVariant data2)
Definition dialogs.cpp:3752
static void regular_move3(QVariant data1, QVariant data2)
Definition dialogs.cpp:4315
static void paradrop_enter_conquer(QVariant data1, QVariant data2)
Definition dialogs.cpp:3737
static void unit_home_city(QVariant data1, QVariant data2)
Definition dialogs.cpp:1877
static void transport_embark(QVariant data1, QVariant data2)
Definition dialogs.cpp:2710
bool try_default_city_action(QVariant q1, QVariant q2)
Definition dialogs.cpp:1646
static void keep_moving(QVariant data1, QVariant data2)
Definition dialogs.cpp:2052
static void spy_steal_maps_esc(QVariant data1, QVariant data2)
Definition dialogs.cpp:4099
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:2501
static void disembark1(QVariant data1, QVariant data2)
Definition dialogs.cpp:2809
void restart_notify_dialogs()
Definition dialogs.cpp:4803
static void disembark3(QVariant data1, QVariant data2)
Definition dialogs.cpp:2839
static bool is_showing_pillage_dialog
Definition dialogs.cpp:226
static void spy_spread_plague(QVariant data1, QVariant data2)
Definition dialogs.cpp:3979
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:2468
static const QHash< action_id, pfcn_void > af_map
Definition dialogs.cpp:403
static void enter_hut4(QVariant data1, QVariant data2)
Definition dialogs.cpp:2914
static void caravan_establish_trade(QVariant data1, QVariant data2)
Definition dialogs.cpp:1832
void popdown_all_game_dialogs(void)
Definition dialogs.cpp:4819
static void spy_steal_maps(QVariant data1, QVariant data2)
Definition dialogs.cpp:4084
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:82
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:238
int action_id
Definition fc_types.h:250
int Government_type_id
Definition fc_types.h:242
#define IDENTITY_NUMBER_ZERO
Definition fc_types.h:94
#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:62
struct world wld
Definition game.c:63
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:92
#define G_LAST
Definition government.h:50
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 CAPTURE_DEFAULT_THIS
Definition gui_main.h:23
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:5133
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
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)
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:53
const char *const notify_label
Definition fonts.h:28
Nation_type_id nation_number(const struct nation_type *pnation)
Definition nation.c:484
bool nation_leader_is_male(const struct nation_leader *pleader)
Definition nation.c:295
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:472
int nation_set_index(const struct nation_set *pset)
Definition nation.c:698
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:231
const char * nation_set_name_translation(const struct nation_set *pset)
Definition nation.c:815
bool is_nation_playable(const struct nation_type *nation)
Definition nation.c:201
bool nation_is_in_group(const struct nation_type *pnation, const struct nation_group *pgroup)
Definition nation.c:1088
const char * nation_set_description(const struct nation_set *pset)
Definition nation.c:824
const char * nation_group_name_translation(const struct nation_group *pgroup)
Definition nation.c:1080
int nation_set_count(void)
Definition nation.c:690
struct nation_group * nation_group_by_number(int id)
Definition nation.c:999
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:1051
struct nation_set * nation_set_by_setting_value(const char *setting)
Definition nation.c:853
const char * nation_leader_name(const struct nation_leader *pleader)
Definition nation.c:287
int nation_group_count(void)
Definition nation.c:929
const char * nation_set_rule_name(const struct nation_set *pset)
Definition nation.c:806
struct nation_style * style_of_nation(const struct nation_type *pnation)
Definition nation.c:670
#define nation_leader_list_iterate(leaderlist, pleader)
Definition nation.h:57
#define nation_sets_iterate_end
Definition nation.h:333
#define nation_sets_iterate(NAME_pset)
Definition nation.h:329
#define nations_iterate_end
Definition nation.h:364
#define nations_iterate(NAME_pnation)
Definition nation.h:361
#define nation_leader_list_iterate_end
Definition nation.h:59
const struct option_set * server_optset
Definition options.c:4369
bool option_str_set(struct option *poption, const char *str)
Definition options.c:977
const char * option_str_get(const struct option *poption)
Definition options.c:944
struct option * optset_option_by_name(const struct option_set *poptset, const char *name)
Definition options.c:482
#define REQEST_PLAYER_INITIATED
Definition packets.h:63
void start_revolution(void)
Definition packhand.c:2415
void set_government_choice(struct government *government)
Definition packhand.c:2401
char * lines
Definition packhand.c:133
int player_number(const struct player *pplayer)
Definition player.c:826
const char * research_advance_name_translation(const struct research *presearch, Tech_type_id tech)
Definition research.c:276
struct research * research_get(const struct player *pplayer)
Definition research.c:130
enum tech_state research_invention_state(const struct research *presearch, Tech_type_id tech)
Definition research.c:622
bool research_invention_gettable(const struct research *presearch, const Tech_type_id tech, bool allow_holes)
Definition research.c:696
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:318
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_musicset[MAX_LEN_NAME]
char preferred_tileset[MAX_LEN_NAME]
char preferred_soundset[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:524
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:95
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:204
#define styles_iterate(_p)
Definition style.h:48
#define styles_iterate_end
Definition style.h:54
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:925
#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:246
#define A_FIRST
Definition tech.h:44
#define A_UNSET
Definition tech.h:48
#define advance_index_iterate(_start, _index)
Definition tech.h:242
struct extra_type * get_preferred_pillage(bv_extras extras)
Definition terrain.c:553
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:7862
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:7129
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:7870
struct sprite * get_nation_flag_sprite(const struct tileset *t, const struct nation_type *pnation)
Definition tilespec.c:7023
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:1401
struct unit * transporter_for_unit_at(const struct unit *pcargo, const struct tile *ptile)
Definition unit.c:1978
bool could_unit_load(const struct unit *pcargo, const struct unit *ptrans)
Definition unit.c:741
bool unit_can_do_action(const struct unit *punit, const action_id act_id)
Definition unit.c:402
void unit_activity_astr(const struct unit *punit, struct astring *astr)
Definition unit.c:1209
#define unit_tile(_pu)
Definition unit.h:408
#define unit_owner(_pu)
Definition unit.h:407
#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:126
const char * unit_name_translation(const struct unit *punit)
Definition unittype.c:1595
#define utype_fuel(ptype)
Definition unittype.h:849