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
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
88static int popdown_scale_unitinfo_dlg_callback(struct widget *pwidget);
89static void remake_unitinfo(int w, int h);
90#endif /* SCALE_UNITINFO */
91
94
95int overview_w = 0;
96int overview_h = 0;
97int unitinfo_w = 0;
98int unitinfo_h = 0;
99
101static struct widget *new_turn_button = NULL;
103static struct widget *minimap_window = NULL;
104static struct widget *find_city_button = NULL;
106static struct widget *tax_button = NULL;
107static 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/**********************************************************************/
119static int players_action_callback(struct widget *pwidget)
120{
121 set_wstate(pwidget, FC_WS_NORMAL);
122 widget_redraw(pwidget);
123 widget_mark_dirty(pwidget);
125 switch (main_data.event.button.button) {
126#if 0
127 case SDL_BUTTON_LEFT:
128
129 break;
131
132 break;
133#endif /* 0 */
134 case SDL_BUTTON_RIGHT:
136 break;
137 default:
139 break;
140 }
141 } else {
143 }
144
145 return -1;
146}
147
148/**********************************************************************/
151static int units_action_callback(struct widget *pwidget)
152{
154 set_wstate(pwidget, FC_WS_NORMAL);
155 widget_redraw(pwidget);
156 widget_mark_dirty(pwidget);
158 }
159
160 return -1;
161}
162
163/**********************************************************************/
166static 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 */
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;
181
182 break;
183#endif /* 0 */
184 case SDL_BUTTON_RIGHT:
186 break;
187 default:
189 break;
190 }
191 } else if (PRESSED_EVENT(main_data.event)) {
193 }
194
195 return -1;
196}
197
198/**********************************************************************/
201static int end_turn_callback(struct widget *button)
202{
204 widget_redraw(button);
205 widget_flush(button);
207 key_end_turn();
208 }
209
210 return -1;
211}
212
213/**********************************************************************/
216static int revolution_callback(struct widget *button)
217{
219 set_wstate(button, FC_WS_DISABLED);
220 widget_redraw(button);
221 widget_mark_dirty(button);
223 }
224
225 return -1;
226}
227
228/**********************************************************************/
231static int research_callback(struct widget *button)
232{
235 }
236
237 return -1;
238}
239
240/**********************************************************************/
243static int economy_callback(struct widget *button)
244{
247 }
248
249 return -1;
250}
251
252/* ====================================== */
253
254/**********************************************************************/
258{
260 struct widget *buf = NULL;
261
263 alphablit(current_theme->map_icon, NULL, icon_widget->theme, NULL, 255);
264
265 if (get_num_units_in_focus() > 0) {
267 }
268
270 /* HIDE */
273
276
280 }
283 }
284
285 /* clear area under old unit info window */
288
289 /* new button direction */
290 alphablit(current_theme->l_arrow_icon, NULL, icon_widget->theme, NULL,
291 255);
292
294 _("Show Unit Info Window"));
295
297
299
300 /* blit part of map window */
301 src.x = 0;
302 src.y = 0;
304 src.h = units_info_window->theme->h;
305
309
310 /* blit right vertical frame */
312 current_theme->fr_right->w,
313 units_info_window->area.h, 1);
314
320
321 /* redraw widgets */
322
323 /* ID_ECONOMY */
326
327 /* ===== */
328 /* ID_RESEARCH */
329 buf = buf->prev;
331
332 /* ===== */
333 /* ID_REVOLUTION */
334 buf = buf->prev;
336
337 /* ===== */
338 /* ID_TOGGLE_UNITS_WINDOW_BUTTON */
339 buf = buf->prev;
341
342#ifdef SCALE_UNITINFO
344#endif
345 } else {
348
351
352 /* SHOW */
354 _("Hide Unit Info Window"));
355
356 alphablit(current_theme->r_arrow_icon, NULL, icon_widget->theme, NULL,
357 255);
358
360
362
364
366 } else {
367 alphablit(current_theme->l_arrow_icon, NULL, icon_widget->theme, NULL,
368 255);
371 }
372 }
373
374 if (get_num_units_in_focus() > 0) {
376 }
377
378 flush_dirty();
379 }
380
381 return -1;
382}
383
384/**********************************************************************/
388{
390 struct unit *focus = head_of_units_in_focus();
391 struct widget *pwidget;
392
393 /* make new map icon */
395 alphablit(current_theme->map_icon, NULL, map_button->theme, NULL, 255);
396
398
399 if (focus) {
401 }
402
404 /* Hide MiniMap */
407
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
417
418 /* Clear area under old map window */
421
424
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
435
436 /* blit left vertical frame theme */
438 current_theme->fr_left->w,
439 minimap_window->area.h, 1);
440
441 map_area.y += adj_size(2);
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
478#endif
479 } else {
480 if (((minimap_window->size.w - minimap_window->area.w) +
482
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);
492
496
498
502 } else {
503 alphablit(current_theme->r_arrow_icon, NULL, map_button->theme, NULL,
504 255);
507 }
508 }
509
510 if (focus) {
512 }
513
514 flush_dirty();
515 }
516
517 return -1;
518}
519
520/* ====================================================================== */
521
522/**********************************************************************/
525static int toggle_msg_window_callback(struct widget *pwidget)
526{
528 if (meswin_dialog_is_open()) {
530 copy_chars_to_utf8_str(pwidget->info_label, _("Show Messages (F9)"));
531 } else {
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/**********************************************************************/
566
567#ifdef SCALE_MINIMAP
568/* ============================================================== */
569
570/**********************************************************************/
573static int move_scale_minimap_dlg_callback(struct widget *pwindow)
574{
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{
588 if (scale_minimap_dlg) {
590 scale_minimap_dlg->end_widget_list);
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{
607 widget_redraw(pwidget);
608 widget_mark_dirty(pwidget);
609 if ((((OVERVIEW_TILE_WIDTH + 1) * map.xsize) +
612 char cbuf[4];
613
614 fc_snprintf(cbuf, sizeof(cbuf), "%d", OVERVIEW_TILE_WIDTH);
616 widget_redraw(pwidget->next);
617 widget_mark_dirty(pwidget->next);
618
621 }
622 flush_dirty();
623 }
624
625 return -1;
626}
627
628/**********************************************************************/
631static int down_width_callback(struct widget *pwidget)
632{
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);
641 widget_redraw(pwidget->prev);
642 widget_mark_dirty(pwidget->prev);
643
645 }
646 flush_dirty();
647 }
648
649 return -1;
650}
651
652/**********************************************************************/
655static int up_height_callback(struct widget *pwidget)
656{
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
666 fc_snprintf(cbuf, sizeof(cbuf), "%d", OVERVIEW_TILE_HEIGHT);
668 widget_redraw(pwidget->next);
669 widget_mark_dirty(pwidget->next);
671 }
672 flush_dirty();
673 }
674
675 return -1;
676}
677
678/**********************************************************************/
681static int down_height_callback(struct widget *pwidget)
682{
684 widget_redraw(pwidget);
685 widget_mark_dirty(pwidget);
686 if (OVERVIEW_TILE_HEIGHT > 1) {
687 char cbuf[4];
688
690 fc_snprintf(cbuf, sizeof(cbuf), "%d", OVERVIEW_TILE_HEIGHT);
692 widget_redraw(pwidget->prev);
693 widget_mark_dirty(pwidget->prev);
694
696 }
697 flush_dirty();
698 }
699
700 return -1;
701}
702
703/**********************************************************************/
706static void popup_minimap_scale_dialog(void)
707{
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;
715
717 return;
718 }
719
720 scale_minimap_dlg = fc_calloc(1, sizeof(struct small_dialog));
721
722 /* Create window */
724 pstr->style |= TTF_STYLE_BOLD;
725 pwindow = create_window_skeleton(NULL, pstr, 0);
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);
736 area.w = MAX(area.w, text1->w + adj_size(30));
737
738 copy_chars_to_utf8_str(pstr, _("Single Tile Height"));
740 area.w = MAX(area.w, text2->w + adj_size(30));
742
743 buf = create_themeicon_button(current_theme->l_arrow_icon, pwindow->dst,
744 NULL, 0);
745 buf->action = down_width_callback;
748
749 fc_snprintf(cbuf, sizeof(cbuf), "%d" , OVERVIEW_TILE_WIDTH);
751 pstr->style |= (TTF_STYLE_BOLD|SF_CENTER);
753 buf->size.w = MAX(adj_size(50), buf->size.w);
754 area.h += buf->size.h + adj_size(5);
756
757 buf = create_themeicon_button(current_theme->r_arrow_icon, pwindow->dst,
758 NULL, 0);
759 buf->action = up_width_callback;
762
763 /* ------------ */
764 buf = create_themeicon_button(current_theme->l_arrow_icon, pwindow->dst,
765 NULL, 0);
766 buf->action = down_height_callback;
769
770 fc_snprintf(cbuf, sizeof(cbuf), "%d" , OVERVIEW_TILE_HEIGHT);
772 pstr->style |= (TTF_STYLE_BOLD|SF_CENTER);
774 buf->size.w = MAX(adj_size(50), buf->size.w);
775 area.h += buf->size.h + adj_size(20);
777
778 buf = create_themeicon_button(current_theme->r_arrow_icon, pwindow->dst,
779 NULL, 0);
780 buf->action = up_height_callback;
783 area.w = MAX(area.w , buf->size.w * 2 + buf->next->size.w + adj_size(20));
784
785 /* ------------ */
787 buf = create_themeicon_button(current_theme->cancel_icon, pwindow->dst,
788 pstr, 0);
791 scale_minimap_dlg->begin_widget_list = 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
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
826
827 blit_entire_src(text1, pwindow->theme, 15, area.y + 1);
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));
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{
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{
893 scale_unit_info_dlg->end_widget_list);
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;
912 units_info_window->area.y, 0, 0};
913 struct widget *pwidget = units_info_window;
914
915 if (w < DEFAULT_UNITS_W - BLOCKU_W) {
917 } else {
919 }
920
921 if (h < DEFAULT_UNITS_H) {
923 } else {
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);
939
940 draw_frame(pwidget->theme, 0, 0, pwidget->size.w, pwidget->size.h);
941
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,
947 FREESURFACE(surf);
948
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{
994 int w = info_width * map.xsize;
995 int h = info_height * map.ysize;
997 (info_window->size.w - info_window->area.w);
999 (info_window->size.h - info_window->area.h);
1000
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 }
1011
1012 return 0;
1013}
1014
1015/**********************************************************************/
1018static int up_info_width_callback(struct widget *pwidget)
1019{
1021 widget_redraw(pwidget);
1022 widget_mark_dirty(pwidget);
1023 if (main_window_width() - ((info_width + 1) * map.xsize + BLOCKU_W +
1026 info_width++;
1028 }
1029 flush_dirty();
1030 }
1031
1032 return -1;
1033}
1034
1035/**********************************************************************/
1038static int down_info_width_callback(struct widget *pwidget)
1039{
1041 widget_redraw(pwidget);
1042 widget_mark_dirty(pwidget);
1043 if (info_width > info_width_min) {
1044 info_width--;
1046 }
1047 flush_dirty();
1048 }
1049
1050 return -1;
1051}
1052
1053/**********************************************************************/
1056static int up_info_height_callback(struct widget *pwidget)
1057{
1059 widget_redraw(pwidget);
1060 widget_mark_dirty(pwidget);
1061 if (main_data.screen->h - ((info_height + 1) * map.ysize +
1063 info_height++;
1065 }
1066 flush_dirty();
1067 }
1068
1069 return -1;
1070}
1071
1072/**********************************************************************/
1075static int down_info_height_callback(struct widget *pwidget)
1076{
1078 widget_redraw(pwidget);
1079 widget_mark_dirty(pwidget);
1081 info_height--;
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
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
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);
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
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"));
1130 area.w = MAX(area.w, text2->w + adj_size(30));
1131 area.h += MAX(adj_size(20), text2->h + adj_size(4));
1133
1134 /* ----------------- */
1135 buf = create_themeicon_button(current_theme->l_arrow_icon, pwindow->dst,
1136 NULL, 0);
1137 buf->action = down_info_width_callback;
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;
1147
1148 /* ------------ */
1149 buf = create_themeicon_button(current_theme->l_arrow_icon, pwindow->dst,
1150 NULL, 0);
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;
1161 area.w = MAX(area.w , buf->size.w * 2 + adj_size(20));
1162
1163 /* ------------ */
1166 pwindow->dst, pstr, 0);
1169 scale_unit_info_dlg->begin_widget_list = buf;
1171 area.h += buf->size.h + adj_size(10);
1172 area.w = MAX(area.w, buf->size.w + adj_size(20));
1173
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
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));
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));
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 }
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/**********************************************************************/
1258static 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 -
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);
1275 }
1276
1277 break;
1278 case SDL_BUTTON_MIDDLE:
1279 /* FIXME: scaling needs to be fixed */
1280#ifdef SCALE_MINIMAP
1282#endif
1283 break;
1284 default:
1285 break;
1286 }
1287
1288 return -1;
1289}
1290
1291/**********************************************************************/
1294static int unit_info_window_callback(struct widget *pwidget)
1295{
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:
1305 break;
1306 case SDL_BUTTON_RIGHT:
1307#ifdef SCALE_UNITINFO
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/**********************************************************************/
1329{
1331 struct widget *pwidget;
1332 SDL_Rect area;
1333
1338 } else {
1340 main_window_width() - BLOCKU_W - current_theme->fr_right->w,
1342 }
1343
1346 area.w = BLOCKU_W;
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/**********************************************************************/
1383{
1384 struct widget *pwidget;
1385 SDL_Rect area;
1386
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/**********************************************************************/
1451{
1452 struct widget *pwidget, *pwindow;
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);
1479
1481
1483
1484 units_info_window = pwindow;
1485
1488
1489 /* Economy button */
1493
1494 fc_snprintf(buf, sizeof(buf), "%s (%s)", _("Economy"), "F5");
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 */
1508 /* TRANS: Research report action */
1509 fc_snprintf(buf, sizeof(buf), "%s (%s)", _("Research"), "F6");
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 */
1523 fc_snprintf(buf, sizeof(buf), "%s (%s)", _("Revolution"), "Ctrl+Shift+G");
1525 pwidget->action = revolution_callback;
1526 pwidget->key = SDLK_G;
1527 pwidget->mod = SDL_KMOD_CTRL | SDL_KMOD_SHIFT;
1528
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);
1538 alphablit(current_theme->map_icon, NULL, icon_theme, NULL, 255);
1539 alphablit(current_theme->r_arrow_icon, NULL, icon_theme, NULL, 255);
1540
1545 pwidget->info_label
1546 = create_utf8_from_char_fonto(_("Hide Unit Info Window"),
1548
1550
1552
1554
1556
1558
1560}
1561
1562/**********************************************************************/
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/**********************************************************************/
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/**********************************************************************/
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/**********************************************************************/
1642
1643/**********************************************************************/
1647{
1648 struct widget *pwidget, *pwindow;
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
1669 pwindow->area.h, 1);
1671 pwindow->area.x + pwindow->area.w - icon_theme->w,
1672 pwindow->area.y);
1674
1676
1678
1679 minimap_window = pwindow;
1681
1682 /* New turn button */
1683 pwidget = create_themeicon(current_theme->new_turn_icon, minimap_window->dst,
1686 fc_snprintf(buf, sizeof(buf), "%s (%s)", _("Turn Done"), _("Shift+Return"));
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,
1700 /* TRANS: Nations report action */
1701 fc_snprintf(buf, sizeof(buf), "%s (%s)", _("Nations"), "F3");
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,
1712 fc_snprintf(buf, sizeof(buf), "%s (%s)\n%s\n%s (%s)", _("Cities Report"),
1713 "F4", _("or"), _("Find City"), "Ctrl+F");
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,
1728 fc_snprintf(buf, sizeof(buf), "%s (%s)", _("Units"), "F2");
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,
1739 fc_snprintf(buf, sizeof(buf), "%s (%s)", _("Hide Messages"), "F9");
1742 pwidget->key = SDLK_F9;
1743
1745
1746#ifdef SMALL_SCREEN
1747 /* Options button */
1752 fc_snprintf(buf, sizeof(buf), "%s (%s)", _("Options"), "Esc");
1755
1758
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 alphablit(current_theme->map_icon, NULL, icon_theme, NULL, 255);
1768 alphablit(current_theme->l_arrow_icon, NULL, icon_theme, NULL, 255);
1769
1774
1775 pwidget->info_label = create_utf8_from_char_fonto(_("Hide Mini Map"),
1778
1780
1781 minimap_dlg->begin_widget_list = pwidget;
1782
1784
1786
1788}
1789
1790/**********************************************************************/
1794{
1795 struct widget *pwidget = get_minimap_window_widget();
1796
1797 /* new turn button */
1798 pwidget = pwidget->prev;
1799 clear_wflag(pwidget, WF_HIDDEN);
1800
1801 /* players button */
1802 pwidget = pwidget->prev;
1803 clear_wflag(pwidget, WF_HIDDEN);
1804
1805 /* find city button */
1806 pwidget = pwidget->prev;
1807 clear_wflag(pwidget, WF_HIDDEN);
1808
1809 /* units button */
1810 pwidget = pwidget->prev;
1811 clear_wflag(pwidget, WF_HIDDEN);
1812
1813 /* show/hide log window button */
1814 pwidget = pwidget->prev;
1815 clear_wflag(pwidget, WF_HIDDEN);
1816
1817#ifdef SMALL_SCREEN
1818 /* options button */
1819 pwidget = pwidget->prev;
1820 clear_wflag(pwidget, WF_HIDDEN);
1821#endif /* SMALL_SCREEN */
1822
1823 /* show/hide minimap button */
1824 pwidget = pwidget->prev;
1825 clear_wflag(pwidget, WF_HIDDEN);
1826}
1827
1828/**********************************************************************/
1832{
1833 struct widget *pwidget = get_minimap_window_widget();
1834
1835 /* new turn button */
1836 pwidget = pwidget->prev;
1837 set_wflag(pwidget, WF_HIDDEN);
1838
1839 /* players button */
1840 pwidget = pwidget->prev;
1841 set_wflag(pwidget, WF_HIDDEN);
1842
1843 /* find city button */
1844 pwidget = pwidget->prev;
1845 set_wflag(pwidget, WF_HIDDEN);
1846
1847 /* units button */
1848 pwidget = pwidget->prev;
1849 set_wflag(pwidget, WF_HIDDEN);
1850
1851 /* show/hide log window button */
1852 pwidget = pwidget->prev;
1853 set_wflag(pwidget, WF_HIDDEN);
1854
1855#ifdef SMALL_SCREEN
1856 /* options button */
1857 pwidget = pwidget->prev;
1858 set_wflag(pwidget, WF_HIDDEN);
1859#endif /* SMALL_SCREEN */
1860
1861 /* show/hide minimap button */
1862 pwidget = pwidget->prev;
1863 set_wflag(pwidget, WF_HIDDEN);
1864}
1865
1866/**********************************************************************/
1870{
1871 struct widget *pwidget = get_minimap_window_widget();
1872
1873 /* new turn button */
1874 pwidget = pwidget->prev;
1875 widget_redraw(pwidget);
1876
1877 /* players button */
1878 pwidget = pwidget->prev;
1879 widget_redraw(pwidget);
1880
1881 /* find city button */
1882 pwidget = pwidget->prev;
1883 widget_redraw(pwidget);
1884
1885 /* units button */
1886 pwidget = pwidget->prev;
1887 widget_redraw(pwidget);
1888 /* show/hide log window button */
1889 pwidget = pwidget->prev;
1890 widget_redraw(pwidget);
1891
1892#ifdef SMALL_SCREEN
1893 /* options button */
1894 pwidget = pwidget->prev;
1895 widget_redraw(pwidget);
1896#endif /* SMALL_SCREEN */
1897
1898 /* show/hide minimap button */
1899 pwidget = pwidget->prev;
1900 widget_redraw(pwidget);
1901}
1902
1903/**********************************************************************/
1907{
1908 struct widget *pwidget = get_minimap_window_widget();
1909
1910 /* new turn button */
1911 pwidget = pwidget->prev;
1912 set_wstate(pwidget, FC_WS_DISABLED);
1913
1914 /* players button */
1915 pwidget = pwidget->prev;
1916 set_wstate(pwidget, FC_WS_DISABLED);
1917
1918 /* find city button */
1919 pwidget = pwidget->prev;
1920 set_wstate(pwidget, FC_WS_DISABLED);
1921
1922 /* units button */
1923 pwidget = pwidget->prev;
1924 set_wstate(pwidget, FC_WS_DISABLED);
1925
1926 /* show/hide log window button */
1927 pwidget = pwidget->prev;
1928 set_wstate(pwidget, FC_WS_DISABLED);
1929
1930#ifdef SMALL_SCREEN
1931 /* options button */
1932 pwidget = pwidget->prev;
1933 set_wstate(pwidget, FC_WS_DISABLED);
1934#endif /* SMALL_SCREEN */
1935}
1936
1937/**********************************************************************/
1949
1950/**********************************************************************/
1954{
1955 struct widget *pwidget;
1957
1959 return;
1960 }
1961
1965
1966#ifndef SMALL_SCREEN
1968#endif
1969
1970 /* cooling icon */
1974
1975#ifdef SMALL_SCREEN
1976 widget_set_position(pwidget,
1977 pwidget->dst->surface->w - pwidget->size.w - adj_size(10),
1978 0);
1979#else /* SMALL_SCREEN */
1980 widget_set_position(pwidget,
1981 pwidget->dst->surface->w - pwidget->size.w - adj_size(10),
1982 adj_size(10));
1983#endif /* SMALL_SCREEN */
1984
1986
1987 /* warming icon */
1990
1992
1993#ifdef SMALL_SCREEN
1994 widget_set_position(pwidget,
1995 pwidget->dst->surface->w - pwidget->size.w * 2 - adj_size(10),
1996 0);
1997#else /* SMALL_SCREEN */
1998 widget_set_position(pwidget,
1999 pwidget->dst->surface->w - pwidget->size.w * 2 - adj_size(10),
2000 adj_size(10));
2001#endif /* SMALL_SCREEN */
2002
2004
2005 /* create order buttons */
2007
2008 /* enable options button and order widgets */
2011}
2012
2013/**********************************************************************/
2034
2035/**********************************************************************/
2040{
2041 struct widget *buf, *end;
2042
2045
2046 /* new turn button */
2047 buf = buf->prev;
2048 end = buf;
2050
2051 /* players button */
2052 buf = buf->prev;
2054
2055 /* find city button */
2056 buf = buf->prev;
2058
2059 /* units button */
2060 buf = buf->prev;
2062
2063 /* show/hide log window button */
2064 buf = buf->prev;
2066
2067#ifdef SMALL_SCREEN
2068 /* options button */
2069 buf = buf->prev;
2071#endif /* SMALL_SCREEN */
2072
2073 /* show/hide minimap button */
2074 buf = buf->prev;
2076
2077 redraw_group(buf, end, TRUE);
2078}
2079
2080/**********************************************************************/
2085{
2088
2090 end = end->prev;
2091 redraw_group(buf, end, TRUE);
2092}
2093
2094/**********************************************************************/
2098{
2099 if (C_S_RUNNING == client_state()) {
2102
2104
2106 }
2107}
2108
2109/**********************************************************************/
2112static void enable_minimap_widgets(void)
2113{
2114 struct widget *buf, *end;
2115
2119
2120 /* new turn button */
2121 buf = buf->prev;
2122 end = buf;
2124
2125 /* players button */
2126 buf = buf->prev;
2128
2129 /* find city button */
2130 buf = buf->prev;
2132
2133 /* units button */
2134 buf = buf->prev;
2136
2137 /* show/hide log window button */
2138 buf = buf->prev;
2140
2141#ifdef SMALL_SCREEN
2142 /* options button */
2143 buf = buf->prev;
2145#endif /* SMALL_SCREEN */
2146
2147 /* show/hide minimap button */
2148 buf = buf->prev;
2150
2151 redraw_group(buf, end, TRUE);
2152 }
2153}
2154
2155/**********************************************************************/
2159{
2160 struct widget *buf, *end;
2161
2165
2167 end = end->prev;
2168 redraw_group(buf, end, TRUE);
2169 }
2170}
2171
2172/**********************************************************************/
2176{
2177 if (C_S_RUNNING == client_state()) {
2180
2182
2184 }
2185}
2186
2187/**********************************************************************/
2191{
2192 return units_info_window;
2193}
2194
2195/**********************************************************************/
2199{
2200 return minimap_window;
2201}
2202
2203/**********************************************************************/
2207{
2208 return tax_button;
2209}
2210
2211/**********************************************************************/
2215{
2216 return research_button;
2217}
2218
2219/**********************************************************************/
2223{
2224 return revolution_button;
2225}
2226
2227/**********************************************************************/
2236
2237/**********************************************************************/
2246/**********************************************************************/
2250{
2251 if (C_S_RUNNING != client_state()) {
2252 return;
2253 }
2254
2255 key_unit_goto();
2257}
2258
2259/**********************************************************************/
2271
2272/**********************************************************************/
2276{
2277 struct tile *ptile;
2278
2279 if (C_S_RUNNING != client_state()) {
2280 return;
2281 }
2282
2283 if (button_behavior->event->button == SDL_BUTTON_LEFT) {
2284 switch (button_behavior->hold_state) {
2285 case MB_HOLD_SHORT:
2286 break;
2287 case MB_HOLD_MEDIUM:
2288 /* switch to goto mode */
2289 key_unit_goto();
2291 break;
2292 case MB_HOLD_LONG:
2293#ifdef UNDER_CE
2294 /* cancel goto mode and open context menu on Pocket PC since we have
2295 * only one 'mouse button' */
2299 /* popup context menu */
2300 if ((ptile = canvas_pos_to_tile((int) button_behavior->event->x,
2301 (int) button_behavior->event->y,
2302 mouse_zoom))) {
2305 }
2306#endif /* UNDER_CE */
2307 break;
2308 default:
2309 break;
2310 }
2311 } else if (button_behavior->event->button == SDL_BUTTON_MIDDLE) {
2312 switch (button_behavior->hold_state) {
2313 case MB_HOLD_SHORT:
2314 break;
2315 case MB_HOLD_MEDIUM:
2316 break;
2317 case MB_HOLD_LONG:
2318 break;
2319 default:
2320 break;
2321 }
2322 } else if (button_behavior->event->button == SDL_BUTTON_RIGHT) {
2323 switch (button_behavior->hold_state) {
2324 case MB_HOLD_SHORT:
2325 break;
2326 case MB_HOLD_MEDIUM:
2327 /* popup context menu */
2328 if ((ptile = canvas_pos_to_tile((int) button_behavior->event->x,
2329 (int) button_behavior->event->y,
2330 mouse_zoom))) {
2333 }
2334 break;
2335 case MB_HOLD_LONG:
2336 break;
2337 default:
2338 break;
2339 }
2340 }
2341}
2342
2343/**********************************************************************/
2347{
2348 struct tile *ptile;
2349 struct city *pcity;
2350
2351 if (C_S_RUNNING != client_state()) {
2352 return;
2353 }
2354
2356
2357 if (button_behavior->event->button == SDL_BUTTON_LEFT) {
2358 switch (button_behavior->hold_state) {
2359 case MB_HOLD_SHORT:
2360 if (LSHIFT || LALT || LCTRL) {
2361 if ((ptile = canvas_pos_to_tile((int) button_behavior->event->x,
2362 (int) button_behavior->event->y,
2363 mouse_zoom))) {
2364 if (LSHIFT) {
2367 } else {
2368 if (((pcity = tile_city(ptile)) != NULL)
2369 && (city_owner(pcity) == client.conn.playing)) {
2370 if (LCTRL) {
2372 } else {
2373 /* LALT - this work only with fullscreen mode */
2375 }
2376 }
2377 }
2378 }
2379 } else {
2383 }
2384 break;
2385 case MB_HOLD_MEDIUM:
2386 /* finish goto */
2390 break;
2391 case MB_HOLD_LONG:
2392#ifndef UNDER_CE
2393 /* finish goto */
2397#endif /* UNDER_CE */
2398 break;
2399 default:
2400 break;
2401 }
2402 } else if (button_behavior->event->button == SDL_BUTTON_MIDDLE) {
2403 switch (button_behavior->hold_state) {
2404 case MB_HOLD_SHORT:
2405/* break;*/
2406 case MB_HOLD_MEDIUM:
2407/* break;*/
2408 case MB_HOLD_LONG:
2409/* break;*/
2410 default:
2411 /* Popup context menu */
2412 if ((ptile = canvas_pos_to_tile((int) button_behavior->event->x,
2413 (int) button_behavior->event->y,
2414 mouse_zoom))) {
2417 }
2418 break;
2419 }
2420 } else if (button_behavior->event->button == SDL_BUTTON_RIGHT) {
2421 switch (button_behavior->hold_state) {
2422 case MB_HOLD_SHORT:
2423 /* recenter map */
2425 flush_dirty();
2426 break;
2427 case MB_HOLD_MEDIUM:
2428 break;
2429 case MB_HOLD_LONG:
2430 break;
2431 default:
2432 break;
2433 }
2434 }
2435}
2436
2437/**********************************************************************/
2441{
2442 if (C_S_RUNNING == client_state()) {
2444
2445 switch (key->scancode) {
2446
2447 case SDL_SCANCODE_KP_8:
2449 break;
2450
2451 case SDL_SCANCODE_KP_9:
2453 break;
2454
2455 case SDL_SCANCODE_KP_6:
2457 break;
2458
2459 case SDL_SCANCODE_KP_3:
2461 break;
2462
2463 case SDL_SCANCODE_KP_2:
2465 break;
2466
2467 case SDL_SCANCODE_KP_1:
2469 break;
2470
2471 case SDL_SCANCODE_KP_4:
2473 break;
2474
2475 case SDL_SCANCODE_KP_7:
2477 break;
2478
2479 case SDL_SCANCODE_KP_5:
2481 return FALSE;
2482
2483 default:
2484 switch (key->key) {
2485
2486 /* Cancel action */
2487 case SDLK_ESCAPE:
2491 return FALSE;
2492
2493 case SDLK_UP:
2495 break;
2496
2497 case SDLK_PAGEUP:
2499 break;
2500
2501 case SDLK_RIGHT:
2503 break;
2504
2505 case SDLK_PAGEDOWN:
2507 break;
2508
2509 case SDLK_DOWN:
2511 break;
2512
2513 case SDLK_END:
2515 break;
2516
2517 case SDLK_LEFT:
2519 break;
2520
2521 case SDLK_HOME:
2523 break;
2524
2525 /* *** Map view settings *** */
2526
2527 /* Show city outlines - Ctrl+y */
2528 case SDLK_Y:
2529 if (LCTRL || RCTRL) {
2531 }
2532 return FALSE;
2533
2534 /* Show map grid - Ctrl+g */
2535 case SDLK_G:
2536 if (LCTRL || RCTRL) {
2538 }
2539 return FALSE;
2540
2541 /* Show national borders - Ctrl+b */
2542 case SDLK_B:
2543 if (LCTRL || RCTRL) {
2545 }
2546 return FALSE;
2547
2548 case SDLK_N:
2549 /* Show native tiles - Ctrl+Shift+n */
2550 if ((LCTRL || RCTRL) && (LSHIFT || RSHIFT)) {
2552 } else if (LCTRL || RCTRL) {
2553 /* show city names - Ctrl+n */
2555 }
2556 return FALSE;
2557
2558 /* Show city growth Ctrl+o */
2559 /* Show pollution - Ctrl+Shift+o */
2560 case SDLK_O:
2561 if (LCTRL || RCTRL) {
2562 if (LSHIFT || RSHIFT) {
2564 } else {
2566 }
2567 }
2568 return FALSE;
2569
2570 /* Show bases - Ctrl+Shift+f */
2571 case SDLK_F:
2572 if ((LCTRL || RCTRL) && (LSHIFT || RSHIFT)) {
2574 }
2575 return FALSE;
2576
2577 /* Show city productions - Ctrl+p */
2578 case SDLK_P:
2579 if (LCTRL || RCTRL) {
2581 }
2582 return FALSE;
2583
2584 /* Show city trade routes - Ctrl+d */
2585 case SDLK_D:
2586 if (LCTRL || RCTRL) {
2588 }
2589 return FALSE;
2590
2591 /* *** Some additional shortcuts that work in the SDL client only *** */
2592
2593 /* Show terrain - Ctrl+Shift+t */
2594 case SDLK_T:
2595 if ((LCTRL || RCTRL) && (LSHIFT || RSHIFT)) {
2597 }
2598 return FALSE;
2599
2600 /* (Show coastline) */
2601
2602 /* (Show roads and rails) */
2603
2604 /* Show irrigation - Ctrl+i */
2605 case SDLK_I:
2606 if (LCTRL || RCTRL) {
2608 }
2609 return FALSE;
2610
2611 /* Show mines - Ctrl+m */
2612 case SDLK_M:
2613 if (LCTRL || RCTRL) {
2615 }
2616 return FALSE;
2617
2618 /* Show resources - Ctrl+s */
2619 case SDLK_S:
2620 if (LCTRL || RCTRL) {
2622 }
2623 return FALSE;
2624
2625 /* Show huts - Ctrl+h */
2626 case SDLK_H:
2627 if (LCTRL || RCTRL) {
2629 }
2630 return FALSE;
2631
2632 /* Show cities - Ctrl+c */
2633 case SDLK_C:
2634 if (LCTRL || RCTRL) {
2636 } else {
2638 }
2639 return FALSE;
2640
2641 /* Show units - Ctrl+u */
2642 case SDLK_U:
2643 if (LCTRL || RCTRL) {
2645 }
2646 return FALSE;
2647
2648 /* (Show focus unit) */
2649
2650 /* Show city output - Ctrl+v */
2651 case SDLK_V:
2653 return FALSE;
2654
2655 /* Show fog of war - Ctrl+w */
2656 case SDLK_W:
2657 if (LCTRL || RCTRL) {
2659 }
2660 return FALSE;
2661
2662 default:
2663 break;
2664 }
2665 }
2666
2667 if (movedir != DIR8_MAGIC_MAX) {
2668 if (!is_unit_move_blocked) {
2670 }
2671 return FALSE;
2672 }
2673 }
2674
2675 return TRUE;
2676}
2677
2678/**********************************************************************/
2681static int newcity_name_edit_callback(struct widget *pedit)
2682{
2685 /* empty input -> restore previous content */
2687 widget_redraw(pedit);
2688 widget_mark_dirty(pedit);
2689 flush_dirty();
2690 }
2691 }
2692
2693 return -1;
2694}
2695
2696/**********************************************************************/
2699static int newcity_ok_callback(struct widget *ok_button)
2700{
2702
2703 finish_city(ok_button->data.tile,
2705
2709
2711
2712 flush_dirty();
2713 }
2714
2715 return -1;
2716}
2717
2718/**********************************************************************/
2721static int newcity_cancel_callback(struct widget *cancel_button)
2722{
2726
2727 cancel_city(cancel_button->data.tile);
2728
2730
2732
2733 flush_dirty();
2734 }
2735
2736 return -1;
2737}
2738
2739/**********************************************************************/
2742static int move_new_city_dlg_callback(struct widget *pwindow)
2743{
2746 }
2747
2748 return -1;
2749}
2750
2751/* ============================== Native =============================== */
2752
2753
2754/**********************************************************************/
2759{
2760 SDL_Surface *background;
2761 utf8_str *pstr = NULL;
2762 struct widget *label = NULL;
2763 struct widget *pwindow = NULL;
2764 struct widget *cancel_button = NULL;
2765 struct widget *ok_button;
2766 struct widget *pedit;
2767 SDL_Rect area;
2768 int suggestlen;
2769
2770 if (new_city_dlg) {
2771 return;
2772 }
2773
2777
2778 new_city_dlg = fc_calloc(1, sizeof(struct small_dialog));
2779
2780 /* Create window */
2783 pstr->style |= TTF_STYLE_BOLD;
2784 pwindow = create_window_skeleton(NULL, pstr, 0);
2786
2787 area = pwindow->area;
2788
2789 /* Create ok button */
2790 ok_button =
2792 pwindow->dst,
2793 _("OK"), FONTO_DEFAULT, 0);
2794 ok_button->action = newcity_ok_callback;
2795 ok_button->key = SDLK_RETURN;
2796 ok_button->data.tile = unit_tile(punit);
2797
2798 area.h += ok_button->size.h;
2799
2800 /* Create cancel button */
2801 cancel_button =
2803 pwindow->dst, _("Cancel"),
2804 FONTO_DEFAULT, 0);
2805 cancel_button->action = newcity_cancel_callback;
2806 cancel_button->key = SDLK_ESCAPE;
2807 cancel_button->data.tile = unit_tile(punit);
2808
2809 /* Correct sizes */
2810 cancel_button->size.w += adj_size(5);
2811 ok_button->size.w = cancel_button->size.w;
2812
2813 /* Create text label */
2814 pstr = create_utf8_from_char_fonto(_("What should we call our new city?"),
2816 pstr->style |= (TTF_STYLE_BOLD|SF_CENTER);
2818 label = create_iconlabel(NULL, pwindow->dst, pstr,
2820
2821 area.h += label->size.h;
2822
2823 pedit = create_edit(NULL, pwindow->dst,
2825 (ok_button->size.w + cancel_button->size.w + adj_size(15)),
2828
2829 area.w = MAX(area.w, pedit->size.w + adj_size(20));
2830 area.h += pedit->size.h + adj_size(25);
2831
2832 /* I make this hack to center label on window */
2833 if (label->size.w < area.w) {
2834 label->size.w = area.w;
2835 } else {
2836 area.w = MAX(pwindow->area.w, label->size.w + adj_size(10));
2837 }
2838
2839 pedit->size.w = area.w - adj_size(20);
2840
2841 /* Create window background */
2843 if (resize_window(pwindow, background, NULL,
2844 (pwindow->size.w - pwindow->area.w) + area.w,
2845 (pwindow->size.h - pwindow->area.h) + area.h)) {
2846 FREESURFACE(background);
2847 }
2848
2849 area = pwindow->area;
2850
2851 /* set start positions */
2852 widget_set_position(pwindow,
2853 (main_window_width() - pwindow->size.w) / 2,
2854 (main_window_height() - pwindow->size.h) / 2);
2855
2856 ok_button->size.x = area.x + adj_size(10);
2857 ok_button->size.y = area.y + area.h - ok_button->size.h - adj_size(10);
2858
2859 cancel_button->size.y = ok_button->size.y;
2860 cancel_button->size.x = area.x + area.w - cancel_button->size.w - adj_size(10);
2861
2862 pedit->size.x = area.x + adj_size(10);
2863 pedit->size.y = area.y + adj_size(4) + label->size.h + adj_size(3);
2864
2865 label->size.x = area.x + adj_size(3);
2866 label->size.y = area.y + adj_size(4);
2867
2868 /* enable widgets */
2869 set_wstate(cancel_button, FC_WS_NORMAL);
2870 set_wstate(ok_button, FC_WS_NORMAL);
2871 set_wstate(pedit, FC_WS_NORMAL);
2872 set_wstate(pwindow, FC_WS_NORMAL);
2873
2874 /* add widgets to main list */
2875 new_city_dlg->end_widget_list = pwindow;
2882
2883 /* redraw */
2884 redraw_group(pedit, pwindow, 0);
2885
2886 widget_flush(pwindow);
2887}
2888
2889/**********************************************************************/
2901
2902/**********************************************************************/
2920
2921/**********************************************************************/
2925{
2926 float pos_x, pos_y;
2927
2928 SDL_GetMouseState(&pos_x, &pos_y);
2929 update_line(pos_x, pos_y);
2931}
2932
2933/**********************************************************************/
2938{
2939 /* PORTME */
2940}
const char * action_id_name_translation(action_id act_id)
Definition actions.c:2011
#define city_owner(_pcity_)
Definition city.h:563
struct civclient client
enum client_states client_state(void)
bool can_client_issue_orders(void)
@ C_S_RUNNING
Definition client_main.h:47
struct sprite * client_warming_sprite(void)
Definition climisc.c:377
struct sprite * client_cooling_sprite(void)
Definition climisc.c:394
struct sprite * client_research_sprite(void)
Definition climisc.c:354
struct sprite * client_government_sprite(void)
Definition climisc.c:412
char * incite_cost
Definition comments.c:75
void key_irrigation_toggle(void)
Definition control.c:3968
void key_recall_previous_focus_unit(void)
Definition control.c:3320
void key_city_output_toggle(void)
Definition control.c:3853
void key_cancel_action(void)
Definition control.c:3258
void key_map_native_toggle(void)
Definition control.c:3877
void key_resources_toggle(void)
Definition control.c:3992
struct unit_list * get_units_in_focus(void)
Definition control.c:177
void key_end_turn(void)
Definition control.c:3312
void request_center_focus_unit(void)
Definition control.c:2750
void key_city_productions_toggle(void)
Definition control.c:3919
void key_unit_move(enum direction8 gui_dir)
Definition control.c:3341
void key_city_outlines_toggle(void)
Definition control.c:3845
void key_terrain_toggle(void)
Definition control.c:3944
void key_huts_toggle(void)
Definition control.c:4000
void key_fog_of_war_toggle(void)
Definition control.c:4056
void key_unit_wait(void)
Definition control.c:3542
void key_units_toggle(void)
Definition control.c:4024
void request_toggle_bases(void)
Definition control.c:2619
void key_map_grid_toggle(void)
Definition control.c:3861
void finish_city(struct tile *ptile, const char *name)
Definition control.c:4091
void key_pollution_toggle(void)
Definition control.c:4008
struct unit * head_of_units_in_focus(void)
Definition control.c:410
void key_city_growth_toggle(void)
Definition control.c:3902
int get_num_units_in_focus(void)
Definition control.c:185
void key_city_trade_routes_toggle(void)
Definition control.c:3928
void key_city_names_toggle(void)
Definition control.c:3893
void key_unit_goto(void)
Definition control.c:3471
void request_toggle_cities(void)
Definition control.c:2671
void cancel_city(struct tile *ptile)
Definition control.c:4110
void key_mines_toggle(void)
Definition control.c:3976
void key_map_borders_toggle(void)
Definition control.c:3869
@ SELECT_POPUP
Definition control.h:38
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
QString current_theme
Definition fc_client.cpp:65
#define DIR8_MAGIC_MAX
Definition fc_types.h:471
@ O_GOLD
Definition fc_types.h:101
#define _(String)
Definition fcintl.h:67
struct world wld
Definition game.c:63
void city_report_dialog_popup(bool raise)
Definition cityrep.c:292
void popup_find_dialog(void)
Definition finddlg.c:58
void popup_newcity_dialog(struct unit *punit, const char *suggestname)
Definition mapctrl.c:197
void create_line_at_mouse_pos(void)
Definition mapctrl.c:355
void set_turn_done_button_state(bool state)
Definition mapctrl.c:210
void update_rect_at_mouse_pos(void)
Definition mapctrl.c:380
void flush_dirty(void)
Definition mapview.c:468
void update_unit_info_label(struct unit_list *punits)
Definition mapview.c:275
void update_mouse_cursor(enum cursor_type new_cursor_type)
Definition mapview.c:257
void meswin_dialog_popdown(void)
Definition messagewin.c:432
void meswin_dialog_popup(bool raise)
Definition messagewin.c:417
bool meswin_dialog_is_open(void)
Definition messagewin.c:443
enum client_pages get_current_client_page(void)
Definition pages.c:3345
void popup_players_dialog(bool raise)
Definition plrdlg.c:91
void science_report_dialog_popup(bool raise)
Definition repodlgs.c:716
void economy_report_dialog_popup(bool raise)
Definition repodlgs.c:1243
void units_report_dialog_popup(bool raise)
Definition repodlgs.c:1768
void popup_hurry_production_dialog(struct city *pcity, SDL_Surface *pdest)
Definition citydlg.c:1176
SDL_Color * get_theme_color(enum theme_color themecolor)
Definition colors.c:47
void popup_government_dialog(void)
Definition dialogs.c:2452
void popup_advanced_terrain_dialog(struct tile *ptile, Uint16 pos_x, Uint16 pos_y)
Definition dialogs.c:1697
SDL_Surface * resize_surface(const SDL_Surface *psrc, Uint16 new_width, Uint16 new_height, int smooth)
Definition graphics.c:1237
int main_window_width(void)
Definition graphics.c:685
int alphablit(SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect, unsigned char alpha_mod)
Definition graphics.c:199
struct sdl2_data main_data
Definition graphics.c:57
int blit_entire_src(SDL_Surface *psrc, SDL_Surface *pdest, Sint16 dest_x, Sint16 dest_y)
Definition graphics.c:417
SDL_Surface * create_surf(int width, int height, Uint32 flags)
Definition graphics.c:351
int clear_surface(SDL_Surface *surf, SDL_Rect *dstrect)
Definition graphics.c:400
int main_window_height(void)
Definition graphics.c:693
#define FREESURFACE(ptr)
Definition graphics.h:322
#define adj_surf(surf)
Definition graphics.h:200
#define map_rgba(format, color)
Definition graphics.h:315
@ ID_REVOLUTION
Definition gui_id.h:132
@ ID_CHATLINE_TOGGLE_LOG_WINDOW_BUTTON
Definition gui_id.h:58
@ ID_NEWCITY_NAME_OK_BUTTON
Definition gui_id.h:126
@ ID_COOLING_ICON
Definition gui_id.h:138
@ ID_NEWCITY_NAME_WINDOW
Definition gui_id.h:124
@ ID_CLIENT_OPTIONS
Definition gui_id.h:38
@ ID_UNITS
Definition gui_id.h:131
@ ID_NEW_TURN
Definition gui_id.h:137
@ ID_TOGGLE_MAP_WINDOW_BUTTON
Definition gui_id.h:85
@ ID_NEWCITY_NAME_CANCEL_BUTTON
Definition gui_id.h:127
@ ID_MINI_MAP_WINDOW
Definition gui_id.h:84
@ ID_CITIES
Definition gui_id.h:129
@ ID_ECONOMY
Definition gui_id.h:133
@ ID_BUTTON
Definition gui_id.h:29
@ ID_WARMING_ICON
Definition gui_id.h:139
@ ID_TOGGLE_UNITS_WINDOW_BUTTON
Definition gui_id.h:83
@ ID_NEWCITY_NAME_LABEL
Definition gui_id.h:128
@ ID_LABEL
Definition gui_id.h:27
@ ID_PLAYERS
Definition gui_id.h:130
@ ID_RESEARCH
Definition gui_id.h:136
@ ID_NEWCITY_NAME_EDIT
Definition gui_id.h:125
@ ID_WINDOW
Definition gui_id.h:30
@ ID_UNITS_WINDOW
Definition gui_id.h:82
static struct mouse_button_behavior button_behavior
Definition gui_main.c:130
bool LSHIFT
Definition gui_main.c:108
bool RSHIFT
Definition gui_main.c:109
bool LALT
Definition gui_main.c:112
bool LCTRL
Definition gui_main.c:110
void disable_focus_animation(void)
Definition gui_main.c:1204
bool RCTRL
Definition gui_main.c:111
#define CF_MAP_UNIT_W_CREATED
Definition gui_main.h:46
@ MB_HOLD_LONG
Definition gui_main.h:80
@ MB_HOLD_MEDIUM
Definition gui_main.h:79
@ MB_HOLD_SHORT
Definition gui_main.h:78
struct widget * selected_widget
Definition widget.c:48
#define CF_OVERVIEW_SHOWN
Definition gui_main.h:48
#define adj_size(size)
Definition gui_main.h:141
#define PRESSED_EVENT(event)
Definition gui_main.h:71
#define CF_UNITINFO_SHOWN
Definition gui_main.h:47
utf8_str * copy_chars_to_utf8_str(utf8_str *pstr, const char *pchars)
Definition gui_string.c:251
SDL_Surface * create_text_surf_from_utf8(utf8_str *pstr)
Definition gui_string.c:425
#define FREEUTF8STR(pstr)
Definition gui_string.h:93
#define SF_CENTER
Definition gui_string.h:40
@ FONTO_DEFAULT
Definition gui_string.h:65
@ FONTO_ATTENTION
Definition gui_string.h:67
@ FONTO_MAX
Definition gui_string.h:71
#define create_utf8_from_char_fonto(string_in, fonto)
Definition gui_string.h:108
static SDL_Surface * get_tax_surface(Output_type_id otype)
struct widget * options_button
Definition optiondlg.c:103
void popdown_newcity_dialog(void)
Definition mapctrl.c:2897
struct widget * get_minimap_window_widget(void)
Definition mapctrl.c:2203
static struct widget * minimap_window
Definition mapctrl.c:107
int unitinfo_h
Definition mapctrl.c:102
static int toggle_unit_info_window_callback(struct widget *icon_widget)
Definition mapctrl.c:261
static int unit_info_window_callback(struct widget *pwidget)
Definition mapctrl.c:1298
static int toggle_map_window_callback(struct widget *map_button)
Definition mapctrl.c:391
void button_down_on_map(struct mouse_button_behavior *button_behavior)
Definition mapctrl.c:2280
struct widget * get_research_widget(void)
Definition mapctrl.c:2219
int overview_w
Definition mapctrl.c:99
void button_up_on_map(struct mouse_button_behavior *button_behavior)
Definition mapctrl.c:2351
static void enable_minimap_widgets(void)
Definition mapctrl.c:2117
void enable_main_widgets(void)
Definition mapctrl.c:2180
bool is_unit_move_blocked
Definition gui_main.c:107
void finger_up_on_map(struct finger_behavior *finger_behavior)
Definition mapctrl.c:2267
int resize_minimap(void)
Definition mapctrl.c:554
struct widget * get_unit_info_window_widget(void)
Definition mapctrl.c:2195
static int minimap_window_callback(struct widget *pwidget)
Definition mapctrl.c:1262
void close_game_page(void)
Definition mapctrl.c:2021
void enable_and_redraw_revolution_button(void)
Definition mapctrl.c:2245
bool map_event_handler(SDL_Keysym key)
Definition mapctrl.c:2445
void show_game_page(void)
Definition mapctrl.c:1958
int overview_h
Definition mapctrl.c:100
struct widget * get_revolution_widget(void)
Definition mapctrl.c:2227
static struct widget * new_turn_button
Definition mapctrl.c:105
void popup_minimap_window(void)
Definition mapctrl.c:1650
bool draw_goto_patrol_lines
Definition mapctrl.c:104
static int revolution_callback(struct widget *button)
Definition mapctrl.c:220
static int newcity_cancel_callback(struct widget *cancel_button)
Definition mapctrl.c:2726
static struct advanced_dialog * minimap_dlg
Definition mapctrl.c:96
void hide_unitinfo_window_buttons(void)
Definition mapctrl.c:1593
static void disable_unitinfo_widgets(void)
Definition mapctrl.c:2089
static int research_callback(struct widget *button)
Definition mapctrl.c:235
int unitinfo_w
Definition mapctrl.c:101
static struct small_dialog * new_city_dlg
Definition mapctrl.c:81
static int players_action_callback(struct widget *pwidget)
Definition mapctrl.c:123
void disable_main_widgets(void)
Definition mapctrl.c:2102
void disable_minimap_window_buttons(void)
Definition mapctrl.c:1911
static int move_new_city_dlg_callback(struct widget *pwindow)
Definition mapctrl.c:2747
static int economy_callback(struct widget *button)
Definition mapctrl.c:247
static int toggle_msg_window_callback(struct widget *pwidget)
Definition mapctrl.c:529
static struct widget * research_button
Definition mapctrl.c:111
static int cities_action_callback(struct widget *button)
Definition mapctrl.c:170
static struct advanced_dialog * unit_info_dlg
Definition mapctrl.c:97
void enable_and_redraw_find_city_button(void)
Definition mapctrl.c:2235
void show_minimap_window_buttons(void)
Definition mapctrl.c:1798
void set_new_minimap_window_pos(void)
Definition mapctrl.c:1386
static char * suggested_city_name
Definition mapctrl.c:80
void hide_minimap_window_buttons(void)
Definition mapctrl.c:1836
static int newcity_ok_callback(struct widget *ok_button)
Definition mapctrl.c:2704
static struct widget * revolution_button
Definition mapctrl.c:109
void show_unitinfo_window_buttons(void)
Definition mapctrl.c:1569
void popdown_minimap_window(void)
Definition mapctrl.c:1945
void disable_unitinfo_window_buttons(void)
Definition mapctrl.c:1617
void set_new_unitinfo_window_pos(void)
Definition mapctrl.c:1332
int overview_start_x
Definition mapview.c:73
static int newcity_name_edit_callback(struct widget *pedit)
Definition mapctrl.c:2686
void popdown_unitinfo_window(void)
Definition mapctrl.c:1637
static struct widget * tax_button
Definition mapctrl.c:110
static void disable_minimap_widgets(void)
Definition mapctrl.c:2044
static struct widget * find_city_button
Definition mapctrl.c:108
static int end_turn_callback(struct widget *button)
Definition mapctrl.c:205
void popup_unitinfo_window(void)
Definition mapctrl.c:1454
void redraw_minimap_window_buttons(void)
Definition mapctrl.c:1874
void finger_down_on_map(struct finger_behavior *finger_behavior)
Definition mapctrl.c:2254
static struct widget * units_info_window
Definition mapctrl.c:106
static void enable_unitinfo_widgets(void)
Definition mapctrl.c:2163
int overview_start_y
Definition mapview.c:74
struct widget * get_tax_rates_widget(void)
Definition mapctrl.c:2211
static int units_action_callback(struct widget *pwidget)
Definition mapctrl.c:155
int resize_unit_info(void)
#define DEFAULT_UNITS_W
Definition mapctrl.h:55
#define DEFAULT_UNITS_H
Definition mapctrl.h:56
#define BLOCKU_W
Definition mapctrl.h:52
#define BLOCKM_W
Definition mapctrl.h:51
void refresh_overview(void)
Definition mapview.c:1124
void redraw_unit_info_label(struct unit_list *punitlist)
Definition mapview.c:522
void create_units_order_widgets(void)
Definition menu.c:398
void disable_order_buttons(void)
Definition menu.c:1462
void undraw_order_widgets(void)
Definition menu.c:961
void enable_order_buttons(void)
Definition menu.c:1472
void delete_units_order_widgets(void)
Definition menu.c:940
void update_order_widgets(void)
Definition menu.c:952
void enable_options_button(void)
Definition optiondlg.c:1366
void init_options_button(void)
Definition optiondlg.c:1382
void disable_options_button(void)
Definition optiondlg.c:1374
int optiondlg_callback(struct widget *pbutton)
Definition optiondlg.c:1345
void popup_players_nations_dialog(void)
Definition plrdlg.c:668
#define GET_SURF(m_sprite)
Definition sprite.h:29
SDL_Surface * theme_get_background(const struct theme *t, enum theme_background background)
@ BACKGROUND_NEWCITYDLG
@ COLOR_THEME_BACKGROUND
Definition themecolors.h:23
@ COLOR_THEME_NEWCITYDLG_TEXT
struct theme * active_theme
Definition themespec.c:154
void set_group_state(struct widget *begin_group_widget_list, struct widget *end_group_widget_list, enum widget_state state)
Definition widget.c:898
void add_to_gui_list(Uint16 id, struct widget *gui)
Definition widget.c:586
struct widget * get_widget_pointer_from_main_list(Uint16 id)
Definition widget.c:578
void draw_frame(SDL_Surface *pdest, Sint16 start_x, Sint16 start_y, Uint16 w, Uint16 h)
Definition widget.c:1114
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
void popdown_window_group_dialog(struct widget *begin_group_widget_list, struct widget *end_group_widget_list)
Definition widget.c:983
void move_window_group(struct widget *begin_widget_list, struct widget *pwindow)
Definition widget.c:1039
static void widget_set_position(struct widget *pwidget, int x, int y)
Definition widget.h:266
@ FC_WS_DISABLED
Definition widget.h:99
@ FC_WS_NORMAL
Definition widget.h:96
@ FC_WS_SELECTED
Definition widget.h:97
void clear_wflag(struct widget *pwidget, enum widget_flag flag)
Definition widget_core.c:62
static void widget_mark_dirty(struct widget *pwidget)
Definition widget.h:286
static void widget_flush(struct widget *pwidget)
Definition widget.h:291
void set_wstate(struct widget *pwidget, enum widget_state state)
Definition widget_core.c:36
static void widget_undraw(struct widget *pwidget)
Definition widget.h:296
@ WF_FREE_GFX
Definition widget.h:70
@ WF_WIDGET_HAS_INFO_LABEL
Definition widget.h:88
@ WF_RESTORE_BACKGROUND
Definition widget.h:85
@ WF_HIDDEN
Definition widget.h:68
@ WF_FREE_THEME
Definition widget.h:72
@ WF_DRAW_TEXT_LABEL_WITH_SPACE
Definition widget.h:87
static int widget_redraw(struct widget *pwidget)
Definition widget.h:276
#define del_widget_from_gui_list(__gui)
Definition widget.h:372
static void widget_set_area(struct widget *pwidget, SDL_Rect area)
Definition widget.h:261
void set_wflag(struct widget *pwidget, enum widget_flag flag)
Definition widget_core.c:54
#define del_group(begin_group_widget_list, end_group_widget_list)
Definition widget.h:389
struct widget * create_themeicon_button(SDL_Surface *icon_theme, struct gui_layer *pdest, utf8_str *pstr, Uint32 flags)
#define create_themeicon_button_from_chars_fonto(icon_theme, pdest, char_string, fonto, flags)
struct widget * create_edit(SDL_Surface *background, struct gui_layer *pdest, utf8_str *pstr, int length, Uint32 flags)
struct widget * create_themeicon(SDL_Surface *icon_theme, struct gui_layer *pdest, Uint32 flags)
struct widget * create_icon2(SDL_Surface *icon, struct gui_layer *pdest, Uint32 flags)
struct widget * create_iconlabel(SDL_Surface *icon, struct gui_layer *pdest, utf8_str *pstr, Uint32 flags)
#define hide_scrollbar(scrollbar)
bool resize_window(struct widget *pwindow, SDL_Surface *bcgd, SDL_Color *pcolor, Uint16 new_w, Uint16 new_h)
struct widget * create_window_skeleton(struct gui_layer *pdest, utf8_str *title, Uint32 flags)
void popup_worklist_editor(struct city *pcity, struct global_worklist *gwl)
Definition wldlg.c:1055
Uint32 sdl3_client_flags
Definition gui_main.c:97
#define fc_assert(condition)
Definition log.h:176
struct tile * map_pos_to_tile(const struct civ_map *nmap, int map_x, int map_y)
Definition map.c:419
void update_line(int canvas_x, int canvas_y)
void recenter_button_pressed(int canvas_x, int canvas_y)
void action_button_pressed(int canvas_x, int canvas_y, enum quickselect_type qtype)
struct tile * canvas_pos_to_tile(float canvas_x, float canvas_y, float zoom)
void center_tile_mapcanvas(const struct tile *ptile)
#define fc_calloc(n, esz)
Definition mem.h:38
#define FC_FREE(ptr)
Definition mem.h:41
void menus_update(void)
struct client_options gui_options
Definition options.c:71
void overview_to_map_pos(int *map_x, int *map_y, int overview_x, int overview_y)
void calculate_overview_dimensions(void)
#define OVERVIEW_TILE_WIDTH
#define OVERVIEW_TILE_HEIGHT
#define MAX(x, y)
Definition shared.h:54
struct widget * begin_active_widget_list
Definition widget.h:184
struct widget * end_widget_list
Definition widget.h:182
struct widget * end_active_widget_list
Definition widget.h:185
struct scroll_bar * scroll
Definition widget.h:187
struct widget * begin_widget_list
Definition widget.h:181
Definition city.h:320
struct connection conn
Definition client_main.h:96
struct overview overview
Definition options.h:425
struct player * playing
Definition connection.h:151
SDL_TouchFingerEvent event
Definition gui_main.h:87
SDL_Surface * surface
Definition graphics.h:229
SDL_Rect dest_rect
Definition graphics.h:228
enum mouse_button_hold_state hold_state
Definition gui_main.h:94
SDL_MouseButtonEvent * event
Definition gui_main.h:95
int width
Definition options.h:94
int height
Definition options.h:94
struct gui_layer * gui
Definition graphics.h:215
SDL_Event event
Definition graphics.h:217
SDL_Window * screen
Definition graphics.h:209
struct widget * begin_widget_list
Definition widget.h:175
struct widget * end_widget_list
Definition widget.h:176
Definition tile.h:50
Definition unit.h:138
Uint8 style
Definition gui_string.h:53
char * text
Definition gui_string.h:60
union widget::@194 data
SDL_Keycode key
Definition widget.h:153
SDL_Surface * theme
Definition widget.h:118
struct tile * tile
Definition widget.h:131
struct widget * prev
Definition widget.h:114
struct gui_layer * dst
Definition widget.h:116
Uint16 mod
Definition widget.h:154
struct advanced_dialog * adv_dlg
Definition widget.h:139
utf8_str * string_utf8
Definition widget.h:121
int(* action)(struct widget *)
Definition widget.h:157
union widget::@195 private_data
SDL_Rect area
Definition widget.h:149
SDL_Surface * gfx
Definition widget.h:120
struct widget * next
Definition widget.h:113
utf8_str * info_label
Definition widget.h:122
SDL_Rect size
Definition widget.h:145
struct civ_map map
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:974
size_t fc_strlcpy(char *dest, const char *src, size_t n)
Definition support.c:791
#define TRUE
Definition support.h:46
#define FALSE
Definition support.h:47
struct city * tile_city(const struct tile *ptile)
Definition tile.c:83
@ CURSOR_GOTO
Definition tilespec.h:288
@ CURSOR_DEFAULT
Definition tilespec.h:300
#define unit_tile(_pu)
Definition unit.h:397
bool update_queue_is_switching_page(void)
float mouse_zoom
Definition zoom.c:28