Freeciv-3.2
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 (NULL != pplayer && pplayer == client.conn.playing) {
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/***********************************************************************/
696{
698 QPixmap *pix;
699 QFont f;
700 struct nation_group *group;
701 int i;
702 struct sprite *s;
703 QHeaderView *header;
704 bool svg = is_svg_flag_enabled();
705
706 selected_nation_tabs->clearContents();
707 selected_nation_tabs->setRowCount(0);
708
709 last_index = 0;
710 i = nation_tabs->currentRow();
711 if (i != -1) {
712 item = nation_tabs->item(i, 0);
713 index = item->data(Qt::UserRole).toInt();
714 }
715
716 group = nation_group_by_number(index);
717 i = 0;
718 nations_iterate(pnation) {
719 if (!is_nation_playable(pnation)
720 || !is_nation_pickable(pnation)) {
721 continue;
722 }
723 if (!nation_is_in_group(pnation, group) && index != -99) {
724 continue;
725 }
727 selected_nation_tabs->insertRow(i);
728 s = get_nation_flag_sprite(tileset, pnation);
729 if (pnation->player) {
730 f = item->font();
731 f.setStrikeOut(true);
732 item->setFont(f);
733 }
734 pix = s->pm;
735 if (svg) {
736 item->setData(Qt::DecorationRole, (*pix).scaledToHeight(50));
737 } else {
738 item->setData(Qt::DecorationRole, *pix);
739 }
740 item->setData(Qt::UserRole, nation_number(pnation));
741 item->setText(nation_adjective_translation(pnation));
742 selected_nation_tabs->setItem(i, 0, item);
744
745 selected_nation_tabs->sortByColumn(0, Qt::AscendingOrder);
746 header = selected_nation_tabs->horizontalHeader();
747 header->resizeSections(QHeaderView::Stretch);
748 header = selected_nation_tabs->verticalHeader();
749 header->resizeSections(QHeaderView::ResizeToContents);
750}
751
752/***********************************************************************/
757{
758 char buf[4096];
759 QModelIndex index ;
761 QModelIndexList indexes = selected.indexes();
762 QString str;
764 int style, ind;
765
766 if (indexes.isEmpty()) {
767 return;
768 }
769
770 index = indexes.at(0);
771 if (indexes.isEmpty()) {
772 return;
773 }
774 qvar = index.data(Qt::UserRole);
775 selected_nation = qvar.toInt();
776
778 description->setPlainText(buf);
779 leader_name->clear();
780 if (client.conn.playing == tplayer) {
781 leader_name->addItem(client.conn.playing->name, true);
782 }
785 str = QString::fromUtf8(nation_leader_name(pleader));
788
789 // Select style for nation
790
792 qvar = qvar.fromValue<int>(style);
793
794 for (ind = 0; ind < styles->rowCount(); ind++) {
795 item = styles->item(ind, 0);
796
797 if (item->data(Qt::UserRole) == qvar) {
798 styles->selectRow(ind);
799 }
800 }
801}
802
803/***********************************************************************/
808{
809 QModelIndex index ;
811 QModelIndexList indexes = selected.indexes();
812
813 if (indexes.isEmpty()) {
814 return;
815 }
816
817 index = indexes.at(0);
818 qvar = index.data(Qt::UserRole);
819 selected_style = qvar.toInt();
820}
821
822/***********************************************************************/
826{
827 if (leader_name->itemData(index).toBool()) {
828 is_male->setChecked(true);
829 is_female->setChecked(false);
830 } else {
831 is_male->setChecked(false);
832 is_female->setChecked(true);
833 }
834}
835
836/***********************************************************************/
841{
843 struct player *natplr;
844
845 if (selected_nation == -1) {
846 return;
847 }
848
849 if (selected_style == -1) {
850 output_window_append(ftc_client, _("You must select your style."));
851 return;
852 }
853
854 if (leader_name->currentText().length() == 0) {
855 output_window_append(ftc_client, _("You must type a legal name."));
856 return;
857 }
858
860 if (natplr != NULL && natplr != client_player()) {
862 _("Nation has been chosen by other player"));
863 return;
864 }
865
866 ln_bytes = leader_name->currentText().toUtf8();
868 selected_nation, sex_buttons->checkedId(),
869 ln_bytes.data(),
871 close();
872 deleteLater();
873}
874
875/***********************************************************************/
879 const char *lines, QWidget *parent)
880 : fcwidget()
881{
882 int x, y;
884
885 setAttribute(Qt::WA_DeleteOnClose);
886 setCursor(Qt::ArrowCursor);
888 setFrameStyle(QFrame::Box);
889 cw = new close_widget(this);
890 cw->put_to_corner();
891
895 qlist = qlines.split("\n");
896 small_font = *fc_font::instance()->get_font("gui_qt_font_notify_label");
897 x = 0;
898 y = 0;
899 calc_size(x, y);
900 resize(x, y);
901 gui()->mapview_wdg->find_place(gui()->mapview_wdg->width() - x - 4, 4,
902 x, y, x, y, 0);
903 move(x, y);
904 was_destroyed = false;
905
906}
907
908/***********************************************************************/
912{
913 QString s, q;
914 int i;
918
919 for (i = 0; i < qlist.size(); ++i) {
920 s = qlist.at(i);
921 q = q + s;
922 if (i < qlist.size() - 1) {
923 q = q + QChar('\n');
924 }
925 }
926 capt_bytes = qcaption.toUtf8();
927 hl_bytes = qheadline.toUtf8();
928 qb_bytes = q.toUtf8();
930 hl_bytes.data(),
931 qb_bytes.data());
932 close();
933 destroy();
934}
935
936/***********************************************************************/
940{
942 int i;
943 QStringList str_list;
944
945 str_list = qlist;
946 str_list << qcaption << qheadline;
947
948 for (i = 0; i < str_list.count(); i++) {
949 x = qMax(x, fm.horizontalAdvance(str_list.at(i)));
950 y = y + 3 + fm.height();
951 }
952 x = x + 15;
953}
954
955/***********************************************************************/
959{
960 QPainter painter(this);
961 QPainterPath path;
962 QPen pen;
964 int i;
965
966 pen.setWidth(1);
967 pen.setColor(palette().color(QPalette::Text));
968 painter.setFont(small_font);
969 painter.setPen(pen);
970 painter.drawText(10, fm.height() + 3, qcaption);
971 painter.drawText(10, 2 * fm.height() + 6, qheadline);
972 for (i = 0; i < qlist.count(); i++) {
973 painter.drawText(10, 3 + (fm.height() + 3) * (i + 3), qlist[i]);
974 }
975 cw->put_to_corner();
976}
977
978/***********************************************************************/
982{
983 cursor = mevent_gpos(event) - geometry().topLeft();
984
985 if (event->button() == Qt::RightButton) {
986 was_destroyed = true;
987 close();
988 }
989}
990
991/***********************************************************************/
995{
997
998 setCursor(Qt::SizeAllCursor);
999}
1000
1001/***********************************************************************/
1005{
1006 setCursor(Qt::ArrowCursor);
1007}
1008
1009/***********************************************************************/
1013{
1014 was_destroyed = true;
1015 destroy();
1016}
1017
1018/***********************************************************************/
1024{
1025 was_destroyed = true;
1026 destroy();
1027}
1028
1029/***********************************************************************/
1033{
1034 vs_city = -1;
1035 vs_unit = -1;
1036}
1037
1038/***********************************************************************/
1042{
1043 if (!m_instance) {
1044 m_instance = new qdef_act;
1045 }
1046 return m_instance;
1047}
1048
1049/***********************************************************************/
1053{
1054 if (m_instance) {
1055 delete m_instance;
1056 m_instance = 0;
1057 }
1058}
1059
1060/***********************************************************************/
1064{
1065 vs_city = i;
1066}
1067
1068/***********************************************************************/
1072{
1073 vs_unit = i;
1074}
1075
1076/***********************************************************************/
1080{
1081 return vs_city;
1082}
1083
1084/***********************************************************************/
1088{
1089 return vs_unit;
1090}
1091
1092/***********************************************************************/
1096{
1097 delete this;
1098}
1099
1100/***********************************************************************/
1104{
1106 false, "", 0);
1107 delete this;
1108}
1109
1110/***********************************************************************/
1113notify_goto::notify_goto(const char *headline, const char *lines,
1114 const struct text_tag_list *tags, tile *ptile,
1115 QWidget *parent): QMessageBox(parent)
1116{
1118 setAttribute(Qt::WA_DeleteOnClose);
1119 goto_but = this->addButton(_("Goto Location"), QMessageBox::ActionRole);
1120 goto_but->setIcon(fc_icons::instance()->get_icon("go-up"));
1121 inspect_but = this->addButton(_("Inspect City"), QMessageBox::ActionRole);
1122 inspect_but->setIcon(fc_icons::instance()->get_icon("plus"));
1123
1124 close_but = this->addButton(QMessageBox::Close);
1125 gtile = ptile;
1126 if (!gtile) {
1127 goto_but->setVisible(false);
1128 inspect_but->setVisible(false);
1129 } else {
1130 struct city *pcity = tile_city(gtile);
1131 inspect_but->setVisible(NULL != pcity
1132 && city_owner(pcity) == client.conn.playing);
1133 }
1135 qlines = lines;
1136 qlines.replace("\n", " ");
1137 setText(qlines);
1138 connect(goto_but, &QAbstractButton::pressed, this, &notify_goto::goto_tile);
1139 connect(inspect_but, &QAbstractButton::pressed, this, &notify_goto::inspect_city);
1140 connect(close_but, &QAbstractButton::pressed, this, &QWidget::close);
1141 show();
1142}
1143
1144/***********************************************************************/
1148{
1150 close();
1151}
1152
1153/***********************************************************************/
1157{
1158 struct city *pcity = tile_city(gtile);
1159 if (pcity) {
1161 }
1162 close();
1163}
1164
1165/***********************************************************************/
1169{
1170 QString rule_name;
1172 const char *rn;
1173 struct option *poption = optset_option_by_name(server_optset, "nationset");
1174
1175 rule_name = qnation_set->currentData().toString();
1176 rn_bytes = rule_name.toUtf8(); /* Hold QByteArray in a variable to
1177 * extend its, and data() buffer's,
1178 * lifetime */
1179 rn = rn_bytes.data();
1183 }
1184}
1185
1186/***********************************************************************/
1191void popup_notify_goto_dialog(const char *headline, const char *lines,
1192 const struct text_tag_list *tags,
1193 struct tile *ptile)
1194{
1195 notify_goto *ask = new notify_goto(headline, lines, tags, ptile,
1196 gui()->central_wdg);
1197 ask->show();
1198}
1199
1200/***********************************************************************/
1203void popup_connect_msg(const char *headline, const char *message)
1204{
1205 QMessageBox *msg = new QMessageBox(gui()->central_wdg);
1206
1207 msg->setText(message);
1208 msg->setStandardButtons(QMessageBox::Ok);
1209 msg->setWindowTitle(headline);
1210 msg->setAttribute(Qt::WA_DeleteOnClose);
1211 msg->show();
1212}
1213
1214/***********************************************************************/
1217void popup_notify_dialog(const char *caption, const char *headline,
1218 const char *lines)
1219{
1221 gui()->mapview_wdg);
1222 nd->show();
1223}
1224
1225/***********************************************************************/
1228void popup_races_dialog(struct player *pplayer)
1229{
1230 if (!is_race_dialog_open) {
1231 race_dialog = new races_dialog(pplayer, gui()->central_wdg);
1232 is_race_dialog_open = true;
1233 race_dialog->show();
1234 }
1235 race_dialog->showNormal();
1236}
1237
1238/***********************************************************************/
1243{
1244 if (is_race_dialog_open) {
1245 race_dialog->close();
1246 is_race_dialog_open = false;
1247 }
1248}
1249
1250/***********************************************************************/
1254{
1255 if (ptile != NULL
1256 && (unit_list_size(ptile->units) > 1
1257 || (unit_list_size(ptile->units) == 1 && tile_city(ptile)))) {
1258 gui()->toggle_unit_sel_widget(ptile);
1259 }
1260}
1261
1262/***********************************************************************/
1266{
1267 gui()->update_unit_sel();
1268}
1269
1270/***********************************************************************/
1279
1280/***********************************************************************/
1283void races_update_pickable(bool nationset_change)
1284{
1285 if (is_race_dialog_open) {
1287 }
1288}
1289
1290/***********************************************************************/
1295{
1296 if (is_race_dialog_open) {
1298 }
1299}
1300
1301/***********************************************************************/
1305{
1308 = (gov != nullptr ? government_number(gov) : G_LAST);
1309
1311 ask = new hud_message_box(gui()->central_wdg);
1312 ask->setStandardButtons(QMessageBox::Cancel | QMessageBox::Ok);
1313 ask->setDefaultButton(QMessageBox::Cancel);
1314 ask->set_text_title(_("You say you wanna revolution?"),
1315 _("Revolution!"));
1316 ask->setAttribute(Qt::WA_DeleteOnClose);
1317 QObject::connect(ask, &hud_message_box::accepted, [=]() {
1318 if (government_id == G_LAST) {
1319 revolution_response(nullptr);
1320 } else {
1322
1323 if (government) {
1325 }
1326 }
1327 });
1328 ask->show();
1329 } else {
1331 }
1332}
1333
1334/***********************************************************************/
1347
1348/***********************************************************************/
1355
1356/***********************************************************************/
1364
1365/***********************************************************************/
1373
1374/***********************************************************************/
1381
1382/***********************************************************************/
1389
1390/***********************************************************************/
1394 QWidget *parent,
1395 void (*run_on_close_in)(int)): QWidget(parent)
1396{
1397 QLabel *l = new QLabel(text);
1398
1399 setProperty("themed_choice", true);
1400 layout = new QVBoxLayout(this);
1402
1403 layout->addWidget(l);
1404 setWindowFlags(Qt::Dialog);
1406 setAttribute(Qt::WA_DeleteOnClose);
1407 gui()->set_diplo_dialog(this);
1408
1420
1421 targeted_unit = nullptr;
1422 // No buttons are added yet.
1423 for (int i = 0; i < BUTTON_COUNT; i++) {
1425 }
1426}
1427
1428/***********************************************************************/
1432{
1433 buttons_list.clear();
1434 action_button_map.clear();
1435 gui()->set_diplo_dialog(NULL);
1436
1437 if (run_on_close) {
1440 }
1441}
1442
1443/***********************************************************************/
1447{
1449
1452 struct canvas *pix;
1453 QPushButton *next, *prev;
1454 unit_skip = new QHBoxLayout;
1455 next = new QPushButton();
1456 next->setIcon(fc_icons::instance()->get_icon("city-right"));
1457 next->setIconSize(QSize(32, 32));
1458 next->setFixedSize(QSize(36, 36));
1459 prev = new QPushButton();
1460 prev->setIcon(fc_icons::instance()->get_icon("city-left"));
1461 prev->setIconSize(QSize(32, 32));
1462 prev->setFixedSize(QSize(36, 36));
1463 target_unit_button = new QPushButton;
1466 pix->map_pixmap.fill(Qt::transparent);
1467 put_unit(targeted_unit, pix, 1.0, 0, 0);
1468 target_unit_button->setIcon(QIcon(pix->map_pixmap));
1469 qtg_canvas_free(pix);
1470 target_unit_button->setIconSize(QSize(96, 96));
1471 target_unit_button->setFixedSize(QSize(100, 100));
1472 unit_skip->addStretch(100);
1473 unit_skip->addWidget(prev, Qt::AlignCenter);
1474 unit_skip->addWidget(target_unit_button, Qt::AlignCenter);
1475 unit_skip->addWidget(next, Qt::AlignCenter);
1476 layout->addLayout(unit_skip);
1477 unit_skip->addStretch(100);
1478 connect(prev, &QAbstractButton::clicked, this, &choice_dialog::prev_unit);
1479 connect(next, &QAbstractButton::clicked, this, &choice_dialog::next_unit);
1480 }
1481
1483}
1484
1485/***********************************************************************/
1489 QVariant data2, QString tool_tip = "",
1490 const int button_id = -1)
1491{
1493 data1, data2);
1494 int action = buttons_list.count();
1495
1496 QObject::connect(button, &QPushButton::clicked,
1499 });
1500
1501 buttons_list.append(button);
1502
1503 if (!tool_tip.isEmpty()) {
1504 button->setToolTip(tool_tip);
1505 }
1506
1507 if (0 <= button_id) {
1508 // The id is valid.
1509 action_button_map[button_id] = button;
1510 }
1511
1512 layout->addWidget(button);
1513}
1514
1515/***********************************************************************/
1519{
1520 QPoint p;
1521
1522 p = mapFromGlobal(QCursor::pos());
1523 p.setY(p.y()-this->height());
1524 p.setX(p.x()-this->width());
1525 move(p);
1526 show();
1527}
1528
1529/***********************************************************************/
1536
1537/***********************************************************************/
1541{
1542 if (id < 0) {
1543 fc_assert_msg(0 <= id, "Invalid button ID.");
1544 return NULL;
1545 }
1546
1547 return action_button_map[id];
1548}
1549
1550/***********************************************************************/
1554{
1557
1559 if (action == -1) {
1560 return false;
1561 }
1562 func = af_map[action];
1563
1564 func(q1, q2);
1565 return true;
1566}
1567
1568/***********************************************************************/
1572{
1575
1577 if (action == -1) {
1578 return false;
1579 }
1580 func = af_map[action];
1581 func(q1, q2);
1582 return true;
1583}
1584
1585/***********************************************************************/
1589{
1590 struct tile *ptile;
1591 struct unit *new_target = nullptr;
1592 bool break_next = false;
1593 bool first = true;
1594 struct canvas *pix;
1595
1596 if (targeted_unit == nullptr) {
1597 return;
1598 }
1599
1600 ptile = targeted_unit->tile;
1601
1602 unit_list_iterate(ptile->units, ptgt) {
1603 if (first) {
1604 new_target = ptgt;
1605 first = false;
1606 }
1607 if (break_next) {
1608 new_target = ptgt;
1609 break;
1610 }
1611 if (ptgt == targeted_unit) {
1612 break_next = true;
1613 }
1618 pix->map_pixmap.fill(Qt::transparent);
1619 put_unit(targeted_unit, pix, 1.0, 0, 0);
1620 target_unit_button->setIcon(QIcon(pix->map_pixmap));
1621 qtg_canvas_free(pix);
1622 switch_target();
1623}
1624
1625/***********************************************************************/
1629{
1630 struct tile *ptile;
1631 struct unit *new_target = nullptr;
1632 struct canvas *pix;
1633 if (targeted_unit == nullptr) {
1634 return;
1635 }
1636
1637 ptile = targeted_unit->tile;
1638 unit_list_iterate(ptile->units, ptgt) {
1639 if ((ptgt == targeted_unit) && new_target != nullptr) {
1640 break;
1641 }
1642 new_target = ptgt;
1647 pix->map_pixmap.fill(Qt::transparent);
1648 put_unit(targeted_unit, pix, 1.0, 0, 0);
1649 target_unit_button->setIcon(QIcon(pix->map_pixmap));
1650 qtg_canvas_free(pix);
1651 switch_target();
1652}
1653
1654/***********************************************************************/
1658{
1659 if (targeted_unit == nullptr) {
1660 return;
1661 }
1662 unit_skip->setParent(nullptr);
1667 : NULL),
1668 act_probs);
1669 layout->addLayout(unit_skip);
1670}
1671
1672/***********************************************************************/
1676{
1677 if (targeted_unit == nullptr) {
1678 return;
1679 }
1680
1681 unit_skip->setParent(nullptr);
1683 unit_id,
1688 layout->addLayout(unit_skip);
1689}
1690
1691/***********************************************************************/
1695{
1697 pfcn_void func = button->getFunc();
1698
1699 func(button->getData1(), button->getData2());
1700 close();
1701}
1702
1703/***********************************************************************/
1712{
1713 // Store the data in the stack.
1714 last_buttons_stack.append(button);
1715
1716 /* Temporary remove the button so it will end up below buttons added
1717 * before unstack_all_buttons() is called. */
1718 layout->removeWidget(button);
1719
1720 // Synchronize the list with the layout.
1721 buttons_list.removeAll(button);
1722}
1723
1724/***********************************************************************/
1729{
1730 while (!last_buttons_stack.isEmpty()) {
1731 Choice_dialog_button *button = last_buttons_stack.takeLast();
1732
1733 // Reinsert the button below the other buttons.
1734 buttons_list.append(button);
1735 layout->addWidget(button);
1736 }
1737}
1738
1739/***********************************************************************/
1742static void caravan_marketplace(QVariant data1, QVariant data2)
1743{
1744 int actor_unit_id = data1.toInt();
1745 int target_city_id = data2.toInt();
1746
1748 && NULL != game_city_by_number(target_city_id)) {
1750 target_city_id, 0, "");
1751 }
1752}
1753
1754/***********************************************************************/
1758{
1759 int actor_unit_id = data1.toInt();
1760 int target_city_id = data2.toInt();
1761
1763 && NULL != game_city_by_number(target_city_id)) {
1765 target_city_id, 0, "");
1766 }
1767}
1768
1769/***********************************************************************/
1772static void caravan_help_build(QVariant data1, QVariant data2)
1773{
1774 int caravan_id = data1.toInt();
1775 int caravan_target_id = data2.toInt();
1776
1781 }
1782}
1783
1784/***********************************************************************/
1787static void unit_disband_recover(QVariant data1, QVariant data2)
1788{
1789 int actor_id = data1.toInt();
1790 int tgt_city_id = data2.toInt();
1791
1792 if (NULL != game_unit_by_number(actor_id)
1795 actor_id, tgt_city_id, 0, "");
1796 }
1797}
1798
1799/***********************************************************************/
1802static void unit_home_city(QVariant data1, QVariant data2)
1803{
1804 int actor_id = data1.toInt();
1805 int tgt_city_id = data2.toInt();
1806
1807 if (NULL != game_unit_by_number(actor_id)
1810 actor_id, tgt_city_id, 0, "");
1811 }
1812}
1813
1814/***********************************************************************/
1817static void unit_upgrade(QVariant data1, QVariant data2)
1818{
1819 struct unit *punit;
1820
1821 int actor_id = data1.toInt();
1822 int tgt_city_id = data2.toInt();
1823
1824 if ((punit = game_unit_by_number(actor_id))
1826 struct unit_list *as_list;
1827
1832 }
1833}
1834
1835/***********************************************************************/
1838static void airlift(QVariant data1, QVariant data2)
1839{
1840 int actor_id = data1.toInt();
1841 int tgt_city_id = data2.toInt();
1842
1843 if (NULL != game_unit_by_number(actor_id)
1846 actor_id, tgt_city_id, 0, "");
1847 }
1848}
1849
1850/***********************************************************************/
1853static void conquer_city(QVariant data1, QVariant data2)
1854{
1855 int actor_id = data1.toInt();
1856 int tgt_city_id = data2.toInt();
1857
1858 if (NULL != game_unit_by_number(actor_id)
1861 actor_id, tgt_city_id, 0, "");
1862 }
1863}
1864
1865/***********************************************************************/
1868static void conquer_city2(QVariant data1, QVariant data2)
1869{
1870 int actor_id = data1.toInt();
1871 int tgt_city_id = data2.toInt();
1872
1873 if (NULL != game_unit_by_number(actor_id)
1876 actor_id, tgt_city_id, 0, "");
1877 }
1878}
1879
1880/***********************************************************************/
1883static void conquer_extras(QVariant data1, QVariant data2)
1884{
1885 int actor_id = data1.toInt();
1886 int target_id = data2.toInt();
1887
1888 if (NULL != game_unit_by_number(actor_id)) {
1890 actor_id, target_id, 0, "");
1891 }
1892}
1893
1894/***********************************************************************/
1897static void conquer_extras2(QVariant data1, QVariant data2)
1898{
1899 int actor_id = data1.toInt();
1900 int target_id = data2.toInt();
1901
1902 if (NULL != game_unit_by_number(actor_id)) {
1904 actor_id, target_id, 0, "");
1905 }
1906}
1907
1908/***********************************************************************/
1911static void act_sel_wait(QVariant data1, QVariant data2)
1912{
1913 key_unit_wait();
1914}
1915
1916/***********************************************************************/
1919static void keep_moving(QVariant data1, QVariant data2)
1920{
1921}
1922
1923/***********************************************************************/
1927{
1928 if (!gov) {
1930 } else {
1932 }
1933}
1934
1935/***********************************************************************/
1940{
1942 /* The client isn't waiting for information for any unanswered follow
1943 * up questions. */
1944
1945 struct unit *actor_unit;
1946
1948 /* The action selection dialog wasn't closed because the actor unit
1949 * was lost. */
1950
1951 // The probabilities didn't just disappear, right?
1954
1956 }
1957
1958 // The action selection process is over, at least for now.
1960
1961 if (did_not_decide) {
1962 /* The action selection dialog was closed but the player didn't
1963 * decide what the unit should do. */
1964
1965 // Reset so the next action selection dialog does the right thing.
1966 did_not_decide = false;
1967 } else {
1968 // An action, or no action at all, was selected.
1971 }
1972 }
1973}
1974
1975/***********************************************************************/
1979static void diplomat_queue_handle_secondary(int actor_id)
1980{
1981 // Stop waiting. Move on to the next queued unit.
1984}
1985
1986/**********************************************************************/
1993{
1994 // Stop assuming the answer to a follow up question will arrive.
1996}
1997
1998/***********************************************************************/
2003 struct city *target_city,
2004 struct unit *target_unit,
2005 struct tile *target_tile,
2006 struct extra_type *target_extra,
2007 const struct act_prob *act_probs)
2008{
2009 struct astring title = ASTRING_INIT, text = ASTRING_INIT;
2011 qtiles caras;
2012 QVariant qv1, qv2;
2014 struct city *actor_homecity;
2017
2020
2021 foreach (caras, gui()->trade_gen.lines) {
2022 if (caras.autocaravan == actor_unit) {
2023 int i;
2024 if (nullptr != game_unit_by_number(actor_unit->id)
2025 && nullptr != game_city_by_number(target_city->id)) {
2027 target_city->id, 0, "");
2030 i = gui()->trade_gen.lines.indexOf(caras);
2031 gui()->trade_gen.lines.takeAt(i);
2032 return;
2033 }
2034 }
2035 }
2036 if (target_city
2040 return;
2041 }
2042
2043 if (target_unit
2047 return;
2048 }
2049 /* Could be caused by the server failing to reply to a request for more
2050 * information or a bug in the client code. */
2052 "Diplomat queue problem. Is another diplomat window open?");
2053
2054 // No extra input is required as no action has been chosen yet.
2056
2058
2059 astr_set(&title,
2060 // TRANS: %s is a unit name, e.g., Spy
2061 _("Choose Your %s's Strategy"),
2063
2064 if (target_city && actor_homecity) {
2065 astr_set(&text,
2066 _("Your %s from %s reaches the city of %s.\nWhat now?"),
2070 } else if (target_city) {
2071 astr_set(&text,
2072 _("Your %s has arrived at %s.\nWhat is your command?"),
2075 } else if (target_unit) {
2076 astr_set(&text,
2077 // TRANS: Your Spy is ready to act against Roman Freight.
2078 _("Your %s is ready to act against %s %s."),
2082 } else {
2084 "No target specified.");
2085
2086 astr_set(&text,
2087 // TRANS: %s is a unit name, e.g., Diplomat, Spy
2088 _("Your %s is waiting for your command."),
2090 }
2091
2092 cd = gui()->get_diplo_dialog();
2093 if ((cd != nullptr) && cd->targeted_unit != nullptr) {
2094 cd->update_dialog(act_probs);
2095 return;
2096 }
2097 cd = new choice_dialog(astr_str(&title), astr_str(&text),
2098 gui()->game_tab_widget,
2100 qv1 = actor_unit->id;
2101
2102 cd->unit_id = actor_unit->id;
2103
2104 cd->target_id[ATK_SELF] = cd->unit_id;
2105
2106 if (target_city) {
2107 cd->target_id[ATK_CITY] = target_city->id;
2108 } else {
2109 cd->target_id[ATK_CITY] = IDENTITY_NUMBER_ZERO;
2110 }
2111
2112 if (target_unit) {
2113 cd->target_id[ATK_UNIT] = target_unit->id;
2114 } else {
2115 cd->target_id[ATK_UNIT] = IDENTITY_NUMBER_ZERO;
2116 }
2117
2118 if (target_tile) {
2119 cd->target_id[ATK_UNITS] = tile_index(target_tile);
2120 } else {
2121 cd->target_id[ATK_UNITS] = TILE_INDEX_NONE;
2122 }
2123
2124 if (target_tile) {
2125 cd->target_id[ATK_TILE] = tile_index(target_tile);
2126 } else {
2127 cd->target_id[ATK_TILE] = TILE_INDEX_NONE;
2128 }
2129
2130 if (target_tile) {
2131 cd->target_id[ATK_EXTRAS] = tile_index(target_tile);
2132 } else {
2133 cd->target_id[ATK_EXTRAS] = TILE_INDEX_NONE;
2134 }
2135
2136 // No target building or target tech supplied. (Feb 2020)
2137 cd->sub_target_id[ASTK_BUILDING] = B_LAST;
2138 cd->sub_target_id[ASTK_TECH] = A_UNSET;
2139
2140 if (target_extra) {
2141 cd->sub_target_id[ASTK_EXTRA] = extra_number(target_extra);
2143 } else {
2144 cd->sub_target_id[ASTK_EXTRA] = EXTRA_NONE;
2145 cd->sub_target_id[ASTK_EXTRA_NOT_THERE] = EXTRA_NONE;
2146 }
2147
2148 // Unit acting against a city
2149
2150 // Set the correct target for the following actions.
2151 qv2 = cd->target_id[ATK_CITY];
2152
2153 action_iterate(act) {
2158 act_probs[act],
2159 actor_unit,
2160 target_city),
2161 qv1, qv2);
2162 }
2164
2165 // Unit acting against another unit
2166
2167 // Set the correct target for the following actions.
2168 qv2 = cd->target_id[ATK_UNIT];
2169
2170 action_iterate(act) {
2175 act_probs[act],
2176 actor_unit,
2177 target_city),
2178 qv1, qv2);
2179 }
2181
2182 // Unit acting against all units at a tile
2183
2184 // Set the correct target for the following actions.
2185 qv2 = cd->target_id[ATK_UNITS];
2186
2187 action_iterate(act) {
2192 act_probs[act],
2193 actor_unit,
2194 target_city),
2195 qv1, qv2);
2196 }
2198
2199 // Unit acting against a tile.
2200
2201 // Set the correct target for the following actions.
2202 qv2 = cd->target_id[ATK_TILE];
2203
2204 action_iterate(act) {
2209 act_probs[act],
2210 actor_unit,
2211 target_city),
2212 qv1, qv2);
2213 }
2215
2216 // Unit acting against a tile's extras.
2217
2218 // Set the correct target for the following actions.
2219 qv2 = cd->target_id[ATK_EXTRAS];
2220
2221 action_iterate(act) {
2226 act_probs[act],
2227 actor_unit,
2228 target_city),
2229 qv1, qv2);
2230 }
2232
2233 // Unit acting against itself
2234
2235 // Set the correct target for the following actions.
2236 qv2 = cd->target_id[ATK_SELF];
2237
2238 action_iterate(act) {
2243 act_probs[act],
2244 actor_unit,
2245 target_city),
2246 qv1, qv2);
2247 }
2249
2251 cd->add_item(QString(_("&Wait")), func, qv1, qv2,
2252 "", BUTTON_WAIT);
2253
2254 func = keep_moving;
2255 cd->add_item(QString(_("Do nothing")), func, qv1, qv2,
2256 "", BUTTON_CANCEL);
2257
2258 cd->set_layout();
2259 cd->show_me();
2260
2261 // Give follow up questions access to action probabilities.
2263 action_iterate(act) {
2266
2267 astr_free(&title);
2268 astr_free(&text);
2269}
2270
2271/***********************************************************************/
2276{
2277 /* Don't add an action mapping here unless the non targeted version is
2278 * selectable in the targeted version's target selection dialog. */
2279 switch ((enum gen_action)tgt_action_id) {
2285 return ACTION_SPY_STEAL_TECH;
2288 default:
2289 // No non targeted version found.
2290 return ACTION_NONE;
2291 }
2292}
2293
2294/**********************************************************************/
2299{
2300 /* Don't add an action mapping here unless the non targeted version is
2301 * selectable in the targeted version's target selection dialog. */
2302 switch ((enum gen_action)tgt_action_id) {
2309 default:
2310 // No non targeted version found.
2311 return ACTION_NONE;
2312 }
2313}
2314
2315/***********************************************************************/
2319 action_id act,
2320 const struct act_prob *act_probs,
2321 const char *custom,
2322 QVariant data1, QVariant data2)
2323{
2324 QString title;
2326
2327 if (!af_map.contains(act)) {
2328 /* The Qt client doesn't support ordering this action from the
2329 * action selection dialog. */
2330 return;
2331 }
2332
2333 // Don't show disabled actions.
2334 if (!action_prob_possible(act_probs[act])) {
2335 return;
2336 }
2337
2339 act_probs[act],
2340 custom));
2341
2343 act_probs[act]));
2344
2345 cd->add_item(title, af_map[act], data1, data2, tool_tip, act);
2346}
2347
2348/***********************************************************************/
2352 action_id act,
2353 const struct act_prob *act_probs,
2354 const char *custom,
2355 QVariant data1, QVariant data2)
2356{
2357 QString title;
2359
2360 /* An action that just became impossible has its button disabled.
2361 * An action that became possible again must be re-enabled. */
2362 button->setEnabled(action_prob_possible(act_probs[act]));
2363 button->setData1(data1);
2364 button->setData2(data2);
2365 // The probability may have changed.
2367 act_probs[act],
2368 custom));
2369
2371 act_probs[act]));
2372
2373 button->setText(title);
2374 button->setToolTip(tool_tip);
2375}
2376
2377/***********************************************************************/
2380static void disband_unit(QVariant data1, QVariant data2)
2381{
2382 int actor_id = data1.toInt();
2383 int target_id = data2.toInt();
2384
2386 target_id, 0, "");
2387}
2388
2389/***********************************************************************/
2392static void fortify(QVariant data1, QVariant data2)
2393{
2394 int actor_id = data1.toInt();
2395 int target_id = data2.toInt();
2396
2397 if (NULL != game_unit_by_number(actor_id)) {
2399 target_id, 0, "");
2400 }
2401}
2402
2403/***********************************************************************/
2406static void convert_unit(QVariant data1, QVariant data2)
2407{
2408 int actor_id = data1.toInt();
2409 int target_id = data2.toInt();
2410
2412 target_id, 0, "");
2413}
2414
2415/***********************************************************************/
2418static void homeless(QVariant data1, QVariant data2)
2419{
2420 int actor_id = data1.toInt();
2421 int target_id = data2.toInt();
2422
2423 if (NULL != game_unit_by_number(actor_id)) {
2425 target_id, 0, "");
2426 }
2427}
2428
2429/***********************************************************************/
2432static void diplomat_bribe(QVariant data1, QVariant data2)
2433{
2434 int diplomat_id = data1.toInt();
2435 int diplomat_target_id = data2.toInt();
2436
2439 // Wait for the server's reply before moving on to the next queued diplomat.
2441
2444 }
2445}
2446
2447/***********************************************************************/
2450static void spy_sabotage_unit(QVariant data1, QVariant data2)
2451{
2452 int diplomat_id = data1.toInt();
2453 int diplomat_target_id = data2.toInt();
2454
2456 diplomat_target_id, 0, "");
2457}
2458
2459/***********************************************************************/
2462static void spy_sabotage_unit_esc(QVariant data1, QVariant data2)
2463{
2464 int diplomat_id = data1.toInt();
2465 int diplomat_target_id = data2.toInt();
2466
2468 diplomat_target_id, 0, "");
2469}
2470
2471/***********************************************************************/
2474static void heal_unit(QVariant data1, QVariant data2)
2475{
2476 int actor_id = data1.toInt();
2477 int target_id = data2.toInt();
2478
2479 request_do_action(ACTION_HEAL_UNIT, actor_id, target_id, 0, "");
2480}
2481
2482/***********************************************************************/
2485static void heal_unit2(QVariant data1, QVariant data2)
2486{
2487 int actor_id = data1.toInt();
2488 int target_id = data2.toInt();
2489
2490 request_do_action(ACTION_HEAL_UNIT2, actor_id, target_id, 0, "");
2491}
2492
2493/***********************************************************************/
2496static void transport_board(QVariant data1, QVariant data2)
2497{
2498 int actor_id = data1.toInt();
2499 int target_id = data2.toInt();
2500
2501 request_do_action(ACTION_TRANSPORT_BOARD, actor_id, target_id, 0, "");
2502}
2503
2504/***********************************************************************/
2507static void transport_board2(QVariant data1, QVariant data2)
2508{
2509 int actor_id = data1.toInt();
2510 int target_id = data2.toInt();
2511
2512 request_do_action(ACTION_TRANSPORT_BOARD2, actor_id, target_id, 0, "");
2513}
2514
2515/***********************************************************************/
2518static void transport_board3(QVariant data1, QVariant data2)
2519{
2520 int actor_id = data1.toInt();
2521 int target_id = data2.toInt();
2522
2523 request_do_action(ACTION_TRANSPORT_BOARD3, actor_id, target_id, 0, "");
2524}
2525
2526/***********************************************************************/
2529static void transport_embark(QVariant data1, QVariant data2)
2530{
2531 int actor_id = data1.toInt();
2532 int target_id = data2.toInt();
2533
2534 request_do_action(ACTION_TRANSPORT_EMBARK, actor_id, target_id, 0, "");
2535}
2536
2537/***********************************************************************/
2540static void transport_embark2(QVariant data1, QVariant data2)
2541{
2542 int actor_id = data1.toInt();
2543 int target_id = data2.toInt();
2544
2545 request_do_action(ACTION_TRANSPORT_EMBARK2, actor_id, target_id, 0, "");
2546}
2547
2548/***********************************************************************/
2551static void transport_embark3(QVariant data1, QVariant data2)
2552{
2553 int actor_id = data1.toInt();
2554 int target_id = data2.toInt();
2555
2556 request_do_action(ACTION_TRANSPORT_EMBARK3, actor_id, target_id, 0, "");
2557}
2558
2559/***********************************************************************/
2562static void transport_embark4(QVariant data1, QVariant data2)
2563{
2564 int actor_id = data1.toInt();
2565 int target_id = data2.toInt();
2566
2567 request_do_action(ACTION_TRANSPORT_EMBARK4, actor_id, target_id, 0, "");
2568}
2569
2570/***********************************************************************/
2573static void transport_unload(QVariant data1, QVariant data2)
2574{
2575 int actor_id = data1.toInt();
2576 int target_id = data2.toInt();
2577
2578 request_do_action(ACTION_TRANSPORT_UNLOAD, actor_id, target_id, 0, "");
2579}
2580
2581/***********************************************************************/
2584static void transport_load(QVariant data1, QVariant data2)
2585{
2586 int actor_id = data1.toInt();
2587 int target_id = data2.toInt();
2588
2589 request_do_action(ACTION_TRANSPORT_LOAD, actor_id, target_id, 0, "");
2590}
2591
2592/***********************************************************************/
2595static void transport_load2(QVariant data1, QVariant data2)
2596{
2597 int actor_id = data1.toInt();
2598 int target_id = data2.toInt();
2599
2600 request_do_action(ACTION_TRANSPORT_LOAD2, actor_id, target_id, 0, "");
2601}
2602
2603/***********************************************************************/
2606static void transport_load3(QVariant data1, QVariant data2)
2607{
2608 int actor_id = data1.toInt();
2609 int target_id = data2.toInt();
2610
2611 request_do_action(ACTION_TRANSPORT_LOAD3, actor_id, target_id, 0, "");
2612}
2613
2614/***********************************************************************/
2617static void transport_deboard(QVariant data1, QVariant data2)
2618{
2619 int actor_id = data1.toInt();
2620 int target_id = data2.toInt();
2621
2622 request_do_action(ACTION_TRANSPORT_DEBOARD, actor_id, target_id, 0, "");
2623}
2624
2625/***********************************************************************/
2628static void disembark1(QVariant data1, QVariant data2)
2629{
2630 int actor_id = data1.toInt();
2631 int target_id = data2.toInt();
2632
2633 if (NULL != game_unit_by_number(actor_id)
2634 && NULL != index_to_tile(&(wld.map), target_id)) {
2636 actor_id, target_id, 0, "");
2637 }
2638}
2639
2640/***********************************************************************/
2643static void disembark2(QVariant data1, QVariant data2)
2644{
2645 int actor_id = data1.toInt();
2646 int target_id = data2.toInt();
2647
2648 if (NULL != game_unit_by_number(actor_id)
2649 && NULL != index_to_tile(&(wld.map), target_id)) {
2651 actor_id, target_id, 0, "");
2652 }
2653}
2654
2655/***********************************************************************/
2658static void enter_hut(QVariant data1, QVariant data2)
2659{
2660 int actor_id = data1.toInt();
2661 int target_id = data2.toInt();
2662
2663 if (NULL != game_unit_by_number(actor_id)
2664 && NULL != index_to_tile(&(wld.map), target_id)) {
2666 actor_id, target_id, 0, "");
2667 }
2668}
2669
2670/***********************************************************************/
2673static void enter_hut2(QVariant data1, QVariant data2)
2674{
2675 int actor_id = data1.toInt();
2676 int target_id = data2.toInt();
2677
2678 if (NULL != game_unit_by_number(actor_id)
2679 && NULL != index_to_tile(&(wld.map), target_id)) {
2681 actor_id, target_id, 0, "");
2682 }
2683}
2684
2685/***********************************************************************/
2688static void frighten_hut(QVariant data1, QVariant data2)
2689{
2690 int actor_id = data1.toInt();
2691 int target_id = data2.toInt();
2692
2693 if (NULL != game_unit_by_number(actor_id)
2694 && NULL != index_to_tile(&(wld.map), target_id)) {
2696 actor_id, target_id, 0, "");
2697 }
2698}
2699
2700/***********************************************************************/
2703static void frighten_hut2(QVariant data1, QVariant data2)
2704{
2705 int actor_id = data1.toInt();
2706 int target_id = data2.toInt();
2707
2708 if (NULL != game_unit_by_number(actor_id)
2709 && NULL != index_to_tile(&(wld.map), target_id)) {
2711 actor_id, target_id, 0, "");
2712 }
2713}
2714
2715/**********************************************************************/
2718static void nuke_units(QVariant data1, QVariant data2)
2719{
2720 int actor_id = data1.toInt();
2721 int target_id = data2.toInt();
2722
2724 target_id, 0, "");
2725}
2726
2727/**********************************************************************/
2730static void wipe_units(QVariant data1, QVariant data2)
2731{
2732 int actor_id = data1.toInt();
2733 int target_id = data2.toInt();
2734
2736 target_id, 0, "");
2737}
2738
2739/**********************************************************************/
2742static void capture_units(QVariant data1, QVariant data2)
2743{
2744 int actor_id = data1.toInt();
2745 int target_id = data2.toInt();
2746
2748 target_id, 0, "");
2749}
2750
2751/***********************************************************************/
2754static void expel_unit(QVariant data1, QVariant data2)
2755{
2756 int actor_id = data1.toInt();
2757 int target_id = data2.toInt();
2758
2760 target_id, 0, "");
2761}
2762
2763/***********************************************************************/
2766static void bombard(QVariant data1, QVariant data2)
2767{
2768 int actor_id = data1.toInt();
2769 int target_id = data2.toInt();
2770
2772 target_id, 0, "");
2773}
2774
2775/***********************************************************************/
2778static void bombard2(QVariant data1, QVariant data2)
2779{
2780 int actor_id = data1.toInt();
2781 int target_id = data2.toInt();
2782
2784 target_id, 0, "");
2785}
2786
2787/***********************************************************************/
2790static void bombard3(QVariant data1, QVariant data2)
2791{
2792 int actor_id = data1.toInt();
2793 int target_id = data2.toInt();
2794
2796 target_id, 0, "");
2797}
2798
2799/***********************************************************************/
2802static void bombard_lethal(QVariant data1, QVariant data2)
2803{
2804 int actor_id = data1.toInt();
2805 int target_id = data2.toInt();
2806
2808 target_id, 0, "");
2809}
2810
2811/***********************************************************************/
2814static void found_city(QVariant data1, QVariant data2)
2815{
2816 int actor_id = data1.toInt();
2817
2819 actor_id);
2820}
2821
2822/***********************************************************************/
2825static void transform_terrain(QVariant data1, QVariant data2)
2826{
2827 int actor_id = data1.toInt();
2828 int target_id = data2.toInt();
2829
2830 if (NULL != game_unit_by_number(actor_id)
2831 && NULL != index_to_tile(&(wld.map), target_id)) {
2833 actor_id, target_id, 0, "");
2834 }
2835}
2836
2837/***********************************************************************/
2840static void cultivate(QVariant data1, QVariant data2)
2841{
2842 int actor_id = data1.toInt();
2843 int target_id = data2.toInt();
2844
2845 if (NULL != game_unit_by_number(actor_id)
2846 && NULL != index_to_tile(&(wld.map), target_id)) {
2848 actor_id, target_id, 0, "");
2849 }
2850}
2851
2852/***********************************************************************/
2855static void plant(QVariant data1, QVariant data2)
2856{
2857 int actor_id = data1.toInt();
2858 int target_id = data2.toInt();
2859
2860 if (NULL != game_unit_by_number(actor_id)
2861 && NULL != index_to_tile(&(wld.map), target_id)) {
2863 actor_id, target_id, 0, "");
2864 }
2865}
2866
2867/***********************************************************************/
2870static void pillage(QVariant data1, QVariant data2)
2871{
2872 int actor_id = data1.toInt();
2873 int target_id = data2.toInt();
2874
2875 if (NULL != game_unit_by_number(actor_id)
2876 && NULL != index_to_tile(&(wld.map), target_id)) {
2878 actor_id, target_id,
2879 /* FIXME: will cause problems if more than
2880 * one action selection dialog at a time
2881 * becomes supported. */
2883 "");
2884 }
2885}
2886
2887/***********************************************************************/
2890static void clean(QVariant data1, QVariant data2)
2891{
2892 int actor_id = data1.toInt();
2893 int target_id = data2.toInt();
2894
2895 if (NULL != game_unit_by_number(actor_id)
2896 && NULL != index_to_tile(&(wld.map), target_id)) {
2898 actor_id, target_id,
2899 /* FIXME: will cause problems if more than
2900 * one action selection dialog at a time
2901 * becomes supported. */
2903 "");
2904 }
2905}
2906
2907/***********************************************************************/
2910static void road(QVariant data1, QVariant data2)
2911{
2912 int actor_id = data1.toInt();
2913 int target_id = data2.toInt();
2914
2915 if (NULL != game_unit_by_number(actor_id)
2916 && NULL != index_to_tile(&(wld.map), target_id)
2919 actor_id, target_id,
2920 /* FIXME: will cause problems if more than
2921 * one action selection dialog at a time
2922 * becomes supported. */
2924 "");
2925 }
2926}
2927
2928/***********************************************************************/
2931static void base(QVariant data1, QVariant data2)
2932{
2933 int actor_id = data1.toInt();
2934 int target_id = data2.toInt();
2935
2936 if (NULL != game_unit_by_number(actor_id)
2937 && NULL != index_to_tile(&(wld.map), target_id)
2940 actor_id, target_id,
2941 /* FIXME: will cause problems if more than
2942 * one action selection dialog at a time
2943 * becomes supported. */
2945 "");
2946 }
2947}
2948
2949/***********************************************************************/
2952static void mine(QVariant data1, QVariant data2)
2953{
2954 int actor_id = data1.toInt();
2955 int target_id = data2.toInt();
2956
2957 if (NULL != game_unit_by_number(actor_id)
2958 && NULL != index_to_tile(&(wld.map), target_id)
2961 actor_id, target_id,
2962 /* FIXME: will cause problems if more than
2963 * one action selection dialog at a time
2964 * becomes supported. */
2966 "");
2967 }
2968}
2969
2970/***********************************************************************/
2973static void irrigate(QVariant data1, QVariant data2)
2974{
2975 int actor_id = data1.toInt();
2976 int target_id = data2.toInt();
2977
2978 if (NULL != game_unit_by_number(actor_id)
2979 && NULL != index_to_tile(&(wld.map), target_id)
2982 actor_id, target_id,
2983 /* FIXME: will cause problems if more than
2984 * one action selection dialog at a time
2985 * becomes supported. */
2987 "");
2988 }
2989}
2990
2991/***********************************************************************/
2994static void nuke(QVariant data1, QVariant data2)
2995{
2996 int diplomat_id = data1.toInt();
2997 int diplomat_target_id = data2.toInt();
2998
3003 }
3004}
3005
3006/***********************************************************************/
3009static void attack(QVariant data1, QVariant data2)
3010{
3011 int diplomat_id = data1.toInt();
3012 int diplomat_target_id = data2.toInt();
3013
3018 }
3019}
3020
3021/***********************************************************************/
3024static void suicide_attack(QVariant data1, QVariant data2)
3025{
3026 int diplomat_id = data1.toInt();
3027 int diplomat_target_id = data2.toInt();
3028
3033 }
3034}
3035
3036/***********************************************************************/
3039static void paradrop(QVariant data1, QVariant data2)
3040{
3041 int actor_id = data1.toInt();
3042 int target_id = data2.toInt();
3043
3044 if (NULL != game_unit_by_number(actor_id)
3045 && NULL != index_to_tile(&(wld.map), target_id)) {
3047 actor_id, target_id, 0, "");
3048 }
3049}
3050
3051/***********************************************************************/
3054static void paradrop_conquer(QVariant data1, QVariant data2)
3055{
3056 int actor_id = data1.toInt();
3057 int target_id = data2.toInt();
3058
3059 if (NULL != game_unit_by_number(actor_id)
3060 && NULL != index_to_tile(&(wld.map), target_id)) {
3062 actor_id, target_id, 0, "");
3063 }
3064}
3065
3066/***********************************************************************/
3069static void paradrop_frighten(QVariant data1, QVariant data2)
3070{
3071 int actor_id = data1.toInt();
3072 int target_id = data2.toInt();
3073
3074 if (NULL != game_unit_by_number(actor_id)
3075 && NULL != index_to_tile(&(wld.map), target_id)) {
3077 actor_id, target_id, 0, "");
3078 }
3079}
3080
3081/***********************************************************************/
3085{
3086 int actor_id = data1.toInt();
3087 int target_id = data2.toInt();
3088
3089 if (NULL != game_unit_by_number(actor_id)
3090 && NULL != index_to_tile(&(wld.map), target_id)) {
3092 actor_id, target_id, 0, "");
3093 }
3094}
3095
3096/***********************************************************************/
3099static void paradrop_enter(QVariant data1, QVariant data2)
3100{
3101 int actor_id = data1.toInt();
3102 int target_id = data2.toInt();
3103
3104 if (NULL != game_unit_by_number(actor_id)
3105 && NULL != index_to_tile(&(wld.map), target_id)) {
3107 actor_id, target_id, 0, "");
3108 }
3109}
3110
3111/***********************************************************************/
3115{
3116 int actor_id = data1.toInt();
3117 int target_id = data2.toInt();
3118
3119 if (NULL != game_unit_by_number(actor_id)
3120 && NULL != index_to_tile(&(wld.map), target_id)) {
3122 actor_id, target_id, 0, "");
3123 }
3124}
3125
3126/***********************************************************************/
3129static void join_city(QVariant data1, QVariant data2)
3130{
3131 int actor_id = data1.toInt();
3132 int target_id = data2.toInt();
3133
3134 if (NULL != game_unit_by_number(actor_id)
3135 && NULL != game_city_by_number(target_id)) {
3137 actor_id, target_id, 0, "");
3138 }
3139}
3140
3141/***********************************************************************/
3144static void spy_steal_shared(QVariant data1, QVariant data2,
3145 action_id act_id)
3146{
3147 QString str;
3148 QVariant qv1;
3150 int diplomat_id = data1.toInt();
3151 int diplomat_target_id = data2.toInt();
3154 struct player *pvictim = NULL;
3157
3158 cd = gui()->get_diplo_dialog();
3159 if (cd != NULL) {
3160 cd->close();
3161 }
3162
3163 if (pvcity == nullptr) {
3164 return;
3165 }
3166
3167 // Wait for the player's reply before moving on to the next queued diplomat.
3169
3171
3172 struct astring stra = ASTRING_INIT;
3173 cd = new choice_dialog(_("Steal"), _("Steal Technology"),
3174 gui()->game_tab_widget,
3176
3177 // Put both actor and target city in qv1 since qv2 is taken
3180 actor_and_target.append(act_id);
3181 qv1 = QVariant::fromValue(actor_and_target);
3182
3183 struct player *pplayer = client_player();
3184 const struct research *presearch = research_get(pplayer);
3185 const struct research *vresearch = research_get(pvictim);
3186
3193 // Defeat keyboard shortcut mnemonics
3195 .replace("&", "&&");
3196 cd->add_item(str, func, qv1, i);
3197 }
3199
3201 get_non_targeted_action_id(act_id)])) {
3202 astr_set(&stra, _("At %s's Discretion"),
3205 str = QString(astr_str(&stra)).replace("&", "&&");
3206 cd->add_item(str, func, qv1, A_UNSET);
3207 }
3208
3209 cd->set_layout();
3210 cd->show_me();
3211
3212 astr_free(&stra);
3213}
3214
3215/***********************************************************************/
3218static void spy_steal(QVariant data1, QVariant data2)
3219{
3221}
3222
3223/***********************************************************************/
3226static void spy_steal_esc(QVariant data1, QVariant data2)
3227{
3229}
3230
3231/***********************************************************************/
3234static void spy_steal_something(QVariant data1, QVariant data2)
3235{
3236 int diplomat_id = data1.toList().at(0).toInt();
3237 int diplomat_target_id = data1.toList().at(1).toInt();
3238 action_id act_id = data1.toList().at(2).toInt();
3239
3242 if (data2.toInt() == A_UNSET) {
3243 // This is the untargeted version.
3245 diplomat_id, diplomat_target_id, data2.toInt(), "");
3246 } else {
3247 // This is the targeted version.
3249 diplomat_target_id, data2.toInt(), "");
3250 }
3251 }
3252}
3253
3254/***********************************************************************/
3258{
3259 int actor_id = data1.toInt();
3260 int target_id = data2.toInt();
3261
3262 if (NULL != game_unit_by_number(actor_id)
3263 && NULL != game_city_by_number(target_id)) {
3264 // Wait for the server's reply before moving on to the next queued diplomat.
3266
3267 request_action_details(ACTION_STRIKE_BUILDING, actor_id, target_id);
3268 }
3269}
3270
3271/***********************************************************************/
3275{
3276 int diplomat_id = data1.toInt();
3277 int diplomat_target_id = data2.toInt();
3278
3281 // Wait for the server's reply before moving on to the next queued diplomat.
3283
3286 }
3287}
3288
3289/***********************************************************************/
3293{
3294 int diplomat_id = data1.toInt();
3295 int diplomat_target_id = data2.toInt();
3296
3299 /* Wait for the server's reply before moving on to the next queued
3300 * diplomat. */
3302
3305 }
3306}
3307
3308/***********************************************************************/
3311static void spy_poison(QVariant data1, QVariant data2)
3312{
3313 int diplomat_id = data1.toInt();
3314 int diplomat_target_id = data2.toInt();
3315
3320 }
3321}
3322
3323/***********************************************************************/
3326static void spy_poison_esc(QVariant data1, QVariant data2)
3327{
3328 int diplomat_id = data1.toInt();
3329 int diplomat_target_id = data2.toInt();
3330
3335 }
3336}
3337
3338/***********************************************************************/
3341static void spy_nuke_city(QVariant data1, QVariant data2)
3342{
3343 int diplomat_id = data1.toInt();
3344 int diplomat_target_id = data2.toInt();
3345
3350 }
3351}
3352
3353/***********************************************************************/
3356static void spy_nuke_city_esc(QVariant data1, QVariant data2)
3357{
3358 int diplomat_id = data1.toInt();
3359 int diplomat_target_id = data2.toInt();
3360
3365 }
3366}
3367
3368/***********************************************************************/
3371static void nuke_city(QVariant data1, QVariant data2)
3372{
3373 int actor_id = data1.toInt();
3374 int target_id = data2.toInt();
3375
3376 if (NULL != game_unit_by_number(actor_id)
3377 && NULL != game_city_by_number(target_id)) {
3379 actor_id, target_id, 0, "");
3380 }
3381}
3382
3383/***********************************************************************/
3386static void destroy_city(QVariant data1, QVariant data2)
3387{
3388 int diplomat_id = data1.toInt();
3389 int diplomat_target_id = data2.toInt();
3390
3395 }
3396}
3397
3398/***********************************************************************/
3401static void spy_steal_gold(QVariant data1, QVariant data2)
3402{
3403 int diplomat_id = data1.toInt();
3404 int diplomat_target_id = data2.toInt();
3405
3410 }
3411}
3412
3413/***********************************************************************/
3416static void spy_steal_gold_esc(QVariant data1, QVariant data2)
3417{
3418 int diplomat_id = data1.toInt();
3419 int diplomat_target_id = data2.toInt();
3420
3425 }
3426}
3427
3428/***********************************************************************/
3431static void spy_steal_maps(QVariant data1, QVariant data2)
3432{
3433 int diplomat_id = data1.toInt();
3434 int diplomat_target_id = data2.toInt();
3435
3440 }
3441}
3442
3443/***********************************************************************/
3446static void spy_steal_maps_esc(QVariant data1, QVariant data2)
3447{
3448 int diplomat_id = data1.toInt();
3449 int diplomat_target_id = data2.toInt();
3450
3455 }
3456}
3457
3458/***********************************************************************/
3461static void spy_escape(QVariant data1, QVariant data2)
3462{
3463 int diplomat_id = data1.toInt();
3464 int diplomat_target_id = data2.toInt();
3465
3470 }
3471}
3472
3473/***********************************************************************/
3476static void spy_embassy(QVariant data1, QVariant data2)
3477{
3478 int diplomat_id = data1.toInt();
3479 int diplomat_target_id = data2.toInt();
3480
3484 diplomat_target_id, 0, "");
3485 }
3486}
3487
3488/***********************************************************************/
3491static void diplomat_embassy(QVariant data1, QVariant data2)
3492{
3493 int diplomat_id = data1.toInt();
3494 int diplomat_target_id = data2.toInt();
3495
3499 diplomat_target_id, 0, "");
3500 }
3501}
3502
3503/***********************************************************************/
3506static void spy_investigate(QVariant data1, QVariant data2)
3507{
3508 int diplomat_id = data1.toInt();
3509 int diplomat_target_id = data2.toInt();
3510
3514 diplomat_target_id, 0, "");
3515 }
3516}
3517
3518/***********************************************************************/
3521static void diplomat_investigate(QVariant data1, QVariant data2)
3522{
3523 int diplomat_id = data1.toInt();
3524 int diplomat_target_id = data2.toInt();
3525
3529 diplomat_target_id, 0, "");
3530 }
3531}
3532
3533/***********************************************************************/
3536static void diplomat_sabotage(QVariant data1, QVariant data2)
3537{
3538 int diplomat_id = data1.toInt();
3539 int diplomat_target_id = data2.toInt();
3540
3544 diplomat_target_id, B_LAST + 1, "");
3545 }
3546}
3547
3548/***********************************************************************/
3551static void diplomat_sabotage_esc(QVariant data1, QVariant data2)
3552{
3553 int diplomat_id = data1.toInt();
3554 int diplomat_target_id = data2.toInt();
3555
3559 diplomat_target_id, B_LAST + 1, "");
3560 }
3561}
3562
3563/***********************************************************************/
3566static void diplomat_steal(QVariant data1, QVariant data2)
3567{
3568 int diplomat_id = data1.toInt();
3569 int diplomat_target_id = data2.toInt();
3570
3575 }
3576}
3577
3578/***********************************************************************/
3581static void diplomat_steal_esc(QVariant data1, QVariant data2)
3582{
3583 int diplomat_id = data1.toInt();
3584 int diplomat_target_id = data2.toInt();
3585
3590 }
3591}
3592
3593/***********************************************************************/
3596static void diplomat_incite(QVariant data1, QVariant data2)
3597{
3598 int diplomat_id = data1.toInt();
3599 int diplomat_target_id = data2.toInt();
3600
3603 // Wait for the server's reply before moving on to the next queued diplomat.
3605
3608 }
3609}
3610
3611/***********************************************************************/
3615{
3616 int diplomat_id = data1.toInt();
3617 int diplomat_target_id = data2.toInt();
3618
3621 // Wait for the server's reply before moving on to the next queued diplomat.
3623
3626 }
3627}
3628
3629/***********************************************************************/
3632static void regular_move(QVariant data1, QVariant data2)
3633{
3634 int actor_id = data1.toInt();
3635 int target_id = data2.toInt();
3636
3637 if (NULL != game_unit_by_number(actor_id)
3638 && NULL != index_to_tile(&(wld.map), target_id)) {
3640 actor_id, target_id, 0, "");
3641 }
3642}
3643
3644/***********************************************************************/
3648void popup_incite_dialog(struct unit *actor, struct city *tcity, int cost,
3649 const struct action *paction)
3650{
3651 char buf[1024];
3652 char buf2[1024];
3653 int diplomat_id = actor->id;
3654 int diplomat_target_id = tcity->id;
3655 const int act_id = paction->id;
3656
3657 // Should be set before sending request to the server.
3659
3660 fc_snprintf(buf, ARRAY_SIZE(buf), PL_("Treasury contains %d gold.",
3661 "Treasury contains %d gold.",
3662 client_player()->economic.gold),
3663 client_player()->economic.gold);
3664
3666 hud_message_box *impossible = new hud_message_box(gui()->central_wdg);
3667
3669 _("You can't incite a revolt in %s."), city_name_get(tcity));
3670 impossible->set_text_title(buf2, "!");
3671 impossible->setStandardButtons(QMessageBox::Ok);
3672 impossible->setAttribute(Qt::WA_DeleteOnClose);
3673 impossible->show();
3674 } else if (cost <= client_player()->economic.gold) {
3675 hud_message_box *ask = new hud_message_box(gui()->central_wdg);
3676
3678 PL_("Incite a revolt for %d gold?\n%s",
3679 "Incite a revolt for %d gold?\n%s", cost), cost, buf);
3680 ask->setStandardButtons(QMessageBox::Cancel | QMessageBox::Ok);
3681 ask->setDefaultButton(QMessageBox::Cancel);
3682 ask->set_text_title(buf2, _("Incite a Revolt!"));
3683 ask->setAttribute(Qt::WA_DeleteOnClose);
3684 QObject::connect(ask, &hud_message_box::accepted, [=]() {
3687 });
3688 ask->show();
3689 return;
3690 } else {
3691 hud_message_box *too_much = new hud_message_box(gui()->central_wdg);
3692
3694 PL_("Inciting a revolt costs %d gold.\n%s",
3695 "Inciting a revolt costs %d gold.\n%s", cost), cost,
3696 buf);
3697 too_much->set_text_title(buf2, "!");
3698 too_much->setStandardButtons(QMessageBox::Ok);
3699 too_much->setAttribute(Qt::WA_DeleteOnClose);
3700 too_much->show();
3701 }
3702
3704}
3705
3706/***********************************************************************/
3710void popup_bribe_dialog(struct unit *actor, struct unit *tunit, int cost,
3711 const struct action *paction)
3712{
3713 hud_message_box *ask = new hud_message_box(gui()->central_wdg);
3714 char buf[1024];
3715 char buf2[1024];
3716 int diplomat_id = actor->id;
3717 int diplomat_target_id = tunit->id;
3718 const int act_id = paction->id;
3719
3720 // Should be set before sending request to the server.
3722
3723 fc_snprintf(buf, ARRAY_SIZE(buf), PL_("Treasury contains %d gold.",
3724 "Treasury contains %d gold.",
3725 client_player()->economic.gold),
3726 client_player()->economic.gold);
3727
3728 if (cost <= client_player()->economic.gold) {
3729 fc_snprintf(buf2, ARRAY_SIZE(buf2), PL_("Bribe unit for %d gold?\n%s",
3730 "Bribe unit for %d gold?\n%s",
3731 cost), cost, buf);
3732 ask->set_text_title(buf2, _("Bribe Enemy Unit"));
3733 ask->setStandardButtons(QMessageBox::Cancel | QMessageBox::Ok);
3734 ask->setDefaultButton(QMessageBox::Cancel);
3735 ask->setAttribute(Qt::WA_DeleteOnClose);
3736 QObject::connect(ask, &hud_message_box::accepted, [=]() {
3739 });
3740 ask->show();
3741 return;
3742 } else {
3744 PL_("Bribing the unit costs %d gold.\n%s",
3745 "Bribing the unit costs %d gold.\n%s", cost), cost, buf);
3746 ask->set_text_title(buf2, _("Traitors Demand Too Much!"));
3747 ask->setAttribute(Qt::WA_DeleteOnClose);
3748 ask->show();
3749 }
3750
3752}
3753
3754/***********************************************************************/
3757static void pillage_something(QVariant data1, QVariant data2)
3758{
3759 int punit_id;
3760 int what;
3761 struct unit *punit;
3762 struct extra_type *target;
3763
3764 what = data1.toInt();
3765 punit_id = data2.toInt();
3767 if (punit) {
3768 target = extra_by_number(what);
3770 }
3772}
3773
3774/***********************************************************************/
3777static void spy_sabotage(QVariant data1, QVariant data2)
3778{
3779 int diplomat_id = data1.toList().at(0).toInt();
3780 int diplomat_target_id = data1.toList().at(1).toInt();
3781 action_id act_id = data1.toList().at(2).toInt();
3782
3785 if (data2.toInt() == B_LAST) {
3786 // This is the untargeted version.
3788 diplomat_id, diplomat_target_id, data2.toInt(),
3789 "");
3790 } else if (data2.toInt() == -1) {
3791 // This is the city production version.
3793 diplomat_id, diplomat_target_id, data2.toInt(),
3794 "");
3795 } else {
3796 // This is the targeted version.
3798 diplomat_target_id, data2.toInt(), "");
3799 }
3800 }
3801}
3802
3803/***********************************************************************/
3808 const struct action *paction)
3809{
3810 QString str;
3811 QVariant qv1, qv2;
3812 int diplomat_id = actor->id;
3813 int diplomat_target_id = tcity->id;
3815 choice_dialog *cd = new choice_dialog(_("Sabotage"),
3816 _("Select Improvement to Sabotage"),
3817 gui()->game_tab_widget,
3819 int nr = 0;
3820 struct astring stra = ASTRING_INIT;
3822
3823 // Should be set before sending request to the server.
3825
3826 // Put both actor, target city and action in qv1 since qv2 is taken
3829 actor_and_target.append(paction->id);
3830 qv1 = QVariant::fromValue(actor_and_target);
3831
3834 paction->id)])) {
3836 cd->add_item(QString(_("City Production")), func, qv1, -1);
3837 }
3838
3839 city_built_iterate(tcity, pimprove) {
3840 if (pimprove->sabotage > 0) {
3842 // Defeat keyboard shortcut mnemonics
3844 .replace("&", "&&");
3845 qv2 = nr;
3846 cd->add_item(str, func, qv1, improvement_number(pimprove));
3847 nr++;
3848 }
3850
3853 astr_set(&stra, _("At %s's Discretion"),
3856 str = QString(astr_str(&stra)).replace("&", "&&");
3857 cd->add_item(str, func, qv1, B_LAST);
3858 }
3859
3860 cd->set_layout();
3861 cd->show_me();
3862 astr_free(&stra);
3863}
3864
3865/***********************************************************************/
3870{
3871 QString str;
3872 QVariant qv1, qv2;
3875 struct extra_type *tgt;
3876
3878 return;
3879 }
3880 cd = new choice_dialog(_("What To Pillage"), _("Select what to pillage:"),
3881 gui()->game_tab_widget);
3882 qv2 = punit->id;
3883 while ((tgt = get_preferred_pillage(extras))) {
3884 int what;
3885
3886 what = extra_index(tgt);
3887 BV_CLR(extras, what);
3888
3890 // Defeat keyboard shortcut mnemonics
3891 str = QString(extra_name_translation(tgt)).replace("&", "&&");
3892 qv1 = what;
3893 cd->add_item(str, func, qv1, qv2);
3894 }
3895 cd->set_layout();
3896 cd->show_me();
3897}
3898
3899/***********************************************************************/
3903 QWidget *parent) : hud_message_box(parent)
3904{
3905 QString str;
3906 QPushButton *pb;
3907
3908 setAttribute(Qt::WA_DeleteOnClose);
3909 setModal(false);
3914
3915 str = QString(PL_("Are you sure you want to disband that %1 unit?",
3916 "Are you sure you want to disband those %1 units?",
3918 pb = addButton(_("Yes"), QMessageBox::AcceptRole);
3919 addButton(_("No"), QMessageBox::RejectRole);
3920 set_text_title(str, _("Disband units"));
3922 connect(pb, &QAbstractButton::clicked, this, &disband_box::disband_clicked);
3923}
3924
3925/***********************************************************************/
3936
3937/***********************************************************************/
3944
3945/***********************************************************************/
3948void popup_disband_dialog(struct unit_list *punits)
3949{
3950 disband_box *ask = new disband_box(punits, gui()->central_wdg);
3951 ask->show();
3952}
3953
3954/***********************************************************************/
3959{
3960 hud_message_box *ask = new hud_message_box(gui()->central_wdg);
3961 QString text;
3962 QString title;
3963
3964 title = QString(_("Modpack suggests using %1 tileset."))
3966 text = QString("It might not work with other tilesets.\n"
3967 "You are currently using tileset %1.")
3969 ask->addButton(_("Keep current tileset"), QMessageBox::RejectRole);
3970 ask->addButton(_("Load tileset"), QMessageBox::AcceptRole);
3971 ask->set_text_title(text, title);
3972 ask->setAttribute(Qt::WA_DeleteOnClose);
3973
3974 QObject::connect(ask, &hud_message_box::accepted, [=]() {
3977 gui()->map_scale)) {
3979 _("Can't load requested tileset."));
3980 }
3981 });
3982 ask->show();
3983}
3984
3985/***********************************************************************/
3990{
3991 hud_message_box *ask = new hud_message_box(gui()->central_wdg);
3992 QString text;
3993 QString title;
3994
3995 title = QString(_("Modpack suggests using %1 soundset."))
3997 text = QString("It might not work with other tilesets.\n"
3998 "You are currently using soundset %1.")
3999 .arg(sound_set_name);
4000 ask->addButton(_("Keep current soundset"), QMessageBox::RejectRole);
4001 ask->addButton(_("Load soundset"), QMessageBox::AcceptRole);
4002 ask->set_text_title(text, title);
4003 ask->setAttribute(Qt::WA_DeleteOnClose);
4004 QObject::connect(ask, &hud_message_box::accepted, [=]() {
4006 });
4007 ask->show();
4008}
4009
4010/***********************************************************************/
4015{
4016 hud_message_box *ask = new hud_message_box(gui()->central_wdg);
4017 QString text;
4018 QString title;
4019
4020 title = QString(_("Modpack suggests using %1 musicset."))
4022 text = QString("It might not work with other tilesets.\n"
4023 "You are currently using musicset %1.")
4024 .arg(music_set_name);
4025 ask->addButton(_("Keep current musicset"), QMessageBox::RejectRole);
4026 ask->addButton(_("Load musicset"), QMessageBox::AcceptRole);
4027 ask->set_text_title(text, title);
4028 ask->setAttribute(Qt::WA_DeleteOnClose);
4029 QObject::connect(ask, &hud_message_box::accepted, [=]() {
4031 });
4032 ask->show();
4033}
4034
4035/***********************************************************************/
4040{
4041 // PORTME
4042 return false;
4043}
4044
4045/***********************************************************************/
4049{
4051 int i;
4052
4053 nd_list = gui()->mapview_wdg->findChildren<notify_dialog *>();
4054 for (i = 0; i < nd_list.count(); i++) {
4055 nd_list[i]->restart();
4056 delete nd_list[i];
4057 }
4058}
4059
4060/***********************************************************************/
4065{
4066 int i;
4069 goto_dialog *gtd;
4070
4071 QApplication::alert(gui()->central_wdg);
4072 cd_list = gui()->game_tab_widget->findChildren <choice_dialog *>();
4073 for (i = 0; i < cd_list.count(); i++) {
4074 cd_list[i]->close();
4075 }
4076 nd_list = gui()->game_tab_widget->findChildren <notify_dialog *>();
4077 for (i = 0; i < nd_list.count(); i++) {
4078 nd_list[i]->close();
4079 }
4080
4089 gui()->popdown_unit_sel();
4090
4091 gtd = gui()->gtd;
4092
4093 if (gtd != nullptr) {
4094 gtd->close_dlg();
4095 }
4096}
4097
4098/***********************************************************************/
4104{
4105 choice_dialog *cd = gui()->get_diplo_dialog();
4106
4107 if (cd != NULL) {
4108 return cd->unit_id;
4109 } else {
4110 return IDENTITY_NUMBER_ZERO;
4111 }
4112}
4113
4114/***********************************************************************/
4121{
4122 choice_dialog *cd = gui()->get_diplo_dialog();
4123
4124 if (cd != NULL) {
4125 return cd->target_id[ATK_CITY];
4126 } else {
4127 return IDENTITY_NUMBER_ZERO;
4128 }
4129}
4130
4131/***********************************************************************/
4138{
4139 choice_dialog *cd = gui()->get_diplo_dialog();
4140
4141 if (cd != NULL) {
4142 return cd->target_id[ATK_TILE];
4143 } else {
4144 return TILE_INDEX_NONE;
4145 }
4146}
4147
4148/**********************************************************************/
4155{
4156 choice_dialog *cd = gui()->get_diplo_dialog();
4157
4158 if (cd != NULL) {
4159 return cd->sub_target_id[ASTK_EXTRA];
4160 } else {
4161 return EXTRA_NONE;
4162 }
4163}
4164
4165/***********************************************************************/
4172{
4173 choice_dialog *cd = gui()->get_diplo_dialog();
4174
4175 if (cd != NULL) {
4176 return cd->target_id[ATK_UNIT];
4177 } else {
4178 return IDENTITY_NUMBER_ZERO;
4179 }
4180}
4181
4182/***********************************************************************/
4186 struct city *target_city,
4187 struct unit *target_unit,
4188 struct tile *target_tile,
4189 struct extra_type *target_extra,
4190 const struct act_prob *act_probs)
4191{
4194 Choice_dialog_button *cancel_button;
4195 QVariant qv1, qv2;
4196
4197 asd = gui()->get_diplo_dialog();
4198 if (asd == NULL) {
4200 "The action selection dialog should have been open");
4201 return;
4202 }
4203
4206 "The action selection dialog is for another actor unit.");
4207 }
4208
4209 // Put the actor id in qv1.
4210 qv1 = actor_unit->id;
4211
4212 cancel_button = asd->get_identified_button(BUTTON_CANCEL);
4213 if (cancel_button != NULL) {
4214 /* Temporary remove the Cancel button so it won't end up above
4215 * any added buttons. */
4216 asd->stack_button(cancel_button);
4217 }
4218
4219 wait_button = asd->get_identified_button(BUTTON_WAIT);
4220 if (wait_button != NULL) {
4221 /* Temporary remove the Wait button so it won't end up above
4222 * any added buttons. */
4223 asd->stack_button(wait_button);
4224 }
4225
4226 action_iterate(act) {
4227 const char *custom;
4228
4229 if (action_id_get_actor_kind(act) != AAK_UNIT) {
4230 // Not relevant.
4231 continue;
4232 }
4233
4235 act_probs[act],
4236 actor_unit,
4237 target_city);
4238
4239 // Put the target id in qv2.
4240 switch (action_id_get_target_kind(act)) {
4241 case ATK_UNIT:
4242 if (target_unit != NULL) {
4243 qv2 = target_unit->id;
4244 } else {
4246 || target_unit != NULL,
4247 "Action enabled against non existing unit!");
4248
4250 }
4251 break;
4252 case ATK_CITY:
4253 if (target_city != NULL) {
4254 qv2 = target_city->id;
4255 } else {
4257 || target_city != NULL,
4258 "Action enabled against non existing city!");
4259
4261 }
4262 break;
4263 case ATK_TILE:
4264 case ATK_EXTRAS:
4265 case ATK_UNITS:
4266 if (target_tile != NULL) {
4268 } else {
4270 || target_tile != NULL,
4271 "Action enabled against all units on "
4272 "non existing tile!");
4273
4275 }
4276 break;
4277 case ATK_SELF:
4278 qv2 = actor_unit->id;
4279 break;
4280 case ATK_COUNT:
4282 "Bad target kind");
4283 continue;
4284 }
4285
4286 if (asd->get_identified_button(act)) {
4287 // Update the existing button.
4288 action_entry_update(asd->get_identified_button(act),
4289 act, act_probs, custom,
4290 qv1, qv2);
4291 } else {
4292 // Add the button (unless its probability is 0).
4294 qv1, qv2);
4295 }
4297
4298 if (wait_button != NULL || cancel_button != NULL) {
4299 /* Reinsert the non action buttons below any potential
4300 * buttons recently added. */
4301 asd->unstack_all_buttons();
4302 }
4303}
4304
4305/***********************************************************************/
4309{
4311
4312 cd = gui()->get_diplo_dialog();
4313 if (cd != NULL) {
4314 did_not_decide = true;
4315 cd->close();
4316 }
4317}
4318
4319/***********************************************************************/
4325
4326/***********************************************************************/
4329void show_tileset_error(bool fatal, const char *tset_name, const char *msg)
4330{
4331 QWidget *parent;
4332 fc_client *std_gui = gui();
4333
4334 if (std_gui != nullptr) {
4335 parent = std_gui->central_wdg;
4336 } else {
4337 parent = nullptr;
4338 }
4339
4340 if (std_gui != nullptr || fatal) {
4341 char buf[1024];
4342 QMessageBox *ask = new QMessageBox(parent);
4343
4344 if (tset_name != NULL) {
4345 fc_snprintf(buf, sizeof(buf),
4346 _("Tileset \"%s\" problem, it's probably incompatible with "
4347 "the ruleset:\n%s"), tset_name, msg);
4348 } else {
4349 fc_snprintf(buf, sizeof(buf),
4350 _("Tileset problem, it's probably incompatible with "
4351 "the ruleset:\n%s"), msg);
4352 }
4353
4354 ask->setText(buf);
4355 ask->setStandardButtons(QMessageBox::Ok);
4356 ask->setWindowTitle(_("Tileset error"));
4357
4358 if (std_gui != nullptr) {
4359 ask->setAttribute(Qt::WA_DeleteOnClose);
4360 ask->show();
4361 } else {
4362 ask->exec();
4363 }
4364 }
4365}
4366
4367/***********************************************************************/
4370void popup_upgrade_dialog(struct unit_list *punits)
4371{
4372 char buf[512];
4374 QString title;
4376
4377 if (!punits || unit_list_size(punits) == 0) {
4378 return;
4379 }
4380
4381 ask = new hud_message_box(gui()->central_wdg);
4382
4383 punit_ids = new QVector<int>();
4385 punit_ids->push_back(punit->id);
4387
4388 if (!get_units_upgrade_info(buf, sizeof(buf), punits)) {
4389 title = _("Upgrade Unit!");
4390 ask->setStandardButtons(QMessageBox::Ok);
4391 } else {
4392 title = _("Upgrade Obsolete Units");
4393 ask->setStandardButtons(QMessageBox::Cancel | QMessageBox::Ok);
4394 ask->setDefaultButton(QMessageBox::Cancel);
4395 }
4396 ask->set_text_title(buf, title);
4397 ask->setAttribute(Qt::WA_DeleteOnClose);
4398 QObject::connect(ask, &hud_message_box::accepted, [=]() {
4399 std::unique_ptr<QVector<int>> uptr(punit_ids);
4400 struct unit *punit;
4401
4402 for (int id : *uptr) {
4404 if (punit) {
4406 }
4407 }
4408 });
4409 ask->show();
4410}
4411
4412/***********************************************************************/
4416{
4417 QPoint p, final_p;
4418
4420 utile = ptile;
4421 pix = NULL;
4422 show_line = 0;
4423 highligh_num = -1;
4424 ufont.setItalic(true);
4426 update_units();
4427 h_pix = NULL;
4428 create_pixmap();
4429 p = mapFromGlobal(QCursor::pos());
4430 cw = new close_widget(this);
4431 setMouseTracking(true);
4432 final_p.setX(p.x());
4433 final_p.setY(p.y());
4434 if (p.x() + width() > parentWidget()->width()) {
4435 final_p.setX(parentWidget()->width() - width());
4436 }
4437 if (p.y() - height() < 0) {
4438 final_p.setY(height());
4439 }
4440 move(final_p.x(), final_p.y() - height());
4441 setFocus();
4442 /* Build fails with qt5 connect style for static functions
4443 * Qt5.2 so dont update */
4444 QTimer::singleShot(10, this, SLOT(update_img()));
4445}
4446
4447/***********************************************************************/
4451{
4452 delete h_pix;
4453 delete pix;
4454 delete cw;
4455}
4456
4457/***********************************************************************/
4461{
4462 int a;
4463 int x, y, i;
4466 QImage img;
4468 QPainter p;
4469 QPen pen;
4470 QPixmap pixc;
4471 QPixmap *pixp;
4473 QRect crop;
4474 struct canvas *unit_pixmap;
4475 struct unit *punit;
4476 float isosize;
4477
4478 if (pix != NULL) {
4479 delete pix;
4480 pix = NULL;
4481 };
4482 isosize = 0.7;
4484 isosize = 0.5;
4485 }
4486
4487 update_units();
4488 if (unit_list.count() > 0) {
4492 } else {
4495 }
4496 more = false;
4497 if (h_pix != nullptr) {
4498 delete h_pix;
4499 }
4500 h_pix = new QPixmap(item_size.width(), item_size.height());
4501 h_pix->fill(palette().color(QPalette::HighlightedText));
4502 if (unit_count < 5) {
4503 row_count = 1;
4504 pix = new QPixmap((unit_list.size()) * item_size.width(),
4505 item_size.height());
4506 } else if (unit_count < 9) {
4507 row_count = 2;
4508 pix = new QPixmap(4 * item_size.width(), 2 * item_size.height());
4509 } else {
4510 row_count = 3;
4511 if (unit_count > 12) {
4512 more = true;
4513 }
4514 pix = new QPixmap(4 * item_size.width(), 3 * item_size.height());
4515 }
4516 pix->fill(Qt::transparent);
4517 foreach(punit, unit_list) {
4520 unit_pixmap->map_pixmap.fill(Qt::transparent);
4521 put_unit(punit, unit_pixmap, 1.0, 0, 0);
4522 img = unit_pixmap->map_pixmap.toImage();
4524 cropped_img = img.copy(crop);
4528 Qt::KeepAspectRatio,
4529 Qt::SmoothTransformation);
4530 } else {
4533 Qt::KeepAspectRatio,
4534 Qt::SmoothTransformation);
4535 }
4536 pixc = QPixmap::fromImage(img);
4537 pixp = new QPixmap(pixc);
4538 pix_list.push_back(pixp);
4540 }
4541 a = qMin(item_size.width() / 4, 12);
4542 x = 0, y = -item_size.height(), i = -1;
4543 p.begin(pix);
4544 ufont.setPixelSize(a);
4545 p.setFont(ufont);
4546 pen.setColor(palette().color(QPalette::Text));
4547 p.setPen(pen);
4548
4549 while (!pix_list.isEmpty()) {
4550 tmp_pix = pix_list.takeFirst();
4551 i++;
4552 if (i % 4 == 0) {
4553 x = 0;
4554 y = y + item_size.height();
4555 }
4556 punit = unit_list.at(i);
4557 Q_ASSERT(punit != NULL);
4558
4559 if (i == highligh_num) {
4560 p.drawPixmap(x, y, *h_pix);
4561 p.drawPixmap(x, y, *tmp_pix);
4562 } else {
4563 p.drawPixmap(x, y, *tmp_pix);
4564 }
4565
4567 int rate, f;
4568 QString str;
4569
4571 f = ((punit->fuel) - 1);
4574 str = str + "(" + QString(move_points_text((rate * f)
4575 + punit->moves_left, false)) + ")";
4576 }
4577 // TRANS: MP = Movement points
4578 str = QString(_("MP:")) + str;
4579 p.drawText(x, y + item_size.height() - 4, str);
4580 }
4581
4582 x = x + item_size.width();
4583 delete tmp_pix;
4584 }
4585 p.end();
4586 setFixedWidth(pix->width() + 20);
4587 setFixedHeight(pix->height() + 2 * (fm.height() + 6));
4588 qDeleteAll(pix_list.begin(), pix_list.end());
4589 }
4590}
4591
4592/***********************************************************************/
4596{
4597 int a, b;
4598 int old_h;
4600 QPoint pos = event->pos();
4601 int x = pos.x();
4602 int y = pos.y();
4603
4605 highligh_num = -1;
4606 if (x > width() - 11
4607 || y > height() - fm.height() - 5
4608 || y < fm.height() + 3 || x < 11) {
4609 // Do nothing if mouse is on border, just skip next if
4610 } else if (row_count > 0) {
4611 a = (x - 10) / item_size.width();
4612 b = (y - fm.height() - 3) / item_size.height();
4613 highligh_num = b * 4 + a;
4614 }
4615 if (old_h != highligh_num) {
4616 create_pixmap();
4617 update();
4618 }
4619}
4620
4621/***********************************************************************/
4627{
4628 struct unit *punit;
4629 if (event->button() == Qt::RightButton) {
4630 was_destroyed = true;
4631 close();
4632 destroy();
4633 }
4634 if (event->button() == Qt::LeftButton && highligh_num != -1) {
4635 update_units();
4636 if (highligh_num >= unit_list.count()) {
4637 return;
4638 }
4641 was_destroyed = true;
4642 close();
4643 destroy();
4644 }
4645}
4646
4647/***********************************************************************/
4652{
4653 create_pixmap();
4654 update();
4655}
4656
4657/***********************************************************************/
4661{
4663 int h, i;
4664 int *f_size;
4665 QPen pen;
4666 QString str, str2;
4667 struct unit *punit;
4668 int point_size = info_font.pointSize();
4669 int pixel_size = info_font.pixelSize();
4670
4671 if (point_size < 0) {
4672 f_size = &pixel_size;
4673 } else {
4674 f_size = &point_size;
4675 }
4676 if (highligh_num != -1 && highligh_num < unit_list.count()) {
4677 struct astring addition = ASTRING_INIT;
4678
4681
4682 // TRANS: HP - hit points
4683 str2 = QString(_("%1 HP:%2/%3")).arg(QString(astr_str(&addition)),
4684 QString::number(punit->hp),
4685 QString::number(unit_type_get(punit)->hp));
4687 }
4688 str = QString(PL_("%1 unit", "%1 units",
4690 .arg(unit_list_size(utile->units));
4691 for (i = *f_size; i > 4; i--) {
4692 if (point_size < 0) {
4693 info_font.setPixelSize(i);
4694 } else {
4695 info_font.setPointSize(i);
4696 }
4698 if (10 + qfm.horizontalAdvance(str2) < width()) {
4699 break;
4700 }
4701 }
4702 h = fm.height();
4703 if (pix != NULL) {
4704 painter->drawPixmap(10, h + 3, *pix);
4705 pen.setColor(palette().color(QPalette::Text));
4706 painter->setPen(pen);
4707 painter->setFont(info_font);
4708 painter->drawText(10, h, str);
4709 if (highligh_num != -1 && highligh_num < unit_list.count()) {
4710 painter->drawText(10, height() - 5, str2);
4711 }
4712 // Draw scroll
4713 if (more) {
4714 int maxl = ((unit_count - 1) / 4) + 1;
4715 float page_height = 3.0f / maxl;
4716 float page_start = (static_cast<float>(show_line)) / maxl;
4717 pen.setColor(palette().color(QPalette::HighlightedText));
4718 painter->setBrush(palette().color(QPalette::HighlightedText).darker());
4719 painter->setPen(palette().color(QPalette::HighlightedText).darker());
4720 painter->drawRect(pix->width() + 10, h, 8, h + pix->height());
4721 painter->setPen(pen);
4722 painter->drawRoundedRect(pix->width() + 10,
4723 h + page_start * pix->height(),
4724 8, h + page_height * pix->height(), 2, 2);
4725 }
4726 }
4727 if (point_size < 0) {
4728 info_font.setPixelSize(*f_size);
4729 } else {
4730 info_font.setPointSize(*f_size);
4731 }
4732 cw->put_to_corner();
4733}
4734
4735/***********************************************************************/
4739{
4741
4742 painter.begin(this);
4743 paint(&painter, event);
4744 painter.end();
4745}
4746
4747/***********************************************************************/
4752{
4753 was_destroyed = true;
4754 close();
4755 destroy();
4756}
4757
4758/***********************************************************************/
4762{
4763 int i = 1;
4764 struct unit_list *punit_list;
4765
4766 unit_count = 0;
4767 if (utile == NULL) {
4768 struct unit *punit = head_of_units_in_focus();
4769 if (punit) {
4771 }
4772 }
4773 unit_list.clear();
4774 if (utile != nullptr) {
4776 if (punit_list != nullptr) {
4778 unit_count++;
4779 if (i > show_line * 4)
4780 unit_list.push_back(punit);
4781 i++;
4783 }
4784 }
4785 if (unit_list.count() == 0) {
4786 close();
4787 }
4788}
4789
4790/***********************************************************************/
4794{
4795 gui()->mapview_wdg->setFocus();
4796 QWidget::closeEvent(event);
4797}
4798
4799/***********************************************************************/
4803{
4804 int nr;
4805
4806 if (!more && utile == NULL) {
4807 return;
4808 }
4809 nr = qCeil(static_cast<qreal>(unit_list_size(utile->units)) / 4) - 3;
4810 if (event->angleDelta().y() < 0) {
4811 show_line++;
4813 } else {
4814 show_line--;
4815 show_line = qMax(0, show_line);
4816 }
4817 update_units();
4818 create_pixmap();
4819 update();
4820 event->accept();
4821}
4822
4823/***********************************************************************/
4827{
4828 if (event->key() == Qt::Key_Escape) {
4829 was_destroyed = true;
4830 close();
4831 destroy();
4832 }
4833 QWidget::keyPressEvent(event);
4834}
4835
4836/***********************************************************************/
4843
4844/***********************************************************************/
4851
4852/***********************************************************************/
4857{
4858 // Just tell the client common code to handle this.
4859 return false;
4860}
4861
4862/***********************************************************************/
4865bool qtg_request_transport(struct unit *pcargo, struct tile *ptile)
4866{
4867 int tcount;
4869 struct unit_list *potential_transports = unit_list_new();
4870#ifndef FREECIV_NDEBUG
4872#endif
4873
4877 }
4879
4881
4882 if (tcount == 0) {
4885
4886 return false; // Unit was not handled here.
4887 } else if (tcount == 1) {
4888 // There's exactly one potential transport - use it automatically
4891
4893
4894 return true;
4895 }
4896
4897 hul = new hud_unit_loader(pcargo, ptile);
4898 hul->show_me();
4899 return true;
4900}
4901
4902/***********************************************************************/
4906void qtg_popup_combat_info(int attacker_unit_id, int defender_unit_id,
4907 int attacker_hp, int defender_hp,
4908 bool make_att_veteran, bool make_def_veteran)
4909{
4910 if (gui()->qt_settings.show_battle_log) {
4911 hud_unit_combat *huc = new hud_unit_combat(attacker_unit_id,
4912 defender_unit_id,
4913 attacker_hp, defender_hp,
4914 make_att_veteran,
4915 make_def_veteran,
4916 gui()->battlelog_wdg->scale,
4917 gui()->battlelog_wdg);
4918
4919 gui()->battlelog_wdg->add_combat_info(huc);
4920 gui()->battlelog_wdg->show();
4921 }
4922}
4923
4924/**********************************************************************/
4928 struct act_confirmation_data *data)
4929{
4930 hud_message_box *ask = new hud_message_box(gui()->central_wdg);
4931
4932 ask->setStandardButtons(QMessageBox::Cancel | QMessageBox::Ok);
4933 ask->setDefaultButton(QMessageBox::Cancel);
4934 ask->set_text_title(body, hdr);
4935 ask->setAttribute(Qt::WA_DeleteOnClose);
4936 QObject::connect(ask, &hud_message_box::accepted, [=]() {
4938 });
4939 QObject::connect(ask, &hud_message_box::rejected, [=]() {
4941 });
4942
4943 ask->show();
4944}
4945
4946/***********************************************************************/
4950 struct act_confirmation_data *data)
4951{
4953
4954 hdr = QString(_("Are you sure you want to do %1?")).
4956
4957 if (expl != NULL) {
4958 body_text += QString(expl);
4959 }
4960
4962}
4963
4964/**********************************************************************/
4967void qtg_popup_image(const char *tag)
4968{
4969 struct sprite *spr = load_popup_sprite(tag);
4970
4971 if (spr != nullptr) {
4972 QDialog *win = new QDialog(gui());
4973 QVBoxLayout *layout = new QVBoxLayout(win);
4974 QPixmap *pm = new QPixmap(*spr->pm);
4975 QLabel *lbl = new QLabel;
4976 int width, height;
4977
4979 win->setFixedSize(width, height);
4980 lbl->setPixmap(*pm);
4981 layout->addWidget(lbl);
4982 win->setLayout(layout);
4983
4984 win->show();
4985
4987 } else {
4988 log_error(_("No image for tag \"%s\", requested by the server."), tag);
4989 }
4990}
const char * action_prepare_ui_name(action_id act_id, const char *mnemonic, const struct act_prob prob, const char *custom)
Definition actions.c:2073
const char * action_id_name_translation(action_id act_id)
Definition actions.c:2011
bool action_prob_possible(const struct act_prob probability)
Definition actions.c:5821
static struct action * action_by_number(action_id act_id)
Definition actions.h:635
#define action_iterate_end
Definition actions.h:465
#define action_id_get_actor_kind(act_id)
Definition actions.h:648
#define action_iterate(_act_)
Definition actions.h:461
#define action_id_get_target_kind(act_id)
Definition actions.h:652
#define ACTION_NONE
Definition actions.h:311
void astr_free(struct astring *astr)
Definition astring.c:153
void astr_set(struct astring *astr, const char *format,...)
Definition astring.c:267
#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:1137
#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:834
#define city_built_iterate_end
Definition city.h:840
void qtg_real_city_dialog_popup(struct city *pcity)
Definition citydlg.cpp:3820
Choice_dialog_button(const QString title, pfcn_void func_in, QVariant data1_in, QVariant data2_in)
Definition dialogs.cpp:1337
void setData2(QVariant wariat)
Definition dialogs.cpp:1385
void setData1(QVariant wariat)
Definition dialogs.cpp:1377
pfcn_void getFunc()
Definition dialogs.cpp:1351
void stack_button(Choice_dialog_button *button)
Definition dialogs.cpp:1711
void prev_unit()
Definition dialogs.cpp:1628
QVBoxLayout * layout
Definition dialogs.h:263
struct unit * targeted_unit
Definition dialogs.h:286
void unstack_all_buttons()
Definition dialogs.cpp:1728
Choice_dialog_button * get_identified_button(const int id)
Definition dialogs.cpp:1540
QPushButton * target_unit_button
Definition dialogs.h:262
void set_layout()
Definition dialogs.cpp:1446
void update_dialog(const struct act_prob *act_probs)
Definition dialogs.cpp:1657
QList< Choice_dialog_button * > last_buttons_stack
Definition dialogs.h:266
choice_dialog(const QString title, const QString text, QWidget *parent=NULL, void(*run_on_close_in)(int)=NULL)
Definition dialogs.cpp:1393
void next_unit()
Definition dialogs.cpp:1588
QVBoxLayout * get_layout()
Definition dialogs.cpp:1532
QHBoxLayout * unit_skip
Definition dialogs.h:264
QList< Choice_dialog_button * > buttons_list
Definition dialogs.h:265
void(* run_on_close)(int)
Definition dialogs.h:268
int target_id[ATK_COUNT]
Definition dialogs.h:284
void switch_target()
Definition dialogs.cpp:1675
QList< Choice_dialog_button * > action_button_map
Definition dialogs.h:267
int sub_target_id[ASTK_COUNT]
Definition dialogs.h:285
void execute_action(const int action)
Definition dialogs.cpp:1694
void add_item(QString title, pfcn_void func, QVariant data1, QVariant data2, QString tool_tip, const int button_id)
Definition dialogs.cpp:1488
void put_to_corner()
Definition mapview.cpp:502
void disband_clicked()
Definition dialogs.cpp:3928
disband_box(struct unit_list *punits, QWidget *parent=0)
Definition dialogs.cpp:3902
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:4847
void set_diplo_dialog(choice_dialog *widget)
Definition dialogs.cpp:4839
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:911
close_widget * cw
Definition dialogs.h:189
void mouseReleaseEvent(QMouseEvent *event)
Definition dialogs.cpp:1004
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:878
void calc_size(int &x, int &y)
Definition dialogs.cpp:939
void paintEvent(QPaintEvent *paint_event)
Definition dialogs.cpp:958
QPoint cursor
Definition dialogs.h:196
void mouseMoveEvent(QMouseEvent *event)
Definition dialogs.cpp:994
virtual void update_menu()
Definition dialogs.cpp:1012
void mousePressEvent(QMouseEvent *event)
Definition dialogs.cpp:981
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:1113
QPushButton * goto_but
Definition dialogs.h:111
void inspect_city()
Definition dialogs.cpp:1156
struct tile * gtile
Definition dialogs.h:114
QPushButton * inspect_but
Definition dialogs.h:112
void goto_tile()
Definition dialogs.cpp:1147
action_id vs_unit
Definition dialogs.h:60
static qdef_act * action()
Definition dialogs.cpp:1041
action_id vs_city_get()
Definition dialogs.cpp:1079
static qdef_act * m_instance
Definition dialogs.h:58
static void drop()
Definition dialogs.cpp:1052
action_id vs_city
Definition dialogs.h:59
void vs_city_set(int i)
Definition dialogs.cpp:1063
void vs_unit_set(int i)
Definition dialogs.cpp:1071
action_id vs_unit_get()
Definition dialogs.cpp:1087
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:1103
void style_selected(const QItemSelection &sl, const QItemSelection &ds)
Definition dialogs.cpp:806
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:755
void nationset_changed(int index)
Definition dialogs.cpp:1168
int selected_nation
Definition dialogs.h:163
void ok_pressed()
Definition dialogs.cpp:840
void leader_selected(int index)
Definition dialogs.cpp:825
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:695
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:1095
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:4793
void update_img()
Definition dialogs.cpp:4651
int show_line
Definition dialogs.h:233
void mouseMoveEvent(QMouseEvent *event)
Definition dialogs.cpp:4595
int highligh_num
Definition dialogs.h:234
void paint(QPainter *painter, QPaintEvent *event)
Definition dialogs.cpp:4660
void update_menu()
Definition dialogs.cpp:4751
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:4415
void update_units()
Definition dialogs.cpp:4761
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:4738
void create_pixmap()
Definition dialogs.cpp:4460
void wheelEvent(QWheelEvent *event)
Definition dialogs.cpp:4802
void keyPressEvent(QKeyEvent *event)
Definition dialogs.cpp:4826
void mousePressEvent(QMouseEvent *event)
Definition dialogs.cpp:4626
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:1258
char * incite_cost
Definition comments.c:75
void action_selection_no_longer_in_progress(const int old_actor_id)
Definition control.c:1051
void request_unit_load(struct unit *pcargo, struct unit *ptrans, struct tile *ptile)
Definition control.c:2156
void unit_focus_set(struct unit *punit)
Definition control.c:506
void request_do_action(action_id action, int actor_id, int target_id, int sub_tgt, const char *name)
Definition control.c:1730
void request_unit_disband(struct unit *punit)
Definition control.c:2075
void request_action_details(action_id action, int actor_id, int target_id)
Definition control.c:1798
void request_new_unit_activity_targeted(struct unit *punit, enum unit_activity act, struct extra_type *tgt)
Definition control.c:1938
void action_confirmation(struct act_confirmation_data *data, bool confirm)
Definition control.c:1766
void action_decision_clear_want(const int old_actor_id)
Definition control.c:1080
void key_unit_wait(void)
Definition control.c:3542
struct unit * head_of_units_in_focus(void)
Definition control.c:410
void request_unit_upgrade(struct unit *punit)
Definition control.c:2106
void action_selection_next_in_focus(const int old_actor_id)
Definition control.c:1092
bool qtg_handmade_scenario_warning()
Definition dialogs.cpp:4856
static void attack(QVariant data1, QVariant data2)
Definition dialogs.cpp:3009
static void wipe_units(QVariant data1, QVariant data2)
Definition dialogs.cpp:2730
char forced_tileset_name[512]
int action_selection_target_extra(void)
Definition dialogs.cpp:4154
static void destroy_city(QVariant data1, QVariant data2)
Definition dialogs.cpp:3386
static void spy_sabotage_unit(QVariant data1, QVariant data2)
Definition dialogs.cpp:2450
static void pillage(QVariant data1, QVariant data2)
Definition dialogs.cpp:2870
static void caravan_marketplace(QVariant data1, QVariant data2)
Definition dialogs.cpp:1742
static void clean(QVariant data1, QVariant data2)
Definition dialogs.cpp:2890
static void spy_steal_shared(QVariant data1, QVariant data2, action_id act_id)
Definition dialogs.cpp:3144
static void spy_sabotage(QVariant data1, QVariant data2)
Definition dialogs.cpp:3777
int action_selection_target_tile(void)
Definition dialogs.cpp:4137
static void spy_investigate(QVariant data1, QVariant data2)
Definition dialogs.cpp:3506
static void act_sel_wait(QVariant data1, QVariant data2)
Definition dialogs.cpp:1911
static void nuke_units(QVariant data1, QVariant data2)
Definition dialogs.cpp:2718
int action_selection_actor_unit(void)
Definition dialogs.cpp:4103
static void capture_units(QVariant data1, QVariant data2)
Definition dialogs.cpp:2742
static void road(QVariant data1, QVariant data2)
Definition dialogs.cpp:2910
static bool is_race_dialog_open
Definition dialogs.cpp:189
static void transport_embark4(QVariant data1, QVariant data2)
Definition dialogs.cpp:2562
bool try_default_unit_action(QVariant q1, QVariant q2)
Definition dialogs.cpp:1553
static void fortify(QVariant data1, QVariant data2)
Definition dialogs.cpp:2392
static void transport_board(QVariant data1, QVariant data2)
Definition dialogs.cpp:2496
static void spy_sabotage_unit_esc(QVariant data1, QVariant data2)
Definition dialogs.cpp:2462
static void disband_unit(QVariant data1, QVariant data2)
Definition dialogs.cpp:2380
static void spy_steal_gold(QVariant data1, QVariant data2)
Definition dialogs.cpp:3401
void popdown_players_report()
Definition plrdlg.cpp:1193
static void spy_escape(QVariant data1, QVariant data2)
Definition dialogs.cpp:3461
static void mine(QVariant data1, QVariant data2)
Definition dialogs.cpp:2952
void popup_musicset_suggestion_dialog(void)
Definition dialogs.cpp:4014
static void spy_steal_gold_esc(QVariant data1, QVariant data2)
Definition dialogs.cpp:3416
static void diplomat_embassy(QVariant data1, QVariant data2)
Definition dialogs.cpp:3491
void unit_select_dialog_popup(struct tile *ptile)
Definition dialogs.cpp:1253
void popup_upgrade_dialog(struct unit_list *punits)
Definition dialogs.cpp:4370
void update_nationset_combo()
Definition dialogs.cpp:1273
void action_selection_close(void)
Definition dialogs.cpp:4308
static void cultivate(QVariant data1, QVariant data2)
Definition dialogs.cpp:2840
static void paradrop_enter(QVariant data1, QVariant data2)
Definition dialogs.cpp:3099
void races_update_pickable(bool nationset_change)
Definition dialogs.cpp:1283
int action_selection_target_city(void)
Definition dialogs.cpp:4120
static void spy_steal_something(QVariant data1, QVariant data2)
Definition dialogs.cpp:3234
#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:1191
static void spy_poison(QVariant data1, QVariant data2)
Definition dialogs.cpp:3311
static void transport_board2(QVariant data1, QVariant data2)
Definition dialogs.cpp:2507
void show_tech_gained_dialog(Tech_type_id tech)
Definition dialogs.cpp:4322
static void base(QVariant data1, QVariant data2)
Definition dialogs.cpp:2931
static void spy_nuke_city_esc(QVariant data1, QVariant data2)
Definition dialogs.cpp:3356
void popup_soundset_suggestion_dialog(void)
Definition dialogs.cpp:3989
static void enter_hut2(QVariant data1, QVariant data2)
Definition dialogs.cpp:2673
void popup_races_dialog(struct player *pplayer)
Definition dialogs.cpp:1228
static void expel_unit(QVariant data1, QVariant data2)
Definition dialogs.cpp:2754
static void paradrop_frighten(QVariant data1, QVariant data2)
Definition dialogs.cpp:3069
static void diplomat_sabotage(QVariant data1, QVariant data2)
Definition dialogs.cpp:3536
void popup_disband_dialog(struct unit_list *punits)
Definition dialogs.cpp:3948
static action_id get_non_targeted_action_id(action_id tgt_action_id)
Definition dialogs.cpp:2275
static void homeless(QVariant data1, QVariant data2)
Definition dialogs.cpp:2418
static void caravan_help_build(QVariant data1, QVariant data2)
Definition dialogs.cpp:1772
void qtg_popup_image(const char *tag)
Definition dialogs.cpp:4967
static void bombard(QVariant data1, QVariant data2)
Definition dialogs.cpp:2766
void popdown_races_dialog(void)
Definition dialogs.cpp:1242
void popup_tileset_suggestion_dialog(void)
Definition dialogs.cpp:3958
static void conquer_city(QVariant data1, QVariant data2)
Definition dialogs.cpp:1853
void revolution_response(struct government *gov)
Definition dialogs.cpp:1926
void popdown_economy_report()
static void join_city(QVariant data1, QVariant data2)
Definition dialogs.cpp:3129
static void spy_request_sabotage_list(QVariant data1, QVariant data2)
Definition dialogs.cpp:3274
static void diplomat_bribe(QVariant data1, QVariant data2)
Definition dialogs.cpp:2432
static void popup_act_confirmation_dialog(QString hdr, QString body, struct act_confirmation_data *data)
Definition dialogs.cpp:4927
static void unit_disband_recover(QVariant data1, QVariant data2)
Definition dialogs.cpp:1787
static void spy_steal(QVariant data1, QVariant data2)
Definition dialogs.cpp:3218
static void airlift(QVariant data1, QVariant data2)
Definition dialogs.cpp:1838
void popup_pillage_dialog(struct unit *punit, bv_extras extras)
Definition dialogs.cpp:3869
void popup_sabotage_dialog(struct unit *actor, struct city *tcity, const struct action *paction)
Definition dialogs.cpp:3807
static void transport_load3(QVariant data1, QVariant data2)
Definition dialogs.cpp:2606
static void bombard_lethal(QVariant data1, QVariant data2)
Definition dialogs.cpp:2802
static void plant(QVariant data1, QVariant data2)
Definition dialogs.cpp:2855
static void nuke(QVariant data1, QVariant data2)
Definition dialogs.cpp:2994
static void disembark2(QVariant data1, QVariant data2)
Definition dialogs.cpp:2643
static void transport_unload(QVariant data1, QVariant data2)
Definition dialogs.cpp:2573
void qtg_request_action_confirmation(const char *expl, struct act_confirmation_data *data)
Definition dialogs.cpp:4949
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:4185
void popdown_science_report()
static void transport_load2(QVariant data1, QVariant data2)
Definition dialogs.cpp:2595
static void diplomat_steal(QVariant data1, QVariant data2)
Definition dialogs.cpp:3566
static void unit_upgrade(QVariant data1, QVariant data2)
Definition dialogs.cpp:1817
bool popup_theme_suggestion_dialog(const char *theme_name)
Definition dialogs.cpp:4039
static void enter_hut(QVariant data1, QVariant data2)
Definition dialogs.cpp:2658
static void spy_request_strike_bld_list(QVariant data1, QVariant data2)
Definition dialogs.cpp:3257
static void diplomat_incite_escape(QVariant data1, QVariant data2)
Definition dialogs.cpp:3614
static void found_city(QVariant data1, QVariant data2)
Definition dialogs.cpp:2814
static void diplomat_investigate(QVariant data1, QVariant data2)
Definition dialogs.cpp:3521
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:4906
static void bombard3(QVariant data1, QVariant data2)
Definition dialogs.cpp:2790
static void transport_deboard(QVariant data1, QVariant data2)
Definition dialogs.cpp:2617
static void diplomat_incite(QVariant data1, QVariant data2)
Definition dialogs.cpp:3596
static void paradrop_conquer(QVariant data1, QVariant data2)
Definition dialogs.cpp:3054
void popdown_endgame_report()
static void diplomat_steal_esc(QVariant data1, QVariant data2)
Definition dialogs.cpp:3581
static bool is_more_user_input_needed
Definition dialogs.cpp:194
static void bombard2(QVariant data1, QVariant data2)
Definition dialogs.cpp:2778
void popup_incite_dialog(struct unit *actor, struct city *tcity, int cost, const struct action *paction)
Definition dialogs.cpp:3648
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:3371
void popup_connect_msg(const char *headline, const char *message)
Definition dialogs.cpp:1203
static void diplomat_sabotage_esc(QVariant data1, QVariant data2)
Definition dialogs.cpp:3551
void popdown_units_report()
static void transport_embark2(QVariant data1, QVariant data2)
Definition dialogs.cpp:2540
static void spy_nuke_city(QVariant data1, QVariant data2)
Definition dialogs.cpp:3341
void unit_select_dialog_update_real(void *unused)
Definition dialogs.cpp:1265
static void spy_steal_esc(QVariant data1, QVariant data2)
Definition dialogs.cpp:3226
static void paradrop(QVariant data1, QVariant data2)
Definition dialogs.cpp:3039
static void suicide_attack(QVariant data1, QVariant data2)
Definition dialogs.cpp:3024
void races_toggles_set_sensitive(void)
Definition dialogs.cpp:1294
static void transport_load(QVariant data1, QVariant data2)
Definition dialogs.cpp:2584
static action_id get_production_targeted_action_id(action_id tgt_action_id)
Definition dialogs.cpp:2298
static void paradrop_frighten_conquer(QVariant data1, QVariant data2)
Definition dialogs.cpp:3084
static void convert_unit(QVariant data1, QVariant data2)
Definition dialogs.cpp:2406
static bool did_not_decide
Definition dialogs.cpp:198
static void spy_poison_esc(QVariant data1, QVariant data2)
Definition dialogs.cpp:3326
static void pillage_something(QVariant data1, QVariant data2)
Definition dialogs.cpp:3757
static void spy_request_sabotage_esc_list(QVariant data1, QVariant data2)
Definition dialogs.cpp:3292
static void transform_terrain(QVariant data1, QVariant data2)
Definition dialogs.cpp:2825
#define BUTTON_CANCEL
Definition dialogs.cpp:72
static void conquer_extras(QVariant data1, QVariant data2)
Definition dialogs.cpp:1883
static void regular_move(QVariant data1, QVariant data2)
Definition dialogs.cpp:3632
static void heal_unit2(QVariant data1, QVariant data2)
Definition dialogs.cpp:2485
static void transport_board3(QVariant data1, QVariant data2)
Definition dialogs.cpp:2518
static void spy_embassy(QVariant data1, QVariant data2)
Definition dialogs.cpp:3476
static races_dialog * race_dialog
Definition dialogs.cpp:188
static void frighten_hut2(QVariant data1, QVariant data2)
Definition dialogs.cpp:2703
static void conquer_city2(QVariant data1, QVariant data2)
Definition dialogs.cpp:1868
static void conquer_extras2(QVariant data1, QVariant data2)
Definition dialogs.cpp:1897
static void frighten_hut(QVariant data1, QVariant data2)
Definition dialogs.cpp:2688
bool qtg_request_transport(struct unit *pcargo, struct tile *ptile)
Definition dialogs.cpp:4865
int action_selection_target_unit(void)
Definition dialogs.cpp:4171
static void irrigate(QVariant data1, QVariant data2)
Definition dialogs.cpp:2973
static void transport_embark3(QVariant data1, QVariant data2)
Definition dialogs.cpp:2551
static void heal_unit(QVariant data1, QVariant data2)
Definition dialogs.cpp:2474
void popdown_city_report()
Definition cityrep.cpp:1338
static void paradrop_enter_conquer(QVariant data1, QVariant data2)
Definition dialogs.cpp:3114
static void unit_home_city(QVariant data1, QVariant data2)
Definition dialogs.cpp:1802
static void transport_embark(QVariant data1, QVariant data2)
Definition dialogs.cpp:2529
bool try_default_city_action(QVariant q1, QVariant q2)
Definition dialogs.cpp:1571
static void keep_moving(QVariant data1, QVariant data2)
Definition dialogs.cpp:1919
static void spy_steal_maps_esc(QVariant data1, QVariant data2)
Definition dialogs.cpp:3446
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:2351
static void disembark1(QVariant data1, QVariant data2)
Definition dialogs.cpp:2628
void restart_notify_dialogs()
Definition dialogs.cpp:4048
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:2318
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:1757
void popdown_all_game_dialogs(void)
Definition dialogs.cpp:4064
static void spy_steal_maps(QVariant data1, QVariant data2)
Definition dialogs.cpp:3431
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:377
int action_id
Definition fc_types.h:389
int Government_type_id
Definition fc_types.h:381
#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:62
struct world wld
Definition game.c:63
struct unit * game_unit_by_number(int id)
Definition game.c:116
struct city * game_city_by_number(int id)
Definition game.c:107
struct government * government_by_number(const Government_type_id gov)
Definition government.c: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:5039
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:456
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:1015
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:4016
bool option_str_set(struct option *poption, const char *str)
Definition options.c:926
const char * option_str_get(const struct option *poption)
Definition options.c:893
struct option * optset_option_by_name(const struct option_set *poptset, const char *name)
Definition options.c:431
#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:2376
void set_government_choice(struct government *government)
Definition packhand.c:2363
char * lines
Definition packhand.c:131
int player_number(const struct player *pplayer)
Definition player.c:837
const char * research_advance_name_translation(const struct research *presearch, Tech_type_id tech)
Definition research.c:273
struct research * research_get(const struct player *pplayer)
Definition research.c:128
enum tech_state research_invention_state(const struct research *presearch, Tech_type_id tech)
Definition research.c:619
bool research_invention_gettable(const struct research *presearch, const Tech_type_id tech, bool allow_holes)
Definition research.c:693
const char * sex_name_translation(sex_t kind)
Definition sex.c:60
@ SEX_FEMALE
Definition sex.h:22
@ SEX_MALE
Definition sex.h:23
#define ARRAY_SIZE(x)
Definition shared.h:85
size_t size
Definition specvec.h:72
struct sprite int int y
Definition sprite_g.h:31
struct sprite int x
Definition sprite_g.h:31
struct sprite int int int int struct sprite int int float bool smooth get_sprite_dimensions
Definition sprite_g.h:36
QPixmap map_pixmap
Definition canvas.h:25
Definition city.h: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:82
struct universal item
Definition climisc.h:83
struct player * player
Definition nation.h:118
bool tech_steal_allow_holes
char preferred_soundset[MAX_LEN_NAME]
char preferred_tileset[MAX_LEN_NAME]
char preferred_musicset[MAX_LEN_NAME]
int revolution_finishes
Definition player.h:271
char name[MAX_LEN_NAME]
Definition player.h:249
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:517
Definition unit.h:138
int moves_left
Definition unit.h:150
struct unit::@81::@83 client
int id
Definition unit.h:145
int hp
Definition unit.h:151
int fuel
Definition unit.h:153
struct tile * tile
Definition unit.h:140
struct act_prob * act_prob_cache
Definition unit.h:228
int homecity
Definition unit.h:146
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:974
#define sz_strlcpy(dest, src)
Definition support.h:195
#define TRUE
Definition support.h:46
#define FALSE
Definition support.h:47
#define is_svg_flag_enabled()
Definition svgflag.h:30
#define advance_index_iterate_end
Definition tech.h:248
#define A_FIRST
Definition tech.h:44
#define A_UNSET
Definition tech.h:48
#define advance_index_iterate(_start, _index)
Definition tech.h:244
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:1257
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:1710
const char * act_sel_action_tool_tip(const struct action *paction, const struct act_prob prob)
Definition text.c:1789
struct city * tile_city(const struct tile *ptile)
Definition tile.c:83
#define tile_index(_pt_)
Definition tile.h:88
#define TILE_INDEX_NONE
Definition tile.h:48
int tileset_hex_width(const struct tileset *t)
Definition tilespec.c:721
int tileset_unit_width(const struct tileset *t)
Definition tilespec.c:797
int tileset_unit_height(const struct tileset *t)
Definition tilespec.c:805
struct sprite * load_popup_sprite(const char *tag)
Definition tilespec.c:7578
bool tileset_is_isometric(const struct tileset *t)
Definition tilespec.c:712
struct sprite * get_sample_city_sprite(const struct tileset *t, int style_idx)
Definition tilespec.c:6851
const char * tileset_basename(const struct tileset *t)
Definition tilespec.c:704
int tileset_hex_height(const struct tileset *t)
Definition tilespec.c:730
void unload_popup_sprite(const char *tag)
Definition tilespec.c:7586
struct sprite * get_nation_flag_sprite(const struct tileset *t, const struct nation_type *pnation)
Definition tilespec.c:6756
void tileset_error(enum log_level level, const char *tset_name, const char *format,...)
Definition tilespec.c:624
bool tilespec_reread(const char *new_tileset_name, bool game_fully_initialized, float scale)
Definition tilespec.c:1355
struct unit * transporter_for_unit_at(const struct unit *pcargo, const struct tile *ptile)
Definition unit.c:1922
bool could_unit_load(const struct unit *pcargo, const struct unit *ptrans)
Definition unit.c:700
bool unit_can_do_action(const struct unit *punit, const action_id act_id)
Definition unit.c:359
void unit_activity_astr(const struct unit *punit, struct astring *astr)
Definition unit.c:1155
#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:839