Freeciv-3.1: /fast/freeciv/nightly/S3_1/client/gui-sdl2/menu.c Source File

Freeciv-3.1

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
65 static struct widget *begin_order_widget_list;
66 static struct widget *end_order_widget_list;
67
68 static struct widget *order_fallout_button;
69 static struct widget *order_pollution_button;
70 static struct widget *order_airbase_button;
71 static struct widget *order_fortress_button;
72 static struct widget *order_build_add_to_city_button;
73 static struct widget *order_mine_button;
74 static struct widget *order_irrigation_button;
75 static struct widget *order_cultivate_button;
76 static struct widget *order_plant_button;
77 static struct widget *order_road_button;
78 static struct widget *order_transform_button;
79 static struct widget *order_trade_button;
80
81#define local_show(id) \
82 clear_wflag(get_widget_pointer_from_id(begin_order_widget_list, id, SCAN_FORWARD), \
83 WF_HIDDEN)
84
85#define local_hide(id) \
86 set_wflag(get_widget_pointer_from_id(begin_order_widget_list, id, SCAN_FORWARD), \
87 WF_HIDDEN )
88
89
90/**********************************************************************/
93 static int unit_order_callback(struct widget *order_widget)
94{
95 if (PRESSED_EVENT(main_data.event)) {
96 struct unit *head_unit = head_of_units_in_focus();
97
98 set_wstate(order_widget, FC_WS_SELECTED);
99 selected_widget = order_widget;
100
101 if (!head_unit) {
102 return -1;
103 }
104
105 switch (order_widget->id) {
106 case ID_UNIT_ORDER_BUILD_CITY:
107 /* Enable the button for adding to a city in all cases, so we
108 get an eventual error message from the server if we try. */
109 key_unit_build_city();
110 break;
111 case ID_UNIT_ORDER_BUILD_WONDER:
112 key_unit_build_wonder();
113 break;
114 case ID_UNIT_ORDER_ROAD:
115 key_unit_road();
116 break;
117 case ID_UNIT_ORDER_TRADE_ROUTE:
118 key_unit_trade_route();
119 break;
120 case ID_UNIT_ORDER_IRRIGATE:
121 key_unit_irrigate();
122 break;
123 case ID_UNIT_ORDER_CULTIVATE:
124 key_unit_cultivate();
125 break;
126 case ID_UNIT_ORDER_MINE:
127 key_unit_mine();
128 break;
129 case ID_UNIT_ORDER_PLANT:
130 key_unit_plant();
131 break;
132 case ID_UNIT_ORDER_TRANSFORM:
133 key_unit_transform();
134 break;
135 case ID_UNIT_ORDER_FORTRESS:
136 key_unit_fortress();
137 break;
138 case ID_UNIT_ORDER_FORTIFY:
139 key_unit_fortify();
140 break;
141 case ID_UNIT_ORDER_AIRBASE:
142 key_unit_airbase();
143 break;
144 case ID_UNIT_ORDER_POLLUTION:
145 key_unit_pollution();
146 break;
147 case ID_UNIT_ORDER_PARADROP:
148 key_unit_paradrop();
149 break;
150 case ID_UNIT_ORDER_FALLOUT:
151 key_unit_fallout();
152 break;
153 case ID_UNIT_ORDER_SENTRY:
154 key_unit_sentry();
155 break;
156 case ID_UNIT_ORDER_PILLAGE:
157 key_unit_pillage();
158 break;
159 case ID_UNIT_ORDER_HOMECITY:
160 key_unit_homecity();
161 break;
162 case ID_UNIT_ORDER_UNLOAD_TRANSPORTER:
163 key_unit_unload_all();
164 break;
165 case ID_UNIT_ORDER_BOARD:
166 unit_list_iterate(get_units_in_focus(), punit) {
167 request_unit_load(punit, NULL, unit_tile(punit));
168 } unit_list_iterate_end;
169 break;
170 case ID_UNIT_ORDER_DEBOARD:
171 unit_list_iterate(get_units_in_focus(), punit) {
172 request_unit_unload(punit);
173 } unit_list_iterate_end;
174 break;
175 case ID_UNIT_ORDER_WAKEUP_OTHERS:
176 key_unit_wakeup_others();
177 break;
178 case ID_UNIT_ORDER_AUTO_SETTLER:
179 unit_list_iterate(get_units_in_focus(), punit) {
180 request_unit_autosettlers(punit);
181 } unit_list_iterate_end;
182 break;
183 case ID_UNIT_ORDER_AUTO_EXPLORE:
184 key_unit_auto_explore();
185 break;
186 case ID_UNIT_ORDER_CONNECT_IRRIGATE:
187 {
188 struct extra_type_list *extras = extra_type_list_by_cause(EC_IRRIGATION);
189
190 if (extra_type_list_size(extras) > 0) {
191 struct extra_type *pextra;
192
193 pextra = extra_type_list_get(extra_type_list_by_cause(EC_IRRIGATION), 0);
194
195 key_unit_connect(ACTIVITY_IRRIGATE, pextra);
196 }
197 }
198 break;
199 case ID_UNIT_ORDER_CONNECT_ROAD:
200 {
201 struct road_type *proad = road_by_gui_type(ROAD_GUI_ROAD);
202
203 if (proad != NULL) {
204 struct extra_type *tgt;
205
206 tgt = road_extra_get(proad);
207
208 key_unit_connect(ACTIVITY_GEN_ROAD, tgt);
209 }
210 }
211 break;
212 case ID_UNIT_ORDER_CONNECT_RAILROAD:
213 {
214 struct road_type *prail = road_by_gui_type(ROAD_GUI_RAILROAD);
215
216 if (prail != NULL) {
217 struct extra_type *tgt;
218
219 tgt = road_extra_get(prail);
220
221 key_unit_connect(ACTIVITY_GEN_ROAD, tgt);
222 }
223 }
224 break;
225 case ID_UNIT_ORDER_PATROL:
226 key_unit_patrol();
227 break;
228 case ID_UNIT_ORDER_GOTO:
229 key_unit_goto();
230 break;
231 case ID_UNIT_ORDER_GOTO_CITY:
232 popup_goto_dialog();
233 break;
234 case ID_UNIT_ORDER_AIRLIFT:
235 popup_airlift_dialog();
236 break;
237 case ID_UNIT_ORDER_RETURN:
238 unit_list_iterate(get_units_in_focus(), punit) {
239 request_unit_return(punit);
240 } unit_list_iterate_end;
241 break;
242 case ID_UNIT_ORDER_UPGRADE:
243 popup_unit_upgrade_dlg(head_unit, FALSE);
244 break;
245 case ID_UNIT_ORDER_CONVERT:
246 key_unit_convert();
247 break;
248 case ID_UNIT_ORDER_DISBAND:
249 popup_unit_disband_dlg(head_unit, FALSE);
250 break;
251 case ID_UNIT_ORDER_DIPLOMAT_DLG:
252 key_unit_action_select_tgt();
253 break;
254 case ID_UNIT_ORDER_NUKE:
255 request_unit_goto(ORDER_PERFORM_ACTION, ACTION_NUKE, -1);
256 break;
257 case ID_UNIT_ORDER_WAIT:
258 key_unit_wait();
259 flush_dirty();
260 break;
261 case ID_UNIT_ORDER_DONE:
262 key_unit_done();
263 flush_dirty();
264 break;
265
266 default:
267 break;
268 }
269 }
270
271 return -1;
272}
273
274/**********************************************************************/
277 static Uint16 redraw_order_widgets(void)
278{
279 Uint16 count = 0;
280 struct widget *tmp_widget = begin_order_widget_list;
281
282 while (TRUE) {
283 if (!(get_wflags(tmp_widget) & WF_HIDDEN)) {
284 if (get_wflags(tmp_widget) & WF_RESTORE_BACKGROUND) {
285 refresh_widget_background(tmp_widget);
286 }
287 widget_redraw(tmp_widget);
288 widget_mark_dirty(tmp_widget);
289 count++;
290 }
291
292 if (tmp_widget == end_order_widget_list) {
293 break;
294 }
295
296 tmp_widget = tmp_widget->next;
297 }
298
299 return count;
300}
301
302/**********************************************************************/
305 static void set_new_order_widget_start_pos(void)
306{
307 struct widget *minimap = get_minimap_window_widget();
308 struct widget *info_wind = get_unit_info_window_widget();
309 struct widget *tmp_widget = begin_order_widget_list;
310 Sint16 sx, sy, xx, yy = 0;
311 int count = 0, lines = 1, w = 0, count_on_line;
312
313 xx = minimap->dst->dest_rect.x + minimap->size.w + adj_size(10);
314 w = (info_wind->dst->dest_rect.x - adj_size(10)) - xx;
315
316 if (w < (tmp_widget->size.w + adj_size(10)) * 2) {
317 if (minimap->size.h == info_wind->size.h) {
318 xx = 0;
319 w = main_window_width();
320 yy = info_wind->size.h;
321 } else {
322 if (minimap->size.h > info_wind->size.h) {
323 w = main_window_width() - xx - adj_size(20);
324 if (w < (tmp_widget->size.w + adj_size(10)) * 2) {
325 xx = 0;
326 w = minimap->size.w;
327 yy = minimap->size.h;
328 } else {
329 yy = info_wind->size.h;
330 }
331 } else {
332 w = info_wind->dst->dest_rect.x - adj_size(20);
333 if (w < (tmp_widget->size.w + adj_size(10)) * 2) {
334 xx = info_wind->dst->dest_rect.x;
335 w = info_wind->size.w;
336 yy = info_wind->size.h;
337 } else {
338 xx = adj_size(10);
339 yy = minimap->size.h;
340 }
341 }
342 }
343 }
344
345 count_on_line = w / (tmp_widget->size.w + adj_size(5));
346
347 /* find how many to reposition */
348 while (TRUE) {
349 if (!(get_wflags(tmp_widget) & WF_HIDDEN)) {
350 count++;
351 }
352
353 if (tmp_widget == end_order_widget_list) {
354 break;
355 }
356
357 tmp_widget = tmp_widget->next;
358 }
359
360 tmp_widget = begin_order_widget_list;
361
362 if (count - count_on_line > 0) {
363 lines = (count + (count_on_line - 1)) / count_on_line;
364
365 count = count_on_line - ((count_on_line * lines) - count);
366 }
367
368 sx = xx + (w - count * (tmp_widget->size.w + adj_size(5))) / 2;
369
370 sy = tmp_widget->dst->surface->h - yy - lines * (tmp_widget->size.h + adj_size(5));
371
372 while (TRUE) {
373 if (!(get_wflags(tmp_widget) & WF_HIDDEN)) {
374 tmp_widget->size.x = sx;
375 tmp_widget->size.y = sy;
376
377 count--;
378 sx += (tmp_widget->size.w + adj_size(5));
379 if (!count) {
380 count = count_on_line;
381 lines--;
382
383 sx = xx + (w - count * (tmp_widget->size.w + adj_size(5))) / 2;
384
385 sy = tmp_widget->dst->surface->h - yy - lines * (tmp_widget->size.h + adj_size(5));
386 }
387 }
388
389 if (tmp_widget == end_order_widget_list) {
390 break;
391 }
392
393 tmp_widget = tmp_widget->next;
394 }
395}
396
397/* ================================ PUBLIC ================================ */
398
399/**********************************************************************/
402 void create_units_order_widgets(void)
403{
404 struct widget *buf = NULL;
405 char cbuf[128];
406 struct road_type *proad;
407 struct road_type *prail;
408
409 /* No orders */
410 fc_snprintf(cbuf, sizeof(cbuf), "%s (%s)", _("No Orders"),
411 /* TRANS: "Space" refers to the space bar on a keyboard. */
412 _("Space"));
413 buf = create_themeicon(current_theme->o_done_icon, main_data.gui,
414 WF_HIDDEN | WF_RESTORE_BACKGROUND
415 | WF_WIDGET_HAS_INFO_LABEL);
416 set_wstate(buf, FC_WS_NORMAL);
417 buf->action = unit_order_callback;
418 buf->info_label = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT);
419 buf->key = SDLK_SPACE;
420 add_to_gui_list(ID_UNIT_ORDER_DONE, buf);
421 /* --------- */
422
423 end_order_widget_list = buf;
424
425 /* Wait */
426 fc_snprintf(cbuf, sizeof(cbuf), "%s (%s)", _("Wait"), "W");
427 buf = create_themeicon(current_theme->o_wait_icon, main_data.gui,
428 WF_HIDDEN | WF_RESTORE_BACKGROUND
429 | WF_WIDGET_HAS_INFO_LABEL);
430 set_wstate(buf, FC_WS_NORMAL);
431 buf->action = unit_order_callback;
432 buf->info_label = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT);
433 buf->key = SDLK_w;
434 add_to_gui_list(ID_UNIT_ORDER_WAIT, buf);
435 /* --------- */
436
437 /* Explode Nuclear */
438 fc_snprintf(cbuf, sizeof(cbuf), "%s (%s)",
439 action_id_name_translation(ACTION_NUKE), "Shift+N");
440 buf = create_themeicon(current_theme->o_nuke_icon, main_data.gui,
441 WF_HIDDEN | WF_RESTORE_BACKGROUND
442 | WF_WIDGET_HAS_INFO_LABEL);
443 set_wstate(buf, FC_WS_NORMAL);
444 buf->action = unit_order_callback;
445 buf->info_label = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT);
446 buf->key = SDLK_n;
447 buf->mod = KMOD_SHIFT;
448 add_to_gui_list(ID_UNIT_ORDER_NUKE, buf);
449 /* --------- */
450
451 /* Act against the specified tile. */
452 /* TRANS: Button to bring up the action selection dialog. */
453 fc_snprintf(cbuf, sizeof(cbuf), "%s (%s)", _("Do..."), "D");
454 buf = create_themeicon(current_theme->o_spy_icon, main_data.gui,
455 WF_HIDDEN | WF_RESTORE_BACKGROUND
456 | WF_WIDGET_HAS_INFO_LABEL);
457 set_wstate(buf, FC_WS_NORMAL);
458 buf->action = unit_order_callback;
459 buf->info_label = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT);
460 buf->key = SDLK_d;
461 add_to_gui_list(ID_UNIT_ORDER_DIPLOMAT_DLG, buf);
462 /* --------- */
463
464 /* Disband */
465 fc_snprintf(cbuf, sizeof(cbuf), "%s (%s)", _("Disband Unit"), "Shift+D");
466 buf = create_themeicon(current_theme->o_disband_icon, main_data.gui,
467 WF_HIDDEN | WF_RESTORE_BACKGROUND
468 | WF_WIDGET_HAS_INFO_LABEL);
469 set_wstate(buf, FC_WS_NORMAL);
470 buf->action = unit_order_callback;
471 buf->info_label = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT);
472 buf->key = SDLK_d;
473 buf->mod = KMOD_SHIFT;
474 add_to_gui_list(ID_UNIT_ORDER_DISBAND, buf);
475 /* --------- */
476
477 /* Upgrade */
478 fc_snprintf(cbuf, sizeof(cbuf), "%s (%s)", _("Upgrade Unit"), "Shift+U");
479 buf = create_themeicon(current_theme->order_icon, main_data.gui,
480 WF_HIDDEN | WF_RESTORE_BACKGROUND
481 | WF_WIDGET_HAS_INFO_LABEL);
482 set_wstate(buf, FC_WS_NORMAL);
483 buf->action = unit_order_callback;
484 buf->info_label = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT);
485 buf->key = SDLK_u;
486 buf->mod = KMOD_SHIFT;
487 add_to_gui_list(ID_UNIT_ORDER_UPGRADE, buf);
488 /* --------- */
489
490 /* Convert */
491 fc_snprintf(cbuf, sizeof(cbuf), "%s (%s)", _("Convert Unit"), "Shift+O");
492 buf = create_themeicon(current_theme->order_icon, main_data.gui,
493 WF_HIDDEN | WF_RESTORE_BACKGROUND
494 | WF_WIDGET_HAS_INFO_LABEL);
495 set_wstate(buf, FC_WS_NORMAL);
496 buf->action = unit_order_callback;
497 buf->info_label = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT);
498 buf->key = SDLK_o;
499 buf->mod = KMOD_SHIFT;
500 add_to_gui_list(ID_UNIT_ORDER_CONVERT, buf);
501 /* --------- */
502
503 /* Return to nearest city */
504 fc_snprintf(cbuf, sizeof(cbuf), "%s (%s)",
505 _("Return to Nearest City"), "Shift+G");
506 buf = create_themeicon(current_theme->o_return_icon, main_data.gui,
507 WF_HIDDEN | WF_RESTORE_BACKGROUND
508 | WF_WIDGET_HAS_INFO_LABEL);
509 set_wstate(buf, FC_WS_NORMAL);
510 buf->action = unit_order_callback;
511 buf->info_label = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT);
512 buf->key = SDLK_g;
513 buf->mod = KMOD_SHIFT;
514 add_to_gui_list(ID_UNIT_ORDER_RETURN, buf);
515 /* --------- */
516
517 /* Goto City */
518 fc_snprintf(cbuf, sizeof(cbuf), "%s (%s)", _("Go to City"), "T");
519 buf = create_themeicon(current_theme->o_goto_city_icon, main_data.gui,
520 WF_HIDDEN | WF_RESTORE_BACKGROUND
521 | WF_WIDGET_HAS_INFO_LABEL);
522 set_wstate(buf, FC_WS_NORMAL);
523 buf->action = unit_order_callback;
524 buf->info_label = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT);
525 buf->key = SDLK_t;
526 add_to_gui_list(ID_UNIT_ORDER_GOTO_CITY, buf);
527 /* --------- */
528
529 /* Airlift */
530 fc_snprintf(cbuf, sizeof(cbuf), "%s (%s)", _("Airlift to City"), "T");
531 buf = create_themeicon(current_theme->order_icon, main_data.gui,
532 WF_HIDDEN | WF_RESTORE_BACKGROUND
533 | WF_WIDGET_HAS_INFO_LABEL);
534 set_wstate(buf, FC_WS_NORMAL);
535 buf->action = unit_order_callback;
536 buf->info_label = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT);
537 buf->key = SDLK_t;
538 add_to_gui_list(ID_UNIT_ORDER_AIRLIFT, buf);
539 /* --------- */
540
541 /* Goto location */
542 fc_snprintf(cbuf, sizeof(cbuf), "%s (%s)", _("Go to Tile"), "G");
543 buf = create_themeicon(current_theme->o_goto_icon, main_data.gui,
544 WF_HIDDEN | WF_RESTORE_BACKGROUND
545 | WF_WIDGET_HAS_INFO_LABEL);
546 set_wstate(buf, FC_WS_NORMAL);
547 buf->action = unit_order_callback;
548 buf->info_label = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT);
549 buf->key = SDLK_g;
550 add_to_gui_list(ID_UNIT_ORDER_GOTO, buf);
551 /* --------- */
552
553 /* Patrol */
554 fc_snprintf(cbuf, sizeof(cbuf), "%s (%s)", _("Patrol"), "Q");
555 buf = create_themeicon(current_theme->o_patrol_icon, main_data.gui,
556 WF_HIDDEN | WF_RESTORE_BACKGROUND
557 | WF_WIDGET_HAS_INFO_LABEL);
558 set_wstate(buf, FC_WS_NORMAL);
559 buf->action = unit_order_callback;
560 buf->info_label = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT);
561 buf->key = SDLK_q;
562 add_to_gui_list(ID_UNIT_ORDER_PATROL, buf);
563 /* --------- */
564
565 /* Connect irrigation */
566 fc_snprintf(cbuf, sizeof(cbuf), "%s (%s)",
567 _("Connect With Irrigation"), "Ctrl+I");
568 buf = create_themeicon(current_theme->o_autoconnect_icon, main_data.gui,
569 WF_HIDDEN | WF_RESTORE_BACKGROUND
570 | WF_WIDGET_HAS_INFO_LABEL);
571 set_wstate(buf, FC_WS_NORMAL);
572 buf->action = unit_order_callback;
573 buf->info_label = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT);
574 buf->key = SDLK_i;
575 buf->mod = KMOD_CTRL;
576 add_to_gui_list(ID_UNIT_ORDER_CONNECT_IRRIGATE, buf);
577 /* --------- */
578
579 /* Connect road */
580 proad = road_by_gui_type(ROAD_GUI_ROAD);
581
582 if (proad != NULL) {
583 fc_snprintf(cbuf, sizeof(cbuf),
584 _("Connect With %s (%s)"),
585 extra_name_translation(road_extra_get(proad)),
586 "Ctrl+R");
587 buf = create_themeicon(current_theme->o_autoconnect_icon, main_data.gui,
588 WF_HIDDEN | WF_RESTORE_BACKGROUND
589 | WF_WIDGET_HAS_INFO_LABEL);
590 set_wstate(buf, FC_WS_NORMAL);
591 buf->action = unit_order_callback;
592 buf->info_label = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT);
593 buf->key = SDLK_r;
594 buf->mod = KMOD_CTRL;
595 add_to_gui_list(ID_UNIT_ORDER_CONNECT_ROAD, buf);
596 }
597 /* --------- */
598
599 /* Connect railroad */
600 prail = road_by_gui_type(ROAD_GUI_RAILROAD);
601 if (prail != NULL) {
602 fc_snprintf(cbuf, sizeof(cbuf),
603 _("Connect With %s (%s)"),
604 extra_name_translation(road_extra_get(prail)),
605 "Ctrl+L");
606 buf = create_themeicon(current_theme->o_autoconnect_icon, main_data.gui,
607 WF_HIDDEN | WF_RESTORE_BACKGROUND
608 | WF_WIDGET_HAS_INFO_LABEL);
609 set_wstate(buf, FC_WS_NORMAL);
610 buf->action = unit_order_callback;
611 buf->info_label = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT);
612 buf->key = SDLK_l;
613 buf->mod = KMOD_CTRL;
614 add_to_gui_list(ID_UNIT_ORDER_CONNECT_RAILROAD, buf);
615 }
616 /* --------- */
617
618 /* Auto-Explore */
619 fc_snprintf(cbuf, sizeof(cbuf), "%s (%s)", _("Auto Explore"), "X");
620 buf = create_themeicon(current_theme->o_autoexp_icon, main_data.gui,
621 WF_HIDDEN | WF_RESTORE_BACKGROUND
622 | WF_WIDGET_HAS_INFO_LABEL);
623 set_wstate(buf, FC_WS_NORMAL);
624 buf->action = unit_order_callback;
625 buf->info_label = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT);
626 buf->key = SDLK_x;
627 add_to_gui_list(ID_UNIT_ORDER_AUTO_EXPLORE, buf);
628 /* --------- */
629
630 /* Auto-Settler */
631 fc_snprintf(cbuf, sizeof(cbuf), "%s (%s)", _("Auto Settler"), "A");
632
633 buf = create_themeicon(current_theme->o_autosett_icon, main_data.gui,
634 WF_HIDDEN | WF_RESTORE_BACKGROUND
635 | WF_WIDGET_HAS_INFO_LABEL);
636 set_wstate(buf, FC_WS_NORMAL);
637 buf->action = unit_order_callback;
638 buf->info_label = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT);
639 buf->key = SDLK_a;
640 add_to_gui_list(ID_UNIT_ORDER_AUTO_SETTLER, buf);
641 /* --------- */
642
643 /* Wake Up Others */
644 fc_snprintf(cbuf, sizeof(cbuf), "%s (%s)",
645 _("Unsentry All On Tile"), "Shift+S");
646 buf = create_themeicon(current_theme->o_wakeup_icon, main_data.gui,
647 WF_HIDDEN | WF_RESTORE_BACKGROUND
648 | WF_WIDGET_HAS_INFO_LABEL);
649 set_wstate(buf, FC_WS_NORMAL);
650 buf->action = unit_order_callback;
651 buf->info_label = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT);
652 buf->key = SDLK_s;
653 buf->mod = KMOD_SHIFT;
654 add_to_gui_list(ID_UNIT_ORDER_WAKEUP_OTHERS, buf);
655 /* --------- */
656
657 /* Unload */
658 fc_snprintf(cbuf, sizeof(cbuf), "%s (%s)",
659 _("Unload All From Transporter"), "Shift+T");
660 buf = create_themeicon(current_theme->o_unload_icon, main_data.gui,
661 WF_HIDDEN | WF_RESTORE_BACKGROUND
662 | WF_WIDGET_HAS_INFO_LABEL);
663 set_wstate(buf, FC_WS_NORMAL);
664 buf->action = unit_order_callback;
665 buf->info_label = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT);
666 buf->mod = KMOD_SHIFT;
667 buf->key = SDLK_t;
668 add_to_gui_list(ID_UNIT_ORDER_UNLOAD_TRANSPORTER, buf);
669 /* --------- */
670
671 /* Board */
672 fc_snprintf(cbuf, sizeof(cbuf), "%s (%s)", _("Load Unit"), "L");
673 buf = create_themeicon(current_theme->o_load_icon, main_data.gui,
674 WF_HIDDEN | WF_RESTORE_BACKGROUND
675 | WF_WIDGET_HAS_INFO_LABEL);
676 set_wstate(buf, FC_WS_NORMAL);
677 buf->action = unit_order_callback;
678 buf->info_label = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT);
679 buf->key = SDLK_l;
680 add_to_gui_list(ID_UNIT_ORDER_BOARD, buf);
681 /* --------- */
682
683 /* Deboard */
684 fc_snprintf(cbuf, sizeof(cbuf), "%s (%s)", _("Unload Unit"), "U");
685 buf = create_themeicon(current_theme->o_unload_icon, main_data.gui,
686 WF_HIDDEN | WF_RESTORE_BACKGROUND
687 | WF_WIDGET_HAS_INFO_LABEL);
688 set_wstate(buf, FC_WS_NORMAL);
689 buf->action = unit_order_callback;
690 buf->info_label = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT);
691 buf->key = SDLK_u;
692 add_to_gui_list(ID_UNIT_ORDER_DEBOARD, buf);
693 /* --------- */
694
695 /* Find Homecity */
696 fc_snprintf(cbuf, sizeof(cbuf), "%s (%s)",
697 action_id_name_translation(ACTION_HOME_CITY), "H");
698 buf = create_themeicon(current_theme->o_homecity_icon, main_data.gui,
699 WF_HIDDEN | WF_RESTORE_BACKGROUND
700 | WF_WIDGET_HAS_INFO_LABEL);
701 set_wstate(buf, FC_WS_NORMAL);
702 buf->action = unit_order_callback;
703 buf->info_label = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT);
704 buf->key = SDLK_h;
705 add_to_gui_list(ID_UNIT_ORDER_HOMECITY, buf);
706 /* --------- */
707
708 /* Pillage */
709 fc_snprintf(cbuf, sizeof(cbuf), "%s (%s)", _("Pillage"), "Shift+P");
710 buf = create_themeicon(current_theme->o_pillage_icon, main_data.gui,
711 WF_HIDDEN | WF_RESTORE_BACKGROUND
712 | WF_WIDGET_HAS_INFO_LABEL);
713 set_wstate(buf, FC_WS_NORMAL);
714 buf->action = unit_order_callback;
715 buf->info_label = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT);
716 buf->key = SDLK_p;
717 buf->mod = KMOD_SHIFT;
718 add_to_gui_list(ID_UNIT_ORDER_PILLAGE, buf);
719 /* --------- */
720
721 /* Sentry */
722 fc_snprintf(cbuf, sizeof(cbuf), "%s (%s)", _("Sentry Unit"), "S");
723 buf = create_themeicon(current_theme->o_sentry_icon, main_data.gui,
724 WF_HIDDEN | WF_RESTORE_BACKGROUND
725 | WF_WIDGET_HAS_INFO_LABEL);
726 set_wstate(buf, FC_WS_NORMAL);
727 buf->action = unit_order_callback;
728 buf->info_label = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT);
729 buf->key = SDLK_s;
730 add_to_gui_list(ID_UNIT_ORDER_SENTRY, buf);
731 /* --------- */
732
733 /* Clean Nuclear Fallout */
734 /* Label will be replaced by real_menus_update() before it's seen */
735 fc_snprintf(cbuf, sizeof(cbuf), "placeholder");
736 buf = create_themeicon(current_theme->o_fallout_icon, main_data.gui,
737 WF_HIDDEN | WF_RESTORE_BACKGROUND
738 | WF_WIDGET_HAS_INFO_LABEL);
739 set_wstate(buf, FC_WS_NORMAL);
740 buf->action = unit_order_callback;
741 buf->info_label = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT);
742 buf->key = SDLK_n;
743 order_fallout_button = buf;
744 add_to_gui_list(ID_UNIT_ORDER_FALLOUT, buf);
745 /* --------- */
746
747 /* Paradrop */
748 fc_snprintf(cbuf, sizeof(cbuf), "%s (%s)",
749 action_id_name_translation(ACTION_PARADROP), "J");
750 buf = create_themeicon(current_theme->o_paradrop_icon, main_data.gui,
751 WF_HIDDEN | WF_RESTORE_BACKGROUND
752 | WF_WIDGET_HAS_INFO_LABEL);
753 set_wstate(buf, FC_WS_NORMAL);
754 buf->action = unit_order_callback;
755 buf->info_label = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT);
756 buf->key = SDLK_j;
757 add_to_gui_list(ID_UNIT_ORDER_PARADROP, buf);
758 /* --------- */
759
760 /* Clean Pollution */
761 /* Label will be replaced by real_menus_update() before it's seen */
762 fc_snprintf(cbuf, sizeof(cbuf), "placeholder");
763 buf = create_themeicon(current_theme->o_pollution_icon, main_data.gui,
764 WF_HIDDEN | WF_RESTORE_BACKGROUND
765 | WF_WIDGET_HAS_INFO_LABEL);
766 set_wstate(buf, FC_WS_NORMAL);
767 buf->action = unit_order_callback;
768 buf->info_label = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT);
769 buf->key = SDLK_p;
770 order_pollution_button = buf;
771 add_to_gui_list(ID_UNIT_ORDER_POLLUTION, buf);
772 /* --------- */
773
774 /* Build Airbase */
775 /* Label will be replaced by real_menus_update() before it's seen */
776 fc_snprintf(cbuf, sizeof(cbuf), "placeholder");
777 buf = create_themeicon(current_theme->o_airbase_icon, main_data.gui,
778 WF_HIDDEN | WF_RESTORE_BACKGROUND
779 | WF_WIDGET_HAS_INFO_LABEL);
780 set_wstate(buf, FC_WS_NORMAL);
781 buf->action = unit_order_callback;
782 buf->info_label = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT);
783 buf->key = SDLK_e;
784 buf->mod = KMOD_SHIFT;
785 order_airbase_button = buf;
786 add_to_gui_list(ID_UNIT_ORDER_AIRBASE, buf);
787 /* --------- */
788
789 /* Fortify */
790 fc_snprintf(cbuf, sizeof(cbuf), "%s (%s)", _("Fortify Unit"), "F");
791 buf = create_themeicon(current_theme->o_fortify_icon, main_data.gui,
792 WF_HIDDEN | WF_RESTORE_BACKGROUND
793 | WF_WIDGET_HAS_INFO_LABEL);
794 set_wstate(buf, FC_WS_NORMAL);
795 buf->action = unit_order_callback;
796 buf->info_label = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT);
797 buf->key = SDLK_f;
798 add_to_gui_list(ID_UNIT_ORDER_FORTIFY, buf);
799 /* --------- */
800
801 /* Build Fortress */
802 /* Label will be replaced by real_menus_update() before it's seen */
803 fc_snprintf(cbuf, sizeof(cbuf), "placeholder");
804 buf = create_themeicon(current_theme->o_fortress_icon, main_data.gui,
805 WF_HIDDEN | WF_RESTORE_BACKGROUND
806 | WF_WIDGET_HAS_INFO_LABEL);
807 set_wstate(buf, FC_WS_NORMAL);
808 buf->action = unit_order_callback;
809 buf->info_label = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT);
810 buf->key = SDLK_f;
811 buf->mod = KMOD_SHIFT;
812 order_fortress_button = buf;
813 add_to_gui_list(ID_UNIT_ORDER_FORTRESS, buf);
814 /* --------- */
815
816 /* Transform Tile */
817 /* Label will be replaced by real_menus_update() before it's seen */
818 fc_snprintf(cbuf, sizeof(cbuf), "placeholder");
819 buf = create_themeicon(current_theme->o_transform_icon, main_data.gui,
820 WF_HIDDEN | WF_RESTORE_BACKGROUND
821 | WF_WIDGET_HAS_INFO_LABEL);
822 set_wstate(buf, FC_WS_NORMAL);
823 buf->action = unit_order_callback;
824 buf->info_label = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT);
825 buf->key = SDLK_o;
826 order_transform_button = buf;
827 add_to_gui_list(ID_UNIT_ORDER_TRANSFORM, buf);
828 /* --------- */
829
830 /* Build Mine */
831 /* Label will be replaced by real_menus_update() before it's seen */
832 fc_snprintf(cbuf, sizeof(cbuf), "placeholder");
833 buf = create_themeicon(current_theme->o_mine_icon, main_data.gui,
834 WF_HIDDEN | WF_RESTORE_BACKGROUND
835 | WF_WIDGET_HAS_INFO_LABEL);
836 set_wstate(buf, FC_WS_NORMAL);
837 buf->action = unit_order_callback;
838 buf->info_label = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT);
839 buf->key = SDLK_m;
840 add_to_gui_list(ID_UNIT_ORDER_MINE, buf);
841
842 order_mine_button = buf;
843 /* --------- */
844
845 /* Build Irrigation */
846 /* Label will be replaced by real_menus_update() before it's seen */
847 fc_snprintf(cbuf, sizeof(cbuf), "placeholder");
848 buf = create_themeicon(current_theme->o_irrigation_icon, main_data.gui,
849 WF_HIDDEN | WF_RESTORE_BACKGROUND
850 | WF_WIDGET_HAS_INFO_LABEL);
851 set_wstate(buf, FC_WS_NORMAL);
852 buf->action = unit_order_callback;
853 buf->key = SDLK_i;
854 buf->info_label = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT);
855 add_to_gui_list(ID_UNIT_ORDER_IRRIGATE, buf);
856
857 order_irrigation_button = buf;
858 /* --------- */
859
860 /* Cultivate */
861 /* Label will be replaced by real_menus_update() before it's seen */
862 fc_snprintf(cbuf, sizeof(cbuf), "placeholder");
863 buf = create_themeicon(current_theme->o_cultivate_icon, main_data.gui,
864 WF_HIDDEN | WF_RESTORE_BACKGROUND
865 | WF_WIDGET_HAS_INFO_LABEL);
866 set_wstate(buf, FC_WS_NORMAL);
867 buf->action = unit_order_callback;
868 buf->key = SDLK_i;
869 buf->mod = KMOD_SHIFT;
870 buf->info_label = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT);
871 add_to_gui_list(ID_UNIT_ORDER_CULTIVATE, buf);
872
873 order_cultivate_button = buf;
874 /* --------- */
875
876 /* Plant */
877 /* Label will be replaced by real_menus_update() before it's seen */
878 fc_snprintf(cbuf, sizeof(cbuf), "placeholder");
879 buf = create_themeicon(current_theme->o_plant_icon, main_data.gui,
880 WF_HIDDEN | WF_RESTORE_BACKGROUND
881 | WF_WIDGET_HAS_INFO_LABEL);
882 set_wstate(buf, FC_WS_NORMAL);
883 buf->action = unit_order_callback;
884 buf->key = SDLK_m;
885 buf->mod = KMOD_SHIFT;
886 buf->info_label = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT);
887 add_to_gui_list(ID_UNIT_ORDER_PLANT, buf);
888
889 order_plant_button = buf;
890 /* --------- */
891
892 /* Establish Trade route */
893 /* Label will be replaced by real_menus_update() before it's seen */
894 fc_snprintf(cbuf, sizeof(cbuf), "placeholder");
895 buf = create_themeicon(current_theme->o_trade_icon, main_data.gui,
896 WF_HIDDEN | WF_RESTORE_BACKGROUND
897 | WF_WIDGET_HAS_INFO_LABEL);
898 set_wstate(buf, FC_WS_NORMAL);
899 buf->action = unit_order_callback;
900 buf->info_label = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT);
901 buf->key = SDLK_r;
902 add_to_gui_list(ID_UNIT_ORDER_TRADE_ROUTE, buf);
903
904 order_trade_button = buf;
905 /* --------- */
906
907 /* Build (Rail-)Road */
908 /* Label will be replaced by real_menus_update() before it's seen */
909 fc_snprintf(cbuf, sizeof(cbuf), "placeholder");
910 buf = create_themeicon(current_theme->o_road_icon, main_data.gui,
911 WF_HIDDEN | WF_RESTORE_BACKGROUND
912 | WF_WIDGET_HAS_INFO_LABEL);
913 set_wstate(buf, FC_WS_NORMAL);
914 buf->action = unit_order_callback;
915 buf->info_label = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT);
916 buf->key = SDLK_r;
917 add_to_gui_list(ID_UNIT_ORDER_ROAD, buf);
918
919 order_road_button = buf;
920 /* --------- */
921
922 /* Help Build Wonder */
923 fc_snprintf(cbuf, sizeof(cbuf), "%s (%s)",
924 action_id_name_translation(ACTION_HELP_WONDER), "B");
925 buf = create_themeicon(current_theme->o_wonder_icon, main_data.gui,
926 WF_HIDDEN | WF_RESTORE_BACKGROUND
927 | WF_WIDGET_HAS_INFO_LABEL);
928 set_wstate(buf, FC_WS_NORMAL);
929 buf->action = unit_order_callback;
930 buf->info_label = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT);
931 buf->key = SDLK_b;
932 add_to_gui_list(ID_UNIT_ORDER_BUILD_WONDER, buf);
933 /* --------- */
934
935 /* Add to City / Build New City */
936 /* Label will be replaced by real_menus_update() before it's seen */
937 fc_snprintf(cbuf, sizeof(cbuf), "placeholder");
938 buf = create_themeicon(current_theme->o_build_city_icon, main_data.gui,
939 WF_HIDDEN | WF_RESTORE_BACKGROUND
940 | WF_WIDGET_HAS_INFO_LABEL);
941 set_wstate(buf, FC_WS_NORMAL);
942 buf->action = unit_order_callback;
943 buf->info_label = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT);
944 buf->key = SDLK_b;
945 add_to_gui_list(ID_UNIT_ORDER_BUILD_CITY, buf);
946
947 order_build_add_to_city_button = buf;
948 /* --------- */
949
950 begin_order_widget_list = buf;
951
952 sdl2_client_flags |= CF_ORDERS_WIDGETS_CREATED;
953}
954
955/**********************************************************************/
958 void delete_units_order_widgets(void)
959{
960 del_group(begin_order_widget_list, end_order_widget_list);
961
962 begin_order_widget_list = NULL;
963 end_order_widget_list = NULL;
964 sdl2_client_flags &= ~CF_ORDERS_WIDGETS_CREATED;
965}
966
967/**********************************************************************/
970 void update_order_widgets(void)
971{
972 set_new_order_widget_start_pos();
973 redraw_order_widgets();
974}
975
976/**********************************************************************/
979 void undraw_order_widgets(void)
980{
981 struct widget *tmp_widget = begin_order_widget_list;
982
983 if (tmp_widget == NULL) {
984 return;
985 }
986
987 while (TRUE) {
988 if (!(get_wflags(tmp_widget) & WF_HIDDEN) && (tmp_widget->gfx)) {
989 widget_undraw(tmp_widget);
990 widget_mark_dirty(tmp_widget);
991 }
992
993 if (tmp_widget == end_order_widget_list) {
994 break;
995 }
996
997 tmp_widget = tmp_widget->next;
998 }
999}
1000
1001/* ============================== Native =============================== */
1002
1003/**********************************************************************/
1007 void real_menus_init(void)
1008{
1009 /* PORTME */
1010}
1011
1012/**********************************************************************/
1015 void real_menus_update(void)
1016{
1017 static Uint16 counter = 0;
1018 struct unit_list *punits = NULL;
1019 struct unit *punit = NULL;
1020 static char cbuf[128];
1021
1022 if ((C_S_RUNNING != client_state())
1023 || (get_client_page() != PAGE_GAME)) {
1024
1025 sdl2_client_flags |= CF_GAME_JUST_STARTED;
1026
1027 if (sdl2_client_flags & CF_MAP_UNIT_W_CREATED) {
1028 set_wflag(options_button, WF_HIDDEN);
1029 hide_minimap_window_buttons();
1030 hide_unitinfo_window_buttons();
1031 }
1032
1033 if (sdl2_client_flags & CF_ORDERS_WIDGETS_CREATED) {
1034 hide_group(begin_order_widget_list, end_order_widget_list);
1035 }
1036
1037 } else {
1038 /* Running state */
1039 if (sdl2_client_flags & CF_MAP_UNIT_W_CREATED) {
1040 /* show options button */
1041 clear_wflag(options_button, WF_HIDDEN);
1042 widget_redraw(options_button);
1043 widget_mark_dirty(options_button);
1044 }
1045
1046 if (NULL == client.conn.playing) {
1047 /* Global observer */
1048 if (sdl2_client_flags & CF_MAP_UNIT_W_CREATED) {
1049 /* show minimap buttons and unitinfo buttons */
1050 show_minimap_window_buttons();
1051 show_unitinfo_window_buttons();
1052 /* disable minimap buttons and unitinfo buttons */
1053 disable_minimap_window_buttons();
1054 disable_unitinfo_window_buttons();
1055 }
1056
1057 return;
1058
1059 } else {
1060 /* running state with player */
1061
1062 if (get_wstate(end_order_widget_list) == FC_WS_DISABLED) {
1063 enable_group(begin_order_widget_list, end_order_widget_list);
1064 }
1065
1066 if (counter) {
1067 undraw_order_widgets();
1068 }
1069
1070 if (sdl2_client_flags & CF_GAME_JUST_STARTED) {
1071 sdl2_client_flags &= ~CF_GAME_JUST_STARTED;
1072
1073 /* show minimap buttons and unitinfo buttons */
1074 show_minimap_window_buttons();
1075 show_unitinfo_window_buttons();
1076
1077 counter = 0;
1078 }
1079 }
1080
1081 punits = get_units_in_focus();
1082 punit = unit_list_get(punits, 0);
1083
1084 if (punit && punit->ssa_controller == SSA_NONE) {
1085 struct city *homecity;
1086 int time;
1087 struct tile *ptile = unit_tile(punit);
1088 struct city *pcity = tile_city(ptile);
1089 struct terrain *pterrain = tile_terrain(ptile);
1090 struct base_type *pbase;
1091 struct extra_type *pextra;
1092
1093 if (!counter) {
1094 local_show(ID_UNIT_ORDER_GOTO);
1095 local_show(ID_UNIT_ORDER_DISBAND);
1096
1097 local_show(ID_UNIT_ORDER_WAIT);
1098 local_show(ID_UNIT_ORDER_DONE);
1099 }
1100
1101 /* Enable the button for adding to a city in all cases, so we
1102 * get an eventual error message from the server if we try. */
1103
1104 if (unit_can_add_or_build_city(punit)) {
1105 if (pcity) {
1106 fc_snprintf(cbuf, sizeof(cbuf), "%s (%s)",
1107 action_id_name_translation(ACTION_JOIN_CITY), "B");
1108 } else {
1109 fc_snprintf(cbuf, sizeof(cbuf), "%s (%s)",
1110 action_id_name_translation(ACTION_FOUND_CITY), "B");
1111 }
1112 copy_chars_to_utf8_str(order_build_add_to_city_button->info_label,
1113 cbuf);
1114 clear_wflag(order_build_add_to_city_button, WF_HIDDEN);
1115 } else {
1116 set_wflag(order_build_add_to_city_button, WF_HIDDEN);
1117 }
1118
1119 if (unit_can_help_build_wonder_here(punit)) {
1120 local_show(ID_UNIT_ORDER_BUILD_WONDER);
1121 } else {
1122 local_hide(ID_UNIT_ORDER_BUILD_WONDER);
1123 }
1124
1125 pextra = next_extra_for_tile(ptile, EC_ROAD, unit_owner(punit), punit);
1126 if (pextra != NULL
1127 && can_unit_do_activity_targeted_client(punit, ACTIVITY_GEN_ROAD, pextra)) {
1128 struct road_type *proad = extra_road_get(pextra);
1129 enum road_compat compat = road_compat_special(proad);
1130
1131 time = turns_to_activity_done(ptile, ACTIVITY_GEN_ROAD, pextra, punit);
1132
1133 /* TRANS: "Build Railroad (R) 3 turns" */
1134 fc_snprintf(cbuf, sizeof(cbuf), _("Build %s (%s) %d %s"),
1135 extra_name_translation(pextra),
1136 "R", time,
1137 PL_("turn", "turns", time));
1138
1139 if (compat == ROCO_RAILROAD) {
1140 order_road_button->theme = current_theme->o_railroad_icon;
1141 } else {
1142 order_road_button->theme = current_theme->o_road_icon;
1143 }
1144 copy_chars_to_utf8_str(order_road_button->info_label, cbuf);
1145 clear_wflag(order_road_button, WF_HIDDEN);
1146 } else {
1147 set_wflag(order_road_button, WF_HIDDEN);
1148 }
1149
1150 /* unit_can_est_trade_route_here(punit) */
1151 if (pcity && utype_can_do_action(unit_type_get(punit),
1152 ACTION_TRADE_ROUTE)
1153 && (homecity = game_city_by_number(punit->homecity))
1154 && can_cities_trade(homecity, pcity)) {
1155 int revenue = get_caravan_enter_city_trade_bonus(homecity, pcity,
1156 punit->carrying,
1157 TRUE);
1158
1159 if (can_establish_trade_route(homecity, pcity)) {
1160 fc_snprintf(cbuf, sizeof(cbuf),
1161 _("%s With %s ( %d one time bonus + %d trade ) (R)"),
1162 action_id_name_translation(ACTION_TRADE_ROUTE),
1163 city_name_get(homecity),
1164 revenue,
1165 trade_base_between_cities(homecity, pcity));
1166 } else {
1167 revenue = (revenue + 2) / 3;
1168 fc_snprintf(cbuf, sizeof(cbuf),
1169 _("%s Of %s ( %d one time bonus ) (R)"),
1170 action_id_name_translation(ACTION_MARKETPLACE),
1171 city_name_get(homecity),
1172 revenue);
1173 }
1174 copy_chars_to_utf8_str(order_trade_button->info_label, cbuf);
1175 clear_wflag(order_trade_button, WF_HIDDEN);
1176 } else {
1177 set_wflag(order_trade_button, WF_HIDDEN);
1178 }
1179
1180 pextra = next_extra_for_tile(ptile, EC_IRRIGATION,
1181 unit_owner(punit), punit);
1182 if (pextra != NULL
1183 && can_unit_do_activity_targeted_client(punit, ACTIVITY_IRRIGATE, pextra)) {
1184 time = turns_to_activity_done(ptile, ACTIVITY_IRRIGATE,
1185 pextra, punit);
1186 /* TRANS: "Build Irrigation (I) 5 turns" */
1187 fc_snprintf(cbuf, sizeof(cbuf), _("Build %s (%s) %d %s"),
1188 extra_name_translation(pextra), "I", time,
1189 PL_("turn", "turns", time));
1190 order_irrigation_button->theme = current_theme->o_irrigation_icon;
1191
1192 copy_chars_to_utf8_str(order_irrigation_button->info_label, cbuf);
1193 clear_wflag(order_irrigation_button, WF_HIDDEN);
1194 } else {
1195 set_wflag(order_irrigation_button, WF_HIDDEN);
1196 }
1197
1198 pextra = next_extra_for_tile(ptile, EC_MINE,
1199 unit_owner(punit), punit);
1200 if (pextra != NULL
1201 && can_unit_do_activity_targeted_client(punit, ACTIVITY_MINE, pextra)) {
1202 time = turns_to_activity_done(ptile, ACTIVITY_MINE, pextra, punit);
1203 /* TRANS: "Build Mine (M) 5 turns" */
1204 fc_snprintf(cbuf, sizeof(cbuf), _("Build %s (%s) %d %s"),
1205 extra_name_translation(pextra), "M", time,
1206 PL_("turn", "turns", time));
1207 order_mine_button->theme = current_theme->o_mine_icon;
1208
1209 copy_chars_to_utf8_str(order_mine_button->info_label, cbuf);
1210 clear_wflag(order_mine_button, WF_HIDDEN);
1211 } else {
1212 set_wflag(order_mine_button, WF_HIDDEN);
1213 }
1214
1215 if (can_unit_do_activity_client(punit, ACTIVITY_CULTIVATE)) {
1216 /* Activity always results in terrain change */
1217 time = turns_to_activity_done(ptile, ACTIVITY_CULTIVATE, NULL, punit);
1218 fc_snprintf(cbuf, sizeof(cbuf), "%s %s (%s) %d %s",
1219 _("Cultivate to"),
1220 terrain_name_translation(pterrain->cultivate_result),
1221 "Shift+I", time, PL_("turn", "turns", time));
1222 copy_chars_to_utf8_str(order_cultivate_button->info_label, cbuf);
1223 clear_wflag(order_cultivate_button, WF_HIDDEN);
1224 } else {
1225 set_wflag(order_cultivate_button, WF_HIDDEN);
1226 }
1227
1228 if (can_unit_do_activity_client(punit, ACTIVITY_PLANT)) {
1229 /* Activity always results in terrain change */
1230 time = turns_to_activity_done(ptile, ACTIVITY_PLANT, NULL, punit);
1231 fc_snprintf(cbuf, sizeof(cbuf), "%s %s (%s) %d %s",
1232 _("Plant to"),
1233 terrain_name_translation(pterrain->plant_result),
1234 "Shift+M", time, PL_("turn", "turns", time));
1235 copy_chars_to_utf8_str(order_plant_button->info_label, cbuf);
1236 clear_wflag(order_plant_button, WF_HIDDEN);
1237 } else {
1238 set_wflag(order_plant_button, WF_HIDDEN);
1239 }
1240
1241 if (can_unit_do_activity_client(punit, ACTIVITY_TRANSFORM)) {
1242 /* Activity always results in terrain change */
1243 time = turns_to_activity_done(ptile, ACTIVITY_TRANSFORM, NULL, punit);
1244 fc_snprintf(cbuf, sizeof(cbuf), "%s %s (%s) %d %s",
1245 _("Transform to"),
1246 terrain_name_translation(pterrain->transform_result),
1247 "O", time, PL_("turn", "turns", time));
1248 copy_chars_to_utf8_str(order_transform_button->info_label, cbuf);
1249 clear_wflag(order_transform_button, WF_HIDDEN);
1250 } else {
1251 set_wflag(order_transform_button, WF_HIDDEN);
1252 }
1253
1254 pbase = get_base_by_gui_type(BASE_GUI_FORTRESS, punit, ptile);
1255 if (pbase != NULL) {
1256 struct extra_type *base_extra = base_extra_get(pbase);
1257
1258 time = turns_to_activity_done(ptile, ACTIVITY_BASE, base_extra, punit);
1259 /* TRANS: "Build Fortress (Shift+F) 5 turns" */
1260 fc_snprintf(cbuf, sizeof(cbuf), _("Build %s (%s) %d %s"),
1261 extra_name_translation(base_extra), "Shift+F", time,
1262 PL_("turn", "turns", time));
1263 copy_chars_to_utf8_str(order_fortress_button->info_label, cbuf);
1264 clear_wflag(order_fortress_button, WF_HIDDEN);
1265 } else {
1266 set_wflag(order_fortress_button, WF_HIDDEN);
1267 }
1268
1269 if (can_unit_do_activity_client(punit, ACTIVITY_FORTIFYING)) {
1270 local_show(ID_UNIT_ORDER_FORTIFY);
1271 } else {
1272 local_hide(ID_UNIT_ORDER_FORTIFY);
1273 }
1274
1275 pbase = get_base_by_gui_type(BASE_GUI_AIRBASE, punit, ptile);
1276 if (pbase != NULL) {
1277 struct extra_type *base_extra = base_extra_get(pbase);
1278
1279 time = turns_to_activity_done(ptile, ACTIVITY_BASE, base_extra, punit);
1280 /* TRANS: "Build Airbase (Shift+E) 5 turns" */
1281 fc_snprintf(cbuf, sizeof(cbuf), _("Build %s (%s) %d %s"),
1282 extra_name_translation(base_extra), "Shift+E", time,
1283 PL_("turn", "turns", time));
1284 copy_chars_to_utf8_str(order_airbase_button->info_label, cbuf);
1285 clear_wflag(order_airbase_button, WF_HIDDEN);
1286 } else {
1287 set_wflag(order_airbase_button, WF_HIDDEN);
1288 }
1289
1290 pextra = prev_extra_in_tile(ptile, ERM_CLEANPOLLUTION,
1291 unit_owner(punit), punit);
1292 if (pextra != NULL
1293 && can_unit_do_activity_targeted_client(punit, ACTIVITY_POLLUTION, pextra)) {
1294 time = turns_to_activity_done(ptile, ACTIVITY_POLLUTION, pextra,
1295 punit);
1296 /* TRANS: "Clean Pollution (P) 3 turns" */
1297 fc_snprintf(cbuf, sizeof(cbuf), _("Clean %s (%s) %d %s"),
1298 extra_name_translation(pextra), "P", time,
1299 PL_("turn", "turns", time));
1300 copy_chars_to_utf8_str(order_pollution_button->info_label, cbuf);
1301 clear_wflag(order_pollution_button, WF_HIDDEN);
1302 } else {
1303 set_wflag(order_pollution_button, WF_HIDDEN);
1304 }
1305
1306 if (can_unit_paradrop(&(wld.map), punit)) {
1307 local_show(ID_UNIT_ORDER_PARADROP);
1308 } else {
1309 local_hide(ID_UNIT_ORDER_PARADROP);
1310 }
1311
1312 pextra = prev_extra_in_tile(ptile, ERM_CLEANFALLOUT,
1313 unit_owner(punit), punit);
1314 if (pextra != NULL
1315 && can_unit_do_activity_targeted_client(punit, ACTIVITY_FALLOUT, pextra)) {
1316 time = turns_to_activity_done(ptile, ACTIVITY_FALLOUT, pextra,
1317 punit);
1318 /* TRANS: "Clean Fallout (N) 3 turns" */
1319 fc_snprintf(cbuf, sizeof(cbuf), _("Clean %s (%s) %d %s"),
1320 extra_name_translation(pextra), "N", time,
1321 PL_("turn", "turns", time));
1322 copy_chars_to_utf8_str(order_fallout_button->info_label, cbuf);
1323 clear_wflag(order_fallout_button, WF_HIDDEN);
1324 } else {
1325 set_wflag(order_fallout_button, WF_HIDDEN);
1326 }
1327
1328 if (can_unit_do_activity_client(punit, ACTIVITY_SENTRY)) {
1329 local_show(ID_UNIT_ORDER_SENTRY);
1330 } else {
1331 local_hide(ID_UNIT_ORDER_SENTRY);
1332 }
1333
1334 if (can_unit_do_activity_client(punit, ACTIVITY_PILLAGE)) {
1335 local_show(ID_UNIT_ORDER_PILLAGE);
1336 } else {
1337 local_hide(ID_UNIT_ORDER_PILLAGE);
1338 }
1339
1340 if (pcity && can_unit_change_homecity(punit)
1341 && pcity->id != punit->homecity) {
1342 local_show(ID_UNIT_ORDER_HOMECITY);
1343 } else {
1344 local_hide(ID_UNIT_ORDER_HOMECITY);
1345 }
1346
1347 if (punit->client.occupied) {
1348 local_show(ID_UNIT_ORDER_UNLOAD_TRANSPORTER);
1349 } else {
1350 local_hide(ID_UNIT_ORDER_UNLOAD_TRANSPORTER);
1351 }
1352
1353 if (units_can_load(punits)) {
1354 local_show(ID_UNIT_ORDER_BOARD);
1355 } else {
1356 local_hide(ID_UNIT_ORDER_BOARD);
1357 }
1358
1359 if (units_can_unload(punits)) {
1360 local_show(ID_UNIT_ORDER_DEBOARD);
1361 } else {
1362 local_hide(ID_UNIT_ORDER_DEBOARD);
1363 }
1364
1365 if (is_unit_activity_on_tile(ACTIVITY_SENTRY, unit_tile(punit))) {
1366 local_show(ID_UNIT_ORDER_WAKEUP_OTHERS);
1367 } else {
1368 local_hide(ID_UNIT_ORDER_WAKEUP_OTHERS);
1369 }
1370
1371 if (can_unit_do_autosettlers(punit)) {
1372 local_show(ID_UNIT_ORDER_AUTO_SETTLER);
1373 } else {
1374 local_hide(ID_UNIT_ORDER_AUTO_SETTLER);
1375 }
1376
1377 if (can_unit_do_activity_client(punit, ACTIVITY_EXPLORE)) {
1378 local_show(ID_UNIT_ORDER_AUTO_EXPLORE);
1379 } else {
1380 local_hide(ID_UNIT_ORDER_AUTO_EXPLORE);
1381 }
1382
1383 {
1384 bool conn_possible = FALSE;
1385 struct extra_type_list *extras;
1386
1387 extras = extra_type_list_by_cause(EC_IRRIGATION);
1388
1389 if (extra_type_list_size(extras) > 0) {
1390 struct extra_type *tgt;
1391
1392 tgt = extra_type_list_get(extras, 0);
1393 conn_possible = can_units_do_connect(punits, ACTIVITY_IRRIGATE, tgt);
1394 }
1395
1396 if (conn_possible) {
1397 local_show(ID_UNIT_ORDER_CONNECT_IRRIGATE);
1398 } else {
1399 local_hide(ID_UNIT_ORDER_CONNECT_IRRIGATE);
1400 }
1401 }
1402
1403 {
1404 struct road_type *proad = road_by_gui_type(ROAD_GUI_ROAD);
1405 bool road_conn_possible;
1406
1407 if (proad != NULL) {
1408 struct extra_type *tgt;
1409
1410 tgt = road_extra_get(proad);
1411
1412 road_conn_possible = can_unit_do_connect(punit, ACTIVITY_GEN_ROAD, tgt);
1413 } else {
1414 road_conn_possible = FALSE;
1415 }
1416
1417 if (road_conn_possible) {
1418 local_show(ID_UNIT_ORDER_CONNECT_ROAD);
1419 } else {
1420 local_hide(ID_UNIT_ORDER_CONNECT_ROAD);
1421 }
1422 }
1423
1424 {
1425 struct road_type *proad = road_by_gui_type(ROAD_GUI_RAILROAD);
1426 bool road_conn_possible;
1427
1428 if (proad != NULL) {
1429 struct extra_type *tgt;
1430
1431 tgt = road_extra_get(proad);
1432
1433 road_conn_possible = can_unit_do_connect(punit, ACTIVITY_GEN_ROAD, tgt);
1434 } else {
1435 road_conn_possible = FALSE;
1436 }
1437
1438 if (road_conn_possible) {
1439 local_show(ID_UNIT_ORDER_CONNECT_RAILROAD);
1440 } else {
1441 local_hide(ID_UNIT_ORDER_CONNECT_RAILROAD);
1442 }
1443 }
1444
1445 if (unit_can_do_action(punit, ACTION_ANY)) {
1446 local_show(ID_UNIT_ORDER_DIPLOMAT_DLG);
1447 } else {
1448 local_hide(ID_UNIT_ORDER_DIPLOMAT_DLG);
1449 }
1450
1451 if (unit_can_do_action(punit, ACTION_NUKE)) {
1452 local_show(ID_UNIT_ORDER_NUKE);
1453 } else {
1454 local_hide(ID_UNIT_ORDER_NUKE);
1455 }
1456
1457 if (pcity && pcity->airlift) {
1458 local_show(ID_UNIT_ORDER_AIRLIFT);
1459 hide(ID_UNIT_ORDER_GOTO_CITY);
1460 } else {
1461 local_show(ID_UNIT_ORDER_GOTO_CITY);
1462 local_hide(ID_UNIT_ORDER_AIRLIFT);
1463 }
1464
1465 if (pcity && can_upgrade_unittype(client.conn.playing,
1466 unit_type_get(punit))) {
1467 local_show(ID_UNIT_ORDER_UPGRADE);
1468 } else {
1469 local_hide(ID_UNIT_ORDER_UPGRADE);
1470 }
1471
1472 if (unit_can_convert(&(wld.map), punit)) {
1473 local_show(ID_UNIT_ORDER_CONVERT);
1474 } else {
1475 local_hide(ID_UNIT_ORDER_CONVERT);
1476 }
1477
1478 set_new_order_widget_start_pos();
1479 counter = redraw_order_widgets();
1480
1481 } else {
1482 if (counter) {
1483 hide_group(begin_order_widget_list, end_order_widget_list);
1484 }
1485
1486 counter = 0;
1487 }
1488 }
1489}
1490
1491/**********************************************************************/
1494 void disable_order_buttons(void)
1495{
1496 undraw_order_widgets();
1497 disable_group(begin_order_widget_list, end_order_widget_list);
1498 redraw_order_widgets();
1499}
1500
1501/**********************************************************************/
1504 void enable_order_buttons(void)
1505{
1506 if (can_client_issue_orders()) {
1507 undraw_order_widgets();
1508 enable_group(begin_order_widget_list, end_order_widget_list);
1509 redraw_order_widgets();
1510 }
1511}
action_id_name_translation
const char * action_id_name_translation(action_id act_id)
Definition actions.c:1910
ACTION_ANY
#define ACTION_ANY
Definition actions.h:290
base_extra_get
struct extra_type * base_extra_get(const struct base_type *pbase)
Definition base.c:101
get_base_by_gui_type
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
city_name_get
const char * city_name_get(const struct city *pcity)
Definition city.c:1111
client
struct civclient client
Definition client_main.c:149
client_state
enum client_states client_state(void)
Definition client_main.c:1029
can_client_issue_orders
bool can_client_issue_orders(void)
Definition client_main.c:1265
client_main.h
C_S_RUNNING
@ C_S_RUNNING
Definition client_main.h:47
turns_to_activity_done
int turns_to_activity_done(const struct tile *ptile, Activity_type_id act, const struct extra_type *tgt, const struct unit *pmodunit)
Definition clientutils.c:203
clientutils.h
can_units_do_connect
bool can_units_do_connect(struct unit_list *punits, enum unit_activity activity, struct extra_type *tgt)
Definition climisc.c:1224
climisc.h
key_unit_sentry
void key_unit_sentry(void)
Definition control.c:3607
key_unit_road
void key_unit_road(void)
Definition control.c:3589
key_unit_pollution
void key_unit_pollution(void)
Definition control.c:3581
request_unit_return
void request_unit_return(struct unit *punit)
Definition control.c:1521
key_unit_build_city
void key_unit_build_city(void)
Definition control.c:3167
key_unit_auto_explore
void key_unit_auto_explore(void)
Definition control.c:3383
key_unit_connect
void key_unit_connect(enum unit_activity activity, struct extra_type *tgt)
Definition control.c:3189
request_unit_load
void request_unit_load(struct unit *pcargo, struct unit *ptrans, struct tile *ptile)
Definition control.c:2056
request_unit_goto
void request_unit_goto(enum unit_orders last_order, action_id act_id, int sub_tgt_id)
Definition control.c:1103
key_unit_paradrop
void key_unit_paradrop(void)
Definition control.c:3293
get_units_in_focus
struct unit_list * get_units_in_focus(void)
Definition control.c:177
request_unit_autosettlers
void request_unit_autosettlers(const struct unit *punit)
Definition control.c:2041
can_unit_do_connect
bool can_unit_do_connect(struct unit *punit, enum unit_activity activity, struct extra_type *tgt)
Definition control.c:1384
key_unit_build_wonder
void key_unit_build_wonder(void)
Definition control.c:3177
key_unit_plant
void key_unit_plant(void)
Definition control.c:3529
key_unit_fortress
void key_unit_fortress(void)
Definition control.c:3438
key_unit_mine
void key_unit_mine(void)
Definition control.c:3521
key_unit_pillage
void key_unit_pillage(void)
Definition control.c:3541
request_unit_unload
void request_unit_unload(struct unit *pcargo)
Definition control.c:2092
key_unit_irrigate
void key_unit_irrigate(void)
Definition control.c:3501
key_unit_unload_all
void key_unit_unload_all(void)
Definition control.c:3323
key_unit_homecity
void key_unit_homecity(void)
Definition control.c:3455
key_unit_patrol
void key_unit_patrol(void)
Definition control.c:3301
key_unit_wakeup_others
void key_unit_wakeup_others(void)
Definition control.c:3356
key_unit_wait
void key_unit_wait(void)
Definition control.c:3348
key_unit_trade_route
void key_unit_trade_route(void)
Definition control.c:3309
head_of_units_in_focus
struct unit * head_of_units_in_focus(void)
Definition control.c:406
key_unit_action_select_tgt
void key_unit_action_select_tgt(void)
Definition control.c:3220
key_unit_fallout
void key_unit_fallout(void)
Definition control.c:3418
key_unit_transform
void key_unit_transform(void)
Definition control.c:3619
key_unit_done
void key_unit_done(void)
Definition control.c:3277
key_unit_airbase
void key_unit_airbase(void)
Definition control.c:3366
key_unit_goto
void key_unit_goto(void)
Definition control.c:3285
key_unit_convert
void key_unit_convert(void)
Definition control.c:3408
key_unit_fortify
void key_unit_fortify(void)
Definition control.c:3426
key_unit_cultivate
void key_unit_cultivate(void)
Definition control.c:3509
control.h
can_unit_do_activity_targeted_client
#define can_unit_do_activity_targeted_client(_punit_, _act_, _tgt_)
Definition control.h:42
can_unit_do_activity_client
#define can_unit_do_activity_client(_punit_, _act_)
Definition control.h:40
punit
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit * punit
Definition dialogs_g.h:73
next_extra_for_tile
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:740
extra_type_list_by_cause
struct extra_type_list * extra_type_list_by_cause(enum extra_cause cause)
Definition extras.c:241
prev_extra_in_tile
struct extra_type * prev_extra_in_tile(const struct tile *ptile, enum extra_rmcause rmcause, const struct player *pplayer, const struct unit *punit)
Definition extras.c:765
extras
static struct extra_type extras[MAX_EXTRA_TYPES]
Definition extras.c:31
extra_name_translation
const char * extra_name_translation(const struct extra_type *pextra)
Definition extras.c:186
extra_road_get
#define extra_road_get(_e_)
Definition extras.h:185
current_theme
QString current_theme
Definition fc_client.cpp:65
road_compat
road_compat
Definition fc_types.h:1105
ROCO_RAILROAD
@ ROCO_RAILROAD
Definition fc_types.h:1105
fcintl.h
PL_
#define PL_(String1, String2, n)
Definition fcintl.h:71
_
#define _(String)
Definition fcintl.h:67
wld
struct world wld
Definition game.c:58
game_city_by_number
struct city * game_city_by_number(int id)
Definition game.c:102
game.h
popup_goto_dialog
void popup_goto_dialog(void)
Definition gotodlg.c:257
flush_dirty
void flush_dirty(void)
Definition mapview.c:450
real_menus_init
void real_menus_init(void)
Definition menu.c:2836
real_menus_update
void real_menus_update(void)
Definition menu.c:2317
popup_unit_disband_dlg
void popup_unit_disband_dlg(struct unit *punit, bool city)
Definition dialogs.c:875
popup_unit_upgrade_dlg
void popup_unit_upgrade_dlg(struct unit *punit, bool city)
Definition dialogs.c:680
popup_airlift_dialog
void popup_airlift_dialog(void)
Definition gotodlg.c:407
main_window_width
int main_window_width(void)
Definition graphics.c:685
main_data
struct sdl2_data main_data
Definition graphics.c:57
sdl2_client_flags
Uint32 sdl2_client_flags
Definition gui_main.c:97
CF_MAP_UNIT_W_CREATED
#define CF_MAP_UNIT_W_CREATED
Definition gui_main.h:43
CF_ORDERS_WIDGETS_CREATED
#define CF_ORDERS_WIDGETS_CREATED
Definition gui_main.h:42
selected_widget
struct widget * selected_widget
Definition widget.c:48
adj_size
#define adj_size(size)
Definition gui_main.h:138
CF_GAME_JUST_STARTED
#define CF_GAME_JUST_STARTED
Definition gui_main.h:46
PRESSED_EVENT
#define PRESSED_EVENT(event)
Definition gui_main.h:68
get_minimap_window_widget
struct widget * get_minimap_window_widget(void)
Definition mapctrl.c:2203
get_unit_info_window_widget
struct widget * get_unit_info_window_widget(void)
Definition mapctrl.c:2195
hide_unitinfo_window_buttons
void hide_unitinfo_window_buttons(void)
Definition mapctrl.c:1593
disable_minimap_window_buttons
void disable_minimap_window_buttons(void)
Definition mapctrl.c:1911
show_minimap_window_buttons
void show_minimap_window_buttons(void)
Definition mapctrl.c:1798
hide_minimap_window_buttons
void hide_minimap_window_buttons(void)
Definition mapctrl.c:1836
show_unitinfo_window_buttons
void show_unitinfo_window_buttons(void)
Definition mapctrl.c:1569
disable_unitinfo_window_buttons
void disable_unitinfo_window_buttons(void)
Definition mapctrl.c:1617
options_button
struct widget * options_button
Definition optiondlg.c:103
order_trade_button
static struct widget * order_trade_button
Definition menu.c:79
order_airbase_button
static struct widget * order_airbase_button
Definition menu.c:70
create_units_order_widgets
void create_units_order_widgets(void)
Definition menu.c:402
disable_order_buttons
void disable_order_buttons(void)
Definition menu.c:1494
unit_order_callback
static int unit_order_callback(struct widget *order_widget)
Definition menu.c:93
local_show
#define local_show(id)
Definition menu.c:81
local_hide
#define local_hide(id)
Definition menu.c:85
order_fortress_button
static struct widget * order_fortress_button
Definition menu.c:71
order_irrigation_button
static struct widget * order_irrigation_button
Definition menu.c:74
redraw_order_widgets
static Uint16 redraw_order_widgets(void)
Definition menu.c:277
order_plant_button
static struct widget * order_plant_button
Definition menu.c:76
order_transform_button
static struct widget * order_transform_button
Definition menu.c:78
undraw_order_widgets
void undraw_order_widgets(void)
Definition menu.c:979
order_fallout_button
static struct widget * order_fallout_button
Definition menu.c:68
begin_order_widget_list
static struct widget * begin_order_widget_list
Definition menu.c:65
order_road_button
static struct widget * order_road_button
Definition menu.c:77
order_cultivate_button
static struct widget * order_cultivate_button
Definition menu.c:75
set_new_order_widget_start_pos
static void set_new_order_widget_start_pos(void)
Definition menu.c:305
order_pollution_button
static struct widget * order_pollution_button
Definition menu.c:69
enable_order_buttons
void enable_order_buttons(void)
Definition menu.c:1504
order_build_add_to_city_button
static struct widget * order_build_add_to_city_button
Definition menu.c:72
order_mine_button
static struct widget * order_mine_button
Definition menu.c:73
end_order_widget_list
static struct widget * end_order_widget_list
Definition menu.c:66
delete_units_order_widgets
void delete_units_order_widgets(void)
Definition menu.c:958
update_order_widgets
void update_order_widgets(void)
Definition menu.c:970
dialogs.h
gotodlg.h
graphics.h
gui_main.h
mapctrl.h
mapview.h
menu.h
pages.h
gui_id.h
ID_UNIT_ORDER_NUKE
@ ID_UNIT_ORDER_NUKE
Definition gui_id.h:122
ID_UNIT_ORDER_AUTO_SETTLER
@ ID_UNIT_ORDER_AUTO_SETTLER
Definition gui_id.h:108
ID_UNIT_ORDER_SENTRY
@ ID_UNIT_ORDER_SENTRY
Definition gui_id.h:101
ID_UNIT_ORDER_AIRBASE
@ ID_UNIT_ORDER_AIRBASE
Definition gui_id.h:97
ID_UNIT_ORDER_DEBOARD
@ ID_UNIT_ORDER_DEBOARD
Definition gui_id.h:106
ID_UNIT_ORDER_BUILD_WONDER
@ ID_UNIT_ORDER_BUILD_WONDER
Definition gui_id.h:87
ID_UNIT_ORDER_IRRIGATE
@ ID_UNIT_ORDER_IRRIGATE
Definition gui_id.h:90
ID_UNIT_ORDER_BUILD_CITY
@ ID_UNIT_ORDER_BUILD_CITY
Definition gui_id.h:86
ID_UNIT_ORDER_RETURN
@ ID_UNIT_ORDER_RETURN
Definition gui_id.h:117
ID_UNIT_ORDER_PATROL
@ ID_UNIT_ORDER_PATROL
Definition gui_id.h:113
ID_UNIT_ORDER_ROAD
@ ID_UNIT_ORDER_ROAD
Definition gui_id.h:88
ID_UNIT_ORDER_MINE
@ ID_UNIT_ORDER_MINE
Definition gui_id.h:92
ID_UNIT_ORDER_DIPLOMAT_DLG
@ ID_UNIT_ORDER_DIPLOMAT_DLG
Definition gui_id.h:121
ID_UNIT_ORDER_DISBAND
@ ID_UNIT_ORDER_DISBAND
Definition gui_id.h:120
ID_UNIT_ORDER_BOARD
@ ID_UNIT_ORDER_BOARD
Definition gui_id.h:105
ID_UNIT_ORDER_PLANT
@ ID_UNIT_ORDER_PLANT
Definition gui_id.h:93
ID_UNIT_ORDER_CONNECT_ROAD
@ ID_UNIT_ORDER_CONNECT_ROAD
Definition gui_id.h:110
ID_UNIT_ORDER_CONVERT
@ ID_UNIT_ORDER_CONVERT
Definition gui_id.h:119
ID_UNIT_ORDER_AUTO_EXPLORE
@ ID_UNIT_ORDER_AUTO_EXPLORE
Definition gui_id.h:109
ID_UNIT_ORDER_WAIT
@ ID_UNIT_ORDER_WAIT
Definition gui_id.h:123
ID_UNIT_ORDER_WAKEUP_OTHERS
@ ID_UNIT_ORDER_WAKEUP_OTHERS
Definition gui_id.h:107
ID_UNIT_ORDER_UNLOAD_TRANSPORTER
@ ID_UNIT_ORDER_UNLOAD_TRANSPORTER
Definition gui_id.h:104
ID_UNIT_ORDER_UPGRADE
@ ID_UNIT_ORDER_UPGRADE
Definition gui_id.h:118
ID_UNIT_ORDER_GOTO_CITY
@ ID_UNIT_ORDER_GOTO_CITY
Definition gui_id.h:115
ID_UNIT_ORDER_FALLOUT
@ ID_UNIT_ORDER_FALLOUT
Definition gui_id.h:100
ID_UNIT_ORDER_POLLUTION
@ ID_UNIT_ORDER_POLLUTION
Definition gui_id.h:98
ID_UNIT_ORDER_FORTRESS
@ ID_UNIT_ORDER_FORTRESS
Definition gui_id.h:95
ID_UNIT_ORDER_TRANSFORM
@ ID_UNIT_ORDER_TRANSFORM
Definition gui_id.h:94
ID_UNIT_ORDER_PILLAGE
@ ID_UNIT_ORDER_PILLAGE
Definition gui_id.h:102
ID_UNIT_ORDER_PARADROP
@ ID_UNIT_ORDER_PARADROP
Definition gui_id.h:99
ID_UNIT_ORDER_HOMECITY
@ ID_UNIT_ORDER_HOMECITY
Definition gui_id.h:103
ID_UNIT_ORDER_CONNECT_IRRIGATE
@ ID_UNIT_ORDER_CONNECT_IRRIGATE
Definition gui_id.h:112
ID_UNIT_ORDER_DONE
@ ID_UNIT_ORDER_DONE
Definition gui_id.h:124
ID_UNIT_ORDER_GOTO
@ ID_UNIT_ORDER_GOTO
Definition gui_id.h:114
ID_UNIT_ORDER_FORTIFY
@ ID_UNIT_ORDER_FORTIFY
Definition gui_id.h:96
ID_UNIT_ORDER_AIRLIFT
@ ID_UNIT_ORDER_AIRLIFT
Definition gui_id.h:116
ID_UNIT_ORDER_CULTIVATE
@ ID_UNIT_ORDER_CULTIVATE
Definition gui_id.h:91
ID_UNIT_ORDER_TRADE_ROUTE
@ ID_UNIT_ORDER_TRADE_ROUTE
Definition gui_id.h:89
ID_UNIT_ORDER_CONNECT_RAILROAD
@ ID_UNIT_ORDER_CONNECT_RAILROAD
Definition gui_id.h:111
copy_chars_to_utf8_str
utf8_str * copy_chars_to_utf8_str(utf8_str *pstr, const char *pchars)
Definition gui_string.c:251
FONTO_DEFAULT
@ FONTO_DEFAULT
Definition gui_string.h:64
create_utf8_from_char_fonto
#define create_utf8_from_char_fonto(string_in, fonto)
Definition gui_string.h:107
gui_tilespec.h
log.h
lines
char * lines
Definition packhand.c:129
get_client_page
enum client_pages get_client_page(void)
Definition update_queue.c:520
road_extra_get
struct extra_type * road_extra_get(const struct road_type *proad)
Definition road.c:42
road_compat_special
enum road_compat road_compat_special(const struct road_type *proad)
Definition road.c:151
road_by_gui_type
struct road_type * road_by_gui_type(enum road_gui_type gui_type)
Definition road.c:180
road.h
compat
static struct compatibility compat[]
Definition savecompat.c:101
base_type
Definition base.h:41
city
Definition city.h:309
city::id
int id
Definition city.h:315
city::airlift
int airlift
Definition city.h:365
civclient::conn
struct connection conn
Definition client_main.h:96
connection::playing
struct player * playing
Definition connection.h:156
extra_type
Definition extras.h:85
road_type
Definition road.h:75
sdl2_data::gui
struct gui_layer * gui
Definition graphics.h:215
sdl2_data::event
SDL_Event event
Definition graphics.h:217
terrain
Definition terrain.h:176
terrain::cultivate_result
struct terrain * cultivate_result
Definition terrain.h:203
terrain::plant_result
struct terrain * plant_result
Definition terrain.h:206
terrain::transform_result
struct terrain * transform_result
Definition terrain.h:217
tile
Definition tile.h:49
unit
Definition unit.h:138
unit::occupied
bool occupied
Definition unit.h:216
unit::client
struct unit::@80::@82 client
unit::homecity
int homecity
Definition unit.h:146
unit::carrying
struct goods_type * carrying
Definition unit.h:186
unit::ssa_controller
enum server_side_agent ssa_controller
Definition unit.h:172
widget
Definition widget.h:112
widget::info_label
utf8_str * info_label
Definition widget.h:122
widget::key
SDL_Keycode key
Definition widget.h:153
widget::action
int(* action)(struct widget *)
Definition widget.h:157
widget::cont
struct container * cont
Definition widget.h:127
widget::mod
Uint16 mod
Definition widget.h:154
widget::theme
SDL_Surface * theme
Definition widget.h:118
widget::id
Uint16 id
Definition widget.h:155
world::map
struct civ_map map
Definition world_object.h:38
fc_snprintf
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:969
TRUE
#define TRUE
Definition support.h:46
FALSE
#define FALSE
Definition support.h:47
terrain_name_translation
const char * terrain_name_translation(const struct terrain *pterrain)
Definition terrain.c:226
tile_city
struct city * tile_city(const struct tile *ptile)
Definition tile.c:83
tile_terrain
#define tile_terrain(_tile)
Definition tile.h:109
can_cities_trade
bool can_cities_trade(const struct city *pc1, const struct city *pc2)
Definition traderoutes.c:214
trade_base_between_cities
int trade_base_between_cities(const struct city *pc1, const struct city *pc2)
Definition traderoutes.c:322
get_caravan_enter_city_trade_bonus
int get_caravan_enter_city_trade_bonus(const struct city *pc1, const struct city *pc2, struct goods_type *pgood, const bool establish_trade)
Definition traderoutes.c:467
can_establish_trade_route
bool can_establish_trade_route(const struct city *pc1, const struct city *pc2)
Definition traderoutes.c:275
traderoutes.h
can_unit_change_homecity
bool can_unit_change_homecity(const struct unit *punit)
Definition unit.c:464
unit_can_add_or_build_city
bool unit_can_add_or_build_city(const struct unit *punit)
Definition unit.c:430
is_unit_activity_on_tile
bool is_unit_activity_on_tile(enum unit_activity activity, const struct tile *ptile)
Definition unit.c:1143
can_unit_do_autosettlers
bool can_unit_do_autosettlers(const struct unit *punit)
Definition unit.c:583
unit_can_help_build_wonder_here
bool unit_can_help_build_wonder_here(const struct unit *punit)
Definition unit.c:263
unit_can_do_action
bool unit_can_do_action(const struct unit *punit, const action_id act_id)
Definition unit.c:331
can_unit_paradrop
bool can_unit_paradrop(const struct civ_map *nmap, const struct unit *punit)
Definition unit.c:827
unit_can_convert
bool unit_can_convert(const struct civ_map *nmap, const struct unit *punit)
Definition unit.c:2021
unit_tile
#define unit_tile(_pu)
Definition unit.h:388
ORDER_PERFORM_ACTION
@ ORDER_PERFORM_ACTION
Definition unit.h:47
unit_owner
#define unit_owner(_pu)
Definition unit.h:387
units_can_unload
bool units_can_unload(const struct unit_list *punits)
Definition unitlist.c:305
units_can_load
bool units_can_load(const struct unit_list *punits)
Definition unitlist.c:291
unitlist.h
unit_list_iterate
#define unit_list_iterate(unitlist, punit)
Definition unitlist.h:31
unit_list_iterate_end
#define unit_list_iterate_end
Definition unitlist.h:33
unit_type_get
const struct unit_type * unit_type_get(const struct unit *punit)
Definition unittype.c:123
can_upgrade_unittype
const struct unit_type * can_upgrade_unittype(const struct player *pplayer, const struct unit_type *punittype)
Definition unittype.c:1755
utype_can_do_action
bool utype_can_do_action(const struct unit_type *putype, const action_id act_id)
Definition unittype.c:443
add_to_gui_list
void add_to_gui_list(Uint16 id, struct widget *gui)
Definition widget.c:585
refresh_widget_background
void refresh_widget_background(struct widget *pwidget)
Definition widget.c:1150
hide_group
void hide_group(struct widget *begin_group_widget_list, struct widget *end_group_widget_list)
Definition widget.c:914
widget.h
enable_group
#define enable_group(begin_group_widget_list, end_group_widget_list)
Definition widget.h:397
FC_WS_DISABLED
@ FC_WS_DISABLED
Definition widget.h:99
FC_WS_NORMAL
@ FC_WS_NORMAL
Definition widget.h:96
FC_WS_SELECTED
@ FC_WS_SELECTED
Definition widget.h:97
clear_wflag
void clear_wflag(struct widget *pwidget, enum widget_flag flag)
Definition widget_core.c:62
widget_mark_dirty
static void widget_mark_dirty(struct widget *pwidget)
Definition widget.h:286
disable_group
#define disable_group(begin_group_widget_list, end_group_widget_list)
Definition widget.h:401
get_wflags
enum widget_flag get_wflags(const struct widget *pwidget)
Definition widget_core.c:86
set_wstate
void set_wstate(struct widget *pwidget, enum widget_state state)
Definition widget_core.c:36
get_wstate
enum widget_state get_wstate(const struct widget *pwidget)
Definition widget_core.c:70
widget_undraw
static void widget_undraw(struct widget *pwidget)
Definition widget.h:296
WF_WIDGET_HAS_INFO_LABEL
@ WF_WIDGET_HAS_INFO_LABEL
Definition widget.h:88
WF_RESTORE_BACKGROUND
@ WF_RESTORE_BACKGROUND
Definition widget.h:85
WF_HIDDEN
@ WF_HIDDEN
Definition widget.h:68
widget_redraw
static int widget_redraw(struct widget *pwidget)
Definition widget.h:276
hide
#define hide(id)
Definition widget.h:238
set_wflag
void set_wflag(struct widget *pwidget, enum widget_flag flag)
Definition widget_core.c:54
del_group
#define del_group(begin_group_widget_list, end_group_widget_list)
Definition widget.h:389
create_themeicon
struct widget * create_themeicon(SDL_Surface *icon_theme, struct gui_layer *pdest, Uint32 flags)
Definition widget_icon.c:208