Freeciv-3.3
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/* SDL3 */
27#include <SDL3/SDL.h>
28
29/* utility */
30#include "fcintl.h"
31#include "log.h"
32
33/* common */
34#include "clientutils.h"
35#include "game.h"
36#include "road.h"
37#include "traderoutes.h"
38#include "unitlist.h"
39
40/* client */
41#include "client_main.h" /* client_state */
42#include "climisc.h"
43#include "control.h"
44#include "pages_g.h"
45
46/* gui-sdl3 */
47#include "dialogs.h"
48#include "gotodlg.h"
49#include "graphics.h"
50#include "gui_id.h"
51#include "gui_main.h"
52#include "gui_tilespec.h"
53#include "mapctrl.h"
54#include "mapview.h"
55#include "widget.h"
56
57#include "menu.h"
58
59extern struct widget *options_button;
60
63
75
76#define local_show(id) \
77 clear_wflag(get_widget_pointer_from_id(begin_order_widget_list, id, SCAN_FORWARD), \
78 WF_HIDDEN)
79
80#define local_hide(id) \
81 set_wflag(get_widget_pointer_from_id(begin_order_widget_list, id, SCAN_FORWARD), \
82 WF_HIDDEN )
83
84
85/**********************************************************************/
89{
92
95
96 if (!head_unit) {
97 return -1;
98 }
99
100 switch (order_widget->id) {
102 /* Enable the button for adding to a city in all cases, so we
103 get an eventual error message from the server if we try. */
105 break;
108 break;
111 break;
114 break;
117 break;
120 break;
123 break;
126 break;
129 break;
132 break;
135 break;
138 break;
141 break;
144 break;
147 break;
150 break;
153 break;
156 break;
161 break;
166 break;
169 break;
174 break;
177 break;
179 {
181
182 if (extra_type_list_size(extras) > 0) {
183 struct extra_type *pextra;
184
186
188 }
189 }
190 break;
192 {
194
195 if (proad != NULL) {
196 struct extra_type *tgt;
197
198 tgt = road_extra_get(proad);
199
201 }
202 }
203 break;
205 {
207
208 if (prail != NULL) {
209 struct extra_type *tgt;
210
211 tgt = road_extra_get(prail);
212
214 }
215 }
216 break;
219 break;
222 break;
225 break;
228 break;
233 break;
236 break;
239 break;
242 break;
245 break;
248 break;
251 flush_dirty();
252 break;
255 flush_dirty();
256 break;
257
258 default:
259 break;
260 }
261 }
262
263 return -1;
264}
265
266/**********************************************************************/
270{
271 Uint16 count = 0;
273
274 while (TRUE) {
275 if (!(get_wflags(tmp_widget) & WF_HIDDEN)) {
278 }
281 count++;
282 }
283
285 break;
286 }
287
288 tmp_widget = tmp_widget->next;
289 }
290
291 return count;
292}
293
294/**********************************************************************/
298{
302 Sint16 sx, sy, xx, yy = 0;
303 int count = 0, lines = 1, w = 0, count_on_line;
304
305 xx = minimap->dst->dest_rect.x + minimap->size.w + adj_size(10);
306 w = (info_wind->dst->dest_rect.x - adj_size(10)) - xx;
307
308 if (w < (tmp_widget->size.w + adj_size(10)) * 2) {
309 if (minimap->size.h == info_wind->size.h) {
310 xx = 0;
311 w = main_window_width();
312 yy = info_wind->size.h;
313 } else {
314 if (minimap->size.h > info_wind->size.h) {
315 w = main_window_width() - xx - adj_size(20);
316 if (w < (tmp_widget->size.w + adj_size(10)) * 2) {
317 xx = 0;
318 w = minimap->size.w;
319 yy = minimap->size.h;
320 } else {
321 yy = info_wind->size.h;
322 }
323 } else {
324 w = info_wind->dst->dest_rect.x - adj_size(20);
325 if (w < (tmp_widget->size.w + adj_size(10)) * 2) {
326 xx = info_wind->dst->dest_rect.x;
327 w = info_wind->size.w;
328 yy = info_wind->size.h;
329 } else {
330 xx = adj_size(10);
331 yy = minimap->size.h;
332 }
333 }
334 }
335 }
336
337 count_on_line = w / (tmp_widget->size.w + adj_size(5));
338
339 /* find how many to reposition */
340 while (TRUE) {
341 if (!(get_wflags(tmp_widget) & WF_HIDDEN)) {
342 count++;
343 }
344
346 break;
347 }
348
349 tmp_widget = tmp_widget->next;
350 }
351
353
354 if (count - count_on_line > 0) {
355 lines = (count + (count_on_line - 1)) / count_on_line;
356
357 count = count_on_line - ((count_on_line * lines) - count);
358 }
359
360 sx = xx + (w - count * (tmp_widget->size.w + adj_size(5))) / 2;
361
362 sy = tmp_widget->dst->surface->h - yy - lines * (tmp_widget->size.h + adj_size(5));
363
364 while (TRUE) {
365 if (!(get_wflags(tmp_widget) & WF_HIDDEN)) {
366 tmp_widget->size.x = sx;
367 tmp_widget->size.y = sy;
368
369 count--;
370 sx += (tmp_widget->size.w + adj_size(5));
371 if (!count) {
372 count = count_on_line;
373 lines--;
374
375 sx = xx + (w - count * (tmp_widget->size.w + adj_size(5))) / 2;
376
377 sy = tmp_widget->dst->surface->h - yy - lines * (tmp_widget->size.h + adj_size(5));
378 }
379 }
380
382 break;
383 }
384
385 tmp_widget = tmp_widget->next;
386 }
387}
388
389/* ================================ PUBLIC ================================ */
390
391/**********************************************************************/
395{
396 struct widget *buf = NULL;
397 char cbuf[128];
398 struct road_type *proad;
399 struct road_type *prail;
400
401 /* No orders */
402 fc_snprintf(cbuf, sizeof(cbuf), "%s (%s)", _("No Orders"),
403 /* TRANS: "Space" refers to the space bar on a keyboard. */
404 _("Space"));
409 buf->action = unit_order_callback;
411 buf->key = SDLK_SPACE;
413 /* --------- */
414
416
417 /* Wait */
418 fc_snprintf(cbuf, sizeof(cbuf), "%s (%s)", _("Wait"), "W");
423 buf->action = unit_order_callback;
425 buf->key = SDLK_W;
427 /* --------- */
428
429 /* Explode Nuclear */
430 fc_snprintf(cbuf, sizeof(cbuf), "%s (%s)",
436 buf->action = unit_order_callback;
438 buf->key = SDLK_N;
439 buf->mod = SDL_KMOD_SHIFT;
441 /* --------- */
442
443 /* Act against the specified tile. */
444 /* TRANS: Button to bring up the action selection dialog. */
445 fc_snprintf(cbuf, sizeof(cbuf), "%s (%s)", _("Do..."), "D");
450 buf->action = unit_order_callback;
452 buf->key = SDLK_D;
454 /* --------- */
455
456 /* Disband */
457 fc_snprintf(cbuf, sizeof(cbuf), "%s (%s)", _("Disband Unit"), "Shift+D");
462 buf->action = unit_order_callback;
464 buf->key = SDLK_D;
465 buf->mod = SDL_KMOD_SHIFT;
467 /* --------- */
468
469 /* Upgrade */
470 fc_snprintf(cbuf, sizeof(cbuf), "%s (%s)", _("Upgrade Unit"), "Shift+U");
475 buf->action = unit_order_callback;
477 buf->key = SDLK_U;
478 buf->mod = SDL_KMOD_SHIFT;
480 /* --------- */
481
482 /* Convert */
483 fc_snprintf(cbuf, sizeof(cbuf), "%s (%s)", _("Convert Unit"), "Shift+O");
488 buf->action = unit_order_callback;
490 buf->key = SDLK_O;
491 buf->mod = SDL_KMOD_SHIFT;
493 /* --------- */
494
495 /* Return to nearest city */
496 fc_snprintf(cbuf, sizeof(cbuf), "%s (%s)",
497 _("Return to Nearest City"), "Shift+G");
502 buf->action = unit_order_callback;
504 buf->key = SDLK_G;
505 buf->mod = SDL_KMOD_SHIFT;
507 /* --------- */
508
509 /* Goto City */
510 fc_snprintf(cbuf, sizeof(cbuf), "%s (%s)", _("Go to City"), "T");
511 buf = create_themeicon(current_theme->o_goto_city_icon, main_data.gui,
515 buf->action = unit_order_callback;
517 buf->key = SDLK_T;
519 /* --------- */
520
521 /* Airlift */
522 fc_snprintf(cbuf, sizeof(cbuf), "%s (%s)", _("Airlift to City"), "T");
527 buf->action = unit_order_callback;
529 buf->key = SDLK_T;
531 /* --------- */
532
533 /* Goto location */
534 fc_snprintf(cbuf, sizeof(cbuf), "%s (%s)", _("Go to Tile"), "G");
539 buf->action = unit_order_callback;
541 buf->key = SDLK_G;
543 /* --------- */
544
545 /* Patrol */
546 fc_snprintf(cbuf, sizeof(cbuf), "%s (%s)", _("Patrol"), "Q");
551 buf->action = unit_order_callback;
553 buf->key = SDLK_Q;
555 /* --------- */
556
557 /* Connect irrigation */
558 fc_snprintf(cbuf, sizeof(cbuf), "%s (%s)",
559 _("Connect With Irrigation"), "Ctrl+I");
560 buf = create_themeicon(current_theme->o_autoconnect_icon, main_data.gui,
564 buf->action = unit_order_callback;
566 buf->key = SDLK_I;
567 buf->mod = SDL_KMOD_CTRL;
569 /* --------- */
570
571 /* Connect road */
573
574 if (proad != NULL) {
575 fc_snprintf(cbuf, sizeof(cbuf),
576 _("Connect With %s (%s)"),
578 "Ctrl+R");
579 buf = create_themeicon(current_theme->o_autoconnect_icon, main_data.gui,
583 buf->action = unit_order_callback;
585 buf->key = SDLK_R;
586 buf->mod = SDL_KMOD_CTRL;
588 }
589 /* --------- */
590
591 /* Connect railroad */
593 if (prail != NULL) {
594 fc_snprintf(cbuf, sizeof(cbuf),
595 _("Connect With %s (%s)"),
597 "Ctrl+L");
598 buf = create_themeicon(current_theme->o_autoconnect_icon, main_data.gui,
602 buf->action = unit_order_callback;
604 buf->key = SDLK_L;
605 buf->mod = SDL_KMOD_CTRL;
607 }
608 /* --------- */
609
610 /* Auto Explore */
611 fc_snprintf(cbuf, sizeof(cbuf), "%s (%s)", _("Auto Explore"), "X");
616 buf->action = unit_order_callback;
618 buf->key = SDLK_X;
620 /* --------- */
621
622 /* Auto Worker */
623 fc_snprintf(cbuf, sizeof(cbuf), "%s (%s)", _("Auto Worker"), "A");
624
625 buf = create_themeicon(current_theme->o_autowork_icon, main_data.gui,
629 buf->action = unit_order_callback;
631 buf->key = SDLK_A;
633 /* --------- */
634
635 /* Wake Up Others */
636 fc_snprintf(cbuf, sizeof(cbuf), "%s (%s)",
637 _("Unsentry All On Tile"), "Shift+S");
642 buf->action = unit_order_callback;
644 buf->key = SDLK_S;
645 buf->mod = SDL_KMOD_SHIFT;
647 /* --------- */
648
649 /* Unload */
650 fc_snprintf(cbuf, sizeof(cbuf), "%s (%s)",
651 _("Unload All From Transporter"), "Shift+T");
656 buf->action = unit_order_callback;
658 buf->mod = SDL_KMOD_SHIFT;
659 buf->key = SDLK_T;
661 /* --------- */
662
663 /* Board */
664 fc_snprintf(cbuf, sizeof(cbuf), "%s (%s)", _("Load Unit"), "L");
669 buf->action = unit_order_callback;
671 buf->key = SDLK_L;
673 /* --------- */
674
675 /* Deboard */
676 fc_snprintf(cbuf, sizeof(cbuf), "%s (%s)", _("Unload Unit"), "U");
681 buf->action = unit_order_callback;
683 buf->key = SDLK_U;
685 /* --------- */
686
687 /* Find Homecity */
688 fc_snprintf(cbuf, sizeof(cbuf), "%s (%s)",
690 buf = create_themeicon(current_theme->o_homecity_icon, main_data.gui,
694 buf->action = unit_order_callback;
696 buf->key = SDLK_H;
698 /* --------- */
699
700 /* Pillage */
701 fc_snprintf(cbuf, sizeof(cbuf), "%s (%s)", _("Pillage"), "Shift+P");
706 buf->action = unit_order_callback;
708 buf->key = SDLK_P;
709 buf->mod = SDL_KMOD_SHIFT;
711 /* --------- */
712
713 /* Sentry */
714 fc_snprintf(cbuf, sizeof(cbuf), "%s (%s)", _("Sentry Unit"), "S");
719 buf->action = unit_order_callback;
721 buf->key = SDLK_S;
723 /* --------- */
724
725 /* Paradrop */
726 fc_snprintf(cbuf, sizeof(cbuf), "%s (%s)",
728 buf = create_themeicon(current_theme->o_paradrop_icon, main_data.gui,
732 buf->action = unit_order_callback;
734 buf->key = SDLK_J;
736 /* --------- */
737
738 /* Generic Clean */
739 /* Label will be replaced by real_menus_update() before it's seen */
740 fc_snprintf(cbuf, sizeof(cbuf), "placeholder");
745 buf->action = unit_order_callback;
747 buf->key = SDLK_P;
750 /* --------- */
751
752 /* Build Airbase */
753 /* Label will be replaced by real_menus_update() before it's seen */
754 fc_snprintf(cbuf, sizeof(cbuf), "placeholder");
759 buf->action = unit_order_callback;
761 buf->key = SDLK_E;
762 buf->mod = SDL_KMOD_SHIFT;
765 /* --------- */
766
767 /* Fortify */
768 fc_snprintf(cbuf, sizeof(cbuf), "%s (%s)", _("Fortify Unit"), "F");
773 buf->action = unit_order_callback;
775 buf->key = SDLK_F;
777 /* --------- */
778
779 /* Build Fortress */
780 /* Label will be replaced by real_menus_update() before it's seen */
781 fc_snprintf(cbuf, sizeof(cbuf), "placeholder");
782 buf = create_themeicon(current_theme->o_fortress_icon, main_data.gui,
786 buf->action = unit_order_callback;
788 buf->key = SDLK_F;
789 buf->mod = SDL_KMOD_SHIFT;
792 /* --------- */
793
794 /* Transform Tile */
795 /* Label will be replaced by real_menus_update() before it's seen */
796 fc_snprintf(cbuf, sizeof(cbuf), "placeholder");
797 buf = create_themeicon(current_theme->o_transform_icon, main_data.gui,
801 buf->action = unit_order_callback;
803 buf->key = SDLK_O;
806 /* --------- */
807
808 /* Build Mine */
809 /* Label will be replaced by real_menus_update() before it's seen */
810 fc_snprintf(cbuf, sizeof(cbuf), "placeholder");
815 buf->action = unit_order_callback;
817 buf->key = SDLK_M;
819
821 /* --------- */
822
823 /* Build Irrigation */
824 /* Label will be replaced by real_menus_update() before it's seen */
825 fc_snprintf(cbuf, sizeof(cbuf), "placeholder");
826 buf = create_themeicon(current_theme->o_irrigation_icon, main_data.gui,
830 buf->action = unit_order_callback;
831 buf->key = SDLK_I;
834
836 /* --------- */
837
838 /* Cultivate */
839 /* Label will be replaced by real_menus_update() before it's seen */
840 fc_snprintf(cbuf, sizeof(cbuf), "placeholder");
841 buf = create_themeicon(current_theme->o_cultivate_icon, main_data.gui,
845 buf->action = unit_order_callback;
846 buf->key = SDLK_I;
847 buf->mod = SDL_KMOD_SHIFT;
850
852 /* --------- */
853
854 /* Plant */
855 /* Label will be replaced by real_menus_update() before it's seen */
856 fc_snprintf(cbuf, sizeof(cbuf), "placeholder");
861 buf->action = unit_order_callback;
862 buf->key = SDLK_M;
863 buf->mod = SDL_KMOD_SHIFT;
866
868 /* --------- */
869
870 /* Establish Trade route */
871 /* Label will be replaced by real_menus_update() before it's seen */
872 fc_snprintf(cbuf, sizeof(cbuf), "placeholder");
877 buf->action = unit_order_callback;
879 buf->key = SDLK_R;
881
883 /* --------- */
884
885 /* Build (Rail-)Road */
886 /* Label will be replaced by real_menus_update() before it's seen */
887 fc_snprintf(cbuf, sizeof(cbuf), "placeholder");
892 buf->action = unit_order_callback;
894 buf->key = SDLK_R;
896
898 /* --------- */
899
900 /* Help Build Wonder */
901 fc_snprintf(cbuf, sizeof(cbuf), "%s (%s)",
907 buf->action = unit_order_callback;
909 buf->key = SDLK_B;
911 /* --------- */
912
913 /* Add to City / Build New City */
914 /* Label will be replaced by real_menus_update() before it's seen */
915 fc_snprintf(cbuf, sizeof(cbuf), "placeholder");
916 buf = create_themeicon(current_theme->o_build_city_icon, main_data.gui,
920 buf->action = unit_order_callback;
922 buf->key = SDLK_B;
924
926 /* --------- */
927
929
931}
932
933/**********************************************************************/
944
945/**********************************************************************/
953
954/**********************************************************************/
958{
960
961 if (tmp_widget == NULL) {
962 return;
963 }
964
965 while (TRUE) {
966 if (!(get_wflags(tmp_widget) & WF_HIDDEN) && (tmp_widget->gfx)) {
969 }
970
972 break;
973 }
974
975 tmp_widget = tmp_widget->next;
976 }
977}
978
979/* ============================== Native =============================== */
980
981/**********************************************************************/
986{
987 /* PORTME */
988}
989
990/**********************************************************************/
994{
995 static Uint16 counter = 0;
996 struct unit_list *punits = NULL;
997 struct unit *punit = NULL;
998 static char cbuf[128];
999
1000 if ((C_S_RUNNING != client_state())
1001 || (get_client_page() != PAGE_GAME)) {
1002
1004
1009 }
1010
1013 }
1014
1015 } else {
1016 /* Running state */
1018 /* Show options button */
1022 }
1023
1024 if (NULL == client.conn.playing) {
1025 /* Global observer */
1027 /* Show minimap buttons and unitinfo buttons */
1030 /* Disable minimap buttons and unitinfo buttons */
1033 }
1034
1035 return;
1036
1037 } else {
1038 /* running state with player */
1039
1042 }
1043
1044 if (counter) {
1046 }
1047
1050
1051 /* Show minimap buttons and unitinfo buttons */
1054
1055 counter = 0;
1056 }
1057 }
1058
1061
1062 if (punit && punit->ssa_controller == SSA_NONE) {
1063 struct city *homecity;
1064 int time;
1065 struct tile *ptile = unit_tile(punit);
1066 struct city *pcity = tile_city(ptile);
1067 struct terrain *pterrain = tile_terrain(ptile);
1068 struct base_type *pbase;
1069 struct extra_type *pextra;
1070
1071 if (!counter) {
1074
1077 }
1078
1079 /* Enable the button for adding to a city in all cases, so we
1080 * get an eventual error message from the server if we try. */
1081
1083 if (pcity != NULL) {
1084 fc_snprintf(cbuf, sizeof(cbuf), "%s (%s)",
1086 } else {
1087 fc_snprintf(cbuf, sizeof(cbuf), "%s (%s)",
1089 }
1091 cbuf);
1093 } else {
1095 }
1096
1099 } else {
1101 }
1102
1103 pextra = next_extra_for_tile(ptile, EC_ROAD, unit_owner(punit), punit);
1104 if (pextra != NULL
1106 struct road_type *proad = extra_road_get(pextra);
1108
1109 time = turns_to_activity_done(ptile, ACTIVITY_GEN_ROAD, pextra, punit);
1110
1111 /* TRANS: "Build Railroad (R) 3 turns" */
1112 fc_snprintf(cbuf, sizeof(cbuf), _("Build %s (%s) %d %s"),
1113 extra_name_translation(pextra),
1114 "R", time,
1115 PL_("turn", "turns", time));
1116
1117 if (compat == ROCO_RAILROAD) {
1118 order_road_button->theme = current_theme->o_railroad_icon;
1119 } else {
1120 order_road_button->theme = current_theme->o_road_icon;
1121 }
1124 } else {
1126 }
1127
1128 /* unit_can_est_trade_route_here(punit) */
1131 && (homecity = game_city_by_number(punit->homecity))
1132 && can_cities_trade(homecity, pcity)) {
1135 punit->carrying,
1136 TRUE);
1137 struct goods_type *pgood = unit_current_goods(punit, homecity);
1138
1139 if (can_establish_trade_route(homecity, pcity, pgood->replace_priority)) {
1140 fc_snprintf(cbuf, sizeof(cbuf),
1141 _("%s With %s ( %d one time bonus + %d trade ) (R)"),
1143 city_name_get(homecity),
1144 revenue,
1145 trade_base_between_cities(homecity, pcity));
1146 } else {
1147 revenue = (revenue + 2) / 3;
1148 fc_snprintf(cbuf, sizeof(cbuf),
1149 _("%s Of %s ( %d one time bonus ) (R)"),
1151 city_name_get(homecity),
1152 revenue);
1153 }
1156 } else {
1158 }
1159
1160 pextra = next_extra_for_tile(ptile, EC_IRRIGATION,
1162 if (pextra != NULL
1165 pextra, punit);
1166 /* TRANS: "Build Irrigation (I) 5 turns" */
1167 fc_snprintf(cbuf, sizeof(cbuf), _("Build %s (%s) %d %s"),
1168 extra_name_translation(pextra), "I", time,
1169 PL_("turn", "turns", time));
1170 order_irrigation_button->theme = current_theme->o_irrigation_icon;
1171
1174 } else {
1176 }
1177
1178 pextra = next_extra_for_tile(ptile, EC_MINE,
1180 if (pextra != NULL
1182 time = turns_to_activity_done(ptile, ACTIVITY_MINE, pextra, punit);
1183 /* TRANS: "Build Mine (M) 5 turns" */
1184 fc_snprintf(cbuf, sizeof(cbuf), _("Build %s (%s) %d %s"),
1185 extra_name_translation(pextra), "M", time,
1186 PL_("turn", "turns", time));
1187 order_mine_button->theme = current_theme->o_mine_icon;
1188
1191 } else {
1193 }
1194
1196 /* Activity always results in terrain change */
1198 fc_snprintf(cbuf, sizeof(cbuf), "%s %s (%s) %d %s",
1199 _("Cultivate to"),
1201 "Shift+I", time, PL_("turn", "turns", time));
1204 } else {
1206 }
1207
1209 /* Activity always results in terrain change */
1211 fc_snprintf(cbuf, sizeof(cbuf), "%s %s (%s) %d %s",
1212 _("Plant to"),
1214 "Shift+M", time, PL_("turn", "turns", time));
1217 } else {
1219 }
1220
1222 /* Activity always results in terrain change */
1224 fc_snprintf(cbuf, sizeof(cbuf), "%s %s (%s) %d %s",
1225 _("Transform to"),
1227 "O", time, PL_("turn", "turns", time));
1230 } else {
1232 }
1233
1235 if (pbase != NULL) {
1237
1239 /* TRANS: "Build Fortress (Shift+F) 5 turns" */
1240 fc_snprintf(cbuf, sizeof(cbuf), _("Build %s (%s) %d %s"),
1241 extra_name_translation(base_extra), "Shift+F", time,
1242 PL_("turn", "turns", time));
1245 } else {
1247 }
1248
1251 } else {
1253 }
1254
1256 if (pbase != NULL) {
1258
1260 /* TRANS: "Build Airbase (Shift+E) 5 turns" */
1261 fc_snprintf(cbuf, sizeof(cbuf), _("Build %s (%s) %d %s"),
1262 extra_name_translation(base_extra), "Shift+E", time,
1263 PL_("turn", "turns", time));
1266 } else {
1268 }
1269
1270 if (can_unit_paradrop(&(wld.map), punit)) {
1272 } else {
1274 }
1275
1276 pextra = prev_cleanable_in_tile(ptile, unit_owner(punit), punit);
1277
1278 if (pextra != NULL
1280 pextra)) {
1282 pextra, punit);
1283 /* TRANS: "Clean Pollution (P) 3 turns" */
1284 fc_snprintf(cbuf, sizeof(cbuf), _("Clean %s (%s) %d %s"),
1285 extra_name_translation(pextra), "P", time,
1286 PL_("turn", "turns", time));
1289 } else {
1291 }
1292
1295 } else {
1297 }
1298
1301 } else {
1303 }
1304
1306 && pcity->id != punit->homecity) {
1308 } else {
1310 }
1311
1312 if (punit->client.occupied) {
1314 } else {
1316 }
1317
1318 if (units_can_load(punits)) {
1320 } else {
1322 }
1323
1324 if (units_can_unload(&(wld.map), punits)) {
1326 } else {
1328 }
1329
1332 } else {
1334 }
1335
1338 } else {
1340 }
1341
1344 } else {
1346 }
1347
1348 {
1349 bool conn_possible = FALSE;
1350 struct extra_type_list *extras;
1351
1353
1354 if (extra_type_list_size(extras) > 0) {
1355 struct extra_type *tgt;
1356
1357 tgt = extra_type_list_get(extras, 0);
1359 }
1360
1361 if (conn_possible) {
1363 } else {
1365 }
1366 }
1367
1368 {
1370 bool road_conn_possible;
1371
1372 if (proad != NULL) {
1373 struct extra_type *tgt;
1374
1375 tgt = road_extra_get(proad);
1376
1378 } else {
1380 }
1381
1382 if (road_conn_possible) {
1384 } else {
1386 }
1387 }
1388
1389 {
1391 bool road_conn_possible;
1392
1393 if (proad != NULL) {
1394 struct extra_type *tgt;
1395
1396 tgt = road_extra_get(proad);
1397
1399 } else {
1401 }
1402
1403 if (road_conn_possible) {
1405 } else {
1407 }
1408 }
1409
1412 } else {
1414 }
1415
1418 } else {
1420 }
1421
1422 if (pcity && pcity->airlift) {
1425 } else {
1428 }
1429
1431 unit_type_get(punit))) {
1433 } else {
1435 }
1436
1437 if (unit_can_convert(&(wld.map), punit)) {
1439 } else {
1441 }
1442
1445
1446 } else {
1447 if (counter) {
1449 }
1450
1451 counter = 0;
1452 }
1453 }
1454}
1455
1456/**********************************************************************/
1465
1466/**********************************************************************/
const char * action_id_name_translation(action_id act_id)
Definition actions.c:1250
#define ACTION_ANY
Definition actions.h:52
struct extra_type * base_extra_get(const struct base_type *pbase)
Definition base.c:105
struct base_type * get_base_by_gui_type(enum base_gui_type type, const struct unit *punit, const struct tile *ptile)
Definition base.c:143
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:1242
char * incite_cost
Definition comments.c:76
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
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
void request_unit_autoworker(const struct unit *punit)
Definition control.c:2141
#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 unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit int const struct action *paction struct unit struct city * pcity
Definition dialogs_g.h:78
struct 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:779
struct extra_type * prev_cleanable_in_tile(const struct tile *ptile, const struct player *pplayer, const struct unit *punit)
Definition extras.c:831
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:64
road_compat
Definition fc_types.h:961
@ ROCO_RAILROAD
Definition fc_types.h:961
#define PL_(String1, String2, n)
Definition fcintl.h:71
#define _(String)
Definition fcintl.h:67
struct world wld
Definition game.c:62
struct city * game_city_by_number(int id)
Definition game.c:106
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_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_AUTO_WORKER
Definition gui_id.h:107
@ 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
#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:1463
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:1473
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)
Uint32 sdl3_client_flags
Definition gui_main.c:98
char * lines
Definition packhand.c:131
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:112
Definition city.h:317
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:108
struct terrain * plant_result
Definition terrain.h:111
struct terrain * transform_result
Definition terrain.h:122
Definition tile.h:50
Definition unit.h:140
bool occupied
Definition unit.h:222
int id
Definition unit.h:147
struct unit::@84::@86 client
int homecity
Definition unit.h:148
struct goods_type * carrying
Definition unit.h:189
enum server_side_agent ssa_controller
Definition unit.h:175
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:960
#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:111
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)
struct goods_type * unit_current_goods(const struct unit *punit, const struct city *homecity)
bool can_establish_trade_route(const struct city *pc1, const struct city *pc2, int priority)
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:472
bool can_unit_change_homecity(const struct civ_map *nmap, const struct unit *punit)
Definition unit.c:505
bool is_unit_activity_on_tile(enum unit_activity activity, const struct tile *ptile)
Definition unit.c:1151
bool unit_can_do_action(const struct unit *punit, const action_id act_id)
Definition unit.c:383
bool can_unit_do_autoworker(const struct unit *punit)
Definition unit.c:630
bool can_unit_paradrop(const struct civ_map *nmap, const struct unit *punit)
Definition unit.c:846
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:2072
#define unit_tile(_pu)
Definition unit.h:404
@ ORDER_PERFORM_ACTION
Definition unit.h:48
#define unit_owner(_pu)
Definition unit.h:403
bool units_can_unload(const struct civ_map *nmap, 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:1709
bool utype_can_do_action(const struct unit_type *putype, const action_id act_id)
Definition unittype.c:377
enum client_pages get_client_page(void)