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-sdl2 */
38#include "citydlg.h"
39#include "colors.h"
40#include "dialogs.h"
41#include "graphics.h"
42#include "gui_id.h"
43#include "gui_tilespec.h"
44#include "mapview.h"
45#include "repodlgs.h"
46#include "themespec.h"
47#include "widget.h"
48
49#include "dialogs_g.h"
50
51typedef int (*act_func)(struct widget *);
52
60
67
68extern bool is_unit_move_blocked;
69
71void popdown_incite_dialog(void);
72void popdown_bribe_dialog(void);
73
74
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 if (paction->result == ACTRES_STRIKE_BUILDING) {
1356 pstr = create_utf8_from_char_fonto(_("Select Improvement to Strike"),
1358 } else {
1359 pstr = create_utf8_from_char_fonto(_("Select Improvement to Sabotage"),
1361 }
1362 pstr->style |= TTF_STYLE_BOLD;
1363
1364 pwindow = create_window_skeleton(NULL, pstr, 0);
1365
1367 set_wstate(pwindow, FC_WS_NORMAL);
1368
1371
1372 area = pwindow->area;
1373 area.h = MAX(area.h, adj_size(2));
1374
1375 /* ---------- */
1376 /* Exit button */
1377 buf = create_themeicon(current_theme->small_cancel_icon, pwindow->dst,
1379 buf->info_label = create_utf8_from_char_fonto(_("Close Dialog (Esc)"),
1381 area.w += buf->size.w + adj_size(10);
1384 buf->key = SDLK_ESCAPE;
1385
1387 /* ---------- */
1388
1391 paction->id)])) {
1393 _("City Production"), sabotage_impr_callback);
1394 buf->data.cont = cont;
1397 add_to_gui_list(MAX_ID - 1000, buf);
1398
1399 area.w = MAX(area.w, buf->size.w);
1400 area.h += buf->size.h;
1401
1402 /* separator */
1404
1406 area.h += buf->next->size.h;
1407
1409 }
1410
1411 /* ------------------ */
1412 n = 0;
1413 city_built_iterate(pcity, pimprove) {
1414 if (pimprove->sabotage > 0) {
1416 (char *) city_improvement_name_translation(pcity, pimprove),
1418 buf->data.cont = cont;
1420
1422
1423 area.w = MAX(area.w , buf->size.w);
1424 imp_h += buf->size.h;
1425
1426 if (n > 9) {
1428 }
1429
1430 n++;
1431 /* ----------- */
1432 }
1434
1436
1437 if (n > 0
1440 /* separator */
1442
1444 area.h += buf->next->size.h;
1445 /* ------------------ */
1446 }
1447
1450 struct astring str = ASTRING_INIT;
1451
1452 /* TRANS: %s is a unit name, e.g., Spy */
1453 astr_set(&str, _("At %s's Discretion"), unit_name_translation(actor));
1456 astr_free(&str);
1457
1458 buf->data.cont = cont;
1460
1462
1463 area.w = MAX(area.w, buf->size.w);
1464 area.h += buf->size.h;
1465 }
1466
1467 /* ----------- */
1468
1469 last = buf;
1472
1473 /* ---------- */
1474 if (n > 10) {
1475 imp_h = 10 * buf->size.h;
1476
1478 1, 10, TRUE, TRUE);
1479 area.w += n;
1480 } else {
1481 n = 0;
1482 }
1483 /* ---------- */
1484
1485 area.h += imp_h;
1486
1487 resize_window(pwindow, NULL, NULL,
1488 (pwindow->size.w - pwindow->area.w) + area.w,
1489 (pwindow->size.h - pwindow->area.h) + area.h);
1490
1491 area = pwindow->area;
1492
1494 put_window_near_map_tile(pwindow, pwindow->size.w, pwindow->size.h,
1495 unit_tile(actor));
1496
1497 w = area.w;
1498
1499 /* exit button */
1500 buf = pwindow->prev;
1501 buf->size.x = area.x + area.w - buf->size.w - 1;
1502 buf->size.y = pwindow->size.y + adj_size(2);
1503
1504 /* Production sabotage */
1505 buf = buf->prev;
1506
1507 buf->size.x = area.x;
1508 buf->size.y = y = area.y + 1;
1509 buf->size.w = w;
1510 h = buf->size.h;
1511
1512 area2.x = adj_size(10);
1513 area2.h = adj_size(2);
1514
1515 buf = buf->prev;
1516 while (buf) {
1518 w -= n;
1519 }
1520
1521 buf->size.w = w;
1522 buf->size.x = buf->next->size.x;
1523 buf->size.y = y = y + buf->next->size.h;
1524
1525 if (buf->id == ID_SEPARATOR) {
1526 FREESURFACE(buf->theme);
1527 buf->size.h = h;
1528 buf->theme = create_surf(w, h, SDL_SWSURFACE);
1529
1530 area2.y = buf->size.h / 2 - 1;
1531 area2.w = buf->size.w - adj_size(20);
1532
1533 SDL_FillRect(buf->theme , &area2, map_rgba(buf->theme->format,
1535 }
1536
1537 if (buf == last) {
1538 break;
1539 }
1540
1542 /* Reset to end of scrolling area */
1544 + 9 * buf->size.h);
1545 w += n;
1546 }
1547 buf = buf->prev;
1548 }
1549
1550 if (diplomat_dlg->pdialog->scroll) {
1552 area.x + area.w,
1556 TRUE);
1557 }
1558
1559 /* -------------------- */
1560 /* redraw */
1562
1563 widget_flush(pwindow);
1564}
1565
1566/* ====================================================================== */
1567/* ============================== INCITE DIALOG ========================= */
1568/* ====================================================================== */
1570
1571/**********************************************************************/
1574static int incite_dlg_window_callback(struct widget *pwindow)
1575{
1578 }
1579
1580 return -1;
1581}
1582
1583/**********************************************************************/
1586static int diplomat_incite_yes_callback(struct widget *pwidget)
1587{
1592 incite_dlg->target_id, 0, "");
1593 }
1594
1596 }
1597
1598 return -1;
1599}
1600
1601/**********************************************************************/
1604static int exit_incite_dlg_callback(struct widget *pwidget)
1605{
1608 }
1609
1610 return -1;
1611}
1612
1613/**********************************************************************/
1630
1631/**********************************************************************/
1635void popup_incite_dialog(struct unit *actor, struct city *pcity, int cost,
1636 const struct action *paction)
1637{
1638 struct widget *pwindow = NULL, *buf = NULL;
1639 utf8_str *pstr;
1640 char tBuf[255], cbuf[255];
1641 bool exit = FALSE;
1642 SDL_Rect area;
1643
1644 if (incite_dlg) {
1645 return;
1646 }
1647
1648 /* Should be set before sending request to the server. */
1650
1651 if (!actor || !unit_can_do_action(actor, paction->id)) {
1653 return;
1654 }
1655
1657
1658 incite_dlg = fc_calloc(1, sizeof(struct small_diplomat_dialog));
1661 incite_dlg->act_id = paction->id;
1662 incite_dlg->pdialog = fc_calloc(1, sizeof(struct small_dialog));
1663
1664 fc_snprintf(tBuf, ARRAY_SIZE(tBuf), PL_("Treasury contains %d gold.",
1665 "Treasury contains %d gold.",
1666 client_player()->economic.gold),
1667 client_player()->economic.gold);
1668
1669 /* Window */
1670 pstr = create_utf8_from_char_fonto(_("Incite a Revolt!"), FONTO_ATTENTION);
1671
1672 pstr->style |= TTF_STYLE_BOLD;
1673
1674 pwindow = create_window_skeleton(NULL, pstr, 0);
1675
1677 set_wstate(pwindow, FC_WS_NORMAL);
1678
1681
1682 area = pwindow->area;
1683 area.w = MAX(area.w, adj_size(8));
1684 area.h = MAX(area.h, adj_size(2));
1685
1687 /* Exit button */
1688 buf = create_themeicon(current_theme->small_cancel_icon, pwindow->dst,
1691 buf->info_label = create_utf8_from_char_fonto(_("Close Dialog (Esc)"),
1693 area.w += buf->size.w + adj_size(10);
1694 buf->action = exit_incite_dlg_callback;
1696 buf->key = SDLK_ESCAPE;
1697
1699 exit = TRUE;
1700 /* --------------- */
1701
1702 fc_snprintf(cbuf, sizeof(cbuf), _("You can't incite a revolt in %s."),
1704
1706
1708
1709 area.w = MAX(area.w , buf->size.w);
1710 area.h += buf->size.h;
1711 /*------------*/
1713 _("City can't be incited!"), NULL);
1714
1716
1717 area.w = MAX(area.w, buf->size.w);
1718 area.h += buf->size.h;
1719
1720 } else if (cost <= client_player()->economic.gold) {
1721 fc_snprintf(cbuf, sizeof(cbuf),
1722 /* TRANS: %s is pre-pluralised "Treasury contains %d gold." */
1723 PL_("Incite a revolt for %d gold?\n%s",
1724 "Incite a revolt for %d gold?\n%s", cost), cost, tBuf);
1725
1727
1729
1730 area.w = MAX(area.w, buf->size.w);
1731 area.h += buf->size.h;
1732
1733 /*------------*/
1736
1737 buf->data.city = pcity;
1739
1741
1742 area.w = MAX(area.w, buf->size.w);
1743 area.h += buf->size.h;
1744 /* ------- */
1747
1749 buf->key = SDLK_ESCAPE;
1750
1752
1753 area.w = MAX(area.w, buf->size.w);
1754 area.h += buf->size.h;
1755
1756 } else {
1757 /* Exit button */
1758 buf = create_themeicon(current_theme->small_cancel_icon, pwindow->dst,
1761 buf->info_label = create_utf8_from_char_fonto(_("Close Dialog (Esc)"),
1763 area.w += buf->size.w + adj_size(10);
1764 buf->action = exit_incite_dlg_callback;
1766 buf->key = SDLK_ESCAPE;
1767
1769 exit = TRUE;
1770 /* --------------- */
1771
1772 fc_snprintf(cbuf, sizeof(cbuf),
1773 /* TRANS: %s is pre-pluralised "Treasury contains %d gold." */
1774 PL_("Inciting a revolt costs %d gold.\n%s",
1775 "Inciting a revolt costs %d gold.\n%s", cost), cost, tBuf);
1776
1778
1780
1781 area.w = MAX(area.w, buf->size.w);
1782 area.h += buf->size.h;
1783
1784 /*------------*/
1786 _("Traitors Demand Too Much!"), NULL);
1787
1789
1790 area.w = MAX(area.w, buf->size.w);
1791 area.h += buf->size.h;
1792 }
1794
1795 /* setup window size and start position */
1796
1797 resize_window(pwindow, NULL, NULL,
1798 (pwindow->size.w - pwindow->area.w) + area.w,
1799 (pwindow->size.h - pwindow->area.h) + area.h);
1800
1801 area = pwindow->area;
1802
1804 put_window_near_map_tile(pwindow, pwindow->size.w, pwindow->size.h,
1805 pcity->tile);
1806
1807 /* setup widget size and start position */
1808 buf = pwindow;
1809
1810 if (exit) {
1811 /* exit button */
1812 buf = buf->prev;
1813 buf->size.x = area.x + area.w - buf->size.w - 1;
1814 buf->size.y = pwindow->size.y + adj_size(2);
1815 }
1816
1817 buf = buf->prev;
1819 area.x,
1820 area.y + 1, area.w, 0,
1822
1823 /* --------------------- */
1824 /* redraw */
1826
1827 widget_flush(pwindow);
1828}
1829
1830/* ====================================================================== */
1831/* ============================ BRIBE DIALOG ========================== */
1832/* ====================================================================== */
1834
1835/**********************************************************************/
1838static int bribe_dlg_window_callback(struct widget *pwindow)
1839{
1842 }
1843
1844 return -1;
1845}
1846
1847/**********************************************************************/
1850static int diplomat_bribe_unit_yes_callback(struct widget *pwidget)
1851{
1856 bribe_dlg->target_id, 0, "");
1857 }
1859 }
1860
1861 return -1;
1862}
1863
1864/**********************************************************************/
1868{
1872 bribe_dlg->target_id, 0, "");
1873 }
1875 }
1876
1877 return -1;
1878}
1879
1880/**********************************************************************/
1883static int exit_bribe_dlg_callback(struct widget *pwidget)
1884{
1887 }
1888
1889 return -1;
1890}
1891
1892/**********************************************************************/
1909
1910/**********************************************************************/
1915 const struct action *paction)
1916{
1917 struct widget *pwindow = NULL, *buf = NULL;
1918 utf8_str *pstr;
1919 char tBuf[255], cbuf[255];
1920 bool exit = FALSE;
1921 SDL_Rect area;
1922
1923 if (bribe_dlg) {
1924 return;
1925 }
1926
1927 /* Should be set before sending request to the server. */
1929
1930 if (!actor || !unit_can_do_action(actor, paction->id)) {
1932 return;
1933 }
1934
1936
1937 bribe_dlg = fc_calloc(1, sizeof(struct small_diplomat_dialog));
1938 bribe_dlg->act_id = paction->id;
1941 bribe_dlg->pdialog = fc_calloc(1, sizeof(struct small_dialog));
1942
1943 fc_snprintf(tBuf, ARRAY_SIZE(tBuf), PL_("Treasury contains %d gold.",
1944 "Treasury contains %d gold.",
1945 client_player()->economic.gold),
1946 client_player()->economic.gold);
1947
1948 /* Window */
1949 pstr = create_utf8_from_char_fonto(_("Bribe Enemy Unit"), FONTO_ATTENTION);
1950
1951 pstr->style |= TTF_STYLE_BOLD;
1952
1953 pwindow = create_window_skeleton(NULL, pstr, 0);
1954
1956 set_wstate(pwindow, FC_WS_NORMAL);
1957
1959 bribe_dlg->pdialog->end_widget_list = pwindow;
1960
1961 area = pwindow->area;
1962 area.w = MAX(area.w, adj_size(8));
1963 area.h = MAX(area.h, adj_size(2));
1964
1965 if (cost <= client_player()->economic.gold) {
1966 fc_snprintf(cbuf, sizeof(cbuf),
1967 /* TRANS: %s is pre-pluralised "Treasury contains %d gold." */
1968 PL_("Bribe unit for %d gold?\n%s",
1969 "Bribe unit for %d gold?\n%s", cost), cost, tBuf);
1970
1972
1974
1975 area.w = MAX(area.w, buf->size.w);
1976 area.h += buf->size.h;
1977
1978 /*------------*/
1981 buf->data.unit = punit;
1983
1985
1986 area.w = MAX(area.w, buf->size.w);
1987 area.h += buf->size.h;
1988 /* ------- */
1990 _("No"), exit_bribe_dlg_callback);
1991
1993 buf->key = SDLK_ESCAPE;
1994
1996
1997 area.w = MAX(area.w, buf->size.w);
1998 area.h += buf->size.h;
1999
2000 } else {
2001 /* Exit button */
2002 buf = create_themeicon(current_theme->small_cancel_icon, pwindow->dst,
2005 buf->info_label = create_utf8_from_char_fonto(_("Close Dialog (Esc)"),
2007 area.w += buf->size.w + adj_size(10);
2008 buf->action = exit_bribe_dlg_callback;
2010 buf->key = SDLK_ESCAPE;
2011
2013 exit = TRUE;
2014 /* --------------- */
2015
2016 fc_snprintf(cbuf, sizeof(cbuf),
2017 /* TRANS: %s is pre-pluralised "Treasury contains %d gold." */
2018 PL_("Bribing the unit costs %d gold.\n%s",
2019 "Bribing the unit costs %d gold.\n%s", cost), cost, tBuf);
2020
2022
2024
2025 area.w = MAX(area.w, buf->size.w);
2026 area.h += buf->size.h;
2027
2028 /*------------*/
2030 _("Traitors Demand Too Much!"), NULL);
2031
2033
2034 area.w = MAX(area.w, buf->size.w);
2035 area.h += buf->size.h;
2036 }
2038
2039 /* Setup window size and start position */
2040
2041 resize_window(pwindow, NULL, NULL,
2042 (pwindow->size.w - pwindow->area.w) + area.w,
2043 (pwindow->size.h - pwindow->area.h) + area.h);
2044
2045 area = pwindow->area;
2046
2048 put_window_near_map_tile(pwindow, pwindow->size.w, pwindow->size.h,
2049 unit_tile(actor));
2050
2051 /* Setup widget size and start position */
2052 buf = pwindow;
2053
2054 if (exit) {
2055 /* Exit button */
2056 buf = buf->prev;
2057 buf->size.x = area.x + area.w - buf->size.w - 1;
2058 buf->size.y = pwindow->size.y + adj_size(2);
2059 }
2060
2061 buf = buf->prev;
2063 area.x,
2064 area.y + 1, area.w, 0,
2066
2067 /* --------------------- */
2068 /* Redraw */
2070
2071 widget_flush(pwindow);
2072}
2073
2074
2075/**********************************************************************/
2079void popup_bribe_stack_dialog(struct unit *actor, struct tile *ptile, int cost,
2080 const struct action *paction)
2081{
2082 struct widget *pwindow = NULL, *buf = NULL;
2083 utf8_str *pstr;
2084 char tBuf[255], cbuf[255];
2085 bool exit = FALSE;
2086 SDL_Rect area;
2087
2088 if (bribe_dlg) {
2089 return;
2090 }
2091
2092 /* Should be set before sending request to the server. */
2094
2095 if (!actor || !unit_can_do_action(actor, paction->id)) {
2097 return;
2098 }
2099
2101
2102 bribe_dlg = fc_calloc(1, sizeof(struct small_diplomat_dialog));
2103 bribe_dlg->act_id = paction->id;
2105 bribe_dlg->target_id = ptile->index;
2106 bribe_dlg->pdialog = fc_calloc(1, sizeof(struct small_dialog));
2107
2108 fc_snprintf(tBuf, ARRAY_SIZE(tBuf), PL_("Treasury contains %d gold.",
2109 "Treasury contains %d gold.",
2110 client_player()->economic.gold),
2111 client_player()->economic.gold);
2112
2113 /* Window */
2114 pstr = create_utf8_from_char_fonto(_("Bribe Enemy Stack"), FONTO_ATTENTION);
2115
2116 pstr->style |= TTF_STYLE_BOLD;
2117
2118 pwindow = create_window_skeleton(NULL, pstr, 0);
2119
2121 set_wstate(pwindow, FC_WS_NORMAL);
2122
2124 bribe_dlg->pdialog->end_widget_list = pwindow;
2125
2126 area = pwindow->area;
2127 area.w = MAX(area.w, adj_size(8));
2128 area.h = MAX(area.h, adj_size(2));
2129
2130 if (cost <= client_player()->economic.gold) {
2131 fc_snprintf(cbuf, sizeof(cbuf),
2132 /* TRANS: %s is pre-pluralised "Treasury contains %d gold." */
2133 PL_("Bribe unit stack for %d gold?\n%s",
2134 "Bribe unit stack for %d gold?\n%s", cost), cost, tBuf);
2135
2137
2139
2140 area.w = MAX(area.w, buf->size.w);
2141 area.h += buf->size.h;
2142
2143 /*------------*/
2146 buf->data.tile = ptile;
2148
2150
2151 area.w = MAX(area.w, buf->size.w);
2152 area.h += buf->size.h;
2153 /* ------- */
2155 _("No"), exit_bribe_dlg_callback);
2156
2158 buf->key = SDLK_ESCAPE;
2159
2161
2162 area.w = MAX(area.w, buf->size.w);
2163 area.h += buf->size.h;
2164
2165 } else {
2166 /* Exit button */
2167 buf = create_themeicon(current_theme->small_cancel_icon, pwindow->dst,
2170 buf->info_label = create_utf8_from_char_fonto(_("Close Dialog (Esc)"),
2172 area.w += buf->size.w + adj_size(10);
2173 buf->action = exit_bribe_dlg_callback;
2175 buf->key = SDLK_ESCAPE;
2176
2178 exit = TRUE;
2179 /* --------------- */
2180
2181 fc_snprintf(cbuf, sizeof(cbuf),
2182 /* TRANS: %s is pre-pluralised "Treasury contains %d gold." */
2183 PL_("Bribing the unit stack costs %d gold.\n%s",
2184 "Bribing the unit stack costs %d gold.\n%s", cost), cost, tBuf);
2185
2187
2189
2190 area.w = MAX(area.w, buf->size.w);
2191 area.h += buf->size.h;
2192
2193 /*------------*/
2195 _("Traitors Demand Too Much!"), NULL);
2196
2198
2199 area.w = MAX(area.w, buf->size.w);
2200 area.h += buf->size.h;
2201 }
2203
2204 /* Setup window size and start position */
2205
2206 resize_window(pwindow, NULL, NULL,
2207 (pwindow->size.w - pwindow->area.w) + area.w,
2208 (pwindow->size.h - pwindow->area.h) + area.h);
2209
2210 area = pwindow->area;
2211
2213 put_window_near_map_tile(pwindow, pwindow->size.w, pwindow->size.h,
2214 unit_tile(actor));
2215
2216 /* Setup widget size and start position */
2217 buf = pwindow;
2218
2219 if (exit) {
2220 /* Exit button */
2221 buf = buf->prev;
2222 buf->size.x = area.x + area.w - buf->size.w - 1;
2223 buf->size.y = pwindow->size.y + adj_size(2);
2224 }
2225
2226 buf = buf->prev;
2228 area.x,
2229 area.y + 1, area.w, 0,
2231
2232 /* --------------------- */
2233 /* Redraw */
2235
2236 widget_flush(pwindow);
2237}
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:5079
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: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: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:1063
void request_do_action(action_id action, int actor_id, int target_id, int sub_tgt, const char *name)
Definition control.c:1742
void request_action_details(action_id action, int actor_id, int target_id)
Definition control.c:1810
void action_decision_clear_want(const int old_actor_id)
Definition control.c:1092
void key_unit_wait(void)
Definition control.c:3554
void auto_center_on_focus_unit(void)
Definition control.c:434
void action_selection_next_in_focus(const int old_actor_id)
Definition control.c:1104
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id popup_bribe_unit_dialog
Definition dialogs_g.h:72
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit int const struct action *paction popup_sabotage_dialog
Definition dialogs_g.h:76
struct unit struct city struct unit * target_unit
Definition dialogs_g.h:55
popup_action_selection
Definition dialogs_g.h:54
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit * actor
Definition dialogs_g.h:72
struct unit * actor_unit
Definition dialogs_g.h:54
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs action_selection_no_longer_in_progress_gui_specific
Definition dialogs_g.h:68
struct unit struct city struct unit struct tile * target_tile
Definition dialogs_g.h:56
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit * punit
Definition dialogs_g.h:73
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit int const struct action *paction struct unit struct city * pcity
Definition dialogs_g.h:77
struct unit struct city * target_city
Definition dialogs_g.h:55
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit int cost
Definition dialogs_g.h:73
struct unit struct city struct unit struct tile struct extra_type * target_extra
Definition dialogs_g.h:56
int int id
Definition editgui_g.h:28
int extra_number(const struct extra_type *pextra)
Definition extras.c:161
struct extra_type * extra_by_number(int id)
Definition extras.c:183
#define EXTRA_NONE
Definition extras.h:85
QString current_theme
Definition fc_client.cpp:65
#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: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: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
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:139
int id
Definition unit.h:146
struct tile * tile
Definition unit.h:141
struct unit::@84::@86 client
struct act_prob * act_prob_cache
Definition unit.h:230
widget_id id
Definition widget.h:155
struct widget * prev
Definition widget.h:114
union widget::@196 data
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: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: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:401
#define unit_tile(_pu)
Definition unit.h:406
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:1573
struct advance * utype_primary_tech_req(const struct unit_type *ptype)
Definition unittype.c:2714