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
355 /* Screen wasn't pressed over a widget. */
360 }
361
364
366
367 return ID_ERROR;
368}
369
370/**********************************************************************/
374 void *data)
375{
376 struct widget *pwidget;
377
378 if ((pwidget = find_next_widget_at_pos(NULL,
379 button_event->x,
380 button_event->y)) != NULL) {
381 if (get_wstate(pwidget) != FC_WS_DISABLED) {
382 return widget_pressed_action(pwidget);
383 }
384 } else {
385 /* No visible widget at this position -> map click */
386#ifdef UNDER_CE
388#endif
390 /* Start counting */
396 mouse_zoom);
397 }
398#ifdef UNDER_CE
399 }
400#endif
401 }
402
403 return ID_ERROR;
404}
405
406/**********************************************************************/
425
426#ifdef UNDER_CE
427 #define SCROLL_MAP_AREA 8
428#else
429 #define SCROLL_MAP_AREA 1
430#endif
431
432/**********************************************************************/
436 void *data)
437{
438 static struct widget *pwidget;
439 struct tile *ptile;
440
441 /* Stop evaluating button hold time when moving to another tile in medium
442 * hold state or above */
445 mouse_zoom);
448 }
449 }
450
453 }
454
455#ifndef UNDER_CE
458 }
459#endif /* UNDER_CE */
460
461 if ((pwidget = find_next_widget_at_pos(NULL,
462 motion_event->x,
463 motion_event->y)) != NULL) {
465 if (get_wstate(pwidget) != FC_WS_DISABLED) {
466 widget_selected_action(pwidget);
467 }
468 } else {
469 if (selected_widget) {
471 } else {
473 mouse_zoom));
474 }
475 }
476
478
479 return ID_ERROR;
480}
481
482/**********************************************************************/
510
511/**********************************************************************/
514static bool check_scroll_area(int x, int y)
515{
516 SDL_Rect rect_north = {.x = 0, .y = 0,
517 .w = main_data.map->w, .h = SCROLL_MAP_AREA};
518 SDL_Rect rect_east = {.x = main_data.map->w - SCROLL_MAP_AREA, .y = 0,
519 .w = SCROLL_MAP_AREA, .h = main_data.map->h};
520 SDL_Rect rect_south = {.x = 0, .y = main_data.map->h - SCROLL_MAP_AREA,
521 .w = main_data.map->w, .h = SCROLL_MAP_AREA};
522 SDL_Rect rect_west = {.x = 0, .y = 0,
523 .w = SCROLL_MAP_AREA, .h = main_data.map->h};
524
525 if (is_in_rect_area(x, y, &rect_north)) {
527 if (is_in_rect_area(x, y, &rect_west)) {
529 } else if (is_in_rect_area(x, y, &rect_east)) {
531 } else {
533 }
534 } else if (is_in_rect_area(x, y, &rect_south)) {
536 if (is_in_rect_area(x, y, &rect_west)) {
538 } else if (is_in_rect_area(x, y, &rect_east)) {
540 } else {
542 }
543 } else if (is_in_rect_area(x, y, &rect_east)) {
546 } else if (is_in_rect_area(x, y, &rect_west)) {
549 } else {
551 }
552
553 return is_map_scrolling;
554}
555
556/* ============================ Public ========================== */
557
558/**********************************************************************/
562{
564
565 event.type = user_event_type;
566 event.user.code = EXIT_FROM_EVENT_LOOP;
567 event.user.data1 = NULL;
568 event.user.data2 = NULL;
569
571}
572
573/**********************************************************************/
578{
579 if (event->type == SDL_EVENT_MOUSE_MOTION) {
580 static int x = 0, y = 0;
581
582 if (((MOVE_STEP_X > 0) && (abs(event->motion.x - x) >= MOVE_STEP_X))
583 || ((MOVE_STEP_Y > 0) && (abs(event->motion.y - y) >= MOVE_STEP_Y)) ) {
584 x = event->motion.x;
585 y = event->motion.y;
586 return TRUE; /* Catch it */
587 } else {
588 return FALSE; /* Drop it, we've handled it */
589 }
590 }
591
592 return TRUE;
593}
594
595/**********************************************************************/
599 void (*loop_action)(void *data),
600 widget_id (*key_down_handler)(SDL_KeyboardEvent *key, void *data),
601 widget_id (*key_up_handler)(SDL_KeyboardEvent *key, void *data),
602 widget_id (*textinput_handler)(const char *text, void *data),
604 void *data),
606 void *data),
608 void *data),
610 void *data),
612 void *data),
614 void *data))
615{
616 Uint16 ID;
617 static fc_timeval tv;
618 static fd_set civfdset;
621 static int result;
622
623 ID = ID_ERROR;
625 while (ID == ID_ERROR) {
626 /* ========================================= */
627 /* Net check with 10ms delay event loop */
628 if (net_socket >= 0) {
630
631 if (net_socket >= 0) {
633 }
634
635 tv.tv_sec = 0;
636 tv.tv_usec = 10000; /* 10ms*/
637
638 result = fc_select(net_socket + 1, &civfdset, NULL, NULL, &tv);
639 if (result < 0) {
640 if (errno != EINTR) {
641 break;
642 } else {
643 continue;
644 }
645 } else {
646 if (result > 0) {
647 if ((net_socket >= 0) && FD_ISSET(net_socket, &civfdset)) {
649 }
650 }
651 }
652 } else { /* If connection is not establish */
653 SDL_Delay(10);
654 }
655 /* ========================================= */
656
658
661 }
662
664 if (autoconnect) {
667 } else {
669 }
670
672 }
673
674 if (is_map_scrolling) {
678 }
679 } else {
681 }
682
683 if (widget_info_counter > 0) {
686 }
687
688 /* ========================================= */
689
690 if (loop_action) {
691 loop_action(data);
692 }
693
694 /* ========================================= */
695
696 while (SDL_PollEvent(&main_data.event) == 1) {
697
698 if (main_data.event.type == user_event_type) {
699 switch (main_data.event.user.code) {
700 case NET:
702 break;
703 case ANIM:
707 break;
710 break;
711 case TRY_AUTO_CONNECT:
712 if (try_to_autoconnect()) {
715 }
716 break;
717 case FLUSH:
719 break;
720 case MAP_SCROLL:
722 break;
724 return MAX_ID;
725 break;
726 default:
727 break;
728 }
729
730 } else {
731
732 switch (main_data.event.type) {
733
734 case SDL_EVENT_QUIT:
735 return MAX_ID;
736 break;
737
738 case SDL_EVENT_KEY_UP:
739 switch (main_data.event.key.key) {
740 /* Find if Shifts are released */
741 case SDLK_RSHIFT:
742 RSHIFT = FALSE;
743 break;
744 case SDLK_LSHIFT:
745 LSHIFT = FALSE;
746 break;
747 case SDLK_LCTRL:
748 LCTRL = FALSE;
749 break;
750 case SDLK_RCTRL:
751 RCTRL = FALSE;
752 break;
753 case SDLK_LALT:
754 LALT = FALSE;
755 break;
756 default:
757 if (key_up_handler) {
758 ID = key_up_handler(&(main_data.event.key), data);
759 }
760 break;
761 }
762 break;
763
765 switch (main_data.event.key.key) {
766#if 0
767 case SDLK_PRINT:
768 fc_snprintf(schot, sizeof(schot), "fc_%05d.bmp", schot_nr++);
769 log_normal(_("Making screenshot %s"), schot);
771 break;
772#endif /* 0 */
773
774 case SDLK_RSHIFT:
775 /* Right Shift is Pressed */
776 RSHIFT = TRUE;
777 break;
778
779 case SDLK_LSHIFT:
780 /* Left Shift is Pressed */
781 LSHIFT = TRUE;
782 break;
783
784 case SDLK_LCTRL:
785 /* Left CTRL is Pressed */
786 LCTRL = TRUE;
787 break;
788
789 case SDLK_RCTRL:
790 /* Right CTRL is Pressed */
791 RCTRL = TRUE;
792 break;
793
794 case SDLK_LALT:
795 /* Left ALT is Pressed */
796 LALT = TRUE;
797 break;
798
799 default:
800 if (key_down_handler) {
801 ID = key_down_handler(&(main_data.event.key), data);
802 }
803 break;
804 }
805 break;
806
808 if (textinput_handler) {
809 ID = textinput_handler(main_data.event.text.text, data);
810 }
811 break;
812
815 ID = finger_down_handler(&main_data.event.tfinger, data);
816 }
817 break;
818
820 if (finger_up_handler) {
821 ID = finger_up_handler(&main_data.event.tfinger, data);
822 }
823 break;
824
827 ID = finger_motion_handler(&main_data.event.tfinger, data);
828 }
829 break;
830
834 }
835 break;
836
839 ID = mouse_button_up_handler(&main_data.event.button, data);
840 }
841 break;
842
845 ID = mouse_motion_handler(&main_data.event.motion, data);
846 }
847 break;
848 }
849 }
850 }
851
852 if (ID == ID_ERROR) {
854 struct callback *cb = callback_list_get(callbacks, 0);
855
857 (cb->callback)(cb->data);
858 free(cb);
859 }
860 }
861
863
864#ifdef __EMSCRIPTEN__
865 emscripten_sleep(100);
866#endif
867 }
868
869 return ID;
870}
871
872/* ============ Freeciv native game function =========== */
873
874/**********************************************************************/
891
892/**********************************************************************/
896{
897 struct widget *widget;
898
899 if (C_S_RUNNING == client_state()) {
900 /* Move units window to botton-right corner. */
902 /* Move minimap window to botton-left corner. */
904
905 /* Move cooling/warming icons to botton-right corner. */
908 - (widget->size.w * 2)), widget->size.y);
909
912 - widget->size.w), widget->size.y);
913
917 center_on_something(); /* With redrawing full map. */
919 } else {
921 dirty_all();
922 }
923
924 flush_all();
925}
926
927/**********************************************************************/
934
935/**********************************************************************/
939{
940 const SDL_DisplayMode *mode;
941
944 } else {
946 }
947
949
950 if (!create_surfaces(mode->w, mode->h)) {
951 /* Try to revert */
954 } else {
956 }
957 }
958
960}
961
962/**********************************************************************/
967{
968 struct option *poption;
969
970#define option_var_set_callback(var, callback) \
971 if ((poption = optset_option_by_name(client_optset, \
972 GUI_SDL_OPTION_STR(var)))) { \
973 option_set_changed_callback(poption, callback); \
974 } else { \
975 log_error("Didn't find option %s!", GUI_SDL_OPTION_STR(var)); \
976 }
977
980#undef option_var_set_callback
981}
982
983/**********************************************************************/
988{
989 int i;
990
991 /* Clear double call */
992 for (i = 0; i <= event_type_max(); i++) {
995 }
996 }
997}
998
999/**********************************************************************/
1004int main(int argc, char **argv)
1005{
1006 return client_main(argc, argv, FALSE);
1007}
1008
1009/**********************************************************************/
1013{
1014 log_normal(_("Migrating options from sdl2 to sdl3 client"));
1015
1016#define MIGRATE_OPTION(opt) gui_options.gui_sdl3_##opt = gui_options.gui_sdl2_##opt;
1017#define MIGRATE_STR_OPTION(opt) \
1018 strncpy(gui_options.gui_sdl3_##opt, gui_options.gui_sdl2_##opt, \
1019 sizeof(gui_options.gui_sdl3_##opt));
1020
1021 /* Default theme name is never migrated */
1023 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_SDL3;
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{
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)
#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: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 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
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_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
static void migrate_options_from_sdl2(void)
Definition gui_main.c:1012
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: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_sdl3_migrated_from_sdl2
Definition options.h:137
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