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;
3908 choice_dialog *cd = new choice_dialog(_("Sabotage"),
3909 _("Select Improvement to Sabotage"),
3910 gui()->game_tab_widget,
3912 int nr = 0;
3913 struct astring stra = ASTRING_INIT;
3915
3916 // Should be set before sending request to the server.
3918
3919 // Put both actor, target city and action in qv1 since qv2 is taken
3922 actor_and_target.append(paction->id);
3923 qv1 = QVariant::fromValue(actor_and_target);
3924
3927 paction->id)])) {
3929 cd->add_item(QString(_("City Production")), func, qv1, -1);
3930 }
3931
3932 city_built_iterate(tcity, pimprove) {
3933 if (pimprove->sabotage > 0) {
3935 // Defeat keyboard shortcut mnemonics
3937 .replace("&", "&&");
3938 qv2 = nr;
3939 cd->add_item(str, func, qv1, improvement_number(pimprove));
3940 nr++;
3941 }
3943
3946 astr_set(&stra, _("At %s's Discretion"),
3949 str = QString(astr_str(&stra)).replace("&", "&&");
3950 cd->add_item(str, func, qv1, B_LAST);
3951 }
3952
3953 cd->set_layout();
3954 cd->show_me();
3955 astr_free(&stra);
3956}
3957
3958/***********************************************************************/
3963{
3964 QString str;
3965 QVariant qv1, qv2;
3968 struct extra_type *tgt;
3969
3971 return;
3972 }
3973 cd = new choice_dialog(_("What To Pillage"), _("Select what to pillage:"),
3974 gui()->game_tab_widget);
3975 qv2 = punit->id;
3976 while ((tgt = get_preferred_pillage(extras))) {
3977 int what;
3978
3979 what = extra_index(tgt);
3980 BV_CLR(extras, what);
3981
3983 // Defeat keyboard shortcut mnemonics
3984 str = QString(extra_name_translation(tgt)).replace("&", "&&");
3985 qv1 = what;
3986 cd->add_item(str, func, qv1, qv2);
3987 }
3988 cd->set_layout();
3989 cd->show_me();
3990}
3991
3992/***********************************************************************/
3996 QWidget *parent) : hud_message_box(parent)
3997{
3998 QString str;
3999 QPushButton *pb;
4000
4001 setAttribute(Qt::WA_DeleteOnClose);
4002 setModal(false);
4007
4008 str = QString(PL_("Are you sure you want to disband that %1 unit?",
4009 "Are you sure you want to disband those %1 units?",
4011 pb = addButton(_("Yes"), QMessageBox::AcceptRole);
4012 addButton(_("No"), QMessageBox::RejectRole);
4013 set_text_title(str, _("Disband units"));
4015 connect(pb, &QAbstractButton::clicked, this, &disband_box::disband_clicked);
4016}
4017
4018/***********************************************************************/
4029
4030/***********************************************************************/
4037
4038/***********************************************************************/
4041void popup_disband_dialog(struct unit_list *punits)
4042{
4043 disband_box *ask = new disband_box(punits, gui()->central_wdg);
4044 ask->show();
4045}
4046
4047/***********************************************************************/
4052{
4053 hud_message_box *ask = new hud_message_box(gui()->central_wdg);
4054 QString text;
4055 QString title;
4056
4057 title = QString(_("Modpack suggests using %1 tileset."))
4059 text = QString("It might not work with other tilesets.\n"
4060 "You are currently using tileset %1.")
4062 ask->addButton(_("Keep current tileset"), QMessageBox::RejectRole);
4063 ask->addButton(_("Load tileset"), QMessageBox::AcceptRole);
4064 ask->set_text_title(text, title);
4065 ask->setAttribute(Qt::WA_DeleteOnClose);
4066
4067 QObject::connect(ask, &hud_message_box::accepted, [=]() {
4070 gui()->map_scale)) {
4072 _("Can't load requested tileset."));
4073 }
4074 });
4075 ask->show();
4076}
4077
4078/***********************************************************************/
4083{
4084 hud_message_box *ask = new hud_message_box(gui()->central_wdg);
4085 QString text;
4086 QString title;
4087
4088 title = QString(_("Modpack suggests using %1 soundset."))
4090 text = QString("It might not work with other tilesets.\n"
4091 "You are currently using soundset %1.")
4092 .arg(sound_set_name);
4093 ask->addButton(_("Keep current soundset"), QMessageBox::RejectRole);
4094 ask->addButton(_("Load soundset"), QMessageBox::AcceptRole);
4095 ask->set_text_title(text, title);
4096 ask->setAttribute(Qt::WA_DeleteOnClose);
4097 QObject::connect(ask, &hud_message_box::accepted, [=]() {
4099 });
4100 ask->show();
4101}
4102
4103/***********************************************************************/
4108{
4109 hud_message_box *ask = new hud_message_box(gui()->central_wdg);
4110 QString text;
4111 QString title;
4112
4113 title = QString(_("Modpack suggests using %1 musicset."))
4115 text = QString("It might not work with other tilesets.\n"
4116 "You are currently using musicset %1.")
4117 .arg(music_set_name);
4118 ask->addButton(_("Keep current musicset"), QMessageBox::RejectRole);
4119 ask->addButton(_("Load musicset"), QMessageBox::AcceptRole);
4120 ask->set_text_title(text, title);
4121 ask->setAttribute(Qt::WA_DeleteOnClose);
4122 QObject::connect(ask, &hud_message_box::accepted, [=]() {
4124 });
4125 ask->show();
4126}
4127
4128/***********************************************************************/
4133{
4134 // PORTME
4135 return false;
4136}
4137
4138/***********************************************************************/
4142{
4144 int i;
4145
4146 nd_list = gui()->mapview_wdg->findChildren<notify_dialog *>();
4147 for (i = 0; i < nd_list.count(); i++) {
4148 nd_list[i]->restart();
4149 delete nd_list[i];
4150 }
4151}
4152
4153/***********************************************************************/
4158{
4159 int i;
4162 goto_dialog *gtd;
4163
4164 QApplication::alert(gui()->central_wdg);
4165 cd_list = gui()->game_tab_widget->findChildren <choice_dialog *>();
4166 for (i = 0; i < cd_list.count(); i++) {
4167 cd_list[i]->close();
4168 }
4169 nd_list = gui()->game_tab_widget->findChildren <notify_dialog *>();
4170 for (i = 0; i < nd_list.count(); i++) {
4171 nd_list[i]->close();
4172 }
4173
4182 gui()->popdown_unit_sel();
4183
4184 gtd = gui()->gtd;
4185
4186 if (gtd != nullptr) {
4187 gtd->close_dlg();
4188 }
4189}
4190
4191/***********************************************************************/
4197{
4198 choice_dialog *cd = gui()->get_diplo_dialog();
4199
4200 if (cd != nullptr) {
4201 return cd->unit_id;
4202 } else {
4203 return IDENTITY_NUMBER_ZERO;
4204 }
4205}
4206
4207/***********************************************************************/
4214{
4215 choice_dialog *cd = gui()->get_diplo_dialog();
4216
4217 if (cd != nullptr) {
4218 return cd->target_id[ATK_CITY];
4219 } else {
4220 return IDENTITY_NUMBER_ZERO;
4221 }
4222}
4223
4224/***********************************************************************/
4231{
4232 choice_dialog *cd = gui()->get_diplo_dialog();
4233
4234 if (cd != nullptr) {
4235 return cd->target_id[ATK_TILE];
4236 } else {
4237 return TILE_INDEX_NONE;
4238 }
4239}
4240
4241/**********************************************************************/
4248{
4249 choice_dialog *cd = gui()->get_diplo_dialog();
4250
4251 if (cd != nullptr) {
4252 return cd->sub_target_id[ASTK_EXTRA];
4253 } else {
4254 return EXTRA_NONE;
4255 }
4256}
4257
4258/***********************************************************************/
4265{
4266 choice_dialog *cd = gui()->get_diplo_dialog();
4267
4268 if (cd != nullptr) {
4269 return cd->target_id[ATK_UNIT];
4270 } else {
4271 return IDENTITY_NUMBER_ZERO;
4272 }
4273}
4274
4275/***********************************************************************/
4279 struct city *target_city,
4280 struct unit *target_unit,
4281 struct tile *target_tile,
4282 struct extra_type *target_extra,
4283 const struct act_prob *act_probs)
4284{
4287 Choice_dialog_button *cancel_button;
4288 QVariant qv1, qv2;
4289
4290 asd = gui()->get_diplo_dialog();
4291 if (asd == nullptr) {
4292 fc_assert_msg(asd != nullptr,
4293 "The action selection dialog should have been open");
4294 return;
4295 }
4296
4299 "The action selection dialog is for another actor unit.");
4300 }
4301
4302 // Put the actor id in qv1.
4303 qv1 = actor_unit->id;
4304
4305 cancel_button = asd->get_identified_button(BUTTON_CANCEL);
4306 if (cancel_button != nullptr) {
4307 /* Temporary remove the Cancel button so it won't end up above
4308 * any added buttons. */
4309 asd->stack_button(cancel_button);
4310 }
4311
4312 wait_button = asd->get_identified_button(BUTTON_WAIT);
4313 if (wait_button != nullptr) {
4314 /* Temporary remove the Wait button so it won't end up above
4315 * any added buttons. */
4316 asd->stack_button(wait_button);
4317 }
4318
4319 action_iterate(act) {
4320 const char *custom;
4321
4322 if (action_id_get_actor_kind(act) != AAK_UNIT) {
4323 // Not relevant.
4324 continue;
4325 }
4326
4328 act_probs[act],
4329 actor_unit,
4330 target_city);
4331
4332 // Put the target id in qv2.
4333 switch (action_id_get_target_kind(act)) {
4334 case ATK_UNIT:
4335 if (target_unit != nullptr) {
4336 qv2 = target_unit->id;
4337 } else {
4339 || target_unit != nullptr,
4340 "Action enabled against non existing unit!");
4341
4343 }
4344 break;
4345 case ATK_CITY:
4346 if (target_city != nullptr) {
4347 qv2 = target_city->id;
4348 } else {
4350 || target_city != nullptr,
4351 "Action enabled against non existing city!");
4352
4354 }
4355 break;
4356 case ATK_TILE:
4357 case ATK_EXTRAS:
4358 case ATK_STACK:
4359 if (target_tile != nullptr) {
4361 } else {
4363 || target_tile != nullptr,
4364 "Action enabled against all units on "
4365 "non existing tile!");
4366
4368 }
4369 break;
4370 case ATK_SELF:
4371 qv2 = actor_unit->id;
4372 break;
4373 case ATK_COUNT:
4375 "Bad target kind");
4376 continue;
4377 }
4378
4379 if (asd->get_identified_button(act)) {
4380 // Update the existing button.
4381 action_entry_update(asd->get_identified_button(act),
4382 act, act_probs, custom,
4383 qv1, qv2);
4384 } else {
4385 // Add the button (unless its probability is 0).
4387 qv1, qv2);
4388 }
4390
4391 if (wait_button != nullptr || cancel_button != nullptr) {
4392 /* Reinsert the non action buttons below any potential
4393 * buttons recently added. */
4394 asd->unstack_all_buttons();
4395 }
4396}
4397
4398/***********************************************************************/
4402{
4404
4405 cd = gui()->get_diplo_dialog();
4406 if (cd != nullptr) {
4407 did_not_decide = true;
4408 cd->close();
4409 }
4410}
4411
4412/***********************************************************************/
4418
4419/***********************************************************************/
4422void show_tileset_error(bool fatal, const char *tset_name, const char *msg)
4423{
4424 QWidget *parent;
4425 fc_client *std_gui = gui();
4426
4427 if (std_gui != nullptr) {
4428 parent = std_gui->central_wdg;
4429 } else {
4430 parent = nullptr;
4431 }
4432
4433 if (std_gui != nullptr || fatal) {
4434 char buf[1024];
4435 QMessageBox *ask = new QMessageBox(parent);
4436
4437 if (tset_name != nullptr) {
4438 fc_snprintf(buf, sizeof(buf),
4439 _("Tileset \"%s\" problem, it's probably incompatible with "
4440 "the ruleset:\n%s"), tset_name, msg);
4441 } else {
4442 fc_snprintf(buf, sizeof(buf),
4443 _("Tileset problem, it's probably incompatible with "
4444 "the ruleset:\n%s"), msg);
4445 }
4446
4447 ask->setText(buf);
4448 ask->setStandardButtons(QMessageBox::Ok);
4449 ask->setWindowTitle(_("Tileset error"));
4450
4451 if (std_gui != nullptr && !fatal) {
4452 ask->setAttribute(Qt::WA_DeleteOnClose);
4453 ask->show();
4454 } else {
4455 ask->exec();
4456 }
4457 }
4458}
4459
4460/***********************************************************************/
4463void popup_upgrade_dialog(struct unit_list *punits)
4464{
4465 char buf[512];
4467 QString title;
4469
4470 if (!punits || unit_list_size(punits) == 0) {
4471 return;
4472 }
4473
4474 ask = new hud_message_box(gui()->central_wdg);
4475
4476 punit_ids = new QVector<int>();
4478 punit_ids->push_back(punit->id);
4480
4481 if (!get_units_upgrade_info(buf, sizeof(buf), punits)) {
4482 title = _("Upgrade Unit!");
4483 ask->setStandardButtons(QMessageBox::Ok);
4484 } else {
4485 title = _("Upgrade Obsolete Units");
4486 ask->setStandardButtons(QMessageBox::Cancel | QMessageBox::Ok);
4487 ask->setDefaultButton(QMessageBox::Cancel);
4488 }
4489 ask->set_text_title(buf, title);
4490 ask->setAttribute(Qt::WA_DeleteOnClose);
4491 QObject::connect(ask, &hud_message_box::accepted, [=]() {
4492 std::unique_ptr<QVector<int>> uptr(punit_ids);
4493 struct unit *punit;
4494
4495 for (int id : *uptr) {
4497 if (punit) {
4499 }
4500 }
4501 });
4502 ask->show();
4503}
4504
4505/***********************************************************************/
4509{
4510 QPoint p, final_p;
4511
4513 utile = ptile;
4514 pix = nullptr;
4515 show_line = 0;
4516 highligh_num = -1;
4517 ufont.setItalic(true);
4519 update_units();
4520 h_pix = nullptr;
4521 create_pixmap();
4522 p = mapFromGlobal(QCursor::pos());
4523 cw = new close_widget(this);
4524 setMouseTracking(true);
4525 final_p.setX(p.x());
4526 final_p.setY(p.y());
4527 if (p.x() + width() > parentWidget()->width()) {
4528 final_p.setX(parentWidget()->width() - width());
4529 }
4530 if (p.y() - height() < 0) {
4531 final_p.setY(height());
4532 }
4533 move(final_p.x(), final_p.y() - height());
4534 setFocus();
4535 /* Build fails with qt5 connect style for static functions
4536 * Qt5.2 so dont update */
4537 QTimer::singleShot(10, this, SLOT(update_img()));
4538}
4539
4540/***********************************************************************/
4544{
4545 delete h_pix;
4546 delete pix;
4547 delete cw;
4548}
4549
4550/***********************************************************************/
4554{
4555 int a;
4556 int x, y, i;
4559 QImage img;
4561 QPainter p;
4562 QPen pen;
4563 QPixmap pixc;
4564 QPixmap *pixp;
4566 QRect crop;
4567 struct canvas *unit_pixmap;
4568 struct unit *punit;
4569 float isosize;
4570
4571 if (pix != nullptr) {
4572 delete pix;
4573 pix = nullptr;
4574 };
4575 isosize = 0.7;
4577 isosize = 0.5;
4578 }
4579
4580 update_units();
4581 if (unit_list.count() > 0) {
4585 } else {
4588 }
4589 more = false;
4590 if (h_pix != nullptr) {
4591 delete h_pix;
4592 }
4593 h_pix = new QPixmap(item_size.width(), item_size.height());
4594 h_pix->fill(palette().color(QPalette::HighlightedText));
4595 if (unit_count < 5) {
4596 row_count = 1;
4597 pix = new QPixmap((unit_list.size()) * item_size.width(),
4598 item_size.height());
4599 } else if (unit_count < 9) {
4600 row_count = 2;
4601 pix = new QPixmap(4 * item_size.width(), 2 * item_size.height());
4602 } else {
4603 row_count = 3;
4604 if (unit_count > 12) {
4605 more = true;
4606 }
4607 pix = new QPixmap(4 * item_size.width(), 3 * item_size.height());
4608 }
4609 pix->fill(Qt::transparent);
4610 foreach(punit, unit_list) {
4613 unit_pixmap->map_pixmap.fill(Qt::transparent);
4614 put_unit(punit, unit_pixmap, 1.0, 0, 0);
4615 img = unit_pixmap->map_pixmap.toImage();
4617 cropped_img = img.copy(crop);
4621 Qt::KeepAspectRatio,
4622 Qt::SmoothTransformation);
4623 } else {
4626 Qt::KeepAspectRatio,
4627 Qt::SmoothTransformation);
4628 }
4629 pixc = QPixmap::fromImage(img);
4630 pixp = new QPixmap(pixc);
4631 pix_list.push_back(pixp);
4633 }
4634 a = qMin(item_size.width() / 4, 12);
4635 x = 0, y = -item_size.height(), i = -1;
4636 p.begin(pix);
4637 ufont.setPixelSize(a);
4638 p.setFont(ufont);
4639 pen.setColor(palette().color(QPalette::Text));
4640 p.setPen(pen);
4641
4642 while (!pix_list.isEmpty()) {
4643 tmp_pix = pix_list.takeFirst();
4644 i++;
4645 if (i % 4 == 0) {
4646 x = 0;
4647 y = y + item_size.height();
4648 }
4649 punit = unit_list.at(i);
4650 Q_ASSERT(punit != nullptr);
4651
4652 if (i == highligh_num) {
4653 p.drawPixmap(x, y, *h_pix);
4654 p.drawPixmap(x, y, *tmp_pix);
4655 } else {
4656 p.drawPixmap(x, y, *tmp_pix);
4657 }
4658
4660 int rate, f;
4661 QString str;
4662
4664 f = ((punit->fuel) - 1);
4667 str = str + "(" + QString(move_points_text((rate * f)
4668 + punit->moves_left, false)) + ")";
4669 }
4670 // TRANS: MP = Movement points
4671 str = QString(_("MP:")) + str;
4672 p.drawText(x, y + item_size.height() - 4, str);
4673 }
4674
4675 x = x + item_size.width();
4676 delete tmp_pix;
4677 }
4678 p.end();
4679 setFixedWidth(pix->width() + 20);
4680 setFixedHeight(pix->height() + 2 * (fm.height() + 6));
4681 qDeleteAll(pix_list.begin(), pix_list.end());
4682 }
4683}
4684
4685/***********************************************************************/
4689{
4690 int a, b;
4691 int old_h;
4693 QPoint pos = event->pos();
4694 int x = pos.x();
4695 int y = pos.y();
4696
4698 highligh_num = -1;
4699 if (x > width() - 11
4700 || y > height() - fm.height() - 5
4701 || y < fm.height() + 3 || x < 11) {
4702 // Do nothing if mouse is on border, just skip next if
4703 } else if (row_count > 0) {
4704 a = (x - 10) / item_size.width();
4705 b = (y - fm.height() - 3) / item_size.height();
4706 highligh_num = b * 4 + a;
4707 }
4708 if (old_h != highligh_num) {
4709 create_pixmap();
4710 update();
4711 }
4712}
4713
4714/***********************************************************************/
4720{
4721 struct unit *punit;
4722 if (event->button() == Qt::RightButton) {
4723 was_destroyed = true;
4724 close();
4725 destroy();
4726 }
4727 if (event->button() == Qt::LeftButton && highligh_num != -1) {
4728 update_units();
4729 if (highligh_num >= unit_list.count()) {
4730 return;
4731 }
4734 was_destroyed = true;
4735 close();
4736 destroy();
4737 }
4738}
4739
4740/***********************************************************************/
4745{
4746 create_pixmap();
4747 update();
4748}
4749
4750/***********************************************************************/
4754{
4756 int h, i;
4757 int *f_size;
4758 QPen pen;
4759 QString str, str2;
4760 struct unit *punit;
4761 int point_size = info_font.pointSize();
4762 int pixel_size = info_font.pixelSize();
4763
4764 if (point_size < 0) {
4765 f_size = &pixel_size;
4766 } else {
4767 f_size = &point_size;
4768 }
4769 if (highligh_num != -1 && highligh_num < unit_list.count()) {
4770 struct astring addition = ASTRING_INIT;
4771
4774
4775 // TRANS: HP - hit points
4776 str2 = QString(_("%1 HP:%2/%3")).arg(QString(astr_str(&addition)),
4777 QString::number(punit->hp),
4778 QString::number(unit_type_get(punit)->hp));
4780 }
4781 str = QString(PL_("%1 unit", "%1 units",
4783 .arg(unit_list_size(utile->units));
4784 for (i = *f_size; i > 4; i--) {
4785 if (point_size < 0) {
4786 info_font.setPixelSize(i);
4787 } else {
4788 info_font.setPointSize(i);
4789 }
4791 if (10 + qfm.horizontalAdvance(str2) < width()) {
4792 break;
4793 }
4794 }
4795 h = fm.height();
4796 if (pix != nullptr) {
4797 painter->drawPixmap(10, h + 3, *pix);
4798 pen.setColor(palette().color(QPalette::Text));
4799 painter->setPen(pen);
4800 painter->setFont(info_font);
4801 painter->drawText(10, h, str);
4802 if (highligh_num != -1 && highligh_num < unit_list.count()) {
4803 painter->drawText(10, height() - 5, str2);
4804 }
4805 // Draw scroll
4806 if (more) {
4807 int maxl = ((unit_count - 1) / 4) + 1;
4808 float page_height = 3.0f / maxl;
4809 float page_start = (static_cast<float>(show_line)) / maxl;
4810 pen.setColor(palette().color(QPalette::HighlightedText));
4811 painter->setBrush(palette().color(QPalette::HighlightedText).darker());
4812 painter->setPen(palette().color(QPalette::HighlightedText).darker());
4813 painter->drawRect(pix->width() + 10, h, 8, h + pix->height());
4814 painter->setPen(pen);
4815 painter->drawRoundedRect(pix->width() + 10,
4816 h + page_start * pix->height(),
4817 8, h + page_height * pix->height(), 2, 2);
4818 }
4819 }
4820 if (point_size < 0) {
4821 info_font.setPixelSize(*f_size);
4822 } else {
4823 info_font.setPointSize(*f_size);
4824 }
4825 cw->put_to_corner();
4826}
4827
4828/***********************************************************************/
4832{
4834
4835 painter.begin(this);
4836 paint(&painter, event);
4837 painter.end();
4838}
4839
4840/***********************************************************************/
4845{
4846 was_destroyed = true;
4847 close();
4848 destroy();
4849}
4850
4851/***********************************************************************/
4855{
4856 int i = 1;
4857 struct unit_list *punit_list;
4858
4859 unit_count = 0;
4860 if (utile == nullptr) {
4861 struct unit *punit = head_of_units_in_focus();
4862 if (punit) {
4864 }
4865 }
4866 unit_list.clear();
4867 if (utile != nullptr) {
4869 if (punit_list != nullptr) {
4871 unit_count++;
4872 if (i > show_line * 4)
4873 unit_list.push_back(punit);
4874 i++;
4876 }
4877 }
4878 if (unit_list.count() == 0) {
4879 close();
4880 }
4881}
4882
4883/***********************************************************************/
4887{
4888 gui()->mapview_wdg->setFocus();
4889 QWidget::closeEvent(event);
4890}
4891
4892/***********************************************************************/
4896{
4897 int nr;
4898
4899 if (!more && utile == nullptr) {
4900 return;
4901 }
4902 nr = qCeil(static_cast<qreal>(unit_list_size(utile->units)) / 4) - 3;
4903 if (event->angleDelta().y() < 0) {
4904 show_line++;
4906 } else {
4907 show_line--;
4908 show_line = qMax(0, show_line);
4909 }
4910 update_units();
4911 create_pixmap();
4912 update();
4913 event->accept();
4914}
4915
4916/***********************************************************************/
4920{
4921 if (event->key() == Qt::Key_Escape) {
4922 was_destroyed = true;
4923 close();
4924 destroy();
4925 }
4926 QWidget::keyPressEvent(event);
4927}
4928
4929/***********************************************************************/
4936
4937/***********************************************************************/
4944
4945/***********************************************************************/
4950{
4951 // Just tell the client common code to handle this.
4952 return false;
4953}
4954
4955/***********************************************************************/
4958bool qtg_request_transport(struct unit *pcargo, struct tile *ptile)
4959{
4960 int tcount;
4962 struct unit_list *potential_transports = unit_list_new();
4963#ifndef FREECIV_NDEBUG
4965#endif
4966
4970 }
4972
4974
4975 if (tcount == 0) {
4976 fc_assert(best_transport == nullptr);
4978
4979 return false; // Unit was not handled here.
4980 } else if (tcount == 1) {
4981 // There's exactly one potential transport - use it automatically
4984
4986
4987 return true;
4988 }
4989
4990 hul = new hud_unit_loader(pcargo, ptile);
4991 hul->show_me();
4992 return true;
4993}
4994
4995/***********************************************************************/
4999void qtg_popup_combat_info(int attacker_unit_id, int defender_unit_id,
5000 int attacker_hp, int defender_hp,
5001 bool make_att_veteran, bool make_def_veteran)
5002{
5003 if (gui()->qt_settings.show_battle_log) {
5004 hud_unit_combat *huc = new hud_unit_combat(attacker_unit_id,
5005 defender_unit_id,
5006 attacker_hp, defender_hp,
5007 make_att_veteran,
5008 make_def_veteran,
5009 gui()->battlelog_wdg->scale,
5010 gui()->battlelog_wdg);
5011
5012 gui()->battlelog_wdg->add_combat_info(huc);
5013 gui()->battlelog_wdg->show();
5014 }
5015}
5016
5017/**********************************************************************/
5021 struct act_confirmation_data *data)
5022{
5023 hud_message_box *ask = new hud_message_box(gui()->central_wdg);
5024
5025 ask->setStandardButtons(QMessageBox::Cancel | QMessageBox::Ok);
5026 ask->setDefaultButton(QMessageBox::Cancel);
5027 ask->set_text_title(body, hdr);
5028 ask->setAttribute(Qt::WA_DeleteOnClose);
5029 QObject::connect(ask, &hud_message_box::accepted, [=]() {
5031 });
5032 QObject::connect(ask, &hud_message_box::rejected, [=]() {
5034 });
5035
5036 ask->show();
5037}
5038
5039/***********************************************************************/
5043 struct act_confirmation_data *data)
5044{
5046
5047 hdr = QString(_("Are you sure you want to do %1?")).
5049
5050 if (expl != nullptr) {
5052 }
5053
5055}
5056
5057/**********************************************************************/
5060void qtg_popup_image(const char *tag)
5061{
5062 struct sprite *spr = load_popup_sprite(tag);
5063
5064 if (spr != nullptr) {
5065 QDialog *win = new QDialog(gui());
5066 QVBoxLayout *layout = new QVBoxLayout(win);
5067 QPixmap *pm = new QPixmap(*spr->pm);
5068 QLabel *lbl = new QLabel;
5069 int width, height;
5070
5072 win->setFixedSize(width, height);
5073 lbl->setPixmap(*pm);
5074 layout->addWidget(lbl);
5075 win->setLayout(layout);
5076
5077 win->show();
5078
5080 } else {
5081 log_error(_("No image for tag \"%s\", requested by the server."), tag);
5082 }
5083}
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:3828
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:4021
disband_box(struct unit_list *punits, QWidget *parent=0)
Definition dialogs.cpp:3995
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:4940
void set_diplo_dialog(choice_dialog *widget)
Definition dialogs.cpp:4932
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:4886
void update_img()
Definition dialogs.cpp:4744
int show_line
Definition dialogs.h:233
void mouseMoveEvent(QMouseEvent *event)
Definition dialogs.cpp:4688
int highligh_num
Definition dialogs.h:234
void paint(QPainter *painter, QPaintEvent *event)
Definition dialogs.cpp:4753
void update_menu()
Definition dialogs.cpp:4844
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:4508
void update_units()
Definition dialogs.cpp:4854
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:4831
void create_pixmap()
Definition dialogs.cpp:4553
void wheelEvent(QWheelEvent *event)
Definition dialogs.cpp:4895
void keyPressEvent(QKeyEvent *event)
Definition dialogs.cpp:4919
void mousePressEvent(QMouseEvent *event)
Definition dialogs.cpp:4719
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:4949
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:4247
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:4230
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:4196
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:4107
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:4463
void update_nationset_combo()
Definition dialogs.cpp:1272
void action_selection_close(void)
Definition dialogs.cpp:4401
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:4213
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:4415
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:4082
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:4041
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:5060
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:4051
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:5020
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:3962
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:5042
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:4278
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:4132
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:4999
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:4422
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:4958
int action_selection_target_unit(void)
Definition dialogs.cpp:4264
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:4141
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:4157
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: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 const struct action *paction const char * expl
Definition dialogs_g.h:94
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:77
struct unit struct city struct unit * target_unit
Definition dialogs_g.h:56
popup_action_selection
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 * actor
Definition dialogs_g.h:73
struct unit * actor_unit
Definition dialogs_g.h:55
const char * caption
Definition dialogs_g.h:37
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:69
const char const char * headline
Definition dialogs_g.h:38
popup_notify_dialog
Definition dialogs_g.h:37
struct unit struct city struct unit struct tile * target_tile
Definition dialogs_g.h:57
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:74
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:78
struct unit struct city * target_city
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 int cost
Definition dialogs_g.h:74
struct unit struct city struct unit struct tile struct extra_type * target_extra
Definition dialogs_g.h:57
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:3565
#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:5086
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:160
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:140
int moves_left
Definition unit.h:152
int id
Definition unit.h:147
int hp
Definition unit.h:153
int fuel
Definition unit.h:155
struct tile * tile
Definition unit.h:142
struct unit::@84::@86 client
struct act_prob * act_prob_cache
Definition unit.h:231
int homecity
Definition unit.h:148
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:407
#define unit_owner(_pu)
Definition unit.h:406
#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