Freeciv-3.1
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 <QtMath>
35
36// utility
37#include "astring.h"
38
39// common
40#include "actions.h"
41#include "city.h"
42#include "game.h"
43#include "government.h"
44#include "improvement.h"
45#include "movement.h"
46#include "nation.h"
47#include "research.h"
48
49// client
50#include "audio.h"
51#include "chatline_common.h"
52#include "client_main.h"
53#include "control.h"
54#include "helpdata.h"
55#include "packhand.h"
56#include "text.h"
57#include "tilespec.h"
58
59// gui-qt
60#include "dialogs.h"
61#include "fc_client.h"
62#include "gui_main.h"
63#include "hudwidget.h"
64#include "qtg_cxxside.h"
65#include "sprite.h"
66
67/* Locations for non action enabler controlled buttons. */
68#define BUTTON_WAIT (ACTION_COUNT + 1)
69#define BUTTON_CANCEL (BUTTON_WAIT + 1)
70#define BUTTON_COUNT (BUTTON_CANCEL + 1)
71
73extern void popdown_players_report();
74extern void popdown_economy_report();
75extern void popdown_units_report();
76extern void popdown_science_report();
77extern void popdown_city_report();
78extern void popdown_endgame_report();
79
80static void spy_request_strike_bld_list(QVariant data1, QVariant data2);
81static void diplomat_incite(QVariant data1, QVariant data2);
82static void diplomat_incite_escape(QVariant data1, QVariant data2);
83static void spy_request_sabotage_list(QVariant data1, QVariant data2);
84static void spy_request_sabotage_esc_list(QVariant data1, QVariant data2);
85static void spy_sabotage(QVariant data1, QVariant data2);
86static void spy_steal(QVariant data1, QVariant data2);
87static void spy_steal_esc(QVariant data1, QVariant data2);
88static void spy_steal_something(QVariant data1, QVariant data2);
89static void diplomat_steal(QVariant data1, QVariant data2);
90static void diplomat_steal_esc(QVariant data1, QVariant data2);
91static void spy_poison(QVariant data1, QVariant data2);
92static void spy_poison_esc(QVariant data1, QVariant data2);
93static void spy_steal_gold(QVariant data1, QVariant data2);
94static void spy_steal_gold_esc(QVariant data1, QVariant data2);
95static void spy_steal_maps(QVariant data1, QVariant data2);
96static void spy_steal_maps_esc(QVariant data1, QVariant data2);
97static void spy_nuke_city(QVariant data1, QVariant data2);
98static void spy_nuke_city_esc(QVariant data1, QVariant data2);
99static void nuke_city(QVariant data1, QVariant data2);
100static void destroy_city(QVariant data1, QVariant data2);
101static void diplomat_embassy(QVariant data1, QVariant data2);
102static void spy_embassy(QVariant data1, QVariant data2);
103static void spy_sabotage_unit(QVariant data1, QVariant data2);
104static void spy_sabotage_unit_esc(QVariant data1, QVariant data2);
105static void spy_investigate(QVariant data1, QVariant data2);
106static void diplomat_investigate(QVariant data1, QVariant data2);
107static void diplomat_sabotage(QVariant data1, QVariant data2);
108static void diplomat_sabotage_esc(QVariant data1, QVariant data2);
109static void diplomat_bribe(QVariant data1, QVariant data2);
110static void caravan_marketplace(QVariant data1, QVariant data2);
111static void caravan_establish_trade(QVariant data1, QVariant data2);
112static void caravan_help_build(QVariant data1, QVariant data2);
113static void unit_disband_recover(QVariant data1, QVariant data2);
114static void capture_units(QVariant data1, QVariant data2);
115static void nuke_units(QVariant data1, QVariant data2);
116static void expel_unit(QVariant data1, QVariant data2);
117static void bombard(QVariant data1, QVariant data2);
118static void bombard2(QVariant data1, QVariant data2);
119static void bombard3(QVariant data1, QVariant data2);
120static void found_city(QVariant data1, QVariant data2);
121static void transform_terrain(QVariant data1, QVariant data2);
122static void cultivate(QVariant data1, QVariant data2);
123static void plant(QVariant data1, QVariant data2);
124static void pillage(QVariant data1, QVariant data2);
125static void clean_pollution(QVariant data1, QVariant data2);
126static void clean_fallout(QVariant data1, QVariant data2);
127static void road(QVariant data1, QVariant data2);
128static void base(QVariant data1, QVariant data2);
129static void mine(QVariant data1, QVariant data2);
130static void irrigate(QVariant data1, QVariant data2);
131static void nuke(QVariant data1, QVariant data2);
132static void attack(QVariant data1, QVariant data2);
133static void suicide_attack(QVariant data1, QVariant data2);
134static void paradrop(QVariant data1, QVariant data2);
135static void paradrop_conquer(QVariant data1, QVariant data2);
136static void paradrop_frighten(QVariant data1, QVariant data2);
137static void paradrop_frighten_conquer(QVariant data1, QVariant data2);
138static void paradrop_enter(QVariant data1, QVariant data2);
139static void paradrop_enter_conquer(QVariant data1, QVariant data2);
140static void disembark1(QVariant data1, QVariant data2);
141static void disembark2(QVariant data1, QVariant data2);
142static void enter_hut(QVariant data1, QVariant data2);
143static void enter_hut2(QVariant data1, QVariant data2);
144static void frighten_hut(QVariant data1, QVariant data2);
145static void frighten_hut2(QVariant data1, QVariant data2);
146static void regular_move(QVariant data1, QVariant data2);
147static void convert_unit(QVariant data1, QVariant data2);
148static void fortify(QVariant data1, QVariant data2);
149static void disband_unit(QVariant data1, QVariant data2);
150static void homeless(QVariant data1, QVariant data2);
151static void join_city(QVariant data1, QVariant data2);
152static void unit_home_city(QVariant data1, QVariant data2);
153static void unit_upgrade(QVariant data1, QVariant data2);
154static void airlift(QVariant data1, QVariant data2);
155static void conquer_city(QVariant data1, QVariant data2);
156static void conquer_city2(QVariant data1, QVariant data2);
157static void conquer_extras(QVariant data1, QVariant data2);
158static void conquer_extras2(QVariant data1, QVariant data2);
159static void heal_unit(QVariant data1, QVariant data2);
160static void heal_unit2(QVariant data1, QVariant data2);
161static void transport_board(QVariant data1, QVariant data2);
162static void transport_embark(QVariant data1, QVariant data2);
163static void transport_embark2(QVariant data1, QVariant data2);
164static void transport_embark3(QVariant data1, QVariant data2);
165static void transport_alight(QVariant data1, QVariant data2);
166static void transport_unload(QVariant data1, QVariant data2);
167static void keep_moving(QVariant data1, QVariant data2);
168static void pillage_something(QVariant data1, QVariant data2);
169static void action_entry(choice_dialog *cd,
170 action_id act,
171 const struct act_prob *act_probs,
172 const char *custom,
173 QVariant data1, QVariant data2);
174
175
176static bool is_showing_pillage_dialog = false;
178static bool is_race_dialog_open = false;
179
180/* Information used in action selection follow up questions. Can't be
181 * stored in the action selection dialog since it is closed before the
182 * follow up question is asked. */
184
185/* Don't remove a unit's action decision want or move on to the next actor
186 unit that wants a decision in the current unit selection. */
187static bool did_not_decide = false;
188
189extern char forced_tileset_name[512];
191
192/***********************************************************************/
196static const QHash<action_id, pfcn_void> af_map_init(void)
197{
198 QHash<action_id, pfcn_void> action_function;
199
200 /* Unit acting against a city target. */
201 action_function[ACTION_ESTABLISH_EMBASSY] = spy_embassy;
202 action_function[ACTION_ESTABLISH_EMBASSY_STAY] = diplomat_embassy;
203 action_function[ACTION_SPY_INVESTIGATE_CITY] = spy_investigate;
204 action_function[ACTION_INV_CITY_SPEND] = diplomat_investigate;
205 action_function[ACTION_SPY_POISON] = spy_poison;
206 action_function[ACTION_SPY_POISON_ESC] = spy_poison_esc;
207 action_function[ACTION_SPY_STEAL_GOLD] = spy_steal_gold;
208 action_function[ACTION_SPY_STEAL_GOLD_ESC] = spy_steal_gold_esc;
209 action_function[ACTION_SPY_SABOTAGE_CITY] = diplomat_sabotage;
210 action_function[ACTION_SPY_SABOTAGE_CITY_ESC] = diplomat_sabotage_esc;
211 action_function[ACTION_SPY_TARGETED_SABOTAGE_CITY] =
213 action_function[ACTION_SPY_TARGETED_SABOTAGE_CITY_ESC] =
215 action_function[ACTION_SPY_STEAL_TECH] = diplomat_steal;
216 action_function[ACTION_SPY_STEAL_TECH_ESC] = diplomat_steal_esc;
217 action_function[ACTION_SPY_TARGETED_STEAL_TECH] = spy_steal;
218 action_function[ACTION_SPY_TARGETED_STEAL_TECH_ESC] = spy_steal_esc;
219 action_function[ACTION_SPY_INCITE_CITY] = diplomat_incite;
220 action_function[ACTION_SPY_INCITE_CITY_ESC] = diplomat_incite_escape;
221 action_function[ACTION_TRADE_ROUTE] = caravan_establish_trade;
222 action_function[ACTION_MARKETPLACE] = caravan_marketplace;
223 action_function[ACTION_HELP_WONDER] = caravan_help_build;
224 action_function[ACTION_JOIN_CITY] = join_city;
225 action_function[ACTION_STEAL_MAPS] = spy_steal_maps;
226 action_function[ACTION_STEAL_MAPS_ESC] = spy_steal_maps_esc;
227 action_function[ACTION_SPY_NUKE] = spy_nuke_city;
228 action_function[ACTION_SPY_NUKE_ESC] = spy_nuke_city_esc;
229 action_function[ACTION_DESTROY_CITY] = destroy_city;
230 action_function[ACTION_DISBAND_UNIT_RECOVER] = unit_disband_recover;
231 action_function[ACTION_HOME_CITY] = unit_home_city;
232 action_function[ACTION_UPGRADE_UNIT] = unit_upgrade;
233 action_function[ACTION_AIRLIFT] = airlift;
234 action_function[ACTION_CONQUER_CITY] = conquer_city;
235 action_function[ACTION_CONQUER_CITY2] = conquer_city2;
236 action_function[ACTION_STRIKE_BUILDING] = spy_request_strike_bld_list;
237 action_function[ACTION_NUKE_CITY] = nuke_city;
238
239 /* Unit acting against a unit target. */
240 action_function[ACTION_SPY_BRIBE_UNIT] = diplomat_bribe;
241 action_function[ACTION_SPY_SABOTAGE_UNIT] = spy_sabotage_unit;
242 action_function[ACTION_SPY_SABOTAGE_UNIT_ESC] = spy_sabotage_unit_esc;
243 action_function[ACTION_EXPEL_UNIT] = expel_unit;
244 action_function[ACTION_HEAL_UNIT] = heal_unit;
245 action_function[ACTION_HEAL_UNIT2] = heal_unit2;
246 action_function[ACTION_TRANSPORT_ALIGHT] = transport_alight;
247 action_function[ACTION_TRANSPORT_UNLOAD] = transport_unload;
248 action_function[ACTION_TRANSPORT_BOARD] = transport_board;
249 action_function[ACTION_TRANSPORT_EMBARK] = transport_embark;
250 action_function[ACTION_TRANSPORT_EMBARK2] = transport_embark2;
251 action_function[ACTION_TRANSPORT_EMBARK3] = transport_embark3;
252
253 /* Unit acting against all units at a tile. */
254 action_function[ACTION_CAPTURE_UNITS] = capture_units;
255 action_function[ACTION_BOMBARD] = bombard;
256 action_function[ACTION_BOMBARD2] = bombard2;
257 action_function[ACTION_BOMBARD3] = bombard3;
258 action_function[ACTION_NUKE_UNITS] = nuke_units;
259
260 /* Unit acting against a tile. */
261 action_function[ACTION_FOUND_CITY] = found_city;
262 action_function[ACTION_NUKE] = nuke;
263 action_function[ACTION_PARADROP] = paradrop;
264 action_function[ACTION_PARADROP_CONQUER] = paradrop_conquer;
265 action_function[ACTION_PARADROP_ENTER] = paradrop_enter;
266 action_function[ACTION_PARADROP_ENTER_CONQUER] = paradrop_enter_conquer;
267 action_function[ACTION_PARADROP_FRIGHTEN] = paradrop_frighten;
268 action_function[ACTION_PARADROP_FRIGHTEN_CONQUER]
270 action_function[ACTION_ATTACK] = attack;
271 action_function[ACTION_SUICIDE_ATTACK] = suicide_attack;
272 action_function[ACTION_TRANSFORM_TERRAIN] = transform_terrain;
273 action_function[ACTION_CULTIVATE] = cultivate;
274 action_function[ACTION_PLANT] = plant;
275 action_function[ACTION_PILLAGE] = pillage;
276 action_function[ACTION_CLEAN_POLLUTION] = clean_pollution;
277 action_function[ACTION_CLEAN_FALLOUT] = clean_fallout;
278 action_function[ACTION_ROAD] = road;
279 action_function[ACTION_BASE] = base;
280 action_function[ACTION_MINE] = mine;
281 action_function[ACTION_IRRIGATE] = irrigate;
282 action_function[ACTION_TRANSPORT_DISEMBARK1] = disembark1;
283 action_function[ACTION_TRANSPORT_DISEMBARK2] = disembark2;
284 action_function[ACTION_HUT_ENTER] = enter_hut;
285 action_function[ACTION_HUT_ENTER2] = enter_hut2;
286 action_function[ACTION_HUT_FRIGHTEN] = frighten_hut;
287 action_function[ACTION_HUT_FRIGHTEN2] = frighten_hut2;
288 action_function[ACTION_UNIT_MOVE] = regular_move;
289
290 /* Unit acting against all tile extras. */
291 action_function[ACTION_CONQUER_EXTRAS] = conquer_extras;
292 action_function[ACTION_CONQUER_EXTRAS2] = conquer_extras2;
293
294 /* Unit acting with no target except itself. */
295 action_function[ACTION_DISBAND_UNIT] = disband_unit;
296 action_function[ACTION_FORTIFY] = fortify;
297 action_function[ACTION_CONVERT] = convert_unit;
298 action_function[ACTION_HOMELESS] = homeless;
299
300 return action_function;
301}
302
303/* Mapping from an action to the function to call when its button is
304 * pushed. */
305static const QHash<action_id, pfcn_void> af_map = af_map_init();
306
307/***********************************************************************/
310qfc_dialog::qfc_dialog(QWidget* parent) : QDialog(parent,
311 Qt::FramelessWindowHint)
312{
313 titlebar_height = 0;
314 moving_now = false;
315 setSizeGripEnabled(true);
317}
318
319/***********************************************************************/
323{
324 raise();
325}
326
327/***********************************************************************/
331{
332 Q_UNUSED(event)
333
334 QPainter p(this);
335 QStyleOptionTitleBar tbar_opt;
336 QStyleOption win_opt;
337 QStyle *style = this->style();
338 QRect active_area = this->rect();
339 QPalette qpal;
340 QRect close_rect, text_rect;
341
342 qpal.setColor(QPalette::Active, QPalette::ToolTipText, Qt::white);
343 tbar_opt.initFrom(this);
344 titlebar_height = style->pixelMetric(QStyle::PM_TitleBarHeight,
345 &tbar_opt, this) + 2;
346 close_pix = close_pix.scaledToHeight(titlebar_height);
347 tbar_opt.rect = QRect(0, 0, this->width(), titlebar_height);
348 text_rect = QRect(0, 0, this->width() - close_pix.width() , titlebar_height);
349 close_rect = QRect(this->width() - close_pix.width(), 0, this->width(),
351 tbar_opt.titleBarState = this->windowState();
352 tbar_opt.text = tbar_opt.fontMetrics.elidedText(this->windowTitle(),
353 Qt::ElideRight,
354 text_rect.width());
355 style->drawComplexControl(QStyle::CC_TitleBar, &tbar_opt, &p, this);
356 style->drawItemText(&p, text_rect, Qt::AlignCenter, qpal,
357 true, tbar_opt.text, QPalette::ToolTipText);
358 style->drawItemPixmap(&p, close_rect, Qt::AlignLeft,
359 close_pix.scaledToHeight(titlebar_height));
360
361 active_area.setTopLeft(QPoint(0, titlebar_height));
362 this->setContentsMargins(0, titlebar_height, 0, 0);
363 win_opt.initFrom(this);
364 win_opt.rect = active_area;
365 style->drawPrimitive(QStyle::PE_Widget, &win_opt, &p, this);
366}
367
368/***********************************************************************/
372{
373 if (moving_now) {
374 move(event->globalPos() - point);
375 }
376}
377
378/***********************************************************************/
382{
383 QPoint pos = event->pos();
384 int x = pos.x();
385 int y = pos.y();
386
387 if (y <= titlebar_height
388 && x <= width() - close_pix.width()) {
389 point = event->globalPos() - geometry().topLeft();
390 moving_now = true;
391 setCursor(Qt::SizeAllCursor);
392 } else if (y <= titlebar_height
393 && x > width() - close_pix.width()) {
394 close();
395 }
396}
397
398/***********************************************************************/
402{
403 moving_now = false;
404 setCursor(Qt::ArrowCursor);
405}
406
407/***********************************************************************/
411 QWidget *parent) : qfc_dialog(parent)
412{
413 int i;
414 QGridLayout *qgroupbox_layout;
415 QGroupBox *no_name;
416 QTableWidgetItem *item;
417 QPixmap *pix;
418 QHeaderView *header;
419 QSize size;
420 QString title;
421 QLabel *ns_label;
422
423 setAttribute(Qt::WA_DeleteOnClose);
424 is_race_dialog_open = true;
425 main_layout = new QGridLayout;
426 selected_nation_tabs = new QTableWidget;
427 nation_tabs = new QTableWidget();
428 styles = new QTableWidget;
429 ok_button = new QPushButton;
430 qnation_set = new QComboBox;
431 ns_label = new QLabel;
432 tplayer = pplayer;
433
434 selected_nation = -1;
435 selected_style = -1;
436 setWindowTitle(_("Select Nation"));
437 selected_nation_tabs->setRowCount(0);
438 selected_nation_tabs->setColumnCount(1);
439 selected_nation_tabs->setSelectionMode(QAbstractItemView::SingleSelection);
440 selected_nation_tabs->verticalHeader()->setVisible(false);
441 selected_nation_tabs->horizontalHeader()->setVisible(false);
442 selected_nation_tabs->setProperty("showGrid", "true");
443 selected_nation_tabs->setEditTriggers(QAbstractItemView::NoEditTriggers);
444 selected_nation_tabs->setShowGrid(false);
445 selected_nation_tabs->setAlternatingRowColors(true);
446
447 nation_tabs->setRowCount(0);
448 nation_tabs->setColumnCount(1);
449 nation_tabs->setSelectionMode(QAbstractItemView::SingleSelection);
450 nation_tabs->verticalHeader()->setVisible(false);
451 nation_tabs->horizontalHeader()->setVisible(false);
452 nation_tabs->setProperty("showGrid", "true");
453 nation_tabs->setEditTriggers(QAbstractItemView::NoEditTriggers);
454 nation_tabs->setShowGrid(false);
455 ns_label->setText(_("Nation Set:"));
456 styles->setRowCount(0);
457 styles->setColumnCount(2);
458 styles->setSelectionMode(QAbstractItemView::SingleSelection);
459 styles->verticalHeader()->setVisible(false);
460 styles->horizontalHeader()->setVisible(false);
461 styles->setProperty("showGrid", "false");
462 styles->setProperty("selectionBehavior", "SelectRows");
463 styles->setEditTriggers(QAbstractItemView::NoEditTriggers);
464 styles->setShowGrid(false);
465
466 qgroupbox_layout = new QGridLayout;
467 no_name = new QGroupBox(parent);
468 leader_name = new QComboBox(no_name);
469 sex_buttons = new QButtonGroup(no_name);
470 is_male = new QRadioButton(no_name);
471 sex_buttons->addButton(is_male, 1);
472 is_female = new QRadioButton(no_name);
473 sex_buttons->addButton(is_female, 0);
474
475 leader_name->setEditable(true);
476 qgroupbox_layout->addWidget(leader_name, 1, 0, 1, 2);
477 qgroupbox_layout->addWidget(is_male, 2, 1);
478 qgroupbox_layout->addWidget(is_female, 2, 0);
479 is_female->setText(_("Female"));
480 is_male->setText(_("Male"));
481 no_name->setLayout(qgroupbox_layout);
482
483 description = new QTextEdit;
484 description->setReadOnly(true);
485 description->setPlainText(_("Choose nation"));
486 no_name->setTitle(_("Your leader name"));
487
492 styles_iterate(pstyle) {
493 i = basic_city_style_for_style(pstyle);
494
495 if (i >= 0) {
496 item = new QTableWidgetItem;
497 styles->insertRow(i);
499 item->setData(Qt::DecorationRole, *pix);
500 item->setData(Qt::UserRole, style_number(pstyle));
501 size.setWidth(pix->width());
502 size.setHeight(pix->height());
503 item->setSizeHint(size);
504 styles->setItem(i, 0, item);
505 item = new QTableWidgetItem;
506 item->setText(style_name_translation(pstyle));
507 styles->setItem(i, 1, item);
508 }
510
511 header = styles->horizontalHeader();
512 header->setSectionResizeMode(QHeaderView::Stretch);
513 header->resizeSections(QHeaderView::ResizeToContents);
514 header = styles->verticalHeader();
515 header->resizeSections(QHeaderView::ResizeToContents);
516 nation_sets_iterate(pset) {
520 /* create nation sets */
521 refresh();
522
523 connect(styles->selectionModel(),
524 SIGNAL(selectionChanged(const QItemSelection &,
525 const QItemSelection &)),
526 SLOT(style_selected(const QItemSelection &,
527 const QItemSelection &)));
528 connect(selected_nation_tabs->selectionModel(),
529 SIGNAL(selectionChanged(const QItemSelection &,
530 const QItemSelection &)),
531 SLOT(nation_selected(const QItemSelection &,
532 const QItemSelection &)));
533 connect(leader_name, SIGNAL(currentIndexChanged(int)),
534 SLOT(leader_selected(int)));
535 connect(leader_name->lineEdit(), &QLineEdit::returnPressed,
537 connect(qnation_set, SIGNAL(currentIndexChanged(int)),
538 SLOT(nationset_changed(int)));
539 connect(nation_tabs->selectionModel(),
540 SIGNAL(selectionChanged(const QItemSelection &,
541 const QItemSelection &)),
542 SLOT(group_selected(const QItemSelection &,
543 const QItemSelection &)));
544
545 ok_button = new QPushButton;
546 ok_button->setText(_("Cancel"));
547 connect(ok_button, &QAbstractButton::pressed, this, &races_dialog::cancel_pressed);
548 main_layout->addWidget(ok_button, 8, 2, 1, 1);
549 random_button = new QPushButton;
550 random_button->setText(_("Random"));
551 connect(random_button, &QAbstractButton::pressed, this, &races_dialog::random_pressed);
552 main_layout->addWidget(random_button, 8, 0, 1, 1);
553 ok_button = new QPushButton;
554 ok_button->setText(_("Ok"));
555 connect(ok_button, &QAbstractButton::pressed, this, &races_dialog::ok_pressed);
556 main_layout->addWidget(ok_button, 8, 3, 1, 1);
557 main_layout->addWidget(no_name, 0, 3, 2, 1);
558 if (nation_set_count() > 1) {
559 main_layout->addWidget(ns_label, 0, 0, 1, 1);
560 main_layout->addWidget(qnation_set, 0, 1, 1, 1);
561 main_layout->addWidget(nation_tabs, 1, 0, 5, 2);
562 } else {
563 main_layout->addWidget(nation_tabs, 0, 0, 6, 2);
564 }
565 main_layout->addWidget(styles, 2, 3, 4, 1);
566 main_layout->addWidget(description, 6, 0, 2, 4);
567 main_layout->addWidget(selected_nation_tabs, 0, 2, 6, 1);
568
569 setLayout(main_layout);
570 set_index(-99);
571
572 if (C_S_RUNNING == client_state()) {
573 title = _("Edit Nation");
574 } else if (NULL != pplayer && pplayer == client.conn.playing) {
575 title = _("What Nation Will You Be?");
576 } else {
577 title = _("Pick Nation");
578 }
579
581 setWindowTitle(title);
582}
583
584/***********************************************************************/
591
592/***********************************************************************/
596{
597 struct nation_group *group;
598 QTableWidgetItem *item;
599 QHeaderView *header;
600 int i;
601 int count;
602
603 nation_tabs->clearContents();
604 nation_tabs->setRowCount(0);
605 nation_tabs->insertRow(0);
606 item = new QTableWidgetItem;
607 item->setText(_("All nations"));
608 item->setData(Qt::UserRole, -99);
609 nation_tabs->setItem(0, 0, item);
610
611 for (i = 1; i < nation_group_count() + 1; i++) {
612 group = nation_group_by_number(i - 1);
613 if (is_nation_group_hidden(group)) {
614 continue;
615 }
616 count = 0;
617 /* checking if group is empty */
618 nations_iterate(pnation) {
619 if (!is_nation_playable(pnation)
620 || !is_nation_pickable(pnation)
621 || !nation_is_in_group(pnation, group)) {
622 continue;
623 }
624 count ++;
626 if (count == 0) {
627 continue;
628 }
629 nation_tabs->insertRow(i);
630 item = new QTableWidgetItem;
631 item->setData(Qt::UserRole, i - 1);
632 item->setText(nation_group_name_translation(group));
633 nation_tabs->setItem(i, 0, item);
634 }
635 header = nation_tabs->horizontalHeader();
636 header->resizeSections(QHeaderView::Stretch);
637 header = nation_tabs->verticalHeader();
638 header->resizeSections(QHeaderView::ResizeToContents);
639 set_index(-99);
640}
641
642/***********************************************************************/
646{
647 struct option *popt;
648 struct nation_set *s;
649
650 popt = optset_option_by_name(server_optset, "nationset");
651 if (popt) {
653 qnation_set->setCurrentIndex(nation_set_index(s));
654 qnation_set->setToolTip(_(nation_set_description(s)));
655 }
656}
657
658/***********************************************************************/
661void races_dialog::group_selected(const QItemSelection &sl,
662 const QItemSelection &ds)
663{
664 QModelIndexList indexes = sl.indexes();
665 QModelIndex index ;
666
667 if (indexes.isEmpty()) {
668 return;
669 }
670 index = indexes.at(0);
671 set_index(index.row());
672}
673
674
675/***********************************************************************/
680{
681 QTableWidgetItem *item;
682 QPixmap *pix;
683 QFont f;
684 struct nation_group *group;
685 int i;
686 struct sprite *s;
687 QHeaderView *header;
688 selected_nation_tabs->clearContents();
689 selected_nation_tabs->setRowCount(0);
690
691 last_index = 0;
692 i = nation_tabs->currentRow();
693 if (i != -1) {
694 item = nation_tabs->item(i, 0);
695 index = item->data(Qt::UserRole).toInt();
696 }
697
698 group = nation_group_by_number(index);
699 i = 0;
700 nations_iterate(pnation) {
701 if (!is_nation_playable(pnation)
702 || !is_nation_pickable(pnation)) {
703 continue;
704 }
705 if (!nation_is_in_group(pnation, group) && index != -99) {
706 continue;
707 }
708 item = new QTableWidgetItem;
709 selected_nation_tabs->insertRow(i);
710 s = get_nation_flag_sprite(tileset, pnation);
711 if (pnation->player) {
712 f = item->font();
713 f.setStrikeOut(true);
714 item->setFont(f);
715 }
716 pix = s->pm;
717 item->setData(Qt::DecorationRole, *pix);
718 item->setData(Qt::UserRole, nation_number(pnation));
719 item->setText(nation_adjective_translation(pnation));
720 selected_nation_tabs->setItem(i, 0, item);
722
723 selected_nation_tabs->sortByColumn(0, Qt::AscendingOrder);
724 header = selected_nation_tabs->horizontalHeader();
725 header->resizeSections(QHeaderView::Stretch);
726 header = selected_nation_tabs->verticalHeader();
727 header->resizeSections(QHeaderView::ResizeToContents);
728}
729
730/***********************************************************************/
733void races_dialog::nation_selected(const QItemSelection &selected,
734 const QItemSelection &deselcted)
735{
736 char buf[4096];
737 QModelIndex index ;
738 QVariant qvar;
739 QModelIndexList indexes = selected.indexes();
740 QString str;
741 QTableWidgetItem *item;
742 int style, ind;
743
744 if (indexes.isEmpty()) {
745 return;
746 }
747
748 index = indexes.at(0);
749 if (indexes.isEmpty()) {
750 return;
751 }
752 qvar = index.data(Qt::UserRole);
753 selected_nation = qvar.toInt();
754
755 helptext_nation(buf, sizeof(buf), nation_by_number(selected_nation), NULL);
756 description->setPlainText(buf);
757 leader_name->clear();
758 if (client.conn.playing == tplayer) {
759 leader_name->addItem(client.conn.playing->name, true);
760 }
762 (selected_nation)), pleader) {
763 str = QString::fromUtf8(nation_leader_name(pleader));
764 leader_name->addItem(str, nation_leader_is_male(pleader));
766
772 qvar = qvar.fromValue<int>(style);
773
774 for (ind = 0; ind < styles->rowCount(); ind++) {
775 item = styles->item(ind, 0);
776
777 if (item->data(Qt::UserRole) == qvar) {
778 styles->selectRow(ind);
779 }
780 }
781}
782
783/***********************************************************************/
786void races_dialog::style_selected(const QItemSelection &selected,
787 const QItemSelection &deselcted)
788{
789 QModelIndex index ;
790 QVariant qvar;
791 QModelIndexList indexes = selected.indexes();
792
793 if (indexes.isEmpty()) {
794 return;
795 }
796
797 index = indexes.at(0);
798 qvar = index.data(Qt::UserRole);
799 selected_style = qvar.toInt();
800}
801
802/***********************************************************************/
806{
807 if (leader_name->itemData(index).toBool()) {
808 is_male->setChecked(true);
809 is_female->setChecked(false);
810 } else {
811 is_male->setChecked(false);
812 is_female->setChecked(true);
813 }
814}
815
816/***********************************************************************/
821{
822 QByteArray ln_bytes;
823 struct player *natplr;
824
825 if (selected_nation == -1) {
826 return;
827 }
828
829 if (selected_style == -1) {
830 output_window_append(ftc_client, _("You must select your style."));
831 return;
832 }
833
834 if (leader_name->currentText().length() == 0) {
835 output_window_append(ftc_client, _("You must type a legal name."));
836 return;
837 }
838
840 if (natplr != NULL && natplr != client_player()) {
842 _("Nation has been chosen by other player"));
843 return;
844 }
845
846 ln_bytes = leader_name->currentText().toUtf8();
848 selected_nation, sex_buttons->checkedId(),
849 ln_bytes.data(),
851 close();
852 deleteLater();
853}
854
855/***********************************************************************/
859 const char *lines, QWidget *parent)
860 : fcwidget()
861{
862 int x, y;
863 QString qlines;
864
865 setAttribute(Qt::WA_DeleteOnClose);
866 setCursor(Qt::ArrowCursor);
867 setParent(parent);
868 setFrameStyle(QFrame::Box);
869 cw = new close_widget(this);
870 cw->put_to_corner();
871
872 qcaption = QString(caption);
873 qheadline = QString(headline);
874 qlines = QString(lines);
875 qlist = qlines.split("\n");
876 small_font = *fc_font::instance()->get_font("gui_qt_font_notify_label");
877 x = 0;
878 y = 0;
879 calc_size(x, y);
880 resize(x, y);
881 gui()->mapview_wdg->find_place(gui()->mapview_wdg->width() - x - 4, 4,
882 x, y, x, y, 0);
883 move(x, y);
884 was_destroyed = false;
885
886}
887
888/***********************************************************************/
892{
893 QString s, q;
894 int i;
895 QByteArray capt_bytes;
896 QByteArray hl_bytes;
897 QByteArray qb_bytes;
898
899 for (i = 0; i < qlist.size(); ++i) {
900 s = qlist.at(i);
901 q = q + s;
902 if (i < qlist.size() - 1) {
903 q = q + QChar('\n');
904 }
905 }
906 capt_bytes = qcaption.toUtf8();
907 hl_bytes = qheadline.toUtf8();
908 qb_bytes = q.toUtf8();
909 popup_notify_dialog(capt_bytes.data(),
910 hl_bytes.data(),
911 qb_bytes.data());
912 close();
913 destroy();
914}
915
916/***********************************************************************/
919void notify_dialog::calc_size(int &x, int &y)
920{
921 QFontMetrics fm(small_font);
922 int i;
923 QStringList str_list;
924
925 str_list = qlist;
926 str_list << qcaption << qheadline;
927
928 for (i = 0; i < str_list.count(); i++) {
929 x = qMax(x, fm.horizontalAdvance(str_list.at(i)));
930 y = y + 3 + fm.height();
931 }
932 x = x + 15;
933}
934
935/***********************************************************************/
938void notify_dialog::paintEvent(QPaintEvent * paint_event)
939{
940 QPainter painter(this);
941 QPainterPath path;
942 QPen pen;
943 QFontMetrics fm(small_font);
944 int i;
945
946 pen.setWidth(1);
947 pen.setColor(palette().color(QPalette::Text));
948 painter.setFont(small_font);
949 painter.setPen(pen);
950 painter.drawText(10, fm.height() + 3, qcaption);
951 painter.drawText(10, 2 * fm.height() + 6, qheadline);
952 for (i = 0; i < qlist.count(); i++) {
953 painter.drawText(10, 3 + (fm.height() + 3) * (i + 3), qlist[i]);
954 }
955 cw->put_to_corner();
956}
957
958/***********************************************************************/
962{
963 cursor = event->globalPos() - geometry().topLeft();
964 if (event->button() == Qt::RightButton) {
965 was_destroyed = true;
966 close();
967 }
968}
969
970/***********************************************************************/
974{
975 move(event->globalPos() - cursor);
976 setCursor(Qt::SizeAllCursor);
977}
978
979/***********************************************************************/
983{
984 setCursor(Qt::ArrowCursor);
985}
986
987/***********************************************************************/
991{
992 was_destroyed = true;
993 destroy();
994}
995
996/***********************************************************************/
1002{
1003 was_destroyed = true;
1004 destroy();
1005}
1006
1007/***********************************************************************/
1011{
1012 vs_city = -1;
1013 vs_unit = -1;
1014}
1015
1016/***********************************************************************/
1020{
1021 if (!m_instance) {
1022 m_instance = new qdef_act;
1023 }
1024 return m_instance;
1025}
1026
1027/***********************************************************************/
1031{
1032 if (m_instance) {
1033 delete m_instance;
1034 m_instance = 0;
1035 }
1036}
1037
1038/***********************************************************************/
1042{
1043 vs_city = i;
1044}
1045
1046/***********************************************************************/
1050{
1051 vs_unit = i;
1052}
1053
1054/***********************************************************************/
1058{
1059 return vs_city;
1060}
1061
1062/***********************************************************************/
1066{
1067 return vs_unit;
1068}
1069
1070/***********************************************************************/
1074{
1075 delete this;
1076}
1077
1078/***********************************************************************/
1082{
1084 false, "", 0);
1085 delete this;
1086}
1087
1088/***********************************************************************/
1091notify_goto::notify_goto(const char *headline, const char *lines,
1092 const struct text_tag_list *tags, tile *ptile,
1093 QWidget *parent): QMessageBox(parent)
1094{
1095 QString qlines;
1096 setAttribute(Qt::WA_DeleteOnClose);
1097 goto_but = this->addButton(_("Goto Location"), QMessageBox::ActionRole);
1098 goto_but->setIcon(fc_icons::instance()->get_icon("go-up"));
1099 inspect_but = this->addButton(_("Inspect City"), QMessageBox::ActionRole);
1100 inspect_but->setIcon(fc_icons::instance()->get_icon("plus"));
1101
1102 close_but = this->addButton(QMessageBox::Close);
1103 gtile = ptile;
1104 if (!gtile) {
1105 goto_but->setVisible(false);
1106 inspect_but->setVisible(false);
1107 } else {
1108 struct city *pcity = tile_city(gtile);
1109 inspect_but->setVisible(NULL != pcity
1110 && city_owner(pcity) == client.conn.playing);
1111 }
1112 setWindowTitle(headline);
1113 qlines = lines;
1114 qlines.replace("\n", " ");
1115 setText(qlines);
1116 connect(goto_but, &QAbstractButton::pressed, this, &notify_goto::goto_tile);
1117 connect(inspect_but, &QAbstractButton::pressed, this, &notify_goto::inspect_city);
1118 connect(close_but, &QAbstractButton::pressed, this, &QWidget::close);
1119 show();
1120}
1121
1122/***********************************************************************/
1126{
1128 close();
1129}
1130
1131/***********************************************************************/
1135{
1136 struct city *pcity = tile_city(gtile);
1137 if (pcity) {
1139 }
1140 close();
1141}
1142
1143/***********************************************************************/
1147{
1148 QString rule_name;
1149 QByteArray rn_bytes;
1150 const char *rn;
1151 struct option *poption = optset_option_by_name(server_optset, "nationset");
1152
1153 rule_name = qnation_set->currentData().toString();
1154 rn_bytes = rule_name.toUtf8(); /* Hold QByteArray in a variable to
1155 * extend its, and data() buffer's,
1156 * lifetime */
1157 rn = rn_bytes.data();
1159 != nation_set_by_rule_name(rn)) {
1160 option_str_set(poption, rn);
1161 }
1162}
1163
1164/***********************************************************************/
1169void popup_notify_goto_dialog(const char *headline, const char *lines,
1170 const struct text_tag_list *tags,
1171 struct tile *ptile)
1172{
1173 notify_goto *ask = new notify_goto(headline, lines, tags, ptile,
1174 gui()->central_wdg);
1175 ask->show();
1176}
1177
1178/***********************************************************************/
1181void popup_connect_msg(const char *headline, const char *message)
1182{
1183 QMessageBox *msg = new QMessageBox(gui()->central_wdg);
1184
1185 msg->setText(message);
1186 msg->setStandardButtons(QMessageBox::Ok);
1187 msg->setWindowTitle(headline);
1188 msg->setAttribute(Qt::WA_DeleteOnClose);
1189 msg->show();
1190}
1191
1192/***********************************************************************/
1195void popup_notify_dialog(const char *caption, const char *headline,
1196 const char *lines)
1197{
1199 gui()->mapview_wdg);
1200 nd->show();
1201}
1202
1203/***********************************************************************/
1206void popup_races_dialog(struct player *pplayer)
1207{
1208 if (!is_race_dialog_open) {
1209 race_dialog = new races_dialog(pplayer, gui()->central_wdg);
1210 is_race_dialog_open = true;
1211 race_dialog->show();
1212 }
1213 race_dialog->showNormal();
1214}
1215
1216/***********************************************************************/
1221{
1222 if (is_race_dialog_open) {
1223 race_dialog->close();
1224 is_race_dialog_open = false;
1225 }
1226}
1227
1228/***********************************************************************/
1232{
1233 if (ptile != NULL
1234 && (unit_list_size(ptile->units) > 1
1235 || (unit_list_size(ptile->units) == 1 && tile_city(ptile)))) {
1236 gui()->toggle_unit_sel_widget(ptile);
1237 }
1238}
1239
1240/***********************************************************************/
1244{
1245 gui()->update_unit_sel();
1246}
1247
1248/***********************************************************************/
1257
1258/***********************************************************************/
1261void races_update_pickable(bool nationset_change)
1262{
1263 if (is_race_dialog_open) {
1265 }
1266}
1267
1268/***********************************************************************/
1273{
1274 if (is_race_dialog_open) {
1276 }
1277}
1278
1279/***********************************************************************/
1283{
1284 hud_message_box *ask;
1285 const Government_type_id government_id
1286 = (gov != nullptr ? government_number(gov) : G_LAST);
1287
1289 ask = new hud_message_box(gui()->central_wdg);
1290 ask->setStandardButtons(QMessageBox::Cancel | QMessageBox::Ok);
1291 ask->setDefaultButton(QMessageBox::Cancel);
1292 ask->set_text_title(_("You say you wanna revolution?"),
1293 _("Revolution!"));
1294 ask->setAttribute(Qt::WA_DeleteOnClose);
1295 QObject::connect(ask, &hud_message_box::accepted, [=]() {
1296 if (government_id == G_LAST) {
1297 revolution_response(nullptr);
1298 } else {
1299 struct government *government = government_by_number(government_id);
1300
1301 if (government) {
1303 }
1304 }
1305 });
1306 ask->show();
1307 } else {
1309 }
1310}
1311
1312/***********************************************************************/
1316 pfcn_void func_in,
1317 QVariant data1_in,
1318 QVariant data2_in)
1319 : QPushButton(title)
1320{
1321 func = func_in;
1322 data1 = data1_in;
1323 data2 = data2_in;
1324}
1325
1326/***********************************************************************/
1333
1334/***********************************************************************/
1339{
1340 return data1;
1341}
1342
1343/***********************************************************************/
1348{
1349 return data2;
1350}
1351
1352/***********************************************************************/
1356{
1357 data1 = wariat;
1358}
1359
1360/***********************************************************************/
1364{
1365 data2 = wariat;
1366}
1367
1368/***********************************************************************/
1371choice_dialog::choice_dialog(const QString title, const QString text,
1372 QWidget *parent,
1373 void (*run_on_close_in)(int)): QWidget(parent)
1374{
1375 QLabel *l = new QLabel(text);
1376
1377 setProperty("themed_choice", true);
1378 layout = new QVBoxLayout(this);
1379 run_on_close = run_on_close_in;
1380
1381 layout->addWidget(l);
1382 setWindowFlags(Qt::Dialog);
1383 setWindowTitle(title);
1384 setAttribute(Qt::WA_DeleteOnClose);
1385 gui()->set_diplo_dialog(this);
1386
1388 target_id[ATK_SELF] = unit_id;
1389 target_id[ATK_CITY] = IDENTITY_NUMBER_ZERO;
1390 target_id[ATK_UNIT] = IDENTITY_NUMBER_ZERO;
1391 target_id[ATK_UNITS] = TILE_INDEX_NONE;
1392 target_id[ATK_TILE] = TILE_INDEX_NONE;
1393 target_id[ATK_EXTRAS] = TILE_INDEX_NONE;
1394 sub_target_id[ASTK_BUILDING] = B_LAST;
1395 sub_target_id[ASTK_TECH] = A_UNSET;
1396 sub_target_id[ASTK_EXTRA] = EXTRA_NONE;
1397 sub_target_id[ASTK_EXTRA_NOT_THERE] = EXTRA_NONE;
1398
1399 targeted_unit = nullptr;
1400 /* No buttons are added yet. */
1401 for (int i = 0; i < BUTTON_COUNT; i++) {
1402 action_button_map << NULL;
1403 }
1404}
1405
1406/***********************************************************************/
1410{
1411 buttons_list.clear();
1412 action_button_map.clear();
1413 gui()->set_diplo_dialog(NULL);
1414
1415 if (run_on_close) {
1417 run_on_close = NULL;
1418 }
1419}
1420
1421/***********************************************************************/
1425{
1427
1429 && unit_list_size(targeted_unit->tile->units) > 1) {
1430 struct canvas *pix;
1431 QPushButton *next, *prev;
1432 unit_skip = new QHBoxLayout;
1433 next = new QPushButton();
1434 next->setIcon(fc_icons::instance()->get_icon("city-right"));
1435 next->setIconSize(QSize(32, 32));
1436 next->setFixedSize(QSize(36, 36));
1437 prev = new QPushButton();
1438 prev->setIcon(fc_icons::instance()->get_icon("city-left"));
1439 prev->setIconSize(QSize(32, 32));
1440 prev->setFixedSize(QSize(36, 36));
1441 target_unit_button = new QPushButton;
1444 pix->map_pixmap.fill(Qt::transparent);
1445 put_unit(targeted_unit, pix, 1.0, 0, 0);
1446 target_unit_button->setIcon(QIcon(pix->map_pixmap));
1447 qtg_canvas_free(pix);
1448 target_unit_button->setIconSize(QSize(96, 96));
1449 target_unit_button->setFixedSize(QSize(100, 100));
1450 unit_skip->addStretch(100);
1451 unit_skip->addWidget(prev, Qt::AlignCenter);
1452 unit_skip->addWidget(target_unit_button, Qt::AlignCenter);
1453 unit_skip->addWidget(next, Qt::AlignCenter);
1454 layout->addLayout(unit_skip);
1455 unit_skip->addStretch(100);
1456 connect(prev, &QAbstractButton::clicked, this, &choice_dialog::prev_unit);
1457 connect(next, &QAbstractButton::clicked, this, &choice_dialog::next_unit);
1458 }
1459
1460 setLayout(layout);
1461}
1462
1463/***********************************************************************/
1466void choice_dialog::add_item(QString title, pfcn_void func, QVariant data1,
1467 QVariant data2, QString tool_tip = "",
1468 const int button_id = -1)
1469{
1471 data1, data2);
1472 int action = buttons_list.count();
1473
1474 QObject::connect(button, &QPushButton::clicked,
1477 });
1478
1479 buttons_list.append(button);
1480
1481 if (!tool_tip.isEmpty()) {
1482 button->setToolTip(tool_tip);
1483 }
1484
1485 if (0 <= button_id) {
1486 /* The id is valid. */
1487 action_button_map[button_id] = button;
1488 }
1489
1490 layout->addWidget(button);
1491}
1492
1493/***********************************************************************/
1497{
1498 QPoint p;
1499
1500 p = mapFromGlobal(QCursor::pos());
1501 p.setY(p.y()-this->height());
1502 p.setX(p.x()-this->width());
1503 move(p);
1504 show();
1505}
1506
1507/***********************************************************************/
1511{
1512 return layout;
1513}
1514
1515/***********************************************************************/
1519{
1520 if (id < 0) {
1521 fc_assert_msg(0 <= id, "Invalid button ID.");
1522 return NULL;
1523 }
1524
1525 return action_button_map[id];
1526}
1527
1528/***********************************************************************/
1531bool try_default_unit_action(QVariant q1, QVariant q2)
1532{
1535
1537 if (action == -1) {
1538 return false;
1539 }
1540 func = af_map[action];
1541
1542 func(q1, q2);
1543 return true;
1544}
1545
1546/***********************************************************************/
1549bool try_default_city_action(QVariant q1, QVariant q2)
1550{
1553
1555 if (action == -1) {
1556 return false;
1557 }
1558 func = af_map[action];
1559 func(q1, q2);
1560 return true;
1561}
1562
1563/***********************************************************************/
1567{
1568 struct tile *ptile;
1569 struct unit *new_target = nullptr;
1570 bool break_next = false;
1571 bool first = true;
1572 struct canvas *pix;
1573
1574 if (targeted_unit == nullptr) {
1575 return;
1576 }
1577
1578 ptile = targeted_unit->tile;
1579
1580 unit_list_iterate(ptile->units, ptgt) {
1581 if (first) {
1582 new_target = ptgt;
1583 first = false;
1584 }
1585 if (break_next) {
1586 new_target = ptgt;
1587 break;
1588 }
1589 if (ptgt == targeted_unit) {
1590 break_next = true;
1591 }
1593 targeted_unit = new_target;
1596 pix->map_pixmap.fill(Qt::transparent);
1597 put_unit(targeted_unit, pix, 1.0, 0, 0);
1598 target_unit_button->setIcon(QIcon(pix->map_pixmap));
1599 qtg_canvas_free(pix);
1600 switch_target();
1601}
1602
1603/***********************************************************************/
1607{
1608 struct tile *ptile;
1609 struct unit *new_target = nullptr;
1610 struct canvas *pix;
1611 if (targeted_unit == nullptr) {
1612 return;
1613 }
1614
1615 ptile = targeted_unit->tile;
1616 unit_list_iterate(ptile->units, ptgt) {
1617 if ((ptgt == targeted_unit) && new_target != nullptr) {
1618 break;
1619 }
1620 new_target = ptgt;
1622 targeted_unit = new_target;
1625 pix->map_pixmap.fill(Qt::transparent);
1626 put_unit(targeted_unit, pix, 1.0, 0, 0);
1627 target_unit_button->setIcon(QIcon(pix->map_pixmap));
1628 qtg_canvas_free(pix);
1629 switch_target();
1630}
1631
1632/***********************************************************************/
1635void choice_dialog::update_dialog(const struct act_prob *act_probs)
1636{
1637 if (targeted_unit == nullptr) {
1638 return;
1639 }
1640 unit_skip->setParent(nullptr);
1643 (sub_target_id[ASTK_EXTRA] != EXTRA_NONE
1644 ? extra_by_number(sub_target_id[ASTK_EXTRA])
1645 : NULL),
1646 act_probs);
1647 layout->addLayout(unit_skip);
1648}
1649
1650/***********************************************************************/
1654{
1655 if (targeted_unit == nullptr) {
1656 return;
1657 }
1658
1659 unit_skip->setParent(nullptr);
1666 layout->addLayout(unit_skip);
1667}
1668
1669/***********************************************************************/
1673{
1675 pfcn_void func = button->getFunc();
1676
1677 func(button->getData1(), button->getData2());
1678 close();
1679}
1680
1681/***********************************************************************/
1690{
1691 /* Store the data in the stack. */
1692 last_buttons_stack.append(button);
1693
1694 /* Temporary remove the button so it will end up below buttons added
1695 * before unstack_all_buttons() is called. */
1696 layout->removeWidget(button);
1697
1698 /* Synchronize the list with the layout. */
1699 buttons_list.removeAll(button);
1700}
1701
1702/***********************************************************************/
1707{
1708 while (!last_buttons_stack.isEmpty()) {
1709 Choice_dialog_button *button = last_buttons_stack.takeLast();
1710
1711 /* Reinsert the button below the other buttons. */
1712 buttons_list.append(button);
1713 layout->addWidget(button);
1714 }
1715}
1716
1717/***********************************************************************/
1720static void caravan_marketplace(QVariant data1, QVariant data2)
1721{
1722 int actor_unit_id = data1.toInt();
1723 int target_city_id = data2.toInt();
1724
1726 && NULL != game_city_by_number(target_city_id)) {
1727 request_do_action(ACTION_MARKETPLACE, actor_unit_id,
1728 target_city_id, 0, "");
1729 }
1730}
1731
1732/***********************************************************************/
1735static void caravan_establish_trade(QVariant data1, QVariant data2)
1736{
1737 int actor_unit_id = data1.toInt();
1738 int target_city_id = data2.toInt();
1739
1741 && NULL != game_city_by_number(target_city_id)) {
1742 request_do_action(ACTION_TRADE_ROUTE, actor_unit_id,
1743 target_city_id, 0, "");
1744 }
1745}
1746
1747/***********************************************************************/
1750static void caravan_help_build(QVariant data1, QVariant data2)
1751{
1752 int caravan_id = data1.toInt();
1753 int caravan_target_id = data2.toInt();
1754
1755 if (NULL != game_unit_by_number(caravan_id)
1756 && NULL != game_city_by_number(caravan_target_id)) {
1757 request_do_action(ACTION_HELP_WONDER,
1758 caravan_id, caravan_target_id, 0, "");
1759 }
1760}
1761
1762/***********************************************************************/
1765static void unit_disband_recover(QVariant data1, QVariant data2)
1766{
1767 int actor_id = data1.toInt();
1768 int tgt_city_id = data2.toInt();
1769
1770 if (NULL != game_unit_by_number(actor_id)
1771 && NULL != game_city_by_number(tgt_city_id)) {
1772 request_do_action(ACTION_DISBAND_UNIT_RECOVER,
1773 actor_id, tgt_city_id, 0, "");
1774 }
1775}
1776
1777/***********************************************************************/
1780static void unit_home_city(QVariant data1, QVariant data2)
1781{
1782 int actor_id = data1.toInt();
1783 int tgt_city_id = data2.toInt();
1784
1785 if (NULL != game_unit_by_number(actor_id)
1786 && NULL != game_city_by_number(tgt_city_id)) {
1787 request_do_action(ACTION_HOME_CITY,
1788 actor_id, tgt_city_id, 0, "");
1789 }
1790}
1791
1792/***********************************************************************/
1795static void unit_upgrade(QVariant data1, QVariant data2)
1796{
1797 struct unit *punit;
1798
1799 int actor_id = data1.toInt();
1800 int tgt_city_id = data2.toInt();
1801
1802 if ((punit = game_unit_by_number(actor_id))
1803 && NULL != game_city_by_number(tgt_city_id)) {
1804 struct unit_list *as_list;
1805
1806 as_list = unit_list_new();
1807 unit_list_append(as_list, punit);
1808 popup_upgrade_dialog(as_list);
1809 unit_list_destroy(as_list);
1810 }
1811}
1812
1813/***********************************************************************/
1816static void airlift(QVariant data1, QVariant data2)
1817{
1818 int actor_id = data1.toInt();
1819 int tgt_city_id = data2.toInt();
1820
1821 if (NULL != game_unit_by_number(actor_id)
1822 && NULL != game_city_by_number(tgt_city_id)) {
1823 request_do_action(ACTION_AIRLIFT,
1824 actor_id, tgt_city_id, 0, "");
1825 }
1826}
1827
1828/***********************************************************************/
1831static void conquer_city(QVariant data1, QVariant data2)
1832{
1833 int actor_id = data1.toInt();
1834 int tgt_city_id = data2.toInt();
1835
1836 if (NULL != game_unit_by_number(actor_id)
1837 && NULL != game_city_by_number(tgt_city_id)) {
1838 request_do_action(ACTION_CONQUER_CITY,
1839 actor_id, tgt_city_id, 0, "");
1840 }
1841}
1842
1843/***********************************************************************/
1846static void conquer_city2(QVariant data1, QVariant data2)
1847{
1848 int actor_id = data1.toInt();
1849 int tgt_city_id = data2.toInt();
1850
1851 if (NULL != game_unit_by_number(actor_id)
1852 && NULL != game_city_by_number(tgt_city_id)) {
1853 request_do_action(ACTION_CONQUER_CITY2,
1854 actor_id, tgt_city_id, 0, "");
1855 }
1856}
1857
1858/***********************************************************************/
1861static void conquer_extras(QVariant data1, QVariant data2)
1862{
1863 int actor_id = data1.toInt();
1864 int target_id = data2.toInt();
1865
1866 if (NULL != game_unit_by_number(actor_id)) {
1867 request_do_action(ACTION_CONQUER_EXTRAS,
1868 actor_id, target_id, 0, "");
1869 }
1870}
1871
1872/***********************************************************************/
1875static void conquer_extras2(QVariant data1, QVariant data2)
1876{
1877 int actor_id = data1.toInt();
1878 int target_id = data2.toInt();
1879
1880 if (NULL != game_unit_by_number(actor_id)) {
1881 request_do_action(ACTION_CONQUER_EXTRAS2,
1882 actor_id, target_id, 0, "");
1883 }
1884}
1885
1886/***********************************************************************/
1889static void act_sel_wait(QVariant data1, QVariant data2)
1890{
1891 key_unit_wait();
1892}
1893
1894/***********************************************************************/
1897static void keep_moving(QVariant data1, QVariant data2)
1898{
1899}
1900
1901/***********************************************************************/
1905{
1906 if (!gov) {
1908 } else {
1910 }
1911}
1912
1913/***********************************************************************/
1918{
1920 /* The client isn't waiting for information for any unanswered follow
1921 * up questions. */
1922
1923 struct unit *actor_unit;
1924
1926 /* The action selection dialog wasn't closed because the actor unit
1927 * was lost. */
1928
1929 /* The probabilities didn't just disappear, right? */
1932
1934 }
1935
1936 /* The action selection process is over, at least for now. */
1938
1939 if (did_not_decide) {
1940 /* The action selection dialog was closed but the player didn't
1941 * decide what the unit should do. */
1942
1943 /* Reset so the next action selection dialog does the right thing. */
1944 did_not_decide = false;
1945 } else {
1946 /* An action, or no action at all, was selected. */
1949 }
1950 }
1951}
1952
1953/***********************************************************************/
1957static void diplomat_queue_handle_secondary(int actor_id)
1958{
1959 /* Stop waiting. Move on to the next queued unit. */
1962}
1963
1964/**********************************************************************/
1971{
1972 /* Stop assuming the answer to a follow up question will arrive. */
1974}
1975
1976/***********************************************************************/
1981 struct city *target_city,
1982 struct unit *target_unit,
1983 struct tile *target_tile,
1984 struct extra_type *target_extra,
1985 const struct act_prob *act_probs)
1986{
1987 struct astring title = ASTRING_INIT, text = ASTRING_INIT;
1988 choice_dialog *cd;
1989 qtiles caras;
1990 QVariant qv1, qv2;
1992 struct city *actor_homecity;
1993 action_id unit_act;
1994 action_id city_act;
1995
1996 unit_act = qdef_act::action()->vs_unit_get();
1997 city_act = qdef_act::action()->vs_city_get();
1998
1999 foreach (caras, gui()->trade_gen.lines) {
2000 if (caras.autocaravan == actor_unit) {
2001 int i;
2002 if (nullptr != game_unit_by_number(actor_unit->id)
2003 && nullptr != game_city_by_number(target_city->id)) {
2004 request_do_action(ACTION_TRADE_ROUTE, actor_unit->id,
2005 target_city->id, 0, "");
2008 i = gui()->trade_gen.lines.indexOf(caras);
2009 gui()->trade_gen.lines.takeAt(i);
2010 return;
2011 }
2012 }
2013 }
2014 if (target_city
2016 && action_prob_possible(act_probs[unit_act])) {
2018 return;
2019 }
2020
2021 if (target_unit
2023 && action_prob_possible(act_probs[city_act])) {
2025 return;
2026 }
2027 /* Could be caused by the server failing to reply to a request for more
2028 * information or a bug in the client code. */
2030 "Diplomat queue problem. Is another diplomat window open?");
2031
2032 /* No extra input is required as no action has been chosen yet. */
2034
2035 actor_homecity = game_city_by_number(actor_unit->homecity);
2036
2037 astr_set(&title,
2038 /* TRANS: %s is a unit name, e.g., Spy */
2039 _("Choose Your %s's Strategy"),
2041
2042 if (target_city && actor_homecity) {
2043 astr_set(&text,
2044 _("Your %s from %s reaches the city of %s.\nWhat now?"),
2046 city_name_get(actor_homecity),
2048 } else if (target_city) {
2049 astr_set(&text,
2050 _("Your %s has arrived at %s.\nWhat is your command?"),
2053 } else if (target_unit) {
2054 astr_set(&text,
2055 /* TRANS: Your Spy is ready to act against Roman Freight. */
2056 _("Your %s is ready to act against %s %s."),
2060 } else {
2062 "No target specified.");
2063
2064 astr_set(&text,
2065 /* TRANS: %s is a unit name, e.g., Diplomat, Spy */
2066 _("Your %s is waiting for your command."),
2068 }
2069
2070 cd = gui()->get_diplo_dialog();
2071 if ((cd != nullptr) && cd->targeted_unit != nullptr) {
2072 cd->update_dialog(act_probs);
2073 return;
2074 }
2075 cd = new choice_dialog(astr_str(&title), astr_str(&text),
2076 gui()->game_tab_widget,
2078 qv1 = actor_unit->id;
2079
2080 cd->unit_id = actor_unit->id;
2081
2082 cd->target_id[ATK_SELF] = cd->unit_id;
2083
2084 if (target_city) {
2085 cd->target_id[ATK_CITY] = target_city->id;
2086 } else {
2087 cd->target_id[ATK_CITY] = IDENTITY_NUMBER_ZERO;
2088 }
2089
2090 if (target_unit) {
2091 cd->target_id[ATK_UNIT] = target_unit->id;
2092 } else {
2093 cd->target_id[ATK_UNIT] = IDENTITY_NUMBER_ZERO;
2094 }
2095
2096 if (target_tile) {
2097 cd->target_id[ATK_UNITS] = tile_index(target_tile);
2098 } else {
2099 cd->target_id[ATK_UNITS] = TILE_INDEX_NONE;
2100 }
2101
2102 if (target_tile) {
2103 cd->target_id[ATK_TILE] = tile_index(target_tile);
2104 } else {
2105 cd->target_id[ATK_TILE] = TILE_INDEX_NONE;
2106 }
2107
2108 if (target_tile) {
2109 cd->target_id[ATK_EXTRAS] = tile_index(target_tile);
2110 } else {
2111 cd->target_id[ATK_EXTRAS] = TILE_INDEX_NONE;
2112 }
2113
2114 /* No target building or target tech supplied. (Feb 2020) */
2115 cd->sub_target_id[ASTK_BUILDING] = B_LAST;
2116 cd->sub_target_id[ASTK_TECH] = A_UNSET;
2117
2118 if (target_extra) {
2119 cd->sub_target_id[ASTK_EXTRA] = extra_number(target_extra);
2120 cd->sub_target_id[ASTK_EXTRA_NOT_THERE] = extra_number(target_extra);
2121 } else {
2122 cd->sub_target_id[ASTK_EXTRA] = EXTRA_NONE;
2123 cd->sub_target_id[ASTK_EXTRA_NOT_THERE] = EXTRA_NONE;
2124 }
2125
2126 /* Unit acting against a city */
2127
2128 /* Set the correct target for the following actions. */
2129 qv2 = cd->target_id[ATK_CITY];
2130
2131 action_iterate(act) {
2132 if (action_id_get_actor_kind(act) == AAK_UNIT
2133 && action_id_get_target_kind(act) == ATK_CITY) {
2134 action_entry(cd, act, act_probs,
2136 act_probs[act],
2137 actor_unit,
2138 target_city),
2139 qv1, qv2);
2140 }
2142
2143 /* Unit acting against another unit */
2144
2145 /* Set the correct target for the following actions. */
2146 qv2 = cd->target_id[ATK_UNIT];
2147
2148 action_iterate(act) {
2149 if (action_id_get_actor_kind(act) == AAK_UNIT
2150 && action_id_get_target_kind(act) == ATK_UNIT) {
2151 action_entry(cd, act, act_probs,
2153 act_probs[act],
2154 actor_unit,
2155 target_city),
2156 qv1, qv2);
2157 }
2159
2160 /* Unit acting against all units at a tile */
2161
2162 /* Set the correct target for the following actions. */
2163 qv2 = cd->target_id[ATK_UNITS];
2164
2165 action_iterate(act) {
2166 if (action_id_get_actor_kind(act) == AAK_UNIT
2167 && action_id_get_target_kind(act) == ATK_UNITS) {
2168 action_entry(cd, act, act_probs,
2170 act_probs[act],
2171 actor_unit,
2172 target_city),
2173 qv1, qv2);
2174 }
2176
2177 /* Unit acting against a tile. */
2178
2179 /* Set the correct target for the following actions. */
2180 qv2 = cd->target_id[ATK_TILE];
2181
2182 action_iterate(act) {
2183 if (action_id_get_actor_kind(act) == AAK_UNIT
2184 && action_id_get_target_kind(act) == ATK_TILE) {
2185 action_entry(cd, act, act_probs,
2187 act_probs[act],
2188 actor_unit,
2189 target_city),
2190 qv1, qv2);
2191 }
2193
2194 /* Unit acting against a tile's extras. */
2195
2196 /* Set the correct target for the following actions. */
2197 qv2 = cd->target_id[ATK_EXTRAS];
2198
2199 action_iterate(act) {
2200 if (action_id_get_actor_kind(act) == AAK_UNIT
2201 && action_id_get_target_kind(act) == ATK_EXTRAS) {
2202 action_entry(cd, act, act_probs,
2204 act_probs[act],
2205 actor_unit,
2206 target_city),
2207 qv1, qv2);
2208 }
2210
2211 /* Unit acting against itself */
2212
2213 /* Set the correct target for the following actions. */
2214 qv2 = cd->target_id[ATK_SELF];
2215
2216 action_iterate(act) {
2217 if (action_id_get_actor_kind(act) == AAK_UNIT
2218 && action_id_get_target_kind(act) == ATK_SELF) {
2219 action_entry(cd, act, act_probs,
2221 act_probs[act],
2222 actor_unit,
2223 target_city),
2224 qv1, qv2);
2225 }
2227
2229 cd->add_item(QString(_("&Wait")), func, qv1, qv2,
2230 "", BUTTON_WAIT);
2231
2232 func = keep_moving;
2233 cd->add_item(QString(_("Do nothing")), func, qv1, qv2,
2234 "", BUTTON_CANCEL);
2235
2236 cd->set_layout();
2237 cd->show_me();
2238
2239 /* Give follow up questions access to action probabilities. */
2241 action_iterate(act) {
2242 actor_unit->client.act_prob_cache[act] = act_probs[act];
2244
2245 astr_free(&title);
2246 astr_free(&text);
2247}
2248
2249/***********************************************************************/
2254{
2255 /* Don't add an action mapping here unless the non targeted version is
2256 * selectable in the targeted version's target selection dialog. */
2257 switch ((enum gen_action)tgt_action_id) {
2258 case ACTION_SPY_TARGETED_SABOTAGE_CITY:
2259 return ACTION_SPY_SABOTAGE_CITY;
2260 case ACTION_SPY_TARGETED_SABOTAGE_CITY_ESC:
2261 return ACTION_SPY_SABOTAGE_CITY_ESC;
2262 case ACTION_SPY_TARGETED_STEAL_TECH:
2263 return ACTION_SPY_STEAL_TECH;
2264 case ACTION_SPY_TARGETED_STEAL_TECH_ESC:
2265 return ACTION_SPY_STEAL_TECH_ESC;
2266 default:
2267 /* No non targeted version found. */
2268 return ACTION_NONE;
2269 }
2270}
2271
2272/**********************************************************************/
2277{
2278 /* Don't add an action mapping here unless the non targeted version is
2279 * selectable in the targeted version's target selection dialog. */
2280 switch ((enum gen_action)tgt_action_id) {
2281 case ACTION_SPY_TARGETED_SABOTAGE_CITY:
2282 return ACTION_SPY_SABOTAGE_CITY_PRODUCTION;
2283 case ACTION_SPY_TARGETED_SABOTAGE_CITY_ESC:
2284 return ACTION_SPY_SABOTAGE_CITY_PRODUCTION_ESC;
2285 case ACTION_STRIKE_BUILDING:
2286 return ACTION_STRIKE_PRODUCTION;
2287 default:
2288 /* No non targeted version found. */
2289 return ACTION_NONE;
2290 }
2291}
2292
2293/***********************************************************************/
2297 action_id act,
2298 const struct act_prob *act_probs,
2299 const char *custom,
2300 QVariant data1, QVariant data2)
2301{
2302 QString title;
2303 QString tool_tip;
2304
2305 if (!af_map.contains(act)) {
2306 /* The Qt client doesn't support ordering this action from the
2307 * action selection dialog. */
2308 return;
2309 }
2310
2311 /* Don't show disabled actions. */
2312 if (!action_prob_possible(act_probs[act])) {
2313 return;
2314 }
2315
2316 title = QString(action_prepare_ui_name(act, "&",
2317 act_probs[act],
2318 custom));
2319
2320 tool_tip = QString(act_sel_action_tool_tip(action_by_number(act),
2321 act_probs[act]));
2322
2323 cd->add_item(title, af_map[act], data1, data2, tool_tip, act);
2324}
2325
2326/***********************************************************************/
2330 action_id act,
2331 const struct act_prob *act_probs,
2332 const char *custom,
2333 QVariant data1, QVariant data2)
2334{
2335 QString title;
2336 QString tool_tip;
2337
2338 /* An action that just became impossible has its button disabled.
2339 * An action that became possible again must be re-enabled. */
2340 button->setEnabled(action_prob_possible(act_probs[act]));
2341 button->setData1(data1);
2342 button->setData2(data2);
2343 /* The probability may have changed. */
2344 title = QString(action_prepare_ui_name(act, "&",
2345 act_probs[act],
2346 custom));
2347
2348 tool_tip = QString(act_sel_action_tool_tip(action_by_number(act),
2349 act_probs[act]));
2350
2351 button->setText(title);
2352 button->setToolTip(tool_tip);
2353}
2354
2355/***********************************************************************/
2358static void disband_unit(QVariant data1, QVariant data2)
2359{
2360 int actor_id = data1.toInt();
2361 int target_id = data2.toInt();
2362
2363 request_do_action(ACTION_DISBAND_UNIT, actor_id,
2364 target_id, 0, "");
2365}
2366
2367/***********************************************************************/
2370static void fortify(QVariant data1, QVariant data2)
2371{
2372 int actor_id = data1.toInt();
2373 int target_id = data2.toInt();
2374
2375 if (NULL != game_unit_by_number(actor_id)) {
2376 request_do_action(ACTION_FORTIFY, actor_id,
2377 target_id, 0, "");
2378 }
2379}
2380
2381/***********************************************************************/
2384static void convert_unit(QVariant data1, QVariant data2)
2385{
2386 int actor_id = data1.toInt();
2387 int target_id = data2.toInt();
2388
2389 request_do_action(ACTION_CONVERT, actor_id,
2390 target_id, 0, "");
2391}
2392
2393/***********************************************************************/
2396static void homeless(QVariant data1, QVariant data2)
2397{
2398 int actor_id = data1.toInt();
2399 int target_id = data2.toInt();
2400
2401 if (NULL != game_unit_by_number(actor_id)) {
2402 request_do_action(ACTION_HOMELESS, actor_id,
2403 target_id, 0, "");
2404 }
2405}
2406
2407/***********************************************************************/
2410static void diplomat_bribe(QVariant data1, QVariant data2)
2411{
2412 int diplomat_id = data1.toInt();
2413 int diplomat_target_id = data2.toInt();
2414
2415 if (NULL != game_unit_by_number(diplomat_id)
2416 && NULL != game_unit_by_number(diplomat_target_id)) {
2417 /* Wait for the server's reply before moving on to the next queued diplomat. */
2419
2420 request_action_details(ACTION_SPY_BRIBE_UNIT, diplomat_id,
2421 diplomat_target_id);
2422 }
2423}
2424
2425/***********************************************************************/
2428static void spy_sabotage_unit(QVariant data1, QVariant data2)
2429{
2430 int diplomat_id = data1.toInt();
2431 int diplomat_target_id = data2.toInt();
2432
2433 request_do_action(ACTION_SPY_SABOTAGE_UNIT, diplomat_id,
2434 diplomat_target_id, 0, "");
2435}
2436
2437/***********************************************************************/
2440static void spy_sabotage_unit_esc(QVariant data1, QVariant data2)
2441{
2442 int diplomat_id = data1.toInt();
2443 int diplomat_target_id = data2.toInt();
2444
2445 request_do_action(ACTION_SPY_SABOTAGE_UNIT_ESC, diplomat_id,
2446 diplomat_target_id, 0, "");
2447}
2448
2449/***********************************************************************/
2452static void heal_unit(QVariant data1, QVariant data2)
2453{
2454 int actor_id = data1.toInt();
2455 int target_id = data2.toInt();
2456
2457 request_do_action(ACTION_HEAL_UNIT, actor_id, target_id, 0, "");
2458}
2459
2460/***********************************************************************/
2463static void heal_unit2(QVariant data1, QVariant data2)
2464{
2465 int actor_id = data1.toInt();
2466 int target_id = data2.toInt();
2467
2468 request_do_action(ACTION_HEAL_UNIT2, actor_id, target_id, 0, "");
2469}
2470
2471/***********************************************************************/
2474static void transport_board(QVariant data1, QVariant data2)
2475{
2476 int actor_id = data1.toInt();
2477 int target_id = data2.toInt();
2478
2479 request_do_action(ACTION_TRANSPORT_BOARD, actor_id, target_id, 0, "");
2480}
2481
2482/***********************************************************************/
2485static void transport_embark(QVariant data1, QVariant data2)
2486{
2487 int actor_id = data1.toInt();
2488 int target_id = data2.toInt();
2489
2490 request_do_action(ACTION_TRANSPORT_EMBARK, actor_id, target_id, 0, "");
2491}
2492
2493/***********************************************************************/
2496static void transport_embark2(QVariant data1, QVariant data2)
2497{
2498 int actor_id = data1.toInt();
2499 int target_id = data2.toInt();
2500
2501 request_do_action(ACTION_TRANSPORT_EMBARK2, actor_id, target_id, 0, "");
2502}
2503
2504/***********************************************************************/
2507static void transport_embark3(QVariant data1, QVariant data2)
2508{
2509 int actor_id = data1.toInt();
2510 int target_id = data2.toInt();
2511
2512 request_do_action(ACTION_TRANSPORT_EMBARK3, actor_id, target_id, 0, "");
2513}
2514
2515/***********************************************************************/
2518static void transport_unload(QVariant data1, QVariant data2)
2519{
2520 int actor_id = data1.toInt();
2521 int target_id = data2.toInt();
2522
2523 request_do_action(ACTION_TRANSPORT_UNLOAD, actor_id, target_id, 0, "");
2524}
2525
2526/***********************************************************************/
2529static void transport_alight(QVariant data1, QVariant data2)
2530{
2531 int actor_id = data1.toInt();
2532 int target_id = data2.toInt();
2533
2534 request_do_action(ACTION_TRANSPORT_ALIGHT, actor_id, target_id, 0, "");
2535}
2536
2537/***********************************************************************/
2540static void disembark1(QVariant data1, QVariant data2)
2541{
2542 int actor_id = data1.toInt();
2543 int target_id = data2.toInt();
2544
2545 if (NULL != game_unit_by_number(actor_id)
2546 && NULL != index_to_tile(&(wld.map), target_id)) {
2547 request_do_action(ACTION_TRANSPORT_DISEMBARK1,
2548 actor_id, target_id, 0, "");
2549 }
2550}
2551
2552/***********************************************************************/
2555static void disembark2(QVariant data1, QVariant data2)
2556{
2557 int actor_id = data1.toInt();
2558 int target_id = data2.toInt();
2559
2560 if (NULL != game_unit_by_number(actor_id)
2561 && NULL != index_to_tile(&(wld.map), target_id)) {
2562 request_do_action(ACTION_TRANSPORT_DISEMBARK2,
2563 actor_id, target_id, 0, "");
2564 }
2565}
2566
2567/***********************************************************************/
2570static void enter_hut(QVariant data1, QVariant data2)
2571{
2572 int actor_id = data1.toInt();
2573 int target_id = data2.toInt();
2574
2575 if (NULL != game_unit_by_number(actor_id)
2576 && NULL != index_to_tile(&(wld.map), target_id)) {
2577 request_do_action(ACTION_HUT_ENTER,
2578 actor_id, target_id, 0, "");
2579 }
2580}
2581
2582/***********************************************************************/
2585static void enter_hut2(QVariant data1, QVariant data2)
2586{
2587 int actor_id = data1.toInt();
2588 int target_id = data2.toInt();
2589
2590 if (NULL != game_unit_by_number(actor_id)
2591 && NULL != index_to_tile(&(wld.map), target_id)) {
2592 request_do_action(ACTION_HUT_ENTER2,
2593 actor_id, target_id, 0, "");
2594 }
2595}
2596
2597/***********************************************************************/
2600static void frighten_hut(QVariant data1, QVariant data2)
2601{
2602 int actor_id = data1.toInt();
2603 int target_id = data2.toInt();
2604
2605 if (NULL != game_unit_by_number(actor_id)
2606 && NULL != index_to_tile(&(wld.map), target_id)) {
2607 request_do_action(ACTION_HUT_FRIGHTEN,
2608 actor_id, target_id, 0, "");
2609 }
2610}
2611
2612/***********************************************************************/
2615static void frighten_hut2(QVariant data1, QVariant data2)
2616{
2617 int actor_id = data1.toInt();
2618 int target_id = data2.toInt();
2619
2620 if (NULL != game_unit_by_number(actor_id)
2621 && NULL != index_to_tile(&(wld.map), target_id)) {
2622 request_do_action(ACTION_HUT_FRIGHTEN2,
2623 actor_id, target_id, 0, "");
2624 }
2625}
2626
2627/**********************************************************************/
2630static void nuke_units(QVariant data1, QVariant data2)
2631{
2632 int actor_id = data1.toInt();
2633 int target_id = data2.toInt();
2634
2635 request_do_action(ACTION_NUKE_UNITS, actor_id,
2636 target_id, 0, "");
2637}
2638
2639/**********************************************************************/
2642static void capture_units(QVariant data1, QVariant data2)
2643{
2644 int actor_id = data1.toInt();
2645 int target_id = data2.toInt();
2646
2647 request_do_action(ACTION_CAPTURE_UNITS, actor_id,
2648 target_id, 0, "");
2649}
2650
2651/***********************************************************************/
2654static void expel_unit(QVariant data1, QVariant data2)
2655{
2656 int actor_id = data1.toInt();
2657 int target_id = data2.toInt();
2658
2659 request_do_action(ACTION_EXPEL_UNIT, actor_id,
2660 target_id, 0, "");
2661}
2662
2663/***********************************************************************/
2666static void bombard(QVariant data1, QVariant data2)
2667{
2668 int actor_id = data1.toInt();
2669 int target_id = data2.toInt();
2670
2671 request_do_action(ACTION_BOMBARD, actor_id,
2672 target_id, 0, "");
2673}
2674
2675/***********************************************************************/
2678static void bombard2(QVariant data1, QVariant data2)
2679{
2680 int actor_id = data1.toInt();
2681 int target_id = data2.toInt();
2682
2683 request_do_action(ACTION_BOMBARD2, actor_id,
2684 target_id, 0, "");
2685}
2686
2687/***********************************************************************/
2690static void bombard3(QVariant data1, QVariant data2)
2691{
2692 int actor_id = data1.toInt();
2693 int target_id = data2.toInt();
2694
2695 request_do_action(ACTION_BOMBARD3, actor_id,
2696 target_id, 0, "");
2697}
2698
2699/***********************************************************************/
2702static void found_city(QVariant data1, QVariant data2)
2703{
2704 int actor_id = data1.toInt();
2705
2707 actor_id, actor_id);
2708}
2709
2710/***********************************************************************/
2713static void transform_terrain(QVariant data1, QVariant data2)
2714{
2715 int actor_id = data1.toInt();
2716 int target_id = data2.toInt();
2717
2718 if (NULL != game_unit_by_number(actor_id)
2719 && NULL != index_to_tile(&(wld.map), target_id)) {
2720 request_do_action(ACTION_TRANSFORM_TERRAIN,
2721 actor_id, target_id, 0, "");
2722 }
2723}
2724
2725/***********************************************************************/
2728static void cultivate(QVariant data1, QVariant data2)
2729{
2730 int actor_id = data1.toInt();
2731 int target_id = data2.toInt();
2732
2733 if (NULL != game_unit_by_number(actor_id)
2734 && NULL != index_to_tile(&(wld.map), target_id)) {
2735 request_do_action(ACTION_CULTIVATE,
2736 actor_id, target_id, 0, "");
2737 }
2738}
2739
2740/***********************************************************************/
2743static void plant(QVariant data1, QVariant data2)
2744{
2745 int actor_id = data1.toInt();
2746 int target_id = data2.toInt();
2747
2748 if (NULL != game_unit_by_number(actor_id)
2749 && NULL != index_to_tile(&(wld.map), target_id)) {
2750 request_do_action(ACTION_PLANT,
2751 actor_id, target_id, 0, "");
2752 }
2753}
2754
2755/***********************************************************************/
2758static void pillage(QVariant data1, QVariant data2)
2759{
2760 int actor_id = data1.toInt();
2761 int target_id = data2.toInt();
2762
2763 if (NULL != game_unit_by_number(actor_id)
2764 && NULL != index_to_tile(&(wld.map), target_id)) {
2765 request_do_action(ACTION_PILLAGE,
2766 actor_id, target_id,
2767 /* FIXME: will cause problems if more than
2768 * one action selection dialog at a time
2769 * becomes supported. */
2771 "");
2772 }
2773}
2774
2775/***********************************************************************/
2778static void clean_pollution(QVariant data1, QVariant data2)
2779{
2780 int actor_id = data1.toInt();
2781 int target_id = data2.toInt();
2782
2783 if (NULL != game_unit_by_number(actor_id)
2784 && NULL != index_to_tile(&(wld.map), target_id)) {
2785 request_do_action(ACTION_CLEAN_POLLUTION,
2786 actor_id, target_id,
2787 /* FIXME: will cause problems if more than
2788 * one action selection dialog at a time
2789 * becomes supported. */
2791 "");
2792 }
2793}
2794
2795/***********************************************************************/
2798static void clean_fallout(QVariant data1, QVariant data2)
2799{
2800 int actor_id = data1.toInt();
2801 int target_id = data2.toInt();
2802
2803 if (NULL != game_unit_by_number(actor_id)
2804 && NULL != index_to_tile(&(wld.map), target_id)) {
2805 request_do_action(ACTION_CLEAN_FALLOUT,
2806 actor_id, target_id,
2807 /* FIXME: will cause problems if more than
2808 * one action selection dialog at a time
2809 * becomes supported. */
2811 "");
2812 }
2813}
2814
2815/***********************************************************************/
2818static void road(QVariant data1, QVariant data2)
2819{
2820 int actor_id = data1.toInt();
2821 int target_id = data2.toInt();
2822
2823 if (NULL != game_unit_by_number(actor_id)
2824 && NULL != index_to_tile(&(wld.map), target_id)
2826 request_do_action(ACTION_ROAD,
2827 actor_id, target_id,
2828 /* FIXME: will cause problems if more than
2829 * one action selection dialog at a time
2830 * becomes supported. */
2832 "");
2833 }
2834}
2835
2836/***********************************************************************/
2839static void base(QVariant data1, QVariant data2)
2840{
2841 int actor_id = data1.toInt();
2842 int target_id = data2.toInt();
2843
2844 if (NULL != game_unit_by_number(actor_id)
2845 && NULL != index_to_tile(&(wld.map), target_id)
2847 request_do_action(ACTION_BASE,
2848 actor_id, target_id,
2849 /* FIXME: will cause problems if more than
2850 * one action selection dialog at a time
2851 * becomes supported. */
2853 "");
2854 }
2855}
2856
2857/***********************************************************************/
2860static void mine(QVariant data1, QVariant data2)
2861{
2862 int actor_id = data1.toInt();
2863 int target_id = data2.toInt();
2864
2865 if (NULL != game_unit_by_number(actor_id)
2866 && NULL != index_to_tile(&(wld.map), target_id)
2868 request_do_action(ACTION_MINE,
2869 actor_id, target_id,
2870 /* FIXME: will cause problems if more than
2871 * one action selection dialog at a time
2872 * becomes supported. */
2874 "");
2875 }
2876}
2877
2878/***********************************************************************/
2881static void irrigate(QVariant data1, QVariant data2)
2882{
2883 int actor_id = data1.toInt();
2884 int target_id = data2.toInt();
2885
2886 if (NULL != game_unit_by_number(actor_id)
2887 && NULL != index_to_tile(&(wld.map), target_id)
2889 request_do_action(ACTION_IRRIGATE,
2890 actor_id, target_id,
2891 /* FIXME: will cause problems if more than
2892 * one action selection dialog at a time
2893 * becomes supported. */
2895 "");
2896 }
2897}
2898
2899/***********************************************************************/
2902static void nuke(QVariant data1, QVariant data2)
2903{
2904 int diplomat_id = data1.toInt();
2905 int diplomat_target_id = data2.toInt();
2906
2907 if (NULL != game_unit_by_number(diplomat_id)
2908 && NULL != index_to_tile(&(wld.map), diplomat_target_id)) {
2909 request_do_action(ACTION_NUKE,
2910 diplomat_id, diplomat_target_id, 0, "");
2911 }
2912}
2913
2914/***********************************************************************/
2917static void attack(QVariant data1, QVariant data2)
2918{
2919 int diplomat_id = data1.toInt();
2920 int diplomat_target_id = data2.toInt();
2921
2922 if (NULL != game_unit_by_number(diplomat_id)
2923 && NULL != index_to_tile(&(wld.map), diplomat_target_id)) {
2924 request_do_action(ACTION_ATTACK,
2925 diplomat_id, diplomat_target_id, 0, "");
2926 }
2927}
2928
2929/***********************************************************************/
2932static void suicide_attack(QVariant data1, QVariant data2)
2933{
2934 int diplomat_id = data1.toInt();
2935 int diplomat_target_id = data2.toInt();
2936
2937 if (NULL != game_unit_by_number(diplomat_id)
2938 && NULL != index_to_tile(&(wld.map), diplomat_target_id)) {
2939 request_do_action(ACTION_SUICIDE_ATTACK,
2940 diplomat_id, diplomat_target_id, 0, "");
2941 }
2942}
2943
2944/***********************************************************************/
2947static void paradrop(QVariant data1, QVariant data2)
2948{
2949 int actor_id = data1.toInt();
2950 int target_id = data2.toInt();
2951
2952 if (NULL != game_unit_by_number(actor_id)
2953 && NULL != index_to_tile(&(wld.map), target_id)) {
2954 request_do_action(ACTION_PARADROP,
2955 actor_id, target_id, 0, "");
2956 }
2957}
2958
2959/***********************************************************************/
2962static void paradrop_conquer(QVariant data1, QVariant data2)
2963{
2964 int actor_id = data1.toInt();
2965 int target_id = data2.toInt();
2966
2967 if (NULL != game_unit_by_number(actor_id)
2968 && NULL != index_to_tile(&(wld.map), target_id)) {
2969 request_do_action(ACTION_PARADROP_CONQUER,
2970 actor_id, target_id, 0, "");
2971 }
2972}
2973
2974/***********************************************************************/
2977static void paradrop_frighten(QVariant data1, QVariant data2)
2978{
2979 int actor_id = data1.toInt();
2980 int target_id = data2.toInt();
2981
2982 if (NULL != game_unit_by_number(actor_id)
2983 && NULL != index_to_tile(&(wld.map), target_id)) {
2984 request_do_action(ACTION_PARADROP_FRIGHTEN,
2985 actor_id, target_id, 0, "");
2986 }
2987}
2988
2989/***********************************************************************/
2992static void paradrop_frighten_conquer(QVariant data1, QVariant data2)
2993{
2994 int actor_id = data1.toInt();
2995 int target_id = data2.toInt();
2996
2997 if (NULL != game_unit_by_number(actor_id)
2998 && NULL != index_to_tile(&(wld.map), target_id)) {
2999 request_do_action(ACTION_PARADROP_FRIGHTEN_CONQUER,
3000 actor_id, target_id, 0, "");
3001 }
3002}
3003
3004/***********************************************************************/
3007static void paradrop_enter(QVariant data1, QVariant data2)
3008{
3009 int actor_id = data1.toInt();
3010 int target_id = data2.toInt();
3011
3012 if (NULL != game_unit_by_number(actor_id)
3013 && NULL != index_to_tile(&(wld.map), target_id)) {
3014 request_do_action(ACTION_PARADROP_ENTER,
3015 actor_id, target_id, 0, "");
3016 }
3017}
3018
3019/***********************************************************************/
3022static void paradrop_enter_conquer(QVariant data1, QVariant data2)
3023{
3024 int actor_id = data1.toInt();
3025 int target_id = data2.toInt();
3026
3027 if (NULL != game_unit_by_number(actor_id)
3028 && NULL != index_to_tile(&(wld.map), target_id)) {
3029 request_do_action(ACTION_PARADROP_ENTER_CONQUER,
3030 actor_id, target_id, 0, "");
3031 }
3032}
3033
3034/***********************************************************************/
3037static void join_city(QVariant data1, QVariant data2)
3038{
3039 int actor_id = data1.toInt();
3040 int target_id = data2.toInt();
3041
3042 if (NULL != game_unit_by_number(actor_id)
3043 && NULL != game_city_by_number(target_id)) {
3044 request_do_action(ACTION_JOIN_CITY,
3045 actor_id, target_id, 0, "");
3046 }
3047}
3048
3049/***********************************************************************/
3052static void spy_steal_shared(QVariant data1, QVariant data2,
3053 action_id act_id)
3054{
3055 QString str;
3056 QVariant qv1;
3058 int diplomat_id = data1.toInt();
3059 int diplomat_target_id = data2.toInt();
3060 struct unit *actor_unit = game_unit_by_number(diplomat_id);
3061 struct city *pvcity = game_city_by_number(diplomat_target_id);
3062 struct player *pvictim = NULL;
3063 choice_dialog *cd;
3064 QList<QVariant> actor_and_target;
3065
3066 cd = gui()->get_diplo_dialog();
3067 if (cd != NULL) {
3068 cd->close();
3069 }
3070
3071 if (pvcity == nullptr) {
3072 return;
3073 }
3074
3075 // Wait for the player's reply before moving on to the next queued diplomat.
3077
3078 pvictim = city_owner(pvcity);
3079
3080 struct astring stra = ASTRING_INIT;
3081 cd = new choice_dialog(_("Steal"), _("Steal Technology"),
3082 gui()->game_tab_widget,
3084
3085 // Put both actor and target city in qv1 since qv2 is taken
3086 actor_and_target.append(diplomat_id);
3087 actor_and_target.append(diplomat_target_id);
3088 actor_and_target.append(act_id);
3089 qv1 = QVariant::fromValue(actor_and_target);
3090
3091 struct player *pplayer = client_player();
3092 const struct research *presearch = research_get(pplayer);
3093 const struct research *vresearch = research_get(pvictim);
3094
3096 if (research_invention_gettable(presearch, i,
3098 && research_invention_state(vresearch, i) == TECH_KNOWN
3099 && research_invention_state(presearch, i) != TECH_KNOWN) {
3101 // Defeat keyboard shortcut mnemonics
3102 str = QString(research_advance_name_translation(presearch, i))
3103 .replace("&", "&&");
3104 cd->add_item(str, func, qv1, i);
3105 }
3107
3109 get_non_targeted_action_id(act_id)])) {
3110 astr_set(&stra, _("At %s's Discretion"),
3113 str = QString(astr_str(&stra)).replace("&", "&&");
3114 cd->add_item(str, func, qv1, A_UNSET);
3115 }
3116
3117 cd->set_layout();
3118 cd->show_me();
3119
3120 astr_free(&stra);
3121}
3122
3123/***********************************************************************/
3126static void spy_steal(QVariant data1, QVariant data2)
3127{
3128 spy_steal_shared(data1, data2, ACTION_SPY_TARGETED_STEAL_TECH);
3129}
3130
3131/***********************************************************************/
3134static void spy_steal_esc(QVariant data1, QVariant data2)
3135{
3136 spy_steal_shared(data1, data2, ACTION_SPY_TARGETED_STEAL_TECH_ESC);
3137}
3138
3139/***********************************************************************/
3142static void spy_steal_something(QVariant data1, QVariant data2)
3143{
3144 int diplomat_id = data1.toList().at(0).toInt();
3145 int diplomat_target_id = data1.toList().at(1).toInt();
3146 action_id act_id = data1.toList().at(2).toInt();
3147
3148 if (NULL != game_unit_by_number(diplomat_id)
3149 && NULL != game_city_by_number(diplomat_target_id)) {
3150 if (data2.toInt() == A_UNSET) {
3151 /* This is the untargeted version. */
3153 diplomat_id, diplomat_target_id, data2.toInt(), "");
3154 } else {
3155 /* This is the targeted version. */
3156 request_do_action(act_id, diplomat_id,
3157 diplomat_target_id, data2.toInt(), "");
3158 }
3159 }
3160}
3161
3162/***********************************************************************/
3165static void spy_request_strike_bld_list(QVariant data1, QVariant data2)
3166{
3167 int actor_id = data1.toInt();
3168 int target_id = data2.toInt();
3169
3170 if (NULL != game_unit_by_number(actor_id)
3171 && NULL != game_city_by_number(target_id)) {
3172 /* Wait for the server's reply before moving on to the next queued diplomat. */
3174
3175 request_action_details(ACTION_STRIKE_BUILDING, actor_id, target_id);
3176 }
3177}
3178
3179/***********************************************************************/
3182static void spy_request_sabotage_list(QVariant data1, QVariant data2)
3183{
3184 int diplomat_id = data1.toInt();
3185 int diplomat_target_id = data2.toInt();
3186
3187 if (NULL != game_unit_by_number(diplomat_id)
3188 && NULL != game_city_by_number(diplomat_target_id)) {
3189 /* Wait for the server's reply before moving on to the next queued diplomat. */
3191
3192 request_action_details(ACTION_SPY_TARGETED_SABOTAGE_CITY, diplomat_id,
3193 diplomat_target_id);
3194 }
3195}
3196
3197/***********************************************************************/
3200static void spy_request_sabotage_esc_list(QVariant data1, QVariant data2)
3201{
3202 int diplomat_id = data1.toInt();
3203 int diplomat_target_id = data2.toInt();
3204
3205 if (NULL != game_unit_by_number(diplomat_id)
3206 && NULL != game_city_by_number(diplomat_target_id)) {
3207 /* Wait for the server's reply before moving on to the next queued
3208 * diplomat. */
3210
3211 request_action_details(ACTION_SPY_TARGETED_SABOTAGE_CITY_ESC,
3212 diplomat_id, diplomat_target_id);
3213 }
3214}
3215
3216/***********************************************************************/
3219static void spy_poison(QVariant data1, QVariant data2)
3220{
3221 int diplomat_id = data1.toInt();
3222 int diplomat_target_id = data2.toInt();
3223
3224 if (NULL != game_unit_by_number(diplomat_id)
3225 && NULL != game_city_by_number(diplomat_target_id)) {
3226 request_do_action(ACTION_SPY_POISON,
3227 diplomat_id, diplomat_target_id, 0, "");
3228 }
3229}
3230
3231/***********************************************************************/
3234static void spy_poison_esc(QVariant data1, QVariant data2)
3235{
3236 int diplomat_id = data1.toInt();
3237 int diplomat_target_id = data2.toInt();
3238
3239 if (NULL != game_unit_by_number(diplomat_id)
3240 && NULL != game_city_by_number(diplomat_target_id)) {
3241 request_do_action(ACTION_SPY_POISON_ESC,
3242 diplomat_id, diplomat_target_id, 0, "");
3243 }
3244}
3245
3246/***********************************************************************/
3249static void spy_nuke_city(QVariant data1, QVariant data2)
3250{
3251 int diplomat_id = data1.toInt();
3252 int diplomat_target_id = data2.toInt();
3253
3254 if (NULL != game_unit_by_number(diplomat_id)
3255 && NULL != game_city_by_number(diplomat_target_id)) {
3256 request_do_action(ACTION_SPY_NUKE,
3257 diplomat_id, diplomat_target_id, 0, "");
3258 }
3259}
3260
3261/***********************************************************************/
3264static void spy_nuke_city_esc(QVariant data1, QVariant data2)
3265{
3266 int diplomat_id = data1.toInt();
3267 int diplomat_target_id = data2.toInt();
3268
3269 if (NULL != game_unit_by_number(diplomat_id)
3270 && NULL != game_city_by_number(diplomat_target_id)) {
3271 request_do_action(ACTION_SPY_NUKE_ESC,
3272 diplomat_id, diplomat_target_id, 0, "");
3273 }
3274}
3275
3276/***********************************************************************/
3279static void nuke_city(QVariant data1, QVariant data2)
3280{
3281 int actor_id = data1.toInt();
3282 int target_id = data2.toInt();
3283
3284 if (NULL != game_unit_by_number(actor_id)
3285 && NULL != game_city_by_number(target_id)) {
3286 request_do_action(ACTION_NUKE_CITY,
3287 actor_id, target_id, 0, "");
3288 }
3289}
3290
3291/***********************************************************************/
3294static void destroy_city(QVariant data1, QVariant data2)
3295{
3296 int diplomat_id = data1.toInt();
3297 int diplomat_target_id = data2.toInt();
3298
3299 if (NULL != game_unit_by_number(diplomat_id)
3300 && NULL != game_city_by_number(diplomat_target_id)) {
3301 request_do_action(ACTION_DESTROY_CITY,
3302 diplomat_id, diplomat_target_id, 0, "");
3303 }
3304}
3305
3306/***********************************************************************/
3309static void spy_steal_gold(QVariant data1, QVariant data2)
3310{
3311 int diplomat_id = data1.toInt();
3312 int diplomat_target_id = data2.toInt();
3313
3314 if (NULL != game_unit_by_number(diplomat_id)
3315 && NULL != game_city_by_number(diplomat_target_id)) {
3316 request_do_action(ACTION_SPY_STEAL_GOLD,
3317 diplomat_id, diplomat_target_id, 0, "");
3318 }
3319}
3320
3321/***********************************************************************/
3324static void spy_steal_gold_esc(QVariant data1, QVariant data2)
3325{
3326 int diplomat_id = data1.toInt();
3327 int diplomat_target_id = data2.toInt();
3328
3329 if (NULL != game_unit_by_number(diplomat_id)
3330 && NULL != game_city_by_number(diplomat_target_id)) {
3331 request_do_action(ACTION_SPY_STEAL_GOLD_ESC,
3332 diplomat_id, diplomat_target_id, 0, "");
3333 }
3334}
3335
3336/***********************************************************************/
3339static void spy_steal_maps(QVariant data1, QVariant data2)
3340{
3341 int diplomat_id = data1.toInt();
3342 int diplomat_target_id = data2.toInt();
3343
3344 if (NULL != game_unit_by_number(diplomat_id)
3345 && NULL != game_city_by_number(diplomat_target_id)) {
3346 request_do_action(ACTION_STEAL_MAPS,
3347 diplomat_id, diplomat_target_id, 0, "");
3348 }
3349}
3350
3351/***********************************************************************/
3354static void spy_steal_maps_esc(QVariant data1, QVariant data2)
3355{
3356 int diplomat_id = data1.toInt();
3357 int diplomat_target_id = data2.toInt();
3358
3359 if (NULL != game_unit_by_number(diplomat_id)
3360 && NULL != game_city_by_number(diplomat_target_id)) {
3361 request_do_action(ACTION_STEAL_MAPS_ESC,
3362 diplomat_id, diplomat_target_id, 0, "");
3363 }
3364}
3365
3366/***********************************************************************/
3369static void spy_embassy(QVariant data1, QVariant data2)
3370{
3371 int diplomat_id = data1.toInt();
3372 int diplomat_target_id = data2.toInt();
3373
3374 if (NULL != game_unit_by_number(diplomat_id)
3375 && NULL != game_city_by_number(diplomat_target_id)) {
3376 request_do_action(ACTION_ESTABLISH_EMBASSY, diplomat_id,
3377 diplomat_target_id, 0, "");
3378 }
3379}
3380
3381/***********************************************************************/
3384static void diplomat_embassy(QVariant data1, QVariant data2)
3385{
3386 int diplomat_id = data1.toInt();
3387 int diplomat_target_id = data2.toInt();
3388
3389 if (NULL != game_unit_by_number(diplomat_id)
3390 && NULL != game_city_by_number(diplomat_target_id)) {
3391 request_do_action(ACTION_ESTABLISH_EMBASSY_STAY, diplomat_id,
3392 diplomat_target_id, 0, "");
3393 }
3394}
3395
3396/***********************************************************************/
3399static void spy_investigate(QVariant data1, QVariant data2)
3400{
3401 int diplomat_id = data1.toInt();
3402 int diplomat_target_id = data2.toInt();
3403
3404 if (NULL != game_city_by_number(diplomat_target_id)
3405 && NULL != game_unit_by_number(diplomat_id)) {
3406 request_do_action(ACTION_SPY_INVESTIGATE_CITY, diplomat_id,
3407 diplomat_target_id, 0, "");
3408 }
3409}
3410
3411/***********************************************************************/
3414static void diplomat_investigate(QVariant data1, QVariant data2)
3415{
3416 int diplomat_id = data1.toInt();
3417 int diplomat_target_id = data2.toInt();
3418
3419 if (NULL != game_city_by_number(diplomat_target_id)
3420 && NULL != game_unit_by_number(diplomat_id)) {
3421 request_do_action(ACTION_INV_CITY_SPEND, diplomat_id,
3422 diplomat_target_id, 0, "");
3423 }
3424}
3425
3426/***********************************************************************/
3429static void diplomat_sabotage(QVariant data1, QVariant data2)
3430{
3431 int diplomat_id = data1.toInt();
3432 int diplomat_target_id = data2.toInt();
3433
3434 if (NULL != game_unit_by_number(diplomat_id)
3435 && NULL != game_city_by_number(diplomat_target_id)) {
3436 request_do_action(ACTION_SPY_SABOTAGE_CITY, diplomat_id,
3437 diplomat_target_id, B_LAST + 1, "");
3438 }
3439}
3440
3441/***********************************************************************/
3444static void diplomat_sabotage_esc(QVariant data1, QVariant data2)
3445{
3446 int diplomat_id = data1.toInt();
3447 int diplomat_target_id = data2.toInt();
3448
3449 if (NULL != game_unit_by_number(diplomat_id)
3450 && NULL != game_city_by_number(diplomat_target_id)) {
3451 request_do_action(ACTION_SPY_SABOTAGE_CITY_ESC, diplomat_id,
3452 diplomat_target_id, B_LAST + 1, "");
3453 }
3454}
3455
3456/***********************************************************************/
3459static void diplomat_steal(QVariant data1, QVariant data2)
3460{
3461 int diplomat_id = data1.toInt();
3462 int diplomat_target_id = data2.toInt();
3463
3464 if (NULL != game_unit_by_number(diplomat_id)
3465 && NULL != game_city_by_number(diplomat_target_id)) {
3466 request_do_action(ACTION_SPY_STEAL_TECH, diplomat_id,
3467 diplomat_target_id, A_UNSET, "");
3468 }
3469}
3470
3471/***********************************************************************/
3474static void diplomat_steal_esc(QVariant data1, QVariant data2)
3475{
3476 int diplomat_id = data1.toInt();
3477 int diplomat_target_id = data2.toInt();
3478
3479 if (NULL != game_unit_by_number(diplomat_id)
3480 && NULL != game_city_by_number(diplomat_target_id)) {
3481 request_do_action(ACTION_SPY_STEAL_TECH_ESC, diplomat_id,
3482 diplomat_target_id, A_UNSET, "");
3483 }
3484}
3485
3486/***********************************************************************/
3489static void diplomat_incite(QVariant data1, QVariant data2)
3490{
3491 int diplomat_id = data1.toInt();
3492 int diplomat_target_id = data2.toInt();
3493
3494 if (NULL != game_unit_by_number(diplomat_id)
3495 && NULL != game_city_by_number(diplomat_target_id)) {
3496 /* Wait for the server's reply before moving on to the next queued diplomat. */
3498
3499 request_action_details(ACTION_SPY_INCITE_CITY, diplomat_id,
3500 diplomat_target_id);
3501 }
3502}
3503
3504/***********************************************************************/
3507static void diplomat_incite_escape(QVariant data1, QVariant data2)
3508{
3509 int diplomat_id = data1.toInt();
3510 int diplomat_target_id = data2.toInt();
3511
3512 if (NULL != game_unit_by_number(diplomat_id)
3513 && NULL != game_city_by_number(diplomat_target_id)) {
3514 /* Wait for the server's reply before moving on to the next queued diplomat. */
3516
3517 request_action_details(ACTION_SPY_INCITE_CITY_ESC, diplomat_id,
3518 diplomat_target_id);
3519 }
3520}
3521
3522/***********************************************************************/
3525static void regular_move(QVariant data1, QVariant data2)
3526{
3527 int actor_id = data1.toInt();
3528 int target_id = data2.toInt();
3529
3530 if (NULL != game_unit_by_number(actor_id)
3531 && NULL != index_to_tile(&(wld.map), target_id)) {
3532 request_do_action(ACTION_UNIT_MOVE,
3533 actor_id, target_id, 0, "");
3534 }
3535}
3536
3537/***********************************************************************/
3541void popup_incite_dialog(struct unit *actor, struct city *tcity, int cost,
3542 const struct action *paction)
3543{
3544 char buf[1024];
3545 char buf2[1024];
3546 int diplomat_id = actor->id;
3547 int diplomat_target_id = tcity->id;
3548 const int act_id = paction->id;
3549
3550 /* Should be set before sending request to the server. */
3552
3553 fc_snprintf(buf, ARRAY_SIZE(buf), PL_("Treasury contains %d gold.",
3554 "Treasury contains %d gold.",
3555 client_player()->economic.gold),
3556 client_player()->economic.gold);
3557
3559 hud_message_box *impossible = new hud_message_box(gui()->central_wdg);
3560
3561 fc_snprintf(buf2, ARRAY_SIZE(buf2),
3562 _("You can't incite a revolt in %s."), city_name_get(tcity));
3563 impossible->set_text_title(buf2, "!");
3564 impossible->setStandardButtons(QMessageBox::Ok);
3565 impossible->setAttribute(Qt::WA_DeleteOnClose);
3566 impossible->show();
3567 } else if (cost <= client_player()->economic.gold) {
3568 hud_message_box *ask = new hud_message_box(gui()->central_wdg);
3569
3570 fc_snprintf(buf2, ARRAY_SIZE(buf2),
3571 PL_("Incite a revolt for %d gold?\n%s",
3572 "Incite a revolt for %d gold?\n%s", cost), cost, buf);
3573 ask->setStandardButtons(QMessageBox::Cancel | QMessageBox::Ok);
3574 ask->setDefaultButton(QMessageBox::Cancel);
3575 ask->set_text_title(buf2, _("Incite a Revolt!"));
3576 ask->setAttribute(Qt::WA_DeleteOnClose);
3577 QObject::connect(ask, &hud_message_box::accepted, [=]() {
3578 request_do_action(act_id, diplomat_id, diplomat_target_id, 0, "");
3580 });
3581 ask->show();
3582 return;
3583 } else {
3584 hud_message_box *too_much = new hud_message_box(gui()->central_wdg);
3585
3586 fc_snprintf(buf2, ARRAY_SIZE(buf2),
3587 PL_("Inciting a revolt costs %d gold.\n%s",
3588 "Inciting a revolt costs %d gold.\n%s", cost), cost,
3589 buf);
3590 too_much->set_text_title(buf2, "!");
3591 too_much->setStandardButtons(QMessageBox::Ok);
3592 too_much->setAttribute(Qt::WA_DeleteOnClose);
3593 too_much->show();
3594 }
3595
3597}
3598
3599/***********************************************************************/
3603void popup_bribe_dialog(struct unit *actor, struct unit *tunit, int cost,
3604 const struct action *paction)
3605{
3606 hud_message_box *ask = new hud_message_box(gui()->central_wdg);
3607 char buf[1024];
3608 char buf2[1024];
3609 int diplomat_id = actor->id;
3610 int diplomat_target_id = tunit->id;
3611 const int act_id = paction->id;
3612
3613 /* Should be set before sending request to the server. */
3615
3616 fc_snprintf(buf, ARRAY_SIZE(buf), PL_("Treasury contains %d gold.",
3617 "Treasury contains %d gold.",
3618 client_player()->economic.gold),
3619 client_player()->economic.gold);
3620
3621 if (cost <= client_player()->economic.gold) {
3622 fc_snprintf(buf2, ARRAY_SIZE(buf2), PL_("Bribe unit for %d gold?\n%s",
3623 "Bribe unit for %d gold?\n%s",
3624 cost), cost, buf);
3625 ask->set_text_title(buf2, _("Bribe Enemy Unit"));
3626 ask->setStandardButtons(QMessageBox::Cancel | QMessageBox::Ok);
3627 ask->setDefaultButton(QMessageBox::Cancel);
3628 ask->setAttribute(Qt::WA_DeleteOnClose);
3629 QObject::connect(ask, &hud_message_box::accepted, [=]() {
3630 request_do_action(act_id, diplomat_id, diplomat_target_id, 0, "");
3632 });
3633 ask->show();
3634 return;
3635 } else {
3636 fc_snprintf(buf2, ARRAY_SIZE(buf2),
3637 PL_("Bribing the unit costs %d gold.\n%s",
3638 "Bribing the unit costs %d gold.\n%s", cost), cost, buf);
3639 ask->set_text_title(buf2, _("Traitors Demand Too Much!"));
3640 ask->setAttribute(Qt::WA_DeleteOnClose);
3641 ask->show();
3642 }
3643
3645}
3646
3647/***********************************************************************/
3650static void pillage_something(QVariant data1, QVariant data2)
3651{
3652 int punit_id;
3653 int what;
3654 struct unit *punit;
3655 struct extra_type *target;
3656
3657 what = data1.toInt();
3658 punit_id = data2.toInt();
3659 punit = game_unit_by_number(punit_id);
3660 if (punit) {
3661 target = extra_by_number(what);
3662 request_new_unit_activity_targeted(punit, ACTIVITY_PILLAGE, target);
3663 }
3665}
3666
3667/***********************************************************************/
3670static void spy_sabotage(QVariant data1, QVariant data2)
3671{
3672 int diplomat_id = data1.toList().at(0).toInt();
3673 int diplomat_target_id = data1.toList().at(1).toInt();
3674 action_id act_id = data1.toList().at(2).toInt();
3675
3676 if (NULL != game_unit_by_number(diplomat_id)
3677 && NULL != game_city_by_number(diplomat_target_id)) {
3678 if (data2.toInt() == B_LAST) {
3679 /* This is the untargeted version. */
3681 diplomat_id, diplomat_target_id, data2.toInt(),
3682 "");
3683 } else if (data2.toInt() == -1) {
3684 /* This is the city production version. */
3686 diplomat_id, diplomat_target_id, data2.toInt(),
3687 "");
3688 } else {
3689 /* This is the targeted version. */
3690 request_do_action(act_id, diplomat_id,
3691 diplomat_target_id, data2.toInt(), "");
3692 }
3693 }
3694}
3695
3696/***********************************************************************/
3700void popup_sabotage_dialog(struct unit *actor, struct city *tcity,
3701 const struct action *paction)
3702{
3703 QString str;
3704 QVariant qv1, qv2;
3705 int diplomat_id = actor->id;
3706 int diplomat_target_id = tcity->id;
3708 choice_dialog *cd = new choice_dialog(_("Sabotage"),
3709 _("Select Improvement to Sabotage"),
3710 gui()->game_tab_widget,
3712 int nr = 0;
3713 struct astring stra = ASTRING_INIT;
3714 QList<QVariant> actor_and_target;
3715
3716 /* Should be set before sending request to the server. */
3718
3719 /* Put both actor, target city and action in qv1 since qv2 is taken */
3720 actor_and_target.append(diplomat_id);
3721 actor_and_target.append(diplomat_target_id);
3722 actor_and_target.append(paction->id);
3723 qv1 = QVariant::fromValue(actor_and_target);
3724
3727 paction->id)])) {
3729 cd->add_item(QString(_("City Production")), func, qv1, -1);
3730 }
3731
3732 city_built_iterate(tcity, pimprove) {
3733 if (pimprove->sabotage > 0) {
3735 // Defeat keyboard shortcut mnemonics
3736 str = QString(city_improvement_name_translation(tcity, pimprove))
3737 .replace("&", "&&");
3738 qv2 = nr;
3739 cd->add_item(str, func, qv1, improvement_number(pimprove));
3740 nr++;
3741 }
3743
3745 get_non_targeted_action_id(paction->id)])) {
3746 astr_set(&stra, _("At %s's Discretion"),
3749 str = QString(astr_str(&stra)).replace("&", "&&");
3750 cd->add_item(str, func, qv1, B_LAST);
3751 }
3752
3753 cd->set_layout();
3754 cd->show_me();
3755 astr_free(&stra);
3756}
3757
3758/***********************************************************************/
3762void popup_pillage_dialog(struct unit *punit, bv_extras extras)
3763{
3764 QString str;
3765 QVariant qv1, qv2;
3767 choice_dialog *cd;
3768 struct extra_type *tgt;
3769
3771 return;
3772 }
3773 cd = new choice_dialog(_("What To Pillage"), _("Select what to pillage:"),
3774 gui()->game_tab_widget);
3775 qv2 = punit->id;
3776 while ((tgt = get_preferred_pillage(extras))) {
3777 int what;
3778
3779 what = extra_index(tgt);
3780 BV_CLR(extras, what);
3781
3783 // Defeat keyboard shortcut mnemonics
3784 str = QString(extra_name_translation(tgt)).replace("&", "&&");
3785 qv1 = what;
3786 cd->add_item(str, func, qv1, qv2);
3787 }
3788 cd->set_layout();
3789 cd->show_me();
3790}
3791
3792/***********************************************************************/
3795disband_box::disband_box(struct unit_list *punits,
3796 QWidget *parent) : hud_message_box(parent)
3797{
3798 QString str;
3799 QPushButton *pb;
3800
3801 setAttribute(Qt::WA_DeleteOnClose);
3802 setModal(false);
3803 cpunits = unit_list_new();
3804 unit_list_iterate(punits, punit) {
3805 unit_list_append(cpunits, punit);
3807
3808 str = QString(PL_("Are you sure you want to disband that %1 unit?",
3809 "Are you sure you want to disband those %1 units?",
3810 unit_list_size(punits))).arg(unit_list_size(punits));
3811 pb = addButton(_("Yes"), QMessageBox::AcceptRole);
3812 addButton(_("No"), QMessageBox::RejectRole);
3813 set_text_title(str, _("Disband units"));
3814 setDefaultButton(pb);
3815 connect(pb, &QAbstractButton::clicked, this, &disband_box::disband_clicked);
3816}
3817
3818/***********************************************************************/
3822{
3824 if (unit_can_do_action(punit, ACTION_DISBAND_UNIT)) {
3826 }
3828}
3829
3830/***********************************************************************/
3834{
3835 unit_list_destroy(cpunits);
3836}
3837
3838/***********************************************************************/
3841void popup_disband_dialog(struct unit_list *punits)
3842{
3843 disband_box *ask = new disband_box(punits, gui()->central_wdg);
3844 ask->show();
3845}
3846
3847/***********************************************************************/
3852{
3853 hud_message_box *ask = new hud_message_box(gui()->central_wdg);
3854 QString text;
3855 QString title;
3856
3857 title = QString(_("Modpack suggests using %1 tileset."))
3859 text = QString("It might not work with other tilesets.\n"
3860 "You are currently using tileset %1.")
3862 ask->addButton(_("Keep current tileset"), QMessageBox::RejectRole);
3863 ask->addButton(_("Load tileset"), QMessageBox::AcceptRole);
3864 ask->set_text_title(text, title);
3865 ask->setAttribute(Qt::WA_DeleteOnClose);
3866
3867 QObject::connect(ask, &hud_message_box::accepted, [=]() {
3870 gui()->map_scale)) {
3872 _("Can't load requested tileset."));
3873 }
3874 });
3875 ask->show();
3876}
3877
3878/***********************************************************************/
3883{
3884 hud_message_box *ask = new hud_message_box(gui()->central_wdg);
3885 QString text;
3886 QString title;
3887
3888 title = QString(_("Modpack suggests using %1 soundset."))
3890 text = QString("It might not work with other tilesets.\n"
3891 "You are currently using soundset %1.")
3892 .arg(sound_set_name);
3893 ask->addButton(_("Keep current soundset"), QMessageBox::RejectRole);
3894 ask->addButton(_("Load soundset"), QMessageBox::AcceptRole);
3895 ask->set_text_title(text, title);
3896 ask->setAttribute(Qt::WA_DeleteOnClose);
3897 QObject::connect(ask, &hud_message_box::accepted, [=]() {
3899 });
3900 ask->show();
3901}
3902
3903/***********************************************************************/
3908{
3909 hud_message_box *ask = new hud_message_box(gui()->central_wdg);
3910 QString text;
3911 QString title;
3912
3913 title = QString(_("Modpack suggests using %1 musicset."))
3915 text = QString("It might not work with other tilesets.\n"
3916 "You are currently using musicset %1.")
3917 .arg(music_set_name);
3918 ask->addButton(_("Keep current musicset"), QMessageBox::RejectRole);
3919 ask->addButton(_("Load musicset"), QMessageBox::AcceptRole);
3920 ask->set_text_title(text, title);
3921 ask->setAttribute(Qt::WA_DeleteOnClose);
3922 QObject::connect(ask, &hud_message_box::accepted, [=]() {
3924 });
3925 ask->show();
3926}
3927
3928/***********************************************************************/
3932bool popup_theme_suggestion_dialog(const char *theme_name)
3933{
3934 /* PORTME */
3935 return false;
3936}
3937
3938/***********************************************************************/
3942{
3943 QList<notify_dialog *> nd_list;
3944 int i;
3945
3946 nd_list = gui()->mapview_wdg->findChildren<notify_dialog *>();
3947 for (i = 0; i < nd_list.count(); i++) {
3948 nd_list[i]->restart();
3949 delete nd_list[i];
3950 }
3951}
3952
3953/***********************************************************************/
3958{
3959 int i;
3960 QList <choice_dialog *> cd_list;
3961 QList <notify_dialog *> nd_list;
3962 goto_dialog *gtd;
3963
3964 QApplication::alert(gui()->central_wdg);
3965 cd_list = gui()->game_tab_widget->findChildren <choice_dialog *>();
3966 for (i = 0; i < cd_list.count(); i++) {
3967 cd_list[i]->close();
3968 }
3969 nd_list = gui()->game_tab_widget->findChildren <notify_dialog *>();
3970 for (i = 0; i < nd_list.count(); i++) {
3971 nd_list[i]->close();
3972 }
3973
3982 gui()->popdown_unit_sel();
3983
3984 gtd = gui()->gtd;
3985
3986 if (gtd != nullptr) {
3987 gtd->close_dlg();
3988 }
3989}
3990
3991/***********************************************************************/
3997{
3998 choice_dialog *cd = gui()->get_diplo_dialog();
3999
4000 if (cd != NULL) {
4001 return cd->unit_id;
4002 } else {
4003 return IDENTITY_NUMBER_ZERO;
4004 }
4005}
4006
4007/***********************************************************************/
4014{
4015 choice_dialog *cd = gui()->get_diplo_dialog();
4016
4017 if (cd != NULL) {
4018 return cd->target_id[ATK_CITY];
4019 } else {
4020 return IDENTITY_NUMBER_ZERO;
4021 }
4022}
4023
4024/***********************************************************************/
4031{
4032 choice_dialog *cd = gui()->get_diplo_dialog();
4033
4034 if (cd != NULL) {
4035 return cd->target_id[ATK_TILE];
4036 } else {
4037 return TILE_INDEX_NONE;
4038 }
4039}
4040
4041/**********************************************************************/
4048{
4049 choice_dialog *cd = gui()->get_diplo_dialog();
4050
4051 if (cd != NULL) {
4052 return cd->sub_target_id[ASTK_EXTRA];
4053 } else {
4054 return EXTRA_NONE;
4055 }
4056}
4057
4058/***********************************************************************/
4065{
4066 choice_dialog *cd = gui()->get_diplo_dialog();
4067
4068 if (cd != NULL) {
4069 return cd->target_id[ATK_UNIT];
4070 } else {
4071 return IDENTITY_NUMBER_ZERO;
4072 }
4073}
4074
4075/***********************************************************************/
4079 struct city *target_city,
4080 struct unit *target_unit,
4081 struct tile *target_tile,
4082 struct extra_type *target_extra,
4083 const struct act_prob *act_probs)
4084{
4085 choice_dialog *asd;
4086 Choice_dialog_button *wait_button;
4087 Choice_dialog_button *cancel_button;
4088 QVariant qv1, qv2;
4089
4090 asd = gui()->get_diplo_dialog();
4091 if (asd == NULL) {
4092 fc_assert_msg(asd != NULL,
4093 "The action selection dialog should have been open");
4094 return;
4095 }
4096
4099 "The action selection dialog is for another actor unit.");
4100 }
4101
4102 /* Put the actor id in qv1. */
4103 qv1 = actor_unit->id;
4104
4105 cancel_button = asd->get_identified_button(BUTTON_CANCEL);
4106 if (cancel_button != NULL) {
4107 /* Temporary remove the Cancel button so it won't end up above
4108 * any added buttons. */
4109 asd->stack_button(cancel_button);
4110 }
4111
4112 wait_button = asd->get_identified_button(BUTTON_WAIT);
4113 if (wait_button != NULL) {
4114 /* Temporary remove the Wait button so it won't end up above
4115 * any added buttons. */
4116 asd->stack_button(wait_button);
4117 }
4118
4119 action_iterate(act) {
4120 const char *custom;
4121
4122 if (action_id_get_actor_kind(act) != AAK_UNIT) {
4123 /* Not relevant. */
4124 continue;
4125 }
4126
4128 act_probs[act],
4129 actor_unit,
4130 target_city);
4131
4132 /* Put the target id in qv2. */
4133 switch (action_id_get_target_kind(act)) {
4134 case ATK_UNIT:
4135 if (target_unit != NULL) {
4136 qv2 = target_unit->id;
4137 } else {
4138 fc_assert_msg(!action_prob_possible(act_probs[act])
4139 || target_unit != NULL,
4140 "Action enabled against non existing unit!");
4141
4143 }
4144 break;
4145 case ATK_CITY:
4146 if (target_city != NULL) {
4147 qv2 = target_city->id;
4148 } else {
4149 fc_assert_msg(!action_prob_possible(act_probs[act])
4150 || target_city != NULL,
4151 "Action enabled against non existing city!");
4152
4154 }
4155 break;
4156 case ATK_TILE:
4157 case ATK_EXTRAS:
4158 case ATK_UNITS:
4159 if (target_tile != NULL) {
4160 qv2 = tile_index(target_tile);
4161 } else {
4162 fc_assert_msg(!action_prob_possible(act_probs[act])
4163 || target_tile != NULL,
4164 "Action enabled against all units on "
4165 "non existing tile!");
4166
4167 qv2 = TILE_INDEX_NONE;
4168 }
4169 break;
4170 case ATK_SELF:
4171 qv2 = actor_unit->id;
4172 break;
4173 case ATK_COUNT:
4174 fc_assert_msg(ATK_COUNT != action_id_get_target_kind(act),
4175 "Bad target kind");
4176 continue;
4177 }
4178
4179 if (asd->get_identified_button(act)) {
4180 /* Update the existing button. */
4182 act, act_probs, custom,
4183 qv1, qv2);
4184 } else {
4185 /* Add the button (unless its probability is 0). */
4186 action_entry(asd, act, act_probs, custom,
4187 qv1, qv2);
4188 }
4190
4191 if (wait_button != NULL || cancel_button != NULL) {
4192 /* Reinsert the non action buttons below any potential
4193 * buttons recently added. */
4194 asd->unstack_all_buttons();
4195 }
4196}
4197
4198/***********************************************************************/
4202{
4203 choice_dialog *cd;
4204
4205 cd = gui()->get_diplo_dialog();
4206 if (cd != NULL) {
4207 did_not_decide = true;
4208 cd->close();
4209 }
4210}
4211
4212/***********************************************************************/
4218
4219/***********************************************************************/
4222void show_tileset_error(bool fatal, const char *tset_name, const char *msg)
4223{
4224 QWidget *parent;
4225 fc_client *std_gui = gui();
4226
4227 if (std_gui != nullptr) {
4228 parent = std_gui->central_wdg;
4229 } else {
4230 parent = nullptr;
4231 }
4232
4233 if (std_gui != nullptr || fatal) {
4234 char buf[1024];
4235 QMessageBox *ask = new QMessageBox(parent);
4236
4237 if (tset_name != NULL) {
4238 fc_snprintf(buf, sizeof(buf),
4239 _("Tileset \"%s\" problem, it's probably incompatible with "
4240 "the ruleset:\n%s"), tset_name, msg);
4241 } else {
4242 fc_snprintf(buf, sizeof(buf),
4243 _("Tileset problem, it's probably incompatible with "
4244 "the ruleset:\n%s"), msg);
4245 }
4246
4247 ask->setText(buf);
4248 ask->setStandardButtons(QMessageBox::Ok);
4249 ask->setWindowTitle(_("Tileset error"));
4250
4251 if (std_gui != nullptr) {
4252 ask->setAttribute(Qt::WA_DeleteOnClose);
4253 ask->show();
4254 } else {
4255 ask->exec();
4256 }
4257 }
4258}
4259
4260/***********************************************************************/
4263void popup_upgrade_dialog(struct unit_list *punits)
4264{
4265 char buf[512];
4266 hud_message_box *ask;
4267 QString title;
4268 QVector<int> *punit_ids;
4269
4270 if (!punits || unit_list_size(punits) == 0) {
4271 return;
4272 }
4273
4274 ask = new hud_message_box(gui()->central_wdg);
4275
4276 punit_ids = new QVector<int>();
4277 unit_list_iterate(punits, punit) {
4278 punit_ids->push_back(punit->id);
4280
4281 if (!get_units_upgrade_info(buf, sizeof(buf), punits)) {
4282 title = _("Upgrade Unit!");
4283 ask->setStandardButtons(QMessageBox::Ok);
4284 } else {
4285 title = _("Upgrade Obsolete Units");
4286 ask->setStandardButtons(QMessageBox::Cancel | QMessageBox::Ok);
4287 ask->setDefaultButton(QMessageBox::Cancel);
4288 }
4289 ask->set_text_title(buf, title);
4290 ask->setAttribute(Qt::WA_DeleteOnClose);
4291 QObject::connect(ask, &hud_message_box::accepted, [=]() {
4292 std::unique_ptr<QVector<int>> uptr(punit_ids);
4293 struct unit *punit;
4294
4295 for (int id : *uptr) {
4297 if (punit) {
4299 }
4300 }
4301 });
4302 ask->show();
4303}
4304
4305/***********************************************************************/
4308units_select::units_select(tile *ptile, QWidget *parent)
4309{
4310 QPoint p, final_p;
4311
4312 setParent(parent);
4313 utile = ptile;
4314 pix = NULL;
4315 show_line = 0;
4316 highligh_num = -1;
4317 ufont.setItalic(true);
4319 update_units();
4320 h_pix = NULL;
4321 create_pixmap();
4322 p = mapFromGlobal(QCursor::pos());
4323 cw = new close_widget(this);
4324 setMouseTracking(true);
4325 final_p.setX(p.x());
4326 final_p.setY(p.y());
4327 if (p.x() + width() > parentWidget()->width()) {
4328 final_p.setX(parentWidget()->width() - width());
4329 }
4330 if (p.y() - height() < 0) {
4331 final_p.setY(height());
4332 }
4333 move(final_p.x(), final_p.y() - height());
4334 setFocus();
4335 /* Build fails with qt5 connect style for static functions
4336 * Qt5.2 so dont update */
4337 QTimer::singleShot(10, this, SLOT(update_img()));
4338}
4339
4340/***********************************************************************/
4344{
4345 delete h_pix;
4346 delete pix;
4347 delete cw;
4348}
4349
4350/***********************************************************************/
4354{
4355 int a;
4356 int x, y, i;
4357 QFontMetrics fm(info_font);
4358 QImage cropped_img;
4359 QImage img;
4360 QList <QPixmap*>pix_list;
4361 QPainter p;
4362 QPen pen;
4363 QPixmap pixc;
4364 QPixmap *pixp;
4365 QPixmap *tmp_pix;
4366 QRect crop;
4367 struct canvas *unit_pixmap;
4368 struct unit *punit;
4369 float isosize;
4370
4371 if (pix != NULL) {
4372 delete pix;
4373 pix = NULL;
4374 };
4375 isosize = 0.7;
4377 isosize = 0.5;
4378 }
4379
4380 update_units();
4381 if (unit_list.count() > 0) {
4385 } else {
4386 item_size.setWidth(tileset_unit_width(tileset) * isosize);
4387 item_size.setHeight(tileset_unit_width(tileset) * isosize);
4388 }
4389 more = false;
4390 if (h_pix != nullptr) {
4391 delete h_pix;
4392 }
4393 h_pix = new QPixmap(item_size.width(), item_size.height());
4394 h_pix->fill(palette().color(QPalette::HighlightedText));
4395 if (unit_count < 5) {
4396 row_count = 1;
4397 pix = new QPixmap((unit_list.size()) * item_size.width(),
4398 item_size.height());
4399 } else if (unit_count < 9) {
4400 row_count = 2;
4401 pix = new QPixmap(4 * item_size.width(), 2 * item_size.height());
4402 } else {
4403 row_count = 3;
4404 if (unit_count > 12) {
4405 more = true;
4406 }
4407 pix = new QPixmap(4 * item_size.width(), 3 * item_size.height());
4408 }
4409 pix->fill(Qt::transparent);
4410 foreach(punit, unit_list) {
4413 unit_pixmap->map_pixmap.fill(Qt::transparent);
4414 put_unit(punit, unit_pixmap, 1.0, 0, 0);
4415 img = unit_pixmap->map_pixmap.toImage();
4416 crop = zealous_crop_rect(img);
4417 cropped_img = img.copy(crop);
4419 img = cropped_img.scaled(tileset_unit_width(tileset),
4421 Qt::KeepAspectRatio,
4422 Qt::SmoothTransformation);
4423 } else {
4424 img = cropped_img.scaled(tileset_unit_width(tileset) * isosize,
4425 tileset_unit_width(tileset) * isosize,
4426 Qt::KeepAspectRatio,
4427 Qt::SmoothTransformation);
4428 }
4429 pixc = QPixmap::fromImage(img);
4430 pixp = new QPixmap(pixc);
4431 pix_list.push_back(pixp);
4432 qtg_canvas_free(unit_pixmap);
4433 }
4434 a = qMin(item_size.width() / 4, 12);
4435 x = 0, y = -item_size.height(), i = -1;
4436 p.begin(pix);
4437 ufont.setPixelSize(a);
4438 p.setFont(ufont);
4439 pen.setColor(palette().color(QPalette::Text));
4440 p.setPen(pen);
4441
4442 while (!pix_list.isEmpty()) {
4443 tmp_pix = pix_list.takeFirst();
4444 i++;
4445 if (i % 4 == 0) {
4446 x = 0;
4447 y = y + item_size.height();
4448 }
4449 punit = unit_list.at(i);
4450 Q_ASSERT(punit != NULL);
4451
4452 if (i == highligh_num) {
4453 p.drawPixmap(x, y, *h_pix);
4454 p.drawPixmap(x, y, *tmp_pix);
4455 } else {
4456 p.drawPixmap(x, y, *tmp_pix);
4457 }
4458
4460 int rate, f;
4461 QString str;
4462
4463 rate = unit_type_get(punit)->move_rate;
4464 f = ((punit->fuel) - 1);
4465 str = QString(move_points_text(punit->moves_left, false));
4467 str = str + "(" + QString(move_points_text((rate * f)
4468 + punit->moves_left, false)) + ")";
4469 }
4470 /* TRANS: MP = Movement points */
4471 str = QString(_("MP:")) + str;
4472 p.drawText(x, y + item_size.height() - 4, str);
4473 }
4474
4475 x = x + item_size.width();
4476 delete tmp_pix;
4477 }
4478 p.end();
4479 setFixedWidth(pix->width() + 20);
4480 setFixedHeight(pix->height() + 2 * (fm.height() + 6));
4481 qDeleteAll(pix_list.begin(), pix_list.end());
4482 }
4483}
4484
4485/***********************************************************************/
4489{
4490 int a, b;
4491 int old_h;
4492 QFontMetrics fm(info_font);
4493 QPoint pos = event->pos();
4494 int x = pos.x();
4495 int y = pos.y();
4496
4497 old_h = highligh_num;
4498 highligh_num = -1;
4499 if (x > width() - 11
4500 || y > height() - fm.height() - 5
4501 || y < fm.height() + 3 || x < 11) {
4502 // Do nothing if mouse is on border, just skip next if
4503 } else if (row_count > 0) {
4504 a = (x - 10) / item_size.width();
4505 b = (y - fm.height() - 3) / item_size.height();
4506 highligh_num = b * 4 + a;
4507 }
4508 if (old_h != highligh_num) {
4509 create_pixmap();
4510 update();
4511 }
4512}
4513
4514/***********************************************************************/
4520{
4521 struct unit *punit;
4522 if (event->button() == Qt::RightButton) {
4523 was_destroyed = true;
4524 close();
4525 destroy();
4526 }
4527 if (event->button() == Qt::LeftButton && highligh_num != -1) {
4528 update_units();
4529 if (highligh_num >= unit_list.count()) {
4530 return;
4531 }
4534 was_destroyed = true;
4535 close();
4536 destroy();
4537 }
4538}
4539
4540/***********************************************************************/
4545{
4546 create_pixmap();
4547 update();
4548}
4549
4550/***********************************************************************/
4553void units_select::paint(QPainter *painter, QPaintEvent *event)
4554{
4555 QFontMetrics fm(info_font);
4556 int h, i;
4557 int *f_size;
4558 QPen pen;
4559 QString str, str2;
4560 struct unit *punit;
4561 int point_size = info_font.pointSize();
4562 int pixel_size = info_font.pixelSize();
4563
4564 if (point_size < 0) {
4565 f_size = &pixel_size;
4566 } else {
4567 f_size = &point_size;
4568 }
4569 if (highligh_num != -1 && highligh_num < unit_list.count()) {
4570 struct astring addition = ASTRING_INIT;
4571
4573 unit_activity_astr(punit, &addition);
4574
4575 // TRANS: HP - hit points
4576 str2 = QString(_("%1 HP:%2/%3")).arg(QString(astr_str(&addition)),
4577 QString::number(punit->hp),
4578 QString::number(unit_type_get(punit)->hp));
4579 astr_free(&addition);
4580 }
4581 str = QString(PL_("%1 unit", "%1 units",
4582 unit_list_size(utile->units)))
4583 .arg(unit_list_size(utile->units));
4584 for (i = *f_size; i > 4; i--) {
4585 if (point_size < 0) {
4586 info_font.setPixelSize(i);
4587 } else {
4588 info_font.setPointSize(i);
4589 }
4590 QFontMetrics qfm(info_font);
4591 if (10 + qfm.horizontalAdvance(str2) < width()) {
4592 break;
4593 }
4594 }
4595 h = fm.height();
4596 if (pix != NULL) {
4597 painter->drawPixmap(10, h + 3, *pix);
4598 pen.setColor(palette().color(QPalette::Text));
4599 painter->setPen(pen);
4600 painter->setFont(info_font);
4601 painter->drawText(10, h, str);
4602 if (highligh_num != -1 && highligh_num < unit_list.count()) {
4603 painter->drawText(10, height() - 5, str2);
4604 }
4605 /* draw scroll */
4606 if (more) {
4607 int maxl = ((unit_count - 1) / 4) + 1;
4608 float page_height = 3.0f / maxl;
4609 float page_start = (static_cast<float>(show_line)) / maxl;
4610 pen.setColor(palette().color(QPalette::HighlightedText));
4611 painter->setBrush(palette().color(QPalette::HighlightedText).darker());
4612 painter->setPen(palette().color(QPalette::HighlightedText).darker());
4613 painter->drawRect(pix->width() + 10, h, 8, h + pix->height());
4614 painter->setPen(pen);
4615 painter->drawRoundedRect(pix->width() + 10,
4616 h + page_start * pix->height(),
4617 8, h + page_height * pix->height(), 2, 2);
4618 }
4619 }
4620 if (point_size < 0) {
4621 info_font.setPixelSize(*f_size);
4622 } else {
4623 info_font.setPointSize(*f_size);
4624 }
4625 cw->put_to_corner();
4626}
4627
4628/***********************************************************************/
4632{
4633 QPainter painter;
4634
4635 painter.begin(this);
4636 paint(&painter, event);
4637 painter.end();
4638}
4639
4640/***********************************************************************/
4645{
4646 was_destroyed = true;
4647 close();
4648 destroy();
4649}
4650
4651/***********************************************************************/
4655{
4656 int i = 1;
4657 struct unit_list *punit_list;
4658
4659 unit_count = 0;
4660 if (utile == NULL) {
4661 struct unit *punit = head_of_units_in_focus();
4662 if (punit) {
4664 }
4665 }
4666 unit_list.clear();
4667 if (utile != nullptr) {
4668 punit_list = utile->units;
4669 if (punit_list != nullptr) {
4671 unit_count++;
4672 if (i > show_line * 4)
4673 unit_list.push_back(punit);
4674 i++;
4676 }
4677 }
4678 if (unit_list.count() == 0) {
4679 close();
4680 }
4681}
4682
4683/***********************************************************************/
4687{
4688 gui()->mapview_wdg->setFocus();
4689 QWidget::closeEvent(event);
4690}
4691
4692/***********************************************************************/
4696{
4697 int nr;
4698
4699 if (!more && utile == NULL) {
4700 return;
4701 }
4702 nr = qCeil(static_cast<qreal>(unit_list_size(utile->units)) / 4) - 3;
4703 if (event->angleDelta().y() < 0) {
4704 show_line++;
4705 show_line = qMin(show_line, nr);
4706 } else {
4707 show_line--;
4708 show_line = qMax(0, show_line);
4709 }
4710 update_units();
4711 create_pixmap();
4712 update();
4713 event->accept();
4714}
4715
4716/***********************************************************************/
4720{
4721 if (event->key() == Qt::Key_Escape) {
4722 was_destroyed = true;
4723 close();
4724 destroy();
4725 }
4726 QWidget::keyPressEvent(event);
4727}
4728
4729/***********************************************************************/
4736
4737/***********************************************************************/
4744
4745/***********************************************************************/
4750{
4751 /* Just tell the client common code to handle this. */
4752 return false;
4753}
4754
4755/***********************************************************************/
4758bool qtg_request_transport(struct unit *pcargo, struct tile *ptile)
4759{
4760 int tcount;
4761 hud_unit_loader *hul;
4762 struct unit_list *potential_transports = unit_list_new();
4763#ifndef FREECIV_NDEBUG
4764 struct unit *best_transport = transporter_for_unit_at(pcargo, ptile);
4765#endif
4766
4767 unit_list_iterate(ptile->units, ptransport) {
4768 if (could_unit_load(pcargo, ptransport)) {
4769 unit_list_append(potential_transports, ptransport);
4770 }
4772
4773 tcount = unit_list_size(potential_transports);
4774
4775 if (tcount == 0) {
4776 fc_assert(best_transport == NULL);
4777 unit_list_destroy(potential_transports);
4778
4779 return false; /* Unit was not handled here. */
4780 } else if (tcount == 1) {
4781 /* There's exactly one potential transport - use it automatically */
4782 fc_assert(unit_list_get(potential_transports, 0) == best_transport);
4783 request_unit_load(pcargo, unit_list_get(potential_transports, 0), ptile);
4784
4785 unit_list_destroy(potential_transports);
4786
4787 return true;
4788 }
4789
4790 hul = new hud_unit_loader(pcargo, ptile);
4791 hul->show_me();
4792 return true;
4793}
4794
4795/***********************************************************************/
4799void qtg_popup_combat_info(int attacker_unit_id, int defender_unit_id,
4800 int attacker_hp, int defender_hp,
4801 bool make_att_veteran, bool make_def_veteran)
4802{
4803 if (gui()->qt_settings.show_battle_log) {
4804 hud_unit_combat* huc = new hud_unit_combat(attacker_unit_id,
4805 defender_unit_id,
4806 attacker_hp, defender_hp,
4807 make_att_veteran,
4808 make_def_veteran,
4809 gui()->battlelog_wdg->scale,
4810 gui()->battlelog_wdg);
4811
4812 gui()->battlelog_wdg->add_combat_info(huc);
4813 gui()->battlelog_wdg->show();
4814 }
4815}
const char * action_prepare_ui_name(action_id act_id, const char *mnemonic, const struct act_prob prob, const char *custom)
Definition actions.c:1972
bool action_prob_possible(const struct act_prob probability)
Definition actions.c:6707
static struct action * action_by_number(action_id act_id)
Definition actions.h:638
#define action_iterate_end
Definition actions.h:472
#define action_id_get_actor_kind(act_id)
Definition actions.h:651
#define action_iterate(_act_)
Definition actions.h:467
#define action_id_get_target_kind(act_id)
Definition actions.h:655
#define ACTION_NONE
Definition actions.h:293
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:369
#define BV_CLR(bv, bit)
Definition bitvector.h:86
QRect zealous_crop_rect(QImage &p)
Definition canvas.cpp:399
void qtg_canvas_free(struct canvas *store)
Definition canvas.cpp:47
struct canvas * qtg_canvas_create(int width, int height)
Definition canvas.cpp:35
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:658
const char * city_name_get(const struct city *pcity)
Definition city.c:1111
#define INCITE_IMPOSSIBLE_COST
Definition city.h:88
#define city_owner(_pcity_)
Definition city.h:543
#define city_built_iterate(_pcity, _p)
Definition city.h:801
#define city_built_iterate_end
Definition city.h:807
void qtg_real_city_dialog_popup(struct city *pcity)
Definition citydlg.cpp:3706
Choice_dialog_button(const QString title, pfcn_void func_in, QVariant data1_in, QVariant data2_in)
Definition dialogs.cpp:1315
void setData2(QVariant wariat)
Definition dialogs.cpp:1363
void setData1(QVariant wariat)
Definition dialogs.cpp:1355
pfcn_void getFunc()
Definition dialogs.cpp:1329
void stack_button(Choice_dialog_button *button)
Definition dialogs.cpp:1689
void prev_unit()
Definition dialogs.cpp:1606
QVBoxLayout * layout
Definition dialogs.h:263
struct unit * targeted_unit
Definition dialogs.h:286
void unstack_all_buttons()
Definition dialogs.cpp:1706
Choice_dialog_button * get_identified_button(const int id)
Definition dialogs.cpp:1518
QPushButton * target_unit_button
Definition dialogs.h:262
void set_layout()
Definition dialogs.cpp:1424
void update_dialog(const struct act_prob *act_probs)
Definition dialogs.cpp:1635
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:1371
void next_unit()
Definition dialogs.cpp:1566
QVBoxLayout * get_layout()
Definition dialogs.cpp:1510
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:1653
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:1672
void add_item(QString title, pfcn_void func, QVariant data1, QVariant data2, QString tool_tip, const int button_id)
Definition dialogs.cpp:1466
void put_to_corner()
Definition mapview.cpp:500
void disband_clicked()
Definition dialogs.cpp:3821
disband_box(struct unit_list *punits, QWidget *parent=0)
Definition dialogs.cpp:3795
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:4740
void set_diplo_dialog(choice_dialog *widget)
Definition dialogs.cpp:4732
QWidget * central_wdg
Definition fc_client.h:256
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:891
close_widget * cw
Definition dialogs.h:189
void mouseReleaseEvent(QMouseEvent *event)
Definition dialogs.cpp:982
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:858
void calc_size(int &x, int &y)
Definition dialogs.cpp:919
void paintEvent(QPaintEvent *paint_event)
Definition dialogs.cpp:938
QPoint cursor
Definition dialogs.h:196
void mouseMoveEvent(QMouseEvent *event)
Definition dialogs.cpp:973
virtual void update_menu()
Definition dialogs.cpp:990
void mousePressEvent(QMouseEvent *event)
Definition dialogs.cpp:961
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:1091
QPushButton * goto_but
Definition dialogs.h:111
void inspect_city()
Definition dialogs.cpp:1134
struct tile * gtile
Definition dialogs.h:114
QPushButton * inspect_but
Definition dialogs.h:112
void goto_tile()
Definition dialogs.cpp:1125
action_id vs_unit
Definition dialogs.h:60
static qdef_act * action()
Definition dialogs.cpp:1019
action_id vs_city_get()
Definition dialogs.cpp:1057
static qdef_act * m_instance
Definition dialogs.h:58
static void drop()
Definition dialogs.cpp:1030
action_id vs_city
Definition dialogs.h:59
void vs_city_set(int i)
Definition dialogs.cpp:1041
void vs_unit_set(int i)
Definition dialogs.cpp:1049
action_id vs_unit_get()
Definition dialogs.cpp:1065
QPoint point
Definition dialogs.h:81
void paintEvent(QPaintEvent *event)
Definition dialogs.cpp:330
QPixmap close_pix
Definition dialogs.h:83
void reactivate()
Definition dialogs.cpp:322
void mouseMoveEvent(QMouseEvent *event)
Definition dialogs.cpp:371
int titlebar_height
Definition dialogs.h:80
void mousePressEvent(QMouseEvent *event)
Definition dialogs.cpp:381
void mouseReleaseEvent(QMouseEvent *event)
Definition dialogs.cpp:401
qfc_dialog(QWidget *parent)
Definition dialogs.cpp:310
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:1081
void style_selected(const QItemSelection &sl, const QItemSelection &ds)
Definition dialogs.cpp:786
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:595
void nation_selected(const QItemSelection &sl, const QItemSelection &ds)
Definition dialogs.cpp:733
void nationset_changed(int index)
Definition dialogs.cpp:1146
int selected_nation
Definition dialogs.h:163
void ok_pressed()
Definition dialogs.cpp:820
void leader_selected(int index)
Definition dialogs.cpp:805
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:661
void set_index(int index)
Definition dialogs.cpp:679
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:645
QTableWidget * styles
Definition dialogs.h:140
struct player * tplayer
Definition dialogs.h:165
races_dialog(struct player *pplayer, QWidget *parent=0)
Definition dialogs.cpp:410
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:1073
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:4686
void update_img()
Definition dialogs.cpp:4544
int show_line
Definition dialogs.h:233
void mouseMoveEvent(QMouseEvent *event)
Definition dialogs.cpp:4488
int highligh_num
Definition dialogs.h:234
void paint(QPainter *painter, QPaintEvent *event)
Definition dialogs.cpp:4553
void update_menu()
Definition dialogs.cpp:4644
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:4308
void update_units()
Definition dialogs.cpp:4654
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:4631
void create_pixmap()
Definition dialogs.cpp:4353
void wheelEvent(QWheelEvent *event)
Definition dialogs.cpp:4695
void keyPressEvent(QKeyEvent *event)
Definition dialogs.cpp:4719
void mousePressEvent(QMouseEvent *event)
Definition dialogs.cpp:4519
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:1241
void action_selection_no_longer_in_progress(const int old_actor_id)
Definition control.c:1032
void request_unit_load(struct unit *pcargo, struct unit *ptrans, struct tile *ptile)
Definition control.c:2056
void unit_focus_set(struct unit *punit)
Definition control.c:502
void request_do_action(action_id action, int actor_id, int target_id, int sub_tgt, const char *name)
Definition control.c:1675
void request_unit_disband(struct unit *punit)
Definition control.c:1975
void request_action_details(action_id action, int actor_id, int target_id)
Definition control.c:1695
void request_new_unit_activity_targeted(struct unit *punit, enum unit_activity act, struct extra_type *tgt)
Definition control.c:1837
void action_decision_clear_want(const int old_actor_id)
Definition control.c:1053
void key_unit_wait(void)
Definition control.c:3348
struct unit * head_of_units_in_focus(void)
Definition control.c:406
void request_unit_upgrade(struct unit *punit)
Definition control.c:2006
void action_selection_next_in_focus(const int old_actor_id)
Definition control.c:1065
bool qtg_handmade_scenario_warning()
Definition dialogs.cpp:4749
static void attack(QVariant data1, QVariant data2)
Definition dialogs.cpp:2917
char forced_tileset_name[512]
int action_selection_target_extra(void)
Definition dialogs.cpp:4047
static void destroy_city(QVariant data1, QVariant data2)
Definition dialogs.cpp:3294
static void spy_sabotage_unit(QVariant data1, QVariant data2)
Definition dialogs.cpp:2428
static void pillage(QVariant data1, QVariant data2)
Definition dialogs.cpp:2758
static void caravan_marketplace(QVariant data1, QVariant data2)
Definition dialogs.cpp:1720
static void clean_pollution(QVariant data1, QVariant data2)
Definition dialogs.cpp:2778
static void spy_steal_shared(QVariant data1, QVariant data2, action_id act_id)
Definition dialogs.cpp:3052
static void clean_fallout(QVariant data1, QVariant data2)
Definition dialogs.cpp:2798
static void spy_sabotage(QVariant data1, QVariant data2)
Definition dialogs.cpp:3670
int action_selection_target_tile(void)
Definition dialogs.cpp:4030
static void spy_investigate(QVariant data1, QVariant data2)
Definition dialogs.cpp:3399
static void act_sel_wait(QVariant data1, QVariant data2)
Definition dialogs.cpp:1889
static void nuke_units(QVariant data1, QVariant data2)
Definition dialogs.cpp:2630
int action_selection_actor_unit(void)
Definition dialogs.cpp:3996
static void capture_units(QVariant data1, QVariant data2)
Definition dialogs.cpp:2642
static void road(QVariant data1, QVariant data2)
Definition dialogs.cpp:2818
static bool is_race_dialog_open
Definition dialogs.cpp:178
bool try_default_unit_action(QVariant q1, QVariant q2)
Definition dialogs.cpp:1531
static void fortify(QVariant data1, QVariant data2)
Definition dialogs.cpp:2370
static void transport_board(QVariant data1, QVariant data2)
Definition dialogs.cpp:2474
static void spy_sabotage_unit_esc(QVariant data1, QVariant data2)
Definition dialogs.cpp:2440
static void disband_unit(QVariant data1, QVariant data2)
Definition dialogs.cpp:2358
static void spy_steal_gold(QVariant data1, QVariant data2)
Definition dialogs.cpp:3309
void popdown_players_report()
Definition plrdlg.cpp:1159
static void mine(QVariant data1, QVariant data2)
Definition dialogs.cpp:2860
void popup_musicset_suggestion_dialog(void)
Definition dialogs.cpp:3907
static void spy_steal_gold_esc(QVariant data1, QVariant data2)
Definition dialogs.cpp:3324
static void diplomat_embassy(QVariant data1, QVariant data2)
Definition dialogs.cpp:3384
void unit_select_dialog_popup(struct tile *ptile)
Definition dialogs.cpp:1231
void popup_upgrade_dialog(struct unit_list *punits)
Definition dialogs.cpp:4263
void update_nationset_combo()
Definition dialogs.cpp:1251
void action_selection_close(void)
Definition dialogs.cpp:4201
static void cultivate(QVariant data1, QVariant data2)
Definition dialogs.cpp:2728
static void paradrop_enter(QVariant data1, QVariant data2)
Definition dialogs.cpp:3007
void races_update_pickable(bool nationset_change)
Definition dialogs.cpp:1261
int action_selection_target_city(void)
Definition dialogs.cpp:4013
static void spy_steal_something(QVariant data1, QVariant data2)
Definition dialogs.cpp:3142
#define BUTTON_WAIT
Definition dialogs.cpp:68
void popup_notify_goto_dialog(const char *headline, const char *lines, const struct text_tag_list *tags, struct tile *ptile)
Definition dialogs.cpp:1169
static void spy_poison(QVariant data1, QVariant data2)
Definition dialogs.cpp:3219
void show_tech_gained_dialog(Tech_type_id tech)
Definition dialogs.cpp:4215
static void base(QVariant data1, QVariant data2)
Definition dialogs.cpp:2839
static void spy_nuke_city_esc(QVariant data1, QVariant data2)
Definition dialogs.cpp:3264
void popup_soundset_suggestion_dialog(void)
Definition dialogs.cpp:3882
static void enter_hut2(QVariant data1, QVariant data2)
Definition dialogs.cpp:2585
void popup_races_dialog(struct player *pplayer)
Definition dialogs.cpp:1206
static void expel_unit(QVariant data1, QVariant data2)
Definition dialogs.cpp:2654
static void paradrop_frighten(QVariant data1, QVariant data2)
Definition dialogs.cpp:2977
static void diplomat_sabotage(QVariant data1, QVariant data2)
Definition dialogs.cpp:3429
void popup_disband_dialog(struct unit_list *punits)
Definition dialogs.cpp:3841
static action_id get_non_targeted_action_id(action_id tgt_action_id)
Definition dialogs.cpp:2253
static void homeless(QVariant data1, QVariant data2)
Definition dialogs.cpp:2396
static void caravan_help_build(QVariant data1, QVariant data2)
Definition dialogs.cpp:1750
static void bombard(QVariant data1, QVariant data2)
Definition dialogs.cpp:2666
void popdown_races_dialog(void)
Definition dialogs.cpp:1220
void popup_tileset_suggestion_dialog(void)
Definition dialogs.cpp:3851
static void conquer_city(QVariant data1, QVariant data2)
Definition dialogs.cpp:1831
void revolution_response(struct government *gov)
Definition dialogs.cpp:1904
void popdown_economy_report()
static void join_city(QVariant data1, QVariant data2)
Definition dialogs.cpp:3037
static void spy_request_sabotage_list(QVariant data1, QVariant data2)
Definition dialogs.cpp:3182
static void diplomat_bribe(QVariant data1, QVariant data2)
Definition dialogs.cpp:2410
static void unit_disband_recover(QVariant data1, QVariant data2)
Definition dialogs.cpp:1765
static void spy_steal(QVariant data1, QVariant data2)
Definition dialogs.cpp:3126
static void airlift(QVariant data1, QVariant data2)
Definition dialogs.cpp:1816
void popup_pillage_dialog(struct unit *punit, bv_extras extras)
Definition dialogs.cpp:3762
void popup_sabotage_dialog(struct unit *actor, struct city *tcity, const struct action *paction)
Definition dialogs.cpp:3700
static void transport_alight(QVariant data1, QVariant data2)
Definition dialogs.cpp:2529
static void plant(QVariant data1, QVariant data2)
Definition dialogs.cpp:2743
static void nuke(QVariant data1, QVariant data2)
Definition dialogs.cpp:2902
static void disembark2(QVariant data1, QVariant data2)
Definition dialogs.cpp:2555
static void transport_unload(QVariant data1, QVariant data2)
Definition dialogs.cpp:2518
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:4078
void popdown_science_report()
static void diplomat_steal(QVariant data1, QVariant data2)
Definition dialogs.cpp:3459
static void unit_upgrade(QVariant data1, QVariant data2)
Definition dialogs.cpp:1795
bool popup_theme_suggestion_dialog(const char *theme_name)
Definition dialogs.cpp:3932
static void enter_hut(QVariant data1, QVariant data2)
Definition dialogs.cpp:2570
static void spy_request_strike_bld_list(QVariant data1, QVariant data2)
Definition dialogs.cpp:3165
static void diplomat_incite_escape(QVariant data1, QVariant data2)
Definition dialogs.cpp:3507
static void found_city(QVariant data1, QVariant data2)
Definition dialogs.cpp:2702
static void diplomat_investigate(QVariant data1, QVariant data2)
Definition dialogs.cpp:3414
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:4799
static void bombard3(QVariant data1, QVariant data2)
Definition dialogs.cpp:2690
static void diplomat_incite(QVariant data1, QVariant data2)
Definition dialogs.cpp:3489
static void paradrop_conquer(QVariant data1, QVariant data2)
Definition dialogs.cpp:2962
void popdown_endgame_report()
static void diplomat_steal_esc(QVariant data1, QVariant data2)
Definition dialogs.cpp:3474
static bool is_more_user_input_needed
Definition dialogs.cpp:183
static void bombard2(QVariant data1, QVariant data2)
Definition dialogs.cpp:2678
void popup_incite_dialog(struct unit *actor, struct city *tcity, int cost, const struct action *paction)
Definition dialogs.cpp:3541
static const QHash< action_id, pfcn_void > af_map_init(void)
Definition dialogs.cpp:196
void popdown_all_spaceships_dialogs()
static void nuke_city(QVariant data1, QVariant data2)
Definition dialogs.cpp:3279
void popup_connect_msg(const char *headline, const char *message)
Definition dialogs.cpp:1181
static void diplomat_sabotage_esc(QVariant data1, QVariant data2)
Definition dialogs.cpp:3444
void popdown_units_report()
static void transport_embark2(QVariant data1, QVariant data2)
Definition dialogs.cpp:2496
static void spy_nuke_city(QVariant data1, QVariant data2)
Definition dialogs.cpp:3249
void unit_select_dialog_update_real(void *unused)
Definition dialogs.cpp:1243
static void spy_steal_esc(QVariant data1, QVariant data2)
Definition dialogs.cpp:3134
static void paradrop(QVariant data1, QVariant data2)
Definition dialogs.cpp:2947
static void suicide_attack(QVariant data1, QVariant data2)
Definition dialogs.cpp:2932
void races_toggles_set_sensitive(void)
Definition dialogs.cpp:1272
static action_id get_production_targeted_action_id(action_id tgt_action_id)
Definition dialogs.cpp:2276
static void paradrop_frighten_conquer(QVariant data1, QVariant data2)
Definition dialogs.cpp:2992
static void convert_unit(QVariant data1, QVariant data2)
Definition dialogs.cpp:2384
static bool did_not_decide
Definition dialogs.cpp:187
static void spy_poison_esc(QVariant data1, QVariant data2)
Definition dialogs.cpp:3234
static void pillage_something(QVariant data1, QVariant data2)
Definition dialogs.cpp:3650
static void spy_request_sabotage_esc_list(QVariant data1, QVariant data2)
Definition dialogs.cpp:3200
static void transform_terrain(QVariant data1, QVariant data2)
Definition dialogs.cpp:2713
#define BUTTON_CANCEL
Definition dialogs.cpp:69
static void conquer_extras(QVariant data1, QVariant data2)
Definition dialogs.cpp:1861
static void regular_move(QVariant data1, QVariant data2)
Definition dialogs.cpp:3525
static void heal_unit2(QVariant data1, QVariant data2)
Definition dialogs.cpp:2463
static void spy_embassy(QVariant data1, QVariant data2)
Definition dialogs.cpp:3369
static races_dialog * race_dialog
Definition dialogs.cpp:177
static void frighten_hut2(QVariant data1, QVariant data2)
Definition dialogs.cpp:2615
static void conquer_city2(QVariant data1, QVariant data2)
Definition dialogs.cpp:1846
static void conquer_extras2(QVariant data1, QVariant data2)
Definition dialogs.cpp:1875
static void frighten_hut(QVariant data1, QVariant data2)
Definition dialogs.cpp:2600
bool qtg_request_transport(struct unit *pcargo, struct tile *ptile)
Definition dialogs.cpp:4758
int action_selection_target_unit(void)
Definition dialogs.cpp:4064
static void irrigate(QVariant data1, QVariant data2)
Definition dialogs.cpp:2881
static void transport_embark3(QVariant data1, QVariant data2)
Definition dialogs.cpp:2507
static void heal_unit(QVariant data1, QVariant data2)
Definition dialogs.cpp:2452
void popdown_city_report()
Definition cityrep.cpp:1341
static void paradrop_enter_conquer(QVariant data1, QVariant data2)
Definition dialogs.cpp:3022
static void unit_home_city(QVariant data1, QVariant data2)
Definition dialogs.cpp:1780
static void transport_embark(QVariant data1, QVariant data2)
Definition dialogs.cpp:2485
bool try_default_city_action(QVariant q1, QVariant q2)
Definition dialogs.cpp:1549
static void keep_moving(QVariant data1, QVariant data2)
Definition dialogs.cpp:1897
static void spy_steal_maps_esc(QVariant data1, QVariant data2)
Definition dialogs.cpp:3354
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:2329
static void disembark1(QVariant data1, QVariant data2)
Definition dialogs.cpp:2540
void restart_notify_dialogs()
Definition dialogs.cpp:3941
static bool is_showing_pillage_dialog
Definition dialogs.cpp:176
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:2296
static const QHash< action_id, pfcn_void > af_map
Definition dialogs.cpp:305
static void caravan_establish_trade(QVariant data1, QVariant data2)
Definition dialogs.cpp:1735
void popdown_all_game_dialogs(void)
Definition dialogs.cpp:3957
static void spy_steal_maps(QVariant data1, QVariant data2)
Definition dialogs.cpp:3339
struct unit struct city struct unit * target_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 struct unit struct unit int const struct action *paction show_tileset_error
Definition dialogs_g.h:84
popup_action_selection
Definition dialogs_g.h:54
struct unit * actor_unit
Definition dialogs_g.h:54
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id popup_bribe_dialog
Definition dialogs_g.h:72
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit * actor
Definition dialogs_g.h:72
const char * caption
Definition dialogs_g.h:36
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs action_selection_no_longer_in_progress_gui_specific
Definition dialogs_g.h:68
const char const char * headline
Definition dialogs_g.h:37
popup_notify_dialog
Definition dialogs_g.h:36
struct unit struct city struct unit struct tile 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:85
struct unit struct city struct unit struct tile * target_tile
Definition dialogs_g.h:56
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit * punit
Definition dialogs_g.h:73
struct unit struct city * target_city
Definition dialogs_g.h:55
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit int cost
Definition dialogs_g.h:73
struct unit struct city struct unit struct tile struct extra_type * target_extra
Definition dialogs_g.h:56
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:85
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:153
struct extra_type * extra_by_number(int id)
Definition extras.c:175
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:186
#define extra_index(_e_)
Definition extras.h:177
#define EXTRA_NONE
Definition extras.h:82
int Tech_type_id
Definition fc_types.h:347
int action_id
Definition fc_types.h:359
int Government_type_id
Definition fc_types.h:351
#define IDENTITY_NUMBER_ZERO
Definition fc_types.h:82
#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:57
struct world wld
Definition game.c:58
struct unit * game_unit_by_number(int id)
Definition game.c:111
struct city * game_city_by_number(int id)
Definition game.c:102
struct government * government_by_number(const Government_type_id gov)
Definition government.c:102
Government_type_id government_number(const struct government *pgovern)
Definition government.c:90
#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 struct tile * pos
Definition finddlg.c:53
void popdown_help_dialog(void)
Definition helpdlg.c:185
const char * title
Definition repodlgs.c:1313
void(* pfcn_void)(QVariant, QVariant)
Definition dialogs.h:46
#define CAPTURE_DEFAULT_THIS
Definition gui_main.h:23
void nationset_changed(void)
Definition dialogs.c:3556
void popup_revolution_dialog(void)
Definition dialogs.c:109
void helptext_nation(char *buf, size_t bufsz, struct nation_type *pnation, const char *user_text)
Definition helpdata.c:4871
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
struct tile * index_to_tile(const struct civ_map *imap, int mindex)
Definition map.c:454
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)
#define FC_FREE(ptr)
Definition mem.h:41
const char * move_points_text(int mp, bool reduce)
Definition movement.c:973
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:485
bool nation_leader_is_male(const struct nation_leader *pleader)
Definition nation.c:289
const char * nation_adjective_for_player(const struct player *pplayer)
Definition nation.c:168
const char * nation_adjective_translation(const struct nation_type *pnation)
Definition nation.c:148
struct nation_type * nation_by_number(const Nation_type_id nation)
Definition nation.c:474
int nation_set_index(const struct nation_set *pset)
Definition nation.c:698
bool is_nation_pickable(const struct nation_type *nation)
Definition nation.c:187
const struct nation_leader_list * nation_leaders(const struct nation_type *pnation)
Definition nation.c:229
const char * nation_set_name_translation(const struct nation_set *pset)
Definition nation.c:817
bool is_nation_playable(const struct nation_type *nation)
Definition nation.c:199
bool nation_is_in_group(const struct nation_type *pnation, const struct nation_group *pgroup)
Definition nation.c:1098
const char * nation_set_description(const struct nation_set *pset)
Definition nation.c:827
const char * nation_group_name_translation(const struct nation_group *pgroup)
Definition nation.c:1089
int nation_set_count(void)
Definition nation.c:690
struct nation_group * nation_group_by_number(int id)
Definition nation.c:1003
struct nation_set * nation_set_by_rule_name(const char *name)
Definition nation.c:778
bool is_nation_group_hidden(struct nation_group *pgroup)
Definition nation.c:1056
struct nation_set * nation_set_by_setting_value(const char *setting)
Definition nation.c:858
const char * nation_leader_name(const struct nation_leader *pleader)
Definition nation.c:280
int nation_group_count(void)
Definition nation.c:934
const char * nation_set_rule_name(const struct nation_set *pset)
Definition nation.c:806
struct nation_style * style_of_nation(const struct nation_type *pnation)
Definition nation.c:671
#define nation_leader_list_iterate(leaderlist, pleader)
Definition nation.h:56
#define nation_sets_iterate_end
Definition nation.h:304
#define nation_sets_iterate(NAME_pset)
Definition nation.h:300
#define nations_iterate_end
Definition nation.h:335
#define nations_iterate(NAME_pnation)
Definition nation.h:332
#define nation_leader_list_iterate_end
Definition nation.h:58
const struct option_set * server_optset
Definition options.c:4009
bool option_str_set(struct option *poption, const char *str)
Definition options.c:901
const char * option_str_get(const struct option *poption)
Definition options.c:868
struct option * optset_option_by_name(const struct option_set *poptset, const char *name)
Definition options.c:406
#define REQEST_PLAYER_INITIATED
Definition packets.h:70
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_unit_get_actions(struct connection *pc, int actor_unit_id16, int actor_unit_id32, int target_unit_id16, int target_unit_id32, int target_tile_id, int target_extra_id, int request_kind)
int dsend_packet_city_name_suggestion_req(struct connection *pc, int unit_id16, int unit_id32)
void start_revolution(void)
Definition packhand.c:2516
void set_government_choice(struct government *government)
Definition packhand.c:2503
char * lines
Definition packhand.c:129
int player_number(const struct player *pplayer)
Definition player.c:828
const char * research_advance_name_translation(const struct research *presearch, Tech_type_id tech)
Definition research.c:271
struct research * research_get(const struct player *pplayer)
Definition research.c:126
enum tech_state research_invention_state(const struct research *presearch, Tech_type_id tech)
Definition research.c:616
bool research_invention_gettable(const struct research *presearch, const Tech_type_id tech, bool allow_holes)
Definition research.c:690
#define ARRAY_SIZE(x)
Definition shared.h:85
size_t size
Definition specvec.h:72
action_id id
Definition actions.h:380
QPixmap map_pixmap
Definition canvas.h:25
Definition city.h:309
int id
Definition city.h:315
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:20
struct player * playing
Definition connection.h:156
Definition mapimg.c:367
Definition climisc.h:80
struct universal item
Definition climisc.h:81
struct player * player
Definition nation.h:117
bool tech_steal_allow_holes
char preferred_soundset[MAX_LEN_NAME]
char preferred_tileset[MAX_LEN_NAME]
char preferred_musicset[MAX_LEN_NAME]
int revolution_finishes
Definition player.h:273
char name[MAX_LEN_NAME]
Definition player.h:251
Definition menu.h:159
struct unit * autocaravan
Definition menu.h:162
QPixmap * pm
Definition sprite.h:25
Definition tile.h:49
int index
Definition tile.h:50
struct unit_list * units
Definition tile.h:57
int move_rate
Definition unittype.h:497
Definition unit.h:138
int moves_left
Definition unit.h:150
int id
Definition unit.h:145
int hp
Definition unit.h:151
struct unit::@80::@82 client
int fuel
Definition unit.h:153
struct tile * tile
Definition unit.h:140
struct act_prob * act_prob_cache
Definition unit.h:225
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:969
#define sz_strlcpy(dest, src)
Definition support.h:161
#define TRUE
Definition support.h:46
#define FALSE
Definition support.h:47
#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:538
bool get_units_upgrade_info(char *buf, size_t bufsz, struct unit_list *punits)
Definition text.c:1290
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:1743
const char * act_sel_action_tool_tip(const struct action *paction, const struct act_prob prob)
Definition text.c:1820
struct city * tile_city(const struct tile *ptile)
Definition tile.c:83
#define tile_index(_pt_)
Definition tile.h:87
#define TILE_INDEX_NONE
Definition tile.h:47
int tileset_hex_width(const struct tileset *t)
Definition tilespec.c:684
int tileset_unit_width(const struct tileset *t)
Definition tilespec.c:760
int tileset_unit_height(const struct tileset *t)
Definition tilespec.c:768
bool tileset_is_isometric(const struct tileset *t)
Definition tilespec.c:675
struct sprite * get_sample_city_sprite(const struct tileset *t, int style_idx)
Definition tilespec.c:6551
const char * tileset_basename(const struct tileset *t)
Definition tilespec.c:667
int tileset_hex_height(const struct tileset *t)
Definition tilespec.c:693
struct sprite * get_nation_flag_sprite(const struct tileset *t, const struct nation_type *pnation)
Definition tilespec.c:6471
void tileset_error(enum log_level level, const char *tset_name, const char *format,...)
Definition tilespec.c:587
bool tilespec_reread(const char *new_tileset_name, bool game_fully_initialized, float scale)
Definition tilespec.c:1299
struct unit * transporter_for_unit_at(const struct unit *pcargo, const struct tile *ptile)
Definition unit.c:1908
bool could_unit_load(const struct unit *pcargo, const struct unit *ptrans)
Definition unit.c:719
bool unit_can_do_action(const struct unit *punit, const action_id act_id)
Definition unit.c:331
void unit_activity_astr(const struct unit *punit, struct astring *astr)
Definition unit.c:1175
#define unit_tile(_pu)
Definition unit.h:388
#define unit_owner(_pu)
Definition unit.h:387
#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:1621
#define utype_fuel(ptype)
Definition unittype.h:822
#define show(id)
Definition widget.h:235