Freeciv-3.4
Loading...
Searching...
No Matches
dialogs.cpp
Go to the documentation of this file.
1/***********************************************************************
2 Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
6 any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12***********************************************************************/
13
14#ifdef HAVE_CONFIG_H
15#include <fc_config.h>
16#endif
17
18// Qt
19#include <QApplication>
20#include <QButtonGroup>
21#include <QComboBox>
22#include <QGroupBox>
23#include <QHeaderView>
24#include <QImage>
25#include <QMessageBox>
26#include <QMouseEvent>
27#include <QPainter>
28#include <QPainterPath>
29#include <QRadioButton>
30#include <QRect>
31#include <QTableWidgetItem>
32#include <QTextEdit>
33#include <QVBoxLayout>
34#include <QWindow>
35#include <QtMath>
36
37// utility
38#include "astring.h"
39
40// common
41#include "actions.h"
42#include "city.h"
43#include "game.h"
44#include "government.h"
45#include "improvement.h"
46#include "movement.h"
47#include "nation.h"
48#include "research.h"
49#include "sex.h"
50
51// client
52#include "audio.h"
53#include "chatline_common.h"
54#include "client_main.h"
55#include "control.h"
56#include "helpdata.h"
57#include "packhand.h"
58#include "svgflag.h"
59#include "text.h"
60#include "tilespec.h"
61
62// gui-qt
63#include "dialogs.h"
64#include "fc_client.h"
65#include "gui_main.h"
66#include "hudwidget.h"
67#include "qtg_cxxside.h"
68#include "sprite.h"
69
70// Locations for non action enabler controlled buttons.
71#define BUTTON_WAIT (ACTION_COUNT + 1)
72#define BUTTON_CANCEL (BUTTON_WAIT + 1)
73#define BUTTON_COUNT (BUTTON_CANCEL + 1)
74
76extern void popdown_players_report();
77extern void popdown_economy_report();
78extern void popdown_units_report();
79extern void popdown_science_report();
80extern void popdown_city_report();
81extern void popdown_endgame_report();
82
83static void spy_request_strike_bld_list(QVariant data1, QVariant data2);
84static void diplomat_incite(QVariant data1, QVariant data2);
85static void diplomat_incite_escape(QVariant data1, QVariant data2);
86static void spy_request_sabotage_list(QVariant data1, QVariant data2);
87static void spy_request_sabotage_esc_list(QVariant data1, QVariant data2);
88static void spy_sabotage(QVariant data1, QVariant data2);
89static void spy_steal(QVariant data1, QVariant data2);
90static void spy_steal_esc(QVariant data1, QVariant data2);
91static void spy_steal_something(QVariant data1, QVariant data2);
92static void diplomat_steal(QVariant data1, QVariant data2);
93static void diplomat_steal_esc(QVariant data1, QVariant data2);
94static void spy_poison(QVariant data1, QVariant data2);
95static void spy_poison_esc(QVariant data1, QVariant data2);
96static void spy_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/***********************************************************************/
444{
445 if (moving_now) {
446 move(event->globalPosition().toPoint() - point);
447 }
448}
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 = event->globalPosition().toPoint() - 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 = event->globalPosition().toPoint() - geometry().topLeft();
1032
1033 if (event->button() == Qt::RightButton) {
1034 was_destroyed = true;
1035 close();
1036 }
1037}
1038
1039/***********************************************************************/
1043{
1044 move(event->globalPosition().toPoint() - cursor);
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
1469
1470 targeted_unit = nullptr;
1471 // No buttons are added yet.
1472 for (int i = 0; i < BUTTON_COUNT; i++) {
1473 action_button_map << nullptr;
1474 }
1475}
1476
1477/***********************************************************************/
1481{
1482 buttons_list.clear();
1483 action_button_map.clear();
1484 gui()->set_diplo_dialog(nullptr);
1485
1486 if (run_on_close) {
1488 run_on_close = nullptr;
1489 }
1490}
1491
1492/***********************************************************************/
1496{
1498
1501 struct canvas *pix;
1502 QPushButton *next, *prev;
1503 unit_skip = new QHBoxLayout;
1504 next = new QPushButton();
1505 next->setIcon(fc_icons::instance()->get_icon("city-right"));
1506 next->setIconSize(QSize(32, 32));
1507 next->setFixedSize(QSize(36, 36));
1508 prev = new QPushButton();
1509 prev->setIcon(fc_icons::instance()->get_icon("city-left"));
1510 prev->setIconSize(QSize(32, 32));
1511 prev->setFixedSize(QSize(36, 36));
1512 target_unit_button = new QPushButton;
1515 pix->map_pixmap.fill(Qt::transparent);
1516 put_unit(targeted_unit, pix, 1.0, 0, 0);
1517 target_unit_button->setIcon(QIcon(pix->map_pixmap));
1518 qtg_canvas_free(pix);
1519 target_unit_button->setIconSize(QSize(96, 96));
1520 target_unit_button->setFixedSize(QSize(100, 100));
1521 unit_skip->addStretch(100);
1522 unit_skip->addWidget(prev, Qt::AlignCenter);
1523 unit_skip->addWidget(target_unit_button, Qt::AlignCenter);
1524 unit_skip->addWidget(next, Qt::AlignCenter);
1525 layout->addLayout(unit_skip);
1526 unit_skip->addStretch(100);
1527 connect(prev, &QAbstractButton::clicked, this, &choice_dialog::prev_unit);
1528 connect(next, &QAbstractButton::clicked, this, &choice_dialog::next_unit);
1529 }
1530
1532}
1533
1534/***********************************************************************/
1538 QVariant data2, QString tool_tip = "",
1539 const int button_id = -1)
1540{
1542 data1, data2);
1543 int action = buttons_list.count();
1544
1545 QObject::connect(button, &QPushButton::clicked,
1548 });
1549
1550 buttons_list.append(button);
1551
1552 if (!tool_tip.isEmpty()) {
1553 button->setToolTip(tool_tip);
1554 }
1555
1556 if (0 <= button_id) {
1557 // The id is valid.
1558 action_button_map[button_id] = button;
1559 }
1560
1561 layout->addWidget(button);
1562}
1563
1564/***********************************************************************/
1568{
1569 QPoint p;
1570
1571 p = mapFromGlobal(QCursor::pos());
1572 p.setY(p.y()-this->height());
1573 p.setX(p.x()-this->width());
1574 move(p);
1575 show();
1576}
1577
1578/***********************************************************************/
1585
1586/***********************************************************************/
1590{
1591 if (id < 0) {
1592 fc_assert_msg(0 <= id, "Invalid button ID.");
1593 return nullptr;
1594 }
1595
1596 return action_button_map[id];
1597}
1598
1599/***********************************************************************/
1603{
1606
1608 if (action == -1) {
1609 return false;
1610 }
1611 func = af_map[action];
1612
1613 func(q1, q2);
1614 return true;
1615}
1616
1617/***********************************************************************/
1621{
1624
1626 if (action == -1) {
1627 return false;
1628 }
1629 func = af_map[action];
1630 func(q1, q2);
1631 return true;
1632}
1633
1634/***********************************************************************/
1638{
1639 struct tile *ptile;
1640 struct unit *new_target = nullptr;
1641 bool break_next = false;
1642 bool first = true;
1643 struct canvas *pix;
1644
1645 if (targeted_unit == nullptr) {
1646 return;
1647 }
1648
1649 ptile = targeted_unit->tile;
1650
1651 unit_list_iterate(ptile->units, ptgt) {
1652 if (first) {
1653 new_target = ptgt;
1654 first = false;
1655 }
1656 if (break_next) {
1657 new_target = ptgt;
1658 break;
1659 }
1660 if (ptgt == targeted_unit) {
1661 break_next = true;
1662 }
1667 pix->map_pixmap.fill(Qt::transparent);
1668 put_unit(targeted_unit, pix, 1.0, 0, 0);
1669 target_unit_button->setIcon(QIcon(pix->map_pixmap));
1670 qtg_canvas_free(pix);
1671 switch_target();
1672}
1673
1674/***********************************************************************/
1678{
1679 struct tile *ptile;
1680 struct unit *new_target = nullptr;
1681 struct canvas *pix;
1682 if (targeted_unit == nullptr) {
1683 return;
1684 }
1685
1686 ptile = targeted_unit->tile;
1687 unit_list_iterate(ptile->units, ptgt) {
1688 if ((ptgt == targeted_unit) && new_target != nullptr) {
1689 break;
1690 }
1691 new_target = ptgt;
1696 pix->map_pixmap.fill(Qt::transparent);
1697 put_unit(targeted_unit, pix, 1.0, 0, 0);
1698 target_unit_button->setIcon(QIcon(pix->map_pixmap));
1699 qtg_canvas_free(pix);
1700 switch_target();
1701}
1702
1703/***********************************************************************/
1707{
1708 if (targeted_unit == nullptr) {
1709 return;
1710 }
1711 unit_skip->setParent(nullptr);
1716 : nullptr),
1717 act_probs);
1718 layout->addLayout(unit_skip);
1719}
1720
1721/***********************************************************************/
1725{
1726 if (targeted_unit == nullptr) {
1727 return;
1728 }
1729
1730 unit_skip->setParent(nullptr);
1732 unit_id,
1737 layout->addLayout(unit_skip);
1738}
1739
1740/***********************************************************************/
1744{
1746 pfcn_void func = button->getFunc();
1747
1748 func(button->getData1(), button->getData2());
1749 close();
1750}
1751
1752/***********************************************************************/
1761{
1762 // Store the data in the stack.
1763 last_buttons_stack.append(button);
1764
1765 /* Temporary remove the button so it will end up below buttons added
1766 * before unstack_all_buttons() is called. */
1767 layout->removeWidget(button);
1768
1769 // Synchronize the list with the layout.
1770 buttons_list.removeAll(button);
1771}
1772
1773/***********************************************************************/
1778{
1779 while (!last_buttons_stack.isEmpty()) {
1780 Choice_dialog_button *button = last_buttons_stack.takeLast();
1781
1782 // Reinsert the button below the other buttons.
1783 buttons_list.append(button);
1784 layout->addWidget(button);
1785 }
1786}
1787
1788/***********************************************************************/
1791static void caravan_marketplace(QVariant data1, QVariant data2)
1792{
1793 int actor_unit_id = data1.toInt();
1794 int target_city_id = data2.toInt();
1795
1796 if (game_unit_by_number(actor_unit_id) != nullptr
1797 && game_city_by_number(target_city_id) != nullptr) {
1799 target_city_id, 0, "");
1800 }
1801}
1802
1803/***********************************************************************/
1807{
1808 int actor_unit_id = data1.toInt();
1809 int target_city_id = data2.toInt();
1810
1811 if (game_unit_by_number(actor_unit_id) != nullptr
1812 && game_city_by_number(target_city_id) != nullptr) {
1814 target_city_id, 0, "");
1815 }
1816}
1817
1818/***********************************************************************/
1821static void caravan_help_build(QVariant data1, QVariant data2)
1822{
1823 int caravan_id = data1.toInt();
1824 int caravan_target_id = data2.toInt();
1825
1826 if (game_unit_by_number(caravan_id) != nullptr
1827 && game_city_by_number(caravan_target_id) != nullptr) {
1830 }
1831}
1832
1833/***********************************************************************/
1836static void unit_disband_recover(QVariant data1, QVariant data2)
1837{
1838 int actor_id = data1.toInt();
1839 int tgt_city_id = data2.toInt();
1840
1841 if (game_unit_by_number(actor_id) != nullptr
1842 && game_city_by_number(tgt_city_id) != nullptr) {
1844 actor_id, tgt_city_id, 0, "");
1845 }
1846}
1847
1848/***********************************************************************/
1851static void unit_home_city(QVariant data1, QVariant data2)
1852{
1853 int actor_id = data1.toInt();
1854 int tgt_city_id = data2.toInt();
1855
1856 if (game_unit_by_number(actor_id) != nullptr
1857 && game_city_by_number(tgt_city_id) != nullptr) {
1859 actor_id, tgt_city_id, 0, "");
1860 }
1861}
1862
1863/***********************************************************************/
1866static void unit_upgrade(QVariant data1, QVariant data2)
1867{
1868 struct unit *punit;
1869
1870 int actor_id = data1.toInt();
1871 int tgt_city_id = data2.toInt();
1872
1873 if ((punit = game_unit_by_number(actor_id)) != nullptr
1874 && game_city_by_number(tgt_city_id) != nullptr) {
1875 struct unit_list *as_list;
1876
1881 }
1882}
1883
1884/***********************************************************************/
1887static void airlift(QVariant data1, QVariant data2)
1888{
1889 int actor_id = data1.toInt();
1890 int tgt_city_id = data2.toInt();
1891
1892 if (game_unit_by_number(actor_id) != nullptr
1893 && game_city_by_number(tgt_city_id) != nullptr) {
1895 actor_id, tgt_city_id, 0, "");
1896 }
1897}
1898
1899/***********************************************************************/
1902static void conquer_city_shrink(QVariant data1, QVariant data2)
1903{
1904 int actor_id = data1.toInt();
1905 int tgt_city_id = data2.toInt();
1906
1907 if (game_unit_by_number(actor_id) != nullptr
1908 && game_city_by_number(tgt_city_id) != nullptr) {
1910 actor_id, tgt_city_id, 0, "");
1911 }
1912}
1913
1914/***********************************************************************/
1917static void conquer_city_shrink2(QVariant data1, QVariant data2)
1918{
1919 int actor_id = data1.toInt();
1920 int tgt_city_id = data2.toInt();
1921
1922 if (game_unit_by_number(actor_id) != nullptr
1923 && game_city_by_number(tgt_city_id) != nullptr) {
1925 actor_id, tgt_city_id, 0, "");
1926 }
1927}
1928
1929/***********************************************************************/
1932static void conquer_city_shrink3(QVariant data1, QVariant data2)
1933{
1934 int actor_id = data1.toInt();
1935 int tgt_city_id = data2.toInt();
1936
1937 if (game_unit_by_number(actor_id) != nullptr
1938 && game_city_by_number(tgt_city_id) != nullptr) {
1940 actor_id, tgt_city_id, 0, "");
1941 }
1942}
1943
1944/***********************************************************************/
1947static void conquer_city_shrink4(QVariant data1, QVariant data2)
1948{
1949 int actor_id = data1.toInt();
1950 int tgt_city_id = data2.toInt();
1951
1952 if (game_unit_by_number(actor_id) != nullptr
1953 && game_city_by_number(tgt_city_id) != nullptr) {
1955 actor_id, tgt_city_id, 0, "");
1956 }
1957}
1958
1959/***********************************************************************/
1962static void conquer_extras(QVariant data1, QVariant data2)
1963{
1964 int actor_id = data1.toInt();
1965 int target_id = data2.toInt();
1966
1967 if (game_unit_by_number(actor_id) != nullptr) {
1969 actor_id, target_id, 0, "");
1970 }
1971}
1972
1973/***********************************************************************/
1976static void conquer_extras2(QVariant data1, QVariant data2)
1977{
1978 int actor_id = data1.toInt();
1979 int target_id = data2.toInt();
1980
1981 if (game_unit_by_number(actor_id) != nullptr) {
1983 actor_id, target_id, 0, "");
1984 }
1985}
1986
1987/***********************************************************************/
1990static void conquer_extras3(QVariant data1, QVariant data2)
1991{
1992 int actor_id = data1.toInt();
1993 int target_id = data2.toInt();
1994
1995 if (game_unit_by_number(actor_id) != nullptr) {
1997 actor_id, target_id, 0, "");
1998 }
1999}
2000
2001/***********************************************************************/
2004static void conquer_extras4(QVariant data1, QVariant data2)
2005{
2006 int actor_id = data1.toInt();
2007 int target_id = data2.toInt();
2008
2009 if (game_unit_by_number(actor_id) != nullptr) {
2011 actor_id, target_id, 0, "");
2012 }
2013}
2014
2015/***********************************************************************/
2018static void act_sel_wait(QVariant data1, QVariant data2)
2019{
2020 key_unit_wait();
2021}
2022
2023/***********************************************************************/
2026static void keep_moving(QVariant data1, QVariant data2)
2027{
2028}
2029
2030/***********************************************************************/
2034{
2035 if (!gov) {
2037 } else {
2039 }
2040}
2041
2042/***********************************************************************/
2047{
2049 /* The client isn't waiting for information for any unanswered follow
2050 * up questions. */
2051
2052 struct unit *actor_unit;
2053
2055 /* The action selection dialog wasn't closed because the actor unit
2056 * was lost. */
2057
2058 // The probabilities didn't just disappear, right?
2061
2063 }
2064
2065 // The action selection process is over, at least for now.
2067
2068 if (did_not_decide) {
2069 /* The action selection dialog was closed but the player didn't
2070 * decide what the unit should do. */
2071
2072 // Reset so the next action selection dialog does the right thing.
2073 did_not_decide = false;
2074 } else {
2075 // An action, or no action at all, was selected.
2078 }
2079 }
2080}
2081
2082/***********************************************************************/
2086static void diplomat_queue_handle_secondary(int actor_id)
2087{
2088 // Stop waiting. Move on to the next queued unit.
2091}
2092
2093/**********************************************************************/
2100{
2101 // Stop assuming the answer to a follow up question will arrive.
2103}
2104
2105/***********************************************************************/
2110 struct city *target_city,
2111 struct unit *target_unit,
2112 struct tile *target_tile,
2113 struct extra_type *target_extra,
2114 const struct act_prob *act_probs)
2115{
2116 struct astring title = ASTRING_INIT, text = ASTRING_INIT;
2118 qtiles caras;
2119 QVariant qv1, qv2;
2121 struct city *actor_homecity;
2124
2127
2128 foreach (caras, gui()->trade_gen.lines) {
2129 if (caras.autocaravan == actor_unit) {
2130 int i;
2131
2132 if (game_unit_by_number(actor_unit->id) != nullptr
2133 && game_city_by_number(target_city->id) != nullptr) {
2135 target_city->id, 0, "");
2138 i = gui()->trade_gen.lines.indexOf(caras);
2139 gui()->trade_gen.lines.takeAt(i);
2140
2141 return;
2142 }
2143 }
2144 }
2145 if (target_city
2149
2150 return;
2151 }
2152
2153 if (target_unit
2157
2158 return;
2159 }
2160 /* Could be caused by the server failing to reply to a request for more
2161 * information or a bug in the client code. */
2163 "Diplomat queue problem. Is another diplomat window open?");
2164
2165 // No extra input is required as no action has been chosen yet.
2167
2169
2170 astr_set(&title,
2171 // TRANS: %s is a unit name, e.g., Spy
2172 _("Choose Your %s's Strategy"),
2174
2175 if (target_city != nullptr && actor_homecity != nullptr) {
2176 astr_set(&text,
2177 _("Your %s from %s reaches the city of %s.\nWhat now?"),
2181 } else if (target_city != nullptr) {
2182 astr_set(&text,
2183 _("Your %s has arrived at %s.\nWhat is your command?"),
2186 } else if (target_unit != nullptr) {
2188
2189 if (owner != nullptr) {
2190 astr_set(&text,
2191 // TRANS: Your Spy is ready to act against Roman Freight.
2192 _("Your %s is ready to act against %s %s."),
2196 } else {
2197 // Flagless target
2198 astr_set(&text,
2199 // TRANS: Your Spy is ready to act against Freight.
2200 _("Your %s is ready to act against %s."),
2203 }
2204 } else {
2205 fc_assert_msg(target_unit != nullptr
2206 || target_city != nullptr
2207 || target_tile != nullptr,
2208 "No target specified.");
2209
2210 astr_set(&text,
2211 // TRANS: %s is a unit name, e.g., Diplomat, Spy
2212 _("Your %s is waiting for your command."),
2214 }
2215
2216 cd = gui()->get_diplo_dialog();
2217 if ((cd != nullptr) && cd->targeted_unit != nullptr) {
2218 cd->update_dialog(act_probs);
2219 return;
2220 }
2221 cd = new choice_dialog(astr_str(&title), astr_str(&text),
2222 gui()->game_tab_widget,
2224 qv1 = actor_unit->id;
2225
2226 cd->unit_id = actor_unit->id;
2227
2228 cd->target_id[ATK_SELF] = cd->unit_id;
2229
2230 if (target_city) {
2231 cd->target_id[ATK_CITY] = target_city->id;
2232 } else {
2233 cd->target_id[ATK_CITY] = IDENTITY_NUMBER_ZERO;
2234 }
2235
2236 if (target_unit) {
2237 cd->target_id[ATK_UNIT] = target_unit->id;
2238 } else {
2239 cd->target_id[ATK_UNIT] = IDENTITY_NUMBER_ZERO;
2240 }
2241
2242 if (target_tile) {
2243 cd->target_id[ATK_STACK] = tile_index(target_tile);
2244 } else {
2245 cd->target_id[ATK_STACK] = TILE_INDEX_NONE;
2246 }
2247
2248 if (target_tile) {
2249 cd->target_id[ATK_TILE] = tile_index(target_tile);
2250 } else {
2251 cd->target_id[ATK_TILE] = TILE_INDEX_NONE;
2252 }
2253
2254 if (target_tile) {
2255 cd->target_id[ATK_EXTRAS] = tile_index(target_tile);
2256 } else {
2257 cd->target_id[ATK_EXTRAS] = TILE_INDEX_NONE;
2258 }
2259
2260 // No target building or target tech supplied. (Feb 2020)
2261 cd->sub_target_id[ASTK_BUILDING] = B_LAST;
2262 cd->sub_target_id[ASTK_TECH] = A_UNSET;
2263
2264 if (target_extra) {
2265 cd->sub_target_id[ASTK_EXTRA] = extra_number(target_extra);
2267 } else {
2268 cd->sub_target_id[ASTK_EXTRA] = EXTRA_NONE;
2269 cd->sub_target_id[ASTK_EXTRA_NOT_THERE] = EXTRA_NONE;
2270 }
2271
2272 // Unit acting against a city
2273
2274 // Set the correct target for the following actions.
2275 qv2 = cd->target_id[ATK_CITY];
2276
2277 action_iterate(act) {
2282 act_probs[act],
2283 actor_unit,
2284 target_city),
2285 qv1, qv2);
2286 }
2288
2289 // Unit acting against another unit
2290
2291 // Set the correct target for the following actions.
2292 qv2 = cd->target_id[ATK_UNIT];
2293
2294 action_iterate(act) {
2299 act_probs[act],
2300 actor_unit,
2301 target_city),
2302 qv1, qv2);
2303 }
2305
2306 // Unit acting against all units at a tile
2307
2308 // Set the correct target for the following actions.
2309 qv2 = cd->target_id[ATK_STACK];
2310
2311 action_iterate(act) {
2316 act_probs[act],
2317 actor_unit,
2318 target_city),
2319 qv1, qv2);
2320 }
2322
2323 // Unit acting against a tile.
2324
2325 // Set the correct target for the following actions.
2326 qv2 = cd->target_id[ATK_TILE];
2327
2328 action_iterate(act) {
2333 act_probs[act],
2334 actor_unit,
2335 target_city),
2336 qv1, qv2);
2337 }
2339
2340 // Unit acting against a tile's extras.
2341
2342 // Set the correct target for the following actions.
2343 qv2 = cd->target_id[ATK_EXTRAS];
2344
2345 action_iterate(act) {
2350 act_probs[act],
2351 actor_unit,
2352 target_city),
2353 qv1, qv2);
2354 }
2356
2357 // Unit acting against itself
2358
2359 // Set the correct target for the following actions.
2360 qv2 = cd->target_id[ATK_SELF];
2361
2362 action_iterate(act) {
2367 act_probs[act],
2368 actor_unit,
2369 target_city),
2370 qv1, qv2);
2371 }
2373
2375 cd->add_item(QString(_("&Wait")), func, qv1, qv2,
2376 "", BUTTON_WAIT);
2377
2378 func = keep_moving;
2379 cd->add_item(QString(_("Do nothing")), func, qv1, qv2,
2380 "", BUTTON_CANCEL);
2381
2382 cd->set_layout();
2383 cd->show_me();
2384
2385 // Give follow up questions access to action probabilities.
2387 action_iterate(act) {
2390
2391 astr_free(&title);
2392 astr_free(&text);
2393}
2394
2395/***********************************************************************/
2400{
2401 /* Don't add an action mapping here unless the non targeted version is
2402 * selectable in the targeted version's target selection dialog. */
2403 switch ((enum gen_action)tgt_action_id) {
2409 return ACTION_SPY_STEAL_TECH;
2412 default:
2413 // No non targeted version found.
2414 return ACTION_NONE;
2415 }
2416}
2417
2418/**********************************************************************/
2423{
2424 /* Don't add an action mapping here unless the non targeted version is
2425 * selectable in the targeted version's target selection dialog. */
2426 switch ((enum gen_action)tgt_action_id) {
2433 default:
2434 // No non targeted version found.
2435 return ACTION_NONE;
2436 }
2437}
2438
2439/***********************************************************************/
2443 action_id act,
2444 const struct act_prob *act_probs,
2445 const char *custom,
2446 QVariant data1, QVariant data2)
2447{
2448 QString title;
2450
2451 if (!af_map.contains(act)) {
2452 /* The Qt client doesn't support ordering this action from the
2453 * action selection dialog. */
2454 return;
2455 }
2456
2457 // Don't show disabled actions.
2458 if (!action_prob_possible(act_probs[act])) {
2459 return;
2460 }
2461
2463 act_probs[act],
2464 custom));
2465
2467 act_probs[act]));
2468
2469 cd->add_item(title, af_map[act], data1, data2, tool_tip, act);
2470}
2471
2472/***********************************************************************/
2476 action_id act,
2477 const struct act_prob *act_probs,
2478 const char *custom,
2479 QVariant data1, QVariant data2)
2480{
2481 QString title;
2483
2484 /* An action that just became impossible has its button disabled.
2485 * An action that became possible again must be re-enabled. */
2486 button->setEnabled(action_prob_possible(act_probs[act]));
2487 button->setData1(data1);
2488 button->setData2(data2);
2489 // The probability may have changed.
2491 act_probs[act],
2492 custom));
2493
2495 act_probs[act]));
2496
2497 button->setText(title);
2498 button->setToolTip(tool_tip);
2499}
2500
2501/***********************************************************************/
2504static void disband_unit(QVariant data1, QVariant data2)
2505{
2506 int actor_id = data1.toInt();
2507 int target_id = data2.toInt();
2508
2510 target_id, 0, "");
2511}
2512
2513/***********************************************************************/
2516static void fortify(QVariant data1, QVariant data2)
2517{
2518 int actor_id = data1.toInt();
2519 int target_id = data2.toInt();
2520
2521 if (game_unit_by_number(actor_id) != nullptr) {
2523 target_id, 0, "");
2524 }
2525}
2526
2527/***********************************************************************/
2530static void convert_unit(QVariant data1, QVariant data2)
2531{
2532 int actor_id = data1.toInt();
2533 int target_id = data2.toInt();
2534
2536 target_id, 0, "");
2537}
2538
2539/***********************************************************************/
2542static void homeless(QVariant data1, QVariant data2)
2543{
2544 int actor_id = data1.toInt();
2545 int target_id = data2.toInt();
2546
2547 if (game_unit_by_number(actor_id) != nullptr) {
2549 target_id, 0, "");
2550 }
2551}
2552
2553/***********************************************************************/
2556static void diplomat_bribe_unit(QVariant data1, QVariant data2)
2557{
2558 int diplomat_id = data1.toInt();
2559 int diplomat_target_id = data2.toInt();
2560
2561 if (game_unit_by_number(diplomat_id) != nullptr
2562 && game_unit_by_number(diplomat_target_id) != nullptr) {
2563 // Wait for the server's reply before moving on to the next queued diplomat.
2565
2568 }
2569}
2570
2571/***********************************************************************/
2574static void diplomat_bribe_stack(QVariant data1, QVariant data2)
2575{
2576 int diplomat_id = data1.toInt();
2577 int diplomat_target_id = data2.toInt();
2578
2579 if (game_unit_by_number(diplomat_id) != nullptr) {
2580 // Wait for the server's reply before moving on to the next queued diplomat.
2582
2585 }
2586}
2587
2588/***********************************************************************/
2591static void spy_sabotage_unit(QVariant data1, QVariant data2)
2592{
2593 int diplomat_id = data1.toInt();
2594 int diplomat_target_id = data2.toInt();
2595
2597 diplomat_target_id, 0, "");
2598}
2599
2600/***********************************************************************/
2603static void spy_sabotage_unit_esc(QVariant data1, QVariant data2)
2604{
2605 int diplomat_id = data1.toInt();
2606 int diplomat_target_id = data2.toInt();
2607
2609 diplomat_target_id, 0, "");
2610}
2611
2612/***********************************************************************/
2615static void heal_unit(QVariant data1, QVariant data2)
2616{
2617 int actor_id = data1.toInt();
2618 int target_id = data2.toInt();
2619
2620 request_do_action(ACTION_HEAL_UNIT, actor_id, target_id, 0, "");
2621}
2622
2623/***********************************************************************/
2626static void heal_unit2(QVariant data1, QVariant data2)
2627{
2628 int actor_id = data1.toInt();
2629 int target_id = data2.toInt();
2630
2631 request_do_action(ACTION_HEAL_UNIT2, actor_id, target_id, 0, "");
2632}
2633
2634/***********************************************************************/
2637static void transport_board(QVariant data1, QVariant data2)
2638{
2639 int actor_id = data1.toInt();
2640 int target_id = data2.toInt();
2641
2642 request_do_action(ACTION_TRANSPORT_BOARD, actor_id, target_id, 0, "");
2643}
2644
2645/***********************************************************************/
2648static void transport_board2(QVariant data1, QVariant data2)
2649{
2650 int actor_id = data1.toInt();
2651 int target_id = data2.toInt();
2652
2653 request_do_action(ACTION_TRANSPORT_BOARD2, actor_id, target_id, 0, "");
2654}
2655
2656/***********************************************************************/
2659static void transport_board3(QVariant data1, QVariant data2)
2660{
2661 int actor_id = data1.toInt();
2662 int target_id = data2.toInt();
2663
2664 request_do_action(ACTION_TRANSPORT_BOARD3, actor_id, target_id, 0, "");
2665}
2666
2667/***********************************************************************/
2670static void transport_embark(QVariant data1, QVariant data2)
2671{
2672 int actor_id = data1.toInt();
2673 int target_id = data2.toInt();
2674
2675 request_do_action(ACTION_TRANSPORT_EMBARK, actor_id, target_id, 0, "");
2676}
2677
2678/***********************************************************************/
2681static void transport_embark2(QVariant data1, QVariant data2)
2682{
2683 int actor_id = data1.toInt();
2684 int target_id = data2.toInt();
2685
2686 request_do_action(ACTION_TRANSPORT_EMBARK2, actor_id, target_id, 0, "");
2687}
2688
2689/***********************************************************************/
2692static void transport_embark3(QVariant data1, QVariant data2)
2693{
2694 int actor_id = data1.toInt();
2695 int target_id = data2.toInt();
2696
2697 request_do_action(ACTION_TRANSPORT_EMBARK3, actor_id, target_id, 0, "");
2698}
2699
2700/***********************************************************************/
2703static void transport_embark4(QVariant data1, QVariant data2)
2704{
2705 int actor_id = data1.toInt();
2706 int target_id = data2.toInt();
2707
2708 request_do_action(ACTION_TRANSPORT_EMBARK4, actor_id, target_id, 0, "");
2709}
2710
2711/***********************************************************************/
2714static void transport_unload(QVariant data1, QVariant data2)
2715{
2716 int actor_id = data1.toInt();
2717 int target_id = data2.toInt();
2718
2719 request_do_action(ACTION_TRANSPORT_UNLOAD, actor_id, target_id, 0, "");
2720}
2721
2722/***********************************************************************/
2725static void transport_load(QVariant data1, QVariant data2)
2726{
2727 int actor_id = data1.toInt();
2728 int target_id = data2.toInt();
2729
2730 request_do_action(ACTION_TRANSPORT_LOAD, actor_id, target_id, 0, "");
2731}
2732
2733/***********************************************************************/
2736static void transport_load2(QVariant data1, QVariant data2)
2737{
2738 int actor_id = data1.toInt();
2739 int target_id = data2.toInt();
2740
2741 request_do_action(ACTION_TRANSPORT_LOAD2, actor_id, target_id, 0, "");
2742}
2743
2744/***********************************************************************/
2747static void transport_load3(QVariant data1, QVariant data2)
2748{
2749 int actor_id = data1.toInt();
2750 int target_id = data2.toInt();
2751
2752 request_do_action(ACTION_TRANSPORT_LOAD3, actor_id, target_id, 0, "");
2753}
2754
2755/***********************************************************************/
2758static void transport_deboard(QVariant data1, QVariant data2)
2759{
2760 int actor_id = data1.toInt();
2761 int target_id = data2.toInt();
2762
2763 request_do_action(ACTION_TRANSPORT_DEBOARD, actor_id, target_id, 0, "");
2764}
2765
2766/***********************************************************************/
2769static void disembark1(QVariant data1, QVariant data2)
2770{
2771 int actor_id = data1.toInt();
2772 int target_id = data2.toInt();
2773
2774 if (game_unit_by_number(actor_id) != nullptr
2775 && index_to_tile(&(wld.map), target_id) != nullptr) {
2777 actor_id, target_id, 0, "");
2778 }
2779}
2780
2781/***********************************************************************/
2784static void disembark2(QVariant data1, QVariant data2)
2785{
2786 int actor_id = data1.toInt();
2787 int target_id = data2.toInt();
2788
2789 if (game_unit_by_number(actor_id) != nullptr
2790 && index_to_tile(&(wld.map), target_id) != nullptr) {
2792 actor_id, target_id, 0, "");
2793 }
2794}
2795
2796/***********************************************************************/
2799static void disembark3(QVariant data1, QVariant data2)
2800{
2801 int actor_id = data1.toInt();
2802 int target_id = data2.toInt();
2803
2804 if (game_unit_by_number(actor_id) != nullptr
2805 && index_to_tile(&(wld.map), target_id) != nullptr) {
2807 actor_id, target_id, 0, "");
2808 }
2809}
2810
2811/***********************************************************************/
2814static void disembark4(QVariant data1, QVariant data2)
2815{
2816 int actor_id = data1.toInt();
2817 int target_id = data2.toInt();
2818
2819 if (game_unit_by_number(actor_id) != nullptr
2820 && index_to_tile(&(wld.map), target_id) != nullptr) {
2822 actor_id, target_id, 0, "");
2823 }
2824}
2825
2826/***********************************************************************/
2829static void enter_hut(QVariant data1, QVariant data2)
2830{
2831 int actor_id = data1.toInt();
2832 int target_id = data2.toInt();
2833
2834 if (game_unit_by_number(actor_id) != nullptr
2835 && index_to_tile(&(wld.map), target_id) != nullptr) {
2837 actor_id, target_id, 0, "");
2838 }
2839}
2840
2841/***********************************************************************/
2844static void enter_hut2(QVariant data1, QVariant data2)
2845{
2846 int actor_id = data1.toInt();
2847 int target_id = data2.toInt();
2848
2849 if (game_unit_by_number(actor_id) != nullptr
2850 && index_to_tile(&(wld.map), target_id) != nullptr) {
2852 actor_id, target_id, 0, "");
2853 }
2854}
2855
2856/***********************************************************************/
2859static void enter_hut3(QVariant data1, QVariant data2)
2860{
2861 int actor_id = data1.toInt();
2862 int target_id = data2.toInt();
2863
2864 if (game_unit_by_number(actor_id) != nullptr
2865 && index_to_tile(&(wld.map), target_id) != nullptr) {
2867 actor_id, target_id, 0, "");
2868 }
2869}
2870
2871/***********************************************************************/
2874static void enter_hut4(QVariant data1, QVariant data2)
2875{
2876 int actor_id = data1.toInt();
2877 int target_id = data2.toInt();
2878
2879 if (game_unit_by_number(actor_id) != nullptr
2880 && index_to_tile(&(wld.map), target_id) != nullptr) {
2882 actor_id, target_id, 0, "");
2883 }
2884}
2885
2886/***********************************************************************/
2889static void frighten_hut(QVariant data1, QVariant data2)
2890{
2891 int actor_id = data1.toInt();
2892 int target_id = data2.toInt();
2893
2894 if (game_unit_by_number(actor_id) != nullptr
2895 && index_to_tile(&(wld.map), target_id) != nullptr) {
2897 actor_id, target_id, 0, "");
2898 }
2899}
2900
2901/***********************************************************************/
2904static void frighten_hut2(QVariant data1, QVariant data2)
2905{
2906 int actor_id = data1.toInt();
2907 int target_id = data2.toInt();
2908
2909 if (game_unit_by_number(actor_id) != nullptr
2910 && index_to_tile(&(wld.map), target_id) != nullptr) {
2912 actor_id, target_id, 0, "");
2913 }
2914}
2915
2916/***********************************************************************/
2919static void frighten_hut3(QVariant data1, QVariant data2)
2920{
2921 int actor_id = data1.toInt();
2922 int target_id = data2.toInt();
2923
2924 if (game_unit_by_number(actor_id) != nullptr
2925 && index_to_tile(&(wld.map), target_id) != nullptr) {
2927 actor_id, target_id, 0, "");
2928 }
2929}
2930
2931/***********************************************************************/
2934static void frighten_hut4(QVariant data1, QVariant data2)
2935{
2936 int actor_id = data1.toInt();
2937 int target_id = data2.toInt();
2938
2939 if (game_unit_by_number(actor_id) != nullptr
2940 && index_to_tile(&(wld.map), target_id) != nullptr) {
2942 actor_id, target_id, 0, "");
2943 }
2944}
2945
2946/**********************************************************************/
2949static void nuke_units(QVariant data1, QVariant data2)
2950{
2951 int actor_id = data1.toInt();
2952 int target_id = data2.toInt();
2953
2955 target_id, 0, "");
2956}
2957
2958/**********************************************************************/
2961static void collect_ransom(QVariant data1, QVariant data2)
2962{
2963 int actor_id = data1.toInt();
2964 int target_id = data2.toInt();
2965
2967 target_id, 0, "");
2968}
2969
2970/**********************************************************************/
2973static void spy_attack(QVariant data1, QVariant data2)
2974{
2975 int actor_id = data1.toInt();
2976 int target_id = data2.toInt();
2977
2979 target_id, 0, "");
2980}
2981
2982/**********************************************************************/
2985static void wipe_units(QVariant data1, QVariant data2)
2986{
2987 int actor_id = data1.toInt();
2988 int target_id = data2.toInt();
2989
2991 target_id, 0, "");
2992}
2993
2994/**********************************************************************/
2997static void capture_units(QVariant data1, QVariant data2)
2998{
2999 int actor_id = data1.toInt();
3000 int target_id = data2.toInt();
3001
3003 target_id, 0, "");
3004}
3005
3006/***********************************************************************/
3009static void expel_unit(QVariant data1, QVariant data2)
3010{
3011 int actor_id = data1.toInt();
3012 int target_id = data2.toInt();
3013
3015 target_id, 0, "");
3016}
3017
3018/***********************************************************************/
3021static void bombard(QVariant data1, QVariant data2)
3022{
3023 int actor_id = data1.toInt();
3024 int target_id = data2.toInt();
3025
3027 target_id, 0, "");
3028}
3029
3030/***********************************************************************/
3033static void bombard2(QVariant data1, QVariant data2)
3034{
3035 int actor_id = data1.toInt();
3036 int target_id = data2.toInt();
3037
3039 target_id, 0, "");
3040}
3041
3042/***********************************************************************/
3045static void bombard3(QVariant data1, QVariant data2)
3046{
3047 int actor_id = data1.toInt();
3048 int target_id = data2.toInt();
3049
3051 target_id, 0, "");
3052}
3053
3054/***********************************************************************/
3057static void bombard4(QVariant data1, QVariant data2)
3058{
3059 int actor_id = data1.toInt();
3060 int target_id = data2.toInt();
3061
3063 target_id, 0, "");
3064}
3065
3066/***********************************************************************/
3069static void bombard_lethal(QVariant data1, QVariant data2)
3070{
3071 int actor_id = data1.toInt();
3072 int target_id = data2.toInt();
3073
3075 target_id, 0, "");
3076}
3077
3078/***********************************************************************/
3081static void bombard_lethal2(QVariant data1, QVariant data2)
3082{
3083 int actor_id = data1.toInt();
3084 int target_id = data2.toInt();
3085
3087 target_id, 0, "");
3088}
3089
3090/***********************************************************************/
3093static void found_city(QVariant data1, QVariant data2)
3094{
3095 int actor_id = data1.toInt();
3096
3098 actor_id);
3099}
3100
3101/***********************************************************************/
3104static void transform_terrain(QVariant data1, QVariant data2)
3105{
3106 int actor_id = data1.toInt();
3107 int target_id = data2.toInt();
3108
3109 if (game_unit_by_number(actor_id) != nullptr
3110 && index_to_tile(&(wld.map), target_id) != nullptr) {
3112 actor_id, target_id, 0, "");
3113 }
3114}
3115
3116/***********************************************************************/
3119static void cultivate(QVariant data1, QVariant data2)
3120{
3121 int actor_id = data1.toInt();
3122 int target_id = data2.toInt();
3123
3124 if (game_unit_by_number(actor_id) != nullptr
3125 && index_to_tile(&(wld.map), target_id) != nullptr) {
3127 actor_id, target_id, 0, "");
3128 }
3129}
3130
3131/***********************************************************************/
3134static void plant(QVariant data1, QVariant data2)
3135{
3136 int actor_id = data1.toInt();
3137 int target_id = data2.toInt();
3138
3139 if (game_unit_by_number(actor_id) != nullptr
3140 && index_to_tile(&(wld.map), target_id) != nullptr) {
3142 actor_id, target_id, 0, "");
3143 }
3144}
3145
3146/***********************************************************************/
3149static void pillage(QVariant data1, QVariant data2)
3150{
3151 int actor_id = data1.toInt();
3152 int target_id = data2.toInt();
3153
3154 if (game_unit_by_number(actor_id) != nullptr
3155 && index_to_tile(&(wld.map), target_id) != nullptr) {
3157 actor_id, target_id,
3158 /* FIXME: will cause problems if more than
3159 * one action selection dialog at a time
3160 * becomes supported. */
3162 "");
3163 }
3164}
3165
3166/***********************************************************************/
3169static void clean(QVariant data1, QVariant data2)
3170{
3171 int actor_id = data1.toInt();
3172 int target_id = data2.toInt();
3173
3174 if (game_unit_by_number(actor_id) != nullptr
3175 && index_to_tile(&(wld.map), target_id) != nullptr) {
3177 actor_id, target_id,
3178 /* FIXME: will cause problems if more than
3179 * one action selection dialog at a time
3180 * becomes supported. */
3182 "");
3183 }
3184}
3185
3186/***********************************************************************/
3189static void road(QVariant data1, QVariant data2)
3190{
3191 int actor_id = data1.toInt();
3192 int target_id = data2.toInt();
3193
3194 if (game_unit_by_number(actor_id) != nullptr
3195 && index_to_tile(&(wld.map), target_id) != nullptr
3198 actor_id, target_id,
3199 /* FIXME: will cause problems if more than
3200 * one action selection dialog at a time
3201 * becomes supported. */
3203 "");
3204 }
3205}
3206
3207/***********************************************************************/
3210static void base(QVariant data1, QVariant data2)
3211{
3212 int actor_id = data1.toInt();
3213 int target_id = data2.toInt();
3214
3215 if (game_unit_by_number(actor_id) != nullptr
3216 && index_to_tile(&(wld.map), target_id) != nullptr
3219 actor_id, target_id,
3220 /* FIXME: will cause problems if more than
3221 * one action selection dialog at a time
3222 * becomes supported. */
3224 "");
3225 }
3226}
3227
3228/***********************************************************************/
3231static void mine(QVariant data1, QVariant data2)
3232{
3233 int actor_id = data1.toInt();
3234 int target_id = data2.toInt();
3235
3236 if (game_unit_by_number(actor_id) != nullptr
3237 && index_to_tile(&(wld.map), target_id) != nullptr
3240 actor_id, target_id,
3241 /* FIXME: will cause problems if more than
3242 * one action selection dialog at a time
3243 * becomes supported. */
3245 "");
3246 }
3247}
3248
3249/***********************************************************************/
3252static void irrigate(QVariant data1, QVariant data2)
3253{
3254 int actor_id = data1.toInt();
3255 int target_id = data2.toInt();
3256
3257 if (game_unit_by_number(actor_id) != nullptr
3258 && index_to_tile(&(wld.map), target_id) != nullptr
3261 actor_id, target_id,
3262 /* FIXME: will cause problems if more than
3263 * one action selection dialog at a time
3264 * becomes supported. */
3266 "");
3267 }
3268}
3269
3270/***********************************************************************/
3273static void nuke(QVariant data1, QVariant data2)
3274{
3275 int diplomat_id = data1.toInt();
3276 int diplomat_target_id = data2.toInt();
3277
3278 if (game_unit_by_number(diplomat_id) != nullptr
3279 && index_to_tile(&(wld.map), diplomat_target_id) != nullptr) {
3282 }
3283}
3284
3285/***********************************************************************/
3288static void attack(QVariant data1, QVariant data2)
3289{
3290 int diplomat_id = data1.toInt();
3291 int diplomat_target_id = data2.toInt();
3292
3293 if (game_unit_by_number(diplomat_id) != nullptr
3294 && index_to_tile(&(wld.map), diplomat_target_id) != nullptr) {
3297 }
3298}
3299
3300/***********************************************************************/
3303static void attack2(QVariant data1, QVariant data2)
3304{
3305 int diplomat_id = data1.toInt();
3306 int diplomat_target_id = data2.toInt();
3307
3308 if (game_unit_by_number(diplomat_id) != nullptr
3309 && index_to_tile(&(wld.map), diplomat_target_id) != nullptr) {
3312 }
3313}
3314
3315/***********************************************************************/
3318static void suicide_attack(QVariant data1, QVariant data2)
3319{
3320 int diplomat_id = data1.toInt();
3321 int diplomat_target_id = data2.toInt();
3322
3323 if (game_unit_by_number(diplomat_id) != nullptr
3324 && index_to_tile(&(wld.map), diplomat_target_id) != nullptr) {
3327 }
3328}
3329
3330/***********************************************************************/
3333static void suicide_attack2(QVariant data1, QVariant data2)
3334{
3335 int diplomat_id = data1.toInt();
3336 int diplomat_target_id = data2.toInt();
3337
3338 if (game_unit_by_number(diplomat_id) != nullptr
3339 && index_to_tile(&(wld.map), diplomat_target_id) != nullptr) {
3342 }
3343}
3344
3345/***********************************************************************/
3348static void paradrop(QVariant data1, QVariant data2)
3349{
3350 int actor_id = data1.toInt();
3351 int target_id = data2.toInt();
3352
3353 if (game_unit_by_number(actor_id) != nullptr
3354 && index_to_tile(&(wld.map), target_id) != nullptr) {
3356 actor_id, target_id, 0, "");
3357 }
3358}
3359
3360/***********************************************************************/
3363static void teleport(QVariant data1, QVariant data2)
3364{
3365 int actor_id = data1.toInt();
3366 int target_id = data2.toInt();
3367
3368 if (game_unit_by_number(actor_id) != nullptr
3369 && index_to_tile(&(wld.map), target_id) != nullptr) {
3371 actor_id, target_id, 0, "");
3372 }
3373}
3374
3375/***********************************************************************/
3378static void paradrop_conquer(QVariant data1, QVariant data2)
3379{
3380 int actor_id = data1.toInt();
3381 int target_id = data2.toInt();
3382
3383 if (game_unit_by_number(actor_id) != nullptr
3384 && index_to_tile(&(wld.map), target_id) != nullptr) {
3386 actor_id, target_id, 0, "");
3387 }
3388}
3389
3390/***********************************************************************/
3393static void teleport_conquer(QVariant data1, QVariant data2)
3394{
3395 int actor_id = data1.toInt();
3396 int target_id = data2.toInt();
3397
3398 if (game_unit_by_number(actor_id) != nullptr
3399 && index_to_tile(&(wld.map), target_id) != nullptr) {
3401 actor_id, target_id, 0, "");
3402 }
3403}
3404
3405/***********************************************************************/
3408static void paradrop_frighten(QVariant data1, QVariant data2)
3409{
3410 int actor_id = data1.toInt();
3411 int target_id = data2.toInt();
3412
3413 if (game_unit_by_number(actor_id) != nullptr
3414 && index_to_tile(&(wld.map), target_id) != nullptr) {
3416 actor_id, target_id, 0, "");
3417 }
3418}
3419
3420/***********************************************************************/
3423static void teleport_frighten(QVariant data1, QVariant data2)
3424{
3425 int actor_id = data1.toInt();
3426 int target_id = data2.toInt();
3427
3428 if (game_unit_by_number(actor_id) != nullptr
3429 && index_to_tile(&(wld.map), target_id) != nullptr) {
3431 actor_id, target_id, 0, "");
3432 }
3433}
3434
3435/***********************************************************************/
3439{
3440 int actor_id = data1.toInt();
3441 int target_id = data2.toInt();
3442
3443 if (game_unit_by_number(actor_id) != nullptr
3444 && index_to_tile(&(wld.map), target_id) != nullptr) {
3446 actor_id, target_id, 0, "");
3447 }
3448}
3449
3450/***********************************************************************/
3454{
3455 int actor_id = data1.toInt();
3456 int target_id = data2.toInt();
3457
3458 if (game_unit_by_number(actor_id) != nullptr
3459 && index_to_tile(&(wld.map), target_id) != nullptr) {
3461 actor_id, target_id, 0, "");
3462 }
3463}
3464
3465/***********************************************************************/
3468static void paradrop_enter(QVariant data1, QVariant data2)
3469{
3470 int actor_id = data1.toInt();
3471 int target_id = data2.toInt();
3472
3473 if (game_unit_by_number(actor_id) != nullptr
3474 && index_to_tile(&(wld.map), target_id) != nullptr) {
3476 actor_id, target_id, 0, "");
3477 }
3478}
3479
3480/***********************************************************************/
3483static void teleport_enter(QVariant data1, QVariant data2)
3484{
3485 int actor_id = data1.toInt();
3486 int target_id = data2.toInt();
3487
3488 if (game_unit_by_number(actor_id) != nullptr
3489 && index_to_tile(&(wld.map), target_id) != nullptr) {
3491 actor_id, target_id, 0, "");
3492 }
3493}
3494
3495/***********************************************************************/
3499{
3500 int actor_id = data1.toInt();
3501 int target_id = data2.toInt();
3502
3503 if (game_unit_by_number(actor_id) != nullptr
3504 && index_to_tile(&(wld.map), target_id) != nullptr) {
3506 actor_id, target_id, 0, "");
3507 }
3508}
3509
3510/***********************************************************************/
3514{
3515 int actor_id = data1.toInt();
3516 int target_id = data2.toInt();
3517
3518 if (game_unit_by_number(actor_id) != nullptr
3519 && index_to_tile(&(wld.map), target_id) != nullptr) {
3521 actor_id, target_id, 0, "");
3522 }
3523}
3524
3525/***********************************************************************/
3528static void join_city(QVariant data1, QVariant data2)
3529{
3530 int actor_id = data1.toInt();
3531 int target_id = data2.toInt();
3532
3533 if (game_unit_by_number(actor_id) != nullptr
3534 && game_city_by_number(target_id) != nullptr) {
3536 actor_id, target_id, 0, "");
3537 }
3538}
3539
3540/***********************************************************************/
3543static void spy_steal_shared(QVariant data1, QVariant data2,
3544 action_id act_id)
3545{
3546 QString str;
3547 QVariant qv1;
3549 int diplomat_id = data1.toInt();
3550 int diplomat_target_id = data2.toInt();
3553 struct player *pvictim = nullptr;
3556
3557 cd = gui()->get_diplo_dialog();
3558 if (cd != nullptr) {
3559 cd->close();
3560 }
3561
3562 if (pvcity == nullptr) {
3563 return;
3564 }
3565
3566 // Wait for the player's reply before moving on to the next queued diplomat.
3568
3570
3571 struct astring stra = ASTRING_INIT;
3572 cd = new choice_dialog(_("Steal"), _("Steal Technology"),
3573 gui()->game_tab_widget,
3575
3576 // Put both actor and target city in qv1 since qv2 is taken
3579 actor_and_target.append(act_id);
3580 qv1 = QVariant::fromValue(actor_and_target);
3581
3582 struct player *pplayer = client_player();
3583 const struct research *presearch = research_get(pplayer);
3584 const struct research *vresearch = research_get(pvictim);
3585
3592 // Defeat keyboard shortcut mnemonics
3594 .replace("&", "&&");
3595 cd->add_item(str, func, qv1, i);
3596 }
3598
3600 get_non_targeted_action_id(act_id)])) {
3601 astr_set(&stra, _("At %s's Discretion"),
3604 str = QString(astr_str(&stra)).replace("&", "&&");
3605 cd->add_item(str, func, qv1, A_UNSET);
3606 }
3607
3608 cd->set_layout();
3609 cd->show_me();
3610
3611 astr_free(&stra);
3612}
3613
3614/***********************************************************************/
3617static void spy_steal(QVariant data1, QVariant data2)
3618{
3620}
3621
3622/***********************************************************************/
3625static void spy_steal_esc(QVariant data1, QVariant data2)
3626{
3628}
3629
3630/***********************************************************************/
3633static void spy_steal_something(QVariant data1, QVariant data2)
3634{
3635 int diplomat_id = data1.toList().at(0).toInt();
3636 int diplomat_target_id = data1.toList().at(1).toInt();
3637 action_id act_id = data1.toList().at(2).toInt();
3638
3639 if (game_unit_by_number(diplomat_id) != nullptr
3640 && game_city_by_number(diplomat_target_id) != nullptr) {
3641 if (data2.toInt() == A_UNSET) {
3642 // This is the untargeted version.
3644 diplomat_id, diplomat_target_id, data2.toInt(), "");
3645 } else {
3646 // This is the targeted version.
3648 diplomat_target_id, data2.toInt(), "");
3649 }
3650 }
3651}
3652
3653/***********************************************************************/
3657{
3658 int actor_id = data1.toInt();
3659 int target_id = data2.toInt();
3660
3661 if (game_unit_by_number(actor_id) != nullptr
3662 && game_city_by_number(target_id) != nullptr) {
3663 // Wait for the server's reply before moving on to the next queued diplomat.
3665
3666 request_action_details(ACTION_STRIKE_BUILDING, actor_id, target_id);
3667 }
3668}
3669
3670/***********************************************************************/
3674{
3675 int diplomat_id = data1.toInt();
3676 int diplomat_target_id = data2.toInt();
3677
3678 if (game_unit_by_number(diplomat_id) != nullptr
3679 && game_city_by_number(diplomat_target_id) != nullptr) {
3680 // Wait for the server's reply before moving on to the next queued diplomat.
3682
3685 }
3686}
3687
3688/***********************************************************************/
3692{
3693 int diplomat_id = data1.toInt();
3694 int diplomat_target_id = data2.toInt();
3695
3696 if (game_unit_by_number(diplomat_id) != nullptr
3697 && game_city_by_number(diplomat_target_id) != nullptr) {
3698 /* Wait for the server's reply before moving on to the next queued
3699 * diplomat. */
3701
3704 }
3705}
3706
3707/***********************************************************************/
3710static void spy_poison(QVariant data1, QVariant data2)
3711{
3712 int diplomat_id = data1.toInt();
3713 int diplomat_target_id = data2.toInt();
3714
3715 if (game_unit_by_number(diplomat_id) != nullptr
3716 && game_city_by_number(diplomat_target_id) != nullptr) {
3719 }
3720}
3721
3722/***********************************************************************/
3725static void spy_poison_esc(QVariant data1, QVariant data2)
3726{
3727 int diplomat_id = data1.toInt();
3728 int diplomat_target_id = data2.toInt();
3729
3730 if (game_unit_by_number(diplomat_id) != nullptr
3731 && game_city_by_number(diplomat_target_id) != nullptr) {
3734 }
3735}
3736
3737/***********************************************************************/
3740static void spy_spread_plague(QVariant data1, QVariant data2)
3741{
3742 int diplomat_id = data1.toInt();
3743 int diplomat_target_id = data2.toInt();
3744
3745 if (game_unit_by_number(diplomat_id) != nullptr
3746 && game_city_by_number(diplomat_target_id) != nullptr) {
3749 }
3750}
3751
3752/***********************************************************************/
3755static void spy_nuke_city(QVariant data1, QVariant data2)
3756{
3757 int diplomat_id = data1.toInt();
3758 int diplomat_target_id = data2.toInt();
3759
3760 if (game_unit_by_number(diplomat_id) != nullptr
3761 && game_city_by_number(diplomat_target_id) != nullptr) {
3764 }
3765}
3766
3767/***********************************************************************/
3770static void spy_nuke_city_esc(QVariant data1, QVariant data2)
3771{
3772 int diplomat_id = data1.toInt();
3773 int diplomat_target_id = data2.toInt();
3774
3775 if (game_unit_by_number(diplomat_id) != nullptr
3776 && game_city_by_number(diplomat_target_id) != nullptr) {
3779 }
3780}
3781
3782/***********************************************************************/
3785static void nuke_city(QVariant data1, QVariant data2)
3786{
3787 int actor_id = data1.toInt();
3788 int target_id = data2.toInt();
3789
3790 if (game_unit_by_number(actor_id) != nullptr
3791 && game_city_by_number(target_id) != nullptr) {
3793 actor_id, target_id, 0, "");
3794 }
3795}
3796
3797/***********************************************************************/
3800static void destroy_city(QVariant data1, QVariant data2)
3801{
3802 int diplomat_id = data1.toInt();
3803 int diplomat_target_id = data2.toInt();
3804
3805 if (game_unit_by_number(diplomat_id) != nullptr
3806 && game_city_by_number(diplomat_target_id) != nullptr) {
3809 }
3810}
3811
3812/***********************************************************************/
3815static void spy_steal_gold(QVariant data1, QVariant data2)
3816{
3817 int diplomat_id = data1.toInt();
3818 int diplomat_target_id = data2.toInt();
3819
3820 if (game_unit_by_number(diplomat_id) != nullptr
3821 && game_city_by_number(diplomat_target_id) != nullptr) {
3824 }
3825}
3826
3827/***********************************************************************/
3830static void spy_steal_gold_esc(QVariant data1, QVariant data2)
3831{
3832 int diplomat_id = data1.toInt();
3833 int diplomat_target_id = data2.toInt();
3834
3835 if (game_unit_by_number(diplomat_id) != nullptr
3836 && game_city_by_number(diplomat_target_id) != nullptr) {
3839 }
3840}
3841
3842/***********************************************************************/
3845static void spy_steal_maps(QVariant data1, QVariant data2)
3846{
3847 int diplomat_id = data1.toInt();
3848 int diplomat_target_id = data2.toInt();
3849
3850 if (game_unit_by_number(diplomat_id) != nullptr
3851 && game_city_by_number(diplomat_target_id) != nullptr) {
3854 }
3855}
3856
3857/***********************************************************************/
3860static void spy_steal_maps_esc(QVariant data1, QVariant data2)
3861{
3862 int diplomat_id = data1.toInt();
3863 int diplomat_target_id = data2.toInt();
3864
3865 if (game_unit_by_number(diplomat_id) != nullptr
3866 && game_city_by_number(diplomat_target_id) != nullptr) {
3869 }
3870}
3871
3872/***********************************************************************/
3875static void spy_escape(QVariant data1, QVariant data2)
3876{
3877 int diplomat_id = data1.toInt();
3878 int diplomat_target_id = data2.toInt();
3879
3880 if (game_unit_by_number(diplomat_id) != nullptr
3881 && game_city_by_number(diplomat_target_id) != nullptr) {
3884 }
3885}
3886
3887/***********************************************************************/
3890static void spy_embassy(QVariant data1, QVariant data2)
3891{
3892 int diplomat_id = data1.toInt();
3893 int diplomat_target_id = data2.toInt();
3894
3895 if (game_unit_by_number(diplomat_id) != nullptr
3896 && game_city_by_number(diplomat_target_id) != nullptr) {
3898 diplomat_target_id, 0, "");
3899 }
3900}
3901
3902/***********************************************************************/
3905static void diplomat_embassy(QVariant data1, QVariant data2)
3906{
3907 int diplomat_id = data1.toInt();
3908 int diplomat_target_id = data2.toInt();
3909
3910 if (game_unit_by_number(diplomat_id) != nullptr
3911 && game_city_by_number(diplomat_target_id) != nullptr) {
3913 diplomat_target_id, 0, "");
3914 }
3915}
3916
3917/***********************************************************************/
3920static void spy_investigate(QVariant data1, QVariant data2)
3921{
3922 int diplomat_id = data1.toInt();
3923 int diplomat_target_id = data2.toInt();
3924
3926 && game_unit_by_number(diplomat_id) != nullptr) {
3928 diplomat_target_id, 0, "");
3929 }
3930}
3931
3932/***********************************************************************/
3935static void diplomat_investigate(QVariant data1, QVariant data2)
3936{
3937 int diplomat_id = data1.toInt();
3938 int diplomat_target_id = data2.toInt();
3939
3941 && game_unit_by_number(diplomat_id) != nullptr) {
3943 diplomat_target_id, 0, "");
3944 }
3945}
3946
3947/***********************************************************************/
3950static void diplomat_sabotage(QVariant data1, QVariant data2)
3951{
3952 int diplomat_id = data1.toInt();
3953 int diplomat_target_id = data2.toInt();
3954
3955 if (game_unit_by_number(diplomat_id) != nullptr
3956 && game_city_by_number(diplomat_target_id) != nullptr) {
3958 diplomat_target_id, B_LAST + 1, "");
3959 }
3960}
3961
3962/***********************************************************************/
3965static void diplomat_sabotage_esc(QVariant data1, QVariant data2)
3966{
3967 int diplomat_id = data1.toInt();
3968 int diplomat_target_id = data2.toInt();
3969
3970 if (game_unit_by_number(diplomat_id) != nullptr
3971 && game_city_by_number(diplomat_target_id) != nullptr) {
3973 diplomat_target_id, B_LAST + 1, "");
3974 }
3975}
3976
3977/***********************************************************************/
3980static void diplomat_steal(QVariant data1, QVariant data2)
3981{
3982 int diplomat_id = data1.toInt();
3983 int diplomat_target_id = data2.toInt();
3984
3985 if (game_unit_by_number(diplomat_id) != nullptr
3986 && game_city_by_number(diplomat_target_id) != nullptr) {
3989 }
3990}
3991
3992/***********************************************************************/
3995static void diplomat_steal_esc(QVariant data1, QVariant data2)
3996{
3997 int diplomat_id = data1.toInt();
3998 int diplomat_target_id = data2.toInt();
3999
4000 if (game_unit_by_number(diplomat_id) != nullptr
4001 && game_city_by_number(diplomat_target_id) != nullptr) {
4004 }
4005}
4006
4007/***********************************************************************/
4010static void diplomat_incite(QVariant data1, QVariant data2)
4011{
4012 int diplomat_id = data1.toInt();
4013 int diplomat_target_id = data2.toInt();
4014
4015 if (game_unit_by_number(diplomat_id) != nullptr
4016 && game_city_by_number(diplomat_target_id) != nullptr) {
4017 // Wait for the server's reply before moving on to the next queued diplomat.
4019
4022 }
4023}
4024
4025/***********************************************************************/
4029{
4030 int diplomat_id = data1.toInt();
4031 int diplomat_target_id = data2.toInt();
4032
4033 if (game_unit_by_number(diplomat_id) != nullptr
4034 && game_city_by_number(diplomat_target_id) != nullptr) {
4035 // Wait for the server's reply before moving on to the next queued diplomat.
4037
4040 }
4041}
4042
4043/***********************************************************************/
4046static void regular_move(QVariant data1, QVariant data2)
4047{
4048 int actor_id = data1.toInt();
4049 int target_id = data2.toInt();
4050
4051 if (game_unit_by_number(actor_id) != nullptr
4052 && index_to_tile(&(wld.map), target_id) != nullptr) {
4054 actor_id, target_id, 0, "");
4055 }
4056}
4057
4058/***********************************************************************/
4061static void regular_move2(QVariant data1, QVariant data2)
4062{
4063 int actor_id = data1.toInt();
4064 int target_id = data2.toInt();
4065
4066 if (game_unit_by_number(actor_id) != nullptr
4067 && index_to_tile(&(wld.map), target_id) != nullptr) {
4069 actor_id, target_id, 0, "");
4070 }
4071}
4072
4073/***********************************************************************/
4076static void regular_move3(QVariant data1, QVariant data2)
4077{
4078 int actor_id = data1.toInt();
4079 int target_id = data2.toInt();
4080
4081 if (game_unit_by_number(actor_id) != nullptr
4082 && index_to_tile(&(wld.map), target_id) != nullptr) {
4084 actor_id, target_id, 0, "");
4085 }
4086}
4087
4088/***********************************************************************/
4092void popup_incite_dialog(struct unit *actor, struct city *tcity, int cost,
4093 const struct action *paction)
4094{
4095 char buf[1024];
4096 char buf2[1024];
4097 int diplomat_id = actor->id;
4098 int diplomat_target_id = tcity->id;
4099 const int act_id = paction->id;
4100
4101 // Should be set before sending request to the server.
4103
4104 fc_snprintf(buf, ARRAY_SIZE(buf), PL_("Treasury contains %d gold.",
4105 "Treasury contains %d gold.",
4106 client_player()->economic.gold),
4107 client_player()->economic.gold);
4108
4110 hud_message_box *impossible = new hud_message_box(gui()->central_wdg);
4111
4113 _("You can't incite a revolt in %s."), city_name_get(tcity));
4114 impossible->set_text_title(buf2, "!");
4115 impossible->setStandardButtons(QMessageBox::Ok);
4116 impossible->setAttribute(Qt::WA_DeleteOnClose);
4117 impossible->show();
4118 } else if (cost <= client_player()->economic.gold) {
4119 hud_message_box *ask = new hud_message_box(gui()->central_wdg);
4120
4122 PL_("Incite a revolt for %d gold?\n%s",
4123 "Incite a revolt for %d gold?\n%s", cost), cost, buf);
4124 ask->setStandardButtons(QMessageBox::Cancel | QMessageBox::Ok);
4125 ask->setDefaultButton(QMessageBox::Cancel);
4126 ask->set_text_title(buf2, _("Incite a Revolt!"));
4127 ask->setAttribute(Qt::WA_DeleteOnClose);
4128 QObject::connect(ask, &hud_message_box::accepted, [=]() {
4131 });
4132 ask->show();
4133 return;
4134 } else {
4135 hud_message_box *too_much = new hud_message_box(gui()->central_wdg);
4136
4138 PL_("Inciting a revolt costs %d gold.\n%s",
4139 "Inciting a revolt costs %d gold.\n%s", cost), cost,
4140 buf);
4141 too_much->set_text_title(buf2, "!");
4142 too_much->setStandardButtons(QMessageBox::Ok);
4143 too_much->setAttribute(Qt::WA_DeleteOnClose);
4144 too_much->show();
4145 }
4146
4148}
4149
4150/***********************************************************************/
4154void popup_bribe_unit_dialog(struct unit *actor, struct unit *tunit, int cost,
4155 const struct action *paction)
4156{
4157 hud_message_box *ask = new hud_message_box(gui()->central_wdg);
4158 char buf[1024];
4159 char buf2[1024];
4160 int diplomat_id = actor->id;
4161 int diplomat_target_id = tunit->id;
4162 const int act_id = paction->id;
4163
4164 // Should be set before sending request to the server.
4166
4167 fc_snprintf(buf, ARRAY_SIZE(buf), PL_("Treasury contains %d gold.",
4168 "Treasury contains %d gold.",
4169 client_player()->economic.gold),
4170 client_player()->economic.gold);
4171
4172 if (cost <= client_player()->economic.gold) {
4173 fc_snprintf(buf2, ARRAY_SIZE(buf2), PL_("Bribe unit for %d gold?\n%s",
4174 "Bribe unit for %d gold?\n%s",
4175 cost), cost, buf);
4176 ask->set_text_title(buf2, _("Bribe Enemy Unit"));
4177 ask->setStandardButtons(QMessageBox::Cancel | QMessageBox::Ok);
4178 ask->setDefaultButton(QMessageBox::Cancel);
4179 ask->setAttribute(Qt::WA_DeleteOnClose);
4180 QObject::connect(ask, &hud_message_box::accepted, [=]() {
4183 });
4184 ask->show();
4185 return;
4186 } else {
4188 PL_("Bribing the unit costs %d gold.\n%s",
4189 "Bribing the unit costs %d gold.\n%s", cost), cost, buf);
4190 ask->set_text_title(buf2, _("Traitors Demand Too Much!"));
4191 ask->setAttribute(Qt::WA_DeleteOnClose);
4192 ask->show();
4193 }
4194
4196}
4197
4198/***********************************************************************/
4203 const struct action *paction)
4204{
4205 hud_message_box *ask = new hud_message_box(gui()->central_wdg);
4206 char buf[1024];
4207 char buf2[1024];
4208 int diplomat_id = actor->id;
4209 int diplomat_target_id = ttile->index;
4210 const int act_id = paction->id;
4211
4212 // Should be set before sending request to the server.
4214
4215 fc_snprintf(buf, ARRAY_SIZE(buf), PL_("Treasury contains %d gold.",
4216 "Treasury contains %d gold.",
4217 client_player()->economic.gold),
4218 client_player()->economic.gold);
4219
4220 if (cost <= client_player()->economic.gold) {
4221 fc_snprintf(buf2, ARRAY_SIZE(buf2), PL_("Bribe unit stack for %d gold?\n%s",
4222 "Bribe unit stack for %d gold?\n%s",
4223 cost), cost, buf);
4224 ask->set_text_title(buf2, _("Bribe Enemy Stack"));
4225 ask->setStandardButtons(QMessageBox::Cancel | QMessageBox::Ok);
4226 ask->setDefaultButton(QMessageBox::Cancel);
4227 ask->setAttribute(Qt::WA_DeleteOnClose);
4228 QObject::connect(ask, &hud_message_box::accepted, [=]() {
4231 });
4232 ask->show();
4233 return;
4234 } else {
4236 PL_("Bribing the unit stack costs %d gold.\n%s",
4237 "Bribing the unit stack costs %d gold.\n%s", cost), cost, buf);
4238 ask->set_text_title(buf2, _("Traitors Demand Too Much!"));
4239 ask->setAttribute(Qt::WA_DeleteOnClose);
4240 ask->show();
4241 }
4242
4244}
4245
4246/***********************************************************************/
4249static void pillage_something(QVariant data1, QVariant data2)
4250{
4251 int punit_id;
4252 int what;
4253 struct unit *punit;
4254 struct extra_type *target;
4255
4256 what = data1.toInt();
4257 punit_id = data2.toInt();
4259 if (punit) {
4260 target = extra_by_number(what);
4262 }
4264}
4265
4266/***********************************************************************/
4269static void spy_sabotage(QVariant data1, QVariant data2)
4270{
4271 int diplomat_id = data1.toList().at(0).toInt();
4272 int diplomat_target_id = data1.toList().at(1).toInt();
4273 action_id act_id = data1.toList().at(2).toInt();
4274
4275 if (game_unit_by_number(diplomat_id) != nullptr
4276 && game_city_by_number(diplomat_target_id) != nullptr) {
4277 if (data2.toInt() == B_LAST) {
4278 // This is the untargeted version.
4280 diplomat_id, diplomat_target_id, data2.toInt(),
4281 "");
4282 } else if (data2.toInt() == -1) {
4283 // This is the city production version.
4285 diplomat_id, diplomat_target_id, data2.toInt(),
4286 "");
4287 } else {
4288 // This is the targeted version.
4290 diplomat_target_id, data2.toInt(), "");
4291 }
4292 }
4293}
4294
4295/***********************************************************************/
4300 const struct action *paction)
4301{
4302 QString str;
4303 QVariant qv1, qv2;
4304 int diplomat_id = actor->id;
4305 int diplomat_target_id = tcity->id;
4308 int nr = 0;
4309 struct astring stra = ASTRING_INIT;
4311
4312 if (paction->result == ACTRES_STRIKE_BUILDING) {
4313 cd = new choice_dialog(_("Strike"),
4314 _("Select Improvement to Strike"),
4315 gui()->game_tab_widget,
4317 } else {
4318 cd = new choice_dialog(_("Sabotage"),
4319 _("Select Improvement to Sabotage"),
4320 gui()->game_tab_widget,
4322 }
4323
4324 // Should be set before sending request to the server.
4326
4327 // Put both actor, target city and action in qv1 since qv2 is taken
4330 actor_and_target.append(paction->id);
4331 qv1 = QVariant::fromValue(actor_and_target);
4332
4335 paction->id)])) {
4337 cd->add_item(QString(_("City Production")), func, qv1, -1);
4338 }
4339
4340 city_built_iterate(tcity, pimprove) {
4341 if (pimprove->sabotage > 0) {
4343 // Defeat keyboard shortcut mnemonics
4345 .replace("&", "&&");
4346 qv2 = nr;
4347 cd->add_item(str, func, qv1, improvement_number(pimprove));
4348 nr++;
4349 }
4351
4354 astr_set(&stra, _("At %s's Discretion"),
4357 str = QString(astr_str(&stra)).replace("&", "&&");
4358 cd->add_item(str, func, qv1, B_LAST);
4359 }
4360
4361 cd->set_layout();
4362 cd->show_me();
4363 astr_free(&stra);
4364}
4365
4366/***********************************************************************/
4371{
4372 QString str;
4373 QVariant qv1, qv2;
4376 struct extra_type *tgt;
4377
4379 return;
4380 }
4381 cd = new choice_dialog(_("What To Pillage"), _("Select what to pillage:"),
4382 gui()->game_tab_widget);
4383 qv2 = punit->id;
4384 while ((tgt = get_preferred_pillage(extras))) {
4385 int what;
4386
4387 what = extra_index(tgt);
4388 BV_CLR(extras, what);
4389
4391 // Defeat keyboard shortcut mnemonics
4392 str = QString(extra_name_translation(tgt)).replace("&", "&&");
4393 qv1 = what;
4394 cd->add_item(str, func, qv1, qv2);
4395 }
4396 cd->set_layout();
4397 cd->show_me();
4398}
4399
4400/***********************************************************************/
4404 QWidget *parent) : hud_message_box(parent)
4405{
4406 QString str;
4407 QPushButton *pb;
4408
4409 setAttribute(Qt::WA_DeleteOnClose);
4410 setModal(false);
4415
4416 str = QString(PL_("Are you sure you want to disband that %1 unit?",
4417 "Are you sure you want to disband those %1 units?",
4419 pb = addButton(_("Yes"), QMessageBox::AcceptRole);
4420 addButton(_("No"), QMessageBox::RejectRole);
4421 set_text_title(str, _("Disband units"));
4423 connect(pb, &QAbstractButton::clicked, this, &disband_box::disband_clicked);
4424}
4425
4426/***********************************************************************/
4437
4438/***********************************************************************/
4445
4446/***********************************************************************/
4449void popup_disband_dialog(struct unit_list *punits)
4450{
4451 disband_box *ask = new disband_box(punits, gui()->central_wdg);
4452 ask->show();
4453}
4454
4455/***********************************************************************/
4460{
4461 hud_message_box *ask = new hud_message_box(gui()->central_wdg);
4462 QString text;
4463 QString title;
4464
4465 title = QString(_("Modpack suggests using %1 tileset."))
4467 text = QString("It might not work with other tilesets.\n"
4468 "You are currently using tileset %1.")
4470 ask->addButton(_("Keep current tileset"), QMessageBox::RejectRole);
4471 ask->addButton(_("Load tileset"), QMessageBox::AcceptRole);
4472 ask->set_text_title(text, title);
4473 ask->setAttribute(Qt::WA_DeleteOnClose);
4474
4475 QObject::connect(ask, &hud_message_box::accepted, [=]() {
4478 gui()->map_scale)) {
4480 _("Can't load requested tileset."));
4481 }
4482 });
4483 ask->show();
4484}
4485
4486/***********************************************************************/
4491{
4492 hud_message_box *ask = new hud_message_box(gui()->central_wdg);
4493 QString text;
4494 QString title;
4495
4496 title = QString(_("Modpack suggests using %1 soundset."))
4498 text = QString("It might not work with other tilesets.\n"
4499 "You are currently using soundset %1.")
4500 .arg(sound_set_name);
4501 ask->addButton(_("Keep current soundset"), QMessageBox::RejectRole);
4502 ask->addButton(_("Load soundset"), QMessageBox::AcceptRole);
4503 ask->set_text_title(text, title);
4504 ask->setAttribute(Qt::WA_DeleteOnClose);
4505 QObject::connect(ask, &hud_message_box::accepted, [=]() {
4507 });
4508 ask->show();
4509}
4510
4511/***********************************************************************/
4516{
4517 hud_message_box *ask = new hud_message_box(gui()->central_wdg);
4518 QString text;
4519 QString title;
4520
4521 title = QString(_("Modpack suggests using %1 musicset."))
4523 text = QString("It might not work with other tilesets.\n"
4524 "You are currently using musicset %1.")
4525 .arg(music_set_name);
4526 ask->addButton(_("Keep current musicset"), QMessageBox::RejectRole);
4527 ask->addButton(_("Load musicset"), QMessageBox::AcceptRole);
4528 ask->set_text_title(text, title);
4529 ask->setAttribute(Qt::WA_DeleteOnClose);
4530 QObject::connect(ask, &hud_message_box::accepted, [=]() {
4532 });
4533 ask->show();
4534}
4535
4536/***********************************************************************/
4541{
4542 // PORTME
4543 return false;
4544}
4545
4546/***********************************************************************/
4550{
4552 int i;
4553
4554 nd_list = gui()->mapview_wdg->findChildren<notify_dialog *>();
4555 for (i = 0; i < nd_list.count(); i++) {
4556 nd_list[i]->restart();
4557 delete nd_list[i];
4558 }
4559}
4560
4561/***********************************************************************/
4566{
4567 int i;
4570 goto_dialog *gtd;
4571
4572 QApplication::alert(gui()->central_wdg);
4573 cd_list = gui()->game_tab_widget->findChildren <choice_dialog *>();
4574 for (i = 0; i < cd_list.count(); i++) {
4575 cd_list[i]->close();
4576 }
4577 nd_list = gui()->game_tab_widget->findChildren <notify_dialog *>();
4578 for (i = 0; i < nd_list.count(); i++) {
4579 nd_list[i]->close();
4580 }
4581
4590 gui()->popdown_unit_sel();
4591
4592 gtd = gui()->gtd;
4593
4594 if (gtd != nullptr) {
4595 gtd->close_dlg();
4596 }
4597}
4598
4599/***********************************************************************/
4605{
4606 choice_dialog *cd = gui()->get_diplo_dialog();
4607
4608 if (cd != nullptr) {
4609 return cd->unit_id;
4610 } else {
4611 return IDENTITY_NUMBER_ZERO;
4612 }
4613}
4614
4615/***********************************************************************/
4622{
4623 choice_dialog *cd = gui()->get_diplo_dialog();
4624
4625 if (cd != nullptr) {
4626 return cd->target_id[ATK_CITY];
4627 } else {
4628 return IDENTITY_NUMBER_ZERO;
4629 }
4630}
4631
4632/***********************************************************************/
4639{
4640 choice_dialog *cd = gui()->get_diplo_dialog();
4641
4642 if (cd != nullptr) {
4643 return cd->target_id[ATK_TILE];
4644 } else {
4645 return TILE_INDEX_NONE;
4646 }
4647}
4648
4649/**********************************************************************/
4656{
4657 choice_dialog *cd = gui()->get_diplo_dialog();
4658
4659 if (cd != nullptr) {
4660 return cd->sub_target_id[ASTK_EXTRA];
4661 } else {
4662 return EXTRA_NONE;
4663 }
4664}
4665
4666/***********************************************************************/
4673{
4674 choice_dialog *cd = gui()->get_diplo_dialog();
4675
4676 if (cd != nullptr) {
4677 return cd->target_id[ATK_UNIT];
4678 } else {
4679 return IDENTITY_NUMBER_ZERO;
4680 }
4681}
4682
4683/***********************************************************************/
4687 struct city *target_city,
4688 struct unit *target_unit,
4689 struct tile *target_tile,
4690 struct extra_type *target_extra,
4691 const struct act_prob *act_probs)
4692{
4695 Choice_dialog_button *cancel_button;
4696 QVariant qv1, qv2;
4697
4698 asd = gui()->get_diplo_dialog();
4699 if (asd == nullptr) {
4700 fc_assert_msg(asd != nullptr,
4701 "The action selection dialog should have been open");
4702 return;
4703 }
4704
4707 "The action selection dialog is for another actor unit.");
4708 }
4709
4710 // Put the actor id in qv1.
4711 qv1 = actor_unit->id;
4712
4713 cancel_button = asd->get_identified_button(BUTTON_CANCEL);
4714 if (cancel_button != nullptr) {
4715 /* Temporary remove the Cancel button so it won't end up above
4716 * any added buttons. */
4717 asd->stack_button(cancel_button);
4718 }
4719
4720 wait_button = asd->get_identified_button(BUTTON_WAIT);
4721 if (wait_button != nullptr) {
4722 /* Temporary remove the Wait button so it won't end up above
4723 * any added buttons. */
4724 asd->stack_button(wait_button);
4725 }
4726
4727 action_iterate(act) {
4728 const char *custom;
4729
4730 if (action_id_get_actor_kind(act) != AAK_UNIT) {
4731 // Not relevant.
4732 continue;
4733 }
4734
4736 act_probs[act],
4737 actor_unit,
4738 target_city);
4739
4740 // Put the target id in qv2.
4741 switch (action_id_get_target_kind(act)) {
4742 case ATK_UNIT:
4743 if (target_unit != nullptr) {
4744 qv2 = target_unit->id;
4745 } else {
4747 || target_unit != nullptr,
4748 "Action enabled against non existing unit!");
4749
4751 }
4752 break;
4753 case ATK_CITY:
4754 if (target_city != nullptr) {
4755 qv2 = target_city->id;
4756 } else {
4758 || target_city != nullptr,
4759 "Action enabled against non existing city!");
4760
4762 }
4763 break;
4764 case ATK_TILE:
4765 case ATK_EXTRAS:
4766 case ATK_STACK:
4767 if (target_tile != nullptr) {
4769 } else {
4771 || target_tile != nullptr,
4772 "Action enabled against all units on "
4773 "non existing tile!");
4774
4776 }
4777 break;
4778 case ATK_SELF:
4779 qv2 = actor_unit->id;
4780 break;
4781 case ATK_COUNT:
4783 "Bad target kind");
4784 continue;
4785 }
4786
4787 if (asd->get_identified_button(act)) {
4788 // Update the existing button.
4789 action_entry_update(asd->get_identified_button(act),
4790 act, act_probs, custom,
4791 qv1, qv2);
4792 } else {
4793 // Add the button (unless its probability is 0).
4795 qv1, qv2);
4796 }
4798
4799 if (wait_button != nullptr || cancel_button != nullptr) {
4800 /* Reinsert the non action buttons below any potential
4801 * buttons recently added. */
4802 asd->unstack_all_buttons();
4803 }
4804}
4805
4806/***********************************************************************/
4810{
4812
4813 cd = gui()->get_diplo_dialog();
4814 if (cd != nullptr) {
4815 did_not_decide = true;
4816 cd->close();
4817 }
4818}
4819
4820/***********************************************************************/
4826
4827/***********************************************************************/
4830void show_tileset_error(bool fatal, const char *tset_name, const char *msg)
4831{
4832 QWidget *parent;
4833 fc_client *std_gui = gui();
4834
4835 if (std_gui != nullptr) {
4836 parent = std_gui->central_wdg;
4837 } else {
4838 parent = nullptr;
4839 }
4840
4841 if (std_gui != nullptr || fatal) {
4842 char buf[1024];
4843 QMessageBox *ask = new QMessageBox(parent);
4844
4845 if (tset_name != nullptr) {
4846 fc_snprintf(buf, sizeof(buf),
4847 _("Tileset \"%s\" problem, it's probably incompatible with "
4848 "the ruleset:\n%s"), tset_name, msg);
4849 } else {
4850 fc_snprintf(buf, sizeof(buf),
4851 _("Tileset problem, it's probably incompatible with "
4852 "the ruleset:\n%s"), msg);
4853 }
4854
4855 ask->setText(buf);
4856 ask->setStandardButtons(QMessageBox::Ok);
4857 ask->setWindowTitle(_("Tileset error"));
4858
4859 if (std_gui != nullptr && !fatal) {
4860 ask->setAttribute(Qt::WA_DeleteOnClose);
4861 ask->show();
4862 } else {
4863 ask->exec();
4864 }
4865 }
4866}
4867
4868/***********************************************************************/
4871void popup_upgrade_dialog(struct unit_list *punits)
4872{
4873 char buf[512];
4875 QString title;
4877
4878 if (!punits || unit_list_size(punits) == 0) {
4879 return;
4880 }
4881
4882 ask = new hud_message_box(gui()->central_wdg);
4883
4884 punit_ids = new QVector<int>();
4886 punit_ids->push_back(punit->id);
4888
4889 if (!get_units_upgrade_info(buf, sizeof(buf), punits)) {
4890 title = _("Upgrade Unit!");
4891 ask->setStandardButtons(QMessageBox::Ok);
4892 } else {
4893 title = _("Upgrade Obsolete Units");
4894 ask->setStandardButtons(QMessageBox::Cancel | QMessageBox::Ok);
4895 ask->setDefaultButton(QMessageBox::Cancel);
4896 }
4897 ask->set_text_title(buf, title);
4898 ask->setAttribute(Qt::WA_DeleteOnClose);
4899 QObject::connect(ask, &hud_message_box::accepted, [=]() {
4900 std::unique_ptr<QVector<int>> uptr(punit_ids);
4901 struct unit *punit;
4902
4903 for (int id : *uptr) {
4905 if (punit) {
4907 }
4908 }
4909 });
4910 ask->show();
4911}
4912
4913/***********************************************************************/
4917{
4918 QPoint p, final_p;
4919
4921 utile = ptile;
4922 pix = nullptr;
4923 show_line = 0;
4924 highlight_num = -1;
4925 ufont.setItalic(true);
4927 update_units();
4928 h_pix = nullptr;
4929 create_pixmap();
4930 p = mapFromGlobal(QCursor::pos());
4931 cw = new close_widget(this);
4932 setMouseTracking(true);
4933 final_p.setX(p.x());
4934 final_p.setY(p.y());
4935 if (p.x() + width() > parentWidget()->width()) {
4936 final_p.setX(parentWidget()->width() - width());
4937 }
4938 if (p.y() - height() < 0) {
4939 final_p.setY(height());
4940 }
4941 move(final_p.x(), final_p.y() - height());
4942 setFocus();
4943 /* Build fails with qt5 connect style for static functions
4944 * Qt5.2 so dont update */
4945 QTimer::singleShot(10, this, SLOT(update_img()));
4946}
4947
4948/***********************************************************************/
4952{
4953 delete h_pix;
4954 delete pix;
4955 delete cw;
4956}
4957
4958/***********************************************************************/
4962{
4963 int a;
4964 int x, y, i;
4967 QImage img;
4969 QPainter p;
4970 QPen pen;
4971 QPixmap pixc;
4972 QPixmap *pixp;
4974 QRect crop;
4975 struct canvas *unit_pixmap;
4976 struct unit *punit;
4977 float isosize;
4978
4979 if (pix != nullptr) {
4980 delete pix;
4981 pix = nullptr;
4982 };
4983 isosize = 0.7;
4985 isosize = 0.5;
4986 }
4987
4988 update_units();
4989 if (unit_list.count() > 0) {
4993 } else {
4996 }
4997 more = false;
4998 if (h_pix != nullptr) {
4999 delete h_pix;
5000 }
5001 h_pix = new QPixmap(item_size.width(), item_size.height());
5002 h_pix->fill(palette().color(QPalette::HighlightedText));
5003 if (unit_count < 5) {
5004 row_count = 1;
5005 pix = new QPixmap((unit_list.size()) * item_size.width(),
5006 item_size.height());
5007 } else if (unit_count < 9) {
5008 row_count = 2;
5009 pix = new QPixmap(4 * item_size.width(), 2 * item_size.height());
5010 } else {
5011 row_count = 3;
5012 if (unit_count > 12) {
5013 more = true;
5014 }
5015 pix = new QPixmap(4 * item_size.width(), 3 * item_size.height());
5016 }
5017 pix->fill(Qt::transparent);
5018 foreach(punit, unit_list) {
5021 unit_pixmap->map_pixmap.fill(Qt::transparent);
5022 put_unit(punit, unit_pixmap, 1.0, 0, 0);
5023 img = unit_pixmap->map_pixmap.toImage();
5025 cropped_img = img.copy(crop);
5029 Qt::KeepAspectRatio,
5030 Qt::SmoothTransformation);
5031 } else {
5034 Qt::KeepAspectRatio,
5035 Qt::SmoothTransformation);
5036 }
5037 pixc = QPixmap::fromImage(img);
5038 pixp = new QPixmap(pixc);
5039 pix_list.push_back(pixp);
5041 }
5042 a = qMin(item_size.width() / 4, 12);
5043 x = 0, y = -item_size.height(), i = -1;
5044 p.begin(pix);
5045 ufont.setPixelSize(a);
5046 p.setFont(ufont);
5047 pen.setColor(palette().color(QPalette::Text));
5048 p.setPen(pen);
5049
5050 while (!pix_list.isEmpty()) {
5051 tmp_pix = pix_list.takeFirst();
5052 i++;
5053 if (i % 4 == 0) {
5054 x = 0;
5055 y = y + item_size.height();
5056 }
5057 punit = unit_list.at(i);
5058 Q_ASSERT(punit != nullptr);
5059
5060 if (i == highlight_num) {
5061 p.drawPixmap(x, y, *h_pix);
5062 p.drawPixmap(x, y, *tmp_pix);
5063 } else {
5064 p.drawPixmap(x, y, *tmp_pix);
5065 }
5066
5068 int rate, f;
5069 QString str;
5070
5072 f = ((punit->fuel) - 1);
5075 str = str + "(" + QString(move_points_text((rate * f)
5076 + punit->moves_left, false)) + ")";
5077 }
5078 // TRANS: MP = Movement points
5079 str = QString(_("MP:")) + str;
5080 p.drawText(x, y + item_size.height() - 4, str);
5081 }
5082
5083 x = x + item_size.width();
5084 delete tmp_pix;
5085 }
5086 p.end();
5087 setFixedWidth(pix->width() + 20);
5088 setFixedHeight(pix->height() + 2 * (fm.height() + 6));
5089 qDeleteAll(pix_list.begin(), pix_list.end());
5090 }
5091}
5092
5093/***********************************************************************/
5097{
5098 int a, b;
5099 int old_h;
5101 QPoint pos = event->pos();
5102 int x = pos.x();
5103 int y = pos.y();
5104
5106 highlight_num = -1;
5107 if (x > width() - 11
5108 || y > height() - fm.height() - 5
5109 || y < fm.height() + 3 || x < 11) {
5110 // Do nothing if mouse is on border, just skip next if
5111 } else if (row_count > 0) {
5112 a = (x - 10) / item_size.width();
5113 b = (y - fm.height() - 3) / item_size.height();
5114 highlight_num = b * 4 + a;
5115 }
5116 if (old_h != highlight_num) {
5117 create_pixmap();
5118 update();
5119 }
5120}
5121
5122/***********************************************************************/
5128{
5129 struct unit *punit;
5130 if (event->button() == Qt::RightButton) {
5131 was_destroyed = true;
5132 close();
5133 destroy();
5134 }
5135 if (event->button() == Qt::LeftButton && highlight_num != -1) {
5136 update_units();
5137 if (highlight_num >= unit_list.count()) {
5138 return;
5139 }
5142 was_destroyed = true;
5143 close();
5144 destroy();
5145 }
5146}
5147
5148/***********************************************************************/
5153{
5154 create_pixmap();
5155 update();
5156}
5157
5158/***********************************************************************/
5162{
5164 int h, i;
5165 int *f_size;
5166 QPen pen;
5167 QString str, str2;
5168 struct unit *punit;
5169 int point_size = info_font.pointSize();
5170 int pixel_size = info_font.pixelSize();
5171
5172 if (point_size < 0) {
5173 f_size = &pixel_size;
5174 } else {
5175 f_size = &point_size;
5176 }
5177 if (highlight_num != -1 && highlight_num < unit_list.count()) {
5178 struct astring addition = ASTRING_INIT;
5179
5182
5183 // TRANS: HP - hit points
5184 str2 = QString(_("%1 HP:%2/%3")).arg(QString(astr_str(&addition)),
5185 QString::number(punit->hp),
5186 QString::number(unit_type_get(punit)->hp));
5188 }
5189 str = QString(PL_("%1 unit", "%1 units",
5191 .arg(unit_list_size(utile->units));
5192 for (i = *f_size; i > 4; i--) {
5193 if (point_size < 0) {
5194 info_font.setPixelSize(i);
5195 } else {
5196 info_font.setPointSize(i);
5197 }
5199 if (10 + qfm.horizontalAdvance(str2) < width()) {
5200 break;
5201 }
5202 }
5203 h = fm.height();
5204 if (pix != nullptr) {
5205 painter->drawPixmap(10, h + 3, *pix);
5206 pen.setColor(palette().color(QPalette::Text));
5207 painter->setPen(pen);
5208 painter->setFont(info_font);
5209 painter->drawText(10, h, str);
5210 if (highlight_num != -1 && highlight_num < unit_list.count()) {
5211 painter->drawText(10, height() - 5, str2);
5212 }
5213 // Draw scroll
5214 if (more) {
5215 int maxl = ((unit_count - 1) / 4) + 1;
5216 float page_height = 3.0f / maxl;
5217 float page_start = (static_cast<float>(show_line)) / maxl;
5218 pen.setColor(palette().color(QPalette::HighlightedText));
5219 painter->setBrush(palette().color(QPalette::HighlightedText).darker());
5220 painter->setPen(palette().color(QPalette::HighlightedText).darker());
5221 painter->drawRect(pix->width() + 10, h, 8, h + pix->height());
5222 painter->setPen(pen);
5223 painter->drawRoundedRect(pix->width() + 10,
5224 h + page_start * pix->height(),
5225 8, h + page_height * pix->height(), 2, 2);
5226 }
5227 }
5228 if (point_size < 0) {
5229 info_font.setPixelSize(*f_size);
5230 } else {
5231 info_font.setPointSize(*f_size);
5232 }
5233 cw->put_to_corner();
5234}
5235
5236/***********************************************************************/
5240{
5242
5243 painter.begin(this);
5244 paint(&painter, event);
5245 painter.end();
5246}
5247
5248/***********************************************************************/
5253{
5254 was_destroyed = true;
5255 close();
5256 destroy();
5257}
5258
5259/***********************************************************************/
5263{
5264 int i = 1;
5265 struct unit_list *punit_list;
5266
5267 unit_count = 0;
5268 if (utile == nullptr) {
5269 struct unit *punit = head_of_units_in_focus();
5270 if (punit) {
5272 }
5273 }
5274 unit_list.clear();
5275 if (utile != nullptr) {
5277 if (punit_list != nullptr) {
5279 unit_count++;
5280 if (i > show_line * 4)
5281 unit_list.push_back(punit);
5282 i++;
5284 }
5285 }
5286 if (unit_list.count() == 0) {
5287 close();
5288 }
5289}
5290
5291/***********************************************************************/
5295{
5296 gui()->mapview_wdg->setFocus();
5297 QWidget::closeEvent(event);
5298}
5299
5300/***********************************************************************/
5304{
5305 int nr;
5306
5307 if (!more && utile == nullptr) {
5308 return;
5309 }
5310 nr = qCeil(static_cast<qreal>(unit_list_size(utile->units)) / 4) - 3;
5311 if (event->angleDelta().y() < 0) {
5312 show_line++;
5314 } else {
5315 show_line--;
5316 show_line = qMax(0, show_line);
5317 }
5318 update_units();
5319 create_pixmap();
5320 update();
5321 event->accept();
5322}
5323
5324/***********************************************************************/
5328{
5329 if (event->key() == Qt::Key_Escape) {
5330 was_destroyed = true;
5331 close();
5332 destroy();
5333 }
5334 QWidget::keyPressEvent(event);
5335}
5336
5337/***********************************************************************/
5344
5345/***********************************************************************/
5352
5353/***********************************************************************/
5358{
5359 // Just tell the client common code to handle this.
5360 return false;
5361}
5362
5363/***********************************************************************/
5366bool qtg_request_transport(struct unit *pcargo, struct tile *ptile)
5367{
5368 int tcount;
5370 struct unit_list *potential_transports = unit_list_new();
5371#ifndef FREECIV_NDEBUG
5373#endif
5374
5378 }
5380
5382
5383 if (tcount == 0) {
5384 fc_assert(best_transport == nullptr);
5386
5387 return false; // Unit was not handled here.
5388 } else if (tcount == 1) {
5389 // There's exactly one potential transport - use it automatically
5392
5394
5395 return true;
5396 }
5397
5398 hul = new hud_unit_loader(pcargo, ptile);
5399 hul->show_me();
5400 return true;
5401}
5402
5403/***********************************************************************/
5407void qtg_popup_combat_info(int attacker_unit_id, int defender_unit_id,
5408 int attacker_hp, int defender_hp,
5409 bool make_att_veteran, bool make_def_veteran)
5410{
5411 if (gui()->qt_settings.show_battle_log) {
5412 hud_unit_combat *huc = new hud_unit_combat(attacker_unit_id,
5413 defender_unit_id,
5414 attacker_hp, defender_hp,
5415 make_att_veteran,
5416 make_def_veteran,
5417 gui()->battlelog_wdg->scale,
5418 gui()->battlelog_wdg);
5419
5420 gui()->battlelog_wdg->add_combat_info(huc);
5421 gui()->battlelog_wdg->show();
5422 }
5423}
5424
5425/**********************************************************************/
5429 struct act_confirmation_data *data)
5430{
5431 hud_message_box *ask = new hud_message_box(gui()->central_wdg);
5432
5433 ask->setStandardButtons(QMessageBox::Cancel | QMessageBox::Ok);
5434 ask->setDefaultButton(QMessageBox::Cancel);
5435 ask->set_text_title(body, hdr);
5436 ask->setAttribute(Qt::WA_DeleteOnClose);
5437 QObject::connect(ask, &hud_message_box::accepted, [=]() {
5439 });
5440 QObject::connect(ask, &hud_message_box::rejected, [=]() {
5442 });
5443
5444 ask->show();
5445}
5446
5447/***********************************************************************/
5451 struct act_confirmation_data *data)
5452{
5454
5455 hdr = QString(_("Are you sure you want to do %1?")).
5457
5458 if (expl != nullptr) {
5460 }
5461
5463}
5464
5465/**********************************************************************/
5468void qtg_popup_image(const char *tag)
5469{
5470 struct sprite *spr = load_popup_sprite(tag);
5471
5472 if (spr != nullptr) {
5473 QDialog *win = new QDialog(gui());
5474 QVBoxLayout *layout = new QVBoxLayout(win);
5475 QPixmap *pm = new QPixmap(*spr->pm);
5476 QLabel *lbl = new QLabel;
5477 int width, height;
5478
5480 win->setFixedSize(width, height);
5481 lbl->setPixmap(*pm);
5482 layout->addWidget(lbl);
5483 win->setLayout(layout);
5484
5485 win->show();
5486
5488 } else {
5489 log_error(_("No image for tag \"%s\", requested by the server."), tag);
5490 }
5491}
const char * action_prepare_ui_name(action_id act_id, const char *mnemonic, const struct act_prob prob, const char *custom)
Definition actions.c:1333
const char * action_id_name_translation(action_id act_id)
Definition actions.c:1271
bool action_prob_possible(const struct act_prob probability)
Definition actions.c:5322
static struct action * action_by_number(action_id act_id)
Definition actions.h:400
#define action_iterate_end
Definition actions.h:218
#define action_id_get_actor_kind(act_id)
Definition actions.h:413
#define action_iterate(_act_)
Definition actions.h:214
#define action_id_get_target_kind(act_id)
Definition actions.h:417
#define ACTION_NONE
Definition actions.h:59
void astr_free(struct astring *astr)
Definition astring.c:148
void astr_set(struct astring *astr, const char *format,...)
Definition astring.c:251
#define str
Definition astring.c:76
static const char * astr_str(const struct astring *astr) fc__attribute((nonnull(1)))
Definition astring.h:93
#define ASTRING_INIT
Definition astring.h:44
void audio_restart(const char *soundset_name, const char *musicset_name)
Definition audio.c:378
#define BV_CLR(bv, bit)
Definition bitvector.h:94
QRect zealous_crop_rect(QImage &p)
Definition canvas.cpp:419
void qtg_canvas_free(struct canvas *store)
Definition canvas.cpp:48
struct canvas * qtg_canvas_create(int width, int height)
Definition canvas.cpp:36
struct canvas int int struct sprite int int int int height
Definition canvas_g.h:44
struct canvas int int struct sprite int int int width
Definition canvas_g.h:44
void output_window_append(const struct ft_color color, const char *featured_text)
const char * city_improvement_name_translation(const struct city *pcity, const struct impr_type *pimprove)
Definition city.c:666
const char * city_name_get(const struct city *pcity)
Definition city.c:1157
#define INCITE_IMPOSSIBLE_COST
Definition city.h:94
#define city_owner(_pcity_)
Definition city.h:564
#define city_built_iterate(_pcity, _p)
Definition city.h:842
#define city_built_iterate_end
Definition city.h:848
void qtg_real_city_dialog_popup(struct city *pcity)
Definition citydlg.cpp:3868
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:1760
void prev_unit()
Definition dialogs.cpp:1677
QVBoxLayout * layout
Definition dialogs.h:263
struct unit * targeted_unit
Definition dialogs.h:286
void unstack_all_buttons()
Definition dialogs.cpp:1777
Choice_dialog_button * get_identified_button(const int id)
Definition dialogs.cpp:1589
QPushButton * target_unit_button
Definition dialogs.h:262
void set_layout()
Definition dialogs.cpp:1495
void update_dialog(const struct act_prob *act_probs)
Definition dialogs.cpp:1706
QList< Choice_dialog_button * > last_buttons_stack
Definition dialogs.h:266
void next_unit()
Definition dialogs.cpp:1637
QVBoxLayout * get_layout()
Definition dialogs.cpp:1581
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:1724
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:1743
void add_item(QString title, pfcn_void func, QVariant data1, QVariant data2, QString tool_tip, const int button_id)
Definition dialogs.cpp:1537
void put_to_corner()
Definition mapview.cpp:503
void disband_clicked()
Definition dialogs.cpp:4429
disband_box(struct unit_list *punits, QWidget *parent=0)
Definition dialogs.cpp:4403
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:5348
void set_diplo_dialog(choice_dialog *widget)
Definition dialogs.cpp:5340
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:5294
void update_img()
Definition dialogs.cpp:5152
int show_line
Definition dialogs.h:233
void mouseMoveEvent(QMouseEvent *event)
Definition dialogs.cpp:5096
void paint(QPainter *painter, QPaintEvent *event)
Definition dialogs.cpp:5161
void update_menu()
Definition dialogs.cpp:5252
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:4916
void update_units()
Definition dialogs.cpp:5262
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:5239
void create_pixmap()
Definition dialogs.cpp:4961
void wheelEvent(QWheelEvent *event)
Definition dialogs.cpp:5303
void keyPressEvent(QKeyEvent *event)
Definition dialogs.cpp:5327
void mousePressEvent(QMouseEvent *event)
Definition dialogs.cpp:5127
close_widget * cw
Definition dialogs.h:213
char music_set_name[512]
bool client_is_global_observer(void)
struct civclient client
enum client_states client_state(void)
char sound_set_name[512]
#define client_player()
@ C_S_RUNNING
Definition client_main.h:47
void client_unit_init_act_prob_cache(struct unit *punit)
Definition climisc.c:1264
char * incite_cost
Definition comments.c:77
void action_selection_no_longer_in_progress(const int old_actor_id)
Definition control.c:1063
void request_unit_load(struct unit *pcargo, struct unit *ptrans, struct tile *ptile)
Definition control.c:2168
void unit_focus_set(struct unit *punit)
Definition control.c:518
void request_do_action(action_id action, int actor_id, int target_id, int sub_tgt, const char *name)
Definition control.c:1742
void request_unit_disband(struct unit *punit)
Definition control.c:2087
void request_action_details(action_id action, int actor_id, int target_id)
Definition control.c:1810
void request_new_unit_activity_targeted(struct unit *punit, enum unit_activity act, struct extra_type *tgt)
Definition control.c:1950
void action_confirmation(struct act_confirmation_data *data, bool confirm)
Definition control.c:1778
void action_decision_clear_want(const int old_actor_id)
Definition control.c:1092
void key_unit_wait(void)
Definition control.c:3554
struct unit * head_of_units_in_focus(void)
Definition control.c:410
void request_unit_upgrade(struct unit *punit)
Definition control.c:2118
void action_selection_next_in_focus(const int old_actor_id)
Definition control.c:1104
bool qtg_handmade_scenario_warning()
Definition dialogs.cpp:5357
static void attack(QVariant data1, QVariant data2)
Definition dialogs.cpp:3288
static void wipe_units(QVariant data1, QVariant data2)
Definition dialogs.cpp:2985
char forced_tileset_name[512]
static void bombard4(QVariant data1, QVariant data2)
Definition dialogs.cpp:3057
int action_selection_target_extra(void)
Definition dialogs.cpp:4655
static void suicide_attack2(QVariant data1, QVariant data2)
Definition dialogs.cpp:3333
static void destroy_city(QVariant data1, QVariant data2)
Definition dialogs.cpp:3800
static void spy_sabotage_unit(QVariant data1, QVariant data2)
Definition dialogs.cpp:2591
static void pillage(QVariant data1, QVariant data2)
Definition dialogs.cpp:3149
static void caravan_marketplace(QVariant data1, QVariant data2)
Definition dialogs.cpp:1791
static void clean(QVariant data1, QVariant data2)
Definition dialogs.cpp:3169
static void spy_steal_shared(QVariant data1, QVariant data2, action_id act_id)
Definition dialogs.cpp:3543
static void spy_sabotage(QVariant data1, QVariant data2)
Definition dialogs.cpp:4269
int action_selection_target_tile(void)
Definition dialogs.cpp:4638
static void teleport_enter(QVariant data1, QVariant data2)
Definition dialogs.cpp:3483
static void conquer_extras3(QVariant data1, QVariant data2)
Definition dialogs.cpp:1990
static void spy_investigate(QVariant data1, QVariant data2)
Definition dialogs.cpp:3920
static void act_sel_wait(QVariant data1, QVariant data2)
Definition dialogs.cpp:2018
static void nuke_units(QVariant data1, QVariant data2)
Definition dialogs.cpp:2949
int action_selection_actor_unit(void)
Definition dialogs.cpp:4604
static void capture_units(QVariant data1, QVariant data2)
Definition dialogs.cpp:2997
static void road(QVariant data1, QVariant data2)
Definition dialogs.cpp:3189
static bool is_race_dialog_open
Definition dialogs.cpp:215
static void transport_embark4(QVariant data1, QVariant data2)
Definition dialogs.cpp:2703
bool try_default_unit_action(QVariant q1, QVariant q2)
Definition dialogs.cpp:1602
static void fortify(QVariant data1, QVariant data2)
Definition dialogs.cpp:2516
static void teleport_frighten(QVariant data1, QVariant data2)
Definition dialogs.cpp:3423
static void transport_board(QVariant data1, QVariant data2)
Definition dialogs.cpp:2637
static void diplomat_bribe_unit(QVariant data1, QVariant data2)
Definition dialogs.cpp:2556
static void spy_sabotage_unit_esc(QVariant data1, QVariant data2)
Definition dialogs.cpp:2603
static void disband_unit(QVariant data1, QVariant data2)
Definition dialogs.cpp:2504
static void spy_steal_gold(QVariant data1, QVariant data2)
Definition dialogs.cpp:3815
void popdown_players_report()
Definition plrdlg.cpp:1197
static void conquer_city_shrink2(QVariant data1, QVariant data2)
Definition dialogs.cpp:1917
static void spy_escape(QVariant data1, QVariant data2)
Definition dialogs.cpp:3875
static void mine(QVariant data1, QVariant data2)
Definition dialogs.cpp:3231
void popup_musicset_suggestion_dialog(void)
Definition dialogs.cpp:4515
static void spy_steal_gold_esc(QVariant data1, QVariant data2)
Definition dialogs.cpp:3830
static void diplomat_embassy(QVariant data1, QVariant data2)
Definition dialogs.cpp:3905
void unit_select_dialog_popup(struct tile *ptile)
Definition dialogs.cpp:1301
void popup_upgrade_dialog(struct unit_list *punits)
Definition dialogs.cpp:4871
void update_nationset_combo()
Definition dialogs.cpp:1321
void action_selection_close(void)
Definition dialogs.cpp:4809
static void cultivate(QVariant data1, QVariant data2)
Definition dialogs.cpp:3119
static void paradrop_enter(QVariant data1, QVariant data2)
Definition dialogs.cpp:3468
void races_update_pickable(bool nationset_change)
Definition dialogs.cpp:1331
int action_selection_target_city(void)
Definition dialogs.cpp:4621
static void spy_steal_something(QVariant data1, QVariant data2)
Definition dialogs.cpp:3633
#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:3710
static void transport_board2(QVariant data1, QVariant data2)
Definition dialogs.cpp:2648
void show_tech_gained_dialog(Tech_type_id tech)
Definition dialogs.cpp:4823
static void base(QVariant data1, QVariant data2)
Definition dialogs.cpp:3210
static void spy_nuke_city_esc(QVariant data1, QVariant data2)
Definition dialogs.cpp:3770
static void teleport(QVariant data1, QVariant data2)
Definition dialogs.cpp:3363
void popup_soundset_suggestion_dialog(void)
Definition dialogs.cpp:4490
static void enter_hut2(QVariant data1, QVariant data2)
Definition dialogs.cpp:2844
void popup_races_dialog(struct player *pplayer)
Definition dialogs.cpp:1276
static void expel_unit(QVariant data1, QVariant data2)
Definition dialogs.cpp:3009
static void paradrop_frighten(QVariant data1, QVariant data2)
Definition dialogs.cpp:3408
static void diplomat_sabotage(QVariant data1, QVariant data2)
Definition dialogs.cpp:3950
void popup_disband_dialog(struct unit_list *punits)
Definition dialogs.cpp:4449
static action_id get_non_targeted_action_id(action_id tgt_action_id)
Definition dialogs.cpp:2399
static void homeless(QVariant data1, QVariant data2)
Definition dialogs.cpp:2542
static void caravan_help_build(QVariant data1, QVariant data2)
Definition dialogs.cpp:1821
void qtg_popup_image(const char *tag)
Definition dialogs.cpp:5468
static void bombard(QVariant data1, QVariant data2)
Definition dialogs.cpp:3021
void popup_bribe_stack_dialog(struct unit *actor, struct tile *ttile, int cost, const struct action *paction)
Definition dialogs.cpp:4202
void popdown_races_dialog(void)
Definition dialogs.cpp:1290
void popup_tileset_suggestion_dialog(void)
Definition dialogs.cpp:4459
void revolution_response(struct government *gov)
Definition dialogs.cpp:2033
void popdown_economy_report()
static void join_city(QVariant data1, QVariant data2)
Definition dialogs.cpp:3528
static void spy_request_sabotage_list(QVariant data1, QVariant data2)
Definition dialogs.cpp:3673
static void popup_act_confirmation_dialog(QString hdr, QString body, struct act_confirmation_data *data)
Definition dialogs.cpp:5428
static void unit_disband_recover(QVariant data1, QVariant data2)
Definition dialogs.cpp:1836
static void spy_steal(QVariant data1, QVariant data2)
Definition dialogs.cpp:3617
static void conquer_extras4(QVariant data1, QVariant data2)
Definition dialogs.cpp:2004
static void frighten_hut4(QVariant data1, QVariant data2)
Definition dialogs.cpp:2934
static void airlift(QVariant data1, QVariant data2)
Definition dialogs.cpp:1887
void popup_pillage_dialog(struct unit *punit, bv_extras extras)
Definition dialogs.cpp:4370
static void enter_hut3(QVariant data1, QVariant data2)
Definition dialogs.cpp:2859
static void transport_load3(QVariant data1, QVariant data2)
Definition dialogs.cpp:2747
static void spy_attack(QVariant data1, QVariant data2)
Definition dialogs.cpp:2973
static void bombard_lethal(QVariant data1, QVariant data2)
Definition dialogs.cpp:3069
static void plant(QVariant data1, QVariant data2)
Definition dialogs.cpp:3134
static void diplomat_bribe_stack(QVariant data1, QVariant data2)
Definition dialogs.cpp:2574
static void nuke(QVariant data1, QVariant data2)
Definition dialogs.cpp:3273
static void disembark2(QVariant data1, QVariant data2)
Definition dialogs.cpp:2784
static void transport_unload(QVariant data1, QVariant data2)
Definition dialogs.cpp:2714
void qtg_request_action_confirmation(const char *expl, struct act_confirmation_data *data)
Definition dialogs.cpp:5450
static void teleport_conquer(QVariant data1, QVariant data2)
Definition dialogs.cpp:3393
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:4686
void popdown_science_report()
static void transport_load2(QVariant data1, QVariant data2)
Definition dialogs.cpp:2736
static void diplomat_steal(QVariant data1, QVariant data2)
Definition dialogs.cpp:3980
static void unit_upgrade(QVariant data1, QVariant data2)
Definition dialogs.cpp:1866
bool popup_theme_suggestion_dialog(const char *theme_name)
Definition dialogs.cpp:4540
static void enter_hut(QVariant data1, QVariant data2)
Definition dialogs.cpp:2829
static void spy_request_strike_bld_list(QVariant data1, QVariant data2)
Definition dialogs.cpp:3656
static void diplomat_incite_escape(QVariant data1, QVariant data2)
Definition dialogs.cpp:4028
static void found_city(QVariant data1, QVariant data2)
Definition dialogs.cpp:3093
static void diplomat_investigate(QVariant data1, QVariant data2)
Definition dialogs.cpp:3935
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:5407
static void bombard3(QVariant data1, QVariant data2)
Definition dialogs.cpp:3045
static void transport_deboard(QVariant data1, QVariant data2)
Definition dialogs.cpp:2758
static void diplomat_incite(QVariant data1, QVariant data2)
Definition dialogs.cpp:4010
static void paradrop_conquer(QVariant data1, QVariant data2)
Definition dialogs.cpp:3378
void popdown_endgame_report()
static void diplomat_steal_esc(QVariant data1, QVariant data2)
Definition dialogs.cpp:3995
static void bombard_lethal2(QVariant data1, QVariant data2)
Definition dialogs.cpp:3081
static void frighten_hut3(QVariant data1, QVariant data2)
Definition dialogs.cpp:2919
static bool is_more_user_input_needed
Definition dialogs.cpp:220
static void bombard2(QVariant data1, QVariant data2)
Definition dialogs.cpp:3033
void popup_incite_dialog(struct unit *actor, struct city *tcity, int cost, const struct action *paction)
Definition dialogs.cpp:4092
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:3785
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:1902
static void conquer_city_shrink3(QVariant data1, QVariant data2)
Definition dialogs.cpp:1932
static void diplomat_sabotage_esc(QVariant data1, QVariant data2)
Definition dialogs.cpp:3965
void popdown_units_report()
static void transport_embark2(QVariant data1, QVariant data2)
Definition dialogs.cpp:2681
static void spy_nuke_city(QVariant data1, QVariant data2)
Definition dialogs.cpp:3755
static void teleport_frighten_conquer(QVariant data1, QVariant data2)
Definition dialogs.cpp:3453
void unit_select_dialog_update_real(void *unused)
Definition dialogs.cpp:1313
static void spy_steal_esc(QVariant data1, QVariant data2)
Definition dialogs.cpp:3625
static void paradrop(QVariant data1, QVariant data2)
Definition dialogs.cpp:3348
static void suicide_attack(QVariant data1, QVariant data2)
Definition dialogs.cpp:3318
void races_toggles_set_sensitive(void)
Definition dialogs.cpp:1342
static void transport_load(QVariant data1, QVariant data2)
Definition dialogs.cpp:2725
static action_id get_production_targeted_action_id(action_id tgt_action_id)
Definition dialogs.cpp:2422
static void paradrop_frighten_conquer(QVariant data1, QVariant data2)
Definition dialogs.cpp:3438
static void convert_unit(QVariant data1, QVariant data2)
Definition dialogs.cpp:2530
static bool did_not_decide
Definition dialogs.cpp:224
static void spy_poison_esc(QVariant data1, QVariant data2)
Definition dialogs.cpp:3725
static void pillage_something(QVariant data1, QVariant data2)
Definition dialogs.cpp:4249
static void spy_request_sabotage_esc_list(QVariant data1, QVariant data2)
Definition dialogs.cpp:3691
void show_tileset_error(bool fatal, const char *tset_name, const char *msg)
Definition dialogs.cpp:4830
static void transform_terrain(QVariant data1, QVariant data2)
Definition dialogs.cpp:3104
static void attack2(QVariant data1, QVariant data2)
Definition dialogs.cpp:3303
#define BUTTON_CANCEL
Definition dialogs.cpp:72
static void conquer_extras(QVariant data1, QVariant data2)
Definition dialogs.cpp:1962
static void regular_move(QVariant data1, QVariant data2)
Definition dialogs.cpp:4046
static void heal_unit2(QVariant data1, QVariant data2)
Definition dialogs.cpp:2626
static void transport_board3(QVariant data1, QVariant data2)
Definition dialogs.cpp:2659
static void spy_embassy(QVariant data1, QVariant data2)
Definition dialogs.cpp:3890
static races_dialog * race_dialog
Definition dialogs.cpp:214
static void conquer_city_shrink4(QVariant data1, QVariant data2)
Definition dialogs.cpp:1947
static void frighten_hut2(QVariant data1, QVariant data2)
Definition dialogs.cpp:2904
static void conquer_extras2(QVariant data1, QVariant data2)
Definition dialogs.cpp:1976
static void regular_move2(QVariant data1, QVariant data2)
Definition dialogs.cpp:4061
static void frighten_hut(QVariant data1, QVariant data2)
Definition dialogs.cpp:2889
bool qtg_request_transport(struct unit *pcargo, struct tile *ptile)
Definition dialogs.cpp:5366
static void disembark4(QVariant data1, QVariant data2)
Definition dialogs.cpp:2814
int action_selection_target_unit(void)
Definition dialogs.cpp:4672
static void irrigate(QVariant data1, QVariant data2)
Definition dialogs.cpp:3252
static void transport_embark3(QVariant data1, QVariant data2)
Definition dialogs.cpp:2692
static void collect_ransom(QVariant data1, QVariant data2)
Definition dialogs.cpp:2961
static void heal_unit(QVariant data1, QVariant data2)
Definition dialogs.cpp:2615
void popdown_city_report()
Definition cityrep.cpp:1339
static void teleport_enter_conquer(QVariant data1, QVariant data2)
Definition dialogs.cpp:3513
static void regular_move3(QVariant data1, QVariant data2)
Definition dialogs.cpp:4076
static void paradrop_enter_conquer(QVariant data1, QVariant data2)
Definition dialogs.cpp:3498
static void unit_home_city(QVariant data1, QVariant data2)
Definition dialogs.cpp:1851
static void transport_embark(QVariant data1, QVariant data2)
Definition dialogs.cpp:2670
bool try_default_city_action(QVariant q1, QVariant q2)
Definition dialogs.cpp:1620
static void keep_moving(QVariant data1, QVariant data2)
Definition dialogs.cpp:2026
static void spy_steal_maps_esc(QVariant data1, QVariant data2)
Definition dialogs.cpp:3860
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:2475
static void disembark1(QVariant data1, QVariant data2)
Definition dialogs.cpp:2769
void restart_notify_dialogs()
Definition dialogs.cpp:4549
static void disembark3(QVariant data1, QVariant data2)
Definition dialogs.cpp:2799
static bool is_showing_pillage_dialog
Definition dialogs.cpp:213
static void spy_spread_plague(QVariant data1, QVariant data2)
Definition dialogs.cpp:3740
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:2442
static const QHash< action_id, pfcn_void > af_map
Definition dialogs.cpp:377
static void enter_hut4(QVariant data1, QVariant data2)
Definition dialogs.cpp:2874
static void caravan_establish_trade(QVariant data1, QVariant data2)
Definition dialogs.cpp:1806
void popdown_all_game_dialogs(void)
Definition dialogs.cpp:4565
static void spy_steal_maps(QVariant data1, QVariant data2)
Definition dialogs.cpp:3845
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id popup_bribe_unit_dialog
Definition dialogs_g.h:72
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit int const struct action *paction struct unit struct city const struct action *paction const char * expl
Definition dialogs_g.h:93
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit int const struct action *paction popup_sabotage_dialog
Definition dialogs_g.h:76
struct unit struct city struct unit * target_unit
Definition dialogs_g.h:55
popup_action_selection
Definition dialogs_g.h:54
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit * actor
Definition dialogs_g.h:72
struct unit * actor_unit
Definition dialogs_g.h:54
const char * caption
Definition dialogs_g.h:36
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs action_selection_no_longer_in_progress_gui_specific
Definition dialogs_g.h:68
const char const char * headline
Definition dialogs_g.h:37
popup_notify_dialog
Definition dialogs_g.h:36
struct unit struct city struct unit struct tile * target_tile
Definition dialogs_g.h:56
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit * punit
Definition dialogs_g.h:73
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit int const struct action *paction struct unit struct city * pcity
Definition dialogs_g.h:77
struct unit struct city * target_city
Definition dialogs_g.h:55
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit int cost
Definition dialogs_g.h:73
struct unit struct city struct unit struct tile struct extra_type * target_extra
Definition dialogs_g.h:56
int int id
Definition editgui_g.h:28
enum event_type event
Definition events.c:82
int extra_number(const struct extra_type *pextra)
Definition extras.c:161
struct extra_type * extra_by_number(int id)
Definition extras.c:183
static struct extra_type extras[MAX_EXTRA_TYPES]
Definition extras.c:31
const char * extra_name_translation(const struct extra_type *pextra)
Definition extras.c:194
#define extra_index(_e_)
Definition extras.h:183
#define EXTRA_NONE
Definition extras.h:85
int Tech_type_id
Definition fc_types.h:238
int action_id
Definition fc_types.h:250
int Government_type_id
Definition fc_types.h:242
#define IDENTITY_NUMBER_ZERO
Definition fc_types.h:94
#define PL_(String1, String2, n)
Definition fcintl.h:71
#define _(String)
Definition fcintl.h:67
const struct ft_color ftc_client
struct civ_game game
Definition game.c:62
struct world wld
Definition game.c:63
struct unit * game_unit_by_number(int id)
Definition game.c:115
struct city * game_city_by_number(int id)
Definition game.c:106
struct government * government_by_number(const Government_type_id gov)
Definition government.c:103
Government_type_id government_number(const struct government *pgovern)
Definition government.c:92
#define G_LAST
Definition government.h:50
int action_selection_target_extra(void)
static int actor_unit_id
static void diplomat_queue_handle_primary(void)
static void diplomat_queue_handle_secondary(void)
#define BUTTON_COUNT
void action_selection_refresh(struct unit *actor_unit, struct city *target_city, struct unit *target_unit, struct tile *target_tile, struct extra_type *target_extra, const struct act_prob *act_probs)
static PangoLayout * layout
Definition canvas.c:325
struct city * owner
Definition citydlg.c:226
static struct tile * pos
Definition finddlg.c:53
void popdown_help_dialog(void)
Definition helpdlg.c:186
const char * title
Definition repodlgs.c:1314
void(* pfcn_void)(QVariant, QVariant)
Definition dialogs.h:46
#define CAPTURE_DEFAULT_THIS
Definition gui_main.h:23
void nationset_changed(void)
Definition dialogs.c:3577
#define show(id)
Definition widget.h:235
void popup_revolution_dialog(void)
Definition dialogs.c:112
void helptext_nation(char *buf, size_t bufsz, struct nation_type *pnation, const char *user_text)
Definition helpdata.c:5132
Impr_type_id improvement_number(const struct impr_type *pimprove)
#define B_LAST
Definition improvement.h:42
get_token_fn_t func
Definition inputfile.c:128
#define fc_assert_msg(condition, message,...)
Definition log.h:182
#define fc_assert(condition)
Definition log.h:177
#define fc_assert_action(condition, action)
Definition log.h:188
@ LOG_ERROR
Definition log.h:31
#define log_error(message,...)
Definition log.h:104
int dsend_packet_unit_get_actions(struct connection *pc, int actor_unit_id, int target_unit_id, int target_tile_id, int target_extra_id, int request_kind)
int dsend_packet_nation_select_req(struct connection *pc, int player_no, Nation_type_id nation_no, bool is_male, const char *name, int style)
int dsend_packet_city_name_suggestion_req(struct connection *pc, int unit_id)
struct tile * index_to_tile(const struct civ_map *imap, int mindex)
Definition map.c:471
void put_unit(const struct unit *punit, struct canvas *pcanvas, float zoom, int canvas_x, int canvas_y)
void center_tile_mapcanvas(const struct tile *ptile)
static const void * body(MD5_CTX *ctx, const void *data, unsigned long size)
Definition md5.c:121
#define FC_FREE(ptr)
Definition mem.h:41
const char * move_points_text(int mp, bool reduce)
Definition movement.c:1066
static mpgui * gui
Definition mpgui_qt.cpp:53
const char *const notify_label
Definition fonts.h:28
Nation_type_id nation_number(const struct nation_type *pnation)
Definition nation.c:484
bool nation_leader_is_male(const struct nation_leader *pleader)
Definition nation.c:295
const char * nation_adjective_for_player(const struct player *pplayer)
Definition nation.c:169
const char * nation_adjective_translation(const struct nation_type *pnation)
Definition nation.c:149
struct nation_type * nation_by_number(const Nation_type_id nation)
Definition nation.c:472
int nation_set_index(const struct nation_set *pset)
Definition nation.c:698
bool is_nation_pickable(const struct nation_type *nation)
Definition nation.c:188
const struct nation_leader_list * nation_leaders(const struct nation_type *pnation)
Definition nation.c:231
const char * nation_set_name_translation(const struct nation_set *pset)
Definition nation.c:815
bool is_nation_playable(const struct nation_type *nation)
Definition nation.c:201
bool nation_is_in_group(const struct nation_type *pnation, const struct nation_group *pgroup)
Definition nation.c:1088
const char * nation_set_description(const struct nation_set *pset)
Definition nation.c:824
const char * nation_group_name_translation(const struct nation_group *pgroup)
Definition nation.c:1080
int nation_set_count(void)
Definition nation.c:690
struct nation_group * nation_group_by_number(int id)
Definition nation.c:999
struct nation_set * nation_set_by_rule_name(const char *name)
Definition nation.c:779
bool is_nation_group_hidden(struct nation_group *pgroup)
Definition nation.c:1051
struct nation_set * nation_set_by_setting_value(const char *setting)
Definition nation.c:853
const char * nation_leader_name(const struct nation_leader *pleader)
Definition nation.c:287
int nation_group_count(void)
Definition nation.c:929
const char * nation_set_rule_name(const struct nation_set *pset)
Definition nation.c:806
struct nation_style * style_of_nation(const struct nation_type *pnation)
Definition nation.c:670
#define nation_leader_list_iterate(leaderlist, pleader)
Definition nation.h:57
#define nation_sets_iterate_end
Definition nation.h:333
#define nation_sets_iterate(NAME_pset)
Definition nation.h:329
#define nations_iterate_end
Definition nation.h:364
#define nations_iterate(NAME_pnation)
Definition nation.h:361
#define nation_leader_list_iterate_end
Definition nation.h:59
const struct option_set * server_optset
Definition options.c:4369
bool option_str_set(struct option *poption, const char *str)
Definition options.c:977
const char * option_str_get(const struct option *poption)
Definition options.c:944
struct option * optset_option_by_name(const struct option_set *poptset, const char *name)
Definition options.c:482
#define REQEST_PLAYER_INITIATED
Definition packets.h:63
void start_revolution(void)
Definition packhand.c:2415
void set_government_choice(struct government *government)
Definition packhand.c:2401
char * lines
Definition packhand.c:133
int player_number(const struct player *pplayer)
Definition player.c:826
const char * research_advance_name_translation(const struct research *presearch, Tech_type_id tech)
Definition research.c:276
struct research * research_get(const struct player *pplayer)
Definition research.c:130
enum tech_state research_invention_state(const struct research *presearch, Tech_type_id tech)
Definition research.c:622
bool research_invention_gettable(const struct research *presearch, const Tech_type_id tech, bool allow_holes)
Definition research.c:696
const char * sex_name_translation(sex_t kind)
Definition sex.c:60
@ SEX_FEMALE
Definition sex.h:22
@ SEX_MALE
Definition sex.h:23
#define ARRAY_SIZE(x)
Definition shared.h:85
size_t size
Definition specvec.h:72
struct sprite int int y
Definition sprite_g.h:31
struct sprite int x
Definition sprite_g.h:31
struct sprite int int int int struct sprite int int float bool smooth get_sprite_dimensions
Definition sprite_g.h:36
QPixmap map_pixmap
Definition canvas.h:25
Definition city.h:318
struct packet_ruleset_control control
Definition game.h:83
struct packet_game_info info
Definition game.h:89
struct connection conn
Definition client_main.h:96
Definition colors.h:21
struct player * playing
Definition connection.h:151
Definition mapimg.c:367
Definition climisc.h:82
struct universal item
Definition climisc.h:83
struct player * player
Definition nation.h:118
bool tech_steal_allow_holes
char preferred_musicset[MAX_LEN_NAME]
char preferred_tileset[MAX_LEN_NAME]
char preferred_soundset[MAX_LEN_NAME]
int revolution_finishes
Definition player.h:273
char name[MAX_LEN_NAME]
Definition player.h:251
Definition menu.h:161
QPixmap * pm
Definition sprite.h:25
Definition tile.h:50
int index
Definition tile.h:51
struct unit_list * units
Definition tile.h:58
int move_rate
Definition unittype.h:524
Definition unit.h:139
int moves_left
Definition unit.h:151
int id
Definition unit.h:146
int hp
Definition unit.h:152
int fuel
Definition unit.h:154
struct tile * tile
Definition unit.h:141
struct unit::@84::@86 client
struct act_prob * act_prob_cache
Definition unit.h:230
int homecity
Definition unit.h:147
struct civ_map map
const char * style_name_translation(const struct nation_style *pstyle)
Definition style.c:95
int style_number(const struct nation_style *pstyle)
Definition style.c:68
int basic_city_style_for_style(struct nation_style *pstyle)
Definition style.c:204
#define styles_iterate(_p)
Definition style.h:48
#define styles_iterate_end
Definition style.h:54
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:925
#define sz_strlcpy(dest, src)
Definition support.h:195
#define TRUE
Definition support.h:46
#define FALSE
Definition support.h:47
#define is_svg_flag_enabled()
Definition svgflag.h:30
#define advance_index_iterate_end
Definition tech.h:246
#define A_FIRST
Definition tech.h:44
#define A_UNSET
Definition tech.h:48
#define advance_index_iterate(_start, _index)
Definition tech.h:242
struct extra_type * get_preferred_pillage(bv_extras extras)
Definition terrain.c:553
bool get_units_upgrade_info(char *buf, size_t bufsz, struct unit_list *punits)
Definition text.c:1310
const char * get_act_sel_action_custom_text(struct action *paction, const struct act_prob prob, const struct unit *actor_unit, const struct city *target_city)
Definition text.c:1763
const char * act_sel_action_tool_tip(const struct action *paction, const struct act_prob prob)
Definition text.c:1868
struct city * tile_city(const struct tile *ptile)
Definition tile.c:83
#define tile_index(_pt_)
Definition tile.h:89
#define TILE_INDEX_NONE
Definition tile.h:48
int tileset_hex_width(const struct tileset *t)
Definition tilespec.c:747
int tileset_unit_width(const struct tileset *t)
Definition tilespec.c:823
int tileset_unit_height(const struct tileset *t)
Definition tilespec.c:831
struct sprite * load_popup_sprite(const char *tag)
Definition tilespec.c:7841
bool tileset_is_isometric(const struct tileset *t)
Definition tilespec.c:738
struct sprite * get_sample_city_sprite(const struct tileset *t, int style_idx)
Definition tilespec.c:7109
const char * tileset_basename(const struct tileset *t)
Definition tilespec.c:730
int tileset_hex_height(const struct tileset *t)
Definition tilespec.c:756
void unload_popup_sprite(const char *tag)
Definition tilespec.c:7849
struct sprite * get_nation_flag_sprite(const struct tileset *t, const struct nation_type *pnation)
Definition tilespec.c:7006
void tileset_error(enum log_level level, const char *tset_name, const char *format,...)
Definition tilespec.c:650
bool tilespec_reread(const char *new_tileset_name, bool game_fully_initialized, float scale)
Definition tilespec.c:1401
struct unit * transporter_for_unit_at(const struct unit *pcargo, const struct tile *ptile)
Definition unit.c:1978
bool could_unit_load(const struct unit *pcargo, const struct unit *ptrans)
Definition unit.c:741
bool unit_can_do_action(const struct unit *punit, const action_id act_id)
Definition unit.c:402
void unit_activity_astr(const struct unit *punit, struct astring *astr)
Definition unit.c:1209
#define unit_tile(_pu)
Definition unit.h:408
#define unit_owner(_pu)
Definition unit.h:407
#define unit_list_iterate(unitlist, punit)
Definition unitlist.h:31
#define unit_list_iterate_end
Definition unitlist.h:33
const struct unit_type * unit_type_get(const struct unit *punit)
Definition unittype.c:126
const char * unit_name_translation(const struct unit *punit)
Definition unittype.c:1595
#define utype_fuel(ptype)
Definition unittype.h:849