Freeciv-3.3: /fast/freeciv/nightly/main/client/gui-sdl3/gui_main.c Source File

Freeciv-3.3

Loading...
Searching...
No Matches
gui_main.c
Go to the documentation of this file.
1/***********************************************************************
2 Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
6 any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12***********************************************************************/
13
14/***********************************************************************
15 gui_main.c - description
16 -------------------
17 begin : Sun Jun 30 2002
18 copyright : (C) 2002 by Rafał Bursig
19 email : Rafał Bursig <bursig@poczta.fm>
20***********************************************************************/
21
22#ifdef HAVE_CONFIG_H
23#include <fc_config.h>
24#endif
25
26#include "fc_prehdrs.h"
27
28#include <errno.h>
29
30#ifdef HAVE_LOCALE_H
31#include <locale.h>
32#endif
33
34#ifdef HAVE_UNISTD_H
35#include <unistd.h>
36#endif
37
38#ifdef __EMSCRIPTEN__
39#include <emscripten.h>
40#endif
41
42/* SDL3 */
43#include <SDL3/SDL.h>
44
45/* utility */
46#include "fc_cmdline.h"
47#include "fciconv.h"
48#include "fcintl.h"
49#include "log.h"
50#include "netintf.h"
51
52/* common */
53#include "unitlist.h"
54
55/* client */
56#include "client_main.h"
57#include "climisc.h"
58#include "clinet.h"
59#include "editgui_g.h"
60#include "spaceshipdlg_g.h"
61#include "tilespec.h"
62#include "update_queue.h"
63#include "zoom.h"
64
65/* gui-sdl3 */
66#include "chatline.h"
67#include "citydlg.h"
68#include "cityrep.h"
69#include "diplodlg.h"
70#include "graphics.h"
71#include "gui_id.h"
72#include "gui_mouse.h"
73#include "gui_tilespec.h"
74#include "inteldlg.h"
75#include "mapctrl.h"
76#include "mapview.h"
77#include "menu.h"
78#include "messagewin.h"
79#include "optiondlg.h"
80#include "repodlgs.h"
81#include "themespec.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
89 const 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 */
94 const char * const gui_character_encoding = "UTF-8";
95 const bool gui_use_transliteration = FALSE;
96
97 Uint32 sdl3_client_flags = 0;
98
99 Uint32 widget_info_counter = 0;
100 int MOVE_STEP_X = DEFAULT_MOVE_STEP;
101 int MOVE_STEP_Y = DEFAULT_MOVE_STEP;
102extern bool draw_goto_patrol_lines;
103 bool is_unit_move_blocked;
104 bool LSHIFT;
105 bool RSHIFT;
106 bool LCTRL;
107 bool RCTRL;
108 bool LALT;
109 static int city_names_font_size = 10;
110 static int city_productions_font_size = 10;
111 int *client_font_sizes[FONT_COUNT] = {
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
117 static unsigned font_size_parameter = 0;
118
119/* ================================ Private ============================ */
120 static int net_socket = -1;
121 static bool autoconnect = FALSE;
122 static bool is_map_scrolling = FALSE;
123 static enum direction8 scroll_dir;
124
125 static struct finger_behavior finger_behavior;
126 static struct mouse_button_behavior button_behavior;
127
128 static SDL_Event __net_user_event;
129 static SDL_Event __anim_user_event;
130 static SDL_Event __info_user_event;
131 static SDL_Event __flush_user_event;
132 static SDL_Event __map_scroll_user_event;
133
134 static SDL_Event *net_user_event = NULL;
135 static SDL_Event *anim_user_event = NULL;
136 static SDL_Event *info_user_event = NULL;
137 static SDL_Event *flush_user_event = NULL;
138 static SDL_Event *map_scroll_user_event = NULL;
139
140static void print_usage(void);
141static bool parse_options(int argc, char **argv);
142static bool check_scroll_area(int x, int y);
143
144 int user_event_type;
145
146 enum USER_EVENT_ID {
147 EVENT_ERROR = 0,
148 NET,
149 ANIM,
150 TRY_AUTO_CONNECT,
151 SHOW_WIDGET_INFO_LABEL,
152 FLUSH,
153 MAP_SCROLL,
154 EXIT_FROM_EVENT_LOOP
155};
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
166 struct callback_list *callbacks = NULL;
167
168/* =========================================================== */
169
170/**********************************************************************/
174 static void print_usage(void)
175{
176 /* Add client-specific usage information here */
177 fc_fprintf(stderr,
178 _(" -f, --fullscreen\tStart Client in Fullscreen mode\n"));
179 fc_fprintf(stderr,
180 _(" -F, --Font SIZE\tUse SIZE as the base font size\n"));
181 fc_fprintf(stderr, _(" -s, --swrenderer\tUse SW renderer\n"));
182 fc_fprintf(stderr, _(" -t, --theme THEME\tUse GUI theme THEME\n"));
183
184 /* TRANS: No full stop after the URL, could cause confusion. */
185 fc_fprintf(stderr, _("Report bugs at %s\n"), BUG_URL);
186}
187
188/**********************************************************************/
191 static bool parse_options(int argc, char **argv)
192{
193 int i = 1;
194 char *option = NULL;
195
196 while (i < argc) {
197 if (is_option("--help", argv[i])) {
198 print_usage();
199
200 return FALSE;
201 } else if (is_option("--fullscreen", argv[i])) {
202 GUI_SDL_OPTION(fullscreen) = TRUE;
203 } else if (is_option("--swrenderer", argv[i])) {
204 sdl3_client_flags |= CF_SWRENDERER;
205 } else if ((option = get_option_malloc("--Font", argv, &i, argc, FALSE))) {
206 if (!str_to_uint(option, &font_size_parameter)) {
207 fc_fprintf(stderr, _("Invalid font size %s"), option);
208 exit(EXIT_FAILURE);
209 }
210 free(option);
211 } else if ((option = get_option_malloc("--theme", argv, &i, argc, FALSE))) {
212 sz_strlcpy(GUI_SDL_OPTION(default_theme_name), option);
213 free(option);
214 } else {
215 fc_fprintf(stderr, _("Unrecognized option: \"%s\"\n"), argv[i]);
216
217 exit(EXIT_FAILURE);
218 }
219
220 i++;
221 }
222
223 return TRUE;
224}
225
226/**********************************************************************/
229 static Uint16 main_key_down_handler(SDL_Keysym key, void *data)
230{
231 static struct widget *pwidget;
232
233 if ((pwidget = find_next_widget_for_key(NULL, key)) != NULL) {
234 return widget_pressed_action(pwidget);
235 } else {
236 if (key.sym == SDLK_TAB) {
237 /* input */
238 popup_input_line();
239 } else {
240 if (map_event_handler(key)
241 && C_S_RUNNING == client_state()) {
242 switch (key.sym) {
243 case SDLK_RETURN:
244 case SDLK_KP_ENTER:
245 if (LSHIFT || RSHIFT) {
246 disable_focus_animation();
247 key_end_turn();
248 } else {
249 struct unit *punit;
250 struct city *pcity;
251
252 if (NULL != (punit = head_of_units_in_focus())
253 && (pcity = tile_city(unit_tile(punit))) != NULL
254 && city_owner(pcity) == client.conn.playing) {
255 popup_city_dialog(pcity);
256 }
257 }
258 return ID_ERROR;
259
260 case SDLK_F2:
261 units_report_dialog_popup(FALSE);
262 return ID_ERROR;
263
264 case SDLK_F4:
265 city_report_dialog_popup(FALSE);
266 return ID_ERROR;
267
268 case SDLK_F7:
269 send_report_request(REPORT_WONDERS_OF_THE_WORLD);
270 return ID_ERROR;
271
272 case SDLK_F8:
273 send_report_request(REPORT_TOP_CITIES);
274 return ID_ERROR;
275
276 case SDLK_F9:
277 if (meswin_dialog_is_open()) {
278 meswin_dialog_popdown();
279 } else {
280 meswin_dialog_popup(TRUE);
281 }
282 flush_dirty();
283 return ID_ERROR;
284
285 case SDLK_F11:
286 send_report_request(REPORT_DEMOGRAPHIC);
287 return ID_ERROR;
288
289 case SDLK_F12:
290 popup_spaceship_dialog(client.conn.playing);
291 return ID_ERROR;
292
293 case SDLK_ASTERISK:
294 send_report_request(REPORT_ACHIEVEMENTS);
295 return ID_ERROR;
296
297 default:
298 return ID_ERROR;
299 }
300 }
301 }
302 }
303
304 return ID_ERROR;
305}
306
307/**********************************************************************/
310 static Uint16 main_key_up_handler(SDL_Keysym key, void *data)
311{
312 if (selected_widget) {
313 unselect_widget_action();
314 }
315
316 return ID_ERROR;
317}
318/**********************************************************************/
321 static Uint16 main_finger_down_handler(SDL_TouchFingerEvent *touch_event,
322 void *data)
323{
324 struct widget *pwidget;
325 /* Touch event coordinates are normalized (0...1). */
326 int x = touch_event->x * main_window_width();
327 int y = touch_event->y * main_window_height();
328
329 if ((pwidget = find_next_widget_at_pos(NULL, x, y)) != NULL) {
330 if (get_wstate(pwidget) != FC_WS_DISABLED) {
331 return widget_pressed_action(pwidget);
332 }
333 } else {
334 /* No visible widget at this position; map pressed. */
335 if (!finger_behavior.counting) {
336 /* Start counting. */
337 finger_behavior.counting = TRUE;
338 finger_behavior.finger_down_ticks = SDL_GetTicks();
339 finger_behavior.event = *touch_event;
340 finger_behavior.hold_state = MB_HOLD_SHORT;
341 finger_behavior.ptile = canvas_pos_to_tile(x, y, mouse_zoom);
342 }
343 }
344 return ID_ERROR;
345}
346/**********************************************************************/
349 static Uint16 main_finger_up_handler(SDL_TouchFingerEvent *touch_event,
350 void *data)
351{
352 /* Touch event coordinates are normalized (0...1). */
353 int x = touch_event->x * main_window_width();
354 int y = touch_event->y * main_window_height();
355 /* Screen wasn't pressed over a widget. */
356 if (finger_behavior.finger_down_ticks
357 && !find_next_widget_at_pos(NULL, x, y)) {
358 finger_behavior.event = *touch_event;
359 finger_up_on_map(&finger_behavior);
360 }
361
362 finger_behavior.counting = FALSE;
363 finger_behavior.finger_down_ticks = 0;
364
365 is_map_scrolling = FALSE;
366
367 return ID_ERROR;
368}
369
370/**********************************************************************/
373 static Uint16 main_mouse_button_down_handler(SDL_MouseButtonEvent *button_event,
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
387 if (!check_scroll_area(button_event->x, button_event->y)) {
388#endif
389 if (!button_behavior.counting) {
390 /* start counting */
391 button_behavior.counting = TRUE;
392 button_behavior.button_down_ticks = SDL_GetTicks();
393 *button_behavior.event = *button_event;
394 button_behavior.hold_state = MB_HOLD_SHORT;
395 button_behavior.ptile = canvas_pos_to_tile(button_event->x, button_event->y,
396 mouse_zoom);
397 }
398#ifdef UNDER_CE
399 }
400#endif
401 }
402
403 return ID_ERROR;
404}
405
406/**********************************************************************/
409 static Uint16 main_mouse_button_up_handler(SDL_MouseButtonEvent *button_event,
410 void *data)
411{
412 if (button_behavior.button_down_ticks /* button wasn't pressed over a widget */
413 && !find_next_widget_at_pos(NULL, button_event->x, button_event->y)) {
414 *button_behavior.event = *button_event;
415 button_up_on_map(&button_behavior);
416 }
417
418 button_behavior.counting = FALSE;
419 button_behavior.button_down_ticks = 0;
420
421 is_map_scrolling = FALSE;
422
423 return ID_ERROR;
424}
425
426#ifdef UNDER_CE
427 #define SCROLL_MAP_AREA 8
428#else
429 #define SCROLL_MAP_AREA 1
430#endif
431
432/**********************************************************************/
435 static Uint16 main_mouse_motion_handler(SDL_MouseMotionEvent *motion_event,
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 */
443 if (button_behavior.counting && (button_behavior.hold_state >= MB_HOLD_MEDIUM)) {
444 ptile = canvas_pos_to_tile(motion_event->x, motion_event->y,
445 mouse_zoom);
446 if (tile_index(ptile) != tile_index(button_behavior.ptile)) {
447 button_behavior.counting = FALSE;
448 }
449 }
450
451 if (draw_goto_patrol_lines) {
452 update_line(motion_event->x, motion_event->y);
453 }
454
455#ifndef UNDER_CE
456 if (GUI_SDL_OPTION(fullscreen)) {
457 check_scroll_area(motion_event->x, motion_event->y);
458 }
459#endif /* UNDER_CE */
460
461 if ((pwidget = find_next_widget_at_pos(NULL,
462 motion_event->x,
463 motion_event->y)) != NULL) {
464 update_mouse_cursor(CURSOR_DEFAULT);
465 if (get_wstate(pwidget) != FC_WS_DISABLED) {
466 widget_selected_action(pwidget);
467 }
468 } else {
469 if (selected_widget) {
470 unselect_widget_action();
471 } else {
472 control_mouse_cursor(canvas_pos_to_tile(motion_event->x, motion_event->y,
473 mouse_zoom));
474 }
475 }
476
477 draw_mouse_cursor();
478
479 return ID_ERROR;
480}
481
482/**********************************************************************/
486 static void update_button_hold_state(void)
487{
488 /* button pressed */
489 if (button_behavior.counting) {
490 if (((SDL_GetTicks() - button_behavior.button_down_ticks) >= MB_MEDIUM_HOLD_DELAY)
491 && ((SDL_GetTicks() - button_behavior.button_down_ticks) < MB_LONG_HOLD_DELAY)) {
492
493 if (button_behavior.hold_state != MB_HOLD_MEDIUM) {
494 button_behavior.hold_state = MB_HOLD_MEDIUM;
495 button_down_on_map(&button_behavior);
496 }
497
498 } else if (((SDL_GetTicks() - button_behavior.button_down_ticks)
499 >= MB_LONG_HOLD_DELAY)) {
500
501 if (button_behavior.hold_state != MB_HOLD_LONG) {
502 button_behavior.hold_state = MB_HOLD_LONG;
503 button_down_on_map(&button_behavior);
504 }
505 }
506 }
507
508 return;
509}
510
511/**********************************************************************/
514 static 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)) {
526 is_map_scrolling = TRUE;
527 if (is_in_rect_area(x, y, &rect_west)) {
528 scroll_dir = DIR8_NORTHWEST;
529 } else if (is_in_rect_area(x, y, &rect_east)) {
530 scroll_dir = DIR8_NORTHEAST;
531 } else {
532 scroll_dir = DIR8_NORTH;
533 }
534 } else if (is_in_rect_area(x, y, &rect_south)) {
535 is_map_scrolling = TRUE;
536 if (is_in_rect_area(x, y, &rect_west)) {
537 scroll_dir = DIR8_SOUTHWEST;
538 } else if (is_in_rect_area(x, y, &rect_east)) {
539 scroll_dir = DIR8_SOUTHEAST;
540 } else {
541 scroll_dir = DIR8_SOUTH;
542 }
543 } else if (is_in_rect_area(x, y, &rect_east)) {
544 is_map_scrolling = TRUE;
545 scroll_dir = DIR8_EAST;
546 } else if (is_in_rect_area(x, y, &rect_west)) {
547 is_map_scrolling = TRUE;
548 scroll_dir = DIR8_WEST;
549 } else {
550 is_map_scrolling = FALSE;
551 }
552
553 return is_map_scrolling;
554}
555
556/* ============================ Public ========================== */
557
558/**********************************************************************/
561 void force_exit_from_event_loop(void)
562{
563 SDL_Event event;
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
570 SDL_PushEvent(&event);
571}
572
573/**********************************************************************/
577 int FilterMouseMotionEvents(void *data, SDL_Event *event)
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 1; /* Catch it */
587 } else {
588 return 0; /* Drop it, we've handled it */
589 }
590 }
591
592 return 1;
593}
594
595/**********************************************************************/
598 Uint16 gui_event_loop(void *data,
599 void (*loop_action)(void *data),
600 Uint16 (*key_down_handler)(SDL_Keysym key, void *data),
601 Uint16 (*key_up_handler)(SDL_Keysym key, void *data),
602 Uint16 (*textinput_handler)(char *text, void *data),
603 Uint16 (*finger_down_handler)(SDL_TouchFingerEvent *touch_event, void *data),
604 Uint16 (*finger_up_handler)(SDL_TouchFingerEvent *touch_event, void *data),
605 Uint16 (*finger_motion_handler)(SDL_TouchFingerEvent *touch_event,
606 void *data),
607 Uint16 (*mouse_button_down_handler)(SDL_MouseButtonEvent *button_event,
608 void *data),
609 Uint16 (*mouse_button_up_handler)(SDL_MouseButtonEvent *button_event,
610 void *data),
611 Uint16 (*mouse_motion_handler)(SDL_MouseMotionEvent *motion_event,
612 void *data))
613{
614 Uint16 ID;
615 static fc_timeval tv;
616 static fd_set civfdset;
617 Uint32 t_current, t_last_unit_anim, t_last_map_scrolling;
618 Uint32 real_timer_next_call;
619 static int result;
620
621 ID = ID_ERROR;
622 t_last_map_scrolling = t_last_unit_anim = real_timer_next_call = SDL_GetTicks();
623 while (ID == ID_ERROR) {
624 /* ========================================= */
625 /* Net check with 10ms delay event loop */
626 if (net_socket >= 0) {
627 FD_ZERO(&civfdset);
628
629 if (net_socket >= 0) {
630 FD_SET(net_socket, &civfdset);
631 }
632
633 tv.tv_sec = 0;
634 tv.tv_usec = 10000; /* 10ms*/
635
636 result = fc_select(net_socket + 1, &civfdset, NULL, NULL, &tv);
637 if (result < 0) {
638 if (errno != EINTR) {
639 break;
640 } else {
641 continue;
642 }
643 } else {
644 if (result > 0) {
645 if ((net_socket >= 0) && FD_ISSET(net_socket, &civfdset)) {
646 SDL_PushEvent(net_user_event);
647 }
648 }
649 }
650 } else { /* If connection is not establish */
651 SDL_Delay(10);
652 }
653 /* ========================================= */
654
655 t_current = SDL_GetTicks();
656
657 if (t_current > real_timer_next_call) {
658 real_timer_next_call = t_current + (real_timer_callback() * 1000);
659 }
660
661 if ((t_current - t_last_unit_anim) > UNITS_TIMER_INTERVAL) {
662 if (autoconnect) {
663 widget_info_counter++;
664 SDL_PushEvent(anim_user_event);
665 } else {
666 SDL_PushEvent(anim_user_event);
667 }
668
669 t_last_unit_anim = SDL_GetTicks();
670 }
671
672 if (is_map_scrolling) {
673 if ((t_current - t_last_map_scrolling) > MAP_SCROLL_TIMER_INTERVAL) {
674 SDL_PushEvent(map_scroll_user_event);
675 t_last_map_scrolling = SDL_GetTicks();
676 }
677 } else {
678 t_last_map_scrolling = SDL_GetTicks();
679 }
680
681 if (widget_info_counter > 0) {
682 SDL_PushEvent(info_user_event);
683 widget_info_counter = 0;
684 }
685
686 /* ========================================= */
687
688 if (loop_action) {
689 loop_action(data);
690 }
691
692 /* ========================================= */
693
694 while (SDL_PollEvent(&main_data.event) == 1) {
695
696 if (main_data.event.type == user_event_type) {
697 switch (main_data.event.user.code) {
698 case NET:
699 input_from_server(net_socket);
700 break;
701 case ANIM:
702 update_button_hold_state();
703 animate_mouse_cursor();
704 draw_mouse_cursor();
705 break;
706 case SHOW_WIDGET_INFO_LABEL:
707 draw_widget_info_label();
708 break;
709 case TRY_AUTO_CONNECT:
710 if (try_to_autoconnect()) {
711 info_user_event->user.code = SHOW_WIDGET_INFO_LABEL;
712 autoconnect = FALSE;
713 }
714 break;
715 case FLUSH:
716 unqueue_flush();
717 break;
718 case MAP_SCROLL:
719 scroll_mapview(scroll_dir);
720 break;
721 case EXIT_FROM_EVENT_LOOP:
722 return MAX_ID;
723 break;
724 default:
725 break;
726 }
727
728 } else {
729
730 switch (main_data.event.type) {
731
732 case SDL_EVENT_QUIT:
733 return MAX_ID;
734 break;
735
736 case SDL_EVENT_KEY_UP:
737 switch (main_data.event.key.keysym.sym) {
738 /* find if Shifts are released */
739 case SDLK_RSHIFT:
740 RSHIFT = FALSE;
741 break;
742 case SDLK_LSHIFT:
743 LSHIFT = FALSE;
744 break;
745 case SDLK_LCTRL:
746 LCTRL = FALSE;
747 break;
748 case SDLK_RCTRL:
749 RCTRL = FALSE;
750 break;
751 case SDLK_LALT:
752 LALT = FALSE;
753 break;
754 default:
755 if (key_up_handler) {
756 ID = key_up_handler(main_data.event.key.keysym, data);
757 }
758 break;
759 }
760 break;
761
762 case SDL_EVENT_KEY_DOWN:
763 switch (main_data.event.key.keysym.sym) {
764#if 0
765 case SDLK_PRINT:
766 fc_snprintf(schot, sizeof(schot), "fc_%05d.bmp", schot_nr++);
767 log_normal(_("Making screenshot %s"), schot);
768 SDL_SaveBMP(main_data.screen, schot);
769 break;
770#endif /* 0 */
771
772 case SDLK_RSHIFT:
773 /* Right Shift is Pressed */
774 RSHIFT = TRUE;
775 break;
776
777 case SDLK_LSHIFT:
778 /* Left Shift is Pressed */
779 LSHIFT = TRUE;
780 break;
781
782 case SDLK_LCTRL:
783 /* Left CTRL is Pressed */
784 LCTRL = TRUE;
785 break;
786
787 case SDLK_RCTRL:
788 /* Right CTRL is Pressed */
789 RCTRL = TRUE;
790 break;
791
792 case SDLK_LALT:
793 /* Left ALT is Pressed */
794 LALT = TRUE;
795 break;
796
797 default:
798 if (key_down_handler) {
799 ID = key_down_handler(main_data.event.key.keysym, data);
800 }
801 break;
802 }
803 break;
804
805 case SDL_EVENT_TEXT_INPUT:
806 if (textinput_handler) {
807 ID = textinput_handler(main_data.event.text.text, data);
808 }
809 break;
810
811 case SDL_EVENT_FINGER_DOWN:
812 if (finger_down_handler) {
813 ID = finger_down_handler(&main_data.event.tfinger, data);
814 }
815 break;
816
817 case SDL_EVENT_FINGER_UP:
818 if (finger_up_handler) {
819 ID = finger_up_handler(&main_data.event.tfinger, data);
820 }
821 break;
822
823 case SDL_EVENT_FINGER_MOTION:
824 if (finger_motion_handler) {
825 ID = finger_motion_handler(&main_data.event.tfinger, data);
826 }
827 break;
828
829 case SDL_EVENT_MOUSE_BUTTON_DOWN:
830 if (mouse_button_down_handler) {
831 ID = mouse_button_down_handler(&main_data.event.button, data);
832 }
833 break;
834
835 case SDL_EVENT_MOUSE_BUTTON_UP:
836 if (mouse_button_up_handler) {
837 ID = mouse_button_up_handler(&main_data.event.button, data);
838 }
839 break;
840
841 case SDL_EVENT_MOUSE_MOTION:
842 if (mouse_motion_handler) {
843 ID = mouse_motion_handler(&main_data.event.motion, data);
844 }
845 break;
846 }
847 }
848 }
849
850 if (ID == ID_ERROR) {
851 if (callbacks && callback_list_size(callbacks) > 0) {
852 struct callback *cb = callback_list_get(callbacks, 0);
853
854 callback_list_remove(callbacks, cb);
855 (cb->callback)(cb->data);
856 free(cb);
857 }
858 }
859
860 update_main_screen();
861
862#ifdef __EMSCRIPTEN__
863 emscripten_sleep(100);
864#endif
865 }
866
867 return ID;
868}
869
870/* ============ Freeciv native game function =========== */
871
872/**********************************************************************/
875 void ui_init(void)
876{
877 Uint32 sdl_flags;
878
879 button_behavior.counting = FALSE;
880 button_behavior.button_down_ticks = 0;
881 button_behavior.hold_state = MB_HOLD_SHORT;
882 button_behavior.event = fc_calloc(1, sizeof(SDL_MouseButtonEvent));
883
884 sdl3_client_flags = 0;
885 sdl_flags = SDL_INIT_VIDEO;
886
887 init_sdl(sdl_flags);
888}
889
890/**********************************************************************/
893 static void real_resize_window_callback(void *data)
894{
895 struct widget *widget;
896
897 if (C_S_RUNNING == client_state()) {
898 /* Move units window to botton-right corner. */
899 set_new_unitinfo_window_pos();
900 /* Move minimap window to botton-left corner. */
901 set_new_minimap_window_pos();
902
903 /* Move cooling/warming icons to botton-right corner. */
904 widget = get_widget_pointer_from_main_list(ID_WARMING_ICON);
905 widget_set_position(widget, (main_window_width() - adj_size(10)
906 - (widget->size.w * 2)), widget->size.y);
907
908 widget = get_widget_pointer_from_main_list(ID_COOLING_ICON);
909 widget_set_position(widget, (main_window_width() - adj_size(10)
910 - widget->size.w), widget->size.y);
911
912 map_canvas_resized(main_window_width(), main_window_height());
913 update_info_label();
914 update_unit_info_label(get_units_in_focus());
915 center_on_something(); /* With redrawing full map. */
916 update_order_widgets();
917 } else {
918 draw_intro_gfx();
919 dirty_all();
920 }
921
922 flush_all();
923}
924
925/**********************************************************************/
928 static void resize_window_callback(struct option *poption)
929{
930 update_queue_add(real_resize_window_callback, NULL);
931}
932
933/**********************************************************************/
936 static void fullscreen_callback(struct option *poption)
937{
938 const SDL_DisplayMode *mode;
939
940 if (GUI_SDL_OPTION(fullscreen)) {
941 SDL_SetWindowFullscreen(main_data.screen, SDL_WINDOW_FULLSCREEN);
942 } else {
943 SDL_SetWindowFullscreen(main_data.screen, 0);
944 }
945
946 mode = SDL_GetWindowFullscreenMode(main_data.screen);
947
948 if (!create_surfaces(mode->w, mode->h)) {
949 /* Try to revert */
950 if (!GUI_SDL_OPTION(fullscreen)) {
951 SDL_SetWindowFullscreen(main_data.screen, SDL_WINDOW_FULLSCREEN);
952 } else {
953 SDL_SetWindowFullscreen(main_data.screen, 0);
954 }
955 }
956
957 update_queue_add(real_resize_window_callback, NULL);
958}
959
960/**********************************************************************/
964 void options_extra_init(void)
965{
966 struct option *poption;
967
968#define option_var_set_callback(var, callback) \
969 if ((poption = optset_option_by_name(client_optset, \
970 GUI_SDL_OPTION_STR(var)))) { \
971 option_set_changed_callback(poption, callback); \
972 } else { \
973 log_error("Didn't find option %s!", GUI_SDL_OPTION_STR(var)); \
974 }
975
976 option_var_set_callback(fullscreen, fullscreen_callback);
977 option_var_set_callback(screen, resize_window_callback);
978#undef option_var_set_callback
979}
980
981/**********************************************************************/
985 static void clear_double_messages_call(void)
986{
987 int i;
988
989 /* Clear double call */
990 for (i = 0; i <= event_type_max(); i++) {
991 if (messages_where[i] & MW_MESSAGES) {
992 messages_where[i] &= ~MW_OUTPUT;
993 }
994 }
995}
996
997/**********************************************************************/
1002 int main(int argc, char **argv)
1003{
1004 return client_main(argc, argv, FALSE);
1005}
1006
1007/**********************************************************************/
1010 static void migrate_options_from_sdl2(void)
1011{
1012 log_normal(_("Migrating options from sdl2 to sdl3 client"));
1013
1014#define MIGRATE_OPTION(opt) gui_options.gui_sdl3_##opt = gui_options.gui_sdl2_##opt;
1015#define MIGRATE_STR_OPTION(opt) \
1016 strncpy(gui_options.gui_sdl3_##opt, gui_options.gui_sdl2_##opt, \
1017 sizeof(gui_options.gui_sdl3_##opt));
1018
1019 /* Default theme name is never migrated */
1020 MIGRATE_OPTION(fullscreen);
1021 MIGRATE_OPTION(screen);
1022 MIGRATE_OPTION(swrenderer);
1023 MIGRATE_OPTION(do_cursor_animation);
1024 MIGRATE_OPTION(use_color_cursors);
1025 MIGRATE_STR_OPTION(font_city_names);
1026 MIGRATE_STR_OPTION(font_city_productions);
1027 MIGRATE_OPTION(use_theme_font_size);
1028 MIGRATE_OPTION(font_size);
1029
1030#undef MIGRATE_OPTION
1031
1032 gui_options.gui_sdl3_migrated_from_sdl2 = TRUE;
1033}
1034
1035/**********************************************************************/
1039 int ui_main(int argc, char *argv[])
1040{
1041 Uint32 flags = 0;
1042
1043 if (parse_options(argc, argv)) {
1044 if (!gui_options.gui_sdl3_migrated_from_sdl2) {
1045 migrate_options_from_sdl2();
1046 }
1047 if (!GUI_SDL_OPTION(default_screen_size_set)) {
1048 if (font_size_parameter > 10) {
1049 GUI_SDL_OPTION(screen) = VIDEO_MODE(640 * font_size_parameter / 10,
1050 480 * font_size_parameter / 10);
1051 }
1052
1053 GUI_SDL_OPTION(default_screen_size_set) = TRUE;
1054 }
1055
1056 if (GUI_SDL_OPTION(fullscreen)) {
1057 flags |= SDL_WINDOW_FULLSCREEN;
1058 } else {
1059 flags &= ~SDL_WINDOW_FULLSCREEN;
1060 }
1061
1062 log_normal(_("Using Video Output: %s"), SDL_GetCurrentVideoDriver());
1063 if (!set_video_mode(GUI_SDL_OPTION(screen.width),
1064 GUI_SDL_OPTION(screen.height),
1065 flags)) {
1066 return EXIT_FAILURE;
1067 }
1068
1069 user_event_type = SDL_RegisterEvents(1);
1070
1071 SDL_zero(__net_user_event);
1072 __net_user_event.type = user_event_type;
1073 __net_user_event.user.code = NET;
1074 __net_user_event.user.data1 = NULL;
1075 __net_user_event.user.data2 = NULL;
1076 net_user_event = &__net_user_event;
1077
1078 SDL_zero(__anim_user_event);
1079 __anim_user_event.type = user_event_type;
1080 __anim_user_event.user.code = EVENT_ERROR;
1081 __anim_user_event.user.data1 = NULL;
1082 __anim_user_event.user.data2 = NULL;
1083 anim_user_event = &__anim_user_event;
1084
1085 SDL_zero(__info_user_event);
1086 __info_user_event.type = user_event_type;
1087 __info_user_event.user.code = SHOW_WIDGET_INFO_LABEL;
1088 __info_user_event.user.data1 = NULL;
1089 __info_user_event.user.data2 = NULL;
1090 info_user_event = &__info_user_event;
1091
1092 SDL_zero(__flush_user_event);
1093 __flush_user_event.type = user_event_type;
1094 __flush_user_event.user.code = FLUSH;
1095 __flush_user_event.user.data1 = NULL;
1096 __flush_user_event.user.data2 = NULL;
1097 flush_user_event = &__flush_user_event;
1098
1099 SDL_zero(__map_scroll_user_event);
1100 __map_scroll_user_event.type = user_event_type;
1101 __map_scroll_user_event.user.code = MAP_SCROLL;
1102 __map_scroll_user_event.user.data1 = NULL;
1103 __map_scroll_user_event.user.data2 = NULL;
1104 map_scroll_user_event = &__map_scroll_user_event;
1105
1106 is_unit_move_blocked = FALSE;
1107
1108 sdl3_client_flags |= (CF_DRAW_PLAYERS_NEUTRAL_STATUS
1109 |CF_DRAW_PLAYERS_WAR_STATUS
1110 |CF_DRAW_PLAYERS_CEASEFIRE_STATUS
1111 |CF_DRAW_PLAYERS_PEACE_STATUS
1112 |CF_DRAW_PLAYERS_ALLIANCE_STATUS);
1113
1114 tileset_init(tileset);
1115 tileset_load_tiles(tileset);
1116 tileset_use_preferred_theme(tileset);
1117
1118 load_cursors();
1119
1120 callbacks = callback_list_new();
1121
1122 diplomacy_dialog_init();
1123 intel_dialog_init();
1124
1125 clear_double_messages_call();
1126
1127 setup_auxiliary_tech_icons();
1128
1129 /* This needs correct main_data.screen size */
1130 init_mapcanvas_and_overview();
1131
1132 set_client_state(C_S_DISCONNECTED);
1133
1134 /* Main game loop */
1135 gui_event_loop(NULL, NULL, main_key_down_handler, main_key_up_handler, NULL,
1136 main_finger_down_handler, main_finger_up_handler, NULL,
1137 main_mouse_button_down_handler, main_mouse_button_up_handler,
1138 main_mouse_motion_handler);
1139 start_quitting();
1140
1141#if defined UNDER_CE && defined GUI_SDL3_SMALL_SCREEN
1142 /* Change back to window mode to restore the title bar */
1143 set_video_mode(320, 240, SDL_SWSURFACE | SDL_ANYFORMAT);
1144#endif
1145
1146 city_map_canvas_free();
1147
1148 free_mapcanvas_and_overview();
1149
1150 free_auxiliary_tech_icons();
1151
1152 diplomacy_dialog_done();
1153 intel_dialog_done();
1154
1155 callback_list_destroy(callbacks);
1156 callbacks = NULL;
1157
1158 unload_cursors();
1159
1160 free(button_behavior.event);
1161 button_behavior.event = NULL;
1162
1163 meswin_dialog_popdown();
1164
1165 del_main_list();
1166
1167 free_font_system();
1168 theme_free(active_theme);
1169 active_theme = NULL;
1170
1171 quit_sdl();
1172 }
1173
1174 return EXIT_SUCCESS;
1175}
1176
1177/**********************************************************************/
1180 void ui_exit(void)
1181{
1182}
1183
1184/**********************************************************************/
1187 enum gui_type get_gui_type(void)
1188{
1189 return GUI_SDL3;
1190}
1191
1192/**********************************************************************/
1196 void sound_bell(void)
1197{
1198 log_debug("sound_bell : PORT ME");
1199}
1200
1201/**********************************************************************/
1204 void enable_focus_animation(void)
1205{
1206 anim_user_event->user.code = ANIM;
1207 sdl3_client_flags |= CF_FOCUS_ANIMATION;
1208}
1209
1210/**********************************************************************/
1213 void disable_focus_animation(void)
1214{
1215 sdl3_client_flags &= ~CF_FOCUS_ANIMATION;
1216}
1217
1218/**********************************************************************/
1222 void add_net_input(int sock)
1223{
1224 log_debug("Connection UP (%d)", sock);
1225 net_socket = sock;
1226 autoconnect = FALSE;
1227 enable_focus_animation();
1228}
1229
1230/**********************************************************************/
1233 void remove_net_input(void)
1234{
1235 log_debug("Connection DOWN... ");
1236 net_socket = (-1);
1237 disable_focus_animation();
1238 draw_goto_patrol_lines = FALSE;
1239 update_mouse_cursor(CURSOR_DEFAULT);
1240}
1241
1242/**********************************************************************/
1247 void add_idle_callback(void (callback)(void *), void *data)
1248{
1249 if (callbacks != NULL) {
1250 struct callback *cb = fc_malloc(sizeof(*cb));
1251
1252 cb->callback = callback;
1253 cb->data = data;
1254
1255 callback_list_prepend(callbacks, cb);
1256 }
1257}
1258
1259/**********************************************************************/
1262 void editgui_tileset_changed(void)
1263{}
1264
1265/**********************************************************************/
1268 void editgui_refresh(void)
1269{}
1270
1271/**********************************************************************/
1274 void editgui_popup_properties(const struct tile_list *tiles, int objtype)
1275{}
1276
1277/**********************************************************************/
1280 void editgui_popdown_all(void)
1281{}
1282
1283/**********************************************************************/
1286 void editgui_notify_object_changed(int objtype, int object_id, bool removal)
1287{}
1288
1289/**********************************************************************/
1292 void editgui_notify_object_created(int tag, int id)
1293{}
1294
1295/**********************************************************************/
1298 void gui_update_font(const char *font_name, const char *font_value)
1299{
1300#define CHECK_FONT(client_font, action) \
1301 do { \
1302 if (strcmp(#client_font, font_name) == 0) { \
1303 char *end; \
1304 long size = strtol(font_value, &end, 10); \
1305 if (end && *end == '\0' && size > 0) { \
1306 *client_font_sizes[client_font] = size; \
1307 action; \
1308 } \
1309 } \
1310 } while (FALSE)
1311
1312 CHECK_FONT(FONT_CITY_NAME, update_city_descriptions());
1313 CHECK_FONT(FONT_CITY_PROD, update_city_descriptions());
1314 /* FONT_REQTREE_TEXT not used yet */
1315
1316#undef CHECK_FONT
1317}
1318
1319/**********************************************************************/
1322 unsigned default_font_size(struct theme *act_theme)
1323{
1324 return font_size_parameter > 0 ? font_size_parameter :
1325 (GUI_SDL_OPTION(use_theme_font_size) ? theme_default_font_size(act_theme) :
1326 GUI_SDL_OPTION(font_size));
1327}
1328
1329/**********************************************************************/
1332 void update_font_from_theme(int theme_font_size)
1333{
1334 *client_font_sizes[FONT_CITY_NAME] = theme_font_size;
1335 *client_font_sizes[FONT_CITY_PROD] = theme_font_size;
1336}
1337
1338/**********************************************************************/
1341 void insert_client_build_info(char *outbuf, size_t outlen)
1342{
1343 /* PORTME */
1344}
1345
1346/**********************************************************************/
1349 bool flush_event(void)
1350{
1351 return SDL_PushEvent(flush_user_event) >= 0;
1352}
city_owner
#define city_owner(_pcity_)
Definition city.h:563
popup_city_dialog
void popup_city_dialog(struct city *pcity)
Definition update_queue.c:623
real_timer_callback
double real_timer_callback(void)
Definition client_main.c:1190
client_main
int client_main(int argc, char *argv[], bool postpone_tileset)
Definition client_main.c:354
client
struct civclient client
Definition client_main.c:153
client_state
enum client_states client_state(void)
Definition client_main.c:1034
send_report_request
void send_report_request(enum report_type type)
Definition client_main.c:844
start_quitting
void start_quitting(void)
Definition client_main.c:1652
set_client_state
void set_client_state(enum client_states newstate)
Definition client_main.c:852
client_main.h
C_S_DISCONNECTED
@ C_S_DISCONNECTED
Definition client_main.h:45
C_S_RUNNING
@ C_S_RUNNING
Definition client_main.h:47
center_on_something
void center_on_something(void)
Definition climisc.c:430
climisc.h
try_to_autoconnect
double try_to_autoconnect(void)
Definition clinet.c:498
input_from_server
void input_from_server(int fd)
Definition clinet.c:411
clinet.h
incite_cost
char * incite_cost
Definition comments.c:74
REPORT_WONDERS_OF_THE_WORLD
@ REPORT_WONDERS_OF_THE_WORLD
Definition conn_types.h:50
REPORT_DEMOGRAPHIC
@ REPORT_DEMOGRAPHIC
Definition conn_types.h:53
REPORT_ACHIEVEMENTS
@ REPORT_ACHIEVEMENTS
Definition conn_types.h:54
REPORT_TOP_CITIES
@ REPORT_TOP_CITIES
Definition conn_types.h:52
get_units_in_focus
struct unit_list * get_units_in_focus(void)
Definition control.c:177
key_end_turn
void key_end_turn(void)
Definition control.c:3285
head_of_units_in_focus
struct unit * head_of_units_in_focus(void)
Definition control.c:405
control_mouse_cursor
void control_mouse_cursor(struct tile *ptile)
Definition control.c:1189
punit
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
editgui_g.h
objtype
int objtype
Definition editgui_g.h:28
editgui_notify_object_changed
editgui_notify_object_changed
Definition editgui_g.h:27
event
enum event_type event
Definition events.c:81
is_option
bool is_option(const char *option_name, char *option)
Definition fc_cmdline.c:112
get_option_malloc
char * get_option_malloc(const char *option_name, char **argv, int *i, int argc, bool gc)
Definition fc_cmdline.c:50
fc_cmdline.h
fc_prehdrs.h
fciconv.h
fc_fprintf
void fc_fprintf(FILE *stream, const char *format,...) fc__attribute((__format__(__printf__
fcintl.h
_
#define _(String)
Definition fcintl.h:67
city_report_dialog_popup
void city_report_dialog_popup(bool raise)
Definition cityrep.c:292
diplomacy_dialog_init
void diplomacy_dialog_init(void)
Definition diplodlg.c:1204
diplomacy_dialog_done
void diplomacy_dialog_done(void)
Definition diplodlg.c:1213
load_cursors
void load_cursors(void)
Definition graphics.c:84
ui_main
int ui_main(int argc, char **argv)
Definition gui_main.c:1910
client_string
const char * client_string
Definition gui_main.c:105
print_usage
static void print_usage(void)
Definition gui_main.c:265
option_var_set_callback
#define option_var_set_callback(var, callback)
MIGRATE_STR_OPTION
#define MIGRATE_STR_OPTION(opt)
ui_exit
void ui_exit(void)
Definition gui_main.c:2089
get_gui_type
enum gui_type get_gui_type(void)
Definition gui_main.c:2100
main
int main(int argc, char **argv)
Definition gui_main.c:1788
ui_init
void ui_init(void)
Definition gui_main.c:1778
add_idle_callback
void add_idle_callback(void(callback)(void *), void *data)
Definition gui_main.c:2428
options_extra_init
void options_extra_init(void)
Definition gui_main.c:2502
insert_client_build_info
void insert_client_build_info(char *outbuf, size_t outlen)
Definition gui_main.c:2562
remove_net_input
void remove_net_input(void)
Definition gui_main.c:2334
sound_bell
void sound_bell(void)
Definition gui_main.c:2108
gui_character_encoding
const char *const gui_character_encoding
Definition gui_main.c:161
add_net_input
void add_net_input(int sock)
Definition gui_main.c:2316
parse_options
static bool parse_options(int argc, char **argv)
Definition gui_main.c:295
MIGRATE_OPTION
#define MIGRATE_OPTION(opt)
gui_use_transliteration
const bool gui_use_transliteration
Definition gui_main.c:162
intel_dialog_done
void intel_dialog_done(void)
Definition inteldlg.c:128
intel_dialog_init
void intel_dialog_init(void)
Definition inteldlg.c:119
flush_dirty
void flush_dirty(void)
Definition mapview.c:468
update_info_label
void update_info_label(void)
Definition mapview.c:138
dirty_all
void dirty_all(void)
Definition mapview.c:456
update_unit_info_label
void update_unit_info_label(struct unit_list *punits)
Definition mapview.c:275
update_city_descriptions
void update_city_descriptions(void)
Definition mapview.c:488
update_mouse_cursor
void update_mouse_cursor(enum cursor_type new_cursor_type)
Definition mapview.c:257
meswin_dialog_popdown
void meswin_dialog_popdown(void)
Definition messagewin.c:432
meswin_dialog_popup
void meswin_dialog_popup(bool raise)
Definition messagewin.c:417
meswin_dialog_is_open
bool meswin_dialog_is_open(void)
Definition messagewin.c:443
units_report_dialog_popup
void units_report_dialog_popup(bool raise)
Definition repodlgs.c:1768
popup_spaceship_dialog
void popup_spaceship_dialog(struct player *pplayer)
Definition spaceshipdlg.c:146
popup_input_line
void popup_input_line(void)
Definition chatline.c:359
set_video_mode
bool set_video_mode(unsigned width, unsigned height, unsigned flags_in)
Definition graphics.c:636
main_window_width
int main_window_width(void)
Definition graphics.c:685
init_sdl
void init_sdl(int flags)
Definition graphics.c:506
update_main_screen
void update_main_screen(void)
Definition graphics.c:669
quit_sdl
void quit_sdl(void)
Definition graphics.c:622
is_in_rect_area
bool is_in_rect_area(int x, int y, const SDL_Rect *rect)
Definition graphics.c:925
main_data
struct sdl2_data main_data
Definition graphics.c:57
create_surfaces
bool create_surfaces(int width, int height)
Definition graphics.c:556
main_window_height
int main_window_height(void)
Definition graphics.c:693
ID_COOLING_ICON
@ ID_COOLING_ICON
Definition gui_id.h:138
ID_ERROR
@ ID_ERROR
Definition gui_id.h:26
ID_WARMING_ICON
@ ID_WARMING_ICON
Definition gui_id.h:139
city_names_font_size
static int city_names_font_size
Definition gui_main.c:113
main_key_down_handler
static Uint16 main_key_down_handler(SDL_Keysym key, void *data)
Definition gui_main.c:233
__anim_user_event
static SDL_Event __anim_user_event
Definition gui_main.c:133
net_user_event
static SDL_Event * net_user_event
Definition gui_main.c:138
resize_window_callback
static void resize_window_callback(struct option *poption)
Definition gui_main.c:932
fullscreen_callback
static void fullscreen_callback(struct option *poption)
Definition gui_main.c:940
editgui_popup_properties
void editgui_popup_properties(const struct tile_list *tiles, int objtype)
Definition gui_main.c:1270
editgui_notify_object_created
void editgui_notify_object_created(int tag, int id)
Definition gui_main.c:1288
CHECK_FONT
#define CHECK_FONT(client_font, action)
button_behavior
static struct mouse_button_behavior button_behavior
Definition gui_main.c:130
is_unit_move_blocked
bool is_unit_move_blocked
Definition gui_main.c:107
__info_user_event
static SDL_Event __info_user_event
Definition gui_main.c:134
LSHIFT
bool LSHIFT
Definition gui_main.c:108
__flush_user_event
static SDL_Event __flush_user_event
Definition gui_main.c:135
FilterMouseMotionEvents
int FilterMouseMotionEvents(void *data, SDL_Event *event)
Definition gui_main.c:581
info_user_event
static SDL_Event * info_user_event
Definition gui_main.c:140
main_mouse_button_down_handler
static Uint16 main_mouse_button_down_handler(SDL_MouseButtonEvent *button_event, void *data)
Definition gui_main.c:377
__net_user_event
static SDL_Event __net_user_event
Definition gui_main.c:132
enable_focus_animation
void enable_focus_animation(void)
Definition gui_main.c:1200
editgui_popdown_all
void editgui_popdown_all(void)
Definition gui_main.c:1276
flush_event
bool flush_event(void)
Definition gui_main.c:1345
MAP_SCROLL_TIMER_INTERVAL
#define MAP_SCROLL_TIMER_INTERVAL
Definition gui_main.c:91
real_resize_window_callback
static void real_resize_window_callback(void *data)
Definition gui_main.c:897
draw_goto_patrol_lines
bool draw_goto_patrol_lines
Definition mapctrl.c:104
UNITS_TIMER_INTERVAL
#define UNITS_TIMER_INTERVAL
Definition gui_main.c:90
update_button_hold_state
static void update_button_hold_state(void)
Definition gui_main.c:490
is_map_scrolling
static bool is_map_scrolling
Definition gui_main.c:126
map_scroll_user_event
static SDL_Event * map_scroll_user_event
Definition gui_main.c:142
RSHIFT
bool RSHIFT
Definition gui_main.c:109
MOVE_STEP_Y
int MOVE_STEP_Y
Definition gui_main.c:105
gui_event_loop
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)(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
main_finger_down_handler
static Uint16 main_finger_down_handler(SDL_TouchFingerEvent *touch_event, void *data)
Definition gui_main.c:325
SCROLL_MAP_AREA
#define SCROLL_MAP_AREA
Definition gui_main.c:433
widget_info_counter
Uint32 widget_info_counter
Definition gui_main.c:103
main_mouse_motion_handler
static Uint16 main_mouse_motion_handler(SDL_MouseMotionEvent *motion_event, void *data)
Definition gui_main.c:439
anim_user_event
static SDL_Event * anim_user_event
Definition gui_main.c:139
autoconnect
static bool autoconnect
Definition gui_main.c:125
check_scroll_area
static bool check_scroll_area(int x, int y)
Definition gui_main.c:518
net_socket
static int net_socket
Definition gui_main.c:124
main_finger_up_handler
static Uint16 main_finger_up_handler(SDL_TouchFingerEvent *touch_event, void *data)
Definition gui_main.c:353
update_font_from_theme
void update_font_from_theme(int theme_font_size)
Definition gui_main.c:1328
city_productions_font_size
static int city_productions_font_size
Definition gui_main.c:114
LALT
bool LALT
Definition gui_main.c:112
LCTRL
bool LCTRL
Definition gui_main.c:110
default_font_size
unsigned default_font_size(struct theme *act_theme)
Definition gui_main.c:1318
clear_double_messages_call
static void clear_double_messages_call(void)
Definition gui_main.c:989
force_exit_from_event_loop
void force_exit_from_event_loop(void)
Definition gui_main.c:565
disable_focus_animation
void disable_focus_animation(void)
Definition gui_main.c:1209
scroll_dir
static enum direction8 scroll_dir
Definition gui_main.c:127
font_size_parameter
static unsigned font_size_parameter
Definition gui_main.c:121
client_font_sizes
int * client_font_sizes[FONT_COUNT]
Definition gui_main.c:115
editgui_refresh
void editgui_refresh(void)
Definition gui_main.c:1264
user_event_type
int user_event_type
Definition gui_main.c:148
__map_scroll_user_event
static SDL_Event __map_scroll_user_event
Definition gui_main.c:136
flush_user_event
static SDL_Event * flush_user_event
Definition gui_main.c:141
callbacks
struct callback_list * callbacks
Definition gui_main.c:170
USER_EVENT_ID
USER_EVENT_ID
Definition gui_main.c:150
NET
@ NET
Definition gui_main.c:152
ANIM
@ ANIM
Definition gui_main.c:153
TRY_AUTO_CONNECT
@ TRY_AUTO_CONNECT
Definition gui_main.c:154
MAP_SCROLL
@ MAP_SCROLL
Definition gui_main.c:157
FLUSH
@ FLUSH
Definition gui_main.c:156
EVENT_ERROR
@ EVENT_ERROR
Definition gui_main.c:151
EXIT_FROM_EVENT_LOOP
@ EXIT_FROM_EVENT_LOOP
Definition gui_main.c:158
SHOW_WIDGET_INFO_LABEL
@ SHOW_WIDGET_INFO_LABEL
Definition gui_main.c:155
main_key_up_handler
static Uint16 main_key_up_handler(SDL_Keysym key, void *data)
Definition gui_main.c:314
editgui_tileset_changed
void editgui_tileset_changed(void)
Definition gui_main.c:1258
main_mouse_button_up_handler
static Uint16 main_mouse_button_up_handler(SDL_MouseButtonEvent *button_event, void *data)
Definition gui_main.c:413
MOVE_STEP_X
int MOVE_STEP_X
Definition gui_main.c:104
RCTRL
bool RCTRL
Definition gui_main.c:111
CF_FOCUS_ANIMATION
#define CF_FOCUS_ANIMATION
Definition gui_main.h:51
CF_DRAW_PLAYERS_ALLIANCE_STATUS
#define CF_DRAW_PLAYERS_ALLIANCE_STATUS
Definition gui_main.h:62
CF_DRAW_PLAYERS_CEASEFIRE_STATUS
#define CF_DRAW_PLAYERS_CEASEFIRE_STATUS
Definition gui_main.h:60
CF_SWRENDERER
#define CF_SWRENDERER
Definition gui_main.h:64
CF_DRAW_PLAYERS_PEACE_STATUS
#define CF_DRAW_PLAYERS_PEACE_STATUS
Definition gui_main.h:61
MB_HOLD_LONG
@ MB_HOLD_LONG
Definition gui_main.h:80
MB_HOLD_MEDIUM
@ MB_HOLD_MEDIUM
Definition gui_main.h:79
MB_HOLD_SHORT
@ MB_HOLD_SHORT
Definition gui_main.h:78
MB_MEDIUM_HOLD_DELAY
#define MB_MEDIUM_HOLD_DELAY
Definition gui_main.h:67
selected_widget
struct widget * selected_widget
Definition widget.c:48
CF_DRAW_PLAYERS_NEUTRAL_STATUS
#define CF_DRAW_PLAYERS_NEUTRAL_STATUS
Definition gui_main.h:63
adj_size
#define adj_size(size)
Definition gui_main.h:141
DEFAULT_MOVE_STEP
#define DEFAULT_MOVE_STEP
Definition gui_main.h:113
MB_LONG_HOLD_DELAY
#define MB_LONG_HOLD_DELAY
Definition gui_main.h:68
CF_DRAW_PLAYERS_WAR_STATUS
#define CF_DRAW_PLAYERS_WAR_STATUS
Definition gui_main.h:59
GUI_SDL_OPTION
#define GUI_SDL_OPTION(optname)
Definition gui_main.h:37
animate_mouse_cursor
void animate_mouse_cursor(void)
Definition gui_mouse.c:182
unload_cursors
void unload_cursors(void)
Definition gui_mouse.c:164
draw_mouse_cursor
void draw_mouse_cursor(void)
Definition gui_mouse.c:100
free_font_system
void free_font_system(void)
Definition gui_string.c:698
setup_auxiliary_tech_icons
void setup_auxiliary_tech_icons(void)
Definition gui_tilespec.c:379
draw_intro_gfx
void draw_intro_gfx(void)
Definition gui_tilespec.c:484
free_auxiliary_tech_icons
void free_auxiliary_tech_icons(void)
Definition gui_tilespec.c:419
button_down_on_map
void button_down_on_map(struct mouse_button_behavior *button_behavior)
Definition mapctrl.c:2280
button_up_on_map
void button_up_on_map(struct mouse_button_behavior *button_behavior)
Definition mapctrl.c:2351
finger_up_on_map
void finger_up_on_map(struct finger_behavior *finger_behavior)
Definition mapctrl.c:2267
map_event_handler
bool map_event_handler(SDL_Keysym key)
Definition mapctrl.c:2445
set_new_minimap_window_pos
void set_new_minimap_window_pos(void)
Definition mapctrl.c:1386
set_new_unitinfo_window_pos
void set_new_unitinfo_window_pos(void)
Definition mapctrl.c:1332
unqueue_flush
void unqueue_flush(void)
Definition mapview.c:140
city_map_canvas_free
void city_map_canvas_free(void)
Definition mapview.c:1185
flush_all
void flush_all(void)
Definition mapview.c:201
update_order_widgets
void update_order_widgets(void)
Definition menu.c:952
theme_free
void theme_free(struct theme *ftheme)
Definition themespec.c:317
theme_default_font_size
int theme_default_font_size(const struct theme *t)
Definition themespec.c:177
active_theme
struct theme * active_theme
Definition themespec.c:154
find_next_widget_for_key
struct widget * find_next_widget_for_key(struct widget *start_widget, SDL_Keysym key)
Definition widget.c:252
widget_pressed_action
Uint16 widget_pressed_action(struct widget *pwidget)
Definition widget.c:296
widget_selected_action
void widget_selected_action(struct widget *pwidget)
Definition widget.c:443
get_widget_pointer_from_main_list
struct widget * get_widget_pointer_from_main_list(Uint16 id)
Definition widget.c:578
find_next_widget_at_pos
struct widget * find_next_widget_at_pos(struct widget *start_widget, int x, int y)
Definition widget.c:222
unselect_widget_action
void unselect_widget_action(void)
Definition widget.c:418
del_main_list
void del_main_list(void)
Definition widget.c:691
widget_set_position
static void widget_set_position(struct widget *pwidget, int x, int y)
Definition widget.h:266
MAX_ID
#define MAX_ID
Definition widget.h:38
FC_WS_DISABLED
@ FC_WS_DISABLED
Definition widget.h:99
get_wstate
enum widget_state get_wstate(const struct widget *pwidget)
Definition widget_core.c:70
draw_widget_info_label
#define draw_widget_info_label()
Definition widget.h:246
gui_id.h
migrate_options_from_sdl2
static void migrate_options_from_sdl2(void)
Definition gui_main.c:1010
sdl3_client_flags
Uint32 sdl3_client_flags
Definition gui_main.c:97
gui_mouse.h
gui_tilespec.h
themespec.h
widget.h
chatline.h
citydlg.h
cityrep.h
diplodlg.h
graphics.h
gui_main.h
inteldlg.h
mapctrl.h
mapview.h
menu.h
messagewin.h
optiondlg.h
repodlgs.h
font_name
const char * font_name
Definition gui_main_g.h:43
gui_update_font
gui_update_font
Definition gui_main_g.h:43
log.h
log_debug
#define log_debug(message,...)
Definition log.h:115
log_normal
#define log_normal(message,...)
Definition log.h:107
update_line
void update_line(int canvas_x, int canvas_y)
Definition mapctrl_common.c:665
scroll_mapview
void scroll_mapview(enum direction8 gui_dir)
Definition mapctrl_common.c:552
init_mapcanvas_and_overview
void init_mapcanvas_and_overview(void)
Definition mapview_common.c:3655
canvas_pos_to_tile
struct tile * canvas_pos_to_tile(float canvas_x, float canvas_y, float zoom)
Definition mapview_common.c:763
free_mapcanvas_and_overview
void free_mapcanvas_and_overview(void)
Definition mapview_common.c:3664
map_canvas_resized
bool map_canvas_resized(int width, int height)
Definition mapview_common.c:3564
fc_calloc
#define fc_calloc(n, esz)
Definition mem.h:38
fc_malloc
#define fc_malloc(sz)
Definition mem.h:34
fc_select
int fc_select(int n, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, fc_timeval *timeout)
Definition netintf.c:125
netintf.h
fc_timeval
struct timeval fc_timeval
Definition netintf.h:90
messages_where
int messages_where[E_COUNT]
Definition options.c:5301
gui_options
struct client_options gui_options
Definition options.c:71
MW_MESSAGES
#define MW_MESSAGES
Definition options.h:616
VIDEO_MODE
#define VIDEO_MODE(ARG_width, ARG_height)
Definition options.h:51
str_to_uint
bool str_to_uint(const char *str, unsigned int *pint)
Definition shared.c:547
spaceshipdlg_g.h
speclist.h
y
struct sprite int int y
Definition sprite_g.h:31
x
struct sprite int x
Definition sprite_g.h:31
callback
Definition gui_main.c:2405
callback::data
void * data
Definition gui_main.c:2407
callback::callback
void(* callback)(void *data)
Definition gui_main.c:2406
city
Definition city.h:320
civclient::conn
struct connection conn
Definition client_main.h:96
client_options::gui_sdl3_migrated_from_sdl2
bool gui_sdl3_migrated_from_sdl2
Definition options.h:138
connection::playing
struct player * playing
Definition connection.h:151
finger_behavior
Definition gui_main.h:83
finger_behavior::finger_down_ticks
Uint32 finger_down_ticks
Definition gui_main.h:85
finger_behavior::ptile
struct tile * ptile
Definition gui_main.h:88
finger_behavior::counting
bool counting
Definition gui_main.h:84
finger_behavior::event
SDL_TouchFingerEvent event
Definition gui_main.h:87
finger_behavior::hold_state
enum mouse_button_hold_state hold_state
Definition gui_main.h:86
mouse_button_behavior
Definition gui_main.h:91
mouse_button_behavior::hold_state
enum mouse_button_hold_state hold_state
Definition gui_main.h:94
mouse_button_behavior::event
SDL_MouseButtonEvent * event
Definition gui_main.h:95
mouse_button_behavior::counting
bool counting
Definition gui_main.h:92
mouse_button_behavior::ptile
struct tile * ptile
Definition gui_main.h:96
mouse_button_behavior::button_down_ticks
Uint32 button_down_ticks
Definition gui_main.h:93
option
Definition options.c:514
sdl2_data::event
SDL_Event event
Definition graphics.h:217
sdl2_data::screen
SDL_Window * screen
Definition graphics.h:209
sdl2_data::map
SDL_Surface * map
Definition graphics.h:210
theme
Definition themespec.c:133
tile
Definition tile.h:50
tileset
Definition tilespec.c:482
unit
Definition unit.h:140
widget
Definition widget.h:112
widget::key
SDL_Keycode key
Definition widget.h:153
widget::widget
struct widget * widget
Definition widget.h:132
widget::size
SDL_Rect size
Definition widget.h:145
widget::data
union widget::@217 data
fc_snprintf
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:960
sz_strlcpy
#define sz_strlcpy(dest, src)
Definition support.h:189
TRUE
#define TRUE
Definition support.h:46
FALSE
#define FALSE
Definition support.h:47
tile_city
struct city * tile_city(const struct tile *ptile)
Definition tile.c:83
tile_index
#define tile_index(_pt_)
Definition tile.h:89
tileset_load_tiles
void tileset_load_tiles(struct tileset *t)
Definition tilespec.c:3662
tileset_use_preferred_theme
void tileset_use_preferred_theme(const struct tileset *t)
Definition tilespec.c:7108
tileset_init
void tileset_init(struct tileset *t)
Definition tilespec.c:7169
tilespec.h
CURSOR_DEFAULT
@ CURSOR_DEFAULT
Definition tilespec.h:302
unit_tile
#define unit_tile(_pu)
Definition unit.h:397
unitlist.h
update_queue_add
void update_queue_add(uq_callback_t callback, void *data)
Definition update_queue.c:345
update_queue.h
mouse_zoom
float mouse_zoom
Definition zoom.c:28
zoom.h