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) {
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 = mevent_gpos(event) - 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/***********************************************************************/
679{
680 QTableWidgetItem *item;
681 QPixmap *pix;
682 QFont f;
683 struct nation_group *group;
684 int i;
685 struct sprite *s;
686 QHeaderView *header;
687 selected_nation_tabs->clearContents();
688 selected_nation_tabs->setRowCount(0);
689
690 last_index = 0;
691 i = nation_tabs->currentRow();
692 if (i != -1) {
693 item = nation_tabs->item(i, 0);
694 index = item->data(Qt::UserRole).toInt();
695 }
696
697 group = nation_group_by_number(index);
698 i = 0;
699 nations_iterate(pnation) {
700 if (!is_nation_playable(pnation)
701 || !is_nation_pickable(pnation)) {
702 continue;
703 }
704 if (!nation_is_in_group(pnation, group) && index != -99) {
705 continue;
706 }
707 item = new QTableWidgetItem;
708 selected_nation_tabs->insertRow(i);
709 s = get_nation_flag_sprite(tileset, pnation);
710 if (pnation->player) {
711 f = item->font();
712 f.setStrikeOut(true);
713 item->setFont(f);
714 }
715 pix = s->pm;
716 item->setData(Qt::DecorationRole, *pix);
717 item->setData(Qt::UserRole, nation_number(pnation));
718 item->setText(nation_adjective_translation(pnation));
719 selected_nation_tabs->setItem(i, 0, item);
721
722 selected_nation_tabs->sortByColumn(0, Qt::AscendingOrder);
723 header = selected_nation_tabs->horizontalHeader();
724 header->resizeSections(QHeaderView::Stretch);
725 header = selected_nation_tabs->verticalHeader();
726 header->resizeSections(QHeaderView::ResizeToContents);
727}
728
729/***********************************************************************/
732void races_dialog::nation_selected(const QItemSelection &selected,
733 const QItemSelection &deselcted)
734{
735 char buf[4096];
736 QModelIndex index ;
737 QVariant qvar;
738 QModelIndexList indexes = selected.indexes();
739 QString str;
740 QTableWidgetItem *item;
741 int style, ind;
742
743 if (indexes.isEmpty()) {
744 return;
745 }
746
747 index = indexes.at(0);
748 if (indexes.isEmpty()) {
749 return;
750 }
751 qvar = index.data(Qt::UserRole);
752 selected_nation = qvar.toInt();
753
754 helptext_nation(buf, sizeof(buf), nation_by_number(selected_nation), NULL);
755 description->setPlainText(buf);
756 leader_name->clear();
757 if (client.conn.playing == tplayer) {
758 leader_name->addItem(client.conn.playing->name, true);
759 }
761 (selected_nation)), pleader) {
762 str = QString::fromUtf8(nation_leader_name(pleader));
763 leader_name->addItem(str, nation_leader_is_male(pleader));
765
771 qvar = qvar.fromValue<int>(style);
772
773 for (ind = 0; ind < styles->rowCount(); ind++) {
774 item = styles->item(ind, 0);
775
776 if (item->data(Qt::UserRole) == qvar) {
777 styles->selectRow(ind);
778 }
779 }
780}
781
782/***********************************************************************/
785void races_dialog::style_selected(const QItemSelection &selected,
786 const QItemSelection &deselcted)
787{
788 QModelIndex index ;
789 QVariant qvar;
790 QModelIndexList indexes = selected.indexes();
791
792 if (indexes.isEmpty()) {
793 return;
794 }
795
796 index = indexes.at(0);
797 qvar = index.data(Qt::UserRole);
798 selected_style = qvar.toInt();
799}
800
801/***********************************************************************/
805{
806 if (leader_name->itemData(index).toBool()) {
807 is_male->setChecked(true);
808 is_female->setChecked(false);
809 } else {
810 is_male->setChecked(false);
811 is_female->setChecked(true);
812 }
813}
814
815/***********************************************************************/
820{
821 QByteArray ln_bytes;
822 struct player *natplr;
823
824 if (selected_nation == -1) {
825 return;
826 }
827
828 if (selected_style == -1) {
829 output_window_append(ftc_client, _("You must select your style."));
830 return;
831 }
832
833 if (leader_name->currentText().length() == 0) {
834 output_window_append(ftc_client, _("You must type a legal name."));
835 return;
836 }
837
839 if (natplr != NULL && natplr != client_player()) {
841 _("Nation has been chosen by other player"));
842 return;
843 }
844
845 ln_bytes = leader_name->currentText().toUtf8();
847 selected_nation, sex_buttons->checkedId(),
848 ln_bytes.data(),
850 close();
851 deleteLater();
852}
853
854/***********************************************************************/
858 const char *lines, QWidget *parent)
859 : fcwidget()
860{
861 int x, y;
862 QString qlines;
863
864 setAttribute(Qt::WA_DeleteOnClose);
865 setCursor(Qt::ArrowCursor);
866 setParent(parent);
867 setFrameStyle(QFrame::Box);
868 cw = new close_widget(this);
869 cw->put_to_corner();
870
871 qcaption = QString(caption);
872 qheadline = QString(headline);
873 qlines = QString(lines);
874 qlist = qlines.split("\n");
875 small_font = *fc_font::instance()->get_font("gui_qt_font_notify_label");
876 x = 0;
877 y = 0;
878 calc_size(x, y);
879 resize(x, y);
880 gui()->mapview_wdg->find_place(gui()->mapview_wdg->width() - x - 4, 4,
881 x, y, x, y, 0);
882 move(x, y);
883 was_destroyed = false;
884
885}
886
887/***********************************************************************/
891{
892 QString s, q;
893 int i;
894 QByteArray capt_bytes;
895 QByteArray hl_bytes;
896 QByteArray qb_bytes;
897
898 for (i = 0; i < qlist.size(); ++i) {
899 s = qlist.at(i);
900 q = q + s;
901 if (i < qlist.size() - 1) {
902 q = q + QChar('\n');
903 }
904 }
905 capt_bytes = qcaption.toUtf8();
906 hl_bytes = qheadline.toUtf8();
907 qb_bytes = q.toUtf8();
908 popup_notify_dialog(capt_bytes.data(),
909 hl_bytes.data(),
910 qb_bytes.data());
911 close();
912 destroy();
913}
914
915/***********************************************************************/
918void notify_dialog::calc_size(int &x, int &y)
919{
920 QFontMetrics fm(small_font);
921 int i;
922 QStringList str_list;
923
924 str_list = qlist;
925 str_list << qcaption << qheadline;
926
927 for (i = 0; i < str_list.count(); i++) {
928 x = qMax(x, fm.horizontalAdvance(str_list.at(i)));
929 y = y + 3 + fm.height();
930 }
931 x = x + 15;
932}
933
934/***********************************************************************/
937void notify_dialog::paintEvent(QPaintEvent * paint_event)
938{
939 QPainter painter(this);
940 QPainterPath path;
941 QPen pen;
942 QFontMetrics fm(small_font);
943 int i;
944
945 pen.setWidth(1);
946 pen.setColor(palette().color(QPalette::Text));
947 painter.setFont(small_font);
948 painter.setPen(pen);
949 painter.drawText(10, fm.height() + 3, qcaption);
950 painter.drawText(10, 2 * fm.height() + 6, qheadline);
951 for (i = 0; i < qlist.count(); i++) {
952 painter.drawText(10, 3 + (fm.height() + 3) * (i + 3), qlist[i]);
953 }
954 cw->put_to_corner();
955}
956
957/***********************************************************************/
961{
962 cursor = mevent_gpos(event) - geometry().topLeft();
963
964 if (event->button() == Qt::RightButton) {
965 was_destroyed = true;
966 close();
967 }
968}
969
970/***********************************************************************/
974{
976
977 setCursor(Qt::SizeAllCursor);
978}
979
980/***********************************************************************/
984{
985 setCursor(Qt::ArrowCursor);
986}
987
988/***********************************************************************/
992{
993 was_destroyed = true;
994 destroy();
995}
996
997/***********************************************************************/
1003{
1004 was_destroyed = true;
1005 destroy();
1006}
1007
1008/***********************************************************************/
1012{
1013 vs_city = -1;
1014 vs_unit = -1;
1015}
1016
1017/***********************************************************************/
1021{
1022 if (!m_instance) {
1023 m_instance = new qdef_act;
1024 }
1025 return m_instance;
1026}
1027
1028/***********************************************************************/
1032{
1033 if (m_instance) {
1034 delete m_instance;
1035 m_instance = 0;
1036 }
1037}
1038
1039/***********************************************************************/
1043{
1044 vs_city = i;
1045}
1046
1047/***********************************************************************/
1051{
1052 vs_unit = i;
1053}
1054
1055/***********************************************************************/
1059{
1060 return vs_city;
1061}
1062
1063/***********************************************************************/
1067{
1068 return vs_unit;
1069}
1070
1071/***********************************************************************/
1075{
1076 delete this;
1077}
1078
1079/***********************************************************************/
1083{
1085 false, "", 0);
1086 delete this;
1087}
1088
1089/***********************************************************************/
1092notify_goto::notify_goto(const char *headline, const char *lines,
1093 const struct text_tag_list *tags, tile *ptile,
1094 QWidget *parent): QMessageBox(parent)
1095{
1096 QString qlines;
1097 setAttribute(Qt::WA_DeleteOnClose);
1098 goto_but = this->addButton(_("Goto Location"), QMessageBox::ActionRole);
1099 goto_but->setIcon(fc_icons::instance()->get_icon("go-up"));
1100 inspect_but = this->addButton(_("Inspect City"), QMessageBox::ActionRole);
1101 inspect_but->setIcon(fc_icons::instance()->get_icon("plus"));
1102
1103 close_but = this->addButton(QMessageBox::Close);
1104 gtile = ptile;
1105 if (!gtile) {
1106 goto_but->setVisible(false);
1107 inspect_but->setVisible(false);
1108 } else {
1109 struct city *pcity = tile_city(gtile);
1110 inspect_but->setVisible(NULL != pcity
1111 && city_owner(pcity) == client.conn.playing);
1112 }
1113 setWindowTitle(headline);
1114 qlines = lines;
1115 qlines.replace("\n", " ");
1116 setText(qlines);
1117 connect(goto_but, &QAbstractButton::pressed, this, &notify_goto::goto_tile);
1118 connect(inspect_but, &QAbstractButton::pressed, this, &notify_goto::inspect_city);
1119 connect(close_but, &QAbstractButton::pressed, this, &QWidget::close);
1120 show();
1121}
1122
1123/***********************************************************************/
1127{
1129 close();
1130}
1131
1132/***********************************************************************/
1136{
1137 struct city *pcity = tile_city(gtile);
1138 if (pcity) {
1140 }
1141 close();
1142}
1143
1144/***********************************************************************/
1148{
1149 QString rule_name;
1150 QByteArray rn_bytes;
1151 const char *rn;
1152 struct option *poption = optset_option_by_name(server_optset, "nationset");
1153
1154 rule_name = qnation_set->currentData().toString();
1155 rn_bytes = rule_name.toUtf8(); /* Hold QByteArray in a variable to
1156 * extend its, and data() buffer's,
1157 * lifetime */
1158 rn = rn_bytes.data();
1160 != nation_set_by_rule_name(rn)) {
1161 option_str_set(poption, rn);
1162 }
1163}
1164
1165/***********************************************************************/
1170void popup_notify_goto_dialog(const char *headline, const char *lines,
1171 const struct text_tag_list *tags,
1172 struct tile *ptile)
1173{
1174 notify_goto *ask = new notify_goto(headline, lines, tags, ptile,
1175 gui()->central_wdg);
1176 ask->show();
1177}
1178
1179/***********************************************************************/
1182void popup_connect_msg(const char *headline, const char *message)
1183{
1184 QMessageBox *msg = new QMessageBox(gui()->central_wdg);
1185
1186 msg->setText(message);
1187 msg->setStandardButtons(QMessageBox::Ok);
1188 msg->setWindowTitle(headline);
1189 msg->setAttribute(Qt::WA_DeleteOnClose);
1190 msg->show();
1191}
1192
1193/***********************************************************************/
1196void popup_notify_dialog(const char *caption, const char *headline,
1197 const char *lines)
1198{
1200 gui()->mapview_wdg);
1201 nd->show();
1202}
1203
1204/***********************************************************************/
1207void popup_races_dialog(struct player *pplayer)
1208{
1209 if (!is_race_dialog_open) {
1210 race_dialog = new races_dialog(pplayer, gui()->central_wdg);
1211 is_race_dialog_open = true;
1212 race_dialog->show();
1213 }
1214 race_dialog->showNormal();
1215}
1216
1217/***********************************************************************/
1222{
1223 if (is_race_dialog_open) {
1224 race_dialog->close();
1225 is_race_dialog_open = false;
1226 }
1227}
1228
1229/***********************************************************************/
1233{
1234 if (ptile != NULL
1235 && (unit_list_size(ptile->units) > 1
1236 || (unit_list_size(ptile->units) == 1 && tile_city(ptile)))) {
1237 gui()->toggle_unit_sel_widget(ptile);
1238 }
1239}
1240
1241/***********************************************************************/
1245{
1246 gui()->update_unit_sel();
1247}
1248
1249/***********************************************************************/
1258
1259/***********************************************************************/
1262void races_update_pickable(bool nationset_change)
1263{
1264 if (is_race_dialog_open) {
1266 }
1267}
1268
1269/***********************************************************************/
1274{
1275 if (is_race_dialog_open) {
1277 }
1278}
1279
1280/***********************************************************************/
1284{
1285 hud_message_box *ask;
1286 const Government_type_id government_id
1287 = (gov != nullptr ? government_number(gov) : G_LAST);
1288
1290 ask = new hud_message_box(gui()->central_wdg);
1291 ask->setStandardButtons(QMessageBox::Cancel | QMessageBox::Ok);
1292 ask->setDefaultButton(QMessageBox::Cancel);
1293 ask->set_text_title(_("You say you wanna revolution?"),
1294 _("Revolution!"));
1295 ask->setAttribute(Qt::WA_DeleteOnClose);
1296 QObject::connect(ask, &hud_message_box::accepted, [=]() {
1297 if (government_id == G_LAST) {
1298 revolution_response(nullptr);
1299 } else {
1300 struct government *government = government_by_number(government_id);
1301
1302 if (government) {
1304 }
1305 }
1306 });
1307 ask->show();
1308 } else {
1310 }
1311}
1312
1313/***********************************************************************/
1317 pfcn_void func_in,
1318 QVariant data1_in,
1319 QVariant data2_in)
1320 : QPushButton(title)
1321{
1322 func = func_in;
1323 data1 = data1_in;
1324 data2 = data2_in;
1325}
1326
1327/***********************************************************************/
1334
1335/***********************************************************************/
1340{
1341 return data1;
1342}
1343
1344/***********************************************************************/
1349{
1350 return data2;
1351}
1352
1353/***********************************************************************/
1357{
1358 data1 = wariat;
1359}
1360
1361/***********************************************************************/
1365{
1366 data2 = wariat;
1367}
1368
1369/***********************************************************************/
1372choice_dialog::choice_dialog(const QString title, const QString text,
1373 QWidget *parent,
1374 void (*run_on_close_in)(int)): QWidget(parent)
1375{
1376 QLabel *l = new QLabel(text);
1377
1378 setProperty("themed_choice", true);
1379 layout = new QVBoxLayout(this);
1380 run_on_close = run_on_close_in;
1381
1382 layout->addWidget(l);
1383 setWindowFlags(Qt::Dialog);
1384 setWindowTitle(title);
1385 setAttribute(Qt::WA_DeleteOnClose);
1386 gui()->set_diplo_dialog(this);
1387
1389 target_id[ATK_SELF] = unit_id;
1390 target_id[ATK_CITY] = IDENTITY_NUMBER_ZERO;
1391 target_id[ATK_UNIT] = IDENTITY_NUMBER_ZERO;
1392 target_id[ATK_UNITS] = TILE_INDEX_NONE;
1393 target_id[ATK_TILE] = TILE_INDEX_NONE;
1394 target_id[ATK_EXTRAS] = TILE_INDEX_NONE;
1395 sub_target_id[ASTK_BUILDING] = B_LAST;
1396 sub_target_id[ASTK_TECH] = A_UNSET;
1397 sub_target_id[ASTK_EXTRA] = EXTRA_NONE;
1398 sub_target_id[ASTK_EXTRA_NOT_THERE] = EXTRA_NONE;
1399
1400 targeted_unit = nullptr;
1401 /* No buttons are added yet. */
1402 for (int i = 0; i < BUTTON_COUNT; i++) {
1403 action_button_map << NULL;
1404 }
1405}
1406
1407/***********************************************************************/
1411{
1412 buttons_list.clear();
1413 action_button_map.clear();
1414 gui()->set_diplo_dialog(NULL);
1415
1416 if (run_on_close) {
1418 run_on_close = NULL;
1419 }
1420}
1421
1422/***********************************************************************/
1426{
1428
1430 && unit_list_size(targeted_unit->tile->units) > 1) {
1431 struct canvas *pix;
1432 QPushButton *next, *prev;
1433 unit_skip = new QHBoxLayout;
1434 next = new QPushButton();
1435 next->setIcon(fc_icons::instance()->get_icon("city-right"));
1436 next->setIconSize(QSize(32, 32));
1437 next->setFixedSize(QSize(36, 36));
1438 prev = new QPushButton();
1439 prev->setIcon(fc_icons::instance()->get_icon("city-left"));
1440 prev->setIconSize(QSize(32, 32));
1441 prev->setFixedSize(QSize(36, 36));
1442 target_unit_button = new QPushButton;
1445 pix->map_pixmap.fill(Qt::transparent);
1446 put_unit(targeted_unit, pix, 1.0, 0, 0);
1447 target_unit_button->setIcon(QIcon(pix->map_pixmap));
1448 qtg_canvas_free(pix);
1449 target_unit_button->setIconSize(QSize(96, 96));
1450 target_unit_button->setFixedSize(QSize(100, 100));
1451 unit_skip->addStretch(100);
1452 unit_skip->addWidget(prev, Qt::AlignCenter);
1453 unit_skip->addWidget(target_unit_button, Qt::AlignCenter);
1454 unit_skip->addWidget(next, Qt::AlignCenter);
1455 layout->addLayout(unit_skip);
1456 unit_skip->addStretch(100);
1457 connect(prev, &QAbstractButton::clicked, this, &choice_dialog::prev_unit);
1458 connect(next, &QAbstractButton::clicked, this, &choice_dialog::next_unit);
1459 }
1460
1461 setLayout(layout);
1462}
1463
1464/***********************************************************************/
1467void choice_dialog::add_item(QString title, pfcn_void func, QVariant data1,
1468 QVariant data2, QString tool_tip = "",
1469 const int button_id = -1)
1470{
1472 data1, data2);
1473 int action = buttons_list.count();
1474
1475 QObject::connect(button, &QPushButton::clicked,
1478 });
1479
1480 buttons_list.append(button);
1481
1482 if (!tool_tip.isEmpty()) {
1483 button->setToolTip(tool_tip);
1484 }
1485
1486 if (0 <= button_id) {
1487 /* The id is valid. */
1488 action_button_map[button_id] = button;
1489 }
1490
1491 layout->addWidget(button);
1492}
1493
1494/***********************************************************************/
1498{
1499 QPoint p;
1500
1501 p = mapFromGlobal(QCursor::pos());
1502 p.setY(p.y()-this->height());
1503 p.setX(p.x()-this->width());
1504 move(p);
1505 show();
1506}
1507
1508/***********************************************************************/
1512{
1513 return layout;
1514}
1515
1516/***********************************************************************/
1520{
1521 if (id < 0) {
1522 fc_assert_msg(0 <= id, "Invalid button ID.");
1523 return NULL;
1524 }
1525
1526 return action_button_map[id];
1527}
1528
1529/***********************************************************************/
1532bool try_default_unit_action(QVariant q1, QVariant q2)
1533{
1536
1538 if (action == -1) {
1539 return false;
1540 }
1541 func = af_map[action];
1542
1543 func(q1, q2);
1544 return true;
1545}
1546
1547/***********************************************************************/
1550bool try_default_city_action(QVariant q1, QVariant q2)
1551{
1554
1556 if (action == -1) {
1557 return false;
1558 }
1559 func = af_map[action];
1560 func(q1, q2);
1561 return true;
1562}
1563
1564/***********************************************************************/
1568{
1569 struct tile *ptile;
1570 struct unit *new_target = nullptr;
1571 bool break_next = false;
1572 bool first = true;
1573 struct canvas *pix;
1574
1575 if (targeted_unit == nullptr) {
1576 return;
1577 }
1578
1579 ptile = targeted_unit->tile;
1580
1581 unit_list_iterate(ptile->units, ptgt) {
1582 if (first) {
1583 new_target = ptgt;
1584 first = false;
1585 }
1586 if (break_next) {
1587 new_target = ptgt;
1588 break;
1589 }
1590 if (ptgt == targeted_unit) {
1591 break_next = true;
1592 }
1594 targeted_unit = new_target;
1597 pix->map_pixmap.fill(Qt::transparent);
1598 put_unit(targeted_unit, pix, 1.0, 0, 0);
1599 target_unit_button->setIcon(QIcon(pix->map_pixmap));
1600 qtg_canvas_free(pix);
1601 switch_target();
1602}
1603
1604/***********************************************************************/
1608{
1609 struct tile *ptile;
1610 struct unit *new_target = nullptr;
1611 struct canvas *pix;
1612 if (targeted_unit == nullptr) {
1613 return;
1614 }
1615
1616 ptile = targeted_unit->tile;
1617 unit_list_iterate(ptile->units, ptgt) {
1618 if ((ptgt == targeted_unit) && new_target != nullptr) {
1619 break;
1620 }
1621 new_target = ptgt;
1623 targeted_unit = new_target;
1626 pix->map_pixmap.fill(Qt::transparent);
1627 put_unit(targeted_unit, pix, 1.0, 0, 0);
1628 target_unit_button->setIcon(QIcon(pix->map_pixmap));
1629 qtg_canvas_free(pix);
1630 switch_target();
1631}
1632
1633/***********************************************************************/
1636void choice_dialog::update_dialog(const struct act_prob *act_probs)
1637{
1638 if (targeted_unit == nullptr) {
1639 return;
1640 }
1641 unit_skip->setParent(nullptr);
1644 (sub_target_id[ASTK_EXTRA] != EXTRA_NONE
1645 ? extra_by_number(sub_target_id[ASTK_EXTRA])
1646 : NULL),
1647 act_probs);
1648 layout->addLayout(unit_skip);
1649}
1650
1651/***********************************************************************/
1655{
1656 if (targeted_unit == nullptr) {
1657 return;
1658 }
1659
1660 unit_skip->setParent(nullptr);
1667 layout->addLayout(unit_skip);
1668}
1669
1670/***********************************************************************/
1674{
1676 pfcn_void func = button->getFunc();
1677
1678 func(button->getData1(), button->getData2());
1679 close();
1680}
1681
1682/***********************************************************************/
1691{
1692 /* Store the data in the stack. */
1693 last_buttons_stack.append(button);
1694
1695 /* Temporary remove the button so it will end up below buttons added
1696 * before unstack_all_buttons() is called. */
1697 layout->removeWidget(button);
1698
1699 /* Synchronize the list with the layout. */
1700 buttons_list.removeAll(button);
1701}
1702
1703/***********************************************************************/
1708{
1709 while (!last_buttons_stack.isEmpty()) {
1710 Choice_dialog_button *button = last_buttons_stack.takeLast();
1711
1712 /* Reinsert the button below the other buttons. */
1713 buttons_list.append(button);
1714 layout->addWidget(button);
1715 }
1716}
1717
1718/***********************************************************************/
1721static void caravan_marketplace(QVariant data1, QVariant data2)
1722{
1723 int actor_unit_id = data1.toInt();
1724 int target_city_id = data2.toInt();
1725
1727 && NULL != game_city_by_number(target_city_id)) {
1728 request_do_action(ACTION_MARKETPLACE, actor_unit_id,
1729 target_city_id, 0, "");
1730 }
1731}
1732
1733/***********************************************************************/
1736static void caravan_establish_trade(QVariant data1, QVariant data2)
1737{
1738 int actor_unit_id = data1.toInt();
1739 int target_city_id = data2.toInt();
1740
1742 && NULL != game_city_by_number(target_city_id)) {
1743 request_do_action(ACTION_TRADE_ROUTE, actor_unit_id,
1744 target_city_id, 0, "");
1745 }
1746}
1747
1748/***********************************************************************/
1751static void caravan_help_build(QVariant data1, QVariant data2)
1752{
1753 int caravan_id = data1.toInt();
1754 int caravan_target_id = data2.toInt();
1755
1756 if (NULL != game_unit_by_number(caravan_id)
1757 && NULL != game_city_by_number(caravan_target_id)) {
1758 request_do_action(ACTION_HELP_WONDER,
1759 caravan_id, caravan_target_id, 0, "");
1760 }
1761}
1762
1763/***********************************************************************/
1766static void unit_disband_recover(QVariant data1, QVariant data2)
1767{
1768 int actor_id = data1.toInt();
1769 int tgt_city_id = data2.toInt();
1770
1771 if (NULL != game_unit_by_number(actor_id)
1772 && NULL != game_city_by_number(tgt_city_id)) {
1773 request_do_action(ACTION_DISBAND_UNIT_RECOVER,
1774 actor_id, tgt_city_id, 0, "");
1775 }
1776}
1777
1778/***********************************************************************/
1781static void unit_home_city(QVariant data1, QVariant data2)
1782{
1783 int actor_id = data1.toInt();
1784 int tgt_city_id = data2.toInt();
1785
1786 if (NULL != game_unit_by_number(actor_id)
1787 && NULL != game_city_by_number(tgt_city_id)) {
1788 request_do_action(ACTION_HOME_CITY,
1789 actor_id, tgt_city_id, 0, "");
1790 }
1791}
1792
1793/***********************************************************************/
1796static void unit_upgrade(QVariant data1, QVariant data2)
1797{
1798 struct unit *punit;
1799
1800 int actor_id = data1.toInt();
1801 int tgt_city_id = data2.toInt();
1802
1803 if ((punit = game_unit_by_number(actor_id))
1804 && NULL != game_city_by_number(tgt_city_id)) {
1805 struct unit_list *as_list;
1806
1807 as_list = unit_list_new();
1808 unit_list_append(as_list, punit);
1809 popup_upgrade_dialog(as_list);
1810 unit_list_destroy(as_list);
1811 }
1812}
1813
1814/***********************************************************************/
1817static void airlift(QVariant data1, QVariant data2)
1818{
1819 int actor_id = data1.toInt();
1820 int tgt_city_id = data2.toInt();
1821
1822 if (NULL != game_unit_by_number(actor_id)
1823 && NULL != game_city_by_number(tgt_city_id)) {
1824 request_do_action(ACTION_AIRLIFT,
1825 actor_id, tgt_city_id, 0, "");
1826 }
1827}
1828
1829/***********************************************************************/
1832static void conquer_city(QVariant data1, QVariant data2)
1833{
1834 int actor_id = data1.toInt();
1835 int tgt_city_id = data2.toInt();
1836
1837 if (NULL != game_unit_by_number(actor_id)
1838 && NULL != game_city_by_number(tgt_city_id)) {
1839 request_do_action(ACTION_CONQUER_CITY,
1840 actor_id, tgt_city_id, 0, "");
1841 }
1842}
1843
1844/***********************************************************************/
1847static void conquer_city2(QVariant data1, QVariant data2)
1848{
1849 int actor_id = data1.toInt();
1850 int tgt_city_id = data2.toInt();
1851
1852 if (NULL != game_unit_by_number(actor_id)
1853 && NULL != game_city_by_number(tgt_city_id)) {
1854 request_do_action(ACTION_CONQUER_CITY2,
1855 actor_id, tgt_city_id, 0, "");
1856 }
1857}
1858
1859/***********************************************************************/
1862static void conquer_extras(QVariant data1, QVariant data2)
1863{
1864 int actor_id = data1.toInt();
1865 int target_id = data2.toInt();
1866
1867 if (NULL != game_unit_by_number(actor_id)) {
1868 request_do_action(ACTION_CONQUER_EXTRAS,
1869 actor_id, target_id, 0, "");
1870 }
1871}
1872
1873/***********************************************************************/
1876static void conquer_extras2(QVariant data1, QVariant data2)
1877{
1878 int actor_id = data1.toInt();
1879 int target_id = data2.toInt();
1880
1881 if (NULL != game_unit_by_number(actor_id)) {
1882 request_do_action(ACTION_CONQUER_EXTRAS2,
1883 actor_id, target_id, 0, "");
1884 }
1885}
1886
1887/***********************************************************************/
1890static void act_sel_wait(QVariant data1, QVariant data2)
1891{
1892 key_unit_wait();
1893}
1894
1895/***********************************************************************/
1898static void keep_moving(QVariant data1, QVariant data2)
1899{
1900}
1901
1902/***********************************************************************/
1906{
1907 if (!gov) {
1909 } else {
1911 }
1912}
1913
1914/***********************************************************************/
1919{
1921 /* The client isn't waiting for information for any unanswered follow
1922 * up questions. */
1923
1924 struct unit *actor_unit;
1925
1927 /* The action selection dialog wasn't closed because the actor unit
1928 * was lost. */
1929
1930 /* The probabilities didn't just disappear, right? */
1933
1935 }
1936
1937 /* The action selection process is over, at least for now. */
1939
1940 if (did_not_decide) {
1941 /* The action selection dialog was closed but the player didn't
1942 * decide what the unit should do. */
1943
1944 /* Reset so the next action selection dialog does the right thing. */
1945 did_not_decide = false;
1946 } else {
1947 /* An action, or no action at all, was selected. */
1950 }
1951 }
1952}
1953
1954/***********************************************************************/
1958static void diplomat_queue_handle_secondary(int actor_id)
1959{
1960 /* Stop waiting. Move on to the next queued unit. */
1963}
1964
1965/**********************************************************************/
1972{
1973 /* Stop assuming the answer to a follow up question will arrive. */
1975}
1976
1977/***********************************************************************/
1982 struct city *target_city,
1983 struct unit *target_unit,
1984 struct tile *target_tile,
1985 struct extra_type *target_extra,
1986 const struct act_prob *act_probs)
1987{
1988 struct astring title = ASTRING_INIT, text = ASTRING_INIT;
1989 choice_dialog *cd;
1990 qtiles caras;
1991 QVariant qv1, qv2;
1993 struct city *actor_homecity;
1994 action_id unit_act;
1995 action_id city_act;
1996
1997 unit_act = qdef_act::action()->vs_unit_get();
1998 city_act = qdef_act::action()->vs_city_get();
1999
2000 foreach (caras, gui()->trade_gen.lines) {
2001 if (caras.autocaravan == actor_unit) {
2002 int i;
2003 if (nullptr != game_unit_by_number(actor_unit->id)
2004 && nullptr != game_city_by_number(target_city->id)) {
2005 request_do_action(ACTION_TRADE_ROUTE, actor_unit->id,
2006 target_city->id, 0, "");
2009 i = gui()->trade_gen.lines.indexOf(caras);
2010 gui()->trade_gen.lines.takeAt(i);
2011 return;
2012 }
2013 }
2014 }
2015 if (target_city
2017 && action_prob_possible(act_probs[unit_act])) {
2019 return;
2020 }
2021
2022 if (target_unit
2024 && action_prob_possible(act_probs[city_act])) {
2026 return;
2027 }
2028 /* Could be caused by the server failing to reply to a request for more
2029 * information or a bug in the client code. */
2031 "Diplomat queue problem. Is another diplomat window open?");
2032
2033 /* No extra input is required as no action has been chosen yet. */
2035
2036 actor_homecity = game_city_by_number(actor_unit->homecity);
2037
2038 astr_set(&title,
2039 /* TRANS: %s is a unit name, e.g., Spy */
2040 _("Choose Your %s's Strategy"),
2042
2043 if (target_city && actor_homecity) {
2044 astr_set(&text,
2045 _("Your %s from %s reaches the city of %s.\nWhat now?"),
2047 city_name_get(actor_homecity),
2049 } else if (target_city) {
2050 astr_set(&text,
2051 _("Your %s has arrived at %s.\nWhat is your command?"),
2054 } else if (target_unit) {
2055 astr_set(&text,
2056 /* TRANS: Your Spy is ready to act against Roman Freight. */
2057 _("Your %s is ready to act against %s %s."),
2061 } else {
2063 "No target specified.");
2064
2065 astr_set(&text,
2066 /* TRANS: %s is a unit name, e.g., Diplomat, Spy */
2067 _("Your %s is waiting for your command."),
2069 }
2070
2071 cd = gui()->get_diplo_dialog();
2072 if ((cd != nullptr) && cd->targeted_unit != nullptr) {
2073 cd->update_dialog(act_probs);
2074 return;
2075 }
2076 cd = new choice_dialog(astr_str(&title), astr_str(&text),
2077 gui()->game_tab_widget,
2079 qv1 = actor_unit->id;
2080
2081 cd->unit_id = actor_unit->id;
2082
2083 cd->target_id[ATK_SELF] = cd->unit_id;
2084
2085 if (target_city) {
2086 cd->target_id[ATK_CITY] = target_city->id;
2087 } else {
2088 cd->target_id[ATK_CITY] = IDENTITY_NUMBER_ZERO;
2089 }
2090
2091 if (target_unit) {
2092 cd->target_id[ATK_UNIT] = target_unit->id;
2093 } else {
2094 cd->target_id[ATK_UNIT] = IDENTITY_NUMBER_ZERO;
2095 }
2096
2097 if (target_tile) {
2098 cd->target_id[ATK_UNITS] = tile_index(target_tile);
2099 } else {
2100 cd->target_id[ATK_UNITS] = TILE_INDEX_NONE;
2101 }
2102
2103 if (target_tile) {
2104 cd->target_id[ATK_TILE] = tile_index(target_tile);
2105 } else {
2106 cd->target_id[ATK_TILE] = TILE_INDEX_NONE;
2107 }
2108
2109 if (target_tile) {
2110 cd->target_id[ATK_EXTRAS] = tile_index(target_tile);
2111 } else {
2112 cd->target_id[ATK_EXTRAS] = TILE_INDEX_NONE;
2113 }
2114
2115 /* No target building or target tech supplied. (Feb 2020) */
2116 cd->sub_target_id[ASTK_BUILDING] = B_LAST;
2117 cd->sub_target_id[ASTK_TECH] = A_UNSET;
2118
2119 if (target_extra) {
2120 cd->sub_target_id[ASTK_EXTRA] = extra_number(target_extra);
2121 cd->sub_target_id[ASTK_EXTRA_NOT_THERE] = extra_number(target_extra);
2122 } else {
2123 cd->sub_target_id[ASTK_EXTRA] = EXTRA_NONE;
2124 cd->sub_target_id[ASTK_EXTRA_NOT_THERE] = EXTRA_NONE;
2125 }
2126
2127 /* Unit acting against a city */
2128
2129 /* Set the correct target for the following actions. */
2130 qv2 = cd->target_id[ATK_CITY];
2131
2132 action_iterate(act) {
2133 if (action_id_get_actor_kind(act) == AAK_UNIT
2134 && action_id_get_target_kind(act) == ATK_CITY) {
2135 action_entry(cd, act, act_probs,
2137 act_probs[act],
2138 actor_unit,
2139 target_city),
2140 qv1, qv2);
2141 }
2143
2144 /* Unit acting against another unit */
2145
2146 /* Set the correct target for the following actions. */
2147 qv2 = cd->target_id[ATK_UNIT];
2148
2149 action_iterate(act) {
2150 if (action_id_get_actor_kind(act) == AAK_UNIT
2151 && action_id_get_target_kind(act) == ATK_UNIT) {
2152 action_entry(cd, act, act_probs,
2154 act_probs[act],
2155 actor_unit,
2156 target_city),
2157 qv1, qv2);
2158 }
2160
2161 /* Unit acting against all units at a tile */
2162
2163 /* Set the correct target for the following actions. */
2164 qv2 = cd->target_id[ATK_UNITS];
2165
2166 action_iterate(act) {
2167 if (action_id_get_actor_kind(act) == AAK_UNIT
2168 && action_id_get_target_kind(act) == ATK_UNITS) {
2169 action_entry(cd, act, act_probs,
2171 act_probs[act],
2172 actor_unit,
2173 target_city),
2174 qv1, qv2);
2175 }
2177
2178 /* Unit acting against a tile. */
2179
2180 /* Set the correct target for the following actions. */
2181 qv2 = cd->target_id[ATK_TILE];
2182
2183 action_iterate(act) {
2184 if (action_id_get_actor_kind(act) == AAK_UNIT
2185 && action_id_get_target_kind(act) == ATK_TILE) {
2186 action_entry(cd, act, act_probs,
2188 act_probs[act],
2189 actor_unit,
2190 target_city),
2191 qv1, qv2);
2192 }
2194
2195 /* Unit acting against a tile's extras. */
2196
2197 /* Set the correct target for the following actions. */
2198 qv2 = cd->target_id[ATK_EXTRAS];
2199
2200 action_iterate(act) {
2201 if (action_id_get_actor_kind(act) == AAK_UNIT
2202 && action_id_get_target_kind(act) == ATK_EXTRAS) {
2203 action_entry(cd, act, act_probs,
2205 act_probs[act],
2206 actor_unit,
2207 target_city),
2208 qv1, qv2);
2209 }
2211
2212 /* Unit acting against itself */
2213
2214 /* Set the correct target for the following actions. */
2215 qv2 = cd->target_id[ATK_SELF];
2216
2217 action_iterate(act) {
2218 if (action_id_get_actor_kind(act) == AAK_UNIT
2219 && action_id_get_target_kind(act) == ATK_SELF) {
2220 action_entry(cd, act, act_probs,
2222 act_probs[act],
2223 actor_unit,
2224 target_city),
2225 qv1, qv2);
2226 }
2228
2230 cd->add_item(QString(_("&Wait")), func, qv1, qv2,
2231 "", BUTTON_WAIT);
2232
2233 func = keep_moving;
2234 cd->add_item(QString(_("Do nothing")), func, qv1, qv2,
2235 "", BUTTON_CANCEL);
2236
2237 cd->set_layout();
2238 cd->show_me();
2239
2240 /* Give follow up questions access to action probabilities. */
2242 action_iterate(act) {
2243 actor_unit->client.act_prob_cache[act] = act_probs[act];
2245
2246 astr_free(&title);
2247 astr_free(&text);
2248}
2249
2250/***********************************************************************/
2255{
2256 /* Don't add an action mapping here unless the non targeted version is
2257 * selectable in the targeted version's target selection dialog. */
2258 switch ((enum gen_action)tgt_action_id) {
2259 case ACTION_SPY_TARGETED_SABOTAGE_CITY:
2260 return ACTION_SPY_SABOTAGE_CITY;
2261 case ACTION_SPY_TARGETED_SABOTAGE_CITY_ESC:
2262 return ACTION_SPY_SABOTAGE_CITY_ESC;
2263 case ACTION_SPY_TARGETED_STEAL_TECH:
2264 return ACTION_SPY_STEAL_TECH;
2265 case ACTION_SPY_TARGETED_STEAL_TECH_ESC:
2266 return ACTION_SPY_STEAL_TECH_ESC;
2267 default:
2268 /* No non targeted version found. */
2269 return ACTION_NONE;
2270 }
2271}
2272
2273/**********************************************************************/
2278{
2279 /* Don't add an action mapping here unless the non targeted version is
2280 * selectable in the targeted version's target selection dialog. */
2281 switch ((enum gen_action)tgt_action_id) {
2282 case ACTION_SPY_TARGETED_SABOTAGE_CITY:
2283 return ACTION_SPY_SABOTAGE_CITY_PRODUCTION;
2284 case ACTION_SPY_TARGETED_SABOTAGE_CITY_ESC:
2285 return ACTION_SPY_SABOTAGE_CITY_PRODUCTION_ESC;
2286 case ACTION_STRIKE_BUILDING:
2287 return ACTION_STRIKE_PRODUCTION;
2288 default:
2289 /* No non targeted version found. */
2290 return ACTION_NONE;
2291 }
2292}
2293
2294/***********************************************************************/
2298 action_id act,
2299 const struct act_prob *act_probs,
2300 const char *custom,
2301 QVariant data1, QVariant data2)
2302{
2303 QString title;
2304 QString tool_tip;
2305
2306 if (!af_map.contains(act)) {
2307 /* The Qt client doesn't support ordering this action from the
2308 * action selection dialog. */
2309 return;
2310 }
2311
2312 /* Don't show disabled actions. */
2313 if (!action_prob_possible(act_probs[act])) {
2314 return;
2315 }
2316
2317 title = QString(action_prepare_ui_name(act, "&",
2318 act_probs[act],
2319 custom));
2320
2321 tool_tip = QString(act_sel_action_tool_tip(action_by_number(act),
2322 act_probs[act]));
2323
2324 cd->add_item(title, af_map[act], data1, data2, tool_tip, act);
2325}
2326
2327/***********************************************************************/
2331 action_id act,
2332 const struct act_prob *act_probs,
2333 const char *custom,
2334 QVariant data1, QVariant data2)
2335{
2336 QString title;
2337 QString tool_tip;
2338
2339 /* An action that just became impossible has its button disabled.
2340 * An action that became possible again must be re-enabled. */
2341 button->setEnabled(action_prob_possible(act_probs[act]));
2342 button->setData1(data1);
2343 button->setData2(data2);
2344 /* The probability may have changed. */
2345 title = QString(action_prepare_ui_name(act, "&",
2346 act_probs[act],
2347 custom));
2348
2349 tool_tip = QString(act_sel_action_tool_tip(action_by_number(act),
2350 act_probs[act]));
2351
2352 button->setText(title);
2353 button->setToolTip(tool_tip);
2354}
2355
2356/***********************************************************************/
2359static void disband_unit(QVariant data1, QVariant data2)
2360{
2361 int actor_id = data1.toInt();
2362 int target_id = data2.toInt();
2363
2364 request_do_action(ACTION_DISBAND_UNIT, actor_id,
2365 target_id, 0, "");
2366}
2367
2368/***********************************************************************/
2371static void fortify(QVariant data1, QVariant data2)
2372{
2373 int actor_id = data1.toInt();
2374 int target_id = data2.toInt();
2375
2376 if (NULL != game_unit_by_number(actor_id)) {
2377 request_do_action(ACTION_FORTIFY, actor_id,
2378 target_id, 0, "");
2379 }
2380}
2381
2382/***********************************************************************/
2385static void convert_unit(QVariant data1, QVariant data2)
2386{
2387 int actor_id = data1.toInt();
2388 int target_id = data2.toInt();
2389
2390 request_do_action(ACTION_CONVERT, actor_id,
2391 target_id, 0, "");
2392}
2393
2394/***********************************************************************/
2397static void homeless(QVariant data1, QVariant data2)
2398{
2399 int actor_id = data1.toInt();
2400 int target_id = data2.toInt();
2401
2402 if (NULL != game_unit_by_number(actor_id)) {
2403 request_do_action(ACTION_HOMELESS, actor_id,
2404 target_id, 0, "");
2405 }
2406}
2407
2408/***********************************************************************/
2411static void diplomat_bribe(QVariant data1, QVariant data2)
2412{
2413 int diplomat_id = data1.toInt();
2414 int diplomat_target_id = data2.toInt();
2415
2416 if (NULL != game_unit_by_number(diplomat_id)
2417 && NULL != game_unit_by_number(diplomat_target_id)) {
2418 /* Wait for the server's reply before moving on to the next queued diplomat. */
2420
2421 request_action_details(ACTION_SPY_BRIBE_UNIT, diplomat_id,
2422 diplomat_target_id);
2423 }
2424}
2425
2426/***********************************************************************/
2429static void spy_sabotage_unit(QVariant data1, QVariant data2)
2430{
2431 int diplomat_id = data1.toInt();
2432 int diplomat_target_id = data2.toInt();
2433
2434 request_do_action(ACTION_SPY_SABOTAGE_UNIT, diplomat_id,
2435 diplomat_target_id, 0, "");
2436}
2437
2438/***********************************************************************/
2441static void spy_sabotage_unit_esc(QVariant data1, QVariant data2)
2442{
2443 int diplomat_id = data1.toInt();
2444 int diplomat_target_id = data2.toInt();
2445
2446 request_do_action(ACTION_SPY_SABOTAGE_UNIT_ESC, diplomat_id,
2447 diplomat_target_id, 0, "");
2448}
2449
2450/***********************************************************************/
2453static void heal_unit(QVariant data1, QVariant data2)
2454{
2455 int actor_id = data1.toInt();
2456 int target_id = data2.toInt();
2457
2458 request_do_action(ACTION_HEAL_UNIT, actor_id, target_id, 0, "");
2459}
2460
2461/***********************************************************************/
2464static void heal_unit2(QVariant data1, QVariant data2)
2465{
2466 int actor_id = data1.toInt();
2467 int target_id = data2.toInt();
2468
2469 request_do_action(ACTION_HEAL_UNIT2, actor_id, target_id, 0, "");
2470}
2471
2472/***********************************************************************/
2475static void transport_board(QVariant data1, QVariant data2)
2476{
2477 int actor_id = data1.toInt();
2478 int target_id = data2.toInt();
2479
2480 request_do_action(ACTION_TRANSPORT_BOARD, actor_id, target_id, 0, "");
2481}
2482
2483/***********************************************************************/
2486static void transport_embark(QVariant data1, QVariant data2)
2487{
2488 int actor_id = data1.toInt();
2489 int target_id = data2.toInt();
2490
2491 request_do_action(ACTION_TRANSPORT_EMBARK, actor_id, target_id, 0, "");
2492}
2493
2494/***********************************************************************/
2497static void transport_embark2(QVariant data1, QVariant data2)
2498{
2499 int actor_id = data1.toInt();
2500 int target_id = data2.toInt();
2501
2502 request_do_action(ACTION_TRANSPORT_EMBARK2, actor_id, target_id, 0, "");
2503}
2504
2505/***********************************************************************/
2508static void transport_embark3(QVariant data1, QVariant data2)
2509{
2510 int actor_id = data1.toInt();
2511 int target_id = data2.toInt();
2512
2513 request_do_action(ACTION_TRANSPORT_EMBARK3, actor_id, target_id, 0, "");
2514}
2515
2516/***********************************************************************/
2519static void transport_unload(QVariant data1, QVariant data2)
2520{
2521 int actor_id = data1.toInt();
2522 int target_id = data2.toInt();
2523
2524 request_do_action(ACTION_TRANSPORT_UNLOAD, actor_id, target_id, 0, "");
2525}
2526
2527/***********************************************************************/
2530static void transport_alight(QVariant data1, QVariant data2)
2531{
2532 int actor_id = data1.toInt();
2533 int target_id = data2.toInt();
2534
2535 request_do_action(ACTION_TRANSPORT_ALIGHT, actor_id, target_id, 0, "");
2536}
2537
2538/***********************************************************************/
2541static void disembark1(QVariant data1, QVariant data2)
2542{
2543 int actor_id = data1.toInt();
2544 int target_id = data2.toInt();
2545
2546 if (NULL != game_unit_by_number(actor_id)
2547 && NULL != index_to_tile(&(wld.map), target_id)) {
2548 request_do_action(ACTION_TRANSPORT_DISEMBARK1,
2549 actor_id, target_id, 0, "");
2550 }
2551}
2552
2553/***********************************************************************/
2556static void disembark2(QVariant data1, QVariant data2)
2557{
2558 int actor_id = data1.toInt();
2559 int target_id = data2.toInt();
2560
2561 if (NULL != game_unit_by_number(actor_id)
2562 && NULL != index_to_tile(&(wld.map), target_id)) {
2563 request_do_action(ACTION_TRANSPORT_DISEMBARK2,
2564 actor_id, target_id, 0, "");
2565 }
2566}
2567
2568/***********************************************************************/
2571static void enter_hut(QVariant data1, QVariant data2)
2572{
2573 int actor_id = data1.toInt();
2574 int target_id = data2.toInt();
2575
2576 if (NULL != game_unit_by_number(actor_id)
2577 && NULL != index_to_tile(&(wld.map), target_id)) {
2578 request_do_action(ACTION_HUT_ENTER,
2579 actor_id, target_id, 0, "");
2580 }
2581}
2582
2583/***********************************************************************/
2586static void enter_hut2(QVariant data1, QVariant data2)
2587{
2588 int actor_id = data1.toInt();
2589 int target_id = data2.toInt();
2590
2591 if (NULL != game_unit_by_number(actor_id)
2592 && NULL != index_to_tile(&(wld.map), target_id)) {
2593 request_do_action(ACTION_HUT_ENTER2,
2594 actor_id, target_id, 0, "");
2595 }
2596}
2597
2598/***********************************************************************/
2601static void frighten_hut(QVariant data1, QVariant data2)
2602{
2603 int actor_id = data1.toInt();
2604 int target_id = data2.toInt();
2605
2606 if (NULL != game_unit_by_number(actor_id)
2607 && NULL != index_to_tile(&(wld.map), target_id)) {
2608 request_do_action(ACTION_HUT_FRIGHTEN,
2609 actor_id, target_id, 0, "");
2610 }
2611}
2612
2613/***********************************************************************/
2616static void frighten_hut2(QVariant data1, QVariant data2)
2617{
2618 int actor_id = data1.toInt();
2619 int target_id = data2.toInt();
2620
2621 if (NULL != game_unit_by_number(actor_id)
2622 && NULL != index_to_tile(&(wld.map), target_id)) {
2623 request_do_action(ACTION_HUT_FRIGHTEN2,
2624 actor_id, target_id, 0, "");
2625 }
2626}
2627
2628/**********************************************************************/
2631static void nuke_units(QVariant data1, QVariant data2)
2632{
2633 int actor_id = data1.toInt();
2634 int target_id = data2.toInt();
2635
2636 request_do_action(ACTION_NUKE_UNITS, actor_id,
2637 target_id, 0, "");
2638}
2639
2640/**********************************************************************/
2643static void capture_units(QVariant data1, QVariant data2)
2644{
2645 int actor_id = data1.toInt();
2646 int target_id = data2.toInt();
2647
2648 request_do_action(ACTION_CAPTURE_UNITS, actor_id,
2649 target_id, 0, "");
2650}
2651
2652/***********************************************************************/
2655static void expel_unit(QVariant data1, QVariant data2)
2656{
2657 int actor_id = data1.toInt();
2658 int target_id = data2.toInt();
2659
2660 request_do_action(ACTION_EXPEL_UNIT, actor_id,
2661 target_id, 0, "");
2662}
2663
2664/***********************************************************************/
2667static void bombard(QVariant data1, QVariant data2)
2668{
2669 int actor_id = data1.toInt();
2670 int target_id = data2.toInt();
2671
2672 request_do_action(ACTION_BOMBARD, actor_id,
2673 target_id, 0, "");
2674}
2675
2676/***********************************************************************/
2679static void bombard2(QVariant data1, QVariant data2)
2680{
2681 int actor_id = data1.toInt();
2682 int target_id = data2.toInt();
2683
2684 request_do_action(ACTION_BOMBARD2, actor_id,
2685 target_id, 0, "");
2686}
2687
2688/***********************************************************************/
2691static void bombard3(QVariant data1, QVariant data2)
2692{
2693 int actor_id = data1.toInt();
2694 int target_id = data2.toInt();
2695
2696 request_do_action(ACTION_BOMBARD3, actor_id,
2697 target_id, 0, "");
2698}
2699
2700/***********************************************************************/
2703static void found_city(QVariant data1, QVariant data2)
2704{
2705 int actor_id = data1.toInt();
2706
2708 actor_id, actor_id);
2709}
2710
2711/***********************************************************************/
2714static void transform_terrain(QVariant data1, QVariant data2)
2715{
2716 int actor_id = data1.toInt();
2717 int target_id = data2.toInt();
2718
2719 if (NULL != game_unit_by_number(actor_id)
2720 && NULL != index_to_tile(&(wld.map), target_id)) {
2721 request_do_action(ACTION_TRANSFORM_TERRAIN,
2722 actor_id, target_id, 0, "");
2723 }
2724}
2725
2726/***********************************************************************/
2729static void cultivate(QVariant data1, QVariant data2)
2730{
2731 int actor_id = data1.toInt();
2732 int target_id = data2.toInt();
2733
2734 if (NULL != game_unit_by_number(actor_id)
2735 && NULL != index_to_tile(&(wld.map), target_id)) {
2736 request_do_action(ACTION_CULTIVATE,
2737 actor_id, target_id, 0, "");
2738 }
2739}
2740
2741/***********************************************************************/
2744static void plant(QVariant data1, QVariant data2)
2745{
2746 int actor_id = data1.toInt();
2747 int target_id = data2.toInt();
2748
2749 if (NULL != game_unit_by_number(actor_id)
2750 && NULL != index_to_tile(&(wld.map), target_id)) {
2751 request_do_action(ACTION_PLANT,
2752 actor_id, target_id, 0, "");
2753 }
2754}
2755
2756/***********************************************************************/
2759static void pillage(QVariant data1, QVariant data2)
2760{
2761 int actor_id = data1.toInt();
2762 int target_id = data2.toInt();
2763
2764 if (NULL != game_unit_by_number(actor_id)
2765 && NULL != index_to_tile(&(wld.map), target_id)) {
2766 request_do_action(ACTION_PILLAGE,
2767 actor_id, target_id,
2768 /* FIXME: will cause problems if more than
2769 * one action selection dialog at a time
2770 * becomes supported. */
2772 "");
2773 }
2774}
2775
2776/***********************************************************************/
2779static void clean_pollution(QVariant data1, QVariant data2)
2780{
2781 int actor_id = data1.toInt();
2782 int target_id = data2.toInt();
2783
2784 if (NULL != game_unit_by_number(actor_id)
2785 && NULL != index_to_tile(&(wld.map), target_id)) {
2786 request_do_action(ACTION_CLEAN_POLLUTION,
2787 actor_id, target_id,
2788 /* FIXME: will cause problems if more than
2789 * one action selection dialog at a time
2790 * becomes supported. */
2792 "");
2793 }
2794}
2795
2796/***********************************************************************/
2799static void clean_fallout(QVariant data1, QVariant data2)
2800{
2801 int actor_id = data1.toInt();
2802 int target_id = data2.toInt();
2803
2804 if (NULL != game_unit_by_number(actor_id)
2805 && NULL != index_to_tile(&(wld.map), target_id)) {
2806 request_do_action(ACTION_CLEAN_FALLOUT,
2807 actor_id, target_id,
2808 /* FIXME: will cause problems if more than
2809 * one action selection dialog at a time
2810 * becomes supported. */
2812 "");
2813 }
2814}
2815
2816/***********************************************************************/
2819static void road(QVariant data1, QVariant data2)
2820{
2821 int actor_id = data1.toInt();
2822 int target_id = data2.toInt();
2823
2824 if (NULL != game_unit_by_number(actor_id)
2825 && NULL != index_to_tile(&(wld.map), target_id)
2827 request_do_action(ACTION_ROAD,
2828 actor_id, target_id,
2829 /* FIXME: will cause problems if more than
2830 * one action selection dialog at a time
2831 * becomes supported. */
2833 "");
2834 }
2835}
2836
2837/***********************************************************************/
2840static void base(QVariant data1, QVariant data2)
2841{
2842 int actor_id = data1.toInt();
2843 int target_id = data2.toInt();
2844
2845 if (NULL != game_unit_by_number(actor_id)
2846 && NULL != index_to_tile(&(wld.map), target_id)
2848 request_do_action(ACTION_BASE,
2849 actor_id, target_id,
2850 /* FIXME: will cause problems if more than
2851 * one action selection dialog at a time
2852 * becomes supported. */
2854 "");
2855 }
2856}
2857
2858/***********************************************************************/
2861static void mine(QVariant data1, QVariant data2)
2862{
2863 int actor_id = data1.toInt();
2864 int target_id = data2.toInt();
2865
2866 if (NULL != game_unit_by_number(actor_id)
2867 && NULL != index_to_tile(&(wld.map), target_id)
2869 request_do_action(ACTION_MINE,
2870 actor_id, target_id,
2871 /* FIXME: will cause problems if more than
2872 * one action selection dialog at a time
2873 * becomes supported. */
2875 "");
2876 }
2877}
2878
2879/***********************************************************************/
2882static void irrigate(QVariant data1, QVariant data2)
2883{
2884 int actor_id = data1.toInt();
2885 int target_id = data2.toInt();
2886
2887 if (NULL != game_unit_by_number(actor_id)
2888 && NULL != index_to_tile(&(wld.map), target_id)
2890 request_do_action(ACTION_IRRIGATE,
2891 actor_id, target_id,
2892 /* FIXME: will cause problems if more than
2893 * one action selection dialog at a time
2894 * becomes supported. */
2896 "");
2897 }
2898}
2899
2900/***********************************************************************/
2903static void nuke(QVariant data1, QVariant data2)
2904{
2905 int diplomat_id = data1.toInt();
2906 int diplomat_target_id = data2.toInt();
2907
2908 if (NULL != game_unit_by_number(diplomat_id)
2909 && NULL != index_to_tile(&(wld.map), diplomat_target_id)) {
2910 request_do_action(ACTION_NUKE,
2911 diplomat_id, diplomat_target_id, 0, "");
2912 }
2913}
2914
2915/***********************************************************************/
2918static void attack(QVariant data1, QVariant data2)
2919{
2920 int diplomat_id = data1.toInt();
2921 int diplomat_target_id = data2.toInt();
2922
2923 if (NULL != game_unit_by_number(diplomat_id)
2924 && NULL != index_to_tile(&(wld.map), diplomat_target_id)) {
2925 request_do_action(ACTION_ATTACK,
2926 diplomat_id, diplomat_target_id, 0, "");
2927 }
2928}
2929
2930/***********************************************************************/
2933static void suicide_attack(QVariant data1, QVariant data2)
2934{
2935 int diplomat_id = data1.toInt();
2936 int diplomat_target_id = data2.toInt();
2937
2938 if (NULL != game_unit_by_number(diplomat_id)
2939 && NULL != index_to_tile(&(wld.map), diplomat_target_id)) {
2940 request_do_action(ACTION_SUICIDE_ATTACK,
2941 diplomat_id, diplomat_target_id, 0, "");
2942 }
2943}
2944
2945/***********************************************************************/
2948static void paradrop(QVariant data1, QVariant data2)
2949{
2950 int actor_id = data1.toInt();
2951 int target_id = data2.toInt();
2952
2953 if (NULL != game_unit_by_number(actor_id)
2954 && NULL != index_to_tile(&(wld.map), target_id)) {
2955 request_do_action(ACTION_PARADROP,
2956 actor_id, target_id, 0, "");
2957 }
2958}
2959
2960/***********************************************************************/
2963static void paradrop_conquer(QVariant data1, QVariant data2)
2964{
2965 int actor_id = data1.toInt();
2966 int target_id = data2.toInt();
2967
2968 if (NULL != game_unit_by_number(actor_id)
2969 && NULL != index_to_tile(&(wld.map), target_id)) {
2970 request_do_action(ACTION_PARADROP_CONQUER,
2971 actor_id, target_id, 0, "");
2972 }
2973}
2974
2975/***********************************************************************/
2978static void paradrop_frighten(QVariant data1, QVariant data2)
2979{
2980 int actor_id = data1.toInt();
2981 int target_id = data2.toInt();
2982
2983 if (NULL != game_unit_by_number(actor_id)
2984 && NULL != index_to_tile(&(wld.map), target_id)) {
2985 request_do_action(ACTION_PARADROP_FRIGHTEN,
2986 actor_id, target_id, 0, "");
2987 }
2988}
2989
2990/***********************************************************************/
2993static void paradrop_frighten_conquer(QVariant data1, QVariant data2)
2994{
2995 int actor_id = data1.toInt();
2996 int target_id = data2.toInt();
2997
2998 if (NULL != game_unit_by_number(actor_id)
2999 && NULL != index_to_tile(&(wld.map), target_id)) {
3000 request_do_action(ACTION_PARADROP_FRIGHTEN_CONQUER,
3001 actor_id, target_id, 0, "");
3002 }
3003}
3004
3005/***********************************************************************/
3008static void paradrop_enter(QVariant data1, QVariant data2)
3009{
3010 int actor_id = data1.toInt();
3011 int target_id = data2.toInt();
3012
3013 if (NULL != game_unit_by_number(actor_id)
3014 && NULL != index_to_tile(&(wld.map), target_id)) {
3015 request_do_action(ACTION_PARADROP_ENTER,
3016 actor_id, target_id, 0, "");
3017 }
3018}
3019
3020/***********************************************************************/
3023static void paradrop_enter_conquer(QVariant data1, QVariant data2)
3024{
3025 int actor_id = data1.toInt();
3026 int target_id = data2.toInt();
3027
3028 if (NULL != game_unit_by_number(actor_id)
3029 && NULL != index_to_tile(&(wld.map), target_id)) {
3030 request_do_action(ACTION_PARADROP_ENTER_CONQUER,
3031 actor_id, target_id, 0, "");
3032 }
3033}
3034
3035/***********************************************************************/
3038static void join_city(QVariant data1, QVariant data2)
3039{
3040 int actor_id = data1.toInt();
3041 int target_id = data2.toInt();
3042
3043 if (NULL != game_unit_by_number(actor_id)
3044 && NULL != game_city_by_number(target_id)) {
3045 request_do_action(ACTION_JOIN_CITY,
3046 actor_id, target_id, 0, "");
3047 }
3048}
3049
3050/***********************************************************************/
3053static void spy_steal_shared(QVariant data1, QVariant data2,
3054 action_id act_id)
3055{
3056 QString str;
3057 QVariant qv1;
3059 int diplomat_id = data1.toInt();
3060 int diplomat_target_id = data2.toInt();
3061 struct unit *actor_unit = game_unit_by_number(diplomat_id);
3062 struct city *pvcity = game_city_by_number(diplomat_target_id);
3063 struct player *pvictim = NULL;
3064 choice_dialog *cd;
3065 QList<QVariant> actor_and_target;
3066
3067 cd = gui()->get_diplo_dialog();
3068 if (cd != NULL) {
3069 cd->close();
3070 }
3071
3072 if (pvcity == nullptr) {
3073 return;
3074 }
3075
3076 // Wait for the player's reply before moving on to the next queued diplomat.
3078
3079 pvictim = city_owner(pvcity);
3080
3081 struct astring stra = ASTRING_INIT;
3082 cd = new choice_dialog(_("Steal"), _("Steal Technology"),
3083 gui()->game_tab_widget,
3085
3086 // Put both actor and target city in qv1 since qv2 is taken
3087 actor_and_target.append(diplomat_id);
3088 actor_and_target.append(diplomat_target_id);
3089 actor_and_target.append(act_id);
3090 qv1 = QVariant::fromValue(actor_and_target);
3091
3092 struct player *pplayer = client_player();
3093 const struct research *presearch = research_get(pplayer);
3094 const struct research *vresearch = research_get(pvictim);
3095
3097 if (research_invention_gettable(presearch, i,
3099 && research_invention_state(vresearch, i) == TECH_KNOWN
3100 && research_invention_state(presearch, i) != TECH_KNOWN) {
3102 // Defeat keyboard shortcut mnemonics
3103 str = QString(research_advance_name_translation(presearch, i))
3104 .replace("&", "&&");
3105 cd->add_item(str, func, qv1, i);
3106 }
3108
3110 get_non_targeted_action_id(act_id)])) {
3111 astr_set(&stra, _("At %s's Discretion"),
3114 str = QString(astr_str(&stra)).replace("&", "&&");
3115 cd->add_item(str, func, qv1, A_UNSET);
3116 }
3117
3118 cd->set_layout();
3119 cd->show_me();
3120
3121 astr_free(&stra);
3122}
3123
3124/***********************************************************************/
3127static void spy_steal(QVariant data1, QVariant data2)
3128{
3129 spy_steal_shared(data1, data2, ACTION_SPY_TARGETED_STEAL_TECH);
3130}
3131
3132/***********************************************************************/
3135static void spy_steal_esc(QVariant data1, QVariant data2)
3136{
3137 spy_steal_shared(data1, data2, ACTION_SPY_TARGETED_STEAL_TECH_ESC);
3138}
3139
3140/***********************************************************************/
3143static void spy_steal_something(QVariant data1, QVariant data2)
3144{
3145 int diplomat_id = data1.toList().at(0).toInt();
3146 int diplomat_target_id = data1.toList().at(1).toInt();
3147 action_id act_id = data1.toList().at(2).toInt();
3148
3149 if (NULL != game_unit_by_number(diplomat_id)
3150 && NULL != game_city_by_number(diplomat_target_id)) {
3151 if (data2.toInt() == A_UNSET) {
3152 /* This is the untargeted version. */
3154 diplomat_id, diplomat_target_id, data2.toInt(), "");
3155 } else {
3156 /* This is the targeted version. */
3157 request_do_action(act_id, diplomat_id,
3158 diplomat_target_id, data2.toInt(), "");
3159 }
3160 }
3161}
3162
3163/***********************************************************************/
3166static void spy_request_strike_bld_list(QVariant data1, QVariant data2)
3167{
3168 int actor_id = data1.toInt();
3169 int target_id = data2.toInt();
3170
3171 if (NULL != game_unit_by_number(actor_id)
3172 && NULL != game_city_by_number(target_id)) {
3173 /* Wait for the server's reply before moving on to the next queued diplomat. */
3175
3176 request_action_details(ACTION_STRIKE_BUILDING, actor_id, target_id);
3177 }
3178}
3179
3180/***********************************************************************/
3183static void spy_request_sabotage_list(QVariant data1, QVariant data2)
3184{
3185 int diplomat_id = data1.toInt();
3186 int diplomat_target_id = data2.toInt();
3187
3188 if (NULL != game_unit_by_number(diplomat_id)
3189 && NULL != game_city_by_number(diplomat_target_id)) {
3190 /* Wait for the server's reply before moving on to the next queued diplomat. */
3192
3193 request_action_details(ACTION_SPY_TARGETED_SABOTAGE_CITY, diplomat_id,
3194 diplomat_target_id);
3195 }
3196}
3197
3198/***********************************************************************/
3201static void spy_request_sabotage_esc_list(QVariant data1, QVariant data2)
3202{
3203 int diplomat_id = data1.toInt();
3204 int diplomat_target_id = data2.toInt();
3205
3206 if (NULL != game_unit_by_number(diplomat_id)
3207 && NULL != game_city_by_number(diplomat_target_id)) {
3208 /* Wait for the server's reply before moving on to the next queued
3209 * diplomat. */
3211
3212 request_action_details(ACTION_SPY_TARGETED_SABOTAGE_CITY_ESC,
3213 diplomat_id, diplomat_target_id);
3214 }
3215}
3216
3217/***********************************************************************/
3220static void spy_poison(QVariant data1, QVariant data2)
3221{
3222 int diplomat_id = data1.toInt();
3223 int diplomat_target_id = data2.toInt();
3224
3225 if (NULL != game_unit_by_number(diplomat_id)
3226 && NULL != game_city_by_number(diplomat_target_id)) {
3227 request_do_action(ACTION_SPY_POISON,
3228 diplomat_id, diplomat_target_id, 0, "");
3229 }
3230}
3231
3232/***********************************************************************/
3235static void spy_poison_esc(QVariant data1, QVariant data2)
3236{
3237 int diplomat_id = data1.toInt();
3238 int diplomat_target_id = data2.toInt();
3239
3240 if (NULL != game_unit_by_number(diplomat_id)
3241 && NULL != game_city_by_number(diplomat_target_id)) {
3242 request_do_action(ACTION_SPY_POISON_ESC,
3243 diplomat_id, diplomat_target_id, 0, "");
3244 }
3245}
3246
3247/***********************************************************************/
3250static void spy_nuke_city(QVariant data1, QVariant data2)
3251{
3252 int diplomat_id = data1.toInt();
3253 int diplomat_target_id = data2.toInt();
3254
3255 if (NULL != game_unit_by_number(diplomat_id)
3256 && NULL != game_city_by_number(diplomat_target_id)) {
3257 request_do_action(ACTION_SPY_NUKE,
3258 diplomat_id, diplomat_target_id, 0, "");
3259 }
3260}
3261
3262/***********************************************************************/
3265static void spy_nuke_city_esc(QVariant data1, QVariant data2)
3266{
3267 int diplomat_id = data1.toInt();
3268 int diplomat_target_id = data2.toInt();
3269
3270 if (NULL != game_unit_by_number(diplomat_id)
3271 && NULL != game_city_by_number(diplomat_target_id)) {
3272 request_do_action(ACTION_SPY_NUKE_ESC,
3273 diplomat_id, diplomat_target_id, 0, "");
3274 }
3275}
3276
3277/***********************************************************************/
3280static void nuke_city(QVariant data1, QVariant data2)
3281{
3282 int actor_id = data1.toInt();
3283 int target_id = data2.toInt();
3284
3285 if (NULL != game_unit_by_number(actor_id)
3286 && NULL != game_city_by_number(target_id)) {
3287 request_do_action(ACTION_NUKE_CITY,
3288 actor_id, target_id, 0, "");
3289 }
3290}
3291
3292/***********************************************************************/
3295static void destroy_city(QVariant data1, QVariant data2)
3296{
3297 int diplomat_id = data1.toInt();
3298 int diplomat_target_id = data2.toInt();
3299
3300 if (NULL != game_unit_by_number(diplomat_id)
3301 && NULL != game_city_by_number(diplomat_target_id)) {
3302 request_do_action(ACTION_DESTROY_CITY,
3303 diplomat_id, diplomat_target_id, 0, "");
3304 }
3305}
3306
3307/***********************************************************************/
3310static void spy_steal_gold(QVariant data1, QVariant data2)
3311{
3312 int diplomat_id = data1.toInt();
3313 int diplomat_target_id = data2.toInt();
3314
3315 if (NULL != game_unit_by_number(diplomat_id)
3316 && NULL != game_city_by_number(diplomat_target_id)) {
3317 request_do_action(ACTION_SPY_STEAL_GOLD,
3318 diplomat_id, diplomat_target_id, 0, "");
3319 }
3320}
3321
3322/***********************************************************************/
3325static void spy_steal_gold_esc(QVariant data1, QVariant data2)
3326{
3327 int diplomat_id = data1.toInt();
3328 int diplomat_target_id = data2.toInt();
3329
3330 if (NULL != game_unit_by_number(diplomat_id)
3331 && NULL != game_city_by_number(diplomat_target_id)) {
3332 request_do_action(ACTION_SPY_STEAL_GOLD_ESC,
3333 diplomat_id, diplomat_target_id, 0, "");
3334 }
3335}
3336
3337/***********************************************************************/
3340static void spy_steal_maps(QVariant data1, QVariant data2)
3341{
3342 int diplomat_id = data1.toInt();
3343 int diplomat_target_id = data2.toInt();
3344
3345 if (NULL != game_unit_by_number(diplomat_id)
3346 && NULL != game_city_by_number(diplomat_target_id)) {
3347 request_do_action(ACTION_STEAL_MAPS,
3348 diplomat_id, diplomat_target_id, 0, "");
3349 }
3350}
3351
3352/***********************************************************************/
3355static void spy_steal_maps_esc(QVariant data1, QVariant data2)
3356{
3357 int diplomat_id = data1.toInt();
3358 int diplomat_target_id = data2.toInt();
3359
3360 if (NULL != game_unit_by_number(diplomat_id)
3361 && NULL != game_city_by_number(diplomat_target_id)) {
3362 request_do_action(ACTION_STEAL_MAPS_ESC,
3363 diplomat_id, diplomat_target_id, 0, "");
3364 }
3365}
3366
3367/***********************************************************************/
3370static void spy_embassy(QVariant data1, QVariant data2)
3371{
3372 int diplomat_id = data1.toInt();
3373 int diplomat_target_id = data2.toInt();
3374
3375 if (NULL != game_unit_by_number(diplomat_id)
3376 && NULL != game_city_by_number(diplomat_target_id)) {
3377 request_do_action(ACTION_ESTABLISH_EMBASSY, diplomat_id,
3378 diplomat_target_id, 0, "");
3379 }
3380}
3381
3382/***********************************************************************/
3385static void diplomat_embassy(QVariant data1, QVariant data2)
3386{
3387 int diplomat_id = data1.toInt();
3388 int diplomat_target_id = data2.toInt();
3389
3390 if (NULL != game_unit_by_number(diplomat_id)
3391 && NULL != game_city_by_number(diplomat_target_id)) {
3392 request_do_action(ACTION_ESTABLISH_EMBASSY_STAY, diplomat_id,
3393 diplomat_target_id, 0, "");
3394 }
3395}
3396
3397/***********************************************************************/
3400static void spy_investigate(QVariant data1, QVariant data2)
3401{
3402 int diplomat_id = data1.toInt();
3403 int diplomat_target_id = data2.toInt();
3404
3405 if (NULL != game_city_by_number(diplomat_target_id)
3406 && NULL != game_unit_by_number(diplomat_id)) {
3407 request_do_action(ACTION_SPY_INVESTIGATE_CITY, diplomat_id,
3408 diplomat_target_id, 0, "");
3409 }
3410}
3411
3412/***********************************************************************/
3415static void diplomat_investigate(QVariant data1, QVariant data2)
3416{
3417 int diplomat_id = data1.toInt();
3418 int diplomat_target_id = data2.toInt();
3419
3420 if (NULL != game_city_by_number(diplomat_target_id)
3421 && NULL != game_unit_by_number(diplomat_id)) {
3422 request_do_action(ACTION_INV_CITY_SPEND, diplomat_id,
3423 diplomat_target_id, 0, "");
3424 }
3425}
3426
3427/***********************************************************************/
3430static void diplomat_sabotage(QVariant data1, QVariant data2)
3431{
3432 int diplomat_id = data1.toInt();
3433 int diplomat_target_id = data2.toInt();
3434
3435 if (NULL != game_unit_by_number(diplomat_id)
3436 && NULL != game_city_by_number(diplomat_target_id)) {
3437 request_do_action(ACTION_SPY_SABOTAGE_CITY, diplomat_id,
3438 diplomat_target_id, B_LAST + 1, "");
3439 }
3440}
3441
3442/***********************************************************************/
3445static void diplomat_sabotage_esc(QVariant data1, QVariant data2)
3446{
3447 int diplomat_id = data1.toInt();
3448 int diplomat_target_id = data2.toInt();
3449
3450 if (NULL != game_unit_by_number(diplomat_id)
3451 && NULL != game_city_by_number(diplomat_target_id)) {
3452 request_do_action(ACTION_SPY_SABOTAGE_CITY_ESC, diplomat_id,
3453 diplomat_target_id, B_LAST + 1, "");
3454 }
3455}
3456
3457/***********************************************************************/
3460static void diplomat_steal(QVariant data1, QVariant data2)
3461{
3462 int diplomat_id = data1.toInt();
3463 int diplomat_target_id = data2.toInt();
3464
3465 if (NULL != game_unit_by_number(diplomat_id)
3466 && NULL != game_city_by_number(diplomat_target_id)) {
3467 request_do_action(ACTION_SPY_STEAL_TECH, diplomat_id,
3468 diplomat_target_id, A_UNSET, "");
3469 }
3470}
3471
3472/***********************************************************************/
3475static void diplomat_steal_esc(QVariant data1, QVariant data2)
3476{
3477 int diplomat_id = data1.toInt();
3478 int diplomat_target_id = data2.toInt();
3479
3480 if (NULL != game_unit_by_number(diplomat_id)
3481 && NULL != game_city_by_number(diplomat_target_id)) {
3482 request_do_action(ACTION_SPY_STEAL_TECH_ESC, diplomat_id,
3483 diplomat_target_id, A_UNSET, "");
3484 }
3485}
3486
3487/***********************************************************************/
3490static void diplomat_incite(QVariant data1, QVariant data2)
3491{
3492 int diplomat_id = data1.toInt();
3493 int diplomat_target_id = data2.toInt();
3494
3495 if (NULL != game_unit_by_number(diplomat_id)
3496 && NULL != game_city_by_number(diplomat_target_id)) {
3497 /* Wait for the server's reply before moving on to the next queued diplomat. */
3499
3500 request_action_details(ACTION_SPY_INCITE_CITY, diplomat_id,
3501 diplomat_target_id);
3502 }
3503}
3504
3505/***********************************************************************/
3508static void diplomat_incite_escape(QVariant data1, QVariant data2)
3509{
3510 int diplomat_id = data1.toInt();
3511 int diplomat_target_id = data2.toInt();
3512
3513 if (NULL != game_unit_by_number(diplomat_id)
3514 && NULL != game_city_by_number(diplomat_target_id)) {
3515 /* Wait for the server's reply before moving on to the next queued diplomat. */
3517
3518 request_action_details(ACTION_SPY_INCITE_CITY_ESC, diplomat_id,
3519 diplomat_target_id);
3520 }
3521}
3522
3523/***********************************************************************/
3526static void regular_move(QVariant data1, QVariant data2)
3527{
3528 int actor_id = data1.toInt();
3529 int target_id = data2.toInt();
3530
3531 if (NULL != game_unit_by_number(actor_id)
3532 && NULL != index_to_tile(&(wld.map), target_id)) {
3533 request_do_action(ACTION_UNIT_MOVE,
3534 actor_id, target_id, 0, "");
3535 }
3536}
3537
3538/***********************************************************************/
3542void popup_incite_dialog(struct unit *actor, struct city *tcity, int cost,
3543 const struct action *paction)
3544{
3545 char buf[1024];
3546 char buf2[1024];
3547 int diplomat_id = actor->id;
3548 int diplomat_target_id = tcity->id;
3549 const int act_id = paction->id;
3550
3551 /* Should be set before sending request to the server. */
3553
3554 fc_snprintf(buf, ARRAY_SIZE(buf), PL_("Treasury contains %d gold.",
3555 "Treasury contains %d gold.",
3556 client_player()->economic.gold),
3557 client_player()->economic.gold);
3558
3560 hud_message_box *impossible = new hud_message_box(gui()->central_wdg);
3561
3562 fc_snprintf(buf2, ARRAY_SIZE(buf2),
3563 _("You can't incite a revolt in %s."), city_name_get(tcity));
3564 impossible->set_text_title(buf2, "!");
3565 impossible->setStandardButtons(QMessageBox::Ok);
3566 impossible->setAttribute(Qt::WA_DeleteOnClose);
3567 impossible->show();
3568 } else if (cost <= client_player()->economic.gold) {
3569 hud_message_box *ask = new hud_message_box(gui()->central_wdg);
3570
3571 fc_snprintf(buf2, ARRAY_SIZE(buf2),
3572 PL_("Incite a revolt for %d gold?\n%s",
3573 "Incite a revolt for %d gold?\n%s", cost), cost, buf);
3574 ask->setStandardButtons(QMessageBox::Cancel | QMessageBox::Ok);
3575 ask->setDefaultButton(QMessageBox::Cancel);
3576 ask->set_text_title(buf2, _("Incite a Revolt!"));
3577 ask->setAttribute(Qt::WA_DeleteOnClose);
3578 QObject::connect(ask, &hud_message_box::accepted, [=]() {
3579 request_do_action(act_id, diplomat_id, diplomat_target_id, 0, "");
3581 });
3582 ask->show();
3583 return;
3584 } else {
3585 hud_message_box *too_much = new hud_message_box(gui()->central_wdg);
3586
3587 fc_snprintf(buf2, ARRAY_SIZE(buf2),
3588 PL_("Inciting a revolt costs %d gold.\n%s",
3589 "Inciting a revolt costs %d gold.\n%s", cost), cost,
3590 buf);
3591 too_much->set_text_title(buf2, "!");
3592 too_much->setStandardButtons(QMessageBox::Ok);
3593 too_much->setAttribute(Qt::WA_DeleteOnClose);
3594 too_much->show();
3595 }
3596
3598}
3599
3600/***********************************************************************/
3604void popup_bribe_dialog(struct unit *actor, struct unit *tunit, int cost,
3605 const struct action *paction)
3606{
3607 hud_message_box *ask = new hud_message_box(gui()->central_wdg);
3608 char buf[1024];
3609 char buf2[1024];
3610 int diplomat_id = actor->id;
3611 int diplomat_target_id = tunit->id;
3612 const int act_id = paction->id;
3613
3614 /* Should be set before sending request to the server. */
3616
3617 fc_snprintf(buf, ARRAY_SIZE(buf), PL_("Treasury contains %d gold.",
3618 "Treasury contains %d gold.",
3619 client_player()->economic.gold),
3620 client_player()->economic.gold);
3621
3622 if (cost <= client_player()->economic.gold) {
3623 fc_snprintf(buf2, ARRAY_SIZE(buf2), PL_("Bribe unit for %d gold?\n%s",
3624 "Bribe unit for %d gold?\n%s",
3625 cost), cost, buf);
3626 ask->set_text_title(buf2, _("Bribe Enemy Unit"));
3627 ask->setStandardButtons(QMessageBox::Cancel | QMessageBox::Ok);
3628 ask->setDefaultButton(QMessageBox::Cancel);
3629 ask->setAttribute(Qt::WA_DeleteOnClose);
3630 QObject::connect(ask, &hud_message_box::accepted, [=]() {
3631 request_do_action(act_id, diplomat_id, diplomat_target_id, 0, "");
3633 });
3634 ask->show();
3635 return;
3636 } else {
3637 fc_snprintf(buf2, ARRAY_SIZE(buf2),
3638 PL_("Bribing the unit costs %d gold.\n%s",
3639 "Bribing the unit costs %d gold.\n%s", cost), cost, buf);
3640 ask->set_text_title(buf2, _("Traitors Demand Too Much!"));
3641 ask->setAttribute(Qt::WA_DeleteOnClose);
3642 ask->show();
3643 }
3644
3646}
3647
3648/***********************************************************************/
3651static void pillage_something(QVariant data1, QVariant data2)
3652{
3653 int punit_id;
3654 int what;
3655 struct unit *punit;
3656 struct extra_type *target;
3657
3658 what = data1.toInt();
3659 punit_id = data2.toInt();
3660 punit = game_unit_by_number(punit_id);
3661 if (punit) {
3662 target = extra_by_number(what);
3663 request_new_unit_activity_targeted(punit, ACTIVITY_PILLAGE, target);
3664 }
3666}
3667
3668/***********************************************************************/
3671static void spy_sabotage(QVariant data1, QVariant data2)
3672{
3673 int diplomat_id = data1.toList().at(0).toInt();
3674 int diplomat_target_id = data1.toList().at(1).toInt();
3675 action_id act_id = data1.toList().at(2).toInt();
3676
3677 if (NULL != game_unit_by_number(diplomat_id)
3678 && NULL != game_city_by_number(diplomat_target_id)) {
3679 if (data2.toInt() == B_LAST) {
3680 /* This is the untargeted version. */
3682 diplomat_id, diplomat_target_id, data2.toInt(),
3683 "");
3684 } else if (data2.toInt() == -1) {
3685 /* This is the city production version. */
3687 diplomat_id, diplomat_target_id, data2.toInt(),
3688 "");
3689 } else {
3690 /* This is the targeted version. */
3691 request_do_action(act_id, diplomat_id,
3692 diplomat_target_id, data2.toInt(), "");
3693 }
3694 }
3695}
3696
3697/***********************************************************************/
3701void popup_sabotage_dialog(struct unit *actor, struct city *tcity,
3702 const struct action *paction)
3703{
3704 QString str;
3705 QVariant qv1, qv2;
3706 int diplomat_id = actor->id;
3707 int diplomat_target_id = tcity->id;
3709 choice_dialog *cd = new choice_dialog(_("Sabotage"),
3710 _("Select Improvement to Sabotage"),
3711 gui()->game_tab_widget,
3713 int nr = 0;
3714 struct astring stra = ASTRING_INIT;
3715 QList<QVariant> actor_and_target;
3716
3717 /* Should be set before sending request to the server. */
3719
3720 /* Put both actor, target city and action in qv1 since qv2 is taken */
3721 actor_and_target.append(diplomat_id);
3722 actor_and_target.append(diplomat_target_id);
3723 actor_and_target.append(paction->id);
3724 qv1 = QVariant::fromValue(actor_and_target);
3725
3728 paction->id)])) {
3730 cd->add_item(QString(_("City Production")), func, qv1, -1);
3731 }
3732
3733 city_built_iterate(tcity, pimprove) {
3734 if (pimprove->sabotage > 0) {
3736 // Defeat keyboard shortcut mnemonics
3737 str = QString(city_improvement_name_translation(tcity, pimprove))
3738 .replace("&", "&&");
3739 qv2 = nr;
3740 cd->add_item(str, func, qv1, improvement_number(pimprove));
3741 nr++;
3742 }
3744
3746 get_non_targeted_action_id(paction->id)])) {
3747 astr_set(&stra, _("At %s's Discretion"),
3750 str = QString(astr_str(&stra)).replace("&", "&&");
3751 cd->add_item(str, func, qv1, B_LAST);
3752 }
3753
3754 cd->set_layout();
3755 cd->show_me();
3756 astr_free(&stra);
3757}
3758
3759/***********************************************************************/
3763void popup_pillage_dialog(struct unit *punit, bv_extras extras)
3764{
3765 QString str;
3766 QVariant qv1, qv2;
3768 choice_dialog *cd;
3769 struct extra_type *tgt;
3770
3772 return;
3773 }
3774 cd = new choice_dialog(_("What To Pillage"), _("Select what to pillage:"),
3775 gui()->game_tab_widget);
3776 qv2 = punit->id;
3777 while ((tgt = get_preferred_pillage(extras))) {
3778 int what;
3779
3780 what = extra_index(tgt);
3781 BV_CLR(extras, what);
3782
3784 // Defeat keyboard shortcut mnemonics
3785 str = QString(extra_name_translation(tgt)).replace("&", "&&");
3786 qv1 = what;
3787 cd->add_item(str, func, qv1, qv2);
3788 }
3789 cd->set_layout();
3790 cd->show_me();
3791}
3792
3793/***********************************************************************/
3796disband_box::disband_box(struct unit_list *punits,
3797 QWidget *parent) : hud_message_box(parent)
3798{
3799 QString str;
3800 QPushButton *pb;
3801
3802 setAttribute(Qt::WA_DeleteOnClose);
3803 setModal(false);
3804 cpunits = unit_list_new();
3805 unit_list_iterate(punits, punit) {
3806 unit_list_append(cpunits, punit);
3808
3809 str = QString(PL_("Are you sure you want to disband that %1 unit?",
3810 "Are you sure you want to disband those %1 units?",
3811 unit_list_size(punits))).arg(unit_list_size(punits));
3812 pb = addButton(_("Yes"), QMessageBox::AcceptRole);
3813 addButton(_("No"), QMessageBox::RejectRole);
3814 set_text_title(str, _("Disband units"));
3815 setDefaultButton(pb);
3816 connect(pb, &QAbstractButton::clicked, this, &disband_box::disband_clicked);
3817}
3818
3819/***********************************************************************/
3823{
3825 if (unit_can_do_action(punit, ACTION_DISBAND_UNIT)) {
3827 }
3829}
3830
3831/***********************************************************************/
3835{
3836 unit_list_destroy(cpunits);
3837}
3838
3839/***********************************************************************/
3842void popup_disband_dialog(struct unit_list *punits)
3843{
3844 disband_box *ask = new disband_box(punits, gui()->central_wdg);
3845 ask->show();
3846}
3847
3848/***********************************************************************/
3853{
3854 hud_message_box *ask = new hud_message_box(gui()->central_wdg);
3855 QString text;
3856 QString title;
3857
3858 title = QString(_("Modpack suggests using %1 tileset."))
3860 text = QString("It might not work with other tilesets.\n"
3861 "You are currently using tileset %1.")
3863 ask->addButton(_("Keep current tileset"), QMessageBox::RejectRole);
3864 ask->addButton(_("Load tileset"), QMessageBox::AcceptRole);
3865 ask->set_text_title(text, title);
3866 ask->setAttribute(Qt::WA_DeleteOnClose);
3867
3868 QObject::connect(ask, &hud_message_box::accepted, [=]() {
3871 gui()->map_scale)) {
3873 _("Can't load requested tileset."));
3874 }
3875 });
3876 ask->show();
3877}
3878
3879/***********************************************************************/
3884{
3885 hud_message_box *ask = new hud_message_box(gui()->central_wdg);
3886 QString text;
3887 QString title;
3888
3889 title = QString(_("Modpack suggests using %1 soundset."))
3891 text = QString("It might not work with other tilesets.\n"
3892 "You are currently using soundset %1.")
3893 .arg(sound_set_name);
3894 ask->addButton(_("Keep current soundset"), QMessageBox::RejectRole);
3895 ask->addButton(_("Load soundset"), QMessageBox::AcceptRole);
3896 ask->set_text_title(text, title);
3897 ask->setAttribute(Qt::WA_DeleteOnClose);
3898 QObject::connect(ask, &hud_message_box::accepted, [=]() {
3900 });
3901 ask->show();
3902}
3903
3904/***********************************************************************/
3909{
3910 hud_message_box *ask = new hud_message_box(gui()->central_wdg);
3911 QString text;
3912 QString title;
3913
3914 title = QString(_("Modpack suggests using %1 musicset."))
3916 text = QString("It might not work with other tilesets.\n"
3917 "You are currently using musicset %1.")
3918 .arg(music_set_name);
3919 ask->addButton(_("Keep current musicset"), QMessageBox::RejectRole);
3920 ask->addButton(_("Load musicset"), QMessageBox::AcceptRole);
3921 ask->set_text_title(text, title);
3922 ask->setAttribute(Qt::WA_DeleteOnClose);
3923 QObject::connect(ask, &hud_message_box::accepted, [=]() {
3925 });
3926 ask->show();
3927}
3928
3929/***********************************************************************/
3933bool popup_theme_suggestion_dialog(const char *theme_name)
3934{
3935 /* PORTME */
3936 return false;
3937}
3938
3939/***********************************************************************/
3943{
3944 QList<notify_dialog *> nd_list;
3945 int i;
3946
3947 nd_list = gui()->mapview_wdg->findChildren<notify_dialog *>();
3948 for (i = 0; i < nd_list.count(); i++) {
3949 nd_list[i]->restart();
3950 delete nd_list[i];
3951 }
3952}
3953
3954/***********************************************************************/
3959{
3960 int i;
3961 QList <choice_dialog *> cd_list;
3962 QList <notify_dialog *> nd_list;
3963 goto_dialog *gtd;
3964
3965 QApplication::alert(gui()->central_wdg);
3966 cd_list = gui()->game_tab_widget->findChildren <choice_dialog *>();
3967 for (i = 0; i < cd_list.count(); i++) {
3968 cd_list[i]->close();
3969 }
3970 nd_list = gui()->game_tab_widget->findChildren <notify_dialog *>();
3971 for (i = 0; i < nd_list.count(); i++) {
3972 nd_list[i]->close();
3973 }
3974
3983 gui()->popdown_unit_sel();
3984
3985 gtd = gui()->gtd;
3986
3987 if (gtd != nullptr) {
3988 gtd->close_dlg();
3989 }
3990}
3991
3992/***********************************************************************/
3998{
3999 choice_dialog *cd = gui()->get_diplo_dialog();
4000
4001 if (cd != NULL) {
4002 return cd->unit_id;
4003 } else {
4004 return IDENTITY_NUMBER_ZERO;
4005 }
4006}
4007
4008/***********************************************************************/
4015{
4016 choice_dialog *cd = gui()->get_diplo_dialog();
4017
4018 if (cd != NULL) {
4019 return cd->target_id[ATK_CITY];
4020 } else {
4021 return IDENTITY_NUMBER_ZERO;
4022 }
4023}
4024
4025/***********************************************************************/
4032{
4033 choice_dialog *cd = gui()->get_diplo_dialog();
4034
4035 if (cd != NULL) {
4036 return cd->target_id[ATK_TILE];
4037 } else {
4038 return TILE_INDEX_NONE;
4039 }
4040}
4041
4042/**********************************************************************/
4049{
4050 choice_dialog *cd = gui()->get_diplo_dialog();
4051
4052 if (cd != NULL) {
4053 return cd->sub_target_id[ASTK_EXTRA];
4054 } else {
4055 return EXTRA_NONE;
4056 }
4057}
4058
4059/***********************************************************************/
4066{
4067 choice_dialog *cd = gui()->get_diplo_dialog();
4068
4069 if (cd != NULL) {
4070 return cd->target_id[ATK_UNIT];
4071 } else {
4072 return IDENTITY_NUMBER_ZERO;
4073 }
4074}
4075
4076/***********************************************************************/
4080 struct city *target_city,
4081 struct unit *target_unit,
4082 struct tile *target_tile,
4083 struct extra_type *target_extra,
4084 const struct act_prob *act_probs)
4085{
4086 choice_dialog *asd;
4087 Choice_dialog_button *wait_button;
4088 Choice_dialog_button *cancel_button;
4089 QVariant qv1, qv2;
4090
4091 asd = gui()->get_diplo_dialog();
4092 if (asd == NULL) {
4093 fc_assert_msg(asd != NULL,
4094 "The action selection dialog should have been open");
4095 return;
4096 }
4097
4100 "The action selection dialog is for another actor unit.");
4101 }
4102
4103 /* Put the actor id in qv1. */
4104 qv1 = actor_unit->id;
4105
4106 cancel_button = asd->get_identified_button(BUTTON_CANCEL);
4107 if (cancel_button != NULL) {
4108 /* Temporary remove the Cancel button so it won't end up above
4109 * any added buttons. */
4110 asd->stack_button(cancel_button);
4111 }
4112
4113 wait_button = asd->get_identified_button(BUTTON_WAIT);
4114 if (wait_button != NULL) {
4115 /* Temporary remove the Wait button so it won't end up above
4116 * any added buttons. */
4117 asd->stack_button(wait_button);
4118 }
4119
4120 action_iterate(act) {
4121 const char *custom;
4122
4123 if (action_id_get_actor_kind(act) != AAK_UNIT) {
4124 /* Not relevant. */
4125 continue;
4126 }
4127
4129 act_probs[act],
4130 actor_unit,
4131 target_city);
4132
4133 /* Put the target id in qv2. */
4134 switch (action_id_get_target_kind(act)) {
4135 case ATK_UNIT:
4136 if (target_unit != NULL) {
4137 qv2 = target_unit->id;
4138 } else {
4139 fc_assert_msg(!action_prob_possible(act_probs[act])
4140 || target_unit != NULL,
4141 "Action enabled against non existing unit!");
4142
4144 }
4145 break;
4146 case ATK_CITY:
4147 if (target_city != NULL) {
4148 qv2 = target_city->id;
4149 } else {
4150 fc_assert_msg(!action_prob_possible(act_probs[act])
4151 || target_city != NULL,
4152 "Action enabled against non existing city!");
4153
4155 }
4156 break;
4157 case ATK_TILE:
4158 case ATK_EXTRAS:
4159 case ATK_UNITS:
4160 if (target_tile != NULL) {
4161 qv2 = tile_index(target_tile);
4162 } else {
4163 fc_assert_msg(!action_prob_possible(act_probs[act])
4164 || target_tile != NULL,
4165 "Action enabled against all units on "
4166 "non existing tile!");
4167
4168 qv2 = TILE_INDEX_NONE;
4169 }
4170 break;
4171 case ATK_SELF:
4172 qv2 = actor_unit->id;
4173 break;
4174 case ATK_COUNT:
4175 fc_assert_msg(ATK_COUNT != action_id_get_target_kind(act),
4176 "Bad target kind");
4177 continue;
4178 }
4179
4180 if (asd->get_identified_button(act)) {
4181 /* Update the existing button. */
4183 act, act_probs, custom,
4184 qv1, qv2);
4185 } else {
4186 /* Add the button (unless its probability is 0). */
4187 action_entry(asd, act, act_probs, custom,
4188 qv1, qv2);
4189 }
4191
4192 if (wait_button != NULL || cancel_button != NULL) {
4193 /* Reinsert the non action buttons below any potential
4194 * buttons recently added. */
4195 asd->unstack_all_buttons();
4196 }
4197}
4198
4199/***********************************************************************/
4203{
4204 choice_dialog *cd;
4205
4206 cd = gui()->get_diplo_dialog();
4207 if (cd != NULL) {
4208 did_not_decide = true;
4209 cd->close();
4210 }
4211}
4212
4213/***********************************************************************/
4219
4220/***********************************************************************/
4223void show_tileset_error(bool fatal, const char *tset_name, const char *msg)
4224{
4225 QWidget *parent;
4226 fc_client *std_gui = gui();
4227
4228 if (std_gui != nullptr) {
4229 parent = std_gui->central_wdg;
4230 } else {
4231 parent = nullptr;
4232 }
4233
4234 if (std_gui != nullptr || fatal) {
4235 char buf[1024];
4236 QMessageBox *ask = new QMessageBox(parent);
4237
4238 if (tset_name != NULL) {
4239 fc_snprintf(buf, sizeof(buf),
4240 _("Tileset \"%s\" problem, it's probably incompatible with "
4241 "the ruleset:\n%s"), tset_name, msg);
4242 } else {
4243 fc_snprintf(buf, sizeof(buf),
4244 _("Tileset problem, it's probably incompatible with "
4245 "the ruleset:\n%s"), msg);
4246 }
4247
4248 ask->setText(buf);
4249 ask->setStandardButtons(QMessageBox::Ok);
4250 ask->setWindowTitle(_("Tileset error"));
4251
4252 if (std_gui != nullptr) {
4253 ask->setAttribute(Qt::WA_DeleteOnClose);
4254 ask->show();
4255 } else {
4256 ask->exec();
4257 }
4258 }
4259}
4260
4261/***********************************************************************/
4264void popup_upgrade_dialog(struct unit_list *punits)
4265{
4266 char buf[512];
4267 hud_message_box *ask;
4268 QString title;
4269 QVector<int> *punit_ids;
4270
4271 if (!punits || unit_list_size(punits) == 0) {
4272 return;
4273 }
4274
4275 ask = new hud_message_box(gui()->central_wdg);
4276
4277 punit_ids = new QVector<int>();
4278 unit_list_iterate(punits, punit) {
4279 punit_ids->push_back(punit->id);
4281
4282 if (!get_units_upgrade_info(buf, sizeof(buf), punits)) {
4283 title = _("Upgrade Unit!");
4284 ask->setStandardButtons(QMessageBox::Ok);
4285 } else {
4286 title = _("Upgrade Obsolete Units");
4287 ask->setStandardButtons(QMessageBox::Cancel | QMessageBox::Ok);
4288 ask->setDefaultButton(QMessageBox::Cancel);
4289 }
4290 ask->set_text_title(buf, title);
4291 ask->setAttribute(Qt::WA_DeleteOnClose);
4292 QObject::connect(ask, &hud_message_box::accepted, [=]() {
4293 std::unique_ptr<QVector<int>> uptr(punit_ids);
4294 struct unit *punit;
4295
4296 for (int id : *uptr) {
4298 if (punit) {
4300 }
4301 }
4302 });
4303 ask->show();
4304}
4305
4306/***********************************************************************/
4309units_select::units_select(tile *ptile, QWidget *parent)
4310{
4311 QPoint p, final_p;
4312
4313 setParent(parent);
4314 utile = ptile;
4315 pix = NULL;
4316 show_line = 0;
4317 highligh_num = -1;
4318 ufont.setItalic(true);
4320 update_units();
4321 h_pix = NULL;
4322 create_pixmap();
4323 p = mapFromGlobal(QCursor::pos());
4324 cw = new close_widget(this);
4325 setMouseTracking(true);
4326 final_p.setX(p.x());
4327 final_p.setY(p.y());
4328 if (p.x() + width() > parentWidget()->width()) {
4329 final_p.setX(parentWidget()->width() - width());
4330 }
4331 if (p.y() - height() < 0) {
4332 final_p.setY(height());
4333 }
4334 move(final_p.x(), final_p.y() - height());
4335 setFocus();
4336 /* Build fails with qt5 connect style for static functions
4337 * Qt5.2 so dont update */
4338 QTimer::singleShot(10, this, SLOT(update_img()));
4339}
4340
4341/***********************************************************************/
4345{
4346 delete h_pix;
4347 delete pix;
4348 delete cw;
4349}
4350
4351/***********************************************************************/
4355{
4356 int a;
4357 int x, y, i;
4358 QFontMetrics fm(info_font);
4359 QImage cropped_img;
4360 QImage img;
4361 QList <QPixmap*>pix_list;
4362 QPainter p;
4363 QPen pen;
4364 QPixmap pixc;
4365 QPixmap *pixp;
4366 QPixmap *tmp_pix;
4367 QRect crop;
4368 struct canvas *unit_pixmap;
4369 struct unit *punit;
4370 float isosize;
4371
4372 if (pix != NULL) {
4373 delete pix;
4374 pix = NULL;
4375 };
4376 isosize = 0.7;
4378 isosize = 0.5;
4379 }
4380
4381 update_units();
4382 if (unit_list.count() > 0) {
4386 } else {
4387 item_size.setWidth(tileset_unit_width(tileset) * isosize);
4388 item_size.setHeight(tileset_unit_width(tileset) * isosize);
4389 }
4390 more = false;
4391 if (h_pix != nullptr) {
4392 delete h_pix;
4393 }
4394 h_pix = new QPixmap(item_size.width(), item_size.height());
4395 h_pix->fill(palette().color(QPalette::HighlightedText));
4396 if (unit_count < 5) {
4397 row_count = 1;
4398 pix = new QPixmap((unit_list.size()) * item_size.width(),
4399 item_size.height());
4400 } else if (unit_count < 9) {
4401 row_count = 2;
4402 pix = new QPixmap(4 * item_size.width(), 2 * item_size.height());
4403 } else {
4404 row_count = 3;
4405 if (unit_count > 12) {
4406 more = true;
4407 }
4408 pix = new QPixmap(4 * item_size.width(), 3 * item_size.height());
4409 }
4410 pix->fill(Qt::transparent);
4411 foreach(punit, unit_list) {
4414 unit_pixmap->map_pixmap.fill(Qt::transparent);
4415 put_unit(punit, unit_pixmap, 1.0, 0, 0);
4416 img = unit_pixmap->map_pixmap.toImage();
4417 crop = zealous_crop_rect(img);
4418 cropped_img = img.copy(crop);
4420 img = cropped_img.scaled(tileset_unit_width(tileset),
4422 Qt::KeepAspectRatio,
4423 Qt::SmoothTransformation);
4424 } else {
4425 img = cropped_img.scaled(tileset_unit_width(tileset) * isosize,
4426 tileset_unit_width(tileset) * isosize,
4427 Qt::KeepAspectRatio,
4428 Qt::SmoothTransformation);
4429 }
4430 pixc = QPixmap::fromImage(img);
4431 pixp = new QPixmap(pixc);
4432 pix_list.push_back(pixp);
4433 qtg_canvas_free(unit_pixmap);
4434 }
4435 a = qMin(item_size.width() / 4, 12);
4436 x = 0, y = -item_size.height(), i = -1;
4437 p.begin(pix);
4438 ufont.setPixelSize(a);
4439 p.setFont(ufont);
4440 pen.setColor(palette().color(QPalette::Text));
4441 p.setPen(pen);
4442
4443 while (!pix_list.isEmpty()) {
4444 tmp_pix = pix_list.takeFirst();
4445 i++;
4446 if (i % 4 == 0) {
4447 x = 0;
4448 y = y + item_size.height();
4449 }
4450 punit = unit_list.at(i);
4451 Q_ASSERT(punit != NULL);
4452
4453 if (i == highligh_num) {
4454 p.drawPixmap(x, y, *h_pix);
4455 p.drawPixmap(x, y, *tmp_pix);
4456 } else {
4457 p.drawPixmap(x, y, *tmp_pix);
4458 }
4459
4461 int rate, f;
4462 QString str;
4463
4464 rate = unit_type_get(punit)->move_rate;
4465 f = ((punit->fuel) - 1);
4466 str = QString(move_points_text(punit->moves_left, false));
4468 str = str + "(" + QString(move_points_text((rate * f)
4469 + punit->moves_left, false)) + ")";
4470 }
4471 /* TRANS: MP = Movement points */
4472 str = QString(_("MP:")) + str;
4473 p.drawText(x, y + item_size.height() - 4, str);
4474 }
4475
4476 x = x + item_size.width();
4477 delete tmp_pix;
4478 }
4479 p.end();
4480 setFixedWidth(pix->width() + 20);
4481 setFixedHeight(pix->height() + 2 * (fm.height() + 6));
4482 qDeleteAll(pix_list.begin(), pix_list.end());
4483 }
4484}
4485
4486/***********************************************************************/
4490{
4491 int a, b;
4492 int old_h;
4493 QFontMetrics fm(info_font);
4494 QPoint pos = event->pos();
4495 int x = pos.x();
4496 int y = pos.y();
4497
4498 old_h = highligh_num;
4499 highligh_num = -1;
4500 if (x > width() - 11
4501 || y > height() - fm.height() - 5
4502 || y < fm.height() + 3 || x < 11) {
4503 // Do nothing if mouse is on border, just skip next if
4504 } else if (row_count > 0) {
4505 a = (x - 10) / item_size.width();
4506 b = (y - fm.height() - 3) / item_size.height();
4507 highligh_num = b * 4 + a;
4508 }
4509 if (old_h != highligh_num) {
4510 create_pixmap();
4511 update();
4512 }
4513}
4514
4515/***********************************************************************/
4521{
4522 struct unit *punit;
4523 if (event->button() == Qt::RightButton) {
4524 was_destroyed = true;
4525 close();
4526 destroy();
4527 }
4528 if (event->button() == Qt::LeftButton && highligh_num != -1) {
4529 update_units();
4530 if (highligh_num >= unit_list.count()) {
4531 return;
4532 }
4535 was_destroyed = true;
4536 close();
4537 destroy();
4538 }
4539}
4540
4541/***********************************************************************/
4546{
4547 create_pixmap();
4548 update();
4549}
4550
4551/***********************************************************************/
4554void units_select::paint(QPainter *painter, QPaintEvent *event)
4555{
4556 QFontMetrics fm(info_font);
4557 int h, i;
4558 int *f_size;
4559 QPen pen;
4560 QString str, str2;
4561 struct unit *punit;
4562 int point_size = info_font.pointSize();
4563 int pixel_size = info_font.pixelSize();
4564
4565 if (point_size < 0) {
4566 f_size = &pixel_size;
4567 } else {
4568 f_size = &point_size;
4569 }
4570 if (highligh_num != -1 && highligh_num < unit_list.count()) {
4571 struct astring addition = ASTRING_INIT;
4572
4574 unit_activity_astr(punit, &addition);
4575
4576 // TRANS: HP - hit points
4577 str2 = QString(_("%1 HP:%2/%3")).arg(QString(astr_str(&addition)),
4578 QString::number(punit->hp),
4579 QString::number(unit_type_get(punit)->hp));
4580 astr_free(&addition);
4581 }
4582 str = QString(PL_("%1 unit", "%1 units",
4583 unit_list_size(utile->units)))
4584 .arg(unit_list_size(utile->units));
4585 for (i = *f_size; i > 4; i--) {
4586 if (point_size < 0) {
4587 info_font.setPixelSize(i);
4588 } else {
4589 info_font.setPointSize(i);
4590 }
4591 QFontMetrics qfm(info_font);
4592 if (10 + qfm.horizontalAdvance(str2) < width()) {
4593 break;
4594 }
4595 }
4596 h = fm.height();
4597 if (pix != NULL) {
4598 painter->drawPixmap(10, h + 3, *pix);
4599 pen.setColor(palette().color(QPalette::Text));
4600 painter->setPen(pen);
4601 painter->setFont(info_font);
4602 painter->drawText(10, h, str);
4603 if (highligh_num != -1 && highligh_num < unit_list.count()) {
4604 painter->drawText(10, height() - 5, str2);
4605 }
4606 /* draw scroll */
4607 if (more) {
4608 int maxl = ((unit_count - 1) / 4) + 1;
4609 float page_height = 3.0f / maxl;
4610 float page_start = (static_cast<float>(show_line)) / maxl;
4611 pen.setColor(palette().color(QPalette::HighlightedText));
4612 painter->setBrush(palette().color(QPalette::HighlightedText).darker());
4613 painter->setPen(palette().color(QPalette::HighlightedText).darker());
4614 painter->drawRect(pix->width() + 10, h, 8, h + pix->height());
4615 painter->setPen(pen);
4616 painter->drawRoundedRect(pix->width() + 10,
4617 h + page_start * pix->height(),
4618 8, h + page_height * pix->height(), 2, 2);
4619 }
4620 }
4621 if (point_size < 0) {
4622 info_font.setPixelSize(*f_size);
4623 } else {
4624 info_font.setPointSize(*f_size);
4625 }
4626 cw->put_to_corner();
4627}
4628
4629/***********************************************************************/
4633{
4634 QPainter painter;
4635
4636 painter.begin(this);
4637 paint(&painter, event);
4638 painter.end();
4639}
4640
4641/***********************************************************************/
4646{
4647 was_destroyed = true;
4648 close();
4649 destroy();
4650}
4651
4652/***********************************************************************/
4656{
4657 int i = 1;
4658 struct unit_list *punit_list;
4659
4660 unit_count = 0;
4661 if (utile == NULL) {
4662 struct unit *punit = head_of_units_in_focus();
4663 if (punit) {
4665 }
4666 }
4667 unit_list.clear();
4668 if (utile != nullptr) {
4669 punit_list = utile->units;
4670 if (punit_list != nullptr) {
4672 unit_count++;
4673 if (i > show_line * 4)
4674 unit_list.push_back(punit);
4675 i++;
4677 }
4678 }
4679 if (unit_list.count() == 0) {
4680 close();
4681 }
4682}
4683
4684/***********************************************************************/
4688{
4689 gui()->mapview_wdg->setFocus();
4690 QWidget::closeEvent(event);
4691}
4692
4693/***********************************************************************/
4697{
4698 int nr;
4699
4700 if (!more && utile == NULL) {
4701 return;
4702 }
4703 nr = qCeil(static_cast<qreal>(unit_list_size(utile->units)) / 4) - 3;
4704 if (event->angleDelta().y() < 0) {
4705 show_line++;
4706 show_line = qMin(show_line, nr);
4707 } else {
4708 show_line--;
4709 show_line = qMax(0, show_line);
4710 }
4711 update_units();
4712 create_pixmap();
4713 update();
4714 event->accept();
4715}
4716
4717/***********************************************************************/
4721{
4722 if (event->key() == Qt::Key_Escape) {
4723 was_destroyed = true;
4724 close();
4725 destroy();
4726 }
4727 QWidget::keyPressEvent(event);
4728}
4729
4730/***********************************************************************/
4737
4738/***********************************************************************/
4745
4746/***********************************************************************/
4751{
4752 /* Just tell the client common code to handle this. */
4753 return false;
4754}
4755
4756/***********************************************************************/
4759bool qtg_request_transport(struct unit *pcargo, struct tile *ptile)
4760{
4761 int tcount;
4762 hud_unit_loader *hul;
4763 struct unit_list *potential_transports = unit_list_new();
4764#ifndef FREECIV_NDEBUG
4765 struct unit *best_transport = transporter_for_unit_at(pcargo, ptile);
4766#endif
4767
4768 unit_list_iterate(ptile->units, ptransport) {
4769 if (could_unit_load(pcargo, ptransport)) {
4770 unit_list_append(potential_transports, ptransport);
4771 }
4773
4774 tcount = unit_list_size(potential_transports);
4775
4776 if (tcount == 0) {
4777 fc_assert(best_transport == NULL);
4778 unit_list_destroy(potential_transports);
4779
4780 return false; /* Unit was not handled here. */
4781 } else if (tcount == 1) {
4782 /* There's exactly one potential transport - use it automatically */
4783 fc_assert(unit_list_get(potential_transports, 0) == best_transport);
4784 request_unit_load(pcargo, unit_list_get(potential_transports, 0), ptile);
4785
4786 unit_list_destroy(potential_transports);
4787
4788 return true;
4789 }
4790
4791 hul = new hud_unit_loader(pcargo, ptile);
4792 hul->show_me();
4793 return true;
4794}
4795
4796/***********************************************************************/
4800void qtg_popup_combat_info(int attacker_unit_id, int defender_unit_id,
4801 int attacker_hp, int defender_hp,
4802 bool make_att_veteran, bool make_def_veteran)
4803{
4804 if (gui()->qt_settings.show_battle_log) {
4805 hud_unit_combat* huc = new hud_unit_combat(attacker_unit_id,
4806 defender_unit_id,
4807 attacker_hp, defender_hp,
4808 make_att_veteran,
4809 make_def_veteran,
4810 gui()->battlelog_wdg->scale,
4811 gui()->battlelog_wdg);
4812
4813 gui()->battlelog_wdg->add_combat_info(huc);
4814 gui()->battlelog_wdg->show();
4815 }
4816}
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:6703
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:1115
#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:810
#define city_built_iterate_end
Definition city.h:816
void qtg_real_city_dialog_popup(struct city *pcity)
Definition citydlg.cpp:3721
Choice_dialog_button(const QString title, pfcn_void func_in, QVariant data1_in, QVariant data2_in)
Definition dialogs.cpp:1316
void setData2(QVariant wariat)
Definition dialogs.cpp:1364
void setData1(QVariant wariat)
Definition dialogs.cpp:1356
pfcn_void getFunc()
Definition dialogs.cpp:1330
void stack_button(Choice_dialog_button *button)
Definition dialogs.cpp:1690
void prev_unit()
Definition dialogs.cpp:1607
QVBoxLayout * layout
Definition dialogs.h:263
struct unit * targeted_unit
Definition dialogs.h:286
void unstack_all_buttons()
Definition dialogs.cpp:1707
Choice_dialog_button * get_identified_button(const int id)
Definition dialogs.cpp:1519
QPushButton * target_unit_button
Definition dialogs.h:262
void set_layout()
Definition dialogs.cpp:1425
void update_dialog(const struct act_prob *act_probs)
Definition dialogs.cpp:1636
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:1372
void next_unit()
Definition dialogs.cpp:1567
QVBoxLayout * get_layout()
Definition dialogs.cpp:1511
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:1654
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:1673
void add_item(QString title, pfcn_void func, QVariant data1, QVariant data2, QString tool_tip, const int button_id)
Definition dialogs.cpp:1467
void put_to_corner()
Definition mapview.cpp:504
void disband_clicked()
Definition dialogs.cpp:3822
disband_box(struct unit_list *punits, QWidget *parent=0)
Definition dialogs.cpp:3796
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:4741
void set_diplo_dialog(choice_dialog *widget)
Definition dialogs.cpp:4733
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:890
close_widget * cw
Definition dialogs.h:189
void mouseReleaseEvent(QMouseEvent *event)
Definition dialogs.cpp:983
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:857
void calc_size(int &x, int &y)
Definition dialogs.cpp:918
void paintEvent(QPaintEvent *paint_event)
Definition dialogs.cpp:937
QPoint cursor
Definition dialogs.h:196
void mouseMoveEvent(QMouseEvent *event)
Definition dialogs.cpp:973
virtual void update_menu()
Definition dialogs.cpp:991
void mousePressEvent(QMouseEvent *event)
Definition dialogs.cpp:960
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:1092
QPushButton * goto_but
Definition dialogs.h:111
void inspect_city()
Definition dialogs.cpp:1135
struct tile * gtile
Definition dialogs.h:114
QPushButton * inspect_but
Definition dialogs.h:112
void goto_tile()
Definition dialogs.cpp:1126
action_id vs_unit
Definition dialogs.h:60
static qdef_act * action()
Definition dialogs.cpp:1020
action_id vs_city_get()
Definition dialogs.cpp:1058
static qdef_act * m_instance
Definition dialogs.h:58
static void drop()
Definition dialogs.cpp:1031
action_id vs_city
Definition dialogs.h:59
void vs_city_set(int i)
Definition dialogs.cpp:1042
void vs_unit_set(int i)
Definition dialogs.cpp:1050
action_id vs_unit_get()
Definition dialogs.cpp:1066
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:1082
void style_selected(const QItemSelection &sl, const QItemSelection &ds)
Definition dialogs.cpp:785
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:732
void nationset_changed(int index)
Definition dialogs.cpp:1147
int selected_nation
Definition dialogs.h:163
void ok_pressed()
Definition dialogs.cpp:819
void leader_selected(int index)
Definition dialogs.cpp:804
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:678
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:1074
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:4687
void update_img()
Definition dialogs.cpp:4545
int show_line
Definition dialogs.h:233
void mouseMoveEvent(QMouseEvent *event)
Definition dialogs.cpp:4489
int highligh_num
Definition dialogs.h:234
void paint(QPainter *painter, QPaintEvent *event)
Definition dialogs.cpp:4554
void update_menu()
Definition dialogs.cpp:4645
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:4309
void update_units()
Definition dialogs.cpp:4655
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:4632
void create_pixmap()
Definition dialogs.cpp:4354
void wheelEvent(QWheelEvent *event)
Definition dialogs.cpp:4696
void keyPressEvent(QKeyEvent *event)
Definition dialogs.cpp:4720
void mousePressEvent(QMouseEvent *event)
Definition dialogs.cpp:4520
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:1252
void action_selection_no_longer_in_progress(const int old_actor_id)
Definition control.c:1050
void request_unit_load(struct unit *pcargo, struct unit *ptrans, struct tile *ptile)
Definition control.c:2083
void unit_focus_set(struct unit *punit)
Definition control.c:507
void request_do_action(action_id action, int actor_id, int target_id, int sub_tgt, const char *name)
Definition control.c:1701
void request_unit_disband(struct unit *punit)
Definition control.c:2002
void request_action_details(action_id action, int actor_id, int target_id)
Definition control.c:1721
void request_new_unit_activity_targeted(struct unit *punit, enum unit_activity act, struct extra_type *tgt)
Definition control.c:1863
void action_decision_clear_want(const int old_actor_id)
Definition control.c:1079
void key_unit_wait(void)
Definition control.c:3375
struct unit * head_of_units_in_focus(void)
Definition control.c:411
void request_unit_upgrade(struct unit *punit)
Definition control.c:2033
void action_selection_next_in_focus(const int old_actor_id)
Definition control.c:1091
bool qtg_handmade_scenario_warning()
Definition dialogs.cpp:4750
static void attack(QVariant data1, QVariant data2)
Definition dialogs.cpp:2918
char forced_tileset_name[512]
int action_selection_target_extra(void)
Definition dialogs.cpp:4048
static void destroy_city(QVariant data1, QVariant data2)
Definition dialogs.cpp:3295
static void spy_sabotage_unit(QVariant data1, QVariant data2)
Definition dialogs.cpp:2429
static void pillage(QVariant data1, QVariant data2)
Definition dialogs.cpp:2759
static void caravan_marketplace(QVariant data1, QVariant data2)
Definition dialogs.cpp:1721
static void clean_pollution(QVariant data1, QVariant data2)
Definition dialogs.cpp:2779
static void spy_steal_shared(QVariant data1, QVariant data2, action_id act_id)
Definition dialogs.cpp:3053
static void clean_fallout(QVariant data1, QVariant data2)
Definition dialogs.cpp:2799
static void spy_sabotage(QVariant data1, QVariant data2)
Definition dialogs.cpp:3671
int action_selection_target_tile(void)
Definition dialogs.cpp:4031
static void spy_investigate(QVariant data1, QVariant data2)
Definition dialogs.cpp:3400
static void act_sel_wait(QVariant data1, QVariant data2)
Definition dialogs.cpp:1890
static void nuke_units(QVariant data1, QVariant data2)
Definition dialogs.cpp:2631
int action_selection_actor_unit(void)
Definition dialogs.cpp:3997
static void capture_units(QVariant data1, QVariant data2)
Definition dialogs.cpp:2643
static void road(QVariant data1, QVariant data2)
Definition dialogs.cpp:2819
static bool is_race_dialog_open
Definition dialogs.cpp:178
bool try_default_unit_action(QVariant q1, QVariant q2)
Definition dialogs.cpp:1532
static void fortify(QVariant data1, QVariant data2)
Definition dialogs.cpp:2371
static void transport_board(QVariant data1, QVariant data2)
Definition dialogs.cpp:2475
static void spy_sabotage_unit_esc(QVariant data1, QVariant data2)
Definition dialogs.cpp:2441
static void disband_unit(QVariant data1, QVariant data2)
Definition dialogs.cpp:2359
static void spy_steal_gold(QVariant data1, QVariant data2)
Definition dialogs.cpp:3310
void popdown_players_report()
Definition plrdlg.cpp:1159
static void mine(QVariant data1, QVariant data2)
Definition dialogs.cpp:2861
void popup_musicset_suggestion_dialog(void)
Definition dialogs.cpp:3908
static void spy_steal_gold_esc(QVariant data1, QVariant data2)
Definition dialogs.cpp:3325
static void diplomat_embassy(QVariant data1, QVariant data2)
Definition dialogs.cpp:3385
void unit_select_dialog_popup(struct tile *ptile)
Definition dialogs.cpp:1232
void popup_upgrade_dialog(struct unit_list *punits)
Definition dialogs.cpp:4264
void update_nationset_combo()
Definition dialogs.cpp:1252
void action_selection_close(void)
Definition dialogs.cpp:4202
static void cultivate(QVariant data1, QVariant data2)
Definition dialogs.cpp:2729
static void paradrop_enter(QVariant data1, QVariant data2)
Definition dialogs.cpp:3008
void races_update_pickable(bool nationset_change)
Definition dialogs.cpp:1262
int action_selection_target_city(void)
Definition dialogs.cpp:4014
static void spy_steal_something(QVariant data1, QVariant data2)
Definition dialogs.cpp:3143
#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:1170
static void spy_poison(QVariant data1, QVariant data2)
Definition dialogs.cpp:3220
void show_tech_gained_dialog(Tech_type_id tech)
Definition dialogs.cpp:4216
static void base(QVariant data1, QVariant data2)
Definition dialogs.cpp:2840
static void spy_nuke_city_esc(QVariant data1, QVariant data2)
Definition dialogs.cpp:3265
void popup_soundset_suggestion_dialog(void)
Definition dialogs.cpp:3883
static void enter_hut2(QVariant data1, QVariant data2)
Definition dialogs.cpp:2586
void popup_races_dialog(struct player *pplayer)
Definition dialogs.cpp:1207
static void expel_unit(QVariant data1, QVariant data2)
Definition dialogs.cpp:2655
static void paradrop_frighten(QVariant data1, QVariant data2)
Definition dialogs.cpp:2978
static void diplomat_sabotage(QVariant data1, QVariant data2)
Definition dialogs.cpp:3430
void popup_disband_dialog(struct unit_list *punits)
Definition dialogs.cpp:3842
static action_id get_non_targeted_action_id(action_id tgt_action_id)
Definition dialogs.cpp:2254
static void homeless(QVariant data1, QVariant data2)
Definition dialogs.cpp:2397
static void caravan_help_build(QVariant data1, QVariant data2)
Definition dialogs.cpp:1751
static void bombard(QVariant data1, QVariant data2)
Definition dialogs.cpp:2667
void popdown_races_dialog(void)
Definition dialogs.cpp:1221
void popup_tileset_suggestion_dialog(void)
Definition dialogs.cpp:3852
static void conquer_city(QVariant data1, QVariant data2)
Definition dialogs.cpp:1832
void revolution_response(struct government *gov)
Definition dialogs.cpp:1905
void popdown_economy_report()
static void join_city(QVariant data1, QVariant data2)
Definition dialogs.cpp:3038
static void spy_request_sabotage_list(QVariant data1, QVariant data2)
Definition dialogs.cpp:3183
static void diplomat_bribe(QVariant data1, QVariant data2)
Definition dialogs.cpp:2411
static void unit_disband_recover(QVariant data1, QVariant data2)
Definition dialogs.cpp:1766
static void spy_steal(QVariant data1, QVariant data2)
Definition dialogs.cpp:3127
static void airlift(QVariant data1, QVariant data2)
Definition dialogs.cpp:1817
void popup_pillage_dialog(struct unit *punit, bv_extras extras)
Definition dialogs.cpp:3763
void popup_sabotage_dialog(struct unit *actor, struct city *tcity, const struct action *paction)
Definition dialogs.cpp:3701
static void transport_alight(QVariant data1, QVariant data2)
Definition dialogs.cpp:2530
static void plant(QVariant data1, QVariant data2)
Definition dialogs.cpp:2744
static void nuke(QVariant data1, QVariant data2)
Definition dialogs.cpp:2903
static void disembark2(QVariant data1, QVariant data2)
Definition dialogs.cpp:2556
static void transport_unload(QVariant data1, QVariant data2)
Definition dialogs.cpp:2519
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:4079
void popdown_science_report()
static void diplomat_steal(QVariant data1, QVariant data2)
Definition dialogs.cpp:3460
static void unit_upgrade(QVariant data1, QVariant data2)
Definition dialogs.cpp:1796
bool popup_theme_suggestion_dialog(const char *theme_name)
Definition dialogs.cpp:3933
static void enter_hut(QVariant data1, QVariant data2)
Definition dialogs.cpp:2571
static void spy_request_strike_bld_list(QVariant data1, QVariant data2)
Definition dialogs.cpp:3166
static void diplomat_incite_escape(QVariant data1, QVariant data2)
Definition dialogs.cpp:3508
static void found_city(QVariant data1, QVariant data2)
Definition dialogs.cpp:2703
static void diplomat_investigate(QVariant data1, QVariant data2)
Definition dialogs.cpp:3415
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:4800
static void bombard3(QVariant data1, QVariant data2)
Definition dialogs.cpp:2691
static void diplomat_incite(QVariant data1, QVariant data2)
Definition dialogs.cpp:3490
static void paradrop_conquer(QVariant data1, QVariant data2)
Definition dialogs.cpp:2963
void popdown_endgame_report()
static void diplomat_steal_esc(QVariant data1, QVariant data2)
Definition dialogs.cpp:3475
static bool is_more_user_input_needed
Definition dialogs.cpp:183
static void bombard2(QVariant data1, QVariant data2)
Definition dialogs.cpp:2679
void popup_incite_dialog(struct unit *actor, struct city *tcity, int cost, const struct action *paction)
Definition dialogs.cpp:3542
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:3280
void popup_connect_msg(const char *headline, const char *message)
Definition dialogs.cpp:1182
static void diplomat_sabotage_esc(QVariant data1, QVariant data2)
Definition dialogs.cpp:3445
void popdown_units_report()
static void transport_embark2(QVariant data1, QVariant data2)
Definition dialogs.cpp:2497
static void spy_nuke_city(QVariant data1, QVariant data2)
Definition dialogs.cpp:3250
void unit_select_dialog_update_real(void *unused)
Definition dialogs.cpp:1244
static void spy_steal_esc(QVariant data1, QVariant data2)
Definition dialogs.cpp:3135
static void paradrop(QVariant data1, QVariant data2)
Definition dialogs.cpp:2948
static void suicide_attack(QVariant data1, QVariant data2)
Definition dialogs.cpp:2933
void races_toggles_set_sensitive(void)
Definition dialogs.cpp:1273
static action_id get_production_targeted_action_id(action_id tgt_action_id)
Definition dialogs.cpp:2277
static void paradrop_frighten_conquer(QVariant data1, QVariant data2)
Definition dialogs.cpp:2993
static void convert_unit(QVariant data1, QVariant data2)
Definition dialogs.cpp:2385
static bool did_not_decide
Definition dialogs.cpp:187
static void spy_poison_esc(QVariant data1, QVariant data2)
Definition dialogs.cpp:3235
static void pillage_something(QVariant data1, QVariant data2)
Definition dialogs.cpp:3651
static void spy_request_sabotage_esc_list(QVariant data1, QVariant data2)
Definition dialogs.cpp:3201
static void transform_terrain(QVariant data1, QVariant data2)
Definition dialogs.cpp:2714
#define BUTTON_CANCEL
Definition dialogs.cpp:69
static void conquer_extras(QVariant data1, QVariant data2)
Definition dialogs.cpp:1862
static void regular_move(QVariant data1, QVariant data2)
Definition dialogs.cpp:3526
static void heal_unit2(QVariant data1, QVariant data2)
Definition dialogs.cpp:2464
static void spy_embassy(QVariant data1, QVariant data2)
Definition dialogs.cpp:3370
static races_dialog * race_dialog
Definition dialogs.cpp:177
static void frighten_hut2(QVariant data1, QVariant data2)
Definition dialogs.cpp:2616
static void conquer_city2(QVariant data1, QVariant data2)
Definition dialogs.cpp:1847
static void conquer_extras2(QVariant data1, QVariant data2)
Definition dialogs.cpp:1876
static void frighten_hut(QVariant data1, QVariant data2)
Definition dialogs.cpp:2601
bool qtg_request_transport(struct unit *pcargo, struct tile *ptile)
Definition dialogs.cpp:4759
int action_selection_target_unit(void)
Definition dialogs.cpp:4065
static void irrigate(QVariant data1, QVariant data2)
Definition dialogs.cpp:2882
static void transport_embark3(QVariant data1, QVariant data2)
Definition dialogs.cpp:2508
static void heal_unit(QVariant data1, QVariant data2)
Definition dialogs.cpp:2453
void popdown_city_report()
Definition cityrep.cpp:1340
static void paradrop_enter_conquer(QVariant data1, QVariant data2)
Definition dialogs.cpp:3023
static void unit_home_city(QVariant data1, QVariant data2)
Definition dialogs.cpp:1781
static void transport_embark(QVariant data1, QVariant data2)
Definition dialogs.cpp:2486
bool try_default_city_action(QVariant q1, QVariant q2)
Definition dialogs.cpp:1550
static void keep_moving(QVariant data1, QVariant data2)
Definition dialogs.cpp:1898
static void spy_steal_maps_esc(QVariant data1, QVariant data2)
Definition dialogs.cpp:3355
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:2330
static void disembark1(QVariant data1, QVariant data2)
Definition dialogs.cpp:2541
void restart_notify_dialogs()
Definition dialogs.cpp:3942
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:2297
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:1736
void popdown_all_game_dialogs(void)
Definition dialogs.cpp:3958
static void spy_steal_maps(QVariant data1, QVariant data2)
Definition dialogs.cpp:3340
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 mevent_gpos(__ev__)
Definition gui_main.h:29
#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:2517
void set_government_choice(struct government *government)
Definition packhand.c:2504
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:82
struct universal item
Definition climisc.h:83
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:167
#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:6547
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:6467
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:1906
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:328
void unit_activity_astr(const struct unit *punit, struct astring *astr)
Definition unit.c:1174
#define unit_tile(_pu)
Definition unit.h:395
#define unit_owner(_pu)
Definition unit.h:394
#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:825
#define show(id)
Definition widget.h:235