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) {
2079 astr_set(&text,
2080 // TRANS: Your Spy is ready to act against Roman Freight.
2081 _("Your %s is ready to act against %s %s."),
2085 } else {
2086 fc_assert_msg(target_unit != nullptr
2087 || target_city != nullptr
2088 || target_tile != nullptr,
2089 "No target specified.");
2090
2091 astr_set(&text,
2092 // TRANS: %s is a unit name, e.g., Diplomat, Spy
2093 _("Your %s is waiting for your command."),
2095 }
2096
2097 cd = gui()->get_diplo_dialog();
2098 if ((cd != nullptr) && cd->targeted_unit != nullptr) {
2099 cd->update_dialog(act_probs);
2100 return;
2101 }
2102 cd = new choice_dialog(astr_str(&title), astr_str(&text),
2103 gui()->game_tab_widget,
2105 qv1 = actor_unit->id;
2106
2107 cd->unit_id = actor_unit->id;
2108
2109 cd->target_id[ATK_SELF] = cd->unit_id;
2110
2111 if (target_city) {
2112 cd->target_id[ATK_CITY] = target_city->id;
2113 } else {
2114 cd->target_id[ATK_CITY] = IDENTITY_NUMBER_ZERO;
2115 }
2116
2117 if (target_unit) {
2118 cd->target_id[ATK_UNIT] = target_unit->id;
2119 } else {
2120 cd->target_id[ATK_UNIT] = IDENTITY_NUMBER_ZERO;
2121 }
2122
2123 if (target_tile) {
2124 cd->target_id[ATK_STACK] = tile_index(target_tile);
2125 } else {
2126 cd->target_id[ATK_STACK] = TILE_INDEX_NONE;
2127 }
2128
2129 if (target_tile) {
2130 cd->target_id[ATK_TILE] = tile_index(target_tile);
2131 } else {
2132 cd->target_id[ATK_TILE] = TILE_INDEX_NONE;
2133 }
2134
2135 if (target_tile) {
2136 cd->target_id[ATK_EXTRAS] = tile_index(target_tile);
2137 } else {
2138 cd->target_id[ATK_EXTRAS] = TILE_INDEX_NONE;
2139 }
2140
2141 // No target building or target tech supplied. (Feb 2020)
2142 cd->sub_target_id[ASTK_BUILDING] = B_LAST;
2143 cd->sub_target_id[ASTK_TECH] = A_UNSET;
2144
2145 if (target_extra) {
2146 cd->sub_target_id[ASTK_EXTRA] = extra_number(target_extra);
2148 } else {
2149 cd->sub_target_id[ASTK_EXTRA] = EXTRA_NONE;
2150 cd->sub_target_id[ASTK_EXTRA_NOT_THERE] = EXTRA_NONE;
2151 }
2152
2153 // Unit acting against a city
2154
2155 // Set the correct target for the following actions.
2156 qv2 = cd->target_id[ATK_CITY];
2157
2158 action_iterate(act) {
2163 act_probs[act],
2164 actor_unit,
2165 target_city),
2166 qv1, qv2);
2167 }
2169
2170 // Unit acting against another unit
2171
2172 // Set the correct target for the following actions.
2173 qv2 = cd->target_id[ATK_UNIT];
2174
2175 action_iterate(act) {
2180 act_probs[act],
2181 actor_unit,
2182 target_city),
2183 qv1, qv2);
2184 }
2186
2187 // Unit acting against all units at a tile
2188
2189 // Set the correct target for the following actions.
2190 qv2 = cd->target_id[ATK_STACK];
2191
2192 action_iterate(act) {
2197 act_probs[act],
2198 actor_unit,
2199 target_city),
2200 qv1, qv2);
2201 }
2203
2204 // Unit acting against a tile.
2205
2206 // Set the correct target for the following actions.
2207 qv2 = cd->target_id[ATK_TILE];
2208
2209 action_iterate(act) {
2214 act_probs[act],
2215 actor_unit,
2216 target_city),
2217 qv1, qv2);
2218 }
2220
2221 // Unit acting against a tile's extras.
2222
2223 // Set the correct target for the following actions.
2224 qv2 = cd->target_id[ATK_EXTRAS];
2225
2226 action_iterate(act) {
2231 act_probs[act],
2232 actor_unit,
2233 target_city),
2234 qv1, qv2);
2235 }
2237
2238 // Unit acting against itself
2239
2240 // Set the correct target for the following actions.
2241 qv2 = cd->target_id[ATK_SELF];
2242
2243 action_iterate(act) {
2248 act_probs[act],
2249 actor_unit,
2250 target_city),
2251 qv1, qv2);
2252 }
2254
2256 cd->add_item(QString(_("&Wait")), func, qv1, qv2,
2257 "", BUTTON_WAIT);
2258
2259 func = keep_moving;
2260 cd->add_item(QString(_("Do nothing")), func, qv1, qv2,
2261 "", BUTTON_CANCEL);
2262
2263 cd->set_layout();
2264 cd->show_me();
2265
2266 // Give follow up questions access to action probabilities.
2268 action_iterate(act) {
2271
2272 astr_free(&title);
2273 astr_free(&text);
2274}
2275
2276/***********************************************************************/
2281{
2282 /* Don't add an action mapping here unless the non targeted version is
2283 * selectable in the targeted version's target selection dialog. */
2284 switch ((enum gen_action)tgt_action_id) {
2290 return ACTION_SPY_STEAL_TECH;
2293 default:
2294 // No non targeted version found.
2295 return ACTION_NONE;
2296 }
2297}
2298
2299/**********************************************************************/
2304{
2305 /* Don't add an action mapping here unless the non targeted version is
2306 * selectable in the targeted version's target selection dialog. */
2307 switch ((enum gen_action)tgt_action_id) {
2314 default:
2315 // No non targeted version found.
2316 return ACTION_NONE;
2317 }
2318}
2319
2320/***********************************************************************/
2324 action_id act,
2325 const struct act_prob *act_probs,
2326 const char *custom,
2327 QVariant data1, QVariant data2)
2328{
2329 QString title;
2331
2332 if (!af_map.contains(act)) {
2333 /* The Qt client doesn't support ordering this action from the
2334 * action selection dialog. */
2335 return;
2336 }
2337
2338 // Don't show disabled actions.
2339 if (!action_prob_possible(act_probs[act])) {
2340 return;
2341 }
2342
2344 act_probs[act],
2345 custom));
2346
2348 act_probs[act]));
2349
2350 cd->add_item(title, af_map[act], data1, data2, tool_tip, act);
2351}
2352
2353/***********************************************************************/
2357 action_id act,
2358 const struct act_prob *act_probs,
2359 const char *custom,
2360 QVariant data1, QVariant data2)
2361{
2362 QString title;
2364
2365 /* An action that just became impossible has its button disabled.
2366 * An action that became possible again must be re-enabled. */
2367 button->setEnabled(action_prob_possible(act_probs[act]));
2368 button->setData1(data1);
2369 button->setData2(data2);
2370 // The probability may have changed.
2372 act_probs[act],
2373 custom));
2374
2376 act_probs[act]));
2377
2378 button->setText(title);
2379 button->setToolTip(tool_tip);
2380}
2381
2382/***********************************************************************/
2385static void disband_unit(QVariant data1, QVariant data2)
2386{
2387 int actor_id = data1.toInt();
2388 int target_id = data2.toInt();
2389
2391 target_id, 0, "");
2392}
2393
2394/***********************************************************************/
2397static void fortify(QVariant data1, QVariant data2)
2398{
2399 int actor_id = data1.toInt();
2400 int target_id = data2.toInt();
2401
2402 if (game_unit_by_number(actor_id) != nullptr) {
2404 target_id, 0, "");
2405 }
2406}
2407
2408/***********************************************************************/
2411static void convert_unit(QVariant data1, QVariant data2)
2412{
2413 int actor_id = data1.toInt();
2414 int target_id = data2.toInt();
2415
2417 target_id, 0, "");
2418}
2419
2420/***********************************************************************/
2423static void homeless(QVariant data1, QVariant data2)
2424{
2425 int actor_id = data1.toInt();
2426 int target_id = data2.toInt();
2427
2428 if (game_unit_by_number(actor_id) != nullptr) {
2430 target_id, 0, "");
2431 }
2432}
2433
2434/***********************************************************************/
2437static void diplomat_bribe_unit(QVariant data1, QVariant data2)
2438{
2439 int diplomat_id = data1.toInt();
2440 int diplomat_target_id = data2.toInt();
2441
2442 if (game_unit_by_number(diplomat_id) != nullptr
2443 && game_unit_by_number(diplomat_target_id) != nullptr) {
2444 // Wait for the server's reply before moving on to the next queued diplomat.
2446
2449 }
2450}
2451
2452/***********************************************************************/
2455static void diplomat_bribe_stack(QVariant data1, QVariant data2)
2456{
2457 int diplomat_id = data1.toInt();
2458 int diplomat_target_id = data2.toInt();
2459
2460 if (game_unit_by_number(diplomat_id) != nullptr) {
2461 // Wait for the server's reply before moving on to the next queued diplomat.
2463
2466 }
2467}
2468
2469/***********************************************************************/
2472static void spy_sabotage_unit(QVariant data1, QVariant data2)
2473{
2474 int diplomat_id = data1.toInt();
2475 int diplomat_target_id = data2.toInt();
2476
2478 diplomat_target_id, 0, "");
2479}
2480
2481/***********************************************************************/
2484static void spy_sabotage_unit_esc(QVariant data1, QVariant data2)
2485{
2486 int diplomat_id = data1.toInt();
2487 int diplomat_target_id = data2.toInt();
2488
2490 diplomat_target_id, 0, "");
2491}
2492
2493/***********************************************************************/
2496static void heal_unit(QVariant data1, QVariant data2)
2497{
2498 int actor_id = data1.toInt();
2499 int target_id = data2.toInt();
2500
2501 request_do_action(ACTION_HEAL_UNIT, actor_id, target_id, 0, "");
2502}
2503
2504/***********************************************************************/
2507static void heal_unit2(QVariant data1, QVariant data2)
2508{
2509 int actor_id = data1.toInt();
2510 int target_id = data2.toInt();
2511
2512 request_do_action(ACTION_HEAL_UNIT2, actor_id, target_id, 0, "");
2513}
2514
2515/***********************************************************************/
2518static void transport_board(QVariant data1, QVariant data2)
2519{
2520 int actor_id = data1.toInt();
2521 int target_id = data2.toInt();
2522
2523 request_do_action(ACTION_TRANSPORT_BOARD, actor_id, target_id, 0, "");
2524}
2525
2526/***********************************************************************/
2529static void transport_board2(QVariant data1, QVariant data2)
2530{
2531 int actor_id = data1.toInt();
2532 int target_id = data2.toInt();
2533
2534 request_do_action(ACTION_TRANSPORT_BOARD2, actor_id, target_id, 0, "");
2535}
2536
2537/***********************************************************************/
2540static void transport_board3(QVariant data1, QVariant data2)
2541{
2542 int actor_id = data1.toInt();
2543 int target_id = data2.toInt();
2544
2545 request_do_action(ACTION_TRANSPORT_BOARD3, actor_id, target_id, 0, "");
2546}
2547
2548/***********************************************************************/
2551static void transport_embark(QVariant data1, QVariant data2)
2552{
2553 int actor_id = data1.toInt();
2554 int target_id = data2.toInt();
2555
2556 request_do_action(ACTION_TRANSPORT_EMBARK, actor_id, target_id, 0, "");
2557}
2558
2559/***********************************************************************/
2562static void transport_embark2(QVariant data1, QVariant data2)
2563{
2564 int actor_id = data1.toInt();
2565 int target_id = data2.toInt();
2566
2567 request_do_action(ACTION_TRANSPORT_EMBARK2, actor_id, target_id, 0, "");
2568}
2569
2570/***********************************************************************/
2573static void transport_embark3(QVariant data1, QVariant data2)
2574{
2575 int actor_id = data1.toInt();
2576 int target_id = data2.toInt();
2577
2578 request_do_action(ACTION_TRANSPORT_EMBARK3, actor_id, target_id, 0, "");
2579}
2580
2581/***********************************************************************/
2584static void transport_embark4(QVariant data1, QVariant data2)
2585{
2586 int actor_id = data1.toInt();
2587 int target_id = data2.toInt();
2588
2589 request_do_action(ACTION_TRANSPORT_EMBARK4, actor_id, target_id, 0, "");
2590}
2591
2592/***********************************************************************/
2595static void transport_unload(QVariant data1, QVariant data2)
2596{
2597 int actor_id = data1.toInt();
2598 int target_id = data2.toInt();
2599
2600 request_do_action(ACTION_TRANSPORT_UNLOAD, actor_id, target_id, 0, "");
2601}
2602
2603/***********************************************************************/
2606static void transport_load(QVariant data1, QVariant data2)
2607{
2608 int actor_id = data1.toInt();
2609 int target_id = data2.toInt();
2610
2611 request_do_action(ACTION_TRANSPORT_LOAD, actor_id, target_id, 0, "");
2612}
2613
2614/***********************************************************************/
2617static void transport_load2(QVariant data1, QVariant data2)
2618{
2619 int actor_id = data1.toInt();
2620 int target_id = data2.toInt();
2621
2622 request_do_action(ACTION_TRANSPORT_LOAD2, actor_id, target_id, 0, "");
2623}
2624
2625/***********************************************************************/
2628static void transport_load3(QVariant data1, QVariant data2)
2629{
2630 int actor_id = data1.toInt();
2631 int target_id = data2.toInt();
2632
2633 request_do_action(ACTION_TRANSPORT_LOAD3, actor_id, target_id, 0, "");
2634}
2635
2636/***********************************************************************/
2639static void transport_deboard(QVariant data1, QVariant data2)
2640{
2641 int actor_id = data1.toInt();
2642 int target_id = data2.toInt();
2643
2644 request_do_action(ACTION_TRANSPORT_DEBOARD, actor_id, target_id, 0, "");
2645}
2646
2647/***********************************************************************/
2650static void disembark1(QVariant data1, QVariant data2)
2651{
2652 int actor_id = data1.toInt();
2653 int target_id = data2.toInt();
2654
2655 if (game_unit_by_number(actor_id) != nullptr
2656 && index_to_tile(&(wld.map), target_id) != nullptr) {
2658 actor_id, target_id, 0, "");
2659 }
2660}
2661
2662/***********************************************************************/
2665static void disembark2(QVariant data1, QVariant data2)
2666{
2667 int actor_id = data1.toInt();
2668 int target_id = data2.toInt();
2669
2670 if (game_unit_by_number(actor_id) != nullptr
2671 && index_to_tile(&(wld.map), target_id) != nullptr) {
2673 actor_id, target_id, 0, "");
2674 }
2675}
2676
2677/***********************************************************************/
2680static void enter_hut(QVariant data1, QVariant data2)
2681{
2682 int actor_id = data1.toInt();
2683 int target_id = data2.toInt();
2684
2685 if (game_unit_by_number(actor_id) != nullptr
2686 && index_to_tile(&(wld.map), target_id) != nullptr) {
2688 actor_id, target_id, 0, "");
2689 }
2690}
2691
2692/***********************************************************************/
2695static void enter_hut2(QVariant data1, QVariant data2)
2696{
2697 int actor_id = data1.toInt();
2698 int target_id = data2.toInt();
2699
2700 if (game_unit_by_number(actor_id) != nullptr
2701 && index_to_tile(&(wld.map), target_id) != nullptr) {
2703 actor_id, target_id, 0, "");
2704 }
2705}
2706
2707/***********************************************************************/
2710static void frighten_hut(QVariant data1, QVariant data2)
2711{
2712 int actor_id = data1.toInt();
2713 int target_id = data2.toInt();
2714
2715 if (game_unit_by_number(actor_id) != nullptr
2716 && index_to_tile(&(wld.map), target_id) != nullptr) {
2718 actor_id, target_id, 0, "");
2719 }
2720}
2721
2722/***********************************************************************/
2725static void frighten_hut2(QVariant data1, QVariant data2)
2726{
2727 int actor_id = data1.toInt();
2728 int target_id = data2.toInt();
2729
2730 if (game_unit_by_number(actor_id) != nullptr
2731 && index_to_tile(&(wld.map), target_id) != nullptr) {
2733 actor_id, target_id, 0, "");
2734 }
2735}
2736
2737/**********************************************************************/
2740static void nuke_units(QVariant data1, QVariant data2)
2741{
2742 int actor_id = data1.toInt();
2743 int target_id = data2.toInt();
2744
2746 target_id, 0, "");
2747}
2748
2749/**********************************************************************/
2752static void collect_ransom(QVariant data1, QVariant data2)
2753{
2754 int actor_id = data1.toInt();
2755 int target_id = data2.toInt();
2756
2758 target_id, 0, "");
2759}
2760
2761/**********************************************************************/
2764static void wipe_units(QVariant data1, QVariant data2)
2765{
2766 int actor_id = data1.toInt();
2767 int target_id = data2.toInt();
2768
2770 target_id, 0, "");
2771}
2772
2773/**********************************************************************/
2776static void capture_units(QVariant data1, QVariant data2)
2777{
2778 int actor_id = data1.toInt();
2779 int target_id = data2.toInt();
2780
2782 target_id, 0, "");
2783}
2784
2785/***********************************************************************/
2788static void expel_unit(QVariant data1, QVariant data2)
2789{
2790 int actor_id = data1.toInt();
2791 int target_id = data2.toInt();
2792
2794 target_id, 0, "");
2795}
2796
2797/***********************************************************************/
2800static void bombard(QVariant data1, QVariant data2)
2801{
2802 int actor_id = data1.toInt();
2803 int target_id = data2.toInt();
2804
2806 target_id, 0, "");
2807}
2808
2809/***********************************************************************/
2812static void bombard2(QVariant data1, QVariant data2)
2813{
2814 int actor_id = data1.toInt();
2815 int target_id = data2.toInt();
2816
2818 target_id, 0, "");
2819}
2820
2821/***********************************************************************/
2824static void bombard3(QVariant data1, QVariant data2)
2825{
2826 int actor_id = data1.toInt();
2827 int target_id = data2.toInt();
2828
2830 target_id, 0, "");
2831}
2832
2833/***********************************************************************/
2836static void bombard_lethal(QVariant data1, QVariant data2)
2837{
2838 int actor_id = data1.toInt();
2839 int target_id = data2.toInt();
2840
2842 target_id, 0, "");
2843}
2844
2845/***********************************************************************/
2848static void found_city(QVariant data1, QVariant data2)
2849{
2850 int actor_id = data1.toInt();
2851
2853 actor_id);
2854}
2855
2856/***********************************************************************/
2859static void transform_terrain(QVariant data1, QVariant data2)
2860{
2861 int actor_id = data1.toInt();
2862 int target_id = data2.toInt();
2863
2864 if (game_unit_by_number(actor_id) != nullptr
2865 && index_to_tile(&(wld.map), target_id) != nullptr) {
2867 actor_id, target_id, 0, "");
2868 }
2869}
2870
2871/***********************************************************************/
2874static void cultivate(QVariant data1, QVariant data2)
2875{
2876 int actor_id = data1.toInt();
2877 int target_id = data2.toInt();
2878
2879 if (game_unit_by_number(actor_id) != nullptr
2880 && index_to_tile(&(wld.map), target_id) != nullptr) {
2882 actor_id, target_id, 0, "");
2883 }
2884}
2885
2886/***********************************************************************/
2889static void plant(QVariant data1, QVariant data2)
2890{
2891 int actor_id = data1.toInt();
2892 int target_id = data2.toInt();
2893
2894 if (game_unit_by_number(actor_id) != nullptr
2895 && index_to_tile(&(wld.map), target_id) != nullptr) {
2897 actor_id, target_id, 0, "");
2898 }
2899}
2900
2901/***********************************************************************/
2904static void pillage(QVariant data1, QVariant data2)
2905{
2906 int actor_id = data1.toInt();
2907 int target_id = data2.toInt();
2908
2909 if (game_unit_by_number(actor_id) != nullptr
2910 && index_to_tile(&(wld.map), target_id) != nullptr) {
2912 actor_id, target_id,
2913 /* FIXME: will cause problems if more than
2914 * one action selection dialog at a time
2915 * becomes supported. */
2917 "");
2918 }
2919}
2920
2921/***********************************************************************/
2924static void clean(QVariant data1, QVariant data2)
2925{
2926 int actor_id = data1.toInt();
2927 int target_id = data2.toInt();
2928
2929 if (game_unit_by_number(actor_id) != nullptr
2930 && index_to_tile(&(wld.map), target_id) != nullptr) {
2932 actor_id, target_id,
2933 /* FIXME: will cause problems if more than
2934 * one action selection dialog at a time
2935 * becomes supported. */
2937 "");
2938 }
2939}
2940
2941/***********************************************************************/
2944static void road(QVariant data1, QVariant data2)
2945{
2946 int actor_id = data1.toInt();
2947 int target_id = data2.toInt();
2948
2949 if (game_unit_by_number(actor_id) != nullptr
2950 && index_to_tile(&(wld.map), target_id) != nullptr
2953 actor_id, target_id,
2954 /* FIXME: will cause problems if more than
2955 * one action selection dialog at a time
2956 * becomes supported. */
2958 "");
2959 }
2960}
2961
2962/***********************************************************************/
2965static void base(QVariant data1, QVariant data2)
2966{
2967 int actor_id = data1.toInt();
2968 int target_id = data2.toInt();
2969
2970 if (game_unit_by_number(actor_id) != nullptr
2971 && index_to_tile(&(wld.map), target_id) != nullptr
2974 actor_id, target_id,
2975 /* FIXME: will cause problems if more than
2976 * one action selection dialog at a time
2977 * becomes supported. */
2979 "");
2980 }
2981}
2982
2983/***********************************************************************/
2986static void mine(QVariant data1, QVariant data2)
2987{
2988 int actor_id = data1.toInt();
2989 int target_id = data2.toInt();
2990
2991 if (game_unit_by_number(actor_id) != nullptr
2992 && index_to_tile(&(wld.map), target_id) != nullptr
2995 actor_id, target_id,
2996 /* FIXME: will cause problems if more than
2997 * one action selection dialog at a time
2998 * becomes supported. */
3000 "");
3001 }
3002}
3003
3004/***********************************************************************/
3007static void irrigate(QVariant data1, QVariant data2)
3008{
3009 int actor_id = data1.toInt();
3010 int target_id = data2.toInt();
3011
3012 if (game_unit_by_number(actor_id) != nullptr
3013 && index_to_tile(&(wld.map), target_id) != nullptr
3016 actor_id, target_id,
3017 /* FIXME: will cause problems if more than
3018 * one action selection dialog at a time
3019 * becomes supported. */
3021 "");
3022 }
3023}
3024
3025/***********************************************************************/
3028static void nuke(QVariant data1, QVariant data2)
3029{
3030 int diplomat_id = data1.toInt();
3031 int diplomat_target_id = data2.toInt();
3032
3033 if (game_unit_by_number(diplomat_id) != nullptr
3034 && index_to_tile(&(wld.map), diplomat_target_id) != nullptr) {
3037 }
3038}
3039
3040/***********************************************************************/
3043static void attack(QVariant data1, QVariant data2)
3044{
3045 int diplomat_id = data1.toInt();
3046 int diplomat_target_id = data2.toInt();
3047
3048 if (game_unit_by_number(diplomat_id) != nullptr
3049 && index_to_tile(&(wld.map), diplomat_target_id) != nullptr) {
3052 }
3053}
3054
3055/***********************************************************************/
3058static void suicide_attack(QVariant data1, QVariant data2)
3059{
3060 int diplomat_id = data1.toInt();
3061 int diplomat_target_id = data2.toInt();
3062
3063 if (game_unit_by_number(diplomat_id) != nullptr
3064 && index_to_tile(&(wld.map), diplomat_target_id) != nullptr) {
3067 }
3068}
3069
3070/***********************************************************************/
3073static void paradrop(QVariant data1, QVariant data2)
3074{
3075 int actor_id = data1.toInt();
3076 int target_id = data2.toInt();
3077
3078 if (game_unit_by_number(actor_id) != nullptr
3079 && index_to_tile(&(wld.map), target_id) != nullptr) {
3081 actor_id, target_id, 0, "");
3082 }
3083}
3084
3085/***********************************************************************/
3088static void paradrop_conquer(QVariant data1, QVariant data2)
3089{
3090 int actor_id = data1.toInt();
3091 int target_id = data2.toInt();
3092
3093 if (game_unit_by_number(actor_id) != nullptr
3094 && index_to_tile(&(wld.map), target_id) != nullptr) {
3096 actor_id, target_id, 0, "");
3097 }
3098}
3099
3100/***********************************************************************/
3103static void paradrop_frighten(QVariant data1, QVariant data2)
3104{
3105 int actor_id = data1.toInt();
3106 int target_id = data2.toInt();
3107
3108 if (game_unit_by_number(actor_id) != nullptr
3109 && index_to_tile(&(wld.map), target_id) != nullptr) {
3111 actor_id, target_id, 0, "");
3112 }
3113}
3114
3115/***********************************************************************/
3119{
3120 int actor_id = data1.toInt();
3121 int target_id = data2.toInt();
3122
3123 if (game_unit_by_number(actor_id) != nullptr
3124 && index_to_tile(&(wld.map), target_id) != nullptr) {
3126 actor_id, target_id, 0, "");
3127 }
3128}
3129
3130/***********************************************************************/
3133static void paradrop_enter(QVariant data1, QVariant data2)
3134{
3135 int actor_id = data1.toInt();
3136 int target_id = data2.toInt();
3137
3138 if (game_unit_by_number(actor_id) != nullptr
3139 && index_to_tile(&(wld.map), target_id) != nullptr) {
3141 actor_id, target_id, 0, "");
3142 }
3143}
3144
3145/***********************************************************************/
3149{
3150 int actor_id = data1.toInt();
3151 int target_id = data2.toInt();
3152
3153 if (game_unit_by_number(actor_id) != nullptr
3154 && index_to_tile(&(wld.map), target_id) != nullptr) {
3156 actor_id, target_id, 0, "");
3157 }
3158}
3159
3160/***********************************************************************/
3163static void join_city(QVariant data1, QVariant data2)
3164{
3165 int actor_id = data1.toInt();
3166 int target_id = data2.toInt();
3167
3168 if (game_unit_by_number(actor_id) != nullptr
3169 && game_city_by_number(target_id) != nullptr) {
3171 actor_id, target_id, 0, "");
3172 }
3173}
3174
3175/***********************************************************************/
3178static void spy_steal_shared(QVariant data1, QVariant data2,
3179 action_id act_id)
3180{
3181 QString str;
3182 QVariant qv1;
3184 int diplomat_id = data1.toInt();
3185 int diplomat_target_id = data2.toInt();
3188 struct player *pvictim = nullptr;
3191
3192 cd = gui()->get_diplo_dialog();
3193 if (cd != nullptr) {
3194 cd->close();
3195 }
3196
3197 if (pvcity == nullptr) {
3198 return;
3199 }
3200
3201 // Wait for the player's reply before moving on to the next queued diplomat.
3203
3205
3206 struct astring stra = ASTRING_INIT;
3207 cd = new choice_dialog(_("Steal"), _("Steal Technology"),
3208 gui()->game_tab_widget,
3210
3211 // Put both actor and target city in qv1 since qv2 is taken
3214 actor_and_target.append(act_id);
3215 qv1 = QVariant::fromValue(actor_and_target);
3216
3217 struct player *pplayer = client_player();
3218 const struct research *presearch = research_get(pplayer);
3219 const struct research *vresearch = research_get(pvictim);
3220
3227 // Defeat keyboard shortcut mnemonics
3229 .replace("&", "&&");
3230 cd->add_item(str, func, qv1, i);
3231 }
3233
3235 get_non_targeted_action_id(act_id)])) {
3236 astr_set(&stra, _("At %s's Discretion"),
3239 str = QString(astr_str(&stra)).replace("&", "&&");
3240 cd->add_item(str, func, qv1, A_UNSET);
3241 }
3242
3243 cd->set_layout();
3244 cd->show_me();
3245
3246 astr_free(&stra);
3247}
3248
3249/***********************************************************************/
3252static void spy_steal(QVariant data1, QVariant data2)
3253{
3255}
3256
3257/***********************************************************************/
3260static void spy_steal_esc(QVariant data1, QVariant data2)
3261{
3263}
3264
3265/***********************************************************************/
3268static void spy_steal_something(QVariant data1, QVariant data2)
3269{
3270 int diplomat_id = data1.toList().at(0).toInt();
3271 int diplomat_target_id = data1.toList().at(1).toInt();
3272 action_id act_id = data1.toList().at(2).toInt();
3273
3274 if (game_unit_by_number(diplomat_id) != nullptr
3275 && game_city_by_number(diplomat_target_id) != nullptr) {
3276 if (data2.toInt() == A_UNSET) {
3277 // This is the untargeted version.
3279 diplomat_id, diplomat_target_id, data2.toInt(), "");
3280 } else {
3281 // This is the targeted version.
3283 diplomat_target_id, data2.toInt(), "");
3284 }
3285 }
3286}
3287
3288/***********************************************************************/
3292{
3293 int actor_id = data1.toInt();
3294 int target_id = data2.toInt();
3295
3296 if (game_unit_by_number(actor_id) != nullptr
3297 && game_city_by_number(target_id) != nullptr) {
3298 // Wait for the server's reply before moving on to the next queued diplomat.
3300
3301 request_action_details(ACTION_STRIKE_BUILDING, actor_id, target_id);
3302 }
3303}
3304
3305/***********************************************************************/
3309{
3310 int diplomat_id = data1.toInt();
3311 int diplomat_target_id = data2.toInt();
3312
3313 if (game_unit_by_number(diplomat_id) != nullptr
3314 && game_city_by_number(diplomat_target_id) != nullptr) {
3315 // Wait for the server's reply before moving on to the next queued diplomat.
3317
3320 }
3321}
3322
3323/***********************************************************************/
3327{
3328 int diplomat_id = data1.toInt();
3329 int diplomat_target_id = data2.toInt();
3330
3331 if (game_unit_by_number(diplomat_id) != nullptr
3332 && game_city_by_number(diplomat_target_id) != nullptr) {
3333 /* Wait for the server's reply before moving on to the next queued
3334 * diplomat. */
3336
3339 }
3340}
3341
3342/***********************************************************************/
3345static void spy_poison(QVariant data1, QVariant data2)
3346{
3347 int diplomat_id = data1.toInt();
3348 int diplomat_target_id = data2.toInt();
3349
3350 if (game_unit_by_number(diplomat_id) != nullptr
3351 && game_city_by_number(diplomat_target_id) != nullptr) {
3354 }
3355}
3356
3357/***********************************************************************/
3360static void spy_poison_esc(QVariant data1, QVariant data2)
3361{
3362 int diplomat_id = data1.toInt();
3363 int diplomat_target_id = data2.toInt();
3364
3365 if (game_unit_by_number(diplomat_id) != nullptr
3366 && game_city_by_number(diplomat_target_id) != nullptr) {
3369 }
3370}
3371
3372/***********************************************************************/
3375static void spy_nuke_city(QVariant data1, QVariant data2)
3376{
3377 int diplomat_id = data1.toInt();
3378 int diplomat_target_id = data2.toInt();
3379
3380 if (game_unit_by_number(diplomat_id) != nullptr
3381 && game_city_by_number(diplomat_target_id) != nullptr) {
3384 }
3385}
3386
3387/***********************************************************************/
3390static void spy_nuke_city_esc(QVariant data1, QVariant data2)
3391{
3392 int diplomat_id = data1.toInt();
3393 int diplomat_target_id = data2.toInt();
3394
3395 if (game_unit_by_number(diplomat_id) != nullptr
3396 && game_city_by_number(diplomat_target_id) != nullptr) {
3399 }
3400}
3401
3402/***********************************************************************/
3405static void nuke_city(QVariant data1, QVariant data2)
3406{
3407 int actor_id = data1.toInt();
3408 int target_id = data2.toInt();
3409
3410 if (game_unit_by_number(actor_id) != nullptr
3411 && game_city_by_number(target_id) != nullptr) {
3413 actor_id, target_id, 0, "");
3414 }
3415}
3416
3417/***********************************************************************/
3420static void destroy_city(QVariant data1, QVariant data2)
3421{
3422 int diplomat_id = data1.toInt();
3423 int diplomat_target_id = data2.toInt();
3424
3425 if (game_unit_by_number(diplomat_id) != nullptr
3426 && game_city_by_number(diplomat_target_id) != nullptr) {
3429 }
3430}
3431
3432/***********************************************************************/
3435static void spy_steal_gold(QVariant data1, QVariant data2)
3436{
3437 int diplomat_id = data1.toInt();
3438 int diplomat_target_id = data2.toInt();
3439
3440 if (game_unit_by_number(diplomat_id) != nullptr
3441 && game_city_by_number(diplomat_target_id) != nullptr) {
3444 }
3445}
3446
3447/***********************************************************************/
3450static void spy_steal_gold_esc(QVariant data1, QVariant data2)
3451{
3452 int diplomat_id = data1.toInt();
3453 int diplomat_target_id = data2.toInt();
3454
3455 if (game_unit_by_number(diplomat_id) != nullptr
3456 && game_city_by_number(diplomat_target_id) != nullptr) {
3459 }
3460}
3461
3462/***********************************************************************/
3465static void spy_steal_maps(QVariant data1, QVariant data2)
3466{
3467 int diplomat_id = data1.toInt();
3468 int diplomat_target_id = data2.toInt();
3469
3470 if (game_unit_by_number(diplomat_id) != nullptr
3471 && game_city_by_number(diplomat_target_id) != nullptr) {
3474 }
3475}
3476
3477/***********************************************************************/
3480static void spy_steal_maps_esc(QVariant data1, QVariant data2)
3481{
3482 int diplomat_id = data1.toInt();
3483 int diplomat_target_id = data2.toInt();
3484
3485 if (game_unit_by_number(diplomat_id) != nullptr
3486 && game_city_by_number(diplomat_target_id) != nullptr) {
3489 }
3490}
3491
3492/***********************************************************************/
3495static void spy_escape(QVariant data1, QVariant data2)
3496{
3497 int diplomat_id = data1.toInt();
3498 int diplomat_target_id = data2.toInt();
3499
3500 if (game_unit_by_number(diplomat_id) != nullptr
3501 && game_city_by_number(diplomat_target_id) != nullptr) {
3504 }
3505}
3506
3507/***********************************************************************/
3510static void spy_embassy(QVariant data1, QVariant data2)
3511{
3512 int diplomat_id = data1.toInt();
3513 int diplomat_target_id = data2.toInt();
3514
3515 if (game_unit_by_number(diplomat_id) != nullptr
3516 && game_city_by_number(diplomat_target_id) != nullptr) {
3518 diplomat_target_id, 0, "");
3519 }
3520}
3521
3522/***********************************************************************/
3525static void diplomat_embassy(QVariant data1, QVariant data2)
3526{
3527 int diplomat_id = data1.toInt();
3528 int diplomat_target_id = data2.toInt();
3529
3530 if (game_unit_by_number(diplomat_id) != nullptr
3531 && game_city_by_number(diplomat_target_id) != nullptr) {
3533 diplomat_target_id, 0, "");
3534 }
3535}
3536
3537/***********************************************************************/
3540static void spy_investigate(QVariant data1, QVariant data2)
3541{
3542 int diplomat_id = data1.toInt();
3543 int diplomat_target_id = data2.toInt();
3544
3546 && game_unit_by_number(diplomat_id) != nullptr) {
3548 diplomat_target_id, 0, "");
3549 }
3550}
3551
3552/***********************************************************************/
3555static void diplomat_investigate(QVariant data1, QVariant data2)
3556{
3557 int diplomat_id = data1.toInt();
3558 int diplomat_target_id = data2.toInt();
3559
3561 && game_unit_by_number(diplomat_id) != nullptr) {
3563 diplomat_target_id, 0, "");
3564 }
3565}
3566
3567/***********************************************************************/
3570static void diplomat_sabotage(QVariant data1, QVariant data2)
3571{
3572 int diplomat_id = data1.toInt();
3573 int diplomat_target_id = data2.toInt();
3574
3575 if (game_unit_by_number(diplomat_id) != nullptr
3576 && game_city_by_number(diplomat_target_id) != nullptr) {
3578 diplomat_target_id, B_LAST + 1, "");
3579 }
3580}
3581
3582/***********************************************************************/
3585static void diplomat_sabotage_esc(QVariant data1, QVariant data2)
3586{
3587 int diplomat_id = data1.toInt();
3588 int diplomat_target_id = data2.toInt();
3589
3590 if (game_unit_by_number(diplomat_id) != nullptr
3591 && game_city_by_number(diplomat_target_id) != nullptr) {
3593 diplomat_target_id, B_LAST + 1, "");
3594 }
3595}
3596
3597/***********************************************************************/
3600static void diplomat_steal(QVariant data1, QVariant data2)
3601{
3602 int diplomat_id = data1.toInt();
3603 int diplomat_target_id = data2.toInt();
3604
3605 if (game_unit_by_number(diplomat_id) != nullptr
3606 && game_city_by_number(diplomat_target_id) != nullptr) {
3609 }
3610}
3611
3612/***********************************************************************/
3615static void diplomat_steal_esc(QVariant data1, QVariant data2)
3616{
3617 int diplomat_id = data1.toInt();
3618 int diplomat_target_id = data2.toInt();
3619
3620 if (game_unit_by_number(diplomat_id) != nullptr
3621 && game_city_by_number(diplomat_target_id) != nullptr) {
3624 }
3625}
3626
3627/***********************************************************************/
3630static void diplomat_incite(QVariant data1, QVariant data2)
3631{
3632 int diplomat_id = data1.toInt();
3633 int diplomat_target_id = data2.toInt();
3634
3635 if (game_unit_by_number(diplomat_id) != nullptr
3636 && game_city_by_number(diplomat_target_id) != nullptr) {
3637 // Wait for the server's reply before moving on to the next queued diplomat.
3639
3642 }
3643}
3644
3645/***********************************************************************/
3649{
3650 int diplomat_id = data1.toInt();
3651 int diplomat_target_id = data2.toInt();
3652
3653 if (game_unit_by_number(diplomat_id) != nullptr
3654 && game_city_by_number(diplomat_target_id) != nullptr) {
3655 // Wait for the server's reply before moving on to the next queued diplomat.
3657
3660 }
3661}
3662
3663/***********************************************************************/
3666static void regular_move(QVariant data1, QVariant data2)
3667{
3668 int actor_id = data1.toInt();
3669 int target_id = data2.toInt();
3670
3671 if (game_unit_by_number(actor_id) != nullptr
3672 && index_to_tile(&(wld.map), target_id) != nullptr) {
3674 actor_id, target_id, 0, "");
3675 }
3676}
3677
3678/***********************************************************************/
3682void popup_incite_dialog(struct unit *actor, struct city *tcity, int cost,
3683 const struct action *paction)
3684{
3685 char buf[1024];
3686 char buf2[1024];
3687 int diplomat_id = actor->id;
3688 int diplomat_target_id = tcity->id;
3689 const int act_id = paction->id;
3690
3691 // Should be set before sending request to the server.
3693
3694 fc_snprintf(buf, ARRAY_SIZE(buf), PL_("Treasury contains %d gold.",
3695 "Treasury contains %d gold.",
3696 client_player()->economic.gold),
3697 client_player()->economic.gold);
3698
3700 hud_message_box *impossible = new hud_message_box(gui()->central_wdg);
3701
3703 _("You can't incite a revolt in %s."), city_name_get(tcity));
3704 impossible->set_text_title(buf2, "!");
3705 impossible->setStandardButtons(QMessageBox::Ok);
3706 impossible->setAttribute(Qt::WA_DeleteOnClose);
3707 impossible->show();
3708 } else if (cost <= client_player()->economic.gold) {
3709 hud_message_box *ask = new hud_message_box(gui()->central_wdg);
3710
3712 PL_("Incite a revolt for %d gold?\n%s",
3713 "Incite a revolt for %d gold?\n%s", cost), cost, buf);
3714 ask->setStandardButtons(QMessageBox::Cancel | QMessageBox::Ok);
3715 ask->setDefaultButton(QMessageBox::Cancel);
3716 ask->set_text_title(buf2, _("Incite a Revolt!"));
3717 ask->setAttribute(Qt::WA_DeleteOnClose);
3718 QObject::connect(ask, &hud_message_box::accepted, [=]() {
3721 });
3722 ask->show();
3723 return;
3724 } else {
3725 hud_message_box *too_much = new hud_message_box(gui()->central_wdg);
3726
3728 PL_("Inciting a revolt costs %d gold.\n%s",
3729 "Inciting a revolt costs %d gold.\n%s", cost), cost,
3730 buf);
3731 too_much->set_text_title(buf2, "!");
3732 too_much->setStandardButtons(QMessageBox::Ok);
3733 too_much->setAttribute(Qt::WA_DeleteOnClose);
3734 too_much->show();
3735 }
3736
3738}
3739
3740/***********************************************************************/
3744void popup_bribe_unit_dialog(struct unit *actor, struct unit *tunit, int cost,
3745 const struct action *paction)
3746{
3747 hud_message_box *ask = new hud_message_box(gui()->central_wdg);
3748 char buf[1024];
3749 char buf2[1024];
3750 int diplomat_id = actor->id;
3751 int diplomat_target_id = tunit->id;
3752 const int act_id = paction->id;
3753
3754 // Should be set before sending request to the server.
3756
3757 fc_snprintf(buf, ARRAY_SIZE(buf), PL_("Treasury contains %d gold.",
3758 "Treasury contains %d gold.",
3759 client_player()->economic.gold),
3760 client_player()->economic.gold);
3761
3762 if (cost <= client_player()->economic.gold) {
3763 fc_snprintf(buf2, ARRAY_SIZE(buf2), PL_("Bribe unit for %d gold?\n%s",
3764 "Bribe unit for %d gold?\n%s",
3765 cost), cost, buf);
3766 ask->set_text_title(buf2, _("Bribe Enemy Unit"));
3767 ask->setStandardButtons(QMessageBox::Cancel | QMessageBox::Ok);
3768 ask->setDefaultButton(QMessageBox::Cancel);
3769 ask->setAttribute(Qt::WA_DeleteOnClose);
3770 QObject::connect(ask, &hud_message_box::accepted, [=]() {
3773 });
3774 ask->show();
3775 return;
3776 } else {
3778 PL_("Bribing the unit costs %d gold.\n%s",
3779 "Bribing the unit costs %d gold.\n%s", cost), cost, buf);
3780 ask->set_text_title(buf2, _("Traitors Demand Too Much!"));
3781 ask->setAttribute(Qt::WA_DeleteOnClose);
3782 ask->show();
3783 }
3784
3786}
3787
3788/***********************************************************************/
3793 const struct action *paction)
3794{
3795 hud_message_box *ask = new hud_message_box(gui()->central_wdg);
3796 char buf[1024];
3797 char buf2[1024];
3798 int diplomat_id = actor->id;
3799 int diplomat_target_id = ttile->index;
3800 const int act_id = paction->id;
3801
3802 // Should be set before sending request to the server.
3804
3805 fc_snprintf(buf, ARRAY_SIZE(buf), PL_("Treasury contains %d gold.",
3806 "Treasury contains %d gold.",
3807 client_player()->economic.gold),
3808 client_player()->economic.gold);
3809
3810 if (cost <= client_player()->economic.gold) {
3811 fc_snprintf(buf2, ARRAY_SIZE(buf2), PL_("Bribe unit stack for %d gold?\n%s",
3812 "Bribe unit stack for %d gold?\n%s",
3813 cost), cost, buf);
3814 ask->set_text_title(buf2, _("Bribe Enemy Stack"));
3815 ask->setStandardButtons(QMessageBox::Cancel | QMessageBox::Ok);
3816 ask->setDefaultButton(QMessageBox::Cancel);
3817 ask->setAttribute(Qt::WA_DeleteOnClose);
3818 QObject::connect(ask, &hud_message_box::accepted, [=]() {
3821 });
3822 ask->show();
3823 return;
3824 } else {
3826 PL_("Bribing the unit stack costs %d gold.\n%s",
3827 "Bribing the unit stack costs %d gold.\n%s", cost), cost, buf);
3828 ask->set_text_title(buf2, _("Traitors Demand Too Much!"));
3829 ask->setAttribute(Qt::WA_DeleteOnClose);
3830 ask->show();
3831 }
3832
3834}
3835
3836/***********************************************************************/
3839static void pillage_something(QVariant data1, QVariant data2)
3840{
3841 int punit_id;
3842 int what;
3843 struct unit *punit;
3844 struct extra_type *target;
3845
3846 what = data1.toInt();
3847 punit_id = data2.toInt();
3849 if (punit) {
3850 target = extra_by_number(what);
3852 }
3854}
3855
3856/***********************************************************************/
3859static void spy_sabotage(QVariant data1, QVariant data2)
3860{
3861 int diplomat_id = data1.toList().at(0).toInt();
3862 int diplomat_target_id = data1.toList().at(1).toInt();
3863 action_id act_id = data1.toList().at(2).toInt();
3864
3865 if (game_unit_by_number(diplomat_id) != nullptr
3866 && game_city_by_number(diplomat_target_id) != nullptr) {
3867 if (data2.toInt() == B_LAST) {
3868 // This is the untargeted version.
3870 diplomat_id, diplomat_target_id, data2.toInt(),
3871 "");
3872 } else if (data2.toInt() == -1) {
3873 // This is the city production version.
3875 diplomat_id, diplomat_target_id, data2.toInt(),
3876 "");
3877 } else {
3878 // This is the targeted version.
3880 diplomat_target_id, data2.toInt(), "");
3881 }
3882 }
3883}
3884
3885/***********************************************************************/
3890 const struct action *paction)
3891{
3892 QString str;
3893 QVariant qv1, qv2;
3894 int diplomat_id = actor->id;
3895 int diplomat_target_id = tcity->id;
3897 choice_dialog *cd = new choice_dialog(_("Sabotage"),
3898 _("Select Improvement to Sabotage"),
3899 gui()->game_tab_widget,
3901 int nr = 0;
3902 struct astring stra = ASTRING_INIT;
3904
3905 // Should be set before sending request to the server.
3907
3908 // Put both actor, target city and action in qv1 since qv2 is taken
3911 actor_and_target.append(paction->id);
3912 qv1 = QVariant::fromValue(actor_and_target);
3913
3916 paction->id)])) {
3918 cd->add_item(QString(_("City Production")), func, qv1, -1);
3919 }
3920
3921 city_built_iterate(tcity, pimprove) {
3922 if (pimprove->sabotage > 0) {
3924 // Defeat keyboard shortcut mnemonics
3926 .replace("&", "&&");
3927 qv2 = nr;
3928 cd->add_item(str, func, qv1, improvement_number(pimprove));
3929 nr++;
3930 }
3932
3935 astr_set(&stra, _("At %s's Discretion"),
3938 str = QString(astr_str(&stra)).replace("&", "&&");
3939 cd->add_item(str, func, qv1, B_LAST);
3940 }
3941
3942 cd->set_layout();
3943 cd->show_me();
3944 astr_free(&stra);
3945}
3946
3947/***********************************************************************/
3952{
3953 QString str;
3954 QVariant qv1, qv2;
3957 struct extra_type *tgt;
3958
3960 return;
3961 }
3962 cd = new choice_dialog(_("What To Pillage"), _("Select what to pillage:"),
3963 gui()->game_tab_widget);
3964 qv2 = punit->id;
3965 while ((tgt = get_preferred_pillage(extras))) {
3966 int what;
3967
3968 what = extra_index(tgt);
3969 BV_CLR(extras, what);
3970
3972 // Defeat keyboard shortcut mnemonics
3973 str = QString(extra_name_translation(tgt)).replace("&", "&&");
3974 qv1 = what;
3975 cd->add_item(str, func, qv1, qv2);
3976 }
3977 cd->set_layout();
3978 cd->show_me();
3979}
3980
3981/***********************************************************************/
3985 QWidget *parent) : hud_message_box(parent)
3986{
3987 QString str;
3988 QPushButton *pb;
3989
3990 setAttribute(Qt::WA_DeleteOnClose);
3991 setModal(false);
3996
3997 str = QString(PL_("Are you sure you want to disband that %1 unit?",
3998 "Are you sure you want to disband those %1 units?",
4000 pb = addButton(_("Yes"), QMessageBox::AcceptRole);
4001 addButton(_("No"), QMessageBox::RejectRole);
4002 set_text_title(str, _("Disband units"));
4004 connect(pb, &QAbstractButton::clicked, this, &disband_box::disband_clicked);
4005}
4006
4007/***********************************************************************/
4018
4019/***********************************************************************/
4026
4027/***********************************************************************/
4030void popup_disband_dialog(struct unit_list *punits)
4031{
4032 disband_box *ask = new disband_box(punits, gui()->central_wdg);
4033 ask->show();
4034}
4035
4036/***********************************************************************/
4041{
4042 hud_message_box *ask = new hud_message_box(gui()->central_wdg);
4043 QString text;
4044 QString title;
4045
4046 title = QString(_("Modpack suggests using %1 tileset."))
4048 text = QString("It might not work with other tilesets.\n"
4049 "You are currently using tileset %1.")
4051 ask->addButton(_("Keep current tileset"), QMessageBox::RejectRole);
4052 ask->addButton(_("Load tileset"), QMessageBox::AcceptRole);
4053 ask->set_text_title(text, title);
4054 ask->setAttribute(Qt::WA_DeleteOnClose);
4055
4056 QObject::connect(ask, &hud_message_box::accepted, [=]() {
4059 gui()->map_scale)) {
4061 _("Can't load requested tileset."));
4062 }
4063 });
4064 ask->show();
4065}
4066
4067/***********************************************************************/
4072{
4073 hud_message_box *ask = new hud_message_box(gui()->central_wdg);
4074 QString text;
4075 QString title;
4076
4077 title = QString(_("Modpack suggests using %1 soundset."))
4079 text = QString("It might not work with other tilesets.\n"
4080 "You are currently using soundset %1.")
4081 .arg(sound_set_name);
4082 ask->addButton(_("Keep current soundset"), QMessageBox::RejectRole);
4083 ask->addButton(_("Load soundset"), QMessageBox::AcceptRole);
4084 ask->set_text_title(text, title);
4085 ask->setAttribute(Qt::WA_DeleteOnClose);
4086 QObject::connect(ask, &hud_message_box::accepted, [=]() {
4088 });
4089 ask->show();
4090}
4091
4092/***********************************************************************/
4097{
4098 hud_message_box *ask = new hud_message_box(gui()->central_wdg);
4099 QString text;
4100 QString title;
4101
4102 title = QString(_("Modpack suggests using %1 musicset."))
4104 text = QString("It might not work with other tilesets.\n"
4105 "You are currently using musicset %1.")
4106 .arg(music_set_name);
4107 ask->addButton(_("Keep current musicset"), QMessageBox::RejectRole);
4108 ask->addButton(_("Load musicset"), QMessageBox::AcceptRole);
4109 ask->set_text_title(text, title);
4110 ask->setAttribute(Qt::WA_DeleteOnClose);
4111 QObject::connect(ask, &hud_message_box::accepted, [=]() {
4113 });
4114 ask->show();
4115}
4116
4117/***********************************************************************/
4122{
4123 // PORTME
4124 return false;
4125}
4126
4127/***********************************************************************/
4131{
4133 int i;
4134
4135 nd_list = gui()->mapview_wdg->findChildren<notify_dialog *>();
4136 for (i = 0; i < nd_list.count(); i++) {
4137 nd_list[i]->restart();
4138 delete nd_list[i];
4139 }
4140}
4141
4142/***********************************************************************/
4147{
4148 int i;
4151 goto_dialog *gtd;
4152
4153 QApplication::alert(gui()->central_wdg);
4154 cd_list = gui()->game_tab_widget->findChildren <choice_dialog *>();
4155 for (i = 0; i < cd_list.count(); i++) {
4156 cd_list[i]->close();
4157 }
4158 nd_list = gui()->game_tab_widget->findChildren <notify_dialog *>();
4159 for (i = 0; i < nd_list.count(); i++) {
4160 nd_list[i]->close();
4161 }
4162
4171 gui()->popdown_unit_sel();
4172
4173 gtd = gui()->gtd;
4174
4175 if (gtd != nullptr) {
4176 gtd->close_dlg();
4177 }
4178}
4179
4180/***********************************************************************/
4186{
4187 choice_dialog *cd = gui()->get_diplo_dialog();
4188
4189 if (cd != nullptr) {
4190 return cd->unit_id;
4191 } else {
4192 return IDENTITY_NUMBER_ZERO;
4193 }
4194}
4195
4196/***********************************************************************/
4203{
4204 choice_dialog *cd = gui()->get_diplo_dialog();
4205
4206 if (cd != nullptr) {
4207 return cd->target_id[ATK_CITY];
4208 } else {
4209 return IDENTITY_NUMBER_ZERO;
4210 }
4211}
4212
4213/***********************************************************************/
4220{
4221 choice_dialog *cd = gui()->get_diplo_dialog();
4222
4223 if (cd != nullptr) {
4224 return cd->target_id[ATK_TILE];
4225 } else {
4226 return TILE_INDEX_NONE;
4227 }
4228}
4229
4230/**********************************************************************/
4237{
4238 choice_dialog *cd = gui()->get_diplo_dialog();
4239
4240 if (cd != nullptr) {
4241 return cd->sub_target_id[ASTK_EXTRA];
4242 } else {
4243 return EXTRA_NONE;
4244 }
4245}
4246
4247/***********************************************************************/
4254{
4255 choice_dialog *cd = gui()->get_diplo_dialog();
4256
4257 if (cd != nullptr) {
4258 return cd->target_id[ATK_UNIT];
4259 } else {
4260 return IDENTITY_NUMBER_ZERO;
4261 }
4262}
4263
4264/***********************************************************************/
4268 struct city *target_city,
4269 struct unit *target_unit,
4270 struct tile *target_tile,
4271 struct extra_type *target_extra,
4272 const struct act_prob *act_probs)
4273{
4276 Choice_dialog_button *cancel_button;
4277 QVariant qv1, qv2;
4278
4279 asd = gui()->get_diplo_dialog();
4280 if (asd == nullptr) {
4281 fc_assert_msg(asd != nullptr,
4282 "The action selection dialog should have been open");
4283 return;
4284 }
4285
4288 "The action selection dialog is for another actor unit.");
4289 }
4290
4291 // Put the actor id in qv1.
4292 qv1 = actor_unit->id;
4293
4294 cancel_button = asd->get_identified_button(BUTTON_CANCEL);
4295 if (cancel_button != nullptr) {
4296 /* Temporary remove the Cancel button so it won't end up above
4297 * any added buttons. */
4298 asd->stack_button(cancel_button);
4299 }
4300
4301 wait_button = asd->get_identified_button(BUTTON_WAIT);
4302 if (wait_button != nullptr) {
4303 /* Temporary remove the Wait button so it won't end up above
4304 * any added buttons. */
4305 asd->stack_button(wait_button);
4306 }
4307
4308 action_iterate(act) {
4309 const char *custom;
4310
4311 if (action_id_get_actor_kind(act) != AAK_UNIT) {
4312 // Not relevant.
4313 continue;
4314 }
4315
4317 act_probs[act],
4318 actor_unit,
4319 target_city);
4320
4321 // Put the target id in qv2.
4322 switch (action_id_get_target_kind(act)) {
4323 case ATK_UNIT:
4324 if (target_unit != nullptr) {
4325 qv2 = target_unit->id;
4326 } else {
4328 || target_unit != nullptr,
4329 "Action enabled against non existing unit!");
4330
4332 }
4333 break;
4334 case ATK_CITY:
4335 if (target_city != nullptr) {
4336 qv2 = target_city->id;
4337 } else {
4339 || target_city != nullptr,
4340 "Action enabled against non existing city!");
4341
4343 }
4344 break;
4345 case ATK_TILE:
4346 case ATK_EXTRAS:
4347 case ATK_STACK:
4348 if (target_tile != nullptr) {
4350 } else {
4352 || target_tile != nullptr,
4353 "Action enabled against all units on "
4354 "non existing tile!");
4355
4357 }
4358 break;
4359 case ATK_SELF:
4360 qv2 = actor_unit->id;
4361 break;
4362 case ATK_COUNT:
4364 "Bad target kind");
4365 continue;
4366 }
4367
4368 if (asd->get_identified_button(act)) {
4369 // Update the existing button.
4370 action_entry_update(asd->get_identified_button(act),
4371 act, act_probs, custom,
4372 qv1, qv2);
4373 } else {
4374 // Add the button (unless its probability is 0).
4376 qv1, qv2);
4377 }
4379
4380 if (wait_button != nullptr || cancel_button != nullptr) {
4381 /* Reinsert the non action buttons below any potential
4382 * buttons recently added. */
4383 asd->unstack_all_buttons();
4384 }
4385}
4386
4387/***********************************************************************/
4391{
4393
4394 cd = gui()->get_diplo_dialog();
4395 if (cd != nullptr) {
4396 did_not_decide = true;
4397 cd->close();
4398 }
4399}
4400
4401/***********************************************************************/
4407
4408/***********************************************************************/
4411void show_tileset_error(bool fatal, const char *tset_name, const char *msg)
4412{
4413 QWidget *parent;
4414 fc_client *std_gui = gui();
4415
4416 if (std_gui != nullptr) {
4417 parent = std_gui->central_wdg;
4418 } else {
4419 parent = nullptr;
4420 }
4421
4422 if (std_gui != nullptr || fatal) {
4423 char buf[1024];
4424 QMessageBox *ask = new QMessageBox(parent);
4425
4426 if (tset_name != nullptr) {
4427 fc_snprintf(buf, sizeof(buf),
4428 _("Tileset \"%s\" problem, it's probably incompatible with "
4429 "the ruleset:\n%s"), tset_name, msg);
4430 } else {
4431 fc_snprintf(buf, sizeof(buf),
4432 _("Tileset problem, it's probably incompatible with "
4433 "the ruleset:\n%s"), msg);
4434 }
4435
4436 ask->setText(buf);
4437 ask->setStandardButtons(QMessageBox::Ok);
4438 ask->setWindowTitle(_("Tileset error"));
4439
4440 if (std_gui != nullptr && !fatal) {
4441 ask->setAttribute(Qt::WA_DeleteOnClose);
4442 ask->show();
4443 } else {
4444 ask->exec();
4445 }
4446 }
4447}
4448
4449/***********************************************************************/
4452void popup_upgrade_dialog(struct unit_list *punits)
4453{
4454 char buf[512];
4456 QString title;
4458
4459 if (!punits || unit_list_size(punits) == 0) {
4460 return;
4461 }
4462
4463 ask = new hud_message_box(gui()->central_wdg);
4464
4465 punit_ids = new QVector<int>();
4467 punit_ids->push_back(punit->id);
4469
4470 if (!get_units_upgrade_info(buf, sizeof(buf), punits)) {
4471 title = _("Upgrade Unit!");
4472 ask->setStandardButtons(QMessageBox::Ok);
4473 } else {
4474 title = _("Upgrade Obsolete Units");
4475 ask->setStandardButtons(QMessageBox::Cancel | QMessageBox::Ok);
4476 ask->setDefaultButton(QMessageBox::Cancel);
4477 }
4478 ask->set_text_title(buf, title);
4479 ask->setAttribute(Qt::WA_DeleteOnClose);
4480 QObject::connect(ask, &hud_message_box::accepted, [=]() {
4481 std::unique_ptr<QVector<int>> uptr(punit_ids);
4482 struct unit *punit;
4483
4484 for (int id : *uptr) {
4486 if (punit) {
4488 }
4489 }
4490 });
4491 ask->show();
4492}
4493
4494/***********************************************************************/
4498{
4499 QPoint p, final_p;
4500
4502 utile = ptile;
4503 pix = nullptr;
4504 show_line = 0;
4505 highligh_num = -1;
4506 ufont.setItalic(true);
4508 update_units();
4509 h_pix = nullptr;
4510 create_pixmap();
4511 p = mapFromGlobal(QCursor::pos());
4512 cw = new close_widget(this);
4513 setMouseTracking(true);
4514 final_p.setX(p.x());
4515 final_p.setY(p.y());
4516 if (p.x() + width() > parentWidget()->width()) {
4517 final_p.setX(parentWidget()->width() - width());
4518 }
4519 if (p.y() - height() < 0) {
4520 final_p.setY(height());
4521 }
4522 move(final_p.x(), final_p.y() - height());
4523 setFocus();
4524 /* Build fails with qt5 connect style for static functions
4525 * Qt5.2 so dont update */
4526 QTimer::singleShot(10, this, SLOT(update_img()));
4527}
4528
4529/***********************************************************************/
4533{
4534 delete h_pix;
4535 delete pix;
4536 delete cw;
4537}
4538
4539/***********************************************************************/
4543{
4544 int a;
4545 int x, y, i;
4548 QImage img;
4550 QPainter p;
4551 QPen pen;
4552 QPixmap pixc;
4553 QPixmap *pixp;
4555 QRect crop;
4556 struct canvas *unit_pixmap;
4557 struct unit *punit;
4558 float isosize;
4559
4560 if (pix != nullptr) {
4561 delete pix;
4562 pix = nullptr;
4563 };
4564 isosize = 0.7;
4566 isosize = 0.5;
4567 }
4568
4569 update_units();
4570 if (unit_list.count() > 0) {
4574 } else {
4577 }
4578 more = false;
4579 if (h_pix != nullptr) {
4580 delete h_pix;
4581 }
4582 h_pix = new QPixmap(item_size.width(), item_size.height());
4583 h_pix->fill(palette().color(QPalette::HighlightedText));
4584 if (unit_count < 5) {
4585 row_count = 1;
4586 pix = new QPixmap((unit_list.size()) * item_size.width(),
4587 item_size.height());
4588 } else if (unit_count < 9) {
4589 row_count = 2;
4590 pix = new QPixmap(4 * item_size.width(), 2 * item_size.height());
4591 } else {
4592 row_count = 3;
4593 if (unit_count > 12) {
4594 more = true;
4595 }
4596 pix = new QPixmap(4 * item_size.width(), 3 * item_size.height());
4597 }
4598 pix->fill(Qt::transparent);
4599 foreach(punit, unit_list) {
4602 unit_pixmap->map_pixmap.fill(Qt::transparent);
4603 put_unit(punit, unit_pixmap, 1.0, 0, 0);
4604 img = unit_pixmap->map_pixmap.toImage();
4606 cropped_img = img.copy(crop);
4610 Qt::KeepAspectRatio,
4611 Qt::SmoothTransformation);
4612 } else {
4615 Qt::KeepAspectRatio,
4616 Qt::SmoothTransformation);
4617 }
4618 pixc = QPixmap::fromImage(img);
4619 pixp = new QPixmap(pixc);
4620 pix_list.push_back(pixp);
4622 }
4623 a = qMin(item_size.width() / 4, 12);
4624 x = 0, y = -item_size.height(), i = -1;
4625 p.begin(pix);
4626 ufont.setPixelSize(a);
4627 p.setFont(ufont);
4628 pen.setColor(palette().color(QPalette::Text));
4629 p.setPen(pen);
4630
4631 while (!pix_list.isEmpty()) {
4632 tmp_pix = pix_list.takeFirst();
4633 i++;
4634 if (i % 4 == 0) {
4635 x = 0;
4636 y = y + item_size.height();
4637 }
4638 punit = unit_list.at(i);
4639 Q_ASSERT(punit != nullptr);
4640
4641 if (i == highligh_num) {
4642 p.drawPixmap(x, y, *h_pix);
4643 p.drawPixmap(x, y, *tmp_pix);
4644 } else {
4645 p.drawPixmap(x, y, *tmp_pix);
4646 }
4647
4649 int rate, f;
4650 QString str;
4651
4653 f = ((punit->fuel) - 1);
4656 str = str + "(" + QString(move_points_text((rate * f)
4657 + punit->moves_left, false)) + ")";
4658 }
4659 // TRANS: MP = Movement points
4660 str = QString(_("MP:")) + str;
4661 p.drawText(x, y + item_size.height() - 4, str);
4662 }
4663
4664 x = x + item_size.width();
4665 delete tmp_pix;
4666 }
4667 p.end();
4668 setFixedWidth(pix->width() + 20);
4669 setFixedHeight(pix->height() + 2 * (fm.height() + 6));
4670 qDeleteAll(pix_list.begin(), pix_list.end());
4671 }
4672}
4673
4674/***********************************************************************/
4678{
4679 int a, b;
4680 int old_h;
4682 QPoint pos = event->pos();
4683 int x = pos.x();
4684 int y = pos.y();
4685
4687 highligh_num = -1;
4688 if (x > width() - 11
4689 || y > height() - fm.height() - 5
4690 || y < fm.height() + 3 || x < 11) {
4691 // Do nothing if mouse is on border, just skip next if
4692 } else if (row_count > 0) {
4693 a = (x - 10) / item_size.width();
4694 b = (y - fm.height() - 3) / item_size.height();
4695 highligh_num = b * 4 + a;
4696 }
4697 if (old_h != highligh_num) {
4698 create_pixmap();
4699 update();
4700 }
4701}
4702
4703/***********************************************************************/
4709{
4710 struct unit *punit;
4711 if (event->button() == Qt::RightButton) {
4712 was_destroyed = true;
4713 close();
4714 destroy();
4715 }
4716 if (event->button() == Qt::LeftButton && highligh_num != -1) {
4717 update_units();
4718 if (highligh_num >= unit_list.count()) {
4719 return;
4720 }
4723 was_destroyed = true;
4724 close();
4725 destroy();
4726 }
4727}
4728
4729/***********************************************************************/
4734{
4735 create_pixmap();
4736 update();
4737}
4738
4739/***********************************************************************/
4743{
4745 int h, i;
4746 int *f_size;
4747 QPen pen;
4748 QString str, str2;
4749 struct unit *punit;
4750 int point_size = info_font.pointSize();
4751 int pixel_size = info_font.pixelSize();
4752
4753 if (point_size < 0) {
4754 f_size = &pixel_size;
4755 } else {
4756 f_size = &point_size;
4757 }
4758 if (highligh_num != -1 && highligh_num < unit_list.count()) {
4759 struct astring addition = ASTRING_INIT;
4760
4763
4764 // TRANS: HP - hit points
4765 str2 = QString(_("%1 HP:%2/%3")).arg(QString(astr_str(&addition)),
4766 QString::number(punit->hp),
4767 QString::number(unit_type_get(punit)->hp));
4769 }
4770 str = QString(PL_("%1 unit", "%1 units",
4772 .arg(unit_list_size(utile->units));
4773 for (i = *f_size; i > 4; i--) {
4774 if (point_size < 0) {
4775 info_font.setPixelSize(i);
4776 } else {
4777 info_font.setPointSize(i);
4778 }
4780 if (10 + qfm.horizontalAdvance(str2) < width()) {
4781 break;
4782 }
4783 }
4784 h = fm.height();
4785 if (pix != nullptr) {
4786 painter->drawPixmap(10, h + 3, *pix);
4787 pen.setColor(palette().color(QPalette::Text));
4788 painter->setPen(pen);
4789 painter->setFont(info_font);
4790 painter->drawText(10, h, str);
4791 if (highligh_num != -1 && highligh_num < unit_list.count()) {
4792 painter->drawText(10, height() - 5, str2);
4793 }
4794 // Draw scroll
4795 if (more) {
4796 int maxl = ((unit_count - 1) / 4) + 1;
4797 float page_height = 3.0f / maxl;
4798 float page_start = (static_cast<float>(show_line)) / maxl;
4799 pen.setColor(palette().color(QPalette::HighlightedText));
4800 painter->setBrush(palette().color(QPalette::HighlightedText).darker());
4801 painter->setPen(palette().color(QPalette::HighlightedText).darker());
4802 painter->drawRect(pix->width() + 10, h, 8, h + pix->height());
4803 painter->setPen(pen);
4804 painter->drawRoundedRect(pix->width() + 10,
4805 h + page_start * pix->height(),
4806 8, h + page_height * pix->height(), 2, 2);
4807 }
4808 }
4809 if (point_size < 0) {
4810 info_font.setPixelSize(*f_size);
4811 } else {
4812 info_font.setPointSize(*f_size);
4813 }
4814 cw->put_to_corner();
4815}
4816
4817/***********************************************************************/
4821{
4823
4824 painter.begin(this);
4825 paint(&painter, event);
4826 painter.end();
4827}
4828
4829/***********************************************************************/
4834{
4835 was_destroyed = true;
4836 close();
4837 destroy();
4838}
4839
4840/***********************************************************************/
4844{
4845 int i = 1;
4846 struct unit_list *punit_list;
4847
4848 unit_count = 0;
4849 if (utile == nullptr) {
4850 struct unit *punit = head_of_units_in_focus();
4851 if (punit) {
4853 }
4854 }
4855 unit_list.clear();
4856 if (utile != nullptr) {
4858 if (punit_list != nullptr) {
4860 unit_count++;
4861 if (i > show_line * 4)
4862 unit_list.push_back(punit);
4863 i++;
4865 }
4866 }
4867 if (unit_list.count() == 0) {
4868 close();
4869 }
4870}
4871
4872/***********************************************************************/
4876{
4877 gui()->mapview_wdg->setFocus();
4878 QWidget::closeEvent(event);
4879}
4880
4881/***********************************************************************/
4885{
4886 int nr;
4887
4888 if (!more && utile == nullptr) {
4889 return;
4890 }
4891 nr = qCeil(static_cast<qreal>(unit_list_size(utile->units)) / 4) - 3;
4892 if (event->angleDelta().y() < 0) {
4893 show_line++;
4895 } else {
4896 show_line--;
4897 show_line = qMax(0, show_line);
4898 }
4899 update_units();
4900 create_pixmap();
4901 update();
4902 event->accept();
4903}
4904
4905/***********************************************************************/
4909{
4910 if (event->key() == Qt::Key_Escape) {
4911 was_destroyed = true;
4912 close();
4913 destroy();
4914 }
4915 QWidget::keyPressEvent(event);
4916}
4917
4918/***********************************************************************/
4925
4926/***********************************************************************/
4933
4934/***********************************************************************/
4939{
4940 // Just tell the client common code to handle this.
4941 return false;
4942}
4943
4944/***********************************************************************/
4947bool qtg_request_transport(struct unit *pcargo, struct tile *ptile)
4948{
4949 int tcount;
4951 struct unit_list *potential_transports = unit_list_new();
4952#ifndef FREECIV_NDEBUG
4954#endif
4955
4959 }
4961
4963
4964 if (tcount == 0) {
4965 fc_assert(best_transport == nullptr);
4967
4968 return false; // Unit was not handled here.
4969 } else if (tcount == 1) {
4970 // There's exactly one potential transport - use it automatically
4973
4975
4976 return true;
4977 }
4978
4979 hul = new hud_unit_loader(pcargo, ptile);
4980 hul->show_me();
4981 return true;
4982}
4983
4984/***********************************************************************/
4988void qtg_popup_combat_info(int attacker_unit_id, int defender_unit_id,
4989 int attacker_hp, int defender_hp,
4990 bool make_att_veteran, bool make_def_veteran)
4991{
4992 if (gui()->qt_settings.show_battle_log) {
4993 hud_unit_combat *huc = new hud_unit_combat(attacker_unit_id,
4994 defender_unit_id,
4995 attacker_hp, defender_hp,
4996 make_att_veteran,
4997 make_def_veteran,
4998 gui()->battlelog_wdg->scale,
4999 gui()->battlelog_wdg);
5000
5001 gui()->battlelog_wdg->add_combat_info(huc);
5002 gui()->battlelog_wdg->show();
5003 }
5004}
5005
5006/**********************************************************************/
5010 struct act_confirmation_data *data)
5011{
5012 hud_message_box *ask = new hud_message_box(gui()->central_wdg);
5013
5014 ask->setStandardButtons(QMessageBox::Cancel | QMessageBox::Ok);
5015 ask->setDefaultButton(QMessageBox::Cancel);
5016 ask->set_text_title(body, hdr);
5017 ask->setAttribute(Qt::WA_DeleteOnClose);
5018 QObject::connect(ask, &hud_message_box::accepted, [=]() {
5020 });
5021 QObject::connect(ask, &hud_message_box::rejected, [=]() {
5023 });
5024
5025 ask->show();
5026}
5027
5028/***********************************************************************/
5032 struct act_confirmation_data *data)
5033{
5035
5036 hdr = QString(_("Are you sure you want to do %1?")).
5038
5039 if (expl != nullptr) {
5041 }
5042
5044}
5045
5046/**********************************************************************/
5049void qtg_popup_image(const char *tag)
5050{
5051 struct sprite *spr = load_popup_sprite(tag);
5052
5053 if (spr != nullptr) {
5054 QDialog *win = new QDialog(gui());
5055 QVBoxLayout *layout = new QVBoxLayout(win);
5056 QPixmap *pm = new QPixmap(*spr->pm);
5057 QLabel *lbl = new QLabel;
5058 int width, height;
5059
5061 win->setFixedSize(width, height);
5062 lbl->setPixmap(*pm);
5063 layout->addWidget(lbl);
5064 win->setLayout(layout);
5065
5066 win->show();
5067
5069 } else {
5070 log_error(_("No image for tag \"%s\", requested by the server."), tag);
5071 }
5072}
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:5068
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:3826
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:4010
disband_box(struct unit_list *punits, QWidget *parent=0)
Definition dialogs.cpp:3984
struct unit_list * cpunits
Definition dialogs.h:97
choice_dialog * opened_dialog
Definition fc_client.h:219
choice_dialog * get_diplo_dialog()
Definition dialogs.cpp:4929
void set_diplo_dialog(choice_dialog *widget)
Definition dialogs.cpp:4921
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:475
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:4875
void update_img()
Definition dialogs.cpp:4733
int show_line
Definition dialogs.h:233
void mouseMoveEvent(QMouseEvent *event)
Definition dialogs.cpp:4677
int highligh_num
Definition dialogs.h:234
void paint(QPainter *painter, QPaintEvent *event)
Definition dialogs.cpp:4742
void update_menu()
Definition dialogs.cpp:4833
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:4497
void update_units()
Definition dialogs.cpp:4843
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:4820
void create_pixmap()
Definition dialogs.cpp:4542
void wheelEvent(QWheelEvent *event)
Definition dialogs.cpp:4884
void keyPressEvent(QKeyEvent *event)
Definition dialogs.cpp:4908
void mousePressEvent(QMouseEvent *event)
Definition dialogs.cpp:4708
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:1051
void request_unit_load(struct unit *pcargo, struct unit *ptrans, struct tile *ptile)
Definition control.c:2156
void unit_focus_set(struct unit *punit)
Definition control.c:506
void request_do_action(action_id action, int actor_id, int target_id, int sub_tgt, const char *name)
Definition control.c:1730
void request_unit_disband(struct unit *punit)
Definition control.c:2075
void request_action_details(action_id action, int actor_id, int target_id)
Definition control.c:1798
void request_new_unit_activity_targeted(struct unit *punit, enum unit_activity act, struct extra_type *tgt)
Definition control.c:1938
void action_confirmation(struct act_confirmation_data *data, bool confirm)
Definition control.c:1766
void action_decision_clear_want(const int old_actor_id)
Definition control.c:1080
void key_unit_wait(void)
Definition control.c:3542
struct unit * head_of_units_in_focus(void)
Definition control.c:410
void request_unit_upgrade(struct unit *punit)
Definition control.c:2106
void action_selection_next_in_focus(const int old_actor_id)
Definition control.c:1092
bool qtg_handmade_scenario_warning()
Definition dialogs.cpp:4938
static void attack(QVariant data1, QVariant data2)
Definition dialogs.cpp:3043
static void wipe_units(QVariant data1, QVariant data2)
Definition dialogs.cpp:2764
char forced_tileset_name[512]
int action_selection_target_extra(void)
Definition dialogs.cpp:4236
static void destroy_city(QVariant data1, QVariant data2)
Definition dialogs.cpp:3420
static void spy_sabotage_unit(QVariant data1, QVariant data2)
Definition dialogs.cpp:2472
static void pillage(QVariant data1, QVariant data2)
Definition dialogs.cpp:2904
static void caravan_marketplace(QVariant data1, QVariant data2)
Definition dialogs.cpp:1741
static void clean(QVariant data1, QVariant data2)
Definition dialogs.cpp:2924
static void spy_steal_shared(QVariant data1, QVariant data2, action_id act_id)
Definition dialogs.cpp:3178
static void spy_sabotage(QVariant data1, QVariant data2)
Definition dialogs.cpp:3859
int action_selection_target_tile(void)
Definition dialogs.cpp:4219
static void spy_investigate(QVariant data1, QVariant data2)
Definition dialogs.cpp:3540
static void act_sel_wait(QVariant data1, QVariant data2)
Definition dialogs.cpp:1910
static void nuke_units(QVariant data1, QVariant data2)
Definition dialogs.cpp:2740
int action_selection_actor_unit(void)
Definition dialogs.cpp:4185
static void capture_units(QVariant data1, QVariant data2)
Definition dialogs.cpp:2776
static void road(QVariant data1, QVariant data2)
Definition dialogs.cpp:2944
static bool is_race_dialog_open
Definition dialogs.cpp:191
static void transport_embark4(QVariant data1, QVariant data2)
Definition dialogs.cpp:2584
bool try_default_unit_action(QVariant q1, QVariant q2)
Definition dialogs.cpp:1552
static void fortify(QVariant data1, QVariant data2)
Definition dialogs.cpp:2397
static void transport_board(QVariant data1, QVariant data2)
Definition dialogs.cpp:2518
static void diplomat_bribe_unit(QVariant data1, QVariant data2)
Definition dialogs.cpp:2437
static void spy_sabotage_unit_esc(QVariant data1, QVariant data2)
Definition dialogs.cpp:2484
static void disband_unit(QVariant data1, QVariant data2)
Definition dialogs.cpp:2385
static void spy_steal_gold(QVariant data1, QVariant data2)
Definition dialogs.cpp:3435
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:3495
static void mine(QVariant data1, QVariant data2)
Definition dialogs.cpp:2986
void popup_musicset_suggestion_dialog(void)
Definition dialogs.cpp:4096
static void spy_steal_gold_esc(QVariant data1, QVariant data2)
Definition dialogs.cpp:3450
static void diplomat_embassy(QVariant data1, QVariant data2)
Definition dialogs.cpp:3525
void unit_select_dialog_popup(struct tile *ptile)
Definition dialogs.cpp:1252
void popup_upgrade_dialog(struct unit_list *punits)
Definition dialogs.cpp:4452
void update_nationset_combo()
Definition dialogs.cpp:1272
void action_selection_close(void)
Definition dialogs.cpp:4390
static void cultivate(QVariant data1, QVariant data2)
Definition dialogs.cpp:2874
static void paradrop_enter(QVariant data1, QVariant data2)
Definition dialogs.cpp:3133
void races_update_pickable(bool nationset_change)
Definition dialogs.cpp:1282
int action_selection_target_city(void)
Definition dialogs.cpp:4202
static void spy_steal_something(QVariant data1, QVariant data2)
Definition dialogs.cpp:3268
#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:3345
static void transport_board2(QVariant data1, QVariant data2)
Definition dialogs.cpp:2529
void show_tech_gained_dialog(Tech_type_id tech)
Definition dialogs.cpp:4404
static void base(QVariant data1, QVariant data2)
Definition dialogs.cpp:2965
static void spy_nuke_city_esc(QVariant data1, QVariant data2)
Definition dialogs.cpp:3390
void popup_soundset_suggestion_dialog(void)
Definition dialogs.cpp:4071
static void enter_hut2(QVariant data1, QVariant data2)
Definition dialogs.cpp:2695
void popup_races_dialog(struct player *pplayer)
Definition dialogs.cpp:1227
static void expel_unit(QVariant data1, QVariant data2)
Definition dialogs.cpp:2788
static void paradrop_frighten(QVariant data1, QVariant data2)
Definition dialogs.cpp:3103
static void diplomat_sabotage(QVariant data1, QVariant data2)
Definition dialogs.cpp:3570
void popup_disband_dialog(struct unit_list *punits)
Definition dialogs.cpp:4030
static action_id get_non_targeted_action_id(action_id tgt_action_id)
Definition dialogs.cpp:2280
static void homeless(QVariant data1, QVariant data2)
Definition dialogs.cpp:2423
static void caravan_help_build(QVariant data1, QVariant data2)
Definition dialogs.cpp:1771
void qtg_popup_image(const char *tag)
Definition dialogs.cpp:5049
static void bombard(QVariant data1, QVariant data2)
Definition dialogs.cpp:2800
void popup_bribe_stack_dialog(struct unit *actor, struct tile *ttile, int cost, const struct action *paction)
Definition dialogs.cpp:3792
void popdown_races_dialog(void)
Definition dialogs.cpp:1241
void popup_tileset_suggestion_dialog(void)
Definition dialogs.cpp:4040
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:3163
static void spy_request_sabotage_list(QVariant data1, QVariant data2)
Definition dialogs.cpp:3308
static void popup_act_confirmation_dialog(QString hdr, QString body, struct act_confirmation_data *data)
Definition dialogs.cpp:5009
static void unit_disband_recover(QVariant data1, QVariant data2)
Definition dialogs.cpp:1786
static void spy_steal(QVariant data1, QVariant data2)
Definition dialogs.cpp:3252
static void airlift(QVariant data1, QVariant data2)
Definition dialogs.cpp:1837
void popup_pillage_dialog(struct unit *punit, bv_extras extras)
Definition dialogs.cpp:3951
static void transport_load3(QVariant data1, QVariant data2)
Definition dialogs.cpp:2628
static void bombard_lethal(QVariant data1, QVariant data2)
Definition dialogs.cpp:2836
static void plant(QVariant data1, QVariant data2)
Definition dialogs.cpp:2889
static void diplomat_bribe_stack(QVariant data1, QVariant data2)
Definition dialogs.cpp:2455
static void nuke(QVariant data1, QVariant data2)
Definition dialogs.cpp:3028
static void disembark2(QVariant data1, QVariant data2)
Definition dialogs.cpp:2665
static void transport_unload(QVariant data1, QVariant data2)
Definition dialogs.cpp:2595
void qtg_request_action_confirmation(const char *expl, struct act_confirmation_data *data)
Definition dialogs.cpp:5031
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:4267
void popdown_science_report()
static void transport_load2(QVariant data1, QVariant data2)
Definition dialogs.cpp:2617
static void diplomat_steal(QVariant data1, QVariant data2)
Definition dialogs.cpp:3600
static void unit_upgrade(QVariant data1, QVariant data2)
Definition dialogs.cpp:1816
bool popup_theme_suggestion_dialog(const char *theme_name)
Definition dialogs.cpp:4121
static void enter_hut(QVariant data1, QVariant data2)
Definition dialogs.cpp:2680
static void spy_request_strike_bld_list(QVariant data1, QVariant data2)
Definition dialogs.cpp:3291
static void diplomat_incite_escape(QVariant data1, QVariant data2)
Definition dialogs.cpp:3648
static void found_city(QVariant data1, QVariant data2)
Definition dialogs.cpp:2848
static void diplomat_investigate(QVariant data1, QVariant data2)
Definition dialogs.cpp:3555
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:4988
static void bombard3(QVariant data1, QVariant data2)
Definition dialogs.cpp:2824
static void transport_deboard(QVariant data1, QVariant data2)
Definition dialogs.cpp:2639
static void diplomat_incite(QVariant data1, QVariant data2)
Definition dialogs.cpp:3630
static void paradrop_conquer(QVariant data1, QVariant data2)
Definition dialogs.cpp:3088
void popdown_endgame_report()
static void diplomat_steal_esc(QVariant data1, QVariant data2)
Definition dialogs.cpp:3615
static bool is_more_user_input_needed
Definition dialogs.cpp:196
static void bombard2(QVariant data1, QVariant data2)
Definition dialogs.cpp:2812
void popup_incite_dialog(struct unit *actor, struct city *tcity, int cost, const struct action *paction)
Definition dialogs.cpp:3682
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:3405
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:3585
void popdown_units_report()
static void transport_embark2(QVariant data1, QVariant data2)
Definition dialogs.cpp:2562
static void spy_nuke_city(QVariant data1, QVariant data2)
Definition dialogs.cpp:3375
void unit_select_dialog_update_real(void *unused)
Definition dialogs.cpp:1264
static void spy_steal_esc(QVariant data1, QVariant data2)
Definition dialogs.cpp:3260
static void paradrop(QVariant data1, QVariant data2)
Definition dialogs.cpp:3073
static void suicide_attack(QVariant data1, QVariant data2)
Definition dialogs.cpp:3058
void races_toggles_set_sensitive(void)
Definition dialogs.cpp:1293
static void transport_load(QVariant data1, QVariant data2)
Definition dialogs.cpp:2606
static action_id get_production_targeted_action_id(action_id tgt_action_id)
Definition dialogs.cpp:2303
static void paradrop_frighten_conquer(QVariant data1, QVariant data2)
Definition dialogs.cpp:3118
static void convert_unit(QVariant data1, QVariant data2)
Definition dialogs.cpp:2411
static bool did_not_decide
Definition dialogs.cpp:200
static void spy_poison_esc(QVariant data1, QVariant data2)
Definition dialogs.cpp:3360
static void pillage_something(QVariant data1, QVariant data2)
Definition dialogs.cpp:3839
static void spy_request_sabotage_esc_list(QVariant data1, QVariant data2)
Definition dialogs.cpp:3326
void show_tileset_error(bool fatal, const char *tset_name, const char *msg)
Definition dialogs.cpp:4411
static void transform_terrain(QVariant data1, QVariant data2)
Definition dialogs.cpp:2859
#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:3666
static void heal_unit2(QVariant data1, QVariant data2)
Definition dialogs.cpp:2507
static void transport_board3(QVariant data1, QVariant data2)
Definition dialogs.cpp:2540
static void spy_embassy(QVariant data1, QVariant data2)
Definition dialogs.cpp:3510
static races_dialog * race_dialog
Definition dialogs.cpp:190
static void frighten_hut2(QVariant data1, QVariant data2)
Definition dialogs.cpp:2725
static void conquer_extras2(QVariant data1, QVariant data2)
Definition dialogs.cpp:1896
static void frighten_hut(QVariant data1, QVariant data2)
Definition dialogs.cpp:2710
bool qtg_request_transport(struct unit *pcargo, struct tile *ptile)
Definition dialogs.cpp:4947
int action_selection_target_unit(void)
Definition dialogs.cpp:4253
static void irrigate(QVariant data1, QVariant data2)
Definition dialogs.cpp:3007
static void transport_embark3(QVariant data1, QVariant data2)
Definition dialogs.cpp:2573
static void collect_ransom(QVariant data1, QVariant data2)
Definition dialogs.cpp:2752
static void heal_unit(QVariant data1, QVariant data2)
Definition dialogs.cpp:2496
void popdown_city_report()
Definition cityrep.cpp:1338
static void paradrop_enter_conquer(QVariant data1, QVariant data2)
Definition dialogs.cpp:3148
static void unit_home_city(QVariant data1, QVariant data2)
Definition dialogs.cpp:1801
static void transport_embark(QVariant data1, QVariant data2)
Definition dialogs.cpp:2551
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:3480
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:2356
static void disembark1(QVariant data1, QVariant data2)
Definition dialogs.cpp:2650
void restart_notify_dialogs()
Definition dialogs.cpp:4130
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:2323
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:4146
static void spy_steal_maps(QVariant data1, QVariant data2)
Definition dialogs.cpp:3465
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:236
int action_id
Definition fc_types.h:248
int Government_type_id
Definition fc_types.h:240
#define IDENTITY_NUMBER_ZERO
Definition fc_types.h:92
#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
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:1048
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:4369
bool option_str_set(struct option *poption, const char *str)
Definition options.c:977
const char * option_str_get(const struct option *poption)
Definition options.c:944
struct option * optset_option_by_name(const struct option_set *poptset, const char *name)
Definition options.c:482
#define REQEST_PLAYER_INITIATED
Definition packets.h:63
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:2399
void set_government_choice(struct government *government)
Definition packhand.c:2386
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:550
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:1842
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:7828
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:7096
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:7836
struct sprite * get_nation_flag_sprite(const struct tileset *t, const struct nation_type *pnation)
Definition tilespec.c:6993
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