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) {
2080 astr_set(&text,
2081 // TRANS: Your Spy is ready to act against Roman Freight.
2082 _("Your %s is ready to act against %s %s."),
2086 } else {
2087 fc_assert_msg(target_unit != nullptr
2088 || target_city != nullptr
2089 || target_tile != nullptr,
2090 "No target specified.");
2091
2092 astr_set(&text,
2093 // TRANS: %s is a unit name, e.g., Diplomat, Spy
2094 _("Your %s is waiting for your command."),
2096 }
2097
2098 cd = gui()->get_diplo_dialog();
2099 if ((cd != nullptr) && cd->targeted_unit != nullptr) {
2100 cd->update_dialog(act_probs);
2101 return;
2102 }
2103 cd = new choice_dialog(astr_str(&title), astr_str(&text),
2104 gui()->game_tab_widget,
2106 qv1 = actor_unit->id;
2107
2108 cd->unit_id = actor_unit->id;
2109
2110 cd->target_id[ATK_SELF] = cd->unit_id;
2111
2112 if (target_city) {
2113 cd->target_id[ATK_CITY] = target_city->id;
2114 } else {
2115 cd->target_id[ATK_CITY] = IDENTITY_NUMBER_ZERO;
2116 }
2117
2118 if (target_unit) {
2119 cd->target_id[ATK_UNIT] = target_unit->id;
2120 } else {
2121 cd->target_id[ATK_UNIT] = IDENTITY_NUMBER_ZERO;
2122 }
2123
2124 if (target_tile) {
2125 cd->target_id[ATK_STACK] = tile_index(target_tile);
2126 } else {
2127 cd->target_id[ATK_STACK] = TILE_INDEX_NONE;
2128 }
2129
2130 if (target_tile) {
2131 cd->target_id[ATK_TILE] = tile_index(target_tile);
2132 } else {
2133 cd->target_id[ATK_TILE] = TILE_INDEX_NONE;
2134 }
2135
2136 if (target_tile) {
2137 cd->target_id[ATK_EXTRAS] = tile_index(target_tile);
2138 } else {
2139 cd->target_id[ATK_EXTRAS] = TILE_INDEX_NONE;
2140 }
2141
2142 // No target building or target tech supplied. (Feb 2020)
2143 cd->sub_target_id[ASTK_BUILDING] = B_LAST;
2144 cd->sub_target_id[ASTK_TECH] = A_UNSET;
2145
2146 if (target_extra) {
2147 cd->sub_target_id[ASTK_EXTRA] = extra_number(target_extra);
2149 } else {
2150 cd->sub_target_id[ASTK_EXTRA] = EXTRA_NONE;
2151 cd->sub_target_id[ASTK_EXTRA_NOT_THERE] = EXTRA_NONE;
2152 }
2153
2154 // Unit acting against a city
2155
2156 // Set the correct target for the following actions.
2157 qv2 = cd->target_id[ATK_CITY];
2158
2159 action_iterate(act) {
2164 act_probs[act],
2165 actor_unit,
2166 target_city),
2167 qv1, qv2);
2168 }
2170
2171 // Unit acting against another unit
2172
2173 // Set the correct target for the following actions.
2174 qv2 = cd->target_id[ATK_UNIT];
2175
2176 action_iterate(act) {
2181 act_probs[act],
2182 actor_unit,
2183 target_city),
2184 qv1, qv2);
2185 }
2187
2188 // Unit acting against all units at a tile
2189
2190 // Set the correct target for the following actions.
2191 qv2 = cd->target_id[ATK_STACK];
2192
2193 action_iterate(act) {
2198 act_probs[act],
2199 actor_unit,
2200 target_city),
2201 qv1, qv2);
2202 }
2204
2205 // Unit acting against a tile.
2206
2207 // Set the correct target for the following actions.
2208 qv2 = cd->target_id[ATK_TILE];
2209
2210 action_iterate(act) {
2215 act_probs[act],
2216 actor_unit,
2217 target_city),
2218 qv1, qv2);
2219 }
2221
2222 // Unit acting against a tile's extras.
2223
2224 // Set the correct target for the following actions.
2225 qv2 = cd->target_id[ATK_EXTRAS];
2226
2227 action_iterate(act) {
2232 act_probs[act],
2233 actor_unit,
2234 target_city),
2235 qv1, qv2);
2236 }
2238
2239 // Unit acting against itself
2240
2241 // Set the correct target for the following actions.
2242 qv2 = cd->target_id[ATK_SELF];
2243
2244 action_iterate(act) {
2249 act_probs[act],
2250 actor_unit,
2251 target_city),
2252 qv1, qv2);
2253 }
2255
2257 cd->add_item(QString(_("&Wait")), func, qv1, qv2,
2258 "", BUTTON_WAIT);
2259
2260 func = keep_moving;
2261 cd->add_item(QString(_("Do nothing")), func, qv1, qv2,
2262 "", BUTTON_CANCEL);
2263
2264 cd->set_layout();
2265 cd->show_me();
2266
2267 // Give follow up questions access to action probabilities.
2269 action_iterate(act) {
2272
2273 astr_free(&title);
2274 astr_free(&text);
2275}
2276
2277/***********************************************************************/
2282{
2283 /* Don't add an action mapping here unless the non targeted version is
2284 * selectable in the targeted version's target selection dialog. */
2285 switch ((enum gen_action)tgt_action_id) {
2291 return ACTION_SPY_STEAL_TECH;
2294 default:
2295 // No non targeted version found.
2296 return ACTION_NONE;
2297 }
2298}
2299
2300/**********************************************************************/
2305{
2306 /* Don't add an action mapping here unless the non targeted version is
2307 * selectable in the targeted version's target selection dialog. */
2308 switch ((enum gen_action)tgt_action_id) {
2315 default:
2316 // No non targeted version found.
2317 return ACTION_NONE;
2318 }
2319}
2320
2321/***********************************************************************/
2325 action_id act,
2326 const struct act_prob *act_probs,
2327 const char *custom,
2328 QVariant data1, QVariant data2)
2329{
2330 QString title;
2332
2333 if (!af_map.contains(act)) {
2334 /* The Qt client doesn't support ordering this action from the
2335 * action selection dialog. */
2336 return;
2337 }
2338
2339 // Don't show disabled actions.
2340 if (!action_prob_possible(act_probs[act])) {
2341 return;
2342 }
2343
2345 act_probs[act],
2346 custom));
2347
2349 act_probs[act]));
2350
2351 cd->add_item(title, af_map[act], data1, data2, tool_tip, act);
2352}
2353
2354/***********************************************************************/
2358 action_id act,
2359 const struct act_prob *act_probs,
2360 const char *custom,
2361 QVariant data1, QVariant data2)
2362{
2363 QString title;
2365
2366 /* An action that just became impossible has its button disabled.
2367 * An action that became possible again must be re-enabled. */
2368 button->setEnabled(action_prob_possible(act_probs[act]));
2369 button->setData1(data1);
2370 button->setData2(data2);
2371 // The probability may have changed.
2373 act_probs[act],
2374 custom));
2375
2377 act_probs[act]));
2378
2379 button->setText(title);
2380 button->setToolTip(tool_tip);
2381}
2382
2383/***********************************************************************/
2386static void disband_unit(QVariant data1, QVariant data2)
2387{
2388 int actor_id = data1.toInt();
2389 int target_id = data2.toInt();
2390
2392 target_id, 0, "");
2393}
2394
2395/***********************************************************************/
2398static void fortify(QVariant data1, QVariant data2)
2399{
2400 int actor_id = data1.toInt();
2401 int target_id = data2.toInt();
2402
2403 if (game_unit_by_number(actor_id) != nullptr) {
2405 target_id, 0, "");
2406 }
2407}
2408
2409/***********************************************************************/
2412static void convert_unit(QVariant data1, QVariant data2)
2413{
2414 int actor_id = data1.toInt();
2415 int target_id = data2.toInt();
2416
2418 target_id, 0, "");
2419}
2420
2421/***********************************************************************/
2424static void homeless(QVariant data1, QVariant data2)
2425{
2426 int actor_id = data1.toInt();
2427 int target_id = data2.toInt();
2428
2429 if (game_unit_by_number(actor_id) != nullptr) {
2431 target_id, 0, "");
2432 }
2433}
2434
2435/***********************************************************************/
2438static void diplomat_bribe_unit(QVariant data1, QVariant data2)
2439{
2440 int diplomat_id = data1.toInt();
2441 int diplomat_target_id = data2.toInt();
2442
2443 if (game_unit_by_number(diplomat_id) != nullptr
2444 && game_unit_by_number(diplomat_target_id) != nullptr) {
2445 // Wait for the server's reply before moving on to the next queued diplomat.
2447
2450 }
2451}
2452
2453/***********************************************************************/
2456static void diplomat_bribe_stack(QVariant data1, QVariant data2)
2457{
2458 int diplomat_id = data1.toInt();
2459 int diplomat_target_id = data2.toInt();
2460
2461 if (game_unit_by_number(diplomat_id) != nullptr) {
2462 // Wait for the server's reply before moving on to the next queued diplomat.
2464
2467 }
2468}
2469
2470/***********************************************************************/
2473static void spy_sabotage_unit(QVariant data1, QVariant data2)
2474{
2475 int diplomat_id = data1.toInt();
2476 int diplomat_target_id = data2.toInt();
2477
2479 diplomat_target_id, 0, "");
2480}
2481
2482/***********************************************************************/
2485static void spy_sabotage_unit_esc(QVariant data1, QVariant data2)
2486{
2487 int diplomat_id = data1.toInt();
2488 int diplomat_target_id = data2.toInt();
2489
2491 diplomat_target_id, 0, "");
2492}
2493
2494/***********************************************************************/
2497static void heal_unit(QVariant data1, QVariant data2)
2498{
2499 int actor_id = data1.toInt();
2500 int target_id = data2.toInt();
2501
2502 request_do_action(ACTION_HEAL_UNIT, actor_id, target_id, 0, "");
2503}
2504
2505/***********************************************************************/
2508static void heal_unit2(QVariant data1, QVariant data2)
2509{
2510 int actor_id = data1.toInt();
2511 int target_id = data2.toInt();
2512
2513 request_do_action(ACTION_HEAL_UNIT2, actor_id, target_id, 0, "");
2514}
2515
2516/***********************************************************************/
2519static void transport_board(QVariant data1, QVariant data2)
2520{
2521 int actor_id = data1.toInt();
2522 int target_id = data2.toInt();
2523
2524 request_do_action(ACTION_TRANSPORT_BOARD, actor_id, target_id, 0, "");
2525}
2526
2527/***********************************************************************/
2530static void transport_board2(QVariant data1, QVariant data2)
2531{
2532 int actor_id = data1.toInt();
2533 int target_id = data2.toInt();
2534
2535 request_do_action(ACTION_TRANSPORT_BOARD2, actor_id, target_id, 0, "");
2536}
2537
2538/***********************************************************************/
2541static void transport_board3(QVariant data1, QVariant data2)
2542{
2543 int actor_id = data1.toInt();
2544 int target_id = data2.toInt();
2545
2546 request_do_action(ACTION_TRANSPORT_BOARD3, actor_id, target_id, 0, "");
2547}
2548
2549/***********************************************************************/
2552static void transport_embark(QVariant data1, QVariant data2)
2553{
2554 int actor_id = data1.toInt();
2555 int target_id = data2.toInt();
2556
2557 request_do_action(ACTION_TRANSPORT_EMBARK, actor_id, target_id, 0, "");
2558}
2559
2560/***********************************************************************/
2563static void transport_embark2(QVariant data1, QVariant data2)
2564{
2565 int actor_id = data1.toInt();
2566 int target_id = data2.toInt();
2567
2568 request_do_action(ACTION_TRANSPORT_EMBARK2, actor_id, target_id, 0, "");
2569}
2570
2571/***********************************************************************/
2574static void transport_embark3(QVariant data1, QVariant data2)
2575{
2576 int actor_id = data1.toInt();
2577 int target_id = data2.toInt();
2578
2579 request_do_action(ACTION_TRANSPORT_EMBARK3, actor_id, target_id, 0, "");
2580}
2581
2582/***********************************************************************/
2585static void transport_embark4(QVariant data1, QVariant data2)
2586{
2587 int actor_id = data1.toInt();
2588 int target_id = data2.toInt();
2589
2590 request_do_action(ACTION_TRANSPORT_EMBARK4, actor_id, target_id, 0, "");
2591}
2592
2593/***********************************************************************/
2596static void transport_unload(QVariant data1, QVariant data2)
2597{
2598 int actor_id = data1.toInt();
2599 int target_id = data2.toInt();
2600
2601 request_do_action(ACTION_TRANSPORT_UNLOAD, actor_id, target_id, 0, "");
2602}
2603
2604/***********************************************************************/
2607static void transport_load(QVariant data1, QVariant data2)
2608{
2609 int actor_id = data1.toInt();
2610 int target_id = data2.toInt();
2611
2612 request_do_action(ACTION_TRANSPORT_LOAD, actor_id, target_id, 0, "");
2613}
2614
2615/***********************************************************************/
2618static void transport_load2(QVariant data1, QVariant data2)
2619{
2620 int actor_id = data1.toInt();
2621 int target_id = data2.toInt();
2622
2623 request_do_action(ACTION_TRANSPORT_LOAD2, actor_id, target_id, 0, "");
2624}
2625
2626/***********************************************************************/
2629static void transport_load3(QVariant data1, QVariant data2)
2630{
2631 int actor_id = data1.toInt();
2632 int target_id = data2.toInt();
2633
2634 request_do_action(ACTION_TRANSPORT_LOAD3, actor_id, target_id, 0, "");
2635}
2636
2637/***********************************************************************/
2640static void transport_deboard(QVariant data1, QVariant data2)
2641{
2642 int actor_id = data1.toInt();
2643 int target_id = data2.toInt();
2644
2645 request_do_action(ACTION_TRANSPORT_DEBOARD, actor_id, target_id, 0, "");
2646}
2647
2648/***********************************************************************/
2651static void disembark1(QVariant data1, QVariant data2)
2652{
2653 int actor_id = data1.toInt();
2654 int target_id = data2.toInt();
2655
2656 if (game_unit_by_number(actor_id) != nullptr
2657 && index_to_tile(&(wld.map), target_id) != nullptr) {
2659 actor_id, target_id, 0, "");
2660 }
2661}
2662
2663/***********************************************************************/
2666static void disembark2(QVariant data1, QVariant data2)
2667{
2668 int actor_id = data1.toInt();
2669 int target_id = data2.toInt();
2670
2671 if (game_unit_by_number(actor_id) != nullptr
2672 && index_to_tile(&(wld.map), target_id) != nullptr) {
2674 actor_id, target_id, 0, "");
2675 }
2676}
2677
2678/***********************************************************************/
2681static void enter_hut(QVariant data1, QVariant data2)
2682{
2683 int actor_id = data1.toInt();
2684 int target_id = data2.toInt();
2685
2686 if (game_unit_by_number(actor_id) != nullptr
2687 && index_to_tile(&(wld.map), target_id) != nullptr) {
2689 actor_id, target_id, 0, "");
2690 }
2691}
2692
2693/***********************************************************************/
2696static void enter_hut2(QVariant data1, QVariant data2)
2697{
2698 int actor_id = data1.toInt();
2699 int target_id = data2.toInt();
2700
2701 if (game_unit_by_number(actor_id) != nullptr
2702 && index_to_tile(&(wld.map), target_id) != nullptr) {
2704 actor_id, target_id, 0, "");
2705 }
2706}
2707
2708/***********************************************************************/
2711static void frighten_hut(QVariant data1, QVariant data2)
2712{
2713 int actor_id = data1.toInt();
2714 int target_id = data2.toInt();
2715
2716 if (game_unit_by_number(actor_id) != nullptr
2717 && index_to_tile(&(wld.map), target_id) != nullptr) {
2719 actor_id, target_id, 0, "");
2720 }
2721}
2722
2723/***********************************************************************/
2726static void frighten_hut2(QVariant data1, QVariant data2)
2727{
2728 int actor_id = data1.toInt();
2729 int target_id = data2.toInt();
2730
2731 if (game_unit_by_number(actor_id) != nullptr
2732 && index_to_tile(&(wld.map), target_id) != nullptr) {
2734 actor_id, target_id, 0, "");
2735 }
2736}
2737
2738/**********************************************************************/
2741static void nuke_units(QVariant data1, QVariant data2)
2742{
2743 int actor_id = data1.toInt();
2744 int target_id = data2.toInt();
2745
2747 target_id, 0, "");
2748}
2749
2750/**********************************************************************/
2753static void collect_ransom(QVariant data1, QVariant data2)
2754{
2755 int actor_id = data1.toInt();
2756 int target_id = data2.toInt();
2757
2759 target_id, 0, "");
2760}
2761
2762/**********************************************************************/
2765static void wipe_units(QVariant data1, QVariant data2)
2766{
2767 int actor_id = data1.toInt();
2768 int target_id = data2.toInt();
2769
2771 target_id, 0, "");
2772}
2773
2774/**********************************************************************/
2777static void capture_units(QVariant data1, QVariant data2)
2778{
2779 int actor_id = data1.toInt();
2780 int target_id = data2.toInt();
2781
2783 target_id, 0, "");
2784}
2785
2786/***********************************************************************/
2789static void expel_unit(QVariant data1, QVariant data2)
2790{
2791 int actor_id = data1.toInt();
2792 int target_id = data2.toInt();
2793
2795 target_id, 0, "");
2796}
2797
2798/***********************************************************************/
2801static void bombard(QVariant data1, QVariant data2)
2802{
2803 int actor_id = data1.toInt();
2804 int target_id = data2.toInt();
2805
2807 target_id, 0, "");
2808}
2809
2810/***********************************************************************/
2813static void bombard2(QVariant data1, QVariant data2)
2814{
2815 int actor_id = data1.toInt();
2816 int target_id = data2.toInt();
2817
2819 target_id, 0, "");
2820}
2821
2822/***********************************************************************/
2825static void bombard3(QVariant data1, QVariant data2)
2826{
2827 int actor_id = data1.toInt();
2828 int target_id = data2.toInt();
2829
2831 target_id, 0, "");
2832}
2833
2834/***********************************************************************/
2837static void bombard_lethal(QVariant data1, QVariant data2)
2838{
2839 int actor_id = data1.toInt();
2840 int target_id = data2.toInt();
2841
2843 target_id, 0, "");
2844}
2845
2846/***********************************************************************/
2849static void found_city(QVariant data1, QVariant data2)
2850{
2851 int actor_id = data1.toInt();
2852
2854 actor_id);
2855}
2856
2857/***********************************************************************/
2860static void transform_terrain(QVariant data1, QVariant data2)
2861{
2862 int actor_id = data1.toInt();
2863 int target_id = data2.toInt();
2864
2865 if (game_unit_by_number(actor_id) != nullptr
2866 && index_to_tile(&(wld.map), target_id) != nullptr) {
2868 actor_id, target_id, 0, "");
2869 }
2870}
2871
2872/***********************************************************************/
2875static void cultivate(QVariant data1, QVariant data2)
2876{
2877 int actor_id = data1.toInt();
2878 int target_id = data2.toInt();
2879
2880 if (game_unit_by_number(actor_id) != nullptr
2881 && index_to_tile(&(wld.map), target_id) != nullptr) {
2883 actor_id, target_id, 0, "");
2884 }
2885}
2886
2887/***********************************************************************/
2890static void plant(QVariant data1, QVariant data2)
2891{
2892 int actor_id = data1.toInt();
2893 int target_id = data2.toInt();
2894
2895 if (game_unit_by_number(actor_id) != nullptr
2896 && index_to_tile(&(wld.map), target_id) != nullptr) {
2898 actor_id, target_id, 0, "");
2899 }
2900}
2901
2902/***********************************************************************/
2905static void pillage(QVariant data1, QVariant data2)
2906{
2907 int actor_id = data1.toInt();
2908 int target_id = data2.toInt();
2909
2910 if (game_unit_by_number(actor_id) != nullptr
2911 && index_to_tile(&(wld.map), target_id) != nullptr) {
2913 actor_id, target_id,
2914 /* FIXME: will cause problems if more than
2915 * one action selection dialog at a time
2916 * becomes supported. */
2918 "");
2919 }
2920}
2921
2922/***********************************************************************/
2925static void clean(QVariant data1, QVariant data2)
2926{
2927 int actor_id = data1.toInt();
2928 int target_id = data2.toInt();
2929
2930 if (game_unit_by_number(actor_id) != nullptr
2931 && index_to_tile(&(wld.map), target_id) != nullptr) {
2933 actor_id, target_id,
2934 /* FIXME: will cause problems if more than
2935 * one action selection dialog at a time
2936 * becomes supported. */
2938 "");
2939 }
2940}
2941
2942/***********************************************************************/
2945static void road(QVariant data1, QVariant data2)
2946{
2947 int actor_id = data1.toInt();
2948 int target_id = data2.toInt();
2949
2950 if (game_unit_by_number(actor_id) != nullptr
2951 && index_to_tile(&(wld.map), target_id) != nullptr
2954 actor_id, target_id,
2955 /* FIXME: will cause problems if more than
2956 * one action selection dialog at a time
2957 * becomes supported. */
2959 "");
2960 }
2961}
2962
2963/***********************************************************************/
2966static void base(QVariant data1, QVariant data2)
2967{
2968 int actor_id = data1.toInt();
2969 int target_id = data2.toInt();
2970
2971 if (game_unit_by_number(actor_id) != nullptr
2972 && index_to_tile(&(wld.map), target_id) != nullptr
2975 actor_id, target_id,
2976 /* FIXME: will cause problems if more than
2977 * one action selection dialog at a time
2978 * becomes supported. */
2980 "");
2981 }
2982}
2983
2984/***********************************************************************/
2987static void mine(QVariant data1, QVariant data2)
2988{
2989 int actor_id = data1.toInt();
2990 int target_id = data2.toInt();
2991
2992 if (game_unit_by_number(actor_id) != nullptr
2993 && index_to_tile(&(wld.map), target_id) != nullptr
2996 actor_id, target_id,
2997 /* FIXME: will cause problems if more than
2998 * one action selection dialog at a time
2999 * becomes supported. */
3001 "");
3002 }
3003}
3004
3005/***********************************************************************/
3008static void irrigate(QVariant data1, QVariant data2)
3009{
3010 int actor_id = data1.toInt();
3011 int target_id = data2.toInt();
3012
3013 if (game_unit_by_number(actor_id) != nullptr
3014 && index_to_tile(&(wld.map), target_id) != nullptr
3017 actor_id, target_id,
3018 /* FIXME: will cause problems if more than
3019 * one action selection dialog at a time
3020 * becomes supported. */
3022 "");
3023 }
3024}
3025
3026/***********************************************************************/
3029static void nuke(QVariant data1, QVariant data2)
3030{
3031 int diplomat_id = data1.toInt();
3032 int diplomat_target_id = data2.toInt();
3033
3034 if (game_unit_by_number(diplomat_id) != nullptr
3035 && index_to_tile(&(wld.map), diplomat_target_id) != nullptr) {
3038 }
3039}
3040
3041/***********************************************************************/
3044static void attack(QVariant data1, QVariant data2)
3045{
3046 int diplomat_id = data1.toInt();
3047 int diplomat_target_id = data2.toInt();
3048
3049 if (game_unit_by_number(diplomat_id) != nullptr
3050 && index_to_tile(&(wld.map), diplomat_target_id) != nullptr) {
3053 }
3054}
3055
3056/***********************************************************************/
3059static void suicide_attack(QVariant data1, QVariant data2)
3060{
3061 int diplomat_id = data1.toInt();
3062 int diplomat_target_id = data2.toInt();
3063
3064 if (game_unit_by_number(diplomat_id) != nullptr
3065 && index_to_tile(&(wld.map), diplomat_target_id) != nullptr) {
3068 }
3069}
3070
3071/***********************************************************************/
3074static void paradrop(QVariant data1, QVariant data2)
3075{
3076 int actor_id = data1.toInt();
3077 int target_id = data2.toInt();
3078
3079 if (game_unit_by_number(actor_id) != nullptr
3080 && index_to_tile(&(wld.map), target_id) != nullptr) {
3082 actor_id, target_id, 0, "");
3083 }
3084}
3085
3086/***********************************************************************/
3089static void paradrop_conquer(QVariant data1, QVariant data2)
3090{
3091 int actor_id = data1.toInt();
3092 int target_id = data2.toInt();
3093
3094 if (game_unit_by_number(actor_id) != nullptr
3095 && index_to_tile(&(wld.map), target_id) != nullptr) {
3097 actor_id, target_id, 0, "");
3098 }
3099}
3100
3101/***********************************************************************/
3104static void paradrop_frighten(QVariant data1, QVariant data2)
3105{
3106 int actor_id = data1.toInt();
3107 int target_id = data2.toInt();
3108
3109 if (game_unit_by_number(actor_id) != nullptr
3110 && index_to_tile(&(wld.map), target_id) != nullptr) {
3112 actor_id, target_id, 0, "");
3113 }
3114}
3115
3116/***********************************************************************/
3120{
3121 int actor_id = data1.toInt();
3122 int target_id = data2.toInt();
3123
3124 if (game_unit_by_number(actor_id) != nullptr
3125 && index_to_tile(&(wld.map), target_id) != nullptr) {
3127 actor_id, target_id, 0, "");
3128 }
3129}
3130
3131/***********************************************************************/
3134static void paradrop_enter(QVariant data1, QVariant data2)
3135{
3136 int actor_id = data1.toInt();
3137 int target_id = data2.toInt();
3138
3139 if (game_unit_by_number(actor_id) != nullptr
3140 && index_to_tile(&(wld.map), target_id) != nullptr) {
3142 actor_id, target_id, 0, "");
3143 }
3144}
3145
3146/***********************************************************************/
3150{
3151 int actor_id = data1.toInt();
3152 int target_id = data2.toInt();
3153
3154 if (game_unit_by_number(actor_id) != nullptr
3155 && index_to_tile(&(wld.map), target_id) != nullptr) {
3157 actor_id, target_id, 0, "");
3158 }
3159}
3160
3161/***********************************************************************/
3164static void join_city(QVariant data1, QVariant data2)
3165{
3166 int actor_id = data1.toInt();
3167 int target_id = data2.toInt();
3168
3169 if (game_unit_by_number(actor_id) != nullptr
3170 && game_city_by_number(target_id) != nullptr) {
3172 actor_id, target_id, 0, "");
3173 }
3174}
3175
3176/***********************************************************************/
3179static void spy_steal_shared(QVariant data1, QVariant data2,
3180 action_id act_id)
3181{
3182 QString str;
3183 QVariant qv1;
3185 int diplomat_id = data1.toInt();
3186 int diplomat_target_id = data2.toInt();
3189 struct player *pvictim = nullptr;
3192
3193 cd = gui()->get_diplo_dialog();
3194 if (cd != nullptr) {
3195 cd->close();
3196 }
3197
3198 if (pvcity == nullptr) {
3199 return;
3200 }
3201
3202 // Wait for the player's reply before moving on to the next queued diplomat.
3204
3206
3207 struct astring stra = ASTRING_INIT;
3208 cd = new choice_dialog(_("Steal"), _("Steal Technology"),
3209 gui()->game_tab_widget,
3211
3212 // Put both actor and target city in qv1 since qv2 is taken
3215 actor_and_target.append(act_id);
3216 qv1 = QVariant::fromValue(actor_and_target);
3217
3218 struct player *pplayer = client_player();
3219 const struct research *presearch = research_get(pplayer);
3220 const struct research *vresearch = research_get(pvictim);
3221
3228 // Defeat keyboard shortcut mnemonics
3230 .replace("&", "&&");
3231 cd->add_item(str, func, qv1, i);
3232 }
3234
3236 get_non_targeted_action_id(act_id)])) {
3237 astr_set(&stra, _("At %s's Discretion"),
3240 str = QString(astr_str(&stra)).replace("&", "&&");
3241 cd->add_item(str, func, qv1, A_UNSET);
3242 }
3243
3244 cd->set_layout();
3245 cd->show_me();
3246
3247 astr_free(&stra);
3248}
3249
3250/***********************************************************************/
3253static void spy_steal(QVariant data1, QVariant data2)
3254{
3256}
3257
3258/***********************************************************************/
3261static void spy_steal_esc(QVariant data1, QVariant data2)
3262{
3264}
3265
3266/***********************************************************************/
3269static void spy_steal_something(QVariant data1, QVariant data2)
3270{
3271 int diplomat_id = data1.toList().at(0).toInt();
3272 int diplomat_target_id = data1.toList().at(1).toInt();
3273 action_id act_id = data1.toList().at(2).toInt();
3274
3275 if (game_unit_by_number(diplomat_id) != nullptr
3276 && game_city_by_number(diplomat_target_id) != nullptr) {
3277 if (data2.toInt() == A_UNSET) {
3278 // This is the untargeted version.
3280 diplomat_id, diplomat_target_id, data2.toInt(), "");
3281 } else {
3282 // This is the targeted version.
3284 diplomat_target_id, data2.toInt(), "");
3285 }
3286 }
3287}
3288
3289/***********************************************************************/
3293{
3294 int actor_id = data1.toInt();
3295 int target_id = data2.toInt();
3296
3297 if (game_unit_by_number(actor_id) != nullptr
3298 && game_city_by_number(target_id) != nullptr) {
3299 // Wait for the server's reply before moving on to the next queued diplomat.
3301
3302 request_action_details(ACTION_STRIKE_BUILDING, actor_id, target_id);
3303 }
3304}
3305
3306/***********************************************************************/
3310{
3311 int diplomat_id = data1.toInt();
3312 int diplomat_target_id = data2.toInt();
3313
3314 if (game_unit_by_number(diplomat_id) != nullptr
3315 && game_city_by_number(diplomat_target_id) != nullptr) {
3316 // Wait for the server's reply before moving on to the next queued diplomat.
3318
3321 }
3322}
3323
3324/***********************************************************************/
3328{
3329 int diplomat_id = data1.toInt();
3330 int diplomat_target_id = data2.toInt();
3331
3332 if (game_unit_by_number(diplomat_id) != nullptr
3333 && game_city_by_number(diplomat_target_id) != nullptr) {
3334 /* Wait for the server's reply before moving on to the next queued
3335 * diplomat. */
3337
3340 }
3341}
3342
3343/***********************************************************************/
3346static void spy_poison(QVariant data1, QVariant data2)
3347{
3348 int diplomat_id = data1.toInt();
3349 int diplomat_target_id = data2.toInt();
3350
3351 if (game_unit_by_number(diplomat_id) != nullptr
3352 && game_city_by_number(diplomat_target_id) != nullptr) {
3355 }
3356}
3357
3358/***********************************************************************/
3361static void spy_poison_esc(QVariant data1, QVariant data2)
3362{
3363 int diplomat_id = data1.toInt();
3364 int diplomat_target_id = data2.toInt();
3365
3366 if (game_unit_by_number(diplomat_id) != nullptr
3367 && game_city_by_number(diplomat_target_id) != nullptr) {
3370 }
3371}
3372
3373/***********************************************************************/
3376static void spy_nuke_city(QVariant data1, QVariant data2)
3377{
3378 int diplomat_id = data1.toInt();
3379 int diplomat_target_id = data2.toInt();
3380
3381 if (game_unit_by_number(diplomat_id) != nullptr
3382 && game_city_by_number(diplomat_target_id) != nullptr) {
3385 }
3386}
3387
3388/***********************************************************************/
3391static void spy_nuke_city_esc(QVariant data1, QVariant data2)
3392{
3393 int diplomat_id = data1.toInt();
3394 int diplomat_target_id = data2.toInt();
3395
3396 if (game_unit_by_number(diplomat_id) != nullptr
3397 && game_city_by_number(diplomat_target_id) != nullptr) {
3400 }
3401}
3402
3403/***********************************************************************/
3406static void nuke_city(QVariant data1, QVariant data2)
3407{
3408 int actor_id = data1.toInt();
3409 int target_id = data2.toInt();
3410
3411 if (game_unit_by_number(actor_id) != nullptr
3412 && game_city_by_number(target_id) != nullptr) {
3414 actor_id, target_id, 0, "");
3415 }
3416}
3417
3418/***********************************************************************/
3421static void destroy_city(QVariant data1, QVariant data2)
3422{
3423 int diplomat_id = data1.toInt();
3424 int diplomat_target_id = data2.toInt();
3425
3426 if (game_unit_by_number(diplomat_id) != nullptr
3427 && game_city_by_number(diplomat_target_id) != nullptr) {
3430 }
3431}
3432
3433/***********************************************************************/
3436static void spy_steal_gold(QVariant data1, QVariant data2)
3437{
3438 int diplomat_id = data1.toInt();
3439 int diplomat_target_id = data2.toInt();
3440
3441 if (game_unit_by_number(diplomat_id) != nullptr
3442 && game_city_by_number(diplomat_target_id) != nullptr) {
3445 }
3446}
3447
3448/***********************************************************************/
3451static void spy_steal_gold_esc(QVariant data1, QVariant data2)
3452{
3453 int diplomat_id = data1.toInt();
3454 int diplomat_target_id = data2.toInt();
3455
3456 if (game_unit_by_number(diplomat_id) != nullptr
3457 && game_city_by_number(diplomat_target_id) != nullptr) {
3460 }
3461}
3462
3463/***********************************************************************/
3466static void spy_steal_maps(QVariant data1, QVariant data2)
3467{
3468 int diplomat_id = data1.toInt();
3469 int diplomat_target_id = data2.toInt();
3470
3471 if (game_unit_by_number(diplomat_id) != nullptr
3472 && game_city_by_number(diplomat_target_id) != nullptr) {
3475 }
3476}
3477
3478/***********************************************************************/
3481static void spy_steal_maps_esc(QVariant data1, QVariant data2)
3482{
3483 int diplomat_id = data1.toInt();
3484 int diplomat_target_id = data2.toInt();
3485
3486 if (game_unit_by_number(diplomat_id) != nullptr
3487 && game_city_by_number(diplomat_target_id) != nullptr) {
3490 }
3491}
3492
3493/***********************************************************************/
3496static void spy_escape(QVariant data1, QVariant data2)
3497{
3498 int diplomat_id = data1.toInt();
3499 int diplomat_target_id = data2.toInt();
3500
3501 if (game_unit_by_number(diplomat_id) != nullptr
3502 && game_city_by_number(diplomat_target_id) != nullptr) {
3505 }
3506}
3507
3508/***********************************************************************/
3511static void spy_embassy(QVariant data1, QVariant data2)
3512{
3513 int diplomat_id = data1.toInt();
3514 int diplomat_target_id = data2.toInt();
3515
3516 if (game_unit_by_number(diplomat_id) != nullptr
3517 && game_city_by_number(diplomat_target_id) != nullptr) {
3519 diplomat_target_id, 0, "");
3520 }
3521}
3522
3523/***********************************************************************/
3526static void diplomat_embassy(QVariant data1, QVariant data2)
3527{
3528 int diplomat_id = data1.toInt();
3529 int diplomat_target_id = data2.toInt();
3530
3531 if (game_unit_by_number(diplomat_id) != nullptr
3532 && game_city_by_number(diplomat_target_id) != nullptr) {
3534 diplomat_target_id, 0, "");
3535 }
3536}
3537
3538/***********************************************************************/
3541static void spy_investigate(QVariant data1, QVariant data2)
3542{
3543 int diplomat_id = data1.toInt();
3544 int diplomat_target_id = data2.toInt();
3545
3547 && game_unit_by_number(diplomat_id) != nullptr) {
3549 diplomat_target_id, 0, "");
3550 }
3551}
3552
3553/***********************************************************************/
3556static void diplomat_investigate(QVariant data1, QVariant data2)
3557{
3558 int diplomat_id = data1.toInt();
3559 int diplomat_target_id = data2.toInt();
3560
3562 && game_unit_by_number(diplomat_id) != nullptr) {
3564 diplomat_target_id, 0, "");
3565 }
3566}
3567
3568/***********************************************************************/
3571static void diplomat_sabotage(QVariant data1, QVariant data2)
3572{
3573 int diplomat_id = data1.toInt();
3574 int diplomat_target_id = data2.toInt();
3575
3576 if (game_unit_by_number(diplomat_id) != nullptr
3577 && game_city_by_number(diplomat_target_id) != nullptr) {
3579 diplomat_target_id, B_LAST + 1, "");
3580 }
3581}
3582
3583/***********************************************************************/
3586static void diplomat_sabotage_esc(QVariant data1, QVariant data2)
3587{
3588 int diplomat_id = data1.toInt();
3589 int diplomat_target_id = data2.toInt();
3590
3591 if (game_unit_by_number(diplomat_id) != nullptr
3592 && game_city_by_number(diplomat_target_id) != nullptr) {
3594 diplomat_target_id, B_LAST + 1, "");
3595 }
3596}
3597
3598/***********************************************************************/
3601static void diplomat_steal(QVariant data1, QVariant data2)
3602{
3603 int diplomat_id = data1.toInt();
3604 int diplomat_target_id = data2.toInt();
3605
3606 if (game_unit_by_number(diplomat_id) != nullptr
3607 && game_city_by_number(diplomat_target_id) != nullptr) {
3610 }
3611}
3612
3613/***********************************************************************/
3616static void diplomat_steal_esc(QVariant data1, QVariant data2)
3617{
3618 int diplomat_id = data1.toInt();
3619 int diplomat_target_id = data2.toInt();
3620
3621 if (game_unit_by_number(diplomat_id) != nullptr
3622 && game_city_by_number(diplomat_target_id) != nullptr) {
3625 }
3626}
3627
3628/***********************************************************************/
3631static void diplomat_incite(QVariant data1, QVariant data2)
3632{
3633 int diplomat_id = data1.toInt();
3634 int diplomat_target_id = data2.toInt();
3635
3636 if (game_unit_by_number(diplomat_id) != nullptr
3637 && game_city_by_number(diplomat_target_id) != nullptr) {
3638 // Wait for the server's reply before moving on to the next queued diplomat.
3640
3643 }
3644}
3645
3646/***********************************************************************/
3650{
3651 int diplomat_id = data1.toInt();
3652 int diplomat_target_id = data2.toInt();
3653
3654 if (game_unit_by_number(diplomat_id) != nullptr
3655 && game_city_by_number(diplomat_target_id) != nullptr) {
3656 // Wait for the server's reply before moving on to the next queued diplomat.
3658
3661 }
3662}
3663
3664/***********************************************************************/
3667static void regular_move(QVariant data1, QVariant data2)
3668{
3669 int actor_id = data1.toInt();
3670 int target_id = data2.toInt();
3671
3672 if (game_unit_by_number(actor_id) != nullptr
3673 && index_to_tile(&(wld.map), target_id) != nullptr) {
3675 actor_id, target_id, 0, "");
3676 }
3677}
3678
3679/***********************************************************************/
3683void popup_incite_dialog(struct unit *actor, struct city *tcity, int cost,
3684 const struct action *paction)
3685{
3686 char buf[1024];
3687 char buf2[1024];
3688 int diplomat_id = actor->id;
3689 int diplomat_target_id = tcity->id;
3690 const int act_id = paction->id;
3691
3692 // Should be set before sending request to the server.
3694
3695 fc_snprintf(buf, ARRAY_SIZE(buf), PL_("Treasury contains %d gold.",
3696 "Treasury contains %d gold.",
3697 client_player()->economic.gold),
3698 client_player()->economic.gold);
3699
3701 hud_message_box *impossible = new hud_message_box(gui()->central_wdg);
3702
3704 _("You can't incite a revolt in %s."), city_name_get(tcity));
3705 impossible->set_text_title(buf2, "!");
3706 impossible->setStandardButtons(QMessageBox::Ok);
3707 impossible->setAttribute(Qt::WA_DeleteOnClose);
3708 impossible->show();
3709 } else if (cost <= client_player()->economic.gold) {
3710 hud_message_box *ask = new hud_message_box(gui()->central_wdg);
3711
3713 PL_("Incite a revolt for %d gold?\n%s",
3714 "Incite a revolt for %d gold?\n%s", cost), cost, buf);
3715 ask->setStandardButtons(QMessageBox::Cancel | QMessageBox::Ok);
3716 ask->setDefaultButton(QMessageBox::Cancel);
3717 ask->set_text_title(buf2, _("Incite a Revolt!"));
3718 ask->setAttribute(Qt::WA_DeleteOnClose);
3719 QObject::connect(ask, &hud_message_box::accepted, [=]() {
3722 });
3723 ask->show();
3724 return;
3725 } else {
3726 hud_message_box *too_much = new hud_message_box(gui()->central_wdg);
3727
3729 PL_("Inciting a revolt costs %d gold.\n%s",
3730 "Inciting a revolt costs %d gold.\n%s", cost), cost,
3731 buf);
3732 too_much->set_text_title(buf2, "!");
3733 too_much->setStandardButtons(QMessageBox::Ok);
3734 too_much->setAttribute(Qt::WA_DeleteOnClose);
3735 too_much->show();
3736 }
3737
3739}
3740
3741/***********************************************************************/
3745void popup_bribe_unit_dialog(struct unit *actor, struct unit *tunit, int cost,
3746 const struct action *paction)
3747{
3748 hud_message_box *ask = new hud_message_box(gui()->central_wdg);
3749 char buf[1024];
3750 char buf2[1024];
3751 int diplomat_id = actor->id;
3752 int diplomat_target_id = tunit->id;
3753 const int act_id = paction->id;
3754
3755 // Should be set before sending request to the server.
3757
3758 fc_snprintf(buf, ARRAY_SIZE(buf), PL_("Treasury contains %d gold.",
3759 "Treasury contains %d gold.",
3760 client_player()->economic.gold),
3761 client_player()->economic.gold);
3762
3763 if (cost <= client_player()->economic.gold) {
3764 fc_snprintf(buf2, ARRAY_SIZE(buf2), PL_("Bribe unit for %d gold?\n%s",
3765 "Bribe unit for %d gold?\n%s",
3766 cost), cost, buf);
3767 ask->set_text_title(buf2, _("Bribe Enemy Unit"));
3768 ask->setStandardButtons(QMessageBox::Cancel | QMessageBox::Ok);
3769 ask->setDefaultButton(QMessageBox::Cancel);
3770 ask->setAttribute(Qt::WA_DeleteOnClose);
3771 QObject::connect(ask, &hud_message_box::accepted, [=]() {
3774 });
3775 ask->show();
3776 return;
3777 } else {
3779 PL_("Bribing the unit costs %d gold.\n%s",
3780 "Bribing the unit costs %d gold.\n%s", cost), cost, buf);
3781 ask->set_text_title(buf2, _("Traitors Demand Too Much!"));
3782 ask->setAttribute(Qt::WA_DeleteOnClose);
3783 ask->show();
3784 }
3785
3787}
3788
3789/***********************************************************************/
3794 const struct action *paction)
3795{
3796 hud_message_box *ask = new hud_message_box(gui()->central_wdg);
3797 char buf[1024];
3798 char buf2[1024];
3799 int diplomat_id = actor->id;
3800 int diplomat_target_id = ttile->index;
3801 const int act_id = paction->id;
3802
3803 // Should be set before sending request to the server.
3805
3806 fc_snprintf(buf, ARRAY_SIZE(buf), PL_("Treasury contains %d gold.",
3807 "Treasury contains %d gold.",
3808 client_player()->economic.gold),
3809 client_player()->economic.gold);
3810
3811 if (cost <= client_player()->economic.gold) {
3812 fc_snprintf(buf2, ARRAY_SIZE(buf2), PL_("Bribe unit stack for %d gold?\n%s",
3813 "Bribe unit stack for %d gold?\n%s",
3814 cost), cost, buf);
3815 ask->set_text_title(buf2, _("Bribe Enemy Stack"));
3816 ask->setStandardButtons(QMessageBox::Cancel | QMessageBox::Ok);
3817 ask->setDefaultButton(QMessageBox::Cancel);
3818 ask->setAttribute(Qt::WA_DeleteOnClose);
3819 QObject::connect(ask, &hud_message_box::accepted, [=]() {
3822 });
3823 ask->show();
3824 return;
3825 } else {
3827 PL_("Bribing the unit stack costs %d gold.\n%s",
3828 "Bribing the unit stack costs %d gold.\n%s", cost), cost, buf);
3829 ask->set_text_title(buf2, _("Traitors Demand Too Much!"));
3830 ask->setAttribute(Qt::WA_DeleteOnClose);
3831 ask->show();
3832 }
3833
3835}
3836
3837/***********************************************************************/
3840static void pillage_something(QVariant data1, QVariant data2)
3841{
3842 int punit_id;
3843 int what;
3844 struct unit *punit;
3845 struct extra_type *target;
3846
3847 what = data1.toInt();
3848 punit_id = data2.toInt();
3850 if (punit) {
3851 target = extra_by_number(what);
3853 }
3855}
3856
3857/***********************************************************************/
3860static void spy_sabotage(QVariant data1, QVariant data2)
3861{
3862 int diplomat_id = data1.toList().at(0).toInt();
3863 int diplomat_target_id = data1.toList().at(1).toInt();
3864 action_id act_id = data1.toList().at(2).toInt();
3865
3866 if (game_unit_by_number(diplomat_id) != nullptr
3867 && game_city_by_number(diplomat_target_id) != nullptr) {
3868 if (data2.toInt() == B_LAST) {
3869 // This is the untargeted version.
3871 diplomat_id, diplomat_target_id, data2.toInt(),
3872 "");
3873 } else if (data2.toInt() == -1) {
3874 // This is the city production version.
3876 diplomat_id, diplomat_target_id, data2.toInt(),
3877 "");
3878 } else {
3879 // This is the targeted version.
3881 diplomat_target_id, data2.toInt(), "");
3882 }
3883 }
3884}
3885
3886/***********************************************************************/
3891 const struct action *paction)
3892{
3893 QString str;
3894 QVariant qv1, qv2;
3895 int diplomat_id = actor->id;
3896 int diplomat_target_id = tcity->id;
3898 choice_dialog *cd = new choice_dialog(_("Sabotage"),
3899 _("Select Improvement to Sabotage"),
3900 gui()->game_tab_widget,
3902 int nr = 0;
3903 struct astring stra = ASTRING_INIT;
3905
3906 // Should be set before sending request to the server.
3908
3909 // Put both actor, target city and action in qv1 since qv2 is taken
3912 actor_and_target.append(paction->id);
3913 qv1 = QVariant::fromValue(actor_and_target);
3914
3917 paction->id)])) {
3919 cd->add_item(QString(_("City Production")), func, qv1, -1);
3920 }
3921
3922 city_built_iterate(tcity, pimprove) {
3923 if (pimprove->sabotage > 0) {
3925 // Defeat keyboard shortcut mnemonics
3927 .replace("&", "&&");
3928 qv2 = nr;
3929 cd->add_item(str, func, qv1, improvement_number(pimprove));
3930 nr++;
3931 }
3933
3936 astr_set(&stra, _("At %s's Discretion"),
3939 str = QString(astr_str(&stra)).replace("&", "&&");
3940 cd->add_item(str, func, qv1, B_LAST);
3941 }
3942
3943 cd->set_layout();
3944 cd->show_me();
3945 astr_free(&stra);
3946}
3947
3948/***********************************************************************/
3953{
3954 QString str;
3955 QVariant qv1, qv2;
3958 struct extra_type *tgt;
3959
3961 return;
3962 }
3963 cd = new choice_dialog(_("What To Pillage"), _("Select what to pillage:"),
3964 gui()->game_tab_widget);
3965 qv2 = punit->id;
3966 while ((tgt = get_preferred_pillage(extras))) {
3967 int what;
3968
3969 what = extra_index(tgt);
3970 BV_CLR(extras, what);
3971
3973 // Defeat keyboard shortcut mnemonics
3974 str = QString(extra_name_translation(tgt)).replace("&", "&&");
3975 qv1 = what;
3976 cd->add_item(str, func, qv1, qv2);
3977 }
3978 cd->set_layout();
3979 cd->show_me();
3980}
3981
3982/***********************************************************************/
3986 QWidget *parent) : hud_message_box(parent)
3987{
3988 QString str;
3989 QPushButton *pb;
3990
3991 setAttribute(Qt::WA_DeleteOnClose);
3992 setModal(false);
3997
3998 str = QString(PL_("Are you sure you want to disband that %1 unit?",
3999 "Are you sure you want to disband those %1 units?",
4001 pb = addButton(_("Yes"), QMessageBox::AcceptRole);
4002 addButton(_("No"), QMessageBox::RejectRole);
4003 set_text_title(str, _("Disband units"));
4005 connect(pb, &QAbstractButton::clicked, this, &disband_box::disband_clicked);
4006}
4007
4008/***********************************************************************/
4019
4020/***********************************************************************/
4027
4028/***********************************************************************/
4031void popup_disband_dialog(struct unit_list *punits)
4032{
4033 disband_box *ask = new disband_box(punits, gui()->central_wdg);
4034 ask->show();
4035}
4036
4037/***********************************************************************/
4042{
4043 hud_message_box *ask = new hud_message_box(gui()->central_wdg);
4044 QString text;
4045 QString title;
4046
4047 title = QString(_("Modpack suggests using %1 tileset."))
4049 text = QString("It might not work with other tilesets.\n"
4050 "You are currently using tileset %1.")
4052 ask->addButton(_("Keep current tileset"), QMessageBox::RejectRole);
4053 ask->addButton(_("Load tileset"), QMessageBox::AcceptRole);
4054 ask->set_text_title(text, title);
4055 ask->setAttribute(Qt::WA_DeleteOnClose);
4056
4057 QObject::connect(ask, &hud_message_box::accepted, [=]() {
4060 gui()->map_scale)) {
4062 _("Can't load requested tileset."));
4063 }
4064 });
4065 ask->show();
4066}
4067
4068/***********************************************************************/
4073{
4074 hud_message_box *ask = new hud_message_box(gui()->central_wdg);
4075 QString text;
4076 QString title;
4077
4078 title = QString(_("Modpack suggests using %1 soundset."))
4080 text = QString("It might not work with other tilesets.\n"
4081 "You are currently using soundset %1.")
4082 .arg(sound_set_name);
4083 ask->addButton(_("Keep current soundset"), QMessageBox::RejectRole);
4084 ask->addButton(_("Load soundset"), QMessageBox::AcceptRole);
4085 ask->set_text_title(text, title);
4086 ask->setAttribute(Qt::WA_DeleteOnClose);
4087 QObject::connect(ask, &hud_message_box::accepted, [=]() {
4089 });
4090 ask->show();
4091}
4092
4093/***********************************************************************/
4098{
4099 hud_message_box *ask = new hud_message_box(gui()->central_wdg);
4100 QString text;
4101 QString title;
4102
4103 title = QString(_("Modpack suggests using %1 musicset."))
4105 text = QString("It might not work with other tilesets.\n"
4106 "You are currently using musicset %1.")
4107 .arg(music_set_name);
4108 ask->addButton(_("Keep current musicset"), QMessageBox::RejectRole);
4109 ask->addButton(_("Load musicset"), QMessageBox::AcceptRole);
4110 ask->set_text_title(text, title);
4111 ask->setAttribute(Qt::WA_DeleteOnClose);
4112 QObject::connect(ask, &hud_message_box::accepted, [=]() {
4114 });
4115 ask->show();
4116}
4117
4118/***********************************************************************/
4123{
4124 // PORTME
4125 return false;
4126}
4127
4128/***********************************************************************/
4132{
4134 int i;
4135
4136 nd_list = gui()->mapview_wdg->findChildren<notify_dialog *>();
4137 for (i = 0; i < nd_list.count(); i++) {
4138 nd_list[i]->restart();
4139 delete nd_list[i];
4140 }
4141}
4142
4143/***********************************************************************/
4148{
4149 int i;
4152 goto_dialog *gtd;
4153
4154 QApplication::alert(gui()->central_wdg);
4155 cd_list = gui()->game_tab_widget->findChildren <choice_dialog *>();
4156 for (i = 0; i < cd_list.count(); i++) {
4157 cd_list[i]->close();
4158 }
4159 nd_list = gui()->game_tab_widget->findChildren <notify_dialog *>();
4160 for (i = 0; i < nd_list.count(); i++) {
4161 nd_list[i]->close();
4162 }
4163
4172 gui()->popdown_unit_sel();
4173
4174 gtd = gui()->gtd;
4175
4176 if (gtd != nullptr) {
4177 gtd->close_dlg();
4178 }
4179}
4180
4181/***********************************************************************/
4187{
4188 choice_dialog *cd = gui()->get_diplo_dialog();
4189
4190 if (cd != nullptr) {
4191 return cd->unit_id;
4192 } else {
4193 return IDENTITY_NUMBER_ZERO;
4194 }
4195}
4196
4197/***********************************************************************/
4204{
4205 choice_dialog *cd = gui()->get_diplo_dialog();
4206
4207 if (cd != nullptr) {
4208 return cd->target_id[ATK_CITY];
4209 } else {
4210 return IDENTITY_NUMBER_ZERO;
4211 }
4212}
4213
4214/***********************************************************************/
4221{
4222 choice_dialog *cd = gui()->get_diplo_dialog();
4223
4224 if (cd != nullptr) {
4225 return cd->target_id[ATK_TILE];
4226 } else {
4227 return TILE_INDEX_NONE;
4228 }
4229}
4230
4231/**********************************************************************/
4238{
4239 choice_dialog *cd = gui()->get_diplo_dialog();
4240
4241 if (cd != nullptr) {
4242 return cd->sub_target_id[ASTK_EXTRA];
4243 } else {
4244 return EXTRA_NONE;
4245 }
4246}
4247
4248/***********************************************************************/
4255{
4256 choice_dialog *cd = gui()->get_diplo_dialog();
4257
4258 if (cd != nullptr) {
4259 return cd->target_id[ATK_UNIT];
4260 } else {
4261 return IDENTITY_NUMBER_ZERO;
4262 }
4263}
4264
4265/***********************************************************************/
4269 struct city *target_city,
4270 struct unit *target_unit,
4271 struct tile *target_tile,
4272 struct extra_type *target_extra,
4273 const struct act_prob *act_probs)
4274{
4277 Choice_dialog_button *cancel_button;
4278 QVariant qv1, qv2;
4279
4280 asd = gui()->get_diplo_dialog();
4281 if (asd == nullptr) {
4282 fc_assert_msg(asd != nullptr,
4283 "The action selection dialog should have been open");
4284 return;
4285 }
4286
4289 "The action selection dialog is for another actor unit.");
4290 }
4291
4292 // Put the actor id in qv1.
4293 qv1 = actor_unit->id;
4294
4295 cancel_button = asd->get_identified_button(BUTTON_CANCEL);
4296 if (cancel_button != nullptr) {
4297 /* Temporary remove the Cancel button so it won't end up above
4298 * any added buttons. */
4299 asd->stack_button(cancel_button);
4300 }
4301
4302 wait_button = asd->get_identified_button(BUTTON_WAIT);
4303 if (wait_button != nullptr) {
4304 /* Temporary remove the Wait button so it won't end up above
4305 * any added buttons. */
4306 asd->stack_button(wait_button);
4307 }
4308
4309 action_iterate(act) {
4310 const char *custom;
4311
4312 if (action_id_get_actor_kind(act) != AAK_UNIT) {
4313 // Not relevant.
4314 continue;
4315 }
4316
4318 act_probs[act],
4319 actor_unit,
4320 target_city);
4321
4322 // Put the target id in qv2.
4323 switch (action_id_get_target_kind(act)) {
4324 case ATK_UNIT:
4325 if (target_unit != nullptr) {
4326 qv2 = target_unit->id;
4327 } else {
4329 || target_unit != nullptr,
4330 "Action enabled against non existing unit!");
4331
4333 }
4334 break;
4335 case ATK_CITY:
4336 if (target_city != nullptr) {
4337 qv2 = target_city->id;
4338 } else {
4340 || target_city != nullptr,
4341 "Action enabled against non existing city!");
4342
4344 }
4345 break;
4346 case ATK_TILE:
4347 case ATK_EXTRAS:
4348 case ATK_STACK:
4349 if (target_tile != nullptr) {
4351 } else {
4353 || target_tile != nullptr,
4354 "Action enabled against all units on "
4355 "non existing tile!");
4356
4358 }
4359 break;
4360 case ATK_SELF:
4361 qv2 = actor_unit->id;
4362 break;
4363 case ATK_COUNT:
4365 "Bad target kind");
4366 continue;
4367 }
4368
4369 if (asd->get_identified_button(act)) {
4370 // Update the existing button.
4371 action_entry_update(asd->get_identified_button(act),
4372 act, act_probs, custom,
4373 qv1, qv2);
4374 } else {
4375 // Add the button (unless its probability is 0).
4377 qv1, qv2);
4378 }
4380
4381 if (wait_button != nullptr || cancel_button != nullptr) {
4382 /* Reinsert the non action buttons below any potential
4383 * buttons recently added. */
4384 asd->unstack_all_buttons();
4385 }
4386}
4387
4388/***********************************************************************/
4392{
4394
4395 cd = gui()->get_diplo_dialog();
4396 if (cd != nullptr) {
4397 did_not_decide = true;
4398 cd->close();
4399 }
4400}
4401
4402/***********************************************************************/
4408
4409/***********************************************************************/
4412void show_tileset_error(bool fatal, const char *tset_name, const char *msg)
4413{
4414 QWidget *parent;
4415 fc_client *std_gui = gui();
4416
4417 if (std_gui != nullptr) {
4418 parent = std_gui->central_wdg;
4419 } else {
4420 parent = nullptr;
4421 }
4422
4423 if (std_gui != nullptr || fatal) {
4424 char buf[1024];
4425 QMessageBox *ask = new QMessageBox(parent);
4426
4427 if (tset_name != nullptr) {
4428 fc_snprintf(buf, sizeof(buf),
4429 _("Tileset \"%s\" problem, it's probably incompatible with "
4430 "the ruleset:\n%s"), tset_name, msg);
4431 } else {
4432 fc_snprintf(buf, sizeof(buf),
4433 _("Tileset problem, it's probably incompatible with "
4434 "the ruleset:\n%s"), msg);
4435 }
4436
4437 ask->setText(buf);
4438 ask->setStandardButtons(QMessageBox::Ok);
4439 ask->setWindowTitle(_("Tileset error"));
4440
4441 if (std_gui != nullptr && !fatal) {
4442 ask->setAttribute(Qt::WA_DeleteOnClose);
4443 ask->show();
4444 } else {
4445 ask->exec();
4446 }
4447 }
4448}
4449
4450/***********************************************************************/
4453void popup_upgrade_dialog(struct unit_list *punits)
4454{
4455 char buf[512];
4457 QString title;
4459
4460 if (!punits || unit_list_size(punits) == 0) {
4461 return;
4462 }
4463
4464 ask = new hud_message_box(gui()->central_wdg);
4465
4466 punit_ids = new QVector<int>();
4468 punit_ids->push_back(punit->id);
4470
4471 if (!get_units_upgrade_info(buf, sizeof(buf), punits)) {
4472 title = _("Upgrade Unit!");
4473 ask->setStandardButtons(QMessageBox::Ok);
4474 } else {
4475 title = _("Upgrade Obsolete Units");
4476 ask->setStandardButtons(QMessageBox::Cancel | QMessageBox::Ok);
4477 ask->setDefaultButton(QMessageBox::Cancel);
4478 }
4479 ask->set_text_title(buf, title);
4480 ask->setAttribute(Qt::WA_DeleteOnClose);
4481 QObject::connect(ask, &hud_message_box::accepted, [=]() {
4482 std::unique_ptr<QVector<int>> uptr(punit_ids);
4483 struct unit *punit;
4484
4485 for (int id : *uptr) {
4487 if (punit) {
4489 }
4490 }
4491 });
4492 ask->show();
4493}
4494
4495/***********************************************************************/
4499{
4500 QPoint p, final_p;
4501
4503 utile = ptile;
4504 pix = nullptr;
4505 show_line = 0;
4506 highligh_num = -1;
4507 ufont.setItalic(true);
4509 update_units();
4510 h_pix = nullptr;
4511 create_pixmap();
4512 p = mapFromGlobal(QCursor::pos());
4513 cw = new close_widget(this);
4514 setMouseTracking(true);
4515 final_p.setX(p.x());
4516 final_p.setY(p.y());
4517 if (p.x() + width() > parentWidget()->width()) {
4518 final_p.setX(parentWidget()->width() - width());
4519 }
4520 if (p.y() - height() < 0) {
4521 final_p.setY(height());
4522 }
4523 move(final_p.x(), final_p.y() - height());
4524 setFocus();
4525 /* Build fails with qt5 connect style for static functions
4526 * Qt5.2 so dont update */
4527 QTimer::singleShot(10, this, SLOT(update_img()));
4528}
4529
4530/***********************************************************************/
4534{
4535 delete h_pix;
4536 delete pix;
4537 delete cw;
4538}
4539
4540/***********************************************************************/
4544{
4545 int a;
4546 int x, y, i;
4549 QImage img;
4551 QPainter p;
4552 QPen pen;
4553 QPixmap pixc;
4554 QPixmap *pixp;
4556 QRect crop;
4557 struct canvas *unit_pixmap;
4558 struct unit *punit;
4559 float isosize;
4560
4561 if (pix != nullptr) {
4562 delete pix;
4563 pix = nullptr;
4564 };
4565 isosize = 0.7;
4567 isosize = 0.5;
4568 }
4569
4570 update_units();
4571 if (unit_list.count() > 0) {
4575 } else {
4578 }
4579 more = false;
4580 if (h_pix != nullptr) {
4581 delete h_pix;
4582 }
4583 h_pix = new QPixmap(item_size.width(), item_size.height());
4584 h_pix->fill(palette().color(QPalette::HighlightedText));
4585 if (unit_count < 5) {
4586 row_count = 1;
4587 pix = new QPixmap((unit_list.size()) * item_size.width(),
4588 item_size.height());
4589 } else if (unit_count < 9) {
4590 row_count = 2;
4591 pix = new QPixmap(4 * item_size.width(), 2 * item_size.height());
4592 } else {
4593 row_count = 3;
4594 if (unit_count > 12) {
4595 more = true;
4596 }
4597 pix = new QPixmap(4 * item_size.width(), 3 * item_size.height());
4598 }
4599 pix->fill(Qt::transparent);
4600 foreach(punit, unit_list) {
4603 unit_pixmap->map_pixmap.fill(Qt::transparent);
4604 put_unit(punit, unit_pixmap, 1.0, 0, 0);
4605 img = unit_pixmap->map_pixmap.toImage();
4607 cropped_img = img.copy(crop);
4611 Qt::KeepAspectRatio,
4612 Qt::SmoothTransformation);
4613 } else {
4616 Qt::KeepAspectRatio,
4617 Qt::SmoothTransformation);
4618 }
4619 pixc = QPixmap::fromImage(img);
4620 pixp = new QPixmap(pixc);
4621 pix_list.push_back(pixp);
4623 }
4624 a = qMin(item_size.width() / 4, 12);
4625 x = 0, y = -item_size.height(), i = -1;
4626 p.begin(pix);
4627 ufont.setPixelSize(a);
4628 p.setFont(ufont);
4629 pen.setColor(palette().color(QPalette::Text));
4630 p.setPen(pen);
4631
4632 while (!pix_list.isEmpty()) {
4633 tmp_pix = pix_list.takeFirst();
4634 i++;
4635 if (i % 4 == 0) {
4636 x = 0;
4637 y = y + item_size.height();
4638 }
4639 punit = unit_list.at(i);
4640 Q_ASSERT(punit != nullptr);
4641
4642 if (i == highligh_num) {
4643 p.drawPixmap(x, y, *h_pix);
4644 p.drawPixmap(x, y, *tmp_pix);
4645 } else {
4646 p.drawPixmap(x, y, *tmp_pix);
4647 }
4648
4650 int rate, f;
4651 QString str;
4652
4654 f = ((punit->fuel) - 1);
4657 str = str + "(" + QString(move_points_text((rate * f)
4658 + punit->moves_left, false)) + ")";
4659 }
4660 // TRANS: MP = Movement points
4661 str = QString(_("MP:")) + str;
4662 p.drawText(x, y + item_size.height() - 4, str);
4663 }
4664
4665 x = x + item_size.width();
4666 delete tmp_pix;
4667 }
4668 p.end();
4669 setFixedWidth(pix->width() + 20);
4670 setFixedHeight(pix->height() + 2 * (fm.height() + 6));
4671 qDeleteAll(pix_list.begin(), pix_list.end());
4672 }
4673}
4674
4675/***********************************************************************/
4679{
4680 int a, b;
4681 int old_h;
4683 QPoint pos = event->pos();
4684 int x = pos.x();
4685 int y = pos.y();
4686
4688 highligh_num = -1;
4689 if (x > width() - 11
4690 || y > height() - fm.height() - 5
4691 || y < fm.height() + 3 || x < 11) {
4692 // Do nothing if mouse is on border, just skip next if
4693 } else if (row_count > 0) {
4694 a = (x - 10) / item_size.width();
4695 b = (y - fm.height() - 3) / item_size.height();
4696 highligh_num = b * 4 + a;
4697 }
4698 if (old_h != highligh_num) {
4699 create_pixmap();
4700 update();
4701 }
4702}
4703
4704/***********************************************************************/
4710{
4711 struct unit *punit;
4712 if (event->button() == Qt::RightButton) {
4713 was_destroyed = true;
4714 close();
4715 destroy();
4716 }
4717 if (event->button() == Qt::LeftButton && highligh_num != -1) {
4718 update_units();
4719 if (highligh_num >= unit_list.count()) {
4720 return;
4721 }
4724 was_destroyed = true;
4725 close();
4726 destroy();
4727 }
4728}
4729
4730/***********************************************************************/
4735{
4736 create_pixmap();
4737 update();
4738}
4739
4740/***********************************************************************/
4744{
4746 int h, i;
4747 int *f_size;
4748 QPen pen;
4749 QString str, str2;
4750 struct unit *punit;
4751 int point_size = info_font.pointSize();
4752 int pixel_size = info_font.pixelSize();
4753
4754 if (point_size < 0) {
4755 f_size = &pixel_size;
4756 } else {
4757 f_size = &point_size;
4758 }
4759 if (highligh_num != -1 && highligh_num < unit_list.count()) {
4760 struct astring addition = ASTRING_INIT;
4761
4764
4765 // TRANS: HP - hit points
4766 str2 = QString(_("%1 HP:%2/%3")).arg(QString(astr_str(&addition)),
4767 QString::number(punit->hp),
4768 QString::number(unit_type_get(punit)->hp));
4770 }
4771 str = QString(PL_("%1 unit", "%1 units",
4773 .arg(unit_list_size(utile->units));
4774 for (i = *f_size; i > 4; i--) {
4775 if (point_size < 0) {
4776 info_font.setPixelSize(i);
4777 } else {
4778 info_font.setPointSize(i);
4779 }
4781 if (10 + qfm.horizontalAdvance(str2) < width()) {
4782 break;
4783 }
4784 }
4785 h = fm.height();
4786 if (pix != nullptr) {
4787 painter->drawPixmap(10, h + 3, *pix);
4788 pen.setColor(palette().color(QPalette::Text));
4789 painter->setPen(pen);
4790 painter->setFont(info_font);
4791 painter->drawText(10, h, str);
4792 if (highligh_num != -1 && highligh_num < unit_list.count()) {
4793 painter->drawText(10, height() - 5, str2);
4794 }
4795 // Draw scroll
4796 if (more) {
4797 int maxl = ((unit_count - 1) / 4) + 1;
4798 float page_height = 3.0f / maxl;
4799 float page_start = (static_cast<float>(show_line)) / maxl;
4800 pen.setColor(palette().color(QPalette::HighlightedText));
4801 painter->setBrush(palette().color(QPalette::HighlightedText).darker());
4802 painter->setPen(palette().color(QPalette::HighlightedText).darker());
4803 painter->drawRect(pix->width() + 10, h, 8, h + pix->height());
4804 painter->setPen(pen);
4805 painter->drawRoundedRect(pix->width() + 10,
4806 h + page_start * pix->height(),
4807 8, h + page_height * pix->height(), 2, 2);
4808 }
4809 }
4810 if (point_size < 0) {
4811 info_font.setPixelSize(*f_size);
4812 } else {
4813 info_font.setPointSize(*f_size);
4814 }
4815 cw->put_to_corner();
4816}
4817
4818/***********************************************************************/
4822{
4824
4825 painter.begin(this);
4826 paint(&painter, event);
4827 painter.end();
4828}
4829
4830/***********************************************************************/
4835{
4836 was_destroyed = true;
4837 close();
4838 destroy();
4839}
4840
4841/***********************************************************************/
4845{
4846 int i = 1;
4847 struct unit_list *punit_list;
4848
4849 unit_count = 0;
4850 if (utile == nullptr) {
4851 struct unit *punit = head_of_units_in_focus();
4852 if (punit) {
4854 }
4855 }
4856 unit_list.clear();
4857 if (utile != nullptr) {
4859 if (punit_list != nullptr) {
4861 unit_count++;
4862 if (i > show_line * 4)
4863 unit_list.push_back(punit);
4864 i++;
4866 }
4867 }
4868 if (unit_list.count() == 0) {
4869 close();
4870 }
4871}
4872
4873/***********************************************************************/
4877{
4878 gui()->mapview_wdg->setFocus();
4879 QWidget::closeEvent(event);
4880}
4881
4882/***********************************************************************/
4886{
4887 int nr;
4888
4889 if (!more && utile == nullptr) {
4890 return;
4891 }
4892 nr = qCeil(static_cast<qreal>(unit_list_size(utile->units)) / 4) - 3;
4893 if (event->angleDelta().y() < 0) {
4894 show_line++;
4896 } else {
4897 show_line--;
4898 show_line = qMax(0, show_line);
4899 }
4900 update_units();
4901 create_pixmap();
4902 update();
4903 event->accept();
4904}
4905
4906/***********************************************************************/
4910{
4911 if (event->key() == Qt::Key_Escape) {
4912 was_destroyed = true;
4913 close();
4914 destroy();
4915 }
4916 QWidget::keyPressEvent(event);
4917}
4918
4919/***********************************************************************/
4926
4927/***********************************************************************/
4934
4935/***********************************************************************/
4940{
4941 // Just tell the client common code to handle this.
4942 return false;
4943}
4944
4945/***********************************************************************/
4948bool qtg_request_transport(struct unit *pcargo, struct tile *ptile)
4949{
4950 int tcount;
4952 struct unit_list *potential_transports = unit_list_new();
4953#ifndef FREECIV_NDEBUG
4955#endif
4956
4960 }
4962
4964
4965 if (tcount == 0) {
4966 fc_assert(best_transport == nullptr);
4968
4969 return false; // Unit was not handled here.
4970 } else if (tcount == 1) {
4971 // There's exactly one potential transport - use it automatically
4974
4976
4977 return true;
4978 }
4979
4980 hul = new hud_unit_loader(pcargo, ptile);
4981 hul->show_me();
4982 return true;
4983}
4984
4985/***********************************************************************/
4989void qtg_popup_combat_info(int attacker_unit_id, int defender_unit_id,
4990 int attacker_hp, int defender_hp,
4991 bool make_att_veteran, bool make_def_veteran)
4992{
4993 if (gui()->qt_settings.show_battle_log) {
4994 hud_unit_combat *huc = new hud_unit_combat(attacker_unit_id,
4995 defender_unit_id,
4996 attacker_hp, defender_hp,
4997 make_att_veteran,
4998 make_def_veteran,
4999 gui()->battlelog_wdg->scale,
5000 gui()->battlelog_wdg);
5001
5002 gui()->battlelog_wdg->add_combat_info(huc);
5003 gui()->battlelog_wdg->show();
5004 }
5005}
5006
5007/**********************************************************************/
5011 struct act_confirmation_data *data)
5012{
5013 hud_message_box *ask = new hud_message_box(gui()->central_wdg);
5014
5015 ask->setStandardButtons(QMessageBox::Cancel | QMessageBox::Ok);
5016 ask->setDefaultButton(QMessageBox::Cancel);
5017 ask->set_text_title(body, hdr);
5018 ask->setAttribute(Qt::WA_DeleteOnClose);
5019 QObject::connect(ask, &hud_message_box::accepted, [=]() {
5021 });
5022 QObject::connect(ask, &hud_message_box::rejected, [=]() {
5024 });
5025
5026 ask->show();
5027}
5028
5029/***********************************************************************/
5033 struct act_confirmation_data *data)
5034{
5036
5037 hdr = QString(_("Are you sure you want to do %1?")).
5039
5040 if (expl != nullptr) {
5042 }
5043
5045}
5046
5047/**********************************************************************/
5050void qtg_popup_image(const char *tag)
5051{
5052 struct sprite *spr = load_popup_sprite(tag);
5053
5054 if (spr != nullptr) {
5055 QDialog *win = new QDialog(gui());
5056 QVBoxLayout *layout = new QVBoxLayout(win);
5057 QPixmap *pm = new QPixmap(*spr->pm);
5058 QLabel *lbl = new QLabel;
5059 int width, height;
5060
5062 win->setFixedSize(width, height);
5063 lbl->setPixmap(*pm);
5064 layout->addWidget(lbl);
5065 win->setLayout(layout);
5066
5067 win->show();
5068
5070 } else {
5071 log_error(_("No image for tag \"%s\", requested by the server."), tag);
5072 }
5073}
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:663
const char * city_name_get(const struct city *pcity)
Definition city.c:1137
#define INCITE_IMPOSSIBLE_COST
Definition city.h:94
#define city_owner(_pcity_)
Definition city.h:563
#define city_built_iterate(_pcity, _p)
Definition city.h:835
#define city_built_iterate_end
Definition city.h:841
void qtg_real_city_dialog_popup(struct city *pcity)
Definition citydlg.cpp:3832
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:4011
disband_box(struct unit_list *punits, QWidget *parent=0)
Definition dialogs.cpp:3985
struct unit_list * cpunits
Definition dialogs.h:97
choice_dialog * opened_dialog
Definition fc_client.h:219
choice_dialog * get_diplo_dialog()
Definition dialogs.cpp:4930
void set_diplo_dialog(choice_dialog *widget)
Definition dialogs.cpp:4922
static fc_font * instance()
Definition fonts.cpp:41
QFont * get_font(QString name)
Definition fonts.cpp:63
QPixmap * get_pixmap(const QString &id)
static fc_icons * instance()
bool was_destroyed
Definition mapview.h:176
void close_dlg()
Definition gotodlg.cpp:475
int set_text_title(QString s1, QString s2, bool return_exec=false)
QString qheadline
Definition dialogs.h:193
void restart()
Definition dialogs.cpp:910
close_widget * cw
Definition dialogs.h:189
void mouseReleaseEvent(QMouseEvent *event)
Definition dialogs.cpp:1003
QFont small_font
Definition dialogs.h:195
QString qcaption
Definition dialogs.h:192
notify_dialog(const char *caption, const char *headline, const char *lines, QWidget *parent=0)
Definition dialogs.cpp:877
void calc_size(int &x, int &y)
Definition dialogs.cpp:938
void paintEvent(QPaintEvent *paint_event)
Definition dialogs.cpp:957
QPoint cursor
Definition dialogs.h:196
void mouseMoveEvent(QMouseEvent *event)
Definition dialogs.cpp:993
virtual void update_menu()
Definition dialogs.cpp:1011
void mousePressEvent(QMouseEvent *event)
Definition dialogs.cpp:980
QStringList qlist
Definition dialogs.h:194
QPushButton * close_but
Definition dialogs.h:113
notify_goto(const char *headline, const char *lines, const struct text_tag_list *tags, struct tile *ptile, QWidget *parent)
Definition dialogs.cpp:1112
QPushButton * goto_but
Definition dialogs.h:111
void inspect_city()
Definition dialogs.cpp:1155
struct tile * gtile
Definition dialogs.h:114
QPushButton * inspect_but
Definition dialogs.h:112
void goto_tile()
Definition dialogs.cpp:1146
action_id vs_unit
Definition dialogs.h:60
static qdef_act * action()
Definition dialogs.cpp:1040
action_id vs_city_get()
Definition dialogs.cpp:1078
static qdef_act * m_instance
Definition dialogs.h:58
static void drop()
Definition dialogs.cpp:1051
action_id vs_city
Definition dialogs.h:59
void vs_city_set(int i)
Definition dialogs.cpp:1062
void vs_unit_set(int i)
Definition dialogs.cpp:1070
action_id vs_unit_get()
Definition dialogs.cpp:1086
QPoint point
Definition dialogs.h:81
void paintEvent(QPaintEvent *event)
Definition dialogs.cpp:353
QPixmap close_pix
Definition dialogs.h:83
void reactivate()
Definition dialogs.cpp:345
void mouseMoveEvent(QMouseEvent *event)
Definition dialogs.cpp:394
int titlebar_height
Definition dialogs.h:80
void mousePressEvent(QMouseEvent *event)
Definition dialogs.cpp:404
void mouseReleaseEvent(QMouseEvent *event)
Definition dialogs.cpp:424
qfc_dialog(QWidget *parent)
Definition dialogs.cpp:333
bool moving_now
Definition dialogs.h:82
int selected_style
Definition dialogs.h:164
QComboBox * leader_name
Definition dialogs.h:135
void random_pressed()
Definition dialogs.cpp:1102
int last_index
Definition dialogs.h:166
QTableWidget * selected_nation_tabs
Definition dialogs.h:134
QPushButton * random_button
Definition dialogs.h:143
void refresh()
Definition dialogs.cpp:613
void style_selected(const QItemSelection &selected)
Definition dialogs.cpp:806
void nationset_changed(int index)
Definition dialogs.cpp:1167
int selected_nation
Definition dialogs.h:163
void ok_pressed()
Definition dialogs.cpp:839
void leader_selected(int index)
Definition dialogs.cpp:824
QPushButton * ok_button
Definition dialogs.h:142
QTextEdit * description
Definition dialogs.h:141
void set_index(int index)
Definition dialogs.cpp:696
QComboBox * qnation_set
Definition dialogs.h:136
QRadioButton * is_male
Definition dialogs.h:138
QButtonGroup * sex_buttons
Definition dialogs.h:137
void update_nationset_combo()
Definition dialogs.cpp:663
QTableWidget * styles
Definition dialogs.h:140
void group_selected(const QItemSelection &selected)
Definition dialogs.cpp:679
struct player * tplayer
Definition dialogs.h:165
races_dialog(struct player *pplayer, QWidget *parent=0)
Definition dialogs.cpp:433
QRadioButton * is_female
Definition dialogs.h:139
QTableWidget * nation_tabs
Definition dialogs.h:132
QGridLayout * main_layout
Definition dialogs.h:131
void nation_selected(const QItemSelection &selected)
Definition dialogs.cpp:756
void cancel_pressed()
Definition dialogs.cpp:1094
QPixmap * h_pix
Definition dialogs.h:206
QFont ufont
Definition dialogs.h:210
QFont info_font
Definition dialogs.h:211
void closeEvent(QCloseEvent *event)
Definition dialogs.cpp:4876
void update_img()
Definition dialogs.cpp:4734
int show_line
Definition dialogs.h:233
void mouseMoveEvent(QMouseEvent *event)
Definition dialogs.cpp:4678
int highligh_num
Definition dialogs.h:234
void paint(QPainter *painter, QPaintEvent *event)
Definition dialogs.cpp:4743
void update_menu()
Definition dialogs.cpp:4834
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:4498
void update_units()
Definition dialogs.cpp:4844
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:4821
void create_pixmap()
Definition dialogs.cpp:4543
void wheelEvent(QWheelEvent *event)
Definition dialogs.cpp:4885
void keyPressEvent(QKeyEvent *event)
Definition dialogs.cpp:4909
void mousePressEvent(QMouseEvent *event)
Definition dialogs.cpp:4709
close_widget * cw
Definition dialogs.h:213
char music_set_name[512]
bool client_is_global_observer(void)
struct civclient client
enum client_states client_state(void)
char sound_set_name[512]
#define client_player()
@ C_S_RUNNING
Definition client_main.h:47
void client_unit_init_act_prob_cache(struct unit *punit)
Definition climisc.c:1259
char * incite_cost
Definition comments.c:77
void action_selection_no_longer_in_progress(const int old_actor_id)
Definition control.c:1051
void request_unit_load(struct unit *pcargo, struct unit *ptrans, struct tile *ptile)
Definition control.c:2156
void unit_focus_set(struct unit *punit)
Definition control.c:506
void request_do_action(action_id action, int actor_id, int target_id, int sub_tgt, const char *name)
Definition control.c:1730
void request_unit_disband(struct unit *punit)
Definition control.c:2075
void request_action_details(action_id action, int actor_id, int target_id)
Definition control.c:1798
void request_new_unit_activity_targeted(struct unit *punit, enum unit_activity act, struct extra_type *tgt)
Definition control.c:1938
void action_confirmation(struct act_confirmation_data *data, bool confirm)
Definition control.c:1766
void action_decision_clear_want(const int old_actor_id)
Definition control.c:1080
void key_unit_wait(void)
Definition control.c:3542
struct unit * head_of_units_in_focus(void)
Definition control.c:410
void request_unit_upgrade(struct unit *punit)
Definition control.c:2106
void action_selection_next_in_focus(const int old_actor_id)
Definition control.c:1092
bool qtg_handmade_scenario_warning()
Definition dialogs.cpp:4939
static void attack(QVariant data1, QVariant data2)
Definition dialogs.cpp:3044
static void wipe_units(QVariant data1, QVariant data2)
Definition dialogs.cpp:2765
char forced_tileset_name[512]
int action_selection_target_extra(void)
Definition dialogs.cpp:4237
static void destroy_city(QVariant data1, QVariant data2)
Definition dialogs.cpp:3421
static void spy_sabotage_unit(QVariant data1, QVariant data2)
Definition dialogs.cpp:2473
static void pillage(QVariant data1, QVariant data2)
Definition dialogs.cpp:2905
static void caravan_marketplace(QVariant data1, QVariant data2)
Definition dialogs.cpp:1742
static void clean(QVariant data1, QVariant data2)
Definition dialogs.cpp:2925
static void spy_steal_shared(QVariant data1, QVariant data2, action_id act_id)
Definition dialogs.cpp:3179
static void spy_sabotage(QVariant data1, QVariant data2)
Definition dialogs.cpp:3860
int action_selection_target_tile(void)
Definition dialogs.cpp:4220
static void spy_investigate(QVariant data1, QVariant data2)
Definition dialogs.cpp:3541
static void act_sel_wait(QVariant data1, QVariant data2)
Definition dialogs.cpp:1911
static void nuke_units(QVariant data1, QVariant data2)
Definition dialogs.cpp:2741
int action_selection_actor_unit(void)
Definition dialogs.cpp:4186
static void capture_units(QVariant data1, QVariant data2)
Definition dialogs.cpp:2777
static void road(QVariant data1, QVariant data2)
Definition dialogs.cpp:2945
static bool is_race_dialog_open
Definition dialogs.cpp:191
static void transport_embark4(QVariant data1, QVariant data2)
Definition dialogs.cpp:2585
bool try_default_unit_action(QVariant q1, QVariant q2)
Definition dialogs.cpp:1553
static void fortify(QVariant data1, QVariant data2)
Definition dialogs.cpp:2398
static void transport_board(QVariant data1, QVariant data2)
Definition dialogs.cpp:2519
static void diplomat_bribe_unit(QVariant data1, QVariant data2)
Definition dialogs.cpp:2438
static void spy_sabotage_unit_esc(QVariant data1, QVariant data2)
Definition dialogs.cpp:2485
static void disband_unit(QVariant data1, QVariant data2)
Definition dialogs.cpp:2386
static void spy_steal_gold(QVariant data1, QVariant data2)
Definition dialogs.cpp:3436
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:3496
static void mine(QVariant data1, QVariant data2)
Definition dialogs.cpp:2987
void popup_musicset_suggestion_dialog(void)
Definition dialogs.cpp:4097
static void spy_steal_gold_esc(QVariant data1, QVariant data2)
Definition dialogs.cpp:3451
static void diplomat_embassy(QVariant data1, QVariant data2)
Definition dialogs.cpp:3526
void unit_select_dialog_popup(struct tile *ptile)
Definition dialogs.cpp:1252
void popup_upgrade_dialog(struct unit_list *punits)
Definition dialogs.cpp:4453
void update_nationset_combo()
Definition dialogs.cpp:1272
void action_selection_close(void)
Definition dialogs.cpp:4391
static void cultivate(QVariant data1, QVariant data2)
Definition dialogs.cpp:2875
static void paradrop_enter(QVariant data1, QVariant data2)
Definition dialogs.cpp:3134
void races_update_pickable(bool nationset_change)
Definition dialogs.cpp:1282
int action_selection_target_city(void)
Definition dialogs.cpp:4203
static void spy_steal_something(QVariant data1, QVariant data2)
Definition dialogs.cpp:3269
#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:3346
static void transport_board2(QVariant data1, QVariant data2)
Definition dialogs.cpp:2530
void show_tech_gained_dialog(Tech_type_id tech)
Definition dialogs.cpp:4405
static void base(QVariant data1, QVariant data2)
Definition dialogs.cpp:2966
static void spy_nuke_city_esc(QVariant data1, QVariant data2)
Definition dialogs.cpp:3391
void popup_soundset_suggestion_dialog(void)
Definition dialogs.cpp:4072
static void enter_hut2(QVariant data1, QVariant data2)
Definition dialogs.cpp:2696
void popup_races_dialog(struct player *pplayer)
Definition dialogs.cpp:1227
static void expel_unit(QVariant data1, QVariant data2)
Definition dialogs.cpp:2789
static void paradrop_frighten(QVariant data1, QVariant data2)
Definition dialogs.cpp:3104
static void diplomat_sabotage(QVariant data1, QVariant data2)
Definition dialogs.cpp:3571
void popup_disband_dialog(struct unit_list *punits)
Definition dialogs.cpp:4031
static action_id get_non_targeted_action_id(action_id tgt_action_id)
Definition dialogs.cpp:2281
static void homeless(QVariant data1, QVariant data2)
Definition dialogs.cpp:2424
static void caravan_help_build(QVariant data1, QVariant data2)
Definition dialogs.cpp:1772
void qtg_popup_image(const char *tag)
Definition dialogs.cpp:5050
static void bombard(QVariant data1, QVariant data2)
Definition dialogs.cpp:2801
void popup_bribe_stack_dialog(struct unit *actor, struct tile *ttile, int cost, const struct action *paction)
Definition dialogs.cpp:3793
void popdown_races_dialog(void)
Definition dialogs.cpp:1241
void popup_tileset_suggestion_dialog(void)
Definition dialogs.cpp:4041
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:3164
static void spy_request_sabotage_list(QVariant data1, QVariant data2)
Definition dialogs.cpp:3309
static void popup_act_confirmation_dialog(QString hdr, QString body, struct act_confirmation_data *data)
Definition dialogs.cpp:5010
static void unit_disband_recover(QVariant data1, QVariant data2)
Definition dialogs.cpp:1787
static void spy_steal(QVariant data1, QVariant data2)
Definition dialogs.cpp:3253
static void airlift(QVariant data1, QVariant data2)
Definition dialogs.cpp:1838
void popup_pillage_dialog(struct unit *punit, bv_extras extras)
Definition dialogs.cpp:3952
static void transport_load3(QVariant data1, QVariant data2)
Definition dialogs.cpp:2629
static void bombard_lethal(QVariant data1, QVariant data2)
Definition dialogs.cpp:2837
static void plant(QVariant data1, QVariant data2)
Definition dialogs.cpp:2890
static void diplomat_bribe_stack(QVariant data1, QVariant data2)
Definition dialogs.cpp:2456
static void nuke(QVariant data1, QVariant data2)
Definition dialogs.cpp:3029
static void disembark2(QVariant data1, QVariant data2)
Definition dialogs.cpp:2666
static void transport_unload(QVariant data1, QVariant data2)
Definition dialogs.cpp:2596
void qtg_request_action_confirmation(const char *expl, struct act_confirmation_data *data)
Definition dialogs.cpp:5032
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:4268
void popdown_science_report()
static void transport_load2(QVariant data1, QVariant data2)
Definition dialogs.cpp:2618
static void diplomat_steal(QVariant data1, QVariant data2)
Definition dialogs.cpp:3601
static void unit_upgrade(QVariant data1, QVariant data2)
Definition dialogs.cpp:1817
bool popup_theme_suggestion_dialog(const char *theme_name)
Definition dialogs.cpp:4122
static void enter_hut(QVariant data1, QVariant data2)
Definition dialogs.cpp:2681
static void spy_request_strike_bld_list(QVariant data1, QVariant data2)
Definition dialogs.cpp:3292
static void diplomat_incite_escape(QVariant data1, QVariant data2)
Definition dialogs.cpp:3649
static void found_city(QVariant data1, QVariant data2)
Definition dialogs.cpp:2849
static void diplomat_investigate(QVariant data1, QVariant data2)
Definition dialogs.cpp:3556
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:4989
static void bombard3(QVariant data1, QVariant data2)
Definition dialogs.cpp:2825
static void transport_deboard(QVariant data1, QVariant data2)
Definition dialogs.cpp:2640
static void diplomat_incite(QVariant data1, QVariant data2)
Definition dialogs.cpp:3631
static void paradrop_conquer(QVariant data1, QVariant data2)
Definition dialogs.cpp:3089
void popdown_endgame_report()
static void diplomat_steal_esc(QVariant data1, QVariant data2)
Definition dialogs.cpp:3616
static bool is_more_user_input_needed
Definition dialogs.cpp:196
static void bombard2(QVariant data1, QVariant data2)
Definition dialogs.cpp:2813
void popup_incite_dialog(struct unit *actor, struct city *tcity, int cost, const struct action *paction)
Definition dialogs.cpp:3683
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:3406
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:3586
void popdown_units_report()
static void transport_embark2(QVariant data1, QVariant data2)
Definition dialogs.cpp:2563
static void spy_nuke_city(QVariant data1, QVariant data2)
Definition dialogs.cpp:3376
void unit_select_dialog_update_real(void *unused)
Definition dialogs.cpp:1264
static void spy_steal_esc(QVariant data1, QVariant data2)
Definition dialogs.cpp:3261
static void paradrop(QVariant data1, QVariant data2)
Definition dialogs.cpp:3074
static void suicide_attack(QVariant data1, QVariant data2)
Definition dialogs.cpp:3059
void races_toggles_set_sensitive(void)
Definition dialogs.cpp:1293
static void transport_load(QVariant data1, QVariant data2)
Definition dialogs.cpp:2607
static action_id get_production_targeted_action_id(action_id tgt_action_id)
Definition dialogs.cpp:2304
static void paradrop_frighten_conquer(QVariant data1, QVariant data2)
Definition dialogs.cpp:3119
static void convert_unit(QVariant data1, QVariant data2)
Definition dialogs.cpp:2412
static bool did_not_decide
Definition dialogs.cpp:200
static void spy_poison_esc(QVariant data1, QVariant data2)
Definition dialogs.cpp:3361
static void pillage_something(QVariant data1, QVariant data2)
Definition dialogs.cpp:3840
static void spy_request_sabotage_esc_list(QVariant data1, QVariant data2)
Definition dialogs.cpp:3327
void show_tileset_error(bool fatal, const char *tset_name, const char *msg)
Definition dialogs.cpp:4412
static void transform_terrain(QVariant data1, QVariant data2)
Definition dialogs.cpp:2860
#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:3667
static void heal_unit2(QVariant data1, QVariant data2)
Definition dialogs.cpp:2508
static void transport_board3(QVariant data1, QVariant data2)
Definition dialogs.cpp:2541
static void spy_embassy(QVariant data1, QVariant data2)
Definition dialogs.cpp:3511
static races_dialog * race_dialog
Definition dialogs.cpp:190
static void frighten_hut2(QVariant data1, QVariant data2)
Definition dialogs.cpp:2726
static void conquer_extras2(QVariant data1, QVariant data2)
Definition dialogs.cpp:1897
static void frighten_hut(QVariant data1, QVariant data2)
Definition dialogs.cpp:2711
bool qtg_request_transport(struct unit *pcargo, struct tile *ptile)
Definition dialogs.cpp:4948
int action_selection_target_unit(void)
Definition dialogs.cpp:4254
static void irrigate(QVariant data1, QVariant data2)
Definition dialogs.cpp:3008
static void transport_embark3(QVariant data1, QVariant data2)
Definition dialogs.cpp:2574
static void collect_ransom(QVariant data1, QVariant data2)
Definition dialogs.cpp:2753
static void heal_unit(QVariant data1, QVariant data2)
Definition dialogs.cpp:2497
void popdown_city_report()
Definition cityrep.cpp:1338
static void paradrop_enter_conquer(QVariant data1, QVariant data2)
Definition dialogs.cpp:3149
static void unit_home_city(QVariant data1, QVariant data2)
Definition dialogs.cpp:1802
static void transport_embark(QVariant data1, QVariant data2)
Definition dialogs.cpp:2552
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:3481
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:2357
static void disembark1(QVariant data1, QVariant data2)
Definition dialogs.cpp:2651
void restart_notify_dialogs()
Definition dialogs.cpp:4131
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:2324
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:4147
static void spy_steal_maps(QVariant data1, QVariant data2)
Definition dialogs.cpp:3466
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id popup_bribe_unit_dialog
Definition dialogs_g.h:73
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit int const struct action *paction struct unit struct city const struct action *paction const char * expl
Definition dialogs_g.h:94
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit int const struct action *paction popup_sabotage_dialog
Definition dialogs_g.h:77
struct unit struct city struct unit * target_unit
Definition dialogs_g.h:56
popup_action_selection
Definition dialogs_g.h:55
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit * actor
Definition dialogs_g.h:73
struct unit * actor_unit
Definition dialogs_g.h:55
const char * caption
Definition dialogs_g.h:37
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs action_selection_no_longer_in_progress_gui_specific
Definition dialogs_g.h:69
const char const char * headline
Definition dialogs_g.h:38
popup_notify_dialog
Definition dialogs_g.h:37
struct unit struct city struct unit struct tile * target_tile
Definition dialogs_g.h:57
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit * punit
Definition dialogs_g.h:74
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit int const struct action *paction struct unit struct city * pcity
Definition dialogs_g.h:78
struct unit struct city * target_city
Definition dialogs_g.h:56
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit int cost
Definition dialogs_g.h:74
struct unit struct city struct unit struct tile struct extra_type * target_extra
Definition dialogs_g.h:57
int int id
Definition editgui_g.h:28
enum event_type event
Definition events.c:81
int extra_number(const struct extra_type *pextra)
Definition extras.c:161
struct extra_type * extra_by_number(int id)
Definition extras.c:183
static struct extra_type extras[MAX_EXTRA_TYPES]
Definition extras.c:31
const char * extra_name_translation(const struct extra_type *pextra)
Definition extras.c:194
#define extra_index(_e_)
Definition extras.h:183
#define EXTRA_NONE
Definition extras.h:85
int Tech_type_id
Definition fc_types.h: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:116
struct city * game_city_by_number(int id)
Definition game.c:107
struct government * government_by_number(const Government_type_id gov)
Definition government.c:105
Government_type_id government_number(const struct government *pgovern)
Definition government.c:93
#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
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:3565
#define show(id)
Definition widget.h:235
void popup_revolution_dialog(void)
Definition dialogs.c:112
void helptext_nation(char *buf, size_t bufsz, struct nation_type *pnation, const char *user_text)
Definition helpdata.c:5116
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:2408
void set_government_choice(struct government *government)
Definition packhand.c:2395
char * lines
Definition packhand.c:132
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:160
QPixmap * pm
Definition sprite.h:25
Definition tile.h:50
int index
Definition tile.h:51
struct unit_list * units
Definition tile.h:58
int move_rate
Definition unittype.h:524
Definition unit.h:140
int moves_left
Definition unit.h:152
int id
Definition unit.h:147
int hp
Definition unit.h:153
int fuel
Definition unit.h:155
struct tile * tile
Definition unit.h:142
struct unit::@84::@86 client
struct act_prob * act_prob_cache
Definition unit.h:231
int homecity
Definition unit.h:148
struct civ_map map
const char * style_name_translation(const struct nation_style *pstyle)
Definition style.c:99
int style_number(const struct nation_style *pstyle)
Definition style.c:68
int basic_city_style_for_style(struct nation_style *pstyle)
Definition style.c:210
#define styles_iterate(_p)
Definition style.h:46
#define styles_iterate_end
Definition style.h:52
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:960
#define sz_strlcpy(dest, src)
Definition support.h:195
#define TRUE
Definition support.h:46
#define FALSE
Definition support.h:47
#define is_svg_flag_enabled()
Definition svgflag.h:30
#define advance_index_iterate_end
Definition tech.h: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:1842
struct city * tile_city(const struct tile *ptile)
Definition tile.c:83
#define tile_index(_pt_)
Definition tile.h:89
#define TILE_INDEX_NONE
Definition tile.h:48
int tileset_hex_width(const struct tileset *t)
Definition tilespec.c:747
int tileset_unit_width(const struct tileset *t)
Definition tilespec.c:823
int tileset_unit_height(const struct tileset *t)
Definition tilespec.c:831
struct sprite * load_popup_sprite(const char *tag)
Definition tilespec.c:7831
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:7099
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:7839
struct sprite * get_nation_flag_sprite(const struct tileset *t, const struct nation_type *pnation)
Definition tilespec.c:6996
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:1986
bool could_unit_load(const struct unit *pcargo, const struct unit *ptrans)
Definition unit.c:743
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:1211
#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:847