Freeciv-3.2
Loading...
Searching...
No Matches
gui_main.c
Go to the documentation of this file.
1/***********************************************************************
2 Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
6 any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12***********************************************************************/
13
14/***********************************************************************
15 gui_main.c - description
16 -------------------
17 begin : Sun Jun 30 2002
18 copyright : (C) 2002 by Rafał Bursig
19 email : Rafał Bursig <bursig@poczta.fm>
20***********************************************************************/
21
22#ifdef HAVE_CONFIG_H
23#include <fc_config.h>
24#endif
25
26#include "fc_prehdrs.h"
27
28#include <errno.h>
29
30#ifdef HAVE_LOCALE_H
31#include <locale.h>
32#endif
33
34#ifdef HAVE_UNISTD_H
35#include <unistd.h>
36#endif
37
38#ifdef __EMSCRIPTEN__
39#include <emscripten.h>
40#endif
41
42/* SDL2 */
43#ifdef SDL2_PLAIN_INCLUDE
44#include <SDL.h>
45#else /* SDL2_PLAIN_INCLUDE */
46#include <SDL2/SDL.h>
47#endif /* SDL2_PLAIN_INCLUDE */
48
49/* utility */
50#include "fc_cmdline.h"
51#include "fciconv.h"
52#include "fcintl.h"
53#include "log.h"
54#include "netintf.h"
55
56/* common */
57#include "unitlist.h"
58
59/* client */
60#include "client_main.h"
61#include "climisc.h"
62#include "clinet.h"
63#include "editgui_g.h"
64#include "tilespec.h"
65#include "update_queue.h"
66#include "zoom.h"
67
68/* gui-sdl2 */
69#include "chatline.h"
70#include "citydlg.h"
71#include "cityrep.h"
72#include "diplodlg.h"
73#include "graphics.h"
74#include "gui_id.h"
75#include "gui_mouse.h"
76#include "gui_tilespec.h"
77#include "inteldlg.h"
78#include "mapctrl.h"
79#include "mapview.h"
80#include "menu.h"
81#include "messagewin.h"
82#include "optiondlg.h"
83#include "repodlgs.h"
84#include "themespec.h"
85#include "spaceshipdlg.h"
86#include "widget.h"
87
88#include "gui_main.h"
89
90#define UNITS_TIMER_INTERVAL 128 /* milliseconds */
91#define MAP_SCROLL_TIMER_INTERVAL 500
92
93const char *client_string = "gui-sdl2";
94
95/* The real GUI character encoding is UTF-16 which is not supported by
96 * fciconv code at this time. Conversion between UTF-8 and UTF-16 is done
97 * in gui_iconv.c */
98const char * const gui_character_encoding = "UTF-8";
100
102
106extern bool draw_goto_patrol_lines;
110bool LCTRL;
111bool RCTRL;
112bool LALT;
113static int city_names_font_size = 10;
116 &city_names_font_size, /* FONT_CITY_NAME */
117 &city_productions_font_size, /* FONT_CITY_PROD */
118 &city_productions_font_size /* FONT_REQTREE_TEXT; not used yet */
119};
120
121static unsigned font_size_parameter = 0;
122
123/* ================================ Private ============================ */
124static int net_socket = -1;
125static bool autoconnect = FALSE;
128
131
137
143
144static void print_usage(void);
145static bool parse_options(int argc, char **argv);
146static bool check_scroll_area(int x, int y);
147
149
160
161struct callback {
162 void (*callback)(void *data);
163 void *data;
164};
165
166#define SPECLIST_TAG callback
167#define SPECLIST_TYPE struct callback
168#include "speclist.h"
169
170struct callback_list *callbacks = NULL;
171
172/* =========================================================== */
173
174/**********************************************************************/
178static void print_usage(void)
179{
180 /* Add client-specific usage information here */
182 _(" -f, --fullscreen\tStart Client in Fullscreen mode\n"));
184 _(" -F, --Font SIZE\tUse SIZE as the base font size\n"));
185 fc_fprintf(stderr, _(" -s, --swrenderer\tUse SW renderer\n"));
186 fc_fprintf(stderr, _(" -t, --theme THEME\tUse GUI theme THEME\n"));
187
188 /* TRANS: No full stop after the URL, could cause confusion. */
189 fc_fprintf(stderr, _("Report bugs at %s\n"), BUG_URL);
190}
191
192/**********************************************************************/
195static bool parse_options(int argc, char **argv)
196{
197 int i = 1;
198 char *option = NULL;
199
200 while (i < argc) {
201 if (is_option("--help", argv[i])) {
202 print_usage();
203
204 return FALSE;
205 } else if (is_option("--fullscreen", argv[i])) {
207 } else if (is_option("--swrenderer", argv[i])) {
209 } else if ((option = get_option_malloc("--Font", argv, &i, argc, FALSE))) {
211 fc_fprintf(stderr, _("Invalid font size %s"), option);
213 }
214 free(option);
215 } else if ((option = get_option_malloc("--theme", argv, &i, argc, FALSE))) {
217 free(option);
218 } else {
219 fc_fprintf(stderr, _("Unrecognized option: \"%s\"\n"), argv[i]);
220
222 }
223
224 i++;
225 }
226
227 return TRUE;
228}
229
230/**********************************************************************/
234{
235 static struct widget *pwidget;
236
237 if ((pwidget = find_next_widget_for_key(NULL, key)) != NULL) {
238 return widget_pressed_action(pwidget);
239 } else {
240 if (key.sym == SDLK_TAB) {
241 /* input */
243 } else {
245 && C_S_RUNNING == client_state()) {
246 switch (key.sym) {
247 case SDLK_RETURN:
248 case SDLK_KP_ENTER:
249 if (LSHIFT || RSHIFT) {
251 key_end_turn();
252 } else {
253 struct unit *punit;
254 struct city *pcity;
255
257 && (pcity = tile_city(unit_tile(punit))) != NULL
258 && city_owner(pcity) == client.conn.playing) {
259 popup_city_dialog(pcity);
260 }
261 }
262 return ID_ERROR;
263
264 case SDLK_F2:
266 return ID_ERROR;
267
268 case SDLK_F4:
270 return ID_ERROR;
271
272 case SDLK_F7:
274 return ID_ERROR;
275
276 case SDLK_F8:
278 return ID_ERROR;
279
280 case SDLK_F9:
281 if (meswin_dialog_is_open()) {
283 } else {
285 }
286 flush_dirty();
287 return ID_ERROR;
288
289 case SDLK_F11:
291 return ID_ERROR;
292
293 case SDLK_F12:
295 return ID_ERROR;
296
297 case SDLK_ASTERISK:
299 return ID_ERROR;
300
301 default:
302 return ID_ERROR;
303 }
304 }
305 }
306 }
307
308 return ID_ERROR;
309}
310
311/**********************************************************************/
314static Uint16 main_key_up_handler(SDL_Keysym key, void *data)
315{
316 if (selected_widget) {
318 }
319
320 return ID_ERROR;
321}
322/**********************************************************************/
326 void *data)
327{
328 struct widget *pwidget;
329 /* Touch event coordinates are normalized (0...1). */
330 int x = touch_event->x * main_window_width();
331 int y = touch_event->y * main_window_height();
332
333 if ((pwidget = find_next_widget_at_pos(NULL, x, y)) != NULL) {
334 if (get_wstate(pwidget) != FC_WS_DISABLED) {
335 return widget_pressed_action(pwidget);
336 }
337 } else {
338 /* No visible widget at this position; map pressed. */
340 /* Start counting. */
346 }
347 }
348 return ID_ERROR;
349}
350/**********************************************************************/
354 void *data)
355{
356 /* Touch event coordinates are normalized (0...1). */
357 int x = touch_event->x * main_window_width();
358 int y = touch_event->y * main_window_height();
359 /* Screen wasn't pressed over a widget. */
364 }
365
368
370
371 return ID_ERROR;
372}
373
374/**********************************************************************/
378 void *data)
379{
380 struct widget *pwidget;
381
382 if ((pwidget = find_next_widget_at_pos(NULL,
383 button_event->x,
384 button_event->y)) != NULL) {
385 if (get_wstate(pwidget) != FC_WS_DISABLED) {
386 return widget_pressed_action(pwidget);
387 }
388 } else {
389 /* no visible widget at this position -> map click */
390#ifdef UNDER_CE
392#endif
394 /* start counting */
400 mouse_zoom);
401 }
402#ifdef UNDER_CE
403 }
404#endif
405 }
406
407 return ID_ERROR;
408}
409
410/**********************************************************************/
429
430#ifdef UNDER_CE
431 #define SCROLL_MAP_AREA 8
432#else
433 #define SCROLL_MAP_AREA 1
434#endif
435
436/**********************************************************************/
440 void *data)
441{
442 static struct widget *pwidget;
443 struct tile *ptile;
444
445 /* stop evaluating button hold time when moving to another tile in medium
446 * hold state or above */
449 mouse_zoom);
452 }
453 }
454
457 }
458
459#ifndef UNDER_CE
462 }
463#endif /* UNDER_CE */
464
465 if ((pwidget = find_next_widget_at_pos(NULL,
466 motion_event->x,
467 motion_event->y)) != NULL) {
469 if (get_wstate(pwidget) != FC_WS_DISABLED) {
470 widget_selected_action(pwidget);
471 }
472 } else {
473 if (selected_widget) {
475 } else {
477 mouse_zoom));
478 }
479 }
480
482
483 return ID_ERROR;
484}
485
486/**********************************************************************/
514
515/**********************************************************************/
518static bool check_scroll_area(int x, int y)
519{
520 SDL_Rect rect_north = {.x = 0, .y = 0,
521 .w = main_data.map->w, .h = SCROLL_MAP_AREA};
522 SDL_Rect rect_east = {.x = main_data.map->w - SCROLL_MAP_AREA, .y = 0,
523 .w = SCROLL_MAP_AREA, .h = main_data.map->h};
524 SDL_Rect rect_south = {.x = 0, .y = main_data.map->h - SCROLL_MAP_AREA,
525 .w = main_data.map->w, .h = SCROLL_MAP_AREA};
526 SDL_Rect rect_west = {.x = 0, .y = 0,
527 .w = SCROLL_MAP_AREA, .h = main_data.map->h};
528
529 if (is_in_rect_area(x, y, &rect_north)) {
531 if (is_in_rect_area(x, y, &rect_west)) {
533 } else if (is_in_rect_area(x, y, &rect_east)) {
535 } else {
537 }
538 } else if (is_in_rect_area(x, y, &rect_south)) {
540 if (is_in_rect_area(x, y, &rect_west)) {
542 } else if (is_in_rect_area(x, y, &rect_east)) {
544 } else {
546 }
547 } else if (is_in_rect_area(x, y, &rect_east)) {
550 } else if (is_in_rect_area(x, y, &rect_west)) {
553 } else {
555 }
556
557 return is_map_scrolling;
558}
559
560/* ============================ Public ========================== */
561
562/**********************************************************************/
566{
568
569 event.type = user_event_type;
570 event.user.code = EXIT_FROM_EVENT_LOOP;
571 event.user.data1 = NULL;
572 event.user.data2 = NULL;
573
575}
576
577/**********************************************************************/
582{
583 if (event->type == SDL_MOUSEMOTION) {
584 static int x = 0, y = 0;
585
586 if (((MOVE_STEP_X > 0) && (abs(event->motion.x - x) >= MOVE_STEP_X))
587 || ((MOVE_STEP_Y > 0) && (abs(event->motion.y - y) >= MOVE_STEP_Y)) ) {
588 x = event->motion.x;
589 y = event->motion.y;
590 return 1; /* Catch it */
591 } else {
592 return 0; /* Drop it, we've handled it */
593 }
594 }
595
596 return 1;
597}
598
599/**********************************************************************/
603 void (*loop_action)(void *data),
604 Uint16 (*key_down_handler)(SDL_Keysym key, void *data),
605 Uint16 (*key_up_handler)(SDL_Keysym key, void *data),
606 Uint16 (*textinput_handler)(const char *text, void *data),
610 void *data),
612 void *data),
614 void *data),
616 void *data))
617{
618 Uint16 ID;
619 static fc_timeval tv;
620 static fd_set civfdset;
623 static int result;
624
625 ID = ID_ERROR;
627 while (ID == ID_ERROR) {
628 /* ========================================= */
629 /* Net check with 10ms delay event loop */
630 if (net_socket >= 0) {
632
633 if (net_socket >= 0) {
635 }
636
637 tv.tv_sec = 0;
638 tv.tv_usec = 10000; /* 10ms*/
639
640 result = fc_select(net_socket + 1, &civfdset, NULL, NULL, &tv);
641 if (result < 0) {
642 if (errno != EINTR) {
643 break;
644 } else {
645 continue;
646 }
647 } else {
648 if (result > 0) {
649 if ((net_socket >= 0) && FD_ISSET(net_socket, &civfdset)) {
651 }
652 }
653 }
654 } else { /* If connection is not establish */
655 SDL_Delay(10);
656 }
657 /* ========================================= */
658
660
663 }
664
666 if (autoconnect) {
669 } else {
671 }
672
674 }
675
676 if (is_map_scrolling) {
680 }
681 } else {
683 }
684
685 if (widget_info_counter > 0) {
688 }
689
690 /* ========================================= */
691
692 if (loop_action) {
693 loop_action(data);
694 }
695
696 /* ========================================= */
697
698 while (SDL_PollEvent(&main_data.event) == 1) {
699
700 if (main_data.event.type == user_event_type) {
701 switch (main_data.event.user.code) {
702 case NET:
704 break;
705 case ANIM:
709 break;
712 break;
713 case TRY_AUTO_CONNECT:
714 if (try_to_autoconnect()) {
717 }
718 break;
719 case FLUSH:
721 break;
722 case MAP_SCROLL:
724 break;
726 return MAX_ID;
727 break;
728 default:
729 break;
730 }
731
732 } else {
733
734 switch (main_data.event.type) {
735
736 case SDL_QUIT:
737 return MAX_ID;
738 break;
739
740 case SDL_KEYUP:
741 switch (main_data.event.key.keysym.sym) {
742 /* find if Shifts are released */
743 case SDLK_RSHIFT:
744 RSHIFT = FALSE;
745 break;
746 case SDLK_LSHIFT:
747 LSHIFT = FALSE;
748 break;
749 case SDLK_LCTRL:
750 LCTRL = FALSE;
751 break;
752 case SDLK_RCTRL:
753 RCTRL = FALSE;
754 break;
755 case SDLK_LALT:
756 LALT = FALSE;
757 break;
758 default:
759 if (key_up_handler) {
760 ID = key_up_handler(main_data.event.key.keysym, data);
761 }
762 break;
763 }
764 break;
765
766 case SDL_KEYDOWN:
767 switch (main_data.event.key.keysym.sym) {
768#if 0
769 case SDLK_PRINT:
770 fc_snprintf(schot, sizeof(schot), "fc_%05d.bmp", schot_nr++);
771 log_normal(_("Making screenshot %s"), schot);
773 break;
774#endif /* 0 */
775
776 case SDLK_RSHIFT:
777 /* Right Shift is Pressed */
778 RSHIFT = TRUE;
779 break;
780
781 case SDLK_LSHIFT:
782 /* Left Shift is Pressed */
783 LSHIFT = TRUE;
784 break;
785
786 case SDLK_LCTRL:
787 /* Left CTRL is Pressed */
788 LCTRL = TRUE;
789 break;
790
791 case SDLK_RCTRL:
792 /* Right CTRL is Pressed */
793 RCTRL = TRUE;
794 break;
795
796 case SDLK_LALT:
797 /* Left ALT is Pressed */
798 LALT = TRUE;
799 break;
800
801 default:
802 if (key_down_handler) {
803 ID = key_down_handler(main_data.event.key.keysym, data);
804 }
805 break;
806 }
807 break;
808
809 case SDL_TEXTINPUT:
810 if (textinput_handler) {
811 ID = textinput_handler(main_data.event.text.text, data);
812 }
813 break;
814
815 case SDL_FINGERDOWN:
817 ID = finger_down_handler(&main_data.event.tfinger, data);
818 }
819 break;
820
821 case SDL_FINGERUP:
822 if (finger_up_handler) {
823 ID = finger_up_handler(&main_data.event.tfinger, data);
824 }
825 break;
826
827 case SDL_FINGERMOTION:
829 ID = finger_motion_handler(&main_data.event.tfinger, data);
830 }
831 break;
832
836 }
837 break;
838
841 ID = mouse_button_up_handler(&main_data.event.button, data);
842 }
843 break;
844
845 case SDL_MOUSEMOTION:
847 ID = mouse_motion_handler(&main_data.event.motion, data);
848 }
849 break;
850 }
851 }
852 }
853
854 if (ID == ID_ERROR) {
856 struct callback *cb = callback_list_get(callbacks, 0);
857
859 (cb->callback)(cb->data);
860 free(cb);
861 }
862 }
863
865
866#ifdef __EMSCRIPTEN__
867 emscripten_sleep(100);
868#endif
869 }
870
871 return ID;
872}
873
874/* ============ Freeciv native game function =========== */
875
876/**********************************************************************/
893
894/**********************************************************************/
898{
899 struct widget *widget;
900
901 if (C_S_RUNNING == client_state()) {
902 /* Move units window to botton-right corner. */
904 /* Move minimap window to botton-left corner. */
906
907 /* Move cooling/warming icons to botton-right corner. */
910 - (widget->size.w * 2)), widget->size.y);
911
914 - widget->size.w), widget->size.y);
915
919 center_on_something(); /* With redrawing full map. */
921 } else {
923 dirty_all();
924 }
925
926 flush_all();
927}
928
929/**********************************************************************/
936
937/**********************************************************************/
963
964/**********************************************************************/
969{
970 struct option *poption;
971
972#define option_var_set_callback(var, callback) \
973 if ((poption = optset_option_by_name(client_optset, \
974 GUI_SDL_OPTION_STR(var)))) { \
975 option_set_changed_callback(poption, callback); \
976 } else { \
977 log_error("Didn't find option %s!", GUI_SDL_OPTION_STR(var)); \
978 }
979
982#undef option_var_set_callback
983}
984
985/**********************************************************************/
990{
991 int i;
992
993 /* Clear double call */
994 for (i = 0; i <= event_type_max(); i++) {
997 }
998 }
999}
1000
1001/**********************************************************************/
1006int main(int argc, char **argv)
1007{
1008 return client_main(argc, argv, FALSE);
1009}
1010
1011/**********************************************************************/
1015{
1016 log_normal(_("Migrating options from sdl to sdl2 client"));
1017
1018#define MIGRATE_OPTION(opt) gui_options.gui_sdl2_##opt = gui_options.gui_sdl_##opt;
1019
1020 /* Default theme name is never migrated */
1022 MIGRATE_OPTION(screen);
1025
1026#undef MIGRATE_OPTION
1027
1029}
1030
1031/**********************************************************************/
1035int ui_main(int argc, char *argv[])
1036{
1037 Uint32 flags = 0;
1038
1039 if (parse_options(argc, argv)) {
1042 }
1044 if (font_size_parameter > 10) {
1045 GUI_SDL_OPTION(screen) = VIDEO_MODE(640 * font_size_parameter / 10,
1046 480 * font_size_parameter / 10);
1047 }
1048
1050 }
1051
1053 flags |= SDL_WINDOW_FULLSCREEN;
1054 } else {
1055 flags &= ~SDL_WINDOW_FULLSCREEN;
1056 }
1057
1058 log_normal(_("Using Video Output: %s"), SDL_GetCurrentVideoDriver());
1059 if (!set_video_mode(GUI_SDL_OPTION(screen.width),
1060 GUI_SDL_OPTION(screen.height),
1061 flags)) {
1062 return EXIT_FAILURE;
1063 }
1064
1066
1069 __net_user_event.user.code = NET;
1070 __net_user_event.user.data1 = NULL;
1071 __net_user_event.user.data2 = NULL;
1073
1076 __anim_user_event.user.code = EVENT_ERROR;
1077 __anim_user_event.user.data1 = NULL;
1078 __anim_user_event.user.data2 = NULL;
1080
1084 __info_user_event.user.data1 = NULL;
1085 __info_user_event.user.data2 = NULL;
1087
1090 __flush_user_event.user.code = FLUSH;
1091 __flush_user_event.user.data1 = NULL;
1092 __flush_user_event.user.data2 = NULL;
1094
1098 __map_scroll_user_event.user.data1 = NULL;
1099 __map_scroll_user_event.user.data2 = NULL;
1101
1103
1109
1113
1114 load_cursors();
1115
1117
1120
1122
1124
1125 /* This needs correct main_data.screen size */
1127
1129
1130 /* Main game loop */
1136
1138
1140
1142
1145
1147 callbacks = NULL;
1148
1150
1153
1155
1156 del_main_list();
1157
1161
1162 quit_sdl();
1163 }
1164
1165 return EXIT_SUCCESS;
1166}
1167
1168/**********************************************************************/
1171void ui_exit(void)
1172{
1173}
1174
1175/**********************************************************************/
1178enum gui_type get_gui_type(void)
1179{
1180 return GUI_SDL2;
1181}
1182
1183/**********************************************************************/
1187void sound_bell(void)
1188{
1189 log_debug("sound_bell : PORT ME");
1190}
1191
1192/**********************************************************************/
1196{
1197 anim_user_event->user.code = ANIM;
1199}
1200
1201/**********************************************************************/
1208
1209/**********************************************************************/
1213void add_net_input(int sock)
1214{
1215 log_debug("Connection UP (%d)", sock);
1216 net_socket = sock;
1219}
1220
1221/**********************************************************************/
1225{
1226 log_debug("Connection DOWN... ");
1227 net_socket = (-1);
1231}
1232
1233/**********************************************************************/
1238void add_idle_callback(void (callback)(void *), void *data)
1239{
1240 if (callbacks != NULL) {
1241 struct callback *cb = fc_malloc(sizeof(*cb));
1242
1243 cb->callback = callback;
1244 cb->data = data;
1245
1247 }
1248}
1249
1250/**********************************************************************/
1254{}
1255
1256/**********************************************************************/
1260{}
1261
1262/**********************************************************************/
1265void editgui_popup_properties(const struct tile_list *tiles, int objtype)
1266{}
1267
1268/**********************************************************************/
1272{}
1273
1274/**********************************************************************/
1277void editgui_notify_object_changed(int objtype, int object_id, bool removal)
1278{}
1279
1280/**********************************************************************/
1284{}
1285
1286/**********************************************************************/
1289void gui_update_font(const char *font_name, const char *font_value)
1290{
1291#define CHECK_FONT(client_font, action) \
1292 do { \
1293 if (strcmp(#client_font, font_name) == 0) { \
1294 char *end; \
1295 long size = strtol(font_value, &end, 10); \
1296 if (end && *end == '\0' && size > 0) { \
1297 *client_font_sizes[client_font] = size; \
1298 action; \
1299 } \
1300 } \
1301 } while (FALSE)
1302
1305 /* FONT_REQTREE_TEXT not used yet */
1306
1307#undef CHECK_FONT
1308}
1309
1310/**********************************************************************/
1319
1320/**********************************************************************/
1328
1329/**********************************************************************/
1333{
1334 /* PORTME */
1335}
1336
1337/**********************************************************************/
1340bool flush_event(void)
1341{
1342 return SDL_PushEvent(flush_user_event) >= 0;
1343}
#define city_owner(_pcity_)
Definition city.h:563
void popup_city_dialog(struct city *pcity)
double real_timer_callback(void)
int client_main(int argc, char *argv[], bool postpone_tileset)
struct civclient client
enum client_states client_state(void)
void send_report_request(enum report_type type)
void start_quitting(void)
void set_client_state(enum client_states newstate)
@ C_S_DISCONNECTED
Definition client_main.h:45
@ C_S_RUNNING
Definition client_main.h:47
void center_on_something(void)
Definition climisc.c:430
double try_to_autoconnect(void)
Definition clinet.c:498
void input_from_server(int fd)
Definition clinet.c:411
char * incite_cost
Definition comments.c:75
@ REPORT_WONDERS_OF_THE_WORLD
Definition conn_types.h:50
@ REPORT_DEMOGRAPHIC
Definition conn_types.h:53
@ REPORT_ACHIEVEMENTS
Definition conn_types.h:54
@ REPORT_TOP_CITIES
Definition conn_types.h:52
struct unit_list * get_units_in_focus(void)
Definition control.c:177
void key_end_turn(void)
Definition control.c:3312
struct unit * head_of_units_in_focus(void)
Definition control.c:410
void control_mouse_cursor(struct tile *ptile)
Definition control.c:1215
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit * punit
Definition dialogs_g.h:74
int objtype
Definition editgui_g.h:28
editgui_notify_object_changed
Definition editgui_g.h:27
enum event_type event
Definition events.c:81
bool is_option(const char *option_name, char *option)
Definition fc_cmdline.c:112
char * get_option_malloc(const char *option_name, char **argv, int *i, int argc, bool gc)
Definition fc_cmdline.c:50
void fc_fprintf(FILE *stream, const char *format,...) fc__attribute((__format__(__printf__
#define _(String)
Definition fcintl.h:67
void city_report_dialog_popup(bool raise)
Definition cityrep.c:292
void diplomacy_dialog_init(void)
Definition diplodlg.c:1206
void diplomacy_dialog_done(void)
Definition diplodlg.c:1215
void load_cursors(void)
Definition graphics.c:78
int ui_main(int argc, char **argv)
Definition gui_main.c:1887
const char * client_string
Definition gui_main.c:105
static void print_usage(void)
Definition gui_main.c:265
#define option_var_set_callback(var, callback)
void ui_exit(void)
Definition gui_main.c:2066
enum gui_type get_gui_type(void)
Definition gui_main.c:2077
int main(int argc, char **argv)
Definition gui_main.c:1765
void ui_init(void)
Definition gui_main.c:1755
void add_idle_callback(void(callback)(void *), void *data)
Definition gui_main.c:2405
void options_extra_init(void)
Definition gui_main.c:2479
void insert_client_build_info(char *outbuf, size_t outlen)
Definition gui_main.c:2539
void remove_net_input(void)
Definition gui_main.c:2311
void sound_bell(void)
Definition gui_main.c:2085
const char *const gui_character_encoding
Definition gui_main.c:161
void add_net_input(int sock)
Definition gui_main.c:2293
static bool parse_options(int argc, char **argv)
Definition gui_main.c:286
#define MIGRATE_OPTION(opt)
const bool gui_use_transliteration
Definition gui_main.c:162
void intel_dialog_done(void)
Definition inteldlg.c:128
void intel_dialog_init(void)
Definition inteldlg.c:119
void flush_dirty(void)
Definition mapview.c:468
void update_info_label(void)
Definition mapview.c:138
void dirty_all(void)
Definition mapview.c:456
void update_unit_info_label(struct unit_list *punits)
Definition mapview.c:275
void update_city_descriptions(void)
Definition mapview.c:488
void update_mouse_cursor(enum cursor_type new_cursor_type)
Definition mapview.c:257
void meswin_dialog_popdown(void)
Definition messagewin.c:432
void meswin_dialog_popup(bool raise)
Definition messagewin.c:417
bool meswin_dialog_is_open(void)
Definition messagewin.c:443
void units_report_dialog_popup(bool raise)
Definition repodlgs.c:1768
void popup_spaceship_dialog(struct player *pplayer)
void popup_input_line(void)
Definition chatline.c:358
bool set_video_mode(unsigned width, unsigned height, unsigned flags_in)
Definition graphics.c: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 void migrate_options_from_sdl(void)
Definition gui_main.c:1014
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
Uint32 sdl2_client_flags
Definition gui_main.c:101
static SDL_Event * flush_user_event
Definition gui_main.c:141
struct callback_list * callbacks
Definition gui_main.c:170
USER_EVENT_ID
Definition gui_main.c:150
@ NET
Definition gui_main.c:152
@ ANIM
Definition gui_main.c:153
@ TRY_AUTO_CONNECT
Definition gui_main.c:154
@ MAP_SCROLL
Definition gui_main.c:157
@ FLUSH
Definition gui_main.c:156
@ EVENT_ERROR
Definition gui_main.c:151
@ EXIT_FROM_EVENT_LOOP
Definition gui_main.c:158
@ SHOW_WIDGET_INFO_LABEL
Definition gui_main.c:155
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_SWRENDERER
Definition gui_main.h:64
#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
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_sdl2_migrated_from_sdl
Definition options.h:136
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