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/* SDL2 */
27#ifdef SDL2_PLAIN_INCLUDE
28#include <SDL.h>
29#else /* SDL2_PLAIN_INCLUDE */
30#include <SDL2/SDL.h>
31#endif /* SDL2_PLAIN_INCLUDE */
32
33/* utility */
34#include "fcintl.h"
35#include "log.h"
36
37/* common */
38#include "unit.h"
39#include "unitlist.h"
40
41/* client */
42#include "client_main.h"
43#include "climisc.h"
44#include "overview_common.h"
45#include "update_queue.h"
46#include "zoom.h"
47
48/* client/gui-sdl2 */
49#include "citydlg.h"
50#include "cityrep.h"
51#include "colors.h"
52#include "dialogs.h"
53#include "finddlg.h"
54#include "graphics.h"
55#include "gui_id.h"
56#include "gui_main.h"
57#include "gui_mouse.h"
58#include "gui_tilespec.h"
59#include "mapview.h"
60#include "menu.h"
61#include "messagewin.h"
62#include "optiondlg.h"
63#include "pages.h"
64#include "plrdlg.h"
65#include "repodlgs.h"
66#include "sprite.h"
67#include "themespec.h"
68#include "widget.h"
69#include "wldlg.h"
70
71#include "mapctrl.h"
72
73#undef SCALE_MINIMAP
74#undef SCALE_UNITINFO
75
76extern int overview_start_x;
77extern int overview_start_y;
78extern bool is_unit_move_blocked;
79
82extern struct widget *options_button;
83
84#ifdef SCALE_MINIMAP
85static struct small_dialog *scale_minimap_dlg = NULL;
86static int popdown_scale_minmap_dlg_callback(struct widget *pwidget);
87#endif /* SCALE_MINIMAP */
88
89#ifdef SCALE_UNITINFO
92static int popdown_scale_unitinfo_dlg_callback(struct widget *pwidget);
93static void remake_unitinfo(int w, int h);
94#endif /* SCALE_UNITINFO */
95
98
99int overview_w = 0;
103
105static struct widget *new_turn_button = NULL;
107static struct widget *minimap_window = NULL;
108static struct widget *find_city_button = NULL;
110static struct widget *tax_button = NULL;
111static struct widget *research_button = NULL;
112
113static void enable_minimap_widgets(void);
114static void disable_minimap_widgets(void);
115static void enable_unitinfo_widgets(void);
116static void disable_unitinfo_widgets(void);
117
118/* ================================================================ */
119
120/**********************************************************************/
123static int players_action_callback(struct widget *pwidget)
124{
125 set_wstate(pwidget, FC_WS_NORMAL);
126 widget_redraw(pwidget);
127 widget_mark_dirty(pwidget);
128 if (main_data.event.type == SDL_MOUSEBUTTONDOWN) {
129 switch (main_data.event.button.button) {
130#if 0
131 case SDL_BUTTON_LEFT:
132
133 break;
135
136 break;
137#endif /* 0 */
138 case SDL_BUTTON_RIGHT:
140 break;
141 default:
143 break;
144 }
145 } else {
147 }
148
149 return -1;
150}
151
152/**********************************************************************/
155static int units_action_callback(struct widget *pwidget)
156{
158 set_wstate(pwidget, FC_WS_NORMAL);
159 widget_redraw(pwidget);
160 widget_mark_dirty(pwidget);
162 }
163
164 return -1;
165}
166
167/**********************************************************************/
170static int cities_action_callback(struct widget *button)
171{
172 set_wstate(button, FC_WS_DISABLED);
173 widget_redraw(button);
174 widget_mark_dirty(button);
175 if (main_data.event.type == SDL_KEYDOWN) {
176 /* Ctrl-F shortcut */
178 } else if (main_data.event.type == SDL_MOUSEBUTTONDOWN) {
179 switch (main_data.event.button.button) {
180#if 0
181 case SDL_BUTTON_LEFT:
182
183 break;
185
186 break;
187#endif /* 0 */
188 case SDL_BUTTON_RIGHT:
190 break;
191 default:
193 break;
194 }
195 } else if (PRESSED_EVENT(main_data.event)) {
197 }
198
199 return -1;
200}
201
202/**********************************************************************/
205static int end_turn_callback(struct widget *button)
206{
208 widget_redraw(button);
209 widget_flush(button);
211 key_end_turn();
212 }
213
214 return -1;
215}
216
217/**********************************************************************/
220static int revolution_callback(struct widget *button)
221{
223 set_wstate(button, FC_WS_DISABLED);
224 widget_redraw(button);
225 widget_mark_dirty(button);
227 }
228
229 return -1;
230}
231
232/**********************************************************************/
235static int research_callback(struct widget *button)
236{
239 }
240
241 return -1;
242}
243
244/**********************************************************************/
247static int economy_callback(struct widget *button)
248{
251 }
252
253 return -1;
254}
255
256/* ====================================== */
257
258/**********************************************************************/
262{
264 struct widget *buf = NULL;
265
267 alphablit(current_theme->map_icon, NULL, icon_widget->theme, NULL, 255);
268
269 if (get_num_units_in_focus() > 0) {
271 }
272
274 /* HIDE */
277
280
284 }
287 }
288
289 /* clear area under old unit info window */
292
293 /* new button direction */
294 alphablit(current_theme->l_arrow_icon, NULL, icon_widget->theme, NULL,
295 255);
296
298 _("Show Unit Info Window"));
299
301
303
304 /* blit part of map window */
305 src.x = 0;
306 src.y = 0;
308 src.h = units_info_window->theme->h;
309
313
314 /* blit right vertical frame */
316 current_theme->fr_right->w,
317 units_info_window->area.h, 1);
318
324
325 /* redraw widgets */
326
327 /* ID_ECONOMY */
330
331 /* ===== */
332 /* ID_RESEARCH */
333 buf = buf->prev;
335
336 /* ===== */
337 /* ID_REVOLUTION */
338 buf = buf->prev;
340
341 /* ===== */
342 /* ID_TOGGLE_UNITS_WINDOW_BUTTON */
343 buf = buf->prev;
345
346#ifdef SCALE_UNITINFO
348#endif
349 } else {
352
355
356 /* SHOW */
358 _("Hide Unit Info Window"));
359
360 alphablit(current_theme->r_arrow_icon, NULL, icon_widget->theme, NULL,
361 255);
362
364
366
368
370 } else {
371 alphablit(current_theme->l_arrow_icon, NULL, icon_widget->theme, NULL,
372 255);
375 }
376 }
377
378 if (get_num_units_in_focus() > 0) {
380 }
381
382 flush_dirty();
383 }
384
385 return -1;
386}
387
388/**********************************************************************/
392{
394 struct unit *focus = head_of_units_in_focus();
395 struct widget *pwidget;
396
397 /* make new map icon */
399 alphablit(current_theme->map_icon, NULL, map_button->theme, NULL, 255);
400
402
403 if (focus) {
405 }
406
408 /* Hide MiniMap */
411
414
415 copy_chars_to_utf8_str(map_button->info_label, _("Show Mini Map"));
416
417 /* make new map icon */
418 alphablit(current_theme->r_arrow_icon, NULL, map_button->theme, NULL, 255);
419
421
422 /* clear area under old map window */
425
428
430
431 /* blit part of map window */
432 src.x = minimap_window->theme->w - BLOCKM_W - current_theme->fr_right->w;
433 src.y = 0;
434 src.w = BLOCKM_W + current_theme->fr_right->w;
435 src.h = minimap_window->theme->h;
436
439
440 /* blit left vertical frame theme */
442 current_theme->fr_left->w,
443 minimap_window->area.h, 1);
444
445 map_area.y += adj_size(2);
448
449 /* redraw widgets */
450 /* ID_NEW_TURN */
451 pwidget = minimap_window->prev;
452 widget_redraw(pwidget);
453
454 /* ID_PLAYERS */
455 pwidget = pwidget->prev;
456 widget_redraw(pwidget);
457
458 /* ID_CITIES */
459 pwidget = pwidget->prev;
460 widget_redraw(pwidget);
461
462 /* ID_UNITS */
463 pwidget = pwidget->prev;
464 widget_redraw(pwidget);
465
466 /* ID_CHATLINE_TOGGLE_LOG_WINDOW_BUTTON */
467 pwidget = pwidget->prev;
468 widget_redraw(pwidget);
469
470#ifdef SMALL_SCREEN
471 /* options */
472 pwidget = pwidget->prev;
473 widget_redraw(pwidget);
474#endif /* SMALL_SCREEN */
475
476 /* ID_TOGGLE_MAP_WINDOW_BUTTON */
477 pwidget = pwidget->prev;
478 widget_redraw(pwidget);
479
480#ifdef SCALE_MINIMAP
482#endif
483 } else {
484 if (((minimap_window->size.w - minimap_window->area.w) +
486
489
490 /* show MiniMap */
491 copy_chars_to_utf8_str(map_button->info_label, _("Hide Mini Map"));
492
493 alphablit(current_theme->l_arrow_icon, NULL, map_button->theme, NULL,
494 255);
496
500
502
506 } else {
507 alphablit(current_theme->r_arrow_icon, NULL, map_button->theme, NULL,
508 255);
511 }
512 }
513
514 if (focus) {
516 }
517
518 flush_dirty();
519 }
520
521 return -1;
522}
523
524/* ====================================================================== */
525
526/**********************************************************************/
529static int toggle_msg_window_callback(struct widget *pwidget)
530{
532 if (meswin_dialog_is_open()) {
534 copy_chars_to_utf8_str(pwidget->info_label, _("Show Messages (F9)"));
535 } else {
537 copy_chars_to_utf8_str(pwidget->info_label, _("Hide Messages (F9)"));
538 }
539
540 selected_widget = pwidget;
541 set_wstate(pwidget, FC_WS_SELECTED);
542 widget_redraw(pwidget);
543 widget_mark_dirty(pwidget);
544
545 flush_dirty();
546 }
547
548 return -1;
549}
550
551/**********************************************************************/
570
571#ifdef SCALE_MINIMAP
572/* ============================================================== */
573
574/**********************************************************************/
577static int move_scale_minimap_dlg_callback(struct widget *pwindow)
578{
580 move_window_group(scale_minimap_dlg->begin_widget_list, pwindow);
581 }
582
583 return -1;
584}
585
586/**********************************************************************/
589static int popdown_scale_minimap_dlg_callback(struct widget *pwidget)
590{
592 if (scale_minimap_dlg) {
594 scale_minimap_dlg->end_widget_list);
596 if (pwidget) {
597 flush_dirty();
598 }
599 }
600 }
601
602 return -1;
603}
604
605/**********************************************************************/
608static int up_width_callback(struct widget *pwidget)
609{
611 widget_redraw(pwidget);
612 widget_mark_dirty(pwidget);
613 if ((((OVERVIEW_TILE_WIDTH + 1) * map.xsize) +
616 char cbuf[4];
617
618 fc_snprintf(cbuf, sizeof(cbuf), "%d", OVERVIEW_TILE_WIDTH);
620 widget_redraw(pwidget->next);
621 widget_mark_dirty(pwidget->next);
622
625 }
626 flush_dirty();
627 }
628
629 return -1;
630}
631
632/**********************************************************************/
635static int down_width_callback(struct widget *pwidget)
636{
638 widget_redraw(pwidget);
639 widget_mark_dirty(pwidget);
640 if (OVERVIEW_TILE_WIDTH > 1) {
641 char cbuf[4];
642
643 fc_snprintf(cbuf, sizeof(cbuf), "%d", OVERVIEW_TILE_WIDTH);
645 widget_redraw(pwidget->prev);
646 widget_mark_dirty(pwidget->prev);
647
649 }
650 flush_dirty();
651 }
652
653 return -1;
654}
655
656/**********************************************************************/
659static int up_height_callback(struct widget *pwidget)
660{
662 widget_redraw(pwidget);
663 widget_mark_dirty(pwidget);
664 if (main_data.screen->h -
665 ((OVERVIEW_TILE_HEIGHT + 1) * map.ysize
666 + (current_theme->fr_bottom->h * 2)) >= 40) {
667 char cbuf[4];
668
670 fc_snprintf(cbuf, sizeof(cbuf), "%d", OVERVIEW_TILE_HEIGHT);
672 widget_redraw(pwidget->next);
673 widget_mark_dirty(pwidget->next);
675 }
676 flush_dirty();
677 }
678
679 return -1;
680}
681
682/**********************************************************************/
685static int down_height_callback(struct widget *pwidget)
686{
688 widget_redraw(pwidget);
689 widget_mark_dirty(pwidget);
690 if (OVERVIEW_TILE_HEIGHT > 1) {
691 char cbuf[4];
692
694 fc_snprintf(cbuf, sizeof(cbuf), "%d", OVERVIEW_TILE_HEIGHT);
696 widget_redraw(pwidget->prev);
697 widget_mark_dirty(pwidget->prev);
698
700 }
701 flush_dirty();
702 }
703
704 return -1;
705}
706
707/**********************************************************************/
710static void popup_minimap_scale_dialog(void)
711{
713 utf8_str *pstr = NULL;
714 struct widget *pwindow = NULL;
715 struct widget *buf = NULL;
716 char cbuf[4];
717 int window_x = 0, window_y = 0;
719
721 return;
722 }
723
724 scale_minimap_dlg = fc_calloc(1, sizeof(struct small_dialog));
725
726 /* Create window */
728 pstr->style |= TTF_STYLE_BOLD;
729 pwindow = create_window_skeleton(NULL, pstr, 0);
731 set_wstate(pwindow, FC_WS_NORMAL);
732 add_to_gui_list(ID_WINDOW, pwindow);
733 scale_minimap_dlg->end_widget_list = pwindow;
734
735 area = pwindow->area;
736
737 /* ----------------- */
738 pstr = create_utf8_from_char_fonto(_("Single Tile Width"), FONTO_ATTENTION);
740 area.w = MAX(area.w, text1->w + adj_size(30));
741
742 copy_chars_to_utf8_str(pstr, _("Single Tile Height"));
744 area.w = MAX(area.w, text2->w + adj_size(30));
746
747 buf = create_themeicon_button(current_theme->l_arrow_icon, pwindow->dst,
748 NULL, 0);
749 buf->action = down_width_callback;
752
753 fc_snprintf(cbuf, sizeof(cbuf), "%d" , OVERVIEW_TILE_WIDTH);
755 pstr->style |= (TTF_STYLE_BOLD|SF_CENTER);
757 buf->size.w = MAX(adj_size(50), buf->size.w);
758 area.h += buf->size.h + adj_size(5);
760
761 buf = create_themeicon_button(current_theme->r_arrow_icon, pwindow->dst,
762 NULL, 0);
763 buf->action = up_width_callback;
766
767 /* ------------ */
768 buf = create_themeicon_button(current_theme->l_arrow_icon, pwindow->dst,
769 NULL, 0);
770 buf->action = down_height_callback;
773
774 fc_snprintf(cbuf, sizeof(cbuf), "%d" , OVERVIEW_TILE_HEIGHT);
776 pstr->style |= (TTF_STYLE_BOLD|SF_CENTER);
778 buf->size.w = MAX(adj_size(50), buf->size.w);
779 area.h += buf->size.h + adj_size(20);
781
782 buf = create_themeicon_button(current_theme->r_arrow_icon, pwindow->dst,
783 NULL, 0);
784 buf->action = up_height_callback;
787 area.w = MAX(area.w , buf->size.w * 2 + buf->next->size.w + adj_size(20));
788
789 /* ------------ */
791 buf = create_themeicon_button(current_theme->cancel_icon, pwindow->dst,
792 pstr, 0);
795 scale_minimap_dlg->begin_widget_list = buf;
797 area.h += buf->size.h + adj_size(10);
798 area.w = MAX(area.w, buf->size.w + adj_size(20));
799 /* ------------ */
800
801 area.h += adj_size(20);
802
804 (pwindow->size.w - pwindow->area.w) + area.w,
805 (pwindow->size.h - pwindow->area.h) + area.h);
806
807 area = pwindow->area;
808
809 if (main_data.event.motion.x + pwindow->size.w > main_window_width()) {
810 if (main_data.event.motion.x - pwindow->size.w >= 0) {
811 window_x = main_data.event.motion.x - pwindow->size.w;
812 } else {
813 window_x = (main_window_width() - pwindow->size. w) / 2;
814 }
815 } else {
816 window_x = main_data.event.motion.x;
817 }
818
819 if (main_data.event.motion.y + pwindow->size.h >= main_data.screen->h) {
820 if (main_data.event.motion.y - pwindow->size.h >= 0) {
821 window_y = main_data.event.motion.y - pwindow->size.h;
822 } else {
823 window_y = (main_data.screen->h - pwindow->size.h) / 2;
824 }
825 } else {
826 window_y = main_data.event.motion.y;
827 }
828
830
831 blit_entire_src(text1, pwindow->theme, 15, area.y + 1);
833
834 /* width label */
835 buf = pwindow->prev->prev;
836 buf->size.y = area.y + adj_size(16);
837 buf->size.x = area.x + (area.w - buf->size.w) / 2;
838
839 /* width left button */
840 buf->next->size.y = buf->size.y + buf->size.h - buf->next->size.h;
841 buf->next->size.x = buf->size.x - buf->next->size.w;
842
843 /* width right button */
844 buf->prev->size.y = buf->size.y + buf->size.h - buf->prev->size.h;
845 buf->prev->size.x = buf->size.x + buf->size.w;
846
847 /* height label */
848 buf = buf->prev->prev->prev;
849 buf->size.y = buf->next->next->next->size.y + buf->next->next->next->size.h + adj_size(20);
850 buf->size.x = area.x + (area.w - buf->size.w) / 2;
851
852 blit_entire_src(text2, pwindow->theme, adj_size(15), buf->size.y - text2->h - adj_size(2));
854
855 /* height left button */
856 buf->next->size.y = buf->size.y + buf->size.h - buf->next->size.h;
857 buf->next->size.x = buf->size.x - buf->next->size.w;
858
859 /* height right button */
860 buf->prev->size.y = buf->size.y + buf->size.h - buf->prev->size.h;
861 buf->prev->size.x = buf->size.x + buf->size.w;
862
863 /* exit button */
864 buf = buf->prev->prev;
865 buf->size.x = area.x + (area.w - buf->size.w) / 2;
866 buf->size.y = area.y + area.h - buf->size.h - adj_size(7);
867
868 /* -------------------- */
869 redraw_group(scale_minimap_dlg->begin_widget_list, pwindow, 0);
870 widget_flush(pwindow);
871}
872#endif /* SCALE_MINIMAP */
873
874/* ==================================================================== */
875#ifdef SCALE_UNITINFO
876
877/**********************************************************************/
880static int move_scale_unitinfo_dlg_callback(struct widget *pwindow)
881{
883 move_window_group(scale_unit_info_dlg->begin_widget_list, pwindow);
884 }
885
886 return -1;
887}
888
889/**********************************************************************/
892static int popdown_scale_unitinfo_dlg_callback(struct widget *pwidget)
893{
897 scale_unit_info_dlg->end_widget_list);
899 if (pwidget) {
900 flush_dirty();
901 }
902 }
903 }
904
905 return -1;
906}
907
908/**********************************************************************/
911static void remake_unitinfo(int w, int h)
912{
913 SDL_Color bg_color = {255, 255, 255, 128};
914 SDL_Surface *surf;
916 units_info_window->area.y, 0, 0};
917 struct widget *pwidget = units_info_window;
918
919 if (w < DEFAULT_UNITS_W - BLOCKU_W) {
921 } else {
923 }
924
925 if (h < DEFAULT_UNITS_H) {
927 } else {
929 }
930
931 /* clear area under old map window */
932 clear_surface(pwidget->dst->surface, &pwidget->size);
933 widget_mark_dirty(pwidget);
934
935 pwidget->size.w = w;
936 pwidget->size.h = h;
937
938 pwidget->size.x = main_window_width() - w;
939 pwidget->size.y = main_window_height() - h;
940
941 FREESURFACE(pwidget->theme);
942 pwidget->theme = create_surf(w, h, SDL_SWSURFACE);
943
944 draw_frame(pwidget->theme, 0, 0, pwidget->size.w, pwidget->size.h);
945
947 pwidget->size.h - ((units_info_window->size.h - units_info_window->area.h)), 1);
948
949 blit_entire_src(surf, pwidget->theme, units_info_window->area.x,
951 FREESURFACE(surf);
952
955 SDL_FillRect(pwidget->theme, &area, map_rgba(pwidget->theme->format, bg_color));
956
957 /* economy button */
958 pwidget = tax_button;
959 FREESURFACE(pwidget->gfx);
960 pwidget->size.x = pwidget->dst->surface->w - w + units_info_window->area.x
961 + (BLOCKU_W - pwidget->size.w) / 2;
962 pwidget->size.y = pwidget->dst->surface->h - h + pwidget->area.y + 2;
963
964 /* research button */
965 pwidget = pwidget->prev;
966 FREESURFACE(pwidget->gfx);
967 pwidget->size.x = pwidget->dst->surface->w - w + units_info_window->area.x
968 + (BLOCKU_W - pwidget->size.w) / 2;
969 pwidget->size.y = pwidget->dst->surface->h - h + units_info_window->area.y +
970 pwidget->size.h + 2;
971
972 /* revolution button */
973 pwidget = pwidget->prev;
974 FREESURFACE(pwidget->gfx);
975 pwidget->size.x = pwidget->dst->surface->w - w + units_info_window->area.x
976 + (BLOCKU_W - pwidget->size.w) / 2;
977 pwidget->size.y = pwidget->dst->surface->h - h + units_info_window->area.y +
978 pwidget->size.h * 2 + 2;
979
980 /* show/hide unit's window button */
981 pwidget = pwidget->prev;
982 FREESURFACE(pwidget->gfx);
983 pwidget->size.x = pwidget->dst->surface->w - w + units_info_window->area.x
984 + (BLOCKU_W - pwidget->size.w) / 2;
985 pwidget->size.y = units_info_window->area.y + units_info_window->area.h -
986 pwidget->size.h - 2;
987
988 unitinfo_w = w;
989 unitinfo_h = h;
990}
991
992/**********************************************************************/
995int resize_unit_info(void)
996{
998 int w = info_width * map.xsize;
999 int h = info_height * map.ysize;
1001 (info_window->size.w - info_window->area.w);
1003 (info_window->size.h - info_window->area.h);
1004
1006 || (w > DEFAULT_UNITS_W - BLOCKU_W)) && (current_w != w))
1007 || (((current_h > DEFAULT_UNITS_H) || (h > DEFAULT_UNITS_H)) && (current_h != h))) {
1008 remake_unitinfo(w, h);
1009 }
1010
1011 if (C_S_RUNNING == client_state()) {
1012 menus_update();
1013 }
1015
1016 return 0;
1017}
1018
1019/**********************************************************************/
1022static int up_info_width_callback(struct widget *pwidget)
1023{
1025 widget_redraw(pwidget);
1026 widget_mark_dirty(pwidget);
1027 if (main_window_width() - ((info_width + 1) * map.xsize + BLOCKU_W +
1030 info_width++;
1032 }
1033 flush_dirty();
1034 }
1035
1036 return -1;
1037}
1038
1039/**********************************************************************/
1042static int down_info_width_callback(struct widget *pwidget)
1043{
1045 widget_redraw(pwidget);
1046 widget_mark_dirty(pwidget);
1047 if (info_width > info_width_min) {
1048 info_width--;
1050 }
1051 flush_dirty();
1052 }
1053
1054 return -1;
1055}
1056
1057/**********************************************************************/
1060static int up_info_height_callback(struct widget *pwidget)
1061{
1063 widget_redraw(pwidget);
1064 widget_mark_dirty(pwidget);
1065 if (main_data.screen->h - ((info_height + 1) * map.ysize +
1067 info_height++;
1069 }
1070 flush_dirty();
1071 }
1072
1073 return -1;
1074}
1075
1076/**********************************************************************/
1079static int down_info_height_callback(struct widget *pwidget)
1080{
1082 widget_redraw(pwidget);
1083 widget_mark_dirty(pwidget);
1085 info_height--;
1087 }
1088 flush_dirty();
1089 }
1090
1091 return -1;
1092}
1093
1094/**********************************************************************/
1097static void popup_unitinfo_scale_dialog(void)
1098{
1099
1100#ifndef SCALE_UNITINFO
1101 return;
1102#endif /* SCALE_UNITINFO */
1103
1105 utf8_str *pstr = NULL;
1106 struct widget *pwindow = NULL;
1107 struct widget *buf = NULL;
1108 int window_x = 0, window_y = 0;
1109 SDL_Rect area;
1110
1112 return;
1113 }
1114
1115 scale_unit_info_dlg = fc_calloc(1, sizeof(struct small_dialog));
1116
1117 /* Create window */
1118 pstr = create_utf8_from_char_fonto(_("Scale Unit Info"), FONTO_ATTENTION);
1119 pstr->style |= TTF_STYLE_BOLD;
1120 pwindow = create_window_skeleton(NULL, pstr, 0);
1122 set_wstate(pwindow, FC_WS_NORMAL);
1123 add_to_gui_list(ID_WINDOW, pwindow);
1124 scale_unit_info_dlg->end_widget_list = pwindow;
1125
1126 area = pwindow->area;
1127
1130 area.w = MAX(area.w, text1->w + adj_size(30));
1131 area.h += MAX(adj_size(20), text1->h + adj_size(4));
1132 copy_chars_to_utf8_str(pstr, _("Height"));
1134 area.w = MAX(area.w, text2->w + adj_size(30));
1135 area.h += MAX(adj_size(20), text2->h + adj_size(4));
1137
1138 /* ----------------- */
1139 buf = create_themeicon_button(current_theme->l_arrow_icon, pwindow->dst,
1140 NULL, 0);
1141 buf->action = down_info_width_callback;
1144 area.h += buf->size.h;
1145
1146 buf = create_themeicon_button(current_theme->r_arrow_icon, pwindow->dst,
1147 NULL, 0);
1148 buf->action = up_info_width_callback;
1151
1152 /* ------------ */
1153 buf = create_themeicon_button(current_theme->l_arrow_icon, pwindow->dst,
1154 NULL, 0);
1158 area.h += buf->size.h + adj_size(10);
1159
1160 buf = create_themeicon_button(current_theme->r_arrow_icon, pwindow->dst,
1161 NULL, 0);
1162 buf->action = up_info_height_callback;
1165 area.w = MAX(area.w , buf->size.w * 2 + adj_size(20));
1166
1167 /* ------------ */
1170 pwindow->dst, pstr, 0);
1173 scale_unit_info_dlg->begin_widget_list = buf;
1175 area.h += buf->size.h + adj_size(10);
1176 area.w = MAX(area.w, buf->size.w + adj_size(20));
1177
1179 (pwindow->size.w - pwindow->area.w) + area.w,
1180 (pwindow->size.h - pwindow->area.h) + area.h);
1181
1182 area = pwindow->area;
1183
1184 /* ------------ */
1185
1186 if (main_data.event.motion.x + pwindow->size.w > main_window_width()) {
1187 if (main_data.event.motion.x - pwindow->size.w >= 0) {
1188 window_x = main_data.event.motion.x - pwindow->size.w;
1189 } else {
1190 window_x = (main_window_width() - pwindow->size.w) / 2;
1191 }
1192 } else {
1193 window_x = main_data.event.motion.x;
1194 }
1195
1196 if (main_data.event.motion.y + pwindow->size.h >= main_data.screen->h) {
1197 if (main_data.event.motion.y - pwindow->size.h >= 0) {
1198 window_y = main_data.event.motion.y - pwindow->size.h;
1199 } else {
1200 window_y = (pwindow->dst->surface->h - pwindow->size.h) / 2;
1201 }
1202 } else {
1203 window_y = main_data.event.motion.y;
1204 }
1205
1207
1208 /* width left button */
1209 buf = pwindow->prev;
1210 buf->size.y = area.y + MAX(adj_size(20), text1->h + adj_size(4));
1211 buf->size.x = area.x + (area.w - buf->size.w * 2) / 2;
1212 blit_entire_src(text1, pwindow->theme, adj_size(15), buf->size.y
1213 - area.y - text1->h - adj_size(2));
1215
1216 /* width right button */
1217 buf->prev->size.y = buf->size.y;
1218 buf->prev->size.x = buf->size.x + buf->size.w;
1219
1220 /* height left button */
1221 buf = buf->prev->prev;
1222 buf->size.y = buf->next->next->size.y +
1223 buf->next->next->size.h + MAX(adj_size(20), text2->h + adj_size(4));
1224 buf->size.x = area.x + (area.w - buf->size.w * 2) / 2;
1225
1226 blit_entire_src(text2, pwindow->theme, adj_size(15), buf->size.y - area.y - text2->h - adj_size(2));
1228
1229 /* height right button */
1230 buf->prev->size.y = buf->size.y;
1231 buf->prev->size.x = buf->size.x + buf->size.w;
1232
1233 /* exit button */
1234 buf = buf->prev->prev;
1235 buf->size.x = area.x + (area.w - buf->size.w) / 2;
1236 buf->size.y = area.y + area.h - buf->size.h - adj_size(7);
1237
1238 if (!info_height) {
1239 info_width_min = (DEFAULT_UNITS_W - BLOCKU_W) / map.xsize;
1240 if (info_width_min == 1) {
1241 info_width_min = 0;
1242 }
1243 info_height_min = DEFAULT_UNITS_H / map.ysize;
1244 if (!info_height_min) {
1245 info_height_min = 1;
1246 }
1249 }
1250
1251 /* -------------------- */
1252 redraw_group(scale_unit_info_dlg->begin_widget_list, pwindow, 0);
1253 widget_flush(pwindow);
1254}
1255#endif /* SCALE_UNITINFO */
1256
1257/* ==================================================================== */
1258
1259/**********************************************************************/
1262static int minimap_window_callback(struct widget *pwidget)
1263{
1264 int mouse_x, mouse_y;
1265
1266 switch (main_data.event.button.button) {
1267 case SDL_BUTTON_RIGHT:
1268 mouse_x = main_data.event.motion.x - minimap_window->dst->dest_rect.x -
1273 && (mouse_x >= 0) && (mouse_x < overview_w)
1274 && (mouse_y >= 0) && (mouse_y < overview_h)) {
1275 int map_x, map_y;
1276
1277 overview_to_map_pos(&map_x, &map_y, mouse_x, mouse_y);
1279 }
1280
1281 break;
1282 case SDL_BUTTON_MIDDLE:
1283 /* FIXME: scaling needs to be fixed */
1284#ifdef SCALE_MINIMAP
1286#endif
1287 break;
1288 default:
1289 break;
1290 }
1291
1292 return -1;
1293}
1294
1295/**********************************************************************/
1298static int unit_info_window_callback(struct widget *pwidget)
1299{
1300 if (main_data.event.type == SDL_MOUSEBUTTONDOWN) {
1301 switch (main_data.event.button.button) {
1302#if 0
1303 case SDL_BUTTON_LEFT:
1304
1305 break;
1306#endif
1307 case SDL_BUTTON_MIDDLE:
1309 break;
1310 case SDL_BUTTON_RIGHT:
1311#ifdef SCALE_UNITINFO
1313#endif
1314 break;
1315 default:
1316 key_unit_wait();
1317 break;
1318 }
1319 } else if (PRESSED_EVENT(main_data.event)) {
1320 key_unit_wait();
1321 }
1322
1323 return -1;
1324}
1325
1326/* ============================== Public =============================== */
1327
1328/**********************************************************************/
1333{
1335 struct widget *pwidget;
1336 SDL_Rect area;
1337
1342 } else {
1344 main_window_width() - BLOCKU_W - current_theme->fr_right->w,
1346 }
1347
1350 area.w = BLOCKU_W;
1352
1353 /* ID_ECONOMY */
1354 pwidget = tax_button;
1355 widget_set_area(pwidget, area);
1356 widget_set_position(pwidget,
1357 area.x + (area.w - pwidget->size.w) / 2,
1358 area.y + 2);
1359
1360 /* ID_RESEARCH */
1361 pwidget = pwidget->prev;
1362 widget_set_area(pwidget, area);
1363 widget_set_position(pwidget,
1364 area.x + (area.w - pwidget->size.w) / 2,
1365 area.y + 2 + pwidget->size.h);
1366
1367 /* ID_REVOLUTION */
1368 pwidget = pwidget->prev;
1369 widget_set_area(pwidget, area);
1370 widget_set_position(pwidget,
1371 area.x + (area.w - pwidget->size.w) / 2,
1372 area.y + 2 + (pwidget->size.h * 2));
1373
1374 /* ID_TOGGLE_UNITS_WINDOW_BUTTON */
1375 pwidget = pwidget->prev;
1376 widget_set_area(pwidget, area);
1377 widget_set_position(pwidget,
1378 area.x + (area.w - pwidget->size.w) / 2,
1379 area.y + area.h - pwidget->size.h - 2);
1380}
1381
1382/**********************************************************************/
1387{
1388 struct widget *pwidget;
1389 SDL_Rect area;
1390
1393
1394 area.x = minimap_window->size.w - current_theme->fr_right->w - BLOCKM_W;
1395 area.y = minimap_window->area.y;
1396 area.w = BLOCKM_W;
1397 area.h = minimap_window->area.h;
1398
1399 /* ID_NEW_TURN */
1400 pwidget = minimap_window->prev;
1401 widget_set_area(pwidget, area);
1402 widget_set_position(pwidget,
1403 area.x + adj_size(2) + pwidget->size.w,
1404 area.y + 2);
1405
1406 /* PLAYERS BUTTON */
1407 pwidget = pwidget->prev;
1408 widget_set_area(pwidget, area);
1409 widget_set_position(pwidget,
1410 area.x + adj_size(2) + pwidget->size.w,
1411 area.y + pwidget->size.h + 2);
1412
1413 /* ID_FIND_CITY */
1414 pwidget = pwidget->prev;
1415 widget_set_area(pwidget, area);
1416 widget_set_position(pwidget,
1417 area.x + adj_size(2) + pwidget->size.w,
1418 area.y + pwidget->size.h * 2 + 2);
1419
1420 /* UNITS BUTTON */
1421 pwidget = pwidget->prev;
1422 widget_set_area(pwidget, area);
1423 widget_set_position(pwidget,
1424 area.x + adj_size(2),
1425 area.y + 2);
1426
1427 /* ID_CHATLINE_TOGGLE_LOG_WINDOW_BUTTON */
1428 pwidget = pwidget->prev;
1429 widget_set_area(pwidget, area);
1430 widget_set_position(pwidget,
1431 area.x + adj_size(2),
1432 area.y + pwidget->size.h + 2);
1433
1434#ifdef SMALL_SCREEN
1435 /* ID_TOGGLE_MAP_WINDOW_BUTTON */
1436 pwidget = pwidget->prev;
1437 widget_set_area(pwidget, area);
1438 widget_set_position(pwidget,
1439 area.x + adj_size(2),
1440 area.y + area.h - pwidget->size.h - 2);
1441#endif /* SMALL_SCREEN */
1442
1443 /* ID_TOGGLE_MAP_WINDOW_BUTTON */
1444 pwidget = pwidget->prev;
1445 widget_set_area(pwidget, area);
1446 widget_set_position(pwidget,
1447 area.x + adj_size(2) + pwidget->size.w,
1448 area.y + area.h - pwidget->size.h - 2);
1449}
1450
1451/**********************************************************************/
1455{
1456 struct widget *pwidget, *pwindow;
1458 char buf[256];
1459
1460 if (unit_info_dlg) {
1461 return;
1462 }
1463
1464 unit_info_dlg = fc_calloc(1, sizeof(struct advanced_dialog));
1465
1466 /* units_info_window */
1467 pwindow = create_window_skeleton(NULL, NULL, 0);
1468
1469 resize_window(pwindow, NULL, NULL,
1470 (pwindow->size.w - pwindow->area.w) + DEFAULT_UNITS_W,
1471 (pwindow->size.h - pwindow->area.h) + DEFAULT_UNITS_H);
1472
1473 draw_frame(pwindow->theme, 0, 0, pwindow->size.w, pwindow->size.h);
1474
1475 unitinfo_w = pwindow->size.w;
1476 unitinfo_h = pwindow->size.h;
1477
1478 icon_theme = resize_surface(current_theme->block, pwindow->area.w,
1479 pwindow->area.h, 1);
1480
1481 blit_entire_src(icon_theme, pwindow->theme, pwindow->area.x, pwindow->area.y);
1483
1485
1487
1488 units_info_window = pwindow;
1489
1492
1493 /* Economy button */
1497
1498 fc_snprintf(buf, sizeof(buf), "%s (%s)", _("Economy"), "F5");
1500 pwidget->action = economy_callback;
1501 pwidget->key = SDLK_F5;
1502
1503 add_to_gui_list(ID_ECONOMY, pwidget);
1504
1505 tax_button = pwidget;
1506
1507 /* research button */
1512 /* TRANS: Research report action */
1513 fc_snprintf(buf, sizeof(buf), "%s (%s)", _("Research"), "F6");
1515 pwidget->action = research_callback;
1516 pwidget->key = SDLK_F6;
1517
1518 add_to_gui_list(ID_RESEARCH, pwidget);
1519
1520 research_button = pwidget;
1521
1522 /* Revolution button */
1527 fc_snprintf(buf, sizeof(buf), "%s (%s)", _("Revolution"), "Ctrl+Shift+G");
1529 pwidget->action = revolution_callback;
1530 pwidget->key = SDLK_g;
1531 pwidget->mod = KMOD_CTRL | KMOD_SHIFT;
1532
1534
1535 revolution_button = pwidget;
1536
1537 /* Show/hide unit's window button */
1538
1539 /* Make UNITS Icon */
1540 icon_theme = create_surf(current_theme->map_icon->w,
1541 current_theme->map_icon->h, SDL_SWSURFACE);
1542 alphablit(current_theme->map_icon, NULL, icon_theme, NULL, 255);
1543 alphablit(current_theme->r_arrow_icon, NULL, icon_theme, NULL, 255);
1544
1549 pwidget->info_label
1550 = create_utf8_from_char_fonto(_("Hide Unit Info Window"),
1552
1554
1556
1558
1560
1562
1564}
1565
1566/**********************************************************************/
1570{
1571 struct widget *pwidget = get_unit_info_window_widget();
1572
1573 /* economy button */
1574 pwidget = pwidget->prev;
1575 clear_wflag(pwidget, WF_HIDDEN);
1576
1577 /* research button */
1578 pwidget = pwidget->prev;
1579 clear_wflag(pwidget, WF_HIDDEN);
1580
1581 /* revolution button */
1582 pwidget = pwidget->prev;
1583 clear_wflag(pwidget, WF_HIDDEN);
1584
1585 /* show/hide unit's window button */
1586 pwidget = pwidget->prev;
1587 clear_wflag(pwidget, WF_HIDDEN);
1588}
1589
1590/**********************************************************************/
1594{
1595 struct widget *pwidget = get_unit_info_window_widget();
1596
1597 /* economy button */
1598 pwidget = pwidget->prev;
1599 set_wflag(pwidget, WF_HIDDEN);
1600
1601 /* research button */
1602 pwidget = pwidget->prev;
1603 set_wflag(pwidget, WF_HIDDEN);
1604
1605 /* revolution button */
1606 pwidget = pwidget->prev;
1607 set_wflag(pwidget, WF_HIDDEN);
1608
1609 /* show/hide unit's window button */
1610 pwidget = pwidget->prev;
1611 set_wflag(pwidget, WF_HIDDEN);
1612}
1613
1614/**********************************************************************/
1618{
1619 struct widget *pwidget = get_unit_info_window_widget();
1620
1621 /* economy button */
1622 pwidget = pwidget->prev;
1623 set_wstate(pwidget, FC_WS_DISABLED);
1624
1625 /* research button */
1626 pwidget = pwidget->prev;
1627 set_wstate(pwidget, FC_WS_DISABLED);
1628
1629 /* revolution button */
1630 pwidget = pwidget->prev;
1631 set_wstate(pwidget, FC_WS_DISABLED);
1632}
1633
1634/**********************************************************************/
1646
1647/**********************************************************************/
1651{
1652 struct widget *pwidget, *pwindow;
1654 SDL_Color black = {0, 0, 0, 255};
1655 char buf[256];
1656
1657 if (minimap_dlg) {
1658 return;
1659 }
1660
1661 minimap_dlg = fc_calloc(1, sizeof(struct advanced_dialog));
1662
1663 /* minimap_window */
1664 pwindow = create_window_skeleton(NULL, NULL, 0);
1665
1666 resize_window(pwindow, NULL, &black,
1667 (pwindow->size.w - pwindow->area.w) + overview_w + BLOCKM_W,
1668 (pwindow->size.h - pwindow->area.h) + overview_h);
1669
1670 draw_frame(pwindow->theme, 0, 0, pwindow->size.w, pwindow->size.h);
1671
1673 pwindow->area.h, 1);
1675 pwindow->area.x + pwindow->area.w - icon_theme->w,
1676 pwindow->area.y);
1678
1680
1682
1683 minimap_window = pwindow;
1685
1686 /* New turn button */
1687 pwidget = create_themeicon(current_theme->new_turn_icon, minimap_window->dst,
1690 fc_snprintf(buf, sizeof(buf), "%s (%s)", _("Turn Done"), _("Shift+Return"));
1692 pwidget->action = end_turn_callback;
1693 pwidget->key = SDLK_RETURN;
1694 pwidget->mod = KMOD_SHIFT;
1695
1696 add_to_gui_list(ID_NEW_TURN, pwidget);
1697
1698 new_turn_button = pwidget;
1699
1700 /* players button */
1701 pwidget = create_themeicon(current_theme->players_icon, minimap_window->dst,
1704 /* TRANS: Nations report action */
1705 fc_snprintf(buf, sizeof(buf), "%s (%s)", _("Nations"), "F3");
1708 pwidget->key = SDLK_F3;
1709
1710 add_to_gui_list(ID_PLAYERS, pwidget);
1711
1712 /* Find city button */
1713 pwidget = create_themeicon(current_theme->find_city_icon, minimap_window->dst,
1716 fc_snprintf(buf, sizeof(buf), "%s (%s)\n%s\n%s (%s)", _("Cities Report"),
1717 "F4", _("or"), _("Find City"), "Ctrl+F");
1719 pwidget->info_label->style |= SF_CENTER;
1720 pwidget->action = cities_action_callback;
1721 pwidget->key = SDLK_f;
1722 pwidget->mod = KMOD_CTRL;
1723
1724 add_to_gui_list(ID_CITIES, pwidget);
1725
1726 find_city_button = pwidget;
1727
1728 /* Units button */
1729 pwidget = create_themeicon(current_theme->units2_icon, minimap_window->dst,
1732 fc_snprintf(buf, sizeof(buf), "%s (%s)", _("Units"), "F2");
1734 pwidget->action = units_action_callback;
1735 pwidget->key = SDLK_F2;
1736
1737 add_to_gui_list(ID_UNITS, pwidget);
1738
1739 /* Show/hide log window button */
1740 pwidget = create_themeicon(current_theme->log_icon, minimap_window->dst,
1743 fc_snprintf(buf, sizeof(buf), "%s (%s)", _("Hide Messages"), "F9");
1746 pwidget->key = SDLK_F9;
1747
1749
1750#ifdef SMALL_SCREEN
1751 /* Options button */
1756 fc_snprintf(buf, sizeof(buf), "%s (%s)", _("Options"), "Esc");
1759
1762
1764#endif /* SMALL_SCREEN */
1765
1766 /* show/hide minimap button */
1767
1768 /* make Map Icon */
1769 icon_theme = create_surf(current_theme->map_icon->w,
1770 current_theme->map_icon->h,
1772 alphablit(current_theme->map_icon, NULL, icon_theme, NULL, 255);
1773 alphablit(current_theme->l_arrow_icon, NULL, icon_theme, NULL, 255);
1774
1779
1780 pwidget->info_label = create_utf8_from_char_fonto(_("Hide Mini Map"),
1783
1785
1786 minimap_dlg->begin_widget_list = pwidget;
1787
1789
1791
1793}
1794
1795/**********************************************************************/
1799{
1800 struct widget *pwidget = get_minimap_window_widget();
1801
1802 /* new turn button */
1803 pwidget = pwidget->prev;
1804 clear_wflag(pwidget, WF_HIDDEN);
1805
1806 /* players button */
1807 pwidget = pwidget->prev;
1808 clear_wflag(pwidget, WF_HIDDEN);
1809
1810 /* find city button */
1811 pwidget = pwidget->prev;
1812 clear_wflag(pwidget, WF_HIDDEN);
1813
1814 /* units button */
1815 pwidget = pwidget->prev;
1816 clear_wflag(pwidget, WF_HIDDEN);
1817
1818 /* show/hide log window button */
1819 pwidget = pwidget->prev;
1820 clear_wflag(pwidget, WF_HIDDEN);
1821
1822#ifdef SMALL_SCREEN
1823 /* options button */
1824 pwidget = pwidget->prev;
1825 clear_wflag(pwidget, WF_HIDDEN);
1826#endif /* SMALL_SCREEN */
1827
1828 /* show/hide minimap button */
1829 pwidget = pwidget->prev;
1830 clear_wflag(pwidget, WF_HIDDEN);
1831}
1832
1833/**********************************************************************/
1837{
1838 struct widget *pwidget = get_minimap_window_widget();
1839
1840 /* new turn button */
1841 pwidget = pwidget->prev;
1842 set_wflag(pwidget, WF_HIDDEN);
1843
1844 /* players button */
1845 pwidget = pwidget->prev;
1846 set_wflag(pwidget, WF_HIDDEN);
1847
1848 /* find city button */
1849 pwidget = pwidget->prev;
1850 set_wflag(pwidget, WF_HIDDEN);
1851
1852 /* units button */
1853 pwidget = pwidget->prev;
1854 set_wflag(pwidget, WF_HIDDEN);
1855
1856 /* show/hide log window button */
1857 pwidget = pwidget->prev;
1858 set_wflag(pwidget, WF_HIDDEN);
1859
1860#ifdef SMALL_SCREEN
1861 /* options button */
1862 pwidget = pwidget->prev;
1863 set_wflag(pwidget, WF_HIDDEN);
1864#endif /* SMALL_SCREEN */
1865
1866 /* show/hide minimap button */
1867 pwidget = pwidget->prev;
1868 set_wflag(pwidget, WF_HIDDEN);
1869}
1870
1871/**********************************************************************/
1875{
1876 struct widget *pwidget = get_minimap_window_widget();
1877
1878 /* new turn button */
1879 pwidget = pwidget->prev;
1880 widget_redraw(pwidget);
1881
1882 /* players button */
1883 pwidget = pwidget->prev;
1884 widget_redraw(pwidget);
1885
1886 /* find city button */
1887 pwidget = pwidget->prev;
1888 widget_redraw(pwidget);
1889
1890 /* units button */
1891 pwidget = pwidget->prev;
1892 widget_redraw(pwidget);
1893 /* show/hide log window button */
1894 pwidget = pwidget->prev;
1895 widget_redraw(pwidget);
1896
1897#ifdef SMALL_SCREEN
1898 /* options button */
1899 pwidget = pwidget->prev;
1900 widget_redraw(pwidget);
1901#endif /* SMALL_SCREEN */
1902
1903 /* show/hide minimap button */
1904 pwidget = pwidget->prev;
1905 widget_redraw(pwidget);
1906}
1907
1908/**********************************************************************/
1912{
1913 struct widget *pwidget = get_minimap_window_widget();
1914
1915 /* new turn button */
1916 pwidget = pwidget->prev;
1917 set_wstate(pwidget, FC_WS_DISABLED);
1918
1919 /* players button */
1920 pwidget = pwidget->prev;
1921 set_wstate(pwidget, FC_WS_DISABLED);
1922
1923 /* find city button */
1924 pwidget = pwidget->prev;
1925 set_wstate(pwidget, FC_WS_DISABLED);
1926
1927 /* units button */
1928 pwidget = pwidget->prev;
1929 set_wstate(pwidget, FC_WS_DISABLED);
1930
1931 /* show/hide log window button */
1932 pwidget = pwidget->prev;
1933 set_wstate(pwidget, FC_WS_DISABLED);
1934
1935#ifdef SMALL_SCREEN
1936 /* options button */
1937 pwidget = pwidget->prev;
1938 set_wstate(pwidget, FC_WS_DISABLED);
1939#endif /* SMALL_SCREEN */
1940}
1941
1942/**********************************************************************/
1954
1955/**********************************************************************/
1959{
1960 struct widget *pwidget;
1962
1964 return;
1965 }
1966
1970
1971#ifndef SMALL_SCREEN
1973#endif
1974
1975 /* cooling icon */
1979
1980#ifdef SMALL_SCREEN
1981 widget_set_position(pwidget,
1982 pwidget->dst->surface->w - pwidget->size.w - adj_size(10),
1983 0);
1984#else /* SMALL_SCREEN */
1985 widget_set_position(pwidget,
1986 pwidget->dst->surface->w - pwidget->size.w - adj_size(10),
1987 adj_size(10));
1988#endif /* SMALL_SCREEN */
1989
1991
1992 /* warming icon */
1995
1997
1998#ifdef SMALL_SCREEN
1999 widget_set_position(pwidget,
2000 pwidget->dst->surface->w - pwidget->size.w * 2 - adj_size(10),
2001 0);
2002#else /* SMALL_SCREEN */
2003 widget_set_position(pwidget,
2004 pwidget->dst->surface->w - pwidget->size.w * 2 - adj_size(10),
2005 adj_size(10));
2006#endif /* SMALL_SCREEN */
2007
2009
2010 /* create order buttons */
2012
2013 /* enable options button and order widgets */
2016}
2017
2018/**********************************************************************/
2039
2040/**********************************************************************/
2045{
2046 struct widget *buf, *end;
2047
2050
2051 /* new turn button */
2052 buf = buf->prev;
2053 end = buf;
2055
2056 /* players button */
2057 buf = buf->prev;
2059
2060 /* find city button */
2061 buf = buf->prev;
2063
2064 /* units button */
2065 buf = buf->prev;
2067
2068 /* show/hide log window button */
2069 buf = buf->prev;
2071
2072#ifdef SMALL_SCREEN
2073 /* options button */
2074 buf = buf->prev;
2076#endif /* SMALL_SCREEN */
2077
2078 /* show/hide minimap button */
2079 buf = buf->prev;
2081
2082 redraw_group(buf, end, TRUE);
2083}
2084
2085/**********************************************************************/
2090{
2093
2095 end = end->prev;
2096 redraw_group(buf, end, TRUE);
2097}
2098
2099/**********************************************************************/
2103{
2104 if (C_S_RUNNING == client_state()) {
2107
2109
2111 }
2112}
2113
2114/**********************************************************************/
2117static void enable_minimap_widgets(void)
2118{
2119 struct widget *buf, *end;
2120
2124
2125 /* new turn button */
2126 buf = buf->prev;
2127 end = buf;
2129
2130 /* players button */
2131 buf = buf->prev;
2133
2134 /* find city button */
2135 buf = buf->prev;
2137
2138 /* units button */
2139 buf = buf->prev;
2141
2142 /* show/hide log window button */
2143 buf = buf->prev;
2145
2146#ifdef SMALL_SCREEN
2147 /* options button */
2148 buf = buf->prev;
2150#endif /* SMALL_SCREEN */
2151
2152 /* show/hide minimap button */
2153 buf = buf->prev;
2155
2156 redraw_group(buf, end, TRUE);
2157 }
2158}
2159
2160/**********************************************************************/
2164{
2165 struct widget *buf, *end;
2166
2170
2172 end = end->prev;
2173 redraw_group(buf, end, TRUE);
2174 }
2175}
2176
2177/**********************************************************************/
2181{
2182 if (C_S_RUNNING == client_state()) {
2185
2187
2189 }
2190}
2191
2192/**********************************************************************/
2196{
2197 return units_info_window;
2198}
2199
2200/**********************************************************************/
2204{
2205 return minimap_window;
2206}
2207
2208/**********************************************************************/
2212{
2213 return tax_button;
2214}
2215
2216/**********************************************************************/
2220{
2221 return research_button;
2222}
2223
2224/**********************************************************************/
2228{
2229 return revolution_button;
2230}
2231
2232/**********************************************************************/
2241
2242/**********************************************************************/
2251/**********************************************************************/
2255{
2256 if (C_S_RUNNING != client_state()) {
2257 return;
2258 }
2259
2260 key_unit_goto();
2262}
2263
2264/**********************************************************************/
2276
2277/**********************************************************************/
2281{
2282 struct tile *ptile;
2283
2284 if (C_S_RUNNING != client_state()) {
2285 return;
2286 }
2287
2288 if (button_behavior->event->button == SDL_BUTTON_LEFT) {
2289 switch (button_behavior->hold_state) {
2290 case MB_HOLD_SHORT:
2291 break;
2292 case MB_HOLD_MEDIUM:
2293 /* switch to goto mode */
2294 key_unit_goto();
2296 break;
2297 case MB_HOLD_LONG:
2298#ifdef UNDER_CE
2299 /* cancel goto mode and open context menu on Pocket PC since we have
2300 * only one 'mouse button' */
2304 /* popup context menu */
2305 if ((ptile = canvas_pos_to_tile((int) button_behavior->event->x,
2306 (int) button_behavior->event->y,
2307 mouse_zoom))) {
2310 }
2311#endif /* UNDER_CE */
2312 break;
2313 default:
2314 break;
2315 }
2316 } else if (button_behavior->event->button == SDL_BUTTON_MIDDLE) {
2317 switch (button_behavior->hold_state) {
2318 case MB_HOLD_SHORT:
2319 break;
2320 case MB_HOLD_MEDIUM:
2321 break;
2322 case MB_HOLD_LONG:
2323 break;
2324 default:
2325 break;
2326 }
2327 } else if (button_behavior->event->button == SDL_BUTTON_RIGHT) {
2328 switch (button_behavior->hold_state) {
2329 case MB_HOLD_SHORT:
2330 break;
2331 case MB_HOLD_MEDIUM:
2332 /* popup context menu */
2333 if ((ptile = canvas_pos_to_tile((int) button_behavior->event->x,
2334 (int) button_behavior->event->y,
2335 mouse_zoom))) {
2338 }
2339 break;
2340 case MB_HOLD_LONG:
2341 break;
2342 default:
2343 break;
2344 }
2345 }
2346}
2347
2348/**********************************************************************/
2352{
2353 struct tile *ptile;
2354 struct city *pcity;
2355
2356 if (C_S_RUNNING != client_state()) {
2357 return;
2358 }
2359
2361
2362 if (button_behavior->event->button == SDL_BUTTON_LEFT) {
2363 switch (button_behavior->hold_state) {
2364 case MB_HOLD_SHORT:
2365 if (LSHIFT || LALT || LCTRL) {
2366 if ((ptile = canvas_pos_to_tile((int) button_behavior->event->x,
2367 (int) button_behavior->event->y,
2368 mouse_zoom))) {
2369 if (LSHIFT) {
2372 } else {
2373 if (((pcity = tile_city(ptile)) != NULL)
2374 && (city_owner(pcity) == client.conn.playing)) {
2375 if (LCTRL) {
2377 } else {
2378 /* LALT - this work only with fullscreen mode */
2380 }
2381 }
2382 }
2383 }
2384 } else {
2388 }
2389 break;
2390 case MB_HOLD_MEDIUM:
2391 /* finish goto */
2395 break;
2396 case MB_HOLD_LONG:
2397#ifndef UNDER_CE
2398 /* finish goto */
2402#endif /* UNDER_CE */
2403 break;
2404 default:
2405 break;
2406 }
2407 } else if (button_behavior->event->button == SDL_BUTTON_MIDDLE) {
2408 switch (button_behavior->hold_state) {
2409 case MB_HOLD_SHORT:
2410/* break;*/
2411 case MB_HOLD_MEDIUM:
2412/* break;*/
2413 case MB_HOLD_LONG:
2414/* break;*/
2415 default:
2416 /* Popup context menu */
2417 if ((ptile = canvas_pos_to_tile((int) button_behavior->event->x,
2418 (int) button_behavior->event->y,
2419 mouse_zoom))) {
2422 }
2423 break;
2424 }
2425 } else if (button_behavior->event->button == SDL_BUTTON_RIGHT) {
2426 switch (button_behavior->hold_state) {
2427 case MB_HOLD_SHORT:
2428 /* recenter map */
2430 flush_dirty();
2431 break;
2432 case MB_HOLD_MEDIUM:
2433 break;
2434 case MB_HOLD_LONG:
2435 break;
2436 default:
2437 break;
2438 }
2439 }
2440}
2441
2442/**********************************************************************/
2446{
2447 if (C_S_RUNNING == client_state()) {
2449
2450 switch (key.scancode) {
2451
2452 case SDL_SCANCODE_KP_8:
2454 break;
2455
2456 case SDL_SCANCODE_KP_9:
2458 break;
2459
2460 case SDL_SCANCODE_KP_6:
2462 break;
2463
2464 case SDL_SCANCODE_KP_3:
2466 break;
2467
2468 case SDL_SCANCODE_KP_2:
2470 break;
2471
2472 case SDL_SCANCODE_KP_1:
2474 break;
2475
2476 case SDL_SCANCODE_KP_4:
2478 break;
2479
2480 case SDL_SCANCODE_KP_7:
2482 break;
2483
2484 case SDL_SCANCODE_KP_5:
2486 return FALSE;
2487
2488 default:
2489 switch (key.sym) {
2490
2491 /* cancel action */
2492 case SDLK_ESCAPE:
2496 return FALSE;
2497
2498 case SDLK_UP:
2500 break;
2501
2502 case SDLK_PAGEUP:
2504 break;
2505
2506 case SDLK_RIGHT:
2508 break;
2509
2510 case SDLK_PAGEDOWN:
2512 break;
2513
2514 case SDLK_DOWN:
2516 break;
2517
2518 case SDLK_END:
2520 break;
2521
2522 case SDLK_LEFT:
2524 break;
2525
2526 case SDLK_HOME:
2528 break;
2529
2530 /* *** map view settings *** */
2531
2532 /* show city outlines - Ctrl+y */
2533 case SDLK_y:
2534 if (LCTRL || RCTRL) {
2536 }
2537 return FALSE;
2538
2539 /* Show map grid - Ctrl+g */
2540 case SDLK_g:
2541 if (LCTRL || RCTRL) {
2543 }
2544 return FALSE;
2545
2546 /* show national borders - Ctrl+b */
2547 case SDLK_b:
2548 if (LCTRL || RCTRL) {
2550 }
2551 return FALSE;
2552
2553 case SDLK_n:
2554 /* show native tiles - Ctrl+Shift+n */
2555 if ((LCTRL || RCTRL) && (LSHIFT || RSHIFT)) {
2557 } else if (LCTRL || RCTRL) {
2558 /* show city names - Ctrl+n */
2560 }
2561 return FALSE;
2562
2563 /* show city growth Ctrl+o */
2564 /* show pollution - Ctrl+Shift+o */
2565 case SDLK_o:
2566 if (LCTRL || RCTRL) {
2567 if (LSHIFT || RSHIFT) {
2569 } else {
2571 }
2572 }
2573 return FALSE;
2574
2575 /* show bases - Ctrl+Shift+f */
2576 case SDLK_f:
2577 if ((LCTRL || RCTRL) && (LSHIFT || RSHIFT)) {
2579 }
2580 return FALSE;
2581
2582 /* show city productions - Ctrl+p */
2583 case SDLK_p:
2584 if (LCTRL || RCTRL) {
2586 }
2587 return FALSE;
2588
2589 /* show city trade routes - Ctrl+d */
2590 case SDLK_d:
2591 if (LCTRL || RCTRL) {
2593 }
2594 return FALSE;
2595
2596 /* *** some additional shortcuts that work in the SDL client only *** */
2597
2598 /* show terrain - Ctrl+Shift+t */
2599 case SDLK_t:
2600 if ((LCTRL || RCTRL) && (LSHIFT || RSHIFT)) {
2602 }
2603 return FALSE;
2604
2605 /* (show coastline) */
2606
2607 /* (show roads and rails) */
2608
2609 /* show irrigation - Ctrl+i */
2610 case SDLK_i:
2611 if (LCTRL || RCTRL) {
2613 }
2614 return FALSE;
2615
2616 /* show mines - Ctrl+m */
2617 case SDLK_m:
2618 if (LCTRL || RCTRL) {
2620 }
2621 return FALSE;
2622
2623 /* show resources - Ctrl+s */
2624 case SDLK_s:
2625 if (LCTRL || RCTRL) {
2627 }
2628 return FALSE;
2629
2630 /* show huts - Ctrl+h */
2631 case SDLK_h:
2632 if (LCTRL || RCTRL) {
2634 }
2635 return FALSE;
2636
2637 /* show cities - Ctrl+c */
2638 case SDLK_c:
2639 if (LCTRL || RCTRL) {
2641 } else {
2643 }
2644 return FALSE;
2645
2646 /* show units - Ctrl+u */
2647 case SDLK_u:
2648 if (LCTRL || RCTRL) {
2650 }
2651 return FALSE;
2652
2653 /* (show focus unit) */
2654
2655 /* Show city output - Ctrl+v */
2656 case SDLK_v:
2658 return FALSE;
2659
2660 /* Show fog of war - Ctrl+w */
2661 case SDLK_w:
2662 if (LCTRL || RCTRL) {
2664 }
2665 return FALSE;
2666
2667 default:
2668 break;
2669 }
2670 }
2671
2672 if (movedir != DIR8_MAGIC_MAX) {
2673 if (!is_unit_move_blocked) {
2675 }
2676 return FALSE;
2677 }
2678 }
2679
2680 return TRUE;
2681}
2682
2683/**********************************************************************/
2686static int newcity_name_edit_callback(struct widget *pedit)
2687{
2690 /* empty input -> restore previous content */
2692 widget_redraw(pedit);
2693 widget_mark_dirty(pedit);
2694 flush_dirty();
2695 }
2696 }
2697
2698 return -1;
2699}
2700
2701/**********************************************************************/
2704static int newcity_ok_callback(struct widget *ok_button)
2705{
2707
2708 finish_city(ok_button->data.tile,
2710
2714
2716
2717 flush_dirty();
2718 }
2719
2720 return -1;
2721}
2722
2723/**********************************************************************/
2726static int newcity_cancel_callback(struct widget *cancel_button)
2727{
2731
2732 cancel_city(cancel_button->data.tile);
2733
2735
2737
2738 flush_dirty();
2739 }
2740
2741 return -1;
2742}
2743
2744/**********************************************************************/
2747static int move_new_city_dlg_callback(struct widget *pwindow)
2748{
2751 }
2752
2753 return -1;
2754}
2755
2756/* ============================== Native =============================== */
2757
2758
2759/**********************************************************************/
2764{
2765 SDL_Surface *background;
2766 utf8_str *pstr = NULL;
2767 struct widget *label = NULL;
2768 struct widget *pwindow = NULL;
2769 struct widget *cancel_button = NULL;
2770 struct widget *ok_button;
2771 struct widget *pedit;
2772 SDL_Rect area;
2773 int suggestlen;
2774
2775 if (new_city_dlg) {
2776 return;
2777 }
2778
2782
2783 new_city_dlg = fc_calloc(1, sizeof(struct small_dialog));
2784
2785 /* Create window */
2788 pstr->style |= TTF_STYLE_BOLD;
2789 pwindow = create_window_skeleton(NULL, pstr, 0);
2791
2792 area = pwindow->area;
2793
2794 /* Create ok button */
2795 ok_button =
2797 pwindow->dst,
2798 _("OK"), FONTO_DEFAULT, 0);
2799 ok_button->action = newcity_ok_callback;
2800 ok_button->key = SDLK_RETURN;
2801 ok_button->data.tile = unit_tile(punit);
2802
2803 area.h += ok_button->size.h;
2804
2805 /* Create cancel button */
2806 cancel_button =
2808 pwindow->dst, _("Cancel"),
2809 FONTO_DEFAULT, 0);
2810 cancel_button->action = newcity_cancel_callback;
2811 cancel_button->key = SDLK_ESCAPE;
2812 cancel_button->data.tile = unit_tile(punit);
2813
2814 /* Correct sizes */
2815 cancel_button->size.w += adj_size(5);
2816 ok_button->size.w = cancel_button->size.w;
2817
2818 /* Create text label */
2819 pstr = create_utf8_from_char_fonto(_("What should we call our new city?"),
2821 pstr->style |= (TTF_STYLE_BOLD|SF_CENTER);
2823 label = create_iconlabel(NULL, pwindow->dst, pstr,
2825
2826 area.h += label->size.h;
2827
2828 pedit = create_edit(NULL, pwindow->dst,
2830 (ok_button->size.w + cancel_button->size.w + adj_size(15)),
2833
2834 area.w = MAX(area.w, pedit->size.w + adj_size(20));
2835 area.h += pedit->size.h + adj_size(25);
2836
2837 /* I make this hack to center label on window */
2838 if (label->size.w < area.w) {
2839 label->size.w = area.w;
2840 } else {
2841 area.w = MAX(pwindow->area.w, label->size.w + adj_size(10));
2842 }
2843
2844 pedit->size.w = area.w - adj_size(20);
2845
2846 /* Create window background */
2848 if (resize_window(pwindow, background, NULL,
2849 (pwindow->size.w - pwindow->area.w) + area.w,
2850 (pwindow->size.h - pwindow->area.h) + area.h)) {
2851 FREESURFACE(background);
2852 }
2853
2854 area = pwindow->area;
2855
2856 /* set start positions */
2857 widget_set_position(pwindow,
2858 (main_window_width() - pwindow->size.w) / 2,
2859 (main_window_height() - pwindow->size.h) / 2);
2860
2861 ok_button->size.x = area.x + adj_size(10);
2862 ok_button->size.y = area.y + area.h - ok_button->size.h - adj_size(10);
2863
2864 cancel_button->size.y = ok_button->size.y;
2865 cancel_button->size.x = area.x + area.w - cancel_button->size.w - adj_size(10);
2866
2867 pedit->size.x = area.x + adj_size(10);
2868 pedit->size.y = area.y + adj_size(4) + label->size.h + adj_size(3);
2869
2870 label->size.x = area.x + adj_size(3);
2871 label->size.y = area.y + adj_size(4);
2872
2873 /* enable widgets */
2874 set_wstate(cancel_button, FC_WS_NORMAL);
2875 set_wstate(ok_button, FC_WS_NORMAL);
2876 set_wstate(pedit, FC_WS_NORMAL);
2877 set_wstate(pwindow, FC_WS_NORMAL);
2878
2879 /* add widgets to main list */
2880 new_city_dlg->end_widget_list = pwindow;
2887
2888 /* redraw */
2889 redraw_group(pedit, pwindow, 0);
2890
2891 widget_flush(pwindow);
2892}
2893
2894/**********************************************************************/
2906
2907/**********************************************************************/
2925
2926/**********************************************************************/
2930{
2931 int pos_x, pos_y;
2932
2933 SDL_GetMouseState(&pos_x, &pos_y);
2934 update_line(pos_x, pos_y);
2936}
2937
2938/**********************************************************************/
2943{
2944 /* PORTME */
2945}
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
Uint32 sdl2_client_flags
Definition gui_main.c:101
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
#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