Freeciv-3.2: /fast/freeciv/nightly/S3_2/client/gui-sdl3/mapctrl.c Source File

Freeciv-3.2

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