Freeciv-3.4
Loading...
Searching...
No Matches
dialogs.cpp
Go to the documentation of this file.
1/***********************************************************************
2 Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
6 any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12***********************************************************************/
13
14#ifdef HAVE_CONFIG_H
15#include <fc_config.h>
16#endif
17
18// Qt
19#include <QApplication>
20#include <QButtonGroup>
21#include <QComboBox>
22#include <QGroupBox>
23#include <QHeaderView>
24#include <QImage>
25#include <QMessageBox>
26#include <QMouseEvent>
27#include <QPainter>
28#include <QPainterPath>
29#include <QRadioButton>
30#include <QRect>
31#include <QTableWidgetItem>
32#include <QTextEdit>
33#include <QVBoxLayout>
34#include <QWindow>
35#include <QtMath>
36
37// utility
38#include "astring.h"
39
40// common
41#include "actions.h"
42#include "city.h"
43#include "game.h"
44#include "government.h"
45#include "improvement.h"
46#include "movement.h"
47#include "nation.h"
48#include "research.h"
49#include "sex.h"
50
51// client
52#include "audio.h"
53#include "chatline_common.h"
54#include "client_main.h"
55#include "control.h"
56#include "helpdata.h"
57#include "packhand.h"
58#include "svgflag.h"
59#include "text.h"
60#include "tilespec.h"
61
62// gui-qt
63#include "dialogs.h"
64#include "fc_client.h"
65#include "gui_main.h"
66#include "hudwidget.h"
67#include "qtg_cxxside.h"
68#include "sprite.h"
69
70// Locations for non action enabler controlled buttons.
71#define BUTTON_WAIT (ACTION_COUNT + 1)
72#define BUTTON_CANCEL (BUTTON_WAIT + 1)
73#define BUTTON_COUNT (BUTTON_CANCEL + 1)
74
76extern void popdown_players_report();
77extern void popdown_economy_report();
78extern void popdown_units_report();
79extern void popdown_science_report();
80extern void popdown_city_report();
81extern void popdown_endgame_report();
82
83static void spy_request_strike_bld_list(QVariant data1, QVariant data2);
84static void diplomat_incite(QVariant data1, QVariant data2);
85static void diplomat_incite_escape(QVariant data1, QVariant data2);
86static void spy_request_sabotage_list(QVariant data1, QVariant data2);
87static void spy_request_sabotage_esc_list(QVariant data1, QVariant data2);
88static void spy_sabotage(QVariant data1, QVariant data2);
89static void spy_steal(QVariant data1, QVariant data2);
90static void spy_steal_esc(QVariant data1, QVariant data2);
91static void spy_steal_something(QVariant data1, QVariant data2);
92static void diplomat_steal(QVariant data1, QVariant data2);
93static void diplomat_steal_esc(QVariant data1, QVariant data2);
94static void spy_poison(QVariant data1, QVariant data2);
95static void spy_poison_esc(QVariant data1, QVariant data2);
96static void spy_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/***********************************************************************/
395{
396 if (moving_now) {
397 move(event->globalPosition().toPoint() - point);
398 }
399}
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 = event->globalPosition().toPoint() - 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 = event->globalPosition().toPoint() - geometry().topLeft();
983
984 if (event->button() == Qt::RightButton) {
985 was_destroyed = true;
986 close();
987 }
988}
989
990/***********************************************************************/
994{
995 move(event->globalPosition().toPoint() - cursor);
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
1420
1421 targeted_unit = nullptr;
1422 // No buttons are added yet.
1423 for (int i = 0; i < BUTTON_COUNT; i++) {
1424 action_button_map << nullptr;
1425 }
1426}
1427
1428/***********************************************************************/
1432{
1433 buttons_list.clear();
1434 action_button_map.clear();
1435 gui()->set_diplo_dialog(nullptr);
1436
1437 if (run_on_close) {
1439 run_on_close = nullptr;
1440 }
1441}
1442
1443/***********************************************************************/
1447{
1449
1452 struct canvas *pix;
1453 QPushButton *next, *prev;
1454 unit_skip = new QHBoxLayout;
1455 next = new QPushButton();
1456 next->setIcon(fc_icons::instance()->get_icon("city-right"));
1457 next->setIconSize(QSize(32, 32));
1458 next->setFixedSize(QSize(36, 36));
1459 prev = new QPushButton();
1460 prev->setIcon(fc_icons::instance()->get_icon("city-left"));
1461 prev->setIconSize(QSize(32, 32));
1462 prev->setFixedSize(QSize(36, 36));
1463 target_unit_button = new QPushButton;
1466 pix->map_pixmap.fill(Qt::transparent);
1467 put_unit(targeted_unit, pix, 1.0, 0, 0);
1468 target_unit_button->setIcon(QIcon(pix->map_pixmap));
1469 qtg_canvas_free(pix);
1470 target_unit_button->setIconSize(QSize(96, 96));
1471 target_unit_button->setFixedSize(QSize(100, 100));
1472 unit_skip->addStretch(100);
1473 unit_skip->addWidget(prev, Qt::AlignCenter);
1474 unit_skip->addWidget(target_unit_button, Qt::AlignCenter);
1475 unit_skip->addWidget(next, Qt::AlignCenter);
1476 layout->addLayout(unit_skip);
1477 unit_skip->addStretch(100);
1478 connect(prev, &QAbstractButton::clicked, this, &choice_dialog::prev_unit);
1479 connect(next, &QAbstractButton::clicked, this, &choice_dialog::next_unit);
1480 }
1481
1483}
1484
1485/***********************************************************************/
1489 QVariant data2, QString tool_tip = "",
1490 const int button_id = -1)
1491{
1493 data1, data2);
1494 int action = buttons_list.count();
1495
1496 QObject::connect(button, &QPushButton::clicked,
1499 });
1500
1501 buttons_list.append(button);
1502
1503 if (!tool_tip.isEmpty()) {
1504 button->setToolTip(tool_tip);
1505 }
1506
1507 if (0 <= button_id) {
1508 // The id is valid.
1509 action_button_map[button_id] = button;
1510 }
1511
1512 layout->addWidget(button);
1513}
1514
1515/***********************************************************************/
1519{
1520 QPoint p;
1521
1522 p = mapFromGlobal(QCursor::pos());
1523 p.setY(p.y()-this->height());
1524 p.setX(p.x()-this->width());
1525 move(p);
1526 show();
1527}
1528
1529/***********************************************************************/
1536
1537/***********************************************************************/
1541{
1542 if (id < 0) {
1543 fc_assert_msg(0 <= id, "Invalid button ID.");
1544 return nullptr;
1545 }
1546
1547 return action_button_map[id];
1548}
1549
1550/***********************************************************************/
1554{
1557
1559 if (action == -1) {
1560 return false;
1561 }
1562 func = af_map[action];
1563
1564 func(q1, q2);
1565 return true;
1566}
1567
1568/***********************************************************************/
1572{
1575
1577 if (action == -1) {
1578 return false;
1579 }
1580 func = af_map[action];
1581 func(q1, q2);
1582 return true;
1583}
1584
1585/***********************************************************************/
1589{
1590 struct tile *ptile;
1591 struct unit *new_target = nullptr;
1592 bool break_next = false;
1593 bool first = true;
1594 struct canvas *pix;
1595
1596 if (targeted_unit == nullptr) {
1597 return;
1598 }
1599
1600 ptile = targeted_unit->tile;
1601
1602 unit_list_iterate(ptile->units, ptgt) {
1603 if (first) {
1604 new_target = ptgt;
1605 first = false;
1606 }
1607 if (break_next) {
1608 new_target = ptgt;
1609 break;
1610 }
1611 if (ptgt == targeted_unit) {
1612 break_next = true;
1613 }
1618 pix->map_pixmap.fill(Qt::transparent);
1619 put_unit(targeted_unit, pix, 1.0, 0, 0);
1620 target_unit_button->setIcon(QIcon(pix->map_pixmap));
1621 qtg_canvas_free(pix);
1622 switch_target();
1623}
1624
1625/***********************************************************************/
1629{
1630 struct tile *ptile;
1631 struct unit *new_target = nullptr;
1632 struct canvas *pix;
1633 if (targeted_unit == nullptr) {
1634 return;
1635 }
1636
1637 ptile = targeted_unit->tile;
1638 unit_list_iterate(ptile->units, ptgt) {
1639 if ((ptgt == targeted_unit) && new_target != nullptr) {
1640 break;
1641 }
1642 new_target = ptgt;
1647 pix->map_pixmap.fill(Qt::transparent);
1648 put_unit(targeted_unit, pix, 1.0, 0, 0);
1649 target_unit_button->setIcon(QIcon(pix->map_pixmap));
1650 qtg_canvas_free(pix);
1651 switch_target();
1652}
1653
1654/***********************************************************************/
1658{
1659 if (targeted_unit == nullptr) {
1660 return;
1661 }
1662 unit_skip->setParent(nullptr);
1667 : nullptr),
1668 act_probs);
1669 layout->addLayout(unit_skip);
1670}
1671
1672/***********************************************************************/
1676{
1677 if (targeted_unit == nullptr) {
1678 return;
1679 }
1680
1681 unit_skip->setParent(nullptr);
1683 unit_id,
1688 layout->addLayout(unit_skip);
1689}
1690
1691/***********************************************************************/
1695{
1697 pfcn_void func = button->getFunc();
1698
1699 func(button->getData1(), button->getData2());
1700 close();
1701}
1702
1703/***********************************************************************/
1712{
1713 // Store the data in the stack.
1714 last_buttons_stack.append(button);
1715
1716 /* Temporary remove the button so it will end up below buttons added
1717 * before unstack_all_buttons() is called. */
1718 layout->removeWidget(button);
1719
1720 // Synchronize the list with the layout.
1721 buttons_list.removeAll(button);
1722}
1723
1724/***********************************************************************/
1729{
1730 while (!last_buttons_stack.isEmpty()) {
1731 Choice_dialog_button *button = last_buttons_stack.takeLast();
1732
1733 // Reinsert the button below the other buttons.
1734 buttons_list.append(button);
1735 layout->addWidget(button);
1736 }
1737}
1738
1739/***********************************************************************/
1742static void caravan_marketplace(QVariant data1, QVariant data2)
1743{
1744 int actor_unit_id = data1.toInt();
1745 int target_city_id = data2.toInt();
1746
1747 if (game_unit_by_number(actor_unit_id) != nullptr
1748 && game_city_by_number(target_city_id) != nullptr) {
1750 target_city_id, 0, "");
1751 }
1752}
1753
1754/***********************************************************************/
1758{
1759 int actor_unit_id = data1.toInt();
1760 int target_city_id = data2.toInt();
1761
1762 if (game_unit_by_number(actor_unit_id) != nullptr
1763 && game_city_by_number(target_city_id) != nullptr) {
1765 target_city_id, 0, "");
1766 }
1767}
1768
1769/***********************************************************************/
1772static void caravan_help_build(QVariant data1, QVariant data2)
1773{
1774 int caravan_id = data1.toInt();
1775 int caravan_target_id = data2.toInt();
1776
1777 if (game_unit_by_number(caravan_id) != nullptr
1778 && game_city_by_number(caravan_target_id) != nullptr) {
1781 }
1782}
1783
1784/***********************************************************************/
1787static void unit_disband_recover(QVariant data1, QVariant data2)
1788{
1789 int actor_id = data1.toInt();
1790 int tgt_city_id = data2.toInt();
1791
1792 if (game_unit_by_number(actor_id) != nullptr
1793 && game_city_by_number(tgt_city_id) != nullptr) {
1795 actor_id, tgt_city_id, 0, "");
1796 }
1797}
1798
1799/***********************************************************************/
1802static void unit_home_city(QVariant data1, QVariant data2)
1803{
1804 int actor_id = data1.toInt();
1805 int tgt_city_id = data2.toInt();
1806
1807 if (game_unit_by_number(actor_id) != nullptr
1808 && game_city_by_number(tgt_city_id) != nullptr) {
1810 actor_id, tgt_city_id, 0, "");
1811 }
1812}
1813
1814/***********************************************************************/
1817static void unit_upgrade(QVariant data1, QVariant data2)
1818{
1819 struct unit *punit;
1820
1821 int actor_id = data1.toInt();
1822 int tgt_city_id = data2.toInt();
1823
1824 if ((punit = game_unit_by_number(actor_id)) != nullptr
1825 && game_city_by_number(tgt_city_id) != nullptr) {
1826 struct unit_list *as_list;
1827
1832 }
1833}
1834
1835/***********************************************************************/
1838static void airlift(QVariant data1, QVariant data2)
1839{
1840 int actor_id = data1.toInt();
1841 int tgt_city_id = data2.toInt();
1842
1843 if (game_unit_by_number(actor_id) != nullptr
1844 && game_city_by_number(tgt_city_id) != nullptr) {
1846 actor_id, tgt_city_id, 0, "");
1847 }
1848}
1849
1850/***********************************************************************/
1853static void conquer_city_shrink(QVariant data1, QVariant data2)
1854{
1855 int actor_id = data1.toInt();
1856 int tgt_city_id = data2.toInt();
1857
1858 if (game_unit_by_number(actor_id) != nullptr
1859 && game_city_by_number(tgt_city_id) != nullptr) {
1861 actor_id, tgt_city_id, 0, "");
1862 }
1863}
1864
1865/***********************************************************************/
1868static void conquer_city_shrink2(QVariant data1, QVariant data2)
1869{
1870 int actor_id = data1.toInt();
1871 int tgt_city_id = data2.toInt();
1872
1873 if (game_unit_by_number(actor_id) != nullptr
1874 && game_city_by_number(tgt_city_id) != nullptr) {
1876 actor_id, tgt_city_id, 0, "");
1877 }
1878}
1879
1880/***********************************************************************/
1883static void conquer_extras(QVariant data1, QVariant data2)
1884{
1885 int actor_id = data1.toInt();
1886 int target_id = data2.toInt();
1887
1888 if (game_unit_by_number(actor_id) != nullptr) {
1890 actor_id, target_id, 0, "");
1891 }
1892}
1893
1894/***********************************************************************/
1897static void conquer_extras2(QVariant data1, QVariant data2)
1898{
1899 int actor_id = data1.toInt();
1900 int target_id = data2.toInt();
1901
1902 if (game_unit_by_number(actor_id) != nullptr) {
1904 actor_id, target_id, 0, "");
1905 }
1906}
1907
1908/***********************************************************************/
1911static void act_sel_wait(QVariant data1, QVariant data2)
1912{
1913 key_unit_wait();
1914}
1915
1916/***********************************************************************/
1919static void keep_moving(QVariant data1, QVariant data2)
1920{
1921}
1922
1923/***********************************************************************/
1927{
1928 if (!gov) {
1930 } else {
1932 }
1933}
1934
1935/***********************************************************************/
1940{
1942 /* The client isn't waiting for information for any unanswered follow
1943 * up questions. */
1944
1945 struct unit *actor_unit;
1946
1948 /* The action selection dialog wasn't closed because the actor unit
1949 * was lost. */
1950
1951 // The probabilities didn't just disappear, right?
1954
1956 }
1957
1958 // The action selection process is over, at least for now.
1960
1961 if (did_not_decide) {
1962 /* The action selection dialog was closed but the player didn't
1963 * decide what the unit should do. */
1964
1965 // Reset so the next action selection dialog does the right thing.
1966 did_not_decide = false;
1967 } else {
1968 // An action, or no action at all, was selected.
1971 }
1972 }
1973}
1974
1975/***********************************************************************/
1979static void diplomat_queue_handle_secondary(int actor_id)
1980{
1981 // Stop waiting. Move on to the next queued unit.
1984}
1985
1986/**********************************************************************/
1993{
1994 // Stop assuming the answer to a follow up question will arrive.
1996}
1997
1998/***********************************************************************/
2003 struct city *target_city,
2004 struct unit *target_unit,
2005 struct tile *target_tile,
2006 struct extra_type *target_extra,
2007 const struct act_prob *act_probs)
2008{
2009 struct astring title = ASTRING_INIT, text = ASTRING_INIT;
2011 qtiles caras;
2012 QVariant qv1, qv2;
2014 struct city *actor_homecity;
2017
2020
2021 foreach (caras, gui()->trade_gen.lines) {
2022 if (caras.autocaravan == actor_unit) {
2023 int i;
2024
2025 if (game_unit_by_number(actor_unit->id) != nullptr
2026 && game_city_by_number(target_city->id) != nullptr) {
2028 target_city->id, 0, "");
2031 i = gui()->trade_gen.lines.indexOf(caras);
2032 gui()->trade_gen.lines.takeAt(i);
2033
2034 return;
2035 }
2036 }
2037 }
2038 if (target_city
2042
2043 return;
2044 }
2045
2046 if (target_unit
2050
2051 return;
2052 }
2053 /* Could be caused by the server failing to reply to a request for more
2054 * information or a bug in the client code. */
2056 "Diplomat queue problem. Is another diplomat window open?");
2057
2058 // No extra input is required as no action has been chosen yet.
2060
2062
2063 astr_set(&title,
2064 // TRANS: %s is a unit name, e.g., Spy
2065 _("Choose Your %s's Strategy"),
2067
2068 if (target_city != nullptr && actor_homecity != nullptr) {
2069 astr_set(&text,
2070 _("Your %s from %s reaches the city of %s.\nWhat now?"),
2074 } else if (target_city != nullptr) {
2075 astr_set(&text,
2076 _("Your %s has arrived at %s.\nWhat is your command?"),
2079 } else if (target_unit != nullptr) {
2081
2082 if (owner != nullptr) {
2083 astr_set(&text,
2084 // TRANS: Your Spy is ready to act against Roman Freight.
2085 _("Your %s is ready to act against %s %s."),
2089 } else {
2090 // Flagless target
2091 astr_set(&text,
2092 // TRANS: Your Spy is ready to act against Freight.
2093 _("Your %s is ready to act against %s."),
2096 }
2097 } else {
2098 fc_assert_msg(target_unit != nullptr
2099 || target_city != nullptr
2100 || target_tile != nullptr,
2101 "No target specified.");
2102
2103 astr_set(&text,
2104 // TRANS: %s is a unit name, e.g., Diplomat, Spy
2105 _("Your %s is waiting for your command."),
2107 }
2108
2109 cd = gui()->get_diplo_dialog();
2110 if ((cd != nullptr) && cd->targeted_unit != nullptr) {
2111 cd->update_dialog(act_probs);
2112 return;
2113 }
2114 cd = new choice_dialog(astr_str(&title), astr_str(&text),
2115 gui()->game_tab_widget,
2117 qv1 = actor_unit->id;
2118
2119 cd->unit_id = actor_unit->id;
2120
2121 cd->target_id[ATK_SELF] = cd->unit_id;
2122
2123 if (target_city) {
2124 cd->target_id[ATK_CITY] = target_city->id;
2125 } else {
2126 cd->target_id[ATK_CITY] = IDENTITY_NUMBER_ZERO;
2127 }
2128
2129 if (target_unit) {
2130 cd->target_id[ATK_UNIT] = target_unit->id;
2131 } else {
2132 cd->target_id[ATK_UNIT] = IDENTITY_NUMBER_ZERO;
2133 }
2134
2135 if (target_tile) {
2136 cd->target_id[ATK_STACK] = tile_index(target_tile);
2137 } else {
2138 cd->target_id[ATK_STACK] = TILE_INDEX_NONE;
2139 }
2140
2141 if (target_tile) {
2142 cd->target_id[ATK_TILE] = tile_index(target_tile);
2143 } else {
2144 cd->target_id[ATK_TILE] = TILE_INDEX_NONE;
2145 }
2146
2147 if (target_tile) {
2148 cd->target_id[ATK_EXTRAS] = tile_index(target_tile);
2149 } else {
2150 cd->target_id[ATK_EXTRAS] = TILE_INDEX_NONE;
2151 }
2152
2153 // No target building or target tech supplied. (Feb 2020)
2154 cd->sub_target_id[ASTK_BUILDING] = B_LAST;
2155 cd->sub_target_id[ASTK_TECH] = A_UNSET;
2156
2157 if (target_extra) {
2158 cd->sub_target_id[ASTK_EXTRA] = extra_number(target_extra);
2160 } else {
2161 cd->sub_target_id[ASTK_EXTRA] = EXTRA_NONE;
2162 cd->sub_target_id[ASTK_EXTRA_NOT_THERE] = EXTRA_NONE;
2163 }
2164
2165 // Unit acting against a city
2166
2167 // Set the correct target for the following actions.
2168 qv2 = cd->target_id[ATK_CITY];
2169
2170 action_iterate(act) {
2175 act_probs[act],
2176 actor_unit,
2177 target_city),
2178 qv1, qv2);
2179 }
2181
2182 // Unit acting against another unit
2183
2184 // Set the correct target for the following actions.
2185 qv2 = cd->target_id[ATK_UNIT];
2186
2187 action_iterate(act) {
2192 act_probs[act],
2193 actor_unit,
2194 target_city),
2195 qv1, qv2);
2196 }
2198
2199 // Unit acting against all units at a tile
2200
2201 // Set the correct target for the following actions.
2202 qv2 = cd->target_id[ATK_STACK];
2203
2204 action_iterate(act) {
2209 act_probs[act],
2210 actor_unit,
2211 target_city),
2212 qv1, qv2);
2213 }
2215
2216 // Unit acting against a tile.
2217
2218 // Set the correct target for the following actions.
2219 qv2 = cd->target_id[ATK_TILE];
2220
2221 action_iterate(act) {
2226 act_probs[act],
2227 actor_unit,
2228 target_city),
2229 qv1, qv2);
2230 }
2232
2233 // Unit acting against a tile's extras.
2234
2235 // Set the correct target for the following actions.
2236 qv2 = cd->target_id[ATK_EXTRAS];
2237
2238 action_iterate(act) {
2243 act_probs[act],
2244 actor_unit,
2245 target_city),
2246 qv1, qv2);
2247 }
2249
2250 // Unit acting against itself
2251
2252 // Set the correct target for the following actions.
2253 qv2 = cd->target_id[ATK_SELF];
2254
2255 action_iterate(act) {
2260 act_probs[act],
2261 actor_unit,
2262 target_city),
2263 qv1, qv2);
2264 }
2266
2268 cd->add_item(QString(_("&Wait")), func, qv1, qv2,
2269 "", BUTTON_WAIT);
2270
2271 func = keep_moving;
2272 cd->add_item(QString(_("Do nothing")), func, qv1, qv2,
2273 "", BUTTON_CANCEL);
2274
2275 cd->set_layout();
2276 cd->show_me();
2277
2278 // Give follow up questions access to action probabilities.
2280 action_iterate(act) {
2283
2284 astr_free(&title);
2285 astr_free(&text);
2286}
2287
2288/***********************************************************************/
2293{
2294 /* Don't add an action mapping here unless the non targeted version is
2295 * selectable in the targeted version's target selection dialog. */
2296 switch ((enum gen_action)tgt_action_id) {
2302 return ACTION_SPY_STEAL_TECH;
2305 default:
2306 // No non targeted version found.
2307 return ACTION_NONE;
2308 }
2309}
2310
2311/**********************************************************************/
2316{
2317 /* Don't add an action mapping here unless the non targeted version is
2318 * selectable in the targeted version's target selection dialog. */
2319 switch ((enum gen_action)tgt_action_id) {
2326 default:
2327 // No non targeted version found.
2328 return ACTION_NONE;
2329 }
2330}
2331
2332/***********************************************************************/
2336 action_id act,
2337 const struct act_prob *act_probs,
2338 const char *custom,
2339 QVariant data1, QVariant data2)
2340{
2341 QString title;
2343
2344 if (!af_map.contains(act)) {
2345 /* The Qt client doesn't support ordering this action from the
2346 * action selection dialog. */
2347 return;
2348 }
2349
2350 // Don't show disabled actions.
2351 if (!action_prob_possible(act_probs[act])) {
2352 return;
2353 }
2354
2356 act_probs[act],
2357 custom));
2358
2360 act_probs[act]));
2361
2362 cd->add_item(title, af_map[act], data1, data2, tool_tip, act);
2363}
2364
2365/***********************************************************************/
2369 action_id act,
2370 const struct act_prob *act_probs,
2371 const char *custom,
2372 QVariant data1, QVariant data2)
2373{
2374 QString title;
2376
2377 /* An action that just became impossible has its button disabled.
2378 * An action that became possible again must be re-enabled. */
2379 button->setEnabled(action_prob_possible(act_probs[act]));
2380 button->setData1(data1);
2381 button->setData2(data2);
2382 // The probability may have changed.
2384 act_probs[act],
2385 custom));
2386
2388 act_probs[act]));
2389
2390 button->setText(title);
2391 button->setToolTip(tool_tip);
2392}
2393
2394/***********************************************************************/
2397static void disband_unit(QVariant data1, QVariant data2)
2398{
2399 int actor_id = data1.toInt();
2400 int target_id = data2.toInt();
2401
2403 target_id, 0, "");
2404}
2405
2406/***********************************************************************/
2409static void fortify(QVariant data1, QVariant data2)
2410{
2411 int actor_id = data1.toInt();
2412 int target_id = data2.toInt();
2413
2414 if (game_unit_by_number(actor_id) != nullptr) {
2416 target_id, 0, "");
2417 }
2418}
2419
2420/***********************************************************************/
2423static void convert_unit(QVariant data1, QVariant data2)
2424{
2425 int actor_id = data1.toInt();
2426 int target_id = data2.toInt();
2427
2429 target_id, 0, "");
2430}
2431
2432/***********************************************************************/
2435static void homeless(QVariant data1, QVariant data2)
2436{
2437 int actor_id = data1.toInt();
2438 int target_id = data2.toInt();
2439
2440 if (game_unit_by_number(actor_id) != nullptr) {
2442 target_id, 0, "");
2443 }
2444}
2445
2446/***********************************************************************/
2449static void diplomat_bribe_unit(QVariant data1, QVariant data2)
2450{
2451 int diplomat_id = data1.toInt();
2452 int diplomat_target_id = data2.toInt();
2453
2454 if (game_unit_by_number(diplomat_id) != nullptr
2455 && game_unit_by_number(diplomat_target_id) != nullptr) {
2456 // Wait for the server's reply before moving on to the next queued diplomat.
2458
2461 }
2462}
2463
2464/***********************************************************************/
2467static void diplomat_bribe_stack(QVariant data1, QVariant data2)
2468{
2469 int diplomat_id = data1.toInt();
2470 int diplomat_target_id = data2.toInt();
2471
2472 if (game_unit_by_number(diplomat_id) != nullptr) {
2473 // Wait for the server's reply before moving on to the next queued diplomat.
2475
2478 }
2479}
2480
2481/***********************************************************************/
2484static void spy_sabotage_unit(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 spy_sabotage_unit_esc(QVariant data1, QVariant data2)
2497{
2498 int diplomat_id = data1.toInt();
2499 int diplomat_target_id = data2.toInt();
2500
2502 diplomat_target_id, 0, "");
2503}
2504
2505/***********************************************************************/
2508static void heal_unit(QVariant data1, QVariant data2)
2509{
2510 int actor_id = data1.toInt();
2511 int target_id = data2.toInt();
2512
2513 request_do_action(ACTION_HEAL_UNIT, actor_id, target_id, 0, "");
2514}
2515
2516/***********************************************************************/
2519static void heal_unit2(QVariant data1, QVariant data2)
2520{
2521 int actor_id = data1.toInt();
2522 int target_id = data2.toInt();
2523
2524 request_do_action(ACTION_HEAL_UNIT2, actor_id, target_id, 0, "");
2525}
2526
2527/***********************************************************************/
2530static void transport_board(QVariant data1, QVariant data2)
2531{
2532 int actor_id = data1.toInt();
2533 int target_id = data2.toInt();
2534
2535 request_do_action(ACTION_TRANSPORT_BOARD, actor_id, target_id, 0, "");
2536}
2537
2538/***********************************************************************/
2541static void transport_board2(QVariant data1, QVariant data2)
2542{
2543 int actor_id = data1.toInt();
2544 int target_id = data2.toInt();
2545
2546 request_do_action(ACTION_TRANSPORT_BOARD2, actor_id, target_id, 0, "");
2547}
2548
2549/***********************************************************************/
2552static void transport_board3(QVariant data1, QVariant data2)
2553{
2554 int actor_id = data1.toInt();
2555 int target_id = data2.toInt();
2556
2557 request_do_action(ACTION_TRANSPORT_BOARD3, actor_id, target_id, 0, "");
2558}
2559
2560/***********************************************************************/
2563static void transport_embark(QVariant data1, QVariant data2)
2564{
2565 int actor_id = data1.toInt();
2566 int target_id = data2.toInt();
2567
2568 request_do_action(ACTION_TRANSPORT_EMBARK, actor_id, target_id, 0, "");
2569}
2570
2571/***********************************************************************/
2574static void transport_embark2(QVariant data1, QVariant data2)
2575{
2576 int actor_id = data1.toInt();
2577 int target_id = data2.toInt();
2578
2579 request_do_action(ACTION_TRANSPORT_EMBARK2, actor_id, target_id, 0, "");
2580}
2581
2582/***********************************************************************/
2585static void transport_embark3(QVariant data1, QVariant data2)
2586{
2587 int actor_id = data1.toInt();
2588 int target_id = data2.toInt();
2589
2590 request_do_action(ACTION_TRANSPORT_EMBARK3, actor_id, target_id, 0, "");
2591}
2592
2593/***********************************************************************/
2596static void transport_embark4(QVariant data1, QVariant data2)
2597{
2598 int actor_id = data1.toInt();
2599 int target_id = data2.toInt();
2600
2601 request_do_action(ACTION_TRANSPORT_EMBARK4, actor_id, target_id, 0, "");
2602}
2603
2604/***********************************************************************/
2607static void transport_unload(QVariant data1, QVariant data2)
2608{
2609 int actor_id = data1.toInt();
2610 int target_id = data2.toInt();
2611
2612 request_do_action(ACTION_TRANSPORT_UNLOAD, actor_id, target_id, 0, "");
2613}
2614
2615/***********************************************************************/
2618static void transport_load(QVariant data1, QVariant data2)
2619{
2620 int actor_id = data1.toInt();
2621 int target_id = data2.toInt();
2622
2623 request_do_action(ACTION_TRANSPORT_LOAD, actor_id, target_id, 0, "");
2624}
2625
2626/***********************************************************************/
2629static void transport_load2(QVariant data1, QVariant data2)
2630{
2631 int actor_id = data1.toInt();
2632 int target_id = data2.toInt();
2633
2634 request_do_action(ACTION_TRANSPORT_LOAD2, actor_id, target_id, 0, "");
2635}
2636
2637/***********************************************************************/
2640static void transport_load3(QVariant data1, QVariant data2)
2641{
2642 int actor_id = data1.toInt();
2643 int target_id = data2.toInt();
2644
2645 request_do_action(ACTION_TRANSPORT_LOAD3, actor_id, target_id, 0, "");
2646}
2647
2648/***********************************************************************/
2651static void transport_deboard(QVariant data1, QVariant data2)
2652{
2653 int actor_id = data1.toInt();
2654 int target_id = data2.toInt();
2655
2656 request_do_action(ACTION_TRANSPORT_DEBOARD, actor_id, target_id, 0, "");
2657}
2658
2659/***********************************************************************/
2662static void disembark1(QVariant data1, QVariant data2)
2663{
2664 int actor_id = data1.toInt();
2665 int target_id = data2.toInt();
2666
2667 if (game_unit_by_number(actor_id) != nullptr
2668 && index_to_tile(&(wld.map), target_id) != nullptr) {
2670 actor_id, target_id, 0, "");
2671 }
2672}
2673
2674/***********************************************************************/
2677static void disembark2(QVariant data1, QVariant data2)
2678{
2679 int actor_id = data1.toInt();
2680 int target_id = data2.toInt();
2681
2682 if (game_unit_by_number(actor_id) != nullptr
2683 && index_to_tile(&(wld.map), target_id) != nullptr) {
2685 actor_id, target_id, 0, "");
2686 }
2687}
2688
2689/***********************************************************************/
2692static void enter_hut(QVariant data1, QVariant data2)
2693{
2694 int actor_id = data1.toInt();
2695 int target_id = data2.toInt();
2696
2697 if (game_unit_by_number(actor_id) != nullptr
2698 && index_to_tile(&(wld.map), target_id) != nullptr) {
2700 actor_id, target_id, 0, "");
2701 }
2702}
2703
2704/***********************************************************************/
2707static void enter_hut2(QVariant data1, QVariant data2)
2708{
2709 int actor_id = data1.toInt();
2710 int target_id = data2.toInt();
2711
2712 if (game_unit_by_number(actor_id) != nullptr
2713 && index_to_tile(&(wld.map), target_id) != nullptr) {
2715 actor_id, target_id, 0, "");
2716 }
2717}
2718
2719/***********************************************************************/
2722static void frighten_hut(QVariant data1, QVariant data2)
2723{
2724 int actor_id = data1.toInt();
2725 int target_id = data2.toInt();
2726
2727 if (game_unit_by_number(actor_id) != nullptr
2728 && index_to_tile(&(wld.map), target_id) != nullptr) {
2730 actor_id, target_id, 0, "");
2731 }
2732}
2733
2734/***********************************************************************/
2737static void frighten_hut2(QVariant data1, QVariant data2)
2738{
2739 int actor_id = data1.toInt();
2740 int target_id = data2.toInt();
2741
2742 if (game_unit_by_number(actor_id) != nullptr
2743 && index_to_tile(&(wld.map), target_id) != nullptr) {
2745 actor_id, target_id, 0, "");
2746 }
2747}
2748
2749/**********************************************************************/
2752static void nuke_units(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 collect_ransom(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 wipe_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 capture_units(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 expel_unit(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 bombard(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 bombard2(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 bombard3(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 bombard_lethal(QVariant data1, QVariant data2)
2849{
2850 int actor_id = data1.toInt();
2851 int target_id = data2.toInt();
2852
2854 target_id, 0, "");
2855}
2856
2857/***********************************************************************/
2860static void found_city(QVariant data1, QVariant data2)
2861{
2862 int actor_id = data1.toInt();
2863
2865 actor_id);
2866}
2867
2868/***********************************************************************/
2871static void transform_terrain(QVariant data1, QVariant data2)
2872{
2873 int actor_id = data1.toInt();
2874 int target_id = data2.toInt();
2875
2876 if (game_unit_by_number(actor_id) != nullptr
2877 && index_to_tile(&(wld.map), target_id) != nullptr) {
2879 actor_id, target_id, 0, "");
2880 }
2881}
2882
2883/***********************************************************************/
2886static void cultivate(QVariant data1, QVariant data2)
2887{
2888 int actor_id = data1.toInt();
2889 int target_id = data2.toInt();
2890
2891 if (game_unit_by_number(actor_id) != nullptr
2892 && index_to_tile(&(wld.map), target_id) != nullptr) {
2894 actor_id, target_id, 0, "");
2895 }
2896}
2897
2898/***********************************************************************/
2901static void plant(QVariant data1, QVariant data2)
2902{
2903 int actor_id = data1.toInt();
2904 int target_id = data2.toInt();
2905
2906 if (game_unit_by_number(actor_id) != nullptr
2907 && index_to_tile(&(wld.map), target_id) != nullptr) {
2909 actor_id, target_id, 0, "");
2910 }
2911}
2912
2913/***********************************************************************/
2916static void pillage(QVariant data1, QVariant data2)
2917{
2918 int actor_id = data1.toInt();
2919 int target_id = data2.toInt();
2920
2921 if (game_unit_by_number(actor_id) != nullptr
2922 && index_to_tile(&(wld.map), target_id) != nullptr) {
2924 actor_id, target_id,
2925 /* FIXME: will cause problems if more than
2926 * one action selection dialog at a time
2927 * becomes supported. */
2929 "");
2930 }
2931}
2932
2933/***********************************************************************/
2936static void clean(QVariant data1, QVariant data2)
2937{
2938 int actor_id = data1.toInt();
2939 int target_id = data2.toInt();
2940
2941 if (game_unit_by_number(actor_id) != nullptr
2942 && index_to_tile(&(wld.map), target_id) != nullptr) {
2944 actor_id, target_id,
2945 /* FIXME: will cause problems if more than
2946 * one action selection dialog at a time
2947 * becomes supported. */
2949 "");
2950 }
2951}
2952
2953/***********************************************************************/
2956static void road(QVariant data1, QVariant data2)
2957{
2958 int actor_id = data1.toInt();
2959 int target_id = data2.toInt();
2960
2961 if (game_unit_by_number(actor_id) != nullptr
2962 && index_to_tile(&(wld.map), target_id) != nullptr
2965 actor_id, target_id,
2966 /* FIXME: will cause problems if more than
2967 * one action selection dialog at a time
2968 * becomes supported. */
2970 "");
2971 }
2972}
2973
2974/***********************************************************************/
2977static void base(QVariant data1, QVariant data2)
2978{
2979 int actor_id = data1.toInt();
2980 int target_id = data2.toInt();
2981
2982 if (game_unit_by_number(actor_id) != nullptr
2983 && index_to_tile(&(wld.map), target_id) != nullptr
2986 actor_id, target_id,
2987 /* FIXME: will cause problems if more than
2988 * one action selection dialog at a time
2989 * becomes supported. */
2991 "");
2992 }
2993}
2994
2995/***********************************************************************/
2998static void mine(QVariant data1, QVariant data2)
2999{
3000 int actor_id = data1.toInt();
3001 int target_id = data2.toInt();
3002
3003 if (game_unit_by_number(actor_id) != nullptr
3004 && index_to_tile(&(wld.map), target_id) != nullptr
3007 actor_id, target_id,
3008 /* FIXME: will cause problems if more than
3009 * one action selection dialog at a time
3010 * becomes supported. */
3012 "");
3013 }
3014}
3015
3016/***********************************************************************/
3019static void irrigate(QVariant data1, QVariant data2)
3020{
3021 int actor_id = data1.toInt();
3022 int target_id = data2.toInt();
3023
3024 if (game_unit_by_number(actor_id) != nullptr
3025 && index_to_tile(&(wld.map), target_id) != nullptr
3028 actor_id, target_id,
3029 /* FIXME: will cause problems if more than
3030 * one action selection dialog at a time
3031 * becomes supported. */
3033 "");
3034 }
3035}
3036
3037/***********************************************************************/
3040static void nuke(QVariant data1, QVariant data2)
3041{
3042 int diplomat_id = data1.toInt();
3043 int diplomat_target_id = data2.toInt();
3044
3045 if (game_unit_by_number(diplomat_id) != nullptr
3046 && index_to_tile(&(wld.map), diplomat_target_id) != nullptr) {
3049 }
3050}
3051
3052/***********************************************************************/
3055static void attack(QVariant data1, QVariant data2)
3056{
3057 int diplomat_id = data1.toInt();
3058 int diplomat_target_id = data2.toInt();
3059
3060 if (game_unit_by_number(diplomat_id) != nullptr
3061 && index_to_tile(&(wld.map), diplomat_target_id) != nullptr) {
3064 }
3065}
3066
3067/***********************************************************************/
3070static void suicide_attack(QVariant data1, QVariant data2)
3071{
3072 int diplomat_id = data1.toInt();
3073 int diplomat_target_id = data2.toInt();
3074
3075 if (game_unit_by_number(diplomat_id) != nullptr
3076 && index_to_tile(&(wld.map), diplomat_target_id) != nullptr) {
3079 }
3080}
3081
3082/***********************************************************************/
3085static void paradrop(QVariant data1, QVariant data2)
3086{
3087 int actor_id = data1.toInt();
3088 int target_id = data2.toInt();
3089
3090 if (game_unit_by_number(actor_id) != nullptr
3091 && index_to_tile(&(wld.map), target_id) != nullptr) {
3093 actor_id, target_id, 0, "");
3094 }
3095}
3096
3097/***********************************************************************/
3100static void paradrop_conquer(QVariant data1, QVariant data2)
3101{
3102 int actor_id = data1.toInt();
3103 int target_id = data2.toInt();
3104
3105 if (game_unit_by_number(actor_id) != nullptr
3106 && index_to_tile(&(wld.map), target_id) != nullptr) {
3108 actor_id, target_id, 0, "");
3109 }
3110}
3111
3112/***********************************************************************/
3115static void paradrop_frighten(QVariant data1, QVariant data2)
3116{
3117 int actor_id = data1.toInt();
3118 int target_id = data2.toInt();
3119
3120 if (game_unit_by_number(actor_id) != nullptr
3121 && index_to_tile(&(wld.map), target_id) != nullptr) {
3123 actor_id, target_id, 0, "");
3124 }
3125}
3126
3127/***********************************************************************/
3131{
3132 int actor_id = data1.toInt();
3133 int target_id = data2.toInt();
3134
3135 if (game_unit_by_number(actor_id) != nullptr
3136 && index_to_tile(&(wld.map), target_id) != nullptr) {
3138 actor_id, target_id, 0, "");
3139 }
3140}
3141
3142/***********************************************************************/
3145static void paradrop_enter(QVariant data1, QVariant data2)
3146{
3147 int actor_id = data1.toInt();
3148 int target_id = data2.toInt();
3149
3150 if (game_unit_by_number(actor_id) != nullptr
3151 && index_to_tile(&(wld.map), target_id) != nullptr) {
3153 actor_id, target_id, 0, "");
3154 }
3155}
3156
3157/***********************************************************************/
3161{
3162 int actor_id = data1.toInt();
3163 int target_id = data2.toInt();
3164
3165 if (game_unit_by_number(actor_id) != nullptr
3166 && index_to_tile(&(wld.map), target_id) != nullptr) {
3168 actor_id, target_id, 0, "");
3169 }
3170}
3171
3172/***********************************************************************/
3175static void join_city(QVariant data1, QVariant data2)
3176{
3177 int actor_id = data1.toInt();
3178 int target_id = data2.toInt();
3179
3180 if (game_unit_by_number(actor_id) != nullptr
3181 && game_city_by_number(target_id) != nullptr) {
3183 actor_id, target_id, 0, "");
3184 }
3185}
3186
3187/***********************************************************************/
3190static void spy_steal_shared(QVariant data1, QVariant data2,
3191 action_id act_id)
3192{
3193 QString str;
3194 QVariant qv1;
3196 int diplomat_id = data1.toInt();
3197 int diplomat_target_id = data2.toInt();
3200 struct player *pvictim = nullptr;
3203
3204 cd = gui()->get_diplo_dialog();
3205 if (cd != nullptr) {
3206 cd->close();
3207 }
3208
3209 if (pvcity == nullptr) {
3210 return;
3211 }
3212
3213 // Wait for the player's reply before moving on to the next queued diplomat.
3215
3217
3218 struct astring stra = ASTRING_INIT;
3219 cd = new choice_dialog(_("Steal"), _("Steal Technology"),
3220 gui()->game_tab_widget,
3222
3223 // Put both actor and target city in qv1 since qv2 is taken
3226 actor_and_target.append(act_id);
3227 qv1 = QVariant::fromValue(actor_and_target);
3228
3229 struct player *pplayer = client_player();
3230 const struct research *presearch = research_get(pplayer);
3231 const struct research *vresearch = research_get(pvictim);
3232
3239 // Defeat keyboard shortcut mnemonics
3241 .replace("&", "&&");
3242 cd->add_item(str, func, qv1, i);
3243 }
3245
3247 get_non_targeted_action_id(act_id)])) {
3248 astr_set(&stra, _("At %s's Discretion"),
3251 str = QString(astr_str(&stra)).replace("&", "&&");
3252 cd->add_item(str, func, qv1, A_UNSET);
3253 }
3254
3255 cd->set_layout();
3256 cd->show_me();
3257
3258 astr_free(&stra);
3259}
3260
3261/***********************************************************************/
3264static void spy_steal(QVariant data1, QVariant data2)
3265{
3267}
3268
3269/***********************************************************************/
3272static void spy_steal_esc(QVariant data1, QVariant data2)
3273{
3275}
3276
3277/***********************************************************************/
3280static void spy_steal_something(QVariant data1, QVariant data2)
3281{
3282 int diplomat_id = data1.toList().at(0).toInt();
3283 int diplomat_target_id = data1.toList().at(1).toInt();
3284 action_id act_id = data1.toList().at(2).toInt();
3285
3286 if (game_unit_by_number(diplomat_id) != nullptr
3287 && game_city_by_number(diplomat_target_id) != nullptr) {
3288 if (data2.toInt() == A_UNSET) {
3289 // This is the untargeted version.
3291 diplomat_id, diplomat_target_id, data2.toInt(), "");
3292 } else {
3293 // This is the targeted version.
3295 diplomat_target_id, data2.toInt(), "");
3296 }
3297 }
3298}
3299
3300/***********************************************************************/
3304{
3305 int actor_id = data1.toInt();
3306 int target_id = data2.toInt();
3307
3308 if (game_unit_by_number(actor_id) != nullptr
3309 && game_city_by_number(target_id) != nullptr) {
3310 // Wait for the server's reply before moving on to the next queued diplomat.
3312
3313 request_action_details(ACTION_STRIKE_BUILDING, actor_id, target_id);
3314 }
3315}
3316
3317/***********************************************************************/
3321{
3322 int diplomat_id = data1.toInt();
3323 int diplomat_target_id = data2.toInt();
3324
3325 if (game_unit_by_number(diplomat_id) != nullptr
3326 && game_city_by_number(diplomat_target_id) != nullptr) {
3327 // Wait for the server's reply before moving on to the next queued diplomat.
3329
3332 }
3333}
3334
3335/***********************************************************************/
3339{
3340 int diplomat_id = data1.toInt();
3341 int diplomat_target_id = data2.toInt();
3342
3343 if (game_unit_by_number(diplomat_id) != nullptr
3344 && game_city_by_number(diplomat_target_id) != nullptr) {
3345 /* Wait for the server's reply before moving on to the next queued
3346 * diplomat. */
3348
3351 }
3352}
3353
3354/***********************************************************************/
3357static void spy_poison(QVariant data1, QVariant data2)
3358{
3359 int diplomat_id = data1.toInt();
3360 int diplomat_target_id = data2.toInt();
3361
3362 if (game_unit_by_number(diplomat_id) != nullptr
3363 && game_city_by_number(diplomat_target_id) != nullptr) {
3366 }
3367}
3368
3369/***********************************************************************/
3372static void spy_poison_esc(QVariant data1, QVariant data2)
3373{
3374 int diplomat_id = data1.toInt();
3375 int diplomat_target_id = data2.toInt();
3376
3377 if (game_unit_by_number(diplomat_id) != nullptr
3378 && game_city_by_number(diplomat_target_id) != nullptr) {
3381 }
3382}
3383
3384/***********************************************************************/
3387static void spy_nuke_city(QVariant data1, QVariant data2)
3388{
3389 int diplomat_id = data1.toInt();
3390 int diplomat_target_id = data2.toInt();
3391
3392 if (game_unit_by_number(diplomat_id) != nullptr
3393 && game_city_by_number(diplomat_target_id) != nullptr) {
3396 }
3397}
3398
3399/***********************************************************************/
3402static void spy_nuke_city_esc(QVariant data1, QVariant data2)
3403{
3404 int diplomat_id = data1.toInt();
3405 int diplomat_target_id = data2.toInt();
3406
3407 if (game_unit_by_number(diplomat_id) != nullptr
3408 && game_city_by_number(diplomat_target_id) != nullptr) {
3411 }
3412}
3413
3414/***********************************************************************/
3417static void nuke_city(QVariant data1, QVariant data2)
3418{
3419 int actor_id = data1.toInt();
3420 int target_id = data2.toInt();
3421
3422 if (game_unit_by_number(actor_id) != nullptr
3423 && game_city_by_number(target_id) != nullptr) {
3425 actor_id, target_id, 0, "");
3426 }
3427}
3428
3429/***********************************************************************/
3432static void destroy_city(QVariant data1, QVariant data2)
3433{
3434 int diplomat_id = data1.toInt();
3435 int diplomat_target_id = data2.toInt();
3436
3437 if (game_unit_by_number(diplomat_id) != nullptr
3438 && game_city_by_number(diplomat_target_id) != nullptr) {
3441 }
3442}
3443
3444/***********************************************************************/
3447static void spy_steal_gold(QVariant data1, QVariant data2)
3448{
3449 int diplomat_id = data1.toInt();
3450 int diplomat_target_id = data2.toInt();
3451
3452 if (game_unit_by_number(diplomat_id) != nullptr
3453 && game_city_by_number(diplomat_target_id) != nullptr) {
3456 }
3457}
3458
3459/***********************************************************************/
3462static void spy_steal_gold_esc(QVariant data1, QVariant data2)
3463{
3464 int diplomat_id = data1.toInt();
3465 int diplomat_target_id = data2.toInt();
3466
3467 if (game_unit_by_number(diplomat_id) != nullptr
3468 && game_city_by_number(diplomat_target_id) != nullptr) {
3471 }
3472}
3473
3474/***********************************************************************/
3477static void spy_steal_maps(QVariant data1, QVariant data2)
3478{
3479 int diplomat_id = data1.toInt();
3480 int diplomat_target_id = data2.toInt();
3481
3482 if (game_unit_by_number(diplomat_id) != nullptr
3483 && game_city_by_number(diplomat_target_id) != nullptr) {
3486 }
3487}
3488
3489/***********************************************************************/
3492static void spy_steal_maps_esc(QVariant data1, QVariant data2)
3493{
3494 int diplomat_id = data1.toInt();
3495 int diplomat_target_id = data2.toInt();
3496
3497 if (game_unit_by_number(diplomat_id) != nullptr
3498 && game_city_by_number(diplomat_target_id) != nullptr) {
3501 }
3502}
3503
3504/***********************************************************************/
3507static void spy_escape(QVariant data1, QVariant data2)
3508{
3509 int diplomat_id = data1.toInt();
3510 int diplomat_target_id = data2.toInt();
3511
3512 if (game_unit_by_number(diplomat_id) != nullptr
3513 && game_city_by_number(diplomat_target_id) != nullptr) {
3516 }
3517}
3518
3519/***********************************************************************/
3522static void spy_embassy(QVariant data1, QVariant data2)
3523{
3524 int diplomat_id = data1.toInt();
3525 int diplomat_target_id = data2.toInt();
3526
3527 if (game_unit_by_number(diplomat_id) != nullptr
3528 && game_city_by_number(diplomat_target_id) != nullptr) {
3530 diplomat_target_id, 0, "");
3531 }
3532}
3533
3534/***********************************************************************/
3537static void diplomat_embassy(QVariant data1, QVariant data2)
3538{
3539 int diplomat_id = data1.toInt();
3540 int diplomat_target_id = data2.toInt();
3541
3542 if (game_unit_by_number(diplomat_id) != nullptr
3543 && game_city_by_number(diplomat_target_id) != nullptr) {
3545 diplomat_target_id, 0, "");
3546 }
3547}
3548
3549/***********************************************************************/
3552static void spy_investigate(QVariant data1, QVariant data2)
3553{
3554 int diplomat_id = data1.toInt();
3555 int diplomat_target_id = data2.toInt();
3556
3558 && game_unit_by_number(diplomat_id) != nullptr) {
3560 diplomat_target_id, 0, "");
3561 }
3562}
3563
3564/***********************************************************************/
3567static void diplomat_investigate(QVariant data1, QVariant data2)
3568{
3569 int diplomat_id = data1.toInt();
3570 int diplomat_target_id = data2.toInt();
3571
3573 && game_unit_by_number(diplomat_id) != nullptr) {
3575 diplomat_target_id, 0, "");
3576 }
3577}
3578
3579/***********************************************************************/
3582static void diplomat_sabotage(QVariant data1, QVariant data2)
3583{
3584 int diplomat_id = data1.toInt();
3585 int diplomat_target_id = data2.toInt();
3586
3587 if (game_unit_by_number(diplomat_id) != nullptr
3588 && game_city_by_number(diplomat_target_id) != nullptr) {
3590 diplomat_target_id, B_LAST + 1, "");
3591 }
3592}
3593
3594/***********************************************************************/
3597static void diplomat_sabotage_esc(QVariant data1, QVariant data2)
3598{
3599 int diplomat_id = data1.toInt();
3600 int diplomat_target_id = data2.toInt();
3601
3602 if (game_unit_by_number(diplomat_id) != nullptr
3603 && game_city_by_number(diplomat_target_id) != nullptr) {
3605 diplomat_target_id, B_LAST + 1, "");
3606 }
3607}
3608
3609/***********************************************************************/
3612static void diplomat_steal(QVariant data1, QVariant data2)
3613{
3614 int diplomat_id = data1.toInt();
3615 int diplomat_target_id = data2.toInt();
3616
3617 if (game_unit_by_number(diplomat_id) != nullptr
3618 && game_city_by_number(diplomat_target_id) != nullptr) {
3621 }
3622}
3623
3624/***********************************************************************/
3627static void diplomat_steal_esc(QVariant data1, QVariant data2)
3628{
3629 int diplomat_id = data1.toInt();
3630 int diplomat_target_id = data2.toInt();
3631
3632 if (game_unit_by_number(diplomat_id) != nullptr
3633 && game_city_by_number(diplomat_target_id) != nullptr) {
3636 }
3637}
3638
3639/***********************************************************************/
3642static void diplomat_incite(QVariant data1, QVariant data2)
3643{
3644 int diplomat_id = data1.toInt();
3645 int diplomat_target_id = data2.toInt();
3646
3647 if (game_unit_by_number(diplomat_id) != nullptr
3648 && game_city_by_number(diplomat_target_id) != nullptr) {
3649 // Wait for the server's reply before moving on to the next queued diplomat.
3651
3654 }
3655}
3656
3657/***********************************************************************/
3661{
3662 int diplomat_id = data1.toInt();
3663 int diplomat_target_id = data2.toInt();
3664
3665 if (game_unit_by_number(diplomat_id) != nullptr
3666 && game_city_by_number(diplomat_target_id) != nullptr) {
3667 // Wait for the server's reply before moving on to the next queued diplomat.
3669
3672 }
3673}
3674
3675/***********************************************************************/
3678static void regular_move(QVariant data1, QVariant data2)
3679{
3680 int actor_id = data1.toInt();
3681 int target_id = data2.toInt();
3682
3683 if (game_unit_by_number(actor_id) != nullptr
3684 && index_to_tile(&(wld.map), target_id) != nullptr) {
3686 actor_id, target_id, 0, "");
3687 }
3688}
3689
3690/***********************************************************************/
3694void popup_incite_dialog(struct unit *actor, struct city *tcity, int cost,
3695 const struct action *paction)
3696{
3697 char buf[1024];
3698 char buf2[1024];
3699 int diplomat_id = actor->id;
3700 int diplomat_target_id = tcity->id;
3701 const int act_id = paction->id;
3702
3703 // Should be set before sending request to the server.
3705
3706 fc_snprintf(buf, ARRAY_SIZE(buf), PL_("Treasury contains %d gold.",
3707 "Treasury contains %d gold.",
3708 client_player()->economic.gold),
3709 client_player()->economic.gold);
3710
3712 hud_message_box *impossible = new hud_message_box(gui()->central_wdg);
3713
3715 _("You can't incite a revolt in %s."), city_name_get(tcity));
3716 impossible->set_text_title(buf2, "!");
3717 impossible->setStandardButtons(QMessageBox::Ok);
3718 impossible->setAttribute(Qt::WA_DeleteOnClose);
3719 impossible->show();
3720 } else if (cost <= client_player()->economic.gold) {
3721 hud_message_box *ask = new hud_message_box(gui()->central_wdg);
3722
3724 PL_("Incite a revolt for %d gold?\n%s",
3725 "Incite a revolt for %d gold?\n%s", cost), cost, buf);
3726 ask->setStandardButtons(QMessageBox::Cancel | QMessageBox::Ok);
3727 ask->setDefaultButton(QMessageBox::Cancel);
3728 ask->set_text_title(buf2, _("Incite a Revolt!"));
3729 ask->setAttribute(Qt::WA_DeleteOnClose);
3730 QObject::connect(ask, &hud_message_box::accepted, [=]() {
3733 });
3734 ask->show();
3735 return;
3736 } else {
3737 hud_message_box *too_much = new hud_message_box(gui()->central_wdg);
3738
3740 PL_("Inciting a revolt costs %d gold.\n%s",
3741 "Inciting a revolt costs %d gold.\n%s", cost), cost,
3742 buf);
3743 too_much->set_text_title(buf2, "!");
3744 too_much->setStandardButtons(QMessageBox::Ok);
3745 too_much->setAttribute(Qt::WA_DeleteOnClose);
3746 too_much->show();
3747 }
3748
3750}
3751
3752/***********************************************************************/
3756void popup_bribe_unit_dialog(struct unit *actor, struct unit *tunit, int cost,
3757 const struct action *paction)
3758{
3759 hud_message_box *ask = new hud_message_box(gui()->central_wdg);
3760 char buf[1024];
3761 char buf2[1024];
3762 int diplomat_id = actor->id;
3763 int diplomat_target_id = tunit->id;
3764 const int act_id = paction->id;
3765
3766 // Should be set before sending request to the server.
3768
3769 fc_snprintf(buf, ARRAY_SIZE(buf), PL_("Treasury contains %d gold.",
3770 "Treasury contains %d gold.",
3771 client_player()->economic.gold),
3772 client_player()->economic.gold);
3773
3774 if (cost <= client_player()->economic.gold) {
3775 fc_snprintf(buf2, ARRAY_SIZE(buf2), PL_("Bribe unit for %d gold?\n%s",
3776 "Bribe unit for %d gold?\n%s",
3777 cost), cost, buf);
3778 ask->set_text_title(buf2, _("Bribe Enemy Unit"));
3779 ask->setStandardButtons(QMessageBox::Cancel | QMessageBox::Ok);
3780 ask->setDefaultButton(QMessageBox::Cancel);
3781 ask->setAttribute(Qt::WA_DeleteOnClose);
3782 QObject::connect(ask, &hud_message_box::accepted, [=]() {
3785 });
3786 ask->show();
3787 return;
3788 } else {
3790 PL_("Bribing the unit costs %d gold.\n%s",
3791 "Bribing the unit costs %d gold.\n%s", cost), cost, buf);
3792 ask->set_text_title(buf2, _("Traitors Demand Too Much!"));
3793 ask->setAttribute(Qt::WA_DeleteOnClose);
3794 ask->show();
3795 }
3796
3798}
3799
3800/***********************************************************************/
3805 const struct action *paction)
3806{
3807 hud_message_box *ask = new hud_message_box(gui()->central_wdg);
3808 char buf[1024];
3809 char buf2[1024];
3810 int diplomat_id = actor->id;
3811 int diplomat_target_id = ttile->index;
3812 const int act_id = paction->id;
3813
3814 // Should be set before sending request to the server.
3816
3817 fc_snprintf(buf, ARRAY_SIZE(buf), PL_("Treasury contains %d gold.",
3818 "Treasury contains %d gold.",
3819 client_player()->economic.gold),
3820 client_player()->economic.gold);
3821
3822 if (cost <= client_player()->economic.gold) {
3823 fc_snprintf(buf2, ARRAY_SIZE(buf2), PL_("Bribe unit stack for %d gold?\n%s",
3824 "Bribe unit stack for %d gold?\n%s",
3825 cost), cost, buf);
3826 ask->set_text_title(buf2, _("Bribe Enemy Stack"));
3827 ask->setStandardButtons(QMessageBox::Cancel | QMessageBox::Ok);
3828 ask->setDefaultButton(QMessageBox::Cancel);
3829 ask->setAttribute(Qt::WA_DeleteOnClose);
3830 QObject::connect(ask, &hud_message_box::accepted, [=]() {
3833 });
3834 ask->show();
3835 return;
3836 } else {
3838 PL_("Bribing the unit stack costs %d gold.\n%s",
3839 "Bribing the unit stack costs %d gold.\n%s", cost), cost, buf);
3840 ask->set_text_title(buf2, _("Traitors Demand Too Much!"));
3841 ask->setAttribute(Qt::WA_DeleteOnClose);
3842 ask->show();
3843 }
3844
3846}
3847
3848/***********************************************************************/
3851static void pillage_something(QVariant data1, QVariant data2)
3852{
3853 int punit_id;
3854 int what;
3855 struct unit *punit;
3856 struct extra_type *target;
3857
3858 what = data1.toInt();
3859 punit_id = data2.toInt();
3861 if (punit) {
3862 target = extra_by_number(what);
3864 }
3866}
3867
3868/***********************************************************************/
3871static void spy_sabotage(QVariant data1, QVariant data2)
3872{
3873 int diplomat_id = data1.toList().at(0).toInt();
3874 int diplomat_target_id = data1.toList().at(1).toInt();
3875 action_id act_id = data1.toList().at(2).toInt();
3876
3877 if (game_unit_by_number(diplomat_id) != nullptr
3878 && game_city_by_number(diplomat_target_id) != nullptr) {
3879 if (data2.toInt() == B_LAST) {
3880 // This is the untargeted version.
3882 diplomat_id, diplomat_target_id, data2.toInt(),
3883 "");
3884 } else if (data2.toInt() == -1) {
3885 // This is the city production version.
3887 diplomat_id, diplomat_target_id, data2.toInt(),
3888 "");
3889 } else {
3890 // This is the targeted version.
3892 diplomat_target_id, data2.toInt(), "");
3893 }
3894 }
3895}
3896
3897/***********************************************************************/
3902 const struct action *paction)
3903{
3904 QString str;
3905 QVariant qv1, qv2;
3906 int diplomat_id = actor->id;
3907 int diplomat_target_id = tcity->id;
3910 int nr = 0;
3911 struct astring stra = ASTRING_INIT;
3913
3914 if (paction->result == ACTRES_STRIKE_BUILDING) {
3915 cd = new choice_dialog(_("Strike"),
3916 _("Select Improvement to Strike"),
3917 gui()->game_tab_widget,
3919 } else {
3920 cd = new choice_dialog(_("Sabotage"),
3921 _("Select Improvement to Sabotage"),
3922 gui()->game_tab_widget,
3924 }
3925
3926 // Should be set before sending request to the server.
3928
3929 // Put both actor, target city and action in qv1 since qv2 is taken
3932 actor_and_target.append(paction->id);
3933 qv1 = QVariant::fromValue(actor_and_target);
3934
3937 paction->id)])) {
3939 cd->add_item(QString(_("City Production")), func, qv1, -1);
3940 }
3941
3942 city_built_iterate(tcity, pimprove) {
3943 if (pimprove->sabotage > 0) {
3945 // Defeat keyboard shortcut mnemonics
3947 .replace("&", "&&");
3948 qv2 = nr;
3949 cd->add_item(str, func, qv1, improvement_number(pimprove));
3950 nr++;
3951 }
3953
3956 astr_set(&stra, _("At %s's Discretion"),
3959 str = QString(astr_str(&stra)).replace("&", "&&");
3960 cd->add_item(str, func, qv1, B_LAST);
3961 }
3962
3963 cd->set_layout();
3964 cd->show_me();
3965 astr_free(&stra);
3966}
3967
3968/***********************************************************************/
3973{
3974 QString str;
3975 QVariant qv1, qv2;
3978 struct extra_type *tgt;
3979
3981 return;
3982 }
3983 cd = new choice_dialog(_("What To Pillage"), _("Select what to pillage:"),
3984 gui()->game_tab_widget);
3985 qv2 = punit->id;
3986 while ((tgt = get_preferred_pillage(extras))) {
3987 int what;
3988
3989 what = extra_index(tgt);
3990 BV_CLR(extras, what);
3991
3993 // Defeat keyboard shortcut mnemonics
3994 str = QString(extra_name_translation(tgt)).replace("&", "&&");
3995 qv1 = what;
3996 cd->add_item(str, func, qv1, qv2);
3997 }
3998 cd->set_layout();
3999 cd->show_me();
4000}
4001
4002/***********************************************************************/
4006 QWidget *parent) : hud_message_box(parent)
4007{
4008 QString str;
4009 QPushButton *pb;
4010
4011 setAttribute(Qt::WA_DeleteOnClose);
4012 setModal(false);
4017
4018 str = QString(PL_("Are you sure you want to disband that %1 unit?",
4019 "Are you sure you want to disband those %1 units?",
4021 pb = addButton(_("Yes"), QMessageBox::AcceptRole);
4022 addButton(_("No"), QMessageBox::RejectRole);
4023 set_text_title(str, _("Disband units"));
4025 connect(pb, &QAbstractButton::clicked, this, &disband_box::disband_clicked);
4026}
4027
4028/***********************************************************************/
4039
4040/***********************************************************************/
4047
4048/***********************************************************************/
4051void popup_disband_dialog(struct unit_list *punits)
4052{
4053 disband_box *ask = new disband_box(punits, gui()->central_wdg);
4054 ask->show();
4055}
4056
4057/***********************************************************************/
4062{
4063 hud_message_box *ask = new hud_message_box(gui()->central_wdg);
4064 QString text;
4065 QString title;
4066
4067 title = QString(_("Modpack suggests using %1 tileset."))
4069 text = QString("It might not work with other tilesets.\n"
4070 "You are currently using tileset %1.")
4072 ask->addButton(_("Keep current tileset"), QMessageBox::RejectRole);
4073 ask->addButton(_("Load tileset"), QMessageBox::AcceptRole);
4074 ask->set_text_title(text, title);
4075 ask->setAttribute(Qt::WA_DeleteOnClose);
4076
4077 QObject::connect(ask, &hud_message_box::accepted, [=]() {
4080 gui()->map_scale)) {
4082 _("Can't load requested tileset."));
4083 }
4084 });
4085 ask->show();
4086}
4087
4088/***********************************************************************/
4093{
4094 hud_message_box *ask = new hud_message_box(gui()->central_wdg);
4095 QString text;
4096 QString title;
4097
4098 title = QString(_("Modpack suggests using %1 soundset."))
4100 text = QString("It might not work with other tilesets.\n"
4101 "You are currently using soundset %1.")
4102 .arg(sound_set_name);
4103 ask->addButton(_("Keep current soundset"), QMessageBox::RejectRole);
4104 ask->addButton(_("Load soundset"), QMessageBox::AcceptRole);
4105 ask->set_text_title(text, title);
4106 ask->setAttribute(Qt::WA_DeleteOnClose);
4107 QObject::connect(ask, &hud_message_box::accepted, [=]() {
4109 });
4110 ask->show();
4111}
4112
4113/***********************************************************************/
4118{
4119 hud_message_box *ask = new hud_message_box(gui()->central_wdg);
4120 QString text;
4121 QString title;
4122
4123 title = QString(_("Modpack suggests using %1 musicset."))
4125 text = QString("It might not work with other tilesets.\n"
4126 "You are currently using musicset %1.")
4127 .arg(music_set_name);
4128 ask->addButton(_("Keep current musicset"), QMessageBox::RejectRole);
4129 ask->addButton(_("Load musicset"), QMessageBox::AcceptRole);
4130 ask->set_text_title(text, title);
4131 ask->setAttribute(Qt::WA_DeleteOnClose);
4132 QObject::connect(ask, &hud_message_box::accepted, [=]() {
4134 });
4135 ask->show();
4136}
4137
4138/***********************************************************************/
4143{
4144 // PORTME
4145 return false;
4146}
4147
4148/***********************************************************************/
4152{
4154 int i;
4155
4156 nd_list = gui()->mapview_wdg->findChildren<notify_dialog *>();
4157 for (i = 0; i < nd_list.count(); i++) {
4158 nd_list[i]->restart();
4159 delete nd_list[i];
4160 }
4161}
4162
4163/***********************************************************************/
4168{
4169 int i;
4172 goto_dialog *gtd;
4173
4174 QApplication::alert(gui()->central_wdg);
4175 cd_list = gui()->game_tab_widget->findChildren <choice_dialog *>();
4176 for (i = 0; i < cd_list.count(); i++) {
4177 cd_list[i]->close();
4178 }
4179 nd_list = gui()->game_tab_widget->findChildren <notify_dialog *>();
4180 for (i = 0; i < nd_list.count(); i++) {
4181 nd_list[i]->close();
4182 }
4183
4192 gui()->popdown_unit_sel();
4193
4194 gtd = gui()->gtd;
4195
4196 if (gtd != nullptr) {
4197 gtd->close_dlg();
4198 }
4199}
4200
4201/***********************************************************************/
4207{
4208 choice_dialog *cd = gui()->get_diplo_dialog();
4209
4210 if (cd != nullptr) {
4211 return cd->unit_id;
4212 } else {
4213 return IDENTITY_NUMBER_ZERO;
4214 }
4215}
4216
4217/***********************************************************************/
4224{
4225 choice_dialog *cd = gui()->get_diplo_dialog();
4226
4227 if (cd != nullptr) {
4228 return cd->target_id[ATK_CITY];
4229 } else {
4230 return IDENTITY_NUMBER_ZERO;
4231 }
4232}
4233
4234/***********************************************************************/
4241{
4242 choice_dialog *cd = gui()->get_diplo_dialog();
4243
4244 if (cd != nullptr) {
4245 return cd->target_id[ATK_TILE];
4246 } else {
4247 return TILE_INDEX_NONE;
4248 }
4249}
4250
4251/**********************************************************************/
4258{
4259 choice_dialog *cd = gui()->get_diplo_dialog();
4260
4261 if (cd != nullptr) {
4262 return cd->sub_target_id[ASTK_EXTRA];
4263 } else {
4264 return EXTRA_NONE;
4265 }
4266}
4267
4268/***********************************************************************/
4275{
4276 choice_dialog *cd = gui()->get_diplo_dialog();
4277
4278 if (cd != nullptr) {
4279 return cd->target_id[ATK_UNIT];
4280 } else {
4281 return IDENTITY_NUMBER_ZERO;
4282 }
4283}
4284
4285/***********************************************************************/
4289 struct city *target_city,
4290 struct unit *target_unit,
4291 struct tile *target_tile,
4292 struct extra_type *target_extra,
4293 const struct act_prob *act_probs)
4294{
4297 Choice_dialog_button *cancel_button;
4298 QVariant qv1, qv2;
4299
4300 asd = gui()->get_diplo_dialog();
4301 if (asd == nullptr) {
4302 fc_assert_msg(asd != nullptr,
4303 "The action selection dialog should have been open");
4304 return;
4305 }
4306
4309 "The action selection dialog is for another actor unit.");
4310 }
4311
4312 // Put the actor id in qv1.
4313 qv1 = actor_unit->id;
4314
4315 cancel_button = asd->get_identified_button(BUTTON_CANCEL);
4316 if (cancel_button != nullptr) {
4317 /* Temporary remove the Cancel button so it won't end up above
4318 * any added buttons. */
4319 asd->stack_button(cancel_button);
4320 }
4321
4322 wait_button = asd->get_identified_button(BUTTON_WAIT);
4323 if (wait_button != nullptr) {
4324 /* Temporary remove the Wait button so it won't end up above
4325 * any added buttons. */
4326 asd->stack_button(wait_button);
4327 }
4328
4329 action_iterate(act) {
4330 const char *custom;
4331
4332 if (action_id_get_actor_kind(act) != AAK_UNIT) {
4333 // Not relevant.
4334 continue;
4335 }
4336
4338 act_probs[act],
4339 actor_unit,
4340 target_city);
4341
4342 // Put the target id in qv2.
4343 switch (action_id_get_target_kind(act)) {
4344 case ATK_UNIT:
4345 if (target_unit != nullptr) {
4346 qv2 = target_unit->id;
4347 } else {
4349 || target_unit != nullptr,
4350 "Action enabled against non existing unit!");
4351
4353 }
4354 break;
4355 case ATK_CITY:
4356 if (target_city != nullptr) {
4357 qv2 = target_city->id;
4358 } else {
4360 || target_city != nullptr,
4361 "Action enabled against non existing city!");
4362
4364 }
4365 break;
4366 case ATK_TILE:
4367 case ATK_EXTRAS:
4368 case ATK_STACK:
4369 if (target_tile != nullptr) {
4371 } else {
4373 || target_tile != nullptr,
4374 "Action enabled against all units on "
4375 "non existing tile!");
4376
4378 }
4379 break;
4380 case ATK_SELF:
4381 qv2 = actor_unit->id;
4382 break;
4383 case ATK_COUNT:
4385 "Bad target kind");
4386 continue;
4387 }
4388
4389 if (asd->get_identified_button(act)) {
4390 // Update the existing button.
4391 action_entry_update(asd->get_identified_button(act),
4392 act, act_probs, custom,
4393 qv1, qv2);
4394 } else {
4395 // Add the button (unless its probability is 0).
4397 qv1, qv2);
4398 }
4400
4401 if (wait_button != nullptr || cancel_button != nullptr) {
4402 /* Reinsert the non action buttons below any potential
4403 * buttons recently added. */
4404 asd->unstack_all_buttons();
4405 }
4406}
4407
4408/***********************************************************************/
4412{
4414
4415 cd = gui()->get_diplo_dialog();
4416 if (cd != nullptr) {
4417 did_not_decide = true;
4418 cd->close();
4419 }
4420}
4421
4422/***********************************************************************/
4428
4429/***********************************************************************/
4432void show_tileset_error(bool fatal, const char *tset_name, const char *msg)
4433{
4434 QWidget *parent;
4435 fc_client *std_gui = gui();
4436
4437 if (std_gui != nullptr) {
4438 parent = std_gui->central_wdg;
4439 } else {
4440 parent = nullptr;
4441 }
4442
4443 if (std_gui != nullptr || fatal) {
4444 char buf[1024];
4445 QMessageBox *ask = new QMessageBox(parent);
4446
4447 if (tset_name != nullptr) {
4448 fc_snprintf(buf, sizeof(buf),
4449 _("Tileset \"%s\" problem, it's probably incompatible with "
4450 "the ruleset:\n%s"), tset_name, msg);
4451 } else {
4452 fc_snprintf(buf, sizeof(buf),
4453 _("Tileset problem, it's probably incompatible with "
4454 "the ruleset:\n%s"), msg);
4455 }
4456
4457 ask->setText(buf);
4458 ask->setStandardButtons(QMessageBox::Ok);
4459 ask->setWindowTitle(_("Tileset error"));
4460
4461 if (std_gui != nullptr && !fatal) {
4462 ask->setAttribute(Qt::WA_DeleteOnClose);
4463 ask->show();
4464 } else {
4465 ask->exec();
4466 }
4467 }
4468}
4469
4470/***********************************************************************/
4473void popup_upgrade_dialog(struct unit_list *punits)
4474{
4475 char buf[512];
4477 QString title;
4479
4480 if (!punits || unit_list_size(punits) == 0) {
4481 return;
4482 }
4483
4484 ask = new hud_message_box(gui()->central_wdg);
4485
4486 punit_ids = new QVector<int>();
4488 punit_ids->push_back(punit->id);
4490
4491 if (!get_units_upgrade_info(buf, sizeof(buf), punits)) {
4492 title = _("Upgrade Unit!");
4493 ask->setStandardButtons(QMessageBox::Ok);
4494 } else {
4495 title = _("Upgrade Obsolete Units");
4496 ask->setStandardButtons(QMessageBox::Cancel | QMessageBox::Ok);
4497 ask->setDefaultButton(QMessageBox::Cancel);
4498 }
4499 ask->set_text_title(buf, title);
4500 ask->setAttribute(Qt::WA_DeleteOnClose);
4501 QObject::connect(ask, &hud_message_box::accepted, [=]() {
4502 std::unique_ptr<QVector<int>> uptr(punit_ids);
4503 struct unit *punit;
4504
4505 for (int id : *uptr) {
4507 if (punit) {
4509 }
4510 }
4511 });
4512 ask->show();
4513}
4514
4515/***********************************************************************/
4519{
4520 QPoint p, final_p;
4521
4523 utile = ptile;
4524 pix = nullptr;
4525 show_line = 0;
4526 highligh_num = -1;
4527 ufont.setItalic(true);
4529 update_units();
4530 h_pix = nullptr;
4531 create_pixmap();
4532 p = mapFromGlobal(QCursor::pos());
4533 cw = new close_widget(this);
4534 setMouseTracking(true);
4535 final_p.setX(p.x());
4536 final_p.setY(p.y());
4537 if (p.x() + width() > parentWidget()->width()) {
4538 final_p.setX(parentWidget()->width() - width());
4539 }
4540 if (p.y() - height() < 0) {
4541 final_p.setY(height());
4542 }
4543 move(final_p.x(), final_p.y() - height());
4544 setFocus();
4545 /* Build fails with qt5 connect style for static functions
4546 * Qt5.2 so dont update */
4547 QTimer::singleShot(10, this, SLOT(update_img()));
4548}
4549
4550/***********************************************************************/
4554{
4555 delete h_pix;
4556 delete pix;
4557 delete cw;
4558}
4559
4560/***********************************************************************/
4564{
4565 int a;
4566 int x, y, i;
4569 QImage img;
4571 QPainter p;
4572 QPen pen;
4573 QPixmap pixc;
4574 QPixmap *pixp;
4576 QRect crop;
4577 struct canvas *unit_pixmap;
4578 struct unit *punit;
4579 float isosize;
4580
4581 if (pix != nullptr) {
4582 delete pix;
4583 pix = nullptr;
4584 };
4585 isosize = 0.7;
4587 isosize = 0.5;
4588 }
4589
4590 update_units();
4591 if (unit_list.count() > 0) {
4595 } else {
4598 }
4599 more = false;
4600 if (h_pix != nullptr) {
4601 delete h_pix;
4602 }
4603 h_pix = new QPixmap(item_size.width(), item_size.height());
4604 h_pix->fill(palette().color(QPalette::HighlightedText));
4605 if (unit_count < 5) {
4606 row_count = 1;
4607 pix = new QPixmap((unit_list.size()) * item_size.width(),
4608 item_size.height());
4609 } else if (unit_count < 9) {
4610 row_count = 2;
4611 pix = new QPixmap(4 * item_size.width(), 2 * item_size.height());
4612 } else {
4613 row_count = 3;
4614 if (unit_count > 12) {
4615 more = true;
4616 }
4617 pix = new QPixmap(4 * item_size.width(), 3 * item_size.height());
4618 }
4619 pix->fill(Qt::transparent);
4620 foreach(punit, unit_list) {
4623 unit_pixmap->map_pixmap.fill(Qt::transparent);
4624 put_unit(punit, unit_pixmap, 1.0, 0, 0);
4625 img = unit_pixmap->map_pixmap.toImage();
4627 cropped_img = img.copy(crop);
4631 Qt::KeepAspectRatio,
4632 Qt::SmoothTransformation);
4633 } else {
4636 Qt::KeepAspectRatio,
4637 Qt::SmoothTransformation);
4638 }
4639 pixc = QPixmap::fromImage(img);
4640 pixp = new QPixmap(pixc);
4641 pix_list.push_back(pixp);
4643 }
4644 a = qMin(item_size.width() / 4, 12);
4645 x = 0, y = -item_size.height(), i = -1;
4646 p.begin(pix);
4647 ufont.setPixelSize(a);
4648 p.setFont(ufont);
4649 pen.setColor(palette().color(QPalette::Text));
4650 p.setPen(pen);
4651
4652 while (!pix_list.isEmpty()) {
4653 tmp_pix = pix_list.takeFirst();
4654 i++;
4655 if (i % 4 == 0) {
4656 x = 0;
4657 y = y + item_size.height();
4658 }
4659 punit = unit_list.at(i);
4660 Q_ASSERT(punit != nullptr);
4661
4662 if (i == highligh_num) {
4663 p.drawPixmap(x, y, *h_pix);
4664 p.drawPixmap(x, y, *tmp_pix);
4665 } else {
4666 p.drawPixmap(x, y, *tmp_pix);
4667 }
4668
4670 int rate, f;
4671 QString str;
4672
4674 f = ((punit->fuel) - 1);
4677 str = str + "(" + QString(move_points_text((rate * f)
4678 + punit->moves_left, false)) + ")";
4679 }
4680 // TRANS: MP = Movement points
4681 str = QString(_("MP:")) + str;
4682 p.drawText(x, y + item_size.height() - 4, str);
4683 }
4684
4685 x = x + item_size.width();
4686 delete tmp_pix;
4687 }
4688 p.end();
4689 setFixedWidth(pix->width() + 20);
4690 setFixedHeight(pix->height() + 2 * (fm.height() + 6));
4691 qDeleteAll(pix_list.begin(), pix_list.end());
4692 }
4693}
4694
4695/***********************************************************************/
4699{
4700 int a, b;
4701 int old_h;
4703 QPoint pos = event->pos();
4704 int x = pos.x();
4705 int y = pos.y();
4706
4708 highligh_num = -1;
4709 if (x > width() - 11
4710 || y > height() - fm.height() - 5
4711 || y < fm.height() + 3 || x < 11) {
4712 // Do nothing if mouse is on border, just skip next if
4713 } else if (row_count > 0) {
4714 a = (x - 10) / item_size.width();
4715 b = (y - fm.height() - 3) / item_size.height();
4716 highligh_num = b * 4 + a;
4717 }
4718 if (old_h != highligh_num) {
4719 create_pixmap();
4720 update();
4721 }
4722}
4723
4724/***********************************************************************/
4730{
4731 struct unit *punit;
4732 if (event->button() == Qt::RightButton) {
4733 was_destroyed = true;
4734 close();
4735 destroy();
4736 }
4737 if (event->button() == Qt::LeftButton && highligh_num != -1) {
4738 update_units();
4739 if (highligh_num >= unit_list.count()) {
4740 return;
4741 }
4744 was_destroyed = true;
4745 close();
4746 destroy();
4747 }
4748}
4749
4750/***********************************************************************/
4755{
4756 create_pixmap();
4757 update();
4758}
4759
4760/***********************************************************************/
4764{
4766 int h, i;
4767 int *f_size;
4768 QPen pen;
4769 QString str, str2;
4770 struct unit *punit;
4771 int point_size = info_font.pointSize();
4772 int pixel_size = info_font.pixelSize();
4773
4774 if (point_size < 0) {
4775 f_size = &pixel_size;
4776 } else {
4777 f_size = &point_size;
4778 }
4779 if (highligh_num != -1 && highligh_num < unit_list.count()) {
4780 struct astring addition = ASTRING_INIT;
4781
4784
4785 // TRANS: HP - hit points
4786 str2 = QString(_("%1 HP:%2/%3")).arg(QString(astr_str(&addition)),
4787 QString::number(punit->hp),
4788 QString::number(unit_type_get(punit)->hp));
4790 }
4791 str = QString(PL_("%1 unit", "%1 units",
4793 .arg(unit_list_size(utile->units));
4794 for (i = *f_size; i > 4; i--) {
4795 if (point_size < 0) {
4796 info_font.setPixelSize(i);
4797 } else {
4798 info_font.setPointSize(i);
4799 }
4801 if (10 + qfm.horizontalAdvance(str2) < width()) {
4802 break;
4803 }
4804 }
4805 h = fm.height();
4806 if (pix != nullptr) {
4807 painter->drawPixmap(10, h + 3, *pix);
4808 pen.setColor(palette().color(QPalette::Text));
4809 painter->setPen(pen);
4810 painter->setFont(info_font);
4811 painter->drawText(10, h, str);
4812 if (highligh_num != -1 && highligh_num < unit_list.count()) {
4813 painter->drawText(10, height() - 5, str2);
4814 }
4815 // Draw scroll
4816 if (more) {
4817 int maxl = ((unit_count - 1) / 4) + 1;
4818 float page_height = 3.0f / maxl;
4819 float page_start = (static_cast<float>(show_line)) / maxl;
4820 pen.setColor(palette().color(QPalette::HighlightedText));
4821 painter->setBrush(palette().color(QPalette::HighlightedText).darker());
4822 painter->setPen(palette().color(QPalette::HighlightedText).darker());
4823 painter->drawRect(pix->width() + 10, h, 8, h + pix->height());
4824 painter->setPen(pen);
4825 painter->drawRoundedRect(pix->width() + 10,
4826 h + page_start * pix->height(),
4827 8, h + page_height * pix->height(), 2, 2);
4828 }
4829 }
4830 if (point_size < 0) {
4831 info_font.setPixelSize(*f_size);
4832 } else {
4833 info_font.setPointSize(*f_size);
4834 }
4835 cw->put_to_corner();
4836}
4837
4838/***********************************************************************/
4842{
4844
4845 painter.begin(this);
4846 paint(&painter, event);
4847 painter.end();
4848}
4849
4850/***********************************************************************/
4855{
4856 was_destroyed = true;
4857 close();
4858 destroy();
4859}
4860
4861/***********************************************************************/
4865{
4866 int i = 1;
4867 struct unit_list *punit_list;
4868
4869 unit_count = 0;
4870 if (utile == nullptr) {
4871 struct unit *punit = head_of_units_in_focus();
4872 if (punit) {
4874 }
4875 }
4876 unit_list.clear();
4877 if (utile != nullptr) {
4879 if (punit_list != nullptr) {
4881 unit_count++;
4882 if (i > show_line * 4)
4883 unit_list.push_back(punit);
4884 i++;
4886 }
4887 }
4888 if (unit_list.count() == 0) {
4889 close();
4890 }
4891}
4892
4893/***********************************************************************/
4897{
4898 gui()->mapview_wdg->setFocus();
4899 QWidget::closeEvent(event);
4900}
4901
4902/***********************************************************************/
4906{
4907 int nr;
4908
4909 if (!more && utile == nullptr) {
4910 return;
4911 }
4912 nr = qCeil(static_cast<qreal>(unit_list_size(utile->units)) / 4) - 3;
4913 if (event->angleDelta().y() < 0) {
4914 show_line++;
4916 } else {
4917 show_line--;
4918 show_line = qMax(0, show_line);
4919 }
4920 update_units();
4921 create_pixmap();
4922 update();
4923 event->accept();
4924}
4925
4926/***********************************************************************/
4930{
4931 if (event->key() == Qt::Key_Escape) {
4932 was_destroyed = true;
4933 close();
4934 destroy();
4935 }
4936 QWidget::keyPressEvent(event);
4937}
4938
4939/***********************************************************************/
4946
4947/***********************************************************************/
4954
4955/***********************************************************************/
4960{
4961 // Just tell the client common code to handle this.
4962 return false;
4963}
4964
4965/***********************************************************************/
4968bool qtg_request_transport(struct unit *pcargo, struct tile *ptile)
4969{
4970 int tcount;
4972 struct unit_list *potential_transports = unit_list_new();
4973#ifndef FREECIV_NDEBUG
4975#endif
4976
4980 }
4982
4984
4985 if (tcount == 0) {
4986 fc_assert(best_transport == nullptr);
4988
4989 return false; // Unit was not handled here.
4990 } else if (tcount == 1) {
4991 // There's exactly one potential transport - use it automatically
4994
4996
4997 return true;
4998 }
4999
5000 hul = new hud_unit_loader(pcargo, ptile);
5001 hul->show_me();
5002 return true;
5003}
5004
5005/***********************************************************************/
5009void qtg_popup_combat_info(int attacker_unit_id, int defender_unit_id,
5010 int attacker_hp, int defender_hp,
5011 bool make_att_veteran, bool make_def_veteran)
5012{
5013 if (gui()->qt_settings.show_battle_log) {
5014 hud_unit_combat *huc = new hud_unit_combat(attacker_unit_id,
5015 defender_unit_id,
5016 attacker_hp, defender_hp,
5017 make_att_veteran,
5018 make_def_veteran,
5019 gui()->battlelog_wdg->scale,
5020 gui()->battlelog_wdg);
5021
5022 gui()->battlelog_wdg->add_combat_info(huc);
5023 gui()->battlelog_wdg->show();
5024 }
5025}
5026
5027/**********************************************************************/
5031 struct act_confirmation_data *data)
5032{
5033 hud_message_box *ask = new hud_message_box(gui()->central_wdg);
5034
5035 ask->setStandardButtons(QMessageBox::Cancel | QMessageBox::Ok);
5036 ask->setDefaultButton(QMessageBox::Cancel);
5037 ask->set_text_title(body, hdr);
5038 ask->setAttribute(Qt::WA_DeleteOnClose);
5039 QObject::connect(ask, &hud_message_box::accepted, [=]() {
5041 });
5042 QObject::connect(ask, &hud_message_box::rejected, [=]() {
5044 });
5045
5046 ask->show();
5047}
5048
5049/***********************************************************************/
5053 struct act_confirmation_data *data)
5054{
5056
5057 hdr = QString(_("Are you sure you want to do %1?")).
5059
5060 if (expl != nullptr) {
5062 }
5063
5065}
5066
5067/**********************************************************************/
5070void qtg_popup_image(const char *tag)
5071{
5072 struct sprite *spr = load_popup_sprite(tag);
5073
5074 if (spr != nullptr) {
5075 QDialog *win = new QDialog(gui());
5076 QVBoxLayout *layout = new QVBoxLayout(win);
5077 QPixmap *pm = new QPixmap(*spr->pm);
5078 QLabel *lbl = new QLabel;
5079 int width, height;
5080
5082 win->setFixedSize(width, height);
5083 lbl->setPixmap(*pm);
5084 layout->addWidget(lbl);
5085 win->setLayout(layout);
5086
5087 win->show();
5088
5090 } else {
5091 log_error(_("No image for tag \"%s\", requested by the server."), tag);
5092 }
5093}
const char * action_prepare_ui_name(action_id act_id, const char *mnemonic, const struct act_prob prob, const char *custom)
Definition actions.c:1333
const char * action_id_name_translation(action_id act_id)
Definition actions.c:1271
bool action_prob_possible(const struct act_prob probability)
Definition actions.c:5317
static struct action * action_by_number(action_id act_id)
Definition actions.h:400
#define action_iterate_end
Definition actions.h:218
#define action_id_get_actor_kind(act_id)
Definition actions.h:413
#define action_iterate(_act_)
Definition actions.h:214
#define action_id_get_target_kind(act_id)
Definition actions.h:417
#define ACTION_NONE
Definition actions.h:59
void astr_free(struct astring *astr)
Definition astring.c:148
void astr_set(struct astring *astr, const char *format,...)
Definition astring.c:251
#define str
Definition astring.c:76
static const char * astr_str(const struct astring *astr) fc__attribute((nonnull(1)))
Definition astring.h:93
#define ASTRING_INIT
Definition astring.h:44
void audio_restart(const char *soundset_name, const char *musicset_name)
Definition audio.c:378
#define BV_CLR(bv, bit)
Definition bitvector.h:94
QRect zealous_crop_rect(QImage &p)
Definition canvas.cpp:419
void qtg_canvas_free(struct canvas *store)
Definition canvas.cpp:48
struct canvas * qtg_canvas_create(int width, int height)
Definition canvas.cpp:36
struct canvas int int struct sprite int int int int height
Definition canvas_g.h:44
struct canvas int int struct sprite int int int width
Definition canvas_g.h:44
void output_window_append(const struct ft_color color, const char *featured_text)
const char * city_improvement_name_translation(const struct city *pcity, const struct impr_type *pimprove)
Definition city.c:666
const char * city_name_get(const struct city *pcity)
Definition city.c:1157
#define INCITE_IMPOSSIBLE_COST
Definition city.h:94
#define city_owner(_pcity_)
Definition city.h:564
#define city_built_iterate(_pcity, _p)
Definition city.h:842
#define city_built_iterate_end
Definition city.h:848
void qtg_real_city_dialog_popup(struct city *pcity)
Definition citydlg.cpp:3865
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:1711
void prev_unit()
Definition dialogs.cpp:1628
QVBoxLayout * layout
Definition dialogs.h:263
struct unit * targeted_unit
Definition dialogs.h:286
void unstack_all_buttons()
Definition dialogs.cpp:1728
Choice_dialog_button * get_identified_button(const int id)
Definition dialogs.cpp:1540
QPushButton * target_unit_button
Definition dialogs.h:262
void set_layout()
Definition dialogs.cpp:1446
void update_dialog(const struct act_prob *act_probs)
Definition dialogs.cpp:1657
QList< Choice_dialog_button * > last_buttons_stack
Definition dialogs.h:266
void next_unit()
Definition dialogs.cpp:1588
QVBoxLayout * get_layout()
Definition dialogs.cpp:1532
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:1675
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:1694
void add_item(QString title, pfcn_void func, QVariant data1, QVariant data2, QString tool_tip, const int button_id)
Definition dialogs.cpp:1488
void put_to_corner()
Definition mapview.cpp:503
void disband_clicked()
Definition dialogs.cpp:4031
disband_box(struct unit_list *punits, QWidget *parent=0)
Definition dialogs.cpp:4005
struct unit_list * cpunits
Definition dialogs.h:97
choice_dialog * opened_dialog
Definition fc_client.h:218
choice_dialog * get_diplo_dialog()
Definition dialogs.cpp:4950
void set_diplo_dialog(choice_dialog *widget)
Definition dialogs.cpp:4942
static fc_font * instance()
Definition fonts.cpp:41
QFont * get_font(QString name)
Definition fonts.cpp:63
QPixmap * get_pixmap(const QString &id)
static fc_icons * instance()
bool was_destroyed
Definition mapview.h:176
void close_dlg()
Definition gotodlg.cpp:511
int set_text_title(QString s1, QString s2, bool return_exec=false)
QString qheadline
Definition dialogs.h:193
void restart()
Definition dialogs.cpp:910
close_widget * cw
Definition dialogs.h:189
void mouseReleaseEvent(QMouseEvent *event)
Definition dialogs.cpp:1003
QFont small_font
Definition dialogs.h:195
QString qcaption
Definition dialogs.h:192
notify_dialog(const char *caption, const char *headline, const char *lines, QWidget *parent=0)
Definition dialogs.cpp:877
void calc_size(int &x, int &y)
Definition dialogs.cpp:938
void paintEvent(QPaintEvent *paint_event)
Definition dialogs.cpp:957
QPoint cursor
Definition dialogs.h:196
void mouseMoveEvent(QMouseEvent *event)
Definition dialogs.cpp:993
virtual void update_menu()
Definition dialogs.cpp:1011
void mousePressEvent(QMouseEvent *event)
Definition dialogs.cpp:980
QStringList qlist
Definition dialogs.h:194
QPushButton * close_but
Definition dialogs.h:113
notify_goto(const char *headline, const char *lines, const struct text_tag_list *tags, struct tile *ptile, QWidget *parent)
Definition dialogs.cpp:1112
QPushButton * goto_but
Definition dialogs.h:111
void inspect_city()
Definition dialogs.cpp:1155
struct tile * gtile
Definition dialogs.h:114
QPushButton * inspect_but
Definition dialogs.h:112
void goto_tile()
Definition dialogs.cpp:1146
action_id vs_unit
Definition dialogs.h:60
static qdef_act * action()
Definition dialogs.cpp:1040
action_id vs_city_get()
Definition dialogs.cpp:1078
static qdef_act * m_instance
Definition dialogs.h:58
static void drop()
Definition dialogs.cpp:1051
action_id vs_city
Definition dialogs.h:59
void vs_city_set(int i)
Definition dialogs.cpp:1062
void vs_unit_set(int i)
Definition dialogs.cpp:1070
action_id vs_unit_get()
Definition dialogs.cpp:1086
QPoint point
Definition dialogs.h:81
void paintEvent(QPaintEvent *event)
Definition dialogs.cpp:353
QPixmap close_pix
Definition dialogs.h:83
void reactivate()
Definition dialogs.cpp:345
void mouseMoveEvent(QMouseEvent *event)
Definition dialogs.cpp:394
int titlebar_height
Definition dialogs.h:80
void mousePressEvent(QMouseEvent *event)
Definition dialogs.cpp:404
void mouseReleaseEvent(QMouseEvent *event)
Definition dialogs.cpp:424
qfc_dialog(QWidget *parent)
Definition dialogs.cpp:333
bool moving_now
Definition dialogs.h:82
int selected_style
Definition dialogs.h:164
QComboBox * leader_name
Definition dialogs.h:135
void random_pressed()
Definition dialogs.cpp:1102
int last_index
Definition dialogs.h:166
QTableWidget * selected_nation_tabs
Definition dialogs.h:134
QPushButton * random_button
Definition dialogs.h:143
void refresh()
Definition dialogs.cpp:613
void style_selected(const QItemSelection &selected)
Definition dialogs.cpp:806
void nationset_changed(int index)
Definition dialogs.cpp:1167
int selected_nation
Definition dialogs.h:163
void ok_pressed()
Definition dialogs.cpp:839
void leader_selected(int index)
Definition dialogs.cpp:824
QPushButton * ok_button
Definition dialogs.h:142
QTextEdit * description
Definition dialogs.h:141
void set_index(int index)
Definition dialogs.cpp:696
QComboBox * qnation_set
Definition dialogs.h:136
QRadioButton * is_male
Definition dialogs.h:138
QButtonGroup * sex_buttons
Definition dialogs.h:137
void update_nationset_combo()
Definition dialogs.cpp:663
QTableWidget * styles
Definition dialogs.h:140
void group_selected(const QItemSelection &selected)
Definition dialogs.cpp:679
struct player * tplayer
Definition dialogs.h:165
races_dialog(struct player *pplayer, QWidget *parent=0)
Definition dialogs.cpp:433
QRadioButton * is_female
Definition dialogs.h:139
QTableWidget * nation_tabs
Definition dialogs.h:132
QGridLayout * main_layout
Definition dialogs.h:131
void nation_selected(const QItemSelection &selected)
Definition dialogs.cpp:756
void cancel_pressed()
Definition dialogs.cpp:1094
QPixmap * h_pix
Definition dialogs.h:206
QFont ufont
Definition dialogs.h:210
QFont info_font
Definition dialogs.h:211
void closeEvent(QCloseEvent *event)
Definition dialogs.cpp:4896
void update_img()
Definition dialogs.cpp:4754
int show_line
Definition dialogs.h:233
void mouseMoveEvent(QMouseEvent *event)
Definition dialogs.cpp:4698
int highligh_num
Definition dialogs.h:234
void paint(QPainter *painter, QPaintEvent *event)
Definition dialogs.cpp:4763
void update_menu()
Definition dialogs.cpp:4854
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:4518
void update_units()
Definition dialogs.cpp:4864
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:4841
void create_pixmap()
Definition dialogs.cpp:4563
void wheelEvent(QWheelEvent *event)
Definition dialogs.cpp:4905
void keyPressEvent(QKeyEvent *event)
Definition dialogs.cpp:4929
void mousePressEvent(QMouseEvent *event)
Definition dialogs.cpp:4729
close_widget * cw
Definition dialogs.h:213
char music_set_name[512]
bool client_is_global_observer(void)
struct civclient client
enum client_states client_state(void)
char sound_set_name[512]
#define client_player()
@ C_S_RUNNING
Definition client_main.h:47
void client_unit_init_act_prob_cache(struct unit *punit)
Definition climisc.c:1264
char * incite_cost
Definition comments.c:77
void action_selection_no_longer_in_progress(const int old_actor_id)
Definition control.c:1063
void request_unit_load(struct unit *pcargo, struct unit *ptrans, struct tile *ptile)
Definition control.c:2168
void unit_focus_set(struct unit *punit)
Definition control.c:518
void request_do_action(action_id action, int actor_id, int target_id, int sub_tgt, const char *name)
Definition control.c:1742
void request_unit_disband(struct unit *punit)
Definition control.c:2087
void request_action_details(action_id action, int actor_id, int target_id)
Definition control.c:1810
void request_new_unit_activity_targeted(struct unit *punit, enum unit_activity act, struct extra_type *tgt)
Definition control.c:1950
void action_confirmation(struct act_confirmation_data *data, bool confirm)
Definition control.c:1778
void action_decision_clear_want(const int old_actor_id)
Definition control.c:1092
void key_unit_wait(void)
Definition control.c:3554
struct unit * head_of_units_in_focus(void)
Definition control.c:410
void request_unit_upgrade(struct unit *punit)
Definition control.c:2118
void action_selection_next_in_focus(const int old_actor_id)
Definition control.c:1104
bool qtg_handmade_scenario_warning()
Definition dialogs.cpp:4959
static void attack(QVariant data1, QVariant data2)
Definition dialogs.cpp:3055
static void wipe_units(QVariant data1, QVariant data2)
Definition dialogs.cpp:2776
char forced_tileset_name[512]
int action_selection_target_extra(void)
Definition dialogs.cpp:4257
static void destroy_city(QVariant data1, QVariant data2)
Definition dialogs.cpp:3432
static void spy_sabotage_unit(QVariant data1, QVariant data2)
Definition dialogs.cpp:2484
static void pillage(QVariant data1, QVariant data2)
Definition dialogs.cpp:2916
static void caravan_marketplace(QVariant data1, QVariant data2)
Definition dialogs.cpp:1742
static void clean(QVariant data1, QVariant data2)
Definition dialogs.cpp:2936
static void spy_steal_shared(QVariant data1, QVariant data2, action_id act_id)
Definition dialogs.cpp:3190
static void spy_sabotage(QVariant data1, QVariant data2)
Definition dialogs.cpp:3871
int action_selection_target_tile(void)
Definition dialogs.cpp:4240
static void spy_investigate(QVariant data1, QVariant data2)
Definition dialogs.cpp:3552
static void act_sel_wait(QVariant data1, QVariant data2)
Definition dialogs.cpp:1911
static void nuke_units(QVariant data1, QVariant data2)
Definition dialogs.cpp:2752
int action_selection_actor_unit(void)
Definition dialogs.cpp:4206
static void capture_units(QVariant data1, QVariant data2)
Definition dialogs.cpp:2788
static void road(QVariant data1, QVariant data2)
Definition dialogs.cpp:2956
static bool is_race_dialog_open
Definition dialogs.cpp:191
static void transport_embark4(QVariant data1, QVariant data2)
Definition dialogs.cpp:2596
bool try_default_unit_action(QVariant q1, QVariant q2)
Definition dialogs.cpp:1553
static void fortify(QVariant data1, QVariant data2)
Definition dialogs.cpp:2409
static void transport_board(QVariant data1, QVariant data2)
Definition dialogs.cpp:2530
static void diplomat_bribe_unit(QVariant data1, QVariant data2)
Definition dialogs.cpp:2449
static void spy_sabotage_unit_esc(QVariant data1, QVariant data2)
Definition dialogs.cpp:2496
static void disband_unit(QVariant data1, QVariant data2)
Definition dialogs.cpp:2397
static void spy_steal_gold(QVariant data1, QVariant data2)
Definition dialogs.cpp:3447
void popdown_players_report()
Definition plrdlg.cpp:1197
static void conquer_city_shrink2(QVariant data1, QVariant data2)
Definition dialogs.cpp:1868
static void spy_escape(QVariant data1, QVariant data2)
Definition dialogs.cpp:3507
static void mine(QVariant data1, QVariant data2)
Definition dialogs.cpp:2998
void popup_musicset_suggestion_dialog(void)
Definition dialogs.cpp:4117
static void spy_steal_gold_esc(QVariant data1, QVariant data2)
Definition dialogs.cpp:3462
static void diplomat_embassy(QVariant data1, QVariant data2)
Definition dialogs.cpp:3537
void unit_select_dialog_popup(struct tile *ptile)
Definition dialogs.cpp:1252
void popup_upgrade_dialog(struct unit_list *punits)
Definition dialogs.cpp:4473
void update_nationset_combo()
Definition dialogs.cpp:1272
void action_selection_close(void)
Definition dialogs.cpp:4411
static void cultivate(QVariant data1, QVariant data2)
Definition dialogs.cpp:2886
static void paradrop_enter(QVariant data1, QVariant data2)
Definition dialogs.cpp:3145
void races_update_pickable(bool nationset_change)
Definition dialogs.cpp:1282
int action_selection_target_city(void)
Definition dialogs.cpp:4223
static void spy_steal_something(QVariant data1, QVariant data2)
Definition dialogs.cpp:3280
#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:3357
static void transport_board2(QVariant data1, QVariant data2)
Definition dialogs.cpp:2541
void show_tech_gained_dialog(Tech_type_id tech)
Definition dialogs.cpp:4425
static void base(QVariant data1, QVariant data2)
Definition dialogs.cpp:2977
static void spy_nuke_city_esc(QVariant data1, QVariant data2)
Definition dialogs.cpp:3402
void popup_soundset_suggestion_dialog(void)
Definition dialogs.cpp:4092
static void enter_hut2(QVariant data1, QVariant data2)
Definition dialogs.cpp:2707
void popup_races_dialog(struct player *pplayer)
Definition dialogs.cpp:1227
static void expel_unit(QVariant data1, QVariant data2)
Definition dialogs.cpp:2800
static void paradrop_frighten(QVariant data1, QVariant data2)
Definition dialogs.cpp:3115
static void diplomat_sabotage(QVariant data1, QVariant data2)
Definition dialogs.cpp:3582
void popup_disband_dialog(struct unit_list *punits)
Definition dialogs.cpp:4051
static action_id get_non_targeted_action_id(action_id tgt_action_id)
Definition dialogs.cpp:2292
static void homeless(QVariant data1, QVariant data2)
Definition dialogs.cpp:2435
static void caravan_help_build(QVariant data1, QVariant data2)
Definition dialogs.cpp:1772
void qtg_popup_image(const char *tag)
Definition dialogs.cpp:5070
static void bombard(QVariant data1, QVariant data2)
Definition dialogs.cpp:2812
void popup_bribe_stack_dialog(struct unit *actor, struct tile *ttile, int cost, const struct action *paction)
Definition dialogs.cpp:3804
void popdown_races_dialog(void)
Definition dialogs.cpp:1241
void popup_tileset_suggestion_dialog(void)
Definition dialogs.cpp:4061
void revolution_response(struct government *gov)
Definition dialogs.cpp:1926
void popdown_economy_report()
static void join_city(QVariant data1, QVariant data2)
Definition dialogs.cpp:3175
static void spy_request_sabotage_list(QVariant data1, QVariant data2)
Definition dialogs.cpp:3320
static void popup_act_confirmation_dialog(QString hdr, QString body, struct act_confirmation_data *data)
Definition dialogs.cpp:5030
static void unit_disband_recover(QVariant data1, QVariant data2)
Definition dialogs.cpp:1787
static void spy_steal(QVariant data1, QVariant data2)
Definition dialogs.cpp:3264
static void airlift(QVariant data1, QVariant data2)
Definition dialogs.cpp:1838
void popup_pillage_dialog(struct unit *punit, bv_extras extras)
Definition dialogs.cpp:3972
static void transport_load3(QVariant data1, QVariant data2)
Definition dialogs.cpp:2640
static void bombard_lethal(QVariant data1, QVariant data2)
Definition dialogs.cpp:2848
static void plant(QVariant data1, QVariant data2)
Definition dialogs.cpp:2901
static void diplomat_bribe_stack(QVariant data1, QVariant data2)
Definition dialogs.cpp:2467
static void nuke(QVariant data1, QVariant data2)
Definition dialogs.cpp:3040
static void disembark2(QVariant data1, QVariant data2)
Definition dialogs.cpp:2677
static void transport_unload(QVariant data1, QVariant data2)
Definition dialogs.cpp:2607
void qtg_request_action_confirmation(const char *expl, struct act_confirmation_data *data)
Definition dialogs.cpp:5052
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:4288
void popdown_science_report()
static void transport_load2(QVariant data1, QVariant data2)
Definition dialogs.cpp:2629
static void diplomat_steal(QVariant data1, QVariant data2)
Definition dialogs.cpp:3612
static void unit_upgrade(QVariant data1, QVariant data2)
Definition dialogs.cpp:1817
bool popup_theme_suggestion_dialog(const char *theme_name)
Definition dialogs.cpp:4142
static void enter_hut(QVariant data1, QVariant data2)
Definition dialogs.cpp:2692
static void spy_request_strike_bld_list(QVariant data1, QVariant data2)
Definition dialogs.cpp:3303
static void diplomat_incite_escape(QVariant data1, QVariant data2)
Definition dialogs.cpp:3660
static void found_city(QVariant data1, QVariant data2)
Definition dialogs.cpp:2860
static void diplomat_investigate(QVariant data1, QVariant data2)
Definition dialogs.cpp:3567
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:5009
static void bombard3(QVariant data1, QVariant data2)
Definition dialogs.cpp:2836
static void transport_deboard(QVariant data1, QVariant data2)
Definition dialogs.cpp:2651
static void diplomat_incite(QVariant data1, QVariant data2)
Definition dialogs.cpp:3642
static void paradrop_conquer(QVariant data1, QVariant data2)
Definition dialogs.cpp:3100
void popdown_endgame_report()
static void diplomat_steal_esc(QVariant data1, QVariant data2)
Definition dialogs.cpp:3627
static bool is_more_user_input_needed
Definition dialogs.cpp:196
static void bombard2(QVariant data1, QVariant data2)
Definition dialogs.cpp:2824
void popup_incite_dialog(struct unit *actor, struct city *tcity, int cost, const struct action *paction)
Definition dialogs.cpp:3694
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:3417
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:1853
static void diplomat_sabotage_esc(QVariant data1, QVariant data2)
Definition dialogs.cpp:3597
void popdown_units_report()
static void transport_embark2(QVariant data1, QVariant data2)
Definition dialogs.cpp:2574
static void spy_nuke_city(QVariant data1, QVariant data2)
Definition dialogs.cpp:3387
void unit_select_dialog_update_real(void *unused)
Definition dialogs.cpp:1264
static void spy_steal_esc(QVariant data1, QVariant data2)
Definition dialogs.cpp:3272
static void paradrop(QVariant data1, QVariant data2)
Definition dialogs.cpp:3085
static void suicide_attack(QVariant data1, QVariant data2)
Definition dialogs.cpp:3070
void races_toggles_set_sensitive(void)
Definition dialogs.cpp:1293
static void transport_load(QVariant data1, QVariant data2)
Definition dialogs.cpp:2618
static action_id get_production_targeted_action_id(action_id tgt_action_id)
Definition dialogs.cpp:2315
static void paradrop_frighten_conquer(QVariant data1, QVariant data2)
Definition dialogs.cpp:3130
static void convert_unit(QVariant data1, QVariant data2)
Definition dialogs.cpp:2423
static bool did_not_decide
Definition dialogs.cpp:200
static void spy_poison_esc(QVariant data1, QVariant data2)
Definition dialogs.cpp:3372
static void pillage_something(QVariant data1, QVariant data2)
Definition dialogs.cpp:3851
static void spy_request_sabotage_esc_list(QVariant data1, QVariant data2)
Definition dialogs.cpp:3338
void show_tileset_error(bool fatal, const char *tset_name, const char *msg)
Definition dialogs.cpp:4432
static void transform_terrain(QVariant data1, QVariant data2)
Definition dialogs.cpp:2871
#define BUTTON_CANCEL
Definition dialogs.cpp:72
static void conquer_extras(QVariant data1, QVariant data2)
Definition dialogs.cpp:1883
static void regular_move(QVariant data1, QVariant data2)
Definition dialogs.cpp:3678
static void heal_unit2(QVariant data1, QVariant data2)
Definition dialogs.cpp:2519
static void transport_board3(QVariant data1, QVariant data2)
Definition dialogs.cpp:2552
static void spy_embassy(QVariant data1, QVariant data2)
Definition dialogs.cpp:3522
static races_dialog * race_dialog
Definition dialogs.cpp:190
static void frighten_hut2(QVariant data1, QVariant data2)
Definition dialogs.cpp:2737
static void conquer_extras2(QVariant data1, QVariant data2)
Definition dialogs.cpp:1897
static void frighten_hut(QVariant data1, QVariant data2)
Definition dialogs.cpp:2722
bool qtg_request_transport(struct unit *pcargo, struct tile *ptile)
Definition dialogs.cpp:4968
int action_selection_target_unit(void)
Definition dialogs.cpp:4274
static void irrigate(QVariant data1, QVariant data2)
Definition dialogs.cpp:3019
static void transport_embark3(QVariant data1, QVariant data2)
Definition dialogs.cpp:2585
static void collect_ransom(QVariant data1, QVariant data2)
Definition dialogs.cpp:2764
static void heal_unit(QVariant data1, QVariant data2)
Definition dialogs.cpp:2508
void popdown_city_report()
Definition cityrep.cpp:1339
static void paradrop_enter_conquer(QVariant data1, QVariant data2)
Definition dialogs.cpp:3160
static void unit_home_city(QVariant data1, QVariant data2)
Definition dialogs.cpp:1802
static void transport_embark(QVariant data1, QVariant data2)
Definition dialogs.cpp:2563
bool try_default_city_action(QVariant q1, QVariant q2)
Definition dialogs.cpp:1571
static void keep_moving(QVariant data1, QVariant data2)
Definition dialogs.cpp:1919
static void spy_steal_maps_esc(QVariant data1, QVariant data2)
Definition dialogs.cpp:3492
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:2368
static void disembark1(QVariant data1, QVariant data2)
Definition dialogs.cpp:2662
void restart_notify_dialogs()
Definition dialogs.cpp:4151
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:2335
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:1757
void popdown_all_game_dialogs(void)
Definition dialogs.cpp:4167
static void spy_steal_maps(QVariant data1, QVariant data2)
Definition dialogs.cpp:3477
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id popup_bribe_unit_dialog
Definition dialogs_g.h:72
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit int const struct action *paction struct unit struct city const struct action *paction const char * expl
Definition dialogs_g.h:93
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit int const struct action *paction popup_sabotage_dialog
Definition dialogs_g.h:76
struct unit struct city struct unit * target_unit
Definition dialogs_g.h:55
popup_action_selection
Definition dialogs_g.h:54
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit * actor
Definition dialogs_g.h:72
struct unit * actor_unit
Definition dialogs_g.h:54
const char * caption
Definition dialogs_g.h:36
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs action_selection_no_longer_in_progress_gui_specific
Definition dialogs_g.h:68
const char const char * headline
Definition dialogs_g.h:37
popup_notify_dialog
Definition dialogs_g.h:36
struct unit struct city struct unit struct tile * target_tile
Definition dialogs_g.h:56
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit * punit
Definition dialogs_g.h:73
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit int const struct action *paction struct unit struct city * pcity
Definition dialogs_g.h:77
struct unit struct city * target_city
Definition dialogs_g.h:55
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit int cost
Definition dialogs_g.h:73
struct unit struct city struct unit struct tile struct extra_type * target_extra
Definition dialogs_g.h:56
int int id
Definition editgui_g.h:28
enum event_type event
Definition events.c:82
int extra_number(const struct extra_type *pextra)
Definition extras.c:161
struct extra_type * extra_by_number(int id)
Definition extras.c:183
static struct extra_type extras[MAX_EXTRA_TYPES]
Definition extras.c:31
const char * extra_name_translation(const struct extra_type *pextra)
Definition extras.c:194
#define extra_index(_e_)
Definition extras.h:183
#define EXTRA_NONE
Definition extras.h:85
int Tech_type_id
Definition fc_types.h:238
int action_id
Definition fc_types.h:250
int Government_type_id
Definition fc_types.h:242
#define IDENTITY_NUMBER_ZERO
Definition fc_types.h:94
#define PL_(String1, String2, n)
Definition fcintl.h:71
#define _(String)
Definition fcintl.h:67
const struct ft_color ftc_client
struct civ_game game
Definition game.c:62
struct world wld
Definition game.c:63
struct unit * game_unit_by_number(int id)
Definition game.c:115
struct city * game_city_by_number(int id)
Definition game.c:106
struct government * government_by_number(const Government_type_id gov)
Definition government.c:103
Government_type_id government_number(const struct government *pgovern)
Definition government.c:92
#define G_LAST
Definition government.h:50
int action_selection_target_extra(void)
static int actor_unit_id
static void diplomat_queue_handle_primary(void)
static void diplomat_queue_handle_secondary(void)
#define BUTTON_COUNT
void action_selection_refresh(struct unit *actor_unit, struct city *target_city, struct unit *target_unit, struct tile *target_tile, struct extra_type *target_extra, const struct act_prob *act_probs)
static PangoLayout * layout
Definition canvas.c:325
struct city * owner
Definition citydlg.c:226
static struct tile * pos
Definition finddlg.c:53
void popdown_help_dialog(void)
Definition helpdlg.c:186
const char * title
Definition repodlgs.c:1314
void(* pfcn_void)(QVariant, QVariant)
Definition dialogs.h:46
#define CAPTURE_DEFAULT_THIS
Definition gui_main.h:23
void nationset_changed(void)
Definition dialogs.c:3577
#define show(id)
Definition widget.h:235
void popup_revolution_dialog(void)
Definition dialogs.c:112
void helptext_nation(char *buf, size_t bufsz, struct nation_type *pnation, const char *user_text)
Definition helpdata.c:5132
Impr_type_id improvement_number(const struct impr_type *pimprove)
#define B_LAST
Definition improvement.h:42
get_token_fn_t func
Definition inputfile.c:128
#define fc_assert_msg(condition, message,...)
Definition log.h:182
#define fc_assert(condition)
Definition log.h:177
#define fc_assert_action(condition, action)
Definition log.h:188
@ LOG_ERROR
Definition log.h:31
#define log_error(message,...)
Definition log.h:104
int dsend_packet_unit_get_actions(struct connection *pc, int actor_unit_id, int target_unit_id, int target_tile_id, int target_extra_id, int request_kind)
int dsend_packet_nation_select_req(struct connection *pc, int player_no, Nation_type_id nation_no, bool is_male, const char *name, int style)
int dsend_packet_city_name_suggestion_req(struct connection *pc, int unit_id)
struct tile * index_to_tile(const struct civ_map *imap, int mindex)
Definition map.c:471
void put_unit(const struct unit *punit, struct canvas *pcanvas, float zoom, int canvas_x, int canvas_y)
void center_tile_mapcanvas(const struct tile *ptile)
static const void * body(MD5_CTX *ctx, const void *data, unsigned long size)
Definition md5.c:121
#define FC_FREE(ptr)
Definition mem.h:41
const char * move_points_text(int mp, bool reduce)
Definition movement.c:1066
static mpgui * gui
Definition mpgui_qt.cpp:53
const char *const notify_label
Definition fonts.h:28
Nation_type_id nation_number(const struct nation_type *pnation)
Definition nation.c:484
bool nation_leader_is_male(const struct nation_leader *pleader)
Definition nation.c:295
const char * nation_adjective_for_player(const struct player *pplayer)
Definition nation.c:169
const char * nation_adjective_translation(const struct nation_type *pnation)
Definition nation.c:149
struct nation_type * nation_by_number(const Nation_type_id nation)
Definition nation.c:472
int nation_set_index(const struct nation_set *pset)
Definition nation.c:698
bool is_nation_pickable(const struct nation_type *nation)
Definition nation.c:188
const struct nation_leader_list * nation_leaders(const struct nation_type *pnation)
Definition nation.c:231
const char * nation_set_name_translation(const struct nation_set *pset)
Definition nation.c:815
bool is_nation_playable(const struct nation_type *nation)
Definition nation.c:201
bool nation_is_in_group(const struct nation_type *pnation, const struct nation_group *pgroup)
Definition nation.c:1088
const char * nation_set_description(const struct nation_set *pset)
Definition nation.c:824
const char * nation_group_name_translation(const struct nation_group *pgroup)
Definition nation.c:1080
int nation_set_count(void)
Definition nation.c:690
struct nation_group * nation_group_by_number(int id)
Definition nation.c:999
struct nation_set * nation_set_by_rule_name(const char *name)
Definition nation.c:779
bool is_nation_group_hidden(struct nation_group *pgroup)
Definition nation.c:1051
struct nation_set * nation_set_by_setting_value(const char *setting)
Definition nation.c:853
const char * nation_leader_name(const struct nation_leader *pleader)
Definition nation.c:287
int nation_group_count(void)
Definition nation.c:929
const char * nation_set_rule_name(const struct nation_set *pset)
Definition nation.c:806
struct nation_style * style_of_nation(const struct nation_type *pnation)
Definition nation.c:670
#define nation_leader_list_iterate(leaderlist, pleader)
Definition nation.h:57
#define nation_sets_iterate_end
Definition nation.h:333
#define nation_sets_iterate(NAME_pset)
Definition nation.h:329
#define nations_iterate_end
Definition nation.h:364
#define nations_iterate(NAME_pnation)
Definition nation.h:361
#define nation_leader_list_iterate_end
Definition nation.h:59
const struct option_set * server_optset
Definition options.c:4369
bool option_str_set(struct option *poption, const char *str)
Definition options.c:977
const char * option_str_get(const struct option *poption)
Definition options.c:944
struct option * optset_option_by_name(const struct option_set *poptset, const char *name)
Definition options.c:482
#define REQEST_PLAYER_INITIATED
Definition packets.h:63
void start_revolution(void)
Definition packhand.c:2415
void set_government_choice(struct government *government)
Definition packhand.c:2401
char * lines
Definition packhand.c:133
int player_number(const struct player *pplayer)
Definition player.c:826
const char * research_advance_name_translation(const struct research *presearch, Tech_type_id tech)
Definition research.c:276
struct research * research_get(const struct player *pplayer)
Definition research.c:130
enum tech_state research_invention_state(const struct research *presearch, Tech_type_id tech)
Definition research.c:622
bool research_invention_gettable(const struct research *presearch, const Tech_type_id tech, bool allow_holes)
Definition research.c:696
const char * sex_name_translation(sex_t kind)
Definition sex.c:60
@ SEX_FEMALE
Definition sex.h:22
@ SEX_MALE
Definition sex.h:23
#define ARRAY_SIZE(x)
Definition shared.h:85
size_t size
Definition specvec.h:72
struct sprite int int y
Definition sprite_g.h:31
struct sprite int x
Definition sprite_g.h:31
struct sprite int int int int struct sprite int int float bool smooth get_sprite_dimensions
Definition sprite_g.h:36
QPixmap map_pixmap
Definition canvas.h:25
Definition city.h:318
struct packet_ruleset_control control
Definition game.h:83
struct packet_game_info info
Definition game.h:89
struct connection conn
Definition client_main.h:96
Definition colors.h:21
struct player * playing
Definition connection.h:151
Definition mapimg.c:367
Definition climisc.h:82
struct universal item
Definition climisc.h:83
struct player * player
Definition nation.h:118
bool tech_steal_allow_holes
char preferred_musicset[MAX_LEN_NAME]
char preferred_tileset[MAX_LEN_NAME]
char preferred_soundset[MAX_LEN_NAME]
int revolution_finishes
Definition player.h:273
char name[MAX_LEN_NAME]
Definition player.h:251
Definition menu.h:161
QPixmap * pm
Definition sprite.h:25
Definition tile.h:50
int index
Definition tile.h:51
struct unit_list * units
Definition tile.h:58
int move_rate
Definition unittype.h:524
Definition unit.h:139
int moves_left
Definition unit.h:151
int id
Definition unit.h:146
int hp
Definition unit.h:152
int fuel
Definition unit.h:154
struct tile * tile
Definition unit.h:141
struct unit::@84::@86 client
struct act_prob * act_prob_cache
Definition unit.h:230
int homecity
Definition unit.h:147
struct civ_map map
const char * style_name_translation(const struct nation_style *pstyle)
Definition style.c:95
int style_number(const struct nation_style *pstyle)
Definition style.c:68
int basic_city_style_for_style(struct nation_style *pstyle)
Definition style.c:204
#define styles_iterate(_p)
Definition style.h:48
#define styles_iterate_end
Definition style.h:54
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c: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:246
#define A_FIRST
Definition tech.h:44
#define A_UNSET
Definition tech.h:48
#define advance_index_iterate(_start, _index)
Definition tech.h:242
struct extra_type * get_preferred_pillage(bv_extras extras)
Definition terrain.c:553
bool get_units_upgrade_info(char *buf, size_t bufsz, struct unit_list *punits)
Definition text.c:1310
const char * get_act_sel_action_custom_text(struct action *paction, const struct act_prob prob, const struct unit *actor_unit, const struct city *target_city)
Definition text.c:1763
const char * act_sel_action_tool_tip(const struct action *paction, const struct act_prob prob)
Definition text.c:1868
struct city * tile_city(const struct tile *ptile)
Definition tile.c:83
#define tile_index(_pt_)
Definition tile.h:89
#define TILE_INDEX_NONE
Definition tile.h:48
int tileset_hex_width(const struct tileset *t)
Definition tilespec.c:747
int tileset_unit_width(const struct tileset *t)
Definition tilespec.c:823
int tileset_unit_height(const struct tileset *t)
Definition tilespec.c:831
struct sprite * load_popup_sprite(const char *tag)
Definition tilespec.c:7841
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:7109
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:7849
struct sprite * get_nation_flag_sprite(const struct tileset *t, const struct nation_type *pnation)
Definition tilespec.c:7006
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:1977
bool could_unit_load(const struct unit *pcargo, const struct unit *ptrans)
Definition unit.c:741
bool unit_can_do_action(const struct unit *punit, const action_id act_id)
Definition unit.c:402
void unit_activity_astr(const struct unit *punit, struct astring *astr)
Definition unit.c:1209
#define unit_tile(_pu)
Definition unit.h: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:126
const char * unit_name_translation(const struct unit *punit)
Definition unittype.c:1595
#define utype_fuel(ptype)
Definition unittype.h:849