Freeciv-3.2
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/**********************************************************************/
672static int found_city_callback(struct widget *pwidget)
673{
675 int actor_id = diplomat_dlg->actor_unit_id;
676
679 actor_id);
680 }
681
682 return -1;
683}
684
685/**********************************************************************/
688static int upgrade_callback(struct widget *pwidget)
689{
691 struct unit *punit;
692
696 }
697
699 }
700
701 return -1;
702}
703
704/**********************************************************************/
708static int simple_action_callback(struct widget *pwidget)
709{
710 int actor_id, target_id, sub_target;
711 struct action *paction;
712
713 bool failed = FALSE;
714
716 return -1;
717 }
718
719 /* Data */
720 paction = action_by_number(MAX_ID - pwidget->id);
721
722 /* Actor */
724 actor_id = diplomat_dlg->actor_unit_id;
725 if (NULL == game_unit_by_number(actor_id)) {
726 /* Probably dead. */
727 failed = TRUE;
728 }
729
730 /* Target */
731 target_id = IDENTITY_NUMBER_ZERO;
733 case ATK_CITY:
734 target_id = diplomat_dlg->target_ids[ATK_CITY];
735 if (NULL == game_city_by_number(target_id)) {
736 /* Probably destroyed. */
737 failed = TRUE;
738 }
739 break;
740 case ATK_UNIT:
741 target_id = diplomat_dlg->target_ids[ATK_UNIT];
742 if (NULL == game_unit_by_number(target_id)) {
743 /* Probably dead. */
744 failed = TRUE;
745 }
746 break;
747 case ATK_UNITS:
748 case ATK_TILE:
749 case ATK_EXTRAS:
750 target_id = diplomat_dlg->target_ids[ATK_TILE];
751 if (NULL == index_to_tile(&(wld.map), target_id)) {
752 /* TODO: Should this be possible at all? If not: add assertion. */
753 failed = TRUE;
754 }
755 break;
756 case ATK_SELF:
757 target_id = IDENTITY_NUMBER_ZERO;
758 break;
759 case ATK_COUNT:
761 failed = TRUE;
762 }
763
764 /* Sub target. */
765 sub_target = NO_TARGET;
766 if (paction->target_complexity != ACT_TGT_COMPL_SIMPLE) {
768 case ASTK_BUILDING:
770 if (NULL == improvement_by_number(sub_target)) {
771 /* Did the ruleset change? */
772 failed = TRUE;
773 }
774 break;
775 case ASTK_TECH:
776 sub_target = diplomat_dlg->sub_target_id[ASTK_TECH];
777 if (NULL == valid_advance_by_number(sub_target)) {
778 /* Did the ruleset change? */
779 failed = TRUE;
780 }
781 break;
782 case ASTK_EXTRA:
784 /* TODO: validate if the extra is there? */
786 if (NULL == extra_by_number(sub_target)) {
787 /* Did the ruleset change? */
788 failed = TRUE;
789 }
790 break;
791 case ASTK_NONE:
792 case ASTK_COUNT:
793 /* Shouldn't happen. */
795 failed = TRUE;
796 break;
797 }
798 }
799
800 /* Send request. */
801 if (!failed) {
802 request_do_action(paction->id, actor_id, target_id, sub_target, "");
803 }
804
805 /* Clean up. */
807 return -1;
808}
809
810/**********************************************************************/
813static int diplomat_close_callback(struct widget *pwidget)
814{
817 }
818
819 return -1;
820}
821
822/**********************************************************************/
840
841/* Mapping from an action to the function to call when its button is
842 * pushed. */
843static const act_func af_map[ACTION_COUNT] = {
844 /* Unit acting against a city target. */
853
854 /* Unit acting against a unit target. */
856
857 /* Unit acting against all units at a tile. */
858 /* No special callback functions needed for any unit stack targeted
859 * actions. */
860
861 /* Unit acting against a tile. */
863
864 /* Unit acting with no target except itself. */
865 /* No special callback functions needed for any self targeted actions. */
866};
867
868/**********************************************************************/
871static void action_entry(const action_id act,
872 const struct act_prob *act_probs,
873 struct unit *act_unit,
874 struct tile *tgt_tile,
875 struct city *tgt_city,
876 struct unit *tgt_unit,
877 struct widget *pwindow,
878 SDL_Rect *area)
879{
880 struct widget *buf;
881 utf8_str *pstr;
882 const char *ui_name;
883 act_func cb;
884
886 act_probs[act],
887 act_unit,
888 tgt_city);
889
890 if (af_map[act] == NULL) {
891 /* No special call back function needed for this action. */
893 } else {
894 /* Special action specific callback function specified. */
895 cb = af_map[act];
896 }
897
898 /* Don't show disabled actions */
899 if (!action_prob_possible(act_probs[act])) {
900 return;
901 }
902
903 ui_name = action_prepare_ui_name(act, "",
904 act_probs[act], custom);
905
907 ui_name, cb);
908
909 switch (action_id_get_target_kind(act)) {
910 case ATK_CITY:
911 buf->data.city = tgt_city;
912 break;
913 case ATK_UNIT:
914 buf->data.unit = tgt_unit;
915 break;
916 case ATK_TILE:
917 case ATK_EXTRAS:
918 case ATK_UNITS:
919 buf->data.tile = tgt_tile;
920 break;
921 case ATK_SELF:
922 buf->data.unit = act_unit;
923 break;
924 case ATK_COUNT:
925 fc_assert_msg(FALSE, "Unsupported target kind");
926 }
927
929
930 add_to_gui_list(MAX_ID - act, buf);
931
932 area->w = MAX(area->w, buf->size.w);
933 area->h += buf->size.h;
934}
935
936/**********************************************************************/
941 struct city *target_city,
942 struct unit *target_unit,
943 struct tile *target_tile,
944 struct extra_type *target_extra,
945 const struct act_prob *act_probs)
946{
947 struct widget *pwindow = NULL, *buf = NULL;
948 utf8_str *pstr;
950
951 fc_assert_ret_msg(!diplomat_dlg, "Diplomat dialog already open");
952
953 /* Could be caused by the server failing to reply to a request for more
954 * information or a bug in the client code. */
956 "Diplomat queue problem. Is another diplomat window open?");
957
958 /* No extra input is required as no action has been chosen yet. */
960
962
963 diplomat_dlg = fc_calloc(1, sizeof(struct diplomat_dialog));
965 diplomat_dlg->pdialog = fc_calloc(1, sizeof(struct advanced_dialog));
966
967 /* window */
968 if (target_city) {
969 struct astring title = ASTRING_INIT;
970
971 /* TRANS: %s is a unit name, e.g., Spy */
972 astr_set(&title, _("Choose Your %s's Strategy"),
976 } else {
977 pstr = create_utf8_from_char_fonto(_("Subvert Enemy Unit"),
979 }
980
981 pstr->style |= TTF_STYLE_BOLD;
982
983 pwindow = create_window_skeleton(NULL, pstr, 0);
984
986 set_wstate(pwindow, FC_WS_NORMAL);
987
990
991 area = pwindow->area;
992 area.w = MAX(area.w, adj_size(8));
993 area.h = MAX(area.h, adj_size(2));
994
995 if (target_city) {
997 } else {
999 }
1000
1001 if (target_unit) {
1003 } else {
1005 }
1006
1010
1011 /* No target building or target tech supplied. (Feb 2020) */
1014
1015 if (target_extra) {
1019 } else {
1022 }
1023
1025
1026 /* ---------- */
1027 /* Unit acting against a city */
1028
1029 action_iterate(act) {
1034 pwindow, &area);
1035 }
1037
1038 /* Unit acting against another unit */
1039
1040 action_iterate(act) {
1045 pwindow, &area);
1046 }
1048
1049 /* Unit acting against all units at a tile */
1050
1051 action_iterate(act) {
1056 pwindow, &area);
1057 }
1059
1060 /* Unit acting against a tile. */
1061
1062 action_iterate(act) {
1067 pwindow, &area);
1068 }
1070
1071 /* Unit acting against a tile's extras. */
1072
1073 action_iterate(act) {
1078 pwindow, &area);
1079 }
1081
1082 /* Unit acting against itself. */
1083
1084 action_iterate(act) {
1089 pwindow, &area);
1090 }
1092
1093 /* ---------- */
1095 _("Wait"), act_sel_wait_callback);
1096
1097 buf->data.tile = target_tile;
1098
1100
1102
1103 area.w = MAX(area.w, buf->size.w);
1104 area.h += buf->size.h;
1105
1106 /* ---------- */
1108 _("Cancel"), diplomat_close_callback);
1109
1111 buf->key = SDLK_ESCAPE;
1112
1114
1115 area.w = MAX(area.w, buf->size.w);
1116 area.h += buf->size.h;
1117 /* ---------- */
1119
1120 /* setup window size and start position */
1121
1122 resize_window(pwindow, NULL, NULL,
1123 (pwindow->size.w - pwindow->area.w) + area.w,
1124 (pwindow->size.h - pwindow->area.h) + area.h);
1125
1126 area = pwindow->area;
1127
1129 put_window_near_map_tile(pwindow, pwindow->size.w, pwindow->size.h,
1131
1132 /* setup widget size and start position */
1133
1134 buf = pwindow->prev;
1136 area.x,
1137 area.y + 1, area.w, 0,
1139
1140 /* --------------------- */
1141 /* redraw */
1143
1144 widget_flush(pwindow);
1145
1146 /* Give follow up questions access to action probabilities. */
1148 action_iterate(act) {
1151}
1152
1153/**********************************************************************/
1159{
1160 if (!diplomat_dlg) {
1161 return IDENTITY_NUMBER_ZERO;
1162 }
1163
1165}
1166
1167/**********************************************************************/
1174{
1175 if (!diplomat_dlg) {
1176 return IDENTITY_NUMBER_ZERO;
1177 }
1178
1180}
1181
1182/**********************************************************************/
1189{
1190 if (!diplomat_dlg) {
1191 return IDENTITY_NUMBER_ZERO;
1192 }
1193
1195}
1196
1197/**********************************************************************/
1204{
1205 if (!diplomat_dlg) {
1206 return TILE_INDEX_NONE;
1207 }
1208
1210}
1211
1212/**********************************************************************/
1219{
1220 if (!diplomat_dlg) {
1221 return EXTRA_NONE;
1222 }
1223
1225}
1226
1227/**********************************************************************/
1231 struct city *target_city,
1232 struct unit *target_unit,
1233 struct tile *target_tile,
1234 struct extra_type *target_extra,
1235 const struct act_prob *act_probs)
1236{
1241 act_probs);
1242}
1243
1244/**********************************************************************/
1252
1253/* ====================================================================== */
1254/* ============================ SABOTAGE DIALOG ========================= */
1255/* ====================================================================== */
1256
1257/**********************************************************************/
1260static int sabotage_impr_callback(struct widget *pwidget)
1261{
1263 int sabotage_improvement = MAX_ID - pwidget->id;
1264 int diplomat_target_id = pwidget->data.cont->id0;
1265 int diplomat_id = pwidget->data.cont->id1;
1266 action_id act_id = pwidget->data.cont->value;
1267
1270
1271 if (sabotage_improvement == 1000) {
1273 }
1274
1278 /* This is the untargeted version. */
1282 } else if (sabotage_improvement == -1) {
1283 /* This is the city production version. */
1287 } else {
1288 /* This is the targeted version. */
1289 request_do_action(act_id,
1292 }
1293 }
1294
1296 }
1297
1298 return -1;
1299}
1300
1301/**********************************************************************/
1305void popup_sabotage_dialog(struct unit *actor, struct city *pcity,
1306 const struct action *paction)
1307{
1308 struct widget *pwindow = NULL, *buf = NULL , *last = NULL;
1309 struct container *cont;
1310 utf8_str *pstr;
1311 SDL_Rect area, area2;
1312 int n, w = 0, h, imp_h = 0, y;
1313
1314 fc_assert_ret_msg(!diplomat_dlg, "Diplomat dialog already open");
1315
1316 /* Should be set before sending request to the server. */
1318
1319 if (!actor) {
1321 return;
1322 }
1323
1325
1326 diplomat_dlg = fc_calloc(1, sizeof(struct diplomat_dialog));
1329 diplomat_dlg->pdialog = fc_calloc(1, sizeof(struct advanced_dialog));
1330
1331 cont = fc_calloc(1, sizeof(struct container));
1332 cont->id0 = pcity->id;
1333 cont->id1 = actor->id; /* Spy id */
1334 cont->value = paction->id;
1335
1336 pstr = create_utf8_from_char_fonto(_("Select Improvement to Sabotage"),
1338 pstr->style |= TTF_STYLE_BOLD;
1339
1340 pwindow = create_window_skeleton(NULL, pstr, 0);
1341
1343 set_wstate(pwindow, FC_WS_NORMAL);
1344
1347
1348 area = pwindow->area;
1349 area.h = MAX(area.h, adj_size(2));
1350
1351 /* ---------- */
1352 /* Exit button */
1353 buf = create_themeicon(current_theme->small_cancel_icon, pwindow->dst,
1355 buf->info_label = create_utf8_from_char_fonto(_("Close Dialog (Esc)"),
1357 area.w += buf->size.w + adj_size(10);
1360 buf->key = SDLK_ESCAPE;
1361
1363 /* ---------- */
1364
1367 paction->id)])) {
1369 _("City Production"), sabotage_impr_callback);
1370 buf->data.cont = cont;
1373 add_to_gui_list(MAX_ID - 1000, buf);
1374
1375 area.w = MAX(area.w, buf->size.w);
1376 area.h += buf->size.h;
1377
1378 /* separator */
1380
1382 area.h += buf->next->size.h;
1383
1385 }
1386
1387 /* ------------------ */
1388 n = 0;
1389 city_built_iterate(pcity, pimprove) {
1390 if (pimprove->sabotage > 0) {
1392 (char *) city_improvement_name_translation(pcity, pimprove),
1394 buf->data.cont = cont;
1396
1398
1399 area.w = MAX(area.w , buf->size.w);
1400 imp_h += buf->size.h;
1401
1402 if (n > 9) {
1404 }
1405
1406 n++;
1407 /* ----------- */
1408 }
1410
1412
1413 if (n > 0
1416 /* separator */
1418
1420 area.h += buf->next->size.h;
1421 /* ------------------ */
1422 }
1423
1426 struct astring str = ASTRING_INIT;
1427
1428 /* TRANS: %s is a unit name, e.g., Spy */
1429 astr_set(&str, _("At %s's Discretion"), unit_name_translation(actor));
1432 astr_free(&str);
1433
1434 buf->data.cont = cont;
1436
1438
1439 area.w = MAX(area.w, buf->size.w);
1440 area.h += buf->size.h;
1441 }
1442
1443 /* ----------- */
1444
1445 last = buf;
1448
1449 /* ---------- */
1450 if (n > 10) {
1451 imp_h = 10 * buf->size.h;
1452
1454 1, 10, TRUE, TRUE);
1455 area.w += n;
1456 } else {
1457 n = 0;
1458 }
1459 /* ---------- */
1460
1461 area.h += imp_h;
1462
1463 resize_window(pwindow, NULL, NULL,
1464 (pwindow->size.w - pwindow->area.w) + area.w,
1465 (pwindow->size.h - pwindow->area.h) + area.h);
1466
1467 area = pwindow->area;
1468
1470 put_window_near_map_tile(pwindow, pwindow->size.w, pwindow->size.h,
1471 unit_tile(actor));
1472
1473 w = area.w;
1474
1475 /* exit button */
1476 buf = pwindow->prev;
1477 buf->size.x = area.x + area.w - buf->size.w - 1;
1478 buf->size.y = pwindow->size.y + adj_size(2);
1479
1480 /* Production sabotage */
1481 buf = buf->prev;
1482
1483 buf->size.x = area.x;
1484 buf->size.y = y = area.y + 1;
1485 buf->size.w = w;
1486 h = buf->size.h;
1487
1488 area2.x = adj_size(10);
1489 area2.h = adj_size(2);
1490
1491 buf = buf->prev;
1492 while (buf) {
1494 w -= n;
1495 }
1496
1497 buf->size.w = w;
1498 buf->size.x = buf->next->size.x;
1499 buf->size.y = y = y + buf->next->size.h;
1500
1501 if (buf->id == ID_SEPARATOR) {
1502 FREESURFACE(buf->theme);
1503 buf->size.h = h;
1504 buf->theme = create_surf(w, h, SDL_SWSURFACE);
1505
1506 area2.y = buf->size.h / 2 - 1;
1507 area2.w = buf->size.w - adj_size(20);
1508
1509 SDL_FillRect(buf->theme , &area2, map_rgba(buf->theme->format,
1511 }
1512
1513 if (buf == last) {
1514 break;
1515 }
1516
1518 /* Reset to end of scrolling area */
1520 + 9 * buf->size.h);
1521 w += n;
1522 }
1523 buf = buf->prev;
1524 }
1525
1526 if (diplomat_dlg->pdialog->scroll) {
1528 area.x + area.w,
1532 TRUE);
1533 }
1534
1535 /* -------------------- */
1536 /* redraw */
1538
1539 widget_flush(pwindow);
1540}
1541
1542/* ====================================================================== */
1543/* ============================== INCITE DIALOG ========================= */
1544/* ====================================================================== */
1546
1547/**********************************************************************/
1550static int incite_dlg_window_callback(struct widget *pwindow)
1551{
1554 }
1555
1556 return -1;
1557}
1558
1559/**********************************************************************/
1562static int diplomat_incite_yes_callback(struct widget *pwidget)
1563{
1568 incite_dlg->target_id, 0, "");
1569 }
1570
1572 }
1573
1574 return -1;
1575}
1576
1577/**********************************************************************/
1580static int exit_incite_dlg_callback(struct widget *pwidget)
1581{
1584 }
1585
1586 return -1;
1587}
1588
1589/**********************************************************************/
1606
1607/**********************************************************************/
1611void popup_incite_dialog(struct unit *actor, struct city *pcity, int cost,
1612 const struct action *paction)
1613{
1614 struct widget *pwindow = NULL, *buf = NULL;
1615 utf8_str *pstr;
1616 char tBuf[255], cbuf[255];
1617 bool exit = FALSE;
1618 SDL_Rect area;
1619
1620 if (incite_dlg) {
1621 return;
1622 }
1623
1624 /* Should be set before sending request to the server. */
1626
1627 if (!actor || !unit_can_do_action(actor, paction->id)) {
1629 return;
1630 }
1631
1633
1634 incite_dlg = fc_calloc(1, sizeof(struct small_diplomat_dialog));
1636 incite_dlg->target_id = pcity->id;
1637 incite_dlg->act_id = paction->id;
1638 incite_dlg->pdialog = fc_calloc(1, sizeof(struct small_dialog));
1639
1640 fc_snprintf(tBuf, ARRAY_SIZE(tBuf), PL_("Treasury contains %d gold.",
1641 "Treasury contains %d gold.",
1642 client_player()->economic.gold),
1643 client_player()->economic.gold);
1644
1645 /* Window */
1646 pstr = create_utf8_from_char_fonto(_("Incite a Revolt!"), FONTO_ATTENTION);
1647
1648 pstr->style |= TTF_STYLE_BOLD;
1649
1650 pwindow = create_window_skeleton(NULL, pstr, 0);
1651
1653 set_wstate(pwindow, FC_WS_NORMAL);
1654
1657
1658 area = pwindow->area;
1659 area.w = MAX(area.w, adj_size(8));
1660 area.h = MAX(area.h, adj_size(2));
1661
1663 /* Exit button */
1664 buf = create_themeicon(current_theme->small_cancel_icon, pwindow->dst,
1667 buf->info_label = create_utf8_from_char_fonto(_("Close Dialog (Esc)"),
1669 area.w += buf->size.w + adj_size(10);
1670 buf->action = exit_incite_dlg_callback;
1672 buf->key = SDLK_ESCAPE;
1673
1675 exit = TRUE;
1676 /* --------------- */
1677
1678 fc_snprintf(cbuf, sizeof(cbuf), _("You can't incite a revolt in %s."),
1679 city_name_get(pcity));
1680
1682
1684
1685 area.w = MAX(area.w , buf->size.w);
1686 area.h += buf->size.h;
1687 /*------------*/
1689 _("City can't be incited!"), NULL);
1690
1692
1693 area.w = MAX(area.w, buf->size.w);
1694 area.h += buf->size.h;
1695
1696 } else if (cost <= client_player()->economic.gold) {
1697 fc_snprintf(cbuf, sizeof(cbuf),
1698 /* TRANS: %s is pre-pluralised "Treasury contains %d gold." */
1699 PL_("Incite a revolt for %d gold?\n%s",
1700 "Incite a revolt for %d gold?\n%s", cost), cost, tBuf);
1701
1703
1705
1706 area.w = MAX(area.w, buf->size.w);
1707 area.h += buf->size.h;
1708
1709 /*------------*/
1712
1713 buf->data.city = pcity;
1715
1717
1718 area.w = MAX(area.w, buf->size.w);
1719 area.h += buf->size.h;
1720 /* ------- */
1722 _("No") , exit_incite_dlg_callback);
1723
1725 buf->key = SDLK_ESCAPE;
1726
1728
1729 area.w = MAX(area.w, buf->size.w);
1730 area.h += buf->size.h;
1731
1732 } else {
1733 /* Exit button */
1734 buf = create_themeicon(current_theme->small_cancel_icon, pwindow->dst,
1737 buf->info_label = create_utf8_from_char_fonto(_("Close Dialog (Esc)"),
1739 area.w += buf->size.w + adj_size(10);
1740 buf->action = exit_incite_dlg_callback;
1742 buf->key = SDLK_ESCAPE;
1743
1745 exit = TRUE;
1746 /* --------------- */
1747
1748 fc_snprintf(cbuf, sizeof(cbuf),
1749 /* TRANS: %s is pre-pluralised "Treasury contains %d gold." */
1750 PL_("Inciting a revolt costs %d gold.\n%s",
1751 "Inciting a revolt costs %d gold.\n%s", cost), cost, tBuf);
1752
1754
1756
1757 area.w = MAX(area.w, buf->size.w);
1758 area.h += buf->size.h;
1759
1760 /*------------*/
1762 _("Traitors Demand Too Much!"), NULL);
1763
1765
1766 area.w = MAX(area.w, buf->size.w);
1767 area.h += buf->size.h;
1768 }
1770
1771 /* setup window size and start position */
1772
1773 resize_window(pwindow, NULL, NULL,
1774 (pwindow->size.w - pwindow->area.w) + area.w,
1775 (pwindow->size.h - pwindow->area.h) + area.h);
1776
1777 area = pwindow->area;
1778
1780 put_window_near_map_tile(pwindow, pwindow->size.w, pwindow->size.h,
1781 pcity->tile);
1782
1783 /* setup widget size and start position */
1784 buf = pwindow;
1785
1786 if (exit) {
1787 /* exit button */
1788 buf = buf->prev;
1789 buf->size.x = area.x + area.w - buf->size.w - 1;
1790 buf->size.y = pwindow->size.y + adj_size(2);
1791 }
1792
1793 buf = buf->prev;
1795 area.x,
1796 area.y + 1, area.w, 0,
1798
1799 /* --------------------- */
1800 /* redraw */
1802
1803 widget_flush(pwindow);
1804}
1805
1806/* ====================================================================== */
1807/* ============================ BRIBE DIALOG ========================== */
1808/* ====================================================================== */
1810
1811/**********************************************************************/
1814static int bribe_dlg_window_callback(struct widget *pwindow)
1815{
1818 }
1819
1820 return -1;
1821}
1822
1823/**********************************************************************/
1826static int diplomat_bribe_yes_callback(struct widget *pwidget)
1827{
1832 bribe_dlg->target_id, 0, "");
1833 }
1835 }
1836
1837 return -1;
1838}
1839
1840/**********************************************************************/
1843static int exit_bribe_dlg_callback(struct widget *pwidget)
1844{
1847 }
1848
1849 return -1;
1850}
1851
1852/**********************************************************************/
1869
1870/**********************************************************************/
1874void popup_bribe_dialog(struct unit *actor, struct unit *punit, int cost,
1875 const struct action *paction)
1876{
1877 struct widget *pwindow = NULL, *buf = NULL;
1878 utf8_str *pstr;
1879 char tBuf[255], cbuf[255];
1880 bool exit = FALSE;
1881 SDL_Rect area;
1882
1883 if (bribe_dlg) {
1884 return;
1885 }
1886
1887 /* Should be set before sending request to the server. */
1889
1890 if (!actor || !unit_can_do_action(actor, paction->id)) {
1892 return;
1893 }
1894
1896
1897 bribe_dlg = fc_calloc(1, sizeof(struct small_diplomat_dialog));
1898 bribe_dlg->act_id = paction->id;
1901 bribe_dlg->pdialog = fc_calloc(1, sizeof(struct small_dialog));
1902
1903 fc_snprintf(tBuf, ARRAY_SIZE(tBuf), PL_("Treasury contains %d gold.",
1904 "Treasury contains %d gold.",
1905 client_player()->economic.gold),
1906 client_player()->economic.gold);
1907
1908 /* Window */
1909 pstr = create_utf8_from_char_fonto(_("Bribe Enemy Unit"), FONTO_ATTENTION);
1910
1911 pstr->style |= TTF_STYLE_BOLD;
1912
1913 pwindow = create_window_skeleton(NULL, pstr, 0);
1914
1916 set_wstate(pwindow, FC_WS_NORMAL);
1917
1919 bribe_dlg->pdialog->end_widget_list = pwindow;
1920
1921 area = pwindow->area;
1922 area.w = MAX(area.w, adj_size(8));
1923 area.h = MAX(area.h, adj_size(2));
1924
1925 if (cost <= client_player()->economic.gold) {
1926 fc_snprintf(cbuf, sizeof(cbuf),
1927 /* TRANS: %s is pre-pluralised "Treasury contains %d gold." */
1928 PL_("Bribe unit for %d gold?\n%s",
1929 "Bribe unit for %d gold?\n%s", cost), cost, tBuf);
1930
1932
1934
1935 area.w = MAX(area.w, buf->size.w);
1936 area.h += buf->size.h;
1937
1938 /*------------*/
1941 buf->data.unit = punit;
1943
1945
1946 area.w = MAX(area.w, buf->size.w);
1947 area.h += buf->size.h;
1948 /* ------- */
1950 _("No") , exit_bribe_dlg_callback);
1951
1953 buf->key = SDLK_ESCAPE;
1954
1956
1957 area.w = MAX(area.w, buf->size.w);
1958 area.h += buf->size.h;
1959
1960 } else {
1961 /* Exit button */
1962 buf = create_themeicon(current_theme->small_cancel_icon, pwindow->dst,
1965 buf->info_label = create_utf8_from_char_fonto(_("Close Dialog (Esc)"),
1967 area.w += buf->size.w + adj_size(10);
1968 buf->action = exit_bribe_dlg_callback;
1970 buf->key = SDLK_ESCAPE;
1971
1973 exit = TRUE;
1974 /* --------------- */
1975
1976 fc_snprintf(cbuf, sizeof(cbuf),
1977 /* TRANS: %s is pre-pluralised "Treasury contains %d gold." */
1978 PL_("Bribing the unit costs %d gold.\n%s",
1979 "Bribing the unit costs %d gold.\n%s", cost), cost, tBuf);
1980
1982
1984
1985 area.w = MAX(area.w, buf->size.w);
1986 area.h += buf->size.h;
1987
1988 /*------------*/
1990 _("Traitors Demand Too Much!"), NULL);
1991
1993
1994 area.w = MAX(area.w, buf->size.w);
1995 area.h += buf->size.h;
1996 }
1998
1999 /* setup window size and start position */
2000
2001 resize_window(pwindow, NULL, NULL,
2002 (pwindow->size.w - pwindow->area.w) + area.w,
2003 (pwindow->size.h - pwindow->area.h) + area.h);
2004
2005 area = pwindow->area;
2006
2008 put_window_near_map_tile(pwindow, pwindow->size.w, pwindow->size.h,
2009 unit_tile(actor));
2010
2011 /* setup widget size and start position */
2012 buf = pwindow;
2013
2014 if (exit) {
2015 /* exit button */
2016 buf = buf->prev;
2017 buf->size.x = area.x + area.w - buf->size.w - 1;
2018 buf->size.y = pwindow->size.y + adj_size(2);
2019 }
2020
2021 buf = buf->prev;
2023 area.x,
2024 area.y + 1, area.w, 0,
2026
2027 /* --------------------- */
2028 /* redraw */
2030
2031 widget_flush(pwindow);
2032}
const char * action_prepare_ui_name(action_id act_id, const char *mnemonic, const struct act_prob prob, const char *custom)
Definition actions.c:2073
enum action_actor_kind action_get_actor_kind(const struct action *paction)
Definition actions.c:1859
bool action_prob_possible(const struct act_prob probability)
Definition actions.c:5821
enum action_sub_target_kind action_get_sub_target_kind(const struct action *paction)
Definition actions.c:1880
enum action_target_kind action_get_target_kind(const struct action *paction)
Definition actions.c:1869
static struct action * action_by_number(action_id act_id)
Definition actions.h:635
#define action_iterate_end
Definition actions.h:465
#define action_id_get_actor_kind(act_id)
Definition actions.h:648
#define action_iterate(_act_)
Definition actions.h:461
#define action_id_get_target_kind(act_id)
Definition actions.h:652
#define ACTION_NONE
Definition actions.h:311
void astr_free(struct astring *astr)
Definition astring.c:153
void astr_set(struct astring *astr, const char *format,...)
Definition astring.c:267
#define str
Definition astring.c:76
#define n
Definition astring.c:77
static const char * astr_str(const struct astring *astr) fc__attribute((nonnull(1)))
Definition astring.h:93
#define ASTRING_INIT
Definition astring.h:44
const char * city_improvement_name_translation(const struct city *pcity, const struct impr_type *pimprove)
Definition city.c:663
const char * city_name_get(const struct city *pcity)
Definition city.c:1137
#define INCITE_IMPOSSIBLE_COST
Definition city.h:96
#define city_owner(_pcity_)
Definition city.h:563
#define city_built_iterate(_pcity, _p)
Definition city.h:834
#define city_built_iterate_end
Definition city.h:840
struct civclient client
#define client_player()
void client_unit_init_act_prob_cache(struct unit *punit)
Definition climisc.c:1258
char * incite_cost
Definition comments.c:75
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 * target_unit
Definition dialogs_g.h:56
popup_action_selection
Definition dialogs_g.h:55
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 int actor_unit_id popup_bribe_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 * actor
Definition dialogs_g.h:73
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 * 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:65
#define NO_TARGET
Definition fc_types.h:354
int Tech_type_id
Definition fc_types.h:377
int action_id
Definition fc_types.h:389
#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:62
struct world wld
Definition game.c:63
struct unit * game_unit_by_number(int id)
Definition game.c:116
struct city * game_city_by_number(int id)
Definition game.c:107
int action_selection_target_extra(void)
static int actor_unit_id
int action_selection_target_tile(void)
int action_selection_actor_unit(void)
static void spy_steal_popup_shared(GtkWidget *w, gpointer data)
void action_selection_close(void)
int action_selection_target_city(void)
static void action_entry(GtkWidget *shl, action_id act_id, const struct act_prob *act_probs, const char *custom, action_id act_num)
static void spy_steal_esc_popup(GtkWidget *w, gpointer data)
static void spy_steal_popup(GtkWidget *w, gpointer data)
static action_id get_non_targeted_action_id(action_id tgt_action_id)
static void found_city_callback(GtkWidget *w, gpointer data)
void action_selection_refresh(struct unit *actor_unit, struct city *target_city, struct unit *target_unit, struct tile *target_tile, struct extra_type *target_extra, const struct act_prob *act_probs)
static void simple_action_callback(GtkWidget *w, gpointer data)
static bool is_more_user_input_needed
static void act_sel_wait_callback(GtkWidget *w, gpointer data)
static action_id get_production_targeted_action_id(action_id tgt_action_id)
static bool did_not_decide
void popup_sabotage_dialog(struct unit *actor, struct city *pcity, const struct action *paction)
int action_selection_target_unit(void)
void popup_incite_dialog(struct unit *actor, struct city *pcity, int cost, const struct action *paction)
static const GCallback af_map[ACTION_COUNT]
static void upgrade_callback(GtkWidget *w, gpointer data)
void flush_dirty(void)
Definition mapview.c: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 spy_sabotage_request(struct widget *pwidget)
bool is_unit_move_blocked
Definition gui_main.c:107
static int diplomat_bribe_yes_callback(struct widget *pwidget)
static int spy_strike_bld_request(struct widget *pwidget)
static int sabotage_impr_callback(struct widget *pwidget)
static int bribe_dlg_window_callback(struct widget *pwindow)
static void act_sel_done_primary(int actor_unit_id)
static int diplomat_incite_yes_callback(struct widget *pwidget)
static int diplomat_close_callback(struct widget *pwidget)
static int spy_sabotage_esc_request(struct widget *pwidget)
static int diplomat_dlg_window_callback(struct widget *pwindow)
static int spy_incite_callback(struct widget *pwidget)
static void act_sel_done_secondary(int actor_unit_id)
void popdown_diplomat_dialog(void)
static int exit_bribe_dlg_callback(struct widget *pwidget)
void popdown_incite_dialog(void)
void popdown_bribe_dialog(void)
static int exit_spy_tgt_dlg_callback(struct widget *pwidget)
static int spy_steal_dlg_window_callback(struct widget *pwindow)
static int spy_steal_callback(struct widget *pwidget)
static int diplomat_bribe_callback(struct widget *pwidget)
static int diplomat_incite_callback(struct widget *pwidget)
int(* act_func)(struct widget *)
static struct small_diplomat_dialog * bribe_dlg
SDL_Color * get_theme_color(enum theme_color themecolor)
Definition colors.c: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:181
#define fc_assert(condition)
Definition log.h:176
#define fc_assert_ret_msg(condition, message,...)
Definition log.h:205
#define fc_assert_action(condition, action)
Definition log.h:187
#define fc_assert_ret_val_msg(condition, val, message,...)
Definition log.h:208
struct tile * index_to_tile(const struct civ_map *imap, int mindex)
Definition map.c:456
#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:320
int id
Definition city.h:326
struct tile * tile
Definition city.h:322
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
Definition unit.h:138
struct unit::@81::@83 client
int id
Definition unit.h:145
struct act_prob * act_prob_cache
Definition unit.h:228
union widget::@194 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:974
#define TRUE
Definition support.h:46
#define FALSE
Definition support.h:47
struct advance * advance_by_number(const Tech_type_id atype)
Definition tech.c:107
const char * advance_name_translation(const struct advance *padvance)
Definition tech.c:290
struct advance * valid_advance_by_number(const Tech_type_id id)
Definition tech.c:176
Tech_type_id advance_number(const struct advance *padvance)
Definition tech.c:98
#define advance_index_iterate_max(_start, _index, _max)
Definition tech.h:252
#define advance_index_iterate_max_end
Definition tech.h:258
static Tech_type_id advance_count(void)
Definition tech.h:170
#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:1710
#define tile_index(_pt_)
Definition tile.h:88
#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:359
#define unit_tile(_pu)
Definition unit.h:397
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:1569
struct advance * utype_primary_tech_req(const struct unit_type *ptype)
Definition unittype.c:2710