Freeciv-3.3
Loading...
Searching...
No Matches
dialogs.cpp
Go to the documentation of this file.
1/***********************************************************************
2 Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
6 any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12***********************************************************************/
13
14#ifdef HAVE_CONFIG_H
15#include <fc_config.h>
16#endif
17
18// Qt
19#include <QApplication>
20#include <QButtonGroup>
21#include <QComboBox>
22#include <QGroupBox>
23#include <QHeaderView>
24#include <QImage>
25#include <QMessageBox>
26#include <QMouseEvent>
27#include <QPainter>
28#include <QPainterPath>
29#include <QRadioButton>
30#include <QRect>
31#include <QTableWidgetItem>
32#include <QTextEdit>
33#include <QVBoxLayout>
34#include <QWindow>
35#include <QtMath>
36
37// utility
38#include "astring.h"
39
40// common
41#include "actions.h"
42#include "city.h"
43#include "game.h"
44#include "government.h"
45#include "improvement.h"
46#include "movement.h"
47#include "nation.h"
48#include "research.h"
49#include "sex.h"
50
51// client
52#include "audio.h"
53#include "chatline_common.h"
54#include "client_main.h"
55#include "control.h"
56#include "helpdata.h"
57#include "packhand.h"
58#include "svgflag.h"
59#include "text.h"
60#include "tilespec.h"
61
62// gui-qt
63#include "dialogs.h"
64#include "fc_client.h"
65#include "gui_main.h"
66#include "hudwidget.h"
67#include "qtg_cxxside.h"
68#include "sprite.h"
69
70// Locations for non action enabler controlled buttons.
71#define BUTTON_WAIT (ACTION_COUNT + 1)
72#define BUTTON_CANCEL (BUTTON_WAIT + 1)
73#define BUTTON_COUNT (BUTTON_CANCEL + 1)
74
76extern void popdown_players_report();
77extern void popdown_economy_report();
78extern void popdown_units_report();
79extern void popdown_science_report();
80extern void popdown_city_report();
81extern void popdown_endgame_report();
82
83static void spy_request_strike_bld_list(QVariant data1, QVariant data2);
84static void diplomat_incite(QVariant data1, QVariant data2);
85static void diplomat_incite_escape(QVariant data1, QVariant data2);
86static void spy_request_sabotage_list(QVariant data1, QVariant data2);
87static void spy_request_sabotage_esc_list(QVariant data1, QVariant data2);
88static void spy_sabotage(QVariant data1, QVariant data2);
89static void spy_steal(QVariant data1, QVariant data2);
90static void spy_steal_esc(QVariant data1, QVariant data2);
91static void spy_steal_something(QVariant data1, QVariant data2);
92static void diplomat_steal(QVariant data1, QVariant data2);
93static void diplomat_steal_esc(QVariant data1, QVariant data2);
94static void spy_poison(QVariant data1, QVariant data2);
95static void spy_poison_esc(QVariant data1, QVariant data2);
96static void spy_steal_gold(QVariant data1, QVariant data2);
97static void spy_steal_gold_esc(QVariant data1, QVariant data2);
98static void spy_steal_maps(QVariant data1, QVariant data2);
99static void spy_steal_maps_esc(QVariant data1, QVariant data2);
100static void spy_escape(QVariant data1, QVariant data2);
101static void spy_nuke_city(QVariant data1, QVariant data2);
102static void spy_nuke_city_esc(QVariant data1, QVariant data2);
103static void nuke_city(QVariant data1, QVariant data2);
104static void destroy_city(QVariant data1, QVariant data2);
105static void diplomat_embassy(QVariant data1, QVariant data2);
106static void spy_embassy(QVariant data1, QVariant data2);
107static void spy_sabotage_unit(QVariant data1, QVariant data2);
108static void spy_sabotage_unit_esc(QVariant data1, QVariant data2);
109static void spy_investigate(QVariant data1, QVariant data2);
110static void diplomat_investigate(QVariant data1, QVariant data2);
111static void diplomat_sabotage(QVariant data1, QVariant data2);
112static void diplomat_sabotage_esc(QVariant data1, QVariant data2);
113static void diplomat_bribe(QVariant data1, QVariant data2);
114static void caravan_marketplace(QVariant data1, QVariant data2);
115static void caravan_establish_trade(QVariant data1, QVariant data2);
116static void caravan_help_build(QVariant data1, QVariant data2);
117static void unit_disband_recover(QVariant data1, QVariant data2);
118static void capture_units(QVariant data1, QVariant data2);
119static void nuke_units(QVariant data1, QVariant data2);
120static void wipe_units(QVariant data1, QVariant data2);
121static void expel_unit(QVariant data1, QVariant data2);
122static void bombard(QVariant data1, QVariant data2);
123static void bombard2(QVariant data1, QVariant data2);
124static void bombard3(QVariant data1, QVariant data2);
125static void bombard_lethal(QVariant data1, QVariant data2);
126static void found_city(QVariant data1, QVariant data2);
127static void transform_terrain(QVariant data1, QVariant data2);
128static void cultivate(QVariant data1, QVariant data2);
129static void plant(QVariant data1, QVariant data2);
130static void pillage(QVariant data1, QVariant data2);
131static void clean(QVariant data1, QVariant data2);
132static void road(QVariant data1, QVariant data2);
133static void base(QVariant data1, QVariant data2);
134static void mine(QVariant data1, QVariant data2);
135static void irrigate(QVariant data1, QVariant data2);
136static void nuke(QVariant data1, QVariant data2);
137static void attack(QVariant data1, QVariant data2);
138static void suicide_attack(QVariant data1, QVariant data2);
139static void paradrop(QVariant data1, QVariant data2);
140static void paradrop_conquer(QVariant data1, QVariant data2);
141static void paradrop_frighten(QVariant data1, QVariant data2);
142static void paradrop_frighten_conquer(QVariant data1, QVariant data2);
143static void paradrop_enter(QVariant data1, QVariant data2);
144static void paradrop_enter_conquer(QVariant data1, QVariant data2);
145static void disembark1(QVariant data1, QVariant data2);
146static void disembark2(QVariant data1, QVariant data2);
147static void enter_hut(QVariant data1, QVariant data2);
148static void enter_hut2(QVariant data1, QVariant data2);
149static void frighten_hut(QVariant data1, QVariant data2);
150static void frighten_hut2(QVariant data1, QVariant data2);
151static void regular_move(QVariant data1, QVariant data2);
152static void convert_unit(QVariant data1, QVariant data2);
153static void fortify(QVariant data1, QVariant data2);
154static void disband_unit(QVariant data1, QVariant data2);
155static void homeless(QVariant data1, QVariant data2);
156static void join_city(QVariant data1, QVariant data2);
157static void unit_home_city(QVariant data1, QVariant data2);
158static void unit_upgrade(QVariant data1, QVariant data2);
159static void airlift(QVariant data1, QVariant data2);
160static void conquer_city(QVariant data1, QVariant data2);
161static void conquer_city2(QVariant data1, QVariant data2);
162static void conquer_extras(QVariant data1, QVariant data2);
163static void conquer_extras2(QVariant data1, QVariant data2);
164static void heal_unit(QVariant data1, QVariant data2);
165static void heal_unit2(QVariant data1, QVariant data2);
166static void transport_board(QVariant data1, QVariant data2);
167static void transport_board2(QVariant data1, QVariant data2);
168static void transport_board3(QVariant data1, QVariant data2);
169static void transport_embark(QVariant data1, QVariant data2);
170static void transport_embark2(QVariant data1, QVariant data2);
171static void transport_embark3(QVariant data1, QVariant data2);
172static void transport_embark4(QVariant data1, QVariant data2);
173static void transport_deboard(QVariant data1, QVariant data2);
174static void transport_unload(QVariant data1, QVariant data2);
175static void transport_load(QVariant data1, QVariant data2);
176static void transport_load2(QVariant data1, QVariant data2);
177static void transport_load3(QVariant data1, QVariant data2);
178static void keep_moving(QVariant data1, QVariant data2);
179static void pillage_something(QVariant data1, QVariant data2);
180static void action_entry(choice_dialog *cd,
181 action_id act,
182 const struct act_prob *act_probs,
183 const char *custom,
184 QVariant data1, QVariant data2);
185
186
187static bool is_showing_pillage_dialog = false;
189static bool is_race_dialog_open = false;
190
191/* Information used in action selection follow up questions. Can't be
192 * stored in the action selection dialog since it is closed before the
193 * follow up question is asked. */
195
196/* Don't remove a unit's action decision want or move on to the next actor
197 unit that wants a decision in the current unit selection. */
198static bool did_not_decide = false;
199
200extern char forced_tileset_name[512];
202
203/***********************************************************************/
208{
210
211 // Unit acting against a city target.
250
251 // Unit acting against a unit target.
270
271 // Unit acting against all units at a tile.
278
279 // Unit acting against a tile.
308
309 // Unit acting against all tile extras.
312
313 // Unit acting with no target except itself.
318
319 return action_function;
320}
321
322/* Mapping from an action to the function to call when its button is
323 * pushed. */
325
326/***********************************************************************/
331{
332 titlebar_height = 0;
333 moving_now = false;
334 setSizeGripEnabled(true);
336}
337
338/***********************************************************************/
342{
343 raise();
344}
345
346/***********************************************************************/
350{
352
353 QPainter p(this);
356 QStyle *style = this->style();
357 QRect active_area = this->rect();
360
361 qpal.setColor(QPalette::Active, QPalette::ToolTipText, Qt::white);
362 tbar_opt.initFrom(this);
363 titlebar_height = style->pixelMetric(QStyle::PM_TitleBarHeight,
364 &tbar_opt, this) + 2;
365 close_pix = close_pix.scaledToHeight(titlebar_height);
366 tbar_opt.rect = QRect(0, 0, this->width(), titlebar_height);
367 text_rect = QRect(0, 0, this->width() - close_pix.width() , titlebar_height);
368 close_rect = QRect(this->width() - close_pix.width(), 0, this->width(),
370 tbar_opt.titleBarState = this->windowState();
371 tbar_opt.text = tbar_opt.fontMetrics.elidedText(this->windowTitle(),
372 Qt::ElideRight,
373 text_rect.width());
374 style->drawComplexControl(QStyle::CC_TitleBar, &tbar_opt, &p, this);
375 style->drawItemText(&p, text_rect, Qt::AlignCenter, qpal,
376 true, tbar_opt.text, QPalette::ToolTipText);
377 style->drawItemPixmap(&p, close_rect, Qt::AlignLeft,
378 close_pix.scaledToHeight(titlebar_height));
379
380 active_area.setTopLeft(QPoint(0, titlebar_height));
381 this->setContentsMargins(0, titlebar_height, 0, 0);
382 win_opt.initFrom(this);
383 win_opt.rect = active_area;
384 style->drawPrimitive(QStyle::PE_Widget, &win_opt, &p, this);
385}
386
387/***********************************************************************/
396
397/***********************************************************************/
401{
402 QPoint pos = event->pos();
403 int x = pos.x();
404 int y = pos.y();
405
406 if (y <= titlebar_height
407 && x <= width() - close_pix.width()) {
408 point = mevent_gpos(event) - geometry().topLeft();
409 moving_now = true;
410 setCursor(Qt::SizeAllCursor);
411 } else if (y <= titlebar_height
412 && x > width() - close_pix.width()) {
413 close();
414 }
415}
416
417/***********************************************************************/
421{
422 moving_now = false;
423 setCursor(Qt::ArrowCursor);
424}
425
426/***********************************************************************/
430 QWidget *parent) : qfc_dialog(parent)
431{
432 int i;
436 QPixmap *pix;
437 QHeaderView *header;
438 QSize size;
440 QLabel *ns_label;
441
442 setAttribute(Qt::WA_DeleteOnClose);
443 is_race_dialog_open = true;
445 selected_nation_tabs = new QTableWidget;
446 nation_tabs = new QTableWidget();
447 styles = new QTableWidget;
448 ok_button = new QPushButton;
450 ns_label = new QLabel;
451 tplayer = pplayer;
452
453 selected_nation = -1;
454 selected_style = -1;
455 setWindowTitle(_("Select Nation"));
456 selected_nation_tabs->setRowCount(0);
457 selected_nation_tabs->setColumnCount(1);
458 selected_nation_tabs->setSelectionMode(QAbstractItemView::SingleSelection);
459 selected_nation_tabs->verticalHeader()->setVisible(false);
460 selected_nation_tabs->horizontalHeader()->setVisible(false);
461 selected_nation_tabs->setProperty("showGrid", "true");
462 selected_nation_tabs->setEditTriggers(QAbstractItemView::NoEditTriggers);
463 selected_nation_tabs->setShowGrid(false);
464 selected_nation_tabs->setAlternatingRowColors(true);
465
466 nation_tabs->setRowCount(0);
467 nation_tabs->setColumnCount(1);
468 nation_tabs->setSelectionMode(QAbstractItemView::SingleSelection);
469 nation_tabs->verticalHeader()->setVisible(false);
470 nation_tabs->horizontalHeader()->setVisible(false);
471 nation_tabs->setProperty("showGrid", "true");
472 nation_tabs->setEditTriggers(QAbstractItemView::NoEditTriggers);
473 nation_tabs->setShowGrid(false);
474 ns_label->setText(_("Nation Set:"));
475 styles->setRowCount(0);
476 styles->setColumnCount(2);
477 styles->setSelectionMode(QAbstractItemView::SingleSelection);
478 styles->verticalHeader()->setVisible(false);
479 styles->horizontalHeader()->setVisible(false);
480 styles->setProperty("showGrid", "false");
481 styles->setProperty("selectionBehavior", "SelectRows");
482 styles->setEditTriggers(QAbstractItemView::NoEditTriggers);
483 styles->setShowGrid(false);
484
486 no_name = new QGroupBox(parent);
490 sex_buttons->addButton(is_male, SEX_MALE);
492 sex_buttons->addButton(is_female, SEX_FEMALE);
493
494 leader_name->setEditable(true);
495 qgroupbox_layout->addWidget(leader_name, 1, 0, 1, 2);
496 qgroupbox_layout->addWidget(is_male, 2, 1);
497 qgroupbox_layout->addWidget(is_female, 2, 0);
500 no_name->setLayout(qgroupbox_layout);
501
503 description->setReadOnly(true);
504 description->setPlainText(_("Choose nation"));
505 no_name->setTitle(_("Your leader name"));
506
507 // Fill styles, no need to update them later
508
511
512 if (i >= 0) {
514 styles->insertRow(i);
516 item->setData(Qt::DecorationRole, *pix);
517 item->setData(Qt::UserRole, style_number(pstyle));
518 size.setWidth(pix->width());
519 size.setHeight(pix->height());
520 item->setSizeHint(size);
521 styles->setItem(i, 0, item);
524 styles->setItem(i, 1, item);
525 }
527
528 header = styles->horizontalHeader();
529 header->setSectionResizeMode(QHeaderView::Stretch);
530 header->resizeSections(QHeaderView::ResizeToContents);
531 header = styles->verticalHeader();
532 header->resizeSections(QHeaderView::ResizeToContents);
537 // Create nation sets
538 refresh();
539
540 connect(styles->selectionModel(),
542 const QItemSelection &)),
544 const QItemSelection &)));
545 connect(selected_nation_tabs->selectionModel(),
547 const QItemSelection &)),
549 const QItemSelection &)));
551 SLOT(leader_selected(int)));
552 connect(leader_name->lineEdit(), &QLineEdit::returnPressed,
555 SLOT(nationset_changed(int)));
556 connect(nation_tabs->selectionModel(),
558 const QItemSelection &)),
560 const QItemSelection &)));
561
562 ok_button = new QPushButton;
563 ok_button->setText(_("Cancel"));
564 connect(ok_button, &QAbstractButton::pressed, this, &races_dialog::cancel_pressed);
565 main_layout->addWidget(ok_button, 8, 2, 1, 1);
566 random_button = new QPushButton;
567 random_button->setText(_("Random"));
568 connect(random_button, &QAbstractButton::pressed, this, &races_dialog::random_pressed);
569 main_layout->addWidget(random_button, 8, 0, 1, 1);
570 ok_button = new QPushButton;
571 ok_button->setText(_("Ok"));
572 connect(ok_button, &QAbstractButton::pressed, this, &races_dialog::ok_pressed);
573 main_layout->addWidget(ok_button, 8, 3, 1, 1);
574 main_layout->addWidget(no_name, 0, 3, 2, 1);
575 if (nation_set_count() > 1) {
576 main_layout->addWidget(ns_label, 0, 0, 1, 1);
577 main_layout->addWidget(qnation_set, 0, 1, 1, 1);
578 main_layout->addWidget(nation_tabs, 1, 0, 5, 2);
579 } else {
580 main_layout->addWidget(nation_tabs, 0, 0, 6, 2);
581 }
582 main_layout->addWidget(styles, 2, 3, 4, 1);
583 main_layout->addWidget(description, 6, 0, 2, 4);
584 main_layout->addWidget(selected_nation_tabs, 0, 2, 6, 1);
585
587 set_index(-99);
588
589 if (C_S_RUNNING == client_state()) {
590 title = _("Edit Nation");
591 } else if (pplayer != nullptr && pplayer == client_player()) {
592 title = _("What Nation Will You Be?");
593 } else {
594 title = _("Pick Nation");
595 }
596
599}
600
601/***********************************************************************/
608
609/***********************************************************************/
613{
614 struct nation_group *group;
616 QHeaderView *header;
617 int i;
618 int count;
619
620 nation_tabs->clearContents();
621 nation_tabs->setRowCount(0);
622 nation_tabs->insertRow(0);
624 item->setText(_("All nations"));
625 item->setData(Qt::UserRole, -99);
626 nation_tabs->setItem(0, 0, item);
627
628 for (i = 1; i < nation_group_count() + 1; i++) {
629 group = nation_group_by_number(i - 1);
630 if (is_nation_group_hidden(group)) {
631 continue;
632 }
633 count = 0;
634 // Checking if group is empty
635 nations_iterate(pnation) {
636 if (!is_nation_playable(pnation)
637 || !is_nation_pickable(pnation)
638 || !nation_is_in_group(pnation, group)) {
639 continue;
640 }
641 count ++;
643 if (count == 0) {
644 continue;
645 }
646 nation_tabs->insertRow(i);
648 item->setData(Qt::UserRole, i - 1);
649 item->setText(nation_group_name_translation(group));
650 nation_tabs->setItem(i, 0, item);
651 }
652 header = nation_tabs->horizontalHeader();
653 header->resizeSections(QHeaderView::Stretch);
654 header = nation_tabs->verticalHeader();
655 header->resizeSections(QHeaderView::ResizeToContents);
656 set_index(-99);
657}
658
659/***********************************************************************/
663{
664 struct option *popt;
665 struct nation_set *s;
666
668 if (popt) {
670 qnation_set->setCurrentIndex(nation_set_index(s));
671 qnation_set->setToolTip(_(nation_set_description(s)));
672 }
673}
674
675/***********************************************************************/
679 const QItemSelection &ds)
680{
681 QModelIndexList indexes = sl.indexes();
682 QModelIndex index ;
683
684 if (indexes.isEmpty()) {
685 return;
686 }
687 index = indexes.at(0);
688 set_index(index.row());
689}
690
691
692/***********************************************************************/
697{
699 QPixmap *pix;
700 QFont f;
701 struct nation_group *group;
702 int i;
703 struct sprite *s;
704 QHeaderView *header;
705 bool svg = is_svg_flag_enabled();
706
707 selected_nation_tabs->clearContents();
708 selected_nation_tabs->setRowCount(0);
709
710 last_index = 0;
711 i = nation_tabs->currentRow();
712 if (i != -1) {
713 item = nation_tabs->item(i, 0);
714 index = item->data(Qt::UserRole).toInt();
715 }
716
717 group = nation_group_by_number(index);
718 i = 0;
719 nations_iterate(pnation) {
720 if (!is_nation_playable(pnation)
721 || !is_nation_pickable(pnation)) {
722 continue;
723 }
724 if (!nation_is_in_group(pnation, group) && index != -99) {
725 continue;
726 }
728 selected_nation_tabs->insertRow(i);
729 s = get_nation_flag_sprite(tileset, pnation);
730 if (pnation->player) {
731 f = item->font();
732 f.setStrikeOut(true);
733 item->setFont(f);
734 }
735 pix = s->pm;
736 if (svg) {
737 item->setData(Qt::DecorationRole, (*pix).scaledToHeight(50));
738 } else {
739 item->setData(Qt::DecorationRole, *pix);
740 }
741 item->setData(Qt::UserRole, nation_number(pnation));
742 item->setText(nation_adjective_translation(pnation));
743 selected_nation_tabs->setItem(i, 0, item);
745
746 selected_nation_tabs->sortByColumn(0, Qt::AscendingOrder);
747 header = selected_nation_tabs->horizontalHeader();
748 header->resizeSections(QHeaderView::Stretch);
749 header = selected_nation_tabs->verticalHeader();
750 header->resizeSections(QHeaderView::ResizeToContents);
751}
752
753/***********************************************************************/
758{
759 char buf[4096];
760 QModelIndex index ;
762 QModelIndexList indexes = selected.indexes();
763 QString str;
765 int style, ind;
766
767 if (indexes.isEmpty()) {
768 return;
769 }
770
771 index = indexes.at(0);
772 if (indexes.isEmpty()) {
773 return;
774 }
775 qvar = index.data(Qt::UserRole);
776 selected_nation = qvar.toInt();
777
779 description->setPlainText(buf);
780 leader_name->clear();
781 if (client.conn.playing == tplayer) {
782 leader_name->addItem(client.conn.playing->name, true);
783 }
786 str = QString::fromUtf8(nation_leader_name(pleader));
789
790 // Select style for nation
791
793 qvar = qvar.fromValue<int>(style);
794
795 for (ind = 0; ind < styles->rowCount(); ind++) {
796 item = styles->item(ind, 0);
797
798 if (item->data(Qt::UserRole) == qvar) {
799 styles->selectRow(ind);
800 }
801 }
802}
803
804/***********************************************************************/
809{
810 QModelIndex index ;
812 QModelIndexList indexes = selected.indexes();
813
814 if (indexes.isEmpty()) {
815 return;
816 }
817
818 index = indexes.at(0);
819 qvar = index.data(Qt::UserRole);
820 selected_style = qvar.toInt();
821}
822
823/***********************************************************************/
827{
828 if (leader_name->itemData(index).toBool()) {
829 is_male->setChecked(true);
830 is_female->setChecked(false);
831 } else {
832 is_male->setChecked(false);
833 is_female->setChecked(true);
834 }
835}
836
837/***********************************************************************/
842{
844 struct player *natplr;
845
846 if (selected_nation == -1) {
847 return;
848 }
849
850 if (selected_style == -1) {
851 output_window_append(ftc_client, _("You must select your style."));
852 return;
853 }
854
855 if (leader_name->currentText().length() == 0) {
856 output_window_append(ftc_client, _("You must type a legal name."));
857 return;
858 }
859
861 if (natplr != nullptr && natplr != client_player()) {
863 _("Nation has been chosen by other player"));
864 return;
865 }
866
867 ln_bytes = leader_name->currentText().toUtf8();
869 selected_nation, sex_buttons->checkedId(),
870 ln_bytes.data(),
872 close();
873 deleteLater();
874}
875
876/***********************************************************************/
880 const char *lines, QWidget *parent)
881 : fcwidget()
882{
883 int x, y;
885
886 setAttribute(Qt::WA_DeleteOnClose);
887 setCursor(Qt::ArrowCursor);
889 setFrameStyle(QFrame::Box);
890 cw = new close_widget(this);
891 cw->put_to_corner();
892
896 qlist = qlines.split("\n");
897 small_font = *fc_font::instance()->get_font("gui_qt_font_notify_label");
898 x = 0;
899 y = 0;
900 calc_size(x, y);
901 resize(x, y);
902 gui()->mapview_wdg->find_place(gui()->mapview_wdg->width() - x - 4, 4,
903 x, y, x, y, 0);
904 move(x, y);
905 was_destroyed = false;
906
907}
908
909/***********************************************************************/
913{
914 QString s, q;
915 int i;
919
920 for (i = 0; i < qlist.size(); ++i) {
921 s = qlist.at(i);
922 q = q + s;
923 if (i < qlist.size() - 1) {
924 q = q + QChar('\n');
925 }
926 }
927 capt_bytes = qcaption.toUtf8();
928 hl_bytes = qheadline.toUtf8();
929 qb_bytes = q.toUtf8();
931 hl_bytes.data(),
932 qb_bytes.data());
933 close();
934 destroy();
935}
936
937/***********************************************************************/
941{
943 int i;
944 QStringList str_list;
945
946 str_list = qlist;
947 str_list << qcaption << qheadline;
948
949 for (i = 0; i < str_list.count(); i++) {
950 x = qMax(x, fm.horizontalAdvance(str_list.at(i)));
951 y = y + 3 + fm.height();
952 }
953 x = x + 15;
954}
955
956/***********************************************************************/
960{
961 QPainter painter(this);
962 QPainterPath path;
963 QPen pen;
965 int i;
966
967 pen.setWidth(1);
968 pen.setColor(palette().color(QPalette::Text));
969 painter.setFont(small_font);
970 painter.setPen(pen);
971 painter.drawText(10, fm.height() + 3, qcaption);
972 painter.drawText(10, 2 * fm.height() + 6, qheadline);
973 for (i = 0; i < qlist.count(); i++) {
974 painter.drawText(10, 3 + (fm.height() + 3) * (i + 3), qlist[i]);
975 }
976 cw->put_to_corner();
977}
978
979/***********************************************************************/
983{
984 cursor = mevent_gpos(event) - geometry().topLeft();
985
986 if (event->button() == Qt::RightButton) {
987 was_destroyed = true;
988 close();
989 }
990}
991
992/***********************************************************************/
996{
998
999 setCursor(Qt::SizeAllCursor);
1000}
1001
1002/***********************************************************************/
1006{
1007 setCursor(Qt::ArrowCursor);
1008}
1009
1010/***********************************************************************/
1014{
1015 was_destroyed = true;
1016 destroy();
1017}
1018
1019/***********************************************************************/
1025{
1026 was_destroyed = true;
1027 destroy();
1028}
1029
1030/***********************************************************************/
1034{
1035 vs_city = -1;
1036 vs_unit = -1;
1037}
1038
1039/***********************************************************************/
1043{
1044 if (!m_instance) {
1045 m_instance = new qdef_act;
1046 }
1047 return m_instance;
1048}
1049
1050/***********************************************************************/
1054{
1055 if (m_instance) {
1056 delete m_instance;
1057 m_instance = 0;
1058 }
1059}
1060
1061/***********************************************************************/
1065{
1066 vs_city = i;
1067}
1068
1069/***********************************************************************/
1073{
1074 vs_unit = i;
1075}
1076
1077/***********************************************************************/
1081{
1082 return vs_city;
1083}
1084
1085/***********************************************************************/
1089{
1090 return vs_unit;
1091}
1092
1093/***********************************************************************/
1097{
1098 delete this;
1099}
1100
1101/***********************************************************************/
1105{
1107 false, "", 0);
1108 delete this;
1109}
1110
1111/***********************************************************************/
1114notify_goto::notify_goto(const char *headline, const char *lines,
1115 const struct text_tag_list *tags, tile *ptile,
1116 QWidget *parent): QMessageBox(parent)
1117{
1119 setAttribute(Qt::WA_DeleteOnClose);
1120 goto_but = this->addButton(_("Goto Location"), QMessageBox::ActionRole);
1121 goto_but->setIcon(fc_icons::instance()->get_icon("go-up"));
1122 inspect_but = this->addButton(_("Inspect City"), QMessageBox::ActionRole);
1123 inspect_but->setIcon(fc_icons::instance()->get_icon("plus"));
1124
1125 close_but = this->addButton(QMessageBox::Close);
1126 gtile = ptile;
1127 if (!gtile) {
1128 goto_but->setVisible(false);
1129 inspect_but->setVisible(false);
1130 } else {
1131 struct city *pcity = tile_city(gtile);
1132 inspect_but->setVisible(pcity != nullptr
1133 && city_owner(pcity) == client.conn.playing);
1134 }
1136 qlines = lines;
1137 qlines.replace("\n", " ");
1138 setText(qlines);
1139 connect(goto_but, &QAbstractButton::pressed, this, &notify_goto::goto_tile);
1140 connect(inspect_but, &QAbstractButton::pressed, this, &notify_goto::inspect_city);
1141 connect(close_but, &QAbstractButton::pressed, this, &QWidget::close);
1142 show();
1143}
1144
1145/***********************************************************************/
1149{
1151 close();
1152}
1153
1154/***********************************************************************/
1158{
1159 struct city *pcity = tile_city(gtile);
1160 if (pcity) {
1162 }
1163 close();
1164}
1165
1166/***********************************************************************/
1170{
1171 QString rule_name;
1173 const char *rn;
1174 struct option *poption = optset_option_by_name(server_optset, "nationset");
1175
1176 rule_name = qnation_set->currentData().toString();
1177 rn_bytes = rule_name.toUtf8(); /* Hold QByteArray in a variable to
1178 * extend its, and data() buffer's,
1179 * lifetime */
1180 rn = rn_bytes.data();
1184 }
1185}
1186
1187/***********************************************************************/
1192void popup_notify_goto_dialog(const char *headline, const char *lines,
1193 const struct text_tag_list *tags,
1194 struct tile *ptile)
1195{
1196 notify_goto *ask = new notify_goto(headline, lines, tags, ptile,
1197 gui()->central_wdg);
1198 ask->show();
1199}
1200
1201/***********************************************************************/
1204void popup_connect_msg(const char *headline, const char *message)
1205{
1206 QMessageBox *msg = new QMessageBox(gui()->central_wdg);
1207
1208 msg->setText(message);
1209 msg->setStandardButtons(QMessageBox::Ok);
1210 msg->setWindowTitle(headline);
1211 msg->setAttribute(Qt::WA_DeleteOnClose);
1212 msg->show();
1213}
1214
1215/***********************************************************************/
1218void popup_notify_dialog(const char *caption, const char *headline,
1219 const char *lines)
1220{
1222 gui()->mapview_wdg);
1223 nd->show();
1224}
1225
1226/***********************************************************************/
1229void popup_races_dialog(struct player *pplayer)
1230{
1231 if (!is_race_dialog_open) {
1232 race_dialog = new races_dialog(pplayer, gui()->central_wdg);
1233 is_race_dialog_open = true;
1234 race_dialog->show();
1235 }
1236 race_dialog->showNormal();
1237}
1238
1239/***********************************************************************/
1244{
1245 if (is_race_dialog_open) {
1246 race_dialog->close();
1247 is_race_dialog_open = false;
1248 }
1249}
1250
1251/***********************************************************************/
1255{
1256 if (ptile != nullptr
1257 && (unit_list_size(ptile->units) > 1
1258 || (unit_list_size(ptile->units) == 1 && tile_city(ptile)))) {
1259 gui()->toggle_unit_sel_widget(ptile);
1260 }
1261}
1262
1263/***********************************************************************/
1267{
1268 gui()->update_unit_sel();
1269}
1270
1271/***********************************************************************/
1280
1281/***********************************************************************/
1284void races_update_pickable(bool nationset_change)
1285{
1286 if (is_race_dialog_open) {
1288 }
1289}
1290
1291/***********************************************************************/
1296{
1297 if (is_race_dialog_open) {
1299 }
1300}
1301
1302/***********************************************************************/
1306{
1309 = (gov != nullptr ? government_number(gov) : G_LAST);
1310
1312 ask = new hud_message_box(gui()->central_wdg);
1313 ask->setStandardButtons(QMessageBox::Cancel | QMessageBox::Ok);
1314 ask->setDefaultButton(QMessageBox::Cancel);
1315 ask->set_text_title(_("You say you wanna revolution?"),
1316 _("Revolution!"));
1317 ask->setAttribute(Qt::WA_DeleteOnClose);
1318 QObject::connect(ask, &hud_message_box::accepted, [=]() {
1319 if (government_id == G_LAST) {
1320 revolution_response(nullptr);
1321 } else {
1323
1324 if (government) {
1326 }
1327 }
1328 });
1329 ask->show();
1330 } else {
1332 }
1333}
1334
1335/***********************************************************************/
1348
1349/***********************************************************************/
1356
1357/***********************************************************************/
1365
1366/***********************************************************************/
1374
1375/***********************************************************************/
1382
1383/***********************************************************************/
1390
1391/***********************************************************************/
1395 QWidget *parent,
1396 void (*run_on_close_in)(int)): QWidget(parent)
1397{
1398 QLabel *l = new QLabel(text);
1399
1400 setProperty("themed_choice", true);
1401 layout = new QVBoxLayout(this);
1403
1404 layout->addWidget(l);
1405 setWindowFlags(Qt::Dialog);
1407 setAttribute(Qt::WA_DeleteOnClose);
1408 gui()->set_diplo_dialog(this);
1409
1421
1422 targeted_unit = nullptr;
1423 // No buttons are added yet.
1424 for (int i = 0; i < BUTTON_COUNT; i++) {
1425 action_button_map << nullptr;
1426 }
1427}
1428
1429/***********************************************************************/
1433{
1434 buttons_list.clear();
1435 action_button_map.clear();
1436 gui()->set_diplo_dialog(nullptr);
1437
1438 if (run_on_close) {
1440 run_on_close = nullptr;
1441 }
1442}
1443
1444/***********************************************************************/
1448{
1450
1453 struct canvas *pix;
1454 QPushButton *next, *prev;
1455 unit_skip = new QHBoxLayout;
1456 next = new QPushButton();
1457 next->setIcon(fc_icons::instance()->get_icon("city-right"));
1458 next->setIconSize(QSize(32, 32));
1459 next->setFixedSize(QSize(36, 36));
1460 prev = new QPushButton();
1461 prev->setIcon(fc_icons::instance()->get_icon("city-left"));
1462 prev->setIconSize(QSize(32, 32));
1463 prev->setFixedSize(QSize(36, 36));
1464 target_unit_button = new QPushButton;
1467 pix->map_pixmap.fill(Qt::transparent);
1468 put_unit(targeted_unit, pix, 1.0, 0, 0);
1469 target_unit_button->setIcon(QIcon(pix->map_pixmap));
1470 qtg_canvas_free(pix);
1471 target_unit_button->setIconSize(QSize(96, 96));
1472 target_unit_button->setFixedSize(QSize(100, 100));
1473 unit_skip->addStretch(100);
1474 unit_skip->addWidget(prev, Qt::AlignCenter);
1475 unit_skip->addWidget(target_unit_button, Qt::AlignCenter);
1476 unit_skip->addWidget(next, Qt::AlignCenter);
1477 layout->addLayout(unit_skip);
1478 unit_skip->addStretch(100);
1479 connect(prev, &QAbstractButton::clicked, this, &choice_dialog::prev_unit);
1480 connect(next, &QAbstractButton::clicked, this, &choice_dialog::next_unit);
1481 }
1482
1484}
1485
1486/***********************************************************************/
1490 QVariant data2, QString tool_tip = "",
1491 const int button_id = -1)
1492{
1494 data1, data2);
1495 int action = buttons_list.count();
1496
1497 QObject::connect(button, &QPushButton::clicked,
1500 });
1501
1502 buttons_list.append(button);
1503
1504 if (!tool_tip.isEmpty()) {
1505 button->setToolTip(tool_tip);
1506 }
1507
1508 if (0 <= button_id) {
1509 // The id is valid.
1510 action_button_map[button_id] = button;
1511 }
1512
1513 layout->addWidget(button);
1514}
1515
1516/***********************************************************************/
1520{
1521 QPoint p;
1522
1523 p = mapFromGlobal(QCursor::pos());
1524 p.setY(p.y()-this->height());
1525 p.setX(p.x()-this->width());
1526 move(p);
1527 show();
1528}
1529
1530/***********************************************************************/
1537
1538/***********************************************************************/
1542{
1543 if (id < 0) {
1544 fc_assert_msg(0 <= id, "Invalid button ID.");
1545 return nullptr;
1546 }
1547
1548 return action_button_map[id];
1549}
1550
1551/***********************************************************************/
1555{
1558
1560 if (action == -1) {
1561 return false;
1562 }
1563 func = af_map[action];
1564
1565 func(q1, q2);
1566 return true;
1567}
1568
1569/***********************************************************************/
1573{
1576
1578 if (action == -1) {
1579 return false;
1580 }
1581 func = af_map[action];
1582 func(q1, q2);
1583 return true;
1584}
1585
1586/***********************************************************************/
1590{
1591 struct tile *ptile;
1592 struct unit *new_target = nullptr;
1593 bool break_next = false;
1594 bool first = true;
1595 struct canvas *pix;
1596
1597 if (targeted_unit == nullptr) {
1598 return;
1599 }
1600
1601 ptile = targeted_unit->tile;
1602
1603 unit_list_iterate(ptile->units, ptgt) {
1604 if (first) {
1605 new_target = ptgt;
1606 first = false;
1607 }
1608 if (break_next) {
1609 new_target = ptgt;
1610 break;
1611 }
1612 if (ptgt == targeted_unit) {
1613 break_next = true;
1614 }
1619 pix->map_pixmap.fill(Qt::transparent);
1620 put_unit(targeted_unit, pix, 1.0, 0, 0);
1621 target_unit_button->setIcon(QIcon(pix->map_pixmap));
1622 qtg_canvas_free(pix);
1623 switch_target();
1624}
1625
1626/***********************************************************************/
1630{
1631 struct tile *ptile;
1632 struct unit *new_target = nullptr;
1633 struct canvas *pix;
1634 if (targeted_unit == nullptr) {
1635 return;
1636 }
1637
1638 ptile = targeted_unit->tile;
1639 unit_list_iterate(ptile->units, ptgt) {
1640 if ((ptgt == targeted_unit) && new_target != nullptr) {
1641 break;
1642 }
1643 new_target = ptgt;
1648 pix->map_pixmap.fill(Qt::transparent);
1649 put_unit(targeted_unit, pix, 1.0, 0, 0);
1650 target_unit_button->setIcon(QIcon(pix->map_pixmap));
1651 qtg_canvas_free(pix);
1652 switch_target();
1653}
1654
1655/***********************************************************************/
1659{
1660 if (targeted_unit == nullptr) {
1661 return;
1662 }
1663 unit_skip->setParent(nullptr);
1668 : nullptr),
1669 act_probs);
1670 layout->addLayout(unit_skip);
1671}
1672
1673/***********************************************************************/
1677{
1678 if (targeted_unit == nullptr) {
1679 return;
1680 }
1681
1682 unit_skip->setParent(nullptr);
1684 unit_id,
1689 layout->addLayout(unit_skip);
1690}
1691
1692/***********************************************************************/
1696{
1698 pfcn_void func = button->getFunc();
1699
1700 func(button->getData1(), button->getData2());
1701 close();
1702}
1703
1704/***********************************************************************/
1713{
1714 // Store the data in the stack.
1715 last_buttons_stack.append(button);
1716
1717 /* Temporary remove the button so it will end up below buttons added
1718 * before unstack_all_buttons() is called. */
1719 layout->removeWidget(button);
1720
1721 // Synchronize the list with the layout.
1722 buttons_list.removeAll(button);
1723}
1724
1725/***********************************************************************/
1730{
1731 while (!last_buttons_stack.isEmpty()) {
1732 Choice_dialog_button *button = last_buttons_stack.takeLast();
1733
1734 // Reinsert the button below the other buttons.
1735 buttons_list.append(button);
1736 layout->addWidget(button);
1737 }
1738}
1739
1740/***********************************************************************/
1743static void caravan_marketplace(QVariant data1, QVariant data2)
1744{
1745 int actor_unit_id = data1.toInt();
1746 int target_city_id = data2.toInt();
1747
1748 if (game_unit_by_number(actor_unit_id) != nullptr
1749 && game_city_by_number(target_city_id) != nullptr) {
1751 target_city_id, 0, "");
1752 }
1753}
1754
1755/***********************************************************************/
1759{
1760 int actor_unit_id = data1.toInt();
1761 int target_city_id = data2.toInt();
1762
1763 if (game_unit_by_number(actor_unit_id) != nullptr
1764 && game_city_by_number(target_city_id) != nullptr) {
1766 target_city_id, 0, "");
1767 }
1768}
1769
1770/***********************************************************************/
1773static void caravan_help_build(QVariant data1, QVariant data2)
1774{
1775 int caravan_id = data1.toInt();
1776 int caravan_target_id = data2.toInt();
1777
1778 if (game_unit_by_number(caravan_id) != nullptr
1779 && game_city_by_number(caravan_target_id) != nullptr) {
1782 }
1783}
1784
1785/***********************************************************************/
1788static void unit_disband_recover(QVariant data1, QVariant data2)
1789{
1790 int actor_id = data1.toInt();
1791 int tgt_city_id = data2.toInt();
1792
1793 if (game_unit_by_number(actor_id) != nullptr
1794 && game_city_by_number(tgt_city_id) != nullptr) {
1796 actor_id, tgt_city_id, 0, "");
1797 }
1798}
1799
1800/***********************************************************************/
1803static void unit_home_city(QVariant data1, QVariant data2)
1804{
1805 int actor_id = data1.toInt();
1806 int tgt_city_id = data2.toInt();
1807
1808 if (game_unit_by_number(actor_id) != nullptr
1809 && game_city_by_number(tgt_city_id) != nullptr) {
1811 actor_id, tgt_city_id, 0, "");
1812 }
1813}
1814
1815/***********************************************************************/
1818static void unit_upgrade(QVariant data1, QVariant data2)
1819{
1820 struct unit *punit;
1821
1822 int actor_id = data1.toInt();
1823 int tgt_city_id = data2.toInt();
1824
1825 if ((punit = game_unit_by_number(actor_id)) != nullptr
1826 && game_city_by_number(tgt_city_id) != nullptr) {
1827 struct unit_list *as_list;
1828
1833 }
1834}
1835
1836/***********************************************************************/
1839static void airlift(QVariant data1, QVariant data2)
1840{
1841 int actor_id = data1.toInt();
1842 int tgt_city_id = data2.toInt();
1843
1844 if (game_unit_by_number(actor_id) != nullptr
1845 && game_city_by_number(tgt_city_id) != nullptr) {
1847 actor_id, tgt_city_id, 0, "");
1848 }
1849}
1850
1851/***********************************************************************/
1854static void conquer_city(QVariant data1, QVariant data2)
1855{
1856 int actor_id = data1.toInt();
1857 int tgt_city_id = data2.toInt();
1858
1859 if (game_unit_by_number(actor_id) != nullptr
1860 && game_city_by_number(tgt_city_id) != nullptr) {
1862 actor_id, tgt_city_id, 0, "");
1863 }
1864}
1865
1866/***********************************************************************/
1869static void conquer_city2(QVariant data1, QVariant data2)
1870{
1871 int actor_id = data1.toInt();
1872 int tgt_city_id = data2.toInt();
1873
1874 if (game_unit_by_number(actor_id) != nullptr
1875 && game_city_by_number(tgt_city_id) != nullptr) {
1877 actor_id, tgt_city_id, 0, "");
1878 }
1879}
1880
1881/***********************************************************************/
1884static void conquer_extras(QVariant data1, QVariant data2)
1885{
1886 int actor_id = data1.toInt();
1887 int target_id = data2.toInt();
1888
1889 if (game_unit_by_number(actor_id) != nullptr) {
1891 actor_id, target_id, 0, "");
1892 }
1893}
1894
1895/***********************************************************************/
1898static void conquer_extras2(QVariant data1, QVariant data2)
1899{
1900 int actor_id = data1.toInt();
1901 int target_id = data2.toInt();
1902
1903 if (game_unit_by_number(actor_id) != nullptr) {
1905 actor_id, target_id, 0, "");
1906 }
1907}
1908
1909/***********************************************************************/
1912static void act_sel_wait(QVariant data1, QVariant data2)
1913{
1914 key_unit_wait();
1915}
1916
1917/***********************************************************************/
1920static void keep_moving(QVariant data1, QVariant data2)
1921{
1922}
1923
1924/***********************************************************************/
1928{
1929 if (!gov) {
1931 } else {
1933 }
1934}
1935
1936/***********************************************************************/
1941{
1943 /* The client isn't waiting for information for any unanswered follow
1944 * up questions. */
1945
1946 struct unit *actor_unit;
1947
1949 /* The action selection dialog wasn't closed because the actor unit
1950 * was lost. */
1951
1952 // The probabilities didn't just disappear, right?
1955
1957 }
1958
1959 // The action selection process is over, at least for now.
1961
1962 if (did_not_decide) {
1963 /* The action selection dialog was closed but the player didn't
1964 * decide what the unit should do. */
1965
1966 // Reset so the next action selection dialog does the right thing.
1967 did_not_decide = false;
1968 } else {
1969 // An action, or no action at all, was selected.
1972 }
1973 }
1974}
1975
1976/***********************************************************************/
1980static void diplomat_queue_handle_secondary(int actor_id)
1981{
1982 // Stop waiting. Move on to the next queued unit.
1985}
1986
1987/**********************************************************************/
1994{
1995 // Stop assuming the answer to a follow up question will arrive.
1997}
1998
1999/***********************************************************************/
2004 struct city *target_city,
2005 struct unit *target_unit,
2006 struct tile *target_tile,
2007 struct extra_type *target_extra,
2008 const struct act_prob *act_probs)
2009{
2010 struct astring title = ASTRING_INIT, text = ASTRING_INIT;
2012 qtiles caras;
2013 QVariant qv1, qv2;
2015 struct city *actor_homecity;
2018
2021
2022 foreach (caras, gui()->trade_gen.lines) {
2023 if (caras.autocaravan == actor_unit) {
2024 int i;
2025
2026 if (game_unit_by_number(actor_unit->id) != nullptr
2027 && game_city_by_number(target_city->id) != nullptr) {
2029 target_city->id, 0, "");
2032 i = gui()->trade_gen.lines.indexOf(caras);
2033 gui()->trade_gen.lines.takeAt(i);
2034
2035 return;
2036 }
2037 }
2038 }
2039 if (target_city
2043
2044 return;
2045 }
2046
2047 if (target_unit
2051
2052 return;
2053 }
2054 /* Could be caused by the server failing to reply to a request for more
2055 * information or a bug in the client code. */
2057 "Diplomat queue problem. Is another diplomat window open?");
2058
2059 // No extra input is required as no action has been chosen yet.
2061
2063
2064 astr_set(&title,
2065 // TRANS: %s is a unit name, e.g., Spy
2066 _("Choose Your %s's Strategy"),
2068
2069 if (target_city != nullptr && actor_homecity != nullptr) {
2070 astr_set(&text,
2071 _("Your %s from %s reaches the city of %s.\nWhat now?"),
2075 } else if (target_city != nullptr) {
2076 astr_set(&text,
2077 _("Your %s has arrived at %s.\nWhat is your command?"),
2080 } else if (target_unit != nullptr) {
2081 astr_set(&text,
2082 // TRANS: Your Spy is ready to act against Roman Freight.
2083 _("Your %s is ready to act against %s %s."),
2087 } else {
2088 fc_assert_msg(target_unit != nullptr
2089 || target_city != nullptr
2090 || target_tile != nullptr,
2091 "No target specified.");
2092
2093 astr_set(&text,
2094 // TRANS: %s is a unit name, e.g., Diplomat, Spy
2095 _("Your %s is waiting for your command."),
2097 }
2098
2099 cd = gui()->get_diplo_dialog();
2100 if ((cd != nullptr) && cd->targeted_unit != nullptr) {
2101 cd->update_dialog(act_probs);
2102 return;
2103 }
2104 cd = new choice_dialog(astr_str(&title), astr_str(&text),
2105 gui()->game_tab_widget,
2107 qv1 = actor_unit->id;
2108
2109 cd->unit_id = actor_unit->id;
2110
2111 cd->target_id[ATK_SELF] = cd->unit_id;
2112
2113 if (target_city) {
2114 cd->target_id[ATK_CITY] = target_city->id;
2115 } else {
2116 cd->target_id[ATK_CITY] = IDENTITY_NUMBER_ZERO;
2117 }
2118
2119 if (target_unit) {
2120 cd->target_id[ATK_UNIT] = target_unit->id;
2121 } else {
2122 cd->target_id[ATK_UNIT] = IDENTITY_NUMBER_ZERO;
2123 }
2124
2125 if (target_tile) {
2126 cd->target_id[ATK_UNITS] = tile_index(target_tile);
2127 } else {
2128 cd->target_id[ATK_UNITS] = TILE_INDEX_NONE;
2129 }
2130
2131 if (target_tile) {
2132 cd->target_id[ATK_TILE] = tile_index(target_tile);
2133 } else {
2134 cd->target_id[ATK_TILE] = TILE_INDEX_NONE;
2135 }
2136
2137 if (target_tile) {
2138 cd->target_id[ATK_EXTRAS] = tile_index(target_tile);
2139 } else {
2140 cd->target_id[ATK_EXTRAS] = TILE_INDEX_NONE;
2141 }
2142
2143 // No target building or target tech supplied. (Feb 2020)
2144 cd->sub_target_id[ASTK_BUILDING] = B_LAST;
2145 cd->sub_target_id[ASTK_TECH] = A_UNSET;
2146
2147 if (target_extra) {
2148 cd->sub_target_id[ASTK_EXTRA] = extra_number(target_extra);
2150 } else {
2151 cd->sub_target_id[ASTK_EXTRA] = EXTRA_NONE;
2152 cd->sub_target_id[ASTK_EXTRA_NOT_THERE] = EXTRA_NONE;
2153 }
2154
2155 // Unit acting against a city
2156
2157 // Set the correct target for the following actions.
2158 qv2 = cd->target_id[ATK_CITY];
2159
2160 action_iterate(act) {
2165 act_probs[act],
2166 actor_unit,
2167 target_city),
2168 qv1, qv2);
2169 }
2171
2172 // Unit acting against another unit
2173
2174 // Set the correct target for the following actions.
2175 qv2 = cd->target_id[ATK_UNIT];
2176
2177 action_iterate(act) {
2182 act_probs[act],
2183 actor_unit,
2184 target_city),
2185 qv1, qv2);
2186 }
2188
2189 // Unit acting against all units at a tile
2190
2191 // Set the correct target for the following actions.
2192 qv2 = cd->target_id[ATK_UNITS];
2193
2194 action_iterate(act) {
2199 act_probs[act],
2200 actor_unit,
2201 target_city),
2202 qv1, qv2);
2203 }
2205
2206 // Unit acting against a tile.
2207
2208 // Set the correct target for the following actions.
2209 qv2 = cd->target_id[ATK_TILE];
2210
2211 action_iterate(act) {
2216 act_probs[act],
2217 actor_unit,
2218 target_city),
2219 qv1, qv2);
2220 }
2222
2223 // Unit acting against a tile's extras.
2224
2225 // Set the correct target for the following actions.
2226 qv2 = cd->target_id[ATK_EXTRAS];
2227
2228 action_iterate(act) {
2233 act_probs[act],
2234 actor_unit,
2235 target_city),
2236 qv1, qv2);
2237 }
2239
2240 // Unit acting against itself
2241
2242 // Set the correct target for the following actions.
2243 qv2 = cd->target_id[ATK_SELF];
2244
2245 action_iterate(act) {
2250 act_probs[act],
2251 actor_unit,
2252 target_city),
2253 qv1, qv2);
2254 }
2256
2258 cd->add_item(QString(_("&Wait")), func, qv1, qv2,
2259 "", BUTTON_WAIT);
2260
2261 func = keep_moving;
2262 cd->add_item(QString(_("Do nothing")), func, qv1, qv2,
2263 "", BUTTON_CANCEL);
2264
2265 cd->set_layout();
2266 cd->show_me();
2267
2268 // Give follow up questions access to action probabilities.
2270 action_iterate(act) {
2273
2274 astr_free(&title);
2275 astr_free(&text);
2276}
2277
2278/***********************************************************************/
2283{
2284 /* Don't add an action mapping here unless the non targeted version is
2285 * selectable in the targeted version's target selection dialog. */
2286 switch ((enum gen_action)tgt_action_id) {
2292 return ACTION_SPY_STEAL_TECH;
2295 default:
2296 // No non targeted version found.
2297 return ACTION_NONE;
2298 }
2299}
2300
2301/**********************************************************************/
2306{
2307 /* Don't add an action mapping here unless the non targeted version is
2308 * selectable in the targeted version's target selection dialog. */
2309 switch ((enum gen_action)tgt_action_id) {
2316 default:
2317 // No non targeted version found.
2318 return ACTION_NONE;
2319 }
2320}
2321
2322/***********************************************************************/
2326 action_id act,
2327 const struct act_prob *act_probs,
2328 const char *custom,
2329 QVariant data1, QVariant data2)
2330{
2331 QString title;
2333
2334 if (!af_map.contains(act)) {
2335 /* The Qt client doesn't support ordering this action from the
2336 * action selection dialog. */
2337 return;
2338 }
2339
2340 // Don't show disabled actions.
2341 if (!action_prob_possible(act_probs[act])) {
2342 return;
2343 }
2344
2346 act_probs[act],
2347 custom));
2348
2350 act_probs[act]));
2351
2352 cd->add_item(title, af_map[act], data1, data2, tool_tip, act);
2353}
2354
2355/***********************************************************************/
2359 action_id act,
2360 const struct act_prob *act_probs,
2361 const char *custom,
2362 QVariant data1, QVariant data2)
2363{
2364 QString title;
2366
2367 /* An action that just became impossible has its button disabled.
2368 * An action that became possible again must be re-enabled. */
2369 button->setEnabled(action_prob_possible(act_probs[act]));
2370 button->setData1(data1);
2371 button->setData2(data2);
2372 // The probability may have changed.
2374 act_probs[act],
2375 custom));
2376
2378 act_probs[act]));
2379
2380 button->setText(title);
2381 button->setToolTip(tool_tip);
2382}
2383
2384/***********************************************************************/
2387static void disband_unit(QVariant data1, QVariant data2)
2388{
2389 int actor_id = data1.toInt();
2390 int target_id = data2.toInt();
2391
2393 target_id, 0, "");
2394}
2395
2396/***********************************************************************/
2399static void fortify(QVariant data1, QVariant data2)
2400{
2401 int actor_id = data1.toInt();
2402 int target_id = data2.toInt();
2403
2404 if (game_unit_by_number(actor_id) != nullptr) {
2406 target_id, 0, "");
2407 }
2408}
2409
2410/***********************************************************************/
2413static void convert_unit(QVariant data1, QVariant data2)
2414{
2415 int actor_id = data1.toInt();
2416 int target_id = data2.toInt();
2417
2419 target_id, 0, "");
2420}
2421
2422/***********************************************************************/
2425static void homeless(QVariant data1, QVariant data2)
2426{
2427 int actor_id = data1.toInt();
2428 int target_id = data2.toInt();
2429
2430 if (game_unit_by_number(actor_id) != nullptr) {
2432 target_id, 0, "");
2433 }
2434}
2435
2436/***********************************************************************/
2439static void diplomat_bribe(QVariant data1, QVariant data2)
2440{
2441 int diplomat_id = data1.toInt();
2442 int diplomat_target_id = data2.toInt();
2443
2444 if (game_unit_by_number(diplomat_id) != nullptr
2445 && game_unit_by_number(diplomat_target_id) != nullptr) {
2446 // Wait for the server's reply before moving on to the next queued diplomat.
2448
2451 }
2452}
2453
2454/***********************************************************************/
2457static void spy_sabotage_unit(QVariant data1, QVariant data2)
2458{
2459 int diplomat_id = data1.toInt();
2460 int diplomat_target_id = data2.toInt();
2461
2463 diplomat_target_id, 0, "");
2464}
2465
2466/***********************************************************************/
2469static void spy_sabotage_unit_esc(QVariant data1, QVariant data2)
2470{
2471 int diplomat_id = data1.toInt();
2472 int diplomat_target_id = data2.toInt();
2473
2475 diplomat_target_id, 0, "");
2476}
2477
2478/***********************************************************************/
2481static void heal_unit(QVariant data1, QVariant data2)
2482{
2483 int actor_id = data1.toInt();
2484 int target_id = data2.toInt();
2485
2486 request_do_action(ACTION_HEAL_UNIT, actor_id, target_id, 0, "");
2487}
2488
2489/***********************************************************************/
2492static void heal_unit2(QVariant data1, QVariant data2)
2493{
2494 int actor_id = data1.toInt();
2495 int target_id = data2.toInt();
2496
2497 request_do_action(ACTION_HEAL_UNIT2, actor_id, target_id, 0, "");
2498}
2499
2500/***********************************************************************/
2503static void transport_board(QVariant data1, QVariant data2)
2504{
2505 int actor_id = data1.toInt();
2506 int target_id = data2.toInt();
2507
2508 request_do_action(ACTION_TRANSPORT_BOARD, actor_id, target_id, 0, "");
2509}
2510
2511/***********************************************************************/
2514static void transport_board2(QVariant data1, QVariant data2)
2515{
2516 int actor_id = data1.toInt();
2517 int target_id = data2.toInt();
2518
2519 request_do_action(ACTION_TRANSPORT_BOARD2, actor_id, target_id, 0, "");
2520}
2521
2522/***********************************************************************/
2525static void transport_board3(QVariant data1, QVariant data2)
2526{
2527 int actor_id = data1.toInt();
2528 int target_id = data2.toInt();
2529
2530 request_do_action(ACTION_TRANSPORT_BOARD3, actor_id, target_id, 0, "");
2531}
2532
2533/***********************************************************************/
2536static void transport_embark(QVariant data1, QVariant data2)
2537{
2538 int actor_id = data1.toInt();
2539 int target_id = data2.toInt();
2540
2541 request_do_action(ACTION_TRANSPORT_EMBARK, actor_id, target_id, 0, "");
2542}
2543
2544/***********************************************************************/
2547static void transport_embark2(QVariant data1, QVariant data2)
2548{
2549 int actor_id = data1.toInt();
2550 int target_id = data2.toInt();
2551
2552 request_do_action(ACTION_TRANSPORT_EMBARK2, actor_id, target_id, 0, "");
2553}
2554
2555/***********************************************************************/
2558static void transport_embark3(QVariant data1, QVariant data2)
2559{
2560 int actor_id = data1.toInt();
2561 int target_id = data2.toInt();
2562
2563 request_do_action(ACTION_TRANSPORT_EMBARK3, actor_id, target_id, 0, "");
2564}
2565
2566/***********************************************************************/
2569static void transport_embark4(QVariant data1, QVariant data2)
2570{
2571 int actor_id = data1.toInt();
2572 int target_id = data2.toInt();
2573
2574 request_do_action(ACTION_TRANSPORT_EMBARK4, actor_id, target_id, 0, "");
2575}
2576
2577/***********************************************************************/
2580static void transport_unload(QVariant data1, QVariant data2)
2581{
2582 int actor_id = data1.toInt();
2583 int target_id = data2.toInt();
2584
2585 request_do_action(ACTION_TRANSPORT_UNLOAD, actor_id, target_id, 0, "");
2586}
2587
2588/***********************************************************************/
2591static void transport_load(QVariant data1, QVariant data2)
2592{
2593 int actor_id = data1.toInt();
2594 int target_id = data2.toInt();
2595
2596 request_do_action(ACTION_TRANSPORT_LOAD, actor_id, target_id, 0, "");
2597}
2598
2599/***********************************************************************/
2602static void transport_load2(QVariant data1, QVariant data2)
2603{
2604 int actor_id = data1.toInt();
2605 int target_id = data2.toInt();
2606
2607 request_do_action(ACTION_TRANSPORT_LOAD2, actor_id, target_id, 0, "");
2608}
2609
2610/***********************************************************************/
2613static void transport_load3(QVariant data1, QVariant data2)
2614{
2615 int actor_id = data1.toInt();
2616 int target_id = data2.toInt();
2617
2618 request_do_action(ACTION_TRANSPORT_LOAD3, actor_id, target_id, 0, "");
2619}
2620
2621/***********************************************************************/
2624static void transport_deboard(QVariant data1, QVariant data2)
2625{
2626 int actor_id = data1.toInt();
2627 int target_id = data2.toInt();
2628
2629 request_do_action(ACTION_TRANSPORT_DEBOARD, actor_id, target_id, 0, "");
2630}
2631
2632/***********************************************************************/
2635static void disembark1(QVariant data1, QVariant data2)
2636{
2637 int actor_id = data1.toInt();
2638 int target_id = data2.toInt();
2639
2640 if (game_unit_by_number(actor_id) != nullptr
2641 && index_to_tile(&(wld.map), target_id) != nullptr) {
2643 actor_id, target_id, 0, "");
2644 }
2645}
2646
2647/***********************************************************************/
2650static void disembark2(QVariant data1, QVariant data2)
2651{
2652 int actor_id = data1.toInt();
2653 int target_id = data2.toInt();
2654
2655 if (game_unit_by_number(actor_id) != nullptr
2656 && index_to_tile(&(wld.map), target_id) != nullptr) {
2658 actor_id, target_id, 0, "");
2659 }
2660}
2661
2662/***********************************************************************/
2665static void enter_hut(QVariant data1, QVariant data2)
2666{
2667 int actor_id = data1.toInt();
2668 int target_id = data2.toInt();
2669
2670 if (game_unit_by_number(actor_id) != nullptr
2671 && index_to_tile(&(wld.map), target_id) != nullptr) {
2673 actor_id, target_id, 0, "");
2674 }
2675}
2676
2677/***********************************************************************/
2680static void enter_hut2(QVariant data1, QVariant data2)
2681{
2682 int actor_id = data1.toInt();
2683 int target_id = data2.toInt();
2684
2685 if (game_unit_by_number(actor_id) != nullptr
2686 && index_to_tile(&(wld.map), target_id) != nullptr) {
2688 actor_id, target_id, 0, "");
2689 }
2690}
2691
2692/***********************************************************************/
2695static void frighten_hut(QVariant data1, QVariant data2)
2696{
2697 int actor_id = data1.toInt();
2698 int target_id = data2.toInt();
2699
2700 if (game_unit_by_number(actor_id) != nullptr
2701 && index_to_tile(&(wld.map), target_id) != nullptr) {
2703 actor_id, target_id, 0, "");
2704 }
2705}
2706
2707/***********************************************************************/
2710static void frighten_hut2(QVariant data1, QVariant data2)
2711{
2712 int actor_id = data1.toInt();
2713 int target_id = data2.toInt();
2714
2715 if (game_unit_by_number(actor_id) != nullptr
2716 && index_to_tile(&(wld.map), target_id) != nullptr) {
2718 actor_id, target_id, 0, "");
2719 }
2720}
2721
2722/**********************************************************************/
2725static void nuke_units(QVariant data1, QVariant data2)
2726{
2727 int actor_id = data1.toInt();
2728 int target_id = data2.toInt();
2729
2731 target_id, 0, "");
2732}
2733
2734/**********************************************************************/
2737static void wipe_units(QVariant data1, QVariant data2)
2738{
2739 int actor_id = data1.toInt();
2740 int target_id = data2.toInt();
2741
2743 target_id, 0, "");
2744}
2745
2746/**********************************************************************/
2749static void capture_units(QVariant data1, QVariant data2)
2750{
2751 int actor_id = data1.toInt();
2752 int target_id = data2.toInt();
2753
2755 target_id, 0, "");
2756}
2757
2758/***********************************************************************/
2761static void expel_unit(QVariant data1, QVariant data2)
2762{
2763 int actor_id = data1.toInt();
2764 int target_id = data2.toInt();
2765
2767 target_id, 0, "");
2768}
2769
2770/***********************************************************************/
2773static void bombard(QVariant data1, QVariant data2)
2774{
2775 int actor_id = data1.toInt();
2776 int target_id = data2.toInt();
2777
2779 target_id, 0, "");
2780}
2781
2782/***********************************************************************/
2785static void bombard2(QVariant data1, QVariant data2)
2786{
2787 int actor_id = data1.toInt();
2788 int target_id = data2.toInt();
2789
2791 target_id, 0, "");
2792}
2793
2794/***********************************************************************/
2797static void bombard3(QVariant data1, QVariant data2)
2798{
2799 int actor_id = data1.toInt();
2800 int target_id = data2.toInt();
2801
2803 target_id, 0, "");
2804}
2805
2806/***********************************************************************/
2809static void bombard_lethal(QVariant data1, QVariant data2)
2810{
2811 int actor_id = data1.toInt();
2812 int target_id = data2.toInt();
2813
2815 target_id, 0, "");
2816}
2817
2818/***********************************************************************/
2821static void found_city(QVariant data1, QVariant data2)
2822{
2823 int actor_id = data1.toInt();
2824
2826 actor_id);
2827}
2828
2829/***********************************************************************/
2832static void transform_terrain(QVariant data1, QVariant data2)
2833{
2834 int actor_id = data1.toInt();
2835 int target_id = data2.toInt();
2836
2837 if (game_unit_by_number(actor_id) != nullptr
2838 && index_to_tile(&(wld.map), target_id) != nullptr) {
2840 actor_id, target_id, 0, "");
2841 }
2842}
2843
2844/***********************************************************************/
2847static void cultivate(QVariant data1, QVariant data2)
2848{
2849 int actor_id = data1.toInt();
2850 int target_id = data2.toInt();
2851
2852 if (game_unit_by_number(actor_id) != nullptr
2853 && index_to_tile(&(wld.map), target_id) != nullptr) {
2855 actor_id, target_id, 0, "");
2856 }
2857}
2858
2859/***********************************************************************/
2862static void plant(QVariant data1, QVariant data2)
2863{
2864 int actor_id = data1.toInt();
2865 int target_id = data2.toInt();
2866
2867 if (game_unit_by_number(actor_id) != nullptr
2868 && index_to_tile(&(wld.map), target_id) != nullptr) {
2870 actor_id, target_id, 0, "");
2871 }
2872}
2873
2874/***********************************************************************/
2877static void pillage(QVariant data1, QVariant data2)
2878{
2879 int actor_id = data1.toInt();
2880 int target_id = data2.toInt();
2881
2882 if (game_unit_by_number(actor_id) != nullptr
2883 && index_to_tile(&(wld.map), target_id) != nullptr) {
2885 actor_id, target_id,
2886 /* FIXME: will cause problems if more than
2887 * one action selection dialog at a time
2888 * becomes supported. */
2890 "");
2891 }
2892}
2893
2894/***********************************************************************/
2897static void clean(QVariant data1, QVariant data2)
2898{
2899 int actor_id = data1.toInt();
2900 int target_id = data2.toInt();
2901
2902 if (game_unit_by_number(actor_id) != nullptr
2903 && index_to_tile(&(wld.map), target_id) != nullptr) {
2905 actor_id, target_id,
2906 /* FIXME: will cause problems if more than
2907 * one action selection dialog at a time
2908 * becomes supported. */
2910 "");
2911 }
2912}
2913
2914/***********************************************************************/
2917static void road(QVariant data1, QVariant data2)
2918{
2919 int actor_id = data1.toInt();
2920 int target_id = data2.toInt();
2921
2922 if (game_unit_by_number(actor_id) != nullptr
2923 && index_to_tile(&(wld.map), target_id) != nullptr
2926 actor_id, target_id,
2927 /* FIXME: will cause problems if more than
2928 * one action selection dialog at a time
2929 * becomes supported. */
2931 "");
2932 }
2933}
2934
2935/***********************************************************************/
2938static void base(QVariant data1, QVariant data2)
2939{
2940 int actor_id = data1.toInt();
2941 int target_id = data2.toInt();
2942
2943 if (game_unit_by_number(actor_id) != nullptr
2944 && index_to_tile(&(wld.map), target_id) != nullptr
2947 actor_id, target_id,
2948 /* FIXME: will cause problems if more than
2949 * one action selection dialog at a time
2950 * becomes supported. */
2952 "");
2953 }
2954}
2955
2956/***********************************************************************/
2959static void mine(QVariant data1, QVariant data2)
2960{
2961 int actor_id = data1.toInt();
2962 int target_id = data2.toInt();
2963
2964 if (game_unit_by_number(actor_id) != nullptr
2965 && index_to_tile(&(wld.map), target_id) != nullptr
2968 actor_id, target_id,
2969 /* FIXME: will cause problems if more than
2970 * one action selection dialog at a time
2971 * becomes supported. */
2973 "");
2974 }
2975}
2976
2977/***********************************************************************/
2980static void irrigate(QVariant data1, QVariant data2)
2981{
2982 int actor_id = data1.toInt();
2983 int target_id = data2.toInt();
2984
2985 if (game_unit_by_number(actor_id) != nullptr
2986 && index_to_tile(&(wld.map), target_id) != nullptr
2989 actor_id, target_id,
2990 /* FIXME: will cause problems if more than
2991 * one action selection dialog at a time
2992 * becomes supported. */
2994 "");
2995 }
2996}
2997
2998/***********************************************************************/
3001static void nuke(QVariant data1, QVariant data2)
3002{
3003 int diplomat_id = data1.toInt();
3004 int diplomat_target_id = data2.toInt();
3005
3006 if (game_unit_by_number(diplomat_id) != nullptr
3007 && index_to_tile(&(wld.map), diplomat_target_id) != nullptr) {
3010 }
3011}
3012
3013/***********************************************************************/
3016static void attack(QVariant data1, QVariant data2)
3017{
3018 int diplomat_id = data1.toInt();
3019 int diplomat_target_id = data2.toInt();
3020
3021 if (game_unit_by_number(diplomat_id) != nullptr
3022 && index_to_tile(&(wld.map), diplomat_target_id) != nullptr) {
3025 }
3026}
3027
3028/***********************************************************************/
3031static void suicide_attack(QVariant data1, QVariant data2)
3032{
3033 int diplomat_id = data1.toInt();
3034 int diplomat_target_id = data2.toInt();
3035
3036 if (game_unit_by_number(diplomat_id) != nullptr
3037 && index_to_tile(&(wld.map), diplomat_target_id) != nullptr) {
3040 }
3041}
3042
3043/***********************************************************************/
3046static void paradrop(QVariant data1, QVariant data2)
3047{
3048 int actor_id = data1.toInt();
3049 int target_id = data2.toInt();
3050
3051 if (game_unit_by_number(actor_id) != nullptr
3052 && index_to_tile(&(wld.map), target_id) != nullptr) {
3054 actor_id, target_id, 0, "");
3055 }
3056}
3057
3058/***********************************************************************/
3061static void paradrop_conquer(QVariant data1, QVariant data2)
3062{
3063 int actor_id = data1.toInt();
3064 int target_id = data2.toInt();
3065
3066 if (game_unit_by_number(actor_id) != nullptr
3067 && index_to_tile(&(wld.map), target_id) != nullptr) {
3069 actor_id, target_id, 0, "");
3070 }
3071}
3072
3073/***********************************************************************/
3076static void paradrop_frighten(QVariant data1, QVariant data2)
3077{
3078 int actor_id = data1.toInt();
3079 int target_id = data2.toInt();
3080
3081 if (game_unit_by_number(actor_id) != nullptr
3082 && index_to_tile(&(wld.map), target_id) != nullptr) {
3084 actor_id, target_id, 0, "");
3085 }
3086}
3087
3088/***********************************************************************/
3092{
3093 int actor_id = data1.toInt();
3094 int target_id = data2.toInt();
3095
3096 if (game_unit_by_number(actor_id) != nullptr
3097 && index_to_tile(&(wld.map), target_id) != nullptr) {
3099 actor_id, target_id, 0, "");
3100 }
3101}
3102
3103/***********************************************************************/
3106static void paradrop_enter(QVariant data1, QVariant data2)
3107{
3108 int actor_id = data1.toInt();
3109 int target_id = data2.toInt();
3110
3111 if (game_unit_by_number(actor_id) != nullptr
3112 && index_to_tile(&(wld.map), target_id) != nullptr) {
3114 actor_id, target_id, 0, "");
3115 }
3116}
3117
3118/***********************************************************************/
3122{
3123 int actor_id = data1.toInt();
3124 int target_id = data2.toInt();
3125
3126 if (game_unit_by_number(actor_id) != nullptr
3127 && index_to_tile(&(wld.map), target_id) != nullptr) {
3129 actor_id, target_id, 0, "");
3130 }
3131}
3132
3133/***********************************************************************/
3136static void join_city(QVariant data1, QVariant data2)
3137{
3138 int actor_id = data1.toInt();
3139 int target_id = data2.toInt();
3140
3141 if (game_unit_by_number(actor_id) != nullptr
3142 && game_city_by_number(target_id) != nullptr) {
3144 actor_id, target_id, 0, "");
3145 }
3146}
3147
3148/***********************************************************************/
3151static void spy_steal_shared(QVariant data1, QVariant data2,
3152 action_id act_id)
3153{
3154 QString str;
3155 QVariant qv1;
3157 int diplomat_id = data1.toInt();
3158 int diplomat_target_id = data2.toInt();
3161 struct player *pvictim = nullptr;
3164
3165 cd = gui()->get_diplo_dialog();
3166 if (cd != nullptr) {
3167 cd->close();
3168 }
3169
3170 if (pvcity == nullptr) {
3171 return;
3172 }
3173
3174 // Wait for the player's reply before moving on to the next queued diplomat.
3176
3178
3179 struct astring stra = ASTRING_INIT;
3180 cd = new choice_dialog(_("Steal"), _("Steal Technology"),
3181 gui()->game_tab_widget,
3183
3184 // Put both actor and target city in qv1 since qv2 is taken
3187 actor_and_target.append(act_id);
3188 qv1 = QVariant::fromValue(actor_and_target);
3189
3190 struct player *pplayer = client_player();
3191 const struct research *presearch = research_get(pplayer);
3192 const struct research *vresearch = research_get(pvictim);
3193
3200 // Defeat keyboard shortcut mnemonics
3202 .replace("&", "&&");
3203 cd->add_item(str, func, qv1, i);
3204 }
3206
3208 get_non_targeted_action_id(act_id)])) {
3209 astr_set(&stra, _("At %s's Discretion"),
3212 str = QString(astr_str(&stra)).replace("&", "&&");
3213 cd->add_item(str, func, qv1, A_UNSET);
3214 }
3215
3216 cd->set_layout();
3217 cd->show_me();
3218
3219 astr_free(&stra);
3220}
3221
3222/***********************************************************************/
3225static void spy_steal(QVariant data1, QVariant data2)
3226{
3228}
3229
3230/***********************************************************************/
3233static void spy_steal_esc(QVariant data1, QVariant data2)
3234{
3236}
3237
3238/***********************************************************************/
3241static void spy_steal_something(QVariant data1, QVariant data2)
3242{
3243 int diplomat_id = data1.toList().at(0).toInt();
3244 int diplomat_target_id = data1.toList().at(1).toInt();
3245 action_id act_id = data1.toList().at(2).toInt();
3246
3247 if (game_unit_by_number(diplomat_id) != nullptr
3248 && game_city_by_number(diplomat_target_id) != nullptr) {
3249 if (data2.toInt() == A_UNSET) {
3250 // This is the untargeted version.
3252 diplomat_id, diplomat_target_id, data2.toInt(), "");
3253 } else {
3254 // This is the targeted version.
3256 diplomat_target_id, data2.toInt(), "");
3257 }
3258 }
3259}
3260
3261/***********************************************************************/
3265{
3266 int actor_id = data1.toInt();
3267 int target_id = data2.toInt();
3268
3269 if (game_unit_by_number(actor_id) != nullptr
3270 && game_city_by_number(target_id) != nullptr) {
3271 // Wait for the server's reply before moving on to the next queued diplomat.
3273
3274 request_action_details(ACTION_STRIKE_BUILDING, actor_id, target_id);
3275 }
3276}
3277
3278/***********************************************************************/
3282{
3283 int diplomat_id = data1.toInt();
3284 int diplomat_target_id = data2.toInt();
3285
3286 if (game_unit_by_number(diplomat_id) != nullptr
3287 && game_city_by_number(diplomat_target_id) != nullptr) {
3288 // Wait for the server's reply before moving on to the next queued diplomat.
3290
3293 }
3294}
3295
3296/***********************************************************************/
3300{
3301 int diplomat_id = data1.toInt();
3302 int diplomat_target_id = data2.toInt();
3303
3304 if (game_unit_by_number(diplomat_id) != nullptr
3305 && game_city_by_number(diplomat_target_id) != nullptr) {
3306 /* Wait for the server's reply before moving on to the next queued
3307 * diplomat. */
3309
3312 }
3313}
3314
3315/***********************************************************************/
3318static void spy_poison(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 && game_city_by_number(diplomat_target_id) != nullptr) {
3327 }
3328}
3329
3330/***********************************************************************/
3333static void spy_poison_esc(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 && game_city_by_number(diplomat_target_id) != nullptr) {
3342 }
3343}
3344
3345/***********************************************************************/
3348static void spy_nuke_city(QVariant data1, QVariant data2)
3349{
3350 int diplomat_id = data1.toInt();
3351 int diplomat_target_id = data2.toInt();
3352
3353 if (game_unit_by_number(diplomat_id) != nullptr
3354 && game_city_by_number(diplomat_target_id) != nullptr) {
3357 }
3358}
3359
3360/***********************************************************************/
3363static void spy_nuke_city_esc(QVariant data1, QVariant data2)
3364{
3365 int diplomat_id = data1.toInt();
3366 int diplomat_target_id = data2.toInt();
3367
3368 if (game_unit_by_number(diplomat_id) != nullptr
3369 && game_city_by_number(diplomat_target_id) != nullptr) {
3372 }
3373}
3374
3375/***********************************************************************/
3378static void nuke_city(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 && game_city_by_number(target_id) != nullptr) {
3386 actor_id, target_id, 0, "");
3387 }
3388}
3389
3390/***********************************************************************/
3393static void destroy_city(QVariant data1, QVariant data2)
3394{
3395 int diplomat_id = data1.toInt();
3396 int diplomat_target_id = data2.toInt();
3397
3398 if (game_unit_by_number(diplomat_id) != nullptr
3399 && game_city_by_number(diplomat_target_id) != nullptr) {
3402 }
3403}
3404
3405/***********************************************************************/
3408static void spy_steal_gold(QVariant data1, QVariant data2)
3409{
3410 int diplomat_id = data1.toInt();
3411 int diplomat_target_id = data2.toInt();
3412
3413 if (game_unit_by_number(diplomat_id) != nullptr
3414 && game_city_by_number(diplomat_target_id) != nullptr) {
3417 }
3418}
3419
3420/***********************************************************************/
3423static void spy_steal_gold_esc(QVariant data1, QVariant data2)
3424{
3425 int diplomat_id = data1.toInt();
3426 int diplomat_target_id = data2.toInt();
3427
3428 if (game_unit_by_number(diplomat_id) != nullptr
3429 && game_city_by_number(diplomat_target_id) != nullptr) {
3432 }
3433}
3434
3435/***********************************************************************/
3438static void spy_steal_maps(QVariant data1, QVariant data2)
3439{
3440 int diplomat_id = data1.toInt();
3441 int diplomat_target_id = data2.toInt();
3442
3443 if (game_unit_by_number(diplomat_id) != nullptr
3444 && game_city_by_number(diplomat_target_id) != nullptr) {
3447 }
3448}
3449
3450/***********************************************************************/
3453static void spy_steal_maps_esc(QVariant data1, QVariant data2)
3454{
3455 int diplomat_id = data1.toInt();
3456 int diplomat_target_id = data2.toInt();
3457
3458 if (game_unit_by_number(diplomat_id) != nullptr
3459 && game_city_by_number(diplomat_target_id) != nullptr) {
3462 }
3463}
3464
3465/***********************************************************************/
3468static void spy_escape(QVariant data1, QVariant data2)
3469{
3470 int diplomat_id = data1.toInt();
3471 int diplomat_target_id = data2.toInt();
3472
3473 if (game_unit_by_number(diplomat_id) != nullptr
3474 && game_city_by_number(diplomat_target_id) != nullptr) {
3477 }
3478}
3479
3480/***********************************************************************/
3483static void spy_embassy(QVariant data1, QVariant data2)
3484{
3485 int diplomat_id = data1.toInt();
3486 int diplomat_target_id = data2.toInt();
3487
3488 if (game_unit_by_number(diplomat_id) != nullptr
3489 && game_city_by_number(diplomat_target_id) != nullptr) {
3491 diplomat_target_id, 0, "");
3492 }
3493}
3494
3495/***********************************************************************/
3498static void diplomat_embassy(QVariant data1, QVariant data2)
3499{
3500 int diplomat_id = data1.toInt();
3501 int diplomat_target_id = data2.toInt();
3502
3503 if (game_unit_by_number(diplomat_id) != nullptr
3504 && game_city_by_number(diplomat_target_id) != nullptr) {
3506 diplomat_target_id, 0, "");
3507 }
3508}
3509
3510/***********************************************************************/
3513static void spy_investigate(QVariant data1, QVariant data2)
3514{
3515 int diplomat_id = data1.toInt();
3516 int diplomat_target_id = data2.toInt();
3517
3519 && game_unit_by_number(diplomat_id) != nullptr) {
3521 diplomat_target_id, 0, "");
3522 }
3523}
3524
3525/***********************************************************************/
3528static void diplomat_investigate(QVariant data1, QVariant data2)
3529{
3530 int diplomat_id = data1.toInt();
3531 int diplomat_target_id = data2.toInt();
3532
3534 && game_unit_by_number(diplomat_id) != nullptr) {
3536 diplomat_target_id, 0, "");
3537 }
3538}
3539
3540/***********************************************************************/
3543static void diplomat_sabotage(QVariant data1, QVariant data2)
3544{
3545 int diplomat_id = data1.toInt();
3546 int diplomat_target_id = data2.toInt();
3547
3548 if (game_unit_by_number(diplomat_id) != nullptr
3549 && game_city_by_number(diplomat_target_id) != nullptr) {
3551 diplomat_target_id, B_LAST + 1, "");
3552 }
3553}
3554
3555/***********************************************************************/
3558static void diplomat_sabotage_esc(QVariant data1, QVariant data2)
3559{
3560 int diplomat_id = data1.toInt();
3561 int diplomat_target_id = data2.toInt();
3562
3563 if (game_unit_by_number(diplomat_id) != nullptr
3564 && game_city_by_number(diplomat_target_id) != nullptr) {
3566 diplomat_target_id, B_LAST + 1, "");
3567 }
3568}
3569
3570/***********************************************************************/
3573static void diplomat_steal(QVariant data1, QVariant data2)
3574{
3575 int diplomat_id = data1.toInt();
3576 int diplomat_target_id = data2.toInt();
3577
3578 if (game_unit_by_number(diplomat_id) != nullptr
3579 && game_city_by_number(diplomat_target_id) != nullptr) {
3582 }
3583}
3584
3585/***********************************************************************/
3588static void diplomat_steal_esc(QVariant data1, QVariant data2)
3589{
3590 int diplomat_id = data1.toInt();
3591 int diplomat_target_id = data2.toInt();
3592
3593 if (game_unit_by_number(diplomat_id) != nullptr
3594 && game_city_by_number(diplomat_target_id) != nullptr) {
3597 }
3598}
3599
3600/***********************************************************************/
3603static void diplomat_incite(QVariant data1, QVariant data2)
3604{
3605 int diplomat_id = data1.toInt();
3606 int diplomat_target_id = data2.toInt();
3607
3608 if (game_unit_by_number(diplomat_id) != nullptr
3609 && game_city_by_number(diplomat_target_id) != nullptr) {
3610 // Wait for the server's reply before moving on to the next queued diplomat.
3612
3615 }
3616}
3617
3618/***********************************************************************/
3622{
3623 int diplomat_id = data1.toInt();
3624 int diplomat_target_id = data2.toInt();
3625
3626 if (game_unit_by_number(diplomat_id) != nullptr
3627 && game_city_by_number(diplomat_target_id) != nullptr) {
3628 // Wait for the server's reply before moving on to the next queued diplomat.
3630
3633 }
3634}
3635
3636/***********************************************************************/
3639static void regular_move(QVariant data1, QVariant data2)
3640{
3641 int actor_id = data1.toInt();
3642 int target_id = data2.toInt();
3643
3644 if (game_unit_by_number(actor_id) != nullptr
3645 && index_to_tile(&(wld.map), target_id) != nullptr) {
3647 actor_id, target_id, 0, "");
3648 }
3649}
3650
3651/***********************************************************************/
3655void popup_incite_dialog(struct unit *actor, struct city *tcity, int cost,
3656 const struct action *paction)
3657{
3658 char buf[1024];
3659 char buf2[1024];
3660 int diplomat_id = actor->id;
3661 int diplomat_target_id = tcity->id;
3662 const int act_id = paction->id;
3663
3664 // Should be set before sending request to the server.
3666
3667 fc_snprintf(buf, ARRAY_SIZE(buf), PL_("Treasury contains %d gold.",
3668 "Treasury contains %d gold.",
3669 client_player()->economic.gold),
3670 client_player()->economic.gold);
3671
3673 hud_message_box *impossible = new hud_message_box(gui()->central_wdg);
3674
3676 _("You can't incite a revolt in %s."), city_name_get(tcity));
3677 impossible->set_text_title(buf2, "!");
3678 impossible->setStandardButtons(QMessageBox::Ok);
3679 impossible->setAttribute(Qt::WA_DeleteOnClose);
3680 impossible->show();
3681 } else if (cost <= client_player()->economic.gold) {
3682 hud_message_box *ask = new hud_message_box(gui()->central_wdg);
3683
3685 PL_("Incite a revolt for %d gold?\n%s",
3686 "Incite a revolt for %d gold?\n%s", cost), cost, buf);
3687 ask->setStandardButtons(QMessageBox::Cancel | QMessageBox::Ok);
3688 ask->setDefaultButton(QMessageBox::Cancel);
3689 ask->set_text_title(buf2, _("Incite a Revolt!"));
3690 ask->setAttribute(Qt::WA_DeleteOnClose);
3691 QObject::connect(ask, &hud_message_box::accepted, [=]() {
3694 });
3695 ask->show();
3696 return;
3697 } else {
3698 hud_message_box *too_much = new hud_message_box(gui()->central_wdg);
3699
3701 PL_("Inciting a revolt costs %d gold.\n%s",
3702 "Inciting a revolt costs %d gold.\n%s", cost), cost,
3703 buf);
3704 too_much->set_text_title(buf2, "!");
3705 too_much->setStandardButtons(QMessageBox::Ok);
3706 too_much->setAttribute(Qt::WA_DeleteOnClose);
3707 too_much->show();
3708 }
3709
3711}
3712
3713/***********************************************************************/
3717void popup_bribe_dialog(struct unit *actor, struct unit *tunit, int cost,
3718 const struct action *paction)
3719{
3720 hud_message_box *ask = new hud_message_box(gui()->central_wdg);
3721 char buf[1024];
3722 char buf2[1024];
3723 int diplomat_id = actor->id;
3724 int diplomat_target_id = tunit->id;
3725 const int act_id = paction->id;
3726
3727 // Should be set before sending request to the server.
3729
3730 fc_snprintf(buf, ARRAY_SIZE(buf), PL_("Treasury contains %d gold.",
3731 "Treasury contains %d gold.",
3732 client_player()->economic.gold),
3733 client_player()->economic.gold);
3734
3735 if (cost <= client_player()->economic.gold) {
3736 fc_snprintf(buf2, ARRAY_SIZE(buf2), PL_("Bribe unit for %d gold?\n%s",
3737 "Bribe unit for %d gold?\n%s",
3738 cost), cost, buf);
3739 ask->set_text_title(buf2, _("Bribe Enemy Unit"));
3740 ask->setStandardButtons(QMessageBox::Cancel | QMessageBox::Ok);
3741 ask->setDefaultButton(QMessageBox::Cancel);
3742 ask->setAttribute(Qt::WA_DeleteOnClose);
3743 QObject::connect(ask, &hud_message_box::accepted, [=]() {
3746 });
3747 ask->show();
3748 return;
3749 } else {
3751 PL_("Bribing the unit costs %d gold.\n%s",
3752 "Bribing the unit costs %d gold.\n%s", cost), cost, buf);
3753 ask->set_text_title(buf2, _("Traitors Demand Too Much!"));
3754 ask->setAttribute(Qt::WA_DeleteOnClose);
3755 ask->show();
3756 }
3757
3759}
3760
3761/***********************************************************************/
3764static void pillage_something(QVariant data1, QVariant data2)
3765{
3766 int punit_id;
3767 int what;
3768 struct unit *punit;
3769 struct extra_type *target;
3770
3771 what = data1.toInt();
3772 punit_id = data2.toInt();
3774 if (punit) {
3775 target = extra_by_number(what);
3777 }
3779}
3780
3781/***********************************************************************/
3784static void spy_sabotage(QVariant data1, QVariant data2)
3785{
3786 int diplomat_id = data1.toList().at(0).toInt();
3787 int diplomat_target_id = data1.toList().at(1).toInt();
3788 action_id act_id = data1.toList().at(2).toInt();
3789
3790 if (game_unit_by_number(diplomat_id) != nullptr
3791 && game_city_by_number(diplomat_target_id) != nullptr) {
3792 if (data2.toInt() == B_LAST) {
3793 // This is the untargeted version.
3795 diplomat_id, diplomat_target_id, data2.toInt(),
3796 "");
3797 } else if (data2.toInt() == -1) {
3798 // This is the city production version.
3800 diplomat_id, diplomat_target_id, data2.toInt(),
3801 "");
3802 } else {
3803 // This is the targeted version.
3805 diplomat_target_id, data2.toInt(), "");
3806 }
3807 }
3808}
3809
3810/***********************************************************************/
3815 const struct action *paction)
3816{
3817 QString str;
3818 QVariant qv1, qv2;
3819 int diplomat_id = actor->id;
3820 int diplomat_target_id = tcity->id;
3822 choice_dialog *cd = new choice_dialog(_("Sabotage"),
3823 _("Select Improvement to Sabotage"),
3824 gui()->game_tab_widget,
3826 int nr = 0;
3827 struct astring stra = ASTRING_INIT;
3829
3830 // Should be set before sending request to the server.
3832
3833 // Put both actor, target city and action in qv1 since qv2 is taken
3836 actor_and_target.append(paction->id);
3837 qv1 = QVariant::fromValue(actor_and_target);
3838
3841 paction->id)])) {
3843 cd->add_item(QString(_("City Production")), func, qv1, -1);
3844 }
3845
3846 city_built_iterate(tcity, pimprove) {
3847 if (pimprove->sabotage > 0) {
3849 // Defeat keyboard shortcut mnemonics
3851 .replace("&", "&&");
3852 qv2 = nr;
3853 cd->add_item(str, func, qv1, improvement_number(pimprove));
3854 nr++;
3855 }
3857
3860 astr_set(&stra, _("At %s's Discretion"),
3863 str = QString(astr_str(&stra)).replace("&", "&&");
3864 cd->add_item(str, func, qv1, B_LAST);
3865 }
3866
3867 cd->set_layout();
3868 cd->show_me();
3869 astr_free(&stra);
3870}
3871
3872/***********************************************************************/
3877{
3878 QString str;
3879 QVariant qv1, qv2;
3882 struct extra_type *tgt;
3883
3885 return;
3886 }
3887 cd = new choice_dialog(_("What To Pillage"), _("Select what to pillage:"),
3888 gui()->game_tab_widget);
3889 qv2 = punit->id;
3890 while ((tgt = get_preferred_pillage(extras))) {
3891 int what;
3892
3893 what = extra_index(tgt);
3894 BV_CLR(extras, what);
3895
3897 // Defeat keyboard shortcut mnemonics
3898 str = QString(extra_name_translation(tgt)).replace("&", "&&");
3899 qv1 = what;
3900 cd->add_item(str, func, qv1, qv2);
3901 }
3902 cd->set_layout();
3903 cd->show_me();
3904}
3905
3906/***********************************************************************/
3910 QWidget *parent) : hud_message_box(parent)
3911{
3912 QString str;
3913 QPushButton *pb;
3914
3915 setAttribute(Qt::WA_DeleteOnClose);
3916 setModal(false);
3921
3922 str = QString(PL_("Are you sure you want to disband that %1 unit?",
3923 "Are you sure you want to disband those %1 units?",
3925 pb = addButton(_("Yes"), QMessageBox::AcceptRole);
3926 addButton(_("No"), QMessageBox::RejectRole);
3927 set_text_title(str, _("Disband units"));
3929 connect(pb, &QAbstractButton::clicked, this, &disband_box::disband_clicked);
3930}
3931
3932/***********************************************************************/
3943
3944/***********************************************************************/
3951
3952/***********************************************************************/
3955void popup_disband_dialog(struct unit_list *punits)
3956{
3957 disband_box *ask = new disband_box(punits, gui()->central_wdg);
3958 ask->show();
3959}
3960
3961/***********************************************************************/
3966{
3967 hud_message_box *ask = new hud_message_box(gui()->central_wdg);
3968 QString text;
3969 QString title;
3970
3971 title = QString(_("Modpack suggests using %1 tileset."))
3973 text = QString("It might not work with other tilesets.\n"
3974 "You are currently using tileset %1.")
3976 ask->addButton(_("Keep current tileset"), QMessageBox::RejectRole);
3977 ask->addButton(_("Load tileset"), QMessageBox::AcceptRole);
3978 ask->set_text_title(text, title);
3979 ask->setAttribute(Qt::WA_DeleteOnClose);
3980
3981 QObject::connect(ask, &hud_message_box::accepted, [=]() {
3984 gui()->map_scale)) {
3986 _("Can't load requested tileset."));
3987 }
3988 });
3989 ask->show();
3990}
3991
3992/***********************************************************************/
3997{
3998 hud_message_box *ask = new hud_message_box(gui()->central_wdg);
3999 QString text;
4000 QString title;
4001
4002 title = QString(_("Modpack suggests using %1 soundset."))
4004 text = QString("It might not work with other tilesets.\n"
4005 "You are currently using soundset %1.")
4006 .arg(sound_set_name);
4007 ask->addButton(_("Keep current soundset"), QMessageBox::RejectRole);
4008 ask->addButton(_("Load soundset"), QMessageBox::AcceptRole);
4009 ask->set_text_title(text, title);
4010 ask->setAttribute(Qt::WA_DeleteOnClose);
4011 QObject::connect(ask, &hud_message_box::accepted, [=]() {
4013 });
4014 ask->show();
4015}
4016
4017/***********************************************************************/
4022{
4023 hud_message_box *ask = new hud_message_box(gui()->central_wdg);
4024 QString text;
4025 QString title;
4026
4027 title = QString(_("Modpack suggests using %1 musicset."))
4029 text = QString("It might not work with other tilesets.\n"
4030 "You are currently using musicset %1.")
4031 .arg(music_set_name);
4032 ask->addButton(_("Keep current musicset"), QMessageBox::RejectRole);
4033 ask->addButton(_("Load musicset"), QMessageBox::AcceptRole);
4034 ask->set_text_title(text, title);
4035 ask->setAttribute(Qt::WA_DeleteOnClose);
4036 QObject::connect(ask, &hud_message_box::accepted, [=]() {
4038 });
4039 ask->show();
4040}
4041
4042/***********************************************************************/
4047{
4048 // PORTME
4049 return false;
4050}
4051
4052/***********************************************************************/
4056{
4058 int i;
4059
4060 nd_list = gui()->mapview_wdg->findChildren<notify_dialog *>();
4061 for (i = 0; i < nd_list.count(); i++) {
4062 nd_list[i]->restart();
4063 delete nd_list[i];
4064 }
4065}
4066
4067/***********************************************************************/
4072{
4073 int i;
4076 goto_dialog *gtd;
4077
4078 QApplication::alert(gui()->central_wdg);
4079 cd_list = gui()->game_tab_widget->findChildren <choice_dialog *>();
4080 for (i = 0; i < cd_list.count(); i++) {
4081 cd_list[i]->close();
4082 }
4083 nd_list = gui()->game_tab_widget->findChildren <notify_dialog *>();
4084 for (i = 0; i < nd_list.count(); i++) {
4085 nd_list[i]->close();
4086 }
4087
4096 gui()->popdown_unit_sel();
4097
4098 gtd = gui()->gtd;
4099
4100 if (gtd != nullptr) {
4101 gtd->close_dlg();
4102 }
4103}
4104
4105/***********************************************************************/
4111{
4112 choice_dialog *cd = gui()->get_diplo_dialog();
4113
4114 if (cd != nullptr) {
4115 return cd->unit_id;
4116 } else {
4117 return IDENTITY_NUMBER_ZERO;
4118 }
4119}
4120
4121/***********************************************************************/
4128{
4129 choice_dialog *cd = gui()->get_diplo_dialog();
4130
4131 if (cd != nullptr) {
4132 return cd->target_id[ATK_CITY];
4133 } else {
4134 return IDENTITY_NUMBER_ZERO;
4135 }
4136}
4137
4138/***********************************************************************/
4145{
4146 choice_dialog *cd = gui()->get_diplo_dialog();
4147
4148 if (cd != nullptr) {
4149 return cd->target_id[ATK_TILE];
4150 } else {
4151 return TILE_INDEX_NONE;
4152 }
4153}
4154
4155/**********************************************************************/
4162{
4163 choice_dialog *cd = gui()->get_diplo_dialog();
4164
4165 if (cd != nullptr) {
4166 return cd->sub_target_id[ASTK_EXTRA];
4167 } else {
4168 return EXTRA_NONE;
4169 }
4170}
4171
4172/***********************************************************************/
4179{
4180 choice_dialog *cd = gui()->get_diplo_dialog();
4181
4182 if (cd != nullptr) {
4183 return cd->target_id[ATK_UNIT];
4184 } else {
4185 return IDENTITY_NUMBER_ZERO;
4186 }
4187}
4188
4189/***********************************************************************/
4193 struct city *target_city,
4194 struct unit *target_unit,
4195 struct tile *target_tile,
4196 struct extra_type *target_extra,
4197 const struct act_prob *act_probs)
4198{
4201 Choice_dialog_button *cancel_button;
4202 QVariant qv1, qv2;
4203
4204 asd = gui()->get_diplo_dialog();
4205 if (asd == nullptr) {
4206 fc_assert_msg(asd != nullptr,
4207 "The action selection dialog should have been open");
4208 return;
4209 }
4210
4213 "The action selection dialog is for another actor unit.");
4214 }
4215
4216 // Put the actor id in qv1.
4217 qv1 = actor_unit->id;
4218
4219 cancel_button = asd->get_identified_button(BUTTON_CANCEL);
4220 if (cancel_button != nullptr) {
4221 /* Temporary remove the Cancel button so it won't end up above
4222 * any added buttons. */
4223 asd->stack_button(cancel_button);
4224 }
4225
4226 wait_button = asd->get_identified_button(BUTTON_WAIT);
4227 if (wait_button != nullptr) {
4228 /* Temporary remove the Wait button so it won't end up above
4229 * any added buttons. */
4230 asd->stack_button(wait_button);
4231 }
4232
4233 action_iterate(act) {
4234 const char *custom;
4235
4236 if (action_id_get_actor_kind(act) != AAK_UNIT) {
4237 // Not relevant.
4238 continue;
4239 }
4240
4242 act_probs[act],
4243 actor_unit,
4244 target_city);
4245
4246 // Put the target id in qv2.
4247 switch (action_id_get_target_kind(act)) {
4248 case ATK_UNIT:
4249 if (target_unit != nullptr) {
4250 qv2 = target_unit->id;
4251 } else {
4253 || target_unit != nullptr,
4254 "Action enabled against non existing unit!");
4255
4257 }
4258 break;
4259 case ATK_CITY:
4260 if (target_city != nullptr) {
4261 qv2 = target_city->id;
4262 } else {
4264 || target_city != nullptr,
4265 "Action enabled against non existing city!");
4266
4268 }
4269 break;
4270 case ATK_TILE:
4271 case ATK_EXTRAS:
4272 case ATK_UNITS:
4273 if (target_tile != nullptr) {
4275 } else {
4277 || target_tile != nullptr,
4278 "Action enabled against all units on "
4279 "non existing tile!");
4280
4282 }
4283 break;
4284 case ATK_SELF:
4285 qv2 = actor_unit->id;
4286 break;
4287 case ATK_COUNT:
4289 "Bad target kind");
4290 continue;
4291 }
4292
4293 if (asd->get_identified_button(act)) {
4294 // Update the existing button.
4295 action_entry_update(asd->get_identified_button(act),
4296 act, act_probs, custom,
4297 qv1, qv2);
4298 } else {
4299 // Add the button (unless its probability is 0).
4301 qv1, qv2);
4302 }
4304
4305 if (wait_button != nullptr || cancel_button != nullptr) {
4306 /* Reinsert the non action buttons below any potential
4307 * buttons recently added. */
4308 asd->unstack_all_buttons();
4309 }
4310}
4311
4312/***********************************************************************/
4316{
4318
4319 cd = gui()->get_diplo_dialog();
4320 if (cd != nullptr) {
4321 did_not_decide = true;
4322 cd->close();
4323 }
4324}
4325
4326/***********************************************************************/
4332
4333/***********************************************************************/
4336void show_tileset_error(bool fatal, const char *tset_name, const char *msg)
4337{
4338 QWidget *parent;
4339 fc_client *std_gui = gui();
4340
4341 if (std_gui != nullptr) {
4342 parent = std_gui->central_wdg;
4343 } else {
4344 parent = nullptr;
4345 }
4346
4347 if (std_gui != nullptr || fatal) {
4348 char buf[1024];
4349 QMessageBox *ask = new QMessageBox(parent);
4350
4351 if (tset_name != nullptr) {
4352 fc_snprintf(buf, sizeof(buf),
4353 _("Tileset \"%s\" problem, it's probably incompatible with "
4354 "the ruleset:\n%s"), tset_name, msg);
4355 } else {
4356 fc_snprintf(buf, sizeof(buf),
4357 _("Tileset problem, it's probably incompatible with "
4358 "the ruleset:\n%s"), msg);
4359 }
4360
4361 ask->setText(buf);
4362 ask->setStandardButtons(QMessageBox::Ok);
4363 ask->setWindowTitle(_("Tileset error"));
4364
4365 if (std_gui != nullptr) {
4366 ask->setAttribute(Qt::WA_DeleteOnClose);
4367 ask->show();
4368 } else {
4369 ask->exec();
4370 }
4371 }
4372}
4373
4374/***********************************************************************/
4377void popup_upgrade_dialog(struct unit_list *punits)
4378{
4379 char buf[512];
4381 QString title;
4383
4384 if (!punits || unit_list_size(punits) == 0) {
4385 return;
4386 }
4387
4388 ask = new hud_message_box(gui()->central_wdg);
4389
4390 punit_ids = new QVector<int>();
4392 punit_ids->push_back(punit->id);
4394
4395 if (!get_units_upgrade_info(buf, sizeof(buf), punits)) {
4396 title = _("Upgrade Unit!");
4397 ask->setStandardButtons(QMessageBox::Ok);
4398 } else {
4399 title = _("Upgrade Obsolete Units");
4400 ask->setStandardButtons(QMessageBox::Cancel | QMessageBox::Ok);
4401 ask->setDefaultButton(QMessageBox::Cancel);
4402 }
4403 ask->set_text_title(buf, title);
4404 ask->setAttribute(Qt::WA_DeleteOnClose);
4405 QObject::connect(ask, &hud_message_box::accepted, [=]() {
4406 std::unique_ptr<QVector<int>> uptr(punit_ids);
4407 struct unit *punit;
4408
4409 for (int id : *uptr) {
4411 if (punit) {
4413 }
4414 }
4415 });
4416 ask->show();
4417}
4418
4419/***********************************************************************/
4423{
4424 QPoint p, final_p;
4425
4427 utile = ptile;
4428 pix = nullptr;
4429 show_line = 0;
4430 highligh_num = -1;
4431 ufont.setItalic(true);
4433 update_units();
4434 h_pix = nullptr;
4435 create_pixmap();
4436 p = mapFromGlobal(QCursor::pos());
4437 cw = new close_widget(this);
4438 setMouseTracking(true);
4439 final_p.setX(p.x());
4440 final_p.setY(p.y());
4441 if (p.x() + width() > parentWidget()->width()) {
4442 final_p.setX(parentWidget()->width() - width());
4443 }
4444 if (p.y() - height() < 0) {
4445 final_p.setY(height());
4446 }
4447 move(final_p.x(), final_p.y() - height());
4448 setFocus();
4449 /* Build fails with qt5 connect style for static functions
4450 * Qt5.2 so dont update */
4451 QTimer::singleShot(10, this, SLOT(update_img()));
4452}
4453
4454/***********************************************************************/
4458{
4459 delete h_pix;
4460 delete pix;
4461 delete cw;
4462}
4463
4464/***********************************************************************/
4468{
4469 int a;
4470 int x, y, i;
4473 QImage img;
4475 QPainter p;
4476 QPen pen;
4477 QPixmap pixc;
4478 QPixmap *pixp;
4480 QRect crop;
4481 struct canvas *unit_pixmap;
4482 struct unit *punit;
4483 float isosize;
4484
4485 if (pix != nullptr) {
4486 delete pix;
4487 pix = nullptr;
4488 };
4489 isosize = 0.7;
4491 isosize = 0.5;
4492 }
4493
4494 update_units();
4495 if (unit_list.count() > 0) {
4499 } else {
4502 }
4503 more = false;
4504 if (h_pix != nullptr) {
4505 delete h_pix;
4506 }
4507 h_pix = new QPixmap(item_size.width(), item_size.height());
4508 h_pix->fill(palette().color(QPalette::HighlightedText));
4509 if (unit_count < 5) {
4510 row_count = 1;
4511 pix = new QPixmap((unit_list.size()) * item_size.width(),
4512 item_size.height());
4513 } else if (unit_count < 9) {
4514 row_count = 2;
4515 pix = new QPixmap(4 * item_size.width(), 2 * item_size.height());
4516 } else {
4517 row_count = 3;
4518 if (unit_count > 12) {
4519 more = true;
4520 }
4521 pix = new QPixmap(4 * item_size.width(), 3 * item_size.height());
4522 }
4523 pix->fill(Qt::transparent);
4524 foreach(punit, unit_list) {
4527 unit_pixmap->map_pixmap.fill(Qt::transparent);
4528 put_unit(punit, unit_pixmap, 1.0, 0, 0);
4529 img = unit_pixmap->map_pixmap.toImage();
4531 cropped_img = img.copy(crop);
4535 Qt::KeepAspectRatio,
4536 Qt::SmoothTransformation);
4537 } else {
4540 Qt::KeepAspectRatio,
4541 Qt::SmoothTransformation);
4542 }
4543 pixc = QPixmap::fromImage(img);
4544 pixp = new QPixmap(pixc);
4545 pix_list.push_back(pixp);
4547 }
4548 a = qMin(item_size.width() / 4, 12);
4549 x = 0, y = -item_size.height(), i = -1;
4550 p.begin(pix);
4551 ufont.setPixelSize(a);
4552 p.setFont(ufont);
4553 pen.setColor(palette().color(QPalette::Text));
4554 p.setPen(pen);
4555
4556 while (!pix_list.isEmpty()) {
4557 tmp_pix = pix_list.takeFirst();
4558 i++;
4559 if (i % 4 == 0) {
4560 x = 0;
4561 y = y + item_size.height();
4562 }
4563 punit = unit_list.at(i);
4564 Q_ASSERT(punit != nullptr);
4565
4566 if (i == highligh_num) {
4567 p.drawPixmap(x, y, *h_pix);
4568 p.drawPixmap(x, y, *tmp_pix);
4569 } else {
4570 p.drawPixmap(x, y, *tmp_pix);
4571 }
4572
4574 int rate, f;
4575 QString str;
4576
4578 f = ((punit->fuel) - 1);
4581 str = str + "(" + QString(move_points_text((rate * f)
4582 + punit->moves_left, false)) + ")";
4583 }
4584 // TRANS: MP = Movement points
4585 str = QString(_("MP:")) + str;
4586 p.drawText(x, y + item_size.height() - 4, str);
4587 }
4588
4589 x = x + item_size.width();
4590 delete tmp_pix;
4591 }
4592 p.end();
4593 setFixedWidth(pix->width() + 20);
4594 setFixedHeight(pix->height() + 2 * (fm.height() + 6));
4595 qDeleteAll(pix_list.begin(), pix_list.end());
4596 }
4597}
4598
4599/***********************************************************************/
4603{
4604 int a, b;
4605 int old_h;
4607 QPoint pos = event->pos();
4608 int x = pos.x();
4609 int y = pos.y();
4610
4612 highligh_num = -1;
4613 if (x > width() - 11
4614 || y > height() - fm.height() - 5
4615 || y < fm.height() + 3 || x < 11) {
4616 // Do nothing if mouse is on border, just skip next if
4617 } else if (row_count > 0) {
4618 a = (x - 10) / item_size.width();
4619 b = (y - fm.height() - 3) / item_size.height();
4620 highligh_num = b * 4 + a;
4621 }
4622 if (old_h != highligh_num) {
4623 create_pixmap();
4624 update();
4625 }
4626}
4627
4628/***********************************************************************/
4634{
4635 struct unit *punit;
4636 if (event->button() == Qt::RightButton) {
4637 was_destroyed = true;
4638 close();
4639 destroy();
4640 }
4641 if (event->button() == Qt::LeftButton && highligh_num != -1) {
4642 update_units();
4643 if (highligh_num >= unit_list.count()) {
4644 return;
4645 }
4648 was_destroyed = true;
4649 close();
4650 destroy();
4651 }
4652}
4653
4654/***********************************************************************/
4659{
4660 create_pixmap();
4661 update();
4662}
4663
4664/***********************************************************************/
4668{
4670 int h, i;
4671 int *f_size;
4672 QPen pen;
4673 QString str, str2;
4674 struct unit *punit;
4675 int point_size = info_font.pointSize();
4676 int pixel_size = info_font.pixelSize();
4677
4678 if (point_size < 0) {
4679 f_size = &pixel_size;
4680 } else {
4681 f_size = &point_size;
4682 }
4683 if (highligh_num != -1 && highligh_num < unit_list.count()) {
4684 struct astring addition = ASTRING_INIT;
4685
4688
4689 // TRANS: HP - hit points
4690 str2 = QString(_("%1 HP:%2/%3")).arg(QString(astr_str(&addition)),
4691 QString::number(punit->hp),
4692 QString::number(unit_type_get(punit)->hp));
4694 }
4695 str = QString(PL_("%1 unit", "%1 units",
4697 .arg(unit_list_size(utile->units));
4698 for (i = *f_size; i > 4; i--) {
4699 if (point_size < 0) {
4700 info_font.setPixelSize(i);
4701 } else {
4702 info_font.setPointSize(i);
4703 }
4705 if (10 + qfm.horizontalAdvance(str2) < width()) {
4706 break;
4707 }
4708 }
4709 h = fm.height();
4710 if (pix != nullptr) {
4711 painter->drawPixmap(10, h + 3, *pix);
4712 pen.setColor(palette().color(QPalette::Text));
4713 painter->setPen(pen);
4714 painter->setFont(info_font);
4715 painter->drawText(10, h, str);
4716 if (highligh_num != -1 && highligh_num < unit_list.count()) {
4717 painter->drawText(10, height() - 5, str2);
4718 }
4719 // Draw scroll
4720 if (more) {
4721 int maxl = ((unit_count - 1) / 4) + 1;
4722 float page_height = 3.0f / maxl;
4723 float page_start = (static_cast<float>(show_line)) / maxl;
4724 pen.setColor(palette().color(QPalette::HighlightedText));
4725 painter->setBrush(palette().color(QPalette::HighlightedText).darker());
4726 painter->setPen(palette().color(QPalette::HighlightedText).darker());
4727 painter->drawRect(pix->width() + 10, h, 8, h + pix->height());
4728 painter->setPen(pen);
4729 painter->drawRoundedRect(pix->width() + 10,
4730 h + page_start * pix->height(),
4731 8, h + page_height * pix->height(), 2, 2);
4732 }
4733 }
4734 if (point_size < 0) {
4735 info_font.setPixelSize(*f_size);
4736 } else {
4737 info_font.setPointSize(*f_size);
4738 }
4739 cw->put_to_corner();
4740}
4741
4742/***********************************************************************/
4746{
4748
4749 painter.begin(this);
4750 paint(&painter, event);
4751 painter.end();
4752}
4753
4754/***********************************************************************/
4759{
4760 was_destroyed = true;
4761 close();
4762 destroy();
4763}
4764
4765/***********************************************************************/
4769{
4770 int i = 1;
4771 struct unit_list *punit_list;
4772
4773 unit_count = 0;
4774 if (utile == nullptr) {
4775 struct unit *punit = head_of_units_in_focus();
4776 if (punit) {
4778 }
4779 }
4780 unit_list.clear();
4781 if (utile != nullptr) {
4783 if (punit_list != nullptr) {
4785 unit_count++;
4786 if (i > show_line * 4)
4787 unit_list.push_back(punit);
4788 i++;
4790 }
4791 }
4792 if (unit_list.count() == 0) {
4793 close();
4794 }
4795}
4796
4797/***********************************************************************/
4801{
4802 gui()->mapview_wdg->setFocus();
4803 QWidget::closeEvent(event);
4804}
4805
4806/***********************************************************************/
4810{
4811 int nr;
4812
4813 if (!more && utile == nullptr) {
4814 return;
4815 }
4816 nr = qCeil(static_cast<qreal>(unit_list_size(utile->units)) / 4) - 3;
4817 if (event->angleDelta().y() < 0) {
4818 show_line++;
4820 } else {
4821 show_line--;
4822 show_line = qMax(0, show_line);
4823 }
4824 update_units();
4825 create_pixmap();
4826 update();
4827 event->accept();
4828}
4829
4830/***********************************************************************/
4834{
4835 if (event->key() == Qt::Key_Escape) {
4836 was_destroyed = true;
4837 close();
4838 destroy();
4839 }
4840 QWidget::keyPressEvent(event);
4841}
4842
4843/***********************************************************************/
4850
4851/***********************************************************************/
4858
4859/***********************************************************************/
4864{
4865 // Just tell the client common code to handle this.
4866 return false;
4867}
4868
4869/***********************************************************************/
4872bool qtg_request_transport(struct unit *pcargo, struct tile *ptile)
4873{
4874 int tcount;
4876 struct unit_list *potential_transports = unit_list_new();
4877#ifndef FREECIV_NDEBUG
4879#endif
4880
4884 }
4886
4888
4889 if (tcount == 0) {
4890 fc_assert(best_transport == nullptr);
4892
4893 return false; // Unit was not handled here.
4894 } else if (tcount == 1) {
4895 // There's exactly one potential transport - use it automatically
4898
4900
4901 return true;
4902 }
4903
4904 hul = new hud_unit_loader(pcargo, ptile);
4905 hul->show_me();
4906 return true;
4907}
4908
4909/***********************************************************************/
4913void qtg_popup_combat_info(int attacker_unit_id, int defender_unit_id,
4914 int attacker_hp, int defender_hp,
4915 bool make_att_veteran, bool make_def_veteran)
4916{
4917 if (gui()->qt_settings.show_battle_log) {
4918 hud_unit_combat *huc = new hud_unit_combat(attacker_unit_id,
4919 defender_unit_id,
4920 attacker_hp, defender_hp,
4921 make_att_veteran,
4922 make_def_veteran,
4923 gui()->battlelog_wdg->scale,
4924 gui()->battlelog_wdg);
4925
4926 gui()->battlelog_wdg->add_combat_info(huc);
4927 gui()->battlelog_wdg->show();
4928 }
4929}
4930
4931/**********************************************************************/
4935 struct act_confirmation_data *data)
4936{
4937 hud_message_box *ask = new hud_message_box(gui()->central_wdg);
4938
4939 ask->setStandardButtons(QMessageBox::Cancel | QMessageBox::Ok);
4940 ask->setDefaultButton(QMessageBox::Cancel);
4941 ask->set_text_title(body, hdr);
4942 ask->setAttribute(Qt::WA_DeleteOnClose);
4943 QObject::connect(ask, &hud_message_box::accepted, [=]() {
4945 });
4946 QObject::connect(ask, &hud_message_box::rejected, [=]() {
4948 });
4949
4950 ask->show();
4951}
4952
4953/***********************************************************************/
4957 struct act_confirmation_data *data)
4958{
4960
4961 hdr = QString(_("Are you sure you want to do %1?")).
4963
4964 if (expl != nullptr) {
4965 body_text += QString(expl);
4966 }
4967
4969}
4970
4971/**********************************************************************/
4974void qtg_popup_image(const char *tag, int width, int height)
4975{
4976 struct sprite *spr = load_popup_sprite(tag);
4977
4978 if (spr != nullptr) {
4979 QDialog *win = new QDialog(gui());
4980 QVBoxLayout *layout = new QVBoxLayout(win);
4981 QPixmap *pm = new QPixmap(*spr->pm);
4982 QLabel *lbl = new QLabel;
4983
4984 win->setFixedSize(width, height);
4985 lbl->setPixmap(*pm);
4986 layout->addWidget(lbl);
4987 win->setLayout(layout);
4988
4989 win->show();
4990
4992 } else {
4993 log_error(_("No image for tag \"%s\", requested by the server."), tag);
4994 }
4995}
const char * action_prepare_ui_name(action_id act_id, const char *mnemonic, const struct act_prob prob, const char *custom)
Definition actions.c:1287
const char * action_id_name_translation(action_id act_id)
Definition actions.c:1225
bool action_prob_possible(const struct act_prob probability)
Definition actions.c:5044
static struct action * action_by_number(action_id act_id)
Definition actions.h:390
#define action_iterate_end
Definition actions.h:209
#define action_id_get_actor_kind(act_id)
Definition actions.h:403
#define action_iterate(_act_)
Definition actions.h:205
#define action_id_get_target_kind(act_id)
Definition actions.h:407
#define ACTION_NONE
Definition actions.h:55
void astr_free(struct astring *astr)
Definition astring.c:148
void astr_set(struct astring *astr, const char *format,...)
Definition astring.c:251
#define str
Definition astring.c:76
static const char * astr_str(const struct astring *astr) fc__attribute((nonnull(1)))
Definition astring.h:93
#define ASTRING_INIT
Definition astring.h:44
void audio_restart(const char *soundset_name, const char *musicset_name)
Definition audio.c:376
#define BV_CLR(bv, bit)
Definition bitvector.h:86
QRect zealous_crop_rect(QImage &p)
Definition canvas.cpp:419
void qtg_canvas_free(struct canvas *store)
Definition canvas.cpp:48
struct canvas * qtg_canvas_create(int width, int height)
Definition canvas.cpp:36
struct canvas int int struct sprite int int int int height
Definition canvas_g.h:44
struct canvas int int struct sprite int int int width
Definition canvas_g.h:44
void output_window_append(const struct ft_color color, const char *featured_text)
const char * city_improvement_name_translation(const struct city *pcity, const struct impr_type *pimprove)
Definition city.c:663
const char * city_name_get(const struct city *pcity)
Definition city.c:1133
#define INCITE_IMPOSSIBLE_COST
Definition city.h:96
#define city_owner(_pcity_)
Definition city.h:563
#define city_built_iterate(_pcity, _p)
Definition city.h:825
#define city_built_iterate_end
Definition city.h:831
void qtg_real_city_dialog_popup(struct city *pcity)
Definition citydlg.cpp:3689
Choice_dialog_button(const QString title, pfcn_void func_in, QVariant data1_in, QVariant data2_in)
Definition dialogs.cpp:1338
void setData2(QVariant wariat)
Definition dialogs.cpp:1386
void setData1(QVariant wariat)
Definition dialogs.cpp:1378
pfcn_void getFunc()
Definition dialogs.cpp:1352
void stack_button(Choice_dialog_button *button)
Definition dialogs.cpp:1712
void prev_unit()
Definition dialogs.cpp:1629
QVBoxLayout * layout
Definition dialogs.h:263
struct unit * targeted_unit
Definition dialogs.h:286
void unstack_all_buttons()
Definition dialogs.cpp:1729
Choice_dialog_button * get_identified_button(const int id)
Definition dialogs.cpp:1541
QPushButton * target_unit_button
Definition dialogs.h:262
void set_layout()
Definition dialogs.cpp:1447
void update_dialog(const struct act_prob *act_probs)
Definition dialogs.cpp:1658
QList< Choice_dialog_button * > last_buttons_stack
Definition dialogs.h:266
void next_unit()
Definition dialogs.cpp:1589
QVBoxLayout * get_layout()
Definition dialogs.cpp:1533
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:1394
int target_id[ATK_COUNT]
Definition dialogs.h:284
void switch_target()
Definition dialogs.cpp:1676
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:1695
void add_item(QString title, pfcn_void func, QVariant data1, QVariant data2, QString tool_tip, const int button_id)
Definition dialogs.cpp:1489
void put_to_corner()
Definition mapview.cpp:502
void disband_clicked()
Definition dialogs.cpp:3935
disband_box(struct unit_list *punits, QWidget *parent=0)
Definition dialogs.cpp:3909
struct unit_list * cpunits
Definition dialogs.h:97
choice_dialog * opened_dialog
Definition fc_client.h:219
choice_dialog * get_diplo_dialog()
Definition dialogs.cpp:4854
void set_diplo_dialog(choice_dialog *widget)
Definition dialogs.cpp:4846
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:460
int set_text_title(QString s1, QString s2, bool return_exec=false)
QString qheadline
Definition dialogs.h:193
void restart()
Definition dialogs.cpp:912
close_widget * cw
Definition dialogs.h:189
void mouseReleaseEvent(QMouseEvent *event)
Definition dialogs.cpp:1005
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:879
void calc_size(int &x, int &y)
Definition dialogs.cpp:940
void paintEvent(QPaintEvent *paint_event)
Definition dialogs.cpp:959
QPoint cursor
Definition dialogs.h:196
void mouseMoveEvent(QMouseEvent *event)
Definition dialogs.cpp:995
virtual void update_menu()
Definition dialogs.cpp:1013
void mousePressEvent(QMouseEvent *event)
Definition dialogs.cpp:982
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:1114
QPushButton * goto_but
Definition dialogs.h:111
void inspect_city()
Definition dialogs.cpp:1157
struct tile * gtile
Definition dialogs.h:114
QPushButton * inspect_but
Definition dialogs.h:112
void goto_tile()
Definition dialogs.cpp:1148
action_id vs_unit
Definition dialogs.h:60
static qdef_act * action()
Definition dialogs.cpp:1042
action_id vs_city_get()
Definition dialogs.cpp:1080
static qdef_act * m_instance
Definition dialogs.h:58
static void drop()
Definition dialogs.cpp:1053
action_id vs_city
Definition dialogs.h:59
void vs_city_set(int i)
Definition dialogs.cpp:1064
void vs_unit_set(int i)
Definition dialogs.cpp:1072
action_id vs_unit_get()
Definition dialogs.cpp:1088
QPoint point
Definition dialogs.h:81
void paintEvent(QPaintEvent *event)
Definition dialogs.cpp:349
QPixmap close_pix
Definition dialogs.h:83
void reactivate()
Definition dialogs.cpp:341
void mouseMoveEvent(QMouseEvent *event)
Definition dialogs.cpp:390
int titlebar_height
Definition dialogs.h:80
void mousePressEvent(QMouseEvent *event)
Definition dialogs.cpp:400
void mouseReleaseEvent(QMouseEvent *event)
Definition dialogs.cpp:420
qfc_dialog(QWidget *parent)
Definition dialogs.cpp:329
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:1104
void style_selected(const QItemSelection &sl, const QItemSelection &ds)
Definition dialogs.cpp:807
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:612
void nation_selected(const QItemSelection &sl, const QItemSelection &ds)
Definition dialogs.cpp:756
void nationset_changed(int index)
Definition dialogs.cpp:1169
int selected_nation
Definition dialogs.h:163
void ok_pressed()
Definition dialogs.cpp:841
void leader_selected(int index)
Definition dialogs.cpp:826
QPushButton * ok_button
Definition dialogs.h:142
QTextEdit * description
Definition dialogs.h:141
void group_selected(const QItemSelection &sl, const QItemSelection &ds)
Definition dialogs.cpp:678
void set_index(int index)
Definition dialogs.cpp:696
QComboBox * qnation_set
Definition dialogs.h:136
QRadioButton * is_male
Definition dialogs.h:138
QButtonGroup * sex_buttons
Definition dialogs.h:137
void update_nationset_combo()
Definition dialogs.cpp:662
QTableWidget * styles
Definition dialogs.h:140
struct player * tplayer
Definition dialogs.h:165
races_dialog(struct player *pplayer, QWidget *parent=0)
Definition dialogs.cpp:429
QRadioButton * is_female
Definition dialogs.h:139
QTableWidget * nation_tabs
Definition dialogs.h:132
QGridLayout * main_layout
Definition dialogs.h:131
void cancel_pressed()
Definition dialogs.cpp:1096
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:4800
void update_img()
Definition dialogs.cpp:4658
int show_line
Definition dialogs.h:233
void mouseMoveEvent(QMouseEvent *event)
Definition dialogs.cpp:4602
int highligh_num
Definition dialogs.h:234
void paint(QPainter *painter, QPaintEvent *event)
Definition dialogs.cpp:4667
void update_menu()
Definition dialogs.cpp:4758
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:4422
void update_units()
Definition dialogs.cpp:4768
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:4745
void create_pixmap()
Definition dialogs.cpp:4467
void wheelEvent(QWheelEvent *event)
Definition dialogs.cpp:4809
void keyPressEvent(QKeyEvent *event)
Definition dialogs.cpp:4833
void mousePressEvent(QMouseEvent *event)
Definition dialogs.cpp:4633
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:1248
char * incite_cost
Definition comments.c:74
void action_selection_no_longer_in_progress(const int old_actor_id)
Definition control.c:1033
void request_unit_load(struct unit *pcargo, struct unit *ptrans, struct tile *ptile)
Definition control.c:2129
void unit_focus_set(struct unit *punit)
Definition control.c:501
void request_do_action(action_id action, int actor_id, int target_id, int sub_tgt, const char *name)
Definition control.c:1704
void request_unit_disband(struct unit *punit)
Definition control.c:2048
void request_action_details(action_id action, int actor_id, int target_id)
Definition control.c:1772
void request_new_unit_activity_targeted(struct unit *punit, enum unit_activity act, struct extra_type *tgt)
Definition control.c:1912
void action_confirmation(struct act_confirmation_data *data, bool confirm)
Definition control.c:1740
void action_decision_clear_want(const int old_actor_id)
Definition control.c:1054
void key_unit_wait(void)
Definition control.c:3515
struct unit * head_of_units_in_focus(void)
Definition control.c:405
void request_unit_upgrade(struct unit *punit)
Definition control.c:2079
void action_selection_next_in_focus(const int old_actor_id)
Definition control.c:1066
bool qtg_handmade_scenario_warning()
Definition dialogs.cpp:4863
static void attack(QVariant data1, QVariant data2)
Definition dialogs.cpp:3016
static void wipe_units(QVariant data1, QVariant data2)
Definition dialogs.cpp:2737
char forced_tileset_name[512]
int action_selection_target_extra(void)
Definition dialogs.cpp:4161
static void destroy_city(QVariant data1, QVariant data2)
Definition dialogs.cpp:3393
static void spy_sabotage_unit(QVariant data1, QVariant data2)
Definition dialogs.cpp:2457
static void pillage(QVariant data1, QVariant data2)
Definition dialogs.cpp:2877
static void caravan_marketplace(QVariant data1, QVariant data2)
Definition dialogs.cpp:1743
static void clean(QVariant data1, QVariant data2)
Definition dialogs.cpp:2897
static void spy_steal_shared(QVariant data1, QVariant data2, action_id act_id)
Definition dialogs.cpp:3151
static void spy_sabotage(QVariant data1, QVariant data2)
Definition dialogs.cpp:3784
int action_selection_target_tile(void)
Definition dialogs.cpp:4144
static void spy_investigate(QVariant data1, QVariant data2)
Definition dialogs.cpp:3513
static void act_sel_wait(QVariant data1, QVariant data2)
Definition dialogs.cpp:1912
static void nuke_units(QVariant data1, QVariant data2)
Definition dialogs.cpp:2725
int action_selection_actor_unit(void)
Definition dialogs.cpp:4110
static void capture_units(QVariant data1, QVariant data2)
Definition dialogs.cpp:2749
static void road(QVariant data1, QVariant data2)
Definition dialogs.cpp:2917
static bool is_race_dialog_open
Definition dialogs.cpp:189
static void transport_embark4(QVariant data1, QVariant data2)
Definition dialogs.cpp:2569
bool try_default_unit_action(QVariant q1, QVariant q2)
Definition dialogs.cpp:1554
static void fortify(QVariant data1, QVariant data2)
Definition dialogs.cpp:2399
static void transport_board(QVariant data1, QVariant data2)
Definition dialogs.cpp:2503
static void spy_sabotage_unit_esc(QVariant data1, QVariant data2)
Definition dialogs.cpp:2469
static void disband_unit(QVariant data1, QVariant data2)
Definition dialogs.cpp:2387
static void spy_steal_gold(QVariant data1, QVariant data2)
Definition dialogs.cpp:3408
void popdown_players_report()
Definition plrdlg.cpp:1191
static void spy_escape(QVariant data1, QVariant data2)
Definition dialogs.cpp:3468
static void mine(QVariant data1, QVariant data2)
Definition dialogs.cpp:2959
void popup_musicset_suggestion_dialog(void)
Definition dialogs.cpp:4021
static void spy_steal_gold_esc(QVariant data1, QVariant data2)
Definition dialogs.cpp:3423
static void diplomat_embassy(QVariant data1, QVariant data2)
Definition dialogs.cpp:3498
void unit_select_dialog_popup(struct tile *ptile)
Definition dialogs.cpp:1254
void popup_upgrade_dialog(struct unit_list *punits)
Definition dialogs.cpp:4377
void update_nationset_combo()
Definition dialogs.cpp:1274
void action_selection_close(void)
Definition dialogs.cpp:4315
static void cultivate(QVariant data1, QVariant data2)
Definition dialogs.cpp:2847
static void paradrop_enter(QVariant data1, QVariant data2)
Definition dialogs.cpp:3106
void races_update_pickable(bool nationset_change)
Definition dialogs.cpp:1284
int action_selection_target_city(void)
Definition dialogs.cpp:4127
static void spy_steal_something(QVariant data1, QVariant data2)
Definition dialogs.cpp:3241
#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:1192
static void spy_poison(QVariant data1, QVariant data2)
Definition dialogs.cpp:3318
static void transport_board2(QVariant data1, QVariant data2)
Definition dialogs.cpp:2514
void show_tech_gained_dialog(Tech_type_id tech)
Definition dialogs.cpp:4329
static void base(QVariant data1, QVariant data2)
Definition dialogs.cpp:2938
static void spy_nuke_city_esc(QVariant data1, QVariant data2)
Definition dialogs.cpp:3363
void popup_soundset_suggestion_dialog(void)
Definition dialogs.cpp:3996
static void enter_hut2(QVariant data1, QVariant data2)
Definition dialogs.cpp:2680
void popup_races_dialog(struct player *pplayer)
Definition dialogs.cpp:1229
static void expel_unit(QVariant data1, QVariant data2)
Definition dialogs.cpp:2761
static void paradrop_frighten(QVariant data1, QVariant data2)
Definition dialogs.cpp:3076
static void diplomat_sabotage(QVariant data1, QVariant data2)
Definition dialogs.cpp:3543
void popup_disband_dialog(struct unit_list *punits)
Definition dialogs.cpp:3955
static action_id get_non_targeted_action_id(action_id tgt_action_id)
Definition dialogs.cpp:2282
static void homeless(QVariant data1, QVariant data2)
Definition dialogs.cpp:2425
static void caravan_help_build(QVariant data1, QVariant data2)
Definition dialogs.cpp:1773
static void bombard(QVariant data1, QVariant data2)
Definition dialogs.cpp:2773
void popdown_races_dialog(void)
Definition dialogs.cpp:1243
void popup_tileset_suggestion_dialog(void)
Definition dialogs.cpp:3965
static void conquer_city(QVariant data1, QVariant data2)
Definition dialogs.cpp:1854
void revolution_response(struct government *gov)
Definition dialogs.cpp:1927
void popdown_economy_report()
static void join_city(QVariant data1, QVariant data2)
Definition dialogs.cpp:3136
static void spy_request_sabotage_list(QVariant data1, QVariant data2)
Definition dialogs.cpp:3281
static void diplomat_bribe(QVariant data1, QVariant data2)
Definition dialogs.cpp:2439
static void popup_act_confirmation_dialog(QString hdr, QString body, struct act_confirmation_data *data)
Definition dialogs.cpp:4934
static void unit_disband_recover(QVariant data1, QVariant data2)
Definition dialogs.cpp:1788
static void spy_steal(QVariant data1, QVariant data2)
Definition dialogs.cpp:3225
static void airlift(QVariant data1, QVariant data2)
Definition dialogs.cpp:1839
void popup_pillage_dialog(struct unit *punit, bv_extras extras)
Definition dialogs.cpp:3876
void popup_sabotage_dialog(struct unit *actor, struct city *tcity, const struct action *paction)
Definition dialogs.cpp:3814
static void transport_load3(QVariant data1, QVariant data2)
Definition dialogs.cpp:2613
static void bombard_lethal(QVariant data1, QVariant data2)
Definition dialogs.cpp:2809
static void plant(QVariant data1, QVariant data2)
Definition dialogs.cpp:2862
static void nuke(QVariant data1, QVariant data2)
Definition dialogs.cpp:3001
static void disembark2(QVariant data1, QVariant data2)
Definition dialogs.cpp:2650
static void transport_unload(QVariant data1, QVariant data2)
Definition dialogs.cpp:2580
void qtg_request_action_confirmation(const char *expl, struct act_confirmation_data *data)
Definition dialogs.cpp:4956
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:4192
void popdown_science_report()
static void transport_load2(QVariant data1, QVariant data2)
Definition dialogs.cpp:2602
static void diplomat_steal(QVariant data1, QVariant data2)
Definition dialogs.cpp:3573
static void unit_upgrade(QVariant data1, QVariant data2)
Definition dialogs.cpp:1818
bool popup_theme_suggestion_dialog(const char *theme_name)
Definition dialogs.cpp:4046
static void enter_hut(QVariant data1, QVariant data2)
Definition dialogs.cpp:2665
static void spy_request_strike_bld_list(QVariant data1, QVariant data2)
Definition dialogs.cpp:3264
static void diplomat_incite_escape(QVariant data1, QVariant data2)
Definition dialogs.cpp:3621
static void found_city(QVariant data1, QVariant data2)
Definition dialogs.cpp:2821
static void diplomat_investigate(QVariant data1, QVariant data2)
Definition dialogs.cpp:3528
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:4913
static void bombard3(QVariant data1, QVariant data2)
Definition dialogs.cpp:2797
static void transport_deboard(QVariant data1, QVariant data2)
Definition dialogs.cpp:2624
static void diplomat_incite(QVariant data1, QVariant data2)
Definition dialogs.cpp:3603
static void paradrop_conquer(QVariant data1, QVariant data2)
Definition dialogs.cpp:3061
void popdown_endgame_report()
static void diplomat_steal_esc(QVariant data1, QVariant data2)
Definition dialogs.cpp:3588
static bool is_more_user_input_needed
Definition dialogs.cpp:194
static void bombard2(QVariant data1, QVariant data2)
Definition dialogs.cpp:2785
void popup_incite_dialog(struct unit *actor, struct city *tcity, int cost, const struct action *paction)
Definition dialogs.cpp:3655
static const QHash< action_id, pfcn_void > af_map_init(void)
Definition dialogs.cpp:207
void popdown_all_spaceships_dialogs()
static void nuke_city(QVariant data1, QVariant data2)
Definition dialogs.cpp:3378
void popup_connect_msg(const char *headline, const char *message)
Definition dialogs.cpp:1204
static void diplomat_sabotage_esc(QVariant data1, QVariant data2)
Definition dialogs.cpp:3558
void popdown_units_report()
static void transport_embark2(QVariant data1, QVariant data2)
Definition dialogs.cpp:2547
static void spy_nuke_city(QVariant data1, QVariant data2)
Definition dialogs.cpp:3348
void unit_select_dialog_update_real(void *unused)
Definition dialogs.cpp:1266
static void spy_steal_esc(QVariant data1, QVariant data2)
Definition dialogs.cpp:3233
static void paradrop(QVariant data1, QVariant data2)
Definition dialogs.cpp:3046
static void suicide_attack(QVariant data1, QVariant data2)
Definition dialogs.cpp:3031
void races_toggles_set_sensitive(void)
Definition dialogs.cpp:1295
static void transport_load(QVariant data1, QVariant data2)
Definition dialogs.cpp:2591
static action_id get_production_targeted_action_id(action_id tgt_action_id)
Definition dialogs.cpp:2305
static void paradrop_frighten_conquer(QVariant data1, QVariant data2)
Definition dialogs.cpp:3091
static void convert_unit(QVariant data1, QVariant data2)
Definition dialogs.cpp:2413
static bool did_not_decide
Definition dialogs.cpp:198
static void spy_poison_esc(QVariant data1, QVariant data2)
Definition dialogs.cpp:3333
static void pillage_something(QVariant data1, QVariant data2)
Definition dialogs.cpp:3764
static void spy_request_sabotage_esc_list(QVariant data1, QVariant data2)
Definition dialogs.cpp:3299
static void transform_terrain(QVariant data1, QVariant data2)
Definition dialogs.cpp:2832
#define BUTTON_CANCEL
Definition dialogs.cpp:72
static void conquer_extras(QVariant data1, QVariant data2)
Definition dialogs.cpp:1884
static void regular_move(QVariant data1, QVariant data2)
Definition dialogs.cpp:3639
static void heal_unit2(QVariant data1, QVariant data2)
Definition dialogs.cpp:2492
static void transport_board3(QVariant data1, QVariant data2)
Definition dialogs.cpp:2525
static void spy_embassy(QVariant data1, QVariant data2)
Definition dialogs.cpp:3483
static races_dialog * race_dialog
Definition dialogs.cpp:188
void qtg_popup_image(const char *tag, int width, int height)
Definition dialogs.cpp:4974
static void frighten_hut2(QVariant data1, QVariant data2)
Definition dialogs.cpp:2710
static void conquer_city2(QVariant data1, QVariant data2)
Definition dialogs.cpp:1869
static void conquer_extras2(QVariant data1, QVariant data2)
Definition dialogs.cpp:1898
static void frighten_hut(QVariant data1, QVariant data2)
Definition dialogs.cpp:2695
bool qtg_request_transport(struct unit *pcargo, struct tile *ptile)
Definition dialogs.cpp:4872
int action_selection_target_unit(void)
Definition dialogs.cpp:4178
static void irrigate(QVariant data1, QVariant data2)
Definition dialogs.cpp:2980
static void transport_embark3(QVariant data1, QVariant data2)
Definition dialogs.cpp:2558
static void heal_unit(QVariant data1, QVariant data2)
Definition dialogs.cpp:2481
void popdown_city_report()
Definition cityrep.cpp:1339
static void paradrop_enter_conquer(QVariant data1, QVariant data2)
Definition dialogs.cpp:3121
static void unit_home_city(QVariant data1, QVariant data2)
Definition dialogs.cpp:1803
static void transport_embark(QVariant data1, QVariant data2)
Definition dialogs.cpp:2536
bool try_default_city_action(QVariant q1, QVariant q2)
Definition dialogs.cpp:1572
static void keep_moving(QVariant data1, QVariant data2)
Definition dialogs.cpp:1920
static void spy_steal_maps_esc(QVariant data1, QVariant data2)
Definition dialogs.cpp:3453
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:2358
static void disembark1(QVariant data1, QVariant data2)
Definition dialogs.cpp:2635
void restart_notify_dialogs()
Definition dialogs.cpp:4055
static bool is_showing_pillage_dialog
Definition dialogs.cpp:187
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:2325
static const QHash< action_id, pfcn_void > af_map
Definition dialogs.cpp:324
static void caravan_establish_trade(QVariant data1, QVariant data2)
Definition dialogs.cpp:1758
void popdown_all_game_dialogs(void)
Definition dialogs.cpp:4071
static void spy_steal_maps(QVariant data1, QVariant data2)
Definition dialogs.cpp:3438
struct unit struct city struct unit * target_unit
Definition dialogs_g.h:56
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit int const struct action *paction show_tileset_error
Definition dialogs_g.h:85
popup_action_selection
Definition dialogs_g.h:55
struct unit * actor_unit
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 popup_bribe_dialog
Definition dialogs_g.h:73
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit * actor
Definition dialogs_g.h:73
const char * caption
Definition dialogs_g.h:37
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs action_selection_no_longer_in_progress_gui_specific
Definition dialogs_g.h:69
const char const char * headline
Definition dialogs_g.h:38
popup_notify_dialog
Definition dialogs_g.h:37
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit int const struct action *paction bool fatal
Definition dialogs_g.h:86
struct unit struct city struct unit struct tile * target_tile
Definition dialogs_g.h:57
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit * punit
Definition dialogs_g.h:74
struct unit struct city * target_city
Definition dialogs_g.h:56
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit int cost
Definition dialogs_g.h:74
struct unit struct city struct unit struct tile struct extra_type * target_extra
Definition dialogs_g.h:57
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 bool const char * tset_name
Definition dialogs_g.h:86
int int id
Definition editgui_g.h:28
enum event_type event
Definition events.c:81
int extra_number(const struct extra_type *pextra)
Definition extras.c:161
struct extra_type * extra_by_number(int id)
Definition extras.c:183
static struct extra_type extras[MAX_EXTRA_TYPES]
Definition extras.c:31
const char * extra_name_translation(const struct extra_type *pextra)
Definition extras.c:194
#define extra_index(_e_)
Definition extras.h:183
#define EXTRA_NONE
Definition extras.h:85
int Tech_type_id
Definition fc_types.h:381
int action_id
Definition fc_types.h:393
int Government_type_id
Definition fc_types.h:385
#define IDENTITY_NUMBER_ZERO
Definition fc_types.h:92
#define PL_(String1, String2, n)
Definition fcintl.h:71
#define _(String)
Definition fcintl.h:67
const struct ft_color ftc_client
struct civ_game game
Definition game.c:61
struct world wld
Definition game.c:62
struct unit * game_unit_by_number(int id)
Definition game.c:115
struct city * game_city_by_number(int id)
Definition game.c:106
struct government * government_by_number(const Government_type_id gov)
Definition government.c:103
Government_type_id government_number(const struct government *pgovern)
Definition government.c:91
#define G_LAST
Definition government.h:48
int action_selection_target_extra(void)
static int actor_unit_id
static void diplomat_queue_handle_primary(void)
static void diplomat_queue_handle_secondary(void)
#define BUTTON_COUNT
void action_selection_refresh(struct unit *actor_unit, struct city *target_city, struct unit *target_unit, struct tile *target_tile, struct extra_type *target_extra, const struct act_prob *act_probs)
static PangoLayout * layout
Definition canvas.c:325
static struct tile * pos
Definition finddlg.c:53
void popdown_help_dialog(void)
Definition helpdlg.c:186
const char * title
Definition repodlgs.c:1314
void(* pfcn_void)(QVariant, QVariant)
Definition dialogs.h:46
#define mevent_gpos(__ev__)
Definition gui_main.h:23
#define CAPTURE_DEFAULT_THIS
Definition gui_main.h:31
void nationset_changed(void)
Definition dialogs.c:3565
#define show(id)
Definition widget.h:235
void popup_revolution_dialog(void)
Definition dialogs.c:112
void helptext_nation(char *buf, size_t bufsz, struct nation_type *pnation, const char *user_text)
Definition helpdata.c:5003
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:181
#define fc_assert(condition)
Definition log.h:176
#define fc_assert_action(condition, action)
Definition log.h:187
@ LOG_ERROR
Definition log.h:30
#define log_error(message,...)
Definition log.h:103
struct tile * index_to_tile(const struct civ_map *imap, int mindex)
Definition map.c:462
void put_unit(const struct unit *punit, struct canvas *pcanvas, float zoom, int canvas_x, int canvas_y)
void center_tile_mapcanvas(const struct tile *ptile)
static const void * body(MD5_CTX *ctx, const void *data, unsigned long size)
Definition md5.c:121
#define FC_FREE(ptr)
Definition mem.h:41
const char * move_points_text(int mp, bool reduce)
Definition movement.c:1016
static mpgui * gui
Definition mpgui_qt.cpp:52
const char *const notify_label
Definition fonts.h:28
Nation_type_id nation_number(const struct nation_type *pnation)
Definition nation.c:486
bool nation_leader_is_male(const struct nation_leader *pleader)
Definition nation.c:290
const char * nation_adjective_for_player(const struct player *pplayer)
Definition nation.c:169
const char * nation_adjective_translation(const struct nation_type *pnation)
Definition nation.c:149
struct nation_type * nation_by_number(const Nation_type_id nation)
Definition nation.c:475
int nation_set_index(const struct nation_set *pset)
Definition nation.c:699
bool is_nation_pickable(const struct nation_type *nation)
Definition nation.c:188
const struct nation_leader_list * nation_leaders(const struct nation_type *pnation)
Definition nation.c:230
const char * nation_set_name_translation(const struct nation_set *pset)
Definition nation.c:818
bool is_nation_playable(const struct nation_type *nation)
Definition nation.c:200
bool nation_is_in_group(const struct nation_type *pnation, const struct nation_group *pgroup)
Definition nation.c:1099
const char * nation_set_description(const struct nation_set *pset)
Definition nation.c:828
const char * nation_group_name_translation(const struct nation_group *pgroup)
Definition nation.c:1090
int nation_set_count(void)
Definition nation.c:691
struct nation_group * nation_group_by_number(int id)
Definition nation.c:1004
struct nation_set * nation_set_by_rule_name(const char *name)
Definition nation.c:779
bool is_nation_group_hidden(struct nation_group *pgroup)
Definition nation.c:1057
struct nation_set * nation_set_by_setting_value(const char *setting)
Definition nation.c:859
const char * nation_leader_name(const struct nation_leader *pleader)
Definition nation.c:281
int nation_group_count(void)
Definition nation.c:935
const char * nation_set_rule_name(const struct nation_set *pset)
Definition nation.c:807
struct nation_style * style_of_nation(const struct nation_type *pnation)
Definition nation.c:672
#define nation_leader_list_iterate(leaderlist, pleader)
Definition nation.h:57
#define nation_sets_iterate_end
Definition nation.h:305
#define nation_sets_iterate(NAME_pset)
Definition nation.h:301
#define nations_iterate_end
Definition nation.h:336
#define nations_iterate(NAME_pnation)
Definition nation.h:333
#define nation_leader_list_iterate_end
Definition nation.h:59
const struct option_set * server_optset
Definition options.c:4281
bool option_str_set(struct option *poption, const char *str)
Definition options.c:961
const char * option_str_get(const struct option *poption)
Definition options.c:928
struct option * optset_option_by_name(const struct option_set *poptset, const char *name)
Definition options.c:466
#define REQEST_PLAYER_INITIATED
Definition packets.h:63
int dsend_packet_unit_get_actions(struct connection *pc, int actor_unit_id, int target_unit_id, int target_tile_id, int target_extra_id, int request_kind)
int dsend_packet_nation_select_req(struct connection *pc, int player_no, Nation_type_id nation_no, bool is_male, const char *name, int style)
int dsend_packet_city_name_suggestion_req(struct connection *pc, int unit_id)
void start_revolution(void)
Definition packhand.c:2392
void set_government_choice(struct government *government)
Definition packhand.c:2379
char * lines
Definition packhand.c:131
int player_number(const struct player *pplayer)
Definition player.c:837
const char * research_advance_name_translation(const struct research *presearch, Tech_type_id tech)
Definition research.c:273
struct research * research_get(const struct player *pplayer)
Definition research.c:128
enum tech_state research_invention_state(const struct research *presearch, Tech_type_id tech)
Definition research.c:619
bool research_invention_gettable(const struct research *presearch, const Tech_type_id tech, bool allow_holes)
Definition research.c:693
const char * sex_name_translation(sex_t kind)
Definition sex.c:60
@ SEX_FEMALE
Definition sex.h:22
@ SEX_MALE
Definition sex.h:23
#define ARRAY_SIZE(x)
Definition shared.h:85
size_t size
Definition specvec.h:72
struct sprite int int y
Definition sprite_g.h:31
struct sprite int x
Definition sprite_g.h:31
QPixmap map_pixmap
Definition canvas.h:25
Definition city.h:320
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:80
struct universal item
Definition climisc.h:81
struct player * player
Definition nation.h:118
bool tech_steal_allow_holes
char preferred_soundset[MAX_LEN_NAME]
char preferred_tileset[MAX_LEN_NAME]
char preferred_musicset[MAX_LEN_NAME]
int revolution_finishes
Definition player.h:273
char name[MAX_LEN_NAME]
Definition player.h:251
Definition menu.h:160
QPixmap * pm
Definition sprite.h:25
Definition tile.h:50
int index
Definition tile.h:51
struct unit_list * units
Definition tile.h:58
int move_rate
Definition unittype.h:524
Definition unit.h:140
int moves_left
Definition unit.h:152
struct unit::@81::@83 client
int id
Definition unit.h:147
int hp
Definition unit.h:153
int fuel
Definition unit.h:155
struct tile * tile
Definition unit.h:142
struct act_prob * act_prob_cache
Definition unit.h:231
int homecity
Definition unit.h:148
struct civ_map map
const char * style_name_translation(const struct nation_style *pstyle)
Definition style.c:99
int style_number(const struct nation_style *pstyle)
Definition style.c:68
int basic_city_style_for_style(struct nation_style *pstyle)
Definition style.c:210
#define styles_iterate(_p)
Definition style.h:46
#define styles_iterate_end
Definition style.h:52
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:960
#define sz_strlcpy(dest, src)
Definition support.h:189
#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:249
#define A_FIRST
Definition tech.h:44
#define A_UNSET
Definition tech.h:48
#define advance_index_iterate(_start, _index)
Definition tech.h:245
struct extra_type * get_preferred_pillage(bv_extras extras)
Definition terrain.c:550
bool get_units_upgrade_info(char *buf, size_t bufsz, struct unit_list *punits)
Definition text.c:1270
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:1723
const char * act_sel_action_tool_tip(const struct action *paction, const struct act_prob prob)
Definition text.c:1802
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:722
int tileset_unit_width(const struct tileset *t)
Definition tilespec.c:798
int tileset_unit_height(const struct tileset *t)
Definition tilespec.c:806
struct sprite * load_popup_sprite(const char *tag)
Definition tilespec.c:7621
bool tileset_is_isometric(const struct tileset *t)
Definition tilespec.c:713
struct sprite * get_sample_city_sprite(const struct tileset *t, int style_idx)
Definition tilespec.c:6890
const char * tileset_basename(const struct tileset *t)
Definition tilespec.c:705
int tileset_hex_height(const struct tileset *t)
Definition tilespec.c:731
void unload_popup_sprite(const char *tag)
Definition tilespec.c:7629
struct sprite * get_nation_flag_sprite(const struct tileset *t, const struct nation_type *pnation)
Definition tilespec.c:6795
void tileset_error(enum log_level level, const char *tset_name, const char *format,...)
Definition tilespec.c:625
bool tilespec_reread(const char *new_tileset_name, bool game_fully_initialized, float scale)
Definition tilespec.c:1376
struct unit * transporter_for_unit_at(const struct unit *pcargo, const struct tile *ptile)
Definition unit.c:1960
bool could_unit_load(const struct unit *pcargo, const struct unit *ptrans)
Definition unit.c:724
bool unit_can_do_action(const struct unit *punit, const action_id act_id)
Definition unit.c:386
void unit_activity_astr(const struct unit *punit, struct astring *astr)
Definition unit.c:1185
#define unit_tile(_pu)
Definition unit.h:397
#define unit_owner(_pu)
Definition unit.h:396
#define unit_list_iterate(unitlist, punit)
Definition unitlist.h:31
#define unit_list_iterate_end
Definition unitlist.h:33
const struct unit_type * unit_type_get(const struct unit *punit)
Definition unittype.c:123
const char * unit_name_translation(const struct unit *punit)
Definition unittype.c:1569
#define utype_fuel(ptype)
Definition unittype.h:843