Freeciv-3.2
Loading...
Searching...
No Matches
menu.c
Go to the documentation of this file.
1/***********************************************************************
2 Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
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/***********************************************************************
15 menu.c - description
16 -------------------
17 begin : Wed Sep 04 2002
18 copyright : (C) 2002 by Rafał Bursig
19 email : Rafał Bursig <bursig@poczta.fm>
20***********************************************************************/
21
22#ifdef HAVE_CONFIG_H
23#include <fc_config.h>
24#endif
25
26/* SDL2 */
27#ifdef SDL2_PLAIN_INCLUDE
28#include <SDL.h>
29#else /* SDL2_PLAIN_INCLUDE */
30#include <SDL2/SDL.h>
31#endif /* SDL2_PLAIN_INCLUDE */
32
33/* utility */
34#include "fcintl.h"
35#include "log.h"
36
37/* common */
38#include "clientutils.h"
39#include "game.h"
40#include "road.h"
41#include "traderoutes.h"
42#include "unitlist.h"
43
44/* client */
45#include "client_main.h" /* client_state */
46#include "climisc.h"
47#include "control.h"
48
49/* gui-sdl2 */
50#include "dialogs.h"
51#include "gotodlg.h"
52#include "graphics.h"
53#include "gui_id.h"
54#include "gui_main.h"
55#include "gui_tilespec.h"
56#include "mapctrl.h"
57#include "mapview.h"
58#include "pages.h"
59#include "widget.h"
60
61#include "menu.h"
62
63extern struct widget *options_button;
64
67
79
80#define local_show(id) \
81 clear_wflag(get_widget_pointer_from_id(begin_order_widget_list, id, SCAN_FORWARD), \
82 WF_HIDDEN)
83
84#define local_hide(id) \
85 set_wflag(get_widget_pointer_from_id(begin_order_widget_list, id, SCAN_FORWARD), \
86 WF_HIDDEN )
87
88
89/**********************************************************************/
93{
96
99
100 if (!head_unit) {
101 return -1;
102 }
103
104 switch (order_widget->id) {
106 /* Enable the button for adding to a city in all cases, so we
107 get an eventual error message from the server if we try. */
109 break;
112 break;
115 break;
118 break;
121 break;
124 break;
127 break;
130 break;
133 break;
136 break;
139 break;
142 break;
145 break;
148 break;
151 break;
154 break;
157 break;
160 break;
165 break;
170 break;
173 break;
178 break;
181 break;
183 {
185
186 if (extra_type_list_size(extras) > 0) {
187 struct extra_type *pextra;
188
190
192 }
193 }
194 break;
196 {
198
199 if (proad != NULL) {
200 struct extra_type *tgt;
201
202 tgt = road_extra_get(proad);
203
205 }
206 }
207 break;
209 {
211
212 if (prail != NULL) {
213 struct extra_type *tgt;
214
215 tgt = road_extra_get(prail);
216
218 }
219 }
220 break;
223 break;
226 break;
229 break;
232 break;
237 break;
240 break;
243 break;
246 break;
249 break;
252 break;
255 flush_dirty();
256 break;
259 flush_dirty();
260 break;
261
262 default:
263 break;
264 }
265 }
266
267 return -1;
268}
269
270/**********************************************************************/
274{
275 Uint16 count = 0;
277
278 while (TRUE) {
279 if (!(get_wflags(tmp_widget) & WF_HIDDEN)) {
282 }
285 count++;
286 }
287
289 break;
290 }
291
292 tmp_widget = tmp_widget->next;
293 }
294
295 return count;
296}
297
298/**********************************************************************/
302{
306 Sint16 sx, sy, xx, yy = 0;
307 int count = 0, lines = 1, w = 0, count_on_line;
308
309 xx = minimap->dst->dest_rect.x + minimap->size.w + adj_size(10);
310 w = (info_wind->dst->dest_rect.x - adj_size(10)) - xx;
311
312 if (w < (tmp_widget->size.w + adj_size(10)) * 2) {
313 if (minimap->size.h == info_wind->size.h) {
314 xx = 0;
315 w = main_window_width();
316 yy = info_wind->size.h;
317 } else {
318 if (minimap->size.h > info_wind->size.h) {
319 w = main_window_width() - xx - adj_size(20);
320 if (w < (tmp_widget->size.w + adj_size(10)) * 2) {
321 xx = 0;
322 w = minimap->size.w;
323 yy = minimap->size.h;
324 } else {
325 yy = info_wind->size.h;
326 }
327 } else {
328 w = info_wind->dst->dest_rect.x - adj_size(20);
329 if (w < (tmp_widget->size.w + adj_size(10)) * 2) {
330 xx = info_wind->dst->dest_rect.x;
331 w = info_wind->size.w;
332 yy = info_wind->size.h;
333 } else {
334 xx = adj_size(10);
335 yy = minimap->size.h;
336 }
337 }
338 }
339 }
340
341 count_on_line = w / (tmp_widget->size.w + adj_size(5));
342
343 /* find how many to reposition */
344 while (TRUE) {
345 if (!(get_wflags(tmp_widget) & WF_HIDDEN)) {
346 count++;
347 }
348
350 break;
351 }
352
353 tmp_widget = tmp_widget->next;
354 }
355
357
358 if (count - count_on_line > 0) {
359 lines = (count + (count_on_line - 1)) / count_on_line;
360
361 count = count_on_line - ((count_on_line * lines) - count);
362 }
363
364 sx = xx + (w - count * (tmp_widget->size.w + adj_size(5))) / 2;
365
366 sy = tmp_widget->dst->surface->h - yy - lines * (tmp_widget->size.h + adj_size(5));
367
368 while (TRUE) {
369 if (!(get_wflags(tmp_widget) & WF_HIDDEN)) {
370 tmp_widget->size.x = sx;
371 tmp_widget->size.y = sy;
372
373 count--;
374 sx += (tmp_widget->size.w + adj_size(5));
375 if (!count) {
376 count = count_on_line;
377 lines--;
378
379 sx = xx + (w - count * (tmp_widget->size.w + adj_size(5))) / 2;
380
381 sy = tmp_widget->dst->surface->h - yy - lines * (tmp_widget->size.h + adj_size(5));
382 }
383 }
384
386 break;
387 }
388
389 tmp_widget = tmp_widget->next;
390 }
391}
392
393/* ================================ PUBLIC ================================ */
394
395/**********************************************************************/
399{
400 struct widget *buf = NULL;
401 char cbuf[128];
402 struct road_type *proad;
403 struct road_type *prail;
404
405 /* No orders */
406 fc_snprintf(cbuf, sizeof(cbuf), "%s (%s)", _("No Orders"),
407 /* TRANS: "Space" refers to the space bar on a keyboard. */
408 _("Space"));
413 buf->action = unit_order_callback;
415 buf->key = SDLK_SPACE;
417 /* --------- */
418
420
421 /* Wait */
422 fc_snprintf(cbuf, sizeof(cbuf), "%s (%s)", _("Wait"), "W");
427 buf->action = unit_order_callback;
429 buf->key = SDLK_w;
431 /* --------- */
432
433 /* Explode Nuclear */
434 fc_snprintf(cbuf, sizeof(cbuf), "%s (%s)",
440 buf->action = unit_order_callback;
442 buf->key = SDLK_n;
443 buf->mod = KMOD_SHIFT;
445 /* --------- */
446
447 /* Act against the specified tile. */
448 /* TRANS: Button to bring up the action selection dialog. */
449 fc_snprintf(cbuf, sizeof(cbuf), "%s (%s)", _("Do..."), "D");
454 buf->action = unit_order_callback;
456 buf->key = SDLK_d;
458 /* --------- */
459
460 /* Disband */
461 fc_snprintf(cbuf, sizeof(cbuf), "%s (%s)", _("Disband Unit"), "Shift+D");
466 buf->action = unit_order_callback;
468 buf->key = SDLK_d;
469 buf->mod = KMOD_SHIFT;
471 /* --------- */
472
473 /* Upgrade */
474 fc_snprintf(cbuf, sizeof(cbuf), "%s (%s)", _("Upgrade Unit"), "Shift+U");
479 buf->action = unit_order_callback;
481 buf->key = SDLK_u;
482 buf->mod = KMOD_SHIFT;
484 /* --------- */
485
486 /* Convert */
487 fc_snprintf(cbuf, sizeof(cbuf), "%s (%s)", _("Convert Unit"), "Shift+O");
492 buf->action = unit_order_callback;
494 buf->key = SDLK_o;
495 buf->mod = KMOD_SHIFT;
497 /* --------- */
498
499 /* Return to nearest city */
500 fc_snprintf(cbuf, sizeof(cbuf), "%s (%s)",
501 _("Return to Nearest City"), "Shift+G");
506 buf->action = unit_order_callback;
508 buf->key = SDLK_g;
509 buf->mod = KMOD_SHIFT;
511 /* --------- */
512
513 /* Goto City */
514 fc_snprintf(cbuf, sizeof(cbuf), "%s (%s)", _("Go to City"), "T");
515 buf = create_themeicon(current_theme->o_goto_city_icon, main_data.gui,
519 buf->action = unit_order_callback;
521 buf->key = SDLK_t;
523 /* --------- */
524
525 /* Airlift */
526 fc_snprintf(cbuf, sizeof(cbuf), "%s (%s)", _("Airlift to City"), "T");
531 buf->action = unit_order_callback;
533 buf->key = SDLK_t;
535 /* --------- */
536
537 /* Goto location */
538 fc_snprintf(cbuf, sizeof(cbuf), "%s (%s)", _("Go to Tile"), "G");
543 buf->action = unit_order_callback;
545 buf->key = SDLK_g;
547 /* --------- */
548
549 /* Patrol */
550 fc_snprintf(cbuf, sizeof(cbuf), "%s (%s)", _("Patrol"), "Q");
555 buf->action = unit_order_callback;
557 buf->key = SDLK_q;
559 /* --------- */
560
561 /* Connect irrigation */
562 fc_snprintf(cbuf, sizeof(cbuf), "%s (%s)",
563 _("Connect With Irrigation"), "Ctrl+I");
564 buf = create_themeicon(current_theme->o_autoconnect_icon, main_data.gui,
568 buf->action = unit_order_callback;
570 buf->key = SDLK_i;
571 buf->mod = KMOD_CTRL;
573 /* --------- */
574
575 /* Connect road */
577
578 if (proad != NULL) {
579 fc_snprintf(cbuf, sizeof(cbuf),
580 _("Connect With %s (%s)"),
582 "Ctrl+R");
583 buf = create_themeicon(current_theme->o_autoconnect_icon, main_data.gui,
587 buf->action = unit_order_callback;
589 buf->key = SDLK_r;
590 buf->mod = KMOD_CTRL;
592 }
593 /* --------- */
594
595 /* Connect railroad */
597 if (prail != NULL) {
598 fc_snprintf(cbuf, sizeof(cbuf),
599 _("Connect With %s (%s)"),
601 "Ctrl+L");
602 buf = create_themeicon(current_theme->o_autoconnect_icon, main_data.gui,
606 buf->action = unit_order_callback;
608 buf->key = SDLK_l;
609 buf->mod = KMOD_CTRL;
611 }
612 /* --------- */
613
614 /* Auto-Explore */
615 fc_snprintf(cbuf, sizeof(cbuf), "%s (%s)", _("Auto Explore"), "X");
620 buf->action = unit_order_callback;
622 buf->key = SDLK_x;
624 /* --------- */
625
626 /* Auto-Settler */
627 fc_snprintf(cbuf, sizeof(cbuf), "%s (%s)", _("Auto Settler"), "A");
628
629 buf = create_themeicon(current_theme->o_autosett_icon, main_data.gui,
633 buf->action = unit_order_callback;
635 buf->key = SDLK_a;
637 /* --------- */
638
639 /* Wake Up Others */
640 fc_snprintf(cbuf, sizeof(cbuf), "%s (%s)",
641 _("Unsentry All On Tile"), "Shift+S");
646 buf->action = unit_order_callback;
648 buf->key = SDLK_s;
649 buf->mod = KMOD_SHIFT;
651 /* --------- */
652
653 /* Unload */
654 fc_snprintf(cbuf, sizeof(cbuf), "%s (%s)",
655 _("Unload All From Transporter"), "Shift+T");
660 buf->action = unit_order_callback;
662 buf->mod = KMOD_SHIFT;
663 buf->key = SDLK_t;
665 /* --------- */
666
667 /* Board */
668 fc_snprintf(cbuf, sizeof(cbuf), "%s (%s)", _("Load Unit"), "L");
673 buf->action = unit_order_callback;
675 buf->key = SDLK_l;
677 /* --------- */
678
679 /* Deboard */
680 fc_snprintf(cbuf, sizeof(cbuf), "%s (%s)", _("Unload Unit"), "U");
685 buf->action = unit_order_callback;
687 buf->key = SDLK_u;
689 /* --------- */
690
691 /* Find Homecity */
692 fc_snprintf(cbuf, sizeof(cbuf), "%s (%s)",
694 buf = create_themeicon(current_theme->o_homecity_icon, main_data.gui,
698 buf->action = unit_order_callback;
700 buf->key = SDLK_h;
702 /* --------- */
703
704 /* Pillage */
705 fc_snprintf(cbuf, sizeof(cbuf), "%s (%s)", _("Pillage"), "Shift+P");
710 buf->action = unit_order_callback;
712 buf->key = SDLK_p;
713 buf->mod = KMOD_SHIFT;
715 /* --------- */
716
717 /* Sentry */
718 fc_snprintf(cbuf, sizeof(cbuf), "%s (%s)", _("Sentry Unit"), "S");
723 buf->action = unit_order_callback;
725 buf->key = SDLK_s;
727 /* --------- */
728
729 /* Paradrop */
730 fc_snprintf(cbuf, sizeof(cbuf), "%s (%s)",
732 buf = create_themeicon(current_theme->o_paradrop_icon, main_data.gui,
736 buf->action = unit_order_callback;
738 buf->key = SDLK_j;
740 /* --------- */
741
742 /* Generic Clean */
743 /* Label will be replaced by real_menus_update() before it's seen */
744 fc_snprintf(cbuf, sizeof(cbuf), "placeholder");
749 buf->action = unit_order_callback;
751 buf->key = SDLK_p;
754 /* --------- */
755
756 /* Build Airbase */
757 /* Label will be replaced by real_menus_update() before it's seen */
758 fc_snprintf(cbuf, sizeof(cbuf), "placeholder");
763 buf->action = unit_order_callback;
765 buf->key = SDLK_e;
766 buf->mod = KMOD_SHIFT;
769 /* --------- */
770
771 /* Fortify */
772 fc_snprintf(cbuf, sizeof(cbuf), "%s (%s)", _("Fortify Unit"), "F");
777 buf->action = unit_order_callback;
779 buf->key = SDLK_f;
781 /* --------- */
782
783 /* Build Fortress */
784 /* Label will be replaced by real_menus_update() before it's seen */
785 fc_snprintf(cbuf, sizeof(cbuf), "placeholder");
786 buf = create_themeicon(current_theme->o_fortress_icon, main_data.gui,
790 buf->action = unit_order_callback;
792 buf->key = SDLK_f;
793 buf->mod = KMOD_SHIFT;
796 /* --------- */
797
798 /* Transform Tile */
799 /* Label will be replaced by real_menus_update() before it's seen */
800 fc_snprintf(cbuf, sizeof(cbuf), "placeholder");
801 buf = create_themeicon(current_theme->o_transform_icon, main_data.gui,
805 buf->action = unit_order_callback;
807 buf->key = SDLK_o;
810 /* --------- */
811
812 /* Build Mine */
813 /* Label will be replaced by real_menus_update() before it's seen */
814 fc_snprintf(cbuf, sizeof(cbuf), "placeholder");
819 buf->action = unit_order_callback;
821 buf->key = SDLK_m;
823
825 /* --------- */
826
827 /* Build Irrigation */
828 /* Label will be replaced by real_menus_update() before it's seen */
829 fc_snprintf(cbuf, sizeof(cbuf), "placeholder");
830 buf = create_themeicon(current_theme->o_irrigation_icon, main_data.gui,
834 buf->action = unit_order_callback;
835 buf->key = SDLK_i;
838
840 /* --------- */
841
842 /* Cultivate */
843 /* Label will be replaced by real_menus_update() before it's seen */
844 fc_snprintf(cbuf, sizeof(cbuf), "placeholder");
845 buf = create_themeicon(current_theme->o_cultivate_icon, main_data.gui,
849 buf->action = unit_order_callback;
850 buf->key = SDLK_i;
851 buf->mod = KMOD_SHIFT;
854
856 /* --------- */
857
858 /* Plant */
859 /* Label will be replaced by real_menus_update() before it's seen */
860 fc_snprintf(cbuf, sizeof(cbuf), "placeholder");
865 buf->action = unit_order_callback;
866 buf->key = SDLK_m;
867 buf->mod = KMOD_SHIFT;
870
872 /* --------- */
873
874 /* Establish Trade route */
875 /* Label will be replaced by real_menus_update() before it's seen */
876 fc_snprintf(cbuf, sizeof(cbuf), "placeholder");
881 buf->action = unit_order_callback;
883 buf->key = SDLK_r;
885
887 /* --------- */
888
889 /* Build (Rail-)Road */
890 /* Label will be replaced by real_menus_update() before it's seen */
891 fc_snprintf(cbuf, sizeof(cbuf), "placeholder");
896 buf->action = unit_order_callback;
898 buf->key = SDLK_r;
900
902 /* --------- */
903
904 /* Help Build Wonder */
905 fc_snprintf(cbuf, sizeof(cbuf), "%s (%s)",
911 buf->action = unit_order_callback;
913 buf->key = SDLK_b;
915 /* --------- */
916
917 /* Add to City / Build New City */
918 /* Label will be replaced by real_menus_update() before it's seen */
919 fc_snprintf(cbuf, sizeof(cbuf), "placeholder");
920 buf = create_themeicon(current_theme->o_build_city_icon, main_data.gui,
924 buf->action = unit_order_callback;
926 buf->key = SDLK_b;
928
930 /* --------- */
931
933
935}
936
937/**********************************************************************/
948
949/**********************************************************************/
957
958/**********************************************************************/
962{
964
965 if (tmp_widget == NULL) {
966 return;
967 }
968
969 while (TRUE) {
970 if (!(get_wflags(tmp_widget) & WF_HIDDEN) && (tmp_widget->gfx)) {
973 }
974
976 break;
977 }
978
979 tmp_widget = tmp_widget->next;
980 }
981}
982
983/* ============================== Native =============================== */
984
985/**********************************************************************/
990{
991 /* PORTME */
992}
993
994/**********************************************************************/
998{
999 static Uint16 counter = 0;
1000 struct unit_list *punits = NULL;
1001 struct unit *punit = NULL;
1002 static char cbuf[128];
1003
1004 if ((C_S_RUNNING != client_state())
1005 || (get_client_page() != PAGE_GAME)) {
1006
1008
1013 }
1014
1017 }
1018
1019 } else {
1020 /* Running state */
1022 /* show options button */
1026 }
1027
1028 if (NULL == client.conn.playing) {
1029 /* Global observer */
1031 /* show minimap buttons and unitinfo buttons */
1034 /* disable minimap buttons and unitinfo buttons */
1037 }
1038
1039 return;
1040
1041 } else {
1042 /* running state with player */
1043
1046 }
1047
1048 if (counter) {
1050 }
1051
1054
1055 /* show minimap buttons and unitinfo buttons */
1058
1059 counter = 0;
1060 }
1061 }
1062
1065
1066 if (punit && punit->ssa_controller == SSA_NONE) {
1067 struct city *homecity;
1068 int time;
1069 struct tile *ptile = unit_tile(punit);
1070 struct city *pcity = tile_city(ptile);
1071 struct terrain *pterrain = tile_terrain(ptile);
1072 struct base_type *pbase;
1073 struct extra_type *pextra;
1074
1075 if (!counter) {
1078
1081 }
1082
1083 /* Enable the button for adding to a city in all cases, so we
1084 * get an eventual error message from the server if we try. */
1085
1087 if (pcity != NULL) {
1088 fc_snprintf(cbuf, sizeof(cbuf), "%s (%s)",
1090 } else {
1091 fc_snprintf(cbuf, sizeof(cbuf), "%s (%s)",
1093 }
1095 cbuf);
1097 } else {
1099 }
1100
1103 } else {
1105 }
1106
1107 pextra = next_extra_for_tile(ptile, EC_ROAD, unit_owner(punit), punit);
1108 if (pextra != NULL
1110 struct road_type *proad = extra_road_get(pextra);
1112
1114
1115 /* TRANS: "Build Railroad (R) 3 turns" */
1116 fc_snprintf(cbuf, sizeof(cbuf), _("Build %s (%s) %d %s"),
1117 extra_name_translation(pextra),
1118 "R", time,
1119 PL_("turn", "turns", time));
1120
1121 if (compat == ROCO_RAILROAD) {
1122 order_road_button->theme = current_theme->o_railroad_icon;
1123 } else {
1124 order_road_button->theme = current_theme->o_road_icon;
1125 }
1128 } else {
1130 }
1131
1132 /* unit_can_est_trade_route_here(punit) */
1135 && (homecity = game_city_by_number(punit->homecity))
1136 && can_cities_trade(homecity, pcity)) {
1137 int revenue = get_caravan_enter_city_trade_bonus(homecity, pcity,
1139 punit->carrying,
1140 TRUE);
1141
1142 if (can_establish_trade_route(homecity, pcity)) {
1143 fc_snprintf(cbuf, sizeof(cbuf),
1144 _("%s With %s ( %d one time bonus + %d trade ) (R)"),
1146 city_name_get(homecity),
1147 revenue,
1148 trade_base_between_cities(homecity, pcity));
1149 } else {
1150 revenue = (revenue + 2) / 3;
1151 fc_snprintf(cbuf, sizeof(cbuf),
1152 _("%s Of %s ( %d one time bonus ) (R)"),
1154 city_name_get(homecity),
1155 revenue);
1156 }
1159 } else {
1161 }
1162
1163 pextra = next_extra_for_tile(ptile, EC_IRRIGATION,
1165 if (pextra != NULL
1168 pextra, punit);
1169 /* TRANS: "Build Irrigation (I) 5 turns" */
1170 fc_snprintf(cbuf, sizeof(cbuf), _("Build %s (%s) %d %s"),
1171 extra_name_translation(pextra), "I", time,
1172 PL_("turn", "turns", time));
1173 order_irrigation_button->theme = current_theme->o_irrigation_icon;
1174
1177 } else {
1179 }
1180
1181 pextra = next_extra_for_tile(ptile, EC_MINE,
1183 if (pextra != NULL
1186 /* TRANS: "Build Mine (M) 5 turns" */
1187 fc_snprintf(cbuf, sizeof(cbuf), _("Build %s (%s) %d %s"),
1188 extra_name_translation(pextra), "M", time,
1189 PL_("turn", "turns", time));
1190 order_mine_button->theme = current_theme->o_mine_icon;
1191
1194 } else {
1196 }
1197
1199 /* Activity always results in terrain change */
1201 fc_snprintf(cbuf, sizeof(cbuf), "%s %s (%s) %d %s",
1202 _("Cultivate to"),
1204 "Shift+I", time, PL_("turn", "turns", time));
1207 } else {
1209 }
1210
1212 /* Activity always results in terrain change */
1214 fc_snprintf(cbuf, sizeof(cbuf), "%s %s (%s) %d %s",
1215 _("Plant to"),
1217 "Shift+M", time, PL_("turn", "turns", time));
1220 } else {
1222 }
1223
1225 /* Activity always results in terrain change */
1227 fc_snprintf(cbuf, sizeof(cbuf), "%s %s (%s) %d %s",
1228 _("Transform to"),
1230 "O", time, PL_("turn", "turns", time));
1233 } else {
1235 }
1236
1238 if (pbase != NULL) {
1240
1242 /* TRANS: "Build Fortress (Shift+F) 5 turns" */
1243 fc_snprintf(cbuf, sizeof(cbuf), _("Build %s (%s) %d %s"),
1245 PL_("turn", "turns", time));
1248 } else {
1250 }
1251
1254 } else {
1256 }
1257
1259 if (pbase != NULL) {
1261
1263 /* TRANS: "Build Airbase (Shift+E) 5 turns" */
1264 fc_snprintf(cbuf, sizeof(cbuf), _("Build %s (%s) %d %s"),
1266 PL_("turn", "turns", time));
1269 } else {
1271 }
1272
1273 if (can_unit_paradrop(&(wld.map), punit)) {
1275 } else {
1277 }
1278
1279 pextra = prev_cleanable_in_tile(ptile, unit_owner(punit), punit);
1280
1281 if (pextra != NULL
1283 pextra)) {
1285 pextra, punit);
1286 /* TRANS: "Clean Pollution (P) 3 turns" */
1287 fc_snprintf(cbuf, sizeof(cbuf), _("Clean %s (%s) %d %s"),
1288 extra_name_translation(pextra), "P", time,
1289 PL_("turn", "turns", time));
1292 } else {
1294 }
1295
1298 } else {
1300 }
1301
1304 } else {
1306 }
1307
1308 if (pcity != NULL && can_unit_change_homecity(&(wld.map), punit)
1309 && pcity->id != punit->homecity) {
1311 } else {
1313 }
1314
1315 if (punit->client.occupied) {
1317 } else {
1319 }
1320
1321 if (units_can_load(punits)) {
1323 } else {
1325 }
1326
1327 if (units_can_unload(punits)) {
1329 } else {
1331 }
1332
1335 } else {
1337 }
1338
1341 } else {
1343 }
1344
1347 } else {
1349 }
1350
1351 {
1352 bool conn_possible = FALSE;
1353 struct extra_type_list *extras;
1354
1356
1357 if (extra_type_list_size(extras) > 0) {
1358 struct extra_type *tgt;
1359
1360 tgt = extra_type_list_get(extras, 0);
1362 }
1363
1364 if (conn_possible) {
1366 } else {
1368 }
1369 }
1370
1371 {
1373 bool road_conn_possible;
1374
1375 if (proad != NULL) {
1376 struct extra_type *tgt;
1377
1378 tgt = road_extra_get(proad);
1379
1381 } else {
1383 }
1384
1385 if (road_conn_possible) {
1387 } else {
1389 }
1390 }
1391
1392 {
1394 bool road_conn_possible;
1395
1396 if (proad != NULL) {
1397 struct extra_type *tgt;
1398
1399 tgt = road_extra_get(proad);
1400
1402 } else {
1404 }
1405
1406 if (road_conn_possible) {
1408 } else {
1410 }
1411 }
1412
1415 } else {
1417 }
1418
1421 } else {
1423 }
1424
1425 if (pcity && pcity->airlift) {
1428 } else {
1431 }
1432
1434 unit_type_get(punit))) {
1436 } else {
1438 }
1439
1440 if (unit_can_convert(&(wld.map), punit)) {
1442 } else {
1444 }
1445
1448
1449 } else {
1450 if (counter) {
1452 }
1453
1454 counter = 0;
1455 }
1456 }
1457}
1458
1459/**********************************************************************/
1468
1469/**********************************************************************/
const char * action_id_name_translation(action_id act_id)
Definition actions.c:2011
#define ACTION_ANY
Definition actions.h:308
struct extra_type * base_extra_get(const struct base_type *pbase)
Definition base.c:101
struct base_type * get_base_by_gui_type(enum base_gui_type type, const struct unit *punit, const struct tile *ptile)
Definition base.c:139
const char * city_name_get(const struct city *pcity)
Definition city.c:1137
struct civclient client
enum client_states client_state(void)
bool can_client_issue_orders(void)
@ C_S_RUNNING
Definition client_main.h:47
int turns_to_activity_done(const struct tile *ptile, Activity_type_id act, const struct extra_type *tgt, const struct unit *pmodunit)
bool can_units_do_connect(struct unit_list *punits, enum unit_activity activity, struct extra_type *tgt)
Definition climisc.c:1241
char * incite_cost
Definition comments.c:75
void key_unit_sentry(void)
Definition control.c:3756
void key_unit_road(void)
Definition control.c:3738
void request_unit_return(struct unit *punit)
Definition control.c:1552
void key_unit_build_city(void)
Definition control.c:3353
void key_unit_auto_explore(void)
Definition control.c:3577
void key_unit_connect(enum unit_activity activity, struct extra_type *tgt)
Definition control.c:3375
void request_unit_load(struct unit *pcargo, struct unit *ptrans, struct tile *ptile)
Definition control.c:2156
void request_unit_goto(enum unit_orders last_order, action_id act_id, int sub_tgt_id)
Definition control.c:1130
void key_unit_paradrop(void)
Definition control.c:3479
struct unit_list * get_units_in_focus(void)
Definition control.c:177
void request_unit_autosettlers(const struct unit *punit)
Definition control.c:2141
bool can_unit_do_connect(struct unit *punit, enum unit_activity activity, struct extra_type *tgt)
Definition control.c:1415
void key_unit_build_wonder(void)
Definition control.c:3363
void key_unit_plant(void)
Definition control.c:3696
void key_unit_fortress(void)
Definition control.c:3624
void key_unit_mine(void)
Definition control.c:3688
void key_unit_pillage(void)
Definition control.c:3708
void request_unit_unload(struct unit *pcargo)
Definition control.c:2194
void key_unit_irrigate(void)
Definition control.c:3668
void key_unit_unload_all(void)
Definition control.c:3517
void key_unit_homecity(void)
Definition control.c:3641
void key_unit_patrol(void)
Definition control.c:3487
void key_unit_wakeup_others(void)
Definition control.c:3550
void key_unit_wait(void)
Definition control.c:3542
void key_unit_trade_route(void)
Definition control.c:3503
struct unit * head_of_units_in_focus(void)
Definition control.c:410
void key_unit_action_select_tgt(void)
Definition control.c:3406
void key_unit_transform(void)
Definition control.c:3768
void key_unit_done(void)
Definition control.c:3463
void key_unit_airbase(void)
Definition control.c:3560
void key_unit_goto(void)
Definition control.c:3471
void key_unit_convert(void)
Definition control.c:3602
void key_unit_clean(void)
Definition control.c:3720
void key_unit_fortify(void)
Definition control.c:3612
void key_unit_cultivate(void)
Definition control.c:3676
#define can_unit_do_activity_targeted_client(_punit_, _act_, _tgt_)
Definition control.h:43
#define can_unit_do_activity_client(_punit_, _act_)
Definition control.h:41
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 extra_type * next_extra_for_tile(const struct tile *ptile, enum extra_cause cause, const struct player *pplayer, const struct unit *punit)
Definition extras.c:765
struct extra_type * prev_cleanable_in_tile(const struct tile *ptile, const struct player *pplayer, const struct unit *punit)
Definition extras.c:817
struct extra_type_list * extra_type_list_by_cause(enum extra_cause cause)
Definition extras.c:249
static struct extra_type extras[MAX_EXTRA_TYPES]
Definition extras.c:31
const char * extra_name_translation(const struct extra_type *pextra)
Definition extras.c:194
#define extra_road_get(_e_)
Definition extras.h:191
QString current_theme
Definition fc_client.cpp:65
road_compat
Definition fc_types.h:1253
@ ROCO_RAILROAD
Definition fc_types.h:1253
#define PL_(String1, String2, n)
Definition fcintl.h:71
#define _(String)
Definition fcintl.h:67
struct world wld
Definition game.c:63
struct city * game_city_by_number(int id)
Definition game.c:107
void popup_goto_dialog(void)
Definition gotodlg.c:258
void flush_dirty(void)
Definition mapview.c:468
void real_menus_init(void)
Definition menu.c:2915
void real_menus_update(void)
Definition menu.c:2353
void popup_unit_disband_dlg(struct unit *punit, bool city)
Definition dialogs.c:878
void popup_unit_upgrade_dlg(struct unit *punit, bool city)
Definition dialogs.c:683
void popup_airlift_dialog(void)
Definition gotodlg.c:408
int main_window_width(void)
Definition graphics.c:685
struct sdl2_data main_data
Definition graphics.c:57
@ ID_UNIT_ORDER_NUKE
Definition gui_id.h:121
@ ID_UNIT_ORDER_AUTO_SETTLER
Definition gui_id.h:107
@ ID_UNIT_ORDER_SENTRY
Definition gui_id.h:100
@ ID_UNIT_ORDER_AIRBASE
Definition gui_id.h:97
@ ID_UNIT_ORDER_DEBOARD
Definition gui_id.h:105
@ ID_UNIT_ORDER_BUILD_WONDER
Definition gui_id.h:87
@ ID_UNIT_ORDER_IRRIGATE
Definition gui_id.h:90
@ ID_UNIT_ORDER_BUILD_CITY
Definition gui_id.h:86
@ ID_UNIT_ORDER_RETURN
Definition gui_id.h:116
@ ID_UNIT_ORDER_PATROL
Definition gui_id.h:112
@ ID_UNIT_ORDER_ROAD
Definition gui_id.h:88
@ ID_UNIT_ORDER_CLEAN
Definition gui_id.h:99
@ ID_UNIT_ORDER_MINE
Definition gui_id.h:92
@ ID_UNIT_ORDER_DIPLOMAT_DLG
Definition gui_id.h:120
@ ID_UNIT_ORDER_DISBAND
Definition gui_id.h:119
@ ID_UNIT_ORDER_BOARD
Definition gui_id.h:104
@ ID_UNIT_ORDER_PLANT
Definition gui_id.h:93
@ ID_UNIT_ORDER_CONNECT_ROAD
Definition gui_id.h:109
@ ID_UNIT_ORDER_CONVERT
Definition gui_id.h:118
@ ID_UNIT_ORDER_AUTO_EXPLORE
Definition gui_id.h:108
@ ID_UNIT_ORDER_WAIT
Definition gui_id.h:122
@ ID_UNIT_ORDER_WAKEUP_OTHERS
Definition gui_id.h:106
@ ID_UNIT_ORDER_UNLOAD_TRANSPORTER
Definition gui_id.h:103
@ ID_UNIT_ORDER_UPGRADE
Definition gui_id.h:117
@ ID_UNIT_ORDER_GOTO_CITY
Definition gui_id.h:114
@ ID_UNIT_ORDER_FORTRESS
Definition gui_id.h:95
@ ID_UNIT_ORDER_TRANSFORM
Definition gui_id.h:94
@ ID_UNIT_ORDER_PILLAGE
Definition gui_id.h:101
@ ID_UNIT_ORDER_PARADROP
Definition gui_id.h:98
@ ID_UNIT_ORDER_HOMECITY
Definition gui_id.h:102
@ ID_UNIT_ORDER_CONNECT_IRRIGATE
Definition gui_id.h:111
@ ID_UNIT_ORDER_DONE
Definition gui_id.h:123
@ ID_UNIT_ORDER_GOTO
Definition gui_id.h:113
@ ID_UNIT_ORDER_FORTIFY
Definition gui_id.h:96
@ ID_UNIT_ORDER_AIRLIFT
Definition gui_id.h:115
@ ID_UNIT_ORDER_CULTIVATE
Definition gui_id.h:91
@ ID_UNIT_ORDER_TRADE_ROUTE
Definition gui_id.h:89
@ ID_UNIT_ORDER_CONNECT_RAILROAD
Definition gui_id.h:110
Uint32 sdl2_client_flags
Definition gui_main.c:101
#define CF_MAP_UNIT_W_CREATED
Definition gui_main.h:46
#define CF_ORDERS_WIDGETS_CREATED
Definition gui_main.h:45
struct widget * selected_widget
Definition widget.c:48
#define adj_size(size)
Definition gui_main.h:141
#define CF_GAME_JUST_STARTED
Definition gui_main.h:49
#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
@ FONTO_DEFAULT
Definition gui_string.h:65
#define create_utf8_from_char_fonto(string_in, fonto)
Definition gui_string.h:108
struct widget * get_minimap_window_widget(void)
Definition mapctrl.c:2203
struct widget * get_unit_info_window_widget(void)
Definition mapctrl.c:2195
void hide_unitinfo_window_buttons(void)
Definition mapctrl.c:1593
void disable_minimap_window_buttons(void)
Definition mapctrl.c:1911
void show_minimap_window_buttons(void)
Definition mapctrl.c:1798
void hide_minimap_window_buttons(void)
Definition mapctrl.c:1836
void show_unitinfo_window_buttons(void)
Definition mapctrl.c:1569
void disable_unitinfo_window_buttons(void)
Definition mapctrl.c:1617
struct widget * options_button
Definition optiondlg.c:103
static struct widget * order_trade_button
Definition menu.c:78
static struct widget * order_airbase_button
Definition menu.c:69
void create_units_order_widgets(void)
Definition menu.c:398
void disable_order_buttons(void)
Definition menu.c:1462
static int unit_order_callback(struct widget *order_widget)
Definition menu.c:92
static struct widget * order_clean_button
Definition menu.c:68
#define local_show(id)
Definition menu.c:80
#define local_hide(id)
Definition menu.c:84
static struct widget * order_fortress_button
Definition menu.c:70
static struct widget * order_irrigation_button
Definition menu.c:73
static Uint16 redraw_order_widgets(void)
Definition menu.c:273
static struct widget * order_plant_button
Definition menu.c:75
static struct widget * order_transform_button
Definition menu.c:77
void undraw_order_widgets(void)
Definition menu.c:961
static struct widget * begin_order_widget_list
Definition menu.c:65
static struct widget * order_road_button
Definition menu.c:76
static struct widget * order_cultivate_button
Definition menu.c:74
static void set_new_order_widget_start_pos(void)
Definition menu.c:301
void enable_order_buttons(void)
Definition menu.c:1472
static struct widget * order_build_add_to_city_button
Definition menu.c:71
static struct widget * order_mine_button
Definition menu.c:72
static struct widget * end_order_widget_list
Definition menu.c:66
void delete_units_order_widgets(void)
Definition menu.c:940
void update_order_widgets(void)
Definition menu.c:952
void add_to_gui_list(Uint16 id, struct widget *gui)
Definition widget.c:586
void refresh_widget_background(struct widget *pwidget)
Definition widget.c:1151
void hide_group(struct widget *begin_group_widget_list, struct widget *end_group_widget_list)
Definition widget.c:915
#define enable_group(begin_group_widget_list, end_group_widget_list)
Definition widget.h:397
@ FC_WS_DISABLED
Definition widget.h:99
@ FC_WS_NORMAL
Definition widget.h:96
@ FC_WS_SELECTED
Definition widget.h:97
void clear_wflag(struct widget *pwidget, enum widget_flag flag)
Definition widget_core.c:62
static void widget_mark_dirty(struct widget *pwidget)
Definition widget.h:286
#define disable_group(begin_group_widget_list, end_group_widget_list)
Definition widget.h:401
enum widget_flag get_wflags(const struct widget *pwidget)
Definition widget_core.c:86
void set_wstate(struct widget *pwidget, enum widget_state state)
Definition widget_core.c:36
enum widget_state get_wstate(const struct widget *pwidget)
Definition widget_core.c:70
static void widget_undraw(struct widget *pwidget)
Definition widget.h:296
@ WF_WIDGET_HAS_INFO_LABEL
Definition widget.h:88
@ WF_RESTORE_BACKGROUND
Definition widget.h:85
@ WF_HIDDEN
Definition widget.h:68
static int widget_redraw(struct widget *pwidget)
Definition widget.h:276
#define hide(id)
Definition widget.h:238
void set_wflag(struct widget *pwidget, enum widget_flag flag)
Definition widget_core.c:54
#define del_group(begin_group_widget_list, end_group_widget_list)
Definition widget.h:389
struct widget * create_themeicon(SDL_Surface *icon_theme, struct gui_layer *pdest, Uint32 flags)
char * lines
Definition packhand.c:131
enum client_pages get_client_page(void)
struct extra_type * road_extra_get(const struct road_type *proad)
Definition road.c:42
enum road_compat road_compat_special(const struct road_type *proad)
Definition road.c:151
struct road_type * road_by_gui_type(enum road_gui_type gui_type)
Definition road.c:180
static struct compatibility compat[]
Definition savecompat.c:105
Definition city.h:320
int id
Definition city.h:326
int airlift
Definition city.h:378
struct connection conn
Definition client_main.h:96
struct player * playing
Definition connection.h:151
SDL_Rect dest_rect
Definition graphics.h:228
struct gui_layer * gui
Definition graphics.h:215
SDL_Event event
Definition graphics.h:217
struct terrain * cultivate_result
Definition terrain.h:215
struct terrain * plant_result
Definition terrain.h:218
struct terrain * transform_result
Definition terrain.h:229
Definition tile.h:50
Definition unit.h:138
bool occupied
Definition unit.h:219
struct unit::@81::@83 client
int homecity
Definition unit.h:146
struct goods_type * carrying
Definition unit.h:186
enum server_side_agent ssa_controller
Definition unit.h:172
SDL_Surface * theme
Definition widget.h:118
struct gui_layer * dst
Definition widget.h:116
utf8_str * info_label
Definition widget.h:122
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
const char * terrain_name_translation(const struct terrain *pterrain)
Definition terrain.c:238
struct city * tile_city(const struct tile *ptile)
Definition tile.c:83
#define tile_terrain(_tile)
Definition tile.h:110
bool can_cities_trade(const struct city *pc1, const struct city *pc2)
int trade_base_between_cities(const struct city *pc1, const struct city *pc2)
bool can_establish_trade_route(const struct city *pc1, const struct city *pc2)
int get_caravan_enter_city_trade_bonus(const struct city *pc1, const struct city *pc2, const struct unit_type *ut, struct goods_type *pgood, const bool establish_trade)
bool unit_can_add_or_build_city(const struct civ_map *nmap, const struct unit *punit)
Definition unit.c:448
bool can_unit_change_homecity(const struct civ_map *nmap, const struct unit *punit)
Definition unit.c:481
bool is_unit_activity_on_tile(enum unit_activity activity, const struct tile *ptile)
Definition unit.c:1123
bool can_unit_do_autosettlers(const struct unit *punit)
Definition unit.c:606
bool unit_can_do_action(const struct unit *punit, const action_id act_id)
Definition unit.c:359
bool can_unit_paradrop(const struct civ_map *nmap, const struct unit *punit)
Definition unit.c:822
bool unit_can_help_build_wonder_here(const struct civ_map *nmap, const struct unit *punit)
Definition unit.c:258
bool unit_can_convert(const struct civ_map *nmap, const struct unit *punit)
Definition unit.c:2035
#define unit_tile(_pu)
Definition unit.h:397
@ ORDER_PERFORM_ACTION
Definition unit.h:47
#define unit_owner(_pu)
Definition unit.h:396
bool units_can_unload(const struct unit_list *punits)
Definition unitlist.c:301
bool units_can_load(const struct unit_list *punits)
Definition unitlist.c:287
#define unit_list_iterate(unitlist, punit)
Definition unitlist.h:31
#define unit_list_iterate_end
Definition unitlist.h:33
const struct unit_type * unit_type_get(const struct unit *punit)
Definition unittype.c:123
const struct unit_type * can_upgrade_unittype(const struct player *pplayer, const struct unit_type *punittype)
Definition unittype.c:1703
bool utype_can_do_action(const struct unit_type *putype, const action_id act_id)
Definition unittype.c:371