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_spread_plague(QVariant data1, QVariant data2);
97static void spy_steal_gold(QVariant data1, QVariant data2);
98static void spy_steal_gold_esc(QVariant data1, QVariant data2);
99static void spy_steal_maps(QVariant data1, QVariant data2);
100static void spy_steal_maps_esc(QVariant data1, QVariant data2);
101static void spy_escape(QVariant data1, QVariant data2);
102static void spy_nuke_city(QVariant data1, QVariant data2);
103static void spy_nuke_city_esc(QVariant data1, QVariant data2);
104static void nuke_city(QVariant data1, QVariant data2);
105static void destroy_city(QVariant data1, QVariant data2);
106static void diplomat_embassy(QVariant data1, QVariant data2);
107static void spy_embassy(QVariant data1, QVariant data2);
108static void spy_sabotage_unit(QVariant data1, QVariant data2);
109static void spy_sabotage_unit_esc(QVariant data1, QVariant data2);
110static void spy_investigate(QVariant data1, QVariant data2);
111static void diplomat_investigate(QVariant data1, QVariant data2);
112static void diplomat_sabotage(QVariant data1, QVariant data2);
113static void diplomat_sabotage_esc(QVariant data1, QVariant data2);
114static void diplomat_bribe_unit(QVariant data1, QVariant data2);
115static void diplomat_bribe_stack(QVariant data1, QVariant data2);
116static void spy_attack(QVariant data1, QVariant data2);
117static void caravan_marketplace(QVariant data1, QVariant data2);
118static void caravan_establish_trade(QVariant data1, QVariant data2);
119static void caravan_help_build(QVariant data1, QVariant data2);
120static void unit_disband_recover(QVariant data1, QVariant data2);
121static void capture_units(QVariant data1, QVariant data2);
122static void nuke_units(QVariant data1, QVariant data2);
123static void collect_ransom(QVariant data1, QVariant data2);
124static void wipe_units(QVariant data1, QVariant data2);
125static void expel_unit(QVariant data1, QVariant data2);
126static void bombard(QVariant data1, QVariant data2);
127static void bombard2(QVariant data1, QVariant data2);
128static void bombard3(QVariant data1, QVariant data2);
129static void bombard4(QVariant data1, QVariant data2);
130static void bombard_lethal(QVariant data1, QVariant data2);
131static void bombard_lethal2(QVariant data1, QVariant data2);
132static void found_city(QVariant data1, QVariant data2);
133static void transform_terrain(QVariant data1, QVariant data2);
134static void cultivate(QVariant data1, QVariant data2);
135static void plant(QVariant data1, QVariant data2);
136static void pillage(QVariant data1, QVariant data2);
137static void clean(QVariant data1, QVariant data2);
138static void road(QVariant data1, QVariant data2);
139static void base(QVariant data1, QVariant data2);
140static void mine(QVariant data1, QVariant data2);
141static void irrigate(QVariant data1, QVariant data2);
142static void nuke(QVariant data1, QVariant data2);
143static void attack(QVariant data1, QVariant data2);
144static void attack2(QVariant data1, QVariant data2);
145static void suicide_attack(QVariant data1, QVariant data2);
146static void suicide_attack2(QVariant data1, QVariant data2);
147static void paradrop(QVariant data1, QVariant data2);
148static void paradrop_conquer(QVariant data1, QVariant data2);
149static void paradrop_frighten(QVariant data1, QVariant data2);
150static void paradrop_frighten_conquer(QVariant data1, QVariant data2);
151static void paradrop_enter(QVariant data1, QVariant data2);
152static void paradrop_enter_conquer(QVariant data1, QVariant data2);
153static void teleport(QVariant data1, QVariant data2);
154static void teleport_conquer(QVariant data1, QVariant data2);
155static void teleport_frighten(QVariant data1, QVariant data2);
156static void teleport_frighten_conquer(QVariant data1, QVariant data2);
157static void teleport_enter(QVariant data1, QVariant data2);
158static void teleport_enter_conquer(QVariant data1, QVariant data2);
159static void disembark1(QVariant data1, QVariant data2);
160static void disembark2(QVariant data1, QVariant data2);
161static void disembark3(QVariant data1, QVariant data2);
162static void disembark4(QVariant data1, QVariant data2);
163static void enter_hut(QVariant data1, QVariant data2);
164static void enter_hut2(QVariant data1, QVariant data2);
165static void enter_hut3(QVariant data1, QVariant data2);
166static void enter_hut4(QVariant data1, QVariant data2);
167static void frighten_hut(QVariant data1, QVariant data2);
168static void frighten_hut2(QVariant data1, QVariant data2);
169static void frighten_hut3(QVariant data1, QVariant data2);
170static void frighten_hut4(QVariant data1, QVariant data2);
171static void regular_move(QVariant data1, QVariant data2);
172static void regular_move2(QVariant data1, QVariant data2);
173static void regular_move3(QVariant data1, QVariant data2);
174static void convert_unit(QVariant data1, QVariant data2);
175static void fortify(QVariant data1, QVariant data2);
176static void disband_unit(QVariant data1, QVariant data2);
177static void homeless(QVariant data1, QVariant data2);
178static void join_city(QVariant data1, QVariant data2);
179static void unit_home_city(QVariant data1, QVariant data2);
180static void unit_upgrade(QVariant data1, QVariant data2);
181static void airlift(QVariant data1, QVariant data2);
182static void conquer_city_shrink(QVariant data1, QVariant data2);
183static void conquer_city_shrink2(QVariant data1, QVariant data2);
184static void conquer_city_shrink3(QVariant data1, QVariant data2);
185static void conquer_city_shrink4(QVariant data1, QVariant data2);
186static void conquer_extras(QVariant data1, QVariant data2);
187static void conquer_extras2(QVariant data1, QVariant data2);
188static void conquer_extras3(QVariant data1, QVariant data2);
189static void conquer_extras4(QVariant data1, QVariant data2);
190static void heal_unit(QVariant data1, QVariant data2);
191static void heal_unit2(QVariant data1, QVariant data2);
192static void transport_board(QVariant data1, QVariant data2);
193static void transport_board2(QVariant data1, QVariant data2);
194static void transport_board3(QVariant data1, QVariant data2);
195static void transport_embark(QVariant data1, QVariant data2);
196static void transport_embark2(QVariant data1, QVariant data2);
197static void transport_embark3(QVariant data1, QVariant data2);
198static void transport_embark4(QVariant data1, QVariant data2);
199static void transport_deboard(QVariant data1, QVariant data2);
200static void transport_unload(QVariant data1, QVariant data2);
201static void transport_load(QVariant data1, QVariant data2);
202static void transport_load2(QVariant data1, QVariant data2);
203static void transport_load3(QVariant data1, QVariant data2);
204static void keep_moving(QVariant data1, QVariant data2);
205static void pillage_something(QVariant data1, QVariant data2);
206static void action_entry(choice_dialog *cd,
207 action_id act,
208 const struct act_prob *act_probs,
209 const char *custom,
210 QVariant data1, QVariant data2);
211
212
213static bool is_showing_pillage_dialog = false;
215static bool is_race_dialog_open = false;
216
217/* Information used in action selection follow up questions. Can't be
218 * stored in the action selection dialog since it is closed before the
219 * follow up question is asked. */
221
222/* Don't remove a unit's action decision want or move on to the next actor
223 unit that wants a decision in the current unit selection. */
224static bool did_not_decide = false;
225
226extern char forced_tileset_name[512];
228
229/***********************************************************************/
234{
236
237 // Unit acting against a city target.
279
280 // Unit acting against a unit target.
299
300 // Unit acting against all units at a tile.
312
313 // Unit acting against a tile.
359
360 // Unit acting against all tile extras.
365
366 // Unit acting with no target except itself.
371
372 return action_function;
373}
374
375/* Mapping from an action to the function to call when its button is
376 * pushed. */
378
379/***********************************************************************/
384{
385 titlebar_height = 0;
386 moving_now = false;
387 setSizeGripEnabled(true);
389}
390
391/***********************************************************************/
395{
396 raise();
397}
398
399/***********************************************************************/
403{
405
406 QPainter p(this);
409 QStyle *style = this->style();
410 QRect active_area = this->rect();
413
414 qpal.setColor(QPalette::Active, QPalette::ToolTipText, Qt::white);
415 tbar_opt.initFrom(this);
416 titlebar_height = style->pixelMetric(QStyle::PM_TitleBarHeight,
417 &tbar_opt, this) + 2;
418 close_pix = close_pix.scaledToHeight(titlebar_height);
419 tbar_opt.rect = QRect(0, 0, this->width(), titlebar_height);
420 text_rect = QRect(0, 0, this->width() - close_pix.width() , titlebar_height);
421 close_rect = QRect(this->width() - close_pix.width(), 0, this->width(),
423 tbar_opt.titleBarState = this->windowState();
424 tbar_opt.text = tbar_opt.fontMetrics.elidedText(this->windowTitle(),
425 Qt::ElideRight,
426 text_rect.width());
427 style->drawComplexControl(QStyle::CC_TitleBar, &tbar_opt, &p, this);
428 style->drawItemText(&p, text_rect, Qt::AlignCenter, qpal,
429 true, tbar_opt.text, QPalette::ToolTipText);
430 style->drawItemPixmap(&p, close_rect, Qt::AlignLeft,
431 close_pix.scaledToHeight(titlebar_height));
432
433 active_area.setTopLeft(QPoint(0, titlebar_height));
434 this->setContentsMargins(0, titlebar_height, 0, 0);
435 win_opt.initFrom(this);
436 win_opt.rect = active_area;
437 style->drawPrimitive(QStyle::PE_Widget, &win_opt, &p, this);
438}
439
440/***********************************************************************/
449
450/***********************************************************************/
454{
455 QPoint pos = event->pos();
456 int x = pos.x();
457 int y = pos.y();
458
459 if (y <= titlebar_height
460 && x <= width() - close_pix.width()) {
461 point = mevent_gpos(event) - geometry().topLeft();
462 moving_now = true;
463 setCursor(Qt::SizeAllCursor);
464 } else if (y <= titlebar_height
465 && x > width() - close_pix.width()) {
466 close();
467 }
468}
469
470/***********************************************************************/
474{
475 moving_now = false;
476 setCursor(Qt::ArrowCursor);
477}
478
479/***********************************************************************/
483 QWidget *parent) : qfc_dialog(parent)
484{
485 int i;
489 QPixmap *pix;
490 QHeaderView *header;
491 QSize size;
493 QLabel *ns_label;
494
495 setAttribute(Qt::WA_DeleteOnClose);
496 is_race_dialog_open = true;
498 selected_nation_tabs = new QTableWidget;
499 nation_tabs = new QTableWidget();
500 styles = new QTableWidget;
501 ok_button = new QPushButton;
503 ns_label = new QLabel;
504 tplayer = pplayer;
505
506 selected_nation = -1;
507 selected_style = -1;
508 setWindowTitle(_("Select Nation"));
509 selected_nation_tabs->setRowCount(0);
510 selected_nation_tabs->setColumnCount(1);
511 selected_nation_tabs->setSelectionMode(QAbstractItemView::SingleSelection);
512 selected_nation_tabs->verticalHeader()->setVisible(false);
513 selected_nation_tabs->horizontalHeader()->setVisible(false);
514 selected_nation_tabs->setProperty("showGrid", "true");
515 selected_nation_tabs->setEditTriggers(QAbstractItemView::NoEditTriggers);
516 selected_nation_tabs->setShowGrid(false);
517 selected_nation_tabs->setAlternatingRowColors(true);
518
519 nation_tabs->setRowCount(0);
520 nation_tabs->setColumnCount(1);
521 nation_tabs->setSelectionMode(QAbstractItemView::SingleSelection);
522 nation_tabs->verticalHeader()->setVisible(false);
523 nation_tabs->horizontalHeader()->setVisible(false);
524 nation_tabs->setProperty("showGrid", "true");
525 nation_tabs->setEditTriggers(QAbstractItemView::NoEditTriggers);
526 nation_tabs->setShowGrid(false);
527 ns_label->setText(_("Nation Set:"));
528 styles->setRowCount(0);
529 styles->setColumnCount(2);
530 styles->setSelectionMode(QAbstractItemView::SingleSelection);
531 styles->verticalHeader()->setVisible(false);
532 styles->horizontalHeader()->setVisible(false);
533 styles->setProperty("showGrid", "false");
534 styles->setProperty("selectionBehavior", "SelectRows");
535 styles->setEditTriggers(QAbstractItemView::NoEditTriggers);
536 styles->setShowGrid(false);
537
539 no_name = new QGroupBox(parent);
543 sex_buttons->addButton(is_male, SEX_MALE);
545 sex_buttons->addButton(is_female, SEX_FEMALE);
546
547 leader_name->setEditable(true);
548 qgroupbox_layout->addWidget(leader_name, 1, 0, 1, 2);
549 qgroupbox_layout->addWidget(is_male, 2, 1);
550 qgroupbox_layout->addWidget(is_female, 2, 0);
553 no_name->setLayout(qgroupbox_layout);
554
556 description->setReadOnly(true);
557 description->setPlainText(_("Choose nation"));
558 no_name->setTitle(_("Your leader name"));
559
560 // Fill styles, no need to update them later
561
564
565 if (i >= 0) {
567 styles->insertRow(i);
569 item->setData(Qt::DecorationRole, *pix);
570 item->setData(Qt::UserRole, style_number(pstyle));
571 size.setWidth(pix->width());
572 size.setHeight(pix->height());
573 item->setSizeHint(size);
574 styles->setItem(i, 0, item);
577 styles->setItem(i, 1, item);
578 }
580
581 header = styles->horizontalHeader();
582 header->setSectionResizeMode(QHeaderView::Stretch);
583 header->resizeSections(QHeaderView::ResizeToContents);
584 header = styles->verticalHeader();
585 header->resizeSections(QHeaderView::ResizeToContents);
590 // Create nation sets
591 refresh();
592
593 connect(styles->selectionModel(),
595 const QItemSelection &)),
597 connect(selected_nation_tabs->selectionModel(),
599 const QItemSelection &)),
602 SLOT(leader_selected(int)));
603 connect(leader_name->lineEdit(), &QLineEdit::returnPressed,
606 SLOT(nationset_changed(int)));
607 connect(nation_tabs->selectionModel(),
609 const QItemSelection &)),
611
612 ok_button = new QPushButton;
613 ok_button->setText(_("Cancel"));
614 connect(ok_button, &QAbstractButton::pressed, this, &races_dialog::cancel_pressed);
615 main_layout->addWidget(ok_button, 8, 2, 1, 1);
616 random_button = new QPushButton;
617 random_button->setText(_("Random"));
618 connect(random_button, &QAbstractButton::pressed, this, &races_dialog::random_pressed);
619 main_layout->addWidget(random_button, 8, 0, 1, 1);
620 ok_button = new QPushButton;
621 ok_button->setText(_("Ok"));
622 connect(ok_button, &QAbstractButton::pressed, this, &races_dialog::ok_pressed);
623 main_layout->addWidget(ok_button, 8, 3, 1, 1);
624 main_layout->addWidget(no_name, 0, 3, 2, 1);
625 if (nation_set_count() > 1) {
626 main_layout->addWidget(ns_label, 0, 0, 1, 1);
627 main_layout->addWidget(qnation_set, 0, 1, 1, 1);
628 main_layout->addWidget(nation_tabs, 1, 0, 5, 2);
629 } else {
630 main_layout->addWidget(nation_tabs, 0, 0, 6, 2);
631 }
632 main_layout->addWidget(styles, 2, 3, 4, 1);
633 main_layout->addWidget(description, 6, 0, 2, 4);
634 main_layout->addWidget(selected_nation_tabs, 0, 2, 6, 1);
635
637 set_index(-99);
638
639 if (C_S_RUNNING == client_state()) {
640 title = _("Edit Nation");
641 } else if (pplayer != nullptr && pplayer == client_player()) {
642 title = _("What Nation Will You Be?");
643 } else {
644 title = _("Pick Nation");
645 }
646
649}
650
651/***********************************************************************/
658
659/***********************************************************************/
663{
664 struct nation_group *group;
666 QHeaderView *header;
667 int i;
668 int count;
669
670 nation_tabs->clearContents();
671 nation_tabs->setRowCount(0);
672 nation_tabs->insertRow(0);
674 item->setText(_("All nations"));
675 item->setData(Qt::UserRole, -99);
676 nation_tabs->setItem(0, 0, item);
677
678 for (i = 1; i < nation_group_count() + 1; i++) {
679 group = nation_group_by_number(i - 1);
680 if (is_nation_group_hidden(group)) {
681 continue;
682 }
683 count = 0;
684 // Checking if group is empty
685 nations_iterate(pnation) {
686 if (!is_nation_playable(pnation)
687 || !is_nation_pickable(pnation)
688 || !nation_is_in_group(pnation, group)) {
689 continue;
690 }
691 count ++;
693 if (count == 0) {
694 continue;
695 }
696 nation_tabs->insertRow(i);
698 item->setData(Qt::UserRole, i - 1);
699 item->setText(nation_group_name_translation(group));
700 nation_tabs->setItem(i, 0, item);
701 }
702 header = nation_tabs->horizontalHeader();
703 header->resizeSections(QHeaderView::Stretch);
704 header = nation_tabs->verticalHeader();
705 header->resizeSections(QHeaderView::ResizeToContents);
706 set_index(-99);
707}
708
709/***********************************************************************/
713{
714 struct option *popt;
715 struct nation_set *s;
716
718 if (popt) {
720 qnation_set->setCurrentIndex(nation_set_index(s));
721 qnation_set->setToolTip(_(nation_set_description(s)));
722 }
723}
724
725/***********************************************************************/
729{
730 QModelIndexList indexes = selected.indexes();
731 QModelIndex index ;
732
733 if (indexes.isEmpty()) {
734 return;
735 }
736
737 index = indexes.at(0);
738 set_index(index.row());
739}
740
741/***********************************************************************/
746{
748 QPixmap *pix;
749 QFont f;
750 struct nation_group *group;
751 int i;
752 struct sprite *s;
753 QHeaderView *header;
754 bool svg = is_svg_flag_enabled();
755
756 selected_nation_tabs->clearContents();
757 selected_nation_tabs->setRowCount(0);
758
759 last_index = 0;
760 i = nation_tabs->currentRow();
761 if (i != -1) {
762 item = nation_tabs->item(i, 0);
763 index = item->data(Qt::UserRole).toInt();
764 }
765
766 group = nation_group_by_number(index);
767 i = 0;
768 nations_iterate(pnation) {
769 if (!is_nation_playable(pnation)
770 || !is_nation_pickable(pnation)) {
771 continue;
772 }
773 if (!nation_is_in_group(pnation, group) && index != -99) {
774 continue;
775 }
777 selected_nation_tabs->insertRow(i);
778 s = get_nation_flag_sprite(tileset, pnation);
779 if (pnation->player) {
780 f = item->font();
781 f.setStrikeOut(true);
782 item->setFont(f);
783 }
784 pix = s->pm;
785 if (svg) {
786 item->setData(Qt::DecorationRole, (*pix).scaledToHeight(50));
787 } else {
788 item->setData(Qt::DecorationRole, *pix);
789 }
790 item->setData(Qt::UserRole, nation_number(pnation));
791 item->setText(nation_adjective_translation(pnation));
792 selected_nation_tabs->setItem(i, 0, item);
794
795 selected_nation_tabs->sortByColumn(0, Qt::AscendingOrder);
796 header = selected_nation_tabs->horizontalHeader();
797 header->resizeSections(QHeaderView::Stretch);
798 header = selected_nation_tabs->verticalHeader();
799 header->resizeSections(QHeaderView::ResizeToContents);
800}
801
802/***********************************************************************/
806{
807 char buf[4096];
808 QModelIndex index ;
810 QModelIndexList indexes = selected.indexes();
811 QString str;
813 int style, ind;
814
815 if (indexes.isEmpty()) {
816 return;
817 }
818
819 index = indexes.at(0);
820 if (indexes.isEmpty()) {
821 return;
822 }
823 qvar = index.data(Qt::UserRole);
824 selected_nation = qvar.toInt();
825
827 description->setPlainText(buf);
828 leader_name->clear();
829 if (client.conn.playing == tplayer) {
830 leader_name->addItem(client.conn.playing->name, true);
831 }
834 str = QString::fromUtf8(nation_leader_name(pleader));
837
838 // Select style for nation
839
841 qvar = qvar.fromValue<int>(style);
842
843 for (ind = 0; ind < styles->rowCount(); ind++) {
844 item = styles->item(ind, 0);
845
846 if (item->data(Qt::UserRole) == qvar) {
847 styles->selectRow(ind);
848 }
849 }
850}
851
852/***********************************************************************/
856{
857 QModelIndex index ;
859 QModelIndexList indexes = selected.indexes();
860
861 if (indexes.isEmpty()) {
862 return;
863 }
864
865 index = indexes.at(0);
866 qvar = index.data(Qt::UserRole);
867 selected_style = qvar.toInt();
868}
869
870/***********************************************************************/
874{
875 if (leader_name->itemData(index).toBool()) {
876 is_male->setChecked(true);
877 is_female->setChecked(false);
878 } else {
879 is_male->setChecked(false);
880 is_female->setChecked(true);
881 }
882}
883
884/***********************************************************************/
889{
891 struct player *natplr;
892
893 if (selected_nation == -1) {
894 return;
895 }
896
897 if (selected_style == -1) {
898 output_window_append(ftc_client, _("You must select your style."));
899 return;
900 }
901
902 if (leader_name->currentText().length() == 0) {
903 output_window_append(ftc_client, _("You must type a legal name."));
904 return;
905 }
906
908 if (natplr != nullptr && natplr != client_player()) {
910 _("Nation has been chosen by other player"));
911 return;
912 }
913
914 ln_bytes = leader_name->currentText().toUtf8();
916 selected_nation, sex_buttons->checkedId(),
917 ln_bytes.data(),
919 close();
920 deleteLater();
921}
922
923/***********************************************************************/
927 const char *lines, QWidget *parent)
928 : fcwidget()
929{
930 int x, y;
932
933 setAttribute(Qt::WA_DeleteOnClose);
934 setCursor(Qt::ArrowCursor);
936 setFrameStyle(QFrame::Box);
937 cw = new close_widget(this);
938 cw->put_to_corner();
939
943 qlist = qlines.split("\n");
944 small_font = *fc_font::instance()->get_font("gui_qt_font_notify_label");
945 x = 0;
946 y = 0;
947 calc_size(x, y);
948 resize(x, y);
949 gui()->mapview_wdg->find_place(gui()->mapview_wdg->width() - x - 4, 4,
950 x, y, x, y, 0);
951 move(x, y);
952 was_destroyed = false;
953
954}
955
956/***********************************************************************/
960{
961 QString s, q;
962 int i;
966
967 for (i = 0; i < qlist.size(); ++i) {
968 s = qlist.at(i);
969 q = q + s;
970 if (i < qlist.size() - 1) {
971 q = q + QChar('\n');
972 }
973 }
974 capt_bytes = qcaption.toUtf8();
975 hl_bytes = qheadline.toUtf8();
976 qb_bytes = q.toUtf8();
978 hl_bytes.data(),
979 qb_bytes.data());
980 close();
981 destroy();
982}
983
984/***********************************************************************/
988{
990 int i;
991 QStringList str_list;
992
993 str_list = qlist;
994 str_list << qcaption << qheadline;
995
996 for (i = 0; i < str_list.count(); i++) {
997 x = qMax(x, fm.horizontalAdvance(str_list.at(i)));
998 y = y + 3 + fm.height();
999 }
1000 x = x + 15;
1001}
1002
1003/***********************************************************************/
1007{
1008 QPainter painter(this);
1009 QPainterPath path;
1010 QPen pen;
1012 int i;
1013
1014 pen.setWidth(1);
1015 pen.setColor(palette().color(QPalette::Text));
1016 painter.setFont(small_font);
1017 painter.setPen(pen);
1018 painter.drawText(10, fm.height() + 3, qcaption);
1019 painter.drawText(10, 2 * fm.height() + 6, qheadline);
1020 for (i = 0; i < qlist.count(); i++) {
1021 painter.drawText(10, 3 + (fm.height() + 3) * (i + 3), qlist[i]);
1022 }
1023 cw->put_to_corner();
1024}
1025
1026/***********************************************************************/
1030{
1031 cursor = mevent_gpos(event) - geometry().topLeft();
1032
1033 if (event->button() == Qt::RightButton) {
1034 was_destroyed = true;
1035 close();
1036 }
1037}
1038
1039/***********************************************************************/
1043{
1045
1046 setCursor(Qt::SizeAllCursor);
1047}
1048
1049/***********************************************************************/
1053{
1054 setCursor(Qt::ArrowCursor);
1055}
1056
1057/***********************************************************************/
1061{
1062 was_destroyed = true;
1063 destroy();
1064}
1065
1066/***********************************************************************/
1072{
1073 was_destroyed = true;
1074 destroy();
1075}
1076
1077/***********************************************************************/
1081{
1082 vs_city = -1;
1083 vs_unit = -1;
1084}
1085
1086/***********************************************************************/
1090{
1091 if (!m_instance) {
1092 m_instance = new qdef_act;
1093 }
1094 return m_instance;
1095}
1096
1097/***********************************************************************/
1101{
1102 if (m_instance) {
1103 delete m_instance;
1104 m_instance = 0;
1105 }
1106}
1107
1108/***********************************************************************/
1112{
1113 vs_city = i;
1114}
1115
1116/***********************************************************************/
1120{
1121 vs_unit = i;
1122}
1123
1124/***********************************************************************/
1128{
1129 return vs_city;
1130}
1131
1132/***********************************************************************/
1136{
1137 return vs_unit;
1138}
1139
1140/***********************************************************************/
1144{
1145 delete this;
1146}
1147
1148/***********************************************************************/
1152{
1154 false, "", 0);
1155 delete this;
1156}
1157
1158/***********************************************************************/
1161notify_goto::notify_goto(const char *headline, const char *lines,
1162 const struct text_tag_list *tags, tile *ptile,
1163 QWidget *parent): QMessageBox(parent)
1164{
1166 setAttribute(Qt::WA_DeleteOnClose);
1167 goto_but = this->addButton(_("Goto Location"), QMessageBox::ActionRole);
1168 goto_but->setIcon(fc_icons::instance()->get_icon("go-up"));
1169 inspect_but = this->addButton(_("Inspect City"), QMessageBox::ActionRole);
1170 inspect_but->setIcon(fc_icons::instance()->get_icon("plus"));
1171
1172 close_but = this->addButton(QMessageBox::Close);
1173 gtile = ptile;
1174 if (!gtile) {
1175 goto_but->setVisible(false);
1176 inspect_but->setVisible(false);
1177 } else {
1178 struct city *pcity = tile_city(gtile);
1179 inspect_but->setVisible(pcity != nullptr
1181 }
1183 qlines = lines;
1184 qlines.replace("\n", " ");
1185 setText(qlines);
1186 connect(goto_but, &QAbstractButton::pressed, this, &notify_goto::goto_tile);
1187 connect(inspect_but, &QAbstractButton::pressed, this, &notify_goto::inspect_city);
1188 connect(close_but, &QAbstractButton::pressed, this, &QWidget::close);
1189 show();
1190}
1191
1192/***********************************************************************/
1196{
1198 close();
1199}
1200
1201/***********************************************************************/
1205{
1206 struct city *pcity = tile_city(gtile);
1207 if (pcity) {
1209 }
1210 close();
1211}
1212
1213/***********************************************************************/
1217{
1218 QString rule_name;
1220 const char *rn;
1221 struct option *poption = optset_option_by_name(server_optset, "nationset");
1222
1223 rule_name = qnation_set->currentData().toString();
1224 rn_bytes = rule_name.toUtf8(); /* Hold QByteArray in a variable to
1225 * extend its, and data() buffer's,
1226 * lifetime */
1227 rn = rn_bytes.data();
1231 }
1232}
1233
1234/***********************************************************************/
1239void popup_notify_goto_dialog(const char *headline, const char *lines,
1240 const struct text_tag_list *tags,
1241 struct tile *ptile)
1242{
1243 notify_goto *ask = new notify_goto(headline, lines, tags, ptile,
1244 gui()->central_wdg);
1245 ask->show();
1246}
1247
1248/***********************************************************************/
1251void popup_connect_msg(const char *headline, const char *message)
1252{
1253 QMessageBox *msg = new QMessageBox(gui()->central_wdg);
1254
1255 msg->setText(message);
1256 msg->setStandardButtons(QMessageBox::Ok);
1257 msg->setWindowTitle(headline);
1258 msg->setAttribute(Qt::WA_DeleteOnClose);
1259 msg->show();
1260}
1261
1262/***********************************************************************/
1265void popup_notify_dialog(const char *caption, const char *headline,
1266 const char *lines)
1267{
1269 gui()->mapview_wdg);
1270 nd->show();
1271}
1272
1273/***********************************************************************/
1276void popup_races_dialog(struct player *pplayer)
1277{
1278 if (!is_race_dialog_open) {
1279 race_dialog = new races_dialog(pplayer, gui()->central_wdg);
1280 is_race_dialog_open = true;
1281 race_dialog->show();
1282 }
1283 race_dialog->showNormal();
1284}
1285
1286/***********************************************************************/
1291{
1292 if (is_race_dialog_open) {
1293 race_dialog->close();
1294 is_race_dialog_open = false;
1295 }
1296}
1297
1298/***********************************************************************/
1302{
1303 if (ptile != nullptr
1304 && (unit_list_size(ptile->units) > 1
1305 || (unit_list_size(ptile->units) == 1 && tile_city(ptile)))) {
1306 gui()->toggle_unit_sel_widget(ptile);
1307 }
1308}
1309
1310/***********************************************************************/
1314{
1315 gui()->update_unit_sel();
1316}
1317
1318/***********************************************************************/
1327
1328/***********************************************************************/
1331void races_update_pickable(bool nationset_change)
1332{
1333 if (is_race_dialog_open) {
1335 }
1336}
1337
1338/***********************************************************************/
1343{
1344 if (is_race_dialog_open) {
1346 }
1347}
1348
1349/***********************************************************************/
1353{
1356 = (gov != nullptr ? government_number(gov) : G_LAST);
1357
1359 ask = new hud_message_box(gui()->central_wdg);
1360 ask->setStandardButtons(QMessageBox::Cancel | QMessageBox::Ok);
1361 ask->setDefaultButton(QMessageBox::Cancel);
1362 ask->set_text_title(_("You say you wanna revolution?"),
1363 _("Revolution!"));
1364 ask->setAttribute(Qt::WA_DeleteOnClose);
1365 QObject::connect(ask, &hud_message_box::accepted, [=]() {
1366 if (government_id == G_LAST) {
1367 revolution_response(nullptr);
1368 } else {
1370
1371 if (government) {
1373 }
1374 }
1375 });
1376 ask->show();
1377 } else {
1379 }
1380}
1381
1382/***********************************************************************/
1395
1396/***********************************************************************/
1403
1404/***********************************************************************/
1412
1413/***********************************************************************/
1421
1422/***********************************************************************/
1429
1430/***********************************************************************/
1437
1438/***********************************************************************/
1442 QWidget *parent,
1443 void (*run_on_close_in)(int)): QWidget(parent)
1444{
1445 QLabel *l = new QLabel(text);
1446
1447 setProperty("themed_choice", true);
1448 layout = new QVBoxLayout(this);
1450
1451 layout->addWidget(l);
1452 setWindowFlags(Qt::Dialog);
1454 setAttribute(Qt::WA_DeleteOnClose);
1455 gui()->set_diplo_dialog(this);
1456
1468
1469 targeted_unit = nullptr;
1470 // No buttons are added yet.
1471 for (int i = 0; i < BUTTON_COUNT; i++) {
1472 action_button_map << nullptr;
1473 }
1474}
1475
1476/***********************************************************************/
1480{
1481 buttons_list.clear();
1482 action_button_map.clear();
1483 gui()->set_diplo_dialog(nullptr);
1484
1485 if (run_on_close) {
1487 run_on_close = nullptr;
1488 }
1489}
1490
1491/***********************************************************************/
1495{
1497
1500 struct canvas *pix;
1501 QPushButton *next, *prev;
1502 unit_skip = new QHBoxLayout;
1503 next = new QPushButton();
1504 next->setIcon(fc_icons::instance()->get_icon("city-right"));
1505 next->setIconSize(QSize(32, 32));
1506 next->setFixedSize(QSize(36, 36));
1507 prev = new QPushButton();
1508 prev->setIcon(fc_icons::instance()->get_icon("city-left"));
1509 prev->setIconSize(QSize(32, 32));
1510 prev->setFixedSize(QSize(36, 36));
1511 target_unit_button = new QPushButton;
1514 pix->map_pixmap.fill(Qt::transparent);
1515 put_unit(targeted_unit, pix, 1.0, 0, 0);
1516 target_unit_button->setIcon(QIcon(pix->map_pixmap));
1517 qtg_canvas_free(pix);
1518 target_unit_button->setIconSize(QSize(96, 96));
1519 target_unit_button->setFixedSize(QSize(100, 100));
1520 unit_skip->addStretch(100);
1521 unit_skip->addWidget(prev, Qt::AlignCenter);
1522 unit_skip->addWidget(target_unit_button, Qt::AlignCenter);
1523 unit_skip->addWidget(next, Qt::AlignCenter);
1524 layout->addLayout(unit_skip);
1525 unit_skip->addStretch(100);
1526 connect(prev, &QAbstractButton::clicked, this, &choice_dialog::prev_unit);
1527 connect(next, &QAbstractButton::clicked, this, &choice_dialog::next_unit);
1528 }
1529
1531}
1532
1533/***********************************************************************/
1537 QVariant data2, QString tool_tip = "",
1538 const int button_id = -1)
1539{
1541 data1, data2);
1542 int action = buttons_list.count();
1543
1544 QObject::connect(button, &QPushButton::clicked,
1547 });
1548
1549 buttons_list.append(button);
1550
1551 if (!tool_tip.isEmpty()) {
1552 button->setToolTip(tool_tip);
1553 }
1554
1555 if (0 <= button_id) {
1556 // The id is valid.
1557 action_button_map[button_id] = button;
1558 }
1559
1560 layout->addWidget(button);
1561}
1562
1563/***********************************************************************/
1567{
1568 QPoint p;
1569
1570 p = mapFromGlobal(QCursor::pos());
1571 p.setY(p.y()-this->height());
1572 p.setX(p.x()-this->width());
1573 move(p);
1574 show();
1575}
1576
1577/***********************************************************************/
1584
1585/***********************************************************************/
1589{
1590 if (id < 0) {
1591 fc_assert_msg(0 <= id, "Invalid button ID.");
1592 return nullptr;
1593 }
1594
1595 return action_button_map[id];
1596}
1597
1598/***********************************************************************/
1602{
1605
1607 if (action == -1) {
1608 return false;
1609 }
1610 func = af_map[action];
1611
1612 func(q1, q2);
1613 return true;
1614}
1615
1616/***********************************************************************/
1620{
1623
1625 if (action == -1) {
1626 return false;
1627 }
1628 func = af_map[action];
1629 func(q1, q2);
1630 return true;
1631}
1632
1633/***********************************************************************/
1637{
1638 struct tile *ptile;
1639 struct unit *new_target = nullptr;
1640 bool break_next = false;
1641 bool first = true;
1642 struct canvas *pix;
1643
1644 if (targeted_unit == nullptr) {
1645 return;
1646 }
1647
1648 ptile = targeted_unit->tile;
1649
1650 unit_list_iterate(ptile->units, ptgt) {
1651 if (first) {
1652 new_target = ptgt;
1653 first = false;
1654 }
1655 if (break_next) {
1656 new_target = ptgt;
1657 break;
1658 }
1659 if (ptgt == targeted_unit) {
1660 break_next = true;
1661 }
1666 pix->map_pixmap.fill(Qt::transparent);
1667 put_unit(targeted_unit, pix, 1.0, 0, 0);
1668 target_unit_button->setIcon(QIcon(pix->map_pixmap));
1669 qtg_canvas_free(pix);
1670 switch_target();
1671}
1672
1673/***********************************************************************/
1677{
1678 struct tile *ptile;
1679 struct unit *new_target = nullptr;
1680 struct canvas *pix;
1681 if (targeted_unit == nullptr) {
1682 return;
1683 }
1684
1685 ptile = targeted_unit->tile;
1686 unit_list_iterate(ptile->units, ptgt) {
1687 if ((ptgt == targeted_unit) && new_target != nullptr) {
1688 break;
1689 }
1690 new_target = ptgt;
1695 pix->map_pixmap.fill(Qt::transparent);
1696 put_unit(targeted_unit, pix, 1.0, 0, 0);
1697 target_unit_button->setIcon(QIcon(pix->map_pixmap));
1698 qtg_canvas_free(pix);
1699 switch_target();
1700}
1701
1702/***********************************************************************/
1706{
1707 if (targeted_unit == nullptr) {
1708 return;
1709 }
1710 unit_skip->setParent(nullptr);
1715 : nullptr),
1716 act_probs);
1717 layout->addLayout(unit_skip);
1718}
1719
1720/***********************************************************************/
1724{
1725 if (targeted_unit == nullptr) {
1726 return;
1727 }
1728
1729 unit_skip->setParent(nullptr);
1731 unit_id,
1736 layout->addLayout(unit_skip);
1737}
1738
1739/***********************************************************************/
1743{
1745 pfcn_void func = button->getFunc();
1746
1747 func(button->getData1(), button->getData2());
1748 close();
1749}
1750
1751/***********************************************************************/
1760{
1761 // Store the data in the stack.
1762 last_buttons_stack.append(button);
1763
1764 /* Temporary remove the button so it will end up below buttons added
1765 * before unstack_all_buttons() is called. */
1766 layout->removeWidget(button);
1767
1768 // Synchronize the list with the layout.
1769 buttons_list.removeAll(button);
1770}
1771
1772/***********************************************************************/
1777{
1778 while (!last_buttons_stack.isEmpty()) {
1779 Choice_dialog_button *button = last_buttons_stack.takeLast();
1780
1781 // Reinsert the button below the other buttons.
1782 buttons_list.append(button);
1783 layout->addWidget(button);
1784 }
1785}
1786
1787/***********************************************************************/
1790static void caravan_marketplace(QVariant data1, QVariant data2)
1791{
1792 int actor_unit_id = data1.toInt();
1793 int target_city_id = data2.toInt();
1794
1795 if (game_unit_by_number(actor_unit_id) != nullptr
1796 && game_city_by_number(target_city_id) != nullptr) {
1798 target_city_id, 0, "");
1799 }
1800}
1801
1802/***********************************************************************/
1806{
1807 int actor_unit_id = data1.toInt();
1808 int target_city_id = data2.toInt();
1809
1810 if (game_unit_by_number(actor_unit_id) != nullptr
1811 && game_city_by_number(target_city_id) != nullptr) {
1813 target_city_id, 0, "");
1814 }
1815}
1816
1817/***********************************************************************/
1820static void caravan_help_build(QVariant data1, QVariant data2)
1821{
1822 int caravan_id = data1.toInt();
1823 int caravan_target_id = data2.toInt();
1824
1825 if (game_unit_by_number(caravan_id) != nullptr
1826 && game_city_by_number(caravan_target_id) != nullptr) {
1829 }
1830}
1831
1832/***********************************************************************/
1835static void unit_disband_recover(QVariant data1, QVariant data2)
1836{
1837 int actor_id = data1.toInt();
1838 int tgt_city_id = data2.toInt();
1839
1840 if (game_unit_by_number(actor_id) != nullptr
1841 && game_city_by_number(tgt_city_id) != nullptr) {
1843 actor_id, tgt_city_id, 0, "");
1844 }
1845}
1846
1847/***********************************************************************/
1850static void unit_home_city(QVariant data1, QVariant data2)
1851{
1852 int actor_id = data1.toInt();
1853 int tgt_city_id = data2.toInt();
1854
1855 if (game_unit_by_number(actor_id) != nullptr
1856 && game_city_by_number(tgt_city_id) != nullptr) {
1858 actor_id, tgt_city_id, 0, "");
1859 }
1860}
1861
1862/***********************************************************************/
1865static void unit_upgrade(QVariant data1, QVariant data2)
1866{
1867 struct unit *punit;
1868
1869 int actor_id = data1.toInt();
1870 int tgt_city_id = data2.toInt();
1871
1872 if ((punit = game_unit_by_number(actor_id)) != nullptr
1873 && game_city_by_number(tgt_city_id) != nullptr) {
1874 struct unit_list *as_list;
1875
1880 }
1881}
1882
1883/***********************************************************************/
1886static void airlift(QVariant data1, QVariant data2)
1887{
1888 int actor_id = data1.toInt();
1889 int tgt_city_id = data2.toInt();
1890
1891 if (game_unit_by_number(actor_id) != nullptr
1892 && game_city_by_number(tgt_city_id) != nullptr) {
1894 actor_id, tgt_city_id, 0, "");
1895 }
1896}
1897
1898/***********************************************************************/
1901static void conquer_city_shrink(QVariant data1, QVariant data2)
1902{
1903 int actor_id = data1.toInt();
1904 int tgt_city_id = data2.toInt();
1905
1906 if (game_unit_by_number(actor_id) != nullptr
1907 && game_city_by_number(tgt_city_id) != nullptr) {
1909 actor_id, tgt_city_id, 0, "");
1910 }
1911}
1912
1913/***********************************************************************/
1916static void conquer_city_shrink2(QVariant data1, QVariant data2)
1917{
1918 int actor_id = data1.toInt();
1919 int tgt_city_id = data2.toInt();
1920
1921 if (game_unit_by_number(actor_id) != nullptr
1922 && game_city_by_number(tgt_city_id) != nullptr) {
1924 actor_id, tgt_city_id, 0, "");
1925 }
1926}
1927
1928/***********************************************************************/
1931static void conquer_city_shrink3(QVariant data1, QVariant data2)
1932{
1933 int actor_id = data1.toInt();
1934 int tgt_city_id = data2.toInt();
1935
1936 if (game_unit_by_number(actor_id) != nullptr
1937 && game_city_by_number(tgt_city_id) != nullptr) {
1939 actor_id, tgt_city_id, 0, "");
1940 }
1941}
1942
1943/***********************************************************************/
1946static void conquer_city_shrink4(QVariant data1, QVariant data2)
1947{
1948 int actor_id = data1.toInt();
1949 int tgt_city_id = data2.toInt();
1950
1951 if (game_unit_by_number(actor_id) != nullptr
1952 && game_city_by_number(tgt_city_id) != nullptr) {
1954 actor_id, tgt_city_id, 0, "");
1955 }
1956}
1957
1958/***********************************************************************/
1961static void conquer_extras(QVariant data1, QVariant data2)
1962{
1963 int actor_id = data1.toInt();
1964 int target_id = data2.toInt();
1965
1966 if (game_unit_by_number(actor_id) != nullptr) {
1968 actor_id, target_id, 0, "");
1969 }
1970}
1971
1972/***********************************************************************/
1975static void conquer_extras2(QVariant data1, QVariant data2)
1976{
1977 int actor_id = data1.toInt();
1978 int target_id = data2.toInt();
1979
1980 if (game_unit_by_number(actor_id) != nullptr) {
1982 actor_id, target_id, 0, "");
1983 }
1984}
1985
1986/***********************************************************************/
1989static void conquer_extras3(QVariant data1, QVariant data2)
1990{
1991 int actor_id = data1.toInt();
1992 int target_id = data2.toInt();
1993
1994 if (game_unit_by_number(actor_id) != nullptr) {
1996 actor_id, target_id, 0, "");
1997 }
1998}
1999
2000/***********************************************************************/
2003static void conquer_extras4(QVariant data1, QVariant data2)
2004{
2005 int actor_id = data1.toInt();
2006 int target_id = data2.toInt();
2007
2008 if (game_unit_by_number(actor_id) != nullptr) {
2010 actor_id, target_id, 0, "");
2011 }
2012}
2013
2014/***********************************************************************/
2017static void act_sel_wait(QVariant data1, QVariant data2)
2018{
2019 key_unit_wait();
2020}
2021
2022/***********************************************************************/
2025static void keep_moving(QVariant data1, QVariant data2)
2026{
2027}
2028
2029/***********************************************************************/
2033{
2034 if (!gov) {
2036 } else {
2038 }
2039}
2040
2041/***********************************************************************/
2046{
2048 /* The client isn't waiting for information for any unanswered follow
2049 * up questions. */
2050
2051 struct unit *actor_unit;
2052
2054 /* The action selection dialog wasn't closed because the actor unit
2055 * was lost. */
2056
2057 // The probabilities didn't just disappear, right?
2060
2062 }
2063
2064 // The action selection process is over, at least for now.
2066
2067 if (did_not_decide) {
2068 /* The action selection dialog was closed but the player didn't
2069 * decide what the unit should do. */
2070
2071 // Reset so the next action selection dialog does the right thing.
2072 did_not_decide = false;
2073 } else {
2074 // An action, or no action at all, was selected.
2077 }
2078 }
2079}
2080
2081/***********************************************************************/
2085static void diplomat_queue_handle_secondary(int actor_id)
2086{
2087 // Stop waiting. Move on to the next queued unit.
2090}
2091
2092/**********************************************************************/
2099{
2100 // Stop assuming the answer to a follow up question will arrive.
2102}
2103
2104/***********************************************************************/
2109 struct city *target_city,
2110 struct unit *target_unit,
2111 struct tile *target_tile,
2112 struct extra_type *target_extra,
2113 const struct act_prob *act_probs)
2114{
2115 struct astring title = ASTRING_INIT, text = ASTRING_INIT;
2117 qtiles caras;
2118 QVariant qv1, qv2;
2120 struct city *actor_homecity;
2123
2126
2127 foreach (caras, gui()->trade_gen.lines) {
2128 if (caras.autocaravan == actor_unit) {
2129 int i;
2130
2131 if (game_unit_by_number(actor_unit->id) != nullptr
2132 && game_city_by_number(target_city->id) != nullptr) {
2134 target_city->id, 0, "");
2137 i = gui()->trade_gen.lines.indexOf(caras);
2138 gui()->trade_gen.lines.takeAt(i);
2139
2140 return;
2141 }
2142 }
2143 }
2144 if (target_city
2148
2149 return;
2150 }
2151
2152 if (target_unit
2156
2157 return;
2158 }
2159 /* Could be caused by the server failing to reply to a request for more
2160 * information or a bug in the client code. */
2162 "Diplomat queue problem. Is another diplomat window open?");
2163
2164 // No extra input is required as no action has been chosen yet.
2166
2168
2169 astr_set(&title,
2170 // TRANS: %s is a unit name, e.g., Spy
2171 _("Choose Your %s's Strategy"),
2173
2174 if (target_city != nullptr && actor_homecity != nullptr) {
2175 astr_set(&text,
2176 _("Your %s from %s reaches the city of %s.\nWhat now?"),
2180 } else if (target_city != nullptr) {
2181 astr_set(&text,
2182 _("Your %s has arrived at %s.\nWhat is your command?"),
2185 } else if (target_unit != nullptr) {
2187
2188 if (owner != nullptr) {
2189 astr_set(&text,
2190 // TRANS: Your Spy is ready to act against Roman Freight.
2191 _("Your %s is ready to act against %s %s."),
2195 } else {
2196 // Flagless target
2197 astr_set(&text,
2198 // TRANS: Your Spy is ready to act against Freight.
2199 _("Your %s is ready to act against %s."),
2202 }
2203 } else {
2204 fc_assert_msg(target_unit != nullptr
2205 || target_city != nullptr
2206 || target_tile != nullptr,
2207 "No target specified.");
2208
2209 astr_set(&text,
2210 // TRANS: %s is a unit name, e.g., Diplomat, Spy
2211 _("Your %s is waiting for your command."),
2213 }
2214
2215 cd = gui()->get_diplo_dialog();
2216 if ((cd != nullptr) && cd->targeted_unit != nullptr) {
2217 cd->update_dialog(act_probs);
2218 return;
2219 }
2220 cd = new choice_dialog(astr_str(&title), astr_str(&text),
2221 gui()->game_tab_widget,
2223 qv1 = actor_unit->id;
2224
2225 cd->unit_id = actor_unit->id;
2226
2227 cd->target_id[ATK_SELF] = cd->unit_id;
2228
2229 if (target_city) {
2230 cd->target_id[ATK_CITY] = target_city->id;
2231 } else {
2232 cd->target_id[ATK_CITY] = IDENTITY_NUMBER_ZERO;
2233 }
2234
2235 if (target_unit) {
2236 cd->target_id[ATK_UNIT] = target_unit->id;
2237 } else {
2238 cd->target_id[ATK_UNIT] = IDENTITY_NUMBER_ZERO;
2239 }
2240
2241 if (target_tile) {
2242 cd->target_id[ATK_STACK] = tile_index(target_tile);
2243 } else {
2244 cd->target_id[ATK_STACK] = TILE_INDEX_NONE;
2245 }
2246
2247 if (target_tile) {
2248 cd->target_id[ATK_TILE] = tile_index(target_tile);
2249 } else {
2250 cd->target_id[ATK_TILE] = TILE_INDEX_NONE;
2251 }
2252
2253 if (target_tile) {
2254 cd->target_id[ATK_EXTRAS] = tile_index(target_tile);
2255 } else {
2256 cd->target_id[ATK_EXTRAS] = TILE_INDEX_NONE;
2257 }
2258
2259 // No target building or target tech supplied. (Feb 2020)
2260 cd->sub_target_id[ASTK_BUILDING] = B_LAST;
2261 cd->sub_target_id[ASTK_TECH] = A_UNSET;
2262
2263 if (target_extra) {
2264 cd->sub_target_id[ASTK_EXTRA] = extra_number(target_extra);
2266 } else {
2267 cd->sub_target_id[ASTK_EXTRA] = EXTRA_NONE;
2268 cd->sub_target_id[ASTK_EXTRA_NOT_THERE] = EXTRA_NONE;
2269 }
2270
2271 // Unit acting against a city
2272
2273 // Set the correct target for the following actions.
2274 qv2 = cd->target_id[ATK_CITY];
2275
2276 action_iterate(act) {
2281 act_probs[act],
2282 actor_unit,
2283 target_city),
2284 qv1, qv2);
2285 }
2287
2288 // Unit acting against another unit
2289
2290 // Set the correct target for the following actions.
2291 qv2 = cd->target_id[ATK_UNIT];
2292
2293 action_iterate(act) {
2298 act_probs[act],
2299 actor_unit,
2300 target_city),
2301 qv1, qv2);
2302 }
2304
2305 // Unit acting against all units at a tile
2306
2307 // Set the correct target for the following actions.
2308 qv2 = cd->target_id[ATK_STACK];
2309
2310 action_iterate(act) {
2315 act_probs[act],
2316 actor_unit,
2317 target_city),
2318 qv1, qv2);
2319 }
2321
2322 // Unit acting against a tile.
2323
2324 // Set the correct target for the following actions.
2325 qv2 = cd->target_id[ATK_TILE];
2326
2327 action_iterate(act) {
2332 act_probs[act],
2333 actor_unit,
2334 target_city),
2335 qv1, qv2);
2336 }
2338
2339 // Unit acting against a tile's extras.
2340
2341 // Set the correct target for the following actions.
2342 qv2 = cd->target_id[ATK_EXTRAS];
2343
2344 action_iterate(act) {
2349 act_probs[act],
2350 actor_unit,
2351 target_city),
2352 qv1, qv2);
2353 }
2355
2356 // Unit acting against itself
2357
2358 // Set the correct target for the following actions.
2359 qv2 = cd->target_id[ATK_SELF];
2360
2361 action_iterate(act) {
2366 act_probs[act],
2367 actor_unit,
2368 target_city),
2369 qv1, qv2);
2370 }
2372
2374 cd->add_item(QString(_("&Wait")), func, qv1, qv2,
2375 "", BUTTON_WAIT);
2376
2377 func = keep_moving;
2378 cd->add_item(QString(_("Do nothing")), func, qv1, qv2,
2379 "", BUTTON_CANCEL);
2380
2381 cd->set_layout();
2382 cd->show_me();
2383
2384 // Give follow up questions access to action probabilities.
2386 action_iterate(act) {
2389
2390 astr_free(&title);
2391 astr_free(&text);
2392}
2393
2394/***********************************************************************/
2399{
2400 /* Don't add an action mapping here unless the non targeted version is
2401 * selectable in the targeted version's target selection dialog. */
2402 switch ((enum gen_action)tgt_action_id) {
2408 return ACTION_SPY_STEAL_TECH;
2411 default:
2412 // No non targeted version found.
2413 return ACTION_NONE;
2414 }
2415}
2416
2417/**********************************************************************/
2422{
2423 /* Don't add an action mapping here unless the non targeted version is
2424 * selectable in the targeted version's target selection dialog. */
2425 switch ((enum gen_action)tgt_action_id) {
2432 default:
2433 // No non targeted version found.
2434 return ACTION_NONE;
2435 }
2436}
2437
2438/***********************************************************************/
2442 action_id act,
2443 const struct act_prob *act_probs,
2444 const char *custom,
2445 QVariant data1, QVariant data2)
2446{
2447 QString title;
2449
2450 if (!af_map.contains(act)) {
2451 /* The Qt client doesn't support ordering this action from the
2452 * action selection dialog. */
2453 return;
2454 }
2455
2456 // Don't show disabled actions.
2457 if (!action_prob_possible(act_probs[act])) {
2458 return;
2459 }
2460
2462 act_probs[act],
2463 custom));
2464
2466 act_probs[act]));
2467
2468 cd->add_item(title, af_map[act], data1, data2, tool_tip, act);
2469}
2470
2471/***********************************************************************/
2475 action_id act,
2476 const struct act_prob *act_probs,
2477 const char *custom,
2478 QVariant data1, QVariant data2)
2479{
2480 QString title;
2482
2483 /* An action that just became impossible has its button disabled.
2484 * An action that became possible again must be re-enabled. */
2485 button->setEnabled(action_prob_possible(act_probs[act]));
2486 button->setData1(data1);
2487 button->setData2(data2);
2488 // The probability may have changed.
2490 act_probs[act],
2491 custom));
2492
2494 act_probs[act]));
2495
2496 button->setText(title);
2497 button->setToolTip(tool_tip);
2498}
2499
2500/***********************************************************************/
2503static void disband_unit(QVariant data1, QVariant data2)
2504{
2505 int actor_id = data1.toInt();
2506 int target_id = data2.toInt();
2507
2509 target_id, 0, "");
2510}
2511
2512/***********************************************************************/
2515static void fortify(QVariant data1, QVariant data2)
2516{
2517 int actor_id = data1.toInt();
2518 int target_id = data2.toInt();
2519
2520 if (game_unit_by_number(actor_id) != nullptr) {
2522 target_id, 0, "");
2523 }
2524}
2525
2526/***********************************************************************/
2529static void convert_unit(QVariant data1, QVariant data2)
2530{
2531 int actor_id = data1.toInt();
2532 int target_id = data2.toInt();
2533
2535 target_id, 0, "");
2536}
2537
2538/***********************************************************************/
2541static void homeless(QVariant data1, QVariant data2)
2542{
2543 int actor_id = data1.toInt();
2544 int target_id = data2.toInt();
2545
2546 if (game_unit_by_number(actor_id) != nullptr) {
2548 target_id, 0, "");
2549 }
2550}
2551
2552/***********************************************************************/
2555static void diplomat_bribe_unit(QVariant data1, QVariant data2)
2556{
2557 int diplomat_id = data1.toInt();
2558 int diplomat_target_id = data2.toInt();
2559
2560 if (game_unit_by_number(diplomat_id) != nullptr
2561 && game_unit_by_number(diplomat_target_id) != nullptr) {
2562 // Wait for the server's reply before moving on to the next queued diplomat.
2564
2567 }
2568}
2569
2570/***********************************************************************/
2573static void diplomat_bribe_stack(QVariant data1, QVariant data2)
2574{
2575 int diplomat_id = data1.toInt();
2576 int diplomat_target_id = data2.toInt();
2577
2578 if (game_unit_by_number(diplomat_id) != nullptr) {
2579 // Wait for the server's reply before moving on to the next queued diplomat.
2581
2584 }
2585}
2586
2587/***********************************************************************/
2590static void spy_sabotage_unit(QVariant data1, QVariant data2)
2591{
2592 int diplomat_id = data1.toInt();
2593 int diplomat_target_id = data2.toInt();
2594
2596 diplomat_target_id, 0, "");
2597}
2598
2599/***********************************************************************/
2602static void spy_sabotage_unit_esc(QVariant data1, QVariant data2)
2603{
2604 int diplomat_id = data1.toInt();
2605 int diplomat_target_id = data2.toInt();
2606
2608 diplomat_target_id, 0, "");
2609}
2610
2611/***********************************************************************/
2614static void heal_unit(QVariant data1, QVariant data2)
2615{
2616 int actor_id = data1.toInt();
2617 int target_id = data2.toInt();
2618
2619 request_do_action(ACTION_HEAL_UNIT, actor_id, target_id, 0, "");
2620}
2621
2622/***********************************************************************/
2625static void heal_unit2(QVariant data1, QVariant data2)
2626{
2627 int actor_id = data1.toInt();
2628 int target_id = data2.toInt();
2629
2630 request_do_action(ACTION_HEAL_UNIT2, actor_id, target_id, 0, "");
2631}
2632
2633/***********************************************************************/
2636static void transport_board(QVariant data1, QVariant data2)
2637{
2638 int actor_id = data1.toInt();
2639 int target_id = data2.toInt();
2640
2641 request_do_action(ACTION_TRANSPORT_BOARD, actor_id, target_id, 0, "");
2642}
2643
2644/***********************************************************************/
2647static void transport_board2(QVariant data1, QVariant data2)
2648{
2649 int actor_id = data1.toInt();
2650 int target_id = data2.toInt();
2651
2652 request_do_action(ACTION_TRANSPORT_BOARD2, actor_id, target_id, 0, "");
2653}
2654
2655/***********************************************************************/
2658static void transport_board3(QVariant data1, QVariant data2)
2659{
2660 int actor_id = data1.toInt();
2661 int target_id = data2.toInt();
2662
2663 request_do_action(ACTION_TRANSPORT_BOARD3, actor_id, target_id, 0, "");
2664}
2665
2666/***********************************************************************/
2669static void transport_embark(QVariant data1, QVariant data2)
2670{
2671 int actor_id = data1.toInt();
2672 int target_id = data2.toInt();
2673
2674 request_do_action(ACTION_TRANSPORT_EMBARK, actor_id, target_id, 0, "");
2675}
2676
2677/***********************************************************************/
2680static void transport_embark2(QVariant data1, QVariant data2)
2681{
2682 int actor_id = data1.toInt();
2683 int target_id = data2.toInt();
2684
2685 request_do_action(ACTION_TRANSPORT_EMBARK2, actor_id, target_id, 0, "");
2686}
2687
2688/***********************************************************************/
2691static void transport_embark3(QVariant data1, QVariant data2)
2692{
2693 int actor_id = data1.toInt();
2694 int target_id = data2.toInt();
2695
2696 request_do_action(ACTION_TRANSPORT_EMBARK3, actor_id, target_id, 0, "");
2697}
2698
2699/***********************************************************************/
2702static void transport_embark4(QVariant data1, QVariant data2)
2703{
2704 int actor_id = data1.toInt();
2705 int target_id = data2.toInt();
2706
2707 request_do_action(ACTION_TRANSPORT_EMBARK4, actor_id, target_id, 0, "");
2708}
2709
2710/***********************************************************************/
2713static void transport_unload(QVariant data1, QVariant data2)
2714{
2715 int actor_id = data1.toInt();
2716 int target_id = data2.toInt();
2717
2718 request_do_action(ACTION_TRANSPORT_UNLOAD, actor_id, target_id, 0, "");
2719}
2720
2721/***********************************************************************/
2724static void transport_load(QVariant data1, QVariant data2)
2725{
2726 int actor_id = data1.toInt();
2727 int target_id = data2.toInt();
2728
2729 request_do_action(ACTION_TRANSPORT_LOAD, actor_id, target_id, 0, "");
2730}
2731
2732/***********************************************************************/
2735static void transport_load2(QVariant data1, QVariant data2)
2736{
2737 int actor_id = data1.toInt();
2738 int target_id = data2.toInt();
2739
2740 request_do_action(ACTION_TRANSPORT_LOAD2, actor_id, target_id, 0, "");
2741}
2742
2743/***********************************************************************/
2746static void transport_load3(QVariant data1, QVariant data2)
2747{
2748 int actor_id = data1.toInt();
2749 int target_id = data2.toInt();
2750
2751 request_do_action(ACTION_TRANSPORT_LOAD3, actor_id, target_id, 0, "");
2752}
2753
2754/***********************************************************************/
2757static void transport_deboard(QVariant data1, QVariant data2)
2758{
2759 int actor_id = data1.toInt();
2760 int target_id = data2.toInt();
2761
2762 request_do_action(ACTION_TRANSPORT_DEBOARD, actor_id, target_id, 0, "");
2763}
2764
2765/***********************************************************************/
2768static void disembark1(QVariant data1, QVariant data2)
2769{
2770 int actor_id = data1.toInt();
2771 int target_id = data2.toInt();
2772
2773 if (game_unit_by_number(actor_id) != nullptr
2774 && index_to_tile(&(wld.map), target_id) != nullptr) {
2776 actor_id, target_id, 0, "");
2777 }
2778}
2779
2780/***********************************************************************/
2783static void disembark2(QVariant data1, QVariant data2)
2784{
2785 int actor_id = data1.toInt();
2786 int target_id = data2.toInt();
2787
2788 if (game_unit_by_number(actor_id) != nullptr
2789 && index_to_tile(&(wld.map), target_id) != nullptr) {
2791 actor_id, target_id, 0, "");
2792 }
2793}
2794
2795/***********************************************************************/
2798static void disembark3(QVariant data1, QVariant data2)
2799{
2800 int actor_id = data1.toInt();
2801 int target_id = data2.toInt();
2802
2803 if (game_unit_by_number(actor_id) != nullptr
2804 && index_to_tile(&(wld.map), target_id) != nullptr) {
2806 actor_id, target_id, 0, "");
2807 }
2808}
2809
2810/***********************************************************************/
2813static void disembark4(QVariant data1, QVariant data2)
2814{
2815 int actor_id = data1.toInt();
2816 int target_id = data2.toInt();
2817
2818 if (game_unit_by_number(actor_id) != nullptr
2819 && index_to_tile(&(wld.map), target_id) != nullptr) {
2821 actor_id, target_id, 0, "");
2822 }
2823}
2824
2825/***********************************************************************/
2828static void enter_hut(QVariant data1, QVariant data2)
2829{
2830 int actor_id = data1.toInt();
2831 int target_id = data2.toInt();
2832
2833 if (game_unit_by_number(actor_id) != nullptr
2834 && index_to_tile(&(wld.map), target_id) != nullptr) {
2836 actor_id, target_id, 0, "");
2837 }
2838}
2839
2840/***********************************************************************/
2843static void enter_hut2(QVariant data1, QVariant data2)
2844{
2845 int actor_id = data1.toInt();
2846 int target_id = data2.toInt();
2847
2848 if (game_unit_by_number(actor_id) != nullptr
2849 && index_to_tile(&(wld.map), target_id) != nullptr) {
2851 actor_id, target_id, 0, "");
2852 }
2853}
2854
2855/***********************************************************************/
2858static void enter_hut3(QVariant data1, QVariant data2)
2859{
2860 int actor_id = data1.toInt();
2861 int target_id = data2.toInt();
2862
2863 if (game_unit_by_number(actor_id) != nullptr
2864 && index_to_tile(&(wld.map), target_id) != nullptr) {
2866 actor_id, target_id, 0, "");
2867 }
2868}
2869
2870/***********************************************************************/
2873static void enter_hut4(QVariant data1, QVariant data2)
2874{
2875 int actor_id = data1.toInt();
2876 int target_id = data2.toInt();
2877
2878 if (game_unit_by_number(actor_id) != nullptr
2879 && index_to_tile(&(wld.map), target_id) != nullptr) {
2881 actor_id, target_id, 0, "");
2882 }
2883}
2884
2885/***********************************************************************/
2888static void frighten_hut(QVariant data1, QVariant data2)
2889{
2890 int actor_id = data1.toInt();
2891 int target_id = data2.toInt();
2892
2893 if (game_unit_by_number(actor_id) != nullptr
2894 && index_to_tile(&(wld.map), target_id) != nullptr) {
2896 actor_id, target_id, 0, "");
2897 }
2898}
2899
2900/***********************************************************************/
2903static void frighten_hut2(QVariant data1, QVariant data2)
2904{
2905 int actor_id = data1.toInt();
2906 int target_id = data2.toInt();
2907
2908 if (game_unit_by_number(actor_id) != nullptr
2909 && index_to_tile(&(wld.map), target_id) != nullptr) {
2911 actor_id, target_id, 0, "");
2912 }
2913}
2914
2915/***********************************************************************/
2918static void frighten_hut3(QVariant data1, QVariant data2)
2919{
2920 int actor_id = data1.toInt();
2921 int target_id = data2.toInt();
2922
2923 if (game_unit_by_number(actor_id) != nullptr
2924 && index_to_tile(&(wld.map), target_id) != nullptr) {
2926 actor_id, target_id, 0, "");
2927 }
2928}
2929
2930/***********************************************************************/
2933static void frighten_hut4(QVariant data1, QVariant data2)
2934{
2935 int actor_id = data1.toInt();
2936 int target_id = data2.toInt();
2937
2938 if (game_unit_by_number(actor_id) != nullptr
2939 && index_to_tile(&(wld.map), target_id) != nullptr) {
2941 actor_id, target_id, 0, "");
2942 }
2943}
2944
2945/**********************************************************************/
2948static void nuke_units(QVariant data1, QVariant data2)
2949{
2950 int actor_id = data1.toInt();
2951 int target_id = data2.toInt();
2952
2954 target_id, 0, "");
2955}
2956
2957/**********************************************************************/
2960static void collect_ransom(QVariant data1, QVariant data2)
2961{
2962 int actor_id = data1.toInt();
2963 int target_id = data2.toInt();
2964
2966 target_id, 0, "");
2967}
2968
2969/**********************************************************************/
2972static void spy_attack(QVariant data1, QVariant data2)
2973{
2974 int actor_id = data1.toInt();
2975 int target_id = data2.toInt();
2976
2978 target_id, 0, "");
2979}
2980
2981/**********************************************************************/
2984static void wipe_units(QVariant data1, QVariant data2)
2985{
2986 int actor_id = data1.toInt();
2987 int target_id = data2.toInt();
2988
2990 target_id, 0, "");
2991}
2992
2993/**********************************************************************/
2996static void capture_units(QVariant data1, QVariant data2)
2997{
2998 int actor_id = data1.toInt();
2999 int target_id = data2.toInt();
3000
3002 target_id, 0, "");
3003}
3004
3005/***********************************************************************/
3008static void expel_unit(QVariant data1, QVariant data2)
3009{
3010 int actor_id = data1.toInt();
3011 int target_id = data2.toInt();
3012
3014 target_id, 0, "");
3015}
3016
3017/***********************************************************************/
3020static void bombard(QVariant data1, QVariant data2)
3021{
3022 int actor_id = data1.toInt();
3023 int target_id = data2.toInt();
3024
3026 target_id, 0, "");
3027}
3028
3029/***********************************************************************/
3032static void bombard2(QVariant data1, QVariant data2)
3033{
3034 int actor_id = data1.toInt();
3035 int target_id = data2.toInt();
3036
3038 target_id, 0, "");
3039}
3040
3041/***********************************************************************/
3044static void bombard3(QVariant data1, QVariant data2)
3045{
3046 int actor_id = data1.toInt();
3047 int target_id = data2.toInt();
3048
3050 target_id, 0, "");
3051}
3052
3053/***********************************************************************/
3056static void bombard4(QVariant data1, QVariant data2)
3057{
3058 int actor_id = data1.toInt();
3059 int target_id = data2.toInt();
3060
3062 target_id, 0, "");
3063}
3064
3065/***********************************************************************/
3068static void bombard_lethal(QVariant data1, QVariant data2)
3069{
3070 int actor_id = data1.toInt();
3071 int target_id = data2.toInt();
3072
3074 target_id, 0, "");
3075}
3076
3077/***********************************************************************/
3080static void bombard_lethal2(QVariant data1, QVariant data2)
3081{
3082 int actor_id = data1.toInt();
3083 int target_id = data2.toInt();
3084
3086 target_id, 0, "");
3087}
3088
3089/***********************************************************************/
3092static void found_city(QVariant data1, QVariant data2)
3093{
3094 int actor_id = data1.toInt();
3095
3097 actor_id);
3098}
3099
3100/***********************************************************************/
3103static void transform_terrain(QVariant data1, QVariant data2)
3104{
3105 int actor_id = data1.toInt();
3106 int target_id = data2.toInt();
3107
3108 if (game_unit_by_number(actor_id) != nullptr
3109 && index_to_tile(&(wld.map), target_id) != nullptr) {
3111 actor_id, target_id, 0, "");
3112 }
3113}
3114
3115/***********************************************************************/
3118static void cultivate(QVariant data1, QVariant data2)
3119{
3120 int actor_id = data1.toInt();
3121 int target_id = data2.toInt();
3122
3123 if (game_unit_by_number(actor_id) != nullptr
3124 && index_to_tile(&(wld.map), target_id) != nullptr) {
3126 actor_id, target_id, 0, "");
3127 }
3128}
3129
3130/***********************************************************************/
3133static void plant(QVariant data1, QVariant data2)
3134{
3135 int actor_id = data1.toInt();
3136 int target_id = data2.toInt();
3137
3138 if (game_unit_by_number(actor_id) != nullptr
3139 && index_to_tile(&(wld.map), target_id) != nullptr) {
3141 actor_id, target_id, 0, "");
3142 }
3143}
3144
3145/***********************************************************************/
3148static void pillage(QVariant data1, QVariant data2)
3149{
3150 int actor_id = data1.toInt();
3151 int target_id = data2.toInt();
3152
3153 if (game_unit_by_number(actor_id) != nullptr
3154 && index_to_tile(&(wld.map), target_id) != nullptr) {
3156 actor_id, target_id,
3157 /* FIXME: will cause problems if more than
3158 * one action selection dialog at a time
3159 * becomes supported. */
3161 "");
3162 }
3163}
3164
3165/***********************************************************************/
3168static void clean(QVariant data1, QVariant data2)
3169{
3170 int actor_id = data1.toInt();
3171 int target_id = data2.toInt();
3172
3173 if (game_unit_by_number(actor_id) != nullptr
3174 && index_to_tile(&(wld.map), target_id) != nullptr) {
3176 actor_id, target_id,
3177 /* FIXME: will cause problems if more than
3178 * one action selection dialog at a time
3179 * becomes supported. */
3181 "");
3182 }
3183}
3184
3185/***********************************************************************/
3188static void road(QVariant data1, QVariant data2)
3189{
3190 int actor_id = data1.toInt();
3191 int target_id = data2.toInt();
3192
3193 if (game_unit_by_number(actor_id) != nullptr
3194 && index_to_tile(&(wld.map), target_id) != nullptr
3197 actor_id, target_id,
3198 /* FIXME: will cause problems if more than
3199 * one action selection dialog at a time
3200 * becomes supported. */
3202 "");
3203 }
3204}
3205
3206/***********************************************************************/
3209static void base(QVariant data1, QVariant data2)
3210{
3211 int actor_id = data1.toInt();
3212 int target_id = data2.toInt();
3213
3214 if (game_unit_by_number(actor_id) != nullptr
3215 && index_to_tile(&(wld.map), target_id) != nullptr
3218 actor_id, target_id,
3219 /* FIXME: will cause problems if more than
3220 * one action selection dialog at a time
3221 * becomes supported. */
3223 "");
3224 }
3225}
3226
3227/***********************************************************************/
3230static void mine(QVariant data1, QVariant data2)
3231{
3232 int actor_id = data1.toInt();
3233 int target_id = data2.toInt();
3234
3235 if (game_unit_by_number(actor_id) != nullptr
3236 && index_to_tile(&(wld.map), target_id) != nullptr
3239 actor_id, target_id,
3240 /* FIXME: will cause problems if more than
3241 * one action selection dialog at a time
3242 * becomes supported. */
3244 "");
3245 }
3246}
3247
3248/***********************************************************************/
3251static void irrigate(QVariant data1, QVariant data2)
3252{
3253 int actor_id = data1.toInt();
3254 int target_id = data2.toInt();
3255
3256 if (game_unit_by_number(actor_id) != nullptr
3257 && index_to_tile(&(wld.map), target_id) != nullptr
3260 actor_id, target_id,
3261 /* FIXME: will cause problems if more than
3262 * one action selection dialog at a time
3263 * becomes supported. */
3265 "");
3266 }
3267}
3268
3269/***********************************************************************/
3272static void nuke(QVariant data1, QVariant data2)
3273{
3274 int diplomat_id = data1.toInt();
3275 int diplomat_target_id = data2.toInt();
3276
3277 if (game_unit_by_number(diplomat_id) != nullptr
3278 && index_to_tile(&(wld.map), diplomat_target_id) != nullptr) {
3281 }
3282}
3283
3284/***********************************************************************/
3287static void attack(QVariant data1, QVariant data2)
3288{
3289 int diplomat_id = data1.toInt();
3290 int diplomat_target_id = data2.toInt();
3291
3292 if (game_unit_by_number(diplomat_id) != nullptr
3293 && index_to_tile(&(wld.map), diplomat_target_id) != nullptr) {
3296 }
3297}
3298
3299/***********************************************************************/
3302static void attack2(QVariant data1, QVariant data2)
3303{
3304 int diplomat_id = data1.toInt();
3305 int diplomat_target_id = data2.toInt();
3306
3307 if (game_unit_by_number(diplomat_id) != nullptr
3308 && index_to_tile(&(wld.map), diplomat_target_id) != nullptr) {
3311 }
3312}
3313
3314/***********************************************************************/
3317static void suicide_attack(QVariant data1, QVariant data2)
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 && index_to_tile(&(wld.map), diplomat_target_id) != nullptr) {
3326 }
3327}
3328
3329/***********************************************************************/
3332static void suicide_attack2(QVariant data1, QVariant data2)
3333{
3334 int diplomat_id = data1.toInt();
3335 int diplomat_target_id = data2.toInt();
3336
3337 if (game_unit_by_number(diplomat_id) != nullptr
3338 && index_to_tile(&(wld.map), diplomat_target_id) != nullptr) {
3341 }
3342}
3343
3344/***********************************************************************/
3347static void paradrop(QVariant data1, QVariant data2)
3348{
3349 int actor_id = data1.toInt();
3350 int target_id = data2.toInt();
3351
3352 if (game_unit_by_number(actor_id) != nullptr
3353 && index_to_tile(&(wld.map), target_id) != nullptr) {
3355 actor_id, target_id, 0, "");
3356 }
3357}
3358
3359/***********************************************************************/
3362static void teleport(QVariant data1, QVariant data2)
3363{
3364 int actor_id = data1.toInt();
3365 int target_id = data2.toInt();
3366
3367 if (game_unit_by_number(actor_id) != nullptr
3368 && index_to_tile(&(wld.map), target_id) != nullptr) {
3370 actor_id, target_id, 0, "");
3371 }
3372}
3373
3374/***********************************************************************/
3377static void paradrop_conquer(QVariant data1, QVariant data2)
3378{
3379 int actor_id = data1.toInt();
3380 int target_id = data2.toInt();
3381
3382 if (game_unit_by_number(actor_id) != nullptr
3383 && index_to_tile(&(wld.map), target_id) != nullptr) {
3385 actor_id, target_id, 0, "");
3386 }
3387}
3388
3389/***********************************************************************/
3392static void teleport_conquer(QVariant data1, QVariant data2)
3393{
3394 int actor_id = data1.toInt();
3395 int target_id = data2.toInt();
3396
3397 if (game_unit_by_number(actor_id) != nullptr
3398 && index_to_tile(&(wld.map), target_id) != nullptr) {
3400 actor_id, target_id, 0, "");
3401 }
3402}
3403
3404/***********************************************************************/
3407static void paradrop_frighten(QVariant data1, QVariant data2)
3408{
3409 int actor_id = data1.toInt();
3410 int target_id = data2.toInt();
3411
3412 if (game_unit_by_number(actor_id) != nullptr
3413 && index_to_tile(&(wld.map), target_id) != nullptr) {
3415 actor_id, target_id, 0, "");
3416 }
3417}
3418
3419/***********************************************************************/
3422static void teleport_frighten(QVariant data1, QVariant data2)
3423{
3424 int actor_id = data1.toInt();
3425 int target_id = data2.toInt();
3426
3427 if (game_unit_by_number(actor_id) != nullptr
3428 && index_to_tile(&(wld.map), target_id) != nullptr) {
3430 actor_id, target_id, 0, "");
3431 }
3432}
3433
3434/***********************************************************************/
3438{
3439 int actor_id = data1.toInt();
3440 int target_id = data2.toInt();
3441
3442 if (game_unit_by_number(actor_id) != nullptr
3443 && index_to_tile(&(wld.map), target_id) != nullptr) {
3445 actor_id, target_id, 0, "");
3446 }
3447}
3448
3449/***********************************************************************/
3453{
3454 int actor_id = data1.toInt();
3455 int target_id = data2.toInt();
3456
3457 if (game_unit_by_number(actor_id) != nullptr
3458 && index_to_tile(&(wld.map), target_id) != nullptr) {
3460 actor_id, target_id, 0, "");
3461 }
3462}
3463
3464/***********************************************************************/
3467static void paradrop_enter(QVariant data1, QVariant data2)
3468{
3469 int actor_id = data1.toInt();
3470 int target_id = data2.toInt();
3471
3472 if (game_unit_by_number(actor_id) != nullptr
3473 && index_to_tile(&(wld.map), target_id) != nullptr) {
3475 actor_id, target_id, 0, "");
3476 }
3477}
3478
3479/***********************************************************************/
3482static void teleport_enter(QVariant data1, QVariant data2)
3483{
3484 int actor_id = data1.toInt();
3485 int target_id = data2.toInt();
3486
3487 if (game_unit_by_number(actor_id) != nullptr
3488 && index_to_tile(&(wld.map), target_id) != nullptr) {
3490 actor_id, target_id, 0, "");
3491 }
3492}
3493
3494/***********************************************************************/
3498{
3499 int actor_id = data1.toInt();
3500 int target_id = data2.toInt();
3501
3502 if (game_unit_by_number(actor_id) != nullptr
3503 && index_to_tile(&(wld.map), target_id) != nullptr) {
3505 actor_id, target_id, 0, "");
3506 }
3507}
3508
3509/***********************************************************************/
3513{
3514 int actor_id = data1.toInt();
3515 int target_id = data2.toInt();
3516
3517 if (game_unit_by_number(actor_id) != nullptr
3518 && index_to_tile(&(wld.map), target_id) != nullptr) {
3520 actor_id, target_id, 0, "");
3521 }
3522}
3523
3524/***********************************************************************/
3527static void join_city(QVariant data1, QVariant data2)
3528{
3529 int actor_id = data1.toInt();
3530 int target_id = data2.toInt();
3531
3532 if (game_unit_by_number(actor_id) != nullptr
3533 && game_city_by_number(target_id) != nullptr) {
3535 actor_id, target_id, 0, "");
3536 }
3537}
3538
3539/***********************************************************************/
3542static void spy_steal_shared(QVariant data1, QVariant data2,
3543 action_id act_id)
3544{
3545 QString str;
3546 QVariant qv1;
3548 int diplomat_id = data1.toInt();
3549 int diplomat_target_id = data2.toInt();
3552 struct player *pvictim = nullptr;
3555
3556 cd = gui()->get_diplo_dialog();
3557 if (cd != nullptr) {
3558 cd->close();
3559 }
3560
3561 if (pvcity == nullptr) {
3562 return;
3563 }
3564
3565 // Wait for the player's reply before moving on to the next queued diplomat.
3567
3569
3570 struct astring stra = ASTRING_INIT;
3571 cd = new choice_dialog(_("Steal"), _("Steal Technology"),
3572 gui()->game_tab_widget,
3574
3575 // Put both actor and target city in qv1 since qv2 is taken
3578 actor_and_target.append(act_id);
3579 qv1 = QVariant::fromValue(actor_and_target);
3580
3581 struct player *pplayer = client_player();
3582 const struct research *presearch = research_get(pplayer);
3583 const struct research *vresearch = research_get(pvictim);
3584
3591 // Defeat keyboard shortcut mnemonics
3593 .replace("&", "&&");
3594 cd->add_item(str, func, qv1, i);
3595 }
3597
3599 get_non_targeted_action_id(act_id)])) {
3600 astr_set(&stra, _("At %s's Discretion"),
3603 str = QString(astr_str(&stra)).replace("&", "&&");
3604 cd->add_item(str, func, qv1, A_UNSET);
3605 }
3606
3607 cd->set_layout();
3608 cd->show_me();
3609
3610 astr_free(&stra);
3611}
3612
3613/***********************************************************************/
3616static void spy_steal(QVariant data1, QVariant data2)
3617{
3619}
3620
3621/***********************************************************************/
3624static void spy_steal_esc(QVariant data1, QVariant data2)
3625{
3627}
3628
3629/***********************************************************************/
3632static void spy_steal_something(QVariant data1, QVariant data2)
3633{
3634 int diplomat_id = data1.toList().at(0).toInt();
3635 int diplomat_target_id = data1.toList().at(1).toInt();
3636 action_id act_id = data1.toList().at(2).toInt();
3637
3638 if (game_unit_by_number(diplomat_id) != nullptr
3639 && game_city_by_number(diplomat_target_id) != nullptr) {
3640 if (data2.toInt() == A_UNSET) {
3641 // This is the untargeted version.
3643 diplomat_id, diplomat_target_id, data2.toInt(), "");
3644 } else {
3645 // This is the targeted version.
3647 diplomat_target_id, data2.toInt(), "");
3648 }
3649 }
3650}
3651
3652/***********************************************************************/
3656{
3657 int actor_id = data1.toInt();
3658 int target_id = data2.toInt();
3659
3660 if (game_unit_by_number(actor_id) != nullptr
3661 && game_city_by_number(target_id) != nullptr) {
3662 // Wait for the server's reply before moving on to the next queued diplomat.
3664
3665 request_action_details(ACTION_STRIKE_BUILDING, actor_id, target_id);
3666 }
3667}
3668
3669/***********************************************************************/
3673{
3674 int diplomat_id = data1.toInt();
3675 int diplomat_target_id = data2.toInt();
3676
3677 if (game_unit_by_number(diplomat_id) != nullptr
3678 && game_city_by_number(diplomat_target_id) != nullptr) {
3679 // Wait for the server's reply before moving on to the next queued diplomat.
3681
3684 }
3685}
3686
3687/***********************************************************************/
3691{
3692 int diplomat_id = data1.toInt();
3693 int diplomat_target_id = data2.toInt();
3694
3695 if (game_unit_by_number(diplomat_id) != nullptr
3696 && game_city_by_number(diplomat_target_id) != nullptr) {
3697 /* Wait for the server's reply before moving on to the next queued
3698 * diplomat. */
3700
3703 }
3704}
3705
3706/***********************************************************************/
3709static void spy_poison(QVariant data1, QVariant data2)
3710{
3711 int diplomat_id = data1.toInt();
3712 int diplomat_target_id = data2.toInt();
3713
3714 if (game_unit_by_number(diplomat_id) != nullptr
3715 && game_city_by_number(diplomat_target_id) != nullptr) {
3718 }
3719}
3720
3721/***********************************************************************/
3724static void spy_poison_esc(QVariant data1, QVariant data2)
3725{
3726 int diplomat_id = data1.toInt();
3727 int diplomat_target_id = data2.toInt();
3728
3729 if (game_unit_by_number(diplomat_id) != nullptr
3730 && game_city_by_number(diplomat_target_id) != nullptr) {
3733 }
3734}
3735
3736/***********************************************************************/
3739static void spy_spread_plague(QVariant data1, QVariant data2)
3740{
3741 int diplomat_id = data1.toInt();
3742 int diplomat_target_id = data2.toInt();
3743
3744 if (game_unit_by_number(diplomat_id) != nullptr
3745 && game_city_by_number(diplomat_target_id) != nullptr) {
3748 }
3749}
3750
3751/***********************************************************************/
3754static void spy_nuke_city(QVariant data1, QVariant data2)
3755{
3756 int diplomat_id = data1.toInt();
3757 int diplomat_target_id = data2.toInt();
3758
3759 if (game_unit_by_number(diplomat_id) != nullptr
3760 && game_city_by_number(diplomat_target_id) != nullptr) {
3763 }
3764}
3765
3766/***********************************************************************/
3769static void spy_nuke_city_esc(QVariant data1, QVariant data2)
3770{
3771 int diplomat_id = data1.toInt();
3772 int diplomat_target_id = data2.toInt();
3773
3774 if (game_unit_by_number(diplomat_id) != nullptr
3775 && game_city_by_number(diplomat_target_id) != nullptr) {
3778 }
3779}
3780
3781/***********************************************************************/
3784static void nuke_city(QVariant data1, QVariant data2)
3785{
3786 int actor_id = data1.toInt();
3787 int target_id = data2.toInt();
3788
3789 if (game_unit_by_number(actor_id) != nullptr
3790 && game_city_by_number(target_id) != nullptr) {
3792 actor_id, target_id, 0, "");
3793 }
3794}
3795
3796/***********************************************************************/
3799static void destroy_city(QVariant data1, QVariant data2)
3800{
3801 int diplomat_id = data1.toInt();
3802 int diplomat_target_id = data2.toInt();
3803
3804 if (game_unit_by_number(diplomat_id) != nullptr
3805 && game_city_by_number(diplomat_target_id) != nullptr) {
3808 }
3809}
3810
3811/***********************************************************************/
3814static void spy_steal_gold(QVariant data1, QVariant data2)
3815{
3816 int diplomat_id = data1.toInt();
3817 int diplomat_target_id = data2.toInt();
3818
3819 if (game_unit_by_number(diplomat_id) != nullptr
3820 && game_city_by_number(diplomat_target_id) != nullptr) {
3823 }
3824}
3825
3826/***********************************************************************/
3829static void spy_steal_gold_esc(QVariant data1, QVariant data2)
3830{
3831 int diplomat_id = data1.toInt();
3832 int diplomat_target_id = data2.toInt();
3833
3834 if (game_unit_by_number(diplomat_id) != nullptr
3835 && game_city_by_number(diplomat_target_id) != nullptr) {
3838 }
3839}
3840
3841/***********************************************************************/
3844static void spy_steal_maps(QVariant data1, QVariant data2)
3845{
3846 int diplomat_id = data1.toInt();
3847 int diplomat_target_id = data2.toInt();
3848
3849 if (game_unit_by_number(diplomat_id) != nullptr
3850 && game_city_by_number(diplomat_target_id) != nullptr) {
3853 }
3854}
3855
3856/***********************************************************************/
3859static void spy_steal_maps_esc(QVariant data1, QVariant data2)
3860{
3861 int diplomat_id = data1.toInt();
3862 int diplomat_target_id = data2.toInt();
3863
3864 if (game_unit_by_number(diplomat_id) != nullptr
3865 && game_city_by_number(diplomat_target_id) != nullptr) {
3868 }
3869}
3870
3871/***********************************************************************/
3874static void spy_escape(QVariant data1, QVariant data2)
3875{
3876 int diplomat_id = data1.toInt();
3877 int diplomat_target_id = data2.toInt();
3878
3879 if (game_unit_by_number(diplomat_id) != nullptr
3880 && game_city_by_number(diplomat_target_id) != nullptr) {
3883 }
3884}
3885
3886/***********************************************************************/
3889static void spy_embassy(QVariant data1, QVariant data2)
3890{
3891 int diplomat_id = data1.toInt();
3892 int diplomat_target_id = data2.toInt();
3893
3894 if (game_unit_by_number(diplomat_id) != nullptr
3895 && game_city_by_number(diplomat_target_id) != nullptr) {
3897 diplomat_target_id, 0, "");
3898 }
3899}
3900
3901/***********************************************************************/
3904static void diplomat_embassy(QVariant data1, QVariant data2)
3905{
3906 int diplomat_id = data1.toInt();
3907 int diplomat_target_id = data2.toInt();
3908
3909 if (game_unit_by_number(diplomat_id) != nullptr
3910 && game_city_by_number(diplomat_target_id) != nullptr) {
3912 diplomat_target_id, 0, "");
3913 }
3914}
3915
3916/***********************************************************************/
3919static void spy_investigate(QVariant data1, QVariant data2)
3920{
3921 int diplomat_id = data1.toInt();
3922 int diplomat_target_id = data2.toInt();
3923
3925 && game_unit_by_number(diplomat_id) != nullptr) {
3927 diplomat_target_id, 0, "");
3928 }
3929}
3930
3931/***********************************************************************/
3934static void diplomat_investigate(QVariant data1, QVariant data2)
3935{
3936 int diplomat_id = data1.toInt();
3937 int diplomat_target_id = data2.toInt();
3938
3940 && game_unit_by_number(diplomat_id) != nullptr) {
3942 diplomat_target_id, 0, "");
3943 }
3944}
3945
3946/***********************************************************************/
3949static void diplomat_sabotage(QVariant data1, QVariant data2)
3950{
3951 int diplomat_id = data1.toInt();
3952 int diplomat_target_id = data2.toInt();
3953
3954 if (game_unit_by_number(diplomat_id) != nullptr
3955 && game_city_by_number(diplomat_target_id) != nullptr) {
3957 diplomat_target_id, B_LAST + 1, "");
3958 }
3959}
3960
3961/***********************************************************************/
3964static void diplomat_sabotage_esc(QVariant data1, QVariant data2)
3965{
3966 int diplomat_id = data1.toInt();
3967 int diplomat_target_id = data2.toInt();
3968
3969 if (game_unit_by_number(diplomat_id) != nullptr
3970 && game_city_by_number(diplomat_target_id) != nullptr) {
3972 diplomat_target_id, B_LAST + 1, "");
3973 }
3974}
3975
3976/***********************************************************************/
3979static void diplomat_steal(QVariant data1, QVariant data2)
3980{
3981 int diplomat_id = data1.toInt();
3982 int diplomat_target_id = data2.toInt();
3983
3984 if (game_unit_by_number(diplomat_id) != nullptr
3985 && game_city_by_number(diplomat_target_id) != nullptr) {
3988 }
3989}
3990
3991/***********************************************************************/
3994static void diplomat_steal_esc(QVariant data1, QVariant data2)
3995{
3996 int diplomat_id = data1.toInt();
3997 int diplomat_target_id = data2.toInt();
3998
3999 if (game_unit_by_number(diplomat_id) != nullptr
4000 && game_city_by_number(diplomat_target_id) != nullptr) {
4003 }
4004}
4005
4006/***********************************************************************/
4009static void diplomat_incite(QVariant data1, QVariant data2)
4010{
4011 int diplomat_id = data1.toInt();
4012 int diplomat_target_id = data2.toInt();
4013
4014 if (game_unit_by_number(diplomat_id) != nullptr
4015 && game_city_by_number(diplomat_target_id) != nullptr) {
4016 // Wait for the server's reply before moving on to the next queued diplomat.
4018
4021 }
4022}
4023
4024/***********************************************************************/
4028{
4029 int diplomat_id = data1.toInt();
4030 int diplomat_target_id = data2.toInt();
4031
4032 if (game_unit_by_number(diplomat_id) != nullptr
4033 && game_city_by_number(diplomat_target_id) != nullptr) {
4034 // Wait for the server's reply before moving on to the next queued diplomat.
4036
4039 }
4040}
4041
4042/***********************************************************************/
4045static void regular_move(QVariant data1, QVariant data2)
4046{
4047 int actor_id = data1.toInt();
4048 int target_id = data2.toInt();
4049
4050 if (game_unit_by_number(actor_id) != nullptr
4051 && index_to_tile(&(wld.map), target_id) != nullptr) {
4053 actor_id, target_id, 0, "");
4054 }
4055}
4056
4057/***********************************************************************/
4060static void regular_move2(QVariant data1, QVariant data2)
4061{
4062 int actor_id = data1.toInt();
4063 int target_id = data2.toInt();
4064
4065 if (game_unit_by_number(actor_id) != nullptr
4066 && index_to_tile(&(wld.map), target_id) != nullptr) {
4068 actor_id, target_id, 0, "");
4069 }
4070}
4071
4072/***********************************************************************/
4075static void regular_move3(QVariant data1, QVariant data2)
4076{
4077 int actor_id = data1.toInt();
4078 int target_id = data2.toInt();
4079
4080 if (game_unit_by_number(actor_id) != nullptr
4081 && index_to_tile(&(wld.map), target_id) != nullptr) {
4083 actor_id, target_id, 0, "");
4084 }
4085}
4086
4087/***********************************************************************/
4091void popup_incite_dialog(struct unit *actor, struct city *tcity, int cost,
4092 const struct action *paction)
4093{
4094 char buf[1024];
4095 char buf2[1024];
4096 int diplomat_id = actor->id;
4097 int diplomat_target_id = tcity->id;
4098 const int act_id = paction->id;
4099
4100 // Should be set before sending request to the server.
4102
4103 fc_snprintf(buf, ARRAY_SIZE(buf), PL_("Treasury contains %d gold.",
4104 "Treasury contains %d gold.",
4105 client_player()->economic.gold),
4106 client_player()->economic.gold);
4107
4109 hud_message_box *impossible = new hud_message_box(gui()->central_wdg);
4110
4112 _("You can't incite a revolt in %s."), city_name_get(tcity));
4113 impossible->set_text_title(buf2, "!");
4114 impossible->setStandardButtons(QMessageBox::Ok);
4115 impossible->setAttribute(Qt::WA_DeleteOnClose);
4116 impossible->show();
4117 } else if (cost <= client_player()->economic.gold) {
4118 hud_message_box *ask = new hud_message_box(gui()->central_wdg);
4119
4121 PL_("Incite a revolt for %d gold?\n%s",
4122 "Incite a revolt for %d gold?\n%s", cost), cost, buf);
4123 ask->setStandardButtons(QMessageBox::Cancel | QMessageBox::Ok);
4124 ask->setDefaultButton(QMessageBox::Cancel);
4125 ask->set_text_title(buf2, _("Incite a Revolt!"));
4126 ask->setAttribute(Qt::WA_DeleteOnClose);
4127 QObject::connect(ask, &hud_message_box::accepted, [=]() {
4130 });
4131 ask->show();
4132 return;
4133 } else {
4134 hud_message_box *too_much = new hud_message_box(gui()->central_wdg);
4135
4137 PL_("Inciting a revolt costs %d gold.\n%s",
4138 "Inciting a revolt costs %d gold.\n%s", cost), cost,
4139 buf);
4140 too_much->set_text_title(buf2, "!");
4141 too_much->setStandardButtons(QMessageBox::Ok);
4142 too_much->setAttribute(Qt::WA_DeleteOnClose);
4143 too_much->show();
4144 }
4145
4147}
4148
4149/***********************************************************************/
4153void popup_bribe_unit_dialog(struct unit *actor, struct unit *tunit, int cost,
4154 const struct action *paction)
4155{
4156 hud_message_box *ask = new hud_message_box(gui()->central_wdg);
4157 char buf[1024];
4158 char buf2[1024];
4159 int diplomat_id = actor->id;
4160 int diplomat_target_id = tunit->id;
4161 const int act_id = paction->id;
4162
4163 // Should be set before sending request to the server.
4165
4166 fc_snprintf(buf, ARRAY_SIZE(buf), PL_("Treasury contains %d gold.",
4167 "Treasury contains %d gold.",
4168 client_player()->economic.gold),
4169 client_player()->economic.gold);
4170
4171 if (cost <= client_player()->economic.gold) {
4172 fc_snprintf(buf2, ARRAY_SIZE(buf2), PL_("Bribe unit for %d gold?\n%s",
4173 "Bribe unit for %d gold?\n%s",
4174 cost), cost, buf);
4175 ask->set_text_title(buf2, _("Bribe Enemy Unit"));
4176 ask->setStandardButtons(QMessageBox::Cancel | QMessageBox::Ok);
4177 ask->setDefaultButton(QMessageBox::Cancel);
4178 ask->setAttribute(Qt::WA_DeleteOnClose);
4179 QObject::connect(ask, &hud_message_box::accepted, [=]() {
4182 });
4183 ask->show();
4184 return;
4185 } else {
4187 PL_("Bribing the unit costs %d gold.\n%s",
4188 "Bribing the unit costs %d gold.\n%s", cost), cost, buf);
4189 ask->set_text_title(buf2, _("Traitors Demand Too Much!"));
4190 ask->setAttribute(Qt::WA_DeleteOnClose);
4191 ask->show();
4192 }
4193
4195}
4196
4197/***********************************************************************/
4202 const struct action *paction)
4203{
4204 hud_message_box *ask = new hud_message_box(gui()->central_wdg);
4205 char buf[1024];
4206 char buf2[1024];
4207 int diplomat_id = actor->id;
4208 int diplomat_target_id = ttile->index;
4209 const int act_id = paction->id;
4210
4211 // Should be set before sending request to the server.
4213
4214 fc_snprintf(buf, ARRAY_SIZE(buf), PL_("Treasury contains %d gold.",
4215 "Treasury contains %d gold.",
4216 client_player()->economic.gold),
4217 client_player()->economic.gold);
4218
4219 if (cost <= client_player()->economic.gold) {
4220 fc_snprintf(buf2, ARRAY_SIZE(buf2), PL_("Bribe unit stack for %d gold?\n%s",
4221 "Bribe unit stack for %d gold?\n%s",
4222 cost), cost, buf);
4223 ask->set_text_title(buf2, _("Bribe Enemy Stack"));
4224 ask->setStandardButtons(QMessageBox::Cancel | QMessageBox::Ok);
4225 ask->setDefaultButton(QMessageBox::Cancel);
4226 ask->setAttribute(Qt::WA_DeleteOnClose);
4227 QObject::connect(ask, &hud_message_box::accepted, [=]() {
4230 });
4231 ask->show();
4232 return;
4233 } else {
4235 PL_("Bribing the unit stack costs %d gold.\n%s",
4236 "Bribing the unit stack costs %d gold.\n%s", cost), cost, buf);
4237 ask->set_text_title(buf2, _("Traitors Demand Too Much!"));
4238 ask->setAttribute(Qt::WA_DeleteOnClose);
4239 ask->show();
4240 }
4241
4243}
4244
4245/***********************************************************************/
4248static void pillage_something(QVariant data1, QVariant data2)
4249{
4250 int punit_id;
4251 int what;
4252 struct unit *punit;
4253 struct extra_type *target;
4254
4255 what = data1.toInt();
4256 punit_id = data2.toInt();
4258 if (punit) {
4259 target = extra_by_number(what);
4261 }
4263}
4264
4265/***********************************************************************/
4268static void spy_sabotage(QVariant data1, QVariant data2)
4269{
4270 int diplomat_id = data1.toList().at(0).toInt();
4271 int diplomat_target_id = data1.toList().at(1).toInt();
4272 action_id act_id = data1.toList().at(2).toInt();
4273
4274 if (game_unit_by_number(diplomat_id) != nullptr
4275 && game_city_by_number(diplomat_target_id) != nullptr) {
4276 if (data2.toInt() == B_LAST) {
4277 // This is the untargeted version.
4279 diplomat_id, diplomat_target_id, data2.toInt(),
4280 "");
4281 } else if (data2.toInt() == -1) {
4282 // This is the city production version.
4284 diplomat_id, diplomat_target_id, data2.toInt(),
4285 "");
4286 } else {
4287 // This is the targeted version.
4289 diplomat_target_id, data2.toInt(), "");
4290 }
4291 }
4292}
4293
4294/***********************************************************************/
4299 const struct action *paction)
4300{
4301 QString str;
4302 QVariant qv1, qv2;
4303 int diplomat_id = actor->id;
4304 int diplomat_target_id = tcity->id;
4307 int nr = 0;
4308 struct astring stra = ASTRING_INIT;
4310
4311 if (paction->result == ACTRES_STRIKE_BUILDING) {
4312 cd = new choice_dialog(_("Strike"),
4313 _("Select Improvement to Strike"),
4314 gui()->game_tab_widget,
4316 } else {
4317 cd = new choice_dialog(_("Sabotage"),
4318 _("Select Improvement to Sabotage"),
4319 gui()->game_tab_widget,
4321 }
4322
4323 // Should be set before sending request to the server.
4325
4326 // Put both actor, target city and action in qv1 since qv2 is taken
4329 actor_and_target.append(paction->id);
4330 qv1 = QVariant::fromValue(actor_and_target);
4331
4334 paction->id)])) {
4336 cd->add_item(QString(_("City Production")), func, qv1, -1);
4337 }
4338
4339 city_built_iterate(tcity, pimprove) {
4340 if (pimprove->sabotage > 0) {
4342 // Defeat keyboard shortcut mnemonics
4344 .replace("&", "&&");
4345 qv2 = nr;
4346 cd->add_item(str, func, qv1, improvement_number(pimprove));
4347 nr++;
4348 }
4350
4353 astr_set(&stra, _("At %s's Discretion"),
4356 str = QString(astr_str(&stra)).replace("&", "&&");
4357 cd->add_item(str, func, qv1, B_LAST);
4358 }
4359
4360 cd->set_layout();
4361 cd->show_me();
4362 astr_free(&stra);
4363}
4364
4365/***********************************************************************/
4370{
4371 QString str;
4372 QVariant qv1, qv2;
4375 struct extra_type *tgt;
4376
4378 return;
4379 }
4380 cd = new choice_dialog(_("What To Pillage"), _("Select what to pillage:"),
4381 gui()->game_tab_widget);
4382 qv2 = punit->id;
4383 while ((tgt = get_preferred_pillage(extras))) {
4384 int what;
4385
4386 what = extra_index(tgt);
4387 BV_CLR(extras, what);
4388
4390 // Defeat keyboard shortcut mnemonics
4391 str = QString(extra_name_translation(tgt)).replace("&", "&&");
4392 qv1 = what;
4393 cd->add_item(str, func, qv1, qv2);
4394 }
4395 cd->set_layout();
4396 cd->show_me();
4397}
4398
4399/***********************************************************************/
4403 QWidget *parent) : hud_message_box(parent)
4404{
4405 QString str;
4406 QPushButton *pb;
4407
4408 setAttribute(Qt::WA_DeleteOnClose);
4409 setModal(false);
4414
4415 str = QString(PL_("Are you sure you want to disband that %1 unit?",
4416 "Are you sure you want to disband those %1 units?",
4418 pb = addButton(_("Yes"), QMessageBox::AcceptRole);
4419 addButton(_("No"), QMessageBox::RejectRole);
4420 set_text_title(str, _("Disband units"));
4422 connect(pb, &QAbstractButton::clicked, this, &disband_box::disband_clicked);
4423}
4424
4425/***********************************************************************/
4436
4437/***********************************************************************/
4444
4445/***********************************************************************/
4448void popup_disband_dialog(struct unit_list *punits)
4449{
4450 disband_box *ask = new disband_box(punits, gui()->central_wdg);
4451 ask->show();
4452}
4453
4454/***********************************************************************/
4459{
4460 hud_message_box *ask = new hud_message_box(gui()->central_wdg);
4461 QString text;
4462 QString title;
4463
4464 title = QString(_("Modpack suggests using %1 tileset."))
4466 text = QString("It might not work with other tilesets.\n"
4467 "You are currently using tileset %1.")
4469 ask->addButton(_("Keep current tileset"), QMessageBox::RejectRole);
4470 ask->addButton(_("Load tileset"), QMessageBox::AcceptRole);
4471 ask->set_text_title(text, title);
4472 ask->setAttribute(Qt::WA_DeleteOnClose);
4473
4474 QObject::connect(ask, &hud_message_box::accepted, [=]() {
4477 gui()->map_scale)) {
4479 _("Can't load requested tileset."));
4480 }
4481 });
4482 ask->show();
4483}
4484
4485/***********************************************************************/
4490{
4491 hud_message_box *ask = new hud_message_box(gui()->central_wdg);
4492 QString text;
4493 QString title;
4494
4495 title = QString(_("Modpack suggests using %1 soundset."))
4497 text = QString("It might not work with other tilesets.\n"
4498 "You are currently using soundset %1.")
4499 .arg(sound_set_name);
4500 ask->addButton(_("Keep current soundset"), QMessageBox::RejectRole);
4501 ask->addButton(_("Load soundset"), QMessageBox::AcceptRole);
4502 ask->set_text_title(text, title);
4503 ask->setAttribute(Qt::WA_DeleteOnClose);
4504 QObject::connect(ask, &hud_message_box::accepted, [=]() {
4506 });
4507 ask->show();
4508}
4509
4510/***********************************************************************/
4515{
4516 hud_message_box *ask = new hud_message_box(gui()->central_wdg);
4517 QString text;
4518 QString title;
4519
4520 title = QString(_("Modpack suggests using %1 musicset."))
4522 text = QString("It might not work with other tilesets.\n"
4523 "You are currently using musicset %1.")
4524 .arg(music_set_name);
4525 ask->addButton(_("Keep current musicset"), QMessageBox::RejectRole);
4526 ask->addButton(_("Load musicset"), QMessageBox::AcceptRole);
4527 ask->set_text_title(text, title);
4528 ask->setAttribute(Qt::WA_DeleteOnClose);
4529 QObject::connect(ask, &hud_message_box::accepted, [=]() {
4531 });
4532 ask->show();
4533}
4534
4535/***********************************************************************/
4540{
4541 // PORTME
4542 return false;
4543}
4544
4545/***********************************************************************/
4549{
4551 int i;
4552
4553 nd_list = gui()->mapview_wdg->findChildren<notify_dialog *>();
4554 for (i = 0; i < nd_list.count(); i++) {
4555 nd_list[i]->restart();
4556 delete nd_list[i];
4557 }
4558}
4559
4560/***********************************************************************/
4565{
4566 int i;
4569 goto_dialog *gtd;
4570
4571 QApplication::alert(gui()->central_wdg);
4572 cd_list = gui()->game_tab_widget->findChildren <choice_dialog *>();
4573 for (i = 0; i < cd_list.count(); i++) {
4574 cd_list[i]->close();
4575 }
4576 nd_list = gui()->game_tab_widget->findChildren <notify_dialog *>();
4577 for (i = 0; i < nd_list.count(); i++) {
4578 nd_list[i]->close();
4579 }
4580
4589 gui()->popdown_unit_sel();
4590
4591 gtd = gui()->gtd;
4592
4593 if (gtd != nullptr) {
4594 gtd->close_dlg();
4595 }
4596}
4597
4598/***********************************************************************/
4604{
4605 choice_dialog *cd = gui()->get_diplo_dialog();
4606
4607 if (cd != nullptr) {
4608 return cd->unit_id;
4609 } else {
4610 return IDENTITY_NUMBER_ZERO;
4611 }
4612}
4613
4614/***********************************************************************/
4621{
4622 choice_dialog *cd = gui()->get_diplo_dialog();
4623
4624 if (cd != nullptr) {
4625 return cd->target_id[ATK_CITY];
4626 } else {
4627 return IDENTITY_NUMBER_ZERO;
4628 }
4629}
4630
4631/***********************************************************************/
4638{
4639 choice_dialog *cd = gui()->get_diplo_dialog();
4640
4641 if (cd != nullptr) {
4642 return cd->target_id[ATK_TILE];
4643 } else {
4644 return TILE_INDEX_NONE;
4645 }
4646}
4647
4648/**********************************************************************/
4655{
4656 choice_dialog *cd = gui()->get_diplo_dialog();
4657
4658 if (cd != nullptr) {
4659 return cd->sub_target_id[ASTK_EXTRA];
4660 } else {
4661 return EXTRA_NONE;
4662 }
4663}
4664
4665/***********************************************************************/
4672{
4673 choice_dialog *cd = gui()->get_diplo_dialog();
4674
4675 if (cd != nullptr) {
4676 return cd->target_id[ATK_UNIT];
4677 } else {
4678 return IDENTITY_NUMBER_ZERO;
4679 }
4680}
4681
4682/***********************************************************************/
4686 struct city *target_city,
4687 struct unit *target_unit,
4688 struct tile *target_tile,
4689 struct extra_type *target_extra,
4690 const struct act_prob *act_probs)
4691{
4694 Choice_dialog_button *cancel_button;
4695 QVariant qv1, qv2;
4696
4697 asd = gui()->get_diplo_dialog();
4698 if (asd == nullptr) {
4699 fc_assert_msg(asd != nullptr,
4700 "The action selection dialog should have been open");
4701 return;
4702 }
4703
4706 "The action selection dialog is for another actor unit.");
4707 }
4708
4709 // Put the actor id in qv1.
4710 qv1 = actor_unit->id;
4711
4712 cancel_button = asd->get_identified_button(BUTTON_CANCEL);
4713 if (cancel_button != nullptr) {
4714 /* Temporary remove the Cancel button so it won't end up above
4715 * any added buttons. */
4716 asd->stack_button(cancel_button);
4717 }
4718
4719 wait_button = asd->get_identified_button(BUTTON_WAIT);
4720 if (wait_button != nullptr) {
4721 /* Temporary remove the Wait button so it won't end up above
4722 * any added buttons. */
4723 asd->stack_button(wait_button);
4724 }
4725
4726 action_iterate(act) {
4727 const char *custom;
4728
4729 if (action_id_get_actor_kind(act) != AAK_UNIT) {
4730 // Not relevant.
4731 continue;
4732 }
4733
4735 act_probs[act],
4736 actor_unit,
4737 target_city);
4738
4739 // Put the target id in qv2.
4740 switch (action_id_get_target_kind(act)) {
4741 case ATK_UNIT:
4742 if (target_unit != nullptr) {
4743 qv2 = target_unit->id;
4744 } else {
4746 || target_unit != nullptr,
4747 "Action enabled against non existing unit!");
4748
4750 }
4751 break;
4752 case ATK_CITY:
4753 if (target_city != nullptr) {
4754 qv2 = target_city->id;
4755 } else {
4757 || target_city != nullptr,
4758 "Action enabled against non existing city!");
4759
4761 }
4762 break;
4763 case ATK_TILE:
4764 case ATK_EXTRAS:
4765 case ATK_STACK:
4766 if (target_tile != nullptr) {
4768 } else {
4770 || target_tile != nullptr,
4771 "Action enabled against all units on "
4772 "non existing tile!");
4773
4775 }
4776 break;
4777 case ATK_SELF:
4778 qv2 = actor_unit->id;
4779 break;
4780 case ATK_COUNT:
4782 "Bad target kind");
4783 continue;
4784 }
4785
4786 if (asd->get_identified_button(act)) {
4787 // Update the existing button.
4788 action_entry_update(asd->get_identified_button(act),
4789 act, act_probs, custom,
4790 qv1, qv2);
4791 } else {
4792 // Add the button (unless its probability is 0).
4794 qv1, qv2);
4795 }
4797
4798 if (wait_button != nullptr || cancel_button != nullptr) {
4799 /* Reinsert the non action buttons below any potential
4800 * buttons recently added. */
4801 asd->unstack_all_buttons();
4802 }
4803}
4804
4805/***********************************************************************/
4809{
4811
4812 cd = gui()->get_diplo_dialog();
4813 if (cd != nullptr) {
4814 did_not_decide = true;
4815 cd->close();
4816 }
4817}
4818
4819/***********************************************************************/
4825
4826/***********************************************************************/
4829void show_tileset_error(bool fatal, const char *tset_name, const char *msg)
4830{
4831 QWidget *parent;
4832 fc_client *std_gui = gui();
4833
4834 if (std_gui != nullptr) {
4835 parent = std_gui->central_wdg;
4836 } else {
4837 parent = nullptr;
4838 }
4839
4840 if (std_gui != nullptr || fatal) {
4841 char buf[1024];
4842 QMessageBox *ask = new QMessageBox(parent);
4843
4844 if (tset_name != nullptr) {
4845 fc_snprintf(buf, sizeof(buf),
4846 _("Tileset \"%s\" problem, it's probably incompatible with "
4847 "the ruleset:\n%s"), tset_name, msg);
4848 } else {
4849 fc_snprintf(buf, sizeof(buf),
4850 _("Tileset problem, it's probably incompatible with "
4851 "the ruleset:\n%s"), msg);
4852 }
4853
4854 ask->setText(buf);
4855 ask->setStandardButtons(QMessageBox::Ok);
4856 ask->setWindowTitle(_("Tileset error"));
4857
4858 if (std_gui != nullptr && !fatal) {
4859 ask->setAttribute(Qt::WA_DeleteOnClose);
4860 ask->show();
4861 } else {
4862 ask->exec();
4863 }
4864 }
4865}
4866
4867/***********************************************************************/
4870void popup_upgrade_dialog(struct unit_list *punits)
4871{
4872 char buf[512];
4874 QString title;
4876
4877 if (!punits || unit_list_size(punits) == 0) {
4878 return;
4879 }
4880
4881 ask = new hud_message_box(gui()->central_wdg);
4882
4883 punit_ids = new QVector<int>();
4885 punit_ids->push_back(punit->id);
4887
4888 if (!get_units_upgrade_info(buf, sizeof(buf), punits)) {
4889 title = _("Upgrade Unit!");
4890 ask->setStandardButtons(QMessageBox::Ok);
4891 } else {
4892 title = _("Upgrade Obsolete Units");
4893 ask->setStandardButtons(QMessageBox::Cancel | QMessageBox::Ok);
4894 ask->setDefaultButton(QMessageBox::Cancel);
4895 }
4896 ask->set_text_title(buf, title);
4897 ask->setAttribute(Qt::WA_DeleteOnClose);
4898 QObject::connect(ask, &hud_message_box::accepted, [=]() {
4899 std::unique_ptr<QVector<int>> uptr(punit_ids);
4900 struct unit *punit;
4901
4902 for (int id : *uptr) {
4904 if (punit) {
4906 }
4907 }
4908 });
4909 ask->show();
4910}
4911
4912/***********************************************************************/
4916{
4917 QPoint p, final_p;
4918
4920 utile = ptile;
4921 pix = nullptr;
4922 show_line = 0;
4923 highlight_num = -1;
4924 ufont.setItalic(true);
4926 update_units();
4927 h_pix = nullptr;
4928 create_pixmap();
4929 p = mapFromGlobal(QCursor::pos());
4930 cw = new close_widget(this);
4931 setMouseTracking(true);
4932 final_p.setX(p.x());
4933 final_p.setY(p.y());
4934 if (p.x() + width() > parentWidget()->width()) {
4935 final_p.setX(parentWidget()->width() - width());
4936 }
4937 if (p.y() - height() < 0) {
4938 final_p.setY(height());
4939 }
4940 move(final_p.x(), final_p.y() - height());
4941 setFocus();
4942 /* Build fails with qt5 connect style for static functions
4943 * Qt5.2 so dont update */
4944 QTimer::singleShot(10, this, SLOT(update_img()));
4945}
4946
4947/***********************************************************************/
4951{
4952 delete h_pix;
4953 delete pix;
4954 delete cw;
4955}
4956
4957/***********************************************************************/
4961{
4962 int a;
4963 int x, y, i;
4966 QImage img;
4968 QPainter p;
4969 QPen pen;
4970 QPixmap pixc;
4971 QPixmap *pixp;
4973 QRect crop;
4974 struct canvas *unit_pixmap;
4975 struct unit *punit;
4976 float isosize;
4977
4978 if (pix != nullptr) {
4979 delete pix;
4980 pix = nullptr;
4981 };
4982 isosize = 0.7;
4984 isosize = 0.5;
4985 }
4986
4987 update_units();
4988 if (unit_list.count() > 0) {
4992 } else {
4995 }
4996 more = false;
4997 if (h_pix != nullptr) {
4998 delete h_pix;
4999 }
5000 h_pix = new QPixmap(item_size.width(), item_size.height());
5001 h_pix->fill(palette().color(QPalette::HighlightedText));
5002 if (unit_count < 5) {
5003 row_count = 1;
5004 pix = new QPixmap((unit_list.size()) * item_size.width(),
5005 item_size.height());
5006 } else if (unit_count < 9) {
5007 row_count = 2;
5008 pix = new QPixmap(4 * item_size.width(), 2 * item_size.height());
5009 } else {
5010 row_count = 3;
5011 if (unit_count > 12) {
5012 more = true;
5013 }
5014 pix = new QPixmap(4 * item_size.width(), 3 * item_size.height());
5015 }
5016 pix->fill(Qt::transparent);
5017 foreach(punit, unit_list) {
5020 unit_pixmap->map_pixmap.fill(Qt::transparent);
5021 put_unit(punit, unit_pixmap, 1.0, 0, 0);
5022 img = unit_pixmap->map_pixmap.toImage();
5024 cropped_img = img.copy(crop);
5028 Qt::KeepAspectRatio,
5029 Qt::SmoothTransformation);
5030 } else {
5033 Qt::KeepAspectRatio,
5034 Qt::SmoothTransformation);
5035 }
5036 pixc = QPixmap::fromImage(img);
5037 pixp = new QPixmap(pixc);
5038 pix_list.push_back(pixp);
5040 }
5041 a = qMin(item_size.width() / 4, 12);
5042 x = 0, y = -item_size.height(), i = -1;
5043 p.begin(pix);
5044 ufont.setPixelSize(a);
5045 p.setFont(ufont);
5046 pen.setColor(palette().color(QPalette::Text));
5047 p.setPen(pen);
5048
5049 while (!pix_list.isEmpty()) {
5050 tmp_pix = pix_list.takeFirst();
5051 i++;
5052 if (i % 4 == 0) {
5053 x = 0;
5054 y = y + item_size.height();
5055 }
5056 punit = unit_list.at(i);
5057 Q_ASSERT(punit != nullptr);
5058
5059 if (i == highlight_num) {
5060 p.drawPixmap(x, y, *h_pix);
5061 p.drawPixmap(x, y, *tmp_pix);
5062 } else {
5063 p.drawPixmap(x, y, *tmp_pix);
5064 }
5065
5067 int rate, f;
5068 QString str;
5069
5071 f = ((punit->fuel) - 1);
5074 str = str + "(" + QString(move_points_text((rate * f)
5075 + punit->moves_left, false)) + ")";
5076 }
5077 // TRANS: MP = Movement points
5078 str = QString(_("MP:")) + str;
5079 p.drawText(x, y + item_size.height() - 4, str);
5080 }
5081
5082 x = x + item_size.width();
5083 delete tmp_pix;
5084 }
5085 p.end();
5086 setFixedWidth(pix->width() + 20);
5087 setFixedHeight(pix->height() + 2 * (fm.height() + 6));
5088 qDeleteAll(pix_list.begin(), pix_list.end());
5089 }
5090}
5091
5092/***********************************************************************/
5096{
5097 int a, b;
5098 int old_h;
5100 QPoint pos = event->pos();
5101 int x = pos.x();
5102 int y = pos.y();
5103
5105 highlight_num = -1;
5106 if (x > width() - 11
5107 || y > height() - fm.height() - 5
5108 || y < fm.height() + 3 || x < 11) {
5109 // Do nothing if mouse is on border, just skip next if
5110 } else if (row_count > 0) {
5111 a = (x - 10) / item_size.width();
5112 b = (y - fm.height() - 3) / item_size.height();
5113 highlight_num = b * 4 + a;
5114 }
5115 if (old_h != highlight_num) {
5116 create_pixmap();
5117 update();
5118 }
5119}
5120
5121/***********************************************************************/
5127{
5128 struct unit *punit;
5129 if (event->button() == Qt::RightButton) {
5130 was_destroyed = true;
5131 close();
5132 destroy();
5133 }
5134 if (event->button() == Qt::LeftButton && highlight_num != -1) {
5135 update_units();
5136 if (highlight_num >= unit_list.count()) {
5137 return;
5138 }
5141 was_destroyed = true;
5142 close();
5143 destroy();
5144 }
5145}
5146
5147/***********************************************************************/
5152{
5153 create_pixmap();
5154 update();
5155}
5156
5157/***********************************************************************/
5161{
5163 int h, i;
5164 int *f_size;
5165 QPen pen;
5166 QString str, str2;
5167 struct unit *punit;
5168 int point_size = info_font.pointSize();
5169 int pixel_size = info_font.pixelSize();
5170
5171 if (point_size < 0) {
5172 f_size = &pixel_size;
5173 } else {
5174 f_size = &point_size;
5175 }
5176 if (highlight_num != -1 && highlight_num < unit_list.count()) {
5177 struct astring addition = ASTRING_INIT;
5178
5181
5182 // TRANS: HP - hit points
5183 str2 = QString(_("%1 HP:%2/%3")).arg(QString(astr_str(&addition)),
5184 QString::number(punit->hp),
5185 QString::number(unit_type_get(punit)->hp));
5187 }
5188 str = QString(PL_("%1 unit", "%1 units",
5190 .arg(unit_list_size(utile->units));
5191 for (i = *f_size; i > 4; i--) {
5192 if (point_size < 0) {
5193 info_font.setPixelSize(i);
5194 } else {
5195 info_font.setPointSize(i);
5196 }
5198 if (10 + qfm.horizontalAdvance(str2) < width()) {
5199 break;
5200 }
5201 }
5202 h = fm.height();
5203 if (pix != nullptr) {
5204 painter->drawPixmap(10, h + 3, *pix);
5205 pen.setColor(palette().color(QPalette::Text));
5206 painter->setPen(pen);
5207 painter->setFont(info_font);
5208 painter->drawText(10, h, str);
5209 if (highlight_num != -1 && highlight_num < unit_list.count()) {
5210 painter->drawText(10, height() - 5, str2);
5211 }
5212 // Draw scroll
5213 if (more) {
5214 int maxl = ((unit_count - 1) / 4) + 1;
5215 float page_height = 3.0f / maxl;
5216 float page_start = (static_cast<float>(show_line)) / maxl;
5217 pen.setColor(palette().color(QPalette::HighlightedText));
5218 painter->setBrush(palette().color(QPalette::HighlightedText).darker());
5219 painter->setPen(palette().color(QPalette::HighlightedText).darker());
5220 painter->drawRect(pix->width() + 10, h, 8, h + pix->height());
5221 painter->setPen(pen);
5222 painter->drawRoundedRect(pix->width() + 10,
5223 h + page_start * pix->height(),
5224 8, h + page_height * pix->height(), 2, 2);
5225 }
5226 }
5227 if (point_size < 0) {
5228 info_font.setPixelSize(*f_size);
5229 } else {
5230 info_font.setPointSize(*f_size);
5231 }
5232 cw->put_to_corner();
5233}
5234
5235/***********************************************************************/
5239{
5241
5242 painter.begin(this);
5243 paint(&painter, event);
5244 painter.end();
5245}
5246
5247/***********************************************************************/
5252{
5253 was_destroyed = true;
5254 close();
5255 destroy();
5256}
5257
5258/***********************************************************************/
5262{
5263 int i = 1;
5264 struct unit_list *punit_list;
5265
5266 unit_count = 0;
5267 if (utile == nullptr) {
5268 struct unit *punit = head_of_units_in_focus();
5269 if (punit) {
5271 }
5272 }
5273 unit_list.clear();
5274 if (utile != nullptr) {
5276 if (punit_list != nullptr) {
5278 unit_count++;
5279 if (i > show_line * 4)
5280 unit_list.push_back(punit);
5281 i++;
5283 }
5284 }
5285 if (unit_list.count() == 0) {
5286 close();
5287 }
5288}
5289
5290/***********************************************************************/
5294{
5295 gui()->mapview_wdg->setFocus();
5296 QWidget::closeEvent(event);
5297}
5298
5299/***********************************************************************/
5303{
5304 int nr;
5305
5306 if (!more && utile == nullptr) {
5307 return;
5308 }
5309 nr = qCeil(static_cast<qreal>(unit_list_size(utile->units)) / 4) - 3;
5310 if (event->angleDelta().y() < 0) {
5311 show_line++;
5313 } else {
5314 show_line--;
5315 show_line = qMax(0, show_line);
5316 }
5317 update_units();
5318 create_pixmap();
5319 update();
5320 event->accept();
5321}
5322
5323/***********************************************************************/
5327{
5328 if (event->key() == Qt::Key_Escape) {
5329 was_destroyed = true;
5330 close();
5331 destroy();
5332 }
5333 QWidget::keyPressEvent(event);
5334}
5335
5336/***********************************************************************/
5343
5344/***********************************************************************/
5351
5352/***********************************************************************/
5357{
5358 // Just tell the client common code to handle this.
5359 return false;
5360}
5361
5362/***********************************************************************/
5365bool qtg_request_transport(struct unit *pcargo, struct tile *ptile)
5366{
5367 int tcount;
5369 struct unit_list *potential_transports = unit_list_new();
5370#ifndef FREECIV_NDEBUG
5372#endif
5373
5377 }
5379
5381
5382 if (tcount == 0) {
5383 fc_assert(best_transport == nullptr);
5385
5386 return false; // Unit was not handled here.
5387 } else if (tcount == 1) {
5388 // There's exactly one potential transport - use it automatically
5391
5393
5394 return true;
5395 }
5396
5397 hul = new hud_unit_loader(pcargo, ptile);
5398 hul->show_me();
5399 return true;
5400}
5401
5402/***********************************************************************/
5406void qtg_popup_combat_info(int attacker_unit_id, int defender_unit_id,
5407 int attacker_hp, int defender_hp,
5408 bool make_att_veteran, bool make_def_veteran)
5409{
5410 if (gui()->qt_settings.show_battle_log) {
5411 hud_unit_combat *huc = new hud_unit_combat(attacker_unit_id,
5412 defender_unit_id,
5413 attacker_hp, defender_hp,
5414 make_att_veteran,
5415 make_def_veteran,
5416 gui()->battlelog_wdg->scale,
5417 gui()->battlelog_wdg);
5418
5419 gui()->battlelog_wdg->add_combat_info(huc);
5420 gui()->battlelog_wdg->show();
5421 }
5422}
5423
5424/**********************************************************************/
5428 struct act_confirmation_data *data)
5429{
5430 hud_message_box *ask = new hud_message_box(gui()->central_wdg);
5431
5432 ask->setStandardButtons(QMessageBox::Cancel | QMessageBox::Ok);
5433 ask->setDefaultButton(QMessageBox::Cancel);
5434 ask->set_text_title(body, hdr);
5435 ask->setAttribute(Qt::WA_DeleteOnClose);
5436 QObject::connect(ask, &hud_message_box::accepted, [=]() {
5438 });
5439 QObject::connect(ask, &hud_message_box::rejected, [=]() {
5441 });
5442
5443 ask->show();
5444}
5445
5446/***********************************************************************/
5450 struct act_confirmation_data *data)
5451{
5453
5454 hdr = QString(_("Are you sure you want to do %1?")).
5456
5457 if (expl != nullptr) {
5459 }
5460
5462}
5463
5464/**********************************************************************/
5467void qtg_popup_image(const char *tag)
5468{
5469 struct sprite *spr = load_popup_sprite(tag);
5470
5471 if (spr != nullptr) {
5472 QDialog *win = new QDialog(gui());
5473 QVBoxLayout *layout = new QVBoxLayout(win);
5474 QPixmap *pm = new QPixmap(*spr->pm);
5475 QLabel *lbl = new QLabel;
5476 int width, height;
5477
5479 win->setFixedSize(width, height);
5480 lbl->setPixmap(*pm);
5481 layout->addWidget(lbl);
5482 win->setLayout(layout);
5483
5484 win->show();
5485
5487 } else {
5488 log_error(_("No image for tag \"%s\", requested by the server."), tag);
5489 }
5490}
const char * action_prepare_ui_name(action_id act_id, const char *mnemonic, const struct act_prob prob, const char *custom)
Definition actions.c:1312
const char * action_id_name_translation(action_id act_id)
Definition actions.c:1250
bool action_prob_possible(const struct act_prob probability)
Definition actions.c:5079
static struct action * action_by_number(action_id act_id)
Definition actions.h:400
#define action_iterate_end
Definition actions.h:218
#define action_id_get_actor_kind(act_id)
Definition actions.h:413
#define action_iterate(_act_)
Definition actions.h:214
#define action_id_get_target_kind(act_id)
Definition actions.h:417
#define ACTION_NONE
Definition actions.h:59
void astr_free(struct astring *astr)
Definition astring.c:148
void astr_set(struct astring *astr, const char *format,...)
Definition astring.c:251
#define str
Definition astring.c:76
static const char * astr_str(const struct astring *astr) fc__attribute((nonnull(1)))
Definition astring.h:93
#define ASTRING_INIT
Definition astring.h:44
void audio_restart(const char *soundset_name, const char *musicset_name)
Definition audio.c:376
#define BV_CLR(bv, bit)
Definition bitvector.h:94
QRect zealous_crop_rect(QImage &p)
Definition canvas.cpp:419
void qtg_canvas_free(struct canvas *store)
Definition canvas.cpp:48
struct canvas * qtg_canvas_create(int width, int height)
Definition canvas.cpp:36
struct canvas int int struct sprite int int int int height
Definition canvas_g.h:44
struct canvas int int struct sprite int int int width
Definition canvas_g.h:44
void output_window_append(const struct ft_color color, const char *featured_text)
const char * city_improvement_name_translation(const struct city *pcity, const struct impr_type *pimprove)
Definition city.c:663
const char * city_name_get(const struct city *pcity)
Definition city.c:1137
#define INCITE_IMPOSSIBLE_COST
Definition city.h:93
#define city_owner(_pcity_)
Definition city.h:560
#define city_built_iterate(_pcity, _p)
Definition city.h:831
#define city_built_iterate_end
Definition city.h:837
void qtg_real_city_dialog_popup(struct city *pcity)
Definition citydlg.cpp:3863
Choice_dialog_button(const QString title, pfcn_void func_in, QVariant data1_in, QVariant data2_in)
Definition dialogs.cpp:1385
void setData2(QVariant wariat)
Definition dialogs.cpp:1433
void setData1(QVariant wariat)
Definition dialogs.cpp:1425
pfcn_void getFunc()
Definition dialogs.cpp:1399
void stack_button(Choice_dialog_button *button)
Definition dialogs.cpp:1759
void prev_unit()
Definition dialogs.cpp:1676
QVBoxLayout * layout
Definition dialogs.h:263
struct unit * targeted_unit
Definition dialogs.h:286
void unstack_all_buttons()
Definition dialogs.cpp:1776
Choice_dialog_button * get_identified_button(const int id)
Definition dialogs.cpp:1588
QPushButton * target_unit_button
Definition dialogs.h:262
void set_layout()
Definition dialogs.cpp:1494
void update_dialog(const struct act_prob *act_probs)
Definition dialogs.cpp:1705
QList< Choice_dialog_button * > last_buttons_stack
Definition dialogs.h:266
void next_unit()
Definition dialogs.cpp:1636
QVBoxLayout * get_layout()
Definition dialogs.cpp:1580
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:1441
int target_id[ATK_COUNT]
Definition dialogs.h:284
void switch_target()
Definition dialogs.cpp:1723
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:1742
void add_item(QString title, pfcn_void func, QVariant data1, QVariant data2, QString tool_tip, const int button_id)
Definition dialogs.cpp:1536
void put_to_corner()
Definition mapview.cpp:502
void disband_clicked()
Definition dialogs.cpp:4428
disband_box(struct unit_list *punits, QWidget *parent=0)
Definition dialogs.cpp:4402
struct unit_list * cpunits
Definition dialogs.h:97
choice_dialog * opened_dialog
Definition fc_client.h:218
choice_dialog * get_diplo_dialog()
Definition dialogs.cpp:5347
void set_diplo_dialog(choice_dialog *widget)
Definition dialogs.cpp:5339
static fc_font * instance()
Definition fonts.cpp:41
QFont * get_font(QString name)
Definition fonts.cpp:63
QPixmap * get_pixmap(const QString &id)
static fc_icons * instance()
bool was_destroyed
Definition mapview.h:176
void close_dlg()
Definition gotodlg.cpp:511
int set_text_title(QString s1, QString s2, bool return_exec=false)
QString qheadline
Definition dialogs.h:193
void restart()
Definition dialogs.cpp:959
close_widget * cw
Definition dialogs.h:189
void mouseReleaseEvent(QMouseEvent *event)
Definition dialogs.cpp:1052
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:926
void calc_size(int &x, int &y)
Definition dialogs.cpp:987
void paintEvent(QPaintEvent *paint_event)
Definition dialogs.cpp:1006
QPoint cursor
Definition dialogs.h:196
void mouseMoveEvent(QMouseEvent *event)
Definition dialogs.cpp:1042
virtual void update_menu()
Definition dialogs.cpp:1060
void mousePressEvent(QMouseEvent *event)
Definition dialogs.cpp:1029
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:1161
QPushButton * goto_but
Definition dialogs.h:111
void inspect_city()
Definition dialogs.cpp:1204
struct tile * gtile
Definition dialogs.h:114
QPushButton * inspect_but
Definition dialogs.h:112
void goto_tile()
Definition dialogs.cpp:1195
action_id vs_unit
Definition dialogs.h:60
static qdef_act * action()
Definition dialogs.cpp:1089
action_id vs_city_get()
Definition dialogs.cpp:1127
static qdef_act * m_instance
Definition dialogs.h:58
static void drop()
Definition dialogs.cpp:1100
action_id vs_city
Definition dialogs.h:59
void vs_city_set(int i)
Definition dialogs.cpp:1111
void vs_unit_set(int i)
Definition dialogs.cpp:1119
action_id vs_unit_get()
Definition dialogs.cpp:1135
QPoint point
Definition dialogs.h:81
void paintEvent(QPaintEvent *event)
Definition dialogs.cpp:402
QPixmap close_pix
Definition dialogs.h:83
void reactivate()
Definition dialogs.cpp:394
void mouseMoveEvent(QMouseEvent *event)
Definition dialogs.cpp:443
int titlebar_height
Definition dialogs.h:80
void mousePressEvent(QMouseEvent *event)
Definition dialogs.cpp:453
void mouseReleaseEvent(QMouseEvent *event)
Definition dialogs.cpp:473
qfc_dialog(QWidget *parent)
Definition dialogs.cpp:382
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:1151
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:662
void style_selected(const QItemSelection &selected)
Definition dialogs.cpp:855
void nationset_changed(int index)
Definition dialogs.cpp:1216
int selected_nation
Definition dialogs.h:163
void ok_pressed()
Definition dialogs.cpp:888
void leader_selected(int index)
Definition dialogs.cpp:873
QPushButton * ok_button
Definition dialogs.h:142
QTextEdit * description
Definition dialogs.h:141
void set_index(int index)
Definition dialogs.cpp:745
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:712
QTableWidget * styles
Definition dialogs.h:140
void group_selected(const QItemSelection &selected)
Definition dialogs.cpp:728
struct player * tplayer
Definition dialogs.h:165
races_dialog(struct player *pplayer, QWidget *parent=0)
Definition dialogs.cpp:482
QRadioButton * is_female
Definition dialogs.h:139
QTableWidget * nation_tabs
Definition dialogs.h:132
QGridLayout * main_layout
Definition dialogs.h:131
void nation_selected(const QItemSelection &selected)
Definition dialogs.cpp:805
void cancel_pressed()
Definition dialogs.cpp:1143
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:5293
void update_img()
Definition dialogs.cpp:5151
int show_line
Definition dialogs.h:233
void mouseMoveEvent(QMouseEvent *event)
Definition dialogs.cpp:5095
void paint(QPainter *painter, QPaintEvent *event)
Definition dialogs.cpp:5160
void update_menu()
Definition dialogs.cpp:5251
int highlight_num
Definition dialogs.h:234
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:4915
void update_units()
Definition dialogs.cpp:5261
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:5238
void create_pixmap()
Definition dialogs.cpp:4960
void wheelEvent(QWheelEvent *event)
Definition dialogs.cpp:5302
void keyPressEvent(QKeyEvent *event)
Definition dialogs.cpp:5326
void mousePressEvent(QMouseEvent *event)
Definition dialogs.cpp:5126
close_widget * cw
Definition dialogs.h:213
char music_set_name[512]
bool client_is_global_observer(void)
struct civclient client
enum client_states client_state(void)
char sound_set_name[512]
#define client_player()
@ C_S_RUNNING
Definition client_main.h:47
void client_unit_init_act_prob_cache(struct unit *punit)
Definition climisc.c:1259
char * incite_cost
Definition comments.c:76
void action_selection_no_longer_in_progress(const int old_actor_id)
Definition control.c:1063
void request_unit_load(struct unit *pcargo, struct unit *ptrans, struct tile *ptile)
Definition control.c:2168
void unit_focus_set(struct unit *punit)
Definition control.c:518
void request_do_action(action_id action, int actor_id, int target_id, int sub_tgt, const char *name)
Definition control.c:1742
void request_unit_disband(struct unit *punit)
Definition control.c:2087
void request_action_details(action_id action, int actor_id, int target_id)
Definition control.c:1810
void request_new_unit_activity_targeted(struct unit *punit, enum unit_activity act, struct extra_type *tgt)
Definition control.c:1950
void action_confirmation(struct act_confirmation_data *data, bool confirm)
Definition control.c:1778
void action_decision_clear_want(const int old_actor_id)
Definition control.c:1092
void key_unit_wait(void)
Definition control.c:3554
struct unit * head_of_units_in_focus(void)
Definition control.c:410
void request_unit_upgrade(struct unit *punit)
Definition control.c:2118
void action_selection_next_in_focus(const int old_actor_id)
Definition control.c:1104
bool qtg_handmade_scenario_warning()
Definition dialogs.cpp:5356
static void attack(QVariant data1, QVariant data2)
Definition dialogs.cpp:3287
static void wipe_units(QVariant data1, QVariant data2)
Definition dialogs.cpp:2984
char forced_tileset_name[512]
static void bombard4(QVariant data1, QVariant data2)
Definition dialogs.cpp:3056
int action_selection_target_extra(void)
Definition dialogs.cpp:4654
static void suicide_attack2(QVariant data1, QVariant data2)
Definition dialogs.cpp:3332
static void destroy_city(QVariant data1, QVariant data2)
Definition dialogs.cpp:3799
static void spy_sabotage_unit(QVariant data1, QVariant data2)
Definition dialogs.cpp:2590
static void pillage(QVariant data1, QVariant data2)
Definition dialogs.cpp:3148
static void caravan_marketplace(QVariant data1, QVariant data2)
Definition dialogs.cpp:1790
static void clean(QVariant data1, QVariant data2)
Definition dialogs.cpp:3168
static void spy_steal_shared(QVariant data1, QVariant data2, action_id act_id)
Definition dialogs.cpp:3542
static void spy_sabotage(QVariant data1, QVariant data2)
Definition dialogs.cpp:4268
int action_selection_target_tile(void)
Definition dialogs.cpp:4637
static void teleport_enter(QVariant data1, QVariant data2)
Definition dialogs.cpp:3482
static void conquer_extras3(QVariant data1, QVariant data2)
Definition dialogs.cpp:1989
static void spy_investigate(QVariant data1, QVariant data2)
Definition dialogs.cpp:3919
static void act_sel_wait(QVariant data1, QVariant data2)
Definition dialogs.cpp:2017
static void nuke_units(QVariant data1, QVariant data2)
Definition dialogs.cpp:2948
int action_selection_actor_unit(void)
Definition dialogs.cpp:4603
static void capture_units(QVariant data1, QVariant data2)
Definition dialogs.cpp:2996
static void road(QVariant data1, QVariant data2)
Definition dialogs.cpp:3188
static bool is_race_dialog_open
Definition dialogs.cpp:215
static void transport_embark4(QVariant data1, QVariant data2)
Definition dialogs.cpp:2702
bool try_default_unit_action(QVariant q1, QVariant q2)
Definition dialogs.cpp:1601
static void fortify(QVariant data1, QVariant data2)
Definition dialogs.cpp:2515
static void teleport_frighten(QVariant data1, QVariant data2)
Definition dialogs.cpp:3422
static void transport_board(QVariant data1, QVariant data2)
Definition dialogs.cpp:2636
static void diplomat_bribe_unit(QVariant data1, QVariant data2)
Definition dialogs.cpp:2555
static void spy_sabotage_unit_esc(QVariant data1, QVariant data2)
Definition dialogs.cpp:2602
static void disband_unit(QVariant data1, QVariant data2)
Definition dialogs.cpp:2503
static void spy_steal_gold(QVariant data1, QVariant data2)
Definition dialogs.cpp:3814
void popdown_players_report()
Definition plrdlg.cpp:1197
static void conquer_city_shrink2(QVariant data1, QVariant data2)
Definition dialogs.cpp:1916
static void spy_escape(QVariant data1, QVariant data2)
Definition dialogs.cpp:3874
static void mine(QVariant data1, QVariant data2)
Definition dialogs.cpp:3230
void popup_musicset_suggestion_dialog(void)
Definition dialogs.cpp:4514
static void spy_steal_gold_esc(QVariant data1, QVariant data2)
Definition dialogs.cpp:3829
static void diplomat_embassy(QVariant data1, QVariant data2)
Definition dialogs.cpp:3904
void unit_select_dialog_popup(struct tile *ptile)
Definition dialogs.cpp:1301
void popup_upgrade_dialog(struct unit_list *punits)
Definition dialogs.cpp:4870
void update_nationset_combo()
Definition dialogs.cpp:1321
void action_selection_close(void)
Definition dialogs.cpp:4808
static void cultivate(QVariant data1, QVariant data2)
Definition dialogs.cpp:3118
static void paradrop_enter(QVariant data1, QVariant data2)
Definition dialogs.cpp:3467
void races_update_pickable(bool nationset_change)
Definition dialogs.cpp:1331
int action_selection_target_city(void)
Definition dialogs.cpp:4620
static void spy_steal_something(QVariant data1, QVariant data2)
Definition dialogs.cpp:3632
#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:1239
static void spy_poison(QVariant data1, QVariant data2)
Definition dialogs.cpp:3709
static void transport_board2(QVariant data1, QVariant data2)
Definition dialogs.cpp:2647
void show_tech_gained_dialog(Tech_type_id tech)
Definition dialogs.cpp:4822
static void base(QVariant data1, QVariant data2)
Definition dialogs.cpp:3209
static void spy_nuke_city_esc(QVariant data1, QVariant data2)
Definition dialogs.cpp:3769
static void teleport(QVariant data1, QVariant data2)
Definition dialogs.cpp:3362
void popup_soundset_suggestion_dialog(void)
Definition dialogs.cpp:4489
static void enter_hut2(QVariant data1, QVariant data2)
Definition dialogs.cpp:2843
void popup_races_dialog(struct player *pplayer)
Definition dialogs.cpp:1276
static void expel_unit(QVariant data1, QVariant data2)
Definition dialogs.cpp:3008
static void paradrop_frighten(QVariant data1, QVariant data2)
Definition dialogs.cpp:3407
static void diplomat_sabotage(QVariant data1, QVariant data2)
Definition dialogs.cpp:3949
void popup_disband_dialog(struct unit_list *punits)
Definition dialogs.cpp:4448
static action_id get_non_targeted_action_id(action_id tgt_action_id)
Definition dialogs.cpp:2398
static void homeless(QVariant data1, QVariant data2)
Definition dialogs.cpp:2541
static void caravan_help_build(QVariant data1, QVariant data2)
Definition dialogs.cpp:1820
void qtg_popup_image(const char *tag)
Definition dialogs.cpp:5467
static void bombard(QVariant data1, QVariant data2)
Definition dialogs.cpp:3020
void popup_bribe_stack_dialog(struct unit *actor, struct tile *ttile, int cost, const struct action *paction)
Definition dialogs.cpp:4201
void popdown_races_dialog(void)
Definition dialogs.cpp:1290
void popup_tileset_suggestion_dialog(void)
Definition dialogs.cpp:4458
void revolution_response(struct government *gov)
Definition dialogs.cpp:2032
void popdown_economy_report()
static void join_city(QVariant data1, QVariant data2)
Definition dialogs.cpp:3527
static void spy_request_sabotage_list(QVariant data1, QVariant data2)
Definition dialogs.cpp:3672
static void popup_act_confirmation_dialog(QString hdr, QString body, struct act_confirmation_data *data)
Definition dialogs.cpp:5427
static void unit_disband_recover(QVariant data1, QVariant data2)
Definition dialogs.cpp:1835
static void spy_steal(QVariant data1, QVariant data2)
Definition dialogs.cpp:3616
static void conquer_extras4(QVariant data1, QVariant data2)
Definition dialogs.cpp:2003
static void frighten_hut4(QVariant data1, QVariant data2)
Definition dialogs.cpp:2933
static void airlift(QVariant data1, QVariant data2)
Definition dialogs.cpp:1886
void popup_pillage_dialog(struct unit *punit, bv_extras extras)
Definition dialogs.cpp:4369
static void enter_hut3(QVariant data1, QVariant data2)
Definition dialogs.cpp:2858
static void transport_load3(QVariant data1, QVariant data2)
Definition dialogs.cpp:2746
static void spy_attack(QVariant data1, QVariant data2)
Definition dialogs.cpp:2972
static void bombard_lethal(QVariant data1, QVariant data2)
Definition dialogs.cpp:3068
static void plant(QVariant data1, QVariant data2)
Definition dialogs.cpp:3133
static void diplomat_bribe_stack(QVariant data1, QVariant data2)
Definition dialogs.cpp:2573
static void nuke(QVariant data1, QVariant data2)
Definition dialogs.cpp:3272
static void disembark2(QVariant data1, QVariant data2)
Definition dialogs.cpp:2783
static void transport_unload(QVariant data1, QVariant data2)
Definition dialogs.cpp:2713
void qtg_request_action_confirmation(const char *expl, struct act_confirmation_data *data)
Definition dialogs.cpp:5449
static void teleport_conquer(QVariant data1, QVariant data2)
Definition dialogs.cpp:3392
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:4685
void popdown_science_report()
static void transport_load2(QVariant data1, QVariant data2)
Definition dialogs.cpp:2735
static void diplomat_steal(QVariant data1, QVariant data2)
Definition dialogs.cpp:3979
static void unit_upgrade(QVariant data1, QVariant data2)
Definition dialogs.cpp:1865
bool popup_theme_suggestion_dialog(const char *theme_name)
Definition dialogs.cpp:4539
static void enter_hut(QVariant data1, QVariant data2)
Definition dialogs.cpp:2828
static void spy_request_strike_bld_list(QVariant data1, QVariant data2)
Definition dialogs.cpp:3655
static void diplomat_incite_escape(QVariant data1, QVariant data2)
Definition dialogs.cpp:4027
static void found_city(QVariant data1, QVariant data2)
Definition dialogs.cpp:3092
static void diplomat_investigate(QVariant data1, QVariant data2)
Definition dialogs.cpp:3934
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:5406
static void bombard3(QVariant data1, QVariant data2)
Definition dialogs.cpp:3044
static void transport_deboard(QVariant data1, QVariant data2)
Definition dialogs.cpp:2757
static void diplomat_incite(QVariant data1, QVariant data2)
Definition dialogs.cpp:4009
static void paradrop_conquer(QVariant data1, QVariant data2)
Definition dialogs.cpp:3377
void popdown_endgame_report()
static void diplomat_steal_esc(QVariant data1, QVariant data2)
Definition dialogs.cpp:3994
static void bombard_lethal2(QVariant data1, QVariant data2)
Definition dialogs.cpp:3080
static void frighten_hut3(QVariant data1, QVariant data2)
Definition dialogs.cpp:2918
static bool is_more_user_input_needed
Definition dialogs.cpp:220
static void bombard2(QVariant data1, QVariant data2)
Definition dialogs.cpp:3032
void popup_incite_dialog(struct unit *actor, struct city *tcity, int cost, const struct action *paction)
Definition dialogs.cpp:4091
static const QHash< action_id, pfcn_void > af_map_init(void)
Definition dialogs.cpp:233
void popdown_all_spaceships_dialogs()
static void nuke_city(QVariant data1, QVariant data2)
Definition dialogs.cpp:3784
void popup_connect_msg(const char *headline, const char *message)
Definition dialogs.cpp:1251
static void conquer_city_shrink(QVariant data1, QVariant data2)
Definition dialogs.cpp:1901
static void conquer_city_shrink3(QVariant data1, QVariant data2)
Definition dialogs.cpp:1931
static void diplomat_sabotage_esc(QVariant data1, QVariant data2)
Definition dialogs.cpp:3964
void popdown_units_report()
static void transport_embark2(QVariant data1, QVariant data2)
Definition dialogs.cpp:2680
static void spy_nuke_city(QVariant data1, QVariant data2)
Definition dialogs.cpp:3754
static void teleport_frighten_conquer(QVariant data1, QVariant data2)
Definition dialogs.cpp:3452
void unit_select_dialog_update_real(void *unused)
Definition dialogs.cpp:1313
static void spy_steal_esc(QVariant data1, QVariant data2)
Definition dialogs.cpp:3624
static void paradrop(QVariant data1, QVariant data2)
Definition dialogs.cpp:3347
static void suicide_attack(QVariant data1, QVariant data2)
Definition dialogs.cpp:3317
void races_toggles_set_sensitive(void)
Definition dialogs.cpp:1342
static void transport_load(QVariant data1, QVariant data2)
Definition dialogs.cpp:2724
static action_id get_production_targeted_action_id(action_id tgt_action_id)
Definition dialogs.cpp:2421
static void paradrop_frighten_conquer(QVariant data1, QVariant data2)
Definition dialogs.cpp:3437
static void convert_unit(QVariant data1, QVariant data2)
Definition dialogs.cpp:2529
static bool did_not_decide
Definition dialogs.cpp:224
static void spy_poison_esc(QVariant data1, QVariant data2)
Definition dialogs.cpp:3724
static void pillage_something(QVariant data1, QVariant data2)
Definition dialogs.cpp:4248
static void spy_request_sabotage_esc_list(QVariant data1, QVariant data2)
Definition dialogs.cpp:3690
void show_tileset_error(bool fatal, const char *tset_name, const char *msg)
Definition dialogs.cpp:4829
static void transform_terrain(QVariant data1, QVariant data2)
Definition dialogs.cpp:3103
static void attack2(QVariant data1, QVariant data2)
Definition dialogs.cpp:3302
#define BUTTON_CANCEL
Definition dialogs.cpp:72
static void conquer_extras(QVariant data1, QVariant data2)
Definition dialogs.cpp:1961
static void regular_move(QVariant data1, QVariant data2)
Definition dialogs.cpp:4045
static void heal_unit2(QVariant data1, QVariant data2)
Definition dialogs.cpp:2625
static void transport_board3(QVariant data1, QVariant data2)
Definition dialogs.cpp:2658
static void spy_embassy(QVariant data1, QVariant data2)
Definition dialogs.cpp:3889
static races_dialog * race_dialog
Definition dialogs.cpp:214
static void conquer_city_shrink4(QVariant data1, QVariant data2)
Definition dialogs.cpp:1946
static void frighten_hut2(QVariant data1, QVariant data2)
Definition dialogs.cpp:2903
static void conquer_extras2(QVariant data1, QVariant data2)
Definition dialogs.cpp:1975
static void regular_move2(QVariant data1, QVariant data2)
Definition dialogs.cpp:4060
static void frighten_hut(QVariant data1, QVariant data2)
Definition dialogs.cpp:2888
bool qtg_request_transport(struct unit *pcargo, struct tile *ptile)
Definition dialogs.cpp:5365
static void disembark4(QVariant data1, QVariant data2)
Definition dialogs.cpp:2813
int action_selection_target_unit(void)
Definition dialogs.cpp:4671
static void irrigate(QVariant data1, QVariant data2)
Definition dialogs.cpp:3251
static void transport_embark3(QVariant data1, QVariant data2)
Definition dialogs.cpp:2691
static void collect_ransom(QVariant data1, QVariant data2)
Definition dialogs.cpp:2960
static void heal_unit(QVariant data1, QVariant data2)
Definition dialogs.cpp:2614
void popdown_city_report()
Definition cityrep.cpp:1336
static void teleport_enter_conquer(QVariant data1, QVariant data2)
Definition dialogs.cpp:3512
static void regular_move3(QVariant data1, QVariant data2)
Definition dialogs.cpp:4075
static void paradrop_enter_conquer(QVariant data1, QVariant data2)
Definition dialogs.cpp:3497
static void unit_home_city(QVariant data1, QVariant data2)
Definition dialogs.cpp:1850
static void transport_embark(QVariant data1, QVariant data2)
Definition dialogs.cpp:2669
bool try_default_city_action(QVariant q1, QVariant q2)
Definition dialogs.cpp:1619
static void keep_moving(QVariant data1, QVariant data2)
Definition dialogs.cpp:2025
static void spy_steal_maps_esc(QVariant data1, QVariant data2)
Definition dialogs.cpp:3859
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:2474
static void disembark1(QVariant data1, QVariant data2)
Definition dialogs.cpp:2768
void restart_notify_dialogs()
Definition dialogs.cpp:4548
static void disembark3(QVariant data1, QVariant data2)
Definition dialogs.cpp:2798
static bool is_showing_pillage_dialog
Definition dialogs.cpp:213
static void spy_spread_plague(QVariant data1, QVariant data2)
Definition dialogs.cpp:3739
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:2441
static const QHash< action_id, pfcn_void > af_map
Definition dialogs.cpp:377
static void enter_hut4(QVariant data1, QVariant data2)
Definition dialogs.cpp:2873
static void caravan_establish_trade(QVariant data1, QVariant data2)
Definition dialogs.cpp:1805
void popdown_all_game_dialogs(void)
Definition dialogs.cpp:4564
static void spy_steal_maps(QVariant data1, QVariant data2)
Definition dialogs.cpp:3844
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id popup_bribe_unit_dialog
Definition dialogs_g.h:72
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit int const struct action *paction struct unit struct city const struct action *paction const char * expl
Definition dialogs_g.h:93
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit int const struct action *paction popup_sabotage_dialog
Definition dialogs_g.h:76
struct unit struct city struct unit * target_unit
Definition dialogs_g.h:55
popup_action_selection
Definition dialogs_g.h:54
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit * actor
Definition dialogs_g.h:72
struct unit * actor_unit
Definition dialogs_g.h:54
const char * caption
Definition dialogs_g.h:36
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs action_selection_no_longer_in_progress_gui_specific
Definition dialogs_g.h:68
const char const char * headline
Definition dialogs_g.h:37
popup_notify_dialog
Definition dialogs_g.h:36
struct unit struct city struct unit struct tile * target_tile
Definition dialogs_g.h:56
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit * punit
Definition dialogs_g.h:73
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit int const struct action *paction struct unit struct city * pcity
Definition dialogs_g.h:77
struct unit struct city * target_city
Definition dialogs_g.h:55
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit int cost
Definition dialogs_g.h:73
struct unit struct city struct unit struct tile struct extra_type * target_extra
Definition dialogs_g.h:56
int int id
Definition editgui_g.h:28
enum event_type event
Definition events.c:81
int extra_number(const struct extra_type *pextra)
Definition extras.c:161
struct extra_type * extra_by_number(int id)
Definition extras.c:183
static struct extra_type extras[MAX_EXTRA_TYPES]
Definition extras.c:31
const char * extra_name_translation(const struct extra_type *pextra)
Definition extras.c:194
#define extra_index(_e_)
Definition extras.h:183
#define EXTRA_NONE
Definition extras.h:85
int Tech_type_id
Definition fc_types.h:237
int action_id
Definition fc_types.h:249
int Government_type_id
Definition fc_types.h:241
#define IDENTITY_NUMBER_ZERO
Definition fc_types.h:93
#define PL_(String1, String2, n)
Definition fcintl.h:71
#define _(String)
Definition fcintl.h:67
const struct ft_color ftc_client
struct civ_game game
Definition game.c:61
struct world wld
Definition game.c:62
struct unit * game_unit_by_number(int id)
Definition game.c:115
struct city * game_city_by_number(int id)
Definition game.c:106
struct government * government_by_number(const Government_type_id gov)
Definition government.c:103
Government_type_id government_number(const struct government *pgovern)
Definition government.c:91
#define G_LAST
Definition government.h:48
int action_selection_target_extra(void)
static int actor_unit_id
static void diplomat_queue_handle_primary(void)
static void diplomat_queue_handle_secondary(void)
#define BUTTON_COUNT
void action_selection_refresh(struct unit *actor_unit, struct city *target_city, struct unit *target_unit, struct tile *target_tile, struct extra_type *target_extra, const struct act_prob *act_probs)
static PangoLayout * layout
Definition canvas.c:325
struct city * owner
Definition citydlg.c:226
static struct tile * pos
Definition finddlg.c:53
void popdown_help_dialog(void)
Definition helpdlg.c:186
const char * title
Definition repodlgs.c:1314
void(* pfcn_void)(QVariant, QVariant)
Definition dialogs.h:46
#define mevent_gpos(__ev__)
Definition gui_main.h:23
#define CAPTURE_DEFAULT_THIS
Definition gui_main.h:31
void nationset_changed(void)
Definition dialogs.c:3577
#define show(id)
Definition widget.h:235
void popup_revolution_dialog(void)
Definition dialogs.c:112
void helptext_nation(char *buf, size_t bufsz, struct nation_type *pnation, const char *user_text)
Definition helpdata.c:5084
Impr_type_id improvement_number(const struct impr_type *pimprove)
#define B_LAST
Definition improvement.h:42
get_token_fn_t func
Definition inputfile.c:128
#define fc_assert_msg(condition, message,...)
Definition log.h:182
#define fc_assert(condition)
Definition log.h:177
#define fc_assert_action(condition, action)
Definition log.h:188
@ LOG_ERROR
Definition log.h:31
#define log_error(message,...)
Definition log.h:104
struct tile * index_to_tile(const struct civ_map *imap, int mindex)
Definition map.c:471
void put_unit(const struct unit *punit, struct canvas *pcanvas, float zoom, int canvas_x, int canvas_y)
void center_tile_mapcanvas(const struct tile *ptile)
static const void * body(MD5_CTX *ctx, const void *data, unsigned long size)
Definition md5.c:121
#define FC_FREE(ptr)
Definition mem.h:41
const char * move_points_text(int mp, bool reduce)
Definition movement.c:1066
static mpgui * gui
Definition mpgui_qt.cpp:52
const char *const notify_label
Definition fonts.h:28
Nation_type_id nation_number(const struct nation_type *pnation)
Definition nation.c:486
bool nation_leader_is_male(const struct nation_leader *pleader)
Definition nation.c:290
const char * nation_adjective_for_player(const struct player *pplayer)
Definition nation.c:169
const char * nation_adjective_translation(const struct nation_type *pnation)
Definition nation.c:149
struct nation_type * nation_by_number(const Nation_type_id nation)
Definition nation.c:475
int nation_set_index(const struct nation_set *pset)
Definition nation.c:699
bool is_nation_pickable(const struct nation_type *nation)
Definition nation.c:188
const struct nation_leader_list * nation_leaders(const struct nation_type *pnation)
Definition nation.c:230
const char * nation_set_name_translation(const struct nation_set *pset)
Definition nation.c:818
bool is_nation_playable(const struct nation_type *nation)
Definition nation.c:200
bool nation_is_in_group(const struct nation_type *pnation, const struct nation_group *pgroup)
Definition nation.c:1099
const char * nation_set_description(const struct nation_set *pset)
Definition nation.c:828
const char * nation_group_name_translation(const struct nation_group *pgroup)
Definition nation.c:1090
int nation_set_count(void)
Definition nation.c:691
struct nation_group * nation_group_by_number(int id)
Definition nation.c:1004
struct nation_set * nation_set_by_rule_name(const char *name)
Definition nation.c:779
bool is_nation_group_hidden(struct nation_group *pgroup)
Definition nation.c:1057
struct nation_set * nation_set_by_setting_value(const char *setting)
Definition nation.c:859
const char * nation_leader_name(const struct nation_leader *pleader)
Definition nation.c:281
int nation_group_count(void)
Definition nation.c:935
const char * nation_set_rule_name(const struct nation_set *pset)
Definition nation.c:807
struct nation_style * style_of_nation(const struct nation_type *pnation)
Definition nation.c:672
#define nation_leader_list_iterate(leaderlist, pleader)
Definition nation.h:57
#define nation_sets_iterate_end
Definition nation.h:305
#define nation_sets_iterate(NAME_pset)
Definition nation.h:301
#define nations_iterate_end
Definition nation.h:336
#define nations_iterate(NAME_pnation)
Definition nation.h:333
#define nation_leader_list_iterate_end
Definition nation.h:59
const struct option_set * server_optset
Definition options.c:4077
bool option_str_set(struct option *poption, const char *str)
Definition options.c:937
const char * option_str_get(const struct option *poption)
Definition options.c:904
struct option * optset_option_by_name(const struct option_set *poptset, const char *name)
Definition options.c:442
#define REQEST_PLAYER_INITIATED
Definition packets.h:63
int dsend_packet_unit_get_actions(struct connection *pc, int actor_unit_id, int target_unit_id, int target_tile_id, int target_extra_id, int request_kind)
int dsend_packet_nation_select_req(struct connection *pc, int player_no, Nation_type_id nation_no, bool is_male, const char *name, int style)
int dsend_packet_city_name_suggestion_req(struct connection *pc, int unit_id)
void start_revolution(void)
Definition packhand.c:2405
void set_government_choice(struct government *government)
Definition packhand.c:2392
char * lines
Definition packhand.c:131
int player_number(const struct player *pplayer)
Definition player.c:837
const char * research_advance_name_translation(const struct research *presearch, Tech_type_id tech)
Definition research.c:273
struct research * research_get(const struct player *pplayer)
Definition research.c:128
enum tech_state research_invention_state(const struct research *presearch, Tech_type_id tech)
Definition research.c:619
bool research_invention_gettable(const struct research *presearch, const Tech_type_id tech, bool allow_holes)
Definition research.c:693
const char * sex_name_translation(sex_t kind)
Definition sex.c:60
@ SEX_FEMALE
Definition sex.h:22
@ SEX_MALE
Definition sex.h:23
#define ARRAY_SIZE(x)
Definition shared.h:85
size_t size
Definition specvec.h:72
struct sprite int int y
Definition sprite_g.h:31
struct sprite int x
Definition sprite_g.h:31
struct sprite int int int int struct sprite int int float bool smooth get_sprite_dimensions
Definition sprite_g.h:36
QPixmap map_pixmap
Definition canvas.h:25
Definition city.h:317
struct packet_ruleset_control control
Definition game.h:83
struct packet_game_info info
Definition game.h:89
struct connection conn
Definition client_main.h:96
Definition colors.h:21
struct player * playing
Definition connection.h:151
Definition mapimg.c:367
Definition climisc.h:82
struct universal item
Definition climisc.h:83
struct player * player
Definition nation.h:118
bool tech_steal_allow_holes
char preferred_soundset[MAX_LEN_NAME]
char preferred_tileset[MAX_LEN_NAME]
char preferred_musicset[MAX_LEN_NAME]
int revolution_finishes
Definition player.h:273
char name[MAX_LEN_NAME]
Definition player.h:251
Definition menu.h:161
QPixmap * pm
Definition sprite.h:25
Definition tile.h:50
int index
Definition tile.h:51
struct unit_list * units
Definition tile.h:58
int move_rate
Definition unittype.h:522
Definition unit.h:139
int moves_left
Definition unit.h:151
int id
Definition unit.h:146
int hp
Definition unit.h:152
int fuel
Definition unit.h:154
struct tile * tile
Definition unit.h:141
struct unit::@84::@86 client
struct act_prob * act_prob_cache
Definition unit.h:230
int homecity
Definition unit.h:147
struct civ_map map
const char * style_name_translation(const struct nation_style *pstyle)
Definition style.c:99
int style_number(const struct nation_style *pstyle)
Definition style.c:68
int basic_city_style_for_style(struct nation_style *pstyle)
Definition style.c:210
#define styles_iterate(_p)
Definition style.h:46
#define styles_iterate_end
Definition style.h:52
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:960
#define sz_strlcpy(dest, src)
Definition support.h:195
#define TRUE
Definition support.h:46
#define FALSE
Definition support.h:47
#define is_svg_flag_enabled()
Definition svgflag.h:30
#define advance_index_iterate_end
Definition tech.h:244
#define A_FIRST
Definition tech.h:44
#define A_UNSET
Definition tech.h:48
#define advance_index_iterate(_start, _index)
Definition tech.h:240
struct extra_type * get_preferred_pillage(bv_extras extras)
Definition terrain.c:549
bool get_units_upgrade_info(char *buf, size_t bufsz, struct unit_list *punits)
Definition text.c:1310
const char * get_act_sel_action_custom_text(struct action *paction, const struct act_prob prob, const struct unit *actor_unit, const struct city *target_city)
Definition text.c:1763
const char * act_sel_action_tool_tip(const struct action *paction, const struct act_prob prob)
Definition text.c:1868
struct city * tile_city(const struct tile *ptile)
Definition tile.c:83
#define tile_index(_pt_)
Definition tile.h:89
#define TILE_INDEX_NONE
Definition tile.h:48
int tileset_hex_width(const struct tileset *t)
Definition tilespec.c:747
int tileset_unit_width(const struct tileset *t)
Definition tilespec.c:823
int tileset_unit_height(const struct tileset *t)
Definition tilespec.c:831
struct sprite * load_popup_sprite(const char *tag)
Definition tilespec.c:7834
bool tileset_is_isometric(const struct tileset *t)
Definition tilespec.c:738
struct sprite * get_sample_city_sprite(const struct tileset *t, int style_idx)
Definition tilespec.c:7106
const char * tileset_basename(const struct tileset *t)
Definition tilespec.c:730
int tileset_hex_height(const struct tileset *t)
Definition tilespec.c:756
void unload_popup_sprite(const char *tag)
Definition tilespec.c:7842
struct sprite * get_nation_flag_sprite(const struct tileset *t, const struct nation_type *pnation)
Definition tilespec.c:7003
void tileset_error(enum log_level level, const char *tset_name, const char *format,...)
Definition tilespec.c:650
bool tilespec_reread(const char *new_tileset_name, bool game_fully_initialized, float scale)
Definition tilespec.c:1401
struct unit * transporter_for_unit_at(const struct unit *pcargo, const struct tile *ptile)
Definition unit.c:1985
bool could_unit_load(const struct unit *pcargo, const struct unit *ptrans)
Definition unit.c:742
bool unit_can_do_action(const struct unit *punit, const action_id act_id)
Definition unit.c:401
void unit_activity_astr(const struct unit *punit, struct astring *astr)
Definition unit.c:1210
#define unit_tile(_pu)
Definition unit.h:406
#define unit_owner(_pu)
Definition unit.h:405
#define unit_list_iterate(unitlist, punit)
Definition unitlist.h:31
#define unit_list_iterate_end
Definition unitlist.h:33
const struct unit_type * unit_type_get(const struct unit *punit)
Definition unittype.c:123
const char * unit_name_translation(const struct unit *punit)
Definition unittype.c:1573
#define utype_fuel(ptype)
Definition unittype.h:844