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/* SDL2 */
43#ifdef SDL2_PLAIN_INCLUDE
44#include <SDL.h>
45#else /* SDL2_PLAIN_INCLUDE */
46#include <SDL2/SDL.h>
47#endif /* SDL2_PLAIN_INCLUDE */
48
49/* utility */
50#include "fc_cmdline.h"
51#include "fciconv.h"
52#include "fcintl.h"
53#include "log.h"
54#include "netintf.h"
55
56/* common */
57#include "unitlist.h"
58
59/* client */
60#include "client_main.h"
61#include "climisc.h"
62#include "clinet.h"
63#include "editgui_g.h"
64#include "gui_properties.h"
65#include "spaceshipdlg_g.h"
66#include "tilespec.h"
67#include "update_queue.h"
68#include "zoom.h"
69
70/* gui-sdl2 */
71#include "chatline.h"
72#include "citydlg.h"
73#include "cityrep.h"
74#include "diplodlg.h"
75#include "graphics.h"
76#include "gui_id.h"
77#include "gui_mouse.h"
78#include "gui_tilespec.h"
79#include "inteldlg.h"
80#include "mapctrl.h"
81#include "mapview.h"
82#include "menu.h"
83#include "messagewin.h"
84#include "optiondlg.h"
85#include "repodlgs.h"
86#include "themespec.h"
87#include "widget.h"
88
89#include "gui_main.h"
90
91#define UNITS_TIMER_INTERVAL 128 /* milliseconds */
92#define MAP_SCROLL_TIMER_INTERVAL 500
93
94const char *client_string = "gui-sdl2";
95
96/* The real GUI character encoding is UTF-16 which is not supported by
97 * fciconv code at this time. Conversion between UTF-8 and UTF-16 is done
98 * in gui_iconv.c */
99const char * const gui_character_encoding = "UTF-8";
101
103
107extern bool draw_goto_patrol_lines;
111bool LCTRL;
112bool RCTRL;
113bool LALT;
114static int city_names_font_size = 10;
117 &city_names_font_size, /* FONT_CITY_NAME */
118 &city_productions_font_size, /* FONT_CITY_PROD */
119 &city_productions_font_size /* FONT_REQTREE_TEXT; not used yet */
120};
121
122static unsigned font_size_parameter = 0;
123
124/* ================================ Private ============================ */
125static int net_socket = -1;
126static bool autoconnect = FALSE;
129
132
138
144
145static void print_usage(void);
146static bool parse_options(int argc, char **argv);
147static bool check_scroll_area(int x, int y);
148
150
161
162struct callback {
163 void (*callback)(void *data);
164 void *data;
165};
166
167#define SPECLIST_TAG callback
168#define SPECLIST_TYPE struct callback
169#include "speclist.h"
170
171struct callback_list *callbacks = NULL;
172
173/* =========================================================== */
174
175/**********************************************************************/
179static void print_usage(void)
180{
181 /* Add client-specific usage information here */
183 _(" -f, --fullscreen\tStart Client in Fullscreen mode\n"));
185 _(" -F, --Font SIZE\tUse SIZE as the base font size\n"));
186 fc_fprintf(stderr, _(" -s, --swrenderer\tUse SW renderer\n"));
187 fc_fprintf(stderr, _(" -t, --theme THEME\tUse GUI theme THEME\n"));
188
189 /* TRANS: No full stop after the URL, could cause confusion. */
190 fc_fprintf(stderr, _("Report bugs at %s\n"), BUG_URL);
191}
192
193/**********************************************************************/
196static bool parse_options(int argc, char **argv)
197{
198 int i = 1;
199 char *option = NULL;
200
201 while (i < argc) {
202 if (is_option("--help", argv[i])) {
203 print_usage();
204
205 return FALSE;
206 } else if (is_option("--fullscreen", argv[i])) {
208 } else if (is_option("--swrenderer", argv[i])) {
210 } else if ((option = get_option_malloc("--Font", argv, &i, argc, FALSE))) {
212 fc_fprintf(stderr, _("Invalid font size %s"), option);
214 }
215 free(option);
216 } else if ((option = get_option_malloc("--theme", argv, &i, argc, FALSE))) {
218 free(option);
219 } else {
220 fc_fprintf(stderr, _("Unrecognized option: \"%s\"\n"), argv[i]);
221
223 }
224
225 i++;
226 }
227
228 return TRUE;
229}
230
231/**********************************************************************/
235{
236 static struct widget *pwidget;
237
238 if ((pwidget = find_next_widget_for_key(NULL, key)) != NULL) {
239 return widget_pressed_action(pwidget);
240 } else {
241 if (key.sym == SDLK_TAB) {
242 /* Input */
244 } else {
246 && C_S_RUNNING == client_state()) {
247 switch (key.sym) {
248 case SDLK_RETURN:
249 case SDLK_KP_ENTER:
250 if (LSHIFT || RSHIFT) {
252 key_end_turn();
253 } else {
254 struct unit *punit;
255 struct city *pcity;
256
261 }
262 }
263 return ID_ERROR;
264
265 case SDLK_F2:
267 return ID_ERROR;
268
269 case SDLK_F4:
271 return ID_ERROR;
272
273 case SDLK_F7:
275 return ID_ERROR;
276
277 case SDLK_F8:
279 return ID_ERROR;
280
281 case SDLK_F9:
282 if (meswin_dialog_is_open()) {
284 } else {
286 }
287 flush_dirty();
288 return ID_ERROR;
289
290 case SDLK_F11:
292 return ID_ERROR;
293
294 case SDLK_F12:
296 return ID_ERROR;
297
298 case SDLK_ASTERISK:
300 return ID_ERROR;
301
302 default:
303 return ID_ERROR;
304 }
305 }
306 }
307 }
308
309 return ID_ERROR;
310}
311
312/**********************************************************************/
316{
317 if (selected_widget) {
319 }
320
321 return ID_ERROR;
322}
323/**********************************************************************/
327 void *data)
328{
329 struct widget *pwidget;
330 /* Touch event coordinates are normalized (0...1). */
331 int x = touch_event->x * main_window_width();
332 int y = touch_event->y * main_window_height();
333
334 if ((pwidget = find_next_widget_at_pos(NULL, x, y)) != NULL) {
335 if (get_wstate(pwidget) != FC_WS_DISABLED) {
336 return widget_pressed_action(pwidget);
337 }
338 } else {
339 /* No visible widget at this position; map pressed. */
341 /* Start counting. */
347 }
348 }
349
350 return ID_ERROR;
351}
352
353/**********************************************************************/
357 void *data)
358{
359 /* Touch event coordinates are normalized (0...1). */
360 int x = touch_event->x * main_window_width();
361 int y = touch_event->y * main_window_height();
362
363 /* Screen wasn't pressed over a widget. */
368 }
369
372
374
375 return ID_ERROR;
376}
377
378/**********************************************************************/
382 void *data)
383{
384 struct widget *pwidget;
385
386 if ((pwidget = find_next_widget_at_pos(NULL,
387 button_event->x,
388 button_event->y)) != NULL) {
389 if (get_wstate(pwidget) != FC_WS_DISABLED) {
390 return widget_pressed_action(pwidget);
391 }
392 } else {
393 /* No visible widget at this position -> map click */
394#ifdef UNDER_CE
396#endif
398 /* Start counting */
404 mouse_zoom);
405 }
406#ifdef UNDER_CE
407 }
408#endif
409 }
410
411 return ID_ERROR;
412}
413
414/**********************************************************************/
433
434#ifdef UNDER_CE
435 #define SCROLL_MAP_AREA 8
436#else
437 #define SCROLL_MAP_AREA 1
438#endif
439
440/**********************************************************************/
444 void *data)
445{
446 static struct widget *pwidget;
447 struct tile *ptile;
448
449 /* Stop evaluating button hold time when moving to another tile in medium
450 * hold state or above */
453 mouse_zoom);
456 }
457 }
458
461 }
462
463#ifndef UNDER_CE
466 }
467#endif /* UNDER_CE */
468
469 if ((pwidget = find_next_widget_at_pos(NULL,
470 motion_event->x,
471 motion_event->y)) != NULL) {
473 if (get_wstate(pwidget) != FC_WS_DISABLED) {
474 widget_selected_action(pwidget);
475 }
476 } else {
477 if (selected_widget) {
479 } else {
481 mouse_zoom));
482 }
483 }
484
486
487 return ID_ERROR;
488}
489
490/**********************************************************************/
518
519/**********************************************************************/
522static bool check_scroll_area(int x, int y)
523{
524 SDL_Rect rect_north = {.x = 0, .y = 0,
525 .w = main_data.map->w, .h = SCROLL_MAP_AREA};
526 SDL_Rect rect_east = {.x = main_data.map->w - SCROLL_MAP_AREA, .y = 0,
527 .w = SCROLL_MAP_AREA, .h = main_data.map->h};
528 SDL_Rect rect_south = {.x = 0, .y = main_data.map->h - SCROLL_MAP_AREA,
529 .w = main_data.map->w, .h = SCROLL_MAP_AREA};
530 SDL_Rect rect_west = {.x = 0, .y = 0,
531 .w = SCROLL_MAP_AREA, .h = main_data.map->h};
532
533 if (is_in_rect_area(x, y, &rect_north)) {
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_south)) {
544 if (is_in_rect_area(x, y, &rect_west)) {
546 } else if (is_in_rect_area(x, y, &rect_east)) {
548 } else {
550 }
551 } else if (is_in_rect_area(x, y, &rect_east)) {
554 } else if (is_in_rect_area(x, y, &rect_west)) {
557 } else {
559 }
560
561 return is_map_scrolling;
562}
563
564/* ============================ Public ========================== */
565
566/**********************************************************************/
570{
572
573 event.type = user_event_type;
574 event.user.code = EXIT_FROM_EVENT_LOOP;
575 event.user.data1 = NULL;
576 event.user.data2 = NULL;
577
579}
580
581/**********************************************************************/
586{
587 if (event->type == SDL_MOUSEMOTION) {
588 static int x = 0, y = 0;
589
590 if (((MOVE_STEP_X > 0) && (abs(event->motion.x - x) >= MOVE_STEP_X))
591 || ((MOVE_STEP_Y > 0) && (abs(event->motion.y - y) >= MOVE_STEP_Y)) ) {
592 x = event->motion.x;
593 y = event->motion.y;
594 return 1; /* Catch it */
595 } else {
596 return 0; /* Drop it, we've handled it */
597 }
598 }
599
600 return 1;
601}
602
603/**********************************************************************/
607 void (*loop_action)(void *data),
608 widget_id (*key_down_handler)(SDL_Keysym key, void *data),
609 widget_id (*key_up_handler)(SDL_Keysym key, void *data),
610 widget_id (*textinput_handler)(const char *text, void *data),
612 void *data),
614 void *data),
616 void *data),
618 void *data),
620 void *data),
622 void *data))
623{
624 Uint16 ID;
625 static fc_timeval tv;
626 static fd_set civfdset;
629 static int result;
630
631 ID = ID_ERROR;
633 while (ID == ID_ERROR) {
634 /* ========================================= */
635 /* Net check with 10ms delay event loop */
636 if (net_socket >= 0) {
638
639 if (net_socket >= 0) {
641 }
642
643 tv.tv_sec = 0;
644 tv.tv_usec = 10000; /* 10ms*/
645
646 result = fc_select(net_socket + 1, &civfdset, NULL, NULL, &tv);
647 if (result < 0) {
648 if (errno != EINTR) {
649 break;
650 } else {
651 continue;
652 }
653 } else {
654 if (result > 0) {
655 if ((net_socket >= 0) && FD_ISSET(net_socket, &civfdset)) {
657 }
658 }
659 }
660 } else { /* If connection is not establish */
661 SDL_Delay(10);
662 }
663 /* ========================================= */
664
666
669 }
670
672 if (autoconnect) {
675 } else {
677 }
678
680 }
681
682 if (is_map_scrolling) {
686 }
687 } else {
689 }
690
691 if (widget_info_counter > 0) {
694 }
695
696 /* ========================================= */
697
698 if (loop_action) {
699 loop_action(data);
700 }
701
702 /* ========================================= */
703
704 while (SDL_PollEvent(&main_data.event) == 1) {
705
706 if (main_data.event.type == user_event_type) {
707 switch (main_data.event.user.code) {
708 case NET:
710 break;
711 case ANIM:
715 break;
718 break;
719 case TRY_AUTO_CONNECT:
720 if (try_to_autoconnect()) {
723 }
724 break;
725 case FLUSH:
727 break;
728 case MAP_SCROLL:
730 break;
732 return MAX_ID;
733 break;
734 default:
735 break;
736 }
737
738 } else {
739
740 switch (main_data.event.type) {
741
742 case SDL_QUIT:
743 return MAX_ID;
744 break;
745
746 case SDL_KEYUP:
747 switch (main_data.event.key.keysym.sym) {
748 /* find if Shifts are released */
749 case SDLK_RSHIFT:
750 RSHIFT = FALSE;
751 break;
752 case SDLK_LSHIFT:
753 LSHIFT = FALSE;
754 break;
755 case SDLK_LCTRL:
756 LCTRL = FALSE;
757 break;
758 case SDLK_RCTRL:
759 RCTRL = FALSE;
760 break;
761 case SDLK_LALT:
762 LALT = FALSE;
763 break;
764 default:
765 if (key_up_handler) {
766 ID = key_up_handler(main_data.event.key.keysym, data);
767 }
768 break;
769 }
770 break;
771
772 case SDL_KEYDOWN:
773 switch (main_data.event.key.keysym.sym) {
774#if 0
775 case SDLK_PRINT:
776 fc_snprintf(schot, sizeof(schot), "fc_%05d.bmp", schot_nr++);
777 log_normal(_("Making screenshot %s"), schot);
779 break;
780#endif /* 0 */
781
782 case SDLK_RSHIFT:
783 /* Right Shift is Pressed */
784 RSHIFT = TRUE;
785 break;
786
787 case SDLK_LSHIFT:
788 /* Left Shift is Pressed */
789 LSHIFT = TRUE;
790 break;
791
792 case SDLK_LCTRL:
793 /* Left CTRL is Pressed */
794 LCTRL = TRUE;
795 break;
796
797 case SDLK_RCTRL:
798 /* Right CTRL is Pressed */
799 RCTRL = TRUE;
800 break;
801
802 case SDLK_LALT:
803 /* Left ALT is Pressed */
804 LALT = TRUE;
805 break;
806
807 default:
808 if (key_down_handler) {
809 ID = key_down_handler(main_data.event.key.keysym, data);
810 }
811 break;
812 }
813 break;
814
815 case SDL_TEXTINPUT:
816 if (textinput_handler) {
817 ID = textinput_handler(main_data.event.text.text, data);
818 }
819 break;
820
821 case SDL_FINGERDOWN:
823 ID = finger_down_handler(&main_data.event.tfinger, data);
824 }
825 break;
826
827 case SDL_FINGERUP:
828 if (finger_up_handler) {
829 ID = finger_up_handler(&main_data.event.tfinger, data);
830 }
831 break;
832
833 case SDL_FINGERMOTION:
835 ID = finger_motion_handler(&main_data.event.tfinger, data);
836 }
837 break;
838
842 }
843 break;
844
847 ID = mouse_button_up_handler(&main_data.event.button, data);
848 }
849 break;
850
851 case SDL_MOUSEMOTION:
853 ID = mouse_motion_handler(&main_data.event.motion, data);
854 }
855 break;
856 }
857 }
858 }
859
860 if (ID == ID_ERROR) {
862 struct callback *cb = callback_list_get(callbacks, 0);
863
865 (cb->callback)(cb->data);
866 free(cb);
867 }
868 }
869
871
872#ifdef __EMSCRIPTEN__
873 emscripten_sleep(100);
874#endif
875 }
876
877 return ID;
878}
879
880/* ============ Freeciv native game function =========== */
881
882/**********************************************************************/
899
900/**********************************************************************/
904{
905 struct widget *widget;
906
907 if (C_S_RUNNING == client_state()) {
908 /* Move units window to botton-right corner. */
910 /* Move minimap window to botton-left corner. */
912
913 /* Move cooling/warming icons to botton-right corner. */
916 - (widget->size.w * 2)), widget->size.y);
917
920 - widget->size.w), widget->size.y);
921
925 center_on_something(); /* With redrawing full map. */
927 } else {
929 dirty_all();
930 }
931
932 flush_all();
933}
934
935/**********************************************************************/
942
943/**********************************************************************/
969
970/**********************************************************************/
975{
976 struct option *poption;
977
978#define option_var_set_callback(var, callback) \
979 if ((poption = optset_option_by_name(client_optset, \
980 GUI_SDL_OPTION_STR(var)))) { \
981 option_set_changed_callback(poption, callback); \
982 } else { \
983 log_error("Didn't find option %s!", GUI_SDL_OPTION_STR(var)); \
984 }
985
988#undef option_var_set_callback
989}
990
991/**********************************************************************/
996{
997 int i;
998
999 /* Clear double call */
1000 for (i = 0; i <= event_type_max(); i++) {
1001 if (messages_where[i] & MW_MESSAGES) {
1003 }
1004 }
1005}
1006
1007/**********************************************************************/
1012int main(int argc, char **argv)
1013{
1014 return client_main(argc, argv, FALSE);
1015}
1016
1017/**********************************************************************/
1021{
1022 log_normal(_("Migrating options from sdl to sdl2 client"));
1023
1024#define MIGRATE_OPTION(opt) gui_options.gui_sdl2_##opt = gui_options.gui_sdl_##opt;
1025
1026 /* Default theme name is never migrated */
1028 MIGRATE_OPTION(screen);
1031
1032#undef MIGRATE_OPTION
1033
1035}
1036
1037/**********************************************************************/
1041int ui_main(int argc, char *argv[])
1042{
1043 Uint32 flags = 0;
1044
1045 if (parse_options(argc, argv)) {
1048 }
1050 if (font_size_parameter > 10) {
1051 GUI_SDL_OPTION(screen) = VIDEO_MODE(640 * font_size_parameter / 10,
1052 480 * font_size_parameter / 10);
1053 }
1054
1056 }
1057
1059 flags |= SDL_WINDOW_FULLSCREEN;
1060 } else {
1061 flags &= ~SDL_WINDOW_FULLSCREEN;
1062 }
1063
1064 log_normal(_("Using Video Output: %s"), SDL_GetCurrentVideoDriver());
1065 if (!set_video_mode(GUI_SDL_OPTION(screen.width),
1066 GUI_SDL_OPTION(screen.height),
1067 flags)) {
1068 return EXIT_FAILURE;
1069 }
1070
1072
1075 __net_user_event.user.code = NET;
1076 __net_user_event.user.data1 = NULL;
1077 __net_user_event.user.data2 = NULL;
1079
1082 __anim_user_event.user.code = EVENT_ERROR;
1083 __anim_user_event.user.data1 = NULL;
1084 __anim_user_event.user.data2 = NULL;
1086
1090 __info_user_event.user.data1 = NULL;
1091 __info_user_event.user.data2 = NULL;
1093
1096 __flush_user_event.user.code = FLUSH;
1097 __flush_user_event.user.data1 = NULL;
1098 __flush_user_event.user.data2 = NULL;
1100
1104 __map_scroll_user_event.user.data1 = NULL;
1105 __map_scroll_user_event.user.data2 = NULL;
1107
1109
1115
1119
1120 load_cursors();
1121
1123
1126
1128
1130
1131 /* This needs correct main_data.screen size */
1133
1135
1136 /* Main game loop */
1142
1143#if defined UNDER_CE && defined GUI_SDL2_SMALL_SCREEN
1144 /* Change back to window mode to restore the title bar */
1146#endif
1147
1149
1151
1153
1156
1158 callbacks = NULL;
1159
1161
1164
1166
1167 del_main_list();
1168
1172
1173 quit_sdl();
1174 }
1175
1176 return EXIT_SUCCESS;
1177}
1178
1179/**********************************************************************/
1182void ui_exit(void)
1183{
1184}
1185
1186/**********************************************************************/
1189enum gui_type get_gui_type(void)
1190{
1191 return GUI_SDL2;
1192}
1193
1194/**********************************************************************/
1198void sound_bell(void)
1199{
1200 log_debug("sound_bell : PORT ME");
1201}
1202
1203/**********************************************************************/
1207{
1208 anim_user_event->user.code = ANIM;
1210}
1211
1212/**********************************************************************/
1219
1220/**********************************************************************/
1224void add_net_input(int sock)
1225{
1226 log_debug("Connection UP (%d)", sock);
1227 net_socket = sock;
1230}
1231
1232/**********************************************************************/
1236{
1237 log_debug("Connection DOWN... ");
1238 net_socket = (-1);
1242}
1243
1244/**********************************************************************/
1249void add_idle_callback(void (callback)(void *), void *data)
1250{
1251 if (callbacks != NULL) {
1252 struct callback *cb = fc_malloc(sizeof(*cb));
1253
1254 cb->callback = callback;
1255 cb->data = data;
1256
1258 }
1259}
1260
1261/**********************************************************************/
1265{}
1266
1267/**********************************************************************/
1271{}
1272
1273/**********************************************************************/
1276void editgui_popup_properties(const struct tile_list *tiles, int objtype)
1277{}
1278
1279/**********************************************************************/
1283{}
1284
1285/**********************************************************************/
1288void editgui_notify_object_changed(int objtype, int object_id, bool removal)
1289{}
1290
1291/**********************************************************************/
1295{}
1296
1297/**********************************************************************/
1300void gui_update_font(const char *font_name, const char *font_value)
1301{
1302#define CHECK_FONT(client_font, action) \
1303 do { \
1304 if (strcmp(#client_font, font_name) == 0) { \
1305 char *end; \
1306 long size = strtol(font_value, &end, 10); \
1307 if (end && *end == '\0' && size > 0) { \
1308 *client_font_sizes[client_font] = size; \
1309 action; \
1310 } \
1311 } \
1312 } while (FALSE)
1313
1316 /* FONT_REQTREE_TEXT not used yet */
1317
1318#undef CHECK_FONT
1319}
1320
1321/**********************************************************************/
1330
1331/**********************************************************************/
1339
1340/**********************************************************************/
1344{
1345 /* PORTME */
1346}
1347
1348/**********************************************************************/
1351bool flush_event(void)
1352{
1353 return SDL_PushEvent(flush_user_event) >= 0;
1354}
1355
1356/**********************************************************************/
#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: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
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:78
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:64
int ui_main(int argc, char **argv)
Definition gui_main.c:1888
const char * client_string
Definition gui_main.c:106
static void print_usage(void)
Definition gui_main.c:266
#define option_var_set_callback(var, callback)
void ui_exit(void)
Definition gui_main.c:2067
enum gui_type get_gui_type(void)
Definition gui_main.c:2078
int main(int argc, char **argv)
Definition gui_main.c:1766
void ui_init(void)
Definition gui_main.c:1756
void add_idle_callback(void(callback)(void *), void *data)
Definition gui_main.c:2406
void options_extra_init(void)
Definition gui_main.c:2480
void setup_gui_properties(void)
Definition gui_main.c:2650
void insert_client_build_info(char *outbuf, size_t outlen)
Definition gui_main.c:2540
void remove_net_input(void)
Definition gui_main.c:2312
void sound_bell(void)
Definition gui_main.c:2086
const char *const gui_character_encoding
Definition gui_main.c:162
void add_net_input(int sock)
Definition gui_main.c:2294
static bool parse_options(int argc, char **argv)
Definition gui_main.c:287
#define MIGRATE_OPTION(opt)
const bool gui_use_transliteration
Definition gui_main.c:163
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 void migrate_options_from_sdl(void)
Definition gui_main.c:1020
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:938
static void fullscreen_callback(struct option *poption)
Definition gui_main.c:946
void editgui_popup_properties(const struct tile_list *tiles, int objtype)
Definition gui_main.c:1276
void editgui_notify_object_created(int tag, int id)
Definition gui_main.c:1294
#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:1206
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:1282
bool flush_event(void)
Definition gui_main.c:1351
#define MAP_SCROLL_TIMER_INTERVAL
Definition gui_main.c:92
static void real_resize_window_callback(void *data)
Definition gui_main.c:903
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:1334
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:1324
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:995
void force_exit_from_event_loop(void)
Definition gui_main.c:569
void disable_focus_animation(void)
Definition gui_main.c:1215
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:1270
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
Uint32 sdl2_client_flags
Definition gui_main.c:102
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:1264
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_SWRENDERER
Definition gui_main.h:64
#define CF_DRAW_PLAYERS_PEACE_STATUS
Definition gui_main.h:61
@ MB_HOLD_LONG
Definition gui_main.h:82
@ MB_HOLD_MEDIUM
Definition gui_main.h:81
@ MB_HOLD_SHORT
Definition gui_main.h:80
#define MB_MEDIUM_HOLD_DELAY
Definition gui_main.h:67
struct widget * selected_widget
Definition widget.c:48
#define CF_DRAW_PLAYERS_NEUTRAL_STATUS
Definition gui_main.h:63
#define adj_size(size)
Definition gui_main.h:145
#define DEFAULT_MOVE_STEP
Definition gui_main.h:115
#define MB_LONG_HOLD_DELAY
Definition gui_main.h:68
#define CF_DRAW_PLAYERS_WAR_STATUS
Definition gui_main.h:59
#define GUI_SDL_OPTION(optname)
Definition gui_main.h:37
void animate_mouse_cursor(void)
Definition gui_mouse.c:182
void unload_cursors(void)
Definition gui_mouse.c:164
void draw_mouse_cursor(void)
Definition gui_mouse.c:100
void free_font_system(void)
Definition gui_string.c:698
void setup_auxiliary_tech_icons(void)
void draw_intro_gfx(void)
void free_auxiliary_tech_icons(void)
void button_down_on_map(struct mouse_button_behavior *button_behavior)
Definition mapctrl.c:2280
void button_up_on_map(struct mouse_button_behavior *button_behavior)
Definition mapctrl.c:2351
void finger_up_on_map(struct finger_behavior *finger_behavior)
Definition mapctrl.c:2267
bool map_event_handler(SDL_Keysym key)
Definition mapctrl.c:2445
void set_new_minimap_window_pos(void)
Definition mapctrl.c:1386
void set_new_unitinfo_window_pos(void)
Definition mapctrl.c:1332
void unqueue_flush(void)
Definition mapview.c:140
void city_map_canvas_free(void)
Definition mapview.c:1190
void flush_all(void)
Definition mapview.c:201
void update_order_widgets(void)
Definition menu.c:952
void theme_free(struct theme *ftheme)
Definition themespec.c:317
int theme_default_font_size(const struct theme *t)
Definition themespec.c:177
struct theme * active_theme
Definition themespec.c:154
struct widget * find_next_widget_for_key(struct widget *start_widget, SDL_Keysym key)
Definition widget.c:252
Uint16 widget_pressed_action(struct widget *pwidget)
Definition widget.c:296
void widget_selected_action(struct widget *pwidget)
Definition widget.c:443
struct widget * get_widget_pointer_from_main_list(Uint16 id)
Definition widget.c:578
struct widget * find_next_widget_at_pos(struct widget *start_widget, int x, int y)
Definition widget.c:222
void unselect_widget_action(void)
Definition widget.c:418
void del_main_list(void)
Definition widget.c:691
static void widget_set_position(struct widget *pwidget, int x, int y)
Definition widget.h:266
#define MAX_ID
Definition widget.h:38
@ FC_WS_DISABLED
Definition widget.h:99
enum widget_state get_wstate(const struct widget *pwidget)
Definition widget_core.c:70
#define draw_widget_info_label()
Definition widget.h:246
const char * font_name
Definition gui_main_g.h:43
gui_update_font
Definition gui_main_g.h:43
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:5400
struct client_options gui_options
Definition options.c:71
#define MW_MESSAGES
Definition options.h:630
#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:2385
void(* callback)(void *data)
Definition gui_main.c:2384
Definition city.h:317
struct connection conn
Definition client_main.h:96
bool gui_sdl2_migrated_from_sdl
Definition options.h:137
struct client_properties::@230 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:140
SDL_Keycode key
Definition widget.h:153
struct widget * widget
Definition widget.h:132
union widget::@223 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:3822
void tileset_use_preferred_theme(const struct tileset *t)
Definition tilespec.c:7314
void tileset_init(struct tileset *t)
Definition tilespec.c:7375
@ CURSOR_DEFAULT
Definition tilespec.h:300
#define unit_tile(_pu)
Definition unit.h:407
void update_queue_add(uq_callback_t callback, void *data)
float mouse_zoom
Definition zoom.c:28