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

Freeciv-3.3

Loading...
Searching...
No Matches
mapctrl.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 mapctrl.c - description
16 -------------------
17 begin : Thu Sep 05 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 "unit.h"
39#include "unitlist.h"
40
41/* client */
42#include "client_main.h"
43#include "climisc.h"
44#include "overview_common.h"
45#include "pages_g.h"
46#include "update_queue.h"
47#include "zoom.h"
48
49/* client/gui-sdl2 */
50#include "citydlg.h"
51#include "cityrep.h"
52#include "colors.h"
53#include "dialogs.h"
54#include "finddlg.h"
55#include "graphics.h"
56#include "gui_id.h"
57#include "gui_main.h"
58#include "gui_mouse.h"
59#include "gui_tilespec.h"
60#include "mapview.h"
61#include "menu.h"
62#include "messagewin.h"
63#include "optiondlg.h"
64#include "plrdlg.h"
65#include "repodlgs.h"
66#include "sprite.h"
67#include "themespec.h"
68#include "widget.h"
69#include "wldlg.h"
70
71#include "mapctrl.h"
72
73#undef SCALE_MINIMAP
74#undef SCALE_UNITINFO
75
76extern int overview_start_x;
77extern int overview_start_y;
78extern bool is_unit_move_blocked;
79
80 static char *suggested_city_name = NULL;
81 static struct small_dialog *new_city_dlg = NULL;
82extern struct widget *options_button;
83
84#ifdef SCALE_MINIMAP
85static struct small_dialog *scale_minimap_dlg = NULL;
86static int popdown_scale_minmap_dlg_callback(struct widget *pwidget);
87#endif /* SCALE_MINIMAP */
88
89#ifdef SCALE_UNITINFO
90static struct small_dialog *scale_unit_info_dlg = NULL;
91static int info_width, info_height = 0, info_width_min, info_height_min;
92static int popdown_scale_unitinfo_dlg_callback(struct widget *pwidget);
93static void remake_unitinfo(int w, int h);
94#endif /* SCALE_UNITINFO */
95
96 static struct advanced_dialog *minimap_dlg = NULL;
97 static struct advanced_dialog *unit_info_dlg = NULL;
98
99 int overview_w = 0;
100 int overview_h = 0;
101 int unitinfo_w = 0;
102 int unitinfo_h = 0;
103
104 bool draw_goto_patrol_lines = FALSE;
105 static struct widget *new_turn_button = NULL;
106 static struct widget *units_info_window = NULL;
107 static struct widget *minimap_window = NULL;
108 static struct widget *find_city_button = NULL;
109 static struct widget *revolution_button = NULL;
110 static struct widget *tax_button = NULL;
111 static struct widget *research_button = NULL;
112
113static void enable_minimap_widgets(void);
114static void disable_minimap_widgets(void);
115static void enable_unitinfo_widgets(void);
116static void disable_unitinfo_widgets(void);
117
118/* ================================================================ */
119
120/**********************************************************************/
123 static int players_action_callback(struct widget *pwidget)
124{
125 set_wstate(pwidget, FC_WS_NORMAL);
126 widget_redraw(pwidget);
127 widget_mark_dirty(pwidget);
128 if (main_data.event.type == SDL_MOUSEBUTTONDOWN) {
129 switch (main_data.event.button.button) {
130#if 0
131 case SDL_BUTTON_LEFT:
132
133 break;
134 case SDL_BUTTON_MIDDLE:
135
136 break;
137#endif /* 0 */
138 case SDL_BUTTON_RIGHT:
139 popup_players_nations_dialog();
140 break;
141 default:
142 popup_players_dialog(true);
143 break;
144 }
145 } else {
146 popup_players_dialog(true);
147 }
148
149 return -1;
150}
151
152/**********************************************************************/
155 static int units_action_callback(struct widget *pwidget)
156{
157 if (PRESSED_EVENT(main_data.event)) {
158 set_wstate(pwidget, FC_WS_NORMAL);
159 widget_redraw(pwidget);
160 widget_mark_dirty(pwidget);
161 units_report_dialog_popup(FALSE);
162 }
163
164 return -1;
165}
166
167/**********************************************************************/
170 static int cities_action_callback(struct widget *button)
171{
172 set_wstate(button, FC_WS_DISABLED);
173 widget_redraw(button);
174 widget_mark_dirty(button);
175 if (main_data.event.type == SDL_KEYDOWN) {
176 /* Ctrl-F shortcut */
177 popup_find_dialog();
178 } else if (main_data.event.type == SDL_MOUSEBUTTONDOWN) {
179 switch (main_data.event.button.button) {
180#if 0
181 case SDL_BUTTON_LEFT:
182
183 break;
184 case SDL_BUTTON_MIDDLE:
185
186 break;
187#endif /* 0 */
188 case SDL_BUTTON_RIGHT:
189 popup_find_dialog();
190 break;
191 default:
192 city_report_dialog_popup(FALSE);
193 break;
194 }
195 } else if (PRESSED_EVENT(main_data.event)) {
196 city_report_dialog_popup(FALSE);
197 }
198
199 return -1;
200}
201
202/**********************************************************************/
205 static int end_turn_callback(struct widget *button)
206{
207 if (PRESSED_EVENT(main_data.event)) {
208 widget_redraw(button);
209 widget_flush(button);
210 disable_focus_animation();
211 key_end_turn();
212 }
213
214 return -1;
215}
216
217/**********************************************************************/
220 static int revolution_callback(struct widget *button)
221{
222 if (PRESSED_EVENT(main_data.event)) {
223 set_wstate(button, FC_WS_DISABLED);
224 widget_redraw(button);
225 widget_mark_dirty(button);
226 popup_government_dialog();
227 }
228
229 return -1;
230}
231
232/**********************************************************************/
235 static int research_callback(struct widget *button)
236{
237 if (PRESSED_EVENT(main_data.event)) {
238 science_report_dialog_popup(TRUE);
239 }
240
241 return -1;
242}
243
244/**********************************************************************/
247 static int economy_callback(struct widget *button)
248{
249 if (PRESSED_EVENT(main_data.event)) {
250 economy_report_dialog_popup(FALSE);
251 }
252
253 return -1;
254}
255
256/* ====================================== */
257
258/**********************************************************************/
261 static int toggle_unit_info_window_callback(struct widget *icon_widget)
262{
263 if (PRESSED_EVENT(main_data.event)) {
264 struct widget *buf = NULL;
265
266 clear_surface(icon_widget->theme, NULL);
267 alphablit(current_theme->map_icon, NULL, icon_widget->theme, NULL, 255);
268
269 if (get_num_units_in_focus() > 0) {
270 undraw_order_widgets();
271 }
272
273 if (sdl2_client_flags & CF_UNITINFO_SHOWN) {
274 /* HIDE */
275 SDL_Surface *buf_surf;
276 SDL_Rect src, window_area;
277
278 set_wstate(icon_widget, FC_WS_NORMAL);
279 selected_widget = NULL;
280
281 if (units_info_window->private_data.adv_dlg->end_active_widget_list) {
282 del_group(units_info_window->private_data.adv_dlg->begin_active_widget_list,
283 units_info_window->private_data.adv_dlg->end_active_widget_list);
284 }
285 if (units_info_window->private_data.adv_dlg->scroll) {
286 hide_scrollbar(units_info_window->private_data.adv_dlg->scroll);
287 }
288
289 /* clear area under old unit info window */
290 widget_undraw(units_info_window);
291 widget_mark_dirty(units_info_window);
292
293 /* new button direction */
294 alphablit(current_theme->l_arrow_icon, NULL, icon_widget->theme, NULL,
295 255);
296
297 copy_chars_to_utf8_str(icon_widget->info_label,
298 _("Show Unit Info Window"));
299
300 sdl2_client_flags &= ~CF_UNITINFO_SHOWN;
301
302 set_new_unitinfo_window_pos();
303
304 /* blit part of map window */
305 src.x = 0;
306 src.y = 0;
307 src.w = (units_info_window->size.w - units_info_window->area.w) + BLOCKU_W;
308 src.h = units_info_window->theme->h;
309
310 window_area = units_info_window->size;
311 alphablit(units_info_window->theme, &src,
312 units_info_window->dst->surface, &window_area, 255);
313
314 /* blit right vertical frame */
315 buf_surf = resize_surface(current_theme->fr_right,
316 current_theme->fr_right->w,
317 units_info_window->area.h, 1);
318
319 window_area.y = units_info_window->area.y;
320 window_area.x = units_info_window->area.x + units_info_window->area.w;
321 alphablit(buf_surf, NULL,
322 units_info_window->dst->surface, &window_area, 255);
323 FREESURFACE(buf_surf);
324
325 /* redraw widgets */
326
327 /* ID_ECONOMY */
328 buf = units_info_window->prev;
329 widget_redraw(buf);
330
331 /* ===== */
332 /* ID_RESEARCH */
333 buf = buf->prev;
334 widget_redraw(buf);
335
336 /* ===== */
337 /* ID_REVOLUTION */
338 buf = buf->prev;
339 widget_redraw(buf);
340
341 /* ===== */
342 /* ID_TOGGLE_UNITS_WINDOW_BUTTON */
343 buf = buf->prev;
344 widget_redraw(buf);
345
346#ifdef SCALE_UNITINFO
347 popdown_scale_unitinfo_dlg_callback(NULL);
348#endif
349 } else {
350 if (main_window_width() - units_info_window->size.w >=
351 minimap_window->dst->dest_rect.x + minimap_window->size.w) {
352
353 set_wstate(icon_widget, FC_WS_NORMAL);
354 selected_widget = NULL;
355
356 /* SHOW */
357 copy_chars_to_utf8_str(icon_widget->info_label,
358 _("Hide Unit Info Window"));
359
360 alphablit(current_theme->r_arrow_icon, NULL, icon_widget->theme, NULL,
361 255);
362
363 sdl2_client_flags |= CF_UNITINFO_SHOWN;
364
365 set_new_unitinfo_window_pos();
366
367 widget_mark_dirty(units_info_window);
368
369 redraw_unit_info_label(get_units_in_focus());
370 } else {
371 alphablit(current_theme->l_arrow_icon, NULL, icon_widget->theme, NULL,
372 255);
373 widget_redraw(icon_widget);
374 widget_mark_dirty(icon_widget);
375 }
376 }
377
378 if (get_num_units_in_focus() > 0) {
379 update_order_widgets();
380 }
381
382 flush_dirty();
383 }
384
385 return -1;
386}
387
388/**********************************************************************/
391 static int toggle_map_window_callback(struct widget *map_button)
392{
393 if (PRESSED_EVENT(main_data.event)) {
394 struct unit *focus = head_of_units_in_focus();
395 struct widget *pwidget;
396
397 /* make new map icon */
398 clear_surface(map_button->theme, NULL);
399 alphablit(current_theme->map_icon, NULL, map_button->theme, NULL, 255);
400
401 set_wstate(minimap_window, FC_WS_NORMAL);
402
403 if (focus) {
404 undraw_order_widgets();
405 }
406
407 if (sdl2_client_flags & CF_OVERVIEW_SHOWN) {
408 /* Hide MiniMap */
409 SDL_Surface *buf_surf;
410 SDL_Rect src, map_area = minimap_window->size;
411
412 set_wstate(map_button, FC_WS_NORMAL);
413 selected_widget = NULL;
414
415 copy_chars_to_utf8_str(map_button->info_label, _("Show Mini Map"));
416
417 /* make new map icon */
418 alphablit(current_theme->r_arrow_icon, NULL, map_button->theme, NULL, 255);
419
420 sdl2_client_flags &= ~CF_OVERVIEW_SHOWN;
421
422 /* clear area under old map window */
423 widget_undraw(minimap_window);
424 widget_mark_dirty(minimap_window);
425
426 minimap_window->size.w = (minimap_window->size.w - minimap_window->area.w) + BLOCKM_W;
427 minimap_window->area.w = BLOCKM_W;
428
429 set_new_minimap_window_pos();
430
431 /* blit part of map window */
432 src.x = minimap_window->theme->w - BLOCKM_W - current_theme->fr_right->w;
433 src.y = 0;
434 src.w = BLOCKM_W + current_theme->fr_right->w;
435 src.h = minimap_window->theme->h;
436
437 alphablit(minimap_window->theme, &src,
438 minimap_window->dst->surface, &map_area, 255);
439
440 /* blit left vertical frame theme */
441 buf_surf = resize_surface(current_theme->fr_left,
442 current_theme->fr_left->w,
443 minimap_window->area.h, 1);
444
445 map_area.y += adj_size(2);
446 alphablit(buf_surf, NULL, minimap_window->dst->surface, &map_area, 255);
447 FREESURFACE(buf_surf);
448
449 /* redraw widgets */
450 /* ID_NEW_TURN */
451 pwidget = minimap_window->prev;
452 widget_redraw(pwidget);
453
454 /* ID_PLAYERS */
455 pwidget = pwidget->prev;
456 widget_redraw(pwidget);
457
458 /* ID_CITIES */
459 pwidget = pwidget->prev;
460 widget_redraw(pwidget);
461
462 /* ID_UNITS */
463 pwidget = pwidget->prev;
464 widget_redraw(pwidget);
465
466 /* ID_CHATLINE_TOGGLE_LOG_WINDOW_BUTTON */
467 pwidget = pwidget->prev;
468 widget_redraw(pwidget);
469
470#ifdef GUI_SDL2_SMALL_SCREEN
471 /* options */
472 pwidget = pwidget->prev;
473 widget_redraw(pwidget);
474#endif /* GUI_SDL2_SMALL_SCREEN */
475
476 /* ID_TOGGLE_MAP_WINDOW_BUTTON */
477 pwidget = pwidget->prev;
478 widget_redraw(pwidget);
479
480#ifdef SCALE_MINIMAP
481 popdown_scale_minmap_dlg_callback(NULL);
482#endif
483 } else {
484 if (((minimap_window->size.w - minimap_window->area.w) +
485 overview_w + BLOCKM_W) <= units_info_window->dst->dest_rect.x) {
486
487 set_wstate(map_button, FC_WS_NORMAL);
488 selected_widget = NULL;
489
490 /* show MiniMap */
491 copy_chars_to_utf8_str(map_button->info_label, _("Hide Mini Map"));
492
493 alphablit(current_theme->l_arrow_icon, NULL, map_button->theme, NULL,
494 255);
495 sdl2_client_flags |= CF_OVERVIEW_SHOWN;
496
497 minimap_window->size.w =
498 (minimap_window->size.w - minimap_window->area.w) + overview_w + BLOCKM_W;
499 minimap_window->area.w = overview_w + BLOCKM_W;
500
501 set_new_minimap_window_pos();
502
503 widget_redraw(minimap_window);
504 redraw_minimap_window_buttons();
505 refresh_overview();
506 } else {
507 alphablit(current_theme->r_arrow_icon, NULL, map_button->theme, NULL,
508 255);
509 widget_redraw(map_button);
510 widget_mark_dirty(map_button);
511 }
512 }
513
514 if (focus) {
515 update_order_widgets();
516 }
517
518 flush_dirty();
519 }
520
521 return -1;
522}
523
524/* ====================================================================== */
525
526/**********************************************************************/
529 static int toggle_msg_window_callback(struct widget *pwidget)
530{
531 if (PRESSED_EVENT(main_data.event)) {
532 if (meswin_dialog_is_open()) {
533 meswin_dialog_popdown();
534 copy_chars_to_utf8_str(pwidget->info_label, _("Show Messages (F9)"));
535 } else {
536 meswin_dialog_popup(TRUE);
537 copy_chars_to_utf8_str(pwidget->info_label, _("Hide Messages (F9)"));
538 }
539
540 selected_widget = pwidget;
541 set_wstate(pwidget, FC_WS_SELECTED);
542 widget_redraw(pwidget);
543 widget_mark_dirty(pwidget);
544
545 flush_dirty();
546 }
547
548 return -1;
549}
550
551/**********************************************************************/
554 int resize_minimap(void)
555{
556 overview_w = gui_options.overview.width;
557 overview_h = gui_options.overview.height;
558 overview_start_x = (overview_w - gui_options.overview.width) / 2;
559 overview_start_y = (overview_h - gui_options.overview.height) / 2;
560
561 if (C_S_RUNNING == client_state()) {
562 popdown_minimap_window();
563 popup_minimap_window();
564 refresh_overview();
565 menus_update();
566 }
567
568 return 0;
569}
570
571#ifdef SCALE_MINIMAP
572/* ============================================================== */
573
574/**********************************************************************/
577static int move_scale_minimap_dlg_callback(struct widget *pwindow)
578{
579 if (PRESSED_EVENT(main_data.event)) {
580 move_window_group(scale_minimap_dlg->begin_widget_list, pwindow);
581 }
582
583 return -1;
584}
585
586/**********************************************************************/
589static int popdown_scale_minimap_dlg_callback(struct widget *pwidget)
590{
591 if (PRESSED_EVENT(main_data.event)) {
592 if (scale_minimap_dlg) {
593 popdown_window_group_dialog(scale_minimap_dlg->begin_widget_list,
594 scale_minimap_dlg->end_widget_list);
595 FC_FREE(scale_minimap_dlg);
596 if (pwidget) {
597 flush_dirty();
598 }
599 }
600 }
601
602 return -1;
603}
604
605/**********************************************************************/
608static int up_width_callback(struct widget *pwidget)
609{
610 if (PRESSED_EVENT(main_data.event)) {
611 widget_redraw(pwidget);
612 widget_mark_dirty(pwidget);
613 if ((((OVERVIEW_TILE_WIDTH + 1) * map.xsize) +
614 (minimap_window->size.w - minimap_window->area.w) + BLOCKM_W) <=
615 units_info_window->dst->dest_rect.x) {
616 char cbuf[4];
617
618 fc_snprintf(cbuf, sizeof(cbuf), "%d", OVERVIEW_TILE_WIDTH);
619 copy_chars_to_utf8_str(pwidget->next->string_utf8, cbuf);
620 widget_redraw(pwidget->next);
621 widget_mark_dirty(pwidget->next);
622
623 calculate_overview_dimensions();
624 resize_minimap();
625 }
626 flush_dirty();
627 }
628
629 return -1;
630}
631
632/**********************************************************************/
635static int down_width_callback(struct widget *pwidget)
636{
637 if (PRESSED_EVENT(main_data.event)) {
638 widget_redraw(pwidget);
639 widget_mark_dirty(pwidget);
640 if (OVERVIEW_TILE_WIDTH > 1) {
641 char cbuf[4];
642
643 fc_snprintf(cbuf, sizeof(cbuf), "%d", OVERVIEW_TILE_WIDTH);
644 copy_chars_to_utf8_str(pwidget->prev->string_utf8, cbuf);
645 widget_redraw(pwidget->prev);
646 widget_mark_dirty(pwidget->prev);
647
648 resize_minimap();
649 }
650 flush_dirty();
651 }
652
653 return -1;
654}
655
656/**********************************************************************/
659static int up_height_callback(struct widget *pwidget)
660{
661 if (PRESSED_EVENT(main_data.event)) {
662 widget_redraw(pwidget);
663 widget_mark_dirty(pwidget);
664 if (main_data.screen->h -
665 ((OVERVIEW_TILE_HEIGHT + 1) * map.ysize
666 + (current_theme->fr_bottom->h * 2)) >= 40) {
667 char cbuf[4];
668
669 OVERVIEW_TILE_HEIGHT++;
670 fc_snprintf(cbuf, sizeof(cbuf), "%d", OVERVIEW_TILE_HEIGHT);
671 copy_chars_to_utf8_str(pwidget->next->string_utf8, cbuf);
672 widget_redraw(pwidget->next);
673 widget_mark_dirty(pwidget->next);
674 resize_minimap();
675 }
676 flush_dirty();
677 }
678
679 return -1;
680}
681
682/**********************************************************************/
685static int down_height_callback(struct widget *pwidget)
686{
687 if (PRESSED_EVENT(main_data.event)) {
688 widget_redraw(pwidget);
689 widget_mark_dirty(pwidget);
690 if (OVERVIEW_TILE_HEIGHT > 1) {
691 char cbuf[4];
692
693 OVERVIEW_TILE_HEIGHT--;
694 fc_snprintf(cbuf, sizeof(cbuf), "%d", OVERVIEW_TILE_HEIGHT);
695 copy_chars_to_utf8_str(pwidget->prev->string_utf8, cbuf);
696 widget_redraw(pwidget->prev);
697 widget_mark_dirty(pwidget->prev);
698
699 resize_minimap();
700 }
701 flush_dirty();
702 }
703
704 return -1;
705}
706
707/**********************************************************************/
710static void popup_minimap_scale_dialog(void)
711{
712 SDL_Surface *text1, *text2;
713 utf8_str *pstr = NULL;
714 struct widget *pwindow = NULL;
715 struct widget *buf = NULL;
716 char cbuf[4];
717 int window_x = 0, window_y = 0;
718 SDL_Rect area;
719
720 if (scale_minimap_dlg || !(sdl2_client_flags & CF_OVERVIEW_SHOWN)) {
721 return;
722 }
723
724 scale_minimap_dlg = fc_calloc(1, sizeof(struct small_dialog));
725
726 /* Create window */
727 pstr = create_utf8_from_char_fonto(_("Scale Mini Map"), FONTO_ATTENTION);
728 pstr->style |= TTF_STYLE_BOLD;
729 pwindow = create_window_skeleton(NULL, pstr, 0);
730 pwindow->action = move_scale_minimap_dlg_callback;
731 set_wstate(pwindow, FC_WS_NORMAL);
732 add_to_gui_list(ID_WINDOW, pwindow);
733 scale_minimap_dlg->end_widget_list = pwindow;
734
735 area = pwindow->area;
736
737 /* ----------------- */
738 pstr = create_utf8_from_char_fonto(_("Single Tile Width"), FONTO_ATTENTION);
739 text1 = create_text_surf_from_utf8(pstr);
740 area.w = MAX(area.w, text1->w + adj_size(30));
741
742 copy_chars_to_utf8_str(pstr, _("Single Tile Height"));
743 text2 = create_text_surf_from_utf8(pstr);
744 area.w = MAX(area.w, text2->w + adj_size(30));
745 FREEUTF8_STR(pstr);
746
747 buf = create_themeicon_button(current_theme->l_arrow_icon, pwindow->dst,
748 NULL, 0);
749 buf->action = down_width_callback;
750 set_wstate(buf, FC_WS_NORMAL);
751 add_to_gui_list(ID_BUTTON, buf);
752
753 fc_snprintf(cbuf, sizeof(cbuf), "%d" , OVERVIEW_TILE_WIDTH);
754 pstr = create_utf8_from_char_fonto(cbuf, FONTO_MAX);
755 pstr->style |= (TTF_STYLE_BOLD|SF_CENTER);
756 buf = create_iconlabel(NULL, pwindow->dst, pstr, WF_RESTORE_BACKGROUND);
757 buf->size.w = MAX(adj_size(50), buf->size.w);
758 area.h += buf->size.h + adj_size(5);
759 add_to_gui_list(ID_LABEL, buf);
760
761 buf = create_themeicon_button(current_theme->r_arrow_icon, pwindow->dst,
762 NULL, 0);
763 buf->action = up_width_callback;
764 set_wstate(buf, FC_WS_NORMAL);
765 add_to_gui_list(ID_BUTTON, buf);
766
767 /* ------------ */
768 buf = create_themeicon_button(current_theme->l_arrow_icon, pwindow->dst,
769 NULL, 0);
770 buf->action = down_height_callback;
771 set_wstate(buf, FC_WS_NORMAL);
772 add_to_gui_list(ID_BUTTON, buf);
773
774 fc_snprintf(cbuf, sizeof(cbuf), "%d" , OVERVIEW_TILE_HEIGHT);
775 pstr = create_utf8_from_char_fonto(cbuf, FONTO_MAX);
776 pstr->style |= (TTF_STYLE_BOLD|SF_CENTER);
777 buf = create_iconlabel(NULL, pwindow->dst, pstr, WF_RESTORE_BACKGROUND);
778 buf->size.w = MAX(adj_size(50), buf->size.w);
779 area.h += buf->size.h + adj_size(20);
780 add_to_gui_list(ID_LABEL, buf);
781
782 buf = create_themeicon_button(current_theme->r_arrow_icon, pwindow->dst,
783 NULL, 0);
784 buf->action = up_height_callback;
785 set_wstate(buf, FC_WS_NORMAL);
786 add_to_gui_list(ID_BUTTON, buf);
787 area.w = MAX(area.w , buf->size.w * 2 + buf->next->size.w + adj_size(20));
788
789 /* ------------ */
790 pstr = create_utf8_from_char_fonto(_("Exit"), FONTO_ATTENTION);
791 buf = create_themeicon_button(current_theme->cancel_icon, pwindow->dst,
792 pstr, 0);
793 buf->action = popdown_scale_minimap_dlg_callback;
794 set_wstate(buf, FC_WS_NORMAL);
795 scale_minimap_dlg->begin_widget_list = buf;
796 add_to_gui_list(ID_BUTTON, buf);
797 area.h += buf->size.h + adj_size(10);
798 area.w = MAX(area.w, buf->size.w + adj_size(20));
799 /* ------------ */
800
801 area.h += adj_size(20);
802
803 resize_window(pwindow, NULL, get_theme_color(COLOR_THEME_BACKGROUND),
804 (pwindow->size.w - pwindow->area.w) + area.w,
805 (pwindow->size.h - pwindow->area.h) + area.h);
806
807 area = pwindow->area;
808
809 if (main_data.event.motion.x + pwindow->size.w > main_window_width()) {
810 if (main_data.event.motion.x - pwindow->size.w >= 0) {
811 window_x = main_data.event.motion.x - pwindow->size.w;
812 } else {
813 window_x = (main_window_width() - pwindow->size. w) / 2;
814 }
815 } else {
816 window_x = main_data.event.motion.x;
817 }
818
819 if (main_data.event.motion.y + pwindow->size.h >= main_data.screen->h) {
820 if (main_data.event.motion.y - pwindow->size.h >= 0) {
821 window_y = main_data.event.motion.y - pwindow->size.h;
822 } else {
823 window_y = (main_data.screen->h - pwindow->size.h) / 2;
824 }
825 } else {
826 window_y = main_data.event.motion.y;
827 }
828
829 widget_set_position(pwindow, window_x, window_y);
830
831 blit_entire_src(text1, pwindow->theme, 15, area.y + 1);
832 FREESURFACE(text1);
833
834 /* width label */
835 buf = pwindow->prev->prev;
836 buf->size.y = area.y + adj_size(16);
837 buf->size.x = area.x + (area.w - buf->size.w) / 2;
838
839 /* width left button */
840 buf->next->size.y = buf->size.y + buf->size.h - buf->next->size.h;
841 buf->next->size.x = buf->size.x - buf->next->size.w;
842
843 /* width right button */
844 buf->prev->size.y = buf->size.y + buf->size.h - buf->prev->size.h;
845 buf->prev->size.x = buf->size.x + buf->size.w;
846
847 /* height label */
848 buf = buf->prev->prev->prev;
849 buf->size.y = buf->next->next->next->size.y + buf->next->next->next->size.h + adj_size(20);
850 buf->size.x = area.x + (area.w - buf->size.w) / 2;
851
852 blit_entire_src(text2, pwindow->theme, adj_size(15), buf->size.y - text2->h - adj_size(2));
853 FREESURFACE(text2);
854
855 /* height left button */
856 buf->next->size.y = buf->size.y + buf->size.h - buf->next->size.h;
857 buf->next->size.x = buf->size.x - buf->next->size.w;
858
859 /* height right button */
860 buf->prev->size.y = buf->size.y + buf->size.h - buf->prev->size.h;
861 buf->prev->size.x = buf->size.x + buf->size.w;
862
863 /* exit button */
864 buf = buf->prev->prev;
865 buf->size.x = area.x + (area.w - buf->size.w) / 2;
866 buf->size.y = area.y + area.h - buf->size.h - adj_size(7);
867
868 /* -------------------- */
869 redraw_group(scale_minimap_dlg->begin_widget_list, pwindow, 0);
870 widget_flush(pwindow);
871}
872#endif /* SCALE_MINIMAP */
873
874/* ==================================================================== */
875#ifdef SCALE_UNITINFO
876
877/**********************************************************************/
880static int move_scale_unitinfo_dlg_callback(struct widget *pwindow)
881{
882 if (PRESSED_EVENT(main_data.event)) {
883 move_window_group(scale_unit_info_dlg->begin_widget_list, pwindow);
884 }
885
886 return -1;
887}
888
889/**********************************************************************/
892static int popdown_scale_unitinfo_dlg_callback(struct widget *pwidget)
893{
894 if (PRESSED_EVENT(main_data.event)) {
895 if (scale_unit_info_dlg) {
896 popdown_window_group_dialog(scale_unit_info_dlg->begin_widget_list,
897 scale_unit_info_dlg->end_widget_list);
898 FC_FREE(scale_unit_info_dlg);
899 if (pwidget) {
900 flush_dirty();
901 }
902 }
903 }
904
905 return -1;
906}
907
908/**********************************************************************/
911static void remake_unitinfo(int w, int h)
912{
913 SDL_Color bg_color = {255, 255, 255, 128};
914 SDL_Surface *surf;
915 SDL_Rect area = {units_info_window->area.x + BLOCKU_W,
916 units_info_window->area.y, 0, 0};
917 struct widget *pwidget = units_info_window;
918
919 if (w < DEFAULT_UNITS_W - BLOCKU_W) {
920 w = (units_info_window->size.w - units_info_window->area.w) + DEFAULT_UNITS_W;
921 } else {
922 w += (units_info_window->size.w - units_info_window->area.w) + BLOCKU_W;
923 }
924
925 if (h < DEFAULT_UNITS_H) {
926 h = (units_info_window->size.h - units_info_window->area.h) + DEFAULT_UNITS_H;
927 } else {
928 h += (units_info_window->size.h - units_info_window->area.h);
929 }
930
931 /* clear area under old map window */
932 clear_surface(pwidget->dst->surface, &pwidget->size);
933 widget_mark_dirty(pwidget);
934
935 pwidget->size.w = w;
936 pwidget->size.h = h;
937
938 pwidget->size.x = main_window_width() - w;
939 pwidget->size.y = main_window_height() - h;
940
941 FREESURFACE(pwidget->theme);
942 pwidget->theme = create_surf(w, h, SDL_SWSURFACE);
943
944 draw_frame(pwidget->theme, 0, 0, pwidget->size.w, pwidget->size.h);
945
946 surf = resize_surface(current_theme->Block, BLOCKU_W,
947 pwidget->size.h - ((units_info_window->size.h - units_info_window->area.h)), 1);
948
949 blit_entire_src(surf, pwidget->theme, units_info_window->area.x,
950 units_info_window->area.y);
951 FREESURFACE(surf);
952
953 area.w = w - BLOCKU_W - (units_info_window->size.w - units_info_window->area.w);
954 area.h = h - (units_info_window->size.h - units_info_window->area.h);
955 SDL_FillRect(pwidget->theme, &area, map_rgba(pwidget->theme->format, bg_color));
956
957 /* economy button */
958 pwidget = tax_button;
959 FREESURFACE(pwidget->gfx);
960 pwidget->size.x = pwidget->dst->surface->w - w + units_info_window->area.x
961 + (BLOCKU_W - pwidget->size.w) / 2;
962 pwidget->size.y = pwidget->dst->surface->h - h + pwidget->area.y + 2;
963
964 /* research button */
965 pwidget = pwidget->prev;
966 FREESURFACE(pwidget->gfx);
967 pwidget->size.x = pwidget->dst->surface->w - w + units_info_window->area.x
968 + (BLOCKU_W - pwidget->size.w) / 2;
969 pwidget->size.y = pwidget->dst->surface->h - h + units_info_window->area.y +
970 pwidget->size.h + 2;
971
972 /* revolution button */
973 pwidget = pwidget->prev;
974 FREESURFACE(pwidget->gfx);
975 pwidget->size.x = pwidget->dst->surface->w - w + units_info_window->area.x
976 + (BLOCKU_W - pwidget->size.w) / 2;
977 pwidget->size.y = pwidget->dst->surface->h - h + units_info_window->area.y +
978 pwidget->size.h * 2 + 2;
979
980 /* show/hide unit's window button */
981 pwidget = pwidget->prev;
982 FREESURFACE(pwidget->gfx);
983 pwidget->size.x = pwidget->dst->surface->w - w + units_info_window->area.x
984 + (BLOCKU_W - pwidget->size.w) / 2;
985 pwidget->size.y = units_info_window->area.y + units_info_window->area.h -
986 pwidget->size.h - 2;
987
988 unitinfo_w = w;
989 unitinfo_h = h;
990}
991
992/**********************************************************************/
995int resize_unit_info(void)
996{
997 struct widget *info_window = get_unit_info_window_widget();
998 int w = info_width * map.xsize;
999 int h = info_height * map.ysize;
1000 int current_w = units_info_window->size.w - BLOCKU_W -
1001 (info_window->size.w - info_window->area.w);
1002 int current_h = units_info_window->size.h -
1003 (info_window->size.h - info_window->area.h);
1004
1005 if ((((current_w > DEFAULT_UNITS_W - BLOCKU_W)
1006 || (w > DEFAULT_UNITS_W - BLOCKU_W)) && (current_w != w))
1007 || (((current_h > DEFAULT_UNITS_H) || (h > DEFAULT_UNITS_H)) && (current_h != h))) {
1008 remake_unitinfo(w, h);
1009 }
1010
1011 if (C_S_RUNNING == client_state()) {
1012 menus_update();
1013 }
1014 update_unit_info_label(get_units_in_focus());
1015
1016 return 0;
1017}
1018
1019/**********************************************************************/
1022static int up_info_width_callback(struct widget *pwidget)
1023{
1024 if (PRESSED_EVENT(main_data.event)) {
1025 widget_redraw(pwidget);
1026 widget_mark_dirty(pwidget);
1027 if (main_window_width() - ((info_width + 1) * map.xsize + BLOCKU_W +
1028 (minimap_window->size.w - minimap_window->area.w)) >=
1029 minimap_window->size.x + minimap_window->size.w) {
1030 info_width++;
1031 resize_unit_info();
1032 }
1033 flush_dirty();
1034 }
1035
1036 return -1;
1037}
1038
1039/**********************************************************************/
1042static int down_info_width_callback(struct widget *pwidget)
1043{
1044 if (PRESSED_EVENT(main_data.event)) {
1045 widget_redraw(pwidget);
1046 widget_mark_dirty(pwidget);
1047 if (info_width > info_width_min) {
1048 info_width--;
1049 resize_unit_info();
1050 }
1051 flush_dirty();
1052 }
1053
1054 return -1;
1055}
1056
1057/**********************************************************************/
1060static int up_info_height_callback(struct widget *pwidget)
1061{
1062 if (PRESSED_EVENT(main_data.event)) {
1063 widget_redraw(pwidget);
1064 widget_mark_dirty(pwidget);
1065 if (main_data.screen->h - ((info_height + 1) * map.ysize +
1066 (units_info_window->size.h - units_info_window->area.h)) >= adj_size(40)) {
1067 info_height++;
1068 resize_unit_info();
1069 }
1070 flush_dirty();
1071 }
1072
1073 return -1;
1074}
1075
1076/**********************************************************************/
1079static int down_info_height_callback(struct widget *pwidget)
1080{
1081 if (PRESSED_EVENT(main_data.event)) {
1082 widget_redraw(pwidget);
1083 widget_mark_dirty(pwidget);
1084 if (info_height > info_height_min) {
1085 info_height--;
1086 resize_unit_info();
1087 }
1088 flush_dirty();
1089 }
1090
1091 return -1;
1092}
1093
1094/**********************************************************************/
1097static void popup_unitinfo_scale_dialog(void)
1098{
1099
1100#ifndef SCALE_UNITINFO
1101 return;
1102#endif /* SCALE_UNITINFO */
1103
1104 SDL_Surface *text1, *text2;
1105 utf8_str *pstr = NULL;
1106 struct widget *pwindow = NULL;
1107 struct widget *buf = NULL;
1108 int window_x = 0, window_y = 0;
1109 SDL_Rect area;
1110
1111 if (scale_unit_info_dlg || !(sdl2_client_flags & CF_UNITINFO_SHOWN)) {
1112 return;
1113 }
1114
1115 scale_unit_info_dlg = fc_calloc(1, sizeof(struct small_dialog));
1116
1117 /* Create window */
1118 pstr = create_utf8_from_char_fonto(_("Scale Unit Info"), FONTO_ATTENTION);
1119 pstr->style |= TTF_STYLE_BOLD;
1120 pwindow = create_window_skeleton(NULL, pstr, 0);
1121 pwindow->action = move_scale_unitinfo_dlg_callback;
1122 set_wstate(pwindow, FC_WS_NORMAL);
1123 add_to_gui_list(ID_WINDOW, pwindow);
1124 scale_unit_info_dlg->end_widget_list = pwindow;
1125
1126 area = pwindow->area;
1127
1128 pstr = create_utf8_from_char_fonto(_("Width"), FONTO_ATTENTION);
1129 text1 = create_text_surf_from_utf8(pstr);
1130 area.w = MAX(area.w, text1->w + adj_size(30));
1131 area.h += MAX(adj_size(20), text1->h + adj_size(4));
1132 copy_chars_to_utf8_str(pstr, _("Height"));
1133 text2 = create_text_surf_from_utf8(pstr);
1134 area.w = MAX(area.w, text2->w + adj_size(30));
1135 area.h += MAX(adj_size(20), text2->h + adj_size(4));
1136 FREEUTF8STR(pstr);
1137
1138 /* ----------------- */
1139 buf = create_themeicon_button(current_theme->l_arrow_icon, pwindow->dst,
1140 NULL, 0);
1141 buf->action = down_info_width_callback;
1142 set_wstate(buf, FC_WS_NORMAL);
1143 add_to_gui_list(ID_BUTTON, buf);
1144 area.h += buf->size.h;
1145
1146 buf = create_themeicon_button(current_theme->r_arrow_icon, pwindow->dst,
1147 NULL, 0);
1148 buf->action = up_info_width_callback;
1149 set_wstate(buf, FC_WS_NORMAL);
1150 add_to_gui_list(ID_BUTTON, buf);
1151
1152 /* ------------ */
1153 buf = create_themeicon_button(current_theme->l_arrow_icon, pwindow->dst,
1154 NULL, 0);
1155 buf->action = down_info_height_callback;
1156 set_wstate(buf, FC_WS_NORMAL);
1157 add_to_gui_list(ID_BUTTON, buf);
1158 area.h += buf->size.h + adj_size(10);
1159
1160 buf = create_themeicon_button(current_theme->r_arrow_icon, pwindow->dst,
1161 NULL, 0);
1162 buf->action = up_info_height_callback;
1163 set_wstate(buf, FC_WS_NORMAL);
1164 add_to_gui_list(ID_BUTTON, buf);
1165 area.w = MAX(area.w , buf->size.w * 2 + adj_size(20));
1166
1167 /* ------------ */
1168 pstr = create_utf8_from_char_fonto(_("Exit"), FONTO_ATTENTION);
1169 buf = create_themeicon_button(current_theme->cancel_icon,
1170 pwindow->dst, pstr, 0);
1171 buf->action = popdown_scale_unitinfo_dlg_callback;
1172 set_wstate(buf, FC_WS_NORMAL);
1173 scale_unit_info_dlg->begin_widget_list = buf;
1174 add_to_gui_list(ID_BUTTON, buf);
1175 area.h += buf->size.h + adj_size(10);
1176 area.w = MAX(area.w, buf->size.w + adj_size(20));
1177
1178 resize_window(pwindow, NULL, get_theme_color(COLOR_THEME_BACKGROUND),
1179 (pwindow->size.w - pwindow->area.w) + area.w,
1180 (pwindow->size.h - pwindow->area.h) + area.h);
1181
1182 area = pwindow->area;
1183
1184 /* ------------ */
1185
1186 if (main_data.event.motion.x + pwindow->size.w > main_window_width()) {
1187 if (main_data.event.motion.x - pwindow->size.w >= 0) {
1188 window_x = main_data.event.motion.x - pwindow->size.w;
1189 } else {
1190 window_x = (main_window_width() - pwindow->size.w) / 2;
1191 }
1192 } else {
1193 window_x = main_data.event.motion.x;
1194 }
1195
1196 if (main_data.event.motion.y + pwindow->size.h >= main_data.screen->h) {
1197 if (main_data.event.motion.y - pwindow->size.h >= 0) {
1198 window_y = main_data.event.motion.y - pwindow->size.h;
1199 } else {
1200 window_y = (pwindow->dst->surface->h - pwindow->size.h) / 2;
1201 }
1202 } else {
1203 window_y = main_data.event.motion.y;
1204 }
1205
1206 widget_set_position(pwindow, window_x, window_y);
1207
1208 /* width left button */
1209 buf = pwindow->prev;
1210 buf->size.y = area.y + MAX(adj_size(20), text1->h + adj_size(4));
1211 buf->size.x = area.x + (area.w - buf->size.w * 2) / 2;
1212 blit_entire_src(text1, pwindow->theme, adj_size(15), buf->size.y
1213 - area.y - text1->h - adj_size(2));
1214 FREESURFACE(text1);
1215
1216 /* width right button */
1217 buf->prev->size.y = buf->size.y;
1218 buf->prev->size.x = buf->size.x + buf->size.w;
1219
1220 /* height left button */
1221 buf = buf->prev->prev;
1222 buf->size.y = buf->next->next->size.y +
1223 buf->next->next->size.h + MAX(adj_size(20), text2->h + adj_size(4));
1224 buf->size.x = area.x + (area.w - buf->size.w * 2) / 2;
1225
1226 blit_entire_src(text2, pwindow->theme, adj_size(15), buf->size.y - area.y - text2->h - adj_size(2));
1227 FREESURFACE(text2);
1228
1229 /* height right button */
1230 buf->prev->size.y = buf->size.y;
1231 buf->prev->size.x = buf->size.x + buf->size.w;
1232
1233 /* exit button */
1234 buf = buf->prev->prev;
1235 buf->size.x = area.x + (area.w - buf->size.w) / 2;
1236 buf->size.y = area.y + area.h - buf->size.h - adj_size(7);
1237
1238 if (!info_height) {
1239 info_width_min = (DEFAULT_UNITS_W - BLOCKU_W) / map.xsize;
1240 if (info_width_min == 1) {
1241 info_width_min = 0;
1242 }
1243 info_height_min = DEFAULT_UNITS_H / map.ysize;
1244 if (!info_height_min) {
1245 info_height_min = 1;
1246 }
1247 info_width = info_width_min;
1248 info_height = info_height_min;
1249 }
1250
1251 /* -------------------- */
1252 redraw_group(scale_unit_info_dlg->begin_widget_list, pwindow, 0);
1253 widget_flush(pwindow);
1254}
1255#endif /* SCALE_UNITINFO */
1256
1257/* ==================================================================== */
1258
1259/**********************************************************************/
1262 static int minimap_window_callback(struct widget *pwidget)
1263{
1264 int mouse_x, mouse_y;
1265
1266 switch (main_data.event.button.button) {
1267 case SDL_BUTTON_RIGHT:
1268 mouse_x = main_data.event.motion.x - minimap_window->dst->dest_rect.x -
1269 minimap_window->area.x - overview_start_x;
1270 mouse_y = main_data.event.motion.y - minimap_window->dst->dest_rect.y -
1271 minimap_window->area.y - overview_start_y;
1272 if ((sdl2_client_flags & CF_OVERVIEW_SHOWN)
1273 && (mouse_x >= 0) && (mouse_x < overview_w)
1274 && (mouse_y >= 0) && (mouse_y < overview_h)) {
1275 int map_x, map_y;
1276
1277 overview_to_map_pos(&map_x, &map_y, mouse_x, mouse_y);
1278 center_tile_mapcanvas(map_pos_to_tile(&(wld.map), map_x, map_y));
1279 }
1280
1281 break;
1282 case SDL_BUTTON_MIDDLE:
1283 /* FIXME: scaling needs to be fixed */
1284#ifdef SCALE_MINIMAP
1285 popup_minimap_scale_dialog();
1286#endif
1287 break;
1288 default:
1289 break;
1290 }
1291
1292 return -1;
1293}
1294
1295/**********************************************************************/
1298 static int unit_info_window_callback(struct widget *pwidget)
1299{
1300 if (main_data.event.type == SDL_MOUSEBUTTONDOWN) {
1301 switch (main_data.event.button.button) {
1302#if 0
1303 case SDL_BUTTON_LEFT:
1304
1305 break;
1306#endif
1307 case SDL_BUTTON_MIDDLE:
1308 request_center_focus_unit();
1309 break;
1310 case SDL_BUTTON_RIGHT:
1311#ifdef SCALE_UNITINFO
1312 popup_unitinfo_scale_dialog();
1313#endif
1314 break;
1315 default:
1316 key_unit_wait();
1317 break;
1318 }
1319 } else if (PRESSED_EVENT(main_data.event)) {
1320 key_unit_wait();
1321 }
1322
1323 return -1;
1324}
1325
1326/* ============================== Public =============================== */
1327
1328/**********************************************************************/
1332 void set_new_unitinfo_window_pos(void)
1333{
1334 struct widget *unit_window = units_info_window;
1335 struct widget *pwidget;
1336 SDL_Rect area;
1337
1338 if (sdl2_client_flags & CF_UNITINFO_SHOWN) {
1339 widget_set_position(units_info_window,
1340 main_window_width() - units_info_window->size.w,
1341 main_window_height() - units_info_window->size.h);
1342 } else {
1343 widget_set_position(unit_window,
1344 main_window_width() - BLOCKU_W - current_theme->fr_right->w,
1345 main_window_height() - units_info_window->size.h);
1346 }
1347
1348 area.x = units_info_window->area.x;
1349 area.y = units_info_window->area.y;
1350 area.w = BLOCKU_W;
1351 area.h = DEFAULT_UNITS_H;
1352
1353 /* ID_ECONOMY */
1354 pwidget = tax_button;
1355 widget_set_area(pwidget, area);
1356 widget_set_position(pwidget,
1357 area.x + (area.w - pwidget->size.w) / 2,
1358 area.y + 2);
1359
1360 /* ID_RESEARCH */
1361 pwidget = pwidget->prev;
1362 widget_set_area(pwidget, area);
1363 widget_set_position(pwidget,
1364 area.x + (area.w - pwidget->size.w) / 2,
1365 area.y + 2 + pwidget->size.h);
1366
1367 /* ID_REVOLUTION */
1368 pwidget = pwidget->prev;
1369 widget_set_area(pwidget, area);
1370 widget_set_position(pwidget,
1371 area.x + (area.w - pwidget->size.w) / 2,
1372 area.y + 2 + (pwidget->size.h * 2));
1373
1374 /* ID_TOGGLE_UNITS_WINDOW_BUTTON */
1375 pwidget = pwidget->prev;
1376 widget_set_area(pwidget, area);
1377 widget_set_position(pwidget,
1378 area.x + (area.w - pwidget->size.w) / 2,
1379 area.y + area.h - pwidget->size.h - 2);
1380}
1381
1382/**********************************************************************/
1386 void set_new_minimap_window_pos(void)
1387{
1388 struct widget *pwidget;
1389 SDL_Rect area;
1390
1391 widget_set_position(minimap_window, 0,
1392 main_window_height() - minimap_window->size.h);
1393
1394 area.x = minimap_window->size.w - current_theme->fr_right->w - BLOCKM_W;
1395 area.y = minimap_window->area.y;
1396 area.w = BLOCKM_W;
1397 area.h = minimap_window->area.h;
1398
1399 /* ID_NEW_TURN */
1400 pwidget = minimap_window->prev;
1401 widget_set_area(pwidget, area);
1402 widget_set_position(pwidget,
1403 area.x + adj_size(2) + pwidget->size.w,
1404 area.y + 2);
1405
1406 /* PLAYERS BUTTON */
1407 pwidget = pwidget->prev;
1408 widget_set_area(pwidget, area);
1409 widget_set_position(pwidget,
1410 area.x + adj_size(2) + pwidget->size.w,
1411 area.y + pwidget->size.h + 2);
1412
1413 /* ID_FIND_CITY */
1414 pwidget = pwidget->prev;
1415 widget_set_area(pwidget, area);
1416 widget_set_position(pwidget,
1417 area.x + adj_size(2) + pwidget->size.w,
1418 area.y + pwidget->size.h * 2 + 2);
1419
1420 /* UNITS BUTTON */
1421 pwidget = pwidget->prev;
1422 widget_set_area(pwidget, area);
1423 widget_set_position(pwidget,
1424 area.x + adj_size(2),
1425 area.y + 2);
1426
1427 /* ID_CHATLINE_TOGGLE_LOG_WINDOW_BUTTON */
1428 pwidget = pwidget->prev;
1429 widget_set_area(pwidget, area);
1430 widget_set_position(pwidget,
1431 area.x + adj_size(2),
1432 area.y + pwidget->size.h + 2);
1433
1434#ifdef GUI_SDL2_SMALL_SCREEN
1435 /* ID_TOGGLE_MAP_WINDOW_BUTTON */
1436 pwidget = pwidget->prev;
1437 widget_set_area(pwidget, area);
1438 widget_set_position(pwidget,
1439 area.x + adj_size(2),
1440 area.y + area.h - pwidget->size.h - 2);
1441#endif /* GUI_SDL2_SMALL_SCREEN */
1442
1443 /* ID_TOGGLE_MAP_WINDOW_BUTTON */
1444 pwidget = pwidget->prev;
1445 widget_set_area(pwidget, area);
1446 widget_set_position(pwidget,
1447 area.x + adj_size(2) + pwidget->size.w,
1448 area.y + area.h - pwidget->size.h - 2);
1449}
1450
1451/**********************************************************************/
1454 void popup_unitinfo_window(void)
1455{
1456 struct widget *pwidget, *pwindow;
1457 SDL_Surface *icon_theme = NULL;
1458 char buf[256];
1459
1460 if (unit_info_dlg) {
1461 return;
1462 }
1463
1464 unit_info_dlg = fc_calloc(1, sizeof(struct advanced_dialog));
1465
1466 /* units_info_window */
1467 pwindow = create_window_skeleton(NULL, NULL, 0);
1468
1469 resize_window(pwindow, NULL, NULL,
1470 (pwindow->size.w - pwindow->area.w) + DEFAULT_UNITS_W,
1471 (pwindow->size.h - pwindow->area.h) + DEFAULT_UNITS_H);
1472
1473 draw_frame(pwindow->theme, 0, 0, pwindow->size.w, pwindow->size.h);
1474
1475 unitinfo_w = pwindow->size.w;
1476 unitinfo_h = pwindow->size.h;
1477
1478 icon_theme = resize_surface(current_theme->block, pwindow->area.w,
1479 pwindow->area.h, 1);
1480
1481 blit_entire_src(icon_theme, pwindow->theme, pwindow->area.x, pwindow->area.y);
1482 FREESURFACE(icon_theme);
1483
1484 pwindow->action = unit_info_window_callback;
1485
1486 add_to_gui_list(ID_UNITS_WINDOW, pwindow);
1487
1488 units_info_window = pwindow;
1489
1490 unit_info_dlg->end_widget_list = units_info_window;
1491 units_info_window->private_data.adv_dlg = unit_info_dlg;
1492
1493 /* Economy button */
1494 pwidget = create_icon2(get_tax_surface(O_GOLD), units_info_window->dst,
1495 WF_FREE_GFX | WF_WIDGET_HAS_INFO_LABEL
1496 | WF_RESTORE_BACKGROUND | WF_FREE_THEME);
1497
1498 fc_snprintf(buf, sizeof(buf), "%s (%s)", _("Economy"), "F5");
1499 pwidget->info_label = create_utf8_from_char_fonto(buf, FONTO_ATTENTION);
1500 pwidget->action = economy_callback;
1501 pwidget->key = SDLK_F5;
1502
1503 add_to_gui_list(ID_ECONOMY, pwidget);
1504
1505 tax_button = pwidget;
1506
1507 /* research button */
1508 pwidget = create_icon2(adj_surf(GET_SURF(client_research_sprite())),
1509 units_info_window->dst,
1510 WF_FREE_GFX | WF_WIDGET_HAS_INFO_LABEL
1511 | WF_RESTORE_BACKGROUND | WF_FREE_THEME);
1512 /* TRANS: Research report action */
1513 fc_snprintf(buf, sizeof(buf), "%s (%s)", _("Research"), "F6");
1514 pwidget->info_label = create_utf8_from_char_fonto(buf, FONTO_ATTENTION);
1515 pwidget->action = research_callback;
1516 pwidget->key = SDLK_F6;
1517
1518 add_to_gui_list(ID_RESEARCH, pwidget);
1519
1520 research_button = pwidget;
1521
1522 /* Revolution button */
1523 pwidget = create_icon2(adj_surf(GET_SURF(client_government_sprite())),
1524 units_info_window->dst,
1525 WF_FREE_GFX | WF_WIDGET_HAS_INFO_LABEL
1526 | WF_RESTORE_BACKGROUND | WF_FREE_THEME);
1527 fc_snprintf(buf, sizeof(buf), "%s (%s)", _("Revolution"), "Ctrl+Shift+G");
1528 pwidget->info_label = create_utf8_from_char_fonto(buf, FONTO_ATTENTION);
1529 pwidget->action = revolution_callback;
1530 pwidget->key = SDLK_g;
1531 pwidget->mod = KMOD_CTRL | KMOD_SHIFT;
1532
1533 add_to_gui_list(ID_REVOLUTION, pwidget);
1534
1535 revolution_button = pwidget;
1536
1537 /* Show/hide unit's window button */
1538
1539 /* Make UNITS Icon */
1540 icon_theme = create_surf(current_theme->map_icon->w,
1541 current_theme->map_icon->h, SDL_SWSURFACE);
1542 alphablit(current_theme->map_icon, NULL, icon_theme, NULL, 255);
1543 alphablit(current_theme->r_arrow_icon, NULL, icon_theme, NULL, 255);
1544
1545 pwidget = create_themeicon(icon_theme, units_info_window->dst,
1546 WF_FREE_GFX | WF_FREE_THEME
1547 | WF_RESTORE_BACKGROUND
1548 | WF_WIDGET_HAS_INFO_LABEL);
1549 pwidget->info_label
1550 = create_utf8_from_char_fonto(_("Hide Unit Info Window"),
1551 FONTO_ATTENTION);
1552
1553 pwidget->action = toggle_unit_info_window_callback;
1554
1555 add_to_gui_list(ID_TOGGLE_UNITS_WINDOW_BUTTON, pwidget);
1556
1557 unit_info_dlg->begin_widget_list = pwidget;
1558
1559 sdl2_client_flags |= CF_UNITINFO_SHOWN;
1560
1561 set_new_unitinfo_window_pos();
1562
1563 widget_redraw(units_info_window);
1564}
1565
1566/**********************************************************************/
1569 void show_unitinfo_window_buttons(void)
1570{
1571 struct widget *pwidget = get_unit_info_window_widget();
1572
1573 /* economy button */
1574 pwidget = pwidget->prev;
1575 clear_wflag(pwidget, WF_HIDDEN);
1576
1577 /* research button */
1578 pwidget = pwidget->prev;
1579 clear_wflag(pwidget, WF_HIDDEN);
1580
1581 /* revolution button */
1582 pwidget = pwidget->prev;
1583 clear_wflag(pwidget, WF_HIDDEN);
1584
1585 /* show/hide unit's window button */
1586 pwidget = pwidget->prev;
1587 clear_wflag(pwidget, WF_HIDDEN);
1588}
1589
1590/**********************************************************************/
1593 void hide_unitinfo_window_buttons(void)
1594{
1595 struct widget *pwidget = get_unit_info_window_widget();
1596
1597 /* economy button */
1598 pwidget = pwidget->prev;
1599 set_wflag(pwidget, WF_HIDDEN);
1600
1601 /* research button */
1602 pwidget = pwidget->prev;
1603 set_wflag(pwidget, WF_HIDDEN);
1604
1605 /* revolution button */
1606 pwidget = pwidget->prev;
1607 set_wflag(pwidget, WF_HIDDEN);
1608
1609 /* show/hide unit's window button */
1610 pwidget = pwidget->prev;
1611 set_wflag(pwidget, WF_HIDDEN);
1612}
1613
1614/**********************************************************************/
1617 void disable_unitinfo_window_buttons(void)
1618{
1619 struct widget *pwidget = get_unit_info_window_widget();
1620
1621 /* economy button */
1622 pwidget = pwidget->prev;
1623 set_wstate(pwidget, FC_WS_DISABLED);
1624
1625 /* research button */
1626 pwidget = pwidget->prev;
1627 set_wstate(pwidget, FC_WS_DISABLED);
1628
1629 /* revolution button */
1630 pwidget = pwidget->prev;
1631 set_wstate(pwidget, FC_WS_DISABLED);
1632}
1633
1634/**********************************************************************/
1637 void popdown_unitinfo_window(void)
1638{
1639 if (unit_info_dlg) {
1640 popdown_window_group_dialog(unit_info_dlg->begin_widget_list,
1641 unit_info_dlg->end_widget_list);
1642 FC_FREE(unit_info_dlg);
1643 sdl2_client_flags &= ~CF_UNITINFO_SHOWN;
1644 }
1645}
1646
1647/**********************************************************************/
1650 void popup_minimap_window(void)
1651{
1652 struct widget *pwidget, *pwindow;
1653 SDL_Surface *icon_theme = NULL;
1654 SDL_Color black = {0, 0, 0, 255};
1655 char buf[256];
1656
1657 if (minimap_dlg) {
1658 return;
1659 }
1660
1661 minimap_dlg = fc_calloc(1, sizeof(struct advanced_dialog));
1662
1663 /* minimap_window */
1664 pwindow = create_window_skeleton(NULL, NULL, 0);
1665
1666 resize_window(pwindow, NULL, &black,
1667 (pwindow->size.w - pwindow->area.w) + overview_w + BLOCKM_W,
1668 (pwindow->size.h - pwindow->area.h) + overview_h);
1669
1670 draw_frame(pwindow->theme, 0, 0, pwindow->size.w, pwindow->size.h);
1671
1672 icon_theme = resize_surface(current_theme->block, BLOCKM_W,
1673 pwindow->area.h, 1);
1674 blit_entire_src(icon_theme, pwindow->theme,
1675 pwindow->area.x + pwindow->area.w - icon_theme->w,
1676 pwindow->area.y);
1677 FREESURFACE(icon_theme);
1678
1679 pwindow->action = minimap_window_callback;
1680
1681 add_to_gui_list(ID_MINI_MAP_WINDOW, pwindow);
1682
1683 minimap_window = pwindow;
1684 minimap_dlg->end_widget_list = minimap_window;
1685
1686 /* New turn button */
1687 pwidget = create_themeicon(current_theme->new_turn_icon, minimap_window->dst,
1688 WF_WIDGET_HAS_INFO_LABEL
1689 | WF_RESTORE_BACKGROUND);
1690 fc_snprintf(buf, sizeof(buf), "%s (%s)", _("Turn Done"), _("Shift+Return"));
1691 pwidget->info_label = create_utf8_from_char_fonto(buf, FONTO_ATTENTION);
1692 pwidget->action = end_turn_callback;
1693 pwidget->key = SDLK_RETURN;
1694 pwidget->mod = KMOD_SHIFT;
1695
1696 add_to_gui_list(ID_NEW_TURN, pwidget);
1697
1698 new_turn_button = pwidget;
1699
1700 /* players button */
1701 pwidget = create_themeicon(current_theme->players_icon, minimap_window->dst,
1702 WF_WIDGET_HAS_INFO_LABEL
1703 | WF_RESTORE_BACKGROUND);
1704 /* TRANS: Nations report action */
1705 fc_snprintf(buf, sizeof(buf), "%s (%s)", _("Nations"), "F3");
1706 pwidget->info_label = create_utf8_from_char_fonto(buf, FONTO_ATTENTION);
1707 pwidget->action = players_action_callback;
1708 pwidget->key = SDLK_F3;
1709
1710 add_to_gui_list(ID_PLAYERS, pwidget);
1711
1712 /* Find city button */
1713 pwidget = create_themeicon(current_theme->find_city_icon, minimap_window->dst,
1714 WF_WIDGET_HAS_INFO_LABEL
1715 | WF_RESTORE_BACKGROUND);
1716 fc_snprintf(buf, sizeof(buf), "%s (%s)\n%s\n%s (%s)", _("Cities Report"),
1717 "F4", _("or"), _("Find City"), "Ctrl+F");
1718 pwidget->info_label = create_utf8_from_char_fonto(buf, FONTO_ATTENTION);
1719 pwidget->info_label->style |= SF_CENTER;
1720 pwidget->action = cities_action_callback;
1721 pwidget->key = SDLK_f;
1722 pwidget->mod = KMOD_CTRL;
1723
1724 add_to_gui_list(ID_CITIES, pwidget);
1725
1726 find_city_button = pwidget;
1727
1728 /* Units button */
1729 pwidget = create_themeicon(current_theme->units2_icon, minimap_window->dst,
1730 WF_WIDGET_HAS_INFO_LABEL
1731 | WF_RESTORE_BACKGROUND);
1732 fc_snprintf(buf, sizeof(buf), "%s (%s)", _("Units"), "F2");
1733 pwidget->info_label = create_utf8_from_char_fonto(buf, FONTO_ATTENTION);
1734 pwidget->action = units_action_callback;
1735 pwidget->key = SDLK_F2;
1736
1737 add_to_gui_list(ID_UNITS, pwidget);
1738
1739 /* Show/hide log window button */
1740 pwidget = create_themeicon(current_theme->log_icon, minimap_window->dst,
1741 WF_WIDGET_HAS_INFO_LABEL
1742 | WF_RESTORE_BACKGROUND);
1743 fc_snprintf(buf, sizeof(buf), "%s (%s)", _("Hide Messages"), "F9");
1744 pwidget->info_label = create_utf8_from_char_fonto(buf, FONTO_ATTENTION);
1745 pwidget->action = toggle_msg_window_callback;
1746 pwidget->key = SDLK_F9;
1747
1748 add_to_gui_list(ID_CHATLINE_TOGGLE_LOG_WINDOW_BUTTON, pwidget);
1749
1750#ifdef GUI_SDL2_SMALL_SCREEN
1751 /* Options button */
1752 options_button = create_themeicon(current_theme->options_icon,
1753 minimap_window->dst,
1754 WF_WIDGET_HAS_INFO_LABEL
1755 | WF_RESTORE_BACKGROUND);
1756 fc_snprintf(buf, sizeof(buf), "%s (%s)", _("Options"), "Esc");
1757 options_button->info_label
1758 = create_utf8_from_char_fonto(buf, FONTO_ATTENTION);
1759
1760 options_button->action = optiondlg_callback;
1761 options_button->key = SDLK_ESCAPE;
1762
1763 add_to_gui_list(ID_CLIENT_OPTIONS, options_button);
1764#endif /* GUI_SDL2_SMALL_SCREEN */
1765
1766 /* show/hide minimap button */
1767
1768 /* make Map Icon */
1769 icon_theme = create_surf(current_theme->map_icon->w,
1770 current_theme->map_icon->h,
1771 SDL_SWSURFACE);
1772 alphablit(current_theme->map_icon, NULL, icon_theme, NULL, 255);
1773 alphablit(current_theme->l_arrow_icon, NULL, icon_theme, NULL, 255);
1774
1775 pwidget = create_themeicon(icon_theme, minimap_window->dst,
1776 WF_FREE_GFX | WF_FREE_THEME |
1777 WF_WIDGET_HAS_INFO_LABEL
1778 | WF_RESTORE_BACKGROUND);
1779
1780 pwidget->info_label = create_utf8_from_char_fonto(_("Hide Mini Map"),
1781 FONTO_ATTENTION);
1782 pwidget->action = toggle_map_window_callback;
1783
1784 add_to_gui_list(ID_TOGGLE_MAP_WINDOW_BUTTON, pwidget);
1785
1786 minimap_dlg->begin_widget_list = pwidget;
1787
1788 sdl2_client_flags |= CF_OVERVIEW_SHOWN;
1789
1790 set_new_minimap_window_pos();
1791
1792 widget_redraw(minimap_window);
1793}
1794
1795/**********************************************************************/
1798 void show_minimap_window_buttons(void)
1799{
1800 struct widget *pwidget = get_minimap_window_widget();
1801
1802 /* new turn button */
1803 pwidget = pwidget->prev;
1804 clear_wflag(pwidget, WF_HIDDEN);
1805
1806 /* players button */
1807 pwidget = pwidget->prev;
1808 clear_wflag(pwidget, WF_HIDDEN);
1809
1810 /* find city button */
1811 pwidget = pwidget->prev;
1812 clear_wflag(pwidget, WF_HIDDEN);
1813
1814 /* units button */
1815 pwidget = pwidget->prev;
1816 clear_wflag(pwidget, WF_HIDDEN);
1817
1818 /* show/hide log window button */
1819 pwidget = pwidget->prev;
1820 clear_wflag(pwidget, WF_HIDDEN);
1821
1822#ifdef GUI_SDL2_SMALL_SCREEN
1823 /* options button */
1824 pwidget = pwidget->prev;
1825 clear_wflag(pwidget, WF_HIDDEN);
1826#endif /* GUI_SDL2_SMALL_SCREEN */
1827
1828 /* show/hide minimap button */
1829 pwidget = pwidget->prev;
1830 clear_wflag(pwidget, WF_HIDDEN);
1831}
1832
1833/**********************************************************************/
1836 void hide_minimap_window_buttons(void)
1837{
1838 struct widget *pwidget = get_minimap_window_widget();
1839
1840 /* new turn button */
1841 pwidget = pwidget->prev;
1842 set_wflag(pwidget, WF_HIDDEN);
1843
1844 /* players button */
1845 pwidget = pwidget->prev;
1846 set_wflag(pwidget, WF_HIDDEN);
1847
1848 /* find city button */
1849 pwidget = pwidget->prev;
1850 set_wflag(pwidget, WF_HIDDEN);
1851
1852 /* units button */
1853 pwidget = pwidget->prev;
1854 set_wflag(pwidget, WF_HIDDEN);
1855
1856 /* show/hide log window button */
1857 pwidget = pwidget->prev;
1858 set_wflag(pwidget, WF_HIDDEN);
1859
1860#ifdef GUI_SDL2_SMALL_SCREEN
1861 /* options button */
1862 pwidget = pwidget->prev;
1863 set_wflag(pwidget, WF_HIDDEN);
1864#endif /* GUI_SDL2_SMALL_SCREEN */
1865
1866 /* show/hide minimap button */
1867 pwidget = pwidget->prev;
1868 set_wflag(pwidget, WF_HIDDEN);
1869}
1870
1871/**********************************************************************/
1874 void redraw_minimap_window_buttons(void)
1875{
1876 struct widget *pwidget = get_minimap_window_widget();
1877
1878 /* new turn button */
1879 pwidget = pwidget->prev;
1880 widget_redraw(pwidget);
1881
1882 /* players button */
1883 pwidget = pwidget->prev;
1884 widget_redraw(pwidget);
1885
1886 /* find city button */
1887 pwidget = pwidget->prev;
1888 widget_redraw(pwidget);
1889
1890 /* units button */
1891 pwidget = pwidget->prev;
1892 widget_redraw(pwidget);
1893 /* show/hide log window button */
1894 pwidget = pwidget->prev;
1895 widget_redraw(pwidget);
1896
1897#ifdef GUI_SDL2_SMALL_SCREEN
1898 /* options button */
1899 pwidget = pwidget->prev;
1900 widget_redraw(pwidget);
1901#endif /* GUI_SDL2_SMALL_SCREEN */
1902
1903 /* show/hide minimap button */
1904 pwidget = pwidget->prev;
1905 widget_redraw(pwidget);
1906}
1907
1908/**********************************************************************/
1911 void disable_minimap_window_buttons(void)
1912{
1913 struct widget *pwidget = get_minimap_window_widget();
1914
1915 /* new turn button */
1916 pwidget = pwidget->prev;
1917 set_wstate(pwidget, FC_WS_DISABLED);
1918
1919 /* players button */
1920 pwidget = pwidget->prev;
1921 set_wstate(pwidget, FC_WS_DISABLED);
1922
1923 /* find city button */
1924 pwidget = pwidget->prev;
1925 set_wstate(pwidget, FC_WS_DISABLED);
1926
1927 /* units button */
1928 pwidget = pwidget->prev;
1929 set_wstate(pwidget, FC_WS_DISABLED);
1930
1931 /* show/hide log window button */
1932 pwidget = pwidget->prev;
1933 set_wstate(pwidget, FC_WS_DISABLED);
1934
1935#ifdef GUI_SDL2_SMALL_SCREEN
1936 /* options button */
1937 pwidget = pwidget->prev;
1938 set_wstate(pwidget, FC_WS_DISABLED);
1939#endif /* GUI_SDL2_SMALL_SCREEN */
1940}
1941
1942/**********************************************************************/
1945 void popdown_minimap_window(void)
1946{
1947 if (minimap_dlg) {
1948 popdown_window_group_dialog(minimap_dlg->begin_widget_list,
1949 minimap_dlg->end_widget_list);
1950 FC_FREE(minimap_dlg);
1951 sdl2_client_flags &= ~CF_OVERVIEW_SHOWN;
1952 }
1953}
1954
1955/**********************************************************************/
1958 void show_game_page(void)
1959{
1960 struct widget *pwidget;
1961 SDL_Surface *icon_theme = NULL;
1962
1963 if (sdl2_client_flags & CF_MAP_UNIT_W_CREATED) {
1964 return;
1965 }
1966
1967 popup_minimap_window();
1968 popup_unitinfo_window();
1969 sdl2_client_flags |= CF_MAP_UNIT_W_CREATED;
1970
1971#ifndef GUI_SDL2_SMALL_SCREEN
1972 init_options_button();
1973#endif
1974
1975 /* cooling icon */
1976 icon_theme = adj_surf(GET_SURF(client_cooling_sprite()));
1977 fc_assert(icon_theme != NULL);
1978 pwidget = create_iconlabel(icon_theme, main_data.gui, NULL, WF_FREE_THEME);
1979
1980#ifdef GUI_SDL2_SMALL_SCREEN
1981 widget_set_position(pwidget,
1982 pwidget->dst->surface->w - pwidget->size.w - adj_size(10),
1983 0);
1984#else /* GUI_SDL2_SMALL_SCREEN */
1985 widget_set_position(pwidget,
1986 pwidget->dst->surface->w - pwidget->size.w - adj_size(10),
1987 adj_size(10));
1988#endif /* GUI_SDL2_SMALL_SCREEN */
1989
1990 add_to_gui_list(ID_COOLING_ICON, pwidget);
1991
1992 /* warming icon */
1993 icon_theme = adj_surf(GET_SURF(client_warming_sprite()));
1994 fc_assert(icon_theme != NULL);
1995
1996 pwidget = create_iconlabel(icon_theme, main_data.gui, NULL, WF_FREE_THEME);
1997
1998#ifdef GUI_SDL2_SMALL_SCREEN
1999 widget_set_position(pwidget,
2000 pwidget->dst->surface->w - pwidget->size.w * 2 - adj_size(10),
2001 0);
2002#else /* GUI_SDL2_SMALL_SCREEN */
2003 widget_set_position(pwidget,
2004 pwidget->dst->surface->w - pwidget->size.w * 2 - adj_size(10),
2005 adj_size(10));
2006#endif /* GUI_SDL2_SMALL_SCREEN */
2007
2008 add_to_gui_list(ID_WARMING_ICON, pwidget);
2009
2010 /* create order buttons */
2011 create_units_order_widgets();
2012
2013 /* enable options button and order widgets */
2014 enable_options_button();
2015 enable_order_buttons();
2016}
2017
2018/**********************************************************************/
2021 void close_game_page(void)
2022{
2023 struct widget *pwidget;
2024
2025 del_widget_from_gui_list(options_button);
2026
2027 pwidget = get_widget_pointer_from_main_list(ID_COOLING_ICON);
2028 del_widget_from_gui_list(pwidget);
2029
2030 pwidget = get_widget_pointer_from_main_list(ID_WARMING_ICON);
2031 del_widget_from_gui_list(pwidget);
2032
2033 delete_units_order_widgets();
2034
2035 popdown_minimap_window();
2036 popdown_unitinfo_window();
2037 sdl2_client_flags &= ~CF_MAP_UNIT_W_CREATED;
2038}
2039
2040/**********************************************************************/
2044 static void disable_minimap_widgets(void)
2045{
2046 struct widget *buf, *end;
2047
2048 buf = get_minimap_window_widget();
2049 set_wstate(buf, FC_WS_DISABLED);
2050
2051 /* new turn button */
2052 buf = buf->prev;
2053 end = buf;
2054 set_wstate(buf, FC_WS_DISABLED);
2055
2056 /* players button */
2057 buf = buf->prev;
2058 set_wstate(buf, FC_WS_DISABLED);
2059
2060 /* find city button */
2061 buf = buf->prev;
2062 set_wstate(buf, FC_WS_DISABLED);
2063
2064 /* units button */
2065 buf = buf->prev;
2066 set_wstate(buf, FC_WS_DISABLED);
2067
2068 /* show/hide log window button */
2069 buf = buf->prev;
2070 set_wstate(buf, FC_WS_DISABLED);
2071
2072#ifdef GUI_SDL2_SMALL_SCREEN
2073 /* options button */
2074 buf = buf->prev;
2075 set_wstate(buf, FC_WS_DISABLED);
2076#endif /* GUI_SDL2_SMALL_SCREEN */
2077
2078 /* show/hide minimap button */
2079 buf = buf->prev;
2080 set_wstate(buf, FC_WS_DISABLED);
2081
2082 redraw_group(buf, end, TRUE);
2083}
2084
2085/**********************************************************************/
2089 static void disable_unitinfo_widgets(void)
2090{
2091 struct widget *buf = units_info_window->private_data.adv_dlg->begin_widget_list;
2092 struct widget *end = units_info_window->private_data.adv_dlg->end_widget_list;
2093
2094 set_group_state(buf, end, FC_WS_DISABLED);
2095 end = end->prev;
2096 redraw_group(buf, end, TRUE);
2097}
2098
2099/**********************************************************************/
2102 void disable_main_widgets(void)
2103{
2104 if (C_S_RUNNING == client_state()) {
2105 disable_minimap_widgets();
2106 disable_unitinfo_widgets();
2107
2108 disable_options_button();
2109
2110 disable_order_buttons();
2111 }
2112}
2113
2114/**********************************************************************/
2117 static void enable_minimap_widgets(void)
2118{
2119 struct widget *buf, *end;
2120
2121 if (can_client_issue_orders()) {
2122 buf = minimap_window;
2123 set_wstate(buf, FC_WS_NORMAL);
2124
2125 /* new turn button */
2126 buf = buf->prev;
2127 end = buf;
2128 set_wstate(buf, FC_WS_NORMAL);
2129
2130 /* players button */
2131 buf = buf->prev;
2132 set_wstate(buf, FC_WS_NORMAL);
2133
2134 /* find city button */
2135 buf = buf->prev;
2136 set_wstate(buf, FC_WS_NORMAL);
2137
2138 /* units button */
2139 buf = buf->prev;
2140 set_wstate(buf, FC_WS_NORMAL);
2141
2142 /* show/hide log window button */
2143 buf = buf->prev;
2144 set_wstate(buf, FC_WS_NORMAL);
2145
2146#ifdef GUI_SDL2_SMALL_SCREEN
2147 /* options button */
2148 buf = buf->prev;
2149 set_wstate(buf, FC_WS_NORMAL);
2150#endif /* GUI_SDL2_SMALL_SCREEN */
2151
2152 /* show/hide minimap button */
2153 buf = buf->prev;
2154 set_wstate(buf, FC_WS_NORMAL);
2155
2156 redraw_group(buf, end, TRUE);
2157 }
2158}
2159
2160/**********************************************************************/
2163 static void enable_unitinfo_widgets(void)
2164{
2165 struct widget *buf, *end;
2166
2167 if (can_client_issue_orders()) {
2168 buf = units_info_window->private_data.adv_dlg->begin_widget_list;
2169 end = units_info_window->private_data.adv_dlg->end_widget_list;
2170
2171 set_group_state(buf, end, FC_WS_NORMAL);
2172 end = end->prev;
2173 redraw_group(buf, end, TRUE);
2174 }
2175}
2176
2177/**********************************************************************/
2180 void enable_main_widgets(void)
2181{
2182 if (C_S_RUNNING == client_state()) {
2183 enable_minimap_widgets();
2184 enable_unitinfo_widgets();
2185
2186 enable_options_button();
2187
2188 enable_order_buttons();
2189 }
2190}
2191
2192/**********************************************************************/
2195 struct widget *get_unit_info_window_widget(void)
2196{
2197 return units_info_window;
2198}
2199
2200/**********************************************************************/
2203 struct widget *get_minimap_window_widget(void)
2204{
2205 return minimap_window;
2206}
2207
2208/**********************************************************************/
2211 struct widget *get_tax_rates_widget(void)
2212{
2213 return tax_button;
2214}
2215
2216/**********************************************************************/
2219 struct widget *get_research_widget(void)
2220{
2221 return research_button;
2222}
2223
2224/**********************************************************************/
2227 struct widget *get_revolution_widget(void)
2228{
2229 return revolution_button;
2230}
2231
2232/**********************************************************************/
2235 void enable_and_redraw_find_city_button(void)
2236{
2237 set_wstate(find_city_button, FC_WS_NORMAL);
2238 widget_redraw(find_city_button);
2239 widget_mark_dirty(find_city_button);
2240}
2241
2242/**********************************************************************/
2245 void enable_and_redraw_revolution_button(void)
2246{
2247 set_wstate(revolution_button, FC_WS_NORMAL);
2248 widget_redraw(revolution_button);
2249 widget_mark_dirty(revolution_button);
2250}
2251/**********************************************************************/
2254 void finger_down_on_map(struct finger_behavior *finger_behavior)
2255{
2256 if (C_S_RUNNING != client_state()) {
2257 return;
2258 }
2259
2260 key_unit_goto();
2261 update_mouse_cursor(CURSOR_GOTO);
2262}
2263
2264/**********************************************************************/
2267 void finger_up_on_map(struct finger_behavior *finger_behavior)
2268{
2269 if (C_S_RUNNING != client_state()) {
2270 return;
2271 }
2272 update_mouse_cursor(CURSOR_DEFAULT);
2273 action_button_pressed(finger_behavior->event.x,
2274 finger_behavior->event.y, SELECT_POPUP);
2275}
2276
2277/**********************************************************************/
2280 void button_down_on_map(struct mouse_button_behavior *button_behavior)
2281{
2282 struct tile *ptile;
2283
2284 if (C_S_RUNNING != client_state()) {
2285 return;
2286 }
2287
2288 if (button_behavior->event->button == SDL_BUTTON_LEFT) {
2289 switch (button_behavior->hold_state) {
2290 case MB_HOLD_SHORT:
2291 break;
2292 case MB_HOLD_MEDIUM:
2293 /* switch to goto mode */
2294 key_unit_goto();
2295 update_mouse_cursor(CURSOR_GOTO);
2296 break;
2297 case MB_HOLD_LONG:
2298#ifdef UNDER_CE
2299 /* cancel goto mode and open context menu on Pocket PC since we have
2300 * only one 'mouse button' */
2301 key_cancel_action();
2302 draw_goto_patrol_lines = FALSE;
2303 update_mouse_cursor(CURSOR_DEFAULT);
2304 /* popup context menu */
2305 if ((ptile = canvas_pos_to_tile((int) button_behavior->event->x,
2306 (int) button_behavior->event->y,
2307 mouse_zoom))) {
2308 popup_advanced_terrain_dialog(ptile, button_behavior->event->x,
2309 button_behavior->event->y);
2310 }
2311#endif /* UNDER_CE */
2312 break;
2313 default:
2314 break;
2315 }
2316 } else if (button_behavior->event->button == SDL_BUTTON_MIDDLE) {
2317 switch (button_behavior->hold_state) {
2318 case MB_HOLD_SHORT:
2319 break;
2320 case MB_HOLD_MEDIUM:
2321 break;
2322 case MB_HOLD_LONG:
2323 break;
2324 default:
2325 break;
2326 }
2327 } else if (button_behavior->event->button == SDL_BUTTON_RIGHT) {
2328 switch (button_behavior->hold_state) {
2329 case MB_HOLD_SHORT:
2330 break;
2331 case MB_HOLD_MEDIUM:
2332 /* popup context menu */
2333 if ((ptile = canvas_pos_to_tile((int) button_behavior->event->x,
2334 (int) button_behavior->event->y,
2335 mouse_zoom))) {
2336 popup_advanced_terrain_dialog(ptile, button_behavior->event->x,
2337 button_behavior->event->y);
2338 }
2339 break;
2340 case MB_HOLD_LONG:
2341 break;
2342 default:
2343 break;
2344 }
2345 }
2346}
2347
2348/**********************************************************************/
2351 void button_up_on_map(struct mouse_button_behavior *button_behavior)
2352{
2353 struct tile *ptile;
2354 struct city *pcity;
2355
2356 if (C_S_RUNNING != client_state()) {
2357 return;
2358 }
2359
2360 draw_goto_patrol_lines = FALSE;
2361
2362 if (button_behavior->event->button == SDL_BUTTON_LEFT) {
2363 switch (button_behavior->hold_state) {
2364 case MB_HOLD_SHORT:
2365 if (LSHIFT || LALT || LCTRL) {
2366 if ((ptile = canvas_pos_to_tile((int) button_behavior->event->x,
2367 (int) button_behavior->event->y,
2368 mouse_zoom))) {
2369 if (LSHIFT) {
2370 popup_advanced_terrain_dialog(ptile, button_behavior->event->x,
2371 button_behavior->event->y);
2372 } else {
2373 if (((pcity = tile_city(ptile)) != NULL)
2374 && (city_owner(pcity) == client.conn.playing)) {
2375 if (LCTRL) {
2376 popup_worklist_editor(pcity, NULL);
2377 } else {
2378 /* LALT - this work only with fullscreen mode */
2379 popup_hurry_production_dialog(pcity, NULL);
2380 }
2381 }
2382 }
2383 }
2384 } else {
2385 update_mouse_cursor(CURSOR_DEFAULT);
2386 action_button_pressed(button_behavior->event->x,
2387 button_behavior->event->y, SELECT_POPUP);
2388 }
2389 break;
2390 case MB_HOLD_MEDIUM:
2391 /* finish goto */
2392 update_mouse_cursor(CURSOR_DEFAULT);
2393 action_button_pressed(button_behavior->event->x,
2394 button_behavior->event->y, SELECT_POPUP);
2395 break;
2396 case MB_HOLD_LONG:
2397#ifndef UNDER_CE
2398 /* finish goto */
2399 update_mouse_cursor(CURSOR_DEFAULT);
2400 action_button_pressed(button_behavior->event->x,
2401 button_behavior->event->y, SELECT_POPUP);
2402#endif /* UNDER_CE */
2403 break;
2404 default:
2405 break;
2406 }
2407 } else if (button_behavior->event->button == SDL_BUTTON_MIDDLE) {
2408 switch (button_behavior->hold_state) {
2409 case MB_HOLD_SHORT:
2410/* break;*/
2411 case MB_HOLD_MEDIUM:
2412/* break;*/
2413 case MB_HOLD_LONG:
2414/* break;*/
2415 default:
2416 /* Popup context menu */
2417 if ((ptile = canvas_pos_to_tile((int) button_behavior->event->x,
2418 (int) button_behavior->event->y,
2419 mouse_zoom))) {
2420 popup_advanced_terrain_dialog(ptile, button_behavior->event->x,
2421 button_behavior->event->y);
2422 }
2423 break;
2424 }
2425 } else if (button_behavior->event->button == SDL_BUTTON_RIGHT) {
2426 switch (button_behavior->hold_state) {
2427 case MB_HOLD_SHORT:
2428 /* recenter map */
2429 recenter_button_pressed(button_behavior->event->x, button_behavior->event->y);
2430 flush_dirty();
2431 break;
2432 case MB_HOLD_MEDIUM:
2433 break;
2434 case MB_HOLD_LONG:
2435 break;
2436 default:
2437 break;
2438 }
2439 }
2440}
2441
2442/**********************************************************************/
2445 bool map_event_handler(SDL_Keysym key)
2446{
2447 if (C_S_RUNNING == client_state()) {
2448 enum direction8 movedir = DIR8_MAGIC_MAX;
2449
2450 switch (key.scancode) {
2451
2452 case SDL_SCANCODE_KP_8:
2453 movedir = DIR8_NORTH;
2454 break;
2455
2456 case SDL_SCANCODE_KP_9:
2457 movedir = DIR8_NORTHEAST;
2458 break;
2459
2460 case SDL_SCANCODE_KP_6:
2461 movedir = DIR8_EAST;
2462 break;
2463
2464 case SDL_SCANCODE_KP_3:
2465 movedir = DIR8_SOUTHEAST;
2466 break;
2467
2468 case SDL_SCANCODE_KP_2:
2469 movedir = DIR8_SOUTH;
2470 break;
2471
2472 case SDL_SCANCODE_KP_1:
2473 movedir = DIR8_SOUTHWEST;
2474 break;
2475
2476 case SDL_SCANCODE_KP_4:
2477 movedir = DIR8_WEST;
2478 break;
2479
2480 case SDL_SCANCODE_KP_7:
2481 movedir = DIR8_NORTHWEST;
2482 break;
2483
2484 case SDL_SCANCODE_KP_5:
2485 key_recall_previous_focus_unit();
2486 return FALSE;
2487
2488 default:
2489 switch (key.sym) {
2490
2491 /* cancel action */
2492 case SDLK_ESCAPE:
2493 key_cancel_action();
2494 draw_goto_patrol_lines = FALSE;
2495 update_mouse_cursor(CURSOR_DEFAULT);
2496 return FALSE;
2497
2498 case SDLK_UP:
2499 movedir = DIR8_NORTH;
2500 break;
2501
2502 case SDLK_PAGEUP:
2503 movedir = DIR8_NORTHEAST;
2504 break;
2505
2506 case SDLK_RIGHT:
2507 movedir = DIR8_EAST;
2508 break;
2509
2510 case SDLK_PAGEDOWN:
2511 movedir = DIR8_SOUTHEAST;
2512 break;
2513
2514 case SDLK_DOWN:
2515 movedir = DIR8_SOUTH;
2516 break;
2517
2518 case SDLK_END:
2519 movedir = DIR8_SOUTHWEST;
2520 break;
2521
2522 case SDLK_LEFT:
2523 movedir = DIR8_WEST;
2524 break;
2525
2526 case SDLK_HOME:
2527 movedir = DIR8_NORTHWEST;
2528 break;
2529
2530 /* *** map view settings *** */
2531
2532 /* show city outlines - Ctrl+y */
2533 case SDLK_y:
2534 if (LCTRL || RCTRL) {
2535 key_city_outlines_toggle();
2536 }
2537 return FALSE;
2538
2539 /* Show map grid - Ctrl+g */
2540 case SDLK_g:
2541 if (LCTRL || RCTRL) {
2542 key_map_grid_toggle();
2543 }
2544 return FALSE;
2545
2546 /* Show national borders - Ctrl+b */
2547 case SDLK_b:
2548 if (LCTRL || RCTRL) {
2549 key_map_borders_toggle();
2550 }
2551 return FALSE;
2552
2553 case SDLK_n:
2554 /* Show native tiles - Ctrl+Shift+n */
2555 if ((LCTRL || RCTRL) && (LSHIFT || RSHIFT)) {
2556 key_map_native_toggle();
2557 } else if (LCTRL || RCTRL) {
2558 /* Show city names - Ctrl+n */
2559 key_city_names_toggle();
2560 }
2561 return FALSE;
2562
2563 /* Show city growth Ctrl+o */
2564 /* Show pollution - Ctrl+Shift+o */
2565 case SDLK_o:
2566 if (LCTRL || RCTRL) {
2567 if (LSHIFT || RSHIFT) {
2568 key_pollution_toggle();
2569 } else {
2570 key_city_growth_toggle();
2571 }
2572 }
2573 return FALSE;
2574
2575 /* Show bases - Ctrl+Shift+f */
2576 case SDLK_f:
2577 if ((LCTRL || RCTRL) && (LSHIFT || RSHIFT)) {
2578 request_toggle_bases();
2579 }
2580 return FALSE;
2581
2582 /* Show city productions - Ctrl+p */
2583 case SDLK_p:
2584 if (LCTRL || RCTRL) {
2585 key_city_productions_toggle();
2586 }
2587 return FALSE;
2588
2589 /* Show city trade routes - Ctrl+d */
2590 case SDLK_d:
2591 if (LCTRL || RCTRL) {
2592 key_city_trade_routes_toggle();
2593 }
2594 return FALSE;
2595
2596 /* *** Some additional shortcuts that work in the SDL client only *** */
2597
2598 /* Show terrain - Ctrl+Shift+t */
2599 case SDLK_t:
2600 if ((LCTRL || RCTRL) && (LSHIFT || RSHIFT)) {
2601 key_terrain_toggle();
2602 }
2603 return FALSE;
2604
2605 /* (Show coastline) */
2606
2607 /* (Show roads and rails) */
2608
2609 /* Show irrigation - Ctrl+i */
2610 case SDLK_i:
2611 if (LCTRL || RCTRL) {
2612 key_irrigation_toggle();
2613 }
2614 return FALSE;
2615
2616 /* Show mines - Ctrl+m */
2617 case SDLK_m:
2618 if (LCTRL || RCTRL) {
2619 key_mines_toggle();
2620 }
2621 return FALSE;
2622
2623 /* Show resources - Ctrl+s */
2624 case SDLK_s:
2625 if (LCTRL || RCTRL) {
2626 key_resources_toggle();
2627 }
2628 return FALSE;
2629
2630 /* Show huts - Ctrl+h */
2631 case SDLK_h:
2632 if (LCTRL || RCTRL) {
2633 key_huts_toggle();
2634 }
2635 return FALSE;
2636
2637 /* Show cities - Ctrl+c */
2638 case SDLK_c:
2639 if (LCTRL || RCTRL) {
2640 request_toggle_cities();
2641 } else {
2642 request_center_focus_unit();
2643 }
2644 return FALSE;
2645
2646 /* Show units - Ctrl+u */
2647 case SDLK_u:
2648 if (LCTRL || RCTRL) {
2649 key_units_toggle();
2650 }
2651 return FALSE;
2652
2653 /* (Show focus unit) */
2654
2655 /* Show city output - Ctrl+v */
2656 case SDLK_v:
2657 key_city_output_toggle();
2658 return FALSE;
2659
2660 /* Show fog of war - Ctrl+w */
2661 case SDLK_w:
2662 if (LCTRL || RCTRL) {
2663 key_fog_of_war_toggle();
2664 }
2665 return FALSE;
2666
2667 default:
2668 break;
2669 }
2670 }
2671
2672 if (movedir != DIR8_MAGIC_MAX) {
2673 if (!is_unit_move_blocked) {
2674 key_unit_move(movedir);
2675 }
2676 return FALSE;
2677 }
2678 }
2679
2680 return TRUE;
2681}
2682
2683/**********************************************************************/
2686 static int newcity_name_edit_callback(struct widget *pedit)
2687{
2688 if (PRESSED_EVENT(main_data.event)) {
2689 if (new_city_dlg->begin_widget_list->string_utf8->text == NULL) {
2690 /* empty input -> restore previous content */
2691 copy_chars_to_utf8_str(pedit->string_utf8, suggested_city_name);
2692 widget_redraw(pedit);
2693 widget_mark_dirty(pedit);
2694 flush_dirty();
2695 }
2696 }
2697
2698 return -1;
2699}
2700
2701/**********************************************************************/
2704 static int newcity_ok_callback(struct widget *ok_button)
2705{
2706 if (PRESSED_EVENT(main_data.event)) {
2707
2708 finish_city(ok_button->data.tile,
2709 new_city_dlg->begin_widget_list->string_utf8->text);
2710
2711 popdown_window_group_dialog(new_city_dlg->begin_widget_list,
2712 new_city_dlg->end_widget_list);
2713 FC_FREE(new_city_dlg);
2714
2715 FC_FREE(suggested_city_name);
2716
2717 flush_dirty();
2718 }
2719
2720 return -1;
2721}
2722
2723/**********************************************************************/
2726 static int newcity_cancel_callback(struct widget *cancel_button)
2727{
2728 if (PRESSED_EVENT(main_data.event)) {
2729 popdown_window_group_dialog(new_city_dlg->begin_widget_list,
2730 new_city_dlg->end_widget_list);
2731
2732 cancel_city(cancel_button->data.tile);
2733
2734 FC_FREE(new_city_dlg);
2735
2736 FC_FREE(suggested_city_name);
2737
2738 flush_dirty();
2739 }
2740
2741 return -1;
2742}
2743
2744/**********************************************************************/
2747 static int move_new_city_dlg_callback(struct widget *pwindow)
2748{
2749 if (PRESSED_EVENT(main_data.event)) {
2750 move_window_group(new_city_dlg->begin_widget_list, pwindow);
2751 }
2752
2753 return -1;
2754}
2755
2756/* ============================== Native =============================== */
2757
2758
2759/**********************************************************************/
2763 void popup_newcity_dialog(struct unit *punit, const char *suggest_name)
2764{
2765 SDL_Surface *background;
2766 utf8_str *pstr = NULL;
2767 struct widget *label = NULL;
2768 struct widget *pwindow = NULL;
2769 struct widget *cancel_button = NULL;
2770 struct widget *ok_button;
2771 struct widget *pedit;
2772 SDL_Rect area;
2773 int suggestlen;
2774
2775 if (new_city_dlg) {
2776 return;
2777 }
2778
2779 suggestlen = strlen(suggest_name) + 1;
2780 suggested_city_name = fc_calloc(1, suggestlen);
2781 fc_strlcpy(suggested_city_name, suggest_name, suggestlen);
2782
2783 new_city_dlg = fc_calloc(1, sizeof(struct small_dialog));
2784
2785 /* Create window */
2786 pstr = create_utf8_from_char_fonto(action_id_name_translation(ACTION_FOUND_CITY),
2787 FONTO_ATTENTION);
2788 pstr->style |= TTF_STYLE_BOLD;
2789 pwindow = create_window_skeleton(NULL, pstr, 0);
2790 pwindow->action = move_new_city_dlg_callback;
2791
2792 area = pwindow->area;
2793
2794 /* Create ok button */
2795 ok_button =
2796 create_themeicon_button_from_chars_fonto(current_theme->small_ok_icon,
2797 pwindow->dst,
2798 _("OK"), FONTO_DEFAULT, 0);
2799 ok_button->action = newcity_ok_callback;
2800 ok_button->key = SDLK_RETURN;
2801 ok_button->data.tile = unit_tile(punit);
2802
2803 area.h += ok_button->size.h;
2804
2805 /* Create cancel button */
2806 cancel_button =
2807 create_themeicon_button_from_chars_fonto(current_theme->small_cancel_icon,
2808 pwindow->dst, _("Cancel"),
2809 FONTO_DEFAULT, 0);
2810 cancel_button->action = newcity_cancel_callback;
2811 cancel_button->key = SDLK_ESCAPE;
2812 cancel_button->data.tile = unit_tile(punit);
2813
2814 /* Correct sizes */
2815 cancel_button->size.w += adj_size(5);
2816 ok_button->size.w = cancel_button->size.w;
2817
2818 /* Create text label */
2819 pstr = create_utf8_from_char_fonto(_("What should we call our new city?"),
2820 FONTO_DEFAULT);
2821 pstr->style |= (TTF_STYLE_BOLD|SF_CENTER);
2822 pstr->fgcol = *get_theme_color(COLOR_THEME_NEWCITYDLG_TEXT);
2823 label = create_iconlabel(NULL, pwindow->dst, pstr,
2824 WF_DRAW_TEXT_LABEL_WITH_SPACE);
2825
2826 area.h += label->size.h;
2827
2828 pedit = create_edit(NULL, pwindow->dst,
2829 create_utf8_from_char_fonto(suggest_name, FONTO_ATTENTION),
2830 (ok_button->size.w + cancel_button->size.w + adj_size(15)),
2831 WF_RESTORE_BACKGROUND);
2832 pedit->action = newcity_name_edit_callback;
2833
2834 area.w = MAX(area.w, pedit->size.w + adj_size(20));
2835 area.h += pedit->size.h + adj_size(25);
2836
2837 /* I make this hack to center label on window */
2838 if (label->size.w < area.w) {
2839 label->size.w = area.w;
2840 } else {
2841 area.w = MAX(pwindow->area.w, label->size.w + adj_size(10));
2842 }
2843
2844 pedit->size.w = area.w - adj_size(20);
2845
2846 /* Create window background */
2847 background = theme_get_background(active_theme, BACKGROUND_NEWCITYDLG);
2848 if (resize_window(pwindow, background, NULL,
2849 (pwindow->size.w - pwindow->area.w) + area.w,
2850 (pwindow->size.h - pwindow->area.h) + area.h)) {
2851 FREESURFACE(background);
2852 }
2853
2854 area = pwindow->area;
2855
2856 /* set start positions */
2857 widget_set_position(pwindow,
2858 (main_window_width() - pwindow->size.w) / 2,
2859 (main_window_height() - pwindow->size.h) / 2);
2860
2861 ok_button->size.x = area.x + adj_size(10);
2862 ok_button->size.y = area.y + area.h - ok_button->size.h - adj_size(10);
2863
2864 cancel_button->size.y = ok_button->size.y;
2865 cancel_button->size.x = area.x + area.w - cancel_button->size.w - adj_size(10);
2866
2867 pedit->size.x = area.x + adj_size(10);
2868 pedit->size.y = area.y + adj_size(4) + label->size.h + adj_size(3);
2869
2870 label->size.x = area.x + adj_size(3);
2871 label->size.y = area.y + adj_size(4);
2872
2873 /* enable widgets */
2874 set_wstate(cancel_button, FC_WS_NORMAL);
2875 set_wstate(ok_button, FC_WS_NORMAL);
2876 set_wstate(pedit, FC_WS_NORMAL);
2877 set_wstate(pwindow, FC_WS_NORMAL);
2878
2879 /* add widgets to main list */
2880 new_city_dlg->end_widget_list = pwindow;
2881 add_to_gui_list(ID_NEWCITY_NAME_WINDOW, pwindow);
2882 add_to_gui_list(ID_NEWCITY_NAME_LABEL, label);
2883 add_to_gui_list(ID_NEWCITY_NAME_CANCEL_BUTTON, cancel_button);
2884 add_to_gui_list(ID_NEWCITY_NAME_OK_BUTTON, ok_button);
2885 add_to_gui_list(ID_NEWCITY_NAME_EDIT, pedit);
2886 new_city_dlg->begin_widget_list = pedit;
2887
2888 /* redraw */
2889 redraw_group(pedit, pwindow, 0);
2890
2891 widget_flush(pwindow);
2892}
2893
2894/**********************************************************************/
2897 void popdown_newcity_dialog(void)
2898{
2899 if (new_city_dlg) {
2900 popdown_window_group_dialog(new_city_dlg->begin_widget_list,
2901 new_city_dlg->end_widget_list);
2902 FC_FREE(new_city_dlg);
2903 flush_dirty();
2904 }
2905}
2906
2907/**********************************************************************/
2911 void set_turn_done_button_state(bool state)
2912{
2913 if (PAGE_GAME == get_current_client_page()
2914 && !update_queue_is_switching_page()) {
2915 if (state) {
2916 set_wstate(new_turn_button, FC_WS_NORMAL);
2917 } else {
2918 set_wstate(new_turn_button, FC_WS_DISABLED);
2919 }
2920 widget_redraw(new_turn_button);
2921 widget_flush(new_turn_button);
2922 redraw_unit_info_label(get_units_in_focus());
2923 }
2924}
2925
2926/**********************************************************************/
2929 void create_line_at_mouse_pos(void)
2930{
2931 int pos_x, pos_y;
2932
2933 SDL_GetMouseState(&pos_x, &pos_y);
2934 update_line(pos_x, pos_y);
2935 draw_goto_patrol_lines = TRUE;
2936}
2937
2938/**********************************************************************/
2942 void update_rect_at_mouse_pos(void)
2943{
2944 /* PORTME */
2945}
action_id_name_translation
const char * action_id_name_translation(action_id act_id)
Definition actions.c:1225
city_owner
#define city_owner(_pcity_)
Definition city.h:563
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
client_warming_sprite
struct sprite * client_warming_sprite(void)
Definition climisc.c:377
client_cooling_sprite
struct sprite * client_cooling_sprite(void)
Definition climisc.c:394
client_research_sprite
struct sprite * client_research_sprite(void)
Definition climisc.c:354
client_government_sprite
struct sprite * client_government_sprite(void)
Definition climisc.c:412
climisc.h
incite_cost
char * incite_cost
Definition comments.c:74
key_irrigation_toggle
void key_irrigation_toggle(void)
Definition control.c:3941
key_recall_previous_focus_unit
void key_recall_previous_focus_unit(void)
Definition control.c:3293
key_city_output_toggle
void key_city_output_toggle(void)
Definition control.c:3826
key_cancel_action
void key_cancel_action(void)
Definition control.c:3231
key_map_native_toggle
void key_map_native_toggle(void)
Definition control.c:3850
key_resources_toggle
void key_resources_toggle(void)
Definition control.c:3965
get_units_in_focus
struct unit_list * get_units_in_focus(void)
Definition control.c:177
key_end_turn
void key_end_turn(void)
Definition control.c:3285
request_center_focus_unit
void request_center_focus_unit(void)
Definition control.c:2723
key_city_productions_toggle
void key_city_productions_toggle(void)
Definition control.c:3892
key_unit_move
void key_unit_move(enum direction8 gui_dir)
Definition control.c:3314
key_city_outlines_toggle
void key_city_outlines_toggle(void)
Definition control.c:3818
key_terrain_toggle
void key_terrain_toggle(void)
Definition control.c:3917
key_huts_toggle
void key_huts_toggle(void)
Definition control.c:3973
key_fog_of_war_toggle
void key_fog_of_war_toggle(void)
Definition control.c:4029
key_unit_wait
void key_unit_wait(void)
Definition control.c:3515
key_units_toggle
void key_units_toggle(void)
Definition control.c:3997
request_toggle_bases
void request_toggle_bases(void)
Definition control.c:2592
key_map_grid_toggle
void key_map_grid_toggle(void)
Definition control.c:3834
finish_city
void finish_city(struct tile *ptile, const char *name)
Definition control.c:4064
key_pollution_toggle
void key_pollution_toggle(void)
Definition control.c:3981
head_of_units_in_focus
struct unit * head_of_units_in_focus(void)
Definition control.c:405
key_city_growth_toggle
void key_city_growth_toggle(void)
Definition control.c:3875
get_num_units_in_focus
int get_num_units_in_focus(void)
Definition control.c:185
key_city_trade_routes_toggle
void key_city_trade_routes_toggle(void)
Definition control.c:3901
key_city_names_toggle
void key_city_names_toggle(void)
Definition control.c:3866
key_unit_goto
void key_unit_goto(void)
Definition control.c:3444
request_toggle_cities
void request_toggle_cities(void)
Definition control.c:2644
cancel_city
void cancel_city(struct tile *ptile)
Definition control.c:4083
key_mines_toggle
void key_mines_toggle(void)
Definition control.c:3949
key_map_borders_toggle
void key_map_borders_toggle(void)
Definition control.c:3842
SELECT_POPUP
@ SELECT_POPUP
Definition control.h:38
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
current_theme
QString current_theme
Definition fc_client.cpp:64
DIR8_MAGIC_MAX
#define DIR8_MAGIC_MAX
Definition fc_types.h:473
O_GOLD
@ O_GOLD
Definition fc_types.h:101
fcintl.h
_
#define _(String)
Definition fcintl.h:67
wld
struct world wld
Definition game.c:62
city_report_dialog_popup
void city_report_dialog_popup(bool raise)
Definition cityrep.c:292
popup_find_dialog
void popup_find_dialog(void)
Definition finddlg.c:58
popup_newcity_dialog
void popup_newcity_dialog(struct unit *punit, const char *suggestname)
Definition mapctrl.c:197
create_line_at_mouse_pos
void create_line_at_mouse_pos(void)
Definition mapctrl.c:355
set_turn_done_button_state
void set_turn_done_button_state(bool state)
Definition mapctrl.c:210
update_rect_at_mouse_pos
void update_rect_at_mouse_pos(void)
Definition mapctrl.c:380
flush_dirty
void flush_dirty(void)
Definition mapview.c:468
update_unit_info_label
void update_unit_info_label(struct unit_list *punits)
Definition mapview.c:275
update_mouse_cursor
void update_mouse_cursor(enum cursor_type new_cursor_type)
Definition mapview.c:257
meswin_dialog_popdown
void meswin_dialog_popdown(void)
Definition messagewin.c:432
meswin_dialog_popup
void meswin_dialog_popup(bool raise)
Definition messagewin.c:417
meswin_dialog_is_open
bool meswin_dialog_is_open(void)
Definition messagewin.c:443
get_current_client_page
enum client_pages get_current_client_page(void)
Definition pages.c:3343
popup_players_dialog
void popup_players_dialog(bool raise)
Definition plrdlg.c:91
science_report_dialog_popup
void science_report_dialog_popup(bool raise)
Definition repodlgs.c:716
economy_report_dialog_popup
void economy_report_dialog_popup(bool raise)
Definition repodlgs.c:1243
units_report_dialog_popup
void units_report_dialog_popup(bool raise)
Definition repodlgs.c:1768
popup_hurry_production_dialog
void popup_hurry_production_dialog(struct city *pcity, SDL_Surface *pdest)
Definition citydlg.c:1173
get_theme_color
SDL_Color * get_theme_color(enum theme_color themecolor)
Definition colors.c:47
popup_government_dialog
void popup_government_dialog(void)
Definition dialogs.c:2452
popup_advanced_terrain_dialog
void popup_advanced_terrain_dialog(struct tile *ptile, Uint16 pos_x, Uint16 pos_y)
Definition dialogs.c:1697
resize_surface
SDL_Surface * resize_surface(const SDL_Surface *psrc, Uint16 new_width, Uint16 new_height, int smooth)
Definition graphics.c:1237
main_window_width
int main_window_width(void)
Definition graphics.c:685
alphablit
int alphablit(SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect, unsigned char alpha_mod)
Definition graphics.c:199
main_data
struct sdl2_data main_data
Definition graphics.c:57
blit_entire_src
int blit_entire_src(SDL_Surface *psrc, SDL_Surface *pdest, Sint16 dest_x, Sint16 dest_y)
Definition graphics.c:417
create_surf
SDL_Surface * create_surf(int width, int height, Uint32 flags)
Definition graphics.c:351
clear_surface
int clear_surface(SDL_Surface *surf, SDL_Rect *dstrect)
Definition graphics.c:400
main_window_height
int main_window_height(void)
Definition graphics.c:693
FREESURFACE
#define FREESURFACE(ptr)
Definition graphics.h:322
adj_surf
#define adj_surf(surf)
Definition graphics.h:200
map_rgba
#define map_rgba(format, color)
Definition graphics.h:315
ID_REVOLUTION
@ ID_REVOLUTION
Definition gui_id.h:132
ID_CHATLINE_TOGGLE_LOG_WINDOW_BUTTON
@ ID_CHATLINE_TOGGLE_LOG_WINDOW_BUTTON
Definition gui_id.h:58
ID_NEWCITY_NAME_OK_BUTTON
@ ID_NEWCITY_NAME_OK_BUTTON
Definition gui_id.h:126
ID_COOLING_ICON
@ ID_COOLING_ICON
Definition gui_id.h:138
ID_NEWCITY_NAME_WINDOW
@ ID_NEWCITY_NAME_WINDOW
Definition gui_id.h:124
ID_CLIENT_OPTIONS
@ ID_CLIENT_OPTIONS
Definition gui_id.h:38
ID_UNITS
@ ID_UNITS
Definition gui_id.h:131
ID_NEW_TURN
@ ID_NEW_TURN
Definition gui_id.h:137
ID_TOGGLE_MAP_WINDOW_BUTTON
@ ID_TOGGLE_MAP_WINDOW_BUTTON
Definition gui_id.h:85
ID_NEWCITY_NAME_CANCEL_BUTTON
@ ID_NEWCITY_NAME_CANCEL_BUTTON
Definition gui_id.h:127
ID_MINI_MAP_WINDOW
@ ID_MINI_MAP_WINDOW
Definition gui_id.h:84
ID_CITIES
@ ID_CITIES
Definition gui_id.h:129
ID_ECONOMY
@ ID_ECONOMY
Definition gui_id.h:133
ID_BUTTON
@ ID_BUTTON
Definition gui_id.h:29
ID_WARMING_ICON
@ ID_WARMING_ICON
Definition gui_id.h:139
ID_TOGGLE_UNITS_WINDOW_BUTTON
@ ID_TOGGLE_UNITS_WINDOW_BUTTON
Definition gui_id.h:83
ID_NEWCITY_NAME_LABEL
@ ID_NEWCITY_NAME_LABEL
Definition gui_id.h:128
ID_LABEL
@ ID_LABEL
Definition gui_id.h:27
ID_PLAYERS
@ ID_PLAYERS
Definition gui_id.h:130
ID_RESEARCH
@ ID_RESEARCH
Definition gui_id.h:136
ID_NEWCITY_NAME_EDIT
@ ID_NEWCITY_NAME_EDIT
Definition gui_id.h:125
ID_WINDOW
@ ID_WINDOW
Definition gui_id.h:30
ID_UNITS_WINDOW
@ ID_UNITS_WINDOW
Definition gui_id.h:82
button_behavior
static struct mouse_button_behavior button_behavior
Definition gui_main.c:130
LSHIFT
bool LSHIFT
Definition gui_main.c:108
RSHIFT
bool RSHIFT
Definition gui_main.c:109
LALT
bool LALT
Definition gui_main.c:112
LCTRL
bool LCTRL
Definition gui_main.c:110
disable_focus_animation
void disable_focus_animation(void)
Definition gui_main.c:1209
sdl2_client_flags
Uint32 sdl2_client_flags
Definition gui_main.c:101
RCTRL
bool RCTRL
Definition gui_main.c:111
CF_MAP_UNIT_W_CREATED
#define CF_MAP_UNIT_W_CREATED
Definition gui_main.h:46
MB_HOLD_LONG
@ MB_HOLD_LONG
Definition gui_main.h:80
MB_HOLD_MEDIUM
@ MB_HOLD_MEDIUM
Definition gui_main.h:79
MB_HOLD_SHORT
@ MB_HOLD_SHORT
Definition gui_main.h:78
selected_widget
struct widget * selected_widget
Definition widget.c:48
CF_OVERVIEW_SHOWN
#define CF_OVERVIEW_SHOWN
Definition gui_main.h:48
adj_size
#define adj_size(size)
Definition gui_main.h:141
PRESSED_EVENT
#define PRESSED_EVENT(event)
Definition gui_main.h:71
CF_UNITINFO_SHOWN
#define CF_UNITINFO_SHOWN
Definition gui_main.h:47
copy_chars_to_utf8_str
utf8_str * copy_chars_to_utf8_str(utf8_str *pstr, const char *pchars)
Definition gui_string.c:251
create_text_surf_from_utf8
SDL_Surface * create_text_surf_from_utf8(utf8_str *pstr)
Definition gui_string.c:425
FREEUTF8STR
#define FREEUTF8STR(pstr)
Definition gui_string.h:93
SF_CENTER
#define SF_CENTER
Definition gui_string.h:40
FONTO_DEFAULT
@ FONTO_DEFAULT
Definition gui_string.h:65
FONTO_ATTENTION
@ FONTO_ATTENTION
Definition gui_string.h:67
FONTO_MAX
@ FONTO_MAX
Definition gui_string.h:71
create_utf8_from_char_fonto
#define create_utf8_from_char_fonto(string_in, fonto)
Definition gui_string.h:108
get_tax_surface
static SDL_Surface * get_tax_surface(Output_type_id otype)
Definition gui_tilespec.h:269
options_button
struct widget * options_button
Definition optiondlg.c:103
popdown_newcity_dialog
void popdown_newcity_dialog(void)
Definition mapctrl.c:2897
get_minimap_window_widget
struct widget * get_minimap_window_widget(void)
Definition mapctrl.c:2203
minimap_window
static struct widget * minimap_window
Definition mapctrl.c:107
unitinfo_h
int unitinfo_h
Definition mapctrl.c:102
toggle_unit_info_window_callback
static int toggle_unit_info_window_callback(struct widget *icon_widget)
Definition mapctrl.c:261
unit_info_window_callback
static int unit_info_window_callback(struct widget *pwidget)
Definition mapctrl.c:1298
toggle_map_window_callback
static int toggle_map_window_callback(struct widget *map_button)
Definition mapctrl.c:391
button_down_on_map
void button_down_on_map(struct mouse_button_behavior *button_behavior)
Definition mapctrl.c:2280
get_research_widget
struct widget * get_research_widget(void)
Definition mapctrl.c:2219
overview_w
int overview_w
Definition mapctrl.c:99
button_up_on_map
void button_up_on_map(struct mouse_button_behavior *button_behavior)
Definition mapctrl.c:2351
enable_minimap_widgets
static void enable_minimap_widgets(void)
Definition mapctrl.c:2117
enable_main_widgets
void enable_main_widgets(void)
Definition mapctrl.c:2180
is_unit_move_blocked
bool is_unit_move_blocked
Definition gui_main.c:107
finger_up_on_map
void finger_up_on_map(struct finger_behavior *finger_behavior)
Definition mapctrl.c:2267
resize_minimap
int resize_minimap(void)
Definition mapctrl.c:554
get_unit_info_window_widget
struct widget * get_unit_info_window_widget(void)
Definition mapctrl.c:2195
minimap_window_callback
static int minimap_window_callback(struct widget *pwidget)
Definition mapctrl.c:1262
close_game_page
void close_game_page(void)
Definition mapctrl.c:2021
enable_and_redraw_revolution_button
void enable_and_redraw_revolution_button(void)
Definition mapctrl.c:2245
map_event_handler
bool map_event_handler(SDL_Keysym key)
Definition mapctrl.c:2445
show_game_page
void show_game_page(void)
Definition mapctrl.c:1958
overview_h
int overview_h
Definition mapctrl.c:100
get_revolution_widget
struct widget * get_revolution_widget(void)
Definition mapctrl.c:2227
new_turn_button
static struct widget * new_turn_button
Definition mapctrl.c:105
popup_minimap_window
void popup_minimap_window(void)
Definition mapctrl.c:1650
draw_goto_patrol_lines
bool draw_goto_patrol_lines
Definition mapctrl.c:104
revolution_callback
static int revolution_callback(struct widget *button)
Definition mapctrl.c:220
newcity_cancel_callback
static int newcity_cancel_callback(struct widget *cancel_button)
Definition mapctrl.c:2726
minimap_dlg
static struct advanced_dialog * minimap_dlg
Definition mapctrl.c:96
hide_unitinfo_window_buttons
void hide_unitinfo_window_buttons(void)
Definition mapctrl.c:1593
disable_unitinfo_widgets
static void disable_unitinfo_widgets(void)
Definition mapctrl.c:2089
research_callback
static int research_callback(struct widget *button)
Definition mapctrl.c:235
unitinfo_w
int unitinfo_w
Definition mapctrl.c:101
new_city_dlg
static struct small_dialog * new_city_dlg
Definition mapctrl.c:81
players_action_callback
static int players_action_callback(struct widget *pwidget)
Definition mapctrl.c:123
disable_main_widgets
void disable_main_widgets(void)
Definition mapctrl.c:2102
disable_minimap_window_buttons
void disable_minimap_window_buttons(void)
Definition mapctrl.c:1911
move_new_city_dlg_callback
static int move_new_city_dlg_callback(struct widget *pwindow)
Definition mapctrl.c:2747
economy_callback
static int economy_callback(struct widget *button)
Definition mapctrl.c:247
toggle_msg_window_callback
static int toggle_msg_window_callback(struct widget *pwidget)
Definition mapctrl.c:529
research_button
static struct widget * research_button
Definition mapctrl.c:111
cities_action_callback
static int cities_action_callback(struct widget *button)
Definition mapctrl.c:170
unit_info_dlg
static struct advanced_dialog * unit_info_dlg
Definition mapctrl.c:97
enable_and_redraw_find_city_button
void enable_and_redraw_find_city_button(void)
Definition mapctrl.c:2235
show_minimap_window_buttons
void show_minimap_window_buttons(void)
Definition mapctrl.c:1798
set_new_minimap_window_pos
void set_new_minimap_window_pos(void)
Definition mapctrl.c:1386
suggested_city_name
static char * suggested_city_name
Definition mapctrl.c:80
hide_minimap_window_buttons
void hide_minimap_window_buttons(void)
Definition mapctrl.c:1836
newcity_ok_callback
static int newcity_ok_callback(struct widget *ok_button)
Definition mapctrl.c:2704
revolution_button
static struct widget * revolution_button
Definition mapctrl.c:109
show_unitinfo_window_buttons
void show_unitinfo_window_buttons(void)
Definition mapctrl.c:1569
popdown_minimap_window
void popdown_minimap_window(void)
Definition mapctrl.c:1945
disable_unitinfo_window_buttons
void disable_unitinfo_window_buttons(void)
Definition mapctrl.c:1617
set_new_unitinfo_window_pos
void set_new_unitinfo_window_pos(void)
Definition mapctrl.c:1332
overview_start_x
int overview_start_x
Definition mapview.c:73
newcity_name_edit_callback
static int newcity_name_edit_callback(struct widget *pedit)
Definition mapctrl.c:2686
popdown_unitinfo_window
void popdown_unitinfo_window(void)
Definition mapctrl.c:1637
tax_button
static struct widget * tax_button
Definition mapctrl.c:110
disable_minimap_widgets
static void disable_minimap_widgets(void)
Definition mapctrl.c:2044
find_city_button
static struct widget * find_city_button
Definition mapctrl.c:108
end_turn_callback
static int end_turn_callback(struct widget *button)
Definition mapctrl.c:205
popup_unitinfo_window
void popup_unitinfo_window(void)
Definition mapctrl.c:1454
redraw_minimap_window_buttons
void redraw_minimap_window_buttons(void)
Definition mapctrl.c:1874
finger_down_on_map
void finger_down_on_map(struct finger_behavior *finger_behavior)
Definition mapctrl.c:2254
units_info_window
static struct widget * units_info_window
Definition mapctrl.c:106
enable_unitinfo_widgets
static void enable_unitinfo_widgets(void)
Definition mapctrl.c:2163
overview_start_y
int overview_start_y
Definition mapview.c:74
get_tax_rates_widget
struct widget * get_tax_rates_widget(void)
Definition mapctrl.c:2211
units_action_callback
static int units_action_callback(struct widget *pwidget)
Definition mapctrl.c:155
resize_unit_info
int resize_unit_info(void)
DEFAULT_UNITS_W
#define DEFAULT_UNITS_W
Definition mapctrl.h:55
DEFAULT_UNITS_H
#define DEFAULT_UNITS_H
Definition mapctrl.h:56
BLOCKU_W
#define BLOCKU_W
Definition mapctrl.h:52
BLOCKM_W
#define BLOCKM_W
Definition mapctrl.h:51
refresh_overview
void refresh_overview(void)
Definition mapview.c:1119
redraw_unit_info_label
void redraw_unit_info_label(struct unit_list *punitlist)
Definition mapview.c:517
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
undraw_order_widgets
void undraw_order_widgets(void)
Definition menu.c:961
enable_order_buttons
void enable_order_buttons(void)
Definition menu.c:1473
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
enable_options_button
void enable_options_button(void)
Definition optiondlg.c:1366
init_options_button
void init_options_button(void)
Definition optiondlg.c:1382
disable_options_button
void disable_options_button(void)
Definition optiondlg.c:1374
optiondlg_callback
int optiondlg_callback(struct widget *pbutton)
Definition optiondlg.c:1345
popup_players_nations_dialog
void popup_players_nations_dialog(void)
Definition plrdlg.c:668
GET_SURF
#define GET_SURF(m_sprite)
Definition sprite.h:29
theme_get_background
SDL_Surface * theme_get_background(const struct theme *t, enum theme_background background)
Definition themebackgrounds.c:94
BACKGROUND_NEWCITYDLG
@ BACKGROUND_NEWCITYDLG
Definition themebackgrounds.h:42
COLOR_THEME_BACKGROUND
@ COLOR_THEME_BACKGROUND
Definition themecolors.h:24
COLOR_THEME_NEWCITYDLG_TEXT
@ COLOR_THEME_NEWCITYDLG_TEXT
Definition themecolors.h:104
active_theme
struct theme * active_theme
Definition themespec.c:154
set_group_state
void set_group_state(struct widget *begin_group_widget_list, struct widget *end_group_widget_list, enum widget_state state)
Definition widget.c:898
add_to_gui_list
void add_to_gui_list(Uint16 id, struct widget *gui)
Definition widget.c:586
get_widget_pointer_from_main_list
struct widget * get_widget_pointer_from_main_list(Uint16 id)
Definition widget.c:578
draw_frame
void draw_frame(SDL_Surface *pdest, Sint16 start_x, Sint16 start_y, Uint16 w, Uint16 h)
Definition widget.c:1114
redraw_group
Uint16 redraw_group(const struct widget *begin_group_widget_list, const struct widget *end_group_widget_list, int add_to_update)
Definition widget.c:720
popdown_window_group_dialog
void popdown_window_group_dialog(struct widget *begin_group_widget_list, struct widget *end_group_widget_list)
Definition widget.c:983
move_window_group
void move_window_group(struct widget *begin_widget_list, struct widget *pwindow)
Definition widget.c:1039
widget_set_position
static void widget_set_position(struct widget *pwidget, int x, int y)
Definition widget.h:266
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
widget_flush
static void widget_flush(struct widget *pwidget)
Definition widget.h:291
set_wstate
void set_wstate(struct widget *pwidget, enum widget_state state)
Definition widget_core.c:36
widget_undraw
static void widget_undraw(struct widget *pwidget)
Definition widget.h:296
WF_FREE_GFX
@ WF_FREE_GFX
Definition widget.h:70
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
WF_FREE_THEME
@ WF_FREE_THEME
Definition widget.h:72
WF_DRAW_TEXT_LABEL_WITH_SPACE
@ WF_DRAW_TEXT_LABEL_WITH_SPACE
Definition widget.h:87
widget_redraw
static int widget_redraw(struct widget *pwidget)
Definition widget.h:276
del_widget_from_gui_list
#define del_widget_from_gui_list(__gui)
Definition widget.h:372
widget_set_area
static void widget_set_area(struct widget *pwidget, SDL_Rect area)
Definition widget.h:261
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_button
struct widget * create_themeicon_button(SDL_Surface *icon_theme, struct gui_layer *pdest, utf8_str *pstr, Uint32 flags)
Definition widget_button.c:343
create_themeicon_button_from_chars_fonto
#define create_themeicon_button_from_chars_fonto(icon_theme, pdest, char_string, fonto, flags)
Definition widget_button.h:36
create_edit
struct widget * create_edit(SDL_Surface *background, struct gui_layer *pdest, utf8_str *pstr, int length, Uint32 flags)
Definition widget_edit.c:350
create_themeicon
struct widget * create_themeicon(SDL_Surface *icon_theme, struct gui_layer *pdest, Uint32 flags)
Definition widget_icon.c:212
create_icon2
struct widget * create_icon2(SDL_Surface *icon, struct gui_layer *pdest, Uint32 flags)
Definition widget_icon.c:337
create_iconlabel
struct widget * create_iconlabel(SDL_Surface *icon, struct gui_layer *pdest, utf8_str *pstr, Uint32 flags)
Definition widget_label.c:215
hide_scrollbar
#define hide_scrollbar(scrollbar)
Definition widget_scrollbar.h:36
resize_window
bool resize_window(struct widget *pwindow, SDL_Surface *bcgd, SDL_Color *pcolor, Uint16 new_w, Uint16 new_h)
Definition widget_window.c:255
create_window_skeleton
struct widget * create_window_skeleton(struct gui_layer *pdest, utf8_str *title, Uint32 flags)
Definition widget_window.c:180
popup_worklist_editor
void popup_worklist_editor(struct city *pcity, struct global_worklist *gwl)
Definition wldlg.c:1055
gui_id.h
gui_mouse.h
gui_tilespec.h
themespec.h
widget.h
citydlg.h
cityrep.h
colors.h
dialogs.h
finddlg.h
graphics.h
gui_main.h
mapctrl.h
mapview.h
menu.h
messagewin.h
optiondlg.h
plrdlg.h
repodlgs.h
sprite.h
wldlg.h
log.h
fc_assert
#define fc_assert(condition)
Definition log.h:176
map_pos_to_tile
struct tile * map_pos_to_tile(const struct civ_map *nmap, int map_x, int map_y)
Definition map.c:425
update_line
void update_line(int canvas_x, int canvas_y)
Definition mapctrl_common.c:665
recenter_button_pressed
void recenter_button_pressed(int canvas_x, int canvas_y)
Definition mapctrl_common.c:633
action_button_pressed
void action_button_pressed(int canvas_x, int canvas_y, enum quickselect_type qtype)
Definition mapctrl_common.c:570
canvas_pos_to_tile
struct tile * canvas_pos_to_tile(float canvas_x, float canvas_y, float zoom)
Definition mapview_common.c:763
center_tile_mapcanvas
void center_tile_mapcanvas(const struct tile *ptile)
Definition mapview_common.c:1237
fc_calloc
#define fc_calloc(n, esz)
Definition mem.h:38
FC_FREE
#define FC_FREE(ptr)
Definition mem.h:41
menus_update
void menus_update(void)
Definition update_queue.c:562
gui_options
struct client_options gui_options
Definition options.c:71
overview_to_map_pos
void overview_to_map_pos(int *map_x, int *map_y, int overview_x, int overview_y)
Definition overview_common.c:358
calculate_overview_dimensions
void calculate_overview_dimensions(void)
Definition overview_common.c:450
overview_common.h
OVERVIEW_TILE_WIDTH
#define OVERVIEW_TILE_WIDTH
Definition overview_common.h:32
OVERVIEW_TILE_HEIGHT
#define OVERVIEW_TILE_HEIGHT
Definition overview_common.h:33
pages_g.h
MAX
#define MAX(x, y)
Definition shared.h:54
advanced_dialog
Definition widget.h:180
advanced_dialog::begin_active_widget_list
struct widget * begin_active_widget_list
Definition widget.h:184
advanced_dialog::end_widget_list
struct widget * end_widget_list
Definition widget.h:182
advanced_dialog::end_active_widget_list
struct widget * end_active_widget_list
Definition widget.h:185
advanced_dialog::scroll
struct scroll_bar * scroll
Definition widget.h:187
advanced_dialog::begin_widget_list
struct widget * begin_widget_list
Definition widget.h:181
city
Definition city.h:320
civclient::conn
struct connection conn
Definition client_main.h:96
client_options::overview
struct overview overview
Definition options.h:463
connection::playing
struct player * playing
Definition connection.h:151
finger_behavior
Definition gui_main.h:83
finger_behavior::event
SDL_TouchFingerEvent event
Definition gui_main.h:87
gui_layer::surface
SDL_Surface * surface
Definition graphics.h:229
gui_layer::dest_rect
SDL_Rect dest_rect
Definition graphics.h:228
mouse_button_behavior
Definition gui_main.h:91
mouse_button_behavior::hold_state
enum mouse_button_hold_state hold_state
Definition gui_main.h:94
mouse_button_behavior::event
SDL_MouseButtonEvent * event
Definition gui_main.h:95
overview::width
int width
Definition options.h:94
overview::height
int height
Definition options.h:94
sdl2_data::gui
struct gui_layer * gui
Definition graphics.h:215
sdl2_data::event
SDL_Event event
Definition graphics.h:217
sdl2_data::screen
SDL_Window * screen
Definition graphics.h:209
small_dialog
Definition widget.h:174
small_dialog::begin_widget_list
struct widget * begin_widget_list
Definition widget.h:175
small_dialog::end_widget_list
struct widget * end_widget_list
Definition widget.h:176
tile
Definition tile.h:50
unit
Definition unit.h:140
utf8_str
Definition gui_string.h:52
utf8_str::style
Uint8 style
Definition gui_string.h:53
utf8_str::text
char * text
Definition gui_string.h:60
widget
Definition widget.h:112
widget::key
SDL_Keycode key
Definition widget.h:153
widget::theme
SDL_Surface * theme
Definition widget.h:118
widget::tile
struct tile * tile
Definition widget.h:131
widget::prev
struct widget * prev
Definition widget.h:114
widget::dst
struct gui_layer * dst
Definition widget.h:116
widget::mod
Uint16 mod
Definition widget.h:154
widget::adv_dlg
struct advanced_dialog * adv_dlg
Definition widget.h:139
widget::string_utf8
utf8_str * string_utf8
Definition widget.h:121
widget::action
int(* action)(struct widget *)
Definition widget.h:157
widget::area
SDL_Rect area
Definition widget.h:149
widget::gfx
SDL_Surface * gfx
Definition widget.h:120
widget::next
struct widget * next
Definition widget.h:113
widget::info_label
utf8_str * info_label
Definition widget.h:122
widget::size
SDL_Rect size
Definition widget.h:145
widget::private_data
union widget::@218 private_data
widget::data
union widget::@217 data
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
fc_strlcpy
size_t fc_strlcpy(char *dest, const char *src, size_t n)
Definition support.c:777
TRUE
#define TRUE
Definition support.h:46
FALSE
#define FALSE
Definition support.h:47
tile_city
struct city * tile_city(const struct tile *ptile)
Definition tile.c:83
CURSOR_GOTO
@ CURSOR_GOTO
Definition tilespec.h:290
CURSOR_DEFAULT
@ CURSOR_DEFAULT
Definition tilespec.h:302
unit.h
unit_tile
#define unit_tile(_pu)
Definition unit.h:397
unitlist.h
update_queue_is_switching_page
bool update_queue_is_switching_page(void)
Definition update_queue.c:535
update_queue.h
mouse_zoom
float mouse_zoom
Definition zoom.c:28
zoom.h