Freeciv-3.1
Loading...
Searching...
No Matches
action_dialog.c
Go to the documentation of this file.
1/***********************************************************************
2 Freeciv - Copyright (C) 1996-2006 - 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/* utility */
19#include "astring.h"
20#include "fcintl.h"
21#include "log.h"
22
23/* common */
24#include "actions.h"
25#include "game.h"
26#include "movement.h"
27#include "research.h"
28#include "traderoutes.h"
29#include "unitlist.h"
30
31/* client */
32#include "client_main.h"
33#include "climisc.h"
34#include "control.h"
35#include "text.h"
36
37/* client/gui-sdl2 */
38#include "citydlg.h"
39#include "colors.h"
40#include "dialogs.h"
41#include "graphics.h"
42#include "gui_id.h"
43#include "gui_tilespec.h"
44#include "mapview.h"
45#include "repodlgs.h"
46#include "themespec.h"
47#include "widget.h"
48
49#include "dialogs_g.h"
50
51typedef int (*act_func)(struct widget *);
52
60
67
68extern bool is_unit_move_blocked;
69
71void popdown_incite_dialog(void);
72void popdown_bribe_dialog(void);
73
74
75static struct diplomat_dialog *diplomat_dlg = NULL;
77static bool did_not_decide = FALSE;
78
79/**********************************************************************/
83{
85 /* The client isn't waiting for information for any unanswered follow
86 * up questions. */
87
88 struct unit *actor_unit;
89
91 /* The action selection dialog wasn't closed because the actor unit
92 * was lost. */
93
94 /* The probabilities didn't just disappear, right? */
97
99 }
100
101 /* The action selection process is over, at least for now. */
103
104 if (did_not_decide) {
105 /* The action selection dialog was closed but the player didn't
106 * decide what the unit should do. */
107
108 /* Reset so the next action selection dialog does the right thing. */
110 } else {
111 /* An action, or no action at all, was selected. */
114 }
115 }
116}
117
118/**********************************************************************/
122{
123 /* Stop blocking. */
126}
127
128/**********************************************************************/
135{
136 /* Stop assuming the answer to a follow up question will arrive. */
138}
139
140/**********************************************************************/
145{
146 /* Don't add an action mapping here unless the non targeted version is
147 * selectable in the targeted version's target selection dialog. */
148 switch ((enum gen_action)tgt_action_id) {
149 case ACTION_SPY_TARGETED_SABOTAGE_CITY:
150 return ACTION_SPY_SABOTAGE_CITY;
151 case ACTION_SPY_TARGETED_SABOTAGE_CITY_ESC:
152 return ACTION_SPY_SABOTAGE_CITY_ESC;
153 case ACTION_SPY_TARGETED_STEAL_TECH:
154 return ACTION_SPY_STEAL_TECH;
155 case ACTION_SPY_TARGETED_STEAL_TECH_ESC:
156 return ACTION_SPY_STEAL_TECH_ESC;
157 default:
158 /* No non targeted version found. */
159 return ACTION_NONE;
160 }
161}
162
163/**********************************************************************/
168{
169 /* Don't add an action mapping here unless the non targeted version is
170 * selectable in the targeted version's target selection dialog. */
171 switch ((enum gen_action)tgt_action_id) {
172 case ACTION_SPY_TARGETED_SABOTAGE_CITY:
173 return ACTION_SPY_SABOTAGE_CITY_PRODUCTION;
174 case ACTION_SPY_TARGETED_SABOTAGE_CITY_ESC:
175 return ACTION_SPY_SABOTAGE_CITY_PRODUCTION_ESC;
176 case ACTION_STRIKE_BUILDING:
177 return ACTION_STRIKE_PRODUCTION;
178 default:
179 /* No non targeted version found. */
180 return ACTION_NONE;
181 }
182}
183
184/**********************************************************************/
187static int diplomat_dlg_window_callback(struct widget *pwindow)
188{
191 }
192
193 return -1;
194}
195
196/**********************************************************************/
200static int spy_strike_bld_request(struct widget *pwidget)
201{
203 && NULL != game_city_by_number(
204 diplomat_dlg->target_ids[ATK_CITY])) {
205 request_action_details(ACTION_STRIKE_BUILDING,
207 diplomat_dlg->target_ids[ATK_CITY]);
210 } else {
212 }
213
214 return -1;
215}
216
217/**********************************************************************/
221static int spy_sabotage_request(struct widget *pwidget)
222{
224 && NULL != game_city_by_number(
225 diplomat_dlg->target_ids[ATK_CITY])) {
226 request_action_details(ACTION_SPY_TARGETED_SABOTAGE_CITY,
228 diplomat_dlg->target_ids[ATK_CITY]);
231 } else {
233 }
234
235 return -1;
236}
237
238/**********************************************************************/
243static int spy_sabotage_esc_request(struct widget *pwidget)
244{
246 && NULL != game_city_by_number(
247 diplomat_dlg->target_ids[ATK_CITY])) {
248 request_action_details(ACTION_SPY_TARGETED_SABOTAGE_CITY_ESC,
250 diplomat_dlg->target_ids[ATK_CITY]);
253 } else {
255 }
256
257 return -1;
258}
259
260/* --------------------------------------------------------- */
261
262/**********************************************************************/
265static int spy_steal_dlg_window_callback(struct widget *pwindow)
266{
269 }
270
271 return -1;
272}
273
274/**********************************************************************/
277static int exit_spy_tgt_dlg_callback(struct widget *pwidget)
278{
280 int actor_id = diplomat_dlg->actor_unit_id;
281
284 act_sel_done_secondary(actor_id);
285 }
286
287 return -1;
288}
289
290/**********************************************************************/
293static int spy_steal_callback(struct widget *pwidget)
294{
296 int steal_advance = MAX_ID - pwidget->id;
297 int actor_id = diplomat_dlg->actor_unit_id;
298
300 && NULL != game_city_by_number(
301 diplomat_dlg->target_ids[ATK_CITY])) {
302 if (steal_advance == A_UNSET) {
303 /* This is the untargeted version. */
307 diplomat_dlg->target_ids[ATK_CITY],
308 steal_advance, "");
309 } else {
310 /* This is the targeted version. */
313 diplomat_dlg->target_ids[ATK_CITY],
314 steal_advance, "");
315 }
316 }
317
320 act_sel_done_secondary(actor_id);
321 }
322
323 return -1;
324}
325
326/**********************************************************************/
329static int spy_steal_popup_shared(struct widget *pwidget)
330{
331 const struct research *presearch, *vresearch;
332 struct city *vcity = pwidget->data.city;
333 int id = diplomat_dlg->actor_unit_id;
334 struct player *victim = NULL;
335 struct container *cont;
336 struct widget *buf = NULL;
337 struct widget *pwindow;
338 utf8_str *pstr;
339 SDL_Surface *surf;
340 int max_col, max_row, col, count = 0;
341 int tech, idx;
343
344 struct unit *actor_unit = game_unit_by_number(id);
345 action_id act_id = diplomat_dlg->act_id;
346
349
350 if (vcity) {
351 victim = city_owner(vcity);
352 }
353
354 fc_assert_ret_val_msg(!diplomat_dlg, 1, "Diplomat dialog already open");
355
356 if (!victim) {
358 return 1;
359 }
360
361 count = 0;
362 presearch = research_get(client_player());
363 vresearch = research_get(victim);
365 if (research_invention_gettable(presearch, i,
367 && TECH_KNOWN == research_invention_state(vresearch, i)
368 && TECH_KNOWN != research_invention_state(presearch, i)) {
369 count++;
370 }
372
373 if (!count) {
374 /* if there is no known tech to steal then
375 * send steal order at Spy's Discretion */
376 int target_id = vcity->id;
377
379 id, target_id, A_UNSET, "");
380
382
383 return -1;
384 }
385
386 cont = fc_calloc(1, sizeof(struct container));
387 cont->id0 = vcity->id;
388 cont->id1 = id; /* spy id */
389
390 diplomat_dlg = fc_calloc(1, sizeof(struct diplomat_dialog));
391 diplomat_dlg->act_id = act_id;
393 diplomat_dlg->target_ids[ATK_CITY] = vcity->id;
394 diplomat_dlg->pdialog = fc_calloc(1, sizeof(struct advanced_dialog));
395
396 pstr = create_utf8_from_char_fonto(_("Select Advance to Steal"),
398 pstr->style |= TTF_STYLE_BOLD;
399
400 pwindow = create_window_skeleton(NULL, pstr, 0);
401
403 set_wstate(pwindow , FC_WS_NORMAL);
404
407
408 area = pwindow->area;
409 area.w = MAX(area.w, adj_size(8));
410
411 /* ------------------ */
412 /* Exit button */
413 buf = create_themeicon(current_theme->small_cancel_icon, pwindow->dst,
415 buf->info_label = create_utf8_from_char_fonto(_("Close Dialog (Esc)"),
417 area.w += buf->size.w + adj_size(10);
420 buf->key = SDLK_ESCAPE;
421
423 /* ------------------------- */
424
426 get_non_targeted_action_id(act_id)])) {
427 /* count + at Spy's Discretion */
428 count++;
429 }
430
431 /* max col - 104 is steal tech widget width */
432 max_col = (main_window_width() - (pwindow->size.w - pwindow->area.w) - adj_size(2)) / adj_size(104);
433 /* max row - 204 is steal tech widget height */
434 max_row = (main_window_height() - (pwindow->size.h - pwindow->area.h)) / adj_size(204);
435
436 /* make space on screen for scrollbar */
437 if (max_col * max_row < count) {
438 max_col--;
439 }
440
441 if (count < max_col + 1) {
442 col = count;
443 } else {
444 if (count < max_col + adj_size(3)) {
445 col = max_col - adj_size(2);
446 } else {
447 if (count < max_col + adj_size(5)) {
448 col = max_col - 1;
449 } else {
450 col = max_col;
451 }
452 }
453 }
454
455 pstr = create_utf8_str_fonto(NULL, 0, FONTO_DEFAULT);
456 pstr->style |= (TTF_STYLE_BOLD | SF_CENTER);
457
458 count = 0;
460 if (research_invention_gettable(presearch, i,
462 && TECH_KNOWN == research_invention_state(vresearch, i)
463 && TECH_KNOWN != research_invention_state(presearch, i)) {
464 count++;
465
467 surf = create_select_tech_icon(pstr, i, TIM_FULL_MODE);
468 buf = create_icon2(surf, pwindow->dst,
470
473 buf->data.cont = cont;
474
475 add_to_gui_list(MAX_ID - i, buf);
476
477 if (count > (col * max_row)) {
478 set_wflag(buf, WF_HIDDEN);
479 }
480 }
482
483 /* Get Spy tech to use for "At Spy's Discretion" -- this will have the
484 * side effect of displaying the unit's icon */
485 tech = advance_number(unit_type_get(actor_unit)->require_advance);
486
488 get_non_targeted_action_id(act_id)])) {
489 struct astring str = ASTRING_INIT;
490
491 /* TRANS: %s is a unit name, e.g., Spy */
492 astr_set(&str, _("At %s's Discretion"),
495 astr_free(&str);
496
497 surf = create_select_tech_icon(pstr, tech, TIM_FULL_MODE);
498
499 buf = create_icon2(surf, pwindow->dst,
501 | WF_FREE_DATA));
504 buf->data.cont = cont;
505
507 count++;
508 }
509
510 /* --------------------------------------------------------- */
511 FREEUTF8STR(pstr);
515
516 /* -------------------------------------------------------------- */
517
518 idx = 0;
519 if (count > col) {
520 count = (count + (col - 1)) / col;
521 if (count > max_row) {
523 count = max_row;
525 }
526 } else {
527 count = 1;
528 }
529
530 area.w = MAX(area.w, (col * buf->size.w + adj_size(2) + idx));
531 area.h = count * buf->size.h + adj_size(2);
532
533 /* alloca window theme and win background buffer */
535 if (resize_window(pwindow, surf, NULL,
536 (pwindow->size.w - pwindow->area.w) + area.w,
537 (pwindow->size.h - pwindow->area.h) + area.h)) {
538 FREESURFACE(surf);
539 }
540
541 area = pwindow->area;
542
543 widget_set_position(pwindow,
544 (main_window_width() - pwindow->size.w) / 2,
545 (main_window_height() - pwindow->size.h) / 2);
546
547 /* exit button */
548 buf = pwindow->prev;
549 buf->size.x = area.x + area.w - buf->size.w - 1;
550 buf->size.y = pwindow->size.y + adj_size(2);
551
552 setup_vertical_widgets_position(col, area.x + 1,
553 area.y, 0, 0,
556
559 area.x + area.w, area.y,
560 area.h, TRUE);
561 }
562
564 widget_mark_dirty(pwindow);
565
566 return -1;
567}
568
569/**********************************************************************/
572static int spy_steal_popup(struct widget *pwidget)
573{
574 diplomat_dlg->act_id = ACTION_SPY_TARGETED_STEAL_TECH;
575 return spy_steal_popup_shared(pwidget);
576}
577
578/**********************************************************************/
581static int spy_steal_esc_popup(struct widget *pwidget)
582{
583 diplomat_dlg->act_id = ACTION_SPY_TARGETED_STEAL_TECH_ESC;
584 return spy_steal_popup_shared(pwidget);
585}
586
587/**********************************************************************/
590static int diplomat_incite_callback(struct widget *pwidget)
591{
594 && NULL != game_city_by_number(
595 diplomat_dlg->target_ids[ATK_CITY])) {
596 request_action_details(ACTION_SPY_INCITE_CITY,
598 diplomat_dlg->target_ids[ATK_CITY]);
601 } else {
603 }
604 }
605
606 return -1;
607}
608
609/**********************************************************************/
612static int spy_incite_callback(struct widget *pwidget)
613{
616 && NULL != game_city_by_number(
617 diplomat_dlg->target_ids[ATK_CITY])) {
618 request_action_details(ACTION_SPY_INCITE_CITY_ESC,
620 diplomat_dlg->target_ids[ATK_CITY]);
623 } else {
625 }
626 }
627
628 return -1;
629}
630
631/**********************************************************************/
634static int act_sel_wait_callback(struct widget *pwidget)
635{
638
639 /* The dialog was popped down when key_unit_wait() resulted in
640 * action_selection_close() being called. */
641 }
642
643 return -1;
644}
645
646/**********************************************************************/
649static int diplomat_bribe_callback(struct widget *pwidget)
650{
653 && NULL !=
655 request_action_details(ACTION_SPY_BRIBE_UNIT,
657 diplomat_dlg->target_ids[ATK_UNIT]);
660 } else {
662 }
663 }
664
665 return -1;
666}
667
668/**********************************************************************/
671static int found_city_callback(struct widget *pwidget)
672{
674 int actor_id = diplomat_dlg->actor_unit_id;
675
678 actor_id, actor_id);
679 }
680
681 return -1;
682}
683
684/**********************************************************************/
687static int upgrade_callback(struct widget *pwidget)
688{
690 struct unit *punit;
691
692 if (game_city_by_number(diplomat_dlg->target_ids[ATK_CITY]) != NULL
695 }
696
698 }
699
700 return -1;
701}
702
703/**********************************************************************/
707static int simple_action_callback(struct widget *pwidget)
708{
709 int actor_id, target_id, sub_target;
710 struct action *paction;
711
712 bool failed = FALSE;
713
715 return -1;
716 }
717
718 /* Data */
719 paction = action_by_number(MAX_ID - pwidget->id);
720
721 /* Actor */
722 fc_assert(action_get_actor_kind(paction) == AAK_UNIT);
723 actor_id = diplomat_dlg->actor_unit_id;
724 if (NULL == game_unit_by_number(actor_id)) {
725 /* Probably dead. */
726 failed = TRUE;
727 }
728
729 /* Target */
730 target_id = IDENTITY_NUMBER_ZERO;
731 switch (action_get_target_kind(paction)) {
732 case ATK_CITY:
733 target_id = diplomat_dlg->target_ids[ATK_CITY];
734 if (NULL == game_city_by_number(target_id)) {
735 /* Probably destroyed. */
736 failed = TRUE;
737 }
738 break;
739 case ATK_UNIT:
740 target_id = diplomat_dlg->target_ids[ATK_UNIT];
741 if (NULL == game_unit_by_number(target_id)) {
742 /* Probably dead. */
743 failed = TRUE;
744 }
745 break;
746 case ATK_UNITS:
747 case ATK_TILE:
748 case ATK_EXTRAS:
749 target_id = diplomat_dlg->target_ids[ATK_TILE];
750 if (NULL == index_to_tile(&(wld.map), target_id)) {
751 /* TODO: Should this be possible at all? If not: add assertion. */
752 failed = TRUE;
753 }
754 break;
755 case ATK_SELF:
756 target_id = IDENTITY_NUMBER_ZERO;
757 break;
758 case ATK_COUNT:
759 fc_assert(action_get_target_kind(paction) != ATK_COUNT);
760 failed = TRUE;
761 }
762
763 /* Sub target. */
764 sub_target = NO_TARGET;
765 if (paction->target_complexity != ACT_TGT_COMPL_SIMPLE) {
766 switch (action_get_sub_target_kind(paction)) {
767 case ASTK_BUILDING:
768 sub_target = diplomat_dlg->sub_target_id[ASTK_BUILDING];
769 if (NULL == improvement_by_number(sub_target)) {
770 /* Did the ruleset change? */
771 failed = TRUE;
772 }
773 break;
774 case ASTK_TECH:
775 sub_target = diplomat_dlg->sub_target_id[ASTK_TECH];
776 if (NULL == valid_advance_by_number(sub_target)) {
777 /* Did the ruleset change? */
778 failed = TRUE;
779 }
780 break;
781 case ASTK_EXTRA:
782 case ASTK_EXTRA_NOT_THERE:
783 /* TODO: validate if the extra is there? */
784 sub_target = diplomat_dlg->sub_target_id[ASTK_EXTRA];
785 if (NULL == extra_by_number(sub_target)) {
786 /* Did the ruleset change? */
787 failed = TRUE;
788 }
789 break;
790 case ASTK_NONE:
791 case ASTK_COUNT:
792 /* Shouldn't happen. */
793 fc_assert(action_get_sub_target_kind(paction) != ASTK_NONE);
794 failed = TRUE;
795 break;
796 }
797 }
798
799 /* Send request. */
800 if (!failed) {
801 request_do_action(paction->id, actor_id, target_id, sub_target, "");
802 }
803
804 /* Clean up. */
806 return -1;
807}
808
809/**********************************************************************/
812static int diplomat_close_callback(struct widget *pwidget)
813{
816 }
817
818 return -1;
819}
820
821/**********************************************************************/
839
840/* Mapping from an action to the function to call when its button is
841 * pushed. */
842static const act_func af_map[ACTION_COUNT] = {
843 /* Unit acting against a city target. */
844 [ACTION_SPY_TARGETED_SABOTAGE_CITY] = spy_sabotage_request,
845 [ACTION_SPY_TARGETED_SABOTAGE_CITY_ESC] = spy_sabotage_esc_request,
846 [ACTION_SPY_TARGETED_STEAL_TECH] = spy_steal_popup,
847 [ACTION_SPY_TARGETED_STEAL_TECH_ESC] = spy_steal_esc_popup,
848 [ACTION_SPY_INCITE_CITY] = diplomat_incite_callback,
849 [ACTION_SPY_INCITE_CITY_ESC] = spy_incite_callback,
850 [ACTION_UPGRADE_UNIT] = upgrade_callback,
851 [ACTION_STRIKE_BUILDING] = spy_strike_bld_request,
852
853 /* Unit acting against a unit target. */
854 [ACTION_SPY_BRIBE_UNIT] = diplomat_bribe_callback,
855
856 /* Unit acting against all units at a tile. */
857 /* No special callback functions needed for any unit stack targeted
858 * actions. */
859
860 /* Unit acting against a tile. */
861 [ACTION_FOUND_CITY] = found_city_callback,
862
863 /* Unit acting with no target except itself. */
864 /* No special callback functions needed for any self targeted actions. */
865};
866
867/**********************************************************************/
870static void action_entry(const action_id act,
871 const struct act_prob *act_probs,
872 struct unit *act_unit,
873 struct tile *tgt_tile,
874 struct city *tgt_city,
875 struct unit *tgt_unit,
876 struct widget *pwindow,
877 SDL_Rect *area)
878{
879 struct widget *buf;
880 utf8_str *pstr;
881 const char *ui_name;
882 act_func cb;
883
885 act_probs[act],
886 act_unit,
887 tgt_city);
888
889 if (af_map[act] == NULL) {
890 /* No special call back function needed for this action. */
892 } else {
893 /* Special action specific callback function specified. */
894 cb = af_map[act];
895 }
896
897 /* Don't show disabled actions */
898 if (!action_prob_possible(act_probs[act])) {
899 return;
900 }
901
902 ui_name = action_prepare_ui_name(act, "",
903 act_probs[act], custom);
904
906 ui_name, cb);
907
908 switch (action_id_get_target_kind(act)) {
909 case ATK_CITY:
910 buf->data.city = tgt_city;
911 break;
912 case ATK_UNIT:
913 buf->data.unit = tgt_unit;
914 break;
915 case ATK_TILE:
916 case ATK_EXTRAS:
917 case ATK_UNITS:
918 buf->data.tile = tgt_tile;
919 break;
920 case ATK_SELF:
921 buf->data.unit = act_unit;
922 break;
923 case ATK_COUNT:
924 fc_assert_msg(FALSE, "Unsupported target kind");
925 }
926
928
929 add_to_gui_list(MAX_ID - act, buf);
930
931 area->w = MAX(area->w, buf->size.w);
932 area->h += buf->size.h;
933}
934
935/**********************************************************************/
940 struct city *target_city,
941 struct unit *target_unit,
942 struct tile *target_tile,
943 struct extra_type *target_extra,
944 const struct act_prob *act_probs)
945{
946 struct widget *pwindow = NULL, *buf = NULL;
947 utf8_str *pstr;
949
950 fc_assert_ret_msg(!diplomat_dlg, "Diplomat dialog already open");
951
952 /* Could be caused by the server failing to reply to a request for more
953 * information or a bug in the client code. */
955 "Diplomat queue problem. Is another diplomat window open?");
956
957 /* No extra input is required as no action has been chosen yet. */
959
961
962 diplomat_dlg = fc_calloc(1, sizeof(struct diplomat_dialog));
964 diplomat_dlg->pdialog = fc_calloc(1, sizeof(struct advanced_dialog));
965
966 /* window */
967 if (target_city) {
968 struct astring title = ASTRING_INIT;
969
970 /* TRANS: %s is a unit name, e.g., Spy */
971 astr_set(&title, _("Choose Your %s's Strategy"),
975 } else {
976 pstr = create_utf8_from_char_fonto(_("Subvert Enemy Unit"),
978 }
979
980 pstr->style |= TTF_STYLE_BOLD;
981
982 pwindow = create_window_skeleton(NULL, pstr, 0);
983
985 set_wstate(pwindow, FC_WS_NORMAL);
986
989
990 area = pwindow->area;
991 area.w = MAX(area.w, adj_size(8));
992 area.h = MAX(area.h, adj_size(2));
993
994 if (target_city) {
996 } else {
998 }
999
1000 if (target_unit) {
1001 diplomat_dlg->target_ids[ATK_UNIT] = target_unit->id;
1002 } else {
1004 }
1005
1009
1010 /* No target building or target tech supplied. (Feb 2020) */
1011 diplomat_dlg->sub_target_id[ASTK_BUILDING] = B_LAST;
1012 diplomat_dlg->sub_target_id[ASTK_TECH] = A_UNSET;
1013
1014 if (target_extra) {
1016 diplomat_dlg->sub_target_id[ASTK_EXTRA_NOT_THERE]
1018 } else {
1019 diplomat_dlg->sub_target_id[ASTK_EXTRA] = EXTRA_NONE;
1020 diplomat_dlg->sub_target_id[ASTK_EXTRA_NOT_THERE] = EXTRA_NONE;
1021 }
1022
1023 diplomat_dlg->target_ids[ATK_SELF] = actor_unit->id;
1024
1025 /* ---------- */
1026 /* Unit acting against a city */
1027
1028 action_iterate(act) {
1029 if (action_id_get_actor_kind(act) == AAK_UNIT
1030 && action_id_get_target_kind(act) == ATK_CITY) {
1031 action_entry(act, act_probs,
1032 actor_unit, NULL, target_city, NULL,
1033 pwindow, &area);
1034 }
1036
1037 /* Unit acting against another unit */
1038
1039 action_iterate(act) {
1040 if (action_id_get_actor_kind(act) == AAK_UNIT
1041 && action_id_get_target_kind(act) == ATK_UNIT) {
1042 action_entry(act, act_probs,
1043 actor_unit, NULL, NULL, target_unit,
1044 pwindow, &area);
1045 }
1047
1048 /* Unit acting against all units at a tile */
1049
1050 action_iterate(act) {
1051 if (action_id_get_actor_kind(act) == AAK_UNIT
1052 && action_id_get_target_kind(act) == ATK_UNITS) {
1053 action_entry(act, act_probs,
1054 actor_unit, target_tile, NULL, NULL,
1055 pwindow, &area);
1056 }
1058
1059 /* Unit acting against a tile. */
1060
1061 action_iterate(act) {
1062 if (action_id_get_actor_kind(act) == AAK_UNIT
1063 && action_id_get_target_kind(act) == ATK_TILE) {
1064 action_entry(act, act_probs,
1065 actor_unit, target_tile, NULL, NULL,
1066 pwindow, &area);
1067 }
1069
1070 /* Unit acting against a tile's extras. */
1071
1072 action_iterate(act) {
1073 if (action_id_get_actor_kind(act) == AAK_UNIT
1074 && action_id_get_target_kind(act) == ATK_EXTRAS) {
1075 action_entry(act, act_probs,
1076 actor_unit, target_tile, NULL, NULL,
1077 pwindow, &area);
1078 }
1080
1081 /* Unit acting against itself. */
1082
1083 action_iterate(act) {
1084 if (action_id_get_actor_kind(act) == AAK_UNIT
1085 && action_id_get_target_kind(act) == ATK_SELF) {
1086 action_entry(act, act_probs,
1087 actor_unit, NULL, NULL, target_unit,
1088 pwindow, &area);
1089 }
1091
1092 /* ---------- */
1093 create_active_iconlabel(buf, pwindow->dst, pstr,
1094 _("Wait"), act_sel_wait_callback);
1095
1096 buf->data.tile = target_tile;
1097
1099
1101
1102 area.w = MAX(area.w, buf->size.w);
1103 area.h += buf->size.h;
1104
1105 /* ---------- */
1106 create_active_iconlabel(buf, pwindow->dst, pstr,
1107 _("Cancel"), diplomat_close_callback);
1108
1109 set_wstate(buf , FC_WS_NORMAL);
1110 buf->key = SDLK_ESCAPE;
1111
1113
1114 area.w = MAX(area.w, buf->size.w);
1115 area.h += buf->size.h;
1116 /* ---------- */
1118
1119 /* setup window size and start position */
1120
1121 resize_window(pwindow, NULL, NULL,
1122 (pwindow->size.w - pwindow->area.w) + area.w,
1123 (pwindow->size.h - pwindow->area.h) + area.h);
1124
1125 area = pwindow->area;
1126
1128 put_window_near_map_tile(pwindow, pwindow->size.w, pwindow->size.h,
1130
1131 /* setup widget size and start position */
1132
1133 buf = pwindow->prev;
1135 area.x,
1136 area.y + 1, area.w, 0,
1138
1139 /* --------------------- */
1140 /* redraw */
1142
1143 widget_flush(pwindow);
1144
1145 /* Give follow up questions access to action probabilities. */
1147 action_iterate(act) {
1148 actor_unit->client.act_prob_cache[act] = act_probs[act];
1150}
1151
1152/**********************************************************************/
1158{
1159 if (!diplomat_dlg) {
1160 return IDENTITY_NUMBER_ZERO;
1161 }
1162
1164}
1165
1166/**********************************************************************/
1173{
1174 if (!diplomat_dlg) {
1175 return IDENTITY_NUMBER_ZERO;
1176 }
1177
1178 return diplomat_dlg->target_ids[ATK_CITY];
1179}
1180
1181/**********************************************************************/
1188{
1189 if (!diplomat_dlg) {
1190 return IDENTITY_NUMBER_ZERO;
1191 }
1192
1193 return diplomat_dlg->target_ids[ATK_UNIT];
1194}
1195
1196/**********************************************************************/
1203{
1204 if (!diplomat_dlg) {
1205 return TILE_INDEX_NONE;
1206 }
1207
1208 return diplomat_dlg->target_ids[ATK_TILE];
1209}
1210
1211/**********************************************************************/
1218{
1219 if (!diplomat_dlg) {
1220 return EXTRA_NONE;
1221 }
1222
1223 return diplomat_dlg->sub_target_id[ASTK_EXTRA];
1224}
1225
1226/**********************************************************************/
1230 struct city *target_city,
1231 struct unit *target_unit,
1232 struct tile *target_tile,
1233 struct extra_type *target_extra,
1234 const struct act_prob *act_probs)
1235{
1240 act_probs);
1241}
1242
1243/**********************************************************************/
1251
1252/* ====================================================================== */
1253/* ============================ SABOTAGE DIALOG ========================= */
1254/* ====================================================================== */
1255
1256/**********************************************************************/
1259static int sabotage_impr_callback(struct widget *pwidget)
1260{
1262 int sabotage_improvement = MAX_ID - pwidget->id;
1263 int diplomat_target_id = pwidget->data.cont->id0;
1264 int diplomat_id = pwidget->data.cont->id1;
1265 action_id act_id = pwidget->data.cont->value;
1266
1269
1270 if (sabotage_improvement == 1000) {
1271 sabotage_improvement = -1;
1272 }
1273
1274 if (NULL != game_unit_by_number(diplomat_id)
1275 && NULL != game_city_by_number(diplomat_target_id)) {
1276 if (sabotage_improvement == B_LAST) {
1277 /* This is the untargeted version. */
1279 diplomat_id, diplomat_target_id,
1280 sabotage_improvement, "");
1281 } else if (sabotage_improvement == -1) {
1282 /* This is the city production version. */
1284 diplomat_id, diplomat_target_id,
1285 sabotage_improvement, "");
1286 } else {
1287 /* This is the targeted version. */
1288 request_do_action(act_id,
1289 diplomat_id, diplomat_target_id,
1290 sabotage_improvement, "");
1291 }
1292 }
1293
1294 act_sel_done_secondary(diplomat_id);
1295 }
1296
1297 return -1;
1298}
1299
1300/**********************************************************************/
1304void popup_sabotage_dialog(struct unit *actor, struct city *pcity,
1305 const struct action *paction)
1306{
1307 struct widget *pwindow = NULL, *buf = NULL , *last = NULL;
1308 struct container *cont;
1309 utf8_str *pstr;
1310 SDL_Rect area, area2;
1311 int n, w = 0, h, imp_h = 0, y;
1312
1313 fc_assert_ret_msg(!diplomat_dlg, "Diplomat dialog already open");
1314
1315 /* Should be set before sending request to the server. */
1317
1318 if (!actor) {
1320 return;
1321 }
1322
1324
1325 diplomat_dlg = fc_calloc(1, sizeof(struct diplomat_dialog));
1327 diplomat_dlg->target_ids[ATK_CITY] = pcity->id;
1328 diplomat_dlg->pdialog = fc_calloc(1, sizeof(struct advanced_dialog));
1329
1330 cont = fc_calloc(1, sizeof(struct container));
1331 cont->id0 = pcity->id;
1332 cont->id1 = actor->id; /* Spy id */
1333 cont->value = paction->id;
1334
1335 pstr = create_utf8_from_char_fonto(_("Select Improvement to Sabotage"),
1337 pstr->style |= TTF_STYLE_BOLD;
1338
1339 pwindow = create_window_skeleton(NULL, pstr, 0);
1340
1342 set_wstate(pwindow, FC_WS_NORMAL);
1343
1346
1347 area = pwindow->area;
1348 area.h = MAX(area.h, adj_size(2));
1349
1350 /* ---------- */
1351 /* Exit button */
1352 buf = create_themeicon(current_theme->small_cancel_icon, pwindow->dst,
1354 buf->info_label = create_utf8_from_char_fonto(_("Close Dialog (Esc)"),
1356 area.w += buf->size.w + adj_size(10);
1357 buf->action = exit_spy_tgt_dlg_callback;
1359 buf->key = SDLK_ESCAPE;
1360
1362 /* ---------- */
1363
1366 paction->id)])) {
1367 create_active_iconlabel(buf, pwindow->dst, pstr,
1368 _("City Production"), sabotage_impr_callback);
1369 buf->data.cont = cont;
1371 set_wflag(buf, WF_FREE_DATA);
1372 add_to_gui_list(MAX_ID - 1000, buf);
1373
1374 area.w = MAX(area.w, buf->size.w);
1375 area.h += buf->size.h;
1376
1377 /* separator */
1378 buf = create_iconlabel(NULL, pwindow->dst, NULL, WF_FREE_THEME);
1379
1381 area.h += buf->next->size.h;
1382
1384 }
1385
1386 /* ------------------ */
1387 n = 0;
1388 city_built_iterate(pcity, pimprove) {
1389 if (pimprove->sabotage > 0) {
1390 create_active_iconlabel(buf, pwindow->dst, pstr,
1391 (char *) city_improvement_name_translation(pcity, pimprove),
1393 buf->data.cont = cont;
1395
1396 add_to_gui_list(MAX_ID - improvement_number(pimprove), buf);
1397
1398 area.w = MAX(area.w , buf->size.w);
1399 imp_h += buf->size.h;
1400
1401 if (n > 9) {
1402 set_wflag(buf, WF_HIDDEN);
1403 }
1404
1405 n++;
1406 /* ----------- */
1407 }
1409
1411
1412 if (n > 0
1414 get_non_targeted_action_id(paction->id)])) {
1415 /* separator */
1416 buf = create_iconlabel(NULL, pwindow->dst, NULL, WF_FREE_THEME);
1417
1419 area.h += buf->next->size.h;
1420 /* ------------------ */
1421 }
1422
1424 get_non_targeted_action_id(paction->id)])) {
1425 struct astring str = ASTRING_INIT;
1426
1427 /* TRANS: %s is a unit name, e.g., Spy */
1428 astr_set(&str, _("At %s's Discretion"), unit_name_translation(actor));
1429 create_active_iconlabel(buf, pwindow->dst, pstr, astr_str(&str),
1431 astr_free(&str);
1432
1433 buf->data.cont = cont;
1435
1437
1438 area.w = MAX(area.w, buf->size.w);
1439 area.h += buf->size.h;
1440 }
1441
1442 /* ----------- */
1443
1444 last = buf;
1447
1448 /* ---------- */
1449 if (n > 10) {
1450 imp_h = 10 * buf->size.h;
1451
1453 1, 10, TRUE, TRUE);
1454 area.w += n;
1455 } else {
1456 n = 0;
1457 }
1458 /* ---------- */
1459
1460 area.h += imp_h;
1461
1462 resize_window(pwindow, NULL, NULL,
1463 (pwindow->size.w - pwindow->area.w) + area.w,
1464 (pwindow->size.h - pwindow->area.h) + area.h);
1465
1466 area = pwindow->area;
1467
1469 put_window_near_map_tile(pwindow, pwindow->size.w, pwindow->size.h,
1470 unit_tile(actor));
1471
1472 w = area.w;
1473
1474 /* exit button */
1475 buf = pwindow->prev;
1476 buf->size.x = area.x + area.w - buf->size.w - 1;
1477 buf->size.y = pwindow->size.y + adj_size(2);
1478
1479 /* Production sabotage */
1480 buf = buf->prev;
1481
1482 buf->size.x = area.x;
1483 buf->size.y = y = area.y + 1;
1484 buf->size.w = w;
1485 h = buf->size.h;
1486
1487 area2.x = adj_size(10);
1488 area2.h = adj_size(2);
1489
1490 buf = buf->prev;
1491 while (buf) {
1493 w -= n;
1494 }
1495
1496 buf->size.w = w;
1497 buf->size.x = buf->next->size.x;
1498 buf->size.y = y = y + buf->next->size.h;
1499
1500 if (buf->id == ID_SEPARATOR) {
1501 FREESURFACE(buf->theme);
1502 buf->size.h = h;
1503 buf->theme = create_surf(w, h, SDL_SWSURFACE);
1504
1505 area2.y = buf->size.h / 2 - 1;
1506 area2.w = buf->size.w - adj_size(20);
1507
1508 SDL_FillRect(buf->theme , &area2, map_rgba(buf->theme->format,
1510 }
1511
1512 if (buf == last) {
1513 break;
1514 }
1515
1517 /* Reset to end of scrolling area */
1519 + 9 * buf->size.h);
1520 w += n;
1521 }
1522 buf = buf->prev;
1523 }
1524
1525 if (diplomat_dlg->pdialog->scroll) {
1527 area.x + area.w,
1531 TRUE);
1532 }
1533
1534 /* -------------------- */
1535 /* redraw */
1537
1538 widget_flush(pwindow);
1539}
1540
1541/* ====================================================================== */
1542/* ============================== INCITE DIALOG ========================= */
1543/* ====================================================================== */
1544static struct small_diplomat_dialog *incite_dlg = NULL;
1545
1546/**********************************************************************/
1549static int incite_dlg_window_callback(struct widget *pwindow)
1550{
1553 }
1554
1555 return -1;
1556}
1557
1558/**********************************************************************/
1561static int diplomat_incite_yes_callback(struct widget *pwidget)
1562{
1567 incite_dlg->target_id, 0, "");
1568 }
1569
1571 }
1572
1573 return -1;
1574}
1575
1576/**********************************************************************/
1579static int exit_incite_dlg_callback(struct widget *pwidget)
1580{
1583 }
1584
1585 return -1;
1586}
1587
1588/**********************************************************************/
1605
1606/**********************************************************************/
1610void popup_incite_dialog(struct unit *actor, struct city *pcity, int cost,
1611 const struct action *paction)
1612{
1613 struct widget *pwindow = NULL, *buf = NULL;
1614 utf8_str *pstr;
1615 char tBuf[255], cbuf[255];
1616 bool exit = FALSE;
1617 SDL_Rect area;
1618
1619 if (incite_dlg) {
1620 return;
1621 }
1622
1623 /* Should be set before sending request to the server. */
1625
1626 if (!actor || !unit_can_do_action(actor, paction->id)) {
1628 return;
1629 }
1630
1632
1633 incite_dlg = fc_calloc(1, sizeof(struct small_diplomat_dialog));
1635 incite_dlg->target_id = pcity->id;
1636 incite_dlg->act_id = paction->id;
1637 incite_dlg->pdialog = fc_calloc(1, sizeof(struct small_dialog));
1638
1639 fc_snprintf(tBuf, ARRAY_SIZE(tBuf), PL_("Treasury contains %d gold.",
1640 "Treasury contains %d gold.",
1641 client_player()->economic.gold),
1642 client_player()->economic.gold);
1643
1644 /* Window */
1645 pstr = create_utf8_from_char_fonto(_("Incite a Revolt!"), FONTO_ATTENTION);
1646
1647 pstr->style |= TTF_STYLE_BOLD;
1648
1649 pwindow = create_window_skeleton(NULL, pstr, 0);
1650
1652 set_wstate(pwindow, FC_WS_NORMAL);
1653
1656
1657 area = pwindow->area;
1658 area.w = MAX(area.w, adj_size(8));
1659 area.h = MAX(area.h, adj_size(2));
1660
1662 /* Exit button */
1663 buf = create_themeicon(current_theme->small_cancel_icon, pwindow->dst,
1666 buf->info_label = create_utf8_from_char_fonto(_("Close Dialog (Esc)"),
1668 area.w += buf->size.w + adj_size(10);
1669 buf->action = exit_incite_dlg_callback;
1671 buf->key = SDLK_ESCAPE;
1672
1674 exit = TRUE;
1675 /* --------------- */
1676
1677 fc_snprintf(cbuf, sizeof(cbuf), _("You can't incite a revolt in %s."),
1678 city_name_get(pcity));
1679
1681
1683
1684 area.w = MAX(area.w , buf->size.w);
1685 area.h += buf->size.h;
1686 /*------------*/
1688 _("City can't be incited!"), NULL);
1689
1691
1692 area.w = MAX(area.w, buf->size.w);
1693 area.h += buf->size.h;
1694
1695 } else if (cost <= client_player()->economic.gold) {
1696 fc_snprintf(cbuf, sizeof(cbuf),
1697 /* TRANS: %s is pre-pluralised "Treasury contains %d gold." */
1698 PL_("Incite a revolt for %d gold?\n%s",
1699 "Incite a revolt for %d gold?\n%s", cost), cost, tBuf);
1700
1702
1704
1705 area.w = MAX(area.w, buf->size.w);
1706 area.h += buf->size.h;
1707
1708 /*------------*/
1711
1712 buf->data.city = pcity;
1714
1716
1717 area.w = MAX(area.w, buf->size.w);
1718 area.h += buf->size.h;
1719 /* ------- */
1721 _("No") , exit_incite_dlg_callback);
1722
1724 buf->key = SDLK_ESCAPE;
1725
1727
1728 area.w = MAX(area.w, buf->size.w);
1729 area.h += buf->size.h;
1730
1731 } else {
1732 /* Exit button */
1733 buf = create_themeicon(current_theme->small_cancel_icon, pwindow->dst,
1736 buf->info_label = create_utf8_from_char_fonto(_("Close Dialog (Esc)"),
1738 area.w += buf->size.w + adj_size(10);
1739 buf->action = exit_incite_dlg_callback;
1741 buf->key = SDLK_ESCAPE;
1742
1744 exit = TRUE;
1745 /* --------------- */
1746
1747 fc_snprintf(cbuf, sizeof(cbuf),
1748 /* TRANS: %s is pre-pluralised "Treasury contains %d gold." */
1749 PL_("Inciting a revolt costs %d gold.\n%s",
1750 "Inciting a revolt costs %d gold.\n%s", cost), cost, tBuf);
1751
1753
1755
1756 area.w = MAX(area.w, buf->size.w);
1757 area.h += buf->size.h;
1758
1759 /*------------*/
1761 _("Traitors Demand Too Much!"), NULL);
1762
1764
1765 area.w = MAX(area.w, buf->size.w);
1766 area.h += buf->size.h;
1767 }
1769
1770 /* setup window size and start position */
1771
1772 resize_window(pwindow, NULL, NULL,
1773 (pwindow->size.w - pwindow->area.w) + area.w,
1774 (pwindow->size.h - pwindow->area.h) + area.h);
1775
1776 area = pwindow->area;
1777
1779 put_window_near_map_tile(pwindow, pwindow->size.w, pwindow->size.h,
1780 pcity->tile);
1781
1782 /* setup widget size and start position */
1783 buf = pwindow;
1784
1785 if (exit) {
1786 /* exit button */
1787 buf = buf->prev;
1788 buf->size.x = area.x + area.w - buf->size.w - 1;
1789 buf->size.y = pwindow->size.y + adj_size(2);
1790 }
1791
1792 buf = buf->prev;
1794 area.x,
1795 area.y + 1, area.w, 0,
1797
1798 /* --------------------- */
1799 /* redraw */
1801
1802 widget_flush(pwindow);
1803}
1804
1805/* ====================================================================== */
1806/* ============================ BRIBE DIALOG ========================== */
1807/* ====================================================================== */
1808static struct small_diplomat_dialog *bribe_dlg = NULL;
1809
1810/**********************************************************************/
1813static int bribe_dlg_window_callback(struct widget *pwindow)
1814{
1817 }
1818
1819 return -1;
1820}
1821
1822/**********************************************************************/
1825static int diplomat_bribe_yes_callback(struct widget *pwidget)
1826{
1831 bribe_dlg->target_id, 0, "");
1832 }
1834 }
1835
1836 return -1;
1837}
1838
1839/**********************************************************************/
1842static int exit_bribe_dlg_callback(struct widget *pwidget)
1843{
1846 }
1847
1848 return -1;
1849}
1850
1851/**********************************************************************/
1868
1869/**********************************************************************/
1873void popup_bribe_dialog(struct unit *actor, struct unit *punit, int cost,
1874 const struct action *paction)
1875{
1876 struct widget *pwindow = NULL, *buf = NULL;
1877 utf8_str *pstr;
1878 char tBuf[255], cbuf[255];
1879 bool exit = FALSE;
1880 SDL_Rect area;
1881
1882 if (bribe_dlg) {
1883 return;
1884 }
1885
1886 /* Should be set before sending request to the server. */
1888
1889 if (!actor || !unit_can_do_action(actor, paction->id)) {
1891 return;
1892 }
1893
1895
1896 bribe_dlg = fc_calloc(1, sizeof(struct small_diplomat_dialog));
1897 bribe_dlg->act_id = paction->id;
1900 bribe_dlg->pdialog = fc_calloc(1, sizeof(struct small_dialog));
1901
1902 fc_snprintf(tBuf, ARRAY_SIZE(tBuf), PL_("Treasury contains %d gold.",
1903 "Treasury contains %d gold.",
1904 client_player()->economic.gold),
1905 client_player()->economic.gold);
1906
1907 /* Window */
1908 pstr = create_utf8_from_char_fonto(_("Bribe Enemy Unit"), FONTO_ATTENTION);
1909
1910 pstr->style |= TTF_STYLE_BOLD;
1911
1912 pwindow = create_window_skeleton(NULL, pstr, 0);
1913
1915 set_wstate(pwindow, FC_WS_NORMAL);
1916
1918 bribe_dlg->pdialog->end_widget_list = pwindow;
1919
1920 area = pwindow->area;
1921 area.w = MAX(area.w, adj_size(8));
1922 area.h = MAX(area.h, adj_size(2));
1923
1924 if (cost <= client_player()->economic.gold) {
1925 fc_snprintf(cbuf, sizeof(cbuf),
1926 /* TRANS: %s is pre-pluralised "Treasury contains %d gold." */
1927 PL_("Bribe unit for %d gold?\n%s",
1928 "Bribe unit for %d gold?\n%s", cost), cost, tBuf);
1929
1931
1933
1934 area.w = MAX(area.w, buf->size.w);
1935 area.h += buf->size.h;
1936
1937 /*------------*/
1940 buf->data.unit = punit;
1942
1944
1945 area.w = MAX(area.w, buf->size.w);
1946 area.h += buf->size.h;
1947 /* ------- */
1949 _("No") , exit_bribe_dlg_callback);
1950
1952 buf->key = SDLK_ESCAPE;
1953
1955
1956 area.w = MAX(area.w, buf->size.w);
1957 area.h += buf->size.h;
1958
1959 } else {
1960 /* Exit button */
1961 buf = create_themeicon(current_theme->small_cancel_icon, pwindow->dst,
1964 buf->info_label = create_utf8_from_char_fonto(_("Close Dialog (Esc)"),
1966 area.w += buf->size.w + adj_size(10);
1967 buf->action = exit_bribe_dlg_callback;
1969 buf->key = SDLK_ESCAPE;
1970
1972 exit = TRUE;
1973 /* --------------- */
1974
1975 fc_snprintf(cbuf, sizeof(cbuf),
1976 /* TRANS: %s is pre-pluralised "Treasury contains %d gold." */
1977 PL_("Bribing the unit costs %d gold.\n%s",
1978 "Bribing the unit costs %d gold.\n%s", cost), cost, tBuf);
1979
1981
1983
1984 area.w = MAX(area.w, buf->size.w);
1985 area.h += buf->size.h;
1986
1987 /*------------*/
1989 _("Traitors Demand Too Much!"), NULL);
1990
1992
1993 area.w = MAX(area.w, buf->size.w);
1994 area.h += buf->size.h;
1995 }
1997
1998 /* setup window size and start position */
1999
2000 resize_window(pwindow, NULL, NULL,
2001 (pwindow->size.w - pwindow->area.w) + area.w,
2002 (pwindow->size.h - pwindow->area.h) + area.h);
2003
2004 area = pwindow->area;
2005
2007 put_window_near_map_tile(pwindow, pwindow->size.w, pwindow->size.h,
2008 unit_tile(actor));
2009
2010 /* setup widget size and start position */
2011 buf = pwindow;
2012
2013 if (exit) {
2014 /* exit button */
2015 buf = buf->prev;
2016 buf->size.x = area.x + area.w - buf->size.w - 1;
2017 buf->size.y = pwindow->size.y + adj_size(2);
2018 }
2019
2020 buf = buf->prev;
2022 area.x,
2023 area.y + 1, area.w, 0,
2025
2026 /* --------------------- */
2027 /* redraw */
2029
2030 widget_flush(pwindow);
2031}
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
enum action_actor_kind action_get_actor_kind(const struct action *paction)
Definition actions.c:1730
bool action_prob_possible(const struct act_prob probability)
Definition actions.c:6703
enum action_sub_target_kind action_get_sub_target_kind(const struct action *paction)
Definition actions.c:1751
enum action_target_kind action_get_target_kind(const struct action *paction)
Definition actions.c:1740
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
#define n
Definition astring.c:77
static const char * astr_str(const struct astring *astr) fc__attribute((nonnull(1)))
Definition astring.h:93
#define ASTRING_INIT
Definition astring.h:44
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
struct civclient client
#define client_player()
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_do_action(action_id action, int actor_id, int target_id, int sub_tgt, const char *name)
Definition control.c:1701
void request_action_details(action_id action, int actor_id, int target_id)
Definition control.c:1721
void action_decision_clear_want(const int old_actor_id)
Definition control.c:1079
void key_unit_wait(void)
Definition control.c:3375
void auto_center_on_focus_unit(void)
Definition control.c:435
void action_selection_next_in_focus(const int old_actor_id)
Definition control.c:1091
struct unit struct city struct unit * target_unit
Definition dialogs_g.h:55
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
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
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
int int id
Definition editgui_g.h:28
int extra_number(const struct extra_type *pextra)
Definition extras.c:153
struct extra_type * extra_by_number(int id)
Definition extras.c:175
#define EXTRA_NONE
Definition extras.h:82
QString current_theme
Definition fc_client.cpp:65
#define NO_TARGET
Definition fc_types.h:324
int action_id
Definition fc_types.h:359
#define IDENTITY_NUMBER_ZERO
Definition fc_types.h:82
#define PL_(String1, String2, n)
Definition fcintl.h:71
#define _(String)
Definition fcintl.h:67
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
int action_selection_target_extra(void)
static int actor_unit_id
int action_selection_target_tile(void)
int action_selection_actor_unit(void)
static void spy_steal_popup_shared(GtkWidget *w, gpointer data)
void action_selection_close(void)
int action_selection_target_city(void)
static void action_entry(GtkWidget *shl, action_id act_id, const struct act_prob *act_probs, const char *custom, action_id act_num)
static void spy_steal_esc_popup(GtkWidget *w, gpointer data)
static void spy_steal_popup(GtkWidget *w, gpointer data)
static action_id get_non_targeted_action_id(action_id tgt_action_id)
static void found_city_callback(GtkWidget *w, gpointer data)
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 void simple_action_callback(GtkWidget *w, gpointer data)
static bool is_more_user_input_needed
static void act_sel_wait_callback(GtkWidget *w, gpointer data)
static action_id get_production_targeted_action_id(action_id tgt_action_id)
static bool did_not_decide
void popup_sabotage_dialog(struct unit *actor, struct city *pcity, const struct action *paction)
int action_selection_target_unit(void)
void popup_incite_dialog(struct unit *actor, struct city *pcity, int cost, const struct action *paction)
static const GCallback af_map[ACTION_COUNT]
static void upgrade_callback(GtkWidget *w, gpointer data)
void flush_dirty(void)
Definition mapview.c:450
const char * title
Definition repodlgs.c:1313
static struct diplomat_dialog * diplomat_dlg
static struct small_diplomat_dialog * incite_dlg
static int exit_incite_dlg_callback(struct widget *pwidget)
static int incite_dlg_window_callback(struct widget *pwindow)
static int spy_sabotage_request(struct widget *pwidget)
bool is_unit_move_blocked
Definition gui_main.c:103
static int diplomat_bribe_yes_callback(struct widget *pwidget)
static int spy_strike_bld_request(struct widget *pwidget)
static int sabotage_impr_callback(struct widget *pwidget)
static int bribe_dlg_window_callback(struct widget *pwindow)
static void act_sel_done_primary(int actor_unit_id)
static int diplomat_incite_yes_callback(struct widget *pwidget)
static int diplomat_close_callback(struct widget *pwidget)
static int spy_sabotage_esc_request(struct widget *pwidget)
static int diplomat_dlg_window_callback(struct widget *pwindow)
static int spy_incite_callback(struct widget *pwidget)
static void act_sel_done_secondary(int actor_unit_id)
void popdown_diplomat_dialog(void)
static int exit_bribe_dlg_callback(struct widget *pwidget)
void popdown_incite_dialog(void)
void popdown_bribe_dialog(void)
static int exit_spy_tgt_dlg_callback(struct widget *pwidget)
static int spy_steal_dlg_window_callback(struct widget *pwindow)
static int spy_steal_callback(struct widget *pwidget)
static int diplomat_bribe_callback(struct widget *pwidget)
static int diplomat_incite_callback(struct widget *pwidget)
int(* act_func)(struct widget *)
static struct small_diplomat_dialog * bribe_dlg
SDL_Color * get_theme_color(enum theme_color themecolor)
Definition colors.c:44
void put_window_near_map_tile(struct widget *pwindow, int window_width, int window_height, struct tile *ptile)
Definition dialogs.c:108
void popup_unit_upgrade_dlg(struct unit *punit, bool city)
Definition dialogs.c:680
int main_window_width(void)
Definition graphics.c:685
struct sdl2_data main_data
Definition graphics.c:57
SDL_Surface * create_surf(int width, int height, Uint32 flags)
Definition graphics.c:351
int main_window_height(void)
Definition graphics.c:693
#define FREESURFACE(ptr)
Definition graphics.h:322
#define map_rgba(format, color)
Definition graphics.h:315
#define adj_size(size)
Definition gui_main.h:138
#define PRESSED_EVENT(event)
Definition gui_main.h:68
void queue_flush(void)
Definition mapview.c:152
SDL_Surface * create_select_tech_icon(utf8_str *pstr, Tech_type_id tech_id, enum tech_info_mode mode)
Definition repodlgs.c:2423
@ TIM_FULL_MODE
Definition repodlgs.h:30
@ ID_BRIBE_DLG_WINDOW
Definition gui_id.h:213
@ ID_TERRAIN_ADV_DLG_WINDOW
Definition gui_id.h:202
@ ID_CARAVAN_DLG_WINDOW
Definition gui_id.h:206
@ ID_BRIBE_DLG_EXIT_BUTTON
Definition gui_id.h:214
@ ID_INCITE_DLG_WINDOW
Definition gui_id.h:209
@ ID_TERRAIN_ADV_DLG_EXIT_BUTTON
Definition gui_id.h:203
@ ID_DIPLOMAT_DLG_WINDOW
Definition gui_id.h:208
@ ID_SEPARATOR
Definition gui_id.h:28
@ ID_LABEL
Definition gui_id.h:27
@ ID_INCITE_DLG_EXIT_BUTTON
Definition gui_id.h:210
utf8_str * copy_chars_to_utf8_str(utf8_str *pstr, const char *pchars)
Definition gui_string.c:251
utf8_str * create_utf8_str_fonto(char *in_text, size_t n_alloc, enum font_origin origin)
Definition gui_string.c:241
#define FREEUTF8STR(pstr)
Definition gui_string.h:92
#define SF_CENTER
Definition gui_string.h:40
@ FONTO_DEFAULT
Definition gui_string.h:64
@ FONTO_ATTENTION
Definition gui_string.h:66
#define create_utf8_from_char_fonto(string_in, fonto)
Definition gui_string.h:107
struct impr_type * improvement_by_number(const Impr_type_id id)
Impr_type_id improvement_number(const struct impr_type *pimprove)
#define B_LAST
Definition improvement.h:42
#define fc_assert_msg(condition, message,...)
Definition log.h:181
#define fc_assert(condition)
Definition log.h:176
#define fc_assert_ret_msg(condition, message,...)
Definition log.h:205
#define fc_assert_action(condition, action)
Definition log.h:187
#define fc_assert_ret_val_msg(condition, val, message,...)
Definition log.h:208
struct tile * index_to_tile(const struct civ_map *imap, int mindex)
Definition map.c:454
#define fc_calloc(n, esz)
Definition mem.h:38
#define FC_FREE(ptr)
Definition mem.h:41
int dsend_packet_city_name_suggestion_req(struct connection *pc, int unit_id16, int unit_id32)
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
#define MIN(x, y)
Definition shared.h:55
#define MAX(x, y)
Definition shared.h:54
action_id id
Definition actions.h:380
enum act_tgt_compl target_complexity
Definition actions.h:390
struct widget * active_widget_list
Definition widget.h:186
struct widget * end_widget_list
Definition widget.h:182
struct widget * begin_widget_list
Definition widget.h:181
struct widget * begin_active_widget_list
Definition widget.h:184
struct widget * end_active_widget_list
Definition widget.h:185
struct scroll_bar * scroll
Definition widget.h:187
Definition city.h:309
int id
Definition city.h:315
struct tile * tile
Definition city.h:311
struct packet_game_info info
Definition game.h:89
struct connection conn
Definition client_main.h:96
int id1
Definition widget.h:104
int id0
Definition widget.h:103
int value
Definition widget.h:105
int sub_target_id[ASTK_COUNT]
struct advanced_dialog * pdialog
int target_ids[ATK_COUNT]
bool tech_steal_allow_holes
SDL_Event event
Definition graphics.h:217
struct widget * begin_widget_list
Definition widget.h:175
struct widget * end_widget_list
Definition widget.h:176
struct small_dialog * pdialog
Definition tile.h:49
Definition unit.h:138
int id
Definition unit.h:145
struct unit::@80::@82 client
struct act_prob * act_prob_cache
Definition unit.h:225
Uint8 style
Definition gui_string.h:53
utf8_str * info_label
Definition widget.h:122
SDL_Keycode key
Definition widget.h:153
union widget::@214 data
struct gui_layer * dst
Definition widget.h:116
struct widget * prev
Definition widget.h:114
int(* action)(struct widget *)
Definition widget.h:157
struct city * city
Definition widget.h:128
struct container * cont
Definition widget.h:127
SDL_Rect area
Definition widget.h:149
Uint16 id
Definition widget.h:155
SDL_Rect size
Definition widget.h:145
struct civ_map map
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:969
#define TRUE
Definition support.h:46
#define FALSE
Definition support.h:47
struct advance * advance_by_number(const Tech_type_id atype)
Definition tech.c:107
const char * advance_name_translation(const struct advance *padvance)
Definition tech.c:290
struct advance * valid_advance_by_number(const Tech_type_id id)
Definition tech.c:176
Tech_type_id advance_number(const struct advance *padvance)
Definition tech.c:98
#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
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
SDL_Surface * theme_get_background(const struct theme *t, enum theme_background background)
@ BACKGROUND_SPYSTEALDLG
@ COLOR_THEME_SABOTAGEDLG_SEPARATOR
struct theme * active_theme
Definition themespec.c:154
#define tile_index(_pt_)
Definition tile.h:87
#define TILE_INDEX_NONE
Definition tile.h:47
bool unit_can_do_action(const struct unit *punit, const action_id act_id)
Definition unit.c:328
#define unit_tile(_pu)
Definition unit.h:395
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
void add_to_gui_list(Uint16 id, struct widget *gui)
Definition widget.c:585
int setup_vertical_widgets_position(int step, Sint16 start_x, Sint16 start_y, Uint16 w, Uint16 h, struct widget *begin, struct widget *end)
Definition widget.c:1050
Uint16 redraw_group(const struct widget *begin_group_widget_list, const struct widget *end_group_widget_list, int add_to_update)
Definition widget.c:719
void popdown_window_group_dialog(struct widget *begin_group_widget_list, struct widget *end_group_widget_list)
Definition widget.c:982
void move_window_group(struct widget *begin_widget_list, struct widget *pwindow)
Definition widget.c:1038
static void widget_set_position(struct widget *pwidget, int x, int y)
Definition widget.h:266
#define MAX_ID
Definition widget.h:38
@ FC_WS_NORMAL
Definition widget.h:96
static void widget_mark_dirty(struct widget *pwidget)
Definition widget.h:286
static void widget_flush(struct widget *pwidget)
Definition widget.h:291
void set_wstate(struct widget *pwidget, enum widget_state state)
Definition widget_core.c:36
@ WF_WIDGET_HAS_INFO_LABEL
Definition widget.h:88
@ WF_FREE_DATA
Definition widget.h:78
@ WF_RESTORE_BACKGROUND
Definition widget.h:85
@ WF_HIDDEN
Definition widget.h:68
@ WF_FREE_THEME
Definition widget.h:72
void set_wflag(struct widget *pwidget, enum widget_flag flag)
Definition widget_core.c:54
struct widget * create_themeicon(SDL_Surface *icon_theme, struct gui_layer *pdest, Uint32 flags)
struct widget * create_icon2(SDL_Surface *icon, struct gui_layer *pdest, Uint32 flags)
struct widget * create_iconlabel(SDL_Surface *icon, struct gui_layer *pdest, utf8_str *pstr, Uint32 flags)
#define create_active_iconlabel(buf, pdest, pstr, pstring, cb)
void setup_vertical_scrollbar_area(struct scroll_bar *scroll, Sint16 start_x, Sint16 start_y, Uint16 height, bool swap_start_x)
Uint32 create_vertical_scrollbar(struct advanced_dialog *dlg, Uint8 step, Uint8 active, bool create_scrollbar, bool create_buttons)
int resize_window(struct widget *pwindow, SDL_Surface *bcgd, SDL_Color *pcolor, Uint16 new_w, Uint16 new_h)
struct widget * create_window_skeleton(struct gui_layer *pdest, utf8_str *title, Uint32 flags)