Freeciv-3.4
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 "specialist.h"
29#include "traderoutes.h"
30#include "unitlist.h"
31
32/* client */
33#include "client_main.h"
34#include "climisc.h"
35#include "control.h"
36#include "text.h"
37
38/* client/gui-sdl3 */
39#include "citydlg.h"
40#include "colors.h"
41#include "dialogs.h"
42#include "graphics.h"
43#include "gui_id.h"
44#include "gui_tilespec.h"
45#include "mapview.h"
46#include "repodlgs.h"
47#include "themespec.h"
48#include "widget.h"
49
50#include "dialogs_g.h"
51
52typedef int (*act_func)(struct widget *);
53
54struct diplomat_dialog {
55 int actor_unit_id;
60};
61
63 int actor_unit_id;
64 int target_id;
66 struct small_dialog *pdialog;
67};
68
69extern bool is_unit_move_blocked;
70
72void popdown_incite_dialog(void);
73void popdown_bribe_dialog(void);
74
75
78static bool did_not_decide = FALSE;
79
80/**********************************************************************/
84{
86 /* The client isn't waiting for information for any unanswered follow
87 * up questions. */
88
89 struct unit *actor_unit;
90
92 /* The action selection dialog wasn't closed because the actor unit
93 * was lost. */
94
95 /* The probabilities didn't just disappear, right? */
98
100 }
101
102 /* The action selection process is over, at least for now. */
104
105 if (did_not_decide) {
106 /* The action selection dialog was closed but the player didn't
107 * decide what the unit should do. */
108
109 /* Reset so the next action selection dialog does the right thing. */
111 } else {
112 /* An action, or no action at all, was selected. */
115 }
116 }
117}
118
119/**********************************************************************/
123{
124 /* Stop blocking. */
127}
128
129/**********************************************************************/
136{
137 /* Stop assuming the answer to a follow up question will arrive. */
139}
140
141/**********************************************************************/
146{
147 /* Don't add an action mapping here unless the non targeted version is
148 * selectable in the targeted version's target selection dialog. */
149 switch ((enum gen_action)tgt_action_id) {
158 default:
159 /* No non targeted version found. */
160 return ACTION_NONE;
161 }
162}
163
164/**********************************************************************/
169{
170 /* Don't add an action mapping here unless the non targeted version is
171 * selectable in the targeted version's target selection dialog. */
172 switch ((enum gen_action)tgt_action_id) {
179 default:
180 /* No non targeted version found. */
181 return ACTION_NONE;
182 }
183}
184
185/**********************************************************************/
188static int diplomat_dlg_window_callback(struct widget *pwindow)
189{
192 }
193
194 return -1;
195}
196
197/**********************************************************************/
217
218/**********************************************************************/
238
239/**********************************************************************/
260
261/* --------------------------------------------------------- */
262
263/**********************************************************************/
266static int spy_steal_dlg_window_callback(struct widget *pwindow)
267{
270 }
271
272 return -1;
273}
274
275/**********************************************************************/
278static int exit_spy_tgt_dlg_callback(struct widget *pwidget)
279{
281 int actor_id = diplomat_dlg->actor_unit_id;
282
285 act_sel_done_secondary(actor_id);
286 }
287
288 return -1;
289}
290
291/**********************************************************************/
294static int spy_steal_callback(struct widget *pwidget)
295{
297 int steal_advance = MAX_ID - pwidget->id;
298 int actor_id = diplomat_dlg->actor_unit_id;
299
303 if (steal_advance == A_UNSET) {
304 /* This is the untargeted version. */
309 steal_advance, "");
310 } else {
311 /* This is the targeted version. */
315 steal_advance, "");
316 }
317 }
318
321 act_sel_done_secondary(actor_id);
322 }
323
324 return -1;
325}
326
327/**********************************************************************/
330static int spy_steal_popup_shared(struct widget *pwidget)
331{
332 const struct research *presearch, *vresearch;
333 struct city *vcity = pwidget->data.city;
334 int id = diplomat_dlg->actor_unit_id;
335 struct player *victim = NULL;
336 struct container *cont;
337 struct widget *buf = NULL;
338 struct widget *pwindow;
339 utf8_str *pstr;
340 SDL_Surface *surf;
341 int max_col, max_row, col, count = 0;
342 int tech, idx;
344 struct unit *actor_unit = game_unit_by_number(id);
345 action_id act_id = diplomat_dlg->act_id;
347
350
351 if (vcity) {
353 }
354
355 fc_assert_ret_val_msg(!diplomat_dlg, 1, "Diplomat dialog already open");
356
357 if (!victim) {
359 return 1;
360 }
361
362 count = 0;
365 ac = advance_count();
371 count++;
372 }
374
375 if (!count) {
376 /* if there is no known tech to steal then
377 * send steal order at Spy's Discretion */
378 int target_id = vcity->id;
379
381 id, target_id, A_UNSET, "");
382
384
385 return -1;
386 }
387
388 cont = fc_calloc(1, sizeof(struct container));
389 cont->id0 = vcity->id;
390 cont->id1 = id; /* spy id */
391
392 diplomat_dlg = fc_calloc(1, sizeof(struct diplomat_dialog));
393 diplomat_dlg->act_id = act_id;
396 diplomat_dlg->pdialog = fc_calloc(1, sizeof(struct advanced_dialog));
397
398 pstr = create_utf8_from_char_fonto(_("Select Advance to Steal"),
400 pstr->style |= TTF_STYLE_BOLD;
401
402 pwindow = create_window_skeleton(NULL, pstr, 0);
403
405 set_wstate(pwindow , FC_WS_NORMAL);
406
409
410 area = pwindow->area;
411 area.w = MAX(area.w, adj_size(8));
412
413 /* ------------------ */
414 /* Exit button */
415 buf = create_themeicon(current_theme->small_cancel_icon, pwindow->dst,
417 buf->info_label = create_utf8_from_char_fonto(_("Close Dialog (Esc)"),
419 area.w += buf->size.w + adj_size(10);
422 buf->key = SDLK_ESCAPE;
423
425 /* ------------------------- */
426
428 get_non_targeted_action_id(act_id)])) {
429 /* count + at Spy's Discretion */
430 count++;
431 }
432
433 /* max col - 104 is steal tech widget width */
434 max_col = (main_window_width() - (pwindow->size.w - pwindow->area.w) - adj_size(2)) / adj_size(104);
435 /* max row - 204 is steal tech widget height */
436 max_row = (main_window_height() - (pwindow->size.h - pwindow->area.h)) / adj_size(204);
437
438 /* make space on screen for scrollbar */
439 if (max_col * max_row < count) {
440 max_col--;
441 }
442
443 if (count < max_col + 1) {
444 col = count;
445 } else {
446 if (count < max_col + adj_size(3)) {
447 col = max_col - adj_size(2);
448 } else {
449 if (count < max_col + adj_size(5)) {
450 col = max_col - 1;
451 } else {
452 col = max_col;
453 }
454 }
455 }
456
458 pstr->style |= (TTF_STYLE_BOLD | SF_CENTER);
459
460 count = 0;
466 count++;
467
470 buf = create_icon2(surf, pwindow->dst,
472
474 buf->action = spy_steal_callback;
475 buf->data.cont = cont;
476
478
479 if (count > (col * max_row)) {
481 }
482 }
484
485 /* Get Spy tech to use for "At Spy's Discretion" -- this will have the
486 * side effect of displaying the unit's icon */
488
490 get_non_targeted_action_id(act_id)])) {
491 struct astring str = ASTRING_INIT;
492
493 /* TRANS: %s is a unit name, e.g., Spy */
494 astr_set(&str, _("At %s's Discretion"),
497 astr_free(&str);
498
500
501 buf = create_icon2(surf, pwindow->dst,
503 | WF_FREE_DATA));
505 buf->action = spy_steal_callback;
506 buf->data.cont = cont;
507
509 count++;
510 }
511
512 /* --------------------------------------------------------- */
517
518 /* -------------------------------------------------------------- */
519
520 idx = 0;
521 if (count > col) {
522 count = (count + (col - 1)) / col;
523 if (count > max_row) {
525 count = max_row;
527 }
528 } else {
529 count = 1;
530 }
531
532 area.w = MAX(area.w, (col * buf->size.w + adj_size(2) + idx));
533 area.h = count * buf->size.h + adj_size(2);
534
535 /* alloca window theme and win background buffer */
537 if (resize_window(pwindow, surf, NULL,
538 (pwindow->size.w - pwindow->area.w) + area.w,
539 (pwindow->size.h - pwindow->area.h) + area.h)) {
540 FREESURFACE(surf);
541 }
542
543 area = pwindow->area;
544
545 widget_set_position(pwindow,
546 (main_window_width() - pwindow->size.w) / 2,
547 (main_window_height() - pwindow->size.h) / 2);
548
549 /* exit button */
550 buf = pwindow->prev;
551 buf->size.x = area.x + area.w - buf->size.w - 1;
552 buf->size.y = pwindow->size.y + adj_size(2);
553
555 area.y, 0, 0,
558
561 area.x + area.w, area.y,
562 area.h, TRUE);
563 }
564
566 widget_mark_dirty(pwindow);
567
568 return -1;
569}
570
571/**********************************************************************/
574static int spy_steal_popup(struct widget *pwidget)
575{
577 return spy_steal_popup_shared(pwidget);
578}
579
580/**********************************************************************/
583static int spy_steal_esc_popup(struct widget *pwidget)
584{
586 return spy_steal_popup_shared(pwidget);
587}
588
589/**********************************************************************/
610
611/**********************************************************************/
632
633/**********************************************************************/
636static int act_sel_wait_callback(struct widget *pwidget)
637{
640
641 /* The dialog was popped down when key_unit_wait() resulted in
642 * action_selection_close() being called. */
643 }
644
645 return -1;
646}
647
648/**********************************************************************/
669
670/**********************************************************************/
689
690/**********************************************************************/
693static int found_city_callback(struct widget *pwidget)
694{
696 int actor_id = diplomat_dlg->actor_unit_id;
697
700 actor_id);
701 }
702
703 return -1;
704}
705
706/**********************************************************************/
709static int upgrade_callback(struct widget *pwidget)
710{
712 struct unit *punit;
713
717 }
718
720 }
721
722 return -1;
723}
724
725/**********************************************************************/
729static int simple_action_callback(struct widget *pwidget)
730{
731 int actor_id, target_id, sub_target;
732 struct action *paction;
733
734 bool failed = FALSE;
735
737 return -1;
738 }
739
740 /* Data */
741 paction = action_by_number(MAX_ID - pwidget->id);
742
743 /* Actor */
745 actor_id = diplomat_dlg->actor_unit_id;
746 if (NULL == game_unit_by_number(actor_id)) {
747 /* Probably dead. */
748 failed = TRUE;
749 }
750
751 /* Target */
752 target_id = IDENTITY_NUMBER_ZERO;
754 case ATK_CITY:
755 target_id = diplomat_dlg->target_ids[ATK_CITY];
756 if (NULL == game_city_by_number(target_id)) {
757 /* Probably destroyed. */
758 failed = TRUE;
759 }
760 break;
761 case ATK_UNIT:
762 target_id = diplomat_dlg->target_ids[ATK_UNIT];
763 if (NULL == game_unit_by_number(target_id)) {
764 /* Probably dead. */
765 failed = TRUE;
766 }
767 break;
768 case ATK_STACK:
769 case ATK_TILE:
770 case ATK_EXTRAS:
771 target_id = diplomat_dlg->target_ids[ATK_TILE];
772 if (NULL == index_to_tile(&(wld.map), target_id)) {
773 /* TODO: Should this be possible at all? If not: add assertion. */
774 failed = TRUE;
775 }
776 break;
777 case ATK_SELF:
778 target_id = IDENTITY_NUMBER_ZERO;
779 break;
780 case ATK_COUNT:
782 failed = TRUE;
783 }
784
785 /* Sub target. */
786 sub_target = NO_TARGET;
787 if (paction->target_complexity != ACT_TGT_COMPL_SIMPLE) {
789 case ASTK_BUILDING:
791 if (NULL == improvement_by_number(sub_target)) {
792 /* Did the ruleset change? */
793 failed = TRUE;
794 }
795 break;
796 case ASTK_TECH:
797 sub_target = diplomat_dlg->sub_target_id[ASTK_TECH];
798 if (NULL == valid_advance_by_number(sub_target)) {
799 /* Did the ruleset change? */
800 failed = TRUE;
801 }
802 break;
803 case ASTK_EXTRA:
805 /* TODO: validate if the extra is there? */
807 if (NULL == extra_by_number(sub_target)) {
808 /* Did the ruleset change? */
809 failed = TRUE;
810 }
811 break;
812 case ASTK_SPECIALIST:
814 if (nullptr == specialist_by_number(sub_target)) {
815 /* Did the ruleset change? */
816 failed = TRUE;
817 }
818 break;
819 case ASTK_NONE:
820 case ASTK_COUNT:
821 /* Shouldn't happen. */
823 failed = TRUE;
824 break;
825 }
826 }
827
828 /* Send request. */
829 if (!failed) {
830 request_do_action(paction->id, actor_id, target_id, sub_target, "");
831 }
832
833 /* Clean up. */
835 return -1;
836}
837
838/**********************************************************************/
841static int diplomat_close_callback(struct widget *pwidget)
842{
845 }
846
847 return -1;
848}
849
850/**********************************************************************/
868
869/* Mapping from an action to the function to call when its button is
870 * pushed. */
871static const act_func af_map[ACTION_COUNT] = {
872 /* Unit acting against a city target. */
881
882 /* Unit acting against a unit target. */
884
885 /* Unit acting against all units at a tile. */
887
888 /* Unit acting against a tile. */
890
891 /* Unit acting with no target except itself. */
892 /* No special callback functions needed for any self targeted actions. */
893};
894
895/**********************************************************************/
898static void action_entry(const action_id act,
899 const struct act_prob *act_probs,
900 struct unit *act_unit,
901 struct tile *tgt_tile,
902 struct city *tgt_city,
903 struct unit *tgt_unit,
904 struct widget *pwindow,
905 SDL_Rect *area)
906{
907 struct widget *buf;
908 utf8_str *pstr;
909 const char *ui_name;
910 act_func cb;
911
913 act_probs[act],
914 act_unit,
915 tgt_city);
916
917 if (af_map[act] == NULL) {
918 /* No special call back function needed for this action. */
920 } else {
921 /* Special action specific callback function specified. */
922 cb = af_map[act];
923 }
924
925 /* Don't show disabled actions */
926 if (!action_prob_possible(act_probs[act])) {
927 return;
928 }
929
930 ui_name = action_prepare_ui_name(act, "",
931 act_probs[act], custom);
932
934 ui_name, cb);
935
936 switch (action_id_get_target_kind(act)) {
937 case ATK_CITY:
938 buf->data.city = tgt_city;
939 break;
940 case ATK_UNIT:
941 buf->data.unit = tgt_unit;
942 break;
943 case ATK_TILE:
944 case ATK_EXTRAS:
945 case ATK_STACK:
946 buf->data.tile = tgt_tile;
947 break;
948 case ATK_SELF:
949 buf->data.unit = act_unit;
950 break;
951 case ATK_COUNT:
952 fc_assert_msg(FALSE, "Unsupported target kind");
953 }
954
956
957 add_to_gui_list(MAX_ID - act, buf);
958
959 area->w = MAX(area->w, buf->size.w);
960 area->h += buf->size.h;
961}
962
963/**********************************************************************/
968 struct city *target_city,
969 struct unit *target_unit,
970 struct tile *target_tile,
971 struct extra_type *target_extra,
972 const struct act_prob *act_probs)
973{
974 struct widget *pwindow = NULL, *buf = NULL;
975 utf8_str *pstr;
977
978 fc_assert_ret_msg(!diplomat_dlg, "Diplomat dialog already open");
979
980 /* Could be caused by the server failing to reply to a request for more
981 * information or a bug in the client code. */
983 "Diplomat queue problem. Is another diplomat window open?");
984
985 /* No extra input is required as no action has been chosen yet. */
987
989
990 diplomat_dlg = fc_calloc(1, sizeof(struct diplomat_dialog));
992 diplomat_dlg->pdialog = fc_calloc(1, sizeof(struct advanced_dialog));
993
994 /* window */
995 if (target_city) {
996 struct astring title = ASTRING_INIT;
997
998 /* TRANS: %s is a unit name, e.g., Spy */
999 astr_set(&title, _("Choose Your %s's Strategy"),
1002 astr_free(&title);
1003 } else {
1004 pstr = create_utf8_from_char_fonto(_("Subvert Enemy Unit"),
1006 }
1007
1008 pstr->style |= TTF_STYLE_BOLD;
1009
1010 pwindow = create_window_skeleton(NULL, pstr, 0);
1011
1013 set_wstate(pwindow, FC_WS_NORMAL);
1014
1017
1018 area = pwindow->area;
1019 area.w = MAX(area.w, adj_size(8));
1020 area.h = MAX(area.h, adj_size(2));
1021
1022 if (target_city) {
1024 } else {
1026 }
1027
1028 if (target_unit) {
1030 } else {
1032 }
1033
1037
1038 /* No target building or target tech supplied. (Feb 2020) */
1042
1043 if (target_extra) {
1047 } else {
1050 }
1051
1053
1054 /* ---------- */
1055 /* Unit acting against a city */
1056
1057 action_iterate(act) {
1062 pwindow, &area);
1063 }
1065
1066 /* Unit acting against another unit */
1067
1068 action_iterate(act) {
1073 pwindow, &area);
1074 }
1076
1077 /* Unit acting against all units at a tile */
1078
1079 action_iterate(act) {
1084 pwindow, &area);
1085 }
1087
1088 /* Unit acting against a tile. */
1089
1090 action_iterate(act) {
1095 pwindow, &area);
1096 }
1098
1099 /* Unit acting against a tile's extras. */
1100
1101 action_iterate(act) {
1106 pwindow, &area);
1107 }
1109
1110 /* Unit acting against itself. */
1111
1112 action_iterate(act) {
1117 pwindow, &area);
1118 }
1120
1121 /* ---------- */
1123 _("Wait"), act_sel_wait_callback);
1124
1125 buf->data.tile = target_tile;
1126
1128
1130
1131 area.w = MAX(area.w, buf->size.w);
1132 area.h += buf->size.h;
1133
1134 /* ---------- */
1136 _("Cancel"), diplomat_close_callback);
1137
1139 buf->key = SDLK_ESCAPE;
1140
1142
1143 area.w = MAX(area.w, buf->size.w);
1144 area.h += buf->size.h;
1145 /* ---------- */
1147
1148 /* setup window size and start position */
1149
1150 resize_window(pwindow, NULL, NULL,
1151 (pwindow->size.w - pwindow->area.w) + area.w,
1152 (pwindow->size.h - pwindow->area.h) + area.h);
1153
1154 area = pwindow->area;
1155
1157 put_window_near_map_tile(pwindow, pwindow->size.w, pwindow->size.h,
1159
1160 /* setup widget size and start position */
1161
1162 buf = pwindow->prev;
1164 area.x,
1165 area.y + 1, area.w, 0,
1167
1168 /* --------------------- */
1169 /* redraw */
1171
1172 widget_flush(pwindow);
1173
1174 /* Give follow up questions access to action probabilities. */
1176 action_iterate(act) {
1179}
1180
1181/**********************************************************************/
1187{
1188 if (!diplomat_dlg) {
1189 return IDENTITY_NUMBER_ZERO;
1190 }
1191
1193}
1194
1195/**********************************************************************/
1202{
1203 if (!diplomat_dlg) {
1204 return IDENTITY_NUMBER_ZERO;
1205 }
1206
1208}
1209
1210/**********************************************************************/
1217{
1218 if (!diplomat_dlg) {
1219 return IDENTITY_NUMBER_ZERO;
1220 }
1221
1223}
1224
1225/**********************************************************************/
1232{
1233 if (!diplomat_dlg) {
1234 return TILE_INDEX_NONE;
1235 }
1236
1238}
1239
1240/**********************************************************************/
1247{
1248 if (!diplomat_dlg) {
1249 return EXTRA_NONE;
1250 }
1251
1253}
1254
1255/**********************************************************************/
1259 struct city *target_city,
1260 struct unit *target_unit,
1261 struct tile *target_tile,
1262 struct extra_type *target_extra,
1263 const struct act_prob *act_probs)
1264{
1269 act_probs);
1270}
1271
1272/**********************************************************************/
1280
1281/* ====================================================================== */
1282/* ============================ SABOTAGE DIALOG ========================= */
1283/* ====================================================================== */
1284
1285/**********************************************************************/
1288static int sabotage_impr_callback(struct widget *pwidget)
1289{
1291 int sabotage_improvement = MAX_ID - pwidget->id;
1292 int diplomat_target_id = pwidget->data.cont->id0;
1293 int diplomat_id = pwidget->data.cont->id1;
1294 action_id act_id = pwidget->data.cont->value;
1295
1298
1299 if (sabotage_improvement == 1000) {
1301 }
1302
1306 /* This is the untargeted version. */
1310 } else if (sabotage_improvement == -1) {
1311 /* This is the city production version. */
1315 } else {
1316 /* This is the targeted version. */
1317 request_do_action(act_id,
1320 }
1321 }
1322
1324 }
1325
1326 return -1;
1327}
1328
1329/**********************************************************************/
1334 const struct action *paction)
1335{
1336 struct widget *pwindow = NULL, *buf = NULL , *last = NULL;
1337 struct container *cont;
1338 utf8_str *pstr;
1339 SDL_Rect area, area2;
1340 int n, w = 0, h, imp_h = 0, y;
1341
1342 fc_assert_ret_msg(!diplomat_dlg, "Diplomat dialog already open");
1343
1344 /* Should be set before sending request to the server. */
1346
1347 if (!actor) {
1349 return;
1350 }
1351
1353
1354 diplomat_dlg = fc_calloc(1, sizeof(struct diplomat_dialog));
1357 diplomat_dlg->pdialog = fc_calloc(1, sizeof(struct advanced_dialog));
1358
1359 cont = fc_calloc(1, sizeof(struct container));
1360 cont->id0 = pcity->id;
1361 cont->id1 = actor->id; /* Spy id */
1362 cont->value = paction->id;
1363
1364 if (paction->result == ACTRES_STRIKE_BUILDING) {
1365 pstr = create_utf8_from_char_fonto(_("Select Improvement to Strike"),
1367 } else {
1368 pstr = create_utf8_from_char_fonto(_("Select Improvement to Sabotage"),
1370 }
1371 pstr->style |= TTF_STYLE_BOLD;
1372
1373 pwindow = create_window_skeleton(NULL, pstr, 0);
1374
1376 set_wstate(pwindow, FC_WS_NORMAL);
1377
1380
1381 area = pwindow->area;
1382 area.h = MAX(area.h, adj_size(2));
1383
1384 /* ---------- */
1385 /* Exit button */
1386 buf = create_themeicon(current_theme->small_cancel_icon, pwindow->dst,
1388 buf->info_label = create_utf8_from_char_fonto(_("Close Dialog (Esc)"),
1390 area.w += buf->size.w + adj_size(10);
1393 buf->key = SDLK_ESCAPE;
1394
1396 /* ---------- */
1397
1400 paction->id)])) {
1402 _("City Production"), sabotage_impr_callback);
1403 buf->data.cont = cont;
1406 add_to_gui_list(MAX_ID - 1000, buf);
1407
1408 area.w = MAX(area.w, buf->size.w);
1409 area.h += buf->size.h;
1410
1411 /* separator */
1413
1415 area.h += buf->next->size.h;
1416
1418 }
1419
1420 /* ------------------ */
1421 n = 0;
1422 city_built_iterate(pcity, pimprove) {
1423 if (pimprove->sabotage > 0) {
1425 (char *) city_improvement_name_translation(pcity, pimprove),
1427 buf->data.cont = cont;
1429
1431
1432 area.w = MAX(area.w , buf->size.w);
1433 imp_h += buf->size.h;
1434
1435 if (n > 9) {
1437 }
1438
1439 n++;
1440 /* ----------- */
1441 }
1443
1445
1446 if (n > 0
1449 /* separator */
1451
1453 area.h += buf->next->size.h;
1454 /* ------------------ */
1455 }
1456
1459 struct astring str = ASTRING_INIT;
1460
1461 /* TRANS: %s is a unit name, e.g., Spy */
1462 astr_set(&str, _("At %s's Discretion"), unit_name_translation(actor));
1465 astr_free(&str);
1466
1467 buf->data.cont = cont;
1469
1471
1472 area.w = MAX(area.w, buf->size.w);
1473 area.h += buf->size.h;
1474 }
1475
1476 /* ----------- */
1477
1478 last = buf;
1481
1482 /* ---------- */
1483 if (n > 10) {
1484 imp_h = 10 * buf->size.h;
1485
1487 1, 10, TRUE, TRUE);
1488 area.w += n;
1489 } else {
1490 n = 0;
1491 }
1492 /* ---------- */
1493
1494 area.h += imp_h;
1495
1496 resize_window(pwindow, NULL, NULL,
1497 (pwindow->size.w - pwindow->area.w) + area.w,
1498 (pwindow->size.h - pwindow->area.h) + area.h);
1499
1500 area = pwindow->area;
1501
1503 put_window_near_map_tile(pwindow, pwindow->size.w, pwindow->size.h,
1504 unit_tile(actor));
1505
1506 w = area.w;
1507
1508 /* exit button */
1509 buf = pwindow->prev;
1510 buf->size.x = area.x + area.w - buf->size.w - 1;
1511 buf->size.y = pwindow->size.y + adj_size(2);
1512
1513 /* Production sabotage */
1514 buf = buf->prev;
1515
1516 buf->size.x = area.x;
1517 buf->size.y = y = area.y + 1;
1518 buf->size.w = w;
1519 h = buf->size.h;
1520
1521 area2.x = adj_size(10);
1522 area2.h = adj_size(2);
1523
1524 buf = buf->prev;
1525 while (buf) {
1527 w -= n;
1528 }
1529
1530 buf->size.w = w;
1531 buf->size.x = buf->next->size.x;
1532 buf->size.y = y = y + buf->next->size.h;
1533
1534 if (buf->id == ID_SEPARATOR) {
1535 FREESURFACE(buf->theme);
1536 buf->size.h = h;
1537 buf->theme = create_surf(w, h);
1538
1539 area2.y = buf->size.h / 2 - 1;
1540 area2.w = buf->size.w - adj_size(20);
1541
1542 SDL_FillSurfaceRect(buf->theme , &area2, map_rgba(buf->theme->format,
1544 }
1545
1546 if (buf == last) {
1547 break;
1548 }
1549
1551 /* Reset to end of scrolling area */
1553 + 9 * buf->size.h);
1554 w += n;
1555 }
1556 buf = buf->prev;
1557 }
1558
1559 if (diplomat_dlg->pdialog->scroll) {
1561 area.x + area.w,
1565 TRUE);
1566 }
1567
1568 /* -------------------- */
1569 /* redraw */
1571
1572 widget_flush(pwindow);
1573}
1574
1575/* ====================================================================== */
1576/* ============================== INCITE DIALOG ========================= */
1577/* ====================================================================== */
1579
1580/**********************************************************************/
1583static int incite_dlg_window_callback(struct widget *pwindow)
1584{
1587 }
1588
1589 return -1;
1590}
1591
1592/**********************************************************************/
1595static int diplomat_incite_yes_callback(struct widget *pwidget)
1596{
1601 incite_dlg->target_id, 0, "");
1602 }
1603
1605 }
1606
1607 return -1;
1608}
1609
1610/**********************************************************************/
1613static int exit_incite_dlg_callback(struct widget *pwidget)
1614{
1617 }
1618
1619 return -1;
1620}
1621
1622/**********************************************************************/
1639
1640/**********************************************************************/
1644void popup_incite_dialog(struct unit *actor, struct city *pcity, int cost,
1645 const struct action *paction)
1646{
1647 struct widget *pwindow = NULL, *buf = NULL;
1648 utf8_str *pstr;
1649 char tBuf[255], cbuf[255];
1650 bool exit = FALSE;
1651 SDL_Rect area;
1652
1653 if (incite_dlg) {
1654 return;
1655 }
1656
1657 /* Should be set before sending request to the server. */
1659
1660 if (!actor || !unit_can_do_action(actor, paction->id)) {
1662 return;
1663 }
1664
1666
1667 incite_dlg = fc_calloc(1, sizeof(struct small_diplomat_dialog));
1670 incite_dlg->act_id = paction->id;
1671 incite_dlg->pdialog = fc_calloc(1, sizeof(struct small_dialog));
1672
1673 fc_snprintf(tBuf, ARRAY_SIZE(tBuf), PL_("Treasury contains %d gold.",
1674 "Treasury contains %d gold.",
1675 client_player()->economic.gold),
1676 client_player()->economic.gold);
1677
1678 /* Window */
1679 pstr = create_utf8_from_char_fonto(_("Incite a Revolt!"), FONTO_ATTENTION);
1680
1681 pstr->style |= TTF_STYLE_BOLD;
1682
1683 pwindow = create_window_skeleton(NULL, pstr, 0);
1684
1686 set_wstate(pwindow, FC_WS_NORMAL);
1687
1690
1691 area = pwindow->area;
1692 area.w = MAX(area.w, adj_size(8));
1693 area.h = MAX(area.h, adj_size(2));
1694
1696 /* Exit button */
1697 buf = create_themeicon(current_theme->small_cancel_icon, pwindow->dst,
1700 buf->info_label = create_utf8_from_char_fonto(_("Close Dialog (Esc)"),
1702 area.w += buf->size.w + adj_size(10);
1703 buf->action = exit_incite_dlg_callback;
1705 buf->key = SDLK_ESCAPE;
1706
1708 exit = TRUE;
1709 /* --------------- */
1710
1711 fc_snprintf(cbuf, sizeof(cbuf), _("You can't incite a revolt in %s."),
1713
1715
1717
1718 area.w = MAX(area.w , buf->size.w);
1719 area.h += buf->size.h;
1720 /*------------*/
1722 _("City can't be incited!"), NULL);
1723
1725
1726 area.w = MAX(area.w, buf->size.w);
1727 area.h += buf->size.h;
1728
1729 } else if (cost <= client_player()->economic.gold) {
1730 fc_snprintf(cbuf, sizeof(cbuf),
1731 /* TRANS: %s is pre-pluralised "Treasury contains %d gold." */
1732 PL_("Incite a revolt for %d gold?\n%s",
1733 "Incite a revolt for %d gold?\n%s", cost), cost, tBuf);
1734
1736
1738
1739 area.w = MAX(area.w, buf->size.w);
1740 area.h += buf->size.h;
1741
1742 /*------------*/
1745
1746 buf->data.city = pcity;
1748
1750
1751 area.w = MAX(area.w, buf->size.w);
1752 area.h += buf->size.h;
1753 /* ------- */
1756
1758 buf->key = SDLK_ESCAPE;
1759
1761
1762 area.w = MAX(area.w, buf->size.w);
1763 area.h += buf->size.h;
1764
1765 } else {
1766 /* Exit button */
1767 buf = create_themeicon(current_theme->small_cancel_icon, pwindow->dst,
1770 buf->info_label = create_utf8_from_char_fonto(_("Close Dialog (Esc)"),
1772 area.w += buf->size.w + adj_size(10);
1773 buf->action = exit_incite_dlg_callback;
1775 buf->key = SDLK_ESCAPE;
1776
1778 exit = TRUE;
1779 /* --------------- */
1780
1781 fc_snprintf(cbuf, sizeof(cbuf),
1782 /* TRANS: %s is pre-pluralised "Treasury contains %d gold." */
1783 PL_("Inciting a revolt costs %d gold.\n%s",
1784 "Inciting a revolt costs %d gold.\n%s", cost), cost, tBuf);
1785
1787
1789
1790 area.w = MAX(area.w, buf->size.w);
1791 area.h += buf->size.h;
1792
1793 /*------------*/
1795 _("Traitors Demand Too Much!"), NULL);
1796
1798
1799 area.w = MAX(area.w, buf->size.w);
1800 area.h += buf->size.h;
1801 }
1803
1804 /* setup window size and start position */
1805
1806 resize_window(pwindow, NULL, NULL,
1807 (pwindow->size.w - pwindow->area.w) + area.w,
1808 (pwindow->size.h - pwindow->area.h) + area.h);
1809
1810 area = pwindow->area;
1811
1813 put_window_near_map_tile(pwindow, pwindow->size.w, pwindow->size.h,
1814 pcity->tile);
1815
1816 /* setup widget size and start position */
1817 buf = pwindow;
1818
1819 if (exit) {
1820 /* exit button */
1821 buf = buf->prev;
1822 buf->size.x = area.x + area.w - buf->size.w - 1;
1823 buf->size.y = pwindow->size.y + adj_size(2);
1824 }
1825
1826 buf = buf->prev;
1828 area.x,
1829 area.y + 1, area.w, 0,
1831
1832 /* --------------------- */
1833 /* redraw */
1835
1836 widget_flush(pwindow);
1837}
1838
1839/* ====================================================================== */
1840/* ============================ BRIBE DIALOG ========================== */
1841/* ====================================================================== */
1843
1844/**********************************************************************/
1847static int bribe_dlg_window_callback(struct widget *pwindow)
1848{
1851 }
1852
1853 return -1;
1854}
1855
1856/**********************************************************************/
1859static int diplomat_bribe_unit_yes_callback(struct widget *pwidget)
1860{
1865 bribe_dlg->target_id, 0, "");
1866 }
1868 }
1869
1870 return -1;
1871}
1872
1873/**********************************************************************/
1877{
1881 bribe_dlg->target_id, 0, "");
1882 }
1884 }
1885
1886 return -1;
1887}
1888
1889/**********************************************************************/
1892static int exit_bribe_dlg_callback(struct widget *pwidget)
1893{
1896 }
1897
1898 return -1;
1899}
1900
1901/**********************************************************************/
1918
1919/**********************************************************************/
1924 const struct action *paction)
1925{
1926 struct widget *pwindow = NULL, *buf = NULL;
1927 utf8_str *pstr;
1928 char tBuf[255], cbuf[255];
1929 bool exit = FALSE;
1930 SDL_Rect area;
1931
1932 if (bribe_dlg) {
1933 return;
1934 }
1935
1936 /* Should be set before sending request to the server. */
1938
1939 if (!actor || !unit_can_do_action(actor, paction->id)) {
1941 return;
1942 }
1943
1945
1946 bribe_dlg = fc_calloc(1, sizeof(struct small_diplomat_dialog));
1947 bribe_dlg->act_id = paction->id;
1950 bribe_dlg->pdialog = fc_calloc(1, sizeof(struct small_dialog));
1951
1952 fc_snprintf(tBuf, ARRAY_SIZE(tBuf), PL_("Treasury contains %d gold.",
1953 "Treasury contains %d gold.",
1954 client_player()->economic.gold),
1955 client_player()->economic.gold);
1956
1957 /* Window */
1958 pstr = create_utf8_from_char_fonto(_("Bribe Enemy Unit"), FONTO_ATTENTION);
1959
1960 pstr->style |= TTF_STYLE_BOLD;
1961
1962 pwindow = create_window_skeleton(NULL, pstr, 0);
1963
1965 set_wstate(pwindow, FC_WS_NORMAL);
1966
1968 bribe_dlg->pdialog->end_widget_list = pwindow;
1969
1970 area = pwindow->area;
1971 area.w = MAX(area.w, adj_size(8));
1972 area.h = MAX(area.h, adj_size(2));
1973
1974 if (cost <= client_player()->economic.gold) {
1975 fc_snprintf(cbuf, sizeof(cbuf),
1976 /* TRANS: %s is pre-pluralised "Treasury contains %d gold." */
1977 PL_("Bribe unit for %d gold?\n%s",
1978 "Bribe unit for %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 /*------------*/
1990 buf->data.unit = punit;
1992
1994
1995 area.w = MAX(area.w, buf->size.w);
1996 area.h += buf->size.h;
1997 /* ------- */
1999 _("No"), exit_bribe_dlg_callback);
2000
2002 buf->key = SDLK_ESCAPE;
2003
2005
2006 area.w = MAX(area.w, buf->size.w);
2007 area.h += buf->size.h;
2008
2009 } else {
2010 /* Exit button */
2011 buf = create_themeicon(current_theme->small_cancel_icon, pwindow->dst,
2014 buf->info_label = create_utf8_from_char_fonto(_("Close Dialog (Esc)"),
2016 area.w += buf->size.w + adj_size(10);
2017 buf->action = exit_bribe_dlg_callback;
2019 buf->key = SDLK_ESCAPE;
2020
2022 exit = TRUE;
2023 /* --------------- */
2024
2025 fc_snprintf(cbuf, sizeof(cbuf),
2026 /* TRANS: %s is pre-pluralised "Treasury contains %d gold." */
2027 PL_("Bribing the unit costs %d gold.\n%s",
2028 "Bribing the unit costs %d gold.\n%s", cost), cost, tBuf);
2029
2031
2033
2034 area.w = MAX(area.w, buf->size.w);
2035 area.h += buf->size.h;
2036
2037 /*------------*/
2039 _("Traitors Demand Too Much!"), NULL);
2040
2042
2043 area.w = MAX(area.w, buf->size.w);
2044 area.h += buf->size.h;
2045 }
2047
2048 /* Setup window size and start position */
2049
2050 resize_window(pwindow, NULL, NULL,
2051 (pwindow->size.w - pwindow->area.w) + area.w,
2052 (pwindow->size.h - pwindow->area.h) + area.h);
2053
2054 area = pwindow->area;
2055
2057 put_window_near_map_tile(pwindow, pwindow->size.w, pwindow->size.h,
2058 unit_tile(actor));
2059
2060 /* Setup widget size and start position */
2061 buf = pwindow;
2062
2063 if (exit) {
2064 /* Exit button */
2065 buf = buf->prev;
2066 buf->size.x = area.x + area.w - buf->size.w - 1;
2067 buf->size.y = pwindow->size.y + adj_size(2);
2068 }
2069
2070 buf = buf->prev;
2072 area.x,
2073 area.y + 1, area.w, 0,
2075
2076 /* --------------------- */
2077 /* Redraw */
2079
2080 widget_flush(pwindow);
2081}
2082
2083/**********************************************************************/
2087void popup_bribe_stack_dialog(struct unit *actor, struct tile *ptile, int cost,
2088 const struct action *paction)
2089{
2090 struct widget *pwindow = NULL, *buf = NULL;
2091 utf8_str *pstr;
2092 char tBuf[255], cbuf[255];
2093 bool exit = FALSE;
2094 SDL_Rect area;
2095
2096 if (bribe_dlg) {
2097 return;
2098 }
2099
2100 /* Should be set before sending request to the server. */
2102
2103 if (!actor || !unit_can_do_action(actor, paction->id)) {
2105 return;
2106 }
2107
2109
2110 bribe_dlg = fc_calloc(1, sizeof(struct small_diplomat_dialog));
2111 bribe_dlg->act_id = paction->id;
2113 bribe_dlg->target_id = ptile->index;
2114 bribe_dlg->pdialog = fc_calloc(1, sizeof(struct small_dialog));
2115
2116 fc_snprintf(tBuf, ARRAY_SIZE(tBuf), PL_("Treasury contains %d gold.",
2117 "Treasury contains %d gold.",
2118 client_player()->economic.gold),
2119 client_player()->economic.gold);
2120
2121 /* Window */
2122 pstr = create_utf8_from_char_fonto(_("Bribe Enemy Stack"), FONTO_ATTENTION);
2123
2124 pstr->style |= TTF_STYLE_BOLD;
2125
2126 pwindow = create_window_skeleton(NULL, pstr, 0);
2127
2129 set_wstate(pwindow, FC_WS_NORMAL);
2130
2132 bribe_dlg->pdialog->end_widget_list = pwindow;
2133
2134 area = pwindow->area;
2135 area.w = MAX(area.w, adj_size(8));
2136 area.h = MAX(area.h, adj_size(2));
2137
2138 if (cost <= client_player()->economic.gold) {
2139 fc_snprintf(cbuf, sizeof(cbuf),
2140 /* TRANS: %s is pre-pluralised "Treasury contains %d gold." */
2141 PL_("Bribe unit stack for %d gold?\n%s",
2142 "Bribe unit stack for %d gold?\n%s", cost), cost, tBuf);
2143
2145
2147
2148 area.w = MAX(area.w, buf->size.w);
2149 area.h += buf->size.h;
2150
2151 /*------------*/
2154 buf->data.tile = ptile;
2156
2158
2159 area.w = MAX(area.w, buf->size.w);
2160 area.h += buf->size.h;
2161 /* ------- */
2163 _("No"), exit_bribe_dlg_callback);
2164
2166 buf->key = SDLK_ESCAPE;
2167
2169
2170 area.w = MAX(area.w, buf->size.w);
2171 area.h += buf->size.h;
2172
2173 } else {
2174 /* Exit button */
2175 buf = create_themeicon(current_theme->small_cancel_icon, pwindow->dst,
2178 buf->info_label = create_utf8_from_char_fonto(_("Close Dialog (Esc)"),
2180 area.w += buf->size.w + adj_size(10);
2181 buf->action = exit_bribe_dlg_callback;
2183 buf->key = SDLK_ESCAPE;
2184
2186 exit = TRUE;
2187 /* --------------- */
2188
2189 fc_snprintf(cbuf, sizeof(cbuf),
2190 /* TRANS: %s is pre-pluralised "Treasury contains %d gold." */
2191 PL_("Bribing the unit stack costs %d gold.\n%s",
2192 "Bribing the unit stack costs %d gold.\n%s", cost), cost, tBuf);
2193
2195
2197
2198 area.w = MAX(area.w, buf->size.w);
2199 area.h += buf->size.h;
2200
2201 /*------------*/
2203 _("Traitors Demand Too Much!"), NULL);
2204
2206
2207 area.w = MAX(area.w, buf->size.w);
2208 area.h += buf->size.h;
2209 }
2211
2212 /* Setup window size and start position */
2213
2214 resize_window(pwindow, NULL, NULL,
2215 (pwindow->size.w - pwindow->area.w) + area.w,
2216 (pwindow->size.h - pwindow->area.h) + area.h);
2217
2218 area = pwindow->area;
2219
2221 put_window_near_map_tile(pwindow, pwindow->size.w, pwindow->size.h,
2222 unit_tile(actor));
2223
2224 /* Setup widget size and start position */
2225 buf = pwindow;
2226
2227 if (exit) {
2228 /* Exit button */
2229 buf = buf->prev;
2230 buf->size.x = area.x + area.w - buf->size.w - 1;
2231 buf->size.y = pwindow->size.y + adj_size(2);
2232 }
2233
2234 buf = buf->prev;
2236 area.x,
2237 area.y + 1, area.w, 0,
2239
2240 /* --------------------- */
2241 /* Redraw */
2243
2244 widget_flush(pwindow);
2245}
const char * action_prepare_ui_name(action_id act_id, const char *mnemonic, const struct act_prob prob, const char *custom)
Definition actions.c:1333
enum action_actor_kind action_get_actor_kind(const struct action *paction)
Definition actions.c:1119
bool action_prob_possible(const struct act_prob probability)
Definition actions.c:5317
enum action_sub_target_kind action_get_sub_target_kind(const struct action *paction)
Definition actions.c:1140
enum action_target_kind action_get_target_kind(const struct action *paction)
Definition actions.c:1129
static struct action * action_by_number(action_id act_id)
Definition actions.h:400
#define action_iterate_end
Definition actions.h:218
#define action_id_get_actor_kind(act_id)
Definition actions.h:413
#define action_iterate(_act_)
Definition actions.h:214
#define action_id_get_target_kind(act_id)
Definition actions.h:417
#define ACTION_NONE
Definition actions.h:59
void astr_free(struct astring *astr)
Definition astring.c:148
void astr_set(struct astring *astr, const char *format,...)
Definition astring.c:251
#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:666
const char * city_name_get(const struct city *pcity)
Definition city.c:1157
#define INCITE_IMPOSSIBLE_COST
Definition city.h:94
#define city_owner(_pcity_)
Definition city.h:564
#define city_built_iterate(_pcity, _p)
Definition city.h:842
#define city_built_iterate_end
Definition city.h:848
struct civclient client
#define client_player()
void client_unit_init_act_prob_cache(struct unit *punit)
Definition climisc.c:1264
char * incite_cost
Definition comments.c:77
void action_selection_no_longer_in_progress(const int old_actor_id)
Definition control.c:1063
void request_do_action(action_id action, int actor_id, int target_id, int sub_tgt, const char *name)
Definition control.c:1742
void request_action_details(action_id action, int actor_id, int target_id)
Definition control.c:1810
void action_decision_clear_want(const int old_actor_id)
Definition control.c:1092
void key_unit_wait(void)
Definition control.c:3554
void auto_center_on_focus_unit(void)
Definition control.c:434
void action_selection_next_in_focus(const int old_actor_id)
Definition control.c:1104
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id popup_bribe_unit_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 struct unit int const struct action *paction popup_sabotage_dialog
Definition dialogs_g.h:76
struct unit struct city struct unit * target_unit
Definition dialogs_g.h:55
popup_action_selection
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 struct unit * actor
Definition dialogs_g.h:72
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 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 struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit int const struct action *paction struct unit struct city * pcity
Definition dialogs_g.h:77
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:161
struct extra_type * extra_by_number(int id)
Definition extras.c:183
#define EXTRA_NONE
Definition extras.h:85
QString current_theme
Definition fc_client.cpp:60
#define NO_TARGET
Definition fc_types.h:215
int Tech_type_id
Definition fc_types.h:238
int action_id
Definition fc_types.h:250
#define IDENTITY_NUMBER_ZERO
Definition fc_types.h:94
#define PL_(String1, String2, n)
Definition fcintl.h:71
#define _(String)
Definition fcintl.h:67
struct civ_game game
Definition game.c:62
struct world wld
Definition game.c:63
struct unit * game_unit_by_number(int id)
Definition game.c:115
struct city * game_city_by_number(int id)
Definition game.c:106
int action_selection_target_extra(void)
static int actor_unit_id
int action_selection_target_tile(void)
int action_selection_actor_unit(void)
void popup_bribe_stack_dialog(struct unit *actor, struct tile *ptile, int cost, const struct action *paction)
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
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:468
const char * title
Definition repodlgs.c:1314
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 diplomat_bribe_unit_callback(struct widget *pwidget)
static int spy_sabotage_request(struct widget *pwidget)
static int diplomat_bribe_stack_callback(struct widget *pwidget)
bool is_unit_move_blocked
Definition gui_main.c:108
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 diplomat_bribe_stack_yes_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_incite_callback(struct widget *pwidget)
int(* act_func)(struct widget *)
static struct small_diplomat_dialog * bribe_dlg
static int diplomat_bribe_unit_yes_callback(struct widget *pwidget)
SDL_Color * get_theme_color(enum theme_color themecolor)
Definition colors.c:47
void put_window_near_map_tile(struct widget *pwindow, int window_width, int window_height, struct tile *ptile)
Definition dialogs.c:109
void popup_unit_upgrade_dlg(struct unit *punit, bool city)
Definition dialogs.c:683
int main_window_width(void)
Definition graphics.c:683
struct sdl2_data main_data
Definition graphics.c:55
SDL_Surface * create_surf(int width, int height, Uint32 flags)
Definition graphics.c:349
int main_window_height(void)
Definition graphics.c:691
#define FREESURFACE(ptr)
Definition graphics.h:322
#define map_rgba(format, color)
Definition graphics.h:315
@ ID_BRIBE_DLG_WINDOW
Definition gui_id.h:212
@ ID_TERRAIN_ADV_DLG_WINDOW
Definition gui_id.h:201
@ ID_CARAVAN_DLG_WINDOW
Definition gui_id.h:205
@ ID_BRIBE_DLG_EXIT_BUTTON
Definition gui_id.h:213
@ ID_INCITE_DLG_WINDOW
Definition gui_id.h:208
@ ID_TERRAIN_ADV_DLG_EXIT_BUTTON
Definition gui_id.h:202
@ ID_DIPLOMAT_DLG_WINDOW
Definition gui_id.h:207
@ ID_SEPARATOR
Definition gui_id.h:28
@ ID_LABEL
Definition gui_id.h:27
@ ID_INCITE_DLG_EXIT_BUTTON
Definition gui_id.h:209
#define adj_size(size)
Definition gui_main.h:145
#define PRESSED_EVENT(event)
Definition gui_main.h:71
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:93
#define SF_CENTER
Definition gui_string.h:40
@ FONTO_DEFAULT
Definition gui_string.h:65
@ FONTO_ATTENTION
Definition gui_string.h:67
#define create_utf8_from_char_fonto(string_in, fonto)
Definition gui_string.h:108
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
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
void add_to_gui_list(widget_id id, struct widget *gui)
Definition widget.c:586
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:1051
Uint16 redraw_group(const struct widget *begin_group_widget_list, const struct widget *end_group_widget_list, int add_to_update)
Definition widget.c:720
void popdown_window_group_dialog(struct widget *begin_group_widget_list, struct widget *end_group_widget_list)
Definition widget.c:983
void move_window_group(struct widget *begin_widget_list, struct widget *pwindow)
Definition widget.c:1039
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)
bool 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)
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:182
#define fc_assert(condition)
Definition log.h:177
#define fc_assert_ret_msg(condition, message,...)
Definition log.h:206
#define fc_assert_action(condition, action)
Definition log.h:188
#define fc_assert_ret_val_msg(condition, val, message,...)
Definition log.h:209
int dsend_packet_city_name_suggestion_req(struct connection *pc, int unit_id)
struct tile * index_to_tile(const struct civ_map *imap, int mindex)
Definition map.c:471
#define fc_calloc(n, esz)
Definition mem.h:38
#define FC_FREE(ptr)
Definition mem.h:41
struct research * research_get(const struct player *pplayer)
Definition research.c:130
enum tech_state research_invention_state(const struct research *presearch, Tech_type_id tech)
Definition research.c:622
bool research_invention_gettable(const struct research *presearch, const Tech_type_id tech, bool allow_holes)
Definition research.c:696
#define ARRAY_SIZE(x)
Definition shared.h:85
#define MIN(x, y)
Definition shared.h:55
#define MAX(x, y)
Definition shared.h:54
struct specialist * specialist_by_number(const Specialist_type_id id)
Definition specialist.c:110
struct sprite int int y
Definition sprite_g.h:31
struct widget * begin_active_widget_list
Definition widget.h:184
struct widget * end_widget_list
Definition widget.h:182
struct widget * end_active_widget_list
Definition widget.h:185
struct widget * active_widget_list
Definition widget.h:186
struct scroll_bar * scroll
Definition widget.h:187
struct widget * begin_widget_list
Definition widget.h:181
Definition city.h:318
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]
int target_ids[ATK_COUNT]
struct advanced_dialog * pdialog
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:50
int index
Definition tile.h:51
Definition unit.h:139
int id
Definition unit.h:146
struct tile * tile
Definition unit.h:141
struct unit::@84::@86 client
struct act_prob * act_prob_cache
Definition unit.h:230
widget_id id
Definition widget.h:155
struct widget * prev
Definition widget.h:114
struct gui_layer * dst
Definition widget.h:116
struct city * city
Definition widget.h:128
struct container * cont
Definition widget.h:127
int(* action)(struct widget *)
Definition widget.h:157
SDL_Rect area
Definition widget.h:149
union widget::@220 data
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:960
#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:110
const char * advance_name_translation(const struct advance *padvance)
Definition tech.c:305
struct advance * valid_advance_by_number(const Tech_type_id id)
Definition tech.c:181
Tech_type_id advance_number(const struct advance *padvance)
Definition tech.c:100
#define advance_index_iterate_max(_start, _index, _max)
Definition tech.h:250
#define advance_index_iterate_max_end
Definition tech.h:256
static Tech_type_id advance_count(void)
Definition tech.h:167
#define A_FIRST
Definition tech.h:44
#define A_UNSET
Definition tech.h:48
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:1763
#define tile_index(_pt_)
Definition tile.h:89
#define TILE_INDEX_NONE
Definition tile.h:48
bool unit_can_do_action(const struct unit *punit, const action_id act_id)
Definition unit.c:402
#define unit_tile(_pu)
Definition unit.h:407
const struct unit_type * unit_type_get(const struct unit *punit)
Definition unittype.c:126
const char * unit_name_translation(const struct unit *punit)
Definition unittype.c:1595
struct advance * utype_primary_tech_req(const struct unit_type *ptype)
Definition unittype.c:2747