Freeciv-3.3: /fast/freeciv/nightly/main/client/gui-sdl2/menu.c Source File

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