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/* 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 "tilespec.h"
61#include "update_queue.h"
62#include "zoom.h"
63
64/* gui-sdl3 */
65#include "chatline.h"
66#include "citydlg.h"
67#include "cityrep.h"
68#include "diplodlg.h"
69#include "graphics.h"
70#include "gui_id.h"
71#include "gui_mouse.h"
72#include "gui_tilespec.h"
73#include "inteldlg.h"
74#include "mapctrl.h"
75#include "mapview.h"
76#include "menu.h"
77#include "messagewin.h"
78#include "optiondlg.h"
79#include "repodlgs.h"
80#include "themespec.h"
81#include "spaceshipdlg.h"
82#include "widget.h"
83
84#include "gui_main.h"
85
86#define UNITS_TIMER_INTERVAL 128 /* milliseconds */
87#define MAP_SCROLL_TIMER_INTERVAL 500
88
89const char *client_string = "gui-sdl3";
90
91/* The real GUI character encoding is UTF-16 which is not supported by
92 * fciconv code at this time. Conversion between UTF-8 and UTF-16 is done
93 * in gui_iconv.c */
94const char * const gui_character_encoding = "UTF-8";
96
98
102extern bool draw_goto_patrol_lines;
106bool LCTRL;
107bool RCTRL;
108bool LALT;
109static int city_names_font_size = 10;
112 &city_names_font_size, /* FONT_CITY_NAME */
113 &city_productions_font_size, /* FONT_CITY_PROD */
114 &city_productions_font_size /* FONT_REQTREE_TEXT; not used yet */
115};
116
117static unsigned font_size_parameter = 0;
118
119/* ================================ Private ============================ */
120static int net_socket = -1;
121static bool autoconnect = FALSE;
124
127
133
139
140static void print_usage(void);
141static bool parse_options(int argc, char **argv);
142static bool check_scroll_area(int x, int y);
143
145
156
157struct callback {
158 void (*callback)(void *data);
159 void *data;
160};
161
162#define SPECLIST_TAG callback
163#define SPECLIST_TYPE struct callback
164#include "speclist.h"
165
166struct callback_list *callbacks = NULL;
167
168/* =========================================================== */
169
170/**********************************************************************/
174static void print_usage(void)
175{
176 /* Add client-specific usage information here */
178 _(" -f, --fullscreen\tStart Client in Fullscreen mode\n"));
180 _(" -F, --Font SIZE\tUse SIZE as the base font size\n"));
181 fc_fprintf(stderr, _(" -t, --theme THEME\tUse GUI theme THEME\n"));
182
183 /* TRANS: No full stop after the URL, could cause confusion. */
184 fc_fprintf(stderr, _("Report bugs at %s\n"), BUG_URL);
185}
186
187/**********************************************************************/
190static bool parse_options(int argc, char **argv)
191{
192 int i = 1;
193 char *option = NULL;
194
195 while (i < argc) {
196 if (is_option("--help", argv[i])) {
197 print_usage();
198
199 return FALSE;
200 } else if (is_option("--fullscreen", argv[i])) {
202 } else if ((option = get_option_malloc("--Font", argv, &i, argc, FALSE))) {
204 fc_fprintf(stderr, _("Invalid font size %s"), option);
206 }
207 free(option);
208 } else if ((option = get_option_malloc("--theme", argv, &i, argc, FALSE))) {
210 free(option);
211 } else {
212 fc_fprintf(stderr, _("Unrecognized option: \"%s\"\n"), argv[i]);
213
215 }
216
217 i++;
218 }
219
220 return TRUE;
221}
222
223/**********************************************************************/
227{
228 static struct widget *pwidget;
229
230 if ((pwidget = find_next_widget_for_key(NULL, key)) != NULL) {
231 return widget_pressed_action(pwidget);
232 } else {
233 if (key->key == SDLK_TAB) {
234 /* Input */
236 } else {
238 && C_S_RUNNING == client_state()) {
239 switch (key->key) {
240 case SDLK_RETURN:
241 case SDLK_KP_ENTER:
242 if (LSHIFT || RSHIFT) {
244 key_end_turn();
245 } else {
246 struct unit *punit;
247 struct city *pcity;
248
250 && (pcity = tile_city(unit_tile(punit))) != NULL
251 && city_owner(pcity) == client.conn.playing) {
252 popup_city_dialog(pcity);
253 }
254 }
255 return ID_ERROR;
256
257 case SDLK_F2:
259 return ID_ERROR;
260
261 case SDLK_F4:
263 return ID_ERROR;
264
265 case SDLK_F7:
267 return ID_ERROR;
268
269 case SDLK_F8:
271 return ID_ERROR;
272
273 case SDLK_F9:
274 if (meswin_dialog_is_open()) {
276 } else {
278 }
279 flush_dirty();
280 return ID_ERROR;
281
282 case SDLK_F11:
284 return ID_ERROR;
285
286 case SDLK_F12:
288 return ID_ERROR;
289
290 case SDLK_ASTERISK:
292 return ID_ERROR;
293
294 default:
295 return ID_ERROR;
296 }
297 }
298 }
299 }
300
301 return ID_ERROR;
302}
303
304/**********************************************************************/
308{
309 if (selected_widget) {
311 }
312
313 return ID_ERROR;
314}
315
316/**********************************************************************/
320 void *data)
321{
322 struct widget *pwidget;
323 /* Touch event coordinates are normalized (0...1). */
324 int x = touch_event->x * main_window_width();
325 int y = touch_event->y * main_window_height();
326
327 if ((pwidget = find_next_widget_at_pos(NULL, x, y)) != NULL) {
328 if (get_wstate(pwidget) != FC_WS_DISABLED) {
329 return widget_pressed_action(pwidget);
330 }
331 } else {
332 /* No visible widget at this position; map pressed. */
334 /* Start counting. */
340 }
341 }
342 return ID_ERROR;
343}
344
345/**********************************************************************/
349 void *data)
350{
351 /* Touch event coordinates are normalized (0...1). */
352 int x = touch_event->x * main_window_width();
353 int y = touch_event->y * main_window_height();
354 /* Screen wasn't pressed over a widget. */
359 }
360
363
365
366 return ID_ERROR;
367}
368
369/**********************************************************************/
373 void *data)
374{
375 struct widget *pwidget;
376
377 if ((pwidget = find_next_widget_at_pos(NULL,
378 button_event->x,
379 button_event->y)) != NULL) {
380 if (get_wstate(pwidget) != FC_WS_DISABLED) {
381 return widget_pressed_action(pwidget);
382 }
383 } else {
384 /* no visible widget at this position -> map click */
385#ifdef UNDER_CE
387#endif
389 /* start counting */
395 mouse_zoom);
396 }
397#ifdef UNDER_CE
398 }
399#endif
400 }
401
402 return ID_ERROR;
403}
404
405/**********************************************************************/
424
425#ifdef UNDER_CE
426 #define SCROLL_MAP_AREA 8
427#else
428 #define SCROLL_MAP_AREA 1
429#endif
430
431/**********************************************************************/
435 void *data)
436{
437 static struct widget *pwidget;
438 struct tile *ptile;
439
440 /* stop evaluating button hold time when moving to another tile in medium
441 * hold state or above */
444 mouse_zoom);
447 }
448 }
449
452 }
453
454#ifndef UNDER_CE
457 }
458#endif /* UNDER_CE */
459
460 if ((pwidget = find_next_widget_at_pos(NULL,
461 motion_event->x,
462 motion_event->y)) != NULL) {
464 if (get_wstate(pwidget) != FC_WS_DISABLED) {
465 widget_selected_action(pwidget);
466 }
467 } else {
468 if (selected_widget) {
470 } else {
472 mouse_zoom));
473 }
474 }
475
477
478 return ID_ERROR;
479}
480
481/**********************************************************************/
509
510/**********************************************************************/
513static bool check_scroll_area(int x, int y)
514{
515 SDL_Rect rect_north = {.x = 0, .y = 0,
516 .w = main_data.map->w, .h = SCROLL_MAP_AREA};
517 SDL_Rect rect_east = {.x = main_data.map->w - SCROLL_MAP_AREA, .y = 0,
518 .w = SCROLL_MAP_AREA, .h = main_data.map->h};
519 SDL_Rect rect_south = {.x = 0, .y = main_data.map->h - SCROLL_MAP_AREA,
520 .w = main_data.map->w, .h = SCROLL_MAP_AREA};
521 SDL_Rect rect_west = {.x = 0, .y = 0,
522 .w = SCROLL_MAP_AREA, .h = main_data.map->h};
523
524 if (is_in_rect_area(x, y, &rect_north)) {
526 if (is_in_rect_area(x, y, &rect_west)) {
528 } else if (is_in_rect_area(x, y, &rect_east)) {
530 } else {
532 }
533 } else if (is_in_rect_area(x, y, &rect_south)) {
535 if (is_in_rect_area(x, y, &rect_west)) {
537 } else if (is_in_rect_area(x, y, &rect_east)) {
539 } else {
541 }
542 } else if (is_in_rect_area(x, y, &rect_east)) {
545 } else if (is_in_rect_area(x, y, &rect_west)) {
548 } else {
550 }
551
552 return is_map_scrolling;
553}
554
555/* ============================ Public ========================== */
556
557/**********************************************************************/
561{
563
564 event.type = user_event_type;
565 event.user.code = EXIT_FROM_EVENT_LOOP;
566 event.user.data1 = NULL;
567 event.user.data2 = NULL;
568
570}
571
572/**********************************************************************/
577{
578 if (event->type == SDL_EVENT_MOUSE_MOTION) {
579 static int x = 0, y = 0;
580
581 if (((MOVE_STEP_X > 0) && (abs(event->motion.x - x) >= MOVE_STEP_X))
582 || ((MOVE_STEP_Y > 0) && (abs(event->motion.y - y) >= MOVE_STEP_Y)) ) {
583 x = event->motion.x;
584 y = event->motion.y;
585 return TRUE; /* Catch it */
586 } else {
587 return FALSE; /* Drop it, we've handled it */
588 }
589 }
590
591 return TRUE;
592}
593
594/**********************************************************************/
598 void (*loop_action)(void *data),
599 Uint16 (*key_down_handler)(SDL_KeyboardEvent *key, void *data),
600 Uint16 (*key_up_handler)(SDL_KeyboardEvent *key, void *data),
601 Uint16 (*textinput_handler)(const char *text, void *data),
605 void *data),
607 void *data),
609 void *data),
611 void *data))
612{
613 Uint16 ID;
614 static fc_timeval tv;
615 static fd_set civfdset;
618 static int result;
619
620 ID = ID_ERROR;
622 while (ID == ID_ERROR) {
623 /* ========================================= */
624 /* Net check with 10ms delay event loop */
625 if (net_socket >= 0) {
627
628 if (net_socket >= 0) {
630 }
631
632 tv.tv_sec = 0;
633 tv.tv_usec = 10000; /* 10ms*/
634
635 result = fc_select(net_socket + 1, &civfdset, NULL, NULL, &tv);
636 if (result < 0) {
637 if (errno != EINTR) {
638 break;
639 } else {
640 continue;
641 }
642 } else {
643 if (result > 0) {
644 if ((net_socket >= 0) && FD_ISSET(net_socket, &civfdset)) {
646 }
647 }
648 }
649 } else { /* If connection is not establish */
650 SDL_Delay(10);
651 }
652 /* ========================================= */
653
655
658 }
659
661 if (autoconnect) {
664 } else {
666 }
667
669 }
670
671 if (is_map_scrolling) {
675 }
676 } else {
678 }
679
680 if (widget_info_counter > 0) {
683 }
684
685 /* ========================================= */
686
687 if (loop_action) {
688 loop_action(data);
689 }
690
691 /* ========================================= */
692
693 while (SDL_PollEvent(&main_data.event) == 1) {
694
695 if (main_data.event.type == user_event_type) {
696 switch (main_data.event.user.code) {
697 case NET:
699 break;
700 case ANIM:
704 break;
707 break;
708 case TRY_AUTO_CONNECT:
709 if (try_to_autoconnect()) {
712 }
713 break;
714 case FLUSH:
716 break;
717 case MAP_SCROLL:
719 break;
721 return MAX_ID;
722 break;
723 default:
724 break;
725 }
726
727 } else {
728
729 switch (main_data.event.type) {
730
731 case SDL_EVENT_QUIT:
732 return MAX_ID;
733 break;
734
735 case SDL_EVENT_KEY_UP:
736 switch (main_data.event.key.key) {
737 /* Find if Shifts are released */
738 case SDLK_RSHIFT:
739 RSHIFT = FALSE;
740 break;
741 case SDLK_LSHIFT:
742 LSHIFT = FALSE;
743 break;
744 case SDLK_LCTRL:
745 LCTRL = FALSE;
746 break;
747 case SDLK_RCTRL:
748 RCTRL = FALSE;
749 break;
750 case SDLK_LALT:
751 LALT = FALSE;
752 break;
753 default:
754 if (key_up_handler) {
755 ID = key_up_handler(&(main_data.event.key), data);
756 }
757 break;
758 }
759 break;
760
762 switch (main_data.event.key.key) {
763#if 0
764 case SDLK_PRINT:
765 fc_snprintf(schot, sizeof(schot), "fc_%05d.bmp", schot_nr++);
766 log_normal(_("Making screenshot %s"), schot);
768 break;
769#endif /* 0 */
770
771 case SDLK_RSHIFT:
772 /* Right Shift is Pressed */
773 RSHIFT = TRUE;
774 break;
775
776 case SDLK_LSHIFT:
777 /* Left Shift is Pressed */
778 LSHIFT = TRUE;
779 break;
780
781 case SDLK_LCTRL:
782 /* Left CTRL is Pressed */
783 LCTRL = TRUE;
784 break;
785
786 case SDLK_RCTRL:
787 /* Right CTRL is Pressed */
788 RCTRL = TRUE;
789 break;
790
791 case SDLK_LALT:
792 /* Left ALT is Pressed */
793 LALT = TRUE;
794 break;
795
796 default:
797 if (key_down_handler) {
798 ID = key_down_handler(&(main_data.event.key), data);
799 }
800 break;
801 }
802 break;
803
805 if (textinput_handler) {
806 ID = textinput_handler(main_data.event.text.text, data);
807 }
808 break;
809
812 ID = finger_down_handler(&main_data.event.tfinger, data);
813 }
814 break;
815
817 if (finger_up_handler) {
818 ID = finger_up_handler(&main_data.event.tfinger, data);
819 }
820 break;
821
824 ID = finger_motion_handler(&main_data.event.tfinger, data);
825 }
826 break;
827
831 }
832 break;
833
836 ID = mouse_button_up_handler(&main_data.event.button, data);
837 }
838 break;
839
842 ID = mouse_motion_handler(&main_data.event.motion, data);
843 }
844 break;
845 }
846 }
847 }
848
849 if (ID == ID_ERROR) {
851 struct callback *cb = callback_list_get(callbacks, 0);
852
854 (cb->callback)(cb->data);
855 free(cb);
856 }
857 }
858
860
861#ifdef __EMSCRIPTEN__
862 emscripten_sleep(100);
863#endif
864 }
865
866 return ID;
867}
868
869/* ============ Freeciv native game function =========== */
870
871/**********************************************************************/
888
889/**********************************************************************/
893{
894 struct widget *widget;
895
896 if (C_S_RUNNING == client_state()) {
897 /* Move units window to botton-right corner. */
899 /* Move minimap window to botton-left corner. */
901
902 /* Move cooling/warming icons to botton-right corner. */
905 - (widget->size.w * 2)), widget->size.y);
906
909 - widget->size.w), widget->size.y);
910
914 center_on_something(); /* With redrawing full map. */
916 } else {
918 dirty_all();
919 }
920
921 flush_all();
922}
923
924/**********************************************************************/
931
932/**********************************************************************/
936{
937 const SDL_DisplayMode *mode;
938
941 } else {
943 }
944
946
947 if (!create_surfaces(mode->w, mode->h)) {
948 /* Try to revert */
951 } else {
953 }
954 }
955
957}
958
959/**********************************************************************/
964{
965 struct option *poption;
966
967#define option_var_set_callback(var, callback) \
968 if ((poption = optset_option_by_name(client_optset, \
969 GUI_SDL_OPTION_STR(var)))) { \
970 option_set_changed_callback(poption, callback); \
971 } else { \
972 log_error("Didn't find option %s!", GUI_SDL_OPTION_STR(var)); \
973 }
974
977#undef option_var_set_callback
978}
979
980/**********************************************************************/
985{
986 int i;
987
988 /* Clear double call */
989 for (i = 0; i <= event_type_max(); i++) {
992 }
993 }
994}
995
996/**********************************************************************/
1001int main(int argc, char **argv)
1002{
1003 return client_main(argc, argv, FALSE);
1004}
1005
1006/**********************************************************************/
1010{
1011 log_normal(_("Migrating options from sdl2 to sdl3 client"));
1012
1013#define MIGRATE_OPTION(opt) gui_options.gui_sdl3_##opt = gui_options.gui_sdl2_##opt;
1014#define MIGRATE_STR_OPTION(opt) \
1015 strncpy(gui_options.gui_sdl3_##opt, gui_options.gui_sdl2_##opt, \
1016 sizeof(gui_options.gui_sdl3_##opt));
1017
1018 /* Default theme name is never migrated */
1020 MIGRATE_OPTION(screen);
1027
1028#undef MIGRATE_OPTION
1029
1031}
1032
1033/**********************************************************************/
1037int ui_main(int argc, char *argv[])
1038{
1039 Uint32 flags = 0;
1040
1041 if (parse_options(argc, argv)) {
1044 }
1046 if (font_size_parameter > 10) {
1047 GUI_SDL_OPTION(screen) = VIDEO_MODE(640 * font_size_parameter / 10,
1048 480 * font_size_parameter / 10);
1049 }
1050
1052 }
1053
1055 flags |= SDL_WINDOW_FULLSCREEN;
1056 } else {
1057 flags &= ~SDL_WINDOW_FULLSCREEN;
1058 }
1059
1060 log_normal(_("Using Video Output: %s"), SDL_GetCurrentVideoDriver());
1061 if (!set_video_mode(GUI_SDL_OPTION(screen.width),
1062 GUI_SDL_OPTION(screen.height),
1063 flags)) {
1064 return EXIT_FAILURE;
1065 }
1066
1068
1071 __net_user_event.user.code = NET;
1072 __net_user_event.user.data1 = NULL;
1073 __net_user_event.user.data2 = NULL;
1075
1078 __anim_user_event.user.code = EVENT_ERROR;
1079 __anim_user_event.user.data1 = NULL;
1080 __anim_user_event.user.data2 = NULL;
1082
1086 __info_user_event.user.data1 = NULL;
1087 __info_user_event.user.data2 = NULL;
1089
1092 __flush_user_event.user.code = FLUSH;
1093 __flush_user_event.user.data1 = NULL;
1094 __flush_user_event.user.data2 = NULL;
1096
1100 __map_scroll_user_event.user.data1 = NULL;
1101 __map_scroll_user_event.user.data2 = NULL;
1103
1105
1111
1115
1116 load_cursors();
1117
1119
1122
1124
1126
1127 /* This needs correct main_data.screen size */
1129
1131
1132 /* Main game loop */
1138
1140
1142
1144
1147
1149 callbacks = NULL;
1150
1152
1155
1157
1158 del_main_list();
1159
1163
1164 quit_sdl();
1165 }
1166
1167 return EXIT_SUCCESS;
1168}
1169
1170/**********************************************************************/
1173void ui_exit(void)
1174{
1175}
1176
1177/**********************************************************************/
1180enum gui_type get_gui_type(void)
1181{
1182 return GUI_SDL3;
1183}
1184
1185/**********************************************************************/
1189void sound_bell(void)
1190{
1191 log_debug("sound_bell : PORT ME");
1192}
1193
1194/**********************************************************************/
1198{
1199 anim_user_event->user.code = ANIM;
1201}
1202
1203/**********************************************************************/
1210
1211/**********************************************************************/
1215void add_net_input(int sock)
1216{
1217 log_debug("Connection UP (%d)", sock);
1218 net_socket = sock;
1221}
1222
1223/**********************************************************************/
1227{
1228 log_debug("Connection DOWN... ");
1229 net_socket = (-1);
1233}
1234
1235/**********************************************************************/
1240void add_idle_callback(void (callback)(void *), void *data)
1241{
1242 if (callbacks != NULL) {
1243 struct callback *cb = fc_malloc(sizeof(*cb));
1244
1245 cb->callback = callback;
1246 cb->data = data;
1247
1249 }
1250}
1251
1252/**********************************************************************/
1256{}
1257
1258/**********************************************************************/
1262{}
1263
1264/**********************************************************************/
1267void editgui_popup_properties(const struct tile_list *tiles, int objtype)
1268{}
1269
1270/**********************************************************************/
1274{}
1275
1276/**********************************************************************/
1279void editgui_notify_object_changed(int objtype, int object_id, bool removal)
1280{}
1281
1282/**********************************************************************/
1286{}
1287
1288/**********************************************************************/
1291void gui_update_font(const char *font_name, const char *font_value)
1292{
1293#define CHECK_FONT(client_font, action) \
1294 do { \
1295 if (strcmp(#client_font, font_name) == 0) { \
1296 char *end; \
1297 long size = strtol(font_value, &end, 10); \
1298 if (end && *end == '\0' && size > 0) { \
1299 *client_font_sizes[client_font] = size; \
1300 action; \
1301 } \
1302 } \
1303 } while (FALSE)
1304
1307 /* FONT_REQTREE_TEXT not used yet */
1308
1309#undef CHECK_FONT
1310}
1311
1312/**********************************************************************/
1321
1322/**********************************************************************/
1330
1331/**********************************************************************/
1335{
1336 /* PORTME */
1337}
1338
1339/**********************************************************************/
1342bool flush_event(void)
1343{
1345}
#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)
#define MIGRATE_STR_OPTION(opt)
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:636
int main_window_width(void)
Definition graphics.c:685
void init_sdl(int flags)
Definition graphics.c:506
void update_main_screen(void)
Definition graphics.c:669
void quit_sdl(void)
Definition graphics.c:622
bool is_in_rect_area(int x, int y, const SDL_Rect *rect)
Definition graphics.c:925
struct sdl2_data main_data
Definition graphics.c:57
bool create_surfaces(int width, int height)
Definition graphics.c:556
int main_window_height(void)
Definition graphics.c:693
@ ID_COOLING_ICON
Definition gui_id.h:138
@ ID_ERROR
Definition gui_id.h:26
@ ID_WARMING_ICON
Definition gui_id.h:139
static int city_names_font_size
Definition gui_main.c:113
static Uint16 main_key_down_handler(SDL_Keysym key, void *data)
Definition gui_main.c:233
static SDL_Event __anim_user_event
Definition gui_main.c:133
static SDL_Event * net_user_event
Definition gui_main.c:138
static void resize_window_callback(struct option *poption)
Definition gui_main.c:932
static void fullscreen_callback(struct option *poption)
Definition gui_main.c:940
void editgui_popup_properties(const struct tile_list *tiles, int objtype)
Definition gui_main.c:1265
void editgui_notify_object_created(int tag, int id)
Definition gui_main.c:1283
#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 SDL_Event __flush_user_event
Definition gui_main.c:135
int FilterMouseMotionEvents(void *data, SDL_Event *event)
Definition gui_main.c:581
static SDL_Event * info_user_event
Definition gui_main.c:140
static Uint16 main_mouse_button_down_handler(SDL_MouseButtonEvent *button_event, void *data)
Definition gui_main.c:377
static SDL_Event __net_user_event
Definition gui_main.c:132
void enable_focus_animation(void)
Definition gui_main.c:1195
void editgui_popdown_all(void)
Definition gui_main.c:1271
bool flush_event(void)
Definition gui_main.c:1340
#define MAP_SCROLL_TIMER_INTERVAL
Definition gui_main.c:91
static void real_resize_window_callback(void *data)
Definition gui_main.c:897
bool draw_goto_patrol_lines
Definition mapctrl.c:104
#define UNITS_TIMER_INTERVAL
Definition gui_main.c:90
Uint16 gui_event_loop(void *data, void(*loop_action)(void *data), Uint16(*key_down_handler)(SDL_Keysym key, void *data), Uint16(*key_up_handler)(SDL_Keysym key, void *data), Uint16(*textinput_handler)(const char *text, void *data), Uint16(*finger_down_handler)(SDL_TouchFingerEvent *touch_event, void *data), Uint16(*finger_up_handler)(SDL_TouchFingerEvent *touch_event, void *data), Uint16(*finger_motion_handler)(SDL_TouchFingerEvent *touch_event, void *data), Uint16(*mouse_button_down_handler)(SDL_MouseButtonEvent *button_event, void *data), Uint16(*mouse_button_up_handler)(SDL_MouseButtonEvent *button_event, void *data), Uint16(*mouse_motion_handler)(SDL_MouseMotionEvent *motion_event, void *data))
Definition gui_main.c:602
static void update_button_hold_state(void)
Definition gui_main.c:490
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
static Uint16 main_finger_down_handler(SDL_TouchFingerEvent *touch_event, void *data)
Definition gui_main.c:325
#define SCROLL_MAP_AREA
Definition gui_main.c:433
Uint32 widget_info_counter
Definition gui_main.c:103
static Uint16 main_mouse_motion_handler(SDL_MouseMotionEvent *motion_event, void *data)
Definition gui_main.c:439
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:518
static int net_socket
Definition gui_main.c:124
static Uint16 main_finger_up_handler(SDL_TouchFingerEvent *touch_event, void *data)
Definition gui_main.c:353
void update_font_from_theme(int theme_font_size)
Definition gui_main.c:1323
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:1313
static void clear_double_messages_call(void)
Definition gui_main.c:989
void force_exit_from_event_loop(void)
Definition gui_main.c:565
void disable_focus_animation(void)
Definition gui_main.c:1204
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:1259
int user_event_type
Definition gui_main.c:148
static SDL_Event __map_scroll_user_event
Definition gui_main.c:136
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
static Uint16 main_key_up_handler(SDL_Keysym key, void *data)
Definition gui_main.c:314
void editgui_tileset_changed(void)
Definition gui_main.c:1253
static Uint16 main_mouse_button_up_handler(SDL_MouseButtonEvent *button_event, void *data)
Definition gui_main.c:413
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
#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:80
@ MB_HOLD_MEDIUM
Definition gui_main.h:79
@ MB_HOLD_SHORT
Definition gui_main.h:78
#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:141
#define DEFAULT_MOVE_STEP
Definition gui_main.h:113
#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
static void migrate_options_from_sdl2(void)
Definition gui_main.c:1009
Uint32 sdl3_client_flags
Definition gui_main.c:97
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:5037
struct client_options gui_options
Definition options.c:71
#define MW_MESSAGES
Definition options.h:578
#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_sdl3_migrated_from_sdl2
Definition options.h:137
struct player * playing
Definition connection.h:151
Uint32 finger_down_ticks
Definition gui_main.h:85
struct tile * ptile
Definition gui_main.h:88
SDL_TouchFingerEvent event
Definition gui_main.h:87
enum mouse_button_hold_state hold_state
Definition gui_main.h:86
enum mouse_button_hold_state hold_state
Definition gui_main.h:94
SDL_MouseButtonEvent * event
Definition gui_main.h:95
struct tile * ptile
Definition gui_main.h:96
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:7069
void tileset_init(struct tileset *t)
Definition tilespec.c:7126
@ 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