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-sdl2 */
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
61
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 pstr = create_utf8_from_char_fonto(_("Select Improvement to Sabotage"),
1366 pstr->style |= TTF_STYLE_BOLD;
1367
1368 pwindow = create_window_skeleton(NULL, pstr, 0);
1369
1371 set_wstate(pwindow, FC_WS_NORMAL);
1372
1375
1376 area = pwindow->area;
1377 area.h = MAX(area.h, adj_size(2));
1378
1379 /* ---------- */
1380 /* Exit button */
1381 buf = create_themeicon(current_theme->small_cancel_icon, pwindow->dst,
1383 buf->info_label = create_utf8_from_char_fonto(_("Close Dialog (Esc)"),
1385 area.w += buf->size.w + adj_size(10);
1388 buf->key = SDLK_ESCAPE;
1389
1391 /* ---------- */
1392
1395 paction->id)])) {
1397 _("City Production"), sabotage_impr_callback);
1398 buf->data.cont = cont;
1401 add_to_gui_list(MAX_ID - 1000, buf);
1402
1403 area.w = MAX(area.w, buf->size.w);
1404 area.h += buf->size.h;
1405
1406 /* separator */
1408
1410 area.h += buf->next->size.h;
1411
1413 }
1414
1415 /* ------------------ */
1416 n = 0;
1417 city_built_iterate(pcity, pimprove) {
1418 if (pimprove->sabotage > 0) {
1420 (char *) city_improvement_name_translation(pcity, pimprove),
1422 buf->data.cont = cont;
1424
1426
1427 area.w = MAX(area.w , buf->size.w);
1428 imp_h += buf->size.h;
1429
1430 if (n > 9) {
1432 }
1433
1434 n++;
1435 /* ----------- */
1436 }
1438
1440
1441 if (n > 0
1444 /* separator */
1446
1448 area.h += buf->next->size.h;
1449 /* ------------------ */
1450 }
1451
1454 struct astring str = ASTRING_INIT;
1455
1456 /* TRANS: %s is a unit name, e.g., Spy */
1457 astr_set(&str, _("At %s's Discretion"), unit_name_translation(actor));
1460 astr_free(&str);
1461
1462 buf->data.cont = cont;
1464
1466
1467 area.w = MAX(area.w, buf->size.w);
1468 area.h += buf->size.h;
1469 }
1470
1471 /* ----------- */
1472
1473 last = buf;
1476
1477 /* ---------- */
1478 if (n > 10) {
1479 imp_h = 10 * buf->size.h;
1480
1482 1, 10, TRUE, TRUE);
1483 area.w += n;
1484 } else {
1485 n = 0;
1486 }
1487 /* ---------- */
1488
1489 area.h += imp_h;
1490
1491 resize_window(pwindow, NULL, NULL,
1492 (pwindow->size.w - pwindow->area.w) + area.w,
1493 (pwindow->size.h - pwindow->area.h) + area.h);
1494
1495 area = pwindow->area;
1496
1498 put_window_near_map_tile(pwindow, pwindow->size.w, pwindow->size.h,
1499 unit_tile(actor));
1500
1501 w = area.w;
1502
1503 /* exit button */
1504 buf = pwindow->prev;
1505 buf->size.x = area.x + area.w - buf->size.w - 1;
1506 buf->size.y = pwindow->size.y + adj_size(2);
1507
1508 /* Production sabotage */
1509 buf = buf->prev;
1510
1511 buf->size.x = area.x;
1512 buf->size.y = y = area.y + 1;
1513 buf->size.w = w;
1514 h = buf->size.h;
1515
1516 area2.x = adj_size(10);
1517 area2.h = adj_size(2);
1518
1519 buf = buf->prev;
1520 while (buf) {
1522 w -= n;
1523 }
1524
1525 buf->size.w = w;
1526 buf->size.x = buf->next->size.x;
1527 buf->size.y = y = y + buf->next->size.h;
1528
1529 if (buf->id == ID_SEPARATOR) {
1530 FREESURFACE(buf->theme);
1531 buf->size.h = h;
1532 buf->theme = create_surf(w, h, SDL_SWSURFACE);
1533
1534 area2.y = buf->size.h / 2 - 1;
1535 area2.w = buf->size.w - adj_size(20);
1536
1537 SDL_FillRect(buf->theme , &area2, map_rgba(buf->theme->format,
1539 }
1540
1541 if (buf == last) {
1542 break;
1543 }
1544
1546 /* Reset to end of scrolling area */
1548 + 9 * buf->size.h);
1549 w += n;
1550 }
1551 buf = buf->prev;
1552 }
1553
1554 if (diplomat_dlg->pdialog->scroll) {
1556 area.x + area.w,
1560 TRUE);
1561 }
1562
1563 /* -------------------- */
1564 /* redraw */
1566
1567 widget_flush(pwindow);
1568}
1569
1570/* ====================================================================== */
1571/* ============================== INCITE DIALOG ========================= */
1572/* ====================================================================== */
1574
1575/**********************************************************************/
1578static int incite_dlg_window_callback(struct widget *pwindow)
1579{
1582 }
1583
1584 return -1;
1585}
1586
1587/**********************************************************************/
1590static int diplomat_incite_yes_callback(struct widget *pwidget)
1591{
1596 incite_dlg->target_id, 0, "");
1597 }
1598
1600 }
1601
1602 return -1;
1603}
1604
1605/**********************************************************************/
1608static int exit_incite_dlg_callback(struct widget *pwidget)
1609{
1612 }
1613
1614 return -1;
1615}
1616
1617/**********************************************************************/
1634
1635/**********************************************************************/
1639void popup_incite_dialog(struct unit *actor, struct city *pcity, int cost,
1640 const struct action *paction)
1641{
1642 struct widget *pwindow = NULL, *buf = NULL;
1643 utf8_str *pstr;
1644 char tBuf[255], cbuf[255];
1645 bool exit = FALSE;
1646 SDL_Rect area;
1647
1648 if (incite_dlg) {
1649 return;
1650 }
1651
1652 /* Should be set before sending request to the server. */
1654
1655 if (!actor || !unit_can_do_action(actor, paction->id)) {
1657 return;
1658 }
1659
1661
1662 incite_dlg = fc_calloc(1, sizeof(struct small_diplomat_dialog));
1665 incite_dlg->act_id = paction->id;
1666 incite_dlg->pdialog = fc_calloc(1, sizeof(struct small_dialog));
1667
1668 fc_snprintf(tBuf, ARRAY_SIZE(tBuf), PL_("Treasury contains %d gold.",
1669 "Treasury contains %d gold.",
1670 client_player()->economic.gold),
1671 client_player()->economic.gold);
1672
1673 /* Window */
1674 pstr = create_utf8_from_char_fonto(_("Incite a Revolt!"), FONTO_ATTENTION);
1675
1676 pstr->style |= TTF_STYLE_BOLD;
1677
1678 pwindow = create_window_skeleton(NULL, pstr, 0);
1679
1681 set_wstate(pwindow, FC_WS_NORMAL);
1682
1685
1686 area = pwindow->area;
1687 area.w = MAX(area.w, adj_size(8));
1688 area.h = MAX(area.h, adj_size(2));
1689
1691 /* Exit button */
1692 buf = create_themeicon(current_theme->small_cancel_icon, pwindow->dst,
1695 buf->info_label = create_utf8_from_char_fonto(_("Close Dialog (Esc)"),
1697 area.w += buf->size.w + adj_size(10);
1698 buf->action = exit_incite_dlg_callback;
1700 buf->key = SDLK_ESCAPE;
1701
1703 exit = TRUE;
1704 /* --------------- */
1705
1706 fc_snprintf(cbuf, sizeof(cbuf), _("You can't incite a revolt in %s."),
1708
1710
1712
1713 area.w = MAX(area.w , buf->size.w);
1714 area.h += buf->size.h;
1715 /*------------*/
1717 _("City can't be incited!"), NULL);
1718
1720
1721 area.w = MAX(area.w, buf->size.w);
1722 area.h += buf->size.h;
1723
1724 } else if (cost <= client_player()->economic.gold) {
1725 fc_snprintf(cbuf, sizeof(cbuf),
1726 /* TRANS: %s is pre-pluralised "Treasury contains %d gold." */
1727 PL_("Incite a revolt for %d gold?\n%s",
1728 "Incite a revolt for %d gold?\n%s", cost), cost, tBuf);
1729
1731
1733
1734 area.w = MAX(area.w, buf->size.w);
1735 area.h += buf->size.h;
1736
1737 /*------------*/
1740
1741 buf->data.city = pcity;
1743
1745
1746 area.w = MAX(area.w, buf->size.w);
1747 area.h += buf->size.h;
1748 /* ------- */
1751
1753 buf->key = SDLK_ESCAPE;
1754
1756
1757 area.w = MAX(area.w, buf->size.w);
1758 area.h += buf->size.h;
1759
1760 } else {
1761 /* Exit button */
1762 buf = create_themeicon(current_theme->small_cancel_icon, pwindow->dst,
1765 buf->info_label = create_utf8_from_char_fonto(_("Close Dialog (Esc)"),
1767 area.w += buf->size.w + adj_size(10);
1768 buf->action = exit_incite_dlg_callback;
1770 buf->key = SDLK_ESCAPE;
1771
1773 exit = TRUE;
1774 /* --------------- */
1775
1776 fc_snprintf(cbuf, sizeof(cbuf),
1777 /* TRANS: %s is pre-pluralised "Treasury contains %d gold." */
1778 PL_("Inciting a revolt costs %d gold.\n%s",
1779 "Inciting a revolt costs %d gold.\n%s", cost), cost, tBuf);
1780
1782
1784
1785 area.w = MAX(area.w, buf->size.w);
1786 area.h += buf->size.h;
1787
1788 /*------------*/
1790 _("Traitors Demand Too Much!"), NULL);
1791
1793
1794 area.w = MAX(area.w, buf->size.w);
1795 area.h += buf->size.h;
1796 }
1798
1799 /* setup window size and start position */
1800
1801 resize_window(pwindow, NULL, NULL,
1802 (pwindow->size.w - pwindow->area.w) + area.w,
1803 (pwindow->size.h - pwindow->area.h) + area.h);
1804
1805 area = pwindow->area;
1806
1808 put_window_near_map_tile(pwindow, pwindow->size.w, pwindow->size.h,
1809 pcity->tile);
1810
1811 /* setup widget size and start position */
1812 buf = pwindow;
1813
1814 if (exit) {
1815 /* exit button */
1816 buf = buf->prev;
1817 buf->size.x = area.x + area.w - buf->size.w - 1;
1818 buf->size.y = pwindow->size.y + adj_size(2);
1819 }
1820
1821 buf = buf->prev;
1823 area.x,
1824 area.y + 1, area.w, 0,
1826
1827 /* --------------------- */
1828 /* redraw */
1830
1831 widget_flush(pwindow);
1832}
1833
1834/* ====================================================================== */
1835/* ============================ BRIBE DIALOG ========================== */
1836/* ====================================================================== */
1838
1839/**********************************************************************/
1842static int bribe_dlg_window_callback(struct widget *pwindow)
1843{
1846 }
1847
1848 return -1;
1849}
1850
1851/**********************************************************************/
1854static int diplomat_bribe_unit_yes_callback(struct widget *pwidget)
1855{
1860 bribe_dlg->target_id, 0, "");
1861 }
1863 }
1864
1865 return -1;
1866}
1867
1868/**********************************************************************/
1872{
1876 bribe_dlg->target_id, 0, "");
1877 }
1879 }
1880
1881 return -1;
1882}
1883
1884/**********************************************************************/
1887static int exit_bribe_dlg_callback(struct widget *pwidget)
1888{
1891 }
1892
1893 return -1;
1894}
1895
1896/**********************************************************************/
1913
1914/**********************************************************************/
1919 const struct action *paction)
1920{
1921 struct widget *pwindow = NULL, *buf = NULL;
1922 utf8_str *pstr;
1923 char tBuf[255], cbuf[255];
1924 bool exit = FALSE;
1925 SDL_Rect area;
1926
1927 if (bribe_dlg) {
1928 return;
1929 }
1930
1931 /* Should be set before sending request to the server. */
1933
1934 if (!actor || !unit_can_do_action(actor, paction->id)) {
1936 return;
1937 }
1938
1940
1941 bribe_dlg = fc_calloc(1, sizeof(struct small_diplomat_dialog));
1942 bribe_dlg->act_id = paction->id;
1945 bribe_dlg->pdialog = fc_calloc(1, sizeof(struct small_dialog));
1946
1947 fc_snprintf(tBuf, ARRAY_SIZE(tBuf), PL_("Treasury contains %d gold.",
1948 "Treasury contains %d gold.",
1949 client_player()->economic.gold),
1950 client_player()->economic.gold);
1951
1952 /* Window */
1953 pstr = create_utf8_from_char_fonto(_("Bribe Enemy Unit"), FONTO_ATTENTION);
1954
1955 pstr->style |= TTF_STYLE_BOLD;
1956
1957 pwindow = create_window_skeleton(NULL, pstr, 0);
1958
1960 set_wstate(pwindow, FC_WS_NORMAL);
1961
1963 bribe_dlg->pdialog->end_widget_list = pwindow;
1964
1965 area = pwindow->area;
1966 area.w = MAX(area.w, adj_size(8));
1967 area.h = MAX(area.h, adj_size(2));
1968
1969 if (cost <= client_player()->economic.gold) {
1970 fc_snprintf(cbuf, sizeof(cbuf),
1971 /* TRANS: %s is pre-pluralised "Treasury contains %d gold." */
1972 PL_("Bribe unit for %d gold?\n%s",
1973 "Bribe unit for %d gold?\n%s", cost), cost, tBuf);
1974
1976
1978
1979 area.w = MAX(area.w, buf->size.w);
1980 area.h += buf->size.h;
1981
1982 /*------------*/
1985 buf->data.unit = punit;
1987
1989
1990 area.w = MAX(area.w, buf->size.w);
1991 area.h += buf->size.h;
1992 /* ------- */
1994 _("No"), exit_bribe_dlg_callback);
1995
1997 buf->key = SDLK_ESCAPE;
1998
2000
2001 area.w = MAX(area.w, buf->size.w);
2002 area.h += buf->size.h;
2003
2004 } else {
2005 /* Exit button */
2006 buf = create_themeicon(current_theme->small_cancel_icon, pwindow->dst,
2009 buf->info_label = create_utf8_from_char_fonto(_("Close Dialog (Esc)"),
2011 area.w += buf->size.w + adj_size(10);
2012 buf->action = exit_bribe_dlg_callback;
2014 buf->key = SDLK_ESCAPE;
2015
2017 exit = TRUE;
2018 /* --------------- */
2019
2020 fc_snprintf(cbuf, sizeof(cbuf),
2021 /* TRANS: %s is pre-pluralised "Treasury contains %d gold." */
2022 PL_("Bribing the unit costs %d gold.\n%s",
2023 "Bribing the unit costs %d gold.\n%s", cost), cost, tBuf);
2024
2026
2028
2029 area.w = MAX(area.w, buf->size.w);
2030 area.h += buf->size.h;
2031
2032 /*------------*/
2034 _("Traitors Demand Too Much!"), NULL);
2035
2037
2038 area.w = MAX(area.w, buf->size.w);
2039 area.h += buf->size.h;
2040 }
2042
2043 /* Setup window size and start position */
2044
2045 resize_window(pwindow, NULL, NULL,
2046 (pwindow->size.w - pwindow->area.w) + area.w,
2047 (pwindow->size.h - pwindow->area.h) + area.h);
2048
2049 area = pwindow->area;
2050
2052 put_window_near_map_tile(pwindow, pwindow->size.w, pwindow->size.h,
2053 unit_tile(actor));
2054
2055 /* Setup widget size and start position */
2056 buf = pwindow;
2057
2058 if (exit) {
2059 /* Exit button */
2060 buf = buf->prev;
2061 buf->size.x = area.x + area.w - buf->size.w - 1;
2062 buf->size.y = pwindow->size.y + adj_size(2);
2063 }
2064
2065 buf = buf->prev;
2067 area.x,
2068 area.y + 1, area.w, 0,
2070
2071 /* --------------------- */
2072 /* Redraw */
2074
2075 widget_flush(pwindow);
2076}
2077
2078
2079/**********************************************************************/
2083void popup_bribe_stack_dialog(struct unit *actor, struct tile *ptile, int cost,
2084 const struct action *paction)
2085{
2086 struct widget *pwindow = NULL, *buf = NULL;
2087 utf8_str *pstr;
2088 char tBuf[255], cbuf[255];
2089 bool exit = FALSE;
2090 SDL_Rect area;
2091
2092 if (bribe_dlg) {
2093 return;
2094 }
2095
2096 /* Should be set before sending request to the server. */
2098
2099 if (!actor || !unit_can_do_action(actor, paction->id)) {
2101 return;
2102 }
2103
2105
2106 bribe_dlg = fc_calloc(1, sizeof(struct small_diplomat_dialog));
2107 bribe_dlg->act_id = paction->id;
2109 bribe_dlg->target_id = ptile->index;
2110 bribe_dlg->pdialog = fc_calloc(1, sizeof(struct small_dialog));
2111
2112 fc_snprintf(tBuf, ARRAY_SIZE(tBuf), PL_("Treasury contains %d gold.",
2113 "Treasury contains %d gold.",
2114 client_player()->economic.gold),
2115 client_player()->economic.gold);
2116
2117 /* Window */
2118 pstr = create_utf8_from_char_fonto(_("Bribe Enemy Stack"), FONTO_ATTENTION);
2119
2120 pstr->style |= TTF_STYLE_BOLD;
2121
2122 pwindow = create_window_skeleton(NULL, pstr, 0);
2123
2125 set_wstate(pwindow, FC_WS_NORMAL);
2126
2128 bribe_dlg->pdialog->end_widget_list = pwindow;
2129
2130 area = pwindow->area;
2131 area.w = MAX(area.w, adj_size(8));
2132 area.h = MAX(area.h, adj_size(2));
2133
2134 if (cost <= client_player()->economic.gold) {
2135 fc_snprintf(cbuf, sizeof(cbuf),
2136 /* TRANS: %s is pre-pluralised "Treasury contains %d gold." */
2137 PL_("Bribe unit stack for %d gold?\n%s",
2138 "Bribe unit stack for %d gold?\n%s", cost), cost, tBuf);
2139
2141
2143
2144 area.w = MAX(area.w, buf->size.w);
2145 area.h += buf->size.h;
2146
2147 /*------------*/
2150 buf->data.tile = ptile;
2152
2154
2155 area.w = MAX(area.w, buf->size.w);
2156 area.h += buf->size.h;
2157 /* ------- */
2159 _("No"), exit_bribe_dlg_callback);
2160
2162 buf->key = SDLK_ESCAPE;
2163
2165
2166 area.w = MAX(area.w, buf->size.w);
2167 area.h += buf->size.h;
2168
2169 } else {
2170 /* Exit button */
2171 buf = create_themeicon(current_theme->small_cancel_icon, pwindow->dst,
2174 buf->info_label = create_utf8_from_char_fonto(_("Close Dialog (Esc)"),
2176 area.w += buf->size.w + adj_size(10);
2177 buf->action = exit_bribe_dlg_callback;
2179 buf->key = SDLK_ESCAPE;
2180
2182 exit = TRUE;
2183 /* --------------- */
2184
2185 fc_snprintf(cbuf, sizeof(cbuf),
2186 /* TRANS: %s is pre-pluralised "Treasury contains %d gold." */
2187 PL_("Bribing the unit stack costs %d gold.\n%s",
2188 "Bribing the unit stack costs %d gold.\n%s", cost), cost, tBuf);
2189
2191
2193
2194 area.w = MAX(area.w, buf->size.w);
2195 area.h += buf->size.h;
2196
2197 /*------------*/
2199 _("Traitors Demand Too Much!"), NULL);
2200
2202
2203 area.w = MAX(area.w, buf->size.w);
2204 area.h += buf->size.h;
2205 }
2207
2208 /* Setup window size and start position */
2209
2210 resize_window(pwindow, NULL, NULL,
2211 (pwindow->size.w - pwindow->area.w) + area.w,
2212 (pwindow->size.h - pwindow->area.h) + area.h);
2213
2214 area = pwindow->area;
2215
2217 put_window_near_map_tile(pwindow, pwindow->size.w, pwindow->size.h,
2218 unit_tile(actor));
2219
2220 /* Setup widget size and start position */
2221 buf = pwindow;
2222
2223 if (exit) {
2224 /* Exit button */
2225 buf = buf->prev;
2226 buf->size.x = area.x + area.w - buf->size.w - 1;
2227 buf->size.y = pwindow->size.y + adj_size(2);
2228 }
2229
2230 buf = buf->prev;
2232 area.x,
2233 area.y + 1, area.w, 0,
2235
2236 /* --------------------- */
2237 /* Redraw */
2239
2240 widget_flush(pwindow);
2241}
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:5306
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:663
const char * city_name_get(const struct city *pcity)
Definition city.c:1137
#define INCITE_IMPOSSIBLE_COST
Definition city.h:94
#define city_owner(_pcity_)
Definition city.h:563
#define city_built_iterate(_pcity, _p)
Definition city.h:835
#define city_built_iterate_end
Definition city.h:841
struct civclient client
#define client_player()
void client_unit_init_act_prob_cache(struct unit *punit)
Definition climisc.c:1259
char * incite_cost
Definition comments.c:76
void action_selection_no_longer_in_progress(const int old_actor_id)
Definition control.c:1051
void request_do_action(action_id action, int actor_id, int target_id, int sub_tgt, const char *name)
Definition control.c:1730
void request_action_details(action_id action, int actor_id, int target_id)
Definition control.c:1798
void action_decision_clear_want(const int old_actor_id)
Definition control.c:1080
void key_unit_wait(void)
Definition control.c:3542
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:1092
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: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 popup_sabotage_dialog
Definition dialogs_g.h:77
struct unit struct city struct unit * target_unit
Definition dialogs_g.h:56
popup_action_selection
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 * actor
Definition dialogs_g.h:73
struct unit * actor_unit
Definition dialogs_g.h:55
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs action_selection_no_longer_in_progress_gui_specific
Definition dialogs_g.h:69
struct unit struct city struct unit struct tile * target_tile
Definition dialogs_g.h:57
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit * punit
Definition dialogs_g.h:74
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:78
struct unit struct city * target_city
Definition dialogs_g.h:56
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit int cost
Definition dialogs_g.h:74
struct unit struct city struct unit struct tile struct extra_type * target_extra
Definition dialogs_g.h:57
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:59
#define NO_TARGET
Definition fc_types.h:214
int Tech_type_id
Definition fc_types.h:237
int action_id
Definition fc_types.h:249
#define IDENTITY_NUMBER_ZERO
Definition fc_types.h:93
#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:116
struct city * game_city_by_number(int id)
Definition game.c:107
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:140
int id
Definition unit.h:147
struct tile * tile
Definition unit.h:142
struct unit::@84::@86 client
struct act_prob * act_prob_cache
Definition unit.h:231
widget_id id
Definition widget.h:155
union widget::@223 data
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
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:107
const char * advance_name_translation(const struct advance *padvance)
Definition tech.c:300
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_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:2742