Freeciv-3.3: /fast/freeciv/nightly/main/client/gui-gtk-3.22/action_dialog.c Source File

Freeciv-3.3

Loading...
Searching...
No Matches
action_dialog.c
Go to the documentation of this file.
1/***********************************************************************
2 Freeciv - Copyright (C) 1996-2005 - Freeciv Development Team
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#include <gtk/gtk.h>
19
20/* utility */
21#include "astring.h"
22#include "support.h"
23
24/* common */
25#include "actions.h"
26#include "game.h"
27#include "traderoutes.h"
28#include "movement.h"
29#include "research.h"
30#include "unit.h"
31#include "unitlist.h"
32
33/* client */
34#include "dialogs_g.h"
35#include "chatline.h"
36#include "choice_dialog.h"
37#include "client_main.h"
38#include "climisc.h"
39#include "connectdlg_common.h"
40#include "control.h"
41#include "gui_main.h"
42#include "gui_stuff.h"
43#include "mapview.h"
44#include "packhand.h"
45#include "text.h"
46
47/* client/gui-gtk-3.22 */
48#include "citydlg.h"
49#include "dialogs.h"
50#include "unitselextradlg.h"
51#include "unitselunitdlg.h"
52#include "wldlg.h"
53
54/* Locations for non action enabler controlled buttons. */
55#define BUTTON_NEW_UNIT_TGT (ACTION_COUNT + 1)
56#define BUTTON_NEW_EXTRA_TGT (BUTTON_NEW_UNIT_TGT + 1)
57#define BUTTON_LOCATION (BUTTON_NEW_EXTRA_TGT + 1)
58#define BUTTON_WAIT (BUTTON_LOCATION + 1)
59#define BUTTON_CANCEL (BUTTON_WAIT + 1)
60#define BUTTON_COUNT (BUTTON_CANCEL + 1)
61
62#define BUTTON_NOT_THERE -1
63
64
65 static GtkWidget *act_sel_dialog;
66 static int action_button_map[BUTTON_COUNT];
67
68 static int actor_unit_id;
69 static int target_ids[ATK_COUNT];
70 static int target_extra_id;
71 static bool is_more_user_input_needed = FALSE;
72 static bool did_not_decide = FALSE;
73 static bool action_selection_restart = FALSE;
74
75 static GtkWidget *spy_tech_shell;
76
77 static GtkWidget *spy_sabotage_shell;
78
79/* A structure to hold parameters for actions inside the GUI instead of
80 * storing the needed data in a global variable. */
81 struct action_data {
82 action_id act_id;
83 int actor_unit_id;
84 int target_city_id;
85 int target_unit_id;
86 int target_tile_id;
87 int target_building_id;
88 int target_tech_id;
89 int target_extra_id;
90};
91
92/* TODO: maybe this should be in the dialog itself? */
93 static struct action_data *act_sel_dialog_data;
94
95/**********************************************************************/
99 static struct action_data *act_data(action_id act_id,
100 int actor_id,
101 int target_city_id,
102 int target_unit_id,
103 int target_tile_id,
104 int target_building_id,
105 int target_tech_id,
106 int tgt_extra_id)
107{
108 struct action_data *data = fc_malloc(sizeof(*data));
109
110 data->act_id = act_id;
111 data->actor_unit_id = actor_id;
112 data->target_city_id = target_city_id;
113 data->target_unit_id = target_unit_id;
114 data->target_tile_id = target_tile_id;
115 data->target_building_id = target_building_id;
116 data->target_tech_id = target_tech_id;
117 data->target_extra_id = tgt_extra_id;
118
119 return data;
120}
121
122/**********************************************************************/
126 static void diplomat_queue_handle_primary(void)
127{
128 if (!is_more_user_input_needed) {
129 /* The client isn't waiting for information for any unanswered follow
130 * up questions. */
131
132 struct unit *actor_unit;
133
134 if ((actor_unit = game_unit_by_number(actor_unit_id))) {
135 /* The action selection dialog wasn't closed because the actor unit
136 * was lost. */
137
138 /* The probabilities didn't just disappear, right? */
139 fc_assert_action(actor_unit->client.act_prob_cache,
140 client_unit_init_act_prob_cache(actor_unit));
141
142 FC_FREE(actor_unit->client.act_prob_cache);
143 }
144
145 if (action_selection_restart) {
146 /* The action selection dialog was closed but only so it can be
147 * redrawn with fresh data. */
148
149 action_selection_restart = FALSE;
150 } else {
151 /* The action selection process is over, at least for now. */
152 action_selection_no_longer_in_progress(actor_unit_id);
153 }
154
155 if (did_not_decide) {
156 /* The action selection dialog was closed but the player didn't
157 * decide what the unit should do. */
158
159 /* Reset so the next action selection dialog does the right thing. */
160 did_not_decide = FALSE;
161 } else {
162 /* An action, or no action at all, was selected. */
163 action_decision_clear_want(actor_unit_id);
164 action_selection_next_in_focus(actor_unit_id);
165 }
166 }
167}
168
169/**********************************************************************/
173 static void diplomat_queue_handle_secondary(void)
174{
175 /* Stop waiting. Move on to the next queued unit. */
176 is_more_user_input_needed = FALSE;
177 diplomat_queue_handle_primary();
178}
179
180/**********************************************************************/
186 void action_selection_no_longer_in_progress_gui_specific(int actor_id)
187{
188 /* Stop assuming the answer to a follow up question will arrive. */
189 is_more_user_input_needed = FALSE;
190}
191
192/**********************************************************************/
196 static action_id get_non_targeted_action_id(action_id tgt_action_id)
197{
198 /* Don't add an action mapping here unless the non targeted version is
199 * selectable in the targeted version's target selection dialog. */
200 switch ((enum gen_action)tgt_action_id) {
201 case ACTION_SPY_TARGETED_SABOTAGE_CITY:
202 return ACTION_SPY_SABOTAGE_CITY;
203 case ACTION_SPY_TARGETED_SABOTAGE_CITY_ESC:
204 return ACTION_SPY_SABOTAGE_CITY_ESC;
205 case ACTION_SPY_TARGETED_STEAL_TECH:
206 return ACTION_SPY_STEAL_TECH;
207 case ACTION_SPY_TARGETED_STEAL_TECH_ESC:
208 return ACTION_SPY_STEAL_TECH_ESC;
209 default:
210 /* No non targeted version found. */
211 return ACTION_NONE;
212 }
213}
214
215/**********************************************************************/
219 static action_id get_production_targeted_action_id(action_id tgt_action_id)
220{
221 /* Don't add an action mapping here unless the non targeted version is
222 * selectable in the targeted version's target selection dialog. */
223 switch ((enum gen_action)tgt_action_id) {
224 case ACTION_SPY_TARGETED_SABOTAGE_CITY:
225 return ACTION_SPY_SABOTAGE_CITY_PRODUCTION;
226 case ACTION_SPY_TARGETED_SABOTAGE_CITY_ESC:
227 return ACTION_SPY_SABOTAGE_CITY_PRODUCTION_ESC;
228 case ACTION_STRIKE_BUILDING:
229 return ACTION_STRIKE_PRODUCTION;
230 default:
231 /* No non targeted version found. */
232 return ACTION_NONE;
233 }
234}
235
236/**********************************************************************/
240 static void simple_action_callback(GtkWidget *w, gpointer data)
241{
242 int actor_id, target_id, sub_target;
243 struct action *paction;
244
245 struct action_data *args = act_sel_dialog_data;
246
247 bool failed = FALSE;
248
249 /* Data */
250 args->act_id = GPOINTER_TO_INT(data);
251 paction = action_by_number(args->act_id);
252
253 /* Actor */
254 fc_assert(action_get_actor_kind(paction) == AAK_UNIT);
255 actor_id = args->actor_unit_id;
256 if (NULL == game_unit_by_number(actor_id)) {
257 /* Probably dead. */
258 failed = TRUE;
259 }
260
261 /* Target */
262 target_id = IDENTITY_NUMBER_ZERO;
263 switch (action_get_target_kind(paction)) {
264 case ATK_CITY:
265 target_id = args->target_city_id;
266 if (NULL == game_city_by_number(target_id)) {
267 /* Probably destroyed. */
268 failed = TRUE;
269 }
270 break;
271 case ATK_UNIT:
272 target_id = args->target_unit_id;
273 if (NULL == game_unit_by_number(target_id)) {
274 /* Probably dead. */
275 failed = TRUE;
276 }
277 break;
278 case ATK_UNITS:
279 case ATK_TILE:
280 case ATK_EXTRAS:
281 target_id = args->target_tile_id;
282 if (NULL == index_to_tile(&(wld.map), target_id)) {
283 /* TODO: Should this be possible at all? If not: add assertion. */
284 failed = TRUE;
285 }
286 break;
287 case ATK_SELF:
288 target_id = IDENTITY_NUMBER_ZERO;
289 break;
290 case ATK_COUNT:
291 fc_assert(action_get_target_kind(paction) != ATK_COUNT);
292 failed = TRUE;
293 }
294
295 /* Sub target. */
296 sub_target = NO_TARGET;
297 if (paction->target_complexity != ACT_TGT_COMPL_SIMPLE) {
298 switch (action_get_sub_target_kind(paction)) {
299 case ASTK_BUILDING:
300 sub_target = args->target_building_id;
301 if (NULL == improvement_by_number(sub_target)) {
302 /* Did the ruleset change? */
303 failed = TRUE;
304 }
305 break;
306 case ASTK_TECH:
307 sub_target = args->target_tech_id;
308 if (NULL == valid_advance_by_number(sub_target)) {
309 /* Did the ruleset change? */
310 failed = TRUE;
311 }
312 break;
313 case ASTK_EXTRA:
314 case ASTK_EXTRA_NOT_THERE:
315 /* TODO: validate if the extra is there? */
316 sub_target = args->target_extra_id;
317 if (NULL == extra_by_number(sub_target)) {
318 /* Did the ruleset change? */
319 failed = TRUE;
320 }
321 break;
322 case ASTK_NONE:
323 case ASTK_COUNT:
324 /* Shouldn't happen. */
325 fc_assert(action_get_sub_target_kind(paction) != ASTK_NONE);
326 failed = TRUE;
327 break;
328 }
329 }
330
331 /* Send request. */
332 if (!failed) {
333 request_do_action(paction->id, actor_id, target_id, sub_target, "");
334 }
335
336 /* Clean up. */
337 gtk_widget_destroy(act_sel_dialog);
338 /* No follow up questions. */
339 act_sel_dialog_data = NULL;
340 FC_FREE(args);
341}
342
343/**********************************************************************/
347 static void request_action_details_callback(GtkWidget *w, gpointer data)
348{
349 int actor_id, target_id;
350 struct action *paction;
351
352 struct action_data *args = act_sel_dialog_data;
353
354 bool failed = FALSE;
355
356 /* Data */
357 args->act_id = GPOINTER_TO_INT(data);
358 paction = action_by_number(args->act_id);
359
360 /* Actor */
361 fc_assert(action_get_actor_kind(paction) == AAK_UNIT);
362 actor_id = args->actor_unit_id;
363 if (NULL == game_unit_by_number(actor_id)) {
364 /* Probably dead. */
365 failed = TRUE;
366 }
367
368 /* Target */
369 target_id = IDENTITY_NUMBER_ZERO;
370 switch (action_get_target_kind(paction)) {
371 case ATK_CITY:
372 target_id = args->target_city_id;
373 if (NULL == game_city_by_number(target_id)) {
374 /* Probably destroyed. */
375 failed = TRUE;
376 }
377 break;
378 case ATK_UNIT:
379 target_id = args->target_unit_id;
380 if (NULL == game_unit_by_number(target_id)) {
381 /* Probably dead. */
382 failed = TRUE;
383 }
384 break;
385 case ATK_UNITS:
386 case ATK_TILE:
387 case ATK_EXTRAS:
388 target_id = args->target_tile_id;
389 if (NULL == index_to_tile(&(wld.map), target_id)) {
390 /* TODO: Should this be possible at all? If not: add assertion. */
391 failed = TRUE;
392 }
393 break;
394 case ATK_SELF:
395 target_id = IDENTITY_NUMBER_ZERO;
396 break;
397 case ATK_COUNT:
398 fc_assert(action_get_target_kind(paction) != ATK_COUNT);
399 failed = TRUE;
400 }
401
402 /* Send request. */
403 if (!failed) {
404 request_action_details(paction->id, actor_id, target_id);
405 }
406
407 /* Wait for the server's reply before moving on to the next unit that
408 * needs to know what action to take. */
409 is_more_user_input_needed = TRUE;
410
411 /* Clean up. */
412 gtk_widget_destroy(act_sel_dialog);
413 /* No client side follow up questions. */
414 act_sel_dialog_data = NULL;
415 FC_FREE(args);
416}
417
418/**********************************************************************/
421 static void found_city_callback(GtkWidget *w, gpointer data)
422{
423 struct action_data *args = act_sel_dialog_data;
424
425 dsend_packet_city_name_suggestion_req(&client.conn,
426 args->actor_unit_id);
427
428 gtk_widget_destroy(act_sel_dialog);
429 free(args);
430}
431
432/**********************************************************************/
435 static void upgrade_callback(GtkWidget *w, gpointer data)
436{
437 struct unit *punit;
438
439 struct action_data *args = act_sel_dialog_data;
440
441 if ((punit = game_unit_by_number(args->actor_unit_id))
442 && NULL != game_city_by_number(args->target_city_id)) {
443 struct unit_list *as_list;
444
445 as_list = unit_list_new();
446 unit_list_append(as_list, punit);
447 popup_upgrade_dialog(as_list);
448 unit_list_destroy(as_list);
449 }
450
451 gtk_widget_destroy(act_sel_dialog);
452 free(args);
453}
454
455/**********************************************************************/
458 static void bribe_response(GtkWidget *w, gint response, gpointer data)
459{
460 struct action_data *args = (struct action_data *)data;
461
462 if (response == GTK_RESPONSE_YES) {
463 request_do_action(args->act_id, args->actor_unit_id,
464 args->target_unit_id, 0, "");
465 }
466
467 gtk_widget_destroy(w);
468 free(args);
469
470 /* The user have answered the follow up question. Move on. */
471 diplomat_queue_handle_secondary();
472}
473
474/**********************************************************************/
477 void popup_bribe_dialog(struct unit *actor, struct unit *punit, int cost,
478 const struct action *paction)
479{
480 GtkWidget *shell;
481 char buf[1024];
482
483 fc_snprintf(buf, ARRAY_SIZE(buf), PL_("Treasury contains %d gold.",
484 "Treasury contains %d gold.",
485 client_player()->economic.gold),
486 client_player()->economic.gold);
487
488 if (cost <= client_player()->economic.gold) {
489 shell = gtk_message_dialog_new(NULL, 0,
490 GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO,
491 /* TRANS: %s is pre-pluralised "Treasury contains %d gold." */
492 PL_("Bribe unit for %d gold?\n%s",
493 "Bribe unit for %d gold?\n%s", cost), cost, buf);
494 gtk_window_set_title(GTK_WINDOW(shell), _("Bribe Enemy Unit"));
495 setup_dialog(shell, toplevel);
496 } else {
497 shell = gtk_message_dialog_new(NULL, 0,
498 GTK_MESSAGE_INFO, GTK_BUTTONS_CLOSE,
499 /* TRANS: %s is pre-pluralised "Treasury contains %d gold." */
500 PL_("Bribing the unit costs %d gold.\n%s",
501 "Bribing the unit costs %d gold.\n%s", cost), cost, buf);
502 gtk_window_set_title(GTK_WINDOW(shell), _("Traitors Demand Too Much!"));
503 setup_dialog(shell, toplevel);
504 }
505 gtk_window_present(GTK_WINDOW(shell));
506
507 g_signal_connect(shell, "response", G_CALLBACK(bribe_response),
508 act_data(paction->id, actor->id,
509 0, punit->id, 0,
510 0, 0, 0));
511}
512
513/**********************************************************************/
516 static void spy_advances_response(GtkWidget *w, gint response,
517 gpointer data)
518{
519 struct action_data *args = (struct action_data *)data;
520
521 if (response == GTK_RESPONSE_ACCEPT && args->target_tech_id > 0) {
522 if (NULL != game_unit_by_number(args->actor_unit_id)
523 && NULL != game_city_by_number(args->target_city_id)) {
524 if (args->target_tech_id == A_UNSET) {
525 /* This is the untargeted version. */
526 request_do_action(get_non_targeted_action_id(args->act_id),
527 args->actor_unit_id, args->target_city_id,
528 args->target_tech_id, "");
529 } else {
530 /* This is the targeted version. */
531 request_do_action(args->act_id,
532 args->actor_unit_id, args->target_city_id,
533 args->target_tech_id, "");
534 }
535 }
536 }
537
538 gtk_widget_destroy(spy_tech_shell);
539 spy_tech_shell = NULL;
540 free(data);
541
542 /* The user have answered the follow up question. Move on. */
543 diplomat_queue_handle_secondary();
544}
545
546/**********************************************************************/
549 static void spy_advances_callback(GtkTreeSelection *select,
550 gpointer data)
551{
552 struct action_data *args = (struct action_data *)data;
553
554 GtkTreeModel *model;
555 GtkTreeIter it;
556
557 if (gtk_tree_selection_get_selected(select, &model, &it)) {
558 gtk_tree_model_get(model, &it, 1, &(args->target_tech_id), -1);
559
560 gtk_dialog_set_response_sensitive(GTK_DIALOG(spy_tech_shell),
561 GTK_RESPONSE_ACCEPT, TRUE);
562 } else {
563 args->target_tech_id = 0;
564
565 gtk_dialog_set_response_sensitive(GTK_DIALOG(spy_tech_shell),
566 GTK_RESPONSE_ACCEPT, FALSE);
567 }
568}
569
570/**********************************************************************/
573 static void create_advances_list(struct player *pplayer,
574 struct player *pvictim,
575 struct action_data *args)
576{
577 GtkWidget *sw, *label, *vbox, *view;
578 GtkListStore *store;
579 GtkCellRenderer *rend;
580 GtkTreeViewColumn *col;
581
582 struct unit *actor_unit = game_unit_by_number(args->actor_unit_id);
583
584 spy_tech_shell = gtk_dialog_new_with_buttons(_("Steal Technology"),
585 NULL, 0,
586 _("_Cancel"), GTK_RESPONSE_CANCEL,
587 _("_Steal"), GTK_RESPONSE_ACCEPT,
588 NULL);
589 setup_dialog(spy_tech_shell, toplevel);
590 gtk_window_set_position(GTK_WINDOW(spy_tech_shell), GTK_WIN_POS_MOUSE);
591
592 gtk_dialog_set_default_response(GTK_DIALOG(spy_tech_shell),
593 GTK_RESPONSE_ACCEPT);
594
595 label = gtk_frame_new(_("Select Advance to Steal"));
596 gtk_container_add(GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(spy_tech_shell))), label);
597
598 vbox = gtk_grid_new();
599 gtk_orientable_set_orientation(GTK_ORIENTABLE(vbox),
600 GTK_ORIENTATION_VERTICAL);
601 gtk_grid_set_row_spacing(GTK_GRID(vbox), 6);
602 gtk_container_add(GTK_CONTAINER(label), vbox);
603
604 store = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_INT);
605
606 view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
607 gtk_widget_set_hexpand(view, TRUE);
608 gtk_widget_set_vexpand(view, TRUE);
609 g_object_unref(store);
610 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(view), FALSE);
611
612 rend = gtk_cell_renderer_text_new();
613 col = gtk_tree_view_column_new_with_attributes(NULL, rend,
614 "text", 0, NULL);
615 gtk_tree_view_append_column(GTK_TREE_VIEW(view), col);
616
617 label = g_object_new(GTK_TYPE_LABEL,
618 "use-underline", TRUE,
619 "mnemonic-widget", view,
620 "label", _("_Advances:"),
621 "xalign", 0.0,
622 "yalign", 0.5,
623 NULL);
624 gtk_container_add(GTK_CONTAINER(vbox), label);
625
626 sw = gtk_scrolled_window_new(NULL, NULL);
627 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw),
628 GTK_SHADOW_ETCHED_IN);
629 gtk_container_add(GTK_CONTAINER(sw), view);
630
631 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw),
632 GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
633 gtk_widget_set_size_request(sw, -1, 200);
634
635 gtk_container_add(GTK_CONTAINER(vbox), sw);
636
637 /* Now populate the list */
638 if (pvictim) { /* you don't want to know what lag can do -- Syela */
639 const struct research *presearch = research_get(pplayer);
640 const struct research *vresearch = research_get(pvictim);
641 GtkTreeIter it;
642 GValue value = { 0, };
643
644 advance_index_iterate(A_FIRST, i) {
645 if (research_invention_gettable(presearch, i,
646 game.info.tech_steal_allow_holes)
647 && research_invention_state(vresearch, i) == TECH_KNOWN
648 && research_invention_state(presearch, i) != TECH_KNOWN) {
649 gtk_list_store_append(store, &it);
650
651 g_value_init(&value, G_TYPE_STRING);
652 g_value_set_static_string(&value, research_advance_name_translation
653 (presearch, i));
654 gtk_list_store_set_value(store, &it, 0, &value);
655 g_value_unset(&value);
656 gtk_list_store_set(store, &it, 1, i, -1);
657 }
658 } advance_index_iterate_end;
659
660 if (action_prob_possible(actor_unit->client.act_prob_cache[
661 get_non_targeted_action_id(args->act_id)])) {
662 gtk_list_store_append(store, &it);
663
664 g_value_init(&value, G_TYPE_STRING);
665 {
666 struct astring str = ASTRING_INIT;
667 /* TRANS: %s is a unit name, e.g., Spy */
668 astr_set(&str, _("At %s's Discretion"),
669 unit_name_translation(actor_unit));
670 g_value_set_string(&value, astr_str(&str));
671 astr_free(&str);
672 }
673 gtk_list_store_set_value(store, &it, 0, &value);
674 g_value_unset(&value);
675 gtk_list_store_set(store, &it, 1, A_UNSET, -1);
676 }
677 }
678
679 gtk_dialog_set_response_sensitive(GTK_DIALOG(spy_tech_shell),
680 GTK_RESPONSE_ACCEPT, FALSE);
681
682 gtk_widget_show_all(gtk_dialog_get_content_area(GTK_DIALOG(spy_tech_shell)));
683
684 g_signal_connect(gtk_tree_view_get_selection(GTK_TREE_VIEW(view)), "changed",
685 G_CALLBACK(spy_advances_callback), args);
686 g_signal_connect(spy_tech_shell, "response",
687 G_CALLBACK(spy_advances_response), args);
688
689 args->target_tech_id = 0;
690
691 gtk_tree_view_focus(GTK_TREE_VIEW(view));
692}
693
694/**********************************************************************/
697 static void spy_improvements_response(GtkWidget *w, gint response, gpointer data)
698{
699 struct action_data *args = (struct action_data *)data;
700
701 if (response == GTK_RESPONSE_ACCEPT && args->target_building_id > -2) {
702 if (NULL != game_unit_by_number(args->actor_unit_id)
703 && NULL != game_city_by_number(args->target_city_id)) {
704 if (args->target_building_id == B_LAST) {
705 /* This is the untargeted version. */
706 request_do_action(get_non_targeted_action_id(args->act_id),
707 args->actor_unit_id,
708 args->target_city_id,
709 args->target_building_id, "");
710 } else if (args->target_building_id == -1) {
711 /* This is the city production version. */
712 request_do_action(get_production_targeted_action_id(args->act_id),
713 args->actor_unit_id,
714 args->target_city_id,
715 args->target_building_id, "");
716 } else {
717 /* This is the targeted version. */
718 request_do_action(args->act_id,
719 args->actor_unit_id,
720 args->target_city_id,
721 args->target_building_id, "");
722 }
723 }
724 }
725
726 gtk_widget_destroy(spy_sabotage_shell);
727 spy_sabotage_shell = NULL;
728 free(args);
729
730 /* The user have answered the follow up question. Move on. */
731 diplomat_queue_handle_secondary();
732}
733
734/**********************************************************************/
737 static void spy_improvements_callback(GtkTreeSelection *select, gpointer data)
738{
739 struct action_data *args = (struct action_data *)data;
740
741 GtkTreeModel *model;
742 GtkTreeIter it;
743
744 if (gtk_tree_selection_get_selected(select, &model, &it)) {
745 gtk_tree_model_get(model, &it, 1, &(args->target_building_id), -1);
746
747 gtk_dialog_set_response_sensitive(GTK_DIALOG(spy_sabotage_shell),
748 GTK_RESPONSE_ACCEPT, TRUE);
749 } else {
750 args->target_building_id = -2;
751
752 gtk_dialog_set_response_sensitive(GTK_DIALOG(spy_sabotage_shell),
753 GTK_RESPONSE_ACCEPT, FALSE);
754 }
755}
756
757/**********************************************************************/
760 static void create_improvements_list(struct player *pplayer,
761 struct city *pcity,
762 struct action_data *args)
763{
764 GtkWidget *sw, *label, *vbox, *view;
765 GtkListStore *store;
766 GtkCellRenderer *rend;
767 GtkTreeViewColumn *col;
768 GtkTreeIter it;
769
770 struct unit *actor_unit = game_unit_by_number(args->actor_unit_id);
771
772 spy_sabotage_shell = gtk_dialog_new_with_buttons(_("Sabotage Improvements"),
773 NULL, 0,
774 _("_Cancel"), GTK_RESPONSE_CANCEL,
775 _("_Sabotage"), GTK_RESPONSE_ACCEPT,
776 NULL);
777 setup_dialog(spy_sabotage_shell, toplevel);
778 gtk_window_set_position(GTK_WINDOW(spy_sabotage_shell), GTK_WIN_POS_MOUSE);
779
780 gtk_dialog_set_default_response(GTK_DIALOG(spy_sabotage_shell),
781 GTK_RESPONSE_ACCEPT);
782
783 label = gtk_frame_new(_("Select Improvement to Sabotage"));
784 gtk_container_add(GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(spy_sabotage_shell))), label);
785
786 vbox = gtk_grid_new();
787 gtk_orientable_set_orientation(GTK_ORIENTABLE(vbox),
788 GTK_ORIENTATION_VERTICAL);
789 gtk_grid_set_row_spacing(GTK_GRID(vbox), 6);
790 gtk_container_add(GTK_CONTAINER(label), vbox);
791
792 store = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_INT);
793
794 view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
795 gtk_widget_set_hexpand(view, TRUE);
796 gtk_widget_set_vexpand(view, TRUE);
797 g_object_unref(store);
798 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(view), FALSE);
799
800 rend = gtk_cell_renderer_text_new();
801 col = gtk_tree_view_column_new_with_attributes(NULL, rend,
802 "text", 0, NULL);
803 gtk_tree_view_append_column(GTK_TREE_VIEW(view), col);
804
805 label = g_object_new(GTK_TYPE_LABEL,
806 "use-underline", TRUE,
807 "mnemonic-widget", view,
808 "label", _("_Improvements:"),
809 "xalign", 0.0,
810 "yalign", 0.5,
811 NULL);
812 gtk_container_add(GTK_CONTAINER(vbox), label);
813
814 sw = gtk_scrolled_window_new(NULL, NULL);
815 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw),
816 GTK_SHADOW_ETCHED_IN);
817 gtk_container_add(GTK_CONTAINER(sw), view);
818
819 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw),
820 GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
821 gtk_scrolled_window_set_min_content_height(GTK_SCROLLED_WINDOW(sw), 200);
822
823 gtk_container_add(GTK_CONTAINER(vbox), sw);
824
825 /* Now populate the list */
826 if (action_prob_possible(actor_unit->client.act_prob_cache[
827 get_production_targeted_action_id(
828 args->act_id)])) {
829 gtk_list_store_append(store, &it);
830 gtk_list_store_set(store, &it, 0, _("City Production"), 1, -1, -1);
831 }
832
833 city_built_iterate(pcity, pimprove) {
834 if (pimprove->sabotage > 0) {
835 gtk_list_store_append(store, &it);
836 gtk_list_store_set(store, &it,
837 0, city_improvement_name_translation(pcity, pimprove),
838 1, improvement_number(pimprove),
839 -1);
840 }
841 } city_built_iterate_end;
842
843 if (action_prob_possible(actor_unit->client.act_prob_cache[
844 get_non_targeted_action_id(args->act_id)])) {
845 struct astring str = ASTRING_INIT;
846
847 gtk_list_store_append(store, &it);
848
849 /* TRANS: %s is a unit name, e.g., Spy */
850 astr_set(&str, _("At %s's Discretion"),
851 unit_name_translation(actor_unit));
852 gtk_list_store_set(store, &it, 0, astr_str(&str), 1, B_LAST, -1);
853
854 astr_free(&str);
855 }
856
857 gtk_dialog_set_response_sensitive(GTK_DIALOG(spy_sabotage_shell),
858 GTK_RESPONSE_ACCEPT, FALSE);
859
860 gtk_widget_show_all(gtk_dialog_get_content_area(GTK_DIALOG(spy_sabotage_shell)));
861
862 g_signal_connect(gtk_tree_view_get_selection(GTK_TREE_VIEW(view)), "changed",
863 G_CALLBACK(spy_improvements_callback), args);
864 g_signal_connect(spy_sabotage_shell, "response",
865 G_CALLBACK(spy_improvements_response), args);
866
867 args->target_building_id = -2;
868
869 gtk_tree_view_focus(GTK_TREE_VIEW(view));
870}
871
872/**********************************************************************/
875 static void spy_steal_popup_shared(GtkWidget *w, gpointer data)
876{
877 struct action_data *args = (struct action_data *)data;
878
879 args->act_id = args->act_id;
880
881 struct city *pvcity = game_city_by_number(args->target_city_id);
882 struct player *pvictim = NULL;
883
884 if (pvcity) {
885 pvictim = city_owner(pvcity);
886 }
887
888/* it is concievable that pvcity will not be found, because something
889has happened to the city during latency. Therefore we must initialize
890pvictim to NULL and account for !pvictim in create_advances_list. -- Syela */
891
892 /* FIXME: Don't discard the second tech choice dialog. */
893 if (!spy_tech_shell) {
894 create_advances_list(client.conn.playing, pvictim, args);
895 gtk_window_present(GTK_WINDOW(spy_tech_shell));
896 } else {
897 free(args);
898 }
899
900 /* Wait for the player's reply before moving on to the next unit that
901 * needs to know what action to take. */
902 is_more_user_input_needed = TRUE;
903
904 gtk_widget_destroy(act_sel_dialog);
905}
906
907/**********************************************************************/
911 static void spy_steal_popup(GtkWidget *w, gpointer data)
912{
913 act_sel_dialog_data->act_id = ACTION_SPY_TARGETED_STEAL_TECH;
914 spy_steal_popup_shared(w, act_sel_dialog_data);
915}
916
917/**********************************************************************/
921 static void spy_steal_esc_popup(GtkWidget *w, gpointer data)
922{
923 act_sel_dialog_data->act_id = ACTION_SPY_TARGETED_STEAL_TECH_ESC;
924 spy_steal_popup_shared(w, act_sel_dialog_data);
925}
926
927/**********************************************************************/
931 void popup_sabotage_dialog(struct unit *actor, struct city *pcity,
932 const struct action *paction)
933{
934 /* FIXME: Don't discard the second target choice dialog. */
935 if (!spy_sabotage_shell) {
936 create_improvements_list(client.conn.playing, pcity,
937 act_data(paction->id,
938 actor->id, pcity->id, 0, 0,
939 0, 0, 0));
940 gtk_window_present(GTK_WINDOW(spy_sabotage_shell));
941 }
942}
943
944/**********************************************************************/
947 static void incite_response(GtkWidget *w, gint response, gpointer data)
948{
949 struct action_data *args = (struct action_data *)data;
950
951 if (response == GTK_RESPONSE_YES) {
952 request_do_action(args->act_id, args->actor_unit_id,
953 args->target_city_id, 0, "");
954 }
955
956 gtk_widget_destroy(w);
957 free(args);
958
959 /* The user have answered the follow up question. Move on. */
960 diplomat_queue_handle_secondary();
961}
962
963/**********************************************************************/
966 void popup_incite_dialog(struct unit *actor, struct city *pcity, int cost,
967 const struct action *paction)
968{
969 GtkWidget *shell;
970 char buf[1024];
971
972 fc_snprintf(buf, ARRAY_SIZE(buf), PL_("Treasury contains %d gold.",
973 "Treasury contains %d gold.",
974 client_player()->economic.gold),
975 client_player()->economic.gold);
976
977 if (INCITE_IMPOSSIBLE_COST == cost) {
978 shell = gtk_message_dialog_new(NULL, 0,
979 GTK_MESSAGE_INFO, GTK_BUTTONS_CLOSE,
980 _("You can't incite a revolt in %s."),
981 city_name_get(pcity));
982 gtk_window_set_title(GTK_WINDOW(shell), _("City can't be incited!"));
983 setup_dialog(shell, toplevel);
984 } else if (cost <= client_player()->economic.gold) {
985 shell = gtk_message_dialog_new(NULL, 0,
986 GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO,
987 /* TRANS: %s is pre-pluralised "Treasury contains %d gold." */
988 PL_("Incite a revolt for %d gold?\n%s",
989 "Incite a revolt for %d gold?\n%s", cost), cost, buf);
990 gtk_window_set_title(GTK_WINDOW(shell), _("Incite a Revolt!"));
991 setup_dialog(shell, toplevel);
992 } else {
993 shell = gtk_message_dialog_new(NULL,
994 0,
995 GTK_MESSAGE_INFO, GTK_BUTTONS_CLOSE,
996 /* TRANS: %s is pre-pluralised "Treasury contains %d gold." */
997 PL_("Inciting a revolt costs %d gold.\n%s",
998 "Inciting a revolt costs %d gold.\n%s", cost), cost, buf);
999 gtk_window_set_title(GTK_WINDOW(shell), _("Traitors Demand Too Much!"));
1000 setup_dialog(shell, toplevel);
1001 }
1002 gtk_window_present(GTK_WINDOW(shell));
1003
1004 g_signal_connect(shell, "response", G_CALLBACK(incite_response),
1005 act_data(paction->id, actor->id,
1006 pcity->id, 0, 0,
1007 0, 0, 0));
1008}
1009
1010/**********************************************************************/
1013 static void tgt_unit_change_callback(GtkWidget *dlg, gint arg)
1014{
1015 int au_id = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(dlg), "actor"));
1016
1017 if (arg == GTK_RESPONSE_YES) {
1018 struct unit *actor = game_unit_by_number(au_id);
1019
1020 if (actor != NULL) {
1021 int tgt_id = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(dlg),
1022 "target"));
1023 struct unit *tgt_unit = game_unit_by_number(tgt_id);
1024 struct tile *tgt_tile = g_object_get_data(G_OBJECT(dlg), "tile");
1025
1026 if (tgt_unit == NULL) {
1027 /* Make the action dialog pop up again. */
1028 dsend_packet_unit_get_actions(&client.conn,
1029 actor->id,
1030 /* Let the server choose the target
1031 * unit. */
1032 IDENTITY_NUMBER_ZERO,
1033 tgt_tile->index,
1034 action_selection_target_extra(),
1035 REQEST_PLAYER_INITIATED);
1036 } else {
1037 dsend_packet_unit_get_actions(&client.conn,
1038 actor->id,
1039 tgt_id,
1040 tgt_tile->index,
1041 action_selection_target_extra(),
1042 REQEST_PLAYER_INITIATED);
1043 }
1044 }
1045 } else {
1046 /* Dialog canceled. This ends the action selection process. */
1047 action_selection_no_longer_in_progress(au_id);
1048 }
1049
1050 gtk_widget_destroy(dlg);
1051}
1052
1053/**********************************************************************/
1056 static void act_sel_new_unit_tgt_callback(GtkWidget *w, gpointer data)
1057{
1058 struct action_data *args = act_sel_dialog_data;
1059
1060 struct unit *punit;
1061 struct unit *tunit;
1062 struct tile *ptile;
1063
1064 if ((punit = game_unit_by_number(args->actor_unit_id))
1065 && (ptile = index_to_tile(&(wld.map), args->target_tile_id))
1066 && (tunit = game_unit_by_number(args->target_unit_id))) {
1067 select_tgt_unit(punit, ptile, ptile->units, tunit,
1068 _("Target unit selection"),
1069 _("Looking for target unit:"),
1070 _("Units at tile:"),
1071 _("Select"),
1072 G_CALLBACK(tgt_unit_change_callback));
1073 }
1074
1075 did_not_decide = TRUE;
1076 action_selection_restart = TRUE;
1077 gtk_widget_destroy(act_sel_dialog);
1078 free(args);
1079}
1080
1081/**********************************************************************/
1084 static void tgt_extra_change_callback(GtkWidget *dlg, gint arg)
1085{
1086 int au_id = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(dlg), "actor"));
1087
1088 if (arg == GTK_RESPONSE_YES) {
1089 struct unit *actor = game_unit_by_number(au_id);
1090
1091 if (actor != NULL) {
1092 int tgt_id = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(dlg),
1093 "target"));
1094 struct extra_type *tgt_extra = extra_by_number(tgt_id);
1095 struct tile *tgt_tile = g_object_get_data(G_OBJECT(dlg), "tile");
1096
1097 if (tgt_extra == NULL) {
1098 /* Make the action dialog pop up again. */
1099 dsend_packet_unit_get_actions(&client.conn,
1100 actor->id,
1101 action_selection_target_unit(),
1102 tgt_tile->index,
1103 /* Let the server choose the target
1104 * extra. */
1105 action_selection_target_extra(),
1106 REQEST_PLAYER_INITIATED);
1107 } else {
1108 dsend_packet_unit_get_actions(&client.conn,
1109 actor->id,
1110 action_selection_target_unit(),
1111 tgt_tile->index,
1112 tgt_id,
1113 REQEST_PLAYER_INITIATED);
1114 }
1115 }
1116 } else {
1117 /* Dialog canceled. This ends the action selection process. */
1118 action_selection_no_longer_in_progress(au_id);
1119 }
1120
1121 gtk_widget_destroy(dlg);
1122}
1123
1124/**********************************************************************/
1127 static void act_sel_new_extra_tgt_callback(GtkWidget *w, gpointer data)
1128{
1129 struct action_data *args = act_sel_dialog_data;
1130
1131 struct unit *act_unit;
1132 struct extra_type *tgt_extra;
1133 struct tile *tgt_tile;
1134
1135 if ((act_unit = game_unit_by_number(args->actor_unit_id))
1136 && (tgt_tile = index_to_tile(&(wld.map), args->target_tile_id))
1137 && (tgt_extra = extra_by_number(args->target_extra_id))) {
1138 bv_extras potential_targets;
1139
1140 /* Start with the extras at the tile */
1141 potential_targets = *tile_extras(tgt_tile);
1142
1143 extra_type_re_active_iterate(pextra) {
1144 if (BV_ISSET(potential_targets, extra_number(pextra))) {
1145 /* This extra is at the tile. Can anything be done to it? */
1146 if (!utype_can_remove_extra(unit_type_get(act_unit),
1147 pextra)) {
1148 BV_CLR(potential_targets, extra_number(pextra));
1149 }
1150 } else {
1151 /* This extra isn't at the tile yet. Can it be created? */
1152 if (utype_can_create_extra(unit_type_get(act_unit),
1153 pextra)) {
1154 BV_SET(potential_targets, extra_number(pextra));
1155 }
1156 }
1157 } extra_type_re_active_iterate_end;
1158
1159 select_tgt_extra(act_unit, tgt_tile, potential_targets, tgt_extra,
1160 /* TRANS: GTK action selection dialog extra target
1161 * selection dialog title. */
1162 _("Target extra selection"),
1163 /* TRANS: GTK action selection dialog extra target
1164 * selection dialog actor unit label. */
1165 _("Looking for target extra:"),
1166 /* TRANS: GTK action selection dialog extra target
1167 * selection dialog extra list label. */
1168 _("Extra targets:"),
1169 _("Select"),
1170 G_CALLBACK(tgt_extra_change_callback));
1171 }
1172
1173 did_not_decide = TRUE;
1174 action_selection_restart = TRUE;
1175 gtk_widget_destroy(act_sel_dialog);
1176 free(args);
1177}
1178
1179/**********************************************************************/
1182 static void act_sel_location_callback(GtkWidget *w, gpointer data)
1183{
1184 struct action_data *args = act_sel_dialog_data;
1185
1186 struct unit *punit;
1187
1188 if ((punit = game_unit_by_number(args->actor_unit_id))) {
1189 center_tile_mapcanvas(unit_tile(punit));
1190 }
1191}
1192
1193/**********************************************************************/
1196 static void act_sel_wait_callback(GtkWidget *w, gpointer data)
1197{
1198 struct action_data *args = act_sel_dialog_data;
1199
1200 key_unit_wait();
1201
1202 /* the dialog was destroyed when key_unit_wait() resulted in
1203 * action_selection_close() being called. */
1204
1205 free(args);
1206}
1207
1208/**********************************************************************/
1211 static void act_sel_destroy_callback(GtkWidget *w, gpointer data)
1212{
1213 act_sel_dialog = NULL;
1214 diplomat_queue_handle_primary();
1215}
1216
1217/**********************************************************************/
1220 static void act_sel_cancel_callback(GtkWidget *w, gpointer data)
1221{
1222 gtk_widget_destroy(act_sel_dialog);
1223 free(act_sel_dialog_data);
1224}
1225
1226/**********************************************************************/
1229 static void act_sel_close_callback(GtkWidget *w,
1230 gint response_id,
1231 gpointer data)
1232{
1233 gtk_widget_destroy(act_sel_dialog);
1234 free(act_sel_dialog_data);
1235}
1236
1237/* Mapping from an action to the function to call when its button is
1238 * pushed. */
1239 static const GCallback af_map[ACTION_COUNT] = {
1240 /* Unit acting against a city target. */
1241 [ACTION_SPY_TARGETED_SABOTAGE_CITY] =
1242 (GCallback)request_action_details_callback,
1243 [ACTION_SPY_TARGETED_SABOTAGE_CITY_ESC] =
1244 (GCallback)request_action_details_callback,
1245 [ACTION_SPY_TARGETED_STEAL_TECH] = (GCallback)spy_steal_popup,
1246 [ACTION_SPY_TARGETED_STEAL_TECH_ESC] = (GCallback)spy_steal_esc_popup,
1247 [ACTION_SPY_INCITE_CITY] = (GCallback)request_action_details_callback,
1248 [ACTION_SPY_INCITE_CITY_ESC] = (GCallback)request_action_details_callback,
1249 [ACTION_UPGRADE_UNIT] = (GCallback)upgrade_callback,
1250 [ACTION_STRIKE_BUILDING] = (GCallback)request_action_details_callback,
1251
1252 /* Unit acting against a unit target. */
1253 [ACTION_SPY_BRIBE_UNIT] = (GCallback)request_action_details_callback,
1254
1255 /* Unit acting against all units at a tile. */
1256 /* No special callback functions needed for any unit stack targeted
1257 * actions. */
1258
1259 /* Unit acting against a tile. */
1260 [ACTION_FOUND_CITY] = (GCallback)found_city_callback,
1261
1262 /* Unit acting with no target except itself. */
1263 /* No special callback functions needed for any self targeted actions. */
1264};
1265
1266/**********************************************************************/
1269 static void action_entry(GtkWidget *shl,
1270 action_id act_id,
1271 const struct act_prob *act_probs,
1272 const char *custom,
1273 action_id act_num)
1274{
1275 const gchar *label;
1276 const gchar *tooltip;
1277 GCallback cb;
1278
1279 if (af_map[act_id] == NULL) {
1280 /* No special call back function needed for this action. */
1281 cb = (GCallback)simple_action_callback;
1282 } else {
1283 /* Special action specific callback function specified. */
1284 cb = af_map[act_id];
1285 }
1286
1287 /* Don't show disabled actions. */
1288 if (!action_prob_possible(act_probs[act_id])) {
1289 return;
1290 }
1291
1292 label = action_prepare_ui_name(act_id, "_",
1293 act_probs[act_id],
1294 custom);
1295
1296 tooltip = act_sel_action_tool_tip(action_by_number(act_id),
1297 act_probs[act_id]);
1298
1299 action_button_map[act_id] = choice_dialog_get_number_of_buttons(shl);
1300 choice_dialog_add(shl, label, cb, GINT_TO_POINTER(act_num),
1301 FALSE, tooltip);
1302}
1303
1304/**********************************************************************/
1307 static void action_entry_update(GtkWidget *shl,
1308 action_id act_id,
1309 const struct act_prob *act_probs,
1310 const char *custom,
1311 action_id act_num)
1312{
1313 const gchar *label;
1314 const gchar *tooltip;
1315
1316 /* An action that just became impossible has its button disabled.
1317 * An action that became possible again must be re-enabled. */
1318 choice_dialog_button_set_sensitive(act_sel_dialog,
1319 action_button_map[act_id],
1320 action_prob_possible(act_probs[act_id]));
1321
1322 /* The probability may have changed. */
1323 label = action_prepare_ui_name(act_id, "_",
1324 act_probs[act_id], custom);
1325
1326 tooltip = act_sel_action_tool_tip(action_by_number(act_id),
1327 act_probs[act_id]);
1328
1329 choice_dialog_button_set_label(act_sel_dialog,
1330 action_button_map[act_id],
1331 label);
1332 choice_dialog_button_set_tooltip(act_sel_dialog,
1333 action_button_map[act_id],
1334 tooltip);
1335}
1336
1337/**********************************************************************/
1341 void popup_action_selection(struct unit *actor_unit,
1342 struct city *target_city,
1343 struct unit *target_unit,
1344 struct tile *target_tile,
1345 struct extra_type *target_extra,
1346 const struct act_prob *act_probs)
1347{
1348 GtkWidget *shl;
1349 struct astring title = ASTRING_INIT, text = ASTRING_INIT;
1350 struct city *actor_homecity;
1351
1352 int button_id;
1353
1354 act_sel_dialog_data =
1355 act_data(ACTION_ANY, /* Not decided yet */
1356 actor_unit->id,
1357 (target_city) ? target_city->id : IDENTITY_NUMBER_ZERO,
1358 (target_unit) ? target_unit->id : IDENTITY_NUMBER_ZERO,
1359 (target_tile) ? target_tile->index : TILE_INDEX_NONE,
1360 /* No target_building or target_tech supplied. (Dec 2019) */
1361 B_LAST, A_UNSET,
1362 target_extra ? target_extra->id : EXTRA_NONE);
1363
1364 /* Could be caused by the server failing to reply to a request for more
1365 * information or a bug in the client code. */
1366 fc_assert_msg(!is_more_user_input_needed,
1367 "Diplomat queue problem. Is another diplomat window open?");
1368
1369 /* No extra input is required as no action has been chosen yet. */
1370 is_more_user_input_needed = FALSE;
1371
1372 /* No buttons are added yet. */
1373 for (button_id = 0; button_id < BUTTON_COUNT; button_id++) {
1374 action_button_map[button_id] = BUTTON_NOT_THERE;
1375 }
1376
1377 actor_homecity = game_city_by_number(actor_unit->homecity);
1378
1379 actor_unit_id = actor_unit->id;
1380 target_ids[ATK_SELF] = actor_unit_id;
1381 target_ids[ATK_CITY] = target_city ?
1382 target_city->id :
1383 IDENTITY_NUMBER_ZERO;
1384 target_ids[ATK_UNIT] = target_unit ?
1385 target_unit->id :
1386 IDENTITY_NUMBER_ZERO;
1387 target_ids[ATK_UNITS] = target_tile ?
1388 tile_index(target_tile) :
1389 TILE_INDEX_NONE;
1390 target_ids[ATK_TILE] = target_tile ?
1391 tile_index(target_tile) :
1392 TILE_INDEX_NONE;
1393 target_ids[ATK_EXTRAS] = target_tile ?
1394 tile_index(target_tile) :
1395 TILE_INDEX_NONE;
1396 target_extra_id = target_extra ?
1397 extra_number(target_extra) :
1398 EXTRA_NONE;
1399
1400 astr_set(&title,
1401 /* TRANS: %s is a unit name, e.g., Spy */
1402 _("Choose Your %s's Strategy"),
1403 unit_name_translation(actor_unit));
1404
1405 if (target_city && actor_homecity) {
1406 astr_set(&text,
1407 _("Your %s from %s reaches the city of %s.\nWhat now?"),
1408 unit_name_translation(actor_unit),
1409 city_name_get(actor_homecity),
1410 city_name_get(target_city));
1411 } else if (target_city) {
1412 astr_set(&text,
1413 _("Your %s has arrived at %s.\nWhat is your command?"),
1414 unit_name_translation(actor_unit),
1415 city_name_get(target_city));
1416 } else if (target_unit) {
1417 astr_set(&text,
1418 /* TRANS: Your Spy is ready to act against Roman Freight. */
1419 _("Your %s is ready to act against %s %s."),
1420 unit_name_translation(actor_unit),
1421 nation_adjective_for_player(unit_owner(target_unit)),
1422 unit_name_translation(target_unit));
1423 } else {
1424 fc_assert_msg(target_unit || target_city || target_tile,
1425 "No target specified.");
1426 astr_set(&text,
1427 /* TRANS: %s is a unit name, e.g., Diplomat, Spy */
1428 _("Your %s is waiting for your command."),
1429 unit_name_translation(actor_unit));
1430 }
1431
1432 shl = choice_dialog_start(GTK_WINDOW(toplevel), astr_str(&title),
1433 astr_str(&text));
1434
1435 /* Unit acting against a city */
1436
1437 action_iterate(act) {
1438 if (action_id_get_actor_kind(act) == AAK_UNIT
1439 && action_id_get_target_kind(act) == ATK_CITY) {
1440 action_entry(shl, act, act_probs,
1441 get_act_sel_action_custom_text(action_by_number(act),
1442 act_probs[act],
1443 actor_unit,
1444 target_city),
1445 act);
1446 }
1447 } action_iterate_end;
1448
1449 /* Unit acting against another unit */
1450
1451 action_iterate(act) {
1452 if (action_id_get_actor_kind(act) == AAK_UNIT
1453 && action_id_get_target_kind(act) == ATK_UNIT) {
1454 action_entry(shl, act, act_probs,
1455 get_act_sel_action_custom_text(action_by_number(act),
1456 act_probs[act],
1457 actor_unit,
1458 target_city),
1459 act);
1460 }
1461 } action_iterate_end;
1462
1463 /* Unit acting against all units at a tile */
1464
1465 action_iterate(act) {
1466 if (action_id_get_actor_kind(act) == AAK_UNIT
1467 && action_id_get_target_kind(act) == ATK_UNITS) {
1468 action_entry(shl, act, act_probs,
1469 get_act_sel_action_custom_text(action_by_number(act),
1470 act_probs[act],
1471 actor_unit,
1472 target_city),
1473 act);
1474 }
1475 } action_iterate_end;
1476
1477 /* Unit acting against a tile */
1478
1479 action_iterate(act) {
1480 if (action_id_get_actor_kind(act) == AAK_UNIT
1481 && action_id_get_target_kind(act) == ATK_TILE) {
1482 action_entry(shl, act, act_probs,
1483 get_act_sel_action_custom_text(action_by_number(act),
1484 act_probs[act],
1485 actor_unit,
1486 target_city),
1487 act);
1488 }
1489 } action_iterate_end;
1490
1491 /* Unit acting against a tile's extras */
1492
1493 action_iterate(act) {
1494 if (action_id_get_actor_kind(act) == AAK_UNIT
1495 && action_id_get_target_kind(act) == ATK_EXTRAS) {
1496 action_entry(shl, act, act_probs,
1497 get_act_sel_action_custom_text(action_by_number(act),
1498 act_probs[act],
1499 actor_unit,
1500 target_city),
1501 act);
1502 }
1503 } action_iterate_end;
1504
1505 /* Unit acting against itself. */
1506
1507 action_iterate(act) {
1508 if (action_id_get_actor_kind(act) == AAK_UNIT
1509 && action_id_get_target_kind(act) == ATK_SELF) {
1510 action_entry(shl, act, act_probs,
1511 get_act_sel_action_custom_text(action_by_number(act),
1512 act_probs[act],
1513 actor_unit,
1514 target_city),
1515 act);
1516 }
1517 } action_iterate_end;
1518
1519 if (target_unit != NULL
1520 && unit_list_size(target_tile->units) > 1) {
1521 action_button_map[BUTTON_NEW_UNIT_TGT] =
1522 choice_dialog_get_number_of_buttons(shl);
1523 choice_dialog_add(shl, _("Change unit target"),
1524 (GCallback)act_sel_new_unit_tgt_callback,
1525 GINT_TO_POINTER(ACTION_NONE), TRUE, NULL);
1526 }
1527
1528 if (target_extra != NULL) {
1529 action_button_map[BUTTON_NEW_EXTRA_TGT] =
1530 choice_dialog_get_number_of_buttons(shl);
1531 choice_dialog_add(shl, _("Change extra target"),
1532 (GCallback)act_sel_new_extra_tgt_callback,
1533 GINT_TO_POINTER(ACTION_NONE), TRUE, NULL);
1534 }
1535
1536 action_button_map[BUTTON_LOCATION] =
1537 choice_dialog_get_number_of_buttons(shl);
1538 choice_dialog_add(shl, _("Show Location"),
1539 (GCallback)act_sel_location_callback,
1540 GINT_TO_POINTER(ACTION_NONE),
1541 TRUE, NULL);
1542
1543 action_button_map[BUTTON_WAIT] =
1544 choice_dialog_get_number_of_buttons(shl);
1545 choice_dialog_add(shl, _("_Wait"),
1546 (GCallback)act_sel_wait_callback,
1547 GINT_TO_POINTER(ACTION_NONE),
1548 TRUE, NULL);
1549
1550 action_button_map[BUTTON_CANCEL] =
1551 choice_dialog_get_number_of_buttons(shl);
1552 choice_dialog_add(shl, _("_Cancel"),
1553 (GCallback)act_sel_cancel_callback,
1554 GINT_TO_POINTER(ACTION_NONE),
1555 FALSE, NULL);
1556
1557 choice_dialog_end(shl);
1558
1559 act_sel_dialog = shl;
1560
1561 choice_dialog_set_hide(shl, TRUE);
1562 g_signal_connect(shl, "destroy",
1563 G_CALLBACK(act_sel_destroy_callback), NULL);
1564 g_signal_connect(shl, "delete_event",
1565 G_CALLBACK(act_sel_close_callback),
1566 GINT_TO_POINTER(ACTION_NONE));
1567
1568 /* Give follow up questions access to action probabilities. */
1569 client_unit_init_act_prob_cache(actor_unit);
1570 action_iterate(act) {
1571 actor_unit->client.act_prob_cache[act] = act_probs[act];
1572 } action_iterate_end;
1573
1574 astr_free(&title);
1575 astr_free(&text);
1576}
1577
1578/**********************************************************************/
1583 int action_selection_actor_unit(void)
1584{
1585 if (act_sel_dialog == NULL) {
1586 return IDENTITY_NUMBER_ZERO;
1587 }
1588 return actor_unit_id;
1589}
1590
1591/**********************************************************************/
1597 int action_selection_target_city(void)
1598{
1599 if (act_sel_dialog == NULL) {
1600 return IDENTITY_NUMBER_ZERO;
1601 }
1602 return target_ids[ATK_CITY];
1603}
1604
1605/**********************************************************************/
1611 int action_selection_target_unit(void)
1612{
1613 if (act_sel_dialog == NULL) {
1614 return IDENTITY_NUMBER_ZERO;
1615 }
1616
1617 return target_ids[ATK_UNIT];
1618}
1619
1620/**********************************************************************/
1626 int action_selection_target_tile(void)
1627{
1628 if (act_sel_dialog == NULL) {
1629 return TILE_INDEX_NONE;
1630 }
1631
1632 return target_ids[ATK_TILE];
1633}
1634
1635/**********************************************************************/
1641 int action_selection_target_extra(void)
1642{
1643 if (act_sel_dialog == NULL) {
1644 return EXTRA_NONE;
1645 }
1646
1647 return target_extra_id;
1648}
1649
1650/**********************************************************************/
1653 void action_selection_refresh(struct unit *actor_unit,
1654 struct city *target_city,
1655 struct unit *target_unit,
1656 struct tile *target_tile,
1657 struct extra_type *target_extra,
1658 const struct act_prob *act_probs)
1659{
1660 if (act_sel_dialog == NULL) {
1661 fc_assert_msg(act_sel_dialog != NULL,
1662 "The action selection dialog should have been open");
1663 return;
1664 }
1665
1666 if (actor_unit->id != action_selection_actor_unit()) {
1667 fc_assert_msg(actor_unit->id == action_selection_actor_unit(),
1668 "The action selection dialog is for another actor unit.");
1669 return;
1670 }
1671
1672 /* A new target may have appeared. */
1673 if (target_city) {
1674 act_sel_dialog_data->target_city_id = target_city->id;
1675 }
1676 if (target_unit) {
1677 act_sel_dialog_data->target_unit_id = target_unit->id;
1678 }
1679 if (target_tile) {
1680 act_sel_dialog_data->target_tile_id = target_tile->index;
1681 }
1682 /* No target_building or target_tech supplied. (Dec 2019) */
1683 if (target_extra) {
1684 act_sel_dialog_data->target_extra_id = target_extra->id;
1685 }
1686
1687 action_iterate(act) {
1688 const char *custom;
1689
1690 if (action_id_get_actor_kind(act) != AAK_UNIT) {
1691 /* Not relevant. */
1692 continue;
1693 }
1694
1695 custom = get_act_sel_action_custom_text(action_by_number(act),
1696 act_probs[act],
1697 actor_unit,
1698 target_city);
1699
1700 if (BUTTON_NOT_THERE == action_button_map[act]) {
1701 /* Add the button (unless its probability is 0). */
1702 action_entry(act_sel_dialog, act, act_probs, custom, act);
1703 } else {
1704 /* Update the existing button. */
1705 action_entry_update(act_sel_dialog, act, act_probs, custom, act);
1706 }
1707 } action_iterate_end;
1708
1709 /* DO NOT change the action_button_map[] for any button to reflect its
1710 * new position. A button keeps its choice dialog internal name when its
1711 * position changes. A button's id number is therefore based on when
1712 * it was added, not on its current position. */
1713
1714 if (BUTTON_NOT_THERE != action_button_map[BUTTON_WAIT]) {
1715 /* Move the wait button below the recently added button. */
1716 choice_dialog_button_move_to_the_end(act_sel_dialog,
1717 action_button_map[BUTTON_WAIT]);
1718 }
1719
1720 if (BUTTON_NOT_THERE != action_button_map[BUTTON_CANCEL]) {
1721 /* Move the cancel button below the recently added button. */
1722 choice_dialog_button_move_to_the_end(act_sel_dialog,
1723 action_button_map[BUTTON_CANCEL]);
1724 }
1725
1726 choice_dialog_end(act_sel_dialog);
1727}
1728
1729/**********************************************************************/
1732 void action_selection_close(void)
1733{
1734 if (act_sel_dialog != NULL) {
1735 did_not_decide = TRUE;
1736 gtk_widget_destroy(act_sel_dialog);
1737 }
1738}
action_prepare_ui_name
const char * action_prepare_ui_name(action_id act_id, const char *mnemonic, const struct act_prob prob, const char *custom)
Definition actions.c:1287
action_get_actor_kind
enum action_actor_kind action_get_actor_kind(const struct action *paction)
Definition actions.c:1073
action_prob_possible
bool action_prob_possible(const struct act_prob probability)
Definition actions.c:5044
action_get_sub_target_kind
enum action_sub_target_kind action_get_sub_target_kind(const struct action *paction)
Definition actions.c:1094
action_get_target_kind
enum action_target_kind action_get_target_kind(const struct action *paction)
Definition actions.c:1083
actions.h
action_by_number
static struct action * action_by_number(action_id act_id)
Definition actions.h:390
action_iterate_end
#define action_iterate_end
Definition actions.h:209
action_id_get_actor_kind
#define action_id_get_actor_kind(act_id)
Definition actions.h:403
action_iterate
#define action_iterate(_act_)
Definition actions.h:205
ACTION_ANY
#define ACTION_ANY
Definition actions.h:52
action_id_get_target_kind
#define action_id_get_target_kind(act_id)
Definition actions.h:407
ACTION_NONE
#define ACTION_NONE
Definition actions.h:55
astr_free
void astr_free(struct astring *astr)
Definition astring.c:148
astr_set
void astr_set(struct astring *astr, const char *format,...)
Definition astring.c:251
str
#define str
Definition astring.c:76
astring.h
astr_str
static const char * astr_str(const struct astring *astr) fc__attribute((nonnull(1)))
Definition astring.h:93
ASTRING_INIT
#define ASTRING_INIT
Definition astring.h:44
BV_SET
#define BV_SET(bv, bit)
Definition bitvector.h:81
BV_ISSET
#define BV_ISSET(bv, bit)
Definition bitvector.h:78
BV_CLR
#define BV_CLR(bv, bit)
Definition bitvector.h:86
city_improvement_name_translation
const char * city_improvement_name_translation(const struct city *pcity, const struct impr_type *pimprove)
Definition city.c:663
city_name_get
const char * city_name_get(const struct city *pcity)
Definition city.c:1133
INCITE_IMPOSSIBLE_COST
#define INCITE_IMPOSSIBLE_COST
Definition city.h:96
city_owner
#define city_owner(_pcity_)
Definition city.h:563
city_built_iterate
#define city_built_iterate(_pcity, _p)
Definition city.h:825
city_built_iterate_end
#define city_built_iterate_end
Definition city.h:831
client
struct civclient client
Definition client_main.c:153
client_main.h
client_player
#define client_player()
Definition client_main.h:106
client_unit_init_act_prob_cache
void client_unit_init_act_prob_cache(struct unit *punit)
Definition climisc.c:1248
climisc.h
incite_cost
char * incite_cost
Definition comments.c:74
connectdlg_common.h
action_selection_no_longer_in_progress
void action_selection_no_longer_in_progress(const int old_actor_id)
Definition control.c:1033
request_do_action
void request_do_action(action_id action, int actor_id, int target_id, int sub_tgt, const char *name)
Definition control.c:1704
request_action_details
void request_action_details(action_id action, int actor_id, int target_id)
Definition control.c:1772
action_decision_clear_want
void action_decision_clear_want(const int old_actor_id)
Definition control.c:1054
key_unit_wait
void key_unit_wait(void)
Definition control.c:3515
action_selection_next_in_focus
void action_selection_next_in_focus(const int old_actor_id)
Definition control.c:1066
control.h
dialogs_g.h
target_unit
struct unit struct city struct unit * target_unit
Definition dialogs_g.h:56
popup_action_selection
popup_action_selection
Definition dialogs_g.h:55
actor_unit
struct unit * actor_unit
Definition dialogs_g.h:55
popup_bribe_dialog
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id popup_bribe_dialog
Definition dialogs_g.h:73
actor
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit * actor
Definition dialogs_g.h:73
action_selection_no_longer_in_progress_gui_specific
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs action_selection_no_longer_in_progress_gui_specific
Definition dialogs_g.h:69
target_tile
struct unit struct city struct unit struct tile * target_tile
Definition dialogs_g.h:57
punit
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit * punit
Definition dialogs_g.h:74
target_city
struct unit struct city * target_city
Definition dialogs_g.h:56
cost
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit int cost
Definition dialogs_g.h:74
target_extra
struct unit struct city struct unit struct tile struct extra_type * target_extra
Definition dialogs_g.h:57
extra_number
int extra_number(const struct extra_type *pextra)
Definition extras.c:161
extra_by_number
struct extra_type * extra_by_number(int id)
Definition extras.c:183
EXTRA_NONE
#define EXTRA_NONE
Definition extras.h:85
extra_type_re_active_iterate_end
#define extra_type_re_active_iterate_end
Definition extras.h:329
extra_type_re_active_iterate
#define extra_type_re_active_iterate(_p)
Definition extras.h:325
NO_TARGET
#define NO_TARGET
Definition fc_types.h:358
action_id
int action_id
Definition fc_types.h:393
IDENTITY_NUMBER_ZERO
#define IDENTITY_NUMBER_ZERO
Definition fc_types.h:92
PL_
#define PL_(String1, String2, n)
Definition fcintl.h:71
_
#define _(String)
Definition fcintl.h:67
game
struct civ_game game
Definition game.c:61
wld
struct world wld
Definition game.c:62
game_unit_by_number
struct unit * game_unit_by_number(int id)
Definition game.c:115
game_city_by_number
struct city * game_city_by_number(int id)
Definition game.c:106
game.h
spy_sabotage_shell
static GtkWidget * spy_sabotage_shell
Definition action_dialog.c:77
action_selection_target_extra
int action_selection_target_extra(void)
Definition action_dialog.c:1641
incite_response
static void incite_response(GtkWidget *w, gint response, gpointer data)
Definition action_dialog.c:947
action_button_map
static int action_button_map[BUTTON_COUNT]
Definition action_dialog.c:66
spy_improvements_callback
static void spy_improvements_callback(GtkTreeSelection *select, gpointer data)
Definition action_dialog.c:737
actor_unit_id
static int actor_unit_id
Definition action_dialog.c:68
BUTTON_NEW_EXTRA_TGT
#define BUTTON_NEW_EXTRA_TGT
Definition action_dialog.c:56
act_sel_new_extra_tgt_callback
static void act_sel_new_extra_tgt_callback(GtkWidget *w, gpointer data)
Definition action_dialog.c:1127
action_selection_target_tile
int action_selection_target_tile(void)
Definition action_dialog.c:1626
create_improvements_list
static void create_improvements_list(struct player *pplayer, struct city *pcity, struct action_data *args)
Definition action_dialog.c:760
act_sel_destroy_callback
static void act_sel_destroy_callback(GtkWidget *w, gpointer data)
Definition action_dialog.c:1211
action_selection_actor_unit
int action_selection_actor_unit(void)
Definition action_dialog.c:1583
spy_advances_response
static void spy_advances_response(GtkWidget *w, gint response, gpointer data)
Definition action_dialog.c:516
tgt_extra_change_callback
static void tgt_extra_change_callback(GtkWidget *dlg, gint arg)
Definition action_dialog.c:1084
act_sel_dialog
static GtkWidget * act_sel_dialog
Definition action_dialog.c:65
spy_steal_popup_shared
static void spy_steal_popup_shared(GtkWidget *w, gpointer data)
Definition action_dialog.c:875
diplomat_queue_handle_primary
static void diplomat_queue_handle_primary(void)
Definition action_dialog.c:126
action_selection_close
void action_selection_close(void)
Definition action_dialog.c:1732
spy_improvements_response
static void spy_improvements_response(GtkWidget *w, gint response, gpointer data)
Definition action_dialog.c:697
action_selection_target_city
int action_selection_target_city(void)
Definition action_dialog.c:1597
bribe_response
static void bribe_response(GtkWidget *w, gint response, gpointer data)
Definition action_dialog.c:458
BUTTON_WAIT
#define BUTTON_WAIT
Definition action_dialog.c:58
action_entry
static void action_entry(GtkWidget *shl, action_id act_id, const struct act_prob *act_probs, const char *custom, action_id act_num)
Definition action_dialog.c:1269
spy_steal_esc_popup
static void spy_steal_esc_popup(GtkWidget *w, gpointer data)
Definition action_dialog.c:921
spy_steal_popup
static void spy_steal_popup(GtkWidget *w, gpointer data)
Definition action_dialog.c:911
act_sel_close_callback
static void act_sel_close_callback(GtkWidget *w, gint response_id, gpointer data)
Definition action_dialog.c:1229
diplomat_queue_handle_secondary
static void diplomat_queue_handle_secondary(void)
Definition action_dialog.c:173
get_non_targeted_action_id
static action_id get_non_targeted_action_id(action_id tgt_action_id)
Definition action_dialog.c:196
request_action_details_callback
static void request_action_details_callback(GtkWidget *w, gpointer data)
Definition action_dialog.c:347
action_selection_restart
static bool action_selection_restart
Definition action_dialog.c:73
BUTTON_NEW_UNIT_TGT
#define BUTTON_NEW_UNIT_TGT
Definition action_dialog.c:55
BUTTON_COUNT
#define BUTTON_COUNT
Definition action_dialog.c:60
act_sel_dialog_data
static struct action_data * act_sel_dialog_data
Definition action_dialog.c:93
found_city_callback
static void found_city_callback(GtkWidget *w, gpointer data)
Definition action_dialog.c:421
act_sel_location_callback
static void act_sel_location_callback(GtkWidget *w, gpointer data)
Definition action_dialog.c:1182
action_selection_refresh
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 action_dialog.c:1653
act_data
static struct action_data * act_data(action_id act_id, int actor_id, int target_city_id, int target_unit_id, int target_tile_id, int target_building_id, int target_tech_id, int tgt_extra_id)
Definition action_dialog.c:99
simple_action_callback
static void simple_action_callback(GtkWidget *w, gpointer data)
Definition action_dialog.c:240
create_advances_list
static void create_advances_list(struct player *pplayer, struct player *pvictim, struct action_data *args)
Definition action_dialog.c:573
is_more_user_input_needed
static bool is_more_user_input_needed
Definition action_dialog.c:71
target_extra_id
static int target_extra_id
Definition action_dialog.c:70
act_sel_wait_callback
static void act_sel_wait_callback(GtkWidget *w, gpointer data)
Definition action_dialog.c:1196
act_sel_new_unit_tgt_callback
static void act_sel_new_unit_tgt_callback(GtkWidget *w, gpointer data)
Definition action_dialog.c:1056
tgt_unit_change_callback
static void tgt_unit_change_callback(GtkWidget *dlg, gint arg)
Definition action_dialog.c:1013
BUTTON_NOT_THERE
#define BUTTON_NOT_THERE
Definition action_dialog.c:62
get_production_targeted_action_id
static action_id get_production_targeted_action_id(action_id tgt_action_id)
Definition action_dialog.c:219
did_not_decide
static bool did_not_decide
Definition action_dialog.c:72
BUTTON_CANCEL
#define BUTTON_CANCEL
Definition action_dialog.c:59
popup_sabotage_dialog
void popup_sabotage_dialog(struct unit *actor, struct city *pcity, const struct action *paction)
Definition action_dialog.c:931
spy_tech_shell
static GtkWidget * spy_tech_shell
Definition action_dialog.c:75
target_ids
static int target_ids[ATK_COUNT]
Definition action_dialog.c:69
act_sel_cancel_callback
static void act_sel_cancel_callback(GtkWidget *w, gpointer data)
Definition action_dialog.c:1220
action_entry_update
static void action_entry_update(GtkWidget *shl, action_id act_id, const struct act_prob *act_probs, const char *custom, action_id act_num)
Definition action_dialog.c:1307
action_selection_target_unit
int action_selection_target_unit(void)
Definition action_dialog.c:1611
popup_incite_dialog
void popup_incite_dialog(struct unit *actor, struct city *pcity, int cost, const struct action *paction)
Definition action_dialog.c:966
af_map
static const GCallback af_map[ACTION_COUNT]
Definition action_dialog.c:1239
upgrade_callback
static void upgrade_callback(GtkWidget *w, gpointer data)
Definition action_dialog.c:435
spy_advances_callback
static void spy_advances_callback(GtkTreeSelection *select, gpointer data)
Definition action_dialog.c:549
BUTTON_LOCATION
#define BUTTON_LOCATION
Definition action_dialog.c:57
choice_dialog_start
GtkWidget * choice_dialog_start(GtkWindow *parent, const gchar *name, const gchar *text)
Definition choice_dialog.c:103
choice_dialog_end
void choice_dialog_end(GtkWidget *dshell)
Definition choice_dialog.c:194
choice_dialog_get_number_of_buttons
int choice_dialog_get_number_of_buttons(GtkWidget *cd)
Definition choice_dialog.c:38
choice_dialog_button_set_tooltip
void choice_dialog_button_set_tooltip(GtkWidget *cd, int number, const char *tool_tip)
Definition choice_dialog.c:81
choice_dialog_button_move_to_the_end
void choice_dialog_button_move_to_the_end(GtkWidget *cd, const int number)
Definition choice_dialog.c:91
choice_dialog_set_hide
void choice_dialog_set_hide(GtkWidget *dshell, gboolean setting)
Definition choice_dialog.c:207
choice_dialog_add
void choice_dialog_add(GtkWidget *dshell, const gchar *label, GCallback handler, gpointer data, bool meta, const gchar *tool_tip)
Definition choice_dialog.c:158
choice_dialog_button_set_label
void choice_dialog_button_set_label(GtkWidget *cd, int number, const char *label)
Definition choice_dialog.c:71
choice_dialog_button_set_sensitive
void choice_dialog_button_set_sensitive(GtkWidget *cd, int button, gboolean state)
Definition choice_dialog.c:62
popup_upgrade_dialog
void popup_upgrade_dialog(struct unit_list *punits)
Definition dialogs.c:1435
toplevel
GtkWidget * toplevel
Definition gui_main.c:125
gtk_tree_view_focus
void gtk_tree_view_focus(GtkTreeView *view)
Definition gui_stuff.c:236
setup_dialog
void setup_dialog(GtkWidget *shell, GtkWidget *parent)
Definition gui_stuff.c:287
shell
static struct gui_dialog * shell
Definition messagedlg.c:39
tooltip
const char * tooltip
Definition repodlgs.c:1315
title
const char * title
Definition repodlgs.c:1314
select_tgt_extra
bool select_tgt_extra(struct unit *actor, struct tile *ptile, bv_extras potential_tgt_extras, struct extra_type *suggested_tgt_extra, const gchar *dlg_title, const gchar *actor_label, const gchar *tgt_label, const gchar *do_label, GCallback do_callback)
Definition unitselextradlg.c:107
select_tgt_unit
bool select_tgt_unit(struct unit *actor, struct tile *ptile, struct unit_list *potential_tgt_units, struct unit *suggested_tgt_unit, const gchar *dlg_title, const gchar *actor_label, const gchar *tgt_label, const gchar *do_label, GCallback do_callback)
Definition unitselunitdlg.c:70
choice_dialog.h
gui_stuff.h
unitselextradlg.h
unitselunitdlg.h
chatline.h
citydlg.h
dialogs.h
gui_main.h
mapview.h
wldlg.h
improvement_by_number
struct impr_type * improvement_by_number(const Impr_type_id id)
Definition improvement.c:194
improvement_number
Impr_type_id improvement_number(const struct impr_type *pimprove)
Definition improvement.c:184
B_LAST
#define B_LAST
Definition improvement.h:42
fc_assert_msg
#define fc_assert_msg(condition, message,...)
Definition log.h:181
fc_assert
#define fc_assert(condition)
Definition log.h:176
fc_assert_action
#define fc_assert_action(condition, action)
Definition log.h:187
index_to_tile
struct tile * index_to_tile(const struct civ_map *imap, int mindex)
Definition map.c:462
center_tile_mapcanvas
void center_tile_mapcanvas(const struct tile *ptile)
Definition mapview_common.c:1237
FC_FREE
#define FC_FREE(ptr)
Definition mem.h:41
fc_malloc
#define fc_malloc(sz)
Definition mem.h:34
movement.h
nation_adjective_for_player
const char * nation_adjective_for_player(const struct player *pplayer)
Definition nation.c:169
REQEST_PLAYER_INITIATED
#define REQEST_PLAYER_INITIATED
Definition packets.h:63
dsend_packet_unit_get_actions
int dsend_packet_unit_get_actions(struct connection *pc, int actor_unit_id, int target_unit_id, int target_tile_id, int target_extra_id, int request_kind)
Definition packets_gen.c:38523
dsend_packet_city_name_suggestion_req
int dsend_packet_city_name_suggestion_req(struct connection *pc, int unit_id)
Definition packets_gen.c:23680
packhand.h
research_advance_name_translation
const char * research_advance_name_translation(const struct research *presearch, Tech_type_id tech)
Definition research.c:273
research_get
struct research * research_get(const struct player *pplayer)
Definition research.c:128
research_invention_state
enum tech_state research_invention_state(const struct research *presearch, Tech_type_id tech)
Definition research.c:619
research_invention_gettable
bool research_invention_gettable(const struct research *presearch, const Tech_type_id tech, bool allow_holes)
Definition research.c:693
research.h
ARRAY_SIZE
#define ARRAY_SIZE(x)
Definition shared.h:85
act_prob
Definition fc_types.h:1220
action_data
Definition action_dialog.c:81
action_data::actor_unit_id
int actor_unit_id
Definition action_dialog.c:83
action_data::target_building_id
int target_building_id
Definition action_dialog.c:87
action_data::target_tech_id
int target_tech_id
Definition action_dialog.c:88
action_data::act_id
action_id act_id
Definition action_dialog.c:82
action_data::target_unit_id
int target_unit_id
Definition action_dialog.c:85
action_data::target_city_id
int target_city_id
Definition action_dialog.c:84
action_data::target_tile_id
int target_tile_id
Definition action_dialog.c:86
action_data::target_extra_id
int target_extra_id
Definition action_dialog.c:89
action
Definition actions.h:106
astring
Definition astring.h:36
city
Definition city.h:320
city::id
int id
Definition city.h:326
civ_game::info
struct packet_game_info info
Definition game.h:89
civclient::conn
struct connection conn
Definition client_main.h:96
connection::playing
struct player * playing
Definition connection.h:151
extra_type
Definition extras.h:88
packet_game_info::tech_steal_allow_holes
bool tech_steal_allow_holes
Definition packets_gen.h:215
player
Definition player.h:249
research
Definition research.h:39
tile
Definition tile.h:50
tile::units
struct unit_list * units
Definition tile.h:58
unit
Definition unit.h:140
unit::client
struct unit::@81::@83 client
unit::id
int id
Definition unit.h:147
unit::index
int index
Definition unit.h:198
unit::act_prob_cache
struct act_prob * act_prob_cache
Definition unit.h:231
unit::homecity
int homecity
Definition unit.h:148
view
Definition mapview_common.h:36
world::map
struct civ_map map
Definition world_object.h:38
fc_snprintf
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:960
support.h
TRUE
#define TRUE
Definition support.h:46
FALSE
#define FALSE
Definition support.h:47
valid_advance_by_number
struct advance * valid_advance_by_number(const Tech_type_id id)
Definition tech.c:176
advance_index_iterate_end
#define advance_index_iterate_end
Definition tech.h:249
A_FIRST
#define A_FIRST
Definition tech.h:44
A_UNSET
#define A_UNSET
Definition tech.h:48
advance_index_iterate
#define advance_index_iterate(_start, _index)
Definition tech.h:245
get_act_sel_action_custom_text
const char * get_act_sel_action_custom_text(struct action *paction, const struct act_prob prob, const struct unit *actor_unit, const struct city *target_city)
Definition text.c:1723
act_sel_action_tool_tip
const char * act_sel_action_tool_tip(const struct action *paction, const struct act_prob prob)
Definition text.c:1802
text.h
tile_index
#define tile_index(_pt_)
Definition tile.h:89
tile_extras
static const bv_extras * tile_extras(const struct tile *ptile)
Definition tile.h:121
TILE_INDEX_NONE
#define TILE_INDEX_NONE
Definition tile.h:48
traderoutes.h
unit.h
unit_tile
#define unit_tile(_pu)
Definition unit.h:397
unit_owner
#define unit_owner(_pu)
Definition unit.h:396
unitlist.h
unit_type_get
const struct unit_type * unit_type_get(const struct unit *punit)
Definition unittype.c:123
utype_can_remove_extra
bool utype_can_remove_extra(const struct unit_type *putype, const struct extra_type *pextra)
Definition unittype.c:241
unit_name_translation
const char * unit_name_translation(const struct unit *punit)
Definition unittype.c:1569
utype_can_create_extra
bool utype_can_create_extra(const struct unit_type *putype, const struct extra_type *pextra)
Definition unittype.c:217