Freeciv-3.3
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/* SDL3 */
43#include <SDL3/SDL.h>
44
45/* utility */
46#include "fc_cmdline.h"
47#include "fciconv.h"
48#include "fcintl.h"
49#include "log.h"
50#include "netintf.h"
51
52/* common */
53#include "unitlist.h"
54
55/* client */
56#include "client_main.h"
57#include "climisc.h"
58#include "clinet.h"
59#include "editgui_g.h"
60#include "gui_properties.h"
61#include "spaceshipdlg_g.h"
62#include "tilespec.h"
63#include "update_queue.h"
64#include "zoom.h"
65
66/* gui-sdl3 */
67#include "chatline.h"
68#include "citydlg.h"
69#include "cityrep.h"
70#include "diplodlg.h"
71#include "graphics.h"
72#include "gui_id.h"
73#include "gui_mouse.h"
74#include "gui_tilespec.h"
75#include "inteldlg.h"
76#include "mapctrl.h"
77#include "mapview.h"
78#include "menu.h"
79#include "messagewin.h"
80#include "optiondlg.h"
81#include "repodlgs.h"
82#include "themespec.h"
83#include "widget.h"
84
85#include "gui_main.h"
86
87#define UNITS_TIMER_INTERVAL 128 /* milliseconds */
88#define MAP_SCROLL_TIMER_INTERVAL 500
89
90const char *client_string = "gui-sdl3";
91
92/* The real GUI character encoding is UTF-16 which is not supported by
93 * fciconv code at this time. Conversion between UTF-8 and UTF-16 is done
94 * in gui_iconv.c */
95const char * const gui_character_encoding = "UTF-8";
97
99
103extern bool draw_goto_patrol_lines;
107bool LCTRL;
108bool RCTRL;
109bool LALT;
110static int city_names_font_size = 10;
113 &city_names_font_size, /* FONT_CITY_NAME */
114 &city_productions_font_size, /* FONT_CITY_PROD */
115 &city_productions_font_size /* FONT_REQTREE_TEXT; not used yet */
116};
117
118static unsigned font_size_parameter = 0;
119
120/* ================================ Private ============================ */
121static int net_socket = -1;
122static bool autoconnect = FALSE;
125
128
134
140
141static void print_usage(void);
142static bool parse_options(int argc, char **argv);
143static bool check_scroll_area(int x, int y);
144
146
157
158struct callback {
159 void (*callback)(void *data);
160 void *data;
161};
162
163#define SPECLIST_TAG callback
164#define SPECLIST_TYPE struct callback
165#include "speclist.h"
166
167struct callback_list *callbacks = NULL;
168
169/* =========================================================== */
170
171/**********************************************************************/
175static void print_usage(void)
176{
177 /* Add client-specific usage information here */
179 _(" -f, --fullscreen\tStart Client in Fullscreen mode\n"));
181 _(" -F, --Font SIZE\tUse SIZE as the base font size\n"));
182 fc_fprintf(stderr, _(" -t, --theme THEME\tUse GUI theme THEME\n"));
183
184 /* TRANS: No full stop after the URL, could cause confusion. */
185 fc_fprintf(stderr, _("Report bugs at %s\n"), BUG_URL);
186}
187
188/**********************************************************************/
191static bool parse_options(int argc, char **argv)
192{
193 int i = 1;
194 char *option = NULL;
195
196 while (i < argc) {
197 if (is_option("--help", argv[i])) {
198 print_usage();
199
200 return FALSE;
201 } else if (is_option("--fullscreen", argv[i])) {
203 } else if ((option = get_option_malloc("--Font", argv, &i, argc, FALSE))) {
205 fc_fprintf(stderr, _("Invalid font size %s"), option);
207 }
208 free(option);
209 } else if ((option = get_option_malloc("--theme", argv, &i, argc, FALSE))) {
211 free(option);
212 } else {
213 fc_fprintf(stderr, _("Unrecognized option: \"%s\"\n"), argv[i]);
214
216 }
217
218 i++;
219 }
220
221 return TRUE;
222}
223
224/**********************************************************************/
228{
229 static struct widget *pwidget;
230
231 if ((pwidget = find_next_widget_for_key(NULL, key)) != NULL) {
232 return widget_pressed_action(pwidget);
233 } else {
234 if (key->key == SDLK_TAB) {
235 /* Input */
237 } else {
239 && C_S_RUNNING == client_state()) {
240 switch (key->key) {
241 case SDLK_RETURN:
242 case SDLK_KP_ENTER:
243 if (LSHIFT || RSHIFT) {
245 key_end_turn();
246 } else {
247 struct unit *punit;
248 struct city *pcity;
249
254 }
255 }
256 return ID_ERROR;
257
258 case SDLK_F2:
260 return ID_ERROR;
261
262 case SDLK_F4:
264 return ID_ERROR;
265
266 case SDLK_F7:
268 return ID_ERROR;
269
270 case SDLK_F8:
272 return ID_ERROR;
273
274 case SDLK_F9:
275 if (meswin_dialog_is_open()) {
277 } else {
279 }
280 flush_dirty();
281 return ID_ERROR;
282
283 case SDLK_F11:
285 return ID_ERROR;
286
287 case SDLK_F12:
289 return ID_ERROR;
290
291 case SDLK_ASTERISK:
293 return ID_ERROR;
294
295 default:
296 return ID_ERROR;
297 }
298 }
299 }
300 }
301
302 return ID_ERROR;
303}
304
305/**********************************************************************/
309{
310 if (selected_widget) {
312 }
313
314 return ID_ERROR;
315}
316
317/**********************************************************************/
321 void *data)
322{
323 struct widget *pwidget;
324 /* Touch event coordinates are normalized (0...1). */
325 int x = touch_event->x * main_window_width();
326 int y = touch_event->y * main_window_height();
327
328 if ((pwidget = find_next_widget_at_pos(NULL, x, y)) != NULL) {
329 if (get_wstate(pwidget) != FC_WS_DISABLED) {
330 return widget_pressed_action(pwidget);
331 }
332 } else {
333 /* No visible widget at this position; map pressed. */
335 /* Start counting. */
341 }
342 }
343 return ID_ERROR;
344}
345
346/**********************************************************************/
350 void *data)
351{
352 /* Touch event coordinates are normalized (0...1). */
353 int x = touch_event->x * main_window_width();
354 int y = touch_event->y * main_window_height();
355
356 /* Screen wasn't pressed over a widget. */
361 }
362
365
367
368 return ID_ERROR;
369}
370
371/**********************************************************************/
375 void *data)
376{
377 struct widget *pwidget;
378
379 if ((pwidget = find_next_widget_at_pos(NULL,
380 button_event->x,
381 button_event->y)) != NULL) {
382 if (get_wstate(pwidget) != FC_WS_DISABLED) {
383 return widget_pressed_action(pwidget);
384 }
385 } else {
386 /* No visible widget at this position -> map click */
387#ifdef UNDER_CE
389#endif
391 /* Start counting */
397 mouse_zoom);
398 }
399#ifdef UNDER_CE
400 }
401#endif
402 }
403
404 return ID_ERROR;
405}
406
407/**********************************************************************/
426
427#ifdef UNDER_CE
428 #define SCROLL_MAP_AREA 8
429#else
430 #define SCROLL_MAP_AREA 1
431#endif
432
433/**********************************************************************/
437 void *data)
438{
439 static struct widget *pwidget;
440 struct tile *ptile;
441
442 /* Stop evaluating button hold time when moving to another tile in medium
443 * hold state or above */
446 mouse_zoom);
449 }
450 }
451
454 }
455
456#ifndef UNDER_CE
459 }
460#endif /* UNDER_CE */
461
462 if ((pwidget = find_next_widget_at_pos(NULL,
463 motion_event->x,
464 motion_event->y)) != NULL) {
466 if (get_wstate(pwidget) != FC_WS_DISABLED) {
467 widget_selected_action(pwidget);
468 }
469 } else {
470 if (selected_widget) {
472 } else {
474 mouse_zoom));
475 }
476 }
477
479
480 return ID_ERROR;
481}
482
483/**********************************************************************/
511
512/**********************************************************************/
515static bool check_scroll_area(int x, int y)
516{
517 SDL_Rect rect_north = {.x = 0, .y = 0,
518 .w = main_data.map->w, .h = SCROLL_MAP_AREA};
519 SDL_Rect rect_east = {.x = main_data.map->w - SCROLL_MAP_AREA, .y = 0,
520 .w = SCROLL_MAP_AREA, .h = main_data.map->h};
521 SDL_Rect rect_south = {.x = 0, .y = main_data.map->h - SCROLL_MAP_AREA,
522 .w = main_data.map->w, .h = SCROLL_MAP_AREA};
523 SDL_Rect rect_west = {.x = 0, .y = 0,
524 .w = SCROLL_MAP_AREA, .h = main_data.map->h};
525
526 if (is_in_rect_area(x, y, &rect_north)) {
528 if (is_in_rect_area(x, y, &rect_west)) {
530 } else if (is_in_rect_area(x, y, &rect_east)) {
532 } else {
534 }
535 } else if (is_in_rect_area(x, y, &rect_south)) {
537 if (is_in_rect_area(x, y, &rect_west)) {
539 } else if (is_in_rect_area(x, y, &rect_east)) {
541 } else {
543 }
544 } else if (is_in_rect_area(x, y, &rect_east)) {
547 } else if (is_in_rect_area(x, y, &rect_west)) {
550 } else {
552 }
553
554 return is_map_scrolling;
555}
556
557/* ============================ Public ========================== */
558
559/**********************************************************************/
563{
565
566 event.type = user_event_type;
567 event.user.code = EXIT_FROM_EVENT_LOOP;
568 event.user.data1 = NULL;
569 event.user.data2 = NULL;
570
572}
573
574/**********************************************************************/
579{
580 if (event->type == SDL_EVENT_MOUSE_MOTION) {
581 static int x = 0, y = 0;
582
583 if (((MOVE_STEP_X > 0) && (abs(event->motion.x - x) >= MOVE_STEP_X))
584 || ((MOVE_STEP_Y > 0) && (abs(event->motion.y - y) >= MOVE_STEP_Y)) ) {
585 x = event->motion.x;
586 y = event->motion.y;
587 return TRUE; /* Catch it */
588 } else {
589 return FALSE; /* Drop it, we've handled it */
590 }
591 }
592
593 return TRUE;
594}
595
596/**********************************************************************/
600 void (*loop_action)(void *data),
601 widget_id (*key_down_handler)(SDL_KeyboardEvent *key, void *data),
602 widget_id (*key_up_handler)(SDL_KeyboardEvent *key, void *data),
603 widget_id (*textinput_handler)(const char *text, void *data),
605 void *data),
607 void *data),
609 void *data),
611 void *data),
613 void *data),
615 void *data))
616{
617 Uint16 ID;
618 static fc_timeval tv;
619 static fd_set civfdset;
622 static int result;
623
624 ID = ID_ERROR;
626 while (ID == ID_ERROR) {
627 /* ========================================= */
628 /* Net check with 10ms delay event loop */
629 if (net_socket >= 0) {
631
632 if (net_socket >= 0) {
634 }
635
636 tv.tv_sec = 0;
637 tv.tv_usec = 10000; /* 10ms*/
638
639 result = fc_select(net_socket + 1, &civfdset, NULL, NULL, &tv);
640 if (result < 0) {
641 if (errno != EINTR) {
642 break;
643 } else {
644 continue;
645 }
646 } else {
647
648#ifdef __EMSCRIPTEN__
649 if (net_socket >= 0) {
651 }
652#else /* __EMSCRIPTEN__ */
653 if (result > 0) {
654 if ((net_socket >= 0) && FD_ISSET(net_socket, &civfdset)) {
656 }
657 }
658#endif /* __EMSCRIPTEN__ */
659
660 }
661 } else { /* If connection is not establish */
662 SDL_Delay(10);
663 }
664 /* ========================================= */
665
667
670 }
671
673 if (autoconnect) {
676 } else {
678 }
679
681 }
682
683 if (is_map_scrolling) {
687 }
688 } else {
690 }
691
692 if (widget_info_counter > 0) {
695 }
696
697 /* ========================================= */
698
699 if (loop_action) {
700 loop_action(data);
701 }
702
703 /* ========================================= */
704
705 while (SDL_PollEvent(&main_data.event) == 1) {
706
707 if (main_data.event.type == user_event_type) {
708 switch (main_data.event.user.code) {
709 case NET:
711 break;
712 case ANIM:
716 break;
719 break;
720 case TRY_AUTO_CONNECT:
721 if (try_to_autoconnect()) {
724 }
725 break;
726 case FLUSH:
728 break;
729 case MAP_SCROLL:
731 break;
733 return MAX_ID;
734 break;
735 default:
736 break;
737 }
738
739 } else {
740
741 switch (main_data.event.type) {
742
743 case SDL_EVENT_QUIT:
744 return MAX_ID;
745 break;
746
747 case SDL_EVENT_KEY_UP:
748 switch (main_data.event.key.key) {
749 /* Find if Shifts are released */
750 case SDLK_RSHIFT:
751 RSHIFT = FALSE;
752 break;
753 case SDLK_LSHIFT:
754 LSHIFT = FALSE;
755 break;
756 case SDLK_LCTRL:
757 LCTRL = FALSE;
758 break;
759 case SDLK_RCTRL:
760 RCTRL = FALSE;
761 break;
762 case SDLK_LALT:
763 LALT = FALSE;
764 break;
765 default:
766 if (key_up_handler) {
767 ID = key_up_handler(&(main_data.event.key), data);
768 }
769 break;
770 }
771 break;
772
774 switch (main_data.event.key.key) {
775#if 0
776 case SDLK_PRINT:
777 fc_snprintf(schot, sizeof(schot), "fc_%05d.bmp", schot_nr++);
778 log_normal(_("Making screenshot %s"), schot);
780 break;
781#endif /* 0 */
782
783 case SDLK_RSHIFT:
784 /* Right Shift is Pressed */
785 RSHIFT = TRUE;
786 break;
787
788 case SDLK_LSHIFT:
789 /* Left Shift is Pressed */
790 LSHIFT = TRUE;
791 break;
792
793 case SDLK_LCTRL:
794 /* Left CTRL is Pressed */
795 LCTRL = TRUE;
796 break;
797
798 case SDLK_RCTRL:
799 /* Right CTRL is Pressed */
800 RCTRL = TRUE;
801 break;
802
803 case SDLK_LALT:
804 /* Left ALT is Pressed */
805 LALT = TRUE;
806 break;
807
808 default:
809 if (key_down_handler) {
810 ID = key_down_handler(&(main_data.event.key), data);
811 }
812 break;
813 }
814 break;
815
817 if (textinput_handler) {
818 ID = textinput_handler(main_data.event.text.text, data);
819 }
820 break;
821
824 ID = finger_down_handler(&main_data.event.tfinger, data);
825 }
826 break;
827
829 if (finger_up_handler) {
830 ID = finger_up_handler(&main_data.event.tfinger, data);
831 }
832 break;
833
836 ID = finger_motion_handler(&main_data.event.tfinger, data);
837 }
838 break;
839
843 }
844 break;
845
848 ID = mouse_button_up_handler(&main_data.event.button, data);
849 }
850 break;
851
854 ID = mouse_motion_handler(&main_data.event.motion, data);
855 }
856 break;
857 }
858 }
859 }
860
861 if (ID == ID_ERROR) {
863 struct callback *cb = callback_list_get(callbacks, 0);
864
866 (cb->callback)(cb->data);
867 free(cb);
868 }
869 }
870
872
873#ifdef __EMSCRIPTEN__
874 emscripten_sleep(100);
875#endif
876 }
877
878 return ID;
879}
880
881/* ============ Freeciv native game function =========== */
882
883/**********************************************************************/
900
901/**********************************************************************/
905{
906 struct widget *widget;
907
908 if (C_S_RUNNING == client_state()) {
909 /* Move units window to bottom-right corner. */
911 /* Move minimap window to bottom-left corner. */
913
914 /* Move cooling/warming icons to bottom-right corner. */
917 - (widget->size.w * 2)), widget->size.y);
918
921 - widget->size.w), widget->size.y);
922
926 center_on_something(); /* With redrawing full map. */
928 } else {
930 dirty_all();
931 }
932
933 flush_all();
934}
935
936/**********************************************************************/
943
944/**********************************************************************/
948{
949 const SDL_DisplayMode *mode;
950
953 } else {
955 }
956
958
959 if (!create_surfaces(mode->w, mode->h)) {
960 /* Try to revert */
963 } else {
965 }
966 }
967
969}
970
971/**********************************************************************/
976{
977 struct option *poption;
978
979#define option_var_set_callback(var, callback) \
980 if ((poption = optset_option_by_name(client_optset, \
981 GUI_SDL_OPTION_STR(var)))) { \
982 option_set_changed_callback(poption, callback); \
983 } else { \
984 log_error("Didn't find option %s!", GUI_SDL_OPTION_STR(var)); \
985 }
986
989#undef option_var_set_callback
990}
991
992/**********************************************************************/
997{
998 int i;
999
1000 /* Clear double call */
1001 for (i = 0; i <= event_type_max(); i++) {
1002 if (messages_where[i] & MW_MESSAGES) {
1004 }
1005 }
1006}
1007
1008/**********************************************************************/
1013int main(int argc, char **argv)
1014{
1015 return client_main(argc, argv, FALSE);
1016}
1017
1018/**********************************************************************/
1022{
1023 log_normal(_("Migrating options from sdl2 to sdl3 client"));
1024
1025#define MIGRATE_OPTION(opt) gui_options.gui_sdl3_##opt = gui_options.gui_sdl2_##opt;
1026#define MIGRATE_STR_OPTION(opt) \
1027 strncpy(gui_options.gui_sdl3_##opt, gui_options.gui_sdl2_##opt, \
1028 sizeof(gui_options.gui_sdl3_##opt));
1029
1030 /* Default theme name is never migrated */
1032 MIGRATE_OPTION(screen);
1039
1040#undef MIGRATE_OPTION
1041
1043}
1044
1045/**********************************************************************/
1049int ui_main(int argc, char *argv[])
1050{
1051 Uint32 flags = 0;
1052
1053 if (parse_options(argc, argv)) {
1056 }
1058 if (font_size_parameter > 10) {
1059 GUI_SDL_OPTION(screen) = VIDEO_MODE(640 * font_size_parameter / 10,
1060 480 * font_size_parameter / 10);
1061 }
1062
1064 }
1065
1067 flags |= SDL_WINDOW_FULLSCREEN;
1068 } else {
1069 flags &= ~SDL_WINDOW_FULLSCREEN;
1070 }
1071
1072 log_normal(_("Using Video Output: %s"), SDL_GetCurrentVideoDriver());
1073 if (!set_video_mode(GUI_SDL_OPTION(screen.width),
1074 GUI_SDL_OPTION(screen.height),
1075 flags)) {
1076 return EXIT_FAILURE;
1077 }
1078
1080
1083 __net_user_event.user.code = NET;
1084 __net_user_event.user.data1 = NULL;
1085 __net_user_event.user.data2 = NULL;
1087
1090 __anim_user_event.user.code = EVENT_ERROR;
1091 __anim_user_event.user.data1 = NULL;
1092 __anim_user_event.user.data2 = NULL;
1094
1098 __info_user_event.user.data1 = NULL;
1099 __info_user_event.user.data2 = NULL;
1101
1104 __flush_user_event.user.code = FLUSH;
1105 __flush_user_event.user.data1 = NULL;
1106 __flush_user_event.user.data2 = NULL;
1108
1112 __map_scroll_user_event.user.data1 = NULL;
1113 __map_scroll_user_event.user.data2 = NULL;
1115
1117
1123
1127
1128 load_cursors();
1129
1131
1134
1136
1138
1139 /* This needs correct main_data.screen size */
1141
1143
1144 /* Main game loop */
1150
1151#if defined UNDER_CE && defined GUI_SDL3_SMALL_SCREEN
1152 /* Change back to window mode to restore the title bar */
1154#endif
1155
1157
1159
1161
1164
1166 callbacks = NULL;
1167
1169
1172
1174
1175 del_main_list();
1176
1180
1181 quit_sdl();
1182 }
1183
1184 return EXIT_SUCCESS;
1185}
1186
1187/**********************************************************************/
1190void ui_exit(void)
1191{
1192}
1193
1194/**********************************************************************/
1197enum gui_type get_gui_type(void)
1198{
1199 return GUI_SDL3;
1200}
1201
1202/**********************************************************************/
1206void sound_bell(void)
1207{
1208 log_debug("sound_bell : PORT ME");
1209}
1210
1211/**********************************************************************/
1215{
1216 anim_user_event->user.code = ANIM;
1218}
1219
1220/**********************************************************************/
1227
1228/**********************************************************************/
1232void add_net_input(int sock)
1233{
1234 log_debug("Connection UP (%d)", sock);
1235 net_socket = sock;
1238}
1239
1240/**********************************************************************/
1244{
1245 log_debug("Connection DOWN... ");
1246 net_socket = (-1);
1250}
1251
1252/**********************************************************************/
1257void add_idle_callback(void (callback)(void *), void *data)
1258{
1259 if (callbacks != NULL) {
1260 struct callback *cb = fc_malloc(sizeof(*cb));
1261
1262 cb->callback = callback;
1263 cb->data = data;
1264
1266 }
1267}
1268
1269/**********************************************************************/
1273{}
1274
1275/**********************************************************************/
1279{}
1280
1281/**********************************************************************/
1284void editgui_popup_properties(const struct tile_list *tiles, int objtype)
1285{}
1286
1287/**********************************************************************/
1291{}
1292
1293/**********************************************************************/
1296void editgui_notify_object_changed(int objtype, int object_id, bool removal)
1297{}
1298
1299/**********************************************************************/
1303{}
1304
1305/**********************************************************************/
1308void gui_update_font(const char *font_name, const char *font_value)
1309{
1310#define CHECK_FONT(client_font, action) \
1311 do { \
1312 if (strcmp(#client_font, font_name) == 0) { \
1313 char *end; \
1314 long size = strtol(font_value, &end, 10); \
1315 if (end && *end == '\0' && size > 0) { \
1316 *client_font_sizes[client_font] = size; \
1317 action; \
1318 } \
1319 } \
1320 } while (FALSE)
1321
1324 /* FONT_REQTREE_TEXT not used yet */
1325
1326#undef CHECK_FONT
1327}
1328
1329/**********************************************************************/
1338
1339/**********************************************************************/
1347
1348/**********************************************************************/
1352{
1353 /* PORTME */
1354}
1355
1356/**********************************************************************/
1359bool flush_event(void)
1360{
1362}
1363
1364/**********************************************************************/
#define city_owner(_pcity_)
Definition city.h:560
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:76
@ 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:3324
struct unit * head_of_units_in_focus(void)
Definition control.c:410
void control_mouse_cursor(struct tile *ptile)
Definition control.c:1227
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:73
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 int const struct action *paction struct unit struct city * pcity
Definition dialogs_g.h:77
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:290
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:64
int ui_main(int argc, char **argv)
Definition gui_main.c:1854
const char * client_string
Definition gui_main.c:106
static void print_usage(void)
Definition gui_main.c:264
#define option_var_set_callback(var, callback)
#define MIGRATE_STR_OPTION(opt)
void ui_exit(void)
Definition gui_main.c:2035
enum gui_type get_gui_type(void)
Definition gui_main.c:2046
int main(int argc, char **argv)
Definition gui_main.c:1732
void ui_init(void)
Definition gui_main.c:1722
void add_idle_callback(void(callback)(void *), void *data)
Definition gui_main.c:2374
void options_extra_init(void)
Definition gui_main.c:2448
void setup_gui_properties(void)
Definition gui_main.c:2618
void insert_client_build_info(char *outbuf, size_t outlen)
Definition gui_main.c:2508
void remove_net_input(void)
Definition gui_main.c:2280
void sound_bell(void)
Definition gui_main.c:2054
const char *const gui_character_encoding
Definition gui_main.c:161
void add_net_input(int sock)
Definition gui_main.c:2262
static bool parse_options(int argc, char **argv)
Definition gui_main.c:285
#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:359
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:234
static int city_names_font_size
Definition gui_main.c:114
static SDL_Event __anim_user_event
Definition gui_main.c:134
static SDL_Event * net_user_event
Definition gui_main.c:139
static widget_id main_finger_up_handler(SDL_TouchFingerEvent *touch_event, void *data)
Definition gui_main.c:356
static void resize_window_callback(struct option *poption)
Definition gui_main.c:946
static void fullscreen_callback(struct option *poption)
Definition gui_main.c:954
void editgui_popup_properties(const struct tile_list *tiles, int objtype)
Definition gui_main.c:1284
void editgui_notify_object_created(int tag, int id)
Definition gui_main.c:1302
#define CHECK_FONT(client_font, action)
static struct mouse_button_behavior button_behavior
Definition gui_main.c:131
bool is_unit_move_blocked
Definition gui_main.c:108
static SDL_Event __info_user_event
Definition gui_main.c:135
bool LSHIFT
Definition gui_main.c:109
static widget_id main_mouse_motion_handler(SDL_MouseMotionEvent *motion_event, void *data)
Definition gui_main.c:443
static SDL_Event __flush_user_event
Definition gui_main.c:136
int FilterMouseMotionEvents(void *data, SDL_Event *event)
Definition gui_main.c:585
static SDL_Event * info_user_event
Definition gui_main.c:141
static SDL_Event __net_user_event
Definition gui_main.c:133
void enable_focus_animation(void)
Definition gui_main.c:1214
static widget_id main_mouse_button_up_handler(SDL_MouseButtonEvent *button_event, void *data)
Definition gui_main.c:417
void editgui_popdown_all(void)
Definition gui_main.c:1290
bool flush_event(void)
Definition gui_main.c:1359
#define MAP_SCROLL_TIMER_INTERVAL
Definition gui_main.c:92
static void real_resize_window_callback(void *data)
Definition gui_main.c:911
bool draw_goto_patrol_lines
Definition mapctrl.c:104
#define UNITS_TIMER_INTERVAL
Definition gui_main.c:91
static void update_button_hold_state(void)
Definition gui_main.c:494
static widget_id main_finger_down_handler(SDL_TouchFingerEvent *touch_event, void *data)
Definition gui_main.c:326
static bool is_map_scrolling
Definition gui_main.c:127
static SDL_Event * map_scroll_user_event
Definition gui_main.c:143
bool RSHIFT
Definition gui_main.c:110
int MOVE_STEP_Y
Definition gui_main.c:106
#define SCROLL_MAP_AREA
Definition gui_main.c:437
Uint32 widget_info_counter
Definition gui_main.c:104
static widget_id main_key_up_handler(SDL_Keysym key, void *data)
Definition gui_main.c:315
static SDL_Event * anim_user_event
Definition gui_main.c:140
static bool autoconnect
Definition gui_main.c:126
static bool check_scroll_area(int x, int y)
Definition gui_main.c:522
static int net_socket
Definition gui_main.c:125
void update_font_from_theme(int theme_font_size)
Definition gui_main.c:1342
static int city_productions_font_size
Definition gui_main.c:115
bool LALT
Definition gui_main.c:113
bool LCTRL
Definition gui_main.c:111
unsigned default_font_size(struct theme *act_theme)
Definition gui_main.c:1332
static widget_id main_mouse_button_down_handler(SDL_MouseButtonEvent *button_event, void *data)
Definition gui_main.c:381
static void clear_double_messages_call(void)
Definition gui_main.c:1003
void force_exit_from_event_loop(void)
Definition gui_main.c:569
void disable_focus_animation(void)
Definition gui_main.c:1223
static enum direction8 scroll_dir
Definition gui_main.c:128
static unsigned font_size_parameter
Definition gui_main.c:122
int * client_font_sizes[FONT_COUNT]
Definition gui_main.c:116
void editgui_refresh(void)
Definition gui_main.c:1278
int user_event_type
Definition gui_main.c:149
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:606
static SDL_Event __map_scroll_user_event
Definition gui_main.c:137
static SDL_Event * flush_user_event
Definition gui_main.c:142
struct callback_list * callbacks
Definition gui_main.c:171
USER_EVENT_ID
Definition gui_main.c:151
@ NET
Definition gui_main.c:153
@ ANIM
Definition gui_main.c:154
@ TRY_AUTO_CONNECT
Definition gui_main.c:155
@ MAP_SCROLL
Definition gui_main.c:158
@ FLUSH
Definition gui_main.c:157
@ EVENT_ERROR
Definition gui_main.c:152
@ EXIT_FROM_EVENT_LOOP
Definition gui_main.c:159
@ SHOW_WIDGET_INFO_LABEL
Definition gui_main.c:156
void editgui_tileset_changed(void)
Definition gui_main.c:1272
int MOVE_STEP_X
Definition gui_main.c:105
bool RCTRL
Definition gui_main.c:112
#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_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 * 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
struct widget * get_widget_pointer_from_main_list(widget_id id)
Definition widget.c:578
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
static void migrate_options_from_sdl2(void)
Definition gui_main.c:1021
Uint32 sdl3_client_flags
Definition gui_main.c:98
const char * font_name
Definition gui_main_g.h:43
gui_update_font
Definition gui_main_g.h:43
struct client_properties gui_properties
#define log_debug(message,...)
Definition log.h:116
#define log_normal(message,...)
Definition log.h:108
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:5108
struct client_options gui_options
Definition options.c:71
#define MW_MESSAGES
Definition options.h:589
#define VIDEO_MODE(ARG_width, ARG_height)
Definition options.h:51
bool str_to_uint(const char *str, unsigned int *pint)
Definition shared.c:547
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:2353
void(* callback)(void *data)
Definition gui_main.c:2352
Definition city.h:317
struct connection conn
Definition client_main.h:96
bool gui_sdl3_migrated_from_sdl2
Definition options.h:137
struct client_properties::@203 views
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:139
SDL_Keycode key
Definition widget.h:153
struct widget * widget
Definition widget.h:132
union widget::@196 data
SDL_Rect size
Definition widget.h:145
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:960
#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:89
void tileset_load_tiles(struct tileset *t)
Definition tilespec.c:3832
void tileset_use_preferred_theme(const struct tileset *t)
Definition tilespec.c:7334
void tileset_init(struct tileset *t)
Definition tilespec.c:7391
@ CURSOR_DEFAULT
Definition tilespec.h:301
#define unit_tile(_pu)
Definition unit.h:406
void update_queue_add(uq_callback_t callback, void *data)
float mouse_zoom
Definition zoom.c:28