Freeciv-3.2
Loading...
Searching...
No Matches
gui_main.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 gui_main.c - description
16 -------------------
17 begin : Sun Jun 30 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#include "fc_prehdrs.h"
27
28#include <errno.h>
29
30#ifdef HAVE_LOCALE_H
31#include <locale.h>
32#endif
33
34#ifdef HAVE_UNISTD_H
35#include <unistd.h>
36#endif
37
38#ifdef __EMSCRIPTEN__
39#include <emscripten.h>
40#endif
41
42/* SDL2 */
43#ifdef SDL2_PLAIN_INCLUDE
44#include <SDL.h>
45#else /* SDL2_PLAIN_INCLUDE */
46#include <SDL2/SDL.h>
47#endif /* SDL2_PLAIN_INCLUDE */
48
49/* utility */
50#include "fc_cmdline.h"
51#include "fciconv.h"
52#include "fcintl.h"
53#include "log.h"
54#include "netintf.h"
55
56/* common */
57#include "unitlist.h"
58
59/* client */
60#include "client_main.h"
61#include "climisc.h"
62#include "clinet.h"
63#include "editgui_g.h"
64#include "tilespec.h"
65#include "update_queue.h"
66#include "zoom.h"
67
68/* gui-sdl2 */
69#include "chatline.h"
70#include "citydlg.h"
71#include "cityrep.h"
72#include "diplodlg.h"
73#include "graphics.h"
74#include "gui_id.h"
75#include "gui_mouse.h"
76#include "gui_tilespec.h"
77#include "inteldlg.h"
78#include "mapctrl.h"
79#include "mapview.h"
80#include "menu.h"
81#include "messagewin.h"
82#include "optiondlg.h"
83#include "repodlgs.h"
84#include "themespec.h"
85#include "spaceshipdlg.h"
86#include "widget.h"
87
88#include "gui_main.h"
89
90#define UNITS_TIMER_INTERVAL 128 /* milliseconds */
91#define MAP_SCROLL_TIMER_INTERVAL 500
92
93const char *client_string = "gui-sdl2";
94
95/* The real GUI character encoding is UTF-16 which is not supported by
96 * fciconv code at this time. Conversion between UTF-8 and UTF-16 is done
97 * in gui_iconv.c */
98const char * const gui_character_encoding = "UTF-8";
100
102
106extern bool draw_goto_patrol_lines;
110bool LCTRL;
111bool RCTRL;
112bool LALT;
113static int city_names_font_size = 10;
116 &city_names_font_size, /* FONT_CITY_NAME */
117 &city_productions_font_size, /* FONT_CITY_PROD */
118 &city_productions_font_size /* FONT_REQTREE_TEXT; not used yet */
119};
120
121static unsigned font_size_parameter = 0;
122
123/* ================================ Private ============================ */
124static int net_socket = -1;
125static bool autoconnect = FALSE;
128
131
137
143
144static void print_usage(void);
145static bool parse_options(int argc, char **argv);
146static bool check_scroll_area(int x, int y);
147
149
160
161struct callback {
162 void (*callback)(void *data);
163 void *data;
164};
165
166#define SPECLIST_TAG callback
167#define SPECLIST_TYPE struct callback
168#include "speclist.h"
169
170struct callback_list *callbacks = NULL;
171
172/* =========================================================== */
173
174/**********************************************************************/
178static void print_usage(void)
179{
180 /* Add client-specific usage information here */
182 _(" -f, --fullscreen\tStart Client in Fullscreen mode\n"));
184 _(" -F, --Font SIZE\tUse SIZE as the base font size\n"));
185 fc_fprintf(stderr, _(" -s, --swrenderer\tUse SW renderer\n"));
186 fc_fprintf(stderr, _(" -t, --theme THEME\tUse GUI theme THEME\n"));
187
188 /* TRANS: No full stop after the URL, could cause confusion. */
189 fc_fprintf(stderr, _("Report bugs at %s\n"), BUG_URL);
190}
191
192/**********************************************************************/
195static bool parse_options(int argc, char **argv)
196{
197 int i = 1;
198 char *option = NULL;
199
200 while (i < argc) {
201 if (is_option("--help", argv[i])) {
202 print_usage();
203
204 return FALSE;
205 } else if (is_option("--fullscreen", argv[i])) {
207 } else if (is_option("--swrenderer", argv[i])) {
209 } else if ((option = get_option_malloc("--Font", argv, &i, argc, FALSE))) {
211 fc_fprintf(stderr, _("Invalid font size %s"), option);
213 }
214 free(option);
215 } else if ((option = get_option_malloc("--theme", argv, &i, argc, FALSE))) {
217 free(option);
218 } else {
219 fc_fprintf(stderr, _("Unrecognized option: \"%s\"\n"), argv[i]);
220
222 }
223
224 i++;
225 }
226
227 return TRUE;
228}
229
230/**********************************************************************/
234{
235 static struct widget *pwidget;
236
237 if ((pwidget = find_next_widget_for_key(NULL, key)) != NULL) {
238 return widget_pressed_action(pwidget);
239 } else {
240 if (key.sym == SDLK_TAB) {
241 /* Input */
243 } else {
245 && C_S_RUNNING == client_state()) {
246 switch (key.sym) {
247 case SDLK_RETURN:
248 case SDLK_KP_ENTER:
249 if (LSHIFT || RSHIFT) {
251 key_end_turn();
252 } else {
253 struct unit *punit;
254 struct city *pcity;
255
257 && (pcity = tile_city(unit_tile(punit))) != NULL
258 && city_owner(pcity) == client.conn.playing) {
259 popup_city_dialog(pcity);
260 }
261 }
262 return ID_ERROR;
263
264 case SDLK_F2:
266 return ID_ERROR;
267
268 case SDLK_F4:
270 return ID_ERROR;
271
272 case SDLK_F7:
274 return ID_ERROR;
275
276 case SDLK_F8:
278 return ID_ERROR;
279
280 case SDLK_F9:
281 if (meswin_dialog_is_open()) {
283 } else {
285 }
286 flush_dirty();
287 return ID_ERROR;
288
289 case SDLK_F11:
291 return ID_ERROR;
292
293 case SDLK_F12:
295 return ID_ERROR;
296
297 case SDLK_ASTERISK:
299 return ID_ERROR;
300
301 default:
302 return ID_ERROR;
303 }
304 }
305 }
306 }
307
308 return ID_ERROR;
309}
310
311/**********************************************************************/
315{
316 if (selected_widget) {
318 }
319
320 return ID_ERROR;
321}
322/**********************************************************************/
326 void *data)
327{
328 struct widget *pwidget;
329 /* Touch event coordinates are normalized (0...1). */
330 int x = touch_event->x * main_window_width();
331 int y = touch_event->y * main_window_height();
332
333 if ((pwidget = find_next_widget_at_pos(NULL, x, y)) != NULL) {
334 if (get_wstate(pwidget) != FC_WS_DISABLED) {
335 return widget_pressed_action(pwidget);
336 }
337 } else {
338 /* No visible widget at this position; map pressed. */
340 /* Start counting. */
346 }
347 }
348
349 return ID_ERROR;
350}
351
352/**********************************************************************/
356 void *data)
357{
358 /* Touch event coordinates are normalized (0...1). */
359 int x = touch_event->x * main_window_width();
360 int y = touch_event->y * main_window_height();
361
362 /* Screen wasn't pressed over a widget. */
367 }
368
371
373
374 return ID_ERROR;
375}
376
377/**********************************************************************/
381 void *data)
382{
383 struct widget *pwidget;
384
385 if ((pwidget = find_next_widget_at_pos(NULL,
386 button_event->x,
387 button_event->y)) != NULL) {
388 if (get_wstate(pwidget) != FC_WS_DISABLED) {
389 return widget_pressed_action(pwidget);
390 }
391 } else {
392 /* No visible widget at this position -> map click */
393#ifdef UNDER_CE
395#endif
397 /* Start counting */
403 mouse_zoom);
404 }
405#ifdef UNDER_CE
406 }
407#endif
408 }
409
410 return ID_ERROR;
411}
412
413/**********************************************************************/
432
433#ifdef UNDER_CE
434 #define SCROLL_MAP_AREA 8
435#else
436 #define SCROLL_MAP_AREA 1
437#endif
438
439/**********************************************************************/
443 void *data)
444{
445 static struct widget *pwidget;
446 struct tile *ptile;
447
448 /* Stop evaluating button hold time when moving to another tile in medium
449 * hold state or above */
452 mouse_zoom);
455 }
456 }
457
460 }
461
462#ifndef UNDER_CE
465 }
466#endif /* UNDER_CE */
467
468 if ((pwidget = find_next_widget_at_pos(NULL,
469 motion_event->x,
470 motion_event->y)) != NULL) {
472 if (get_wstate(pwidget) != FC_WS_DISABLED) {
473 widget_selected_action(pwidget);
474 }
475 } else {
476 if (selected_widget) {
478 } else {
480 mouse_zoom));
481 }
482 }
483
485
486 return ID_ERROR;
487}
488
489/**********************************************************************/
517
518/**********************************************************************/
521static bool check_scroll_area(int x, int y)
522{
523 SDL_Rect rect_north = {.x = 0, .y = 0,
524 .w = main_data.map->w, .h = SCROLL_MAP_AREA};
525 SDL_Rect rect_east = {.x = main_data.map->w - SCROLL_MAP_AREA, .y = 0,
526 .w = SCROLL_MAP_AREA, .h = main_data.map->h};
527 SDL_Rect rect_south = {.x = 0, .y = main_data.map->h - SCROLL_MAP_AREA,
528 .w = main_data.map->w, .h = SCROLL_MAP_AREA};
529 SDL_Rect rect_west = {.x = 0, .y = 0,
530 .w = SCROLL_MAP_AREA, .h = main_data.map->h};
531
532 if (is_in_rect_area(x, y, &rect_north)) {
534 if (is_in_rect_area(x, y, &rect_west)) {
536 } else if (is_in_rect_area(x, y, &rect_east)) {
538 } else {
540 }
541 } else if (is_in_rect_area(x, y, &rect_south)) {
543 if (is_in_rect_area(x, y, &rect_west)) {
545 } else if (is_in_rect_area(x, y, &rect_east)) {
547 } else {
549 }
550 } else if (is_in_rect_area(x, y, &rect_east)) {
553 } else if (is_in_rect_area(x, y, &rect_west)) {
556 } else {
558 }
559
560 return is_map_scrolling;
561}
562
563/* ============================ Public ========================== */
564
565/**********************************************************************/
569{
571
572 event.type = user_event_type;
573 event.user.code = EXIT_FROM_EVENT_LOOP;
574 event.user.data1 = NULL;
575 event.user.data2 = NULL;
576
578}
579
580/**********************************************************************/
585{
586 if (event->type == SDL_MOUSEMOTION) {
587 static int x = 0, y = 0;
588
589 if (((MOVE_STEP_X > 0) && (abs(event->motion.x - x) >= MOVE_STEP_X))
590 || ((MOVE_STEP_Y > 0) && (abs(event->motion.y - y) >= MOVE_STEP_Y)) ) {
591 x = event->motion.x;
592 y = event->motion.y;
593 return 1; /* Catch it */
594 } else {
595 return 0; /* Drop it, we've handled it */
596 }
597 }
598
599 return 1;
600}
601
602/**********************************************************************/
606 void (*loop_action)(void *data),
607 widget_id (*key_down_handler)(SDL_Keysym key, void *data),
608 widget_id (*key_up_handler)(SDL_Keysym key, void *data),
609 widget_id (*textinput_handler)(const char *text, void *data),
611 void *data),
613 void *data),
615 void *data),
617 void *data),
619 void *data),
621 void *data))
622{
623 Uint16 ID;
624 static fc_timeval tv;
625 static fd_set civfdset;
628 static int result;
629
630 ID = ID_ERROR;
632 while (ID == ID_ERROR) {
633 /* ========================================= */
634 /* Net check with 10ms delay event loop */
635 if (net_socket >= 0) {
637
638 if (net_socket >= 0) {
640 }
641
642 tv.tv_sec = 0;
643 tv.tv_usec = 10000; /* 10ms*/
644
645 result = fc_select(net_socket + 1, &civfdset, NULL, NULL, &tv);
646 if (result < 0) {
647 if (errno != EINTR) {
648 break;
649 } else {
650 continue;
651 }
652 } else {
653 if (result > 0) {
654 if ((net_socket >= 0) && FD_ISSET(net_socket, &civfdset)) {
656 }
657 }
658 }
659 } else { /* If connection is not establish */
660 SDL_Delay(10);
661 }
662 /* ========================================= */
663
665
668 }
669
671 if (autoconnect) {
674 } else {
676 }
677
679 }
680
681 if (is_map_scrolling) {
685 }
686 } else {
688 }
689
690 if (widget_info_counter > 0) {
693 }
694
695 /* ========================================= */
696
697 if (loop_action) {
698 loop_action(data);
699 }
700
701 /* ========================================= */
702
703 while (SDL_PollEvent(&main_data.event) == 1) {
704
705 if (main_data.event.type == user_event_type) {
706 switch (main_data.event.user.code) {
707 case NET:
709 break;
710 case ANIM:
714 break;
717 break;
718 case TRY_AUTO_CONNECT:
719 if (try_to_autoconnect()) {
722 }
723 break;
724 case FLUSH:
726 break;
727 case MAP_SCROLL:
729 break;
731 return MAX_ID;
732 break;
733 default:
734 break;
735 }
736
737 } else {
738
739 switch (main_data.event.type) {
740
741 case SDL_QUIT:
742 return MAX_ID;
743 break;
744
745 case SDL_KEYUP:
746 switch (main_data.event.key.keysym.sym) {
747 /* find if Shifts are released */
748 case SDLK_RSHIFT:
749 RSHIFT = FALSE;
750 break;
751 case SDLK_LSHIFT:
752 LSHIFT = FALSE;
753 break;
754 case SDLK_LCTRL:
755 LCTRL = FALSE;
756 break;
757 case SDLK_RCTRL:
758 RCTRL = FALSE;
759 break;
760 case SDLK_LALT:
761 LALT = FALSE;
762 break;
763 default:
764 if (key_up_handler) {
765 ID = key_up_handler(main_data.event.key.keysym, data);
766 }
767 break;
768 }
769 break;
770
771 case SDL_KEYDOWN:
772 switch (main_data.event.key.keysym.sym) {
773#if 0
774 case SDLK_PRINT:
775 fc_snprintf(schot, sizeof(schot), "fc_%05d.bmp", schot_nr++);
776 log_normal(_("Making screenshot %s"), schot);
778 break;
779#endif /* 0 */
780
781 case SDLK_RSHIFT:
782 /* Right Shift is Pressed */
783 RSHIFT = TRUE;
784 break;
785
786 case SDLK_LSHIFT:
787 /* Left Shift is Pressed */
788 LSHIFT = TRUE;
789 break;
790
791 case SDLK_LCTRL:
792 /* Left CTRL is Pressed */
793 LCTRL = TRUE;
794 break;
795
796 case SDLK_RCTRL:
797 /* Right CTRL is Pressed */
798 RCTRL = TRUE;
799 break;
800
801 case SDLK_LALT:
802 /* Left ALT is Pressed */
803 LALT = TRUE;
804 break;
805
806 default:
807 if (key_down_handler) {
808 ID = key_down_handler(main_data.event.key.keysym, data);
809 }
810 break;
811 }
812 break;
813
814 case SDL_TEXTINPUT:
815 if (textinput_handler) {
816 ID = textinput_handler(main_data.event.text.text, data);
817 }
818 break;
819
820 case SDL_FINGERDOWN:
822 ID = finger_down_handler(&main_data.event.tfinger, data);
823 }
824 break;
825
826 case SDL_FINGERUP:
827 if (finger_up_handler) {
828 ID = finger_up_handler(&main_data.event.tfinger, data);
829 }
830 break;
831
832 case SDL_FINGERMOTION:
834 ID = finger_motion_handler(&main_data.event.tfinger, data);
835 }
836 break;
837
841 }
842 break;
843
846 ID = mouse_button_up_handler(&main_data.event.button, data);
847 }
848 break;
849
850 case SDL_MOUSEMOTION:
852 ID = mouse_motion_handler(&main_data.event.motion, data);
853 }
854 break;
855 }
856 }
857 }
858
859 if (ID == ID_ERROR) {
861 struct callback *cb = callback_list_get(callbacks, 0);
862
864 (cb->callback)(cb->data);
865 free(cb);
866 }
867 }
868
870
871#ifdef __EMSCRIPTEN__
872 emscripten_sleep(100);
873#endif
874 }
875
876 return ID;
877}
878
879/* ============ Freeciv native game function =========== */
880
881/**********************************************************************/
898
899/**********************************************************************/
903{
904 struct widget *widget;
905
906 if (C_S_RUNNING == client_state()) {
907 /* Move units window to botton-right corner. */
909 /* Move minimap window to botton-left corner. */
911
912 /* Move cooling/warming icons to botton-right corner. */
915 - (widget->size.w * 2)), widget->size.y);
916
919 - widget->size.w), widget->size.y);
920
924 center_on_something(); /* With redrawing full map. */
926 } else {
928 dirty_all();
929 }
930
931 flush_all();
932}
933
934/**********************************************************************/
941
942/**********************************************************************/
968
969/**********************************************************************/
974{
975 struct option *poption;
976
977#define option_var_set_callback(var, callback) \
978 if ((poption = optset_option_by_name(client_optset, \
979 GUI_SDL_OPTION_STR(var)))) { \
980 option_set_changed_callback(poption, callback); \
981 } else { \
982 log_error("Didn't find option %s!", GUI_SDL_OPTION_STR(var)); \
983 }
984
987#undef option_var_set_callback
988}
989
990/**********************************************************************/
995{
996 int i;
997
998 /* Clear double call */
999 for (i = 0; i <= event_type_max(); i++) {
1000 if (messages_where[i] & MW_MESSAGES) {
1002 }
1003 }
1004}
1005
1006/**********************************************************************/
1011int main(int argc, char **argv)
1012{
1013 return client_main(argc, argv, FALSE);
1014}
1015
1016/**********************************************************************/
1020{
1021 log_normal(_("Migrating options from sdl to sdl2 client"));
1022
1023#define MIGRATE_OPTION(opt) gui_options.gui_sdl2_##opt = gui_options.gui_sdl_##opt;
1024
1025 /* Default theme name is never migrated */
1027 MIGRATE_OPTION(screen);
1030
1031#undef MIGRATE_OPTION
1032
1034}
1035
1036/**********************************************************************/
1040int ui_main(int argc, char *argv[])
1041{
1042 Uint32 flags = 0;
1043
1044 if (parse_options(argc, argv)) {
1047 }
1049 if (font_size_parameter > 10) {
1050 GUI_SDL_OPTION(screen) = VIDEO_MODE(640 * font_size_parameter / 10,
1051 480 * font_size_parameter / 10);
1052 }
1053
1055 }
1056
1058 flags |= SDL_WINDOW_FULLSCREEN;
1059 } else {
1060 flags &= ~SDL_WINDOW_FULLSCREEN;
1061 }
1062
1063 log_normal(_("Using Video Output: %s"), SDL_GetCurrentVideoDriver());
1064 if (!set_video_mode(GUI_SDL_OPTION(screen.width),
1065 GUI_SDL_OPTION(screen.height),
1066 flags)) {
1067 return EXIT_FAILURE;
1068 }
1069
1071
1074 __net_user_event.user.code = NET;
1075 __net_user_event.user.data1 = NULL;
1076 __net_user_event.user.data2 = NULL;
1078
1081 __anim_user_event.user.code = EVENT_ERROR;
1082 __anim_user_event.user.data1 = NULL;
1083 __anim_user_event.user.data2 = NULL;
1085
1089 __info_user_event.user.data1 = NULL;
1090 __info_user_event.user.data2 = NULL;
1092
1095 __flush_user_event.user.code = FLUSH;
1096 __flush_user_event.user.data1 = NULL;
1097 __flush_user_event.user.data2 = NULL;
1099
1103 __map_scroll_user_event.user.data1 = NULL;
1104 __map_scroll_user_event.user.data2 = NULL;
1106
1108
1114
1118
1119 load_cursors();
1120
1122
1125
1127
1129
1130 /* This needs correct main_data.screen size */
1132
1134
1135 /* Main game loop */
1141
1143
1145
1147
1150
1152 callbacks = NULL;
1153
1155
1158
1160
1161 del_main_list();
1162
1166
1167 quit_sdl();
1168 }
1169
1170 return EXIT_SUCCESS;
1171}
1172
1173/**********************************************************************/
1176void ui_exit(void)
1177{
1178}
1179
1180/**********************************************************************/
1183enum gui_type get_gui_type(void)
1184{
1185 return GUI_SDL2;
1186}
1187
1188/**********************************************************************/
1192void sound_bell(void)
1193{
1194 log_debug("sound_bell : PORT ME");
1195}
1196
1197/**********************************************************************/
1201{
1202 anim_user_event->user.code = ANIM;
1204}
1205
1206/**********************************************************************/
1213
1214/**********************************************************************/
1218void add_net_input(int sock)
1219{
1220 log_debug("Connection UP (%d)", sock);
1221 net_socket = sock;
1224}
1225
1226/**********************************************************************/
1230{
1231 log_debug("Connection DOWN... ");
1232 net_socket = (-1);
1236}
1237
1238/**********************************************************************/
1243void add_idle_callback(void (callback)(void *), void *data)
1244{
1245 if (callbacks != NULL) {
1246 struct callback *cb = fc_malloc(sizeof(*cb));
1247
1248 cb->callback = callback;
1249 cb->data = data;
1250
1252 }
1253}
1254
1255/**********************************************************************/
1259{}
1260
1261/**********************************************************************/
1265{}
1266
1267/**********************************************************************/
1270void editgui_popup_properties(const struct tile_list *tiles, int objtype)
1271{}
1272
1273/**********************************************************************/
1277{}
1278
1279/**********************************************************************/
1282void editgui_notify_object_changed(int objtype, int object_id, bool removal)
1283{}
1284
1285/**********************************************************************/
1289{}
1290
1291/**********************************************************************/
1294void gui_update_font(const char *font_name, const char *font_value)
1295{
1296#define CHECK_FONT(client_font, action) \
1297 do { \
1298 if (strcmp(#client_font, font_name) == 0) { \
1299 char *end; \
1300 long size = strtol(font_value, &end, 10); \
1301 if (end && *end == '\0' && size > 0) { \
1302 *client_font_sizes[client_font] = size; \
1303 action; \
1304 } \
1305 } \
1306 } while (FALSE)
1307
1310 /* FONT_REQTREE_TEXT not used yet */
1311
1312#undef CHECK_FONT
1313}
1314
1315/**********************************************************************/
1324
1325/**********************************************************************/
1333
1334/**********************************************************************/
1338{
1339 /* PORTME */
1340}
1341
1342/**********************************************************************/
1345bool flush_event(void)
1346{
1347 return SDL_PushEvent(flush_user_event) >= 0;
1348}
#define city_owner(_pcity_)
Definition city.h:563
void popup_city_dialog(struct city *pcity)
double real_timer_callback(void)
int client_main(int argc, char *argv[], bool postpone_tileset)
struct civclient client
enum client_states client_state(void)
void send_report_request(enum report_type type)
void start_quitting(void)
void set_client_state(enum client_states newstate)
@ C_S_DISCONNECTED
Definition client_main.h:45
@ C_S_RUNNING
Definition client_main.h:47
void center_on_something(void)
Definition climisc.c:430
double try_to_autoconnect(void)
Definition clinet.c:498
void input_from_server(int fd)
Definition clinet.c:411
char * incite_cost
Definition comments.c:75
@ REPORT_WONDERS_OF_THE_WORLD
Definition conn_types.h:50
@ REPORT_DEMOGRAPHIC
Definition conn_types.h:53
@ REPORT_ACHIEVEMENTS
Definition conn_types.h:54
@ REPORT_TOP_CITIES
Definition conn_types.h:52
struct unit_list * get_units_in_focus(void)
Definition control.c:177
void key_end_turn(void)
Definition control.c:3312
struct unit * head_of_units_in_focus(void)
Definition control.c:410
void control_mouse_cursor(struct tile *ptile)
Definition control.c:1215
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
int objtype
Definition editgui_g.h:28
editgui_notify_object_changed
Definition editgui_g.h:27
enum event_type event
Definition events.c:81
bool is_option(const char *option_name, char *option)
Definition fc_cmdline.c:112
char * get_option_malloc(const char *option_name, char **argv, int *i, int argc, bool gc)
Definition fc_cmdline.c:50
void fc_fprintf(FILE *stream, const char *format,...) fc__attribute((__format__(__printf__
#define _(String)
Definition fcintl.h:67
void city_report_dialog_popup(bool raise)
Definition cityrep.c:292
void diplomacy_dialog_init(void)
Definition diplodlg.c:1206
void diplomacy_dialog_done(void)
Definition diplodlg.c:1215
void load_cursors(void)
Definition graphics.c:78
int ui_main(int argc, char **argv)
Definition gui_main.c:1887
const char * client_string
Definition gui_main.c:105
static void print_usage(void)
Definition gui_main.c:265
#define option_var_set_callback(var, callback)
void ui_exit(void)
Definition gui_main.c:2066
enum gui_type get_gui_type(void)
Definition gui_main.c:2077
int main(int argc, char **argv)
Definition gui_main.c:1765
void ui_init(void)
Definition gui_main.c:1755
void add_idle_callback(void(callback)(void *), void *data)
Definition gui_main.c:2405
void options_extra_init(void)
Definition gui_main.c:2479
void insert_client_build_info(char *outbuf, size_t outlen)
Definition gui_main.c:2539
void remove_net_input(void)
Definition gui_main.c:2311
void sound_bell(void)
Definition gui_main.c:2085
const char *const gui_character_encoding
Definition gui_main.c:161
void add_net_input(int sock)
Definition gui_main.c:2293
static bool parse_options(int argc, char **argv)
Definition gui_main.c:286
#define MIGRATE_OPTION(opt)
const bool gui_use_transliteration
Definition gui_main.c:162
void intel_dialog_done(void)
Definition inteldlg.c:128
void intel_dialog_init(void)
Definition inteldlg.c:119
void flush_dirty(void)
Definition mapview.c:468
void update_info_label(void)
Definition mapview.c:138
void dirty_all(void)
Definition mapview.c:456
void update_unit_info_label(struct unit_list *punits)
Definition mapview.c:275
void update_city_descriptions(void)
Definition mapview.c:488
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
void units_report_dialog_popup(bool raise)
Definition repodlgs.c:1768
void popup_spaceship_dialog(struct player *pplayer)
void popup_input_line(void)
Definition chatline.c:358
bool set_video_mode(unsigned width, unsigned height, unsigned flags_in)
Definition graphics.c:634
int main_window_width(void)
Definition graphics.c:683
void init_sdl(int flags)
Definition graphics.c:504
void update_main_screen(void)
Definition graphics.c:667
void quit_sdl(void)
Definition graphics.c:620
bool is_in_rect_area(int x, int y, const SDL_Rect *rect)
Definition graphics.c:923
struct sdl2_data main_data
Definition graphics.c:55
bool create_surfaces(int width, int height)
Definition graphics.c:554
int main_window_height(void)
Definition graphics.c:691
@ ID_COOLING_ICON
Definition gui_id.h:138
@ ID_ERROR
Definition gui_id.h:26
@ ID_WARMING_ICON
Definition gui_id.h:139
static widget_id main_key_down_handler(SDL_Keysym key, void *data)
Definition gui_main.c:233
static int city_names_font_size
Definition gui_main.c:113
static SDL_Event __anim_user_event
Definition gui_main.c:133
static void migrate_options_from_sdl(void)
Definition gui_main.c:1019
static SDL_Event * net_user_event
Definition gui_main.c:138
static widget_id main_finger_up_handler(SDL_TouchFingerEvent *touch_event, void *data)
Definition gui_main.c:355
static void resize_window_callback(struct option *poption)
Definition gui_main.c:937
static void fullscreen_callback(struct option *poption)
Definition gui_main.c:945
void editgui_popup_properties(const struct tile_list *tiles, int objtype)
Definition gui_main.c:1270
void editgui_notify_object_created(int tag, int id)
Definition gui_main.c:1288
#define CHECK_FONT(client_font, action)
static struct mouse_button_behavior button_behavior
Definition gui_main.c:130
bool is_unit_move_blocked
Definition gui_main.c:107
static SDL_Event __info_user_event
Definition gui_main.c:134
bool LSHIFT
Definition gui_main.c:108
static widget_id main_mouse_motion_handler(SDL_MouseMotionEvent *motion_event, void *data)
Definition gui_main.c:442
static SDL_Event __flush_user_event
Definition gui_main.c:135
int FilterMouseMotionEvents(void *data, SDL_Event *event)
Definition gui_main.c:584
static SDL_Event * info_user_event
Definition gui_main.c:140
static SDL_Event __net_user_event
Definition gui_main.c:132
void enable_focus_animation(void)
Definition gui_main.c:1200
static widget_id main_mouse_button_up_handler(SDL_MouseButtonEvent *button_event, void *data)
Definition gui_main.c:416
void editgui_popdown_all(void)
Definition gui_main.c:1276
bool flush_event(void)
Definition gui_main.c:1345
#define MAP_SCROLL_TIMER_INTERVAL
Definition gui_main.c:91
static void real_resize_window_callback(void *data)
Definition gui_main.c:902
bool draw_goto_patrol_lines
Definition mapctrl.c:104
#define UNITS_TIMER_INTERVAL
Definition gui_main.c:90
static void update_button_hold_state(void)
Definition gui_main.c:493
static widget_id main_finger_down_handler(SDL_TouchFingerEvent *touch_event, void *data)
Definition gui_main.c:325
static bool is_map_scrolling
Definition gui_main.c:126
static SDL_Event * map_scroll_user_event
Definition gui_main.c:142
bool RSHIFT
Definition gui_main.c:109
int MOVE_STEP_Y
Definition gui_main.c:105
#define SCROLL_MAP_AREA
Definition gui_main.c:436
Uint32 widget_info_counter
Definition gui_main.c:103
static widget_id main_key_up_handler(SDL_Keysym key, void *data)
Definition gui_main.c:314
static SDL_Event * anim_user_event
Definition gui_main.c:139
static bool autoconnect
Definition gui_main.c:125
static bool check_scroll_area(int x, int y)
Definition gui_main.c:521
static int net_socket
Definition gui_main.c:124
void update_font_from_theme(int theme_font_size)
Definition gui_main.c:1328
static int city_productions_font_size
Definition gui_main.c:114
bool LALT
Definition gui_main.c:112
bool LCTRL
Definition gui_main.c:110
unsigned default_font_size(struct theme *act_theme)
Definition gui_main.c:1318
static widget_id main_mouse_button_down_handler(SDL_MouseButtonEvent *button_event, void *data)
Definition gui_main.c:380
static void clear_double_messages_call(void)
Definition gui_main.c:994
void force_exit_from_event_loop(void)
Definition gui_main.c:568
void disable_focus_animation(void)
Definition gui_main.c:1209
static enum direction8 scroll_dir
Definition gui_main.c:127
static unsigned font_size_parameter
Definition gui_main.c:121
int * client_font_sizes[FONT_COUNT]
Definition gui_main.c:115
void editgui_refresh(void)
Definition gui_main.c:1264
int user_event_type
Definition gui_main.c:148
widget_id gui_event_loop(void *data, void(*loop_action)(void *data), widget_id(*key_down_handler)(SDL_Keysym key, void *data), widget_id(*key_up_handler)(SDL_Keysym key, void *data), widget_id(*textinput_handler)(const char *text, void *data), widget_id(*finger_down_handler)(SDL_TouchFingerEvent *touch_event, void *data), widget_id(*finger_up_handler)(SDL_TouchFingerEvent *touch_event, void *data), widget_id(*finger_motion_handler)(SDL_TouchFingerEvent *touch_event, void *data), widget_id(*mouse_button_down_handler)(SDL_MouseButtonEvent *button_event, void *data), widget_id(*mouse_button_up_handler)(SDL_MouseButtonEvent *button_event, void *data), widget_id(*mouse_motion_handler)(SDL_MouseMotionEvent *motion_event, void *data))
Definition gui_main.c:605
static SDL_Event __map_scroll_user_event
Definition gui_main.c:136
Uint32 sdl2_client_flags
Definition gui_main.c:101
static SDL_Event * flush_user_event
Definition gui_main.c:141
struct callback_list * callbacks
Definition gui_main.c:170
USER_EVENT_ID
Definition gui_main.c:150
@ NET
Definition gui_main.c:152
@ ANIM
Definition gui_main.c:153
@ TRY_AUTO_CONNECT
Definition gui_main.c:154
@ MAP_SCROLL
Definition gui_main.c:157
@ FLUSH
Definition gui_main.c:156
@ EVENT_ERROR
Definition gui_main.c:151
@ EXIT_FROM_EVENT_LOOP
Definition gui_main.c:158
@ SHOW_WIDGET_INFO_LABEL
Definition gui_main.c:155
void editgui_tileset_changed(void)
Definition gui_main.c:1258
int MOVE_STEP_X
Definition gui_main.c:104
bool RCTRL
Definition gui_main.c:111
#define CF_FOCUS_ANIMATION
Definition gui_main.h:51
#define CF_DRAW_PLAYERS_ALLIANCE_STATUS
Definition gui_main.h:62
Uint32 widget_id
Definition gui_main.h:77
#define CF_DRAW_PLAYERS_CEASEFIRE_STATUS
Definition gui_main.h:60
#define CF_SWRENDERER
Definition gui_main.h:64
#define CF_DRAW_PLAYERS_PEACE_STATUS
Definition gui_main.h:61
@ MB_HOLD_LONG
Definition gui_main.h:82
@ MB_HOLD_MEDIUM
Definition gui_main.h:81
@ MB_HOLD_SHORT
Definition gui_main.h:80
#define MB_MEDIUM_HOLD_DELAY
Definition gui_main.h:67
struct widget * selected_widget
Definition widget.c:48
#define CF_DRAW_PLAYERS_NEUTRAL_STATUS
Definition gui_main.h:63
#define adj_size(size)
Definition gui_main.h:145
#define DEFAULT_MOVE_STEP
Definition gui_main.h:115
#define MB_LONG_HOLD_DELAY
Definition gui_main.h:68
#define CF_DRAW_PLAYERS_WAR_STATUS
Definition gui_main.h:59
#define GUI_SDL_OPTION(optname)
Definition gui_main.h:37
void animate_mouse_cursor(void)
Definition gui_mouse.c:182
void unload_cursors(void)
Definition gui_mouse.c:164
void draw_mouse_cursor(void)
Definition gui_mouse.c:100
void free_font_system(void)
Definition gui_string.c:698
void setup_auxiliary_tech_icons(void)
void draw_intro_gfx(void)
void free_auxiliary_tech_icons(void)
void button_down_on_map(struct mouse_button_behavior *button_behavior)
Definition mapctrl.c:2280
void button_up_on_map(struct mouse_button_behavior *button_behavior)
Definition mapctrl.c:2351
void finger_up_on_map(struct finger_behavior *finger_behavior)
Definition mapctrl.c:2267
bool map_event_handler(SDL_Keysym key)
Definition mapctrl.c:2445
void set_new_minimap_window_pos(void)
Definition mapctrl.c:1386
void set_new_unitinfo_window_pos(void)
Definition mapctrl.c:1332
void unqueue_flush(void)
Definition mapview.c:140
void city_map_canvas_free(void)
Definition mapview.c:1190
void flush_all(void)
Definition mapview.c:201
void update_order_widgets(void)
Definition menu.c:952
void theme_free(struct theme *ftheme)
Definition themespec.c:317
int theme_default_font_size(const struct theme *t)
Definition themespec.c:177
struct theme * active_theme
Definition themespec.c:154
struct widget * find_next_widget_for_key(struct widget *start_widget, SDL_Keysym key)
Definition widget.c:252
Uint16 widget_pressed_action(struct widget *pwidget)
Definition widget.c:296
void widget_selected_action(struct widget *pwidget)
Definition widget.c:443
struct widget * get_widget_pointer_from_main_list(Uint16 id)
Definition widget.c:578
struct widget * find_next_widget_at_pos(struct widget *start_widget, int x, int y)
Definition widget.c:222
void unselect_widget_action(void)
Definition widget.c:418
void del_main_list(void)
Definition widget.c:691
static void widget_set_position(struct widget *pwidget, int x, int y)
Definition widget.h:266
#define MAX_ID
Definition widget.h:38
@ FC_WS_DISABLED
Definition widget.h:99
enum widget_state get_wstate(const struct widget *pwidget)
Definition widget_core.c:70
#define draw_widget_info_label()
Definition widget.h:246
const char * font_name
Definition gui_main_g.h:43
gui_update_font
Definition gui_main_g.h:43
#define log_debug(message,...)
Definition log.h:115
#define log_normal(message,...)
Definition log.h:107
void update_line(int canvas_x, int canvas_y)
void scroll_mapview(enum direction8 gui_dir)
void init_mapcanvas_and_overview(void)
struct tile * canvas_pos_to_tile(float canvas_x, float canvas_y, float zoom)
void free_mapcanvas_and_overview(void)
bool map_canvas_resized(int width, int height)
#define fc_calloc(n, esz)
Definition mem.h:38
#define fc_malloc(sz)
Definition mem.h:34
int fc_select(int n, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, fc_timeval *timeout)
Definition netintf.c:125
struct timeval fc_timeval
Definition netintf.h:90
int messages_where[E_COUNT]
Definition options.c:5051
struct client_options gui_options
Definition options.c:72
#define MW_MESSAGES
Definition options.h:581
#define VIDEO_MODE(ARG_width, ARG_height)
Definition options.h:51
bool str_to_uint(const char *str, unsigned int *pint)
Definition shared.c:551
struct sprite int int y
Definition sprite_g.h:31
struct sprite int x
Definition sprite_g.h:31
void * data
Definition gui_main.c:2384
void(* callback)(void *data)
Definition gui_main.c:2383
Definition city.h:320
struct connection conn
Definition client_main.h:96
bool gui_sdl2_migrated_from_sdl
Definition options.h:136
struct player * playing
Definition connection.h:151
Uint32 finger_down_ticks
Definition gui_main.h:87
struct tile * ptile
Definition gui_main.h:90
SDL_TouchFingerEvent event
Definition gui_main.h:89
enum mouse_button_hold_state hold_state
Definition gui_main.h:88
enum mouse_button_hold_state hold_state
Definition gui_main.h:96
SDL_MouseButtonEvent * event
Definition gui_main.h:97
struct tile * ptile
Definition gui_main.h:98
SDL_Event event
Definition graphics.h:217
SDL_Window * screen
Definition graphics.h:209
SDL_Surface * map
Definition graphics.h:210
Definition tile.h:50
Definition unit.h:138
union widget::@194 data
SDL_Keycode key
Definition widget.h:153
struct widget * widget
Definition widget.h:132
SDL_Rect size
Definition widget.h:145
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:974
#define sz_strlcpy(dest, src)
Definition support.h:195
#define TRUE
Definition support.h:46
#define FALSE
Definition support.h:47
struct city * tile_city(const struct tile *ptile)
Definition tile.c:83
#define tile_index(_pt_)
Definition tile.h:88
void tileset_load_tiles(struct tileset *t)
Definition tilespec.c:3628
void tileset_use_preferred_theme(const struct tileset *t)
Definition tilespec.c:7070
void tileset_init(struct tileset *t)
Definition tilespec.c:7127
@ CURSOR_DEFAULT
Definition tilespec.h:300
#define unit_tile(_pu)
Definition unit.h:397
void update_queue_add(uq_callback_t callback, void *data)
float mouse_zoom
Definition zoom.c:28