Freeciv-3.3
Loading...
Searching...
No Matches
dialogs.cpp
Go to the documentation of this file.
1/***********************************************************************
2 Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
6 any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12***********************************************************************/
13
14#ifdef HAVE_CONFIG_H
15#include <fc_config.h>
16#endif
17
18// Qt
19#include <QApplication>
20#include <QButtonGroup>
21#include <QComboBox>
22#include <QGroupBox>
23#include <QHeaderView>
24#include <QImage>
25#include <QMessageBox>
26#include <QMouseEvent>
27#include <QPainter>
28#include <QPainterPath>
29#include <QRadioButton>
30#include <QRect>
31#include <QTableWidgetItem>
32#include <QTextEdit>
33#include <QVBoxLayout>
34#include <QWindow>
35#include <QtMath>
36
37// utility
38#include "astring.h"
39
40// common
41#include "actions.h"
42#include "city.h"
43#include "game.h"
44#include "government.h"
45#include "improvement.h"
46#include "movement.h"
47#include "nation.h"
48#include "research.h"
49#include "sex.h"
50
51// client
52#include "audio.h"
53#include "chatline_common.h"
54#include "client_main.h"
55#include "control.h"
56#include "helpdata.h"
57#include "packhand.h"
58#include "svgflag.h"
59#include "text.h"
60#include "tilespec.h"
61
62// gui-qt
63#include "dialogs.h"
64#include "fc_client.h"
65#include "gui_main.h"
66#include "hudwidget.h"
67#include "qtg_cxxside.h"
68#include "sprite.h"
69
70// Locations for non action enabler controlled buttons.
71#define BUTTON_WAIT (ACTION_COUNT + 1)
72#define BUTTON_CANCEL (BUTTON_WAIT + 1)
73#define BUTTON_COUNT (BUTTON_CANCEL + 1)
74
76extern void popdown_players_report();
77extern void popdown_economy_report();
78extern void popdown_units_report();
79extern void popdown_science_report();
80extern void popdown_city_report();
81extern void popdown_endgame_report();
82
83static void spy_request_strike_bld_list(QVariant data1, QVariant data2);
84static void diplomat_incite(QVariant data1, QVariant data2);
85static void diplomat_incite_escape(QVariant data1, QVariant data2);
86static void spy_request_sabotage_list(QVariant data1, QVariant data2);
87static void spy_request_sabotage_esc_list(QVariant data1, QVariant data2);
88static void spy_sabotage(QVariant data1, QVariant data2);
89static void spy_steal(QVariant data1, QVariant data2);
90static void spy_steal_esc(QVariant data1, QVariant data2);
91static void spy_steal_something(QVariant data1, QVariant data2);
92static void diplomat_steal(QVariant data1, QVariant data2);
93static void diplomat_steal_esc(QVariant data1, QVariant data2);
94static void spy_poison(QVariant data1, QVariant data2);
95static void spy_poison_esc(QVariant data1, QVariant data2);
96static void spy_steal_gold(QVariant data1, QVariant data2);
97static void spy_steal_gold_esc(QVariant data1, QVariant data2);
98static void spy_steal_maps(QVariant data1, QVariant data2);
99static void spy_steal_maps_esc(QVariant data1, QVariant data2);
100static void spy_escape(QVariant data1, QVariant data2);
101static void spy_nuke_city(QVariant data1, QVariant data2);
102static void spy_nuke_city_esc(QVariant data1, QVariant data2);
103static void nuke_city(QVariant data1, QVariant data2);
104static void destroy_city(QVariant data1, QVariant data2);
105static void diplomat_embassy(QVariant data1, QVariant data2);
106static void spy_embassy(QVariant data1, QVariant data2);
107static void spy_sabotage_unit(QVariant data1, QVariant data2);
108static void spy_sabotage_unit_esc(QVariant data1, QVariant data2);
109static void spy_investigate(QVariant data1, QVariant data2);
110static void diplomat_investigate(QVariant data1, QVariant data2);
111static void diplomat_sabotage(QVariant data1, QVariant data2);
112static void diplomat_sabotage_esc(QVariant data1, QVariant data2);
113static void diplomat_bribe_unit(QVariant data1, QVariant data2);
114static void diplomat_bribe_stack(QVariant data1, QVariant data2);
115static void caravan_marketplace(QVariant data1, QVariant data2);
116static void caravan_establish_trade(QVariant data1, QVariant data2);
117static void caravan_help_build(QVariant data1, QVariant data2);
118static void unit_disband_recover(QVariant data1, QVariant data2);
119static void capture_units(QVariant data1, QVariant data2);
120static void nuke_units(QVariant data1, QVariant data2);
121static void collect_ransom(QVariant data1, QVariant data2);
122static void wipe_units(QVariant data1, QVariant data2);
123static void expel_unit(QVariant data1, QVariant data2);
124static void bombard(QVariant data1, QVariant data2);
125static void bombard2(QVariant data1, QVariant data2);
126static void bombard3(QVariant data1, QVariant data2);
127static void bombard_lethal(QVariant data1, QVariant data2);
128static void found_city(QVariant data1, QVariant data2);
129static void transform_terrain(QVariant data1, QVariant data2);
130static void cultivate(QVariant data1, QVariant data2);
131static void plant(QVariant data1, QVariant data2);
132static void pillage(QVariant data1, QVariant data2);
133static void clean(QVariant data1, QVariant data2);
134static void road(QVariant data1, QVariant data2);
135static void base(QVariant data1, QVariant data2);
136static void mine(QVariant data1, QVariant data2);
137static void irrigate(QVariant data1, QVariant data2);
138static void nuke(QVariant data1, QVariant data2);
139static void attack(QVariant data1, QVariant data2);
140static void suicide_attack(QVariant data1, QVariant data2);
141static void paradrop(QVariant data1, QVariant data2);
142static void paradrop_conquer(QVariant data1, QVariant data2);
143static void paradrop_frighten(QVariant data1, QVariant data2);
144static void paradrop_frighten_conquer(QVariant data1, QVariant data2);
145static void paradrop_enter(QVariant data1, QVariant data2);
146static void paradrop_enter_conquer(QVariant data1, QVariant data2);
147static void disembark1(QVariant data1, QVariant data2);
148static void disembark2(QVariant data1, QVariant data2);
149static void enter_hut(QVariant data1, QVariant data2);
150static void enter_hut2(QVariant data1, QVariant data2);
151static void frighten_hut(QVariant data1, QVariant data2);
152static void frighten_hut2(QVariant data1, QVariant data2);
153static void regular_move(QVariant data1, QVariant data2);
154static void convert_unit(QVariant data1, QVariant data2);
155static void fortify(QVariant data1, QVariant data2);
156static void disband_unit(QVariant data1, QVariant data2);
157static void homeless(QVariant data1, QVariant data2);
158static void join_city(QVariant data1, QVariant data2);
159static void unit_home_city(QVariant data1, QVariant data2);
160static void unit_upgrade(QVariant data1, QVariant data2);
161static void airlift(QVariant data1, QVariant data2);
162static void conquer_city_shrink(QVariant data1, QVariant data2);
163static void conquer_city_shrink2(QVariant data1, QVariant data2);
164static void conquer_extras(QVariant data1, QVariant data2);
165static void conquer_extras2(QVariant data1, QVariant data2);
166static void heal_unit(QVariant data1, QVariant data2);
167static void heal_unit2(QVariant data1, QVariant data2);
168static void transport_board(QVariant data1, QVariant data2);
169static void transport_board2(QVariant data1, QVariant data2);
170static void transport_board3(QVariant data1, QVariant data2);
171static void transport_embark(QVariant data1, QVariant data2);
172static void transport_embark2(QVariant data1, QVariant data2);
173static void transport_embark3(QVariant data1, QVariant data2);
174static void transport_embark4(QVariant data1, QVariant data2);
175static void transport_deboard(QVariant data1, QVariant data2);
176static void transport_unload(QVariant data1, QVariant data2);
177static void transport_load(QVariant data1, QVariant data2);
178static void transport_load2(QVariant data1, QVariant data2);
179static void transport_load3(QVariant data1, QVariant data2);
180static void keep_moving(QVariant data1, QVariant data2);
181static void pillage_something(QVariant data1, QVariant data2);
182static void action_entry(choice_dialog *cd,
183 action_id act,
184 const struct act_prob *act_probs,
185 const char *custom,
186 QVariant data1, QVariant data2);
187
188
189static bool is_showing_pillage_dialog = false;
191static bool is_race_dialog_open = false;
192
193/* Information used in action selection follow up questions. Can't be
194 * stored in the action selection dialog since it is closed before the
195 * follow up question is asked. */
197
198/* Don't remove a unit's action decision want or move on to the next actor
199 unit that wants a decision in the current unit selection. */
200static bool did_not_decide = false;
201
202extern char forced_tileset_name[512];
204
205/***********************************************************************/
210{
212
213 // Unit acting against a city target.
252
253 // Unit acting against a unit target.
272
273 // Unit acting against all units at a tile.
282
283 // Unit acting against a tile.
312
313 // Unit acting against all tile extras.
316
317 // Unit acting with no target except itself.
322
323 return action_function;
324}
325
326/* Mapping from an action to the function to call when its button is
327 * pushed. */
329
330/***********************************************************************/
335{
336 titlebar_height = 0;
337 moving_now = false;
338 setSizeGripEnabled(true);
340}
341
342/***********************************************************************/
346{
347 raise();
348}
349
350/***********************************************************************/
354{
356
357 QPainter p(this);
360 QStyle *style = this->style();
361 QRect active_area = this->rect();
364
365 qpal.setColor(QPalette::Active, QPalette::ToolTipText, Qt::white);
366 tbar_opt.initFrom(this);
367 titlebar_height = style->pixelMetric(QStyle::PM_TitleBarHeight,
368 &tbar_opt, this) + 2;
369 close_pix = close_pix.scaledToHeight(titlebar_height);
370 tbar_opt.rect = QRect(0, 0, this->width(), titlebar_height);
371 text_rect = QRect(0, 0, this->width() - close_pix.width() , titlebar_height);
372 close_rect = QRect(this->width() - close_pix.width(), 0, this->width(),
374 tbar_opt.titleBarState = this->windowState();
375 tbar_opt.text = tbar_opt.fontMetrics.elidedText(this->windowTitle(),
376 Qt::ElideRight,
377 text_rect.width());
378 style->drawComplexControl(QStyle::CC_TitleBar, &tbar_opt, &p, this);
379 style->drawItemText(&p, text_rect, Qt::AlignCenter, qpal,
380 true, tbar_opt.text, QPalette::ToolTipText);
381 style->drawItemPixmap(&p, close_rect, Qt::AlignLeft,
382 close_pix.scaledToHeight(titlebar_height));
383
384 active_area.setTopLeft(QPoint(0, titlebar_height));
385 this->setContentsMargins(0, titlebar_height, 0, 0);
386 win_opt.initFrom(this);
387 win_opt.rect = active_area;
388 style->drawPrimitive(QStyle::PE_Widget, &win_opt, &p, this);
389}
390
391/***********************************************************************/
400
401/***********************************************************************/
405{
406 QPoint pos = event->pos();
407 int x = pos.x();
408 int y = pos.y();
409
410 if (y <= titlebar_height
411 && x <= width() - close_pix.width()) {
412 point = mevent_gpos(event) - geometry().topLeft();
413 moving_now = true;
414 setCursor(Qt::SizeAllCursor);
415 } else if (y <= titlebar_height
416 && x > width() - close_pix.width()) {
417 close();
418 }
419}
420
421/***********************************************************************/
425{
426 moving_now = false;
427 setCursor(Qt::ArrowCursor);
428}
429
430/***********************************************************************/
434 QWidget *parent) : qfc_dialog(parent)
435{
436 int i;
440 QPixmap *pix;
441 QHeaderView *header;
442 QSize size;
444 QLabel *ns_label;
445
446 setAttribute(Qt::WA_DeleteOnClose);
447 is_race_dialog_open = true;
449 selected_nation_tabs = new QTableWidget;
450 nation_tabs = new QTableWidget();
451 styles = new QTableWidget;
452 ok_button = new QPushButton;
454 ns_label = new QLabel;
455 tplayer = pplayer;
456
457 selected_nation = -1;
458 selected_style = -1;
459 setWindowTitle(_("Select Nation"));
460 selected_nation_tabs->setRowCount(0);
461 selected_nation_tabs->setColumnCount(1);
462 selected_nation_tabs->setSelectionMode(QAbstractItemView::SingleSelection);
463 selected_nation_tabs->verticalHeader()->setVisible(false);
464 selected_nation_tabs->horizontalHeader()->setVisible(false);
465 selected_nation_tabs->setProperty("showGrid", "true");
466 selected_nation_tabs->setEditTriggers(QAbstractItemView::NoEditTriggers);
467 selected_nation_tabs->setShowGrid(false);
468 selected_nation_tabs->setAlternatingRowColors(true);
469
470 nation_tabs->setRowCount(0);
471 nation_tabs->setColumnCount(1);
472 nation_tabs->setSelectionMode(QAbstractItemView::SingleSelection);
473 nation_tabs->verticalHeader()->setVisible(false);
474 nation_tabs->horizontalHeader()->setVisible(false);
475 nation_tabs->setProperty("showGrid", "true");
476 nation_tabs->setEditTriggers(QAbstractItemView::NoEditTriggers);
477 nation_tabs->setShowGrid(false);
478 ns_label->setText(_("Nation Set:"));
479 styles->setRowCount(0);
480 styles->setColumnCount(2);
481 styles->setSelectionMode(QAbstractItemView::SingleSelection);
482 styles->verticalHeader()->setVisible(false);
483 styles->horizontalHeader()->setVisible(false);
484 styles->setProperty("showGrid", "false");
485 styles->setProperty("selectionBehavior", "SelectRows");
486 styles->setEditTriggers(QAbstractItemView::NoEditTriggers);
487 styles->setShowGrid(false);
488
490 no_name = new QGroupBox(parent);
494 sex_buttons->addButton(is_male, SEX_MALE);
496 sex_buttons->addButton(is_female, SEX_FEMALE);
497
498 leader_name->setEditable(true);
499 qgroupbox_layout->addWidget(leader_name, 1, 0, 1, 2);
500 qgroupbox_layout->addWidget(is_male, 2, 1);
501 qgroupbox_layout->addWidget(is_female, 2, 0);
504 no_name->setLayout(qgroupbox_layout);
505
507 description->setReadOnly(true);
508 description->setPlainText(_("Choose nation"));
509 no_name->setTitle(_("Your leader name"));
510
511 // Fill styles, no need to update them later
512
515
516 if (i >= 0) {
518 styles->insertRow(i);
520 item->setData(Qt::DecorationRole, *pix);
521 item->setData(Qt::UserRole, style_number(pstyle));
522 size.setWidth(pix->width());
523 size.setHeight(pix->height());
524 item->setSizeHint(size);
525 styles->setItem(i, 0, item);
528 styles->setItem(i, 1, item);
529 }
531
532 header = styles->horizontalHeader();
533 header->setSectionResizeMode(QHeaderView::Stretch);
534 header->resizeSections(QHeaderView::ResizeToContents);
535 header = styles->verticalHeader();
536 header->resizeSections(QHeaderView::ResizeToContents);
541 // Create nation sets
542 refresh();
543
544 connect(styles->selectionModel(),
546 const QItemSelection &)),
548 connect(selected_nation_tabs->selectionModel(),
550 const QItemSelection &)),
553 SLOT(leader_selected(int)));
554 connect(leader_name->lineEdit(), &QLineEdit::returnPressed,
557 SLOT(nationset_changed(int)));
558 connect(nation_tabs->selectionModel(),
560 const QItemSelection &)),
562
563 ok_button = new QPushButton;
564 ok_button->setText(_("Cancel"));
565 connect(ok_button, &QAbstractButton::pressed, this, &races_dialog::cancel_pressed);
566 main_layout->addWidget(ok_button, 8, 2, 1, 1);
567 random_button = new QPushButton;
568 random_button->setText(_("Random"));
569 connect(random_button, &QAbstractButton::pressed, this, &races_dialog::random_pressed);
570 main_layout->addWidget(random_button, 8, 0, 1, 1);
571 ok_button = new QPushButton;
572 ok_button->setText(_("Ok"));
573 connect(ok_button, &QAbstractButton::pressed, this, &races_dialog::ok_pressed);
574 main_layout->addWidget(ok_button, 8, 3, 1, 1);
575 main_layout->addWidget(no_name, 0, 3, 2, 1);
576 if (nation_set_count() > 1) {
577 main_layout->addWidget(ns_label, 0, 0, 1, 1);
578 main_layout->addWidget(qnation_set, 0, 1, 1, 1);
579 main_layout->addWidget(nation_tabs, 1, 0, 5, 2);
580 } else {
581 main_layout->addWidget(nation_tabs, 0, 0, 6, 2);
582 }
583 main_layout->addWidget(styles, 2, 3, 4, 1);
584 main_layout->addWidget(description, 6, 0, 2, 4);
585 main_layout->addWidget(selected_nation_tabs, 0, 2, 6, 1);
586
588 set_index(-99);
589
590 if (C_S_RUNNING == client_state()) {
591 title = _("Edit Nation");
592 } else if (pplayer != nullptr && pplayer == client_player()) {
593 title = _("What Nation Will You Be?");
594 } else {
595 title = _("Pick Nation");
596 }
597
600}
601
602/***********************************************************************/
609
610/***********************************************************************/
614{
615 struct nation_group *group;
617 QHeaderView *header;
618 int i;
619 int count;
620
621 nation_tabs->clearContents();
622 nation_tabs->setRowCount(0);
623 nation_tabs->insertRow(0);
625 item->setText(_("All nations"));
626 item->setData(Qt::UserRole, -99);
627 nation_tabs->setItem(0, 0, item);
628
629 for (i = 1; i < nation_group_count() + 1; i++) {
630 group = nation_group_by_number(i - 1);
631 if (is_nation_group_hidden(group)) {
632 continue;
633 }
634 count = 0;
635 // Checking if group is empty
636 nations_iterate(pnation) {
637 if (!is_nation_playable(pnation)
638 || !is_nation_pickable(pnation)
639 || !nation_is_in_group(pnation, group)) {
640 continue;
641 }
642 count ++;
644 if (count == 0) {
645 continue;
646 }
647 nation_tabs->insertRow(i);
649 item->setData(Qt::UserRole, i - 1);
650 item->setText(nation_group_name_translation(group));
651 nation_tabs->setItem(i, 0, item);
652 }
653 header = nation_tabs->horizontalHeader();
654 header->resizeSections(QHeaderView::Stretch);
655 header = nation_tabs->verticalHeader();
656 header->resizeSections(QHeaderView::ResizeToContents);
657 set_index(-99);
658}
659
660/***********************************************************************/
664{
665 struct option *popt;
666 struct nation_set *s;
667
669 if (popt) {
671 qnation_set->setCurrentIndex(nation_set_index(s));
672 qnation_set->setToolTip(_(nation_set_description(s)));
673 }
674}
675
676/***********************************************************************/
680{
681 QModelIndexList indexes = selected.indexes();
682 QModelIndex index ;
683
684 if (indexes.isEmpty()) {
685 return;
686 }
687
688 index = indexes.at(0);
689 set_index(index.row());
690}
691
692/***********************************************************************/
697{
699 QPixmap *pix;
700 QFont f;
701 struct nation_group *group;
702 int i;
703 struct sprite *s;
704 QHeaderView *header;
705 bool svg = is_svg_flag_enabled();
706
707 selected_nation_tabs->clearContents();
708 selected_nation_tabs->setRowCount(0);
709
710 last_index = 0;
711 i = nation_tabs->currentRow();
712 if (i != -1) {
713 item = nation_tabs->item(i, 0);
714 index = item->data(Qt::UserRole).toInt();
715 }
716
717 group = nation_group_by_number(index);
718 i = 0;
719 nations_iterate(pnation) {
720 if (!is_nation_playable(pnation)
721 || !is_nation_pickable(pnation)) {
722 continue;
723 }
724 if (!nation_is_in_group(pnation, group) && index != -99) {
725 continue;
726 }
728 selected_nation_tabs->insertRow(i);
729 s = get_nation_flag_sprite(tileset, pnation);
730 if (pnation->player) {
731 f = item->font();
732 f.setStrikeOut(true);
733 item->setFont(f);
734 }
735 pix = s->pm;
736 if (svg) {
737 item->setData(Qt::DecorationRole, (*pix).scaledToHeight(50));
738 } else {
739 item->setData(Qt::DecorationRole, *pix);
740 }
741 item->setData(Qt::UserRole, nation_number(pnation));
742 item->setText(nation_adjective_translation(pnation));
743 selected_nation_tabs->setItem(i, 0, item);
745
746 selected_nation_tabs->sortByColumn(0, Qt::AscendingOrder);
747 header = selected_nation_tabs->horizontalHeader();
748 header->resizeSections(QHeaderView::Stretch);
749 header = selected_nation_tabs->verticalHeader();
750 header->resizeSections(QHeaderView::ResizeToContents);
751}
752
753/***********************************************************************/
757{
758 char buf[4096];
759 QModelIndex index ;
761 QModelIndexList indexes = selected.indexes();
762 QString str;
764 int style, ind;
765
766 if (indexes.isEmpty()) {
767 return;
768 }
769
770 index = indexes.at(0);
771 if (indexes.isEmpty()) {
772 return;
773 }
774 qvar = index.data(Qt::UserRole);
775 selected_nation = qvar.toInt();
776
778 description->setPlainText(buf);
779 leader_name->clear();
780 if (client.conn.playing == tplayer) {
781 leader_name->addItem(client.conn.playing->name, true);
782 }
785 str = QString::fromUtf8(nation_leader_name(pleader));
788
789 // Select style for nation
790
792 qvar = qvar.fromValue<int>(style);
793
794 for (ind = 0; ind < styles->rowCount(); ind++) {
795 item = styles->item(ind, 0);
796
797 if (item->data(Qt::UserRole) == qvar) {
798 styles->selectRow(ind);
799 }
800 }
801}
802
803/***********************************************************************/
807{
808 QModelIndex index ;
810 QModelIndexList indexes = selected.indexes();
811
812 if (indexes.isEmpty()) {
813 return;
814 }
815
816 index = indexes.at(0);
817 qvar = index.data(Qt::UserRole);
818 selected_style = qvar.toInt();
819}
820
821/***********************************************************************/
825{
826 if (leader_name->itemData(index).toBool()) {
827 is_male->setChecked(true);
828 is_female->setChecked(false);
829 } else {
830 is_male->setChecked(false);
831 is_female->setChecked(true);
832 }
833}
834
835/***********************************************************************/
840{
842 struct player *natplr;
843
844 if (selected_nation == -1) {
845 return;
846 }
847
848 if (selected_style == -1) {
849 output_window_append(ftc_client, _("You must select your style."));
850 return;
851 }
852
853 if (leader_name->currentText().length() == 0) {
854 output_window_append(ftc_client, _("You must type a legal name."));
855 return;
856 }
857
859 if (natplr != nullptr && natplr != client_player()) {
861 _("Nation has been chosen by other player"));
862 return;
863 }
864
865 ln_bytes = leader_name->currentText().toUtf8();
867 selected_nation, sex_buttons->checkedId(),
868 ln_bytes.data(),
870 close();
871 deleteLater();
872}
873
874/***********************************************************************/
878 const char *lines, QWidget *parent)
879 : fcwidget()
880{
881 int x, y;
883
884 setAttribute(Qt::WA_DeleteOnClose);
885 setCursor(Qt::ArrowCursor);
887 setFrameStyle(QFrame::Box);
888 cw = new close_widget(this);
889 cw->put_to_corner();
890
894 qlist = qlines.split("\n");
895 small_font = *fc_font::instance()->get_font("gui_qt_font_notify_label");
896 x = 0;
897 y = 0;
898 calc_size(x, y);
899 resize(x, y);
900 gui()->mapview_wdg->find_place(gui()->mapview_wdg->width() - x - 4, 4,
901 x, y, x, y, 0);
902 move(x, y);
903 was_destroyed = false;
904
905}
906
907/***********************************************************************/
911{
912 QString s, q;
913 int i;
917
918 for (i = 0; i < qlist.size(); ++i) {
919 s = qlist.at(i);
920 q = q + s;
921 if (i < qlist.size() - 1) {
922 q = q + QChar('\n');
923 }
924 }
925 capt_bytes = qcaption.toUtf8();
926 hl_bytes = qheadline.toUtf8();
927 qb_bytes = q.toUtf8();
929 hl_bytes.data(),
930 qb_bytes.data());
931 close();
932 destroy();
933}
934
935/***********************************************************************/
939{
941 int i;
942 QStringList str_list;
943
944 str_list = qlist;
945 str_list << qcaption << qheadline;
946
947 for (i = 0; i < str_list.count(); i++) {
948 x = qMax(x, fm.horizontalAdvance(str_list.at(i)));
949 y = y + 3 + fm.height();
950 }
951 x = x + 15;
952}
953
954/***********************************************************************/
958{
959 QPainter painter(this);
960 QPainterPath path;
961 QPen pen;
963 int i;
964
965 pen.setWidth(1);
966 pen.setColor(palette().color(QPalette::Text));
967 painter.setFont(small_font);
968 painter.setPen(pen);
969 painter.drawText(10, fm.height() + 3, qcaption);
970 painter.drawText(10, 2 * fm.height() + 6, qheadline);
971 for (i = 0; i < qlist.count(); i++) {
972 painter.drawText(10, 3 + (fm.height() + 3) * (i + 3), qlist[i]);
973 }
974 cw->put_to_corner();
975}
976
977/***********************************************************************/
981{
982 cursor = mevent_gpos(event) - geometry().topLeft();
983
984 if (event->button() == Qt::RightButton) {
985 was_destroyed = true;
986 close();
987 }
988}
989
990/***********************************************************************/
994{
996
997 setCursor(Qt::SizeAllCursor);
998}
999
1000/***********************************************************************/
1004{
1005 setCursor(Qt::ArrowCursor);
1006}
1007
1008/***********************************************************************/
1012{
1013 was_destroyed = true;
1014 destroy();
1015}
1016
1017/***********************************************************************/
1023{
1024 was_destroyed = true;
1025 destroy();
1026}
1027
1028/***********************************************************************/
1032{
1033 vs_city = -1;
1034 vs_unit = -1;
1035}
1036
1037/***********************************************************************/
1041{
1042 if (!m_instance) {
1043 m_instance = new qdef_act;
1044 }
1045 return m_instance;
1046}
1047
1048/***********************************************************************/
1052{
1053 if (m_instance) {
1054 delete m_instance;
1055 m_instance = 0;
1056 }
1057}
1058
1059/***********************************************************************/
1063{
1064 vs_city = i;
1065}
1066
1067/***********************************************************************/
1071{
1072 vs_unit = i;
1073}
1074
1075/***********************************************************************/
1079{
1080 return vs_city;
1081}
1082
1083/***********************************************************************/
1087{
1088 return vs_unit;
1089}
1090
1091/***********************************************************************/
1095{
1096 delete this;
1097}
1098
1099/***********************************************************************/
1103{
1105 false, "", 0);
1106 delete this;
1107}
1108
1109/***********************************************************************/
1112notify_goto::notify_goto(const char *headline, const char *lines,
1113 const struct text_tag_list *tags, tile *ptile,
1114 QWidget *parent): QMessageBox(parent)
1115{
1117 setAttribute(Qt::WA_DeleteOnClose);
1118 goto_but = this->addButton(_("Goto Location"), QMessageBox::ActionRole);
1119 goto_but->setIcon(fc_icons::instance()->get_icon("go-up"));
1120 inspect_but = this->addButton(_("Inspect City"), QMessageBox::ActionRole);
1121 inspect_but->setIcon(fc_icons::instance()->get_icon("plus"));
1122
1123 close_but = this->addButton(QMessageBox::Close);
1124 gtile = ptile;
1125 if (!gtile) {
1126 goto_but->setVisible(false);
1127 inspect_but->setVisible(false);
1128 } else {
1129 struct city *pcity = tile_city(gtile);
1130 inspect_but->setVisible(pcity != nullptr
1132 }
1134 qlines = lines;
1135 qlines.replace("\n", " ");
1136 setText(qlines);
1137 connect(goto_but, &QAbstractButton::pressed, this, &notify_goto::goto_tile);
1138 connect(inspect_but, &QAbstractButton::pressed, this, &notify_goto::inspect_city);
1139 connect(close_but, &QAbstractButton::pressed, this, &QWidget::close);
1140 show();
1141}
1142
1143/***********************************************************************/
1147{
1149 close();
1150}
1151
1152/***********************************************************************/
1156{
1157 struct city *pcity = tile_city(gtile);
1158 if (pcity) {
1160 }
1161 close();
1162}
1163
1164/***********************************************************************/
1168{
1169 QString rule_name;
1171 const char *rn;
1172 struct option *poption = optset_option_by_name(server_optset, "nationset");
1173
1174 rule_name = qnation_set->currentData().toString();
1175 rn_bytes = rule_name.toUtf8(); /* Hold QByteArray in a variable to
1176 * extend its, and data() buffer's,
1177 * lifetime */
1178 rn = rn_bytes.data();
1182 }
1183}
1184
1185/***********************************************************************/
1190void popup_notify_goto_dialog(const char *headline, const char *lines,
1191 const struct text_tag_list *tags,
1192 struct tile *ptile)
1193{
1194 notify_goto *ask = new notify_goto(headline, lines, tags, ptile,
1195 gui()->central_wdg);
1196 ask->show();
1197}
1198
1199/***********************************************************************/
1202void popup_connect_msg(const char *headline, const char *message)
1203{
1204 QMessageBox *msg = new QMessageBox(gui()->central_wdg);
1205
1206 msg->setText(message);
1207 msg->setStandardButtons(QMessageBox::Ok);
1208 msg->setWindowTitle(headline);
1209 msg->setAttribute(Qt::WA_DeleteOnClose);
1210 msg->show();
1211}
1212
1213/***********************************************************************/
1216void popup_notify_dialog(const char *caption, const char *headline,
1217 const char *lines)
1218{
1220 gui()->mapview_wdg);
1221 nd->show();
1222}
1223
1224/***********************************************************************/
1227void popup_races_dialog(struct player *pplayer)
1228{
1229 if (!is_race_dialog_open) {
1230 race_dialog = new races_dialog(pplayer, gui()->central_wdg);
1231 is_race_dialog_open = true;
1232 race_dialog->show();
1233 }
1234 race_dialog->showNormal();
1235}
1236
1237/***********************************************************************/
1242{
1243 if (is_race_dialog_open) {
1244 race_dialog->close();
1245 is_race_dialog_open = false;
1246 }
1247}
1248
1249/***********************************************************************/
1253{
1254 if (ptile != nullptr
1255 && (unit_list_size(ptile->units) > 1
1256 || (unit_list_size(ptile->units) == 1 && tile_city(ptile)))) {
1257 gui()->toggle_unit_sel_widget(ptile);
1258 }
1259}
1260
1261/***********************************************************************/
1265{
1266 gui()->update_unit_sel();
1267}
1268
1269/***********************************************************************/
1278
1279/***********************************************************************/
1282void races_update_pickable(bool nationset_change)
1283{
1284 if (is_race_dialog_open) {
1286 }
1287}
1288
1289/***********************************************************************/
1294{
1295 if (is_race_dialog_open) {
1297 }
1298}
1299
1300/***********************************************************************/
1304{
1307 = (gov != nullptr ? government_number(gov) : G_LAST);
1308
1310 ask = new hud_message_box(gui()->central_wdg);
1311 ask->setStandardButtons(QMessageBox::Cancel | QMessageBox::Ok);
1312 ask->setDefaultButton(QMessageBox::Cancel);
1313 ask->set_text_title(_("You say you wanna revolution?"),
1314 _("Revolution!"));
1315 ask->setAttribute(Qt::WA_DeleteOnClose);
1316 QObject::connect(ask, &hud_message_box::accepted, [=]() {
1317 if (government_id == G_LAST) {
1318 revolution_response(nullptr);
1319 } else {
1321
1322 if (government) {
1324 }
1325 }
1326 });
1327 ask->show();
1328 } else {
1330 }
1331}
1332
1333/***********************************************************************/
1346
1347/***********************************************************************/
1354
1355/***********************************************************************/
1363
1364/***********************************************************************/
1372
1373/***********************************************************************/
1380
1381/***********************************************************************/
1388
1389/***********************************************************************/
1393 QWidget *parent,
1394 void (*run_on_close_in)(int)): QWidget(parent)
1395{
1396 QLabel *l = new QLabel(text);
1397
1398 setProperty("themed_choice", true);
1399 layout = new QVBoxLayout(this);
1401
1402 layout->addWidget(l);
1403 setWindowFlags(Qt::Dialog);
1405 setAttribute(Qt::WA_DeleteOnClose);
1406 gui()->set_diplo_dialog(this);
1407
1419
1420 targeted_unit = nullptr;
1421 // No buttons are added yet.
1422 for (int i = 0; i < BUTTON_COUNT; i++) {
1423 action_button_map << nullptr;
1424 }
1425}
1426
1427/***********************************************************************/
1431{
1432 buttons_list.clear();
1433 action_button_map.clear();
1434 gui()->set_diplo_dialog(nullptr);
1435
1436 if (run_on_close) {
1438 run_on_close = nullptr;
1439 }
1440}
1441
1442/***********************************************************************/
1446{
1448
1451 struct canvas *pix;
1452 QPushButton *next, *prev;
1453 unit_skip = new QHBoxLayout;
1454 next = new QPushButton();
1455 next->setIcon(fc_icons::instance()->get_icon("city-right"));
1456 next->setIconSize(QSize(32, 32));
1457 next->setFixedSize(QSize(36, 36));
1458 prev = new QPushButton();
1459 prev->setIcon(fc_icons::instance()->get_icon("city-left"));
1460 prev->setIconSize(QSize(32, 32));
1461 prev->setFixedSize(QSize(36, 36));
1462 target_unit_button = new QPushButton;
1465 pix->map_pixmap.fill(Qt::transparent);
1466 put_unit(targeted_unit, pix, 1.0, 0, 0);
1467 target_unit_button->setIcon(QIcon(pix->map_pixmap));
1468 qtg_canvas_free(pix);
1469 target_unit_button->setIconSize(QSize(96, 96));
1470 target_unit_button->setFixedSize(QSize(100, 100));
1471 unit_skip->addStretch(100);
1472 unit_skip->addWidget(prev, Qt::AlignCenter);
1473 unit_skip->addWidget(target_unit_button, Qt::AlignCenter);
1474 unit_skip->addWidget(next, Qt::AlignCenter);
1475 layout->addLayout(unit_skip);
1476 unit_skip->addStretch(100);
1477 connect(prev, &QAbstractButton::clicked, this, &choice_dialog::prev_unit);
1478 connect(next, &QAbstractButton::clicked, this, &choice_dialog::next_unit);
1479 }
1480
1482}
1483
1484/***********************************************************************/
1488 QVariant data2, QString tool_tip = "",
1489 const int button_id = -1)
1490{
1492 data1, data2);
1493 int action = buttons_list.count();
1494
1495 QObject::connect(button, &QPushButton::clicked,
1498 });
1499
1500 buttons_list.append(button);
1501
1502 if (!tool_tip.isEmpty()) {
1503 button->setToolTip(tool_tip);
1504 }
1505
1506 if (0 <= button_id) {
1507 // The id is valid.
1508 action_button_map[button_id] = button;
1509 }
1510
1511 layout->addWidget(button);
1512}
1513
1514/***********************************************************************/
1518{
1519 QPoint p;
1520
1521 p = mapFromGlobal(QCursor::pos());
1522 p.setY(p.y()-this->height());
1523 p.setX(p.x()-this->width());
1524 move(p);
1525 show();
1526}
1527
1528/***********************************************************************/
1535
1536/***********************************************************************/
1540{
1541 if (id < 0) {
1542 fc_assert_msg(0 <= id, "Invalid button ID.");
1543 return nullptr;
1544 }
1545
1546 return action_button_map[id];
1547}
1548
1549/***********************************************************************/
1553{
1556
1558 if (action == -1) {
1559 return false;
1560 }
1561 func = af_map[action];
1562
1563 func(q1, q2);
1564 return true;
1565}
1566
1567/***********************************************************************/
1571{
1574
1576 if (action == -1) {
1577 return false;
1578 }
1579 func = af_map[action];
1580 func(q1, q2);
1581 return true;
1582}
1583
1584/***********************************************************************/
1588{
1589 struct tile *ptile;
1590 struct unit *new_target = nullptr;
1591 bool break_next = false;
1592 bool first = true;
1593 struct canvas *pix;
1594
1595 if (targeted_unit == nullptr) {
1596 return;
1597 }
1598
1599 ptile = targeted_unit->tile;
1600
1601 unit_list_iterate(ptile->units, ptgt) {
1602 if (first) {
1603 new_target = ptgt;
1604 first = false;
1605 }
1606 if (break_next) {
1607 new_target = ptgt;
1608 break;
1609 }
1610 if (ptgt == targeted_unit) {
1611 break_next = true;
1612 }
1617 pix->map_pixmap.fill(Qt::transparent);
1618 put_unit(targeted_unit, pix, 1.0, 0, 0);
1619 target_unit_button->setIcon(QIcon(pix->map_pixmap));
1620 qtg_canvas_free(pix);
1621 switch_target();
1622}
1623
1624/***********************************************************************/
1628{
1629 struct tile *ptile;
1630 struct unit *new_target = nullptr;
1631 struct canvas *pix;
1632 if (targeted_unit == nullptr) {
1633 return;
1634 }
1635
1636 ptile = targeted_unit->tile;
1637 unit_list_iterate(ptile->units, ptgt) {
1638 if ((ptgt == targeted_unit) && new_target != nullptr) {
1639 break;
1640 }
1641 new_target = ptgt;
1646 pix->map_pixmap.fill(Qt::transparent);
1647 put_unit(targeted_unit, pix, 1.0, 0, 0);
1648 target_unit_button->setIcon(QIcon(pix->map_pixmap));
1649 qtg_canvas_free(pix);
1650 switch_target();
1651}
1652
1653/***********************************************************************/
1657{
1658 if (targeted_unit == nullptr) {
1659 return;
1660 }
1661 unit_skip->setParent(nullptr);
1666 : nullptr),
1667 act_probs);
1668 layout->addLayout(unit_skip);
1669}
1670
1671/***********************************************************************/
1675{
1676 if (targeted_unit == nullptr) {
1677 return;
1678 }
1679
1680 unit_skip->setParent(nullptr);
1682 unit_id,
1687 layout->addLayout(unit_skip);
1688}
1689
1690/***********************************************************************/
1694{
1696 pfcn_void func = button->getFunc();
1697
1698 func(button->getData1(), button->getData2());
1699 close();
1700}
1701
1702/***********************************************************************/
1711{
1712 // Store the data in the stack.
1713 last_buttons_stack.append(button);
1714
1715 /* Temporary remove the button so it will end up below buttons added
1716 * before unstack_all_buttons() is called. */
1717 layout->removeWidget(button);
1718
1719 // Synchronize the list with the layout.
1720 buttons_list.removeAll(button);
1721}
1722
1723/***********************************************************************/
1728{
1729 while (!last_buttons_stack.isEmpty()) {
1730 Choice_dialog_button *button = last_buttons_stack.takeLast();
1731
1732 // Reinsert the button below the other buttons.
1733 buttons_list.append(button);
1734 layout->addWidget(button);
1735 }
1736}
1737
1738/***********************************************************************/
1741static void caravan_marketplace(QVariant data1, QVariant data2)
1742{
1743 int actor_unit_id = data1.toInt();
1744 int target_city_id = data2.toInt();
1745
1746 if (game_unit_by_number(actor_unit_id) != nullptr
1747 && game_city_by_number(target_city_id) != nullptr) {
1749 target_city_id, 0, "");
1750 }
1751}
1752
1753/***********************************************************************/
1757{
1758 int actor_unit_id = data1.toInt();
1759 int target_city_id = data2.toInt();
1760
1761 if (game_unit_by_number(actor_unit_id) != nullptr
1762 && game_city_by_number(target_city_id) != nullptr) {
1764 target_city_id, 0, "");
1765 }
1766}
1767
1768/***********************************************************************/
1771static void caravan_help_build(QVariant data1, QVariant data2)
1772{
1773 int caravan_id = data1.toInt();
1774 int caravan_target_id = data2.toInt();
1775
1776 if (game_unit_by_number(caravan_id) != nullptr
1777 && game_city_by_number(caravan_target_id) != nullptr) {
1780 }
1781}
1782
1783/***********************************************************************/
1786static void unit_disband_recover(QVariant data1, QVariant data2)
1787{
1788 int actor_id = data1.toInt();
1789 int tgt_city_id = data2.toInt();
1790
1791 if (game_unit_by_number(actor_id) != nullptr
1792 && game_city_by_number(tgt_city_id) != nullptr) {
1794 actor_id, tgt_city_id, 0, "");
1795 }
1796}
1797
1798/***********************************************************************/
1801static void unit_home_city(QVariant data1, QVariant data2)
1802{
1803 int actor_id = data1.toInt();
1804 int tgt_city_id = data2.toInt();
1805
1806 if (game_unit_by_number(actor_id) != nullptr
1807 && game_city_by_number(tgt_city_id) != nullptr) {
1809 actor_id, tgt_city_id, 0, "");
1810 }
1811}
1812
1813/***********************************************************************/
1816static void unit_upgrade(QVariant data1, QVariant data2)
1817{
1818 struct unit *punit;
1819
1820 int actor_id = data1.toInt();
1821 int tgt_city_id = data2.toInt();
1822
1823 if ((punit = game_unit_by_number(actor_id)) != nullptr
1824 && game_city_by_number(tgt_city_id) != nullptr) {
1825 struct unit_list *as_list;
1826
1831 }
1832}
1833
1834/***********************************************************************/
1837static void airlift(QVariant data1, QVariant data2)
1838{
1839 int actor_id = data1.toInt();
1840 int tgt_city_id = data2.toInt();
1841
1842 if (game_unit_by_number(actor_id) != nullptr
1843 && game_city_by_number(tgt_city_id) != nullptr) {
1845 actor_id, tgt_city_id, 0, "");
1846 }
1847}
1848
1849/***********************************************************************/
1852static void conquer_city_shrink(QVariant data1, QVariant data2)
1853{
1854 int actor_id = data1.toInt();
1855 int tgt_city_id = data2.toInt();
1856
1857 if (game_unit_by_number(actor_id) != nullptr
1858 && game_city_by_number(tgt_city_id) != nullptr) {
1860 actor_id, tgt_city_id, 0, "");
1861 }
1862}
1863
1864/***********************************************************************/
1867static void conquer_city_shrink2(QVariant data1, QVariant data2)
1868{
1869 int actor_id = data1.toInt();
1870 int tgt_city_id = data2.toInt();
1871
1872 if (game_unit_by_number(actor_id) != nullptr
1873 && game_city_by_number(tgt_city_id) != nullptr) {
1875 actor_id, tgt_city_id, 0, "");
1876 }
1877}
1878
1879/***********************************************************************/
1882static void conquer_extras(QVariant data1, QVariant data2)
1883{
1884 int actor_id = data1.toInt();
1885 int target_id = data2.toInt();
1886
1887 if (game_unit_by_number(actor_id) != nullptr) {
1889 actor_id, target_id, 0, "");
1890 }
1891}
1892
1893/***********************************************************************/
1896static void conquer_extras2(QVariant data1, QVariant data2)
1897{
1898 int actor_id = data1.toInt();
1899 int target_id = data2.toInt();
1900
1901 if (game_unit_by_number(actor_id) != nullptr) {
1903 actor_id, target_id, 0, "");
1904 }
1905}
1906
1907/***********************************************************************/
1910static void act_sel_wait(QVariant data1, QVariant data2)
1911{
1912 key_unit_wait();
1913}
1914
1915/***********************************************************************/
1918static void keep_moving(QVariant data1, QVariant data2)
1919{
1920}
1921
1922/***********************************************************************/
1926{
1927 if (!gov) {
1929 } else {
1931 }
1932}
1933
1934/***********************************************************************/
1939{
1941 /* The client isn't waiting for information for any unanswered follow
1942 * up questions. */
1943
1944 struct unit *actor_unit;
1945
1947 /* The action selection dialog wasn't closed because the actor unit
1948 * was lost. */
1949
1950 // The probabilities didn't just disappear, right?
1953
1955 }
1956
1957 // The action selection process is over, at least for now.
1959
1960 if (did_not_decide) {
1961 /* The action selection dialog was closed but the player didn't
1962 * decide what the unit should do. */
1963
1964 // Reset so the next action selection dialog does the right thing.
1965 did_not_decide = false;
1966 } else {
1967 // An action, or no action at all, was selected.
1970 }
1971 }
1972}
1973
1974/***********************************************************************/
1978static void diplomat_queue_handle_secondary(int actor_id)
1979{
1980 // Stop waiting. Move on to the next queued unit.
1983}
1984
1985/**********************************************************************/
1992{
1993 // Stop assuming the answer to a follow up question will arrive.
1995}
1996
1997/***********************************************************************/
2002 struct city *target_city,
2003 struct unit *target_unit,
2004 struct tile *target_tile,
2005 struct extra_type *target_extra,
2006 const struct act_prob *act_probs)
2007{
2008 struct astring title = ASTRING_INIT, text = ASTRING_INIT;
2010 qtiles caras;
2011 QVariant qv1, qv2;
2013 struct city *actor_homecity;
2016
2019
2020 foreach (caras, gui()->trade_gen.lines) {
2021 if (caras.autocaravan == actor_unit) {
2022 int i;
2023
2024 if (game_unit_by_number(actor_unit->id) != nullptr
2025 && game_city_by_number(target_city->id) != nullptr) {
2027 target_city->id, 0, "");
2030 i = gui()->trade_gen.lines.indexOf(caras);
2031 gui()->trade_gen.lines.takeAt(i);
2032
2033 return;
2034 }
2035 }
2036 }
2037 if (target_city
2041
2042 return;
2043 }
2044
2045 if (target_unit
2049
2050 return;
2051 }
2052 /* Could be caused by the server failing to reply to a request for more
2053 * information or a bug in the client code. */
2055 "Diplomat queue problem. Is another diplomat window open?");
2056
2057 // No extra input is required as no action has been chosen yet.
2059
2061
2062 astr_set(&title,
2063 // TRANS: %s is a unit name, e.g., Spy
2064 _("Choose Your %s's Strategy"),
2066
2067 if (target_city != nullptr && actor_homecity != nullptr) {
2068 astr_set(&text,
2069 _("Your %s from %s reaches the city of %s.\nWhat now?"),
2073 } else if (target_city != nullptr) {
2074 astr_set(&text,
2075 _("Your %s has arrived at %s.\nWhat is your command?"),
2078 } else if (target_unit != nullptr) {
2080
2081 if (owner != nullptr) {
2082 astr_set(&text,
2083 // TRANS: Your Spy is ready to act against Roman Freight.
2084 _("Your %s is ready to act against %s %s."),
2088 } else {
2089 // Flagless target
2090 astr_set(&text,
2091 // TRANS: Your Spy is ready to act against Freight.
2092 _("Your %s is ready to act against %s."),
2095 }
2096 } else {
2097 fc_assert_msg(target_unit != nullptr
2098 || target_city != nullptr
2099 || target_tile != nullptr,
2100 "No target specified.");
2101
2102 astr_set(&text,
2103 // TRANS: %s is a unit name, e.g., Diplomat, Spy
2104 _("Your %s is waiting for your command."),
2106 }
2107
2108 cd = gui()->get_diplo_dialog();
2109 if ((cd != nullptr) && cd->targeted_unit != nullptr) {
2110 cd->update_dialog(act_probs);
2111 return;
2112 }
2113 cd = new choice_dialog(astr_str(&title), astr_str(&text),
2114 gui()->game_tab_widget,
2116 qv1 = actor_unit->id;
2117
2118 cd->unit_id = actor_unit->id;
2119
2120 cd->target_id[ATK_SELF] = cd->unit_id;
2121
2122 if (target_city) {
2123 cd->target_id[ATK_CITY] = target_city->id;
2124 } else {
2125 cd->target_id[ATK_CITY] = IDENTITY_NUMBER_ZERO;
2126 }
2127
2128 if (target_unit) {
2129 cd->target_id[ATK_UNIT] = target_unit->id;
2130 } else {
2131 cd->target_id[ATK_UNIT] = IDENTITY_NUMBER_ZERO;
2132 }
2133
2134 if (target_tile) {
2135 cd->target_id[ATK_STACK] = tile_index(target_tile);
2136 } else {
2137 cd->target_id[ATK_STACK] = TILE_INDEX_NONE;
2138 }
2139
2140 if (target_tile) {
2141 cd->target_id[ATK_TILE] = tile_index(target_tile);
2142 } else {
2143 cd->target_id[ATK_TILE] = TILE_INDEX_NONE;
2144 }
2145
2146 if (target_tile) {
2147 cd->target_id[ATK_EXTRAS] = tile_index(target_tile);
2148 } else {
2149 cd->target_id[ATK_EXTRAS] = TILE_INDEX_NONE;
2150 }
2151
2152 // No target building or target tech supplied. (Feb 2020)
2153 cd->sub_target_id[ASTK_BUILDING] = B_LAST;
2154 cd->sub_target_id[ASTK_TECH] = A_UNSET;
2155
2156 if (target_extra) {
2157 cd->sub_target_id[ASTK_EXTRA] = extra_number(target_extra);
2159 } else {
2160 cd->sub_target_id[ASTK_EXTRA] = EXTRA_NONE;
2161 cd->sub_target_id[ASTK_EXTRA_NOT_THERE] = EXTRA_NONE;
2162 }
2163
2164 // Unit acting against a city
2165
2166 // Set the correct target for the following actions.
2167 qv2 = cd->target_id[ATK_CITY];
2168
2169 action_iterate(act) {
2174 act_probs[act],
2175 actor_unit,
2176 target_city),
2177 qv1, qv2);
2178 }
2180
2181 // Unit acting against another unit
2182
2183 // Set the correct target for the following actions.
2184 qv2 = cd->target_id[ATK_UNIT];
2185
2186 action_iterate(act) {
2191 act_probs[act],
2192 actor_unit,
2193 target_city),
2194 qv1, qv2);
2195 }
2197
2198 // Unit acting against all units at a tile
2199
2200 // Set the correct target for the following actions.
2201 qv2 = cd->target_id[ATK_STACK];
2202
2203 action_iterate(act) {
2208 act_probs[act],
2209 actor_unit,
2210 target_city),
2211 qv1, qv2);
2212 }
2214
2215 // Unit acting against a tile.
2216
2217 // Set the correct target for the following actions.
2218 qv2 = cd->target_id[ATK_TILE];
2219
2220 action_iterate(act) {
2225 act_probs[act],
2226 actor_unit,
2227 target_city),
2228 qv1, qv2);
2229 }
2231
2232 // Unit acting against a tile's extras.
2233
2234 // Set the correct target for the following actions.
2235 qv2 = cd->target_id[ATK_EXTRAS];
2236
2237 action_iterate(act) {
2242 act_probs[act],
2243 actor_unit,
2244 target_city),
2245 qv1, qv2);
2246 }
2248
2249 // Unit acting against itself
2250
2251 // Set the correct target for the following actions.
2252 qv2 = cd->target_id[ATK_SELF];
2253
2254 action_iterate(act) {
2259 act_probs[act],
2260 actor_unit,
2261 target_city),
2262 qv1, qv2);
2263 }
2265
2267 cd->add_item(QString(_("&Wait")), func, qv1, qv2,
2268 "", BUTTON_WAIT);
2269
2270 func = keep_moving;
2271 cd->add_item(QString(_("Do nothing")), func, qv1, qv2,
2272 "", BUTTON_CANCEL);
2273
2274 cd->set_layout();
2275 cd->show_me();
2276
2277 // Give follow up questions access to action probabilities.
2279 action_iterate(act) {
2282
2283 astr_free(&title);
2284 astr_free(&text);
2285}
2286
2287/***********************************************************************/
2292{
2293 /* Don't add an action mapping here unless the non targeted version is
2294 * selectable in the targeted version's target selection dialog. */
2295 switch ((enum gen_action)tgt_action_id) {
2301 return ACTION_SPY_STEAL_TECH;
2304 default:
2305 // No non targeted version found.
2306 return ACTION_NONE;
2307 }
2308}
2309
2310/**********************************************************************/
2315{
2316 /* Don't add an action mapping here unless the non targeted version is
2317 * selectable in the targeted version's target selection dialog. */
2318 switch ((enum gen_action)tgt_action_id) {
2325 default:
2326 // No non targeted version found.
2327 return ACTION_NONE;
2328 }
2329}
2330
2331/***********************************************************************/
2335 action_id act,
2336 const struct act_prob *act_probs,
2337 const char *custom,
2338 QVariant data1, QVariant data2)
2339{
2340 QString title;
2342
2343 if (!af_map.contains(act)) {
2344 /* The Qt client doesn't support ordering this action from the
2345 * action selection dialog. */
2346 return;
2347 }
2348
2349 // Don't show disabled actions.
2350 if (!action_prob_possible(act_probs[act])) {
2351 return;
2352 }
2353
2355 act_probs[act],
2356 custom));
2357
2359 act_probs[act]));
2360
2361 cd->add_item(title, af_map[act], data1, data2, tool_tip, act);
2362}
2363
2364/***********************************************************************/
2368 action_id act,
2369 const struct act_prob *act_probs,
2370 const char *custom,
2371 QVariant data1, QVariant data2)
2372{
2373 QString title;
2375
2376 /* An action that just became impossible has its button disabled.
2377 * An action that became possible again must be re-enabled. */
2378 button->setEnabled(action_prob_possible(act_probs[act]));
2379 button->setData1(data1);
2380 button->setData2(data2);
2381 // The probability may have changed.
2383 act_probs[act],
2384 custom));
2385
2387 act_probs[act]));
2388
2389 button->setText(title);
2390 button->setToolTip(tool_tip);
2391}
2392
2393/***********************************************************************/
2396static void disband_unit(QVariant data1, QVariant data2)
2397{
2398 int actor_id = data1.toInt();
2399 int target_id = data2.toInt();
2400
2402 target_id, 0, "");
2403}
2404
2405/***********************************************************************/
2408static void fortify(QVariant data1, QVariant data2)
2409{
2410 int actor_id = data1.toInt();
2411 int target_id = data2.toInt();
2412
2413 if (game_unit_by_number(actor_id) != nullptr) {
2415 target_id, 0, "");
2416 }
2417}
2418
2419/***********************************************************************/
2422static void convert_unit(QVariant data1, QVariant data2)
2423{
2424 int actor_id = data1.toInt();
2425 int target_id = data2.toInt();
2426
2428 target_id, 0, "");
2429}
2430
2431/***********************************************************************/
2434static void homeless(QVariant data1, QVariant data2)
2435{
2436 int actor_id = data1.toInt();
2437 int target_id = data2.toInt();
2438
2439 if (game_unit_by_number(actor_id) != nullptr) {
2441 target_id, 0, "");
2442 }
2443}
2444
2445/***********************************************************************/
2448static void diplomat_bribe_unit(QVariant data1, QVariant data2)
2449{
2450 int diplomat_id = data1.toInt();
2451 int diplomat_target_id = data2.toInt();
2452
2453 if (game_unit_by_number(diplomat_id) != nullptr
2454 && game_unit_by_number(diplomat_target_id) != nullptr) {
2455 // Wait for the server's reply before moving on to the next queued diplomat.
2457
2460 }
2461}
2462
2463/***********************************************************************/
2466static void diplomat_bribe_stack(QVariant data1, QVariant data2)
2467{
2468 int diplomat_id = data1.toInt();
2469 int diplomat_target_id = data2.toInt();
2470
2471 if (game_unit_by_number(diplomat_id) != nullptr) {
2472 // Wait for the server's reply before moving on to the next queued diplomat.
2474
2477 }
2478}
2479
2480/***********************************************************************/
2483static void spy_sabotage_unit(QVariant data1, QVariant data2)
2484{
2485 int diplomat_id = data1.toInt();
2486 int diplomat_target_id = data2.toInt();
2487
2489 diplomat_target_id, 0, "");
2490}
2491
2492/***********************************************************************/
2495static void spy_sabotage_unit_esc(QVariant data1, QVariant data2)
2496{
2497 int diplomat_id = data1.toInt();
2498 int diplomat_target_id = data2.toInt();
2499
2501 diplomat_target_id, 0, "");
2502}
2503
2504/***********************************************************************/
2507static void heal_unit(QVariant data1, QVariant data2)
2508{
2509 int actor_id = data1.toInt();
2510 int target_id = data2.toInt();
2511
2512 request_do_action(ACTION_HEAL_UNIT, actor_id, target_id, 0, "");
2513}
2514
2515/***********************************************************************/
2518static void heal_unit2(QVariant data1, QVariant data2)
2519{
2520 int actor_id = data1.toInt();
2521 int target_id = data2.toInt();
2522
2523 request_do_action(ACTION_HEAL_UNIT2, actor_id, target_id, 0, "");
2524}
2525
2526/***********************************************************************/
2529static void transport_board(QVariant data1, QVariant data2)
2530{
2531 int actor_id = data1.toInt();
2532 int target_id = data2.toInt();
2533
2534 request_do_action(ACTION_TRANSPORT_BOARD, actor_id, target_id, 0, "");
2535}
2536
2537/***********************************************************************/
2540static void transport_board2(QVariant data1, QVariant data2)
2541{
2542 int actor_id = data1.toInt();
2543 int target_id = data2.toInt();
2544
2545 request_do_action(ACTION_TRANSPORT_BOARD2, actor_id, target_id, 0, "");
2546}
2547
2548/***********************************************************************/
2551static void transport_board3(QVariant data1, QVariant data2)
2552{
2553 int actor_id = data1.toInt();
2554 int target_id = data2.toInt();
2555
2556 request_do_action(ACTION_TRANSPORT_BOARD3, actor_id, target_id, 0, "");
2557}
2558
2559/***********************************************************************/
2562static void transport_embark(QVariant data1, QVariant data2)
2563{
2564 int actor_id = data1.toInt();
2565 int target_id = data2.toInt();
2566
2567 request_do_action(ACTION_TRANSPORT_EMBARK, actor_id, target_id, 0, "");
2568}
2569
2570/***********************************************************************/
2573static void transport_embark2(QVariant data1, QVariant data2)
2574{
2575 int actor_id = data1.toInt();
2576 int target_id = data2.toInt();
2577
2578 request_do_action(ACTION_TRANSPORT_EMBARK2, actor_id, target_id, 0, "");
2579}
2580
2581/***********************************************************************/
2584static void transport_embark3(QVariant data1, QVariant data2)
2585{
2586 int actor_id = data1.toInt();
2587 int target_id = data2.toInt();
2588
2589 request_do_action(ACTION_TRANSPORT_EMBARK3, actor_id, target_id, 0, "");
2590}
2591
2592/***********************************************************************/
2595static void transport_embark4(QVariant data1, QVariant data2)
2596{
2597 int actor_id = data1.toInt();
2598 int target_id = data2.toInt();
2599
2600 request_do_action(ACTION_TRANSPORT_EMBARK4, actor_id, target_id, 0, "");
2601}
2602
2603/***********************************************************************/
2606static void transport_unload(QVariant data1, QVariant data2)
2607{
2608 int actor_id = data1.toInt();
2609 int target_id = data2.toInt();
2610
2611 request_do_action(ACTION_TRANSPORT_UNLOAD, actor_id, target_id, 0, "");
2612}
2613
2614/***********************************************************************/
2617static void transport_load(QVariant data1, QVariant data2)
2618{
2619 int actor_id = data1.toInt();
2620 int target_id = data2.toInt();
2621
2622 request_do_action(ACTION_TRANSPORT_LOAD, actor_id, target_id, 0, "");
2623}
2624
2625/***********************************************************************/
2628static void transport_load2(QVariant data1, QVariant data2)
2629{
2630 int actor_id = data1.toInt();
2631 int target_id = data2.toInt();
2632
2633 request_do_action(ACTION_TRANSPORT_LOAD2, actor_id, target_id, 0, "");
2634}
2635
2636/***********************************************************************/
2639static void transport_load3(QVariant data1, QVariant data2)
2640{
2641 int actor_id = data1.toInt();
2642 int target_id = data2.toInt();
2643
2644 request_do_action(ACTION_TRANSPORT_LOAD3, actor_id, target_id, 0, "");
2645}
2646
2647/***********************************************************************/
2650static void transport_deboard(QVariant data1, QVariant data2)
2651{
2652 int actor_id = data1.toInt();
2653 int target_id = data2.toInt();
2654
2655 request_do_action(ACTION_TRANSPORT_DEBOARD, actor_id, target_id, 0, "");
2656}
2657
2658/***********************************************************************/
2661static void disembark1(QVariant data1, QVariant data2)
2662{
2663 int actor_id = data1.toInt();
2664 int target_id = data2.toInt();
2665
2666 if (game_unit_by_number(actor_id) != nullptr
2667 && index_to_tile(&(wld.map), target_id) != nullptr) {
2669 actor_id, target_id, 0, "");
2670 }
2671}
2672
2673/***********************************************************************/
2676static void disembark2(QVariant data1, QVariant data2)
2677{
2678 int actor_id = data1.toInt();
2679 int target_id = data2.toInt();
2680
2681 if (game_unit_by_number(actor_id) != nullptr
2682 && index_to_tile(&(wld.map), target_id) != nullptr) {
2684 actor_id, target_id, 0, "");
2685 }
2686}
2687
2688/***********************************************************************/
2691static void enter_hut(QVariant data1, QVariant data2)
2692{
2693 int actor_id = data1.toInt();
2694 int target_id = data2.toInt();
2695
2696 if (game_unit_by_number(actor_id) != nullptr
2697 && index_to_tile(&(wld.map), target_id) != nullptr) {
2699 actor_id, target_id, 0, "");
2700 }
2701}
2702
2703/***********************************************************************/
2706static void enter_hut2(QVariant data1, QVariant data2)
2707{
2708 int actor_id = data1.toInt();
2709 int target_id = data2.toInt();
2710
2711 if (game_unit_by_number(actor_id) != nullptr
2712 && index_to_tile(&(wld.map), target_id) != nullptr) {
2714 actor_id, target_id, 0, "");
2715 }
2716}
2717
2718/***********************************************************************/
2721static void frighten_hut(QVariant data1, QVariant data2)
2722{
2723 int actor_id = data1.toInt();
2724 int target_id = data2.toInt();
2725
2726 if (game_unit_by_number(actor_id) != nullptr
2727 && index_to_tile(&(wld.map), target_id) != nullptr) {
2729 actor_id, target_id, 0, "");
2730 }
2731}
2732
2733/***********************************************************************/
2736static void frighten_hut2(QVariant data1, QVariant data2)
2737{
2738 int actor_id = data1.toInt();
2739 int target_id = data2.toInt();
2740
2741 if (game_unit_by_number(actor_id) != nullptr
2742 && index_to_tile(&(wld.map), target_id) != nullptr) {
2744 actor_id, target_id, 0, "");
2745 }
2746}
2747
2748/**********************************************************************/
2751static void nuke_units(QVariant data1, QVariant data2)
2752{
2753 int actor_id = data1.toInt();
2754 int target_id = data2.toInt();
2755
2757 target_id, 0, "");
2758}
2759
2760/**********************************************************************/
2763static void collect_ransom(QVariant data1, QVariant data2)
2764{
2765 int actor_id = data1.toInt();
2766 int target_id = data2.toInt();
2767
2769 target_id, 0, "");
2770}
2771
2772/**********************************************************************/
2775static void wipe_units(QVariant data1, QVariant data2)
2776{
2777 int actor_id = data1.toInt();
2778 int target_id = data2.toInt();
2779
2781 target_id, 0, "");
2782}
2783
2784/**********************************************************************/
2787static void capture_units(QVariant data1, QVariant data2)
2788{
2789 int actor_id = data1.toInt();
2790 int target_id = data2.toInt();
2791
2793 target_id, 0, "");
2794}
2795
2796/***********************************************************************/
2799static void expel_unit(QVariant data1, QVariant data2)
2800{
2801 int actor_id = data1.toInt();
2802 int target_id = data2.toInt();
2803
2805 target_id, 0, "");
2806}
2807
2808/***********************************************************************/
2811static void bombard(QVariant data1, QVariant data2)
2812{
2813 int actor_id = data1.toInt();
2814 int target_id = data2.toInt();
2815
2817 target_id, 0, "");
2818}
2819
2820/***********************************************************************/
2823static void bombard2(QVariant data1, QVariant data2)
2824{
2825 int actor_id = data1.toInt();
2826 int target_id = data2.toInt();
2827
2829 target_id, 0, "");
2830}
2831
2832/***********************************************************************/
2835static void bombard3(QVariant data1, QVariant data2)
2836{
2837 int actor_id = data1.toInt();
2838 int target_id = data2.toInt();
2839
2841 target_id, 0, "");
2842}
2843
2844/***********************************************************************/
2847static void bombard_lethal(QVariant data1, QVariant data2)
2848{
2849 int actor_id = data1.toInt();
2850 int target_id = data2.toInt();
2851
2853 target_id, 0, "");
2854}
2855
2856/***********************************************************************/
2859static void found_city(QVariant data1, QVariant data2)
2860{
2861 int actor_id = data1.toInt();
2862
2864 actor_id);
2865}
2866
2867/***********************************************************************/
2870static void transform_terrain(QVariant data1, QVariant data2)
2871{
2872 int actor_id = data1.toInt();
2873 int target_id = data2.toInt();
2874
2875 if (game_unit_by_number(actor_id) != nullptr
2876 && index_to_tile(&(wld.map), target_id) != nullptr) {
2878 actor_id, target_id, 0, "");
2879 }
2880}
2881
2882/***********************************************************************/
2885static void cultivate(QVariant data1, QVariant data2)
2886{
2887 int actor_id = data1.toInt();
2888 int target_id = data2.toInt();
2889
2890 if (game_unit_by_number(actor_id) != nullptr
2891 && index_to_tile(&(wld.map), target_id) != nullptr) {
2893 actor_id, target_id, 0, "");
2894 }
2895}
2896
2897/***********************************************************************/
2900static void plant(QVariant data1, QVariant data2)
2901{
2902 int actor_id = data1.toInt();
2903 int target_id = data2.toInt();
2904
2905 if (game_unit_by_number(actor_id) != nullptr
2906 && index_to_tile(&(wld.map), target_id) != nullptr) {
2908 actor_id, target_id, 0, "");
2909 }
2910}
2911
2912/***********************************************************************/
2915static void pillage(QVariant data1, QVariant data2)
2916{
2917 int actor_id = data1.toInt();
2918 int target_id = data2.toInt();
2919
2920 if (game_unit_by_number(actor_id) != nullptr
2921 && index_to_tile(&(wld.map), target_id) != nullptr) {
2923 actor_id, target_id,
2924 /* FIXME: will cause problems if more than
2925 * one action selection dialog at a time
2926 * becomes supported. */
2928 "");
2929 }
2930}
2931
2932/***********************************************************************/
2935static void clean(QVariant data1, QVariant data2)
2936{
2937 int actor_id = data1.toInt();
2938 int target_id = data2.toInt();
2939
2940 if (game_unit_by_number(actor_id) != nullptr
2941 && index_to_tile(&(wld.map), target_id) != nullptr) {
2943 actor_id, target_id,
2944 /* FIXME: will cause problems if more than
2945 * one action selection dialog at a time
2946 * becomes supported. */
2948 "");
2949 }
2950}
2951
2952/***********************************************************************/
2955static void road(QVariant data1, QVariant data2)
2956{
2957 int actor_id = data1.toInt();
2958 int target_id = data2.toInt();
2959
2960 if (game_unit_by_number(actor_id) != nullptr
2961 && index_to_tile(&(wld.map), target_id) != nullptr
2964 actor_id, target_id,
2965 /* FIXME: will cause problems if more than
2966 * one action selection dialog at a time
2967 * becomes supported. */
2969 "");
2970 }
2971}
2972
2973/***********************************************************************/
2976static void base(QVariant data1, QVariant data2)
2977{
2978 int actor_id = data1.toInt();
2979 int target_id = data2.toInt();
2980
2981 if (game_unit_by_number(actor_id) != nullptr
2982 && index_to_tile(&(wld.map), target_id) != nullptr
2985 actor_id, target_id,
2986 /* FIXME: will cause problems if more than
2987 * one action selection dialog at a time
2988 * becomes supported. */
2990 "");
2991 }
2992}
2993
2994/***********************************************************************/
2997static void mine(QVariant data1, QVariant data2)
2998{
2999 int actor_id = data1.toInt();
3000 int target_id = data2.toInt();
3001
3002 if (game_unit_by_number(actor_id) != nullptr
3003 && index_to_tile(&(wld.map), target_id) != nullptr
3006 actor_id, target_id,
3007 /* FIXME: will cause problems if more than
3008 * one action selection dialog at a time
3009 * becomes supported. */
3011 "");
3012 }
3013}
3014
3015/***********************************************************************/
3018static void irrigate(QVariant data1, QVariant data2)
3019{
3020 int actor_id = data1.toInt();
3021 int target_id = data2.toInt();
3022
3023 if (game_unit_by_number(actor_id) != nullptr
3024 && index_to_tile(&(wld.map), target_id) != nullptr
3027 actor_id, target_id,
3028 /* FIXME: will cause problems if more than
3029 * one action selection dialog at a time
3030 * becomes supported. */
3032 "");
3033 }
3034}
3035
3036/***********************************************************************/
3039static void nuke(QVariant data1, QVariant data2)
3040{
3041 int diplomat_id = data1.toInt();
3042 int diplomat_target_id = data2.toInt();
3043
3044 if (game_unit_by_number(diplomat_id) != nullptr
3045 && index_to_tile(&(wld.map), diplomat_target_id) != nullptr) {
3048 }
3049}
3050
3051/***********************************************************************/
3054static void attack(QVariant data1, QVariant data2)
3055{
3056 int diplomat_id = data1.toInt();
3057 int diplomat_target_id = data2.toInt();
3058
3059 if (game_unit_by_number(diplomat_id) != nullptr
3060 && index_to_tile(&(wld.map), diplomat_target_id) != nullptr) {
3063 }
3064}
3065
3066/***********************************************************************/
3069static void suicide_attack(QVariant data1, QVariant data2)
3070{
3071 int diplomat_id = data1.toInt();
3072 int diplomat_target_id = data2.toInt();
3073
3074 if (game_unit_by_number(diplomat_id) != nullptr
3075 && index_to_tile(&(wld.map), diplomat_target_id) != nullptr) {
3078 }
3079}
3080
3081/***********************************************************************/
3084static void paradrop(QVariant data1, QVariant data2)
3085{
3086 int actor_id = data1.toInt();
3087 int target_id = data2.toInt();
3088
3089 if (game_unit_by_number(actor_id) != nullptr
3090 && index_to_tile(&(wld.map), target_id) != nullptr) {
3092 actor_id, target_id, 0, "");
3093 }
3094}
3095
3096/***********************************************************************/
3099static void paradrop_conquer(QVariant data1, QVariant data2)
3100{
3101 int actor_id = data1.toInt();
3102 int target_id = data2.toInt();
3103
3104 if (game_unit_by_number(actor_id) != nullptr
3105 && index_to_tile(&(wld.map), target_id) != nullptr) {
3107 actor_id, target_id, 0, "");
3108 }
3109}
3110
3111/***********************************************************************/
3114static void paradrop_frighten(QVariant data1, QVariant data2)
3115{
3116 int actor_id = data1.toInt();
3117 int target_id = data2.toInt();
3118
3119 if (game_unit_by_number(actor_id) != nullptr
3120 && index_to_tile(&(wld.map), target_id) != nullptr) {
3122 actor_id, target_id, 0, "");
3123 }
3124}
3125
3126/***********************************************************************/
3130{
3131 int actor_id = data1.toInt();
3132 int target_id = data2.toInt();
3133
3134 if (game_unit_by_number(actor_id) != nullptr
3135 && index_to_tile(&(wld.map), target_id) != nullptr) {
3137 actor_id, target_id, 0, "");
3138 }
3139}
3140
3141/***********************************************************************/
3144static void paradrop_enter(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/***********************************************************************/
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 join_city(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 && game_city_by_number(target_id) != nullptr) {
3182 actor_id, target_id, 0, "");
3183 }
3184}
3185
3186/***********************************************************************/
3189static void spy_steal_shared(QVariant data1, QVariant data2,
3190 action_id act_id)
3191{
3192 QString str;
3193 QVariant qv1;
3195 int diplomat_id = data1.toInt();
3196 int diplomat_target_id = data2.toInt();
3199 struct player *pvictim = nullptr;
3202
3203 cd = gui()->get_diplo_dialog();
3204 if (cd != nullptr) {
3205 cd->close();
3206 }
3207
3208 if (pvcity == nullptr) {
3209 return;
3210 }
3211
3212 // Wait for the player's reply before moving on to the next queued diplomat.
3214
3216
3217 struct astring stra = ASTRING_INIT;
3218 cd = new choice_dialog(_("Steal"), _("Steal Technology"),
3219 gui()->game_tab_widget,
3221
3222 // Put both actor and target city in qv1 since qv2 is taken
3225 actor_and_target.append(act_id);
3226 qv1 = QVariant::fromValue(actor_and_target);
3227
3228 struct player *pplayer = client_player();
3229 const struct research *presearch = research_get(pplayer);
3230 const struct research *vresearch = research_get(pvictim);
3231
3238 // Defeat keyboard shortcut mnemonics
3240 .replace("&", "&&");
3241 cd->add_item(str, func, qv1, i);
3242 }
3244
3246 get_non_targeted_action_id(act_id)])) {
3247 astr_set(&stra, _("At %s's Discretion"),
3250 str = QString(astr_str(&stra)).replace("&", "&&");
3251 cd->add_item(str, func, qv1, A_UNSET);
3252 }
3253
3254 cd->set_layout();
3255 cd->show_me();
3256
3257 astr_free(&stra);
3258}
3259
3260/***********************************************************************/
3263static void spy_steal(QVariant data1, QVariant data2)
3264{
3266}
3267
3268/***********************************************************************/
3271static void spy_steal_esc(QVariant data1, QVariant data2)
3272{
3274}
3275
3276/***********************************************************************/
3279static void spy_steal_something(QVariant data1, QVariant data2)
3280{
3281 int diplomat_id = data1.toList().at(0).toInt();
3282 int diplomat_target_id = data1.toList().at(1).toInt();
3283 action_id act_id = data1.toList().at(2).toInt();
3284
3285 if (game_unit_by_number(diplomat_id) != nullptr
3286 && game_city_by_number(diplomat_target_id) != nullptr) {
3287 if (data2.toInt() == A_UNSET) {
3288 // This is the untargeted version.
3290 diplomat_id, diplomat_target_id, data2.toInt(), "");
3291 } else {
3292 // This is the targeted version.
3294 diplomat_target_id, data2.toInt(), "");
3295 }
3296 }
3297}
3298
3299/***********************************************************************/
3303{
3304 int actor_id = data1.toInt();
3305 int target_id = data2.toInt();
3306
3307 if (game_unit_by_number(actor_id) != nullptr
3308 && game_city_by_number(target_id) != nullptr) {
3309 // Wait for the server's reply before moving on to the next queued diplomat.
3311
3312 request_action_details(ACTION_STRIKE_BUILDING, actor_id, target_id);
3313 }
3314}
3315
3316/***********************************************************************/
3320{
3321 int diplomat_id = data1.toInt();
3322 int diplomat_target_id = data2.toInt();
3323
3324 if (game_unit_by_number(diplomat_id) != nullptr
3325 && game_city_by_number(diplomat_target_id) != nullptr) {
3326 // Wait for the server's reply before moving on to the next queued diplomat.
3328
3331 }
3332}
3333
3334/***********************************************************************/
3338{
3339 int diplomat_id = data1.toInt();
3340 int diplomat_target_id = data2.toInt();
3341
3342 if (game_unit_by_number(diplomat_id) != nullptr
3343 && game_city_by_number(diplomat_target_id) != nullptr) {
3344 /* Wait for the server's reply before moving on to the next queued
3345 * diplomat. */
3347
3350 }
3351}
3352
3353/***********************************************************************/
3356static void spy_poison(QVariant data1, QVariant data2)
3357{
3358 int diplomat_id = data1.toInt();
3359 int diplomat_target_id = data2.toInt();
3360
3361 if (game_unit_by_number(diplomat_id) != nullptr
3362 && game_city_by_number(diplomat_target_id) != nullptr) {
3365 }
3366}
3367
3368/***********************************************************************/
3371static void spy_poison_esc(QVariant data1, QVariant data2)
3372{
3373 int diplomat_id = data1.toInt();
3374 int diplomat_target_id = data2.toInt();
3375
3376 if (game_unit_by_number(diplomat_id) != nullptr
3377 && game_city_by_number(diplomat_target_id) != nullptr) {
3380 }
3381}
3382
3383/***********************************************************************/
3386static void spy_nuke_city(QVariant data1, QVariant data2)
3387{
3388 int diplomat_id = data1.toInt();
3389 int diplomat_target_id = data2.toInt();
3390
3391 if (game_unit_by_number(diplomat_id) != nullptr
3392 && game_city_by_number(diplomat_target_id) != nullptr) {
3395 }
3396}
3397
3398/***********************************************************************/
3401static void spy_nuke_city_esc(QVariant data1, QVariant data2)
3402{
3403 int diplomat_id = data1.toInt();
3404 int diplomat_target_id = data2.toInt();
3405
3406 if (game_unit_by_number(diplomat_id) != nullptr
3407 && game_city_by_number(diplomat_target_id) != nullptr) {
3410 }
3411}
3412
3413/***********************************************************************/
3416static void nuke_city(QVariant data1, QVariant data2)
3417{
3418 int actor_id = data1.toInt();
3419 int target_id = data2.toInt();
3420
3421 if (game_unit_by_number(actor_id) != nullptr
3422 && game_city_by_number(target_id) != nullptr) {
3424 actor_id, target_id, 0, "");
3425 }
3426}
3427
3428/***********************************************************************/
3431static void destroy_city(QVariant data1, QVariant data2)
3432{
3433 int diplomat_id = data1.toInt();
3434 int diplomat_target_id = data2.toInt();
3435
3436 if (game_unit_by_number(diplomat_id) != nullptr
3437 && game_city_by_number(diplomat_target_id) != nullptr) {
3440 }
3441}
3442
3443/***********************************************************************/
3446static void spy_steal_gold(QVariant data1, QVariant data2)
3447{
3448 int diplomat_id = data1.toInt();
3449 int diplomat_target_id = data2.toInt();
3450
3451 if (game_unit_by_number(diplomat_id) != nullptr
3452 && game_city_by_number(diplomat_target_id) != nullptr) {
3455 }
3456}
3457
3458/***********************************************************************/
3461static void spy_steal_gold_esc(QVariant data1, QVariant data2)
3462{
3463 int diplomat_id = data1.toInt();
3464 int diplomat_target_id = data2.toInt();
3465
3466 if (game_unit_by_number(diplomat_id) != nullptr
3467 && game_city_by_number(diplomat_target_id) != nullptr) {
3470 }
3471}
3472
3473/***********************************************************************/
3476static void spy_steal_maps(QVariant data1, QVariant data2)
3477{
3478 int diplomat_id = data1.toInt();
3479 int diplomat_target_id = data2.toInt();
3480
3481 if (game_unit_by_number(diplomat_id) != nullptr
3482 && game_city_by_number(diplomat_target_id) != nullptr) {
3485 }
3486}
3487
3488/***********************************************************************/
3491static void spy_steal_maps_esc(QVariant data1, QVariant data2)
3492{
3493 int diplomat_id = data1.toInt();
3494 int diplomat_target_id = data2.toInt();
3495
3496 if (game_unit_by_number(diplomat_id) != nullptr
3497 && game_city_by_number(diplomat_target_id) != nullptr) {
3500 }
3501}
3502
3503/***********************************************************************/
3506static void spy_escape(QVariant data1, QVariant data2)
3507{
3508 int diplomat_id = data1.toInt();
3509 int diplomat_target_id = data2.toInt();
3510
3511 if (game_unit_by_number(diplomat_id) != nullptr
3512 && game_city_by_number(diplomat_target_id) != nullptr) {
3515 }
3516}
3517
3518/***********************************************************************/
3521static void spy_embassy(QVariant data1, QVariant data2)
3522{
3523 int diplomat_id = data1.toInt();
3524 int diplomat_target_id = data2.toInt();
3525
3526 if (game_unit_by_number(diplomat_id) != nullptr
3527 && game_city_by_number(diplomat_target_id) != nullptr) {
3529 diplomat_target_id, 0, "");
3530 }
3531}
3532
3533/***********************************************************************/
3536static void diplomat_embassy(QVariant data1, QVariant data2)
3537{
3538 int diplomat_id = data1.toInt();
3539 int diplomat_target_id = data2.toInt();
3540
3541 if (game_unit_by_number(diplomat_id) != nullptr
3542 && game_city_by_number(diplomat_target_id) != nullptr) {
3544 diplomat_target_id, 0, "");
3545 }
3546}
3547
3548/***********************************************************************/
3551static void spy_investigate(QVariant data1, QVariant data2)
3552{
3553 int diplomat_id = data1.toInt();
3554 int diplomat_target_id = data2.toInt();
3555
3557 && game_unit_by_number(diplomat_id) != nullptr) {
3559 diplomat_target_id, 0, "");
3560 }
3561}
3562
3563/***********************************************************************/
3566static void diplomat_investigate(QVariant data1, QVariant data2)
3567{
3568 int diplomat_id = data1.toInt();
3569 int diplomat_target_id = data2.toInt();
3570
3572 && game_unit_by_number(diplomat_id) != nullptr) {
3574 diplomat_target_id, 0, "");
3575 }
3576}
3577
3578/***********************************************************************/
3581static void diplomat_sabotage(QVariant data1, QVariant data2)
3582{
3583 int diplomat_id = data1.toInt();
3584 int diplomat_target_id = data2.toInt();
3585
3586 if (game_unit_by_number(diplomat_id) != nullptr
3587 && game_city_by_number(diplomat_target_id) != nullptr) {
3589 diplomat_target_id, B_LAST + 1, "");
3590 }
3591}
3592
3593/***********************************************************************/
3596static void diplomat_sabotage_esc(QVariant data1, QVariant data2)
3597{
3598 int diplomat_id = data1.toInt();
3599 int diplomat_target_id = data2.toInt();
3600
3601 if (game_unit_by_number(diplomat_id) != nullptr
3602 && game_city_by_number(diplomat_target_id) != nullptr) {
3604 diplomat_target_id, B_LAST + 1, "");
3605 }
3606}
3607
3608/***********************************************************************/
3611static void diplomat_steal(QVariant data1, QVariant data2)
3612{
3613 int diplomat_id = data1.toInt();
3614 int diplomat_target_id = data2.toInt();
3615
3616 if (game_unit_by_number(diplomat_id) != nullptr
3617 && game_city_by_number(diplomat_target_id) != nullptr) {
3620 }
3621}
3622
3623/***********************************************************************/
3626static void diplomat_steal_esc(QVariant data1, QVariant data2)
3627{
3628 int diplomat_id = data1.toInt();
3629 int diplomat_target_id = data2.toInt();
3630
3631 if (game_unit_by_number(diplomat_id) != nullptr
3632 && game_city_by_number(diplomat_target_id) != nullptr) {
3635 }
3636}
3637
3638/***********************************************************************/
3641static void diplomat_incite(QVariant data1, QVariant data2)
3642{
3643 int diplomat_id = data1.toInt();
3644 int diplomat_target_id = data2.toInt();
3645
3646 if (game_unit_by_number(diplomat_id) != nullptr
3647 && game_city_by_number(diplomat_target_id) != nullptr) {
3648 // Wait for the server's reply before moving on to the next queued diplomat.
3650
3653 }
3654}
3655
3656/***********************************************************************/
3660{
3661 int diplomat_id = data1.toInt();
3662 int diplomat_target_id = data2.toInt();
3663
3664 if (game_unit_by_number(diplomat_id) != nullptr
3665 && game_city_by_number(diplomat_target_id) != nullptr) {
3666 // Wait for the server's reply before moving on to the next queued diplomat.
3668
3671 }
3672}
3673
3674/***********************************************************************/
3677static void regular_move(QVariant data1, QVariant data2)
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/***********************************************************************/
3693void popup_incite_dialog(struct unit *actor, struct city *tcity, int cost,
3694 const struct action *paction)
3695{
3696 char buf[1024];
3697 char buf2[1024];
3698 int diplomat_id = actor->id;
3699 int diplomat_target_id = tcity->id;
3700 const int act_id = paction->id;
3701
3702 // Should be set before sending request to the server.
3704
3705 fc_snprintf(buf, ARRAY_SIZE(buf), PL_("Treasury contains %d gold.",
3706 "Treasury contains %d gold.",
3707 client_player()->economic.gold),
3708 client_player()->economic.gold);
3709
3711 hud_message_box *impossible = new hud_message_box(gui()->central_wdg);
3712
3714 _("You can't incite a revolt in %s."), city_name_get(tcity));
3715 impossible->set_text_title(buf2, "!");
3716 impossible->setStandardButtons(QMessageBox::Ok);
3717 impossible->setAttribute(Qt::WA_DeleteOnClose);
3718 impossible->show();
3719 } else if (cost <= client_player()->economic.gold) {
3720 hud_message_box *ask = new hud_message_box(gui()->central_wdg);
3721
3723 PL_("Incite a revolt for %d gold?\n%s",
3724 "Incite a revolt for %d gold?\n%s", cost), cost, buf);
3725 ask->setStandardButtons(QMessageBox::Cancel | QMessageBox::Ok);
3726 ask->setDefaultButton(QMessageBox::Cancel);
3727 ask->set_text_title(buf2, _("Incite a Revolt!"));
3728 ask->setAttribute(Qt::WA_DeleteOnClose);
3729 QObject::connect(ask, &hud_message_box::accepted, [=]() {
3732 });
3733 ask->show();
3734 return;
3735 } else {
3736 hud_message_box *too_much = new hud_message_box(gui()->central_wdg);
3737
3739 PL_("Inciting a revolt costs %d gold.\n%s",
3740 "Inciting a revolt costs %d gold.\n%s", cost), cost,
3741 buf);
3742 too_much->set_text_title(buf2, "!");
3743 too_much->setStandardButtons(QMessageBox::Ok);
3744 too_much->setAttribute(Qt::WA_DeleteOnClose);
3745 too_much->show();
3746 }
3747
3749}
3750
3751/***********************************************************************/
3755void popup_bribe_unit_dialog(struct unit *actor, struct unit *tunit, int cost,
3756 const struct action *paction)
3757{
3758 hud_message_box *ask = new hud_message_box(gui()->central_wdg);
3759 char buf[1024];
3760 char buf2[1024];
3761 int diplomat_id = actor->id;
3762 int diplomat_target_id = tunit->id;
3763 const int act_id = paction->id;
3764
3765 // Should be set before sending request to the server.
3767
3768 fc_snprintf(buf, ARRAY_SIZE(buf), PL_("Treasury contains %d gold.",
3769 "Treasury contains %d gold.",
3770 client_player()->economic.gold),
3771 client_player()->economic.gold);
3772
3773 if (cost <= client_player()->economic.gold) {
3774 fc_snprintf(buf2, ARRAY_SIZE(buf2), PL_("Bribe unit for %d gold?\n%s",
3775 "Bribe unit for %d gold?\n%s",
3776 cost), cost, buf);
3777 ask->set_text_title(buf2, _("Bribe Enemy Unit"));
3778 ask->setStandardButtons(QMessageBox::Cancel | QMessageBox::Ok);
3779 ask->setDefaultButton(QMessageBox::Cancel);
3780 ask->setAttribute(Qt::WA_DeleteOnClose);
3781 QObject::connect(ask, &hud_message_box::accepted, [=]() {
3784 });
3785 ask->show();
3786 return;
3787 } else {
3789 PL_("Bribing the unit costs %d gold.\n%s",
3790 "Bribing the unit costs %d gold.\n%s", cost), cost, buf);
3791 ask->set_text_title(buf2, _("Traitors Demand Too Much!"));
3792 ask->setAttribute(Qt::WA_DeleteOnClose);
3793 ask->show();
3794 }
3795
3797}
3798
3799/***********************************************************************/
3804 const struct action *paction)
3805{
3806 hud_message_box *ask = new hud_message_box(gui()->central_wdg);
3807 char buf[1024];
3808 char buf2[1024];
3809 int diplomat_id = actor->id;
3810 int diplomat_target_id = ttile->index;
3811 const int act_id = paction->id;
3812
3813 // Should be set before sending request to the server.
3815
3816 fc_snprintf(buf, ARRAY_SIZE(buf), PL_("Treasury contains %d gold.",
3817 "Treasury contains %d gold.",
3818 client_player()->economic.gold),
3819 client_player()->economic.gold);
3820
3821 if (cost <= client_player()->economic.gold) {
3822 fc_snprintf(buf2, ARRAY_SIZE(buf2), PL_("Bribe unit stack for %d gold?\n%s",
3823 "Bribe unit stack for %d gold?\n%s",
3824 cost), cost, buf);
3825 ask->set_text_title(buf2, _("Bribe Enemy Stack"));
3826 ask->setStandardButtons(QMessageBox::Cancel | QMessageBox::Ok);
3827 ask->setDefaultButton(QMessageBox::Cancel);
3828 ask->setAttribute(Qt::WA_DeleteOnClose);
3829 QObject::connect(ask, &hud_message_box::accepted, [=]() {
3832 });
3833 ask->show();
3834 return;
3835 } else {
3837 PL_("Bribing the unit stack costs %d gold.\n%s",
3838 "Bribing the unit stack costs %d gold.\n%s", cost), cost, buf);
3839 ask->set_text_title(buf2, _("Traitors Demand Too Much!"));
3840 ask->setAttribute(Qt::WA_DeleteOnClose);
3841 ask->show();
3842 }
3843
3845}
3846
3847/***********************************************************************/
3850static void pillage_something(QVariant data1, QVariant data2)
3851{
3852 int punit_id;
3853 int what;
3854 struct unit *punit;
3855 struct extra_type *target;
3856
3857 what = data1.toInt();
3858 punit_id = data2.toInt();
3860 if (punit) {
3861 target = extra_by_number(what);
3863 }
3865}
3866
3867/***********************************************************************/
3870static void spy_sabotage(QVariant data1, QVariant data2)
3871{
3872 int diplomat_id = data1.toList().at(0).toInt();
3873 int diplomat_target_id = data1.toList().at(1).toInt();
3874 action_id act_id = data1.toList().at(2).toInt();
3875
3876 if (game_unit_by_number(diplomat_id) != nullptr
3877 && game_city_by_number(diplomat_target_id) != nullptr) {
3878 if (data2.toInt() == B_LAST) {
3879 // This is the untargeted version.
3881 diplomat_id, diplomat_target_id, data2.toInt(),
3882 "");
3883 } else if (data2.toInt() == -1) {
3884 // This is the city production version.
3886 diplomat_id, diplomat_target_id, data2.toInt(),
3887 "");
3888 } else {
3889 // This is the targeted version.
3891 diplomat_target_id, data2.toInt(), "");
3892 }
3893 }
3894}
3895
3896/***********************************************************************/
3901 const struct action *paction)
3902{
3903 QString str;
3904 QVariant qv1, qv2;
3905 int diplomat_id = actor->id;
3906 int diplomat_target_id = tcity->id;
3909 int nr = 0;
3910 struct astring stra = ASTRING_INIT;
3912
3913 if (paction->result == ACTRES_STRIKE_BUILDING) {
3914 cd = new choice_dialog(_("Strike"),
3915 _("Select Improvement to Strike"),
3916 gui()->game_tab_widget,
3918 } else {
3919 cd = new choice_dialog(_("Sabotage"),
3920 _("Select Improvement to Sabotage"),
3921 gui()->game_tab_widget,
3923 }
3924
3925 // Should be set before sending request to the server.
3927
3928 // Put both actor, target city and action in qv1 since qv2 is taken
3931 actor_and_target.append(paction->id);
3932 qv1 = QVariant::fromValue(actor_and_target);
3933
3936 paction->id)])) {
3938 cd->add_item(QString(_("City Production")), func, qv1, -1);
3939 }
3940
3941 city_built_iterate(tcity, pimprove) {
3942 if (pimprove->sabotage > 0) {
3944 // Defeat keyboard shortcut mnemonics
3946 .replace("&", "&&");
3947 qv2 = nr;
3948 cd->add_item(str, func, qv1, improvement_number(pimprove));
3949 nr++;
3950 }
3952
3955 astr_set(&stra, _("At %s's Discretion"),
3958 str = QString(astr_str(&stra)).replace("&", "&&");
3959 cd->add_item(str, func, qv1, B_LAST);
3960 }
3961
3962 cd->set_layout();
3963 cd->show_me();
3964 astr_free(&stra);
3965}
3966
3967/***********************************************************************/
3972{
3973 QString str;
3974 QVariant qv1, qv2;
3977 struct extra_type *tgt;
3978
3980 return;
3981 }
3982 cd = new choice_dialog(_("What To Pillage"), _("Select what to pillage:"),
3983 gui()->game_tab_widget);
3984 qv2 = punit->id;
3985 while ((tgt = get_preferred_pillage(extras))) {
3986 int what;
3987
3988 what = extra_index(tgt);
3989 BV_CLR(extras, what);
3990
3992 // Defeat keyboard shortcut mnemonics
3993 str = QString(extra_name_translation(tgt)).replace("&", "&&");
3994 qv1 = what;
3995 cd->add_item(str, func, qv1, qv2);
3996 }
3997 cd->set_layout();
3998 cd->show_me();
3999}
4000
4001/***********************************************************************/
4005 QWidget *parent) : hud_message_box(parent)
4006{
4007 QString str;
4008 QPushButton *pb;
4009
4010 setAttribute(Qt::WA_DeleteOnClose);
4011 setModal(false);
4016
4017 str = QString(PL_("Are you sure you want to disband that %1 unit?",
4018 "Are you sure you want to disband those %1 units?",
4020 pb = addButton(_("Yes"), QMessageBox::AcceptRole);
4021 addButton(_("No"), QMessageBox::RejectRole);
4022 set_text_title(str, _("Disband units"));
4024 connect(pb, &QAbstractButton::clicked, this, &disband_box::disband_clicked);
4025}
4026
4027/***********************************************************************/
4038
4039/***********************************************************************/
4046
4047/***********************************************************************/
4050void popup_disband_dialog(struct unit_list *punits)
4051{
4052 disband_box *ask = new disband_box(punits, gui()->central_wdg);
4053 ask->show();
4054}
4055
4056/***********************************************************************/
4061{
4062 hud_message_box *ask = new hud_message_box(gui()->central_wdg);
4063 QString text;
4064 QString title;
4065
4066 title = QString(_("Modpack suggests using %1 tileset."))
4068 text = QString("It might not work with other tilesets.\n"
4069 "You are currently using tileset %1.")
4071 ask->addButton(_("Keep current tileset"), QMessageBox::RejectRole);
4072 ask->addButton(_("Load tileset"), QMessageBox::AcceptRole);
4073 ask->set_text_title(text, title);
4074 ask->setAttribute(Qt::WA_DeleteOnClose);
4075
4076 QObject::connect(ask, &hud_message_box::accepted, [=]() {
4079 gui()->map_scale)) {
4081 _("Can't load requested tileset."));
4082 }
4083 });
4084 ask->show();
4085}
4086
4087/***********************************************************************/
4092{
4093 hud_message_box *ask = new hud_message_box(gui()->central_wdg);
4094 QString text;
4095 QString title;
4096
4097 title = QString(_("Modpack suggests using %1 soundset."))
4099 text = QString("It might not work with other tilesets.\n"
4100 "You are currently using soundset %1.")
4101 .arg(sound_set_name);
4102 ask->addButton(_("Keep current soundset"), QMessageBox::RejectRole);
4103 ask->addButton(_("Load soundset"), QMessageBox::AcceptRole);
4104 ask->set_text_title(text, title);
4105 ask->setAttribute(Qt::WA_DeleteOnClose);
4106 QObject::connect(ask, &hud_message_box::accepted, [=]() {
4108 });
4109 ask->show();
4110}
4111
4112/***********************************************************************/
4117{
4118 hud_message_box *ask = new hud_message_box(gui()->central_wdg);
4119 QString text;
4120 QString title;
4121
4122 title = QString(_("Modpack suggests using %1 musicset."))
4124 text = QString("It might not work with other tilesets.\n"
4125 "You are currently using musicset %1.")
4126 .arg(music_set_name);
4127 ask->addButton(_("Keep current musicset"), QMessageBox::RejectRole);
4128 ask->addButton(_("Load musicset"), QMessageBox::AcceptRole);
4129 ask->set_text_title(text, title);
4130 ask->setAttribute(Qt::WA_DeleteOnClose);
4131 QObject::connect(ask, &hud_message_box::accepted, [=]() {
4133 });
4134 ask->show();
4135}
4136
4137/***********************************************************************/
4142{
4143 // PORTME
4144 return false;
4145}
4146
4147/***********************************************************************/
4151{
4153 int i;
4154
4155 nd_list = gui()->mapview_wdg->findChildren<notify_dialog *>();
4156 for (i = 0; i < nd_list.count(); i++) {
4157 nd_list[i]->restart();
4158 delete nd_list[i];
4159 }
4160}
4161
4162/***********************************************************************/
4167{
4168 int i;
4171 goto_dialog *gtd;
4172
4173 QApplication::alert(gui()->central_wdg);
4174 cd_list = gui()->game_tab_widget->findChildren <choice_dialog *>();
4175 for (i = 0; i < cd_list.count(); i++) {
4176 cd_list[i]->close();
4177 }
4178 nd_list = gui()->game_tab_widget->findChildren <notify_dialog *>();
4179 for (i = 0; i < nd_list.count(); i++) {
4180 nd_list[i]->close();
4181 }
4182
4191 gui()->popdown_unit_sel();
4192
4193 gtd = gui()->gtd;
4194
4195 if (gtd != nullptr) {
4196 gtd->close_dlg();
4197 }
4198}
4199
4200/***********************************************************************/
4206{
4207 choice_dialog *cd = gui()->get_diplo_dialog();
4208
4209 if (cd != nullptr) {
4210 return cd->unit_id;
4211 } else {
4212 return IDENTITY_NUMBER_ZERO;
4213 }
4214}
4215
4216/***********************************************************************/
4223{
4224 choice_dialog *cd = gui()->get_diplo_dialog();
4225
4226 if (cd != nullptr) {
4227 return cd->target_id[ATK_CITY];
4228 } else {
4229 return IDENTITY_NUMBER_ZERO;
4230 }
4231}
4232
4233/***********************************************************************/
4240{
4241 choice_dialog *cd = gui()->get_diplo_dialog();
4242
4243 if (cd != nullptr) {
4244 return cd->target_id[ATK_TILE];
4245 } else {
4246 return TILE_INDEX_NONE;
4247 }
4248}
4249
4250/**********************************************************************/
4257{
4258 choice_dialog *cd = gui()->get_diplo_dialog();
4259
4260 if (cd != nullptr) {
4261 return cd->sub_target_id[ASTK_EXTRA];
4262 } else {
4263 return EXTRA_NONE;
4264 }
4265}
4266
4267/***********************************************************************/
4274{
4275 choice_dialog *cd = gui()->get_diplo_dialog();
4276
4277 if (cd != nullptr) {
4278 return cd->target_id[ATK_UNIT];
4279 } else {
4280 return IDENTITY_NUMBER_ZERO;
4281 }
4282}
4283
4284/***********************************************************************/
4288 struct city *target_city,
4289 struct unit *target_unit,
4290 struct tile *target_tile,
4291 struct extra_type *target_extra,
4292 const struct act_prob *act_probs)
4293{
4296 Choice_dialog_button *cancel_button;
4297 QVariant qv1, qv2;
4298
4299 asd = gui()->get_diplo_dialog();
4300 if (asd == nullptr) {
4301 fc_assert_msg(asd != nullptr,
4302 "The action selection dialog should have been open");
4303 return;
4304 }
4305
4308 "The action selection dialog is for another actor unit.");
4309 }
4310
4311 // Put the actor id in qv1.
4312 qv1 = actor_unit->id;
4313
4314 cancel_button = asd->get_identified_button(BUTTON_CANCEL);
4315 if (cancel_button != nullptr) {
4316 /* Temporary remove the Cancel button so it won't end up above
4317 * any added buttons. */
4318 asd->stack_button(cancel_button);
4319 }
4320
4321 wait_button = asd->get_identified_button(BUTTON_WAIT);
4322 if (wait_button != nullptr) {
4323 /* Temporary remove the Wait button so it won't end up above
4324 * any added buttons. */
4325 asd->stack_button(wait_button);
4326 }
4327
4328 action_iterate(act) {
4329 const char *custom;
4330
4331 if (action_id_get_actor_kind(act) != AAK_UNIT) {
4332 // Not relevant.
4333 continue;
4334 }
4335
4337 act_probs[act],
4338 actor_unit,
4339 target_city);
4340
4341 // Put the target id in qv2.
4342 switch (action_id_get_target_kind(act)) {
4343 case ATK_UNIT:
4344 if (target_unit != nullptr) {
4345 qv2 = target_unit->id;
4346 } else {
4348 || target_unit != nullptr,
4349 "Action enabled against non existing unit!");
4350
4352 }
4353 break;
4354 case ATK_CITY:
4355 if (target_city != nullptr) {
4356 qv2 = target_city->id;
4357 } else {
4359 || target_city != nullptr,
4360 "Action enabled against non existing city!");
4361
4363 }
4364 break;
4365 case ATK_TILE:
4366 case ATK_EXTRAS:
4367 case ATK_STACK:
4368 if (target_tile != nullptr) {
4370 } else {
4372 || target_tile != nullptr,
4373 "Action enabled against all units on "
4374 "non existing tile!");
4375
4377 }
4378 break;
4379 case ATK_SELF:
4380 qv2 = actor_unit->id;
4381 break;
4382 case ATK_COUNT:
4384 "Bad target kind");
4385 continue;
4386 }
4387
4388 if (asd->get_identified_button(act)) {
4389 // Update the existing button.
4390 action_entry_update(asd->get_identified_button(act),
4391 act, act_probs, custom,
4392 qv1, qv2);
4393 } else {
4394 // Add the button (unless its probability is 0).
4396 qv1, qv2);
4397 }
4399
4400 if (wait_button != nullptr || cancel_button != nullptr) {
4401 /* Reinsert the non action buttons below any potential
4402 * buttons recently added. */
4403 asd->unstack_all_buttons();
4404 }
4405}
4406
4407/***********************************************************************/
4411{
4413
4414 cd = gui()->get_diplo_dialog();
4415 if (cd != nullptr) {
4416 did_not_decide = true;
4417 cd->close();
4418 }
4419}
4420
4421/***********************************************************************/
4427
4428/***********************************************************************/
4431void show_tileset_error(bool fatal, const char *tset_name, const char *msg)
4432{
4433 QWidget *parent;
4434 fc_client *std_gui = gui();
4435
4436 if (std_gui != nullptr) {
4437 parent = std_gui->central_wdg;
4438 } else {
4439 parent = nullptr;
4440 }
4441
4442 if (std_gui != nullptr || fatal) {
4443 char buf[1024];
4444 QMessageBox *ask = new QMessageBox(parent);
4445
4446 if (tset_name != nullptr) {
4447 fc_snprintf(buf, sizeof(buf),
4448 _("Tileset \"%s\" problem, it's probably incompatible with "
4449 "the ruleset:\n%s"), tset_name, msg);
4450 } else {
4451 fc_snprintf(buf, sizeof(buf),
4452 _("Tileset problem, it's probably incompatible with "
4453 "the ruleset:\n%s"), msg);
4454 }
4455
4456 ask->setText(buf);
4457 ask->setStandardButtons(QMessageBox::Ok);
4458 ask->setWindowTitle(_("Tileset error"));
4459
4460 if (std_gui != nullptr && !fatal) {
4461 ask->setAttribute(Qt::WA_DeleteOnClose);
4462 ask->show();
4463 } else {
4464 ask->exec();
4465 }
4466 }
4467}
4468
4469/***********************************************************************/
4472void popup_upgrade_dialog(struct unit_list *punits)
4473{
4474 char buf[512];
4476 QString title;
4478
4479 if (!punits || unit_list_size(punits) == 0) {
4480 return;
4481 }
4482
4483 ask = new hud_message_box(gui()->central_wdg);
4484
4485 punit_ids = new QVector<int>();
4487 punit_ids->push_back(punit->id);
4489
4490 if (!get_units_upgrade_info(buf, sizeof(buf), punits)) {
4491 title = _("Upgrade Unit!");
4492 ask->setStandardButtons(QMessageBox::Ok);
4493 } else {
4494 title = _("Upgrade Obsolete Units");
4495 ask->setStandardButtons(QMessageBox::Cancel | QMessageBox::Ok);
4496 ask->setDefaultButton(QMessageBox::Cancel);
4497 }
4498 ask->set_text_title(buf, title);
4499 ask->setAttribute(Qt::WA_DeleteOnClose);
4500 QObject::connect(ask, &hud_message_box::accepted, [=]() {
4501 std::unique_ptr<QVector<int>> uptr(punit_ids);
4502 struct unit *punit;
4503
4504 for (int id : *uptr) {
4506 if (punit) {
4508 }
4509 }
4510 });
4511 ask->show();
4512}
4513
4514/***********************************************************************/
4518{
4519 QPoint p, final_p;
4520
4522 utile = ptile;
4523 pix = nullptr;
4524 show_line = 0;
4525 highligh_num = -1;
4526 ufont.setItalic(true);
4528 update_units();
4529 h_pix = nullptr;
4530 create_pixmap();
4531 p = mapFromGlobal(QCursor::pos());
4532 cw = new close_widget(this);
4533 setMouseTracking(true);
4534 final_p.setX(p.x());
4535 final_p.setY(p.y());
4536 if (p.x() + width() > parentWidget()->width()) {
4537 final_p.setX(parentWidget()->width() - width());
4538 }
4539 if (p.y() - height() < 0) {
4540 final_p.setY(height());
4541 }
4542 move(final_p.x(), final_p.y() - height());
4543 setFocus();
4544 /* Build fails with qt5 connect style for static functions
4545 * Qt5.2 so dont update */
4546 QTimer::singleShot(10, this, SLOT(update_img()));
4547}
4548
4549/***********************************************************************/
4553{
4554 delete h_pix;
4555 delete pix;
4556 delete cw;
4557}
4558
4559/***********************************************************************/
4563{
4564 int a;
4565 int x, y, i;
4568 QImage img;
4570 QPainter p;
4571 QPen pen;
4572 QPixmap pixc;
4573 QPixmap *pixp;
4575 QRect crop;
4576 struct canvas *unit_pixmap;
4577 struct unit *punit;
4578 float isosize;
4579
4580 if (pix != nullptr) {
4581 delete pix;
4582 pix = nullptr;
4583 };
4584 isosize = 0.7;
4586 isosize = 0.5;
4587 }
4588
4589 update_units();
4590 if (unit_list.count() > 0) {
4594 } else {
4597 }
4598 more = false;
4599 if (h_pix != nullptr) {
4600 delete h_pix;
4601 }
4602 h_pix = new QPixmap(item_size.width(), item_size.height());
4603 h_pix->fill(palette().color(QPalette::HighlightedText));
4604 if (unit_count < 5) {
4605 row_count = 1;
4606 pix = new QPixmap((unit_list.size()) * item_size.width(),
4607 item_size.height());
4608 } else if (unit_count < 9) {
4609 row_count = 2;
4610 pix = new QPixmap(4 * item_size.width(), 2 * item_size.height());
4611 } else {
4612 row_count = 3;
4613 if (unit_count > 12) {
4614 more = true;
4615 }
4616 pix = new QPixmap(4 * item_size.width(), 3 * item_size.height());
4617 }
4618 pix->fill(Qt::transparent);
4619 foreach(punit, unit_list) {
4622 unit_pixmap->map_pixmap.fill(Qt::transparent);
4623 put_unit(punit, unit_pixmap, 1.0, 0, 0);
4624 img = unit_pixmap->map_pixmap.toImage();
4626 cropped_img = img.copy(crop);
4630 Qt::KeepAspectRatio,
4631 Qt::SmoothTransformation);
4632 } else {
4635 Qt::KeepAspectRatio,
4636 Qt::SmoothTransformation);
4637 }
4638 pixc = QPixmap::fromImage(img);
4639 pixp = new QPixmap(pixc);
4640 pix_list.push_back(pixp);
4642 }
4643 a = qMin(item_size.width() / 4, 12);
4644 x = 0, y = -item_size.height(), i = -1;
4645 p.begin(pix);
4646 ufont.setPixelSize(a);
4647 p.setFont(ufont);
4648 pen.setColor(palette().color(QPalette::Text));
4649 p.setPen(pen);
4650
4651 while (!pix_list.isEmpty()) {
4652 tmp_pix = pix_list.takeFirst();
4653 i++;
4654 if (i % 4 == 0) {
4655 x = 0;
4656 y = y + item_size.height();
4657 }
4658 punit = unit_list.at(i);
4659 Q_ASSERT(punit != nullptr);
4660
4661 if (i == highligh_num) {
4662 p.drawPixmap(x, y, *h_pix);
4663 p.drawPixmap(x, y, *tmp_pix);
4664 } else {
4665 p.drawPixmap(x, y, *tmp_pix);
4666 }
4667
4669 int rate, f;
4670 QString str;
4671
4673 f = ((punit->fuel) - 1);
4676 str = str + "(" + QString(move_points_text((rate * f)
4677 + punit->moves_left, false)) + ")";
4678 }
4679 // TRANS: MP = Movement points
4680 str = QString(_("MP:")) + str;
4681 p.drawText(x, y + item_size.height() - 4, str);
4682 }
4683
4684 x = x + item_size.width();
4685 delete tmp_pix;
4686 }
4687 p.end();
4688 setFixedWidth(pix->width() + 20);
4689 setFixedHeight(pix->height() + 2 * (fm.height() + 6));
4690 qDeleteAll(pix_list.begin(), pix_list.end());
4691 }
4692}
4693
4694/***********************************************************************/
4698{
4699 int a, b;
4700 int old_h;
4702 QPoint pos = event->pos();
4703 int x = pos.x();
4704 int y = pos.y();
4705
4707 highligh_num = -1;
4708 if (x > width() - 11
4709 || y > height() - fm.height() - 5
4710 || y < fm.height() + 3 || x < 11) {
4711 // Do nothing if mouse is on border, just skip next if
4712 } else if (row_count > 0) {
4713 a = (x - 10) / item_size.width();
4714 b = (y - fm.height() - 3) / item_size.height();
4715 highligh_num = b * 4 + a;
4716 }
4717 if (old_h != highligh_num) {
4718 create_pixmap();
4719 update();
4720 }
4721}
4722
4723/***********************************************************************/
4729{
4730 struct unit *punit;
4731 if (event->button() == Qt::RightButton) {
4732 was_destroyed = true;
4733 close();
4734 destroy();
4735 }
4736 if (event->button() == Qt::LeftButton && highligh_num != -1) {
4737 update_units();
4738 if (highligh_num >= unit_list.count()) {
4739 return;
4740 }
4743 was_destroyed = true;
4744 close();
4745 destroy();
4746 }
4747}
4748
4749/***********************************************************************/
4754{
4755 create_pixmap();
4756 update();
4757}
4758
4759/***********************************************************************/
4763{
4765 int h, i;
4766 int *f_size;
4767 QPen pen;
4768 QString str, str2;
4769 struct unit *punit;
4770 int point_size = info_font.pointSize();
4771 int pixel_size = info_font.pixelSize();
4772
4773 if (point_size < 0) {
4774 f_size = &pixel_size;
4775 } else {
4776 f_size = &point_size;
4777 }
4778 if (highligh_num != -1 && highligh_num < unit_list.count()) {
4779 struct astring addition = ASTRING_INIT;
4780
4783
4784 // TRANS: HP - hit points
4785 str2 = QString(_("%1 HP:%2/%3")).arg(QString(astr_str(&addition)),
4786 QString::number(punit->hp),
4787 QString::number(unit_type_get(punit)->hp));
4789 }
4790 str = QString(PL_("%1 unit", "%1 units",
4792 .arg(unit_list_size(utile->units));
4793 for (i = *f_size; i > 4; i--) {
4794 if (point_size < 0) {
4795 info_font.setPixelSize(i);
4796 } else {
4797 info_font.setPointSize(i);
4798 }
4800 if (10 + qfm.horizontalAdvance(str2) < width()) {
4801 break;
4802 }
4803 }
4804 h = fm.height();
4805 if (pix != nullptr) {
4806 painter->drawPixmap(10, h + 3, *pix);
4807 pen.setColor(palette().color(QPalette::Text));
4808 painter->setPen(pen);
4809 painter->setFont(info_font);
4810 painter->drawText(10, h, str);
4811 if (highligh_num != -1 && highligh_num < unit_list.count()) {
4812 painter->drawText(10, height() - 5, str2);
4813 }
4814 // Draw scroll
4815 if (more) {
4816 int maxl = ((unit_count - 1) / 4) + 1;
4817 float page_height = 3.0f / maxl;
4818 float page_start = (static_cast<float>(show_line)) / maxl;
4819 pen.setColor(palette().color(QPalette::HighlightedText));
4820 painter->setBrush(palette().color(QPalette::HighlightedText).darker());
4821 painter->setPen(palette().color(QPalette::HighlightedText).darker());
4822 painter->drawRect(pix->width() + 10, h, 8, h + pix->height());
4823 painter->setPen(pen);
4824 painter->drawRoundedRect(pix->width() + 10,
4825 h + page_start * pix->height(),
4826 8, h + page_height * pix->height(), 2, 2);
4827 }
4828 }
4829 if (point_size < 0) {
4830 info_font.setPixelSize(*f_size);
4831 } else {
4832 info_font.setPointSize(*f_size);
4833 }
4834 cw->put_to_corner();
4835}
4836
4837/***********************************************************************/
4841{
4843
4844 painter.begin(this);
4845 paint(&painter, event);
4846 painter.end();
4847}
4848
4849/***********************************************************************/
4854{
4855 was_destroyed = true;
4856 close();
4857 destroy();
4858}
4859
4860/***********************************************************************/
4864{
4865 int i = 1;
4866 struct unit_list *punit_list;
4867
4868 unit_count = 0;
4869 if (utile == nullptr) {
4870 struct unit *punit = head_of_units_in_focus();
4871 if (punit) {
4873 }
4874 }
4875 unit_list.clear();
4876 if (utile != nullptr) {
4878 if (punit_list != nullptr) {
4880 unit_count++;
4881 if (i > show_line * 4)
4882 unit_list.push_back(punit);
4883 i++;
4885 }
4886 }
4887 if (unit_list.count() == 0) {
4888 close();
4889 }
4890}
4891
4892/***********************************************************************/
4896{
4897 gui()->mapview_wdg->setFocus();
4898 QWidget::closeEvent(event);
4899}
4900
4901/***********************************************************************/
4905{
4906 int nr;
4907
4908 if (!more && utile == nullptr) {
4909 return;
4910 }
4911 nr = qCeil(static_cast<qreal>(unit_list_size(utile->units)) / 4) - 3;
4912 if (event->angleDelta().y() < 0) {
4913 show_line++;
4915 } else {
4916 show_line--;
4917 show_line = qMax(0, show_line);
4918 }
4919 update_units();
4920 create_pixmap();
4921 update();
4922 event->accept();
4923}
4924
4925/***********************************************************************/
4929{
4930 if (event->key() == Qt::Key_Escape) {
4931 was_destroyed = true;
4932 close();
4933 destroy();
4934 }
4935 QWidget::keyPressEvent(event);
4936}
4937
4938/***********************************************************************/
4945
4946/***********************************************************************/
4953
4954/***********************************************************************/
4959{
4960 // Just tell the client common code to handle this.
4961 return false;
4962}
4963
4964/***********************************************************************/
4967bool qtg_request_transport(struct unit *pcargo, struct tile *ptile)
4968{
4969 int tcount;
4971 struct unit_list *potential_transports = unit_list_new();
4972#ifndef FREECIV_NDEBUG
4974#endif
4975
4979 }
4981
4983
4984 if (tcount == 0) {
4985 fc_assert(best_transport == nullptr);
4987
4988 return false; // Unit was not handled here.
4989 } else if (tcount == 1) {
4990 // There's exactly one potential transport - use it automatically
4993
4995
4996 return true;
4997 }
4998
4999 hul = new hud_unit_loader(pcargo, ptile);
5000 hul->show_me();
5001 return true;
5002}
5003
5004/***********************************************************************/
5008void qtg_popup_combat_info(int attacker_unit_id, int defender_unit_id,
5009 int attacker_hp, int defender_hp,
5010 bool make_att_veteran, bool make_def_veteran)
5011{
5012 if (gui()->qt_settings.show_battle_log) {
5013 hud_unit_combat *huc = new hud_unit_combat(attacker_unit_id,
5014 defender_unit_id,
5015 attacker_hp, defender_hp,
5016 make_att_veteran,
5017 make_def_veteran,
5018 gui()->battlelog_wdg->scale,
5019 gui()->battlelog_wdg);
5020
5021 gui()->battlelog_wdg->add_combat_info(huc);
5022 gui()->battlelog_wdg->show();
5023 }
5024}
5025
5026/**********************************************************************/
5030 struct act_confirmation_data *data)
5031{
5032 hud_message_box *ask = new hud_message_box(gui()->central_wdg);
5033
5034 ask->setStandardButtons(QMessageBox::Cancel | QMessageBox::Ok);
5035 ask->setDefaultButton(QMessageBox::Cancel);
5036 ask->set_text_title(body, hdr);
5037 ask->setAttribute(Qt::WA_DeleteOnClose);
5038 QObject::connect(ask, &hud_message_box::accepted, [=]() {
5040 });
5041 QObject::connect(ask, &hud_message_box::rejected, [=]() {
5043 });
5044
5045 ask->show();
5046}
5047
5048/***********************************************************************/
5052 struct act_confirmation_data *data)
5053{
5055
5056 hdr = QString(_("Are you sure you want to do %1?")).
5058
5059 if (expl != nullptr) {
5061 }
5062
5064}
5065
5066/**********************************************************************/
5069void qtg_popup_image(const char *tag)
5070{
5071 struct sprite *spr = load_popup_sprite(tag);
5072
5073 if (spr != nullptr) {
5074 QDialog *win = new QDialog(gui());
5075 QVBoxLayout *layout = new QVBoxLayout(win);
5076 QPixmap *pm = new QPixmap(*spr->pm);
5077 QLabel *lbl = new QLabel;
5078 int width, height;
5079
5081 win->setFixedSize(width, height);
5082 lbl->setPixmap(*pm);
5083 layout->addWidget(lbl);
5084 win->setLayout(layout);
5085
5086 win->show();
5087
5089 } else {
5090 log_error(_("No image for tag \"%s\", requested by the server."), tag);
5091 }
5092}
const char * action_prepare_ui_name(action_id act_id, const char *mnemonic, const struct act_prob prob, const char *custom)
Definition actions.c:1312
const char * action_id_name_translation(action_id act_id)
Definition actions.c:1250
bool action_prob_possible(const struct act_prob probability)
Definition actions.c:5079
static struct action * action_by_number(action_id act_id)
Definition actions.h:400
#define action_iterate_end
Definition actions.h:218
#define action_id_get_actor_kind(act_id)
Definition actions.h:413
#define action_iterate(_act_)
Definition actions.h:214
#define action_id_get_target_kind(act_id)
Definition actions.h:417
#define ACTION_NONE
Definition actions.h:59
void astr_free(struct astring *astr)
Definition astring.c:148
void astr_set(struct astring *astr, const char *format,...)
Definition astring.c:251
#define str
Definition astring.c:76
static const char * astr_str(const struct astring *astr) fc__attribute((nonnull(1)))
Definition astring.h:93
#define ASTRING_INIT
Definition astring.h:44
void audio_restart(const char *soundset_name, const char *musicset_name)
Definition audio.c:376
#define BV_CLR(bv, bit)
Definition bitvector.h:94
QRect zealous_crop_rect(QImage &p)
Definition canvas.cpp:419
void qtg_canvas_free(struct canvas *store)
Definition canvas.cpp:48
struct canvas * qtg_canvas_create(int width, int height)
Definition canvas.cpp:36
struct canvas int int struct sprite int int int int height
Definition canvas_g.h:44
struct canvas int int struct sprite int int int width
Definition canvas_g.h:44
void output_window_append(const struct ft_color color, const char *featured_text)
const char * city_improvement_name_translation(const struct city *pcity, const struct impr_type *pimprove)
Definition city.c:663
const char * city_name_get(const struct city *pcity)
Definition city.c:1137
#define INCITE_IMPOSSIBLE_COST
Definition city.h:93
#define city_owner(_pcity_)
Definition city.h:560
#define city_built_iterate(_pcity, _p)
Definition city.h:831
#define city_built_iterate_end
Definition city.h:837
void qtg_real_city_dialog_popup(struct city *pcity)
Definition citydlg.cpp:3860
Choice_dialog_button(const QString title, pfcn_void func_in, QVariant data1_in, QVariant data2_in)
Definition dialogs.cpp:1336
void setData2(QVariant wariat)
Definition dialogs.cpp:1384
void setData1(QVariant wariat)
Definition dialogs.cpp:1376
pfcn_void getFunc()
Definition dialogs.cpp:1350
void stack_button(Choice_dialog_button *button)
Definition dialogs.cpp:1710
void prev_unit()
Definition dialogs.cpp:1627
QVBoxLayout * layout
Definition dialogs.h:263
struct unit * targeted_unit
Definition dialogs.h:286
void unstack_all_buttons()
Definition dialogs.cpp:1727
Choice_dialog_button * get_identified_button(const int id)
Definition dialogs.cpp:1539
QPushButton * target_unit_button
Definition dialogs.h:262
void set_layout()
Definition dialogs.cpp:1445
void update_dialog(const struct act_prob *act_probs)
Definition dialogs.cpp:1656
QList< Choice_dialog_button * > last_buttons_stack
Definition dialogs.h:266
void next_unit()
Definition dialogs.cpp:1587
QVBoxLayout * get_layout()
Definition dialogs.cpp:1531
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:1392
int target_id[ATK_COUNT]
Definition dialogs.h:284
void switch_target()
Definition dialogs.cpp:1674
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:1693
void add_item(QString title, pfcn_void func, QVariant data1, QVariant data2, QString tool_tip, const int button_id)
Definition dialogs.cpp:1487
void put_to_corner()
Definition mapview.cpp:502
void disband_clicked()
Definition dialogs.cpp:4030
disband_box(struct unit_list *punits, QWidget *parent=0)
Definition dialogs.cpp:4004
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:4949
void set_diplo_dialog(choice_dialog *widget)
Definition dialogs.cpp:4941
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:910
close_widget * cw
Definition dialogs.h:189
void mouseReleaseEvent(QMouseEvent *event)
Definition dialogs.cpp:1003
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:877
void calc_size(int &x, int &y)
Definition dialogs.cpp:938
void paintEvent(QPaintEvent *paint_event)
Definition dialogs.cpp:957
QPoint cursor
Definition dialogs.h:196
void mouseMoveEvent(QMouseEvent *event)
Definition dialogs.cpp:993
virtual void update_menu()
Definition dialogs.cpp:1011
void mousePressEvent(QMouseEvent *event)
Definition dialogs.cpp:980
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:1112
QPushButton * goto_but
Definition dialogs.h:111
void inspect_city()
Definition dialogs.cpp:1155
struct tile * gtile
Definition dialogs.h:114
QPushButton * inspect_but
Definition dialogs.h:112
void goto_tile()
Definition dialogs.cpp:1146
action_id vs_unit
Definition dialogs.h:60
static qdef_act * action()
Definition dialogs.cpp:1040
action_id vs_city_get()
Definition dialogs.cpp:1078
static qdef_act * m_instance
Definition dialogs.h:58
static void drop()
Definition dialogs.cpp:1051
action_id vs_city
Definition dialogs.h:59
void vs_city_set(int i)
Definition dialogs.cpp:1062
void vs_unit_set(int i)
Definition dialogs.cpp:1070
action_id vs_unit_get()
Definition dialogs.cpp:1086
QPoint point
Definition dialogs.h:81
void paintEvent(QPaintEvent *event)
Definition dialogs.cpp:353
QPixmap close_pix
Definition dialogs.h:83
void reactivate()
Definition dialogs.cpp:345
void mouseMoveEvent(QMouseEvent *event)
Definition dialogs.cpp:394
int titlebar_height
Definition dialogs.h:80
void mousePressEvent(QMouseEvent *event)
Definition dialogs.cpp:404
void mouseReleaseEvent(QMouseEvent *event)
Definition dialogs.cpp:424
qfc_dialog(QWidget *parent)
Definition dialogs.cpp:333
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:1102
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:613
void style_selected(const QItemSelection &selected)
Definition dialogs.cpp:806
void nationset_changed(int index)
Definition dialogs.cpp:1167
int selected_nation
Definition dialogs.h:163
void ok_pressed()
Definition dialogs.cpp:839
void leader_selected(int index)
Definition dialogs.cpp:824
QPushButton * ok_button
Definition dialogs.h:142
QTextEdit * description
Definition dialogs.h:141
void set_index(int index)
Definition dialogs.cpp:696
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:663
QTableWidget * styles
Definition dialogs.h:140
void group_selected(const QItemSelection &selected)
Definition dialogs.cpp:679
struct player * tplayer
Definition dialogs.h:165
races_dialog(struct player *pplayer, QWidget *parent=0)
Definition dialogs.cpp:433
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:756
void cancel_pressed()
Definition dialogs.cpp:1094
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:4895
void update_img()
Definition dialogs.cpp:4753
int show_line
Definition dialogs.h:233
void mouseMoveEvent(QMouseEvent *event)
Definition dialogs.cpp:4697
int highligh_num
Definition dialogs.h:234
void paint(QPainter *painter, QPaintEvent *event)
Definition dialogs.cpp:4762
void update_menu()
Definition dialogs.cpp:4853
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:4517
void update_units()
Definition dialogs.cpp:4863
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:4840
void create_pixmap()
Definition dialogs.cpp:4562
void wheelEvent(QWheelEvent *event)
Definition dialogs.cpp:4904
void keyPressEvent(QKeyEvent *event)
Definition dialogs.cpp:4928
void mousePressEvent(QMouseEvent *event)
Definition dialogs.cpp:4728
close_widget * cw
Definition dialogs.h:213
char music_set_name[512]
bool client_is_global_observer(void)
struct civclient client
enum client_states client_state(void)
char sound_set_name[512]
#define client_player()
@ C_S_RUNNING
Definition client_main.h:47
void client_unit_init_act_prob_cache(struct unit *punit)
Definition climisc.c:1259
char * incite_cost
Definition comments.c:76
void action_selection_no_longer_in_progress(const int old_actor_id)
Definition control.c:1063
void request_unit_load(struct unit *pcargo, struct unit *ptrans, struct tile *ptile)
Definition control.c:2168
void unit_focus_set(struct unit *punit)
Definition control.c:518
void request_do_action(action_id action, int actor_id, int target_id, int sub_tgt, const char *name)
Definition control.c:1742
void request_unit_disband(struct unit *punit)
Definition control.c:2087
void request_action_details(action_id action, int actor_id, int target_id)
Definition control.c:1810
void request_new_unit_activity_targeted(struct unit *punit, enum unit_activity act, struct extra_type *tgt)
Definition control.c:1950
void action_confirmation(struct act_confirmation_data *data, bool confirm)
Definition control.c:1778
void action_decision_clear_want(const int old_actor_id)
Definition control.c:1092
void key_unit_wait(void)
Definition control.c:3554
struct unit * head_of_units_in_focus(void)
Definition control.c:410
void request_unit_upgrade(struct unit *punit)
Definition control.c:2118
void action_selection_next_in_focus(const int old_actor_id)
Definition control.c:1104
bool qtg_handmade_scenario_warning()
Definition dialogs.cpp:4958
static void attack(QVariant data1, QVariant data2)
Definition dialogs.cpp:3054
static void wipe_units(QVariant data1, QVariant data2)
Definition dialogs.cpp:2775
char forced_tileset_name[512]
int action_selection_target_extra(void)
Definition dialogs.cpp:4256
static void destroy_city(QVariant data1, QVariant data2)
Definition dialogs.cpp:3431
static void spy_sabotage_unit(QVariant data1, QVariant data2)
Definition dialogs.cpp:2483
static void pillage(QVariant data1, QVariant data2)
Definition dialogs.cpp:2915
static void caravan_marketplace(QVariant data1, QVariant data2)
Definition dialogs.cpp:1741
static void clean(QVariant data1, QVariant data2)
Definition dialogs.cpp:2935
static void spy_steal_shared(QVariant data1, QVariant data2, action_id act_id)
Definition dialogs.cpp:3189
static void spy_sabotage(QVariant data1, QVariant data2)
Definition dialogs.cpp:3870
int action_selection_target_tile(void)
Definition dialogs.cpp:4239
static void spy_investigate(QVariant data1, QVariant data2)
Definition dialogs.cpp:3551
static void act_sel_wait(QVariant data1, QVariant data2)
Definition dialogs.cpp:1910
static void nuke_units(QVariant data1, QVariant data2)
Definition dialogs.cpp:2751
int action_selection_actor_unit(void)
Definition dialogs.cpp:4205
static void capture_units(QVariant data1, QVariant data2)
Definition dialogs.cpp:2787
static void road(QVariant data1, QVariant data2)
Definition dialogs.cpp:2955
static bool is_race_dialog_open
Definition dialogs.cpp:191
static void transport_embark4(QVariant data1, QVariant data2)
Definition dialogs.cpp:2595
bool try_default_unit_action(QVariant q1, QVariant q2)
Definition dialogs.cpp:1552
static void fortify(QVariant data1, QVariant data2)
Definition dialogs.cpp:2408
static void transport_board(QVariant data1, QVariant data2)
Definition dialogs.cpp:2529
static void diplomat_bribe_unit(QVariant data1, QVariant data2)
Definition dialogs.cpp:2448
static void spy_sabotage_unit_esc(QVariant data1, QVariant data2)
Definition dialogs.cpp:2495
static void disband_unit(QVariant data1, QVariant data2)
Definition dialogs.cpp:2396
static void spy_steal_gold(QVariant data1, QVariant data2)
Definition dialogs.cpp:3446
void popdown_players_report()
Definition plrdlg.cpp:1197
static void conquer_city_shrink2(QVariant data1, QVariant data2)
Definition dialogs.cpp:1867
static void spy_escape(QVariant data1, QVariant data2)
Definition dialogs.cpp:3506
static void mine(QVariant data1, QVariant data2)
Definition dialogs.cpp:2997
void popup_musicset_suggestion_dialog(void)
Definition dialogs.cpp:4116
static void spy_steal_gold_esc(QVariant data1, QVariant data2)
Definition dialogs.cpp:3461
static void diplomat_embassy(QVariant data1, QVariant data2)
Definition dialogs.cpp:3536
void unit_select_dialog_popup(struct tile *ptile)
Definition dialogs.cpp:1252
void popup_upgrade_dialog(struct unit_list *punits)
Definition dialogs.cpp:4472
void update_nationset_combo()
Definition dialogs.cpp:1272
void action_selection_close(void)
Definition dialogs.cpp:4410
static void cultivate(QVariant data1, QVariant data2)
Definition dialogs.cpp:2885
static void paradrop_enter(QVariant data1, QVariant data2)
Definition dialogs.cpp:3144
void races_update_pickable(bool nationset_change)
Definition dialogs.cpp:1282
int action_selection_target_city(void)
Definition dialogs.cpp:4222
static void spy_steal_something(QVariant data1, QVariant data2)
Definition dialogs.cpp:3279
#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:1190
static void spy_poison(QVariant data1, QVariant data2)
Definition dialogs.cpp:3356
static void transport_board2(QVariant data1, QVariant data2)
Definition dialogs.cpp:2540
void show_tech_gained_dialog(Tech_type_id tech)
Definition dialogs.cpp:4424
static void base(QVariant data1, QVariant data2)
Definition dialogs.cpp:2976
static void spy_nuke_city_esc(QVariant data1, QVariant data2)
Definition dialogs.cpp:3401
void popup_soundset_suggestion_dialog(void)
Definition dialogs.cpp:4091
static void enter_hut2(QVariant data1, QVariant data2)
Definition dialogs.cpp:2706
void popup_races_dialog(struct player *pplayer)
Definition dialogs.cpp:1227
static void expel_unit(QVariant data1, QVariant data2)
Definition dialogs.cpp:2799
static void paradrop_frighten(QVariant data1, QVariant data2)
Definition dialogs.cpp:3114
static void diplomat_sabotage(QVariant data1, QVariant data2)
Definition dialogs.cpp:3581
void popup_disband_dialog(struct unit_list *punits)
Definition dialogs.cpp:4050
static action_id get_non_targeted_action_id(action_id tgt_action_id)
Definition dialogs.cpp:2291
static void homeless(QVariant data1, QVariant data2)
Definition dialogs.cpp:2434
static void caravan_help_build(QVariant data1, QVariant data2)
Definition dialogs.cpp:1771
void qtg_popup_image(const char *tag)
Definition dialogs.cpp:5069
static void bombard(QVariant data1, QVariant data2)
Definition dialogs.cpp:2811
void popup_bribe_stack_dialog(struct unit *actor, struct tile *ttile, int cost, const struct action *paction)
Definition dialogs.cpp:3803
void popdown_races_dialog(void)
Definition dialogs.cpp:1241
void popup_tileset_suggestion_dialog(void)
Definition dialogs.cpp:4060
void revolution_response(struct government *gov)
Definition dialogs.cpp:1925
void popdown_economy_report()
static void join_city(QVariant data1, QVariant data2)
Definition dialogs.cpp:3174
static void spy_request_sabotage_list(QVariant data1, QVariant data2)
Definition dialogs.cpp:3319
static void popup_act_confirmation_dialog(QString hdr, QString body, struct act_confirmation_data *data)
Definition dialogs.cpp:5029
static void unit_disband_recover(QVariant data1, QVariant data2)
Definition dialogs.cpp:1786
static void spy_steal(QVariant data1, QVariant data2)
Definition dialogs.cpp:3263
static void airlift(QVariant data1, QVariant data2)
Definition dialogs.cpp:1837
void popup_pillage_dialog(struct unit *punit, bv_extras extras)
Definition dialogs.cpp:3971
static void transport_load3(QVariant data1, QVariant data2)
Definition dialogs.cpp:2639
static void bombard_lethal(QVariant data1, QVariant data2)
Definition dialogs.cpp:2847
static void plant(QVariant data1, QVariant data2)
Definition dialogs.cpp:2900
static void diplomat_bribe_stack(QVariant data1, QVariant data2)
Definition dialogs.cpp:2466
static void nuke(QVariant data1, QVariant data2)
Definition dialogs.cpp:3039
static void disembark2(QVariant data1, QVariant data2)
Definition dialogs.cpp:2676
static void transport_unload(QVariant data1, QVariant data2)
Definition dialogs.cpp:2606
void qtg_request_action_confirmation(const char *expl, struct act_confirmation_data *data)
Definition dialogs.cpp:5051
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:4287
void popdown_science_report()
static void transport_load2(QVariant data1, QVariant data2)
Definition dialogs.cpp:2628
static void diplomat_steal(QVariant data1, QVariant data2)
Definition dialogs.cpp:3611
static void unit_upgrade(QVariant data1, QVariant data2)
Definition dialogs.cpp:1816
bool popup_theme_suggestion_dialog(const char *theme_name)
Definition dialogs.cpp:4141
static void enter_hut(QVariant data1, QVariant data2)
Definition dialogs.cpp:2691
static void spy_request_strike_bld_list(QVariant data1, QVariant data2)
Definition dialogs.cpp:3302
static void diplomat_incite_escape(QVariant data1, QVariant data2)
Definition dialogs.cpp:3659
static void found_city(QVariant data1, QVariant data2)
Definition dialogs.cpp:2859
static void diplomat_investigate(QVariant data1, QVariant data2)
Definition dialogs.cpp:3566
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:5008
static void bombard3(QVariant data1, QVariant data2)
Definition dialogs.cpp:2835
static void transport_deboard(QVariant data1, QVariant data2)
Definition dialogs.cpp:2650
static void diplomat_incite(QVariant data1, QVariant data2)
Definition dialogs.cpp:3641
static void paradrop_conquer(QVariant data1, QVariant data2)
Definition dialogs.cpp:3099
void popdown_endgame_report()
static void diplomat_steal_esc(QVariant data1, QVariant data2)
Definition dialogs.cpp:3626
static bool is_more_user_input_needed
Definition dialogs.cpp:196
static void bombard2(QVariant data1, QVariant data2)
Definition dialogs.cpp:2823
void popup_incite_dialog(struct unit *actor, struct city *tcity, int cost, const struct action *paction)
Definition dialogs.cpp:3693
static const QHash< action_id, pfcn_void > af_map_init(void)
Definition dialogs.cpp:209
void popdown_all_spaceships_dialogs()
static void nuke_city(QVariant data1, QVariant data2)
Definition dialogs.cpp:3416
void popup_connect_msg(const char *headline, const char *message)
Definition dialogs.cpp:1202
static void conquer_city_shrink(QVariant data1, QVariant data2)
Definition dialogs.cpp:1852
static void diplomat_sabotage_esc(QVariant data1, QVariant data2)
Definition dialogs.cpp:3596
void popdown_units_report()
static void transport_embark2(QVariant data1, QVariant data2)
Definition dialogs.cpp:2573
static void spy_nuke_city(QVariant data1, QVariant data2)
Definition dialogs.cpp:3386
void unit_select_dialog_update_real(void *unused)
Definition dialogs.cpp:1264
static void spy_steal_esc(QVariant data1, QVariant data2)
Definition dialogs.cpp:3271
static void paradrop(QVariant data1, QVariant data2)
Definition dialogs.cpp:3084
static void suicide_attack(QVariant data1, QVariant data2)
Definition dialogs.cpp:3069
void races_toggles_set_sensitive(void)
Definition dialogs.cpp:1293
static void transport_load(QVariant data1, QVariant data2)
Definition dialogs.cpp:2617
static action_id get_production_targeted_action_id(action_id tgt_action_id)
Definition dialogs.cpp:2314
static void paradrop_frighten_conquer(QVariant data1, QVariant data2)
Definition dialogs.cpp:3129
static void convert_unit(QVariant data1, QVariant data2)
Definition dialogs.cpp:2422
static bool did_not_decide
Definition dialogs.cpp:200
static void spy_poison_esc(QVariant data1, QVariant data2)
Definition dialogs.cpp:3371
static void pillage_something(QVariant data1, QVariant data2)
Definition dialogs.cpp:3850
static void spy_request_sabotage_esc_list(QVariant data1, QVariant data2)
Definition dialogs.cpp:3337
void show_tileset_error(bool fatal, const char *tset_name, const char *msg)
Definition dialogs.cpp:4431
static void transform_terrain(QVariant data1, QVariant data2)
Definition dialogs.cpp:2870
#define BUTTON_CANCEL
Definition dialogs.cpp:72
static void conquer_extras(QVariant data1, QVariant data2)
Definition dialogs.cpp:1882
static void regular_move(QVariant data1, QVariant data2)
Definition dialogs.cpp:3677
static void heal_unit2(QVariant data1, QVariant data2)
Definition dialogs.cpp:2518
static void transport_board3(QVariant data1, QVariant data2)
Definition dialogs.cpp:2551
static void spy_embassy(QVariant data1, QVariant data2)
Definition dialogs.cpp:3521
static races_dialog * race_dialog
Definition dialogs.cpp:190
static void frighten_hut2(QVariant data1, QVariant data2)
Definition dialogs.cpp:2736
static void conquer_extras2(QVariant data1, QVariant data2)
Definition dialogs.cpp:1896
static void frighten_hut(QVariant data1, QVariant data2)
Definition dialogs.cpp:2721
bool qtg_request_transport(struct unit *pcargo, struct tile *ptile)
Definition dialogs.cpp:4967
int action_selection_target_unit(void)
Definition dialogs.cpp:4273
static void irrigate(QVariant data1, QVariant data2)
Definition dialogs.cpp:3018
static void transport_embark3(QVariant data1, QVariant data2)
Definition dialogs.cpp:2584
static void collect_ransom(QVariant data1, QVariant data2)
Definition dialogs.cpp:2763
static void heal_unit(QVariant data1, QVariant data2)
Definition dialogs.cpp:2507
void popdown_city_report()
Definition cityrep.cpp:1336
static void paradrop_enter_conquer(QVariant data1, QVariant data2)
Definition dialogs.cpp:3159
static void unit_home_city(QVariant data1, QVariant data2)
Definition dialogs.cpp:1801
static void transport_embark(QVariant data1, QVariant data2)
Definition dialogs.cpp:2562
bool try_default_city_action(QVariant q1, QVariant q2)
Definition dialogs.cpp:1570
static void keep_moving(QVariant data1, QVariant data2)
Definition dialogs.cpp:1918
static void spy_steal_maps_esc(QVariant data1, QVariant data2)
Definition dialogs.cpp:3491
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:2367
static void disembark1(QVariant data1, QVariant data2)
Definition dialogs.cpp:2661
void restart_notify_dialogs()
Definition dialogs.cpp:4150
static bool is_showing_pillage_dialog
Definition dialogs.cpp:189
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:2334
static const QHash< action_id, pfcn_void > af_map
Definition dialogs.cpp:328
static void caravan_establish_trade(QVariant data1, QVariant data2)
Definition dialogs.cpp:1756
void popdown_all_game_dialogs(void)
Definition dialogs.cpp:4166
static void spy_steal_maps(QVariant data1, QVariant data2)
Definition dialogs.cpp:3476
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id popup_bribe_unit_dialog
Definition dialogs_g.h:72
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit int const struct action *paction struct unit struct city const struct action *paction const char * expl
Definition dialogs_g.h:93
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit int const struct action *paction popup_sabotage_dialog
Definition dialogs_g.h:76
struct unit struct city struct unit * target_unit
Definition dialogs_g.h:55
popup_action_selection
Definition dialogs_g.h:54
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit * actor
Definition dialogs_g.h:72
struct unit * actor_unit
Definition dialogs_g.h:54
const char * caption
Definition dialogs_g.h:36
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs action_selection_no_longer_in_progress_gui_specific
Definition dialogs_g.h:68
const char const char * headline
Definition dialogs_g.h:37
popup_notify_dialog
Definition dialogs_g.h:36
struct unit struct city struct unit struct tile * target_tile
Definition dialogs_g.h:56
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit * punit
Definition dialogs_g.h:73
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit int const struct action *paction struct unit struct city * pcity
Definition dialogs_g.h:77
struct unit struct city * target_city
Definition dialogs_g.h:55
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit int cost
Definition dialogs_g.h:73
struct unit struct city struct unit struct tile struct extra_type * target_extra
Definition dialogs_g.h:56
int int id
Definition editgui_g.h:28
enum event_type event
Definition events.c:81
int extra_number(const struct extra_type *pextra)
Definition extras.c:161
struct extra_type * extra_by_number(int id)
Definition extras.c:183
static struct extra_type extras[MAX_EXTRA_TYPES]
Definition extras.c:31
const char * extra_name_translation(const struct extra_type *pextra)
Definition extras.c:194
#define extra_index(_e_)
Definition extras.h:183
#define EXTRA_NONE
Definition extras.h:85
int Tech_type_id
Definition fc_types.h:237
int action_id
Definition fc_types.h:249
int Government_type_id
Definition fc_types.h:241
#define IDENTITY_NUMBER_ZERO
Definition fc_types.h:93
#define PL_(String1, String2, n)
Definition fcintl.h:71
#define _(String)
Definition fcintl.h:67
const struct ft_color ftc_client
struct civ_game game
Definition game.c:61
struct world wld
Definition game.c:62
struct unit * game_unit_by_number(int id)
Definition game.c:115
struct city * game_city_by_number(int id)
Definition game.c:106
struct government * government_by_number(const Government_type_id gov)
Definition government.c:103
Government_type_id government_number(const struct government *pgovern)
Definition government.c:91
#define G_LAST
Definition government.h:48
int action_selection_target_extra(void)
static int actor_unit_id
static void diplomat_queue_handle_primary(void)
static void diplomat_queue_handle_secondary(void)
#define BUTTON_COUNT
void action_selection_refresh(struct unit *actor_unit, struct city *target_city, struct unit *target_unit, struct tile *target_tile, struct extra_type *target_extra, const struct act_prob *act_probs)
static PangoLayout * layout
Definition canvas.c:325
struct city * owner
Definition citydlg.c:226
static struct tile * pos
Definition finddlg.c:53
void popdown_help_dialog(void)
Definition helpdlg.c:186
const char * title
Definition repodlgs.c:1314
void(* pfcn_void)(QVariant, QVariant)
Definition dialogs.h:46
#define mevent_gpos(__ev__)
Definition gui_main.h:23
#define CAPTURE_DEFAULT_THIS
Definition gui_main.h:31
void nationset_changed(void)
Definition dialogs.c:3577
#define show(id)
Definition widget.h:235
void popup_revolution_dialog(void)
Definition dialogs.c:112
void helptext_nation(char *buf, size_t bufsz, struct nation_type *pnation, const char *user_text)
Definition helpdata.c:5084
Impr_type_id improvement_number(const struct impr_type *pimprove)
#define B_LAST
Definition improvement.h:42
get_token_fn_t func
Definition inputfile.c:128
#define fc_assert_msg(condition, message,...)
Definition log.h:182
#define fc_assert(condition)
Definition log.h:177
#define fc_assert_action(condition, action)
Definition log.h:188
@ LOG_ERROR
Definition log.h:31
#define log_error(message,...)
Definition log.h:104
struct tile * index_to_tile(const struct civ_map *imap, int mindex)
Definition map.c:471
void put_unit(const struct unit *punit, struct canvas *pcanvas, float zoom, int canvas_x, int canvas_y)
void center_tile_mapcanvas(const struct tile *ptile)
static const void * body(MD5_CTX *ctx, const void *data, unsigned long size)
Definition md5.c:121
#define FC_FREE(ptr)
Definition mem.h:41
const char * move_points_text(int mp, bool reduce)
Definition movement.c:1066
static mpgui * gui
Definition mpgui_qt.cpp:52
const char *const notify_label
Definition fonts.h:28
Nation_type_id nation_number(const struct nation_type *pnation)
Definition nation.c:486
bool nation_leader_is_male(const struct nation_leader *pleader)
Definition nation.c:290
const char * nation_adjective_for_player(const struct player *pplayer)
Definition nation.c:169
const char * nation_adjective_translation(const struct nation_type *pnation)
Definition nation.c:149
struct nation_type * nation_by_number(const Nation_type_id nation)
Definition nation.c:475
int nation_set_index(const struct nation_set *pset)
Definition nation.c:699
bool is_nation_pickable(const struct nation_type *nation)
Definition nation.c:188
const struct nation_leader_list * nation_leaders(const struct nation_type *pnation)
Definition nation.c:230
const char * nation_set_name_translation(const struct nation_set *pset)
Definition nation.c:818
bool is_nation_playable(const struct nation_type *nation)
Definition nation.c:200
bool nation_is_in_group(const struct nation_type *pnation, const struct nation_group *pgroup)
Definition nation.c:1099
const char * nation_set_description(const struct nation_set *pset)
Definition nation.c:828
const char * nation_group_name_translation(const struct nation_group *pgroup)
Definition nation.c:1090
int nation_set_count(void)
Definition nation.c:691
struct nation_group * nation_group_by_number(int id)
Definition nation.c:1004
struct nation_set * nation_set_by_rule_name(const char *name)
Definition nation.c:779
bool is_nation_group_hidden(struct nation_group *pgroup)
Definition nation.c:1057
struct nation_set * nation_set_by_setting_value(const char *setting)
Definition nation.c:859
const char * nation_leader_name(const struct nation_leader *pleader)
Definition nation.c:281
int nation_group_count(void)
Definition nation.c:935
const char * nation_set_rule_name(const struct nation_set *pset)
Definition nation.c:807
struct nation_style * style_of_nation(const struct nation_type *pnation)
Definition nation.c:672
#define nation_leader_list_iterate(leaderlist, pleader)
Definition nation.h:57
#define nation_sets_iterate_end
Definition nation.h:305
#define nation_sets_iterate(NAME_pset)
Definition nation.h:301
#define nations_iterate_end
Definition nation.h:336
#define nations_iterate(NAME_pnation)
Definition nation.h:333
#define nation_leader_list_iterate_end
Definition nation.h:59
const struct option_set * server_optset
Definition options.c:4077
bool option_str_set(struct option *poption, const char *str)
Definition options.c:937
const char * option_str_get(const struct option *poption)
Definition options.c:904
struct option * optset_option_by_name(const struct option_set *poptset, const char *name)
Definition options.c:442
#define REQEST_PLAYER_INITIATED
Definition packets.h:63
int dsend_packet_unit_get_actions(struct connection *pc, int actor_unit_id, int target_unit_id, int target_tile_id, int target_extra_id, int request_kind)
int dsend_packet_nation_select_req(struct connection *pc, int player_no, Nation_type_id nation_no, bool is_male, const char *name, int style)
int dsend_packet_city_name_suggestion_req(struct connection *pc, int unit_id)
void start_revolution(void)
Definition packhand.c:2405
void set_government_choice(struct government *government)
Definition packhand.c:2392
char * lines
Definition packhand.c:131
int player_number(const struct player *pplayer)
Definition player.c:837
const char * research_advance_name_translation(const struct research *presearch, Tech_type_id tech)
Definition research.c:273
struct research * research_get(const struct player *pplayer)
Definition research.c:128
enum tech_state research_invention_state(const struct research *presearch, Tech_type_id tech)
Definition research.c:619
bool research_invention_gettable(const struct research *presearch, const Tech_type_id tech, bool allow_holes)
Definition research.c:693
const char * sex_name_translation(sex_t kind)
Definition sex.c:60
@ SEX_FEMALE
Definition sex.h:22
@ SEX_MALE
Definition sex.h:23
#define ARRAY_SIZE(x)
Definition shared.h:85
size_t size
Definition specvec.h:72
struct sprite int int y
Definition sprite_g.h:31
struct sprite int x
Definition sprite_g.h:31
struct sprite int int int int struct sprite int int float bool smooth get_sprite_dimensions
Definition sprite_g.h:36
QPixmap map_pixmap
Definition canvas.h:25
Definition city.h:317
struct packet_ruleset_control control
Definition game.h:83
struct packet_game_info info
Definition game.h:89
struct connection conn
Definition client_main.h:96
Definition colors.h:21
struct player * playing
Definition connection.h:151
Definition mapimg.c:367
Definition climisc.h:82
struct universal item
Definition climisc.h:83
struct player * player
Definition nation.h:118
bool tech_steal_allow_holes
char preferred_soundset[MAX_LEN_NAME]
char preferred_tileset[MAX_LEN_NAME]
char preferred_musicset[MAX_LEN_NAME]
int revolution_finishes
Definition player.h:273
char name[MAX_LEN_NAME]
Definition player.h:251
Definition menu.h:161
QPixmap * pm
Definition sprite.h:25
Definition tile.h:50
int index
Definition tile.h:51
struct unit_list * units
Definition tile.h:58
int move_rate
Definition unittype.h:522
Definition unit.h:139
int moves_left
Definition unit.h:151
int id
Definition unit.h:146
int hp
Definition unit.h:152
int fuel
Definition unit.h:154
struct tile * tile
Definition unit.h:141
struct unit::@84::@86 client
struct act_prob * act_prob_cache
Definition unit.h:230
int homecity
Definition unit.h:147
struct civ_map map
const char * style_name_translation(const struct nation_style *pstyle)
Definition style.c:99
int style_number(const struct nation_style *pstyle)
Definition style.c:68
int basic_city_style_for_style(struct nation_style *pstyle)
Definition style.c:210
#define styles_iterate(_p)
Definition style.h:46
#define styles_iterate_end
Definition style.h:52
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:960
#define sz_strlcpy(dest, src)
Definition support.h:195
#define TRUE
Definition support.h:46
#define FALSE
Definition support.h:47
#define is_svg_flag_enabled()
Definition svgflag.h:30
#define advance_index_iterate_end
Definition tech.h:244
#define A_FIRST
Definition tech.h:44
#define A_UNSET
Definition tech.h:48
#define advance_index_iterate(_start, _index)
Definition tech.h:240
struct extra_type * get_preferred_pillage(bv_extras extras)
Definition terrain.c:549
bool get_units_upgrade_info(char *buf, size_t bufsz, struct unit_list *punits)
Definition text.c:1310
const char * get_act_sel_action_custom_text(struct action *paction, const struct act_prob prob, const struct unit *actor_unit, const struct city *target_city)
Definition text.c:1763
const char * act_sel_action_tool_tip(const struct action *paction, const struct act_prob prob)
Definition text.c:1868
struct city * tile_city(const struct tile *ptile)
Definition tile.c:83
#define tile_index(_pt_)
Definition tile.h:89
#define TILE_INDEX_NONE
Definition tile.h:48
int tileset_hex_width(const struct tileset *t)
Definition tilespec.c:747
int tileset_unit_width(const struct tileset *t)
Definition tilespec.c:823
int tileset_unit_height(const struct tileset *t)
Definition tilespec.c:831
struct sprite * load_popup_sprite(const char *tag)
Definition tilespec.c:7834
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:7106
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:7842
struct sprite * get_nation_flag_sprite(const struct tileset *t, const struct nation_type *pnation)
Definition tilespec.c:7003
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:1985
bool could_unit_load(const struct unit *pcargo, const struct unit *ptrans)
Definition unit.c:742
bool unit_can_do_action(const struct unit *punit, const action_id act_id)
Definition unit.c:401
void unit_activity_astr(const struct unit *punit, struct astring *astr)
Definition unit.c:1210
#define unit_tile(_pu)
Definition unit.h:406
#define unit_owner(_pu)
Definition unit.h:405
#define unit_list_iterate(unitlist, punit)
Definition unitlist.h:31
#define unit_list_iterate_end
Definition unitlist.h:33
const struct unit_type * unit_type_get(const struct unit *punit)
Definition unittype.c:123
const char * unit_name_translation(const struct unit *punit)
Definition unittype.c:1573
#define utype_fuel(ptype)
Definition unittype.h:844