Freeciv-3.3
Loading...
Searching...
No Matches
action_dialog.c
Go to the documentation of this file.
1/***********************************************************************
2 Freeciv - Copyright (C) 1996-2006 - Freeciv Development Team
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
6 any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12***********************************************************************/
13
14#ifdef HAVE_CONFIG_H
15#include <fc_config.h>
16#endif
17
18/* utility */
19#include "astring.h"
20#include "fcintl.h"
21#include "log.h"
22
23/* common */
24#include "actions.h"
25#include "game.h"
26#include "movement.h"
27#include "research.h"
28#include "traderoutes.h"
29#include "unitlist.h"
30
31/* client */
32#include "client_main.h"
33#include "climisc.h"
34#include "control.h"
35#include "text.h"
36
37/* client/gui-sdl3 */
38#include "citydlg.h"
39#include "colors.h"
40#include "dialogs.h"
41#include "graphics.h"
42#include "gui_id.h"
43#include "gui_tilespec.h"
44#include "mapview.h"
45#include "repodlgs.h"
46#include "themespec.h"
47#include "widget.h"
48
49#include "dialogs_g.h"
50
51typedef int (*act_func)(struct widget *);
52
53struct diplomat_dialog {
54 int actor_unit_id;
59};
60
62 int actor_unit_id;
63 int target_id;
65 struct small_dialog *pdialog;
66};
67
68extern bool is_unit_move_blocked;
69
71void popdown_incite_dialog(void);
72void popdown_bribe_dialog(void);
73
74
77static bool did_not_decide = FALSE;
78
79/**********************************************************************/
83{
85 /* The client isn't waiting for information for any unanswered follow
86 * up questions. */
87
88 struct unit *actor_unit;
89
91 /* The action selection dialog wasn't closed because the actor unit
92 * was lost. */
93
94 /* The probabilities didn't just disappear, right? */
97
99 }
100
101 /* The action selection process is over, at least for now. */
103
104 if (did_not_decide) {
105 /* The action selection dialog was closed but the player didn't
106 * decide what the unit should do. */
107
108 /* Reset so the next action selection dialog does the right thing. */
110 } else {
111 /* An action, or no action at all, was selected. */
114 }
115 }
116}
117
118/**********************************************************************/
122{
123 /* Stop blocking. */
126}
127
128/**********************************************************************/
135{
136 /* Stop assuming the answer to a follow up question will arrive. */
138}
139
140/**********************************************************************/
145{
146 /* Don't add an action mapping here unless the non targeted version is
147 * selectable in the targeted version's target selection dialog. */
148 switch ((enum gen_action)tgt_action_id) {
157 default:
158 /* No non targeted version found. */
159 return ACTION_NONE;
160 }
161}
162
163/**********************************************************************/
168{
169 /* Don't add an action mapping here unless the non targeted version is
170 * selectable in the targeted version's target selection dialog. */
171 switch ((enum gen_action)tgt_action_id) {
178 default:
179 /* No non targeted version found. */
180 return ACTION_NONE;
181 }
182}
183
184/**********************************************************************/
187static int diplomat_dlg_window_callback(struct widget *pwindow)
188{
191 }
192
193 return -1;
194}
195
196/**********************************************************************/
216
217/**********************************************************************/
237
238/**********************************************************************/
259
260/* --------------------------------------------------------- */
261
262/**********************************************************************/
265static int spy_steal_dlg_window_callback(struct widget *pwindow)
266{
269 }
270
271 return -1;
272}
273
274/**********************************************************************/
277static int exit_spy_tgt_dlg_callback(struct widget *pwidget)
278{
280 int actor_id = diplomat_dlg->actor_unit_id;
281
284 act_sel_done_secondary(actor_id);
285 }
286
287 return -1;
288}
289
290/**********************************************************************/
293static int spy_steal_callback(struct widget *pwidget)
294{
296 int steal_advance = MAX_ID - pwidget->id;
297 int actor_id = diplomat_dlg->actor_unit_id;
298
302 if (steal_advance == A_UNSET) {
303 /* This is the untargeted version. */
308 steal_advance, "");
309 } else {
310 /* This is the targeted version. */
314 steal_advance, "");
315 }
316 }
317
320 act_sel_done_secondary(actor_id);
321 }
322
323 return -1;
324}
325
326/**********************************************************************/
329static int spy_steal_popup_shared(struct widget *pwidget)
330{
331 const struct research *presearch, *vresearch;
332 struct city *vcity = pwidget->data.city;
333 int id = diplomat_dlg->actor_unit_id;
334 struct player *victim = NULL;
335 struct container *cont;
336 struct widget *buf = NULL;
337 struct widget *pwindow;
338 utf8_str *pstr;
339 SDL_Surface *surf;
340 int max_col, max_row, col, count = 0;
341 int tech, idx;
343 struct unit *actor_unit = game_unit_by_number(id);
344 action_id act_id = diplomat_dlg->act_id;
346
349
350 if (vcity) {
352 }
353
354 fc_assert_ret_val_msg(!diplomat_dlg, 1, "Diplomat dialog already open");
355
356 if (!victim) {
358 return 1;
359 }
360
361 count = 0;
364 ac = advance_count();
370 count++;
371 }
373
374 if (!count) {
375 /* if there is no known tech to steal then
376 * send steal order at Spy's Discretion */
377 int target_id = vcity->id;
378
380 id, target_id, A_UNSET, "");
381
383
384 return -1;
385 }
386
387 cont = fc_calloc(1, sizeof(struct container));
388 cont->id0 = vcity->id;
389 cont->id1 = id; /* spy id */
390
391 diplomat_dlg = fc_calloc(1, sizeof(struct diplomat_dialog));
392 diplomat_dlg->act_id = act_id;
395 diplomat_dlg->pdialog = fc_calloc(1, sizeof(struct advanced_dialog));
396
397 pstr = create_utf8_from_char_fonto(_("Select Advance to Steal"),
399 pstr->style |= TTF_STYLE_BOLD;
400
401 pwindow = create_window_skeleton(NULL, pstr, 0);
402
404 set_wstate(pwindow , FC_WS_NORMAL);
405
408
409 area = pwindow->area;
410 area.w = MAX(area.w, adj_size(8));
411
412 /* ------------------ */
413 /* Exit button */
414 buf = create_themeicon(current_theme->small_cancel_icon, pwindow->dst,
416 buf->info_label = create_utf8_from_char_fonto(_("Close Dialog (Esc)"),
418 area.w += buf->size.w + adj_size(10);
421 buf->key = SDLK_ESCAPE;
422
424 /* ------------------------- */
425
427 get_non_targeted_action_id(act_id)])) {
428 /* count + at Spy's Discretion */
429 count++;
430 }
431
432 /* max col - 104 is steal tech widget width */
433 max_col = (main_window_width() - (pwindow->size.w - pwindow->area.w) - adj_size(2)) / adj_size(104);
434 /* max row - 204 is steal tech widget height */
435 max_row = (main_window_height() - (pwindow->size.h - pwindow->area.h)) / adj_size(204);
436
437 /* make space on screen for scrollbar */
438 if (max_col * max_row < count) {
439 max_col--;
440 }
441
442 if (count < max_col + 1) {
443 col = count;
444 } else {
445 if (count < max_col + adj_size(3)) {
446 col = max_col - adj_size(2);
447 } else {
448 if (count < max_col + adj_size(5)) {
449 col = max_col - 1;
450 } else {
451 col = max_col;
452 }
453 }
454 }
455
457 pstr->style |= (TTF_STYLE_BOLD | SF_CENTER);
458
459 count = 0;
465 count++;
466
469 buf = create_icon2(surf, pwindow->dst,
471
473 buf->action = spy_steal_callback;
474 buf->data.cont = cont;
475
477
478 if (count > (col * max_row)) {
480 }
481 }
483
484 /* Get Spy tech to use for "At Spy's Discretion" -- this will have the
485 * side effect of displaying the unit's icon */
487
489 get_non_targeted_action_id(act_id)])) {
490 struct astring str = ASTRING_INIT;
491
492 /* TRANS: %s is a unit name, e.g., Spy */
493 astr_set(&str, _("At %s's Discretion"),
496 astr_free(&str);
497
499
500 buf = create_icon2(surf, pwindow->dst,
502 | WF_FREE_DATA));
504 buf->action = spy_steal_callback;
505 buf->data.cont = cont;
506
508 count++;
509 }
510
511 /* --------------------------------------------------------- */
516
517 /* -------------------------------------------------------------- */
518
519 idx = 0;
520 if (count > col) {
521 count = (count + (col - 1)) / col;
522 if (count > max_row) {
524 count = max_row;
526 }
527 } else {
528 count = 1;
529 }
530
531 area.w = MAX(area.w, (col * buf->size.w + adj_size(2) + idx));
532 area.h = count * buf->size.h + adj_size(2);
533
534 /* alloca window theme and win background buffer */
536 if (resize_window(pwindow, surf, NULL,
537 (pwindow->size.w - pwindow->area.w) + area.w,
538 (pwindow->size.h - pwindow->area.h) + area.h)) {
539 FREESURFACE(surf);
540 }
541
542 area = pwindow->area;
543
544 widget_set_position(pwindow,
545 (main_window_width() - pwindow->size.w) / 2,
546 (main_window_height() - pwindow->size.h) / 2);
547
548 /* exit button */
549 buf = pwindow->prev;
550 buf->size.x = area.x + area.w - buf->size.w - 1;
551 buf->size.y = pwindow->size.y + adj_size(2);
552
554 area.y, 0, 0,
557
560 area.x + area.w, area.y,
561 area.h, TRUE);
562 }
563
565 widget_mark_dirty(pwindow);
566
567 return -1;
568}
569
570/**********************************************************************/
573static int spy_steal_popup(struct widget *pwidget)
574{
576 return spy_steal_popup_shared(pwidget);
577}
578
579/**********************************************************************/
582static int spy_steal_esc_popup(struct widget *pwidget)
583{
585 return spy_steal_popup_shared(pwidget);
586}
587
588/**********************************************************************/
609
610/**********************************************************************/
631
632/**********************************************************************/
635static int act_sel_wait_callback(struct widget *pwidget)
636{
639
640 /* The dialog was popped down when key_unit_wait() resulted in
641 * action_selection_close() being called. */
642 }
643
644 return -1;
645}
646
647/**********************************************************************/
668
669/**********************************************************************/
688
689/**********************************************************************/
692static int found_city_callback(struct widget *pwidget)
693{
695 int actor_id = diplomat_dlg->actor_unit_id;
696
699 actor_id);
700 }
701
702 return -1;
703}
704
705/**********************************************************************/
708static int upgrade_callback(struct widget *pwidget)
709{
711 struct unit *punit;
712
716 }
717
719 }
720
721 return -1;
722}
723
724/**********************************************************************/
728static int simple_action_callback(struct widget *pwidget)
729{
730 int actor_id, target_id, sub_target;
731 struct action *paction;
732
733 bool failed = FALSE;
734
736 return -1;
737 }
738
739 /* Data */
740 paction = action_by_number(MAX_ID - pwidget->id);
741
742 /* Actor */
744 actor_id = diplomat_dlg->actor_unit_id;
745 if (NULL == game_unit_by_number(actor_id)) {
746 /* Probably dead. */
747 failed = TRUE;
748 }
749
750 /* Target */
751 target_id = IDENTITY_NUMBER_ZERO;
753 case ATK_CITY:
754 target_id = diplomat_dlg->target_ids[ATK_CITY];
755 if (NULL == game_city_by_number(target_id)) {
756 /* Probably destroyed. */
757 failed = TRUE;
758 }
759 break;
760 case ATK_UNIT:
761 target_id = diplomat_dlg->target_ids[ATK_UNIT];
762 if (NULL == game_unit_by_number(target_id)) {
763 /* Probably dead. */
764 failed = TRUE;
765 }
766 break;
767 case ATK_STACK:
768 case ATK_TILE:
769 case ATK_EXTRAS:
770 target_id = diplomat_dlg->target_ids[ATK_TILE];
771 if (NULL == index_to_tile(&(wld.map), target_id)) {
772 /* TODO: Should this be possible at all? If not: add assertion. */
773 failed = TRUE;
774 }
775 break;
776 case ATK_SELF:
777 target_id = IDENTITY_NUMBER_ZERO;
778 break;
779 case ATK_COUNT:
781 failed = TRUE;
782 }
783
784 /* Sub target. */
785 sub_target = NO_TARGET;
786 if (paction->target_complexity != ACT_TGT_COMPL_SIMPLE) {
788 case ASTK_BUILDING:
790 if (NULL == improvement_by_number(sub_target)) {
791 /* Did the ruleset change? */
792 failed = TRUE;
793 }
794 break;
795 case ASTK_TECH:
796 sub_target = diplomat_dlg->sub_target_id[ASTK_TECH];
797 if (NULL == valid_advance_by_number(sub_target)) {
798 /* Did the ruleset change? */
799 failed = TRUE;
800 }
801 break;
802 case ASTK_EXTRA:
804 /* TODO: validate if the extra is there? */
806 if (NULL == extra_by_number(sub_target)) {
807 /* Did the ruleset change? */
808 failed = TRUE;
809 }
810 break;
811 case ASTK_NONE:
812 case ASTK_COUNT:
813 /* Shouldn't happen. */
815 failed = TRUE;
816 break;
817 }
818 }
819
820 /* Send request. */
821 if (!failed) {
822 request_do_action(paction->id, actor_id, target_id, sub_target, "");
823 }
824
825 /* Clean up. */
827 return -1;
828}
829
830/**********************************************************************/
833static int diplomat_close_callback(struct widget *pwidget)
834{
837 }
838
839 return -1;
840}
841
842/**********************************************************************/
860
861/* Mapping from an action to the function to call when its button is
862 * pushed. */
863static const act_func af_map[ACTION_COUNT] = {
864 /* Unit acting against a city target. */
873
874 /* Unit acting against a unit target. */
876
877 /* Unit acting against all units at a tile. */
879
880 /* Unit acting against a tile. */
882
883 /* Unit acting with no target except itself. */
884 /* No special callback functions needed for any self targeted actions. */
885};
886
887/**********************************************************************/
890static void action_entry(const action_id act,
891 const struct act_prob *act_probs,
892 struct unit *act_unit,
893 struct tile *tgt_tile,
894 struct city *tgt_city,
895 struct unit *tgt_unit,
896 struct widget *pwindow,
897 SDL_Rect *area)
898{
899 struct widget *buf;
900 utf8_str *pstr;
901 const char *ui_name;
902 act_func cb;
903
905 act_probs[act],
906 act_unit,
907 tgt_city);
908
909 if (af_map[act] == NULL) {
910 /* No special call back function needed for this action. */
912 } else {
913 /* Special action specific callback function specified. */
914 cb = af_map[act];
915 }
916
917 /* Don't show disabled actions */
918 if (!action_prob_possible(act_probs[act])) {
919 return;
920 }
921
922 ui_name = action_prepare_ui_name(act, "",
923 act_probs[act], custom);
924
926 ui_name, cb);
927
928 switch (action_id_get_target_kind(act)) {
929 case ATK_CITY:
930 buf->data.city = tgt_city;
931 break;
932 case ATK_UNIT:
933 buf->data.unit = tgt_unit;
934 break;
935 case ATK_TILE:
936 case ATK_EXTRAS:
937 case ATK_STACK:
938 buf->data.tile = tgt_tile;
939 break;
940 case ATK_SELF:
941 buf->data.unit = act_unit;
942 break;
943 case ATK_COUNT:
944 fc_assert_msg(FALSE, "Unsupported target kind");
945 }
946
948
949 add_to_gui_list(MAX_ID - act, buf);
950
951 area->w = MAX(area->w, buf->size.w);
952 area->h += buf->size.h;
953}
954
955/**********************************************************************/
960 struct city *target_city,
961 struct unit *target_unit,
962 struct tile *target_tile,
963 struct extra_type *target_extra,
964 const struct act_prob *act_probs)
965{
966 struct widget *pwindow = NULL, *buf = NULL;
967 utf8_str *pstr;
969
970 fc_assert_ret_msg(!diplomat_dlg, "Diplomat dialog already open");
971
972 /* Could be caused by the server failing to reply to a request for more
973 * information or a bug in the client code. */
975 "Diplomat queue problem. Is another diplomat window open?");
976
977 /* No extra input is required as no action has been chosen yet. */
979
981
982 diplomat_dlg = fc_calloc(1, sizeof(struct diplomat_dialog));
984 diplomat_dlg->pdialog = fc_calloc(1, sizeof(struct advanced_dialog));
985
986 /* window */
987 if (target_city) {
988 struct astring title = ASTRING_INIT;
989
990 /* TRANS: %s is a unit name, e.g., Spy */
991 astr_set(&title, _("Choose Your %s's Strategy"),
995 } else {
996 pstr = create_utf8_from_char_fonto(_("Subvert Enemy Unit"),
998 }
999
1000 pstr->style |= TTF_STYLE_BOLD;
1001
1002 pwindow = create_window_skeleton(NULL, pstr, 0);
1003
1005 set_wstate(pwindow, FC_WS_NORMAL);
1006
1009
1010 area = pwindow->area;
1011 area.w = MAX(area.w, adj_size(8));
1012 area.h = MAX(area.h, adj_size(2));
1013
1014 if (target_city) {
1016 } else {
1018 }
1019
1020 if (target_unit) {
1022 } else {
1024 }
1025
1029
1030 /* No target building or target tech supplied. (Feb 2020) */
1033
1034 if (target_extra) {
1038 } else {
1041 }
1042
1044
1045 /* ---------- */
1046 /* Unit acting against a city */
1047
1048 action_iterate(act) {
1053 pwindow, &area);
1054 }
1056
1057 /* Unit acting against another unit */
1058
1059 action_iterate(act) {
1064 pwindow, &area);
1065 }
1067
1068 /* Unit acting against all units at a tile */
1069
1070 action_iterate(act) {
1075 pwindow, &area);
1076 }
1078
1079 /* Unit acting against a tile. */
1080
1081 action_iterate(act) {
1086 pwindow, &area);
1087 }
1089
1090 /* Unit acting against a tile's extras. */
1091
1092 action_iterate(act) {
1097 pwindow, &area);
1098 }
1100
1101 /* Unit acting against itself. */
1102
1103 action_iterate(act) {
1108 pwindow, &area);
1109 }
1111
1112 /* ---------- */
1114 _("Wait"), act_sel_wait_callback);
1115
1116 buf->data.tile = target_tile;
1117
1119
1121
1122 area.w = MAX(area.w, buf->size.w);
1123 area.h += buf->size.h;
1124
1125 /* ---------- */
1127 _("Cancel"), diplomat_close_callback);
1128
1130 buf->key = SDLK_ESCAPE;
1131
1133
1134 area.w = MAX(area.w, buf->size.w);
1135 area.h += buf->size.h;
1136 /* ---------- */
1138
1139 /* setup window size and start position */
1140
1141 resize_window(pwindow, NULL, NULL,
1142 (pwindow->size.w - pwindow->area.w) + area.w,
1143 (pwindow->size.h - pwindow->area.h) + area.h);
1144
1145 area = pwindow->area;
1146
1148 put_window_near_map_tile(pwindow, pwindow->size.w, pwindow->size.h,
1150
1151 /* setup widget size and start position */
1152
1153 buf = pwindow->prev;
1155 area.x,
1156 area.y + 1, area.w, 0,
1158
1159 /* --------------------- */
1160 /* redraw */
1162
1163 widget_flush(pwindow);
1164
1165 /* Give follow up questions access to action probabilities. */
1167 action_iterate(act) {
1170}
1171
1172/**********************************************************************/
1178{
1179 if (!diplomat_dlg) {
1180 return IDENTITY_NUMBER_ZERO;
1181 }
1182
1184}
1185
1186/**********************************************************************/
1193{
1194 if (!diplomat_dlg) {
1195 return IDENTITY_NUMBER_ZERO;
1196 }
1197
1199}
1200
1201/**********************************************************************/
1208{
1209 if (!diplomat_dlg) {
1210 return IDENTITY_NUMBER_ZERO;
1211 }
1212
1214}
1215
1216/**********************************************************************/
1223{
1224 if (!diplomat_dlg) {
1225 return TILE_INDEX_NONE;
1226 }
1227
1229}
1230
1231/**********************************************************************/
1238{
1239 if (!diplomat_dlg) {
1240 return EXTRA_NONE;
1241 }
1242
1244}
1245
1246/**********************************************************************/
1250 struct city *target_city,
1251 struct unit *target_unit,
1252 struct tile *target_tile,
1253 struct extra_type *target_extra,
1254 const struct act_prob *act_probs)
1255{
1260 act_probs);
1261}
1262
1263/**********************************************************************/
1271
1272/* ====================================================================== */
1273/* ============================ SABOTAGE DIALOG ========================= */
1274/* ====================================================================== */
1275
1276/**********************************************************************/
1279static int sabotage_impr_callback(struct widget *pwidget)
1280{
1282 int sabotage_improvement = MAX_ID - pwidget->id;
1283 int diplomat_target_id = pwidget->data.cont->id0;
1284 int diplomat_id = pwidget->data.cont->id1;
1285 action_id act_id = pwidget->data.cont->value;
1286
1289
1290 if (sabotage_improvement == 1000) {
1292 }
1293
1297 /* This is the untargeted version. */
1301 } else if (sabotage_improvement == -1) {
1302 /* This is the city production version. */
1306 } else {
1307 /* This is the targeted version. */
1308 request_do_action(act_id,
1311 }
1312 }
1313
1315 }
1316
1317 return -1;
1318}
1319
1320/**********************************************************************/
1325 const struct action *paction)
1326{
1327 struct widget *pwindow = NULL, *buf = NULL , *last = NULL;
1328 struct container *cont;
1329 utf8_str *pstr;
1330 SDL_Rect area, area2;
1331 int n, w = 0, h, imp_h = 0, y;
1332
1333 fc_assert_ret_msg(!diplomat_dlg, "Diplomat dialog already open");
1334
1335 /* Should be set before sending request to the server. */
1337
1338 if (!actor) {
1340 return;
1341 }
1342
1344
1345 diplomat_dlg = fc_calloc(1, sizeof(struct diplomat_dialog));
1348 diplomat_dlg->pdialog = fc_calloc(1, sizeof(struct advanced_dialog));
1349
1350 cont = fc_calloc(1, sizeof(struct container));
1351 cont->id0 = pcity->id;
1352 cont->id1 = actor->id; /* Spy id */
1353 cont->value = paction->id;
1354
1355 pstr = create_utf8_from_char_fonto(_("Select Improvement to Sabotage"),
1357 pstr->style |= TTF_STYLE_BOLD;
1358
1359 pwindow = create_window_skeleton(NULL, pstr, 0);
1360
1362 set_wstate(pwindow, FC_WS_NORMAL);
1363
1366
1367 area = pwindow->area;
1368 area.h = MAX(area.h, adj_size(2));
1369
1370 /* ---------- */
1371 /* Exit button */
1372 buf = create_themeicon(current_theme->small_cancel_icon, pwindow->dst,
1374 buf->info_label = create_utf8_from_char_fonto(_("Close Dialog (Esc)"),
1376 area.w += buf->size.w + adj_size(10);
1379 buf->key = SDLK_ESCAPE;
1380
1382 /* ---------- */
1383
1386 paction->id)])) {
1388 _("City Production"), sabotage_impr_callback);
1389 buf->data.cont = cont;
1392 add_to_gui_list(MAX_ID - 1000, buf);
1393
1394 area.w = MAX(area.w, buf->size.w);
1395 area.h += buf->size.h;
1396
1397 /* separator */
1399
1401 area.h += buf->next->size.h;
1402
1404 }
1405
1406 /* ------------------ */
1407 n = 0;
1408 city_built_iterate(pcity, pimprove) {
1409 if (pimprove->sabotage > 0) {
1411 (char *) city_improvement_name_translation(pcity, pimprove),
1413 buf->data.cont = cont;
1415
1417
1418 area.w = MAX(area.w , buf->size.w);
1419 imp_h += buf->size.h;
1420
1421 if (n > 9) {
1423 }
1424
1425 n++;
1426 /* ----------- */
1427 }
1429
1431
1432 if (n > 0
1435 /* separator */
1437
1439 area.h += buf->next->size.h;
1440 /* ------------------ */
1441 }
1442
1445 struct astring str = ASTRING_INIT;
1446
1447 /* TRANS: %s is a unit name, e.g., Spy */
1448 astr_set(&str, _("At %s's Discretion"), unit_name_translation(actor));
1451 astr_free(&str);
1452
1453 buf->data.cont = cont;
1455
1457
1458 area.w = MAX(area.w, buf->size.w);
1459 area.h += buf->size.h;
1460 }
1461
1462 /* ----------- */
1463
1464 last = buf;
1467
1468 /* ---------- */
1469 if (n > 10) {
1470 imp_h = 10 * buf->size.h;
1471
1473 1, 10, TRUE, TRUE);
1474 area.w += n;
1475 } else {
1476 n = 0;
1477 }
1478 /* ---------- */
1479
1480 area.h += imp_h;
1481
1482 resize_window(pwindow, NULL, NULL,
1483 (pwindow->size.w - pwindow->area.w) + area.w,
1484 (pwindow->size.h - pwindow->area.h) + area.h);
1485
1486 area = pwindow->area;
1487
1489 put_window_near_map_tile(pwindow, pwindow->size.w, pwindow->size.h,
1490 unit_tile(actor));
1491
1492 w = area.w;
1493
1494 /* exit button */
1495 buf = pwindow->prev;
1496 buf->size.x = area.x + area.w - buf->size.w - 1;
1497 buf->size.y = pwindow->size.y + adj_size(2);
1498
1499 /* Production sabotage */
1500 buf = buf->prev;
1501
1502 buf->size.x = area.x;
1503 buf->size.y = y = area.y + 1;
1504 buf->size.w = w;
1505 h = buf->size.h;
1506
1507 area2.x = adj_size(10);
1508 area2.h = adj_size(2);
1509
1510 buf = buf->prev;
1511 while (buf) {
1513 w -= n;
1514 }
1515
1516 buf->size.w = w;
1517 buf->size.x = buf->next->size.x;
1518 buf->size.y = y = y + buf->next->size.h;
1519
1520 if (buf->id == ID_SEPARATOR) {
1521 FREESURFACE(buf->theme);
1522 buf->size.h = h;
1523 buf->theme = create_surf(w, h);
1524
1525 area2.y = buf->size.h / 2 - 1;
1526 area2.w = buf->size.w - adj_size(20);
1527
1528 SDL_FillSurfaceRect(buf->theme , &area2, map_rgba(buf->theme->format,
1530 }
1531
1532 if (buf == last) {
1533 break;
1534 }
1535
1537 /* Reset to end of scrolling area */
1539 + 9 * buf->size.h);
1540 w += n;
1541 }
1542 buf = buf->prev;
1543 }
1544
1545 if (diplomat_dlg->pdialog->scroll) {
1547 area.x + area.w,
1551 TRUE);
1552 }
1553
1554 /* -------------------- */
1555 /* redraw */
1557
1558 widget_flush(pwindow);
1559}
1560
1561/* ====================================================================== */
1562/* ============================== INCITE DIALOG ========================= */
1563/* ====================================================================== */
1565
1566/**********************************************************************/
1569static int incite_dlg_window_callback(struct widget *pwindow)
1570{
1573 }
1574
1575 return -1;
1576}
1577
1578/**********************************************************************/
1581static int diplomat_incite_yes_callback(struct widget *pwidget)
1582{
1587 incite_dlg->target_id, 0, "");
1588 }
1589
1591 }
1592
1593 return -1;
1594}
1595
1596/**********************************************************************/
1599static int exit_incite_dlg_callback(struct widget *pwidget)
1600{
1603 }
1604
1605 return -1;
1606}
1607
1608/**********************************************************************/
1625
1626/**********************************************************************/
1630void popup_incite_dialog(struct unit *actor, struct city *pcity, int cost,
1631 const struct action *paction)
1632{
1633 struct widget *pwindow = NULL, *buf = NULL;
1634 utf8_str *pstr;
1635 char tBuf[255], cbuf[255];
1636 bool exit = FALSE;
1637 SDL_Rect area;
1638
1639 if (incite_dlg) {
1640 return;
1641 }
1642
1643 /* Should be set before sending request to the server. */
1645
1646 if (!actor || !unit_can_do_action(actor, paction->id)) {
1648 return;
1649 }
1650
1652
1653 incite_dlg = fc_calloc(1, sizeof(struct small_diplomat_dialog));
1656 incite_dlg->act_id = paction->id;
1657 incite_dlg->pdialog = fc_calloc(1, sizeof(struct small_dialog));
1658
1659 fc_snprintf(tBuf, ARRAY_SIZE(tBuf), PL_("Treasury contains %d gold.",
1660 "Treasury contains %d gold.",
1661 client_player()->economic.gold),
1662 client_player()->economic.gold);
1663
1664 /* Window */
1665 pstr = create_utf8_from_char_fonto(_("Incite a Revolt!"), FONTO_ATTENTION);
1666
1667 pstr->style |= TTF_STYLE_BOLD;
1668
1669 pwindow = create_window_skeleton(NULL, pstr, 0);
1670
1672 set_wstate(pwindow, FC_WS_NORMAL);
1673
1676
1677 area = pwindow->area;
1678 area.w = MAX(area.w, adj_size(8));
1679 area.h = MAX(area.h, adj_size(2));
1680
1682 /* Exit button */
1683 buf = create_themeicon(current_theme->small_cancel_icon, pwindow->dst,
1686 buf->info_label = create_utf8_from_char_fonto(_("Close Dialog (Esc)"),
1688 area.w += buf->size.w + adj_size(10);
1689 buf->action = exit_incite_dlg_callback;
1691 buf->key = SDLK_ESCAPE;
1692
1694 exit = TRUE;
1695 /* --------------- */
1696
1697 fc_snprintf(cbuf, sizeof(cbuf), _("You can't incite a revolt in %s."),
1699
1701
1703
1704 area.w = MAX(area.w , buf->size.w);
1705 area.h += buf->size.h;
1706 /*------------*/
1708 _("City can't be incited!"), NULL);
1709
1711
1712 area.w = MAX(area.w, buf->size.w);
1713 area.h += buf->size.h;
1714
1715 } else if (cost <= client_player()->economic.gold) {
1716 fc_snprintf(cbuf, sizeof(cbuf),
1717 /* TRANS: %s is pre-pluralised "Treasury contains %d gold." */
1718 PL_("Incite a revolt for %d gold?\n%s",
1719 "Incite a revolt for %d gold?\n%s", cost), cost, tBuf);
1720
1722
1724
1725 area.w = MAX(area.w, buf->size.w);
1726 area.h += buf->size.h;
1727
1728 /*------------*/
1731
1732 buf->data.city = pcity;
1734
1736
1737 area.w = MAX(area.w, buf->size.w);
1738 area.h += buf->size.h;
1739 /* ------- */
1742
1744 buf->key = SDLK_ESCAPE;
1745
1747
1748 area.w = MAX(area.w, buf->size.w);
1749 area.h += buf->size.h;
1750
1751 } else {
1752 /* Exit button */
1753 buf = create_themeicon(current_theme->small_cancel_icon, pwindow->dst,
1756 buf->info_label = create_utf8_from_char_fonto(_("Close Dialog (Esc)"),
1758 area.w += buf->size.w + adj_size(10);
1759 buf->action = exit_incite_dlg_callback;
1761 buf->key = SDLK_ESCAPE;
1762
1764 exit = TRUE;
1765 /* --------------- */
1766
1767 fc_snprintf(cbuf, sizeof(cbuf),
1768 /* TRANS: %s is pre-pluralised "Treasury contains %d gold." */
1769 PL_("Inciting a revolt costs %d gold.\n%s",
1770 "Inciting a revolt costs %d gold.\n%s", cost), cost, tBuf);
1771
1773
1775
1776 area.w = MAX(area.w, buf->size.w);
1777 area.h += buf->size.h;
1778
1779 /*------------*/
1781 _("Traitors Demand Too Much!"), NULL);
1782
1784
1785 area.w = MAX(area.w, buf->size.w);
1786 area.h += buf->size.h;
1787 }
1789
1790 /* setup window size and start position */
1791
1792 resize_window(pwindow, NULL, NULL,
1793 (pwindow->size.w - pwindow->area.w) + area.w,
1794 (pwindow->size.h - pwindow->area.h) + area.h);
1795
1796 area = pwindow->area;
1797
1799 put_window_near_map_tile(pwindow, pwindow->size.w, pwindow->size.h,
1800 pcity->tile);
1801
1802 /* setup widget size and start position */
1803 buf = pwindow;
1804
1805 if (exit) {
1806 /* exit button */
1807 buf = buf->prev;
1808 buf->size.x = area.x + area.w - buf->size.w - 1;
1809 buf->size.y = pwindow->size.y + adj_size(2);
1810 }
1811
1812 buf = buf->prev;
1814 area.x,
1815 area.y + 1, area.w, 0,
1817
1818 /* --------------------- */
1819 /* redraw */
1821
1822 widget_flush(pwindow);
1823}
1824
1825/* ====================================================================== */
1826/* ============================ BRIBE DIALOG ========================== */
1827/* ====================================================================== */
1829
1830/**********************************************************************/
1833static int bribe_dlg_window_callback(struct widget *pwindow)
1834{
1837 }
1838
1839 return -1;
1840}
1841
1842/**********************************************************************/
1845static int diplomat_bribe_unit_yes_callback(struct widget *pwidget)
1846{
1851 bribe_dlg->target_id, 0, "");
1852 }
1854 }
1855
1856 return -1;
1857}
1858
1859/**********************************************************************/
1863{
1867 bribe_dlg->target_id, 0, "");
1868 }
1870 }
1871
1872 return -1;
1873}
1874
1875/**********************************************************************/
1878static int exit_bribe_dlg_callback(struct widget *pwidget)
1879{
1882 }
1883
1884 return -1;
1885}
1886
1887/**********************************************************************/
1904
1905/**********************************************************************/
1910 const struct action *paction)
1911{
1912 struct widget *pwindow = NULL, *buf = NULL;
1913 utf8_str *pstr;
1914 char tBuf[255], cbuf[255];
1915 bool exit = FALSE;
1916 SDL_Rect area;
1917
1918 if (bribe_dlg) {
1919 return;
1920 }
1921
1922 /* Should be set before sending request to the server. */
1924
1925 if (!actor || !unit_can_do_action(actor, paction->id)) {
1927 return;
1928 }
1929
1931
1932 bribe_dlg = fc_calloc(1, sizeof(struct small_diplomat_dialog));
1933 bribe_dlg->act_id = paction->id;
1936 bribe_dlg->pdialog = fc_calloc(1, sizeof(struct small_dialog));
1937
1938 fc_snprintf(tBuf, ARRAY_SIZE(tBuf), PL_("Treasury contains %d gold.",
1939 "Treasury contains %d gold.",
1940 client_player()->economic.gold),
1941 client_player()->economic.gold);
1942
1943 /* Window */
1944 pstr = create_utf8_from_char_fonto(_("Bribe Enemy Unit"), FONTO_ATTENTION);
1945
1946 pstr->style |= TTF_STYLE_BOLD;
1947
1948 pwindow = create_window_skeleton(NULL, pstr, 0);
1949
1951 set_wstate(pwindow, FC_WS_NORMAL);
1952
1954 bribe_dlg->pdialog->end_widget_list = pwindow;
1955
1956 area = pwindow->area;
1957 area.w = MAX(area.w, adj_size(8));
1958 area.h = MAX(area.h, adj_size(2));
1959
1960 if (cost <= client_player()->economic.gold) {
1961 fc_snprintf(cbuf, sizeof(cbuf),
1962 /* TRANS: %s is pre-pluralised "Treasury contains %d gold." */
1963 PL_("Bribe unit for %d gold?\n%s",
1964 "Bribe unit for %d gold?\n%s", cost), cost, tBuf);
1965
1967
1969
1970 area.w = MAX(area.w, buf->size.w);
1971 area.h += buf->size.h;
1972
1973 /*------------*/
1976 buf->data.unit = punit;
1978
1980
1981 area.w = MAX(area.w, buf->size.w);
1982 area.h += buf->size.h;
1983 /* ------- */
1985 _("No"), exit_bribe_dlg_callback);
1986
1988 buf->key = SDLK_ESCAPE;
1989
1991
1992 area.w = MAX(area.w, buf->size.w);
1993 area.h += buf->size.h;
1994
1995 } else {
1996 /* Exit button */
1997 buf = create_themeicon(current_theme->small_cancel_icon, pwindow->dst,
2000 buf->info_label = create_utf8_from_char_fonto(_("Close Dialog (Esc)"),
2002 area.w += buf->size.w + adj_size(10);
2003 buf->action = exit_bribe_dlg_callback;
2005 buf->key = SDLK_ESCAPE;
2006
2008 exit = TRUE;
2009 /* --------------- */
2010
2011 fc_snprintf(cbuf, sizeof(cbuf),
2012 /* TRANS: %s is pre-pluralised "Treasury contains %d gold." */
2013 PL_("Bribing the unit costs %d gold.\n%s",
2014 "Bribing the unit costs %d gold.\n%s", cost), cost, tBuf);
2015
2017
2019
2020 area.w = MAX(area.w, buf->size.w);
2021 area.h += buf->size.h;
2022
2023 /*------------*/
2025 _("Traitors Demand Too Much!"), NULL);
2026
2028
2029 area.w = MAX(area.w, buf->size.w);
2030 area.h += buf->size.h;
2031 }
2033
2034 /* Setup window size and start position */
2035
2036 resize_window(pwindow, NULL, NULL,
2037 (pwindow->size.w - pwindow->area.w) + area.w,
2038 (pwindow->size.h - pwindow->area.h) + area.h);
2039
2040 area = pwindow->area;
2041
2043 put_window_near_map_tile(pwindow, pwindow->size.w, pwindow->size.h,
2044 unit_tile(actor));
2045
2046 /* Setup widget size and start position */
2047 buf = pwindow;
2048
2049 if (exit) {
2050 /* Exit button */
2051 buf = buf->prev;
2052 buf->size.x = area.x + area.w - buf->size.w - 1;
2053 buf->size.y = pwindow->size.y + adj_size(2);
2054 }
2055
2056 buf = buf->prev;
2058 area.x,
2059 area.y + 1, area.w, 0,
2061
2062 /* --------------------- */
2063 /* Redraw */
2065
2066 widget_flush(pwindow);
2067}
2068
2069/**********************************************************************/
2073void popup_bribe_stack_dialog(struct unit *actor, struct tile *ptile, int cost,
2074 const struct action *paction)
2075{
2076 struct widget *pwindow = NULL, *buf = NULL;
2077 utf8_str *pstr;
2078 char tBuf[255], cbuf[255];
2079 bool exit = FALSE;
2080 SDL_Rect area;
2081
2082 if (bribe_dlg) {
2083 return;
2084 }
2085
2086 /* Should be set before sending request to the server. */
2088
2089 if (!actor || !unit_can_do_action(actor, paction->id)) {
2091 return;
2092 }
2093
2095
2096 bribe_dlg = fc_calloc(1, sizeof(struct small_diplomat_dialog));
2097 bribe_dlg->act_id = paction->id;
2099 bribe_dlg->target_id = ptile->index;
2100 bribe_dlg->pdialog = fc_calloc(1, sizeof(struct small_dialog));
2101
2102 fc_snprintf(tBuf, ARRAY_SIZE(tBuf), PL_("Treasury contains %d gold.",
2103 "Treasury contains %d gold.",
2104 client_player()->economic.gold),
2105 client_player()->economic.gold);
2106
2107 /* Window */
2108 pstr = create_utf8_from_char_fonto(_("Bribe Enemy Stack"), FONTO_ATTENTION);
2109
2110 pstr->style |= TTF_STYLE_BOLD;
2111
2112 pwindow = create_window_skeleton(NULL, pstr, 0);
2113
2115 set_wstate(pwindow, FC_WS_NORMAL);
2116
2118 bribe_dlg->pdialog->end_widget_list = pwindow;
2119
2120 area = pwindow->area;
2121 area.w = MAX(area.w, adj_size(8));
2122 area.h = MAX(area.h, adj_size(2));
2123
2124 if (cost <= client_player()->economic.gold) {
2125 fc_snprintf(cbuf, sizeof(cbuf),
2126 /* TRANS: %s is pre-pluralised "Treasury contains %d gold." */
2127 PL_("Bribe unit stack for %d gold?\n%s",
2128 "Bribe unit stack for %d gold?\n%s", cost), cost, tBuf);
2129
2131
2133
2134 area.w = MAX(area.w, buf->size.w);
2135 area.h += buf->size.h;
2136
2137 /*------------*/
2140 buf->data.tile = ptile;
2142
2144
2145 area.w = MAX(area.w, buf->size.w);
2146 area.h += buf->size.h;
2147 /* ------- */
2149 _("No"), exit_bribe_dlg_callback);
2150
2152 buf->key = SDLK_ESCAPE;
2153
2155
2156 area.w = MAX(area.w, buf->size.w);
2157 area.h += buf->size.h;
2158
2159 } else {
2160 /* Exit button */
2161 buf = create_themeicon(current_theme->small_cancel_icon, pwindow->dst,
2164 buf->info_label = create_utf8_from_char_fonto(_("Close Dialog (Esc)"),
2166 area.w += buf->size.w + adj_size(10);
2167 buf->action = exit_bribe_dlg_callback;
2169 buf->key = SDLK_ESCAPE;
2170
2172 exit = TRUE;
2173 /* --------------- */
2174
2175 fc_snprintf(cbuf, sizeof(cbuf),
2176 /* TRANS: %s is pre-pluralised "Treasury contains %d gold." */
2177 PL_("Bribing the unit stack costs %d gold.\n%s",
2178 "Bribing the unit stack costs %d gold.\n%s", cost), cost, tBuf);
2179
2181
2183
2184 area.w = MAX(area.w, buf->size.w);
2185 area.h += buf->size.h;
2186
2187 /*------------*/
2189 _("Traitors Demand Too Much!"), NULL);
2190
2192
2193 area.w = MAX(area.w, buf->size.w);
2194 area.h += buf->size.h;
2195 }
2197
2198 /* Setup window size and start position */
2199
2200 resize_window(pwindow, NULL, NULL,
2201 (pwindow->size.w - pwindow->area.w) + area.w,
2202 (pwindow->size.h - pwindow->area.h) + area.h);
2203
2204 area = pwindow->area;
2205
2207 put_window_near_map_tile(pwindow, pwindow->size.w, pwindow->size.h,
2208 unit_tile(actor));
2209
2210 /* Setup widget size and start position */
2211 buf = pwindow;
2212
2213 if (exit) {
2214 /* Exit button */
2215 buf = buf->prev;
2216 buf->size.x = area.x + area.w - buf->size.w - 1;
2217 buf->size.y = pwindow->size.y + adj_size(2);
2218 }
2219
2220 buf = buf->prev;
2222 area.x,
2223 area.y + 1, area.w, 0,
2225
2226 /* --------------------- */
2227 /* Redraw */
2229
2230 widget_flush(pwindow);
2231}
const char * action_prepare_ui_name(action_id act_id, const char *mnemonic, const struct act_prob prob, const char *custom)
Definition actions.c:1312
enum action_actor_kind action_get_actor_kind(const struct action *paction)
Definition actions.c:1098
bool action_prob_possible(const struct act_prob probability)
Definition actions.c:5091
enum action_sub_target_kind action_get_sub_target_kind(const struct action *paction)
Definition actions.c:1119
enum action_target_kind action_get_target_kind(const struct action *paction)
Definition actions.c:1108
static struct action * action_by_number(action_id act_id)
Definition actions.h:396
#define action_iterate_end
Definition actions.h:214
#define action_id_get_actor_kind(act_id)
Definition actions.h:409
#define action_iterate(_act_)
Definition actions.h:210
#define action_id_get_target_kind(act_id)
Definition actions.h:413
#define ACTION_NONE
Definition actions.h:55
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:93
#define city_owner(_pcity_)
Definition city.h:560
#define city_built_iterate(_pcity, _p)
Definition city.h:831
#define city_built_iterate_end
Definition city.h:837
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:64
#define NO_TARGET
Definition fc_types.h:213
int Tech_type_id
Definition fc_types.h:236
int action_id
Definition fc_types.h:248
#define IDENTITY_NUMBER_ZERO
Definition fc_types.h:92
#define PL_(String1, String2, n)
Definition fcintl.h:71
#define _(String)
Definition fcintl.h:67
struct civ_game game
Definition game.c:61
struct world wld
Definition game.c:62
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:685
struct sdl2_data main_data
Definition graphics.c:57
SDL_Surface * create_surf(int width, int height, Uint32 flags)
Definition graphics.c:351
int main_window_height(void)
Definition graphics.c:693
#define FREESURFACE(ptr)
Definition graphics.h:322
#define map_rgba(format, color)
Definition graphics.h:315
@ 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:141
#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(Uint16 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
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
int dsend_packet_city_name_suggestion_req(struct connection *pc, int unit_id)
struct research * research_get(const struct player *pplayer)
Definition research.c:128
enum tech_state research_invention_state(const struct research *presearch, Tech_type_id tech)
Definition research.c:619
bool research_invention_gettable(const struct research *presearch, const Tech_type_id tech, bool allow_holes)
Definition research.c:693
#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 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:317
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
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
Uint16 id
Definition widget.h:155
SDL_Rect size
Definition widget.h:145
struct civ_map map
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c: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:248
#define advance_index_iterate_max_end
Definition tech.h:254
static Tech_type_id advance_count(void)
Definition tech.h:165
#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:1757
#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:383
#define unit_tile(_pu)
Definition unit.h:404
const struct unit_type * unit_type_get(const struct unit *punit)
Definition unittype.c:123
const char * unit_name_translation(const struct unit *punit)
Definition unittype.c:1575
struct advance * utype_primary_tech_req(const struct unit_type *ptype)
Definition unittype.c:2716