Freeciv-3.3
Loading...
Searching...
No Matches
dialogs.cpp
Go to the documentation of this file.
1/***********************************************************************
2 Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
6 any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12***********************************************************************/
13
14#ifdef HAVE_CONFIG_H
15#include <fc_config.h>
16#endif
17
18// Qt
19#include <QApplication>
20#include <QButtonGroup>
21#include <QComboBox>
22#include <QGroupBox>
23#include <QHeaderView>
24#include <QImage>
25#include <QMessageBox>
26#include <QMouseEvent>
27#include <QPainter>
28#include <QPainterPath>
29#include <QRadioButton>
30#include <QRect>
31#include <QTableWidgetItem>
32#include <QTextEdit>
33#include <QVBoxLayout>
34#include <QWindow>
35#include <QtMath>
36
37// utility
38#include "astring.h"
39
40// common
41#include "actions.h"
42#include "city.h"
43#include "game.h"
44#include "government.h"
45#include "improvement.h"
46#include "movement.h"
47#include "nation.h"
48#include "research.h"
49#include "sex.h"
50
51// client
52#include "audio.h"
53#include "chatline_common.h"
54#include "client_main.h"
55#include "control.h"
56#include "helpdata.h"
57#include "packhand.h"
58#include "svgflag.h"
59#include "text.h"
60#include "tilespec.h"
61
62// gui-qt
63#include "dialogs.h"
64#include "fc_client.h"
65#include "gui_main.h"
66#include "hudwidget.h"
67#include "qtg_cxxside.h"
68#include "sprite.h"
69
70// Locations for non action enabler controlled buttons.
71#define BUTTON_WAIT (ACTION_COUNT + 1)
72#define BUTTON_CANCEL (BUTTON_WAIT + 1)
73#define BUTTON_COUNT (BUTTON_CANCEL + 1)
74
76extern void popdown_players_report();
77extern void popdown_economy_report();
78extern void popdown_units_report();
79extern void popdown_science_report();
80extern void popdown_city_report();
81extern void popdown_endgame_report();
82
83static void spy_request_strike_bld_list(QVariant data1, QVariant data2);
84static void diplomat_incite(QVariant data1, QVariant data2);
85static void diplomat_incite_escape(QVariant data1, QVariant data2);
86static void spy_request_sabotage_list(QVariant data1, QVariant data2);
87static void spy_request_sabotage_esc_list(QVariant data1, QVariant data2);
88static void spy_sabotage(QVariant data1, QVariant data2);
89static void spy_steal(QVariant data1, QVariant data2);
90static void spy_steal_esc(QVariant data1, QVariant data2);
91static void spy_steal_something(QVariant data1, QVariant data2);
92static void diplomat_steal(QVariant data1, QVariant data2);
93static void diplomat_steal_esc(QVariant data1, QVariant data2);
94static void spy_poison(QVariant data1, QVariant data2);
95static void spy_poison_esc(QVariant data1, QVariant data2);
96static void spy_steal_gold(QVariant data1, QVariant data2);
97static void spy_steal_gold_esc(QVariant data1, QVariant data2);
98static void spy_steal_maps(QVariant data1, QVariant data2);
99static void spy_steal_maps_esc(QVariant data1, QVariant data2);
100static void spy_escape(QVariant data1, QVariant data2);
101static void spy_nuke_city(QVariant data1, QVariant data2);
102static void spy_nuke_city_esc(QVariant data1, QVariant data2);
103static void nuke_city(QVariant data1, QVariant data2);
104static void destroy_city(QVariant data1, QVariant data2);
105static void diplomat_embassy(QVariant data1, QVariant data2);
106static void spy_embassy(QVariant data1, QVariant data2);
107static void spy_sabotage_unit(QVariant data1, QVariant data2);
108static void spy_sabotage_unit_esc(QVariant data1, QVariant data2);
109static void spy_investigate(QVariant data1, QVariant data2);
110static void diplomat_investigate(QVariant data1, QVariant data2);
111static void diplomat_sabotage(QVariant data1, QVariant data2);
112static void diplomat_sabotage_esc(QVariant data1, QVariant data2);
113static void diplomat_bribe_unit(QVariant data1, QVariant data2);
114static void diplomat_bribe_stack(QVariant data1, QVariant data2);
115static void caravan_marketplace(QVariant data1, QVariant data2);
116static void caravan_establish_trade(QVariant data1, QVariant data2);
117static void caravan_help_build(QVariant data1, QVariant data2);
118static void unit_disband_recover(QVariant data1, QVariant data2);
119static void capture_units(QVariant data1, QVariant data2);
120static void nuke_units(QVariant data1, QVariant data2);
121static void wipe_units(QVariant data1, QVariant data2);
122static void expel_unit(QVariant data1, QVariant data2);
123static void bombard(QVariant data1, QVariant data2);
124static void bombard2(QVariant data1, QVariant data2);
125static void bombard3(QVariant data1, QVariant data2);
126static void bombard_lethal(QVariant data1, QVariant data2);
127static void found_city(QVariant data1, QVariant data2);
128static void transform_terrain(QVariant data1, QVariant data2);
129static void cultivate(QVariant data1, QVariant data2);
130static void plant(QVariant data1, QVariant data2);
131static void pillage(QVariant data1, QVariant data2);
132static void clean(QVariant data1, QVariant data2);
133static void road(QVariant data1, QVariant data2);
134static void base(QVariant data1, QVariant data2);
135static void mine(QVariant data1, QVariant data2);
136static void irrigate(QVariant data1, QVariant data2);
137static void nuke(QVariant data1, QVariant data2);
138static void attack(QVariant data1, QVariant data2);
139static void suicide_attack(QVariant data1, QVariant data2);
140static void paradrop(QVariant data1, QVariant data2);
141static void paradrop_conquer(QVariant data1, QVariant data2);
142static void paradrop_frighten(QVariant data1, QVariant data2);
143static void paradrop_frighten_conquer(QVariant data1, QVariant data2);
144static void paradrop_enter(QVariant data1, QVariant data2);
145static void paradrop_enter_conquer(QVariant data1, QVariant data2);
146static void disembark1(QVariant data1, QVariant data2);
147static void disembark2(QVariant data1, QVariant data2);
148static void enter_hut(QVariant data1, QVariant data2);
149static void enter_hut2(QVariant data1, QVariant data2);
150static void frighten_hut(QVariant data1, QVariant data2);
151static void frighten_hut2(QVariant data1, QVariant data2);
152static void regular_move(QVariant data1, QVariant data2);
153static void convert_unit(QVariant data1, QVariant data2);
154static void fortify(QVariant data1, QVariant data2);
155static void disband_unit(QVariant data1, QVariant data2);
156static void homeless(QVariant data1, QVariant data2);
157static void join_city(QVariant data1, QVariant data2);
158static void unit_home_city(QVariant data1, QVariant data2);
159static void unit_upgrade(QVariant data1, QVariant data2);
160static void airlift(QVariant data1, QVariant data2);
161static void conquer_city_shrink(QVariant data1, QVariant data2);
162static void conquer_city_shrink2(QVariant data1, QVariant data2);
163static void conquer_extras(QVariant data1, QVariant data2);
164static void conquer_extras2(QVariant data1, QVariant data2);
165static void heal_unit(QVariant data1, QVariant data2);
166static void heal_unit2(QVariant data1, QVariant data2);
167static void transport_board(QVariant data1, QVariant data2);
168static void transport_board2(QVariant data1, QVariant data2);
169static void transport_board3(QVariant data1, QVariant data2);
170static void transport_embark(QVariant data1, QVariant data2);
171static void transport_embark2(QVariant data1, QVariant data2);
172static void transport_embark3(QVariant data1, QVariant data2);
173static void transport_embark4(QVariant data1, QVariant data2);
174static void transport_deboard(QVariant data1, QVariant data2);
175static void transport_unload(QVariant data1, QVariant data2);
176static void transport_load(QVariant data1, QVariant data2);
177static void transport_load2(QVariant data1, QVariant data2);
178static void transport_load3(QVariant data1, QVariant data2);
179static void keep_moving(QVariant data1, QVariant data2);
180static void pillage_something(QVariant data1, QVariant data2);
181static void action_entry(choice_dialog *cd,
182 action_id act,
183 const struct act_prob *act_probs,
184 const char *custom,
185 QVariant data1, QVariant data2);
186
187
188static bool is_showing_pillage_dialog = false;
190static bool is_race_dialog_open = false;
191
192/* Information used in action selection follow up questions. Can't be
193 * stored in the action selection dialog since it is closed before the
194 * follow up question is asked. */
196
197/* Don't remove a unit's action decision want or move on to the next actor
198 unit that wants a decision in the current unit selection. */
199static bool did_not_decide = false;
200
201extern char forced_tileset_name[512];
203
204/***********************************************************************/
209{
211
212 // Unit acting against a city target.
251
252 // Unit acting against a unit target.
271
272 // Unit acting against all units at a tile.
280
281 // Unit acting against a tile.
310
311 // Unit acting against all tile extras.
314
315 // Unit acting with no target except itself.
320
321 return action_function;
322}
323
324/* Mapping from an action to the function to call when its button is
325 * pushed. */
327
328/***********************************************************************/
333{
334 titlebar_height = 0;
335 moving_now = false;
336 setSizeGripEnabled(true);
338}
339
340/***********************************************************************/
344{
345 raise();
346}
347
348/***********************************************************************/
352{
354
355 QPainter p(this);
358 QStyle *style = this->style();
359 QRect active_area = this->rect();
362
363 qpal.setColor(QPalette::Active, QPalette::ToolTipText, Qt::white);
364 tbar_opt.initFrom(this);
365 titlebar_height = style->pixelMetric(QStyle::PM_TitleBarHeight,
366 &tbar_opt, this) + 2;
367 close_pix = close_pix.scaledToHeight(titlebar_height);
368 tbar_opt.rect = QRect(0, 0, this->width(), titlebar_height);
369 text_rect = QRect(0, 0, this->width() - close_pix.width() , titlebar_height);
370 close_rect = QRect(this->width() - close_pix.width(), 0, this->width(),
372 tbar_opt.titleBarState = this->windowState();
373 tbar_opt.text = tbar_opt.fontMetrics.elidedText(this->windowTitle(),
374 Qt::ElideRight,
375 text_rect.width());
376 style->drawComplexControl(QStyle::CC_TitleBar, &tbar_opt, &p, this);
377 style->drawItemText(&p, text_rect, Qt::AlignCenter, qpal,
378 true, tbar_opt.text, QPalette::ToolTipText);
379 style->drawItemPixmap(&p, close_rect, Qt::AlignLeft,
380 close_pix.scaledToHeight(titlebar_height));
381
382 active_area.setTopLeft(QPoint(0, titlebar_height));
383 this->setContentsMargins(0, titlebar_height, 0, 0);
384 win_opt.initFrom(this);
385 win_opt.rect = active_area;
386 style->drawPrimitive(QStyle::PE_Widget, &win_opt, &p, this);
387}
388
389/***********************************************************************/
398
399/***********************************************************************/
403{
404 QPoint pos = event->pos();
405 int x = pos.x();
406 int y = pos.y();
407
408 if (y <= titlebar_height
409 && x <= width() - close_pix.width()) {
410 point = mevent_gpos(event) - geometry().topLeft();
411 moving_now = true;
412 setCursor(Qt::SizeAllCursor);
413 } else if (y <= titlebar_height
414 && x > width() - close_pix.width()) {
415 close();
416 }
417}
418
419/***********************************************************************/
423{
424 moving_now = false;
425 setCursor(Qt::ArrowCursor);
426}
427
428/***********************************************************************/
432 QWidget *parent) : qfc_dialog(parent)
433{
434 int i;
438 QPixmap *pix;
439 QHeaderView *header;
440 QSize size;
442 QLabel *ns_label;
443
444 setAttribute(Qt::WA_DeleteOnClose);
445 is_race_dialog_open = true;
447 selected_nation_tabs = new QTableWidget;
448 nation_tabs = new QTableWidget();
449 styles = new QTableWidget;
450 ok_button = new QPushButton;
452 ns_label = new QLabel;
453 tplayer = pplayer;
454
455 selected_nation = -1;
456 selected_style = -1;
457 setWindowTitle(_("Select Nation"));
458 selected_nation_tabs->setRowCount(0);
459 selected_nation_tabs->setColumnCount(1);
460 selected_nation_tabs->setSelectionMode(QAbstractItemView::SingleSelection);
461 selected_nation_tabs->verticalHeader()->setVisible(false);
462 selected_nation_tabs->horizontalHeader()->setVisible(false);
463 selected_nation_tabs->setProperty("showGrid", "true");
464 selected_nation_tabs->setEditTriggers(QAbstractItemView::NoEditTriggers);
465 selected_nation_tabs->setShowGrid(false);
466 selected_nation_tabs->setAlternatingRowColors(true);
467
468 nation_tabs->setRowCount(0);
469 nation_tabs->setColumnCount(1);
470 nation_tabs->setSelectionMode(QAbstractItemView::SingleSelection);
471 nation_tabs->verticalHeader()->setVisible(false);
472 nation_tabs->horizontalHeader()->setVisible(false);
473 nation_tabs->setProperty("showGrid", "true");
474 nation_tabs->setEditTriggers(QAbstractItemView::NoEditTriggers);
475 nation_tabs->setShowGrid(false);
476 ns_label->setText(_("Nation Set:"));
477 styles->setRowCount(0);
478 styles->setColumnCount(2);
479 styles->setSelectionMode(QAbstractItemView::SingleSelection);
480 styles->verticalHeader()->setVisible(false);
481 styles->horizontalHeader()->setVisible(false);
482 styles->setProperty("showGrid", "false");
483 styles->setProperty("selectionBehavior", "SelectRows");
484 styles->setEditTriggers(QAbstractItemView::NoEditTriggers);
485 styles->setShowGrid(false);
486
488 no_name = new QGroupBox(parent);
492 sex_buttons->addButton(is_male, SEX_MALE);
494 sex_buttons->addButton(is_female, SEX_FEMALE);
495
496 leader_name->setEditable(true);
497 qgroupbox_layout->addWidget(leader_name, 1, 0, 1, 2);
498 qgroupbox_layout->addWidget(is_male, 2, 1);
499 qgroupbox_layout->addWidget(is_female, 2, 0);
502 no_name->setLayout(qgroupbox_layout);
503
505 description->setReadOnly(true);
506 description->setPlainText(_("Choose nation"));
507 no_name->setTitle(_("Your leader name"));
508
509 // Fill styles, no need to update them later
510
513
514 if (i >= 0) {
516 styles->insertRow(i);
518 item->setData(Qt::DecorationRole, *pix);
519 item->setData(Qt::UserRole, style_number(pstyle));
520 size.setWidth(pix->width());
521 size.setHeight(pix->height());
522 item->setSizeHint(size);
523 styles->setItem(i, 0, item);
526 styles->setItem(i, 1, item);
527 }
529
530 header = styles->horizontalHeader();
531 header->setSectionResizeMode(QHeaderView::Stretch);
532 header->resizeSections(QHeaderView::ResizeToContents);
533 header = styles->verticalHeader();
534 header->resizeSections(QHeaderView::ResizeToContents);
539 // Create nation sets
540 refresh();
541
542 connect(styles->selectionModel(),
544 const QItemSelection &)),
546 const QItemSelection &)));
547 connect(selected_nation_tabs->selectionModel(),
549 const QItemSelection &)),
551 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 const QItemSelection &)));
563
564 ok_button = new QPushButton;
565 ok_button->setText(_("Cancel"));
566 connect(ok_button, &QAbstractButton::pressed, this, &races_dialog::cancel_pressed);
567 main_layout->addWidget(ok_button, 8, 2, 1, 1);
568 random_button = new QPushButton;
569 random_button->setText(_("Random"));
570 connect(random_button, &QAbstractButton::pressed, this, &races_dialog::random_pressed);
571 main_layout->addWidget(random_button, 8, 0, 1, 1);
572 ok_button = new QPushButton;
573 ok_button->setText(_("Ok"));
574 connect(ok_button, &QAbstractButton::pressed, this, &races_dialog::ok_pressed);
575 main_layout->addWidget(ok_button, 8, 3, 1, 1);
576 main_layout->addWidget(no_name, 0, 3, 2, 1);
577 if (nation_set_count() > 1) {
578 main_layout->addWidget(ns_label, 0, 0, 1, 1);
579 main_layout->addWidget(qnation_set, 0, 1, 1, 1);
580 main_layout->addWidget(nation_tabs, 1, 0, 5, 2);
581 } else {
582 main_layout->addWidget(nation_tabs, 0, 0, 6, 2);
583 }
584 main_layout->addWidget(styles, 2, 3, 4, 1);
585 main_layout->addWidget(description, 6, 0, 2, 4);
586 main_layout->addWidget(selected_nation_tabs, 0, 2, 6, 1);
587
589 set_index(-99);
590
591 if (C_S_RUNNING == client_state()) {
592 title = _("Edit Nation");
593 } else if (pplayer != nullptr && pplayer == client_player()) {
594 title = _("What Nation Will You Be?");
595 } else {
596 title = _("Pick Nation");
597 }
598
601}
602
603/***********************************************************************/
610
611/***********************************************************************/
615{
616 struct nation_group *group;
618 QHeaderView *header;
619 int i;
620 int count;
621
622 nation_tabs->clearContents();
623 nation_tabs->setRowCount(0);
624 nation_tabs->insertRow(0);
626 item->setText(_("All nations"));
627 item->setData(Qt::UserRole, -99);
628 nation_tabs->setItem(0, 0, item);
629
630 for (i = 1; i < nation_group_count() + 1; i++) {
631 group = nation_group_by_number(i - 1);
632 if (is_nation_group_hidden(group)) {
633 continue;
634 }
635 count = 0;
636 // Checking if group is empty
637 nations_iterate(pnation) {
638 if (!is_nation_playable(pnation)
639 || !is_nation_pickable(pnation)
640 || !nation_is_in_group(pnation, group)) {
641 continue;
642 }
643 count ++;
645 if (count == 0) {
646 continue;
647 }
648 nation_tabs->insertRow(i);
650 item->setData(Qt::UserRole, i - 1);
651 item->setText(nation_group_name_translation(group));
652 nation_tabs->setItem(i, 0, item);
653 }
654 header = nation_tabs->horizontalHeader();
655 header->resizeSections(QHeaderView::Stretch);
656 header = nation_tabs->verticalHeader();
657 header->resizeSections(QHeaderView::ResizeToContents);
658 set_index(-99);
659}
660
661/***********************************************************************/
665{
666 struct option *popt;
667 struct nation_set *s;
668
670 if (popt) {
672 qnation_set->setCurrentIndex(nation_set_index(s));
673 qnation_set->setToolTip(_(nation_set_description(s)));
674 }
675}
676
677/***********************************************************************/
681 const QItemSelection &ds)
682{
683 QModelIndexList indexes = sl.indexes();
684 QModelIndex index ;
685
686 if (indexes.isEmpty()) {
687 return;
688 }
689 index = indexes.at(0);
690 set_index(index.row());
691}
692
693/***********************************************************************/
698{
700 QPixmap *pix;
701 QFont f;
702 struct nation_group *group;
703 int i;
704 struct sprite *s;
705 QHeaderView *header;
706 bool svg = is_svg_flag_enabled();
707
708 selected_nation_tabs->clearContents();
709 selected_nation_tabs->setRowCount(0);
710
711 last_index = 0;
712 i = nation_tabs->currentRow();
713 if (i != -1) {
714 item = nation_tabs->item(i, 0);
715 index = item->data(Qt::UserRole).toInt();
716 }
717
718 group = nation_group_by_number(index);
719 i = 0;
720 nations_iterate(pnation) {
721 if (!is_nation_playable(pnation)
722 || !is_nation_pickable(pnation)) {
723 continue;
724 }
725 if (!nation_is_in_group(pnation, group) && index != -99) {
726 continue;
727 }
729 selected_nation_tabs->insertRow(i);
730 s = get_nation_flag_sprite(tileset, pnation);
731 if (pnation->player) {
732 f = item->font();
733 f.setStrikeOut(true);
734 item->setFont(f);
735 }
736 pix = s->pm;
737 if (svg) {
738 item->setData(Qt::DecorationRole, (*pix).scaledToHeight(50));
739 } else {
740 item->setData(Qt::DecorationRole, *pix);
741 }
742 item->setData(Qt::UserRole, nation_number(pnation));
743 item->setText(nation_adjective_translation(pnation));
744 selected_nation_tabs->setItem(i, 0, item);
746
747 selected_nation_tabs->sortByColumn(0, Qt::AscendingOrder);
748 header = selected_nation_tabs->horizontalHeader();
749 header->resizeSections(QHeaderView::Stretch);
750 header = selected_nation_tabs->verticalHeader();
751 header->resizeSections(QHeaderView::ResizeToContents);
752}
753
754/***********************************************************************/
759{
760 char buf[4096];
761 QModelIndex index ;
763 QModelIndexList indexes = selected.indexes();
764 QString str;
766 int style, ind;
767
768 if (indexes.isEmpty()) {
769 return;
770 }
771
772 index = indexes.at(0);
773 if (indexes.isEmpty()) {
774 return;
775 }
776 qvar = index.data(Qt::UserRole);
777 selected_nation = qvar.toInt();
778
780 description->setPlainText(buf);
781 leader_name->clear();
782 if (client.conn.playing == tplayer) {
783 leader_name->addItem(client.conn.playing->name, true);
784 }
787 str = QString::fromUtf8(nation_leader_name(pleader));
790
791 // Select style for nation
792
794 qvar = qvar.fromValue<int>(style);
795
796 for (ind = 0; ind < styles->rowCount(); ind++) {
797 item = styles->item(ind, 0);
798
799 if (item->data(Qt::UserRole) == qvar) {
800 styles->selectRow(ind);
801 }
802 }
803}
804
805/***********************************************************************/
810{
811 QModelIndex index ;
813 QModelIndexList indexes = selected.indexes();
814
815 if (indexes.isEmpty()) {
816 return;
817 }
818
819 index = indexes.at(0);
820 qvar = index.data(Qt::UserRole);
821 selected_style = qvar.toInt();
822}
823
824/***********************************************************************/
828{
829 if (leader_name->itemData(index).toBool()) {
830 is_male->setChecked(true);
831 is_female->setChecked(false);
832 } else {
833 is_male->setChecked(false);
834 is_female->setChecked(true);
835 }
836}
837
838/***********************************************************************/
843{
845 struct player *natplr;
846
847 if (selected_nation == -1) {
848 return;
849 }
850
851 if (selected_style == -1) {
852 output_window_append(ftc_client, _("You must select your style."));
853 return;
854 }
855
856 if (leader_name->currentText().length() == 0) {
857 output_window_append(ftc_client, _("You must type a legal name."));
858 return;
859 }
860
862 if (natplr != nullptr && natplr != client_player()) {
864 _("Nation has been chosen by other player"));
865 return;
866 }
867
868 ln_bytes = leader_name->currentText().toUtf8();
870 selected_nation, sex_buttons->checkedId(),
871 ln_bytes.data(),
873 close();
874 deleteLater();
875}
876
877/***********************************************************************/
881 const char *lines, QWidget *parent)
882 : fcwidget()
883{
884 int x, y;
886
887 setAttribute(Qt::WA_DeleteOnClose);
888 setCursor(Qt::ArrowCursor);
890 setFrameStyle(QFrame::Box);
891 cw = new close_widget(this);
892 cw->put_to_corner();
893
897 qlist = qlines.split("\n");
898 small_font = *fc_font::instance()->get_font("gui_qt_font_notify_label");
899 x = 0;
900 y = 0;
901 calc_size(x, y);
902 resize(x, y);
903 gui()->mapview_wdg->find_place(gui()->mapview_wdg->width() - x - 4, 4,
904 x, y, x, y, 0);
905 move(x, y);
906 was_destroyed = false;
907
908}
909
910/***********************************************************************/
914{
915 QString s, q;
916 int i;
920
921 for (i = 0; i < qlist.size(); ++i) {
922 s = qlist.at(i);
923 q = q + s;
924 if (i < qlist.size() - 1) {
925 q = q + QChar('\n');
926 }
927 }
928 capt_bytes = qcaption.toUtf8();
929 hl_bytes = qheadline.toUtf8();
930 qb_bytes = q.toUtf8();
932 hl_bytes.data(),
933 qb_bytes.data());
934 close();
935 destroy();
936}
937
938/***********************************************************************/
942{
944 int i;
945 QStringList str_list;
946
947 str_list = qlist;
948 str_list << qcaption << qheadline;
949
950 for (i = 0; i < str_list.count(); i++) {
951 x = qMax(x, fm.horizontalAdvance(str_list.at(i)));
952 y = y + 3 + fm.height();
953 }
954 x = x + 15;
955}
956
957/***********************************************************************/
961{
962 QPainter painter(this);
963 QPainterPath path;
964 QPen pen;
966 int i;
967
968 pen.setWidth(1);
969 pen.setColor(palette().color(QPalette::Text));
970 painter.setFont(small_font);
971 painter.setPen(pen);
972 painter.drawText(10, fm.height() + 3, qcaption);
973 painter.drawText(10, 2 * fm.height() + 6, qheadline);
974 for (i = 0; i < qlist.count(); i++) {
975 painter.drawText(10, 3 + (fm.height() + 3) * (i + 3), qlist[i]);
976 }
977 cw->put_to_corner();
978}
979
980/***********************************************************************/
984{
985 cursor = mevent_gpos(event) - geometry().topLeft();
986
987 if (event->button() == Qt::RightButton) {
988 was_destroyed = true;
989 close();
990 }
991}
992
993/***********************************************************************/
997{
999
1000 setCursor(Qt::SizeAllCursor);
1001}
1002
1003/***********************************************************************/
1007{
1008 setCursor(Qt::ArrowCursor);
1009}
1010
1011/***********************************************************************/
1015{
1016 was_destroyed = true;
1017 destroy();
1018}
1019
1020/***********************************************************************/
1026{
1027 was_destroyed = true;
1028 destroy();
1029}
1030
1031/***********************************************************************/
1035{
1036 vs_city = -1;
1037 vs_unit = -1;
1038}
1039
1040/***********************************************************************/
1044{
1045 if (!m_instance) {
1046 m_instance = new qdef_act;
1047 }
1048 return m_instance;
1049}
1050
1051/***********************************************************************/
1055{
1056 if (m_instance) {
1057 delete m_instance;
1058 m_instance = 0;
1059 }
1060}
1061
1062/***********************************************************************/
1066{
1067 vs_city = i;
1068}
1069
1070/***********************************************************************/
1074{
1075 vs_unit = i;
1076}
1077
1078/***********************************************************************/
1082{
1083 return vs_city;
1084}
1085
1086/***********************************************************************/
1090{
1091 return vs_unit;
1092}
1093
1094/***********************************************************************/
1098{
1099 delete this;
1100}
1101
1102/***********************************************************************/
1106{
1108 false, "", 0);
1109 delete this;
1110}
1111
1112/***********************************************************************/
1115notify_goto::notify_goto(const char *headline, const char *lines,
1116 const struct text_tag_list *tags, tile *ptile,
1117 QWidget *parent): QMessageBox(parent)
1118{
1120 setAttribute(Qt::WA_DeleteOnClose);
1121 goto_but = this->addButton(_("Goto Location"), QMessageBox::ActionRole);
1122 goto_but->setIcon(fc_icons::instance()->get_icon("go-up"));
1123 inspect_but = this->addButton(_("Inspect City"), QMessageBox::ActionRole);
1124 inspect_but->setIcon(fc_icons::instance()->get_icon("plus"));
1125
1126 close_but = this->addButton(QMessageBox::Close);
1127 gtile = ptile;
1128 if (!gtile) {
1129 goto_but->setVisible(false);
1130 inspect_but->setVisible(false);
1131 } else {
1132 struct city *pcity = tile_city(gtile);
1133 inspect_but->setVisible(pcity != nullptr
1135 }
1137 qlines = lines;
1138 qlines.replace("\n", " ");
1139 setText(qlines);
1140 connect(goto_but, &QAbstractButton::pressed, this, &notify_goto::goto_tile);
1141 connect(inspect_but, &QAbstractButton::pressed, this, &notify_goto::inspect_city);
1142 connect(close_but, &QAbstractButton::pressed, this, &QWidget::close);
1143 show();
1144}
1145
1146/***********************************************************************/
1150{
1152 close();
1153}
1154
1155/***********************************************************************/
1159{
1160 struct city *pcity = tile_city(gtile);
1161 if (pcity) {
1163 }
1164 close();
1165}
1166
1167/***********************************************************************/
1171{
1172 QString rule_name;
1174 const char *rn;
1175 struct option *poption = optset_option_by_name(server_optset, "nationset");
1176
1177 rule_name = qnation_set->currentData().toString();
1178 rn_bytes = rule_name.toUtf8(); /* Hold QByteArray in a variable to
1179 * extend its, and data() buffer's,
1180 * lifetime */
1181 rn = rn_bytes.data();
1185 }
1186}
1187
1188/***********************************************************************/
1193void popup_notify_goto_dialog(const char *headline, const char *lines,
1194 const struct text_tag_list *tags,
1195 struct tile *ptile)
1196{
1197 notify_goto *ask = new notify_goto(headline, lines, tags, ptile,
1198 gui()->central_wdg);
1199 ask->show();
1200}
1201
1202/***********************************************************************/
1205void popup_connect_msg(const char *headline, const char *message)
1206{
1207 QMessageBox *msg = new QMessageBox(gui()->central_wdg);
1208
1209 msg->setText(message);
1210 msg->setStandardButtons(QMessageBox::Ok);
1211 msg->setWindowTitle(headline);
1212 msg->setAttribute(Qt::WA_DeleteOnClose);
1213 msg->show();
1214}
1215
1216/***********************************************************************/
1219void popup_notify_dialog(const char *caption, const char *headline,
1220 const char *lines)
1221{
1223 gui()->mapview_wdg);
1224 nd->show();
1225}
1226
1227/***********************************************************************/
1230void popup_races_dialog(struct player *pplayer)
1231{
1232 if (!is_race_dialog_open) {
1233 race_dialog = new races_dialog(pplayer, gui()->central_wdg);
1234 is_race_dialog_open = true;
1235 race_dialog->show();
1236 }
1237 race_dialog->showNormal();
1238}
1239
1240/***********************************************************************/
1245{
1246 if (is_race_dialog_open) {
1247 race_dialog->close();
1248 is_race_dialog_open = false;
1249 }
1250}
1251
1252/***********************************************************************/
1256{
1257 if (ptile != nullptr
1258 && (unit_list_size(ptile->units) > 1
1259 || (unit_list_size(ptile->units) == 1 && tile_city(ptile)))) {
1260 gui()->toggle_unit_sel_widget(ptile);
1261 }
1262}
1263
1264/***********************************************************************/
1268{
1269 gui()->update_unit_sel();
1270}
1271
1272/***********************************************************************/
1281
1282/***********************************************************************/
1285void races_update_pickable(bool nationset_change)
1286{
1287 if (is_race_dialog_open) {
1289 }
1290}
1291
1292/***********************************************************************/
1297{
1298 if (is_race_dialog_open) {
1300 }
1301}
1302
1303/***********************************************************************/
1307{
1310 = (gov != nullptr ? government_number(gov) : G_LAST);
1311
1313 ask = new hud_message_box(gui()->central_wdg);
1314 ask->setStandardButtons(QMessageBox::Cancel | QMessageBox::Ok);
1315 ask->setDefaultButton(QMessageBox::Cancel);
1316 ask->set_text_title(_("You say you wanna revolution?"),
1317 _("Revolution!"));
1318 ask->setAttribute(Qt::WA_DeleteOnClose);
1319 QObject::connect(ask, &hud_message_box::accepted, [=]() {
1320 if (government_id == G_LAST) {
1321 revolution_response(nullptr);
1322 } else {
1324
1325 if (government) {
1327 }
1328 }
1329 });
1330 ask->show();
1331 } else {
1333 }
1334}
1335
1336/***********************************************************************/
1349
1350/***********************************************************************/
1357
1358/***********************************************************************/
1366
1367/***********************************************************************/
1375
1376/***********************************************************************/
1383
1384/***********************************************************************/
1391
1392/***********************************************************************/
1396 QWidget *parent,
1397 void (*run_on_close_in)(int)): QWidget(parent)
1398{
1399 QLabel *l = new QLabel(text);
1400
1401 setProperty("themed_choice", true);
1402 layout = new QVBoxLayout(this);
1404
1405 layout->addWidget(l);
1406 setWindowFlags(Qt::Dialog);
1408 setAttribute(Qt::WA_DeleteOnClose);
1409 gui()->set_diplo_dialog(this);
1410
1422
1423 targeted_unit = nullptr;
1424 // No buttons are added yet.
1425 for (int i = 0; i < BUTTON_COUNT; i++) {
1426 action_button_map << nullptr;
1427 }
1428}
1429
1430/***********************************************************************/
1434{
1435 buttons_list.clear();
1436 action_button_map.clear();
1437 gui()->set_diplo_dialog(nullptr);
1438
1439 if (run_on_close) {
1441 run_on_close = nullptr;
1442 }
1443}
1444
1445/***********************************************************************/
1449{
1451
1454 struct canvas *pix;
1455 QPushButton *next, *prev;
1456 unit_skip = new QHBoxLayout;
1457 next = new QPushButton();
1458 next->setIcon(fc_icons::instance()->get_icon("city-right"));
1459 next->setIconSize(QSize(32, 32));
1460 next->setFixedSize(QSize(36, 36));
1461 prev = new QPushButton();
1462 prev->setIcon(fc_icons::instance()->get_icon("city-left"));
1463 prev->setIconSize(QSize(32, 32));
1464 prev->setFixedSize(QSize(36, 36));
1465 target_unit_button = new QPushButton;
1468 pix->map_pixmap.fill(Qt::transparent);
1469 put_unit(targeted_unit, pix, 1.0, 0, 0);
1470 target_unit_button->setIcon(QIcon(pix->map_pixmap));
1471 qtg_canvas_free(pix);
1472 target_unit_button->setIconSize(QSize(96, 96));
1473 target_unit_button->setFixedSize(QSize(100, 100));
1474 unit_skip->addStretch(100);
1475 unit_skip->addWidget(prev, Qt::AlignCenter);
1476 unit_skip->addWidget(target_unit_button, Qt::AlignCenter);
1477 unit_skip->addWidget(next, Qt::AlignCenter);
1478 layout->addLayout(unit_skip);
1479 unit_skip->addStretch(100);
1480 connect(prev, &QAbstractButton::clicked, this, &choice_dialog::prev_unit);
1481 connect(next, &QAbstractButton::clicked, this, &choice_dialog::next_unit);
1482 }
1483
1485}
1486
1487/***********************************************************************/
1491 QVariant data2, QString tool_tip = "",
1492 const int button_id = -1)
1493{
1495 data1, data2);
1496 int action = buttons_list.count();
1497
1498 QObject::connect(button, &QPushButton::clicked,
1501 });
1502
1503 buttons_list.append(button);
1504
1505 if (!tool_tip.isEmpty()) {
1506 button->setToolTip(tool_tip);
1507 }
1508
1509 if (0 <= button_id) {
1510 // The id is valid.
1511 action_button_map[button_id] = button;
1512 }
1513
1514 layout->addWidget(button);
1515}
1516
1517/***********************************************************************/
1521{
1522 QPoint p;
1523
1524 p = mapFromGlobal(QCursor::pos());
1525 p.setY(p.y()-this->height());
1526 p.setX(p.x()-this->width());
1527 move(p);
1528 show();
1529}
1530
1531/***********************************************************************/
1538
1539/***********************************************************************/
1543{
1544 if (id < 0) {
1545 fc_assert_msg(0 <= id, "Invalid button ID.");
1546 return nullptr;
1547 }
1548
1549 return action_button_map[id];
1550}
1551
1552/***********************************************************************/
1556{
1559
1561 if (action == -1) {
1562 return false;
1563 }
1564 func = af_map[action];
1565
1566 func(q1, q2);
1567 return true;
1568}
1569
1570/***********************************************************************/
1574{
1577
1579 if (action == -1) {
1580 return false;
1581 }
1582 func = af_map[action];
1583 func(q1, q2);
1584 return true;
1585}
1586
1587/***********************************************************************/
1591{
1592 struct tile *ptile;
1593 struct unit *new_target = nullptr;
1594 bool break_next = false;
1595 bool first = true;
1596 struct canvas *pix;
1597
1598 if (targeted_unit == nullptr) {
1599 return;
1600 }
1601
1602 ptile = targeted_unit->tile;
1603
1604 unit_list_iterate(ptile->units, ptgt) {
1605 if (first) {
1606 new_target = ptgt;
1607 first = false;
1608 }
1609 if (break_next) {
1610 new_target = ptgt;
1611 break;
1612 }
1613 if (ptgt == targeted_unit) {
1614 break_next = true;
1615 }
1620 pix->map_pixmap.fill(Qt::transparent);
1621 put_unit(targeted_unit, pix, 1.0, 0, 0);
1622 target_unit_button->setIcon(QIcon(pix->map_pixmap));
1623 qtg_canvas_free(pix);
1624 switch_target();
1625}
1626
1627/***********************************************************************/
1631{
1632 struct tile *ptile;
1633 struct unit *new_target = nullptr;
1634 struct canvas *pix;
1635 if (targeted_unit == nullptr) {
1636 return;
1637 }
1638
1639 ptile = targeted_unit->tile;
1640 unit_list_iterate(ptile->units, ptgt) {
1641 if ((ptgt == targeted_unit) && new_target != nullptr) {
1642 break;
1643 }
1644 new_target = ptgt;
1649 pix->map_pixmap.fill(Qt::transparent);
1650 put_unit(targeted_unit, pix, 1.0, 0, 0);
1651 target_unit_button->setIcon(QIcon(pix->map_pixmap));
1652 qtg_canvas_free(pix);
1653 switch_target();
1654}
1655
1656/***********************************************************************/
1660{
1661 if (targeted_unit == nullptr) {
1662 return;
1663 }
1664 unit_skip->setParent(nullptr);
1669 : nullptr),
1670 act_probs);
1671 layout->addLayout(unit_skip);
1672}
1673
1674/***********************************************************************/
1678{
1679 if (targeted_unit == nullptr) {
1680 return;
1681 }
1682
1683 unit_skip->setParent(nullptr);
1685 unit_id,
1690 layout->addLayout(unit_skip);
1691}
1692
1693/***********************************************************************/
1697{
1699 pfcn_void func = button->getFunc();
1700
1701 func(button->getData1(), button->getData2());
1702 close();
1703}
1704
1705/***********************************************************************/
1714{
1715 // Store the data in the stack.
1716 last_buttons_stack.append(button);
1717
1718 /* Temporary remove the button so it will end up below buttons added
1719 * before unstack_all_buttons() is called. */
1720 layout->removeWidget(button);
1721
1722 // Synchronize the list with the layout.
1723 buttons_list.removeAll(button);
1724}
1725
1726/***********************************************************************/
1731{
1732 while (!last_buttons_stack.isEmpty()) {
1733 Choice_dialog_button *button = last_buttons_stack.takeLast();
1734
1735 // Reinsert the button below the other buttons.
1736 buttons_list.append(button);
1737 layout->addWidget(button);
1738 }
1739}
1740
1741/***********************************************************************/
1744static void caravan_marketplace(QVariant data1, QVariant data2)
1745{
1746 int actor_unit_id = data1.toInt();
1747 int target_city_id = data2.toInt();
1748
1749 if (game_unit_by_number(actor_unit_id) != nullptr
1750 && game_city_by_number(target_city_id) != nullptr) {
1752 target_city_id, 0, "");
1753 }
1754}
1755
1756/***********************************************************************/
1760{
1761 int actor_unit_id = data1.toInt();
1762 int target_city_id = data2.toInt();
1763
1764 if (game_unit_by_number(actor_unit_id) != nullptr
1765 && game_city_by_number(target_city_id) != nullptr) {
1767 target_city_id, 0, "");
1768 }
1769}
1770
1771/***********************************************************************/
1774static void caravan_help_build(QVariant data1, QVariant data2)
1775{
1776 int caravan_id = data1.toInt();
1777 int caravan_target_id = data2.toInt();
1778
1779 if (game_unit_by_number(caravan_id) != nullptr
1780 && game_city_by_number(caravan_target_id) != nullptr) {
1783 }
1784}
1785
1786/***********************************************************************/
1789static void unit_disband_recover(QVariant data1, QVariant data2)
1790{
1791 int actor_id = data1.toInt();
1792 int tgt_city_id = data2.toInt();
1793
1794 if (game_unit_by_number(actor_id) != nullptr
1795 && game_city_by_number(tgt_city_id) != nullptr) {
1797 actor_id, tgt_city_id, 0, "");
1798 }
1799}
1800
1801/***********************************************************************/
1804static void unit_home_city(QVariant data1, QVariant data2)
1805{
1806 int actor_id = data1.toInt();
1807 int tgt_city_id = data2.toInt();
1808
1809 if (game_unit_by_number(actor_id) != nullptr
1810 && game_city_by_number(tgt_city_id) != nullptr) {
1812 actor_id, tgt_city_id, 0, "");
1813 }
1814}
1815
1816/***********************************************************************/
1819static void unit_upgrade(QVariant data1, QVariant data2)
1820{
1821 struct unit *punit;
1822
1823 int actor_id = data1.toInt();
1824 int tgt_city_id = data2.toInt();
1825
1826 if ((punit = game_unit_by_number(actor_id)) != nullptr
1827 && game_city_by_number(tgt_city_id) != nullptr) {
1828 struct unit_list *as_list;
1829
1834 }
1835}
1836
1837/***********************************************************************/
1840static void airlift(QVariant data1, QVariant data2)
1841{
1842 int actor_id = data1.toInt();
1843 int tgt_city_id = data2.toInt();
1844
1845 if (game_unit_by_number(actor_id) != nullptr
1846 && game_city_by_number(tgt_city_id) != nullptr) {
1848 actor_id, tgt_city_id, 0, "");
1849 }
1850}
1851
1852/***********************************************************************/
1855static void conquer_city_shrink(QVariant data1, QVariant data2)
1856{
1857 int actor_id = data1.toInt();
1858 int tgt_city_id = data2.toInt();
1859
1860 if (game_unit_by_number(actor_id) != nullptr
1861 && game_city_by_number(tgt_city_id) != nullptr) {
1863 actor_id, tgt_city_id, 0, "");
1864 }
1865}
1866
1867/***********************************************************************/
1870static void conquer_city_shrink2(QVariant data1, QVariant data2)
1871{
1872 int actor_id = data1.toInt();
1873 int tgt_city_id = data2.toInt();
1874
1875 if (game_unit_by_number(actor_id) != nullptr
1876 && game_city_by_number(tgt_city_id) != nullptr) {
1878 actor_id, tgt_city_id, 0, "");
1879 }
1880}
1881
1882/***********************************************************************/
1885static void conquer_extras(QVariant data1, QVariant data2)
1886{
1887 int actor_id = data1.toInt();
1888 int target_id = data2.toInt();
1889
1890 if (game_unit_by_number(actor_id) != nullptr) {
1892 actor_id, target_id, 0, "");
1893 }
1894}
1895
1896/***********************************************************************/
1899static void conquer_extras2(QVariant data1, QVariant data2)
1900{
1901 int actor_id = data1.toInt();
1902 int target_id = data2.toInt();
1903
1904 if (game_unit_by_number(actor_id) != nullptr) {
1906 actor_id, target_id, 0, "");
1907 }
1908}
1909
1910/***********************************************************************/
1913static void act_sel_wait(QVariant data1, QVariant data2)
1914{
1915 key_unit_wait();
1916}
1917
1918/***********************************************************************/
1921static void keep_moving(QVariant data1, QVariant data2)
1922{
1923}
1924
1925/***********************************************************************/
1929{
1930 if (!gov) {
1932 } else {
1934 }
1935}
1936
1937/***********************************************************************/
1942{
1944 /* The client isn't waiting for information for any unanswered follow
1945 * up questions. */
1946
1947 struct unit *actor_unit;
1948
1950 /* The action selection dialog wasn't closed because the actor unit
1951 * was lost. */
1952
1953 // The probabilities didn't just disappear, right?
1956
1958 }
1959
1960 // The action selection process is over, at least for now.
1962
1963 if (did_not_decide) {
1964 /* The action selection dialog was closed but the player didn't
1965 * decide what the unit should do. */
1966
1967 // Reset so the next action selection dialog does the right thing.
1968 did_not_decide = false;
1969 } else {
1970 // An action, or no action at all, was selected.
1973 }
1974 }
1975}
1976
1977/***********************************************************************/
1981static void diplomat_queue_handle_secondary(int actor_id)
1982{
1983 // Stop waiting. Move on to the next queued unit.
1986}
1987
1988/**********************************************************************/
1995{
1996 // Stop assuming the answer to a follow up question will arrive.
1998}
1999
2000/***********************************************************************/
2005 struct city *target_city,
2006 struct unit *target_unit,
2007 struct tile *target_tile,
2008 struct extra_type *target_extra,
2009 const struct act_prob *act_probs)
2010{
2011 struct astring title = ASTRING_INIT, text = ASTRING_INIT;
2013 qtiles caras;
2014 QVariant qv1, qv2;
2016 struct city *actor_homecity;
2019
2022
2023 foreach (caras, gui()->trade_gen.lines) {
2024 if (caras.autocaravan == actor_unit) {
2025 int i;
2026
2027 if (game_unit_by_number(actor_unit->id) != nullptr
2028 && game_city_by_number(target_city->id) != nullptr) {
2030 target_city->id, 0, "");
2033 i = gui()->trade_gen.lines.indexOf(caras);
2034 gui()->trade_gen.lines.takeAt(i);
2035
2036 return;
2037 }
2038 }
2039 }
2040 if (target_city
2044
2045 return;
2046 }
2047
2048 if (target_unit
2052
2053 return;
2054 }
2055 /* Could be caused by the server failing to reply to a request for more
2056 * information or a bug in the client code. */
2058 "Diplomat queue problem. Is another diplomat window open?");
2059
2060 // No extra input is required as no action has been chosen yet.
2062
2064
2065 astr_set(&title,
2066 // TRANS: %s is a unit name, e.g., Spy
2067 _("Choose Your %s's Strategy"),
2069
2070 if (target_city != nullptr && actor_homecity != nullptr) {
2071 astr_set(&text,
2072 _("Your %s from %s reaches the city of %s.\nWhat now?"),
2076 } else if (target_city != nullptr) {
2077 astr_set(&text,
2078 _("Your %s has arrived at %s.\nWhat is your command?"),
2081 } else if (target_unit != nullptr) {
2082 astr_set(&text,
2083 // TRANS: Your Spy is ready to act against Roman Freight.
2084 _("Your %s is ready to act against %s %s."),
2088 } else {
2089 fc_assert_msg(target_unit != nullptr
2090 || target_city != nullptr
2091 || target_tile != nullptr,
2092 "No target specified.");
2093
2094 astr_set(&text,
2095 // TRANS: %s is a unit name, e.g., Diplomat, Spy
2096 _("Your %s is waiting for your command."),
2098 }
2099
2100 cd = gui()->get_diplo_dialog();
2101 if ((cd != nullptr) && cd->targeted_unit != nullptr) {
2102 cd->update_dialog(act_probs);
2103 return;
2104 }
2105 cd = new choice_dialog(astr_str(&title), astr_str(&text),
2106 gui()->game_tab_widget,
2108 qv1 = actor_unit->id;
2109
2110 cd->unit_id = actor_unit->id;
2111
2112 cd->target_id[ATK_SELF] = cd->unit_id;
2113
2114 if (target_city) {
2115 cd->target_id[ATK_CITY] = target_city->id;
2116 } else {
2117 cd->target_id[ATK_CITY] = IDENTITY_NUMBER_ZERO;
2118 }
2119
2120 if (target_unit) {
2121 cd->target_id[ATK_UNIT] = target_unit->id;
2122 } else {
2123 cd->target_id[ATK_UNIT] = IDENTITY_NUMBER_ZERO;
2124 }
2125
2126 if (target_tile) {
2127 cd->target_id[ATK_STACK] = tile_index(target_tile);
2128 } else {
2129 cd->target_id[ATK_STACK] = TILE_INDEX_NONE;
2130 }
2131
2132 if (target_tile) {
2133 cd->target_id[ATK_TILE] = tile_index(target_tile);
2134 } else {
2135 cd->target_id[ATK_TILE] = TILE_INDEX_NONE;
2136 }
2137
2138 if (target_tile) {
2139 cd->target_id[ATK_EXTRAS] = tile_index(target_tile);
2140 } else {
2141 cd->target_id[ATK_EXTRAS] = TILE_INDEX_NONE;
2142 }
2143
2144 // No target building or target tech supplied. (Feb 2020)
2145 cd->sub_target_id[ASTK_BUILDING] = B_LAST;
2146 cd->sub_target_id[ASTK_TECH] = A_UNSET;
2147
2148 if (target_extra) {
2149 cd->sub_target_id[ASTK_EXTRA] = extra_number(target_extra);
2151 } else {
2152 cd->sub_target_id[ASTK_EXTRA] = EXTRA_NONE;
2153 cd->sub_target_id[ASTK_EXTRA_NOT_THERE] = EXTRA_NONE;
2154 }
2155
2156 // Unit acting against a city
2157
2158 // Set the correct target for the following actions.
2159 qv2 = cd->target_id[ATK_CITY];
2160
2161 action_iterate(act) {
2166 act_probs[act],
2167 actor_unit,
2168 target_city),
2169 qv1, qv2);
2170 }
2172
2173 // Unit acting against another unit
2174
2175 // Set the correct target for the following actions.
2176 qv2 = cd->target_id[ATK_UNIT];
2177
2178 action_iterate(act) {
2183 act_probs[act],
2184 actor_unit,
2185 target_city),
2186 qv1, qv2);
2187 }
2189
2190 // Unit acting against all units at a tile
2191
2192 // Set the correct target for the following actions.
2193 qv2 = cd->target_id[ATK_STACK];
2194
2195 action_iterate(act) {
2200 act_probs[act],
2201 actor_unit,
2202 target_city),
2203 qv1, qv2);
2204 }
2206
2207 // Unit acting against a tile.
2208
2209 // Set the correct target for the following actions.
2210 qv2 = cd->target_id[ATK_TILE];
2211
2212 action_iterate(act) {
2217 act_probs[act],
2218 actor_unit,
2219 target_city),
2220 qv1, qv2);
2221 }
2223
2224 // Unit acting against a tile's extras.
2225
2226 // Set the correct target for the following actions.
2227 qv2 = cd->target_id[ATK_EXTRAS];
2228
2229 action_iterate(act) {
2234 act_probs[act],
2235 actor_unit,
2236 target_city),
2237 qv1, qv2);
2238 }
2240
2241 // Unit acting against itself
2242
2243 // Set the correct target for the following actions.
2244 qv2 = cd->target_id[ATK_SELF];
2245
2246 action_iterate(act) {
2251 act_probs[act],
2252 actor_unit,
2253 target_city),
2254 qv1, qv2);
2255 }
2257
2259 cd->add_item(QString(_("&Wait")), func, qv1, qv2,
2260 "", BUTTON_WAIT);
2261
2262 func = keep_moving;
2263 cd->add_item(QString(_("Do nothing")), func, qv1, qv2,
2264 "", BUTTON_CANCEL);
2265
2266 cd->set_layout();
2267 cd->show_me();
2268
2269 // Give follow up questions access to action probabilities.
2271 action_iterate(act) {
2274
2275 astr_free(&title);
2276 astr_free(&text);
2277}
2278
2279/***********************************************************************/
2284{
2285 /* Don't add an action mapping here unless the non targeted version is
2286 * selectable in the targeted version's target selection dialog. */
2287 switch ((enum gen_action)tgt_action_id) {
2293 return ACTION_SPY_STEAL_TECH;
2296 default:
2297 // No non targeted version found.
2298 return ACTION_NONE;
2299 }
2300}
2301
2302/**********************************************************************/
2307{
2308 /* Don't add an action mapping here unless the non targeted version is
2309 * selectable in the targeted version's target selection dialog. */
2310 switch ((enum gen_action)tgt_action_id) {
2317 default:
2318 // No non targeted version found.
2319 return ACTION_NONE;
2320 }
2321}
2322
2323/***********************************************************************/
2327 action_id act,
2328 const struct act_prob *act_probs,
2329 const char *custom,
2330 QVariant data1, QVariant data2)
2331{
2332 QString title;
2334
2335 if (!af_map.contains(act)) {
2336 /* The Qt client doesn't support ordering this action from the
2337 * action selection dialog. */
2338 return;
2339 }
2340
2341 // Don't show disabled actions.
2342 if (!action_prob_possible(act_probs[act])) {
2343 return;
2344 }
2345
2347 act_probs[act],
2348 custom));
2349
2351 act_probs[act]));
2352
2353 cd->add_item(title, af_map[act], data1, data2, tool_tip, act);
2354}
2355
2356/***********************************************************************/
2360 action_id act,
2361 const struct act_prob *act_probs,
2362 const char *custom,
2363 QVariant data1, QVariant data2)
2364{
2365 QString title;
2367
2368 /* An action that just became impossible has its button disabled.
2369 * An action that became possible again must be re-enabled. */
2370 button->setEnabled(action_prob_possible(act_probs[act]));
2371 button->setData1(data1);
2372 button->setData2(data2);
2373 // The probability may have changed.
2375 act_probs[act],
2376 custom));
2377
2379 act_probs[act]));
2380
2381 button->setText(title);
2382 button->setToolTip(tool_tip);
2383}
2384
2385/***********************************************************************/
2388static void disband_unit(QVariant data1, QVariant data2)
2389{
2390 int actor_id = data1.toInt();
2391 int target_id = data2.toInt();
2392
2394 target_id, 0, "");
2395}
2396
2397/***********************************************************************/
2400static void fortify(QVariant data1, QVariant data2)
2401{
2402 int actor_id = data1.toInt();
2403 int target_id = data2.toInt();
2404
2405 if (game_unit_by_number(actor_id) != nullptr) {
2407 target_id, 0, "");
2408 }
2409}
2410
2411/***********************************************************************/
2414static void convert_unit(QVariant data1, QVariant data2)
2415{
2416 int actor_id = data1.toInt();
2417 int target_id = data2.toInt();
2418
2420 target_id, 0, "");
2421}
2422
2423/***********************************************************************/
2426static void homeless(QVariant data1, QVariant data2)
2427{
2428 int actor_id = data1.toInt();
2429 int target_id = data2.toInt();
2430
2431 if (game_unit_by_number(actor_id) != nullptr) {
2433 target_id, 0, "");
2434 }
2435}
2436
2437/***********************************************************************/
2440static void diplomat_bribe_unit(QVariant data1, QVariant data2)
2441{
2442 int diplomat_id = data1.toInt();
2443 int diplomat_target_id = data2.toInt();
2444
2445 if (game_unit_by_number(diplomat_id) != nullptr
2446 && game_unit_by_number(diplomat_target_id) != nullptr) {
2447 // Wait for the server's reply before moving on to the next queued diplomat.
2449
2452 }
2453}
2454
2455/***********************************************************************/
2458static void diplomat_bribe_stack(QVariant data1, QVariant data2)
2459{
2460 int diplomat_id = data1.toInt();
2461 int diplomat_target_id = data2.toInt();
2462
2463 if (game_unit_by_number(diplomat_id) != nullptr) {
2464 // Wait for the server's reply before moving on to the next queued diplomat.
2466
2469 }
2470}
2471
2472/***********************************************************************/
2475static void spy_sabotage_unit(QVariant data1, QVariant data2)
2476{
2477 int diplomat_id = data1.toInt();
2478 int diplomat_target_id = data2.toInt();
2479
2481 diplomat_target_id, 0, "");
2482}
2483
2484/***********************************************************************/
2487static void spy_sabotage_unit_esc(QVariant data1, QVariant data2)
2488{
2489 int diplomat_id = data1.toInt();
2490 int diplomat_target_id = data2.toInt();
2491
2493 diplomat_target_id, 0, "");
2494}
2495
2496/***********************************************************************/
2499static void heal_unit(QVariant data1, QVariant data2)
2500{
2501 int actor_id = data1.toInt();
2502 int target_id = data2.toInt();
2503
2504 request_do_action(ACTION_HEAL_UNIT, actor_id, target_id, 0, "");
2505}
2506
2507/***********************************************************************/
2510static void heal_unit2(QVariant data1, QVariant data2)
2511{
2512 int actor_id = data1.toInt();
2513 int target_id = data2.toInt();
2514
2515 request_do_action(ACTION_HEAL_UNIT2, actor_id, target_id, 0, "");
2516}
2517
2518/***********************************************************************/
2521static void transport_board(QVariant data1, QVariant data2)
2522{
2523 int actor_id = data1.toInt();
2524 int target_id = data2.toInt();
2525
2526 request_do_action(ACTION_TRANSPORT_BOARD, actor_id, target_id, 0, "");
2527}
2528
2529/***********************************************************************/
2532static void transport_board2(QVariant data1, QVariant data2)
2533{
2534 int actor_id = data1.toInt();
2535 int target_id = data2.toInt();
2536
2537 request_do_action(ACTION_TRANSPORT_BOARD2, actor_id, target_id, 0, "");
2538}
2539
2540/***********************************************************************/
2543static void transport_board3(QVariant data1, QVariant data2)
2544{
2545 int actor_id = data1.toInt();
2546 int target_id = data2.toInt();
2547
2548 request_do_action(ACTION_TRANSPORT_BOARD3, actor_id, target_id, 0, "");
2549}
2550
2551/***********************************************************************/
2554static void transport_embark(QVariant data1, QVariant data2)
2555{
2556 int actor_id = data1.toInt();
2557 int target_id = data2.toInt();
2558
2559 request_do_action(ACTION_TRANSPORT_EMBARK, actor_id, target_id, 0, "");
2560}
2561
2562/***********************************************************************/
2565static void transport_embark2(QVariant data1, QVariant data2)
2566{
2567 int actor_id = data1.toInt();
2568 int target_id = data2.toInt();
2569
2570 request_do_action(ACTION_TRANSPORT_EMBARK2, actor_id, target_id, 0, "");
2571}
2572
2573/***********************************************************************/
2576static void transport_embark3(QVariant data1, QVariant data2)
2577{
2578 int actor_id = data1.toInt();
2579 int target_id = data2.toInt();
2580
2581 request_do_action(ACTION_TRANSPORT_EMBARK3, actor_id, target_id, 0, "");
2582}
2583
2584/***********************************************************************/
2587static void transport_embark4(QVariant data1, QVariant data2)
2588{
2589 int actor_id = data1.toInt();
2590 int target_id = data2.toInt();
2591
2592 request_do_action(ACTION_TRANSPORT_EMBARK4, actor_id, target_id, 0, "");
2593}
2594
2595/***********************************************************************/
2598static void transport_unload(QVariant data1, QVariant data2)
2599{
2600 int actor_id = data1.toInt();
2601 int target_id = data2.toInt();
2602
2603 request_do_action(ACTION_TRANSPORT_UNLOAD, actor_id, target_id, 0, "");
2604}
2605
2606/***********************************************************************/
2609static void transport_load(QVariant data1, QVariant data2)
2610{
2611 int actor_id = data1.toInt();
2612 int target_id = data2.toInt();
2613
2614 request_do_action(ACTION_TRANSPORT_LOAD, actor_id, target_id, 0, "");
2615}
2616
2617/***********************************************************************/
2620static void transport_load2(QVariant data1, QVariant data2)
2621{
2622 int actor_id = data1.toInt();
2623 int target_id = data2.toInt();
2624
2625 request_do_action(ACTION_TRANSPORT_LOAD2, actor_id, target_id, 0, "");
2626}
2627
2628/***********************************************************************/
2631static void transport_load3(QVariant data1, QVariant data2)
2632{
2633 int actor_id = data1.toInt();
2634 int target_id = data2.toInt();
2635
2636 request_do_action(ACTION_TRANSPORT_LOAD3, actor_id, target_id, 0, "");
2637}
2638
2639/***********************************************************************/
2642static void transport_deboard(QVariant data1, QVariant data2)
2643{
2644 int actor_id = data1.toInt();
2645 int target_id = data2.toInt();
2646
2647 request_do_action(ACTION_TRANSPORT_DEBOARD, actor_id, target_id, 0, "");
2648}
2649
2650/***********************************************************************/
2653static void disembark1(QVariant data1, QVariant data2)
2654{
2655 int actor_id = data1.toInt();
2656 int target_id = data2.toInt();
2657
2658 if (game_unit_by_number(actor_id) != nullptr
2659 && index_to_tile(&(wld.map), target_id) != nullptr) {
2661 actor_id, target_id, 0, "");
2662 }
2663}
2664
2665/***********************************************************************/
2668static void disembark2(QVariant data1, QVariant data2)
2669{
2670 int actor_id = data1.toInt();
2671 int target_id = data2.toInt();
2672
2673 if (game_unit_by_number(actor_id) != nullptr
2674 && index_to_tile(&(wld.map), target_id) != nullptr) {
2676 actor_id, target_id, 0, "");
2677 }
2678}
2679
2680/***********************************************************************/
2683static void enter_hut(QVariant data1, QVariant data2)
2684{
2685 int actor_id = data1.toInt();
2686 int target_id = data2.toInt();
2687
2688 if (game_unit_by_number(actor_id) != nullptr
2689 && index_to_tile(&(wld.map), target_id) != nullptr) {
2691 actor_id, target_id, 0, "");
2692 }
2693}
2694
2695/***********************************************************************/
2698static void enter_hut2(QVariant data1, QVariant data2)
2699{
2700 int actor_id = data1.toInt();
2701 int target_id = data2.toInt();
2702
2703 if (game_unit_by_number(actor_id) != nullptr
2704 && index_to_tile(&(wld.map), target_id) != nullptr) {
2706 actor_id, target_id, 0, "");
2707 }
2708}
2709
2710/***********************************************************************/
2713static void frighten_hut(QVariant data1, QVariant data2)
2714{
2715 int actor_id = data1.toInt();
2716 int target_id = data2.toInt();
2717
2718 if (game_unit_by_number(actor_id) != nullptr
2719 && index_to_tile(&(wld.map), target_id) != nullptr) {
2721 actor_id, target_id, 0, "");
2722 }
2723}
2724
2725/***********************************************************************/
2728static void frighten_hut2(QVariant data1, QVariant data2)
2729{
2730 int actor_id = data1.toInt();
2731 int target_id = data2.toInt();
2732
2733 if (game_unit_by_number(actor_id) != nullptr
2734 && index_to_tile(&(wld.map), target_id) != nullptr) {
2736 actor_id, target_id, 0, "");
2737 }
2738}
2739
2740/**********************************************************************/
2743static void nuke_units(QVariant data1, QVariant data2)
2744{
2745 int actor_id = data1.toInt();
2746 int target_id = data2.toInt();
2747
2749 target_id, 0, "");
2750}
2751
2752/**********************************************************************/
2755static void wipe_units(QVariant data1, QVariant data2)
2756{
2757 int actor_id = data1.toInt();
2758 int target_id = data2.toInt();
2759
2761 target_id, 0, "");
2762}
2763
2764/**********************************************************************/
2767static void capture_units(QVariant data1, QVariant data2)
2768{
2769 int actor_id = data1.toInt();
2770 int target_id = data2.toInt();
2771
2773 target_id, 0, "");
2774}
2775
2776/***********************************************************************/
2779static void expel_unit(QVariant data1, QVariant data2)
2780{
2781 int actor_id = data1.toInt();
2782 int target_id = data2.toInt();
2783
2785 target_id, 0, "");
2786}
2787
2788/***********************************************************************/
2791static void bombard(QVariant data1, QVariant data2)
2792{
2793 int actor_id = data1.toInt();
2794 int target_id = data2.toInt();
2795
2797 target_id, 0, "");
2798}
2799
2800/***********************************************************************/
2803static void bombard2(QVariant data1, QVariant data2)
2804{
2805 int actor_id = data1.toInt();
2806 int target_id = data2.toInt();
2807
2809 target_id, 0, "");
2810}
2811
2812/***********************************************************************/
2815static void bombard3(QVariant data1, QVariant data2)
2816{
2817 int actor_id = data1.toInt();
2818 int target_id = data2.toInt();
2819
2821 target_id, 0, "");
2822}
2823
2824/***********************************************************************/
2827static void bombard_lethal(QVariant data1, QVariant data2)
2828{
2829 int actor_id = data1.toInt();
2830 int target_id = data2.toInt();
2831
2833 target_id, 0, "");
2834}
2835
2836/***********************************************************************/
2839static void found_city(QVariant data1, QVariant data2)
2840{
2841 int actor_id = data1.toInt();
2842
2844 actor_id);
2845}
2846
2847/***********************************************************************/
2850static void transform_terrain(QVariant data1, QVariant data2)
2851{
2852 int actor_id = data1.toInt();
2853 int target_id = data2.toInt();
2854
2855 if (game_unit_by_number(actor_id) != nullptr
2856 && index_to_tile(&(wld.map), target_id) != nullptr) {
2858 actor_id, target_id, 0, "");
2859 }
2860}
2861
2862/***********************************************************************/
2865static void cultivate(QVariant data1, QVariant data2)
2866{
2867 int actor_id = data1.toInt();
2868 int target_id = data2.toInt();
2869
2870 if (game_unit_by_number(actor_id) != nullptr
2871 && index_to_tile(&(wld.map), target_id) != nullptr) {
2873 actor_id, target_id, 0, "");
2874 }
2875}
2876
2877/***********************************************************************/
2880static void plant(QVariant data1, QVariant data2)
2881{
2882 int actor_id = data1.toInt();
2883 int target_id = data2.toInt();
2884
2885 if (game_unit_by_number(actor_id) != nullptr
2886 && index_to_tile(&(wld.map), target_id) != nullptr) {
2888 actor_id, target_id, 0, "");
2889 }
2890}
2891
2892/***********************************************************************/
2895static void pillage(QVariant data1, QVariant data2)
2896{
2897 int actor_id = data1.toInt();
2898 int target_id = data2.toInt();
2899
2900 if (game_unit_by_number(actor_id) != nullptr
2901 && index_to_tile(&(wld.map), target_id) != nullptr) {
2903 actor_id, target_id,
2904 /* FIXME: will cause problems if more than
2905 * one action selection dialog at a time
2906 * becomes supported. */
2908 "");
2909 }
2910}
2911
2912/***********************************************************************/
2915static void clean(QVariant data1, QVariant data2)
2916{
2917 int actor_id = data1.toInt();
2918 int target_id = data2.toInt();
2919
2920 if (game_unit_by_number(actor_id) != nullptr
2921 && index_to_tile(&(wld.map), target_id) != nullptr) {
2923 actor_id, target_id,
2924 /* FIXME: will cause problems if more than
2925 * one action selection dialog at a time
2926 * becomes supported. */
2928 "");
2929 }
2930}
2931
2932/***********************************************************************/
2935static void road(QVariant data1, QVariant data2)
2936{
2937 int actor_id = data1.toInt();
2938 int target_id = data2.toInt();
2939
2940 if (game_unit_by_number(actor_id) != nullptr
2941 && index_to_tile(&(wld.map), target_id) != nullptr
2944 actor_id, target_id,
2945 /* FIXME: will cause problems if more than
2946 * one action selection dialog at a time
2947 * becomes supported. */
2949 "");
2950 }
2951}
2952
2953/***********************************************************************/
2956static void base(QVariant data1, QVariant data2)
2957{
2958 int actor_id = data1.toInt();
2959 int target_id = data2.toInt();
2960
2961 if (game_unit_by_number(actor_id) != nullptr
2962 && index_to_tile(&(wld.map), target_id) != nullptr
2965 actor_id, target_id,
2966 /* FIXME: will cause problems if more than
2967 * one action selection dialog at a time
2968 * becomes supported. */
2970 "");
2971 }
2972}
2973
2974/***********************************************************************/
2977static void mine(QVariant data1, QVariant data2)
2978{
2979 int actor_id = data1.toInt();
2980 int target_id = data2.toInt();
2981
2982 if (game_unit_by_number(actor_id) != nullptr
2983 && index_to_tile(&(wld.map), target_id) != nullptr
2986 actor_id, target_id,
2987 /* FIXME: will cause problems if more than
2988 * one action selection dialog at a time
2989 * becomes supported. */
2991 "");
2992 }
2993}
2994
2995/***********************************************************************/
2998static void irrigate(QVariant data1, QVariant data2)
2999{
3000 int actor_id = data1.toInt();
3001 int target_id = data2.toInt();
3002
3003 if (game_unit_by_number(actor_id) != nullptr
3004 && index_to_tile(&(wld.map), target_id) != nullptr
3007 actor_id, target_id,
3008 /* FIXME: will cause problems if more than
3009 * one action selection dialog at a time
3010 * becomes supported. */
3012 "");
3013 }
3014}
3015
3016/***********************************************************************/
3019static void nuke(QVariant data1, QVariant data2)
3020{
3021 int diplomat_id = data1.toInt();
3022 int diplomat_target_id = data2.toInt();
3023
3024 if (game_unit_by_number(diplomat_id) != nullptr
3025 && index_to_tile(&(wld.map), diplomat_target_id) != nullptr) {
3028 }
3029}
3030
3031/***********************************************************************/
3034static void attack(QVariant data1, QVariant data2)
3035{
3036 int diplomat_id = data1.toInt();
3037 int diplomat_target_id = data2.toInt();
3038
3039 if (game_unit_by_number(diplomat_id) != nullptr
3040 && index_to_tile(&(wld.map), diplomat_target_id) != nullptr) {
3043 }
3044}
3045
3046/***********************************************************************/
3049static void suicide_attack(QVariant data1, QVariant data2)
3050{
3051 int diplomat_id = data1.toInt();
3052 int diplomat_target_id = data2.toInt();
3053
3054 if (game_unit_by_number(diplomat_id) != nullptr
3055 && index_to_tile(&(wld.map), diplomat_target_id) != nullptr) {
3058 }
3059}
3060
3061/***********************************************************************/
3064static void paradrop(QVariant data1, QVariant data2)
3065{
3066 int actor_id = data1.toInt();
3067 int target_id = data2.toInt();
3068
3069 if (game_unit_by_number(actor_id) != nullptr
3070 && index_to_tile(&(wld.map), target_id) != nullptr) {
3072 actor_id, target_id, 0, "");
3073 }
3074}
3075
3076/***********************************************************************/
3079static void paradrop_conquer(QVariant data1, QVariant data2)
3080{
3081 int actor_id = data1.toInt();
3082 int target_id = data2.toInt();
3083
3084 if (game_unit_by_number(actor_id) != nullptr
3085 && index_to_tile(&(wld.map), target_id) != nullptr) {
3087 actor_id, target_id, 0, "");
3088 }
3089}
3090
3091/***********************************************************************/
3094static void paradrop_frighten(QVariant data1, QVariant data2)
3095{
3096 int actor_id = data1.toInt();
3097 int target_id = data2.toInt();
3098
3099 if (game_unit_by_number(actor_id) != nullptr
3100 && index_to_tile(&(wld.map), target_id) != nullptr) {
3102 actor_id, target_id, 0, "");
3103 }
3104}
3105
3106/***********************************************************************/
3110{
3111 int actor_id = data1.toInt();
3112 int target_id = data2.toInt();
3113
3114 if (game_unit_by_number(actor_id) != nullptr
3115 && index_to_tile(&(wld.map), target_id) != nullptr) {
3117 actor_id, target_id, 0, "");
3118 }
3119}
3120
3121/***********************************************************************/
3124static void paradrop_enter(QVariant data1, QVariant data2)
3125{
3126 int actor_id = data1.toInt();
3127 int target_id = data2.toInt();
3128
3129 if (game_unit_by_number(actor_id) != nullptr
3130 && index_to_tile(&(wld.map), target_id) != nullptr) {
3132 actor_id, target_id, 0, "");
3133 }
3134}
3135
3136/***********************************************************************/
3140{
3141 int actor_id = data1.toInt();
3142 int target_id = data2.toInt();
3143
3144 if (game_unit_by_number(actor_id) != nullptr
3145 && index_to_tile(&(wld.map), target_id) != nullptr) {
3147 actor_id, target_id, 0, "");
3148 }
3149}
3150
3151/***********************************************************************/
3154static void join_city(QVariant data1, QVariant data2)
3155{
3156 int actor_id = data1.toInt();
3157 int target_id = data2.toInt();
3158
3159 if (game_unit_by_number(actor_id) != nullptr
3160 && game_city_by_number(target_id) != nullptr) {
3162 actor_id, target_id, 0, "");
3163 }
3164}
3165
3166/***********************************************************************/
3169static void spy_steal_shared(QVariant data1, QVariant data2,
3170 action_id act_id)
3171{
3172 QString str;
3173 QVariant qv1;
3175 int diplomat_id = data1.toInt();
3176 int diplomat_target_id = data2.toInt();
3179 struct player *pvictim = nullptr;
3182
3183 cd = gui()->get_diplo_dialog();
3184 if (cd != nullptr) {
3185 cd->close();
3186 }
3187
3188 if (pvcity == nullptr) {
3189 return;
3190 }
3191
3192 // Wait for the player's reply before moving on to the next queued diplomat.
3194
3196
3197 struct astring stra = ASTRING_INIT;
3198 cd = new choice_dialog(_("Steal"), _("Steal Technology"),
3199 gui()->game_tab_widget,
3201
3202 // Put both actor and target city in qv1 since qv2 is taken
3205 actor_and_target.append(act_id);
3206 qv1 = QVariant::fromValue(actor_and_target);
3207
3208 struct player *pplayer = client_player();
3209 const struct research *presearch = research_get(pplayer);
3210 const struct research *vresearch = research_get(pvictim);
3211
3218 // Defeat keyboard shortcut mnemonics
3220 .replace("&", "&&");
3221 cd->add_item(str, func, qv1, i);
3222 }
3224
3226 get_non_targeted_action_id(act_id)])) {
3227 astr_set(&stra, _("At %s's Discretion"),
3230 str = QString(astr_str(&stra)).replace("&", "&&");
3231 cd->add_item(str, func, qv1, A_UNSET);
3232 }
3233
3234 cd->set_layout();
3235 cd->show_me();
3236
3237 astr_free(&stra);
3238}
3239
3240/***********************************************************************/
3243static void spy_steal(QVariant data1, QVariant data2)
3244{
3246}
3247
3248/***********************************************************************/
3251static void spy_steal_esc(QVariant data1, QVariant data2)
3252{
3254}
3255
3256/***********************************************************************/
3259static void spy_steal_something(QVariant data1, QVariant data2)
3260{
3261 int diplomat_id = data1.toList().at(0).toInt();
3262 int diplomat_target_id = data1.toList().at(1).toInt();
3263 action_id act_id = data1.toList().at(2).toInt();
3264
3265 if (game_unit_by_number(diplomat_id) != nullptr
3266 && game_city_by_number(diplomat_target_id) != nullptr) {
3267 if (data2.toInt() == A_UNSET) {
3268 // This is the untargeted version.
3270 diplomat_id, diplomat_target_id, data2.toInt(), "");
3271 } else {
3272 // This is the targeted version.
3274 diplomat_target_id, data2.toInt(), "");
3275 }
3276 }
3277}
3278
3279/***********************************************************************/
3283{
3284 int actor_id = data1.toInt();
3285 int target_id = data2.toInt();
3286
3287 if (game_unit_by_number(actor_id) != nullptr
3288 && game_city_by_number(target_id) != nullptr) {
3289 // Wait for the server's reply before moving on to the next queued diplomat.
3291
3292 request_action_details(ACTION_STRIKE_BUILDING, actor_id, target_id);
3293 }
3294}
3295
3296/***********************************************************************/
3300{
3301 int diplomat_id = data1.toInt();
3302 int diplomat_target_id = data2.toInt();
3303
3304 if (game_unit_by_number(diplomat_id) != nullptr
3305 && game_city_by_number(diplomat_target_id) != nullptr) {
3306 // Wait for the server's reply before moving on to the next queued diplomat.
3308
3311 }
3312}
3313
3314/***********************************************************************/
3318{
3319 int diplomat_id = data1.toInt();
3320 int diplomat_target_id = data2.toInt();
3321
3322 if (game_unit_by_number(diplomat_id) != nullptr
3323 && game_city_by_number(diplomat_target_id) != nullptr) {
3324 /* Wait for the server's reply before moving on to the next queued
3325 * diplomat. */
3327
3330 }
3331}
3332
3333/***********************************************************************/
3336static void spy_poison(QVariant data1, QVariant data2)
3337{
3338 int diplomat_id = data1.toInt();
3339 int diplomat_target_id = data2.toInt();
3340
3341 if (game_unit_by_number(diplomat_id) != nullptr
3342 && game_city_by_number(diplomat_target_id) != nullptr) {
3345 }
3346}
3347
3348/***********************************************************************/
3351static void spy_poison_esc(QVariant data1, QVariant data2)
3352{
3353 int diplomat_id = data1.toInt();
3354 int diplomat_target_id = data2.toInt();
3355
3356 if (game_unit_by_number(diplomat_id) != nullptr
3357 && game_city_by_number(diplomat_target_id) != nullptr) {
3360 }
3361}
3362
3363/***********************************************************************/
3366static void spy_nuke_city(QVariant data1, QVariant data2)
3367{
3368 int diplomat_id = data1.toInt();
3369 int diplomat_target_id = data2.toInt();
3370
3371 if (game_unit_by_number(diplomat_id) != nullptr
3372 && game_city_by_number(diplomat_target_id) != nullptr) {
3375 }
3376}
3377
3378/***********************************************************************/
3381static void spy_nuke_city_esc(QVariant data1, QVariant data2)
3382{
3383 int diplomat_id = data1.toInt();
3384 int diplomat_target_id = data2.toInt();
3385
3386 if (game_unit_by_number(diplomat_id) != nullptr
3387 && game_city_by_number(diplomat_target_id) != nullptr) {
3390 }
3391}
3392
3393/***********************************************************************/
3396static void nuke_city(QVariant data1, QVariant data2)
3397{
3398 int actor_id = data1.toInt();
3399 int target_id = data2.toInt();
3400
3401 if (game_unit_by_number(actor_id) != nullptr
3402 && game_city_by_number(target_id) != nullptr) {
3404 actor_id, target_id, 0, "");
3405 }
3406}
3407
3408/***********************************************************************/
3411static void destroy_city(QVariant data1, QVariant data2)
3412{
3413 int diplomat_id = data1.toInt();
3414 int diplomat_target_id = data2.toInt();
3415
3416 if (game_unit_by_number(diplomat_id) != nullptr
3417 && game_city_by_number(diplomat_target_id) != nullptr) {
3420 }
3421}
3422
3423/***********************************************************************/
3426static void spy_steal_gold(QVariant data1, QVariant data2)
3427{
3428 int diplomat_id = data1.toInt();
3429 int diplomat_target_id = data2.toInt();
3430
3431 if (game_unit_by_number(diplomat_id) != nullptr
3432 && game_city_by_number(diplomat_target_id) != nullptr) {
3435 }
3436}
3437
3438/***********************************************************************/
3441static void spy_steal_gold_esc(QVariant data1, QVariant data2)
3442{
3443 int diplomat_id = data1.toInt();
3444 int diplomat_target_id = data2.toInt();
3445
3446 if (game_unit_by_number(diplomat_id) != nullptr
3447 && game_city_by_number(diplomat_target_id) != nullptr) {
3450 }
3451}
3452
3453/***********************************************************************/
3456static void spy_steal_maps(QVariant data1, QVariant data2)
3457{
3458 int diplomat_id = data1.toInt();
3459 int diplomat_target_id = data2.toInt();
3460
3461 if (game_unit_by_number(diplomat_id) != nullptr
3462 && game_city_by_number(diplomat_target_id) != nullptr) {
3465 }
3466}
3467
3468/***********************************************************************/
3471static void spy_steal_maps_esc(QVariant data1, QVariant data2)
3472{
3473 int diplomat_id = data1.toInt();
3474 int diplomat_target_id = data2.toInt();
3475
3476 if (game_unit_by_number(diplomat_id) != nullptr
3477 && game_city_by_number(diplomat_target_id) != nullptr) {
3480 }
3481}
3482
3483/***********************************************************************/
3486static void spy_escape(QVariant data1, QVariant data2)
3487{
3488 int diplomat_id = data1.toInt();
3489 int diplomat_target_id = data2.toInt();
3490
3491 if (game_unit_by_number(diplomat_id) != nullptr
3492 && game_city_by_number(diplomat_target_id) != nullptr) {
3495 }
3496}
3497
3498/***********************************************************************/
3501static void spy_embassy(QVariant data1, QVariant data2)
3502{
3503 int diplomat_id = data1.toInt();
3504 int diplomat_target_id = data2.toInt();
3505
3506 if (game_unit_by_number(diplomat_id) != nullptr
3507 && game_city_by_number(diplomat_target_id) != nullptr) {
3509 diplomat_target_id, 0, "");
3510 }
3511}
3512
3513/***********************************************************************/
3516static void diplomat_embassy(QVariant data1, QVariant data2)
3517{
3518 int diplomat_id = data1.toInt();
3519 int diplomat_target_id = data2.toInt();
3520
3521 if (game_unit_by_number(diplomat_id) != nullptr
3522 && game_city_by_number(diplomat_target_id) != nullptr) {
3524 diplomat_target_id, 0, "");
3525 }
3526}
3527
3528/***********************************************************************/
3531static void spy_investigate(QVariant data1, QVariant data2)
3532{
3533 int diplomat_id = data1.toInt();
3534 int diplomat_target_id = data2.toInt();
3535
3537 && game_unit_by_number(diplomat_id) != nullptr) {
3539 diplomat_target_id, 0, "");
3540 }
3541}
3542
3543/***********************************************************************/
3546static void diplomat_investigate(QVariant data1, QVariant data2)
3547{
3548 int diplomat_id = data1.toInt();
3549 int diplomat_target_id = data2.toInt();
3550
3552 && game_unit_by_number(diplomat_id) != nullptr) {
3554 diplomat_target_id, 0, "");
3555 }
3556}
3557
3558/***********************************************************************/
3561static void diplomat_sabotage(QVariant data1, QVariant data2)
3562{
3563 int diplomat_id = data1.toInt();
3564 int diplomat_target_id = data2.toInt();
3565
3566 if (game_unit_by_number(diplomat_id) != nullptr
3567 && game_city_by_number(diplomat_target_id) != nullptr) {
3569 diplomat_target_id, B_LAST + 1, "");
3570 }
3571}
3572
3573/***********************************************************************/
3576static void diplomat_sabotage_esc(QVariant data1, QVariant data2)
3577{
3578 int diplomat_id = data1.toInt();
3579 int diplomat_target_id = data2.toInt();
3580
3581 if (game_unit_by_number(diplomat_id) != nullptr
3582 && game_city_by_number(diplomat_target_id) != nullptr) {
3584 diplomat_target_id, B_LAST + 1, "");
3585 }
3586}
3587
3588/***********************************************************************/
3591static void diplomat_steal(QVariant data1, QVariant data2)
3592{
3593 int diplomat_id = data1.toInt();
3594 int diplomat_target_id = data2.toInt();
3595
3596 if (game_unit_by_number(diplomat_id) != nullptr
3597 && game_city_by_number(diplomat_target_id) != nullptr) {
3600 }
3601}
3602
3603/***********************************************************************/
3606static void diplomat_steal_esc(QVariant data1, QVariant data2)
3607{
3608 int diplomat_id = data1.toInt();
3609 int diplomat_target_id = data2.toInt();
3610
3611 if (game_unit_by_number(diplomat_id) != nullptr
3612 && game_city_by_number(diplomat_target_id) != nullptr) {
3615 }
3616}
3617
3618/***********************************************************************/
3621static void diplomat_incite(QVariant data1, QVariant data2)
3622{
3623 int diplomat_id = data1.toInt();
3624 int diplomat_target_id = data2.toInt();
3625
3626 if (game_unit_by_number(diplomat_id) != nullptr
3627 && game_city_by_number(diplomat_target_id) != nullptr) {
3628 // Wait for the server's reply before moving on to the next queued diplomat.
3630
3633 }
3634}
3635
3636/***********************************************************************/
3640{
3641 int diplomat_id = data1.toInt();
3642 int diplomat_target_id = data2.toInt();
3643
3644 if (game_unit_by_number(diplomat_id) != nullptr
3645 && game_city_by_number(diplomat_target_id) != nullptr) {
3646 // Wait for the server's reply before moving on to the next queued diplomat.
3648
3651 }
3652}
3653
3654/***********************************************************************/
3657static void regular_move(QVariant data1, QVariant data2)
3658{
3659 int actor_id = data1.toInt();
3660 int target_id = data2.toInt();
3661
3662 if (game_unit_by_number(actor_id) != nullptr
3663 && index_to_tile(&(wld.map), target_id) != nullptr) {
3665 actor_id, target_id, 0, "");
3666 }
3667}
3668
3669/***********************************************************************/
3673void popup_incite_dialog(struct unit *actor, struct city *tcity, int cost,
3674 const struct action *paction)
3675{
3676 char buf[1024];
3677 char buf2[1024];
3678 int diplomat_id = actor->id;
3679 int diplomat_target_id = tcity->id;
3680 const int act_id = paction->id;
3681
3682 // Should be set before sending request to the server.
3684
3685 fc_snprintf(buf, ARRAY_SIZE(buf), PL_("Treasury contains %d gold.",
3686 "Treasury contains %d gold.",
3687 client_player()->economic.gold),
3688 client_player()->economic.gold);
3689
3691 hud_message_box *impossible = new hud_message_box(gui()->central_wdg);
3692
3694 _("You can't incite a revolt in %s."), city_name_get(tcity));
3695 impossible->set_text_title(buf2, "!");
3696 impossible->setStandardButtons(QMessageBox::Ok);
3697 impossible->setAttribute(Qt::WA_DeleteOnClose);
3698 impossible->show();
3699 } else if (cost <= client_player()->economic.gold) {
3700 hud_message_box *ask = new hud_message_box(gui()->central_wdg);
3701
3703 PL_("Incite a revolt for %d gold?\n%s",
3704 "Incite a revolt for %d gold?\n%s", cost), cost, buf);
3705 ask->setStandardButtons(QMessageBox::Cancel | QMessageBox::Ok);
3706 ask->setDefaultButton(QMessageBox::Cancel);
3707 ask->set_text_title(buf2, _("Incite a Revolt!"));
3708 ask->setAttribute(Qt::WA_DeleteOnClose);
3709 QObject::connect(ask, &hud_message_box::accepted, [=]() {
3712 });
3713 ask->show();
3714 return;
3715 } else {
3716 hud_message_box *too_much = new hud_message_box(gui()->central_wdg);
3717
3719 PL_("Inciting a revolt costs %d gold.\n%s",
3720 "Inciting a revolt costs %d gold.\n%s", cost), cost,
3721 buf);
3722 too_much->set_text_title(buf2, "!");
3723 too_much->setStandardButtons(QMessageBox::Ok);
3724 too_much->setAttribute(Qt::WA_DeleteOnClose);
3725 too_much->show();
3726 }
3727
3729}
3730
3731/***********************************************************************/
3735void popup_bribe_unit_dialog(struct unit *actor, struct unit *tunit, int cost,
3736 const struct action *paction)
3737{
3738 hud_message_box *ask = new hud_message_box(gui()->central_wdg);
3739 char buf[1024];
3740 char buf2[1024];
3741 int diplomat_id = actor->id;
3742 int diplomat_target_id = tunit->id;
3743 const int act_id = paction->id;
3744
3745 // Should be set before sending request to the server.
3747
3748 fc_snprintf(buf, ARRAY_SIZE(buf), PL_("Treasury contains %d gold.",
3749 "Treasury contains %d gold.",
3750 client_player()->economic.gold),
3751 client_player()->economic.gold);
3752
3753 if (cost <= client_player()->economic.gold) {
3754 fc_snprintf(buf2, ARRAY_SIZE(buf2), PL_("Bribe unit for %d gold?\n%s",
3755 "Bribe unit for %d gold?\n%s",
3756 cost), cost, buf);
3757 ask->set_text_title(buf2, _("Bribe Enemy Unit"));
3758 ask->setStandardButtons(QMessageBox::Cancel | QMessageBox::Ok);
3759 ask->setDefaultButton(QMessageBox::Cancel);
3760 ask->setAttribute(Qt::WA_DeleteOnClose);
3761 QObject::connect(ask, &hud_message_box::accepted, [=]() {
3764 });
3765 ask->show();
3766 return;
3767 } else {
3769 PL_("Bribing the unit costs %d gold.\n%s",
3770 "Bribing the unit costs %d gold.\n%s", cost), cost, buf);
3771 ask->set_text_title(buf2, _("Traitors Demand Too Much!"));
3772 ask->setAttribute(Qt::WA_DeleteOnClose);
3773 ask->show();
3774 }
3775
3777}
3778
3779/***********************************************************************/
3784 const struct action *paction)
3785{
3786 hud_message_box *ask = new hud_message_box(gui()->central_wdg);
3787 char buf[1024];
3788 char buf2[1024];
3789 int diplomat_id = actor->id;
3790 int diplomat_target_id = ttile->index;
3791 const int act_id = paction->id;
3792
3793 // Should be set before sending request to the server.
3795
3796 fc_snprintf(buf, ARRAY_SIZE(buf), PL_("Treasury contains %d gold.",
3797 "Treasury contains %d gold.",
3798 client_player()->economic.gold),
3799 client_player()->economic.gold);
3800
3801 if (cost <= client_player()->economic.gold) {
3802 fc_snprintf(buf2, ARRAY_SIZE(buf2), PL_("Bribe unit stack for %d gold?\n%s",
3803 "Bribe unit stack for %d gold?\n%s",
3804 cost), cost, buf);
3805 ask->set_text_title(buf2, _("Bribe Enemy Stack"));
3806 ask->setStandardButtons(QMessageBox::Cancel | QMessageBox::Ok);
3807 ask->setDefaultButton(QMessageBox::Cancel);
3808 ask->setAttribute(Qt::WA_DeleteOnClose);
3809 QObject::connect(ask, &hud_message_box::accepted, [=]() {
3812 });
3813 ask->show();
3814 return;
3815 } else {
3817 PL_("Bribing the unit stack costs %d gold.\n%s",
3818 "Bribing the unit stack costs %d gold.\n%s", cost), cost, buf);
3819 ask->set_text_title(buf2, _("Traitors Demand Too Much!"));
3820 ask->setAttribute(Qt::WA_DeleteOnClose);
3821 ask->show();
3822 }
3823
3825}
3826
3827/***********************************************************************/
3830static void pillage_something(QVariant data1, QVariant data2)
3831{
3832 int punit_id;
3833 int what;
3834 struct unit *punit;
3835 struct extra_type *target;
3836
3837 what = data1.toInt();
3838 punit_id = data2.toInt();
3840 if (punit) {
3841 target = extra_by_number(what);
3843 }
3845}
3846
3847/***********************************************************************/
3850static void spy_sabotage(QVariant data1, QVariant data2)
3851{
3852 int diplomat_id = data1.toList().at(0).toInt();
3853 int diplomat_target_id = data1.toList().at(1).toInt();
3854 action_id act_id = data1.toList().at(2).toInt();
3855
3856 if (game_unit_by_number(diplomat_id) != nullptr
3857 && game_city_by_number(diplomat_target_id) != nullptr) {
3858 if (data2.toInt() == B_LAST) {
3859 // This is the untargeted version.
3861 diplomat_id, diplomat_target_id, data2.toInt(),
3862 "");
3863 } else if (data2.toInt() == -1) {
3864 // This is the city production version.
3866 diplomat_id, diplomat_target_id, data2.toInt(),
3867 "");
3868 } else {
3869 // This is the targeted version.
3871 diplomat_target_id, data2.toInt(), "");
3872 }
3873 }
3874}
3875
3876/***********************************************************************/
3881 const struct action *paction)
3882{
3883 QString str;
3884 QVariant qv1, qv2;
3885 int diplomat_id = actor->id;
3886 int diplomat_target_id = tcity->id;
3888 choice_dialog *cd = new choice_dialog(_("Sabotage"),
3889 _("Select Improvement to Sabotage"),
3890 gui()->game_tab_widget,
3892 int nr = 0;
3893 struct astring stra = ASTRING_INIT;
3895
3896 // Should be set before sending request to the server.
3898
3899 // Put both actor, target city and action in qv1 since qv2 is taken
3902 actor_and_target.append(paction->id);
3903 qv1 = QVariant::fromValue(actor_and_target);
3904
3907 paction->id)])) {
3909 cd->add_item(QString(_("City Production")), func, qv1, -1);
3910 }
3911
3912 city_built_iterate(tcity, pimprove) {
3913 if (pimprove->sabotage > 0) {
3915 // Defeat keyboard shortcut mnemonics
3917 .replace("&", "&&");
3918 qv2 = nr;
3919 cd->add_item(str, func, qv1, improvement_number(pimprove));
3920 nr++;
3921 }
3923
3926 astr_set(&stra, _("At %s's Discretion"),
3929 str = QString(astr_str(&stra)).replace("&", "&&");
3930 cd->add_item(str, func, qv1, B_LAST);
3931 }
3932
3933 cd->set_layout();
3934 cd->show_me();
3935 astr_free(&stra);
3936}
3937
3938/***********************************************************************/
3943{
3944 QString str;
3945 QVariant qv1, qv2;
3948 struct extra_type *tgt;
3949
3951 return;
3952 }
3953 cd = new choice_dialog(_("What To Pillage"), _("Select what to pillage:"),
3954 gui()->game_tab_widget);
3955 qv2 = punit->id;
3956 while ((tgt = get_preferred_pillage(extras))) {
3957 int what;
3958
3959 what = extra_index(tgt);
3960 BV_CLR(extras, what);
3961
3963 // Defeat keyboard shortcut mnemonics
3964 str = QString(extra_name_translation(tgt)).replace("&", "&&");
3965 qv1 = what;
3966 cd->add_item(str, func, qv1, qv2);
3967 }
3968 cd->set_layout();
3969 cd->show_me();
3970}
3971
3972/***********************************************************************/
3976 QWidget *parent) : hud_message_box(parent)
3977{
3978 QString str;
3979 QPushButton *pb;
3980
3981 setAttribute(Qt::WA_DeleteOnClose);
3982 setModal(false);
3987
3988 str = QString(PL_("Are you sure you want to disband that %1 unit?",
3989 "Are you sure you want to disband those %1 units?",
3991 pb = addButton(_("Yes"), QMessageBox::AcceptRole);
3992 addButton(_("No"), QMessageBox::RejectRole);
3993 set_text_title(str, _("Disband units"));
3995 connect(pb, &QAbstractButton::clicked, this, &disband_box::disband_clicked);
3996}
3997
3998/***********************************************************************/
4009
4010/***********************************************************************/
4017
4018/***********************************************************************/
4021void popup_disband_dialog(struct unit_list *punits)
4022{
4023 disband_box *ask = new disband_box(punits, gui()->central_wdg);
4024 ask->show();
4025}
4026
4027/***********************************************************************/
4032{
4033 hud_message_box *ask = new hud_message_box(gui()->central_wdg);
4034 QString text;
4035 QString title;
4036
4037 title = QString(_("Modpack suggests using %1 tileset."))
4039 text = QString("It might not work with other tilesets.\n"
4040 "You are currently using tileset %1.")
4042 ask->addButton(_("Keep current tileset"), QMessageBox::RejectRole);
4043 ask->addButton(_("Load tileset"), QMessageBox::AcceptRole);
4044 ask->set_text_title(text, title);
4045 ask->setAttribute(Qt::WA_DeleteOnClose);
4046
4047 QObject::connect(ask, &hud_message_box::accepted, [=]() {
4050 gui()->map_scale)) {
4052 _("Can't load requested tileset."));
4053 }
4054 });
4055 ask->show();
4056}
4057
4058/***********************************************************************/
4063{
4064 hud_message_box *ask = new hud_message_box(gui()->central_wdg);
4065 QString text;
4066 QString title;
4067
4068 title = QString(_("Modpack suggests using %1 soundset."))
4070 text = QString("It might not work with other tilesets.\n"
4071 "You are currently using soundset %1.")
4072 .arg(sound_set_name);
4073 ask->addButton(_("Keep current soundset"), QMessageBox::RejectRole);
4074 ask->addButton(_("Load soundset"), QMessageBox::AcceptRole);
4075 ask->set_text_title(text, title);
4076 ask->setAttribute(Qt::WA_DeleteOnClose);
4077 QObject::connect(ask, &hud_message_box::accepted, [=]() {
4079 });
4080 ask->show();
4081}
4082
4083/***********************************************************************/
4088{
4089 hud_message_box *ask = new hud_message_box(gui()->central_wdg);
4090 QString text;
4091 QString title;
4092
4093 title = QString(_("Modpack suggests using %1 musicset."))
4095 text = QString("It might not work with other tilesets.\n"
4096 "You are currently using musicset %1.")
4097 .arg(music_set_name);
4098 ask->addButton(_("Keep current musicset"), QMessageBox::RejectRole);
4099 ask->addButton(_("Load musicset"), QMessageBox::AcceptRole);
4100 ask->set_text_title(text, title);
4101 ask->setAttribute(Qt::WA_DeleteOnClose);
4102 QObject::connect(ask, &hud_message_box::accepted, [=]() {
4104 });
4105 ask->show();
4106}
4107
4108/***********************************************************************/
4113{
4114 // PORTME
4115 return false;
4116}
4117
4118/***********************************************************************/
4122{
4124 int i;
4125
4126 nd_list = gui()->mapview_wdg->findChildren<notify_dialog *>();
4127 for (i = 0; i < nd_list.count(); i++) {
4128 nd_list[i]->restart();
4129 delete nd_list[i];
4130 }
4131}
4132
4133/***********************************************************************/
4138{
4139 int i;
4142 goto_dialog *gtd;
4143
4144 QApplication::alert(gui()->central_wdg);
4145 cd_list = gui()->game_tab_widget->findChildren <choice_dialog *>();
4146 for (i = 0; i < cd_list.count(); i++) {
4147 cd_list[i]->close();
4148 }
4149 nd_list = gui()->game_tab_widget->findChildren <notify_dialog *>();
4150 for (i = 0; i < nd_list.count(); i++) {
4151 nd_list[i]->close();
4152 }
4153
4162 gui()->popdown_unit_sel();
4163
4164 gtd = gui()->gtd;
4165
4166 if (gtd != nullptr) {
4167 gtd->close_dlg();
4168 }
4169}
4170
4171/***********************************************************************/
4177{
4178 choice_dialog *cd = gui()->get_diplo_dialog();
4179
4180 if (cd != nullptr) {
4181 return cd->unit_id;
4182 } else {
4183 return IDENTITY_NUMBER_ZERO;
4184 }
4185}
4186
4187/***********************************************************************/
4194{
4195 choice_dialog *cd = gui()->get_diplo_dialog();
4196
4197 if (cd != nullptr) {
4198 return cd->target_id[ATK_CITY];
4199 } else {
4200 return IDENTITY_NUMBER_ZERO;
4201 }
4202}
4203
4204/***********************************************************************/
4211{
4212 choice_dialog *cd = gui()->get_diplo_dialog();
4213
4214 if (cd != nullptr) {
4215 return cd->target_id[ATK_TILE];
4216 } else {
4217 return TILE_INDEX_NONE;
4218 }
4219}
4220
4221/**********************************************************************/
4228{
4229 choice_dialog *cd = gui()->get_diplo_dialog();
4230
4231 if (cd != nullptr) {
4232 return cd->sub_target_id[ASTK_EXTRA];
4233 } else {
4234 return EXTRA_NONE;
4235 }
4236}
4237
4238/***********************************************************************/
4245{
4246 choice_dialog *cd = gui()->get_diplo_dialog();
4247
4248 if (cd != nullptr) {
4249 return cd->target_id[ATK_UNIT];
4250 } else {
4251 return IDENTITY_NUMBER_ZERO;
4252 }
4253}
4254
4255/***********************************************************************/
4259 struct city *target_city,
4260 struct unit *target_unit,
4261 struct tile *target_tile,
4262 struct extra_type *target_extra,
4263 const struct act_prob *act_probs)
4264{
4267 Choice_dialog_button *cancel_button;
4268 QVariant qv1, qv2;
4269
4270 asd = gui()->get_diplo_dialog();
4271 if (asd == nullptr) {
4272 fc_assert_msg(asd != nullptr,
4273 "The action selection dialog should have been open");
4274 return;
4275 }
4276
4279 "The action selection dialog is for another actor unit.");
4280 }
4281
4282 // Put the actor id in qv1.
4283 qv1 = actor_unit->id;
4284
4285 cancel_button = asd->get_identified_button(BUTTON_CANCEL);
4286 if (cancel_button != nullptr) {
4287 /* Temporary remove the Cancel button so it won't end up above
4288 * any added buttons. */
4289 asd->stack_button(cancel_button);
4290 }
4291
4292 wait_button = asd->get_identified_button(BUTTON_WAIT);
4293 if (wait_button != nullptr) {
4294 /* Temporary remove the Wait button so it won't end up above
4295 * any added buttons. */
4296 asd->stack_button(wait_button);
4297 }
4298
4299 action_iterate(act) {
4300 const char *custom;
4301
4302 if (action_id_get_actor_kind(act) != AAK_UNIT) {
4303 // Not relevant.
4304 continue;
4305 }
4306
4308 act_probs[act],
4309 actor_unit,
4310 target_city);
4311
4312 // Put the target id in qv2.
4313 switch (action_id_get_target_kind(act)) {
4314 case ATK_UNIT:
4315 if (target_unit != nullptr) {
4316 qv2 = target_unit->id;
4317 } else {
4319 || target_unit != nullptr,
4320 "Action enabled against non existing unit!");
4321
4323 }
4324 break;
4325 case ATK_CITY:
4326 if (target_city != nullptr) {
4327 qv2 = target_city->id;
4328 } else {
4330 || target_city != nullptr,
4331 "Action enabled against non existing city!");
4332
4334 }
4335 break;
4336 case ATK_TILE:
4337 case ATK_EXTRAS:
4338 case ATK_STACK:
4339 if (target_tile != nullptr) {
4341 } else {
4343 || target_tile != nullptr,
4344 "Action enabled against all units on "
4345 "non existing tile!");
4346
4348 }
4349 break;
4350 case ATK_SELF:
4351 qv2 = actor_unit->id;
4352 break;
4353 case ATK_COUNT:
4355 "Bad target kind");
4356 continue;
4357 }
4358
4359 if (asd->get_identified_button(act)) {
4360 // Update the existing button.
4361 action_entry_update(asd->get_identified_button(act),
4362 act, act_probs, custom,
4363 qv1, qv2);
4364 } else {
4365 // Add the button (unless its probability is 0).
4367 qv1, qv2);
4368 }
4370
4371 if (wait_button != nullptr || cancel_button != nullptr) {
4372 /* Reinsert the non action buttons below any potential
4373 * buttons recently added. */
4374 asd->unstack_all_buttons();
4375 }
4376}
4377
4378/***********************************************************************/
4382{
4384
4385 cd = gui()->get_diplo_dialog();
4386 if (cd != nullptr) {
4387 did_not_decide = true;
4388 cd->close();
4389 }
4390}
4391
4392/***********************************************************************/
4398
4399/***********************************************************************/
4402void show_tileset_error(bool fatal, const char *tset_name, const char *msg)
4403{
4404 QWidget *parent;
4405 fc_client *std_gui = gui();
4406
4407 if (std_gui != nullptr) {
4408 parent = std_gui->central_wdg;
4409 } else {
4410 parent = nullptr;
4411 }
4412
4413 if (std_gui != nullptr || fatal) {
4414 char buf[1024];
4415 QMessageBox *ask = new QMessageBox(parent);
4416
4417 if (tset_name != nullptr) {
4418 fc_snprintf(buf, sizeof(buf),
4419 _("Tileset \"%s\" problem, it's probably incompatible with "
4420 "the ruleset:\n%s"), tset_name, msg);
4421 } else {
4422 fc_snprintf(buf, sizeof(buf),
4423 _("Tileset problem, it's probably incompatible with "
4424 "the ruleset:\n%s"), msg);
4425 }
4426
4427 ask->setText(buf);
4428 ask->setStandardButtons(QMessageBox::Ok);
4429 ask->setWindowTitle(_("Tileset error"));
4430
4431 if (std_gui != nullptr) {
4432 ask->setAttribute(Qt::WA_DeleteOnClose);
4433 ask->show();
4434 } else {
4435 ask->exec();
4436 }
4437 }
4438}
4439
4440/***********************************************************************/
4443void popup_upgrade_dialog(struct unit_list *punits)
4444{
4445 char buf[512];
4447 QString title;
4449
4450 if (!punits || unit_list_size(punits) == 0) {
4451 return;
4452 }
4453
4454 ask = new hud_message_box(gui()->central_wdg);
4455
4456 punit_ids = new QVector<int>();
4458 punit_ids->push_back(punit->id);
4460
4461 if (!get_units_upgrade_info(buf, sizeof(buf), punits)) {
4462 title = _("Upgrade Unit!");
4463 ask->setStandardButtons(QMessageBox::Ok);
4464 } else {
4465 title = _("Upgrade Obsolete Units");
4466 ask->setStandardButtons(QMessageBox::Cancel | QMessageBox::Ok);
4467 ask->setDefaultButton(QMessageBox::Cancel);
4468 }
4469 ask->set_text_title(buf, title);
4470 ask->setAttribute(Qt::WA_DeleteOnClose);
4471 QObject::connect(ask, &hud_message_box::accepted, [=]() {
4472 std::unique_ptr<QVector<int>> uptr(punit_ids);
4473 struct unit *punit;
4474
4475 for (int id : *uptr) {
4477 if (punit) {
4479 }
4480 }
4481 });
4482 ask->show();
4483}
4484
4485/***********************************************************************/
4489{
4490 QPoint p, final_p;
4491
4493 utile = ptile;
4494 pix = nullptr;
4495 show_line = 0;
4496 highligh_num = -1;
4497 ufont.setItalic(true);
4499 update_units();
4500 h_pix = nullptr;
4501 create_pixmap();
4502 p = mapFromGlobal(QCursor::pos());
4503 cw = new close_widget(this);
4504 setMouseTracking(true);
4505 final_p.setX(p.x());
4506 final_p.setY(p.y());
4507 if (p.x() + width() > parentWidget()->width()) {
4508 final_p.setX(parentWidget()->width() - width());
4509 }
4510 if (p.y() - height() < 0) {
4511 final_p.setY(height());
4512 }
4513 move(final_p.x(), final_p.y() - height());
4514 setFocus();
4515 /* Build fails with qt5 connect style for static functions
4516 * Qt5.2 so dont update */
4517 QTimer::singleShot(10, this, SLOT(update_img()));
4518}
4519
4520/***********************************************************************/
4524{
4525 delete h_pix;
4526 delete pix;
4527 delete cw;
4528}
4529
4530/***********************************************************************/
4534{
4535 int a;
4536 int x, y, i;
4539 QImage img;
4541 QPainter p;
4542 QPen pen;
4543 QPixmap pixc;
4544 QPixmap *pixp;
4546 QRect crop;
4547 struct canvas *unit_pixmap;
4548 struct unit *punit;
4549 float isosize;
4550
4551 if (pix != nullptr) {
4552 delete pix;
4553 pix = nullptr;
4554 };
4555 isosize = 0.7;
4557 isosize = 0.5;
4558 }
4559
4560 update_units();
4561 if (unit_list.count() > 0) {
4565 } else {
4568 }
4569 more = false;
4570 if (h_pix != nullptr) {
4571 delete h_pix;
4572 }
4573 h_pix = new QPixmap(item_size.width(), item_size.height());
4574 h_pix->fill(palette().color(QPalette::HighlightedText));
4575 if (unit_count < 5) {
4576 row_count = 1;
4577 pix = new QPixmap((unit_list.size()) * item_size.width(),
4578 item_size.height());
4579 } else if (unit_count < 9) {
4580 row_count = 2;
4581 pix = new QPixmap(4 * item_size.width(), 2 * item_size.height());
4582 } else {
4583 row_count = 3;
4584 if (unit_count > 12) {
4585 more = true;
4586 }
4587 pix = new QPixmap(4 * item_size.width(), 3 * item_size.height());
4588 }
4589 pix->fill(Qt::transparent);
4590 foreach(punit, unit_list) {
4593 unit_pixmap->map_pixmap.fill(Qt::transparent);
4594 put_unit(punit, unit_pixmap, 1.0, 0, 0);
4595 img = unit_pixmap->map_pixmap.toImage();
4597 cropped_img = img.copy(crop);
4601 Qt::KeepAspectRatio,
4602 Qt::SmoothTransformation);
4603 } else {
4606 Qt::KeepAspectRatio,
4607 Qt::SmoothTransformation);
4608 }
4609 pixc = QPixmap::fromImage(img);
4610 pixp = new QPixmap(pixc);
4611 pix_list.push_back(pixp);
4613 }
4614 a = qMin(item_size.width() / 4, 12);
4615 x = 0, y = -item_size.height(), i = -1;
4616 p.begin(pix);
4617 ufont.setPixelSize(a);
4618 p.setFont(ufont);
4619 pen.setColor(palette().color(QPalette::Text));
4620 p.setPen(pen);
4621
4622 while (!pix_list.isEmpty()) {
4623 tmp_pix = pix_list.takeFirst();
4624 i++;
4625 if (i % 4 == 0) {
4626 x = 0;
4627 y = y + item_size.height();
4628 }
4629 punit = unit_list.at(i);
4630 Q_ASSERT(punit != nullptr);
4631
4632 if (i == highligh_num) {
4633 p.drawPixmap(x, y, *h_pix);
4634 p.drawPixmap(x, y, *tmp_pix);
4635 } else {
4636 p.drawPixmap(x, y, *tmp_pix);
4637 }
4638
4640 int rate, f;
4641 QString str;
4642
4644 f = ((punit->fuel) - 1);
4647 str = str + "(" + QString(move_points_text((rate * f)
4648 + punit->moves_left, false)) + ")";
4649 }
4650 // TRANS: MP = Movement points
4651 str = QString(_("MP:")) + str;
4652 p.drawText(x, y + item_size.height() - 4, str);
4653 }
4654
4655 x = x + item_size.width();
4656 delete tmp_pix;
4657 }
4658 p.end();
4659 setFixedWidth(pix->width() + 20);
4660 setFixedHeight(pix->height() + 2 * (fm.height() + 6));
4661 qDeleteAll(pix_list.begin(), pix_list.end());
4662 }
4663}
4664
4665/***********************************************************************/
4669{
4670 int a, b;
4671 int old_h;
4673 QPoint pos = event->pos();
4674 int x = pos.x();
4675 int y = pos.y();
4676
4678 highligh_num = -1;
4679 if (x > width() - 11
4680 || y > height() - fm.height() - 5
4681 || y < fm.height() + 3 || x < 11) {
4682 // Do nothing if mouse is on border, just skip next if
4683 } else if (row_count > 0) {
4684 a = (x - 10) / item_size.width();
4685 b = (y - fm.height() - 3) / item_size.height();
4686 highligh_num = b * 4 + a;
4687 }
4688 if (old_h != highligh_num) {
4689 create_pixmap();
4690 update();
4691 }
4692}
4693
4694/***********************************************************************/
4700{
4701 struct unit *punit;
4702 if (event->button() == Qt::RightButton) {
4703 was_destroyed = true;
4704 close();
4705 destroy();
4706 }
4707 if (event->button() == Qt::LeftButton && highligh_num != -1) {
4708 update_units();
4709 if (highligh_num >= unit_list.count()) {
4710 return;
4711 }
4714 was_destroyed = true;
4715 close();
4716 destroy();
4717 }
4718}
4719
4720/***********************************************************************/
4725{
4726 create_pixmap();
4727 update();
4728}
4729
4730/***********************************************************************/
4734{
4736 int h, i;
4737 int *f_size;
4738 QPen pen;
4739 QString str, str2;
4740 struct unit *punit;
4741 int point_size = info_font.pointSize();
4742 int pixel_size = info_font.pixelSize();
4743
4744 if (point_size < 0) {
4745 f_size = &pixel_size;
4746 } else {
4747 f_size = &point_size;
4748 }
4749 if (highligh_num != -1 && highligh_num < unit_list.count()) {
4750 struct astring addition = ASTRING_INIT;
4751
4754
4755 // TRANS: HP - hit points
4756 str2 = QString(_("%1 HP:%2/%3")).arg(QString(astr_str(&addition)),
4757 QString::number(punit->hp),
4758 QString::number(unit_type_get(punit)->hp));
4760 }
4761 str = QString(PL_("%1 unit", "%1 units",
4763 .arg(unit_list_size(utile->units));
4764 for (i = *f_size; i > 4; i--) {
4765 if (point_size < 0) {
4766 info_font.setPixelSize(i);
4767 } else {
4768 info_font.setPointSize(i);
4769 }
4771 if (10 + qfm.horizontalAdvance(str2) < width()) {
4772 break;
4773 }
4774 }
4775 h = fm.height();
4776 if (pix != nullptr) {
4777 painter->drawPixmap(10, h + 3, *pix);
4778 pen.setColor(palette().color(QPalette::Text));
4779 painter->setPen(pen);
4780 painter->setFont(info_font);
4781 painter->drawText(10, h, str);
4782 if (highligh_num != -1 && highligh_num < unit_list.count()) {
4783 painter->drawText(10, height() - 5, str2);
4784 }
4785 // Draw scroll
4786 if (more) {
4787 int maxl = ((unit_count - 1) / 4) + 1;
4788 float page_height = 3.0f / maxl;
4789 float page_start = (static_cast<float>(show_line)) / maxl;
4790 pen.setColor(palette().color(QPalette::HighlightedText));
4791 painter->setBrush(palette().color(QPalette::HighlightedText).darker());
4792 painter->setPen(palette().color(QPalette::HighlightedText).darker());
4793 painter->drawRect(pix->width() + 10, h, 8, h + pix->height());
4794 painter->setPen(pen);
4795 painter->drawRoundedRect(pix->width() + 10,
4796 h + page_start * pix->height(),
4797 8, h + page_height * pix->height(), 2, 2);
4798 }
4799 }
4800 if (point_size < 0) {
4801 info_font.setPixelSize(*f_size);
4802 } else {
4803 info_font.setPointSize(*f_size);
4804 }
4805 cw->put_to_corner();
4806}
4807
4808/***********************************************************************/
4812{
4814
4815 painter.begin(this);
4816 paint(&painter, event);
4817 painter.end();
4818}
4819
4820/***********************************************************************/
4825{
4826 was_destroyed = true;
4827 close();
4828 destroy();
4829}
4830
4831/***********************************************************************/
4835{
4836 int i = 1;
4837 struct unit_list *punit_list;
4838
4839 unit_count = 0;
4840 if (utile == nullptr) {
4841 struct unit *punit = head_of_units_in_focus();
4842 if (punit) {
4844 }
4845 }
4846 unit_list.clear();
4847 if (utile != nullptr) {
4849 if (punit_list != nullptr) {
4851 unit_count++;
4852 if (i > show_line * 4)
4853 unit_list.push_back(punit);
4854 i++;
4856 }
4857 }
4858 if (unit_list.count() == 0) {
4859 close();
4860 }
4861}
4862
4863/***********************************************************************/
4867{
4868 gui()->mapview_wdg->setFocus();
4869 QWidget::closeEvent(event);
4870}
4871
4872/***********************************************************************/
4876{
4877 int nr;
4878
4879 if (!more && utile == nullptr) {
4880 return;
4881 }
4882 nr = qCeil(static_cast<qreal>(unit_list_size(utile->units)) / 4) - 3;
4883 if (event->angleDelta().y() < 0) {
4884 show_line++;
4886 } else {
4887 show_line--;
4888 show_line = qMax(0, show_line);
4889 }
4890 update_units();
4891 create_pixmap();
4892 update();
4893 event->accept();
4894}
4895
4896/***********************************************************************/
4900{
4901 if (event->key() == Qt::Key_Escape) {
4902 was_destroyed = true;
4903 close();
4904 destroy();
4905 }
4906 QWidget::keyPressEvent(event);
4907}
4908
4909/***********************************************************************/
4916
4917/***********************************************************************/
4924
4925/***********************************************************************/
4930{
4931 // Just tell the client common code to handle this.
4932 return false;
4933}
4934
4935/***********************************************************************/
4938bool qtg_request_transport(struct unit *pcargo, struct tile *ptile)
4939{
4940 int tcount;
4942 struct unit_list *potential_transports = unit_list_new();
4943#ifndef FREECIV_NDEBUG
4945#endif
4946
4950 }
4952
4954
4955 if (tcount == 0) {
4956 fc_assert(best_transport == nullptr);
4958
4959 return false; // Unit was not handled here.
4960 } else if (tcount == 1) {
4961 // There's exactly one potential transport - use it automatically
4964
4966
4967 return true;
4968 }
4969
4970 hul = new hud_unit_loader(pcargo, ptile);
4971 hul->show_me();
4972 return true;
4973}
4974
4975/***********************************************************************/
4979void qtg_popup_combat_info(int attacker_unit_id, int defender_unit_id,
4980 int attacker_hp, int defender_hp,
4981 bool make_att_veteran, bool make_def_veteran)
4982{
4983 if (gui()->qt_settings.show_battle_log) {
4984 hud_unit_combat *huc = new hud_unit_combat(attacker_unit_id,
4985 defender_unit_id,
4986 attacker_hp, defender_hp,
4987 make_att_veteran,
4988 make_def_veteran,
4989 gui()->battlelog_wdg->scale,
4990 gui()->battlelog_wdg);
4991
4992 gui()->battlelog_wdg->add_combat_info(huc);
4993 gui()->battlelog_wdg->show();
4994 }
4995}
4996
4997/**********************************************************************/
5001 struct act_confirmation_data *data)
5002{
5003 hud_message_box *ask = new hud_message_box(gui()->central_wdg);
5004
5005 ask->setStandardButtons(QMessageBox::Cancel | QMessageBox::Ok);
5006 ask->setDefaultButton(QMessageBox::Cancel);
5007 ask->set_text_title(body, hdr);
5008 ask->setAttribute(Qt::WA_DeleteOnClose);
5009 QObject::connect(ask, &hud_message_box::accepted, [=]() {
5011 });
5012 QObject::connect(ask, &hud_message_box::rejected, [=]() {
5014 });
5015
5016 ask->show();
5017}
5018
5019/***********************************************************************/
5023 struct act_confirmation_data *data)
5024{
5026
5027 hdr = QString(_("Are you sure you want to do %1?")).
5029
5030 if (expl != nullptr) {
5032 }
5033
5035}
5036
5037/**********************************************************************/
5040void qtg_popup_image(const char *tag)
5041{
5042 struct sprite *spr = load_popup_sprite(tag);
5043
5044 if (spr != nullptr) {
5045 QDialog *win = new QDialog(gui());
5046 QVBoxLayout *layout = new QVBoxLayout(win);
5047 QPixmap *pm = new QPixmap(*spr->pm);
5048 QLabel *lbl = new QLabel;
5049 int width, height;
5050
5052 win->setFixedSize(width, height);
5053 lbl->setPixmap(*pm);
5054 layout->addWidget(lbl);
5055 win->setLayout(layout);
5056
5057 win->show();
5058
5060 } else {
5061 log_error(_("No image for tag \"%s\", requested by the server."), tag);
5062 }
5063}
const char * action_prepare_ui_name(action_id act_id, const char *mnemonic, const struct act_prob prob, const char *custom)
Definition actions.c:1312
const char * action_id_name_translation(action_id act_id)
Definition actions.c:1250
bool action_prob_possible(const struct act_prob probability)
Definition actions.c:5091
static struct action * action_by_number(action_id act_id)
Definition actions.h:396
#define action_iterate_end
Definition actions.h:214
#define action_id_get_actor_kind(act_id)
Definition actions.h:409
#define action_iterate(_act_)
Definition actions.h:210
#define action_id_get_target_kind(act_id)
Definition actions.h:413
#define ACTION_NONE
Definition actions.h:55
void astr_free(struct astring *astr)
Definition astring.c:148
void astr_set(struct astring *astr, const char *format,...)
Definition astring.c:251
#define str
Definition astring.c:76
static const char * astr_str(const struct astring *astr) fc__attribute((nonnull(1)))
Definition astring.h:93
#define ASTRING_INIT
Definition astring.h:44
void audio_restart(const char *soundset_name, const char *musicset_name)
Definition audio.c:376
#define BV_CLR(bv, bit)
Definition bitvector.h:94
QRect zealous_crop_rect(QImage &p)
Definition canvas.cpp:419
void qtg_canvas_free(struct canvas *store)
Definition canvas.cpp:48
struct canvas * qtg_canvas_create(int width, int height)
Definition canvas.cpp:36
struct canvas int int struct sprite int int int int height
Definition canvas_g.h:44
struct canvas int int struct sprite int int int width
Definition canvas_g.h:44
void output_window_append(const struct ft_color color, const char *featured_text)
const char * city_improvement_name_translation(const struct city *pcity, const struct impr_type *pimprove)
Definition city.c:663
const char * city_name_get(const struct city *pcity)
Definition city.c:1137
#define INCITE_IMPOSSIBLE_COST
Definition city.h:93
#define city_owner(_pcity_)
Definition city.h:560
#define city_built_iterate(_pcity, _p)
Definition city.h:831
#define city_built_iterate_end
Definition city.h:837
void qtg_real_city_dialog_popup(struct city *pcity)
Definition citydlg.cpp:3824
Choice_dialog_button(const QString title, pfcn_void func_in, QVariant data1_in, QVariant data2_in)
Definition dialogs.cpp:1339
void setData2(QVariant wariat)
Definition dialogs.cpp:1387
void setData1(QVariant wariat)
Definition dialogs.cpp:1379
pfcn_void getFunc()
Definition dialogs.cpp:1353
void stack_button(Choice_dialog_button *button)
Definition dialogs.cpp:1713
void prev_unit()
Definition dialogs.cpp:1630
QVBoxLayout * layout
Definition dialogs.h:263
struct unit * targeted_unit
Definition dialogs.h:286
void unstack_all_buttons()
Definition dialogs.cpp:1730
Choice_dialog_button * get_identified_button(const int id)
Definition dialogs.cpp:1542
QPushButton * target_unit_button
Definition dialogs.h:262
void set_layout()
Definition dialogs.cpp:1448
void update_dialog(const struct act_prob *act_probs)
Definition dialogs.cpp:1659
QList< Choice_dialog_button * > last_buttons_stack
Definition dialogs.h:266
void next_unit()
Definition dialogs.cpp:1590
QVBoxLayout * get_layout()
Definition dialogs.cpp:1534
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:1395
int target_id[ATK_COUNT]
Definition dialogs.h:284
void switch_target()
Definition dialogs.cpp:1677
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:1696
void add_item(QString title, pfcn_void func, QVariant data1, QVariant data2, QString tool_tip, const int button_id)
Definition dialogs.cpp:1490
void put_to_corner()
Definition mapview.cpp:502
void disband_clicked()
Definition dialogs.cpp:4001
disband_box(struct unit_list *punits, QWidget *parent=0)
Definition dialogs.cpp:3975
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:4920
void set_diplo_dialog(choice_dialog *widget)
Definition dialogs.cpp:4912
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:474
int set_text_title(QString s1, QString s2, bool return_exec=false)
QString qheadline
Definition dialogs.h:193
void restart()
Definition dialogs.cpp:913
close_widget * cw
Definition dialogs.h:189
void mouseReleaseEvent(QMouseEvent *event)
Definition dialogs.cpp:1006
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:880
void calc_size(int &x, int &y)
Definition dialogs.cpp:941
void paintEvent(QPaintEvent *paint_event)
Definition dialogs.cpp:960
QPoint cursor
Definition dialogs.h:196
void mouseMoveEvent(QMouseEvent *event)
Definition dialogs.cpp:996
virtual void update_menu()
Definition dialogs.cpp:1014
void mousePressEvent(QMouseEvent *event)
Definition dialogs.cpp:983
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:1115
QPushButton * goto_but
Definition dialogs.h:111
void inspect_city()
Definition dialogs.cpp:1158
struct tile * gtile
Definition dialogs.h:114
QPushButton * inspect_but
Definition dialogs.h:112
void goto_tile()
Definition dialogs.cpp:1149
action_id vs_unit
Definition dialogs.h:60
static qdef_act * action()
Definition dialogs.cpp:1043
action_id vs_city_get()
Definition dialogs.cpp:1081
static qdef_act * m_instance
Definition dialogs.h:58
static void drop()
Definition dialogs.cpp:1054
action_id vs_city
Definition dialogs.h:59
void vs_city_set(int i)
Definition dialogs.cpp:1065
void vs_unit_set(int i)
Definition dialogs.cpp:1073
action_id vs_unit_get()
Definition dialogs.cpp:1089
QPoint point
Definition dialogs.h:81
void paintEvent(QPaintEvent *event)
Definition dialogs.cpp:351
QPixmap close_pix
Definition dialogs.h:83
void reactivate()
Definition dialogs.cpp:343
void mouseMoveEvent(QMouseEvent *event)
Definition dialogs.cpp:392
int titlebar_height
Definition dialogs.h:80
void mousePressEvent(QMouseEvent *event)
Definition dialogs.cpp:402
void mouseReleaseEvent(QMouseEvent *event)
Definition dialogs.cpp:422
qfc_dialog(QWidget *parent)
Definition dialogs.cpp:331
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:1105
void style_selected(const QItemSelection &sl, const QItemSelection &ds)
Definition dialogs.cpp:808
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:614
void nation_selected(const QItemSelection &sl, const QItemSelection &ds)
Definition dialogs.cpp:757
void nationset_changed(int index)
Definition dialogs.cpp:1170
int selected_nation
Definition dialogs.h:163
void ok_pressed()
Definition dialogs.cpp:842
void leader_selected(int index)
Definition dialogs.cpp:827
QPushButton * ok_button
Definition dialogs.h:142
QTextEdit * description
Definition dialogs.h:141
void group_selected(const QItemSelection &sl, const QItemSelection &ds)
Definition dialogs.cpp:680
void set_index(int index)
Definition dialogs.cpp:697
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:664
QTableWidget * styles
Definition dialogs.h:140
struct player * tplayer
Definition dialogs.h:165
races_dialog(struct player *pplayer, QWidget *parent=0)
Definition dialogs.cpp:431
QRadioButton * is_female
Definition dialogs.h:139
QTableWidget * nation_tabs
Definition dialogs.h:132
QGridLayout * main_layout
Definition dialogs.h:131
void cancel_pressed()
Definition dialogs.cpp:1097
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:4866
void update_img()
Definition dialogs.cpp:4724
int show_line
Definition dialogs.h:233
void mouseMoveEvent(QMouseEvent *event)
Definition dialogs.cpp:4668
int highligh_num
Definition dialogs.h:234
void paint(QPainter *painter, QPaintEvent *event)
Definition dialogs.cpp:4733
void update_menu()
Definition dialogs.cpp:4824
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:4488
void update_units()
Definition dialogs.cpp:4834
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:4811
void create_pixmap()
Definition dialogs.cpp:4533
void wheelEvent(QWheelEvent *event)
Definition dialogs.cpp:4875
void keyPressEvent(QKeyEvent *event)
Definition dialogs.cpp:4899
void mousePressEvent(QMouseEvent *event)
Definition dialogs.cpp:4699
close_widget * cw
Definition dialogs.h:213
char music_set_name[512]
bool client_is_global_observer(void)
struct civclient client
enum client_states client_state(void)
char sound_set_name[512]
#define client_player()
@ C_S_RUNNING
Definition client_main.h:47
void client_unit_init_act_prob_cache(struct unit *punit)
Definition climisc.c:1259
char * incite_cost
Definition comments.c:76
void action_selection_no_longer_in_progress(const int old_actor_id)
Definition control.c:1051
void request_unit_load(struct unit *pcargo, struct unit *ptrans, struct tile *ptile)
Definition control.c:2156
void unit_focus_set(struct unit *punit)
Definition control.c:506
void request_do_action(action_id action, int actor_id, int target_id, int sub_tgt, const char *name)
Definition control.c:1730
void request_unit_disband(struct unit *punit)
Definition control.c:2075
void request_action_details(action_id action, int actor_id, int target_id)
Definition control.c:1798
void request_new_unit_activity_targeted(struct unit *punit, enum unit_activity act, struct extra_type *tgt)
Definition control.c:1938
void action_confirmation(struct act_confirmation_data *data, bool confirm)
Definition control.c:1766
void action_decision_clear_want(const int old_actor_id)
Definition control.c:1080
void key_unit_wait(void)
Definition control.c:3542
struct unit * head_of_units_in_focus(void)
Definition control.c:410
void request_unit_upgrade(struct unit *punit)
Definition control.c:2106
void action_selection_next_in_focus(const int old_actor_id)
Definition control.c:1092
bool qtg_handmade_scenario_warning()
Definition dialogs.cpp:4929
static void attack(QVariant data1, QVariant data2)
Definition dialogs.cpp:3034
static void wipe_units(QVariant data1, QVariant data2)
Definition dialogs.cpp:2755
char forced_tileset_name[512]
int action_selection_target_extra(void)
Definition dialogs.cpp:4227
static void destroy_city(QVariant data1, QVariant data2)
Definition dialogs.cpp:3411
static void spy_sabotage_unit(QVariant data1, QVariant data2)
Definition dialogs.cpp:2475
static void pillage(QVariant data1, QVariant data2)
Definition dialogs.cpp:2895
static void caravan_marketplace(QVariant data1, QVariant data2)
Definition dialogs.cpp:1744
static void clean(QVariant data1, QVariant data2)
Definition dialogs.cpp:2915
static void spy_steal_shared(QVariant data1, QVariant data2, action_id act_id)
Definition dialogs.cpp:3169
static void spy_sabotage(QVariant data1, QVariant data2)
Definition dialogs.cpp:3850
int action_selection_target_tile(void)
Definition dialogs.cpp:4210
static void spy_investigate(QVariant data1, QVariant data2)
Definition dialogs.cpp:3531
static void act_sel_wait(QVariant data1, QVariant data2)
Definition dialogs.cpp:1913
static void nuke_units(QVariant data1, QVariant data2)
Definition dialogs.cpp:2743
int action_selection_actor_unit(void)
Definition dialogs.cpp:4176
static void capture_units(QVariant data1, QVariant data2)
Definition dialogs.cpp:2767
static void road(QVariant data1, QVariant data2)
Definition dialogs.cpp:2935
static bool is_race_dialog_open
Definition dialogs.cpp:190
static void transport_embark4(QVariant data1, QVariant data2)
Definition dialogs.cpp:2587
bool try_default_unit_action(QVariant q1, QVariant q2)
Definition dialogs.cpp:1555
static void fortify(QVariant data1, QVariant data2)
Definition dialogs.cpp:2400
static void transport_board(QVariant data1, QVariant data2)
Definition dialogs.cpp:2521
static void diplomat_bribe_unit(QVariant data1, QVariant data2)
Definition dialogs.cpp:2440
static void spy_sabotage_unit_esc(QVariant data1, QVariant data2)
Definition dialogs.cpp:2487
static void disband_unit(QVariant data1, QVariant data2)
Definition dialogs.cpp:2388
static void spy_steal_gold(QVariant data1, QVariant data2)
Definition dialogs.cpp:3426
void popdown_players_report()
Definition plrdlg.cpp:1197
static void conquer_city_shrink2(QVariant data1, QVariant data2)
Definition dialogs.cpp:1870
static void spy_escape(QVariant data1, QVariant data2)
Definition dialogs.cpp:3486
static void mine(QVariant data1, QVariant data2)
Definition dialogs.cpp:2977
void popup_musicset_suggestion_dialog(void)
Definition dialogs.cpp:4087
static void spy_steal_gold_esc(QVariant data1, QVariant data2)
Definition dialogs.cpp:3441
static void diplomat_embassy(QVariant data1, QVariant data2)
Definition dialogs.cpp:3516
void unit_select_dialog_popup(struct tile *ptile)
Definition dialogs.cpp:1255
void popup_upgrade_dialog(struct unit_list *punits)
Definition dialogs.cpp:4443
void update_nationset_combo()
Definition dialogs.cpp:1275
void action_selection_close(void)
Definition dialogs.cpp:4381
static void cultivate(QVariant data1, QVariant data2)
Definition dialogs.cpp:2865
static void paradrop_enter(QVariant data1, QVariant data2)
Definition dialogs.cpp:3124
void races_update_pickable(bool nationset_change)
Definition dialogs.cpp:1285
int action_selection_target_city(void)
Definition dialogs.cpp:4193
static void spy_steal_something(QVariant data1, QVariant data2)
Definition dialogs.cpp:3259
#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:1193
static void spy_poison(QVariant data1, QVariant data2)
Definition dialogs.cpp:3336
static void transport_board2(QVariant data1, QVariant data2)
Definition dialogs.cpp:2532
void show_tech_gained_dialog(Tech_type_id tech)
Definition dialogs.cpp:4395
static void base(QVariant data1, QVariant data2)
Definition dialogs.cpp:2956
static void spy_nuke_city_esc(QVariant data1, QVariant data2)
Definition dialogs.cpp:3381
void popup_soundset_suggestion_dialog(void)
Definition dialogs.cpp:4062
static void enter_hut2(QVariant data1, QVariant data2)
Definition dialogs.cpp:2698
void popup_races_dialog(struct player *pplayer)
Definition dialogs.cpp:1230
static void expel_unit(QVariant data1, QVariant data2)
Definition dialogs.cpp:2779
static void paradrop_frighten(QVariant data1, QVariant data2)
Definition dialogs.cpp:3094
static void diplomat_sabotage(QVariant data1, QVariant data2)
Definition dialogs.cpp:3561
void popup_disband_dialog(struct unit_list *punits)
Definition dialogs.cpp:4021
static action_id get_non_targeted_action_id(action_id tgt_action_id)
Definition dialogs.cpp:2283
static void homeless(QVariant data1, QVariant data2)
Definition dialogs.cpp:2426
static void caravan_help_build(QVariant data1, QVariant data2)
Definition dialogs.cpp:1774
void qtg_popup_image(const char *tag)
Definition dialogs.cpp:5040
static void bombard(QVariant data1, QVariant data2)
Definition dialogs.cpp:2791
void popup_bribe_stack_dialog(struct unit *actor, struct tile *ttile, int cost, const struct action *paction)
Definition dialogs.cpp:3783
void popdown_races_dialog(void)
Definition dialogs.cpp:1244
void popup_tileset_suggestion_dialog(void)
Definition dialogs.cpp:4031
void revolution_response(struct government *gov)
Definition dialogs.cpp:1928
void popdown_economy_report()
static void join_city(QVariant data1, QVariant data2)
Definition dialogs.cpp:3154
static void spy_request_sabotage_list(QVariant data1, QVariant data2)
Definition dialogs.cpp:3299
static void popup_act_confirmation_dialog(QString hdr, QString body, struct act_confirmation_data *data)
Definition dialogs.cpp:5000
static void unit_disband_recover(QVariant data1, QVariant data2)
Definition dialogs.cpp:1789
static void spy_steal(QVariant data1, QVariant data2)
Definition dialogs.cpp:3243
static void airlift(QVariant data1, QVariant data2)
Definition dialogs.cpp:1840
void popup_pillage_dialog(struct unit *punit, bv_extras extras)
Definition dialogs.cpp:3942
static void transport_load3(QVariant data1, QVariant data2)
Definition dialogs.cpp:2631
static void bombard_lethal(QVariant data1, QVariant data2)
Definition dialogs.cpp:2827
static void plant(QVariant data1, QVariant data2)
Definition dialogs.cpp:2880
static void diplomat_bribe_stack(QVariant data1, QVariant data2)
Definition dialogs.cpp:2458
static void nuke(QVariant data1, QVariant data2)
Definition dialogs.cpp:3019
static void disembark2(QVariant data1, QVariant data2)
Definition dialogs.cpp:2668
static void transport_unload(QVariant data1, QVariant data2)
Definition dialogs.cpp:2598
void qtg_request_action_confirmation(const char *expl, struct act_confirmation_data *data)
Definition dialogs.cpp:5022
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:4258
void popdown_science_report()
static void transport_load2(QVariant data1, QVariant data2)
Definition dialogs.cpp:2620
static void diplomat_steal(QVariant data1, QVariant data2)
Definition dialogs.cpp:3591
static void unit_upgrade(QVariant data1, QVariant data2)
Definition dialogs.cpp:1819
bool popup_theme_suggestion_dialog(const char *theme_name)
Definition dialogs.cpp:4112
static void enter_hut(QVariant data1, QVariant data2)
Definition dialogs.cpp:2683
static void spy_request_strike_bld_list(QVariant data1, QVariant data2)
Definition dialogs.cpp:3282
static void diplomat_incite_escape(QVariant data1, QVariant data2)
Definition dialogs.cpp:3639
static void found_city(QVariant data1, QVariant data2)
Definition dialogs.cpp:2839
static void diplomat_investigate(QVariant data1, QVariant data2)
Definition dialogs.cpp:3546
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:4979
static void bombard3(QVariant data1, QVariant data2)
Definition dialogs.cpp:2815
static void transport_deboard(QVariant data1, QVariant data2)
Definition dialogs.cpp:2642
static void diplomat_incite(QVariant data1, QVariant data2)
Definition dialogs.cpp:3621
static void paradrop_conquer(QVariant data1, QVariant data2)
Definition dialogs.cpp:3079
void popdown_endgame_report()
static void diplomat_steal_esc(QVariant data1, QVariant data2)
Definition dialogs.cpp:3606
static bool is_more_user_input_needed
Definition dialogs.cpp:195
static void bombard2(QVariant data1, QVariant data2)
Definition dialogs.cpp:2803
void popup_incite_dialog(struct unit *actor, struct city *tcity, int cost, const struct action *paction)
Definition dialogs.cpp:3673
static const QHash< action_id, pfcn_void > af_map_init(void)
Definition dialogs.cpp:208
void popdown_all_spaceships_dialogs()
static void nuke_city(QVariant data1, QVariant data2)
Definition dialogs.cpp:3396
void popup_connect_msg(const char *headline, const char *message)
Definition dialogs.cpp:1205
static void conquer_city_shrink(QVariant data1, QVariant data2)
Definition dialogs.cpp:1855
static void diplomat_sabotage_esc(QVariant data1, QVariant data2)
Definition dialogs.cpp:3576
void popdown_units_report()
static void transport_embark2(QVariant data1, QVariant data2)
Definition dialogs.cpp:2565
static void spy_nuke_city(QVariant data1, QVariant data2)
Definition dialogs.cpp:3366
void unit_select_dialog_update_real(void *unused)
Definition dialogs.cpp:1267
static void spy_steal_esc(QVariant data1, QVariant data2)
Definition dialogs.cpp:3251
static void paradrop(QVariant data1, QVariant data2)
Definition dialogs.cpp:3064
static void suicide_attack(QVariant data1, QVariant data2)
Definition dialogs.cpp:3049
void races_toggles_set_sensitive(void)
Definition dialogs.cpp:1296
static void transport_load(QVariant data1, QVariant data2)
Definition dialogs.cpp:2609
static action_id get_production_targeted_action_id(action_id tgt_action_id)
Definition dialogs.cpp:2306
static void paradrop_frighten_conquer(QVariant data1, QVariant data2)
Definition dialogs.cpp:3109
static void convert_unit(QVariant data1, QVariant data2)
Definition dialogs.cpp:2414
static bool did_not_decide
Definition dialogs.cpp:199
static void spy_poison_esc(QVariant data1, QVariant data2)
Definition dialogs.cpp:3351
static void pillage_something(QVariant data1, QVariant data2)
Definition dialogs.cpp:3830
static void spy_request_sabotage_esc_list(QVariant data1, QVariant data2)
Definition dialogs.cpp:3317
void show_tileset_error(bool fatal, const char *tset_name, const char *msg)
Definition dialogs.cpp:4402
static void transform_terrain(QVariant data1, QVariant data2)
Definition dialogs.cpp:2850
#define BUTTON_CANCEL
Definition dialogs.cpp:72
static void conquer_extras(QVariant data1, QVariant data2)
Definition dialogs.cpp:1885
static void regular_move(QVariant data1, QVariant data2)
Definition dialogs.cpp:3657
static void heal_unit2(QVariant data1, QVariant data2)
Definition dialogs.cpp:2510
static void transport_board3(QVariant data1, QVariant data2)
Definition dialogs.cpp:2543
static void spy_embassy(QVariant data1, QVariant data2)
Definition dialogs.cpp:3501
static races_dialog * race_dialog
Definition dialogs.cpp:189
static void frighten_hut2(QVariant data1, QVariant data2)
Definition dialogs.cpp:2728
static void conquer_extras2(QVariant data1, QVariant data2)
Definition dialogs.cpp:1899
static void frighten_hut(QVariant data1, QVariant data2)
Definition dialogs.cpp:2713
bool qtg_request_transport(struct unit *pcargo, struct tile *ptile)
Definition dialogs.cpp:4938
int action_selection_target_unit(void)
Definition dialogs.cpp:4244
static void irrigate(QVariant data1, QVariant data2)
Definition dialogs.cpp:2998
static void transport_embark3(QVariant data1, QVariant data2)
Definition dialogs.cpp:2576
static void heal_unit(QVariant data1, QVariant data2)
Definition dialogs.cpp:2499
void popdown_city_report()
Definition cityrep.cpp:1338
static void paradrop_enter_conquer(QVariant data1, QVariant data2)
Definition dialogs.cpp:3139
static void unit_home_city(QVariant data1, QVariant data2)
Definition dialogs.cpp:1804
static void transport_embark(QVariant data1, QVariant data2)
Definition dialogs.cpp:2554
bool try_default_city_action(QVariant q1, QVariant q2)
Definition dialogs.cpp:1573
static void keep_moving(QVariant data1, QVariant data2)
Definition dialogs.cpp:1921
static void spy_steal_maps_esc(QVariant data1, QVariant data2)
Definition dialogs.cpp:3471
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:2359
static void disembark1(QVariant data1, QVariant data2)
Definition dialogs.cpp:2653
void restart_notify_dialogs()
Definition dialogs.cpp:4121
static bool is_showing_pillage_dialog
Definition dialogs.cpp:188
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:2326
static const QHash< action_id, pfcn_void > af_map
Definition dialogs.cpp:326
static void caravan_establish_trade(QVariant data1, QVariant data2)
Definition dialogs.cpp:1759
void popdown_all_game_dialogs(void)
Definition dialogs.cpp:4137
static void spy_steal_maps(QVariant data1, QVariant data2)
Definition dialogs.cpp:3456
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id popup_bribe_unit_dialog
Definition dialogs_g.h:73
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit int const struct action *paction struct unit struct city const struct action *paction const char * expl
Definition dialogs_g.h:94
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit int const struct action *paction popup_sabotage_dialog
Definition dialogs_g.h:77
struct unit struct city struct unit * target_unit
Definition dialogs_g.h:56
popup_action_selection
Definition dialogs_g.h:55
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit * actor
Definition dialogs_g.h:73
struct unit * actor_unit
Definition dialogs_g.h:55
const char * caption
Definition dialogs_g.h:37
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs action_selection_no_longer_in_progress_gui_specific
Definition dialogs_g.h:69
const char const char * headline
Definition dialogs_g.h:38
popup_notify_dialog
Definition dialogs_g.h:37
struct unit struct city struct unit struct tile * target_tile
Definition dialogs_g.h:57
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit * punit
Definition dialogs_g.h:74
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit int const struct action *paction struct unit struct city * pcity
Definition dialogs_g.h:78
struct unit struct city * target_city
Definition dialogs_g.h:56
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit int cost
Definition dialogs_g.h:74
struct unit struct city struct unit struct tile struct extra_type * target_extra
Definition dialogs_g.h:57
int int id
Definition editgui_g.h:28
enum event_type event
Definition events.c:81
int extra_number(const struct extra_type *pextra)
Definition extras.c:161
struct extra_type * extra_by_number(int id)
Definition extras.c:183
static struct extra_type extras[MAX_EXTRA_TYPES]
Definition extras.c:31
const char * extra_name_translation(const struct extra_type *pextra)
Definition extras.c:194
#define extra_index(_e_)
Definition extras.h:183
#define EXTRA_NONE
Definition extras.h:85
int Tech_type_id
Definition fc_types.h:236
int action_id
Definition fc_types.h:248
int Government_type_id
Definition fc_types.h:240
#define IDENTITY_NUMBER_ZERO
Definition fc_types.h:92
#define PL_(String1, String2, n)
Definition fcintl.h:71
#define _(String)
Definition fcintl.h:67
const struct ft_color ftc_client
struct civ_game game
Definition game.c:61
struct world wld
Definition game.c:62
struct unit * game_unit_by_number(int id)
Definition game.c:115
struct city * game_city_by_number(int id)
Definition game.c:106
struct government * government_by_number(const Government_type_id gov)
Definition government.c:103
Government_type_id government_number(const struct government *pgovern)
Definition government.c:91
#define G_LAST
Definition government.h:48
int action_selection_target_extra(void)
static int actor_unit_id
static void diplomat_queue_handle_primary(void)
static void diplomat_queue_handle_secondary(void)
#define BUTTON_COUNT
void action_selection_refresh(struct unit *actor_unit, struct city *target_city, struct unit *target_unit, struct tile *target_tile, struct extra_type *target_extra, const struct act_prob *act_probs)
static PangoLayout * layout
Definition canvas.c:325
static struct tile * pos
Definition finddlg.c:53
void popdown_help_dialog(void)
Definition helpdlg.c:186
const char * title
Definition repodlgs.c:1314
void(* pfcn_void)(QVariant, QVariant)
Definition dialogs.h:46
#define mevent_gpos(__ev__)
Definition gui_main.h:23
#define CAPTURE_DEFAULT_THIS
Definition gui_main.h:31
void nationset_changed(void)
Definition dialogs.c:3565
#define show(id)
Definition widget.h:235
void popup_revolution_dialog(void)
Definition dialogs.c:112
void helptext_nation(char *buf, size_t bufsz, struct nation_type *pnation, const char *user_text)
Definition helpdata.c:5034
Impr_type_id improvement_number(const struct impr_type *pimprove)
#define B_LAST
Definition improvement.h:42
get_token_fn_t func
Definition inputfile.c:128
#define fc_assert_msg(condition, message,...)
Definition log.h:182
#define fc_assert(condition)
Definition log.h:177
#define fc_assert_action(condition, action)
Definition log.h:188
@ LOG_ERROR
Definition log.h:31
#define log_error(message,...)
Definition log.h:104
struct tile * index_to_tile(const struct civ_map *imap, int mindex)
Definition map.c:471
void put_unit(const struct unit *punit, struct canvas *pcanvas, float zoom, int canvas_x, int canvas_y)
void center_tile_mapcanvas(const struct tile *ptile)
static const void * body(MD5_CTX *ctx, const void *data, unsigned long size)
Definition md5.c:121
#define FC_FREE(ptr)
Definition mem.h:41
const char * move_points_text(int mp, bool reduce)
Definition movement.c:1016
static mpgui * gui
Definition mpgui_qt.cpp:52
const char *const notify_label
Definition fonts.h:28
Nation_type_id nation_number(const struct nation_type *pnation)
Definition nation.c:486
bool nation_leader_is_male(const struct nation_leader *pleader)
Definition nation.c:290
const char * nation_adjective_for_player(const struct player *pplayer)
Definition nation.c:169
const char * nation_adjective_translation(const struct nation_type *pnation)
Definition nation.c:149
struct nation_type * nation_by_number(const Nation_type_id nation)
Definition nation.c:475
int nation_set_index(const struct nation_set *pset)
Definition nation.c:699
bool is_nation_pickable(const struct nation_type *nation)
Definition nation.c:188
const struct nation_leader_list * nation_leaders(const struct nation_type *pnation)
Definition nation.c:230
const char * nation_set_name_translation(const struct nation_set *pset)
Definition nation.c:818
bool is_nation_playable(const struct nation_type *nation)
Definition nation.c:200
bool nation_is_in_group(const struct nation_type *pnation, const struct nation_group *pgroup)
Definition nation.c:1099
const char * nation_set_description(const struct nation_set *pset)
Definition nation.c:828
const char * nation_group_name_translation(const struct nation_group *pgroup)
Definition nation.c:1090
int nation_set_count(void)
Definition nation.c:691
struct nation_group * nation_group_by_number(int id)
Definition nation.c:1004
struct nation_set * nation_set_by_rule_name(const char *name)
Definition nation.c:779
bool is_nation_group_hidden(struct nation_group *pgroup)
Definition nation.c:1057
struct nation_set * nation_set_by_setting_value(const char *setting)
Definition nation.c:859
const char * nation_leader_name(const struct nation_leader *pleader)
Definition nation.c:281
int nation_group_count(void)
Definition nation.c:935
const char * nation_set_rule_name(const struct nation_set *pset)
Definition nation.c:807
struct nation_style * style_of_nation(const struct nation_type *pnation)
Definition nation.c:672
#define nation_leader_list_iterate(leaderlist, pleader)
Definition nation.h:57
#define nation_sets_iterate_end
Definition nation.h:305
#define nation_sets_iterate(NAME_pset)
Definition nation.h:301
#define nations_iterate_end
Definition nation.h:336
#define nations_iterate(NAME_pnation)
Definition nation.h:333
#define nation_leader_list_iterate_end
Definition nation.h:59
const struct option_set * server_optset
Definition options.c:4278
bool option_str_set(struct option *poption, const char *str)
Definition options.c:962
const char * option_str_get(const struct option *poption)
Definition options.c:929
struct option * optset_option_by_name(const struct option_set *poptset, const char *name)
Definition options.c:467
#define REQEST_PLAYER_INITIATED
Definition packets.h:63
int dsend_packet_unit_get_actions(struct connection *pc, int actor_unit_id, int target_unit_id, int target_tile_id, int target_extra_id, int request_kind)
int dsend_packet_nation_select_req(struct connection *pc, int player_no, Nation_type_id nation_no, bool is_male, const char *name, int style)
int dsend_packet_city_name_suggestion_req(struct connection *pc, int unit_id)
void start_revolution(void)
Definition packhand.c:2398
void set_government_choice(struct government *government)
Definition packhand.c:2385
char * lines
Definition packhand.c:131
int player_number(const struct player *pplayer)
Definition player.c:837
const char * research_advance_name_translation(const struct research *presearch, Tech_type_id tech)
Definition research.c:273
struct research * research_get(const struct player *pplayer)
Definition research.c:128
enum tech_state research_invention_state(const struct research *presearch, Tech_type_id tech)
Definition research.c:619
bool research_invention_gettable(const struct research *presearch, const Tech_type_id tech, bool allow_holes)
Definition research.c:693
const char * sex_name_translation(sex_t kind)
Definition sex.c:60
@ SEX_FEMALE
Definition sex.h:22
@ SEX_MALE
Definition sex.h:23
#define ARRAY_SIZE(x)
Definition shared.h:85
size_t size
Definition specvec.h:72
struct sprite int int y
Definition sprite_g.h:31
struct sprite int x
Definition sprite_g.h:31
struct sprite int int int int struct sprite int int float bool smooth get_sprite_dimensions
Definition sprite_g.h:36
QPixmap map_pixmap
Definition canvas.h:25
Definition city.h:317
struct packet_ruleset_control control
Definition game.h:83
struct packet_game_info info
Definition game.h:89
struct connection conn
Definition client_main.h:96
Definition colors.h:21
struct player * playing
Definition connection.h:151
Definition mapimg.c:367
Definition climisc.h:82
struct universal item
Definition climisc.h:83
struct player * player
Definition nation.h:118
bool tech_steal_allow_holes
char preferred_soundset[MAX_LEN_NAME]
char preferred_tileset[MAX_LEN_NAME]
char preferred_musicset[MAX_LEN_NAME]
int revolution_finishes
Definition player.h:273
char name[MAX_LEN_NAME]
Definition player.h:251
Definition menu.h:160
QPixmap * pm
Definition sprite.h:25
Definition tile.h:50
int index
Definition tile.h:51
struct unit_list * units
Definition tile.h:58
int move_rate
Definition unittype.h: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:244
#define A_FIRST
Definition tech.h:44
#define A_UNSET
Definition tech.h:48
#define advance_index_iterate(_start, _index)
Definition tech.h:240
struct extra_type * get_preferred_pillage(bv_extras extras)
Definition terrain.c:550
bool get_units_upgrade_info(char *buf, size_t bufsz, struct unit_list *punits)
Definition text.c:1304
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:1757
const char * act_sel_action_tool_tip(const struct action *paction, const struct act_prob prob)
Definition text.c:1836
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:7807
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:7075
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:7815
struct sprite * get_nation_flag_sprite(const struct tileset *t, const struct nation_type *pnation)
Definition tilespec.c:6980
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:1959
bool could_unit_load(const struct unit *pcargo, const struct unit *ptrans)
Definition unit.c:724
bool unit_can_do_action(const struct unit *punit, const action_id act_id)
Definition unit.c:383
void unit_activity_astr(const struct unit *punit, struct astring *astr)
Definition unit.c:1184
#define unit_tile(_pu)
Definition unit.h:404
#define unit_owner(_pu)
Definition unit.h:403
#define unit_list_iterate(unitlist, punit)
Definition unitlist.h:31
#define unit_list_iterate_end
Definition unitlist.h:33
const struct unit_type * unit_type_get(const struct unit *punit)
Definition unittype.c:123
const char * unit_name_translation(const struct unit *punit)
Definition unittype.c:1575
#define utype_fuel(ptype)
Definition unittype.h:846