Freeciv-3.2: /fast/freeciv/nightly/S3_2/client/gui-sdl3/gui_main.c Source File

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/* SDL3 */
39#include <SDL3/SDL.h>
40
41/* utility */
42#include "fc_cmdline.h"
43#include "fciconv.h"
44#include "fcintl.h"
45#include "log.h"
46#include "netintf.h"
47
48/* common */
49#include "unitlist.h"
50
51/* client */
52#include "client_main.h"
53#include "climisc.h"
54#include "clinet.h"
55#include "editgui_g.h"
56#include "tilespec.h"
57#include "update_queue.h"
58#include "zoom.h"
59
60/* gui-sdl3 */
61#include "chatline.h"
62#include "citydlg.h"
63#include "cityrep.h"
64#include "diplodlg.h"
65#include "graphics.h"
66#include "gui_id.h"
67#include "gui_mouse.h"
68#include "gui_tilespec.h"
69#include "inteldlg.h"
70#include "mapctrl.h"
71#include "mapview.h"
72#include "menu.h"
73#include "messagewin.h"
74#include "optiondlg.h"
75#include "repodlgs.h"
76#include "themespec.h"
77#include "spaceshipdlg.h"
78#include "widget.h"
79
80#include "gui_main.h"
81
82#define UNITS_TIMER_INTERVAL 128 /* milliseconds */
83#define MAP_SCROLL_TIMER_INTERVAL 500
84
85 const char *client_string = "gui-sdl3";
86
87/* The real GUI character encoding is UTF-16 which is not supported by
88 * fciconv code at this time. Conversion between UTF-8 and UTF-16 is done
89 * in gui_iconv.c */
90 const char * const gui_character_encoding = "UTF-8";
91 const bool gui_use_transliteration = FALSE;
92
93 Uint32 sdl3_client_flags = 0;
94
95 Uint32 widget_info_counter = 0;
96 int MOVE_STEP_X = DEFAULT_MOVE_STEP;
97 int MOVE_STEP_Y = DEFAULT_MOVE_STEP;
98extern bool draw_goto_patrol_lines;
99 bool is_unit_move_blocked;
100 bool LSHIFT;
101 bool RSHIFT;
102 bool LCTRL;
103 bool RCTRL;
104 bool LALT;
105 static int city_names_font_size = 10;
106 static int city_productions_font_size = 10;
107 int *client_font_sizes[FONT_COUNT] = {
108 &city_names_font_size, /* FONT_CITY_NAME */
109 &city_productions_font_size, /* FONT_CITY_PROD */
110 &city_productions_font_size /* FONT_REQTREE_TEXT; not used yet */
111};
112
113 static unsigned font_size_parameter = 0;
114
115/* ================================ Private ============================ */
116 static int net_socket = -1;
117 static bool autoconnect = FALSE;
118 static bool is_map_scrolling = FALSE;
119 static enum direction8 scroll_dir;
120
121 static struct finger_behavior finger_behavior;
122 static struct mouse_button_behavior button_behavior;
123
124 static SDL_Event __net_user_event;
125 static SDL_Event __anim_user_event;
126 static SDL_Event __info_user_event;
127 static SDL_Event __flush_user_event;
128 static SDL_Event __map_scroll_user_event;
129
130 static SDL_Event *net_user_event = NULL;
131 static SDL_Event *anim_user_event = NULL;
132 static SDL_Event *info_user_event = NULL;
133 static SDL_Event *flush_user_event = NULL;
134 static SDL_Event *map_scroll_user_event = NULL;
135
136static void print_usage(void);
137static bool parse_options(int argc, char **argv);
138static bool check_scroll_area(int x, int y);
139
140 int user_event_type;
141
142 enum USER_EVENT_ID {
143 EVENT_ERROR = 0,
144 NET,
145 ANIM,
146 TRY_AUTO_CONNECT,
147 SHOW_WIDGET_INFO_LABEL,
148 FLUSH,
149 MAP_SCROLL,
150 EXIT_FROM_EVENT_LOOP
151};
152
153struct callback {
154 void (*callback)(void *data);
155 void *data;
156};
157
158#define SPECLIST_TAG callback
159#define SPECLIST_TYPE struct callback
160#include "speclist.h"
161
162 struct callback_list *callbacks = NULL;
163
164/* =========================================================== */
165
166/**********************************************************************/
170 static void print_usage(void)
171{
172 /* Add client-specific usage information here */
173 fc_fprintf(stderr,
174 _(" -f, --fullscreen\tStart Client in Fullscreen mode\n"));
175 fc_fprintf(stderr,
176 _(" -F, --Font SIZE\tUse SIZE as the base font size\n"));
177 fc_fprintf(stderr, _(" -s, --swrenderer\tUse SW renderer\n"));
178 fc_fprintf(stderr, _(" -t, --theme THEME\tUse GUI theme THEME\n"));
179
180 /* TRANS: No full stop after the URL, could cause confusion. */
181 fc_fprintf(stderr, _("Report bugs at %s\n"), BUG_URL);
182}
183
184/**********************************************************************/
187 static bool parse_options(int argc, char **argv)
188{
189 int i = 1;
190 char *option = NULL;
191
192 while (i < argc) {
193 if (is_option("--help", argv[i])) {
194 print_usage();
195
196 return FALSE;
197 } else if (is_option("--fullscreen", argv[i])) {
198 GUI_SDL_OPTION(fullscreen) = TRUE;
199 } else if (is_option("--swrenderer", argv[i])) {
200 sdl3_client_flags |= CF_SWRENDERER;
201 } else if ((option = get_option_malloc("--Font", argv, &i, argc, FALSE))) {
202 if (!str_to_uint(option, &font_size_parameter)) {
203 fc_fprintf(stderr, _("Invalid font size %s"), option);
204 exit(EXIT_FAILURE);
205 }
206 free(option);
207 } else if ((option = get_option_malloc("--theme", argv, &i, argc, FALSE))) {
208 sz_strlcpy(GUI_SDL_OPTION(default_theme_name), option);
209 free(option);
210 } else {
211 fc_fprintf(stderr, _("Unrecognized option: \"%s\"\n"), argv[i]);
212
213 exit(EXIT_FAILURE);
214 }
215
216 i++;
217 }
218
219 return TRUE;
220}
221
222/**********************************************************************/
225 static Uint16 main_key_down_handler(SDL_Keysym key, void *data)
226{
227 static struct widget *pwidget;
228
229 if ((pwidget = find_next_widget_for_key(NULL, key)) != NULL) {
230 return widget_pressed_action(pwidget);
231 } else {
232 if (key.sym == SDLK_TAB) {
233 /* input */
234 popup_input_line();
235 } else {
236 if (map_event_handler(key)
237 && C_S_RUNNING == client_state()) {
238 switch (key.sym) {
239 case SDLK_RETURN:
240 case SDLK_KP_ENTER:
241 if (LSHIFT || RSHIFT) {
242 disable_focus_animation();
243 key_end_turn();
244 } else {
245 struct unit *punit;
246 struct city *pcity;
247
248 if (NULL != (punit = head_of_units_in_focus())
249 && (pcity = tile_city(unit_tile(punit))) != NULL
250 && city_owner(pcity) == client.conn.playing) {
251 popup_city_dialog(pcity);
252 }
253 }
254 return ID_ERROR;
255
256 case SDLK_F2:
257 units_report_dialog_popup(FALSE);
258 return ID_ERROR;
259
260 case SDLK_F4:
261 city_report_dialog_popup(FALSE);
262 return ID_ERROR;
263
264 case SDLK_F7:
265 send_report_request(REPORT_WONDERS_OF_THE_WORLD);
266 return ID_ERROR;
267
268 case SDLK_F8:
269 send_report_request(REPORT_TOP_CITIES);
270 return ID_ERROR;
271
272 case SDLK_F9:
273 if (meswin_dialog_is_open()) {
274 meswin_dialog_popdown();
275 } else {
276 meswin_dialog_popup(TRUE);
277 }
278 flush_dirty();
279 return ID_ERROR;
280
281 case SDLK_F11:
282 send_report_request(REPORT_DEMOGRAPHIC);
283 return ID_ERROR;
284
285 case SDLK_F12:
286 popup_spaceship_dialog(client.conn.playing);
287 return ID_ERROR;
288
289 case SDLK_ASTERISK:
290 send_report_request(REPORT_ACHIEVEMENTS);
291 return ID_ERROR;
292
293 default:
294 return ID_ERROR;
295 }
296 }
297 }
298 }
299
300 return ID_ERROR;
301}
302
303/**********************************************************************/
306 static Uint16 main_key_up_handler(SDL_Keysym key, void *data)
307{
308 if (selected_widget) {
309 unselect_widget_action();
310 }
311
312 return ID_ERROR;
313}
314/**********************************************************************/
317 static Uint16 main_finger_down_handler(SDL_TouchFingerEvent *touch_event,
318 void *data)
319{
320 struct widget *pwidget;
321 /* Touch event coordinates are normalized (0...1). */
322 int x = touch_event->x * main_window_width();
323 int y = touch_event->y * main_window_height();
324
325 if ((pwidget = find_next_widget_at_pos(NULL, x, y)) != NULL) {
326 if (get_wstate(pwidget) != FC_WS_DISABLED) {
327 return widget_pressed_action(pwidget);
328 }
329 } else {
330 /* No visible widget at this position; map pressed. */
331 if (!finger_behavior.counting) {
332 /* Start counting. */
333 finger_behavior.counting = TRUE;
334 finger_behavior.finger_down_ticks = SDL_GetTicks();
335 finger_behavior.event = *touch_event;
336 finger_behavior.hold_state = MB_HOLD_SHORT;
337 finger_behavior.ptile = canvas_pos_to_tile(x, y, mouse_zoom);
338 }
339 }
340 return ID_ERROR;
341}
342/**********************************************************************/
345 static Uint16 main_finger_up_handler(SDL_TouchFingerEvent *touch_event,
346 void *data)
347{
348 /* Touch event coordinates are normalized (0...1). */
349 int x = touch_event->x * main_window_width();
350 int y = touch_event->y * main_window_height();
351 /* Screen wasn't pressed over a widget. */
352 if (finger_behavior.finger_down_ticks
353 && !find_next_widget_at_pos(NULL, x, y)) {
354 finger_behavior.event = *touch_event;
355 finger_up_on_map(&finger_behavior);
356 }
357
358 finger_behavior.counting = FALSE;
359 finger_behavior.finger_down_ticks = 0;
360
361 is_map_scrolling = FALSE;
362
363 return ID_ERROR;
364}
365
366/**********************************************************************/
369 static Uint16 main_mouse_button_down_handler(SDL_MouseButtonEvent *button_event,
370 void *data)
371{
372 struct widget *pwidget;
373
374 if ((pwidget = find_next_widget_at_pos(NULL,
375 button_event->x,
376 button_event->y)) != NULL) {
377 if (get_wstate(pwidget) != FC_WS_DISABLED) {
378 return widget_pressed_action(pwidget);
379 }
380 } else {
381 /* no visible widget at this position -> map click */
382#ifdef UNDER_CE
383 if (!check_scroll_area(button_event->x, button_event->y)) {
384#endif
385 if (!button_behavior.counting) {
386 /* start counting */
387 button_behavior.counting = TRUE;
388 button_behavior.button_down_ticks = SDL_GetTicks();
389 *button_behavior.event = *button_event;
390 button_behavior.hold_state = MB_HOLD_SHORT;
391 button_behavior.ptile = canvas_pos_to_tile(button_event->x, button_event->y,
392 mouse_zoom);
393 }
394#ifdef UNDER_CE
395 }
396#endif
397 }
398
399 return ID_ERROR;
400}
401
402/**********************************************************************/
405 static Uint16 main_mouse_button_up_handler(SDL_MouseButtonEvent *button_event,
406 void *data)
407{
408 if (button_behavior.button_down_ticks /* button wasn't pressed over a widget */
409 && !find_next_widget_at_pos(NULL, button_event->x, button_event->y)) {
410 *button_behavior.event = *button_event;
411 button_up_on_map(&button_behavior);
412 }
413
414 button_behavior.counting = FALSE;
415 button_behavior.button_down_ticks = 0;
416
417 is_map_scrolling = FALSE;
418
419 return ID_ERROR;
420}
421
422#ifdef UNDER_CE
423 #define SCROLL_MAP_AREA 8
424#else
425 #define SCROLL_MAP_AREA 1
426#endif
427
428/**********************************************************************/
431 static Uint16 main_mouse_motion_handler(SDL_MouseMotionEvent *motion_event,
432 void *data)
433{
434 static struct widget *pwidget;
435 struct tile *ptile;
436
437 /* stop evaluating button hold time when moving to another tile in medium
438 * hold state or above */
439 if (button_behavior.counting && (button_behavior.hold_state >= MB_HOLD_MEDIUM)) {
440 ptile = canvas_pos_to_tile(motion_event->x, motion_event->y,
441 mouse_zoom);
442 if (tile_index(ptile) != tile_index(button_behavior.ptile)) {
443 button_behavior.counting = FALSE;
444 }
445 }
446
447 if (draw_goto_patrol_lines) {
448 update_line(motion_event->x, motion_event->y);
449 }
450
451#ifndef UNDER_CE
452 if (GUI_SDL_OPTION(fullscreen)) {
453 check_scroll_area(motion_event->x, motion_event->y);
454 }
455#endif /* UNDER_CE */
456
457 if ((pwidget = find_next_widget_at_pos(NULL,
458 motion_event->x,
459 motion_event->y)) != NULL) {
460 update_mouse_cursor(CURSOR_DEFAULT);
461 if (get_wstate(pwidget) != FC_WS_DISABLED) {
462 widget_selected_action(pwidget);
463 }
464 } else {
465 if (selected_widget) {
466 unselect_widget_action();
467 } else {
468 control_mouse_cursor(canvas_pos_to_tile(motion_event->x, motion_event->y,
469 mouse_zoom));
470 }
471 }
472
473 draw_mouse_cursor();
474
475 return ID_ERROR;
476}
477
478/**********************************************************************/
482 static void update_button_hold_state(void)
483{
484 /* button pressed */
485 if (button_behavior.counting) {
486 if (((SDL_GetTicks() - button_behavior.button_down_ticks) >= MB_MEDIUM_HOLD_DELAY)
487 && ((SDL_GetTicks() - button_behavior.button_down_ticks) < MB_LONG_HOLD_DELAY)) {
488
489 if (button_behavior.hold_state != MB_HOLD_MEDIUM) {
490 button_behavior.hold_state = MB_HOLD_MEDIUM;
491 button_down_on_map(&button_behavior);
492 }
493
494 } else if (((SDL_GetTicks() - button_behavior.button_down_ticks)
495 >= MB_LONG_HOLD_DELAY)) {
496
497 if (button_behavior.hold_state != MB_HOLD_LONG) {
498 button_behavior.hold_state = MB_HOLD_LONG;
499 button_down_on_map(&button_behavior);
500 }
501 }
502 }
503
504 return;
505}
506
507/**********************************************************************/
510 static bool check_scroll_area(int x, int y)
511{
512 SDL_Rect rect_north = {.x = 0, .y = 0,
513 .w = main_data.map->w, .h = SCROLL_MAP_AREA};
514 SDL_Rect rect_east = {.x = main_data.map->w - SCROLL_MAP_AREA, .y = 0,
515 .w = SCROLL_MAP_AREA, .h = main_data.map->h};
516 SDL_Rect rect_south = {.x = 0, .y = main_data.map->h - SCROLL_MAP_AREA,
517 .w = main_data.map->w, .h = SCROLL_MAP_AREA};
518 SDL_Rect rect_west = {.x = 0, .y = 0,
519 .w = SCROLL_MAP_AREA, .h = main_data.map->h};
520
521 if (is_in_rect_area(x, y, &rect_north)) {
522 is_map_scrolling = TRUE;
523 if (is_in_rect_area(x, y, &rect_west)) {
524 scroll_dir = DIR8_NORTHWEST;
525 } else if (is_in_rect_area(x, y, &rect_east)) {
526 scroll_dir = DIR8_NORTHEAST;
527 } else {
528 scroll_dir = DIR8_NORTH;
529 }
530 } else if (is_in_rect_area(x, y, &rect_south)) {
531 is_map_scrolling = TRUE;
532 if (is_in_rect_area(x, y, &rect_west)) {
533 scroll_dir = DIR8_SOUTHWEST;
534 } else if (is_in_rect_area(x, y, &rect_east)) {
535 scroll_dir = DIR8_SOUTHEAST;
536 } else {
537 scroll_dir = DIR8_SOUTH;
538 }
539 } else if (is_in_rect_area(x, y, &rect_east)) {
540 is_map_scrolling = TRUE;
541 scroll_dir = DIR8_EAST;
542 } else if (is_in_rect_area(x, y, &rect_west)) {
543 is_map_scrolling = TRUE;
544 scroll_dir = DIR8_WEST;
545 } else {
546 is_map_scrolling = FALSE;
547 }
548
549 return is_map_scrolling;
550}
551
552/* ============================ Public ========================== */
553
554/**********************************************************************/
557 void force_exit_from_event_loop(void)
558{
559 SDL_Event event;
560
561 event.type = user_event_type;
562 event.user.code = EXIT_FROM_EVENT_LOOP;
563 event.user.data1 = NULL;
564 event.user.data2 = NULL;
565
566 SDL_PushEvent(&event);
567}
568
569/**********************************************************************/
573 int FilterMouseMotionEvents(void *data, SDL_Event *event)
574{
575 if (event->type == SDL_EVENT_MOUSE_MOTION) {
576 static int x = 0, y = 0;
577
578 if (((MOVE_STEP_X > 0) && (abs(event->motion.x - x) >= MOVE_STEP_X))
579 || ((MOVE_STEP_Y > 0) && (abs(event->motion.y - y) >= MOVE_STEP_Y)) ) {
580 x = event->motion.x;
581 y = event->motion.y;
582 return 1; /* Catch it */
583 } else {
584 return 0; /* Drop it, we've handled it */
585 }
586 }
587
588 return 1;
589}
590
591/**********************************************************************/
594 Uint16 gui_event_loop(void *data,
595 void (*loop_action)(void *data),
596 Uint16 (*key_down_handler)(SDL_Keysym key, void *data),
597 Uint16 (*key_up_handler)(SDL_Keysym key, void *data),
598 Uint16 (*textinput_handler)(char *text, void *data),
599 Uint16 (*finger_down_handler)(SDL_TouchFingerEvent *touch_event, void *data),
600 Uint16 (*finger_up_handler)(SDL_TouchFingerEvent *touch_event, void *data),
601 Uint16 (*finger_motion_handler)(SDL_TouchFingerEvent *touch_event,
602 void *data),
603 Uint16 (*mouse_button_down_handler)(SDL_MouseButtonEvent *button_event,
604 void *data),
605 Uint16 (*mouse_button_up_handler)(SDL_MouseButtonEvent *button_event,
606 void *data),
607 Uint16 (*mouse_motion_handler)(SDL_MouseMotionEvent *motion_event,
608 void *data))
609{
610 Uint16 ID;
611 static fc_timeval tv;
612 static fd_set civfdset;
613 Uint32 t_current, t_last_unit_anim, t_last_map_scrolling;
614 Uint32 real_timer_next_call;
615 static int result;
616
617 ID = ID_ERROR;
618 t_last_map_scrolling = t_last_unit_anim = real_timer_next_call = SDL_GetTicks();
619 while (ID == ID_ERROR) {
620 /* ========================================= */
621 /* Net check with 10ms delay event loop */
622 if (net_socket >= 0) {
623 FD_ZERO(&civfdset);
624
625 if (net_socket >= 0) {
626 FD_SET(net_socket, &civfdset);
627 }
628
629 tv.tv_sec = 0;
630 tv.tv_usec = 10000; /* 10ms*/
631
632 result = fc_select(net_socket + 1, &civfdset, NULL, NULL, &tv);
633 if (result < 0) {
634 if (errno != EINTR) {
635 break;
636 } else {
637 continue;
638 }
639 } else {
640 if (result > 0) {
641 if ((net_socket >= 0) && FD_ISSET(net_socket, &civfdset)) {
642 SDL_PushEvent(net_user_event);
643 }
644 }
645 }
646 } else { /* If connection is not establish */
647 SDL_Delay(10);
648 }
649 /* ========================================= */
650
651 t_current = SDL_GetTicks();
652
653 if (t_current > real_timer_next_call) {
654 real_timer_next_call = t_current + (real_timer_callback() * 1000);
655 }
656
657 if ((t_current - t_last_unit_anim) > UNITS_TIMER_INTERVAL) {
658 if (autoconnect) {
659 widget_info_counter++;
660 SDL_PushEvent(anim_user_event);
661 } else {
662 SDL_PushEvent(anim_user_event);
663 }
664
665 t_last_unit_anim = SDL_GetTicks();
666 }
667
668 if (is_map_scrolling) {
669 if ((t_current - t_last_map_scrolling) > MAP_SCROLL_TIMER_INTERVAL) {
670 SDL_PushEvent(map_scroll_user_event);
671 t_last_map_scrolling = SDL_GetTicks();
672 }
673 } else {
674 t_last_map_scrolling = SDL_GetTicks();
675 }
676
677 if (widget_info_counter > 0) {
678 SDL_PushEvent(info_user_event);
679 widget_info_counter = 0;
680 }
681
682 /* ========================================= */
683
684 if (loop_action) {
685 loop_action(data);
686 }
687
688 /* ========================================= */
689
690 while (SDL_PollEvent(&main_data.event) == 1) {
691
692 if (main_data.event.type == user_event_type) {
693 switch (main_data.event.user.code) {
694 case NET:
695 input_from_server(net_socket);
696 break;
697 case ANIM:
698 update_button_hold_state();
699 animate_mouse_cursor();
700 draw_mouse_cursor();
701 break;
702 case SHOW_WIDGET_INFO_LABEL:
703 draw_widget_info_label();
704 break;
705 case TRY_AUTO_CONNECT:
706 if (try_to_autoconnect()) {
707 info_user_event->user.code = SHOW_WIDGET_INFO_LABEL;
708 autoconnect = FALSE;
709 }
710 break;
711 case FLUSH:
712 unqueue_flush();
713 break;
714 case MAP_SCROLL:
715 scroll_mapview(scroll_dir);
716 break;
717 case EXIT_FROM_EVENT_LOOP:
718 return MAX_ID;
719 break;
720 default:
721 break;
722 }
723
724 } else {
725
726 switch (main_data.event.type) {
727
728 case SDL_EVENT_QUIT:
729 return MAX_ID;
730 break;
731
732 case SDL_EVENT_KEY_UP:
733 switch (main_data.event.key.keysym.sym) {
734 /* find if Shifts are released */
735 case SDLK_RSHIFT:
736 RSHIFT = FALSE;
737 break;
738 case SDLK_LSHIFT:
739 LSHIFT = FALSE;
740 break;
741 case SDLK_LCTRL:
742 LCTRL = FALSE;
743 break;
744 case SDLK_RCTRL:
745 RCTRL = FALSE;
746 break;
747 case SDLK_LALT:
748 LALT = FALSE;
749 break;
750 default:
751 if (key_up_handler) {
752 ID = key_up_handler(main_data.event.key.keysym, data);
753 }
754 break;
755 }
756 break;
757
758 case SDL_EVENT_KEY_DOWN:
759 switch (main_data.event.key.keysym.sym) {
760#if 0
761 case SDLK_PRINT:
762 fc_snprintf(schot, sizeof(schot), "fc_%05d.bmp", schot_nr++);
763 log_normal(_("Making screenshot %s"), schot);
764 SDL_SaveBMP(main_data.screen, schot);
765 break;
766#endif /* 0 */
767
768 case SDLK_RSHIFT:
769 /* Right Shift is Pressed */
770 RSHIFT = TRUE;
771 break;
772
773 case SDLK_LSHIFT:
774 /* Left Shift is Pressed */
775 LSHIFT = TRUE;
776 break;
777
778 case SDLK_LCTRL:
779 /* Left CTRL is Pressed */
780 LCTRL = TRUE;
781 break;
782
783 case SDLK_RCTRL:
784 /* Right CTRL is Pressed */
785 RCTRL = TRUE;
786 break;
787
788 case SDLK_LALT:
789 /* Left ALT is Pressed */
790 LALT = TRUE;
791 break;
792
793 default:
794 if (key_down_handler) {
795 ID = key_down_handler(main_data.event.key.keysym, data);
796 }
797 break;
798 }
799 break;
800
801 case SDL_EVENT_TEXT_INPUT:
802 if (textinput_handler) {
803 ID = textinput_handler(main_data.event.text.text, data);
804 }
805 break;
806
807 case SDL_EVENT_FINGER_DOWN:
808 if (finger_down_handler) {
809 ID = finger_down_handler(&main_data.event.tfinger, data);
810 }
811 break;
812
813 case SDL_EVENT_FINGER_UP:
814 if (finger_up_handler) {
815 ID = finger_up_handler(&main_data.event.tfinger, data);
816 }
817 break;
818
819 case SDL_EVENT_FINGER_MOTION:
820 if (finger_motion_handler) {
821 ID = finger_motion_handler(&main_data.event.tfinger, data);
822 }
823 break;
824
825 case SDL_EVENT_MOUSE_BUTTON_DOWN:
826 if (mouse_button_down_handler) {
827 ID = mouse_button_down_handler(&main_data.event.button, data);
828 }
829 break;
830
831 case SDL_EVENT_MOUSE_BUTTON_UP:
832 if (mouse_button_up_handler) {
833 ID = mouse_button_up_handler(&main_data.event.button, data);
834 }
835 break;
836
837 case SDL_EVENT_MOUSE_MOTION:
838 if (mouse_motion_handler) {
839 ID = mouse_motion_handler(&main_data.event.motion, data);
840 }
841 break;
842 }
843 }
844 }
845
846 if (ID == ID_ERROR) {
847 if (callbacks && callback_list_size(callbacks) > 0) {
848 struct callback *cb = callback_list_get(callbacks, 0);
849
850 callback_list_remove(callbacks, cb);
851 (cb->callback)(cb->data);
852 free(cb);
853 }
854 }
855
856 update_main_screen();
857 }
858
859 return ID;
860}
861
862/* ============ Freeciv native game function =========== */
863
864/**********************************************************************/
867 void ui_init(void)
868{
869 Uint32 sdl_flags;
870
871 button_behavior.counting = FALSE;
872 button_behavior.button_down_ticks = 0;
873 button_behavior.hold_state = MB_HOLD_SHORT;
874 button_behavior.event = fc_calloc(1, sizeof(SDL_MouseButtonEvent));
875
876 sdl3_client_flags = 0;
877 sdl_flags = SDL_INIT_VIDEO;
878
879 init_sdl(sdl_flags);
880}
881
882/**********************************************************************/
885 static void real_resize_window_callback(void *data)
886{
887 struct widget *widget;
888
889 if (C_S_RUNNING == client_state()) {
890 /* Move units window to botton-right corner. */
891 set_new_unitinfo_window_pos();
892 /* Move minimap window to botton-left corner. */
893 set_new_minimap_window_pos();
894
895 /* Move cooling/warming icons to botton-right corner. */
896 widget = get_widget_pointer_from_main_list(ID_WARMING_ICON);
897 widget_set_position(widget, (main_window_width() - adj_size(10)
898 - (widget->size.w * 2)), widget->size.y);
899
900 widget = get_widget_pointer_from_main_list(ID_COOLING_ICON);
901 widget_set_position(widget, (main_window_width() - adj_size(10)
902 - widget->size.w), widget->size.y);
903
904 map_canvas_resized(main_window_width(), main_window_height());
905 update_info_label();
906 update_unit_info_label(get_units_in_focus());
907 center_on_something(); /* With redrawing full map. */
908 update_order_widgets();
909 } else {
910 draw_intro_gfx();
911 dirty_all();
912 }
913
914 flush_all();
915}
916
917/**********************************************************************/
920 static void resize_window_callback(struct option *poption)
921{
922 update_queue_add(real_resize_window_callback, NULL);
923}
924
925/**********************************************************************/
928 static void fullscreen_callback(struct option *poption)
929{
930 const SDL_DisplayMode *mode;
931
932 if (GUI_SDL_OPTION(fullscreen)) {
933 SDL_SetWindowFullscreen(main_data.screen, SDL_WINDOW_FULLSCREEN);
934 } else {
935 SDL_SetWindowFullscreen(main_data.screen, 0);
936 }
937
938 mode = SDL_GetWindowFullscreenMode(main_data.screen);
939
940 if (!create_surfaces(mode->w, mode->h)) {
941 /* Try to revert */
942 if (!GUI_SDL_OPTION(fullscreen)) {
943 SDL_SetWindowFullscreen(main_data.screen, SDL_WINDOW_FULLSCREEN);
944 } else {
945 SDL_SetWindowFullscreen(main_data.screen, 0);
946 }
947 }
948
949 update_queue_add(real_resize_window_callback, NULL);
950}
951
952/**********************************************************************/
956 void options_extra_init(void)
957{
958 struct option *poption;
959
960#define option_var_set_callback(var, callback) \
961 if ((poption = optset_option_by_name(client_optset, \
962 GUI_SDL_OPTION_STR(var)))) { \
963 option_set_changed_callback(poption, callback); \
964 } else { \
965 log_error("Didn't find option %s!", GUI_SDL_OPTION_STR(var)); \
966 }
967
968 option_var_set_callback(fullscreen, fullscreen_callback);
969 option_var_set_callback(screen, resize_window_callback);
970#undef option_var_set_callback
971}
972
973/**********************************************************************/
977 static void clear_double_messages_call(void)
978{
979 int i;
980
981 /* Clear double call */
982 for (i = 0; i <= event_type_max(); i++) {
983 if (messages_where[i] & MW_MESSAGES) {
984 messages_where[i] &= ~MW_OUTPUT;
985 }
986 }
987}
988
989/**********************************************************************/
994 int main(int argc, char **argv)
995{
996 return client_main(argc, argv, FALSE);
997}
998
999/**********************************************************************/
1002 static void migrate_options_from_sdl2(void)
1003{
1004 log_normal(_("Migrating options from sdl2 to sdl3 client"));
1005
1006#define MIGRATE_OPTION(opt) gui_options.gui_sdl3_##opt = gui_options.gui_sdl2_##opt;
1007#define MIGRATE_STR_OPTION(opt) \
1008 strncpy(gui_options.gui_sdl3_##opt, gui_options.gui_sdl2_##opt, \
1009 sizeof(gui_options.gui_sdl3_##opt));
1010
1011 /* Default theme name is never migrated */
1012 MIGRATE_OPTION(fullscreen);
1013 MIGRATE_OPTION(screen);
1014 MIGRATE_OPTION(swrenderer);
1015 MIGRATE_OPTION(do_cursor_animation);
1016 MIGRATE_OPTION(use_color_cursors);
1017 MIGRATE_STR_OPTION(font_city_names);
1018 MIGRATE_STR_OPTION(font_city_productions);
1019 MIGRATE_OPTION(use_theme_font_size);
1020 MIGRATE_OPTION(font_size);
1021
1022#undef MIGRATE_OPTION
1023
1024 gui_options.gui_sdl3_migrated_from_sdl2 = TRUE;
1025}
1026
1027/**********************************************************************/
1031 int ui_main(int argc, char *argv[])
1032{
1033 Uint32 flags = 0;
1034
1035 if (parse_options(argc, argv)) {
1036 if (!gui_options.gui_sdl3_migrated_from_sdl2) {
1037 migrate_options_from_sdl2();
1038 }
1039 if (!GUI_SDL_OPTION(default_screen_size_set)) {
1040 if (font_size_parameter > 10) {
1041 GUI_SDL_OPTION(screen) = VIDEO_MODE(640 * font_size_parameter / 10,
1042 480 * font_size_parameter / 10);
1043 }
1044
1045 GUI_SDL_OPTION(default_screen_size_set) = TRUE;
1046 }
1047
1048 if (GUI_SDL_OPTION(fullscreen)) {
1049 flags |= SDL_WINDOW_FULLSCREEN;
1050 } else {
1051 flags &= ~SDL_WINDOW_FULLSCREEN;
1052 }
1053
1054 log_normal(_("Using Video Output: %s"), SDL_GetCurrentVideoDriver());
1055 if (!set_video_mode(GUI_SDL_OPTION(screen.width),
1056 GUI_SDL_OPTION(screen.height),
1057 flags)) {
1058 return EXIT_FAILURE;
1059 }
1060
1061 user_event_type = SDL_RegisterEvents(1);
1062
1063 SDL_zero(__net_user_event);
1064 __net_user_event.type = user_event_type;
1065 __net_user_event.user.code = NET;
1066 __net_user_event.user.data1 = NULL;
1067 __net_user_event.user.data2 = NULL;
1068 net_user_event = &__net_user_event;
1069
1070 SDL_zero(__anim_user_event);
1071 __anim_user_event.type = user_event_type;
1072 __anim_user_event.user.code = EVENT_ERROR;
1073 __anim_user_event.user.data1 = NULL;
1074 __anim_user_event.user.data2 = NULL;
1075 anim_user_event = &__anim_user_event;
1076
1077 SDL_zero(__info_user_event);
1078 __info_user_event.type = user_event_type;
1079 __info_user_event.user.code = SHOW_WIDGET_INFO_LABEL;
1080 __info_user_event.user.data1 = NULL;
1081 __info_user_event.user.data2 = NULL;
1082 info_user_event = &__info_user_event;
1083
1084 SDL_zero(__flush_user_event);
1085 __flush_user_event.type = user_event_type;
1086 __flush_user_event.user.code = FLUSH;
1087 __flush_user_event.user.data1 = NULL;
1088 __flush_user_event.user.data2 = NULL;
1089 flush_user_event = &__flush_user_event;
1090
1091 SDL_zero(__map_scroll_user_event);
1092 __map_scroll_user_event.type = user_event_type;
1093 __map_scroll_user_event.user.code = MAP_SCROLL;
1094 __map_scroll_user_event.user.data1 = NULL;
1095 __map_scroll_user_event.user.data2 = NULL;
1096 map_scroll_user_event = &__map_scroll_user_event;
1097
1098 is_unit_move_blocked = FALSE;
1099
1100 sdl3_client_flags |= (CF_DRAW_PLAYERS_NEUTRAL_STATUS
1101 |CF_DRAW_PLAYERS_WAR_STATUS
1102 |CF_DRAW_PLAYERS_CEASEFIRE_STATUS
1103 |CF_DRAW_PLAYERS_PEACE_STATUS
1104 |CF_DRAW_PLAYERS_ALLIANCE_STATUS);
1105
1106 tileset_init(tileset);
1107 tileset_load_tiles(tileset);
1108 tileset_use_preferred_theme(tileset);
1109
1110 load_cursors();
1111
1112 callbacks = callback_list_new();
1113
1114 diplomacy_dialog_init();
1115 intel_dialog_init();
1116
1117 clear_double_messages_call();
1118
1119 setup_auxiliary_tech_icons();
1120
1121 /* This needs correct main_data.screen size */
1122 init_mapcanvas_and_overview();
1123
1124 set_client_state(C_S_DISCONNECTED);
1125
1126 /* Main game loop */
1127 gui_event_loop(NULL, NULL, main_key_down_handler, main_key_up_handler, NULL,
1128 main_finger_down_handler, main_finger_up_handler, NULL,
1129 main_mouse_button_down_handler, main_mouse_button_up_handler,
1130 main_mouse_motion_handler);
1131 start_quitting();
1132
1133 city_map_canvas_free();
1134
1135 free_mapcanvas_and_overview();
1136
1137 free_auxiliary_tech_icons();
1138
1139 diplomacy_dialog_done();
1140 intel_dialog_done();
1141
1142 callback_list_destroy(callbacks);
1143 callbacks = NULL;
1144
1145 unload_cursors();
1146
1147 free(button_behavior.event);
1148 button_behavior.event = NULL;
1149
1150 meswin_dialog_popdown();
1151
1152 del_main_list();
1153
1154 free_font_system();
1155 theme_free(active_theme);
1156 active_theme = NULL;
1157
1158 quit_sdl();
1159 }
1160
1161 return EXIT_SUCCESS;
1162}
1163
1164/**********************************************************************/
1167 void ui_exit(void)
1168{
1169}
1170
1171/**********************************************************************/
1174 enum gui_type get_gui_type(void)
1175{
1176 return GUI_SDL3;
1177}
1178
1179/**********************************************************************/
1183 void sound_bell(void)
1184{
1185 log_debug("sound_bell : PORT ME");
1186}
1187
1188/**********************************************************************/
1191 void enable_focus_animation(void)
1192{
1193 anim_user_event->user.code = ANIM;
1194 sdl3_client_flags |= CF_FOCUS_ANIMATION;
1195}
1196
1197/**********************************************************************/
1200 void disable_focus_animation(void)
1201{
1202 sdl3_client_flags &= ~CF_FOCUS_ANIMATION;
1203}
1204
1205/**********************************************************************/
1209 void add_net_input(int sock)
1210{
1211 log_debug("Connection UP (%d)", sock);
1212 net_socket = sock;
1213 autoconnect = FALSE;
1214 enable_focus_animation();
1215}
1216
1217/**********************************************************************/
1220 void remove_net_input(void)
1221{
1222 log_debug("Connection DOWN... ");
1223 net_socket = (-1);
1224 disable_focus_animation();
1225 draw_goto_patrol_lines = FALSE;
1226 update_mouse_cursor(CURSOR_DEFAULT);
1227}
1228
1229/**********************************************************************/
1234 void add_idle_callback(void (callback)(void *), void *data)
1235{
1236 if (callbacks != NULL) {
1237 struct callback *cb = fc_malloc(sizeof(*cb));
1238
1239 cb->callback = callback;
1240 cb->data = data;
1241
1242 callback_list_prepend(callbacks, cb);
1243 }
1244}
1245
1246/**********************************************************************/
1249 void editgui_tileset_changed(void)
1250{}
1251
1252/**********************************************************************/
1255 void editgui_refresh(void)
1256{}
1257
1258/**********************************************************************/
1261 void editgui_popup_properties(const struct tile_list *tiles, int objtype)
1262{}
1263
1264/**********************************************************************/
1267 void editgui_popdown_all(void)
1268{}
1269
1270/**********************************************************************/
1273 void editgui_notify_object_changed(int objtype, int object_id, bool removal)
1274{}
1275
1276/**********************************************************************/
1279 void editgui_notify_object_created(int tag, int id)
1280{}
1281
1282/**********************************************************************/
1285 void gui_update_font(const char *font_name, const char *font_value)
1286{
1287#define CHECK_FONT(client_font, action) \
1288 do { \
1289 if (strcmp(#client_font, font_name) == 0) { \
1290 char *end; \
1291 long size = strtol(font_value, &end, 10); \
1292 if (end && *end == '\0' && size > 0) { \
1293 *client_font_sizes[client_font] = size; \
1294 action; \
1295 } \
1296 } \
1297 } while (FALSE)
1298
1299 CHECK_FONT(FONT_CITY_NAME, update_city_descriptions());
1300 CHECK_FONT(FONT_CITY_PROD, update_city_descriptions());
1301 /* FONT_REQTREE_TEXT not used yet */
1302
1303#undef CHECK_FONT
1304}
1305
1306/**********************************************************************/
1309 unsigned default_font_size(struct theme *act_theme)
1310{
1311 return font_size_parameter > 0 ? font_size_parameter :
1312 (GUI_SDL_OPTION(use_theme_font_size) ? theme_default_font_size(act_theme) :
1313 GUI_SDL_OPTION(font_size));
1314}
1315
1316/**********************************************************************/
1319 void update_font_from_theme(int theme_font_size)
1320{
1321 *client_font_sizes[FONT_CITY_NAME] = theme_font_size;
1322 *client_font_sizes[FONT_CITY_PROD] = theme_font_size;
1323}
1324
1325/**********************************************************************/
1328 void insert_client_build_info(char *outbuf, size_t outlen)
1329{
1330 /* PORTME */
1331}
1332
1333/**********************************************************************/
1336 bool flush_event(void)
1337{
1338 return SDL_PushEvent(flush_user_event) >= 0;
1339}
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:1182
client_main
int client_main(int argc, char *argv[], bool postpone_tileset)
Definition client_main.c:351
client
struct civclient client
Definition client_main.c:150
client_state
enum client_states client_state(void)
Definition client_main.c:1026
send_report_request
void send_report_request(enum report_type type)
Definition client_main.c:836
start_quitting
void start_quitting(void)
Definition client_main.c:1644
set_client_state
void set_client_state(enum client_states newstate)
Definition client_main.c:844
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:3283
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:78
ui_main
int ui_main(int argc, char **argv)
Definition gui_main.c:1909
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:2088
get_gui_type
enum gui_type get_gui_type(void)
Definition gui_main.c:2099
main
int main(int argc, char **argv)
Definition gui_main.c:1787
ui_init
void ui_init(void)
Definition gui_main.c:1777
add_idle_callback
void add_idle_callback(void(callback)(void *), void *data)
Definition gui_main.c:2427
options_extra_init
void options_extra_init(void)
Definition gui_main.c:2501
insert_client_build_info
void insert_client_build_info(char *outbuf, size_t outlen)
Definition gui_main.c:2561
remove_net_input
void remove_net_input(void)
Definition gui_main.c:2333
sound_bell
void sound_bell(void)
Definition gui_main.c:2107
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:2315
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:358
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:109
main_key_down_handler
static Uint16 main_key_down_handler(SDL_Keysym key, void *data)
Definition gui_main.c:229
__anim_user_event
static SDL_Event __anim_user_event
Definition gui_main.c:129
net_user_event
static SDL_Event * net_user_event
Definition gui_main.c:134
resize_window_callback
static void resize_window_callback(struct option *poption)
Definition gui_main.c:924
fullscreen_callback
static void fullscreen_callback(struct option *poption)
Definition gui_main.c:932
editgui_popup_properties
void editgui_popup_properties(const struct tile_list *tiles, int objtype)
Definition gui_main.c:1257
editgui_notify_object_created
void editgui_notify_object_created(int tag, int id)
Definition gui_main.c:1275
CHECK_FONT
#define CHECK_FONT(client_font, action)
button_behavior
static struct mouse_button_behavior button_behavior
Definition gui_main.c:126
is_unit_move_blocked
bool is_unit_move_blocked
Definition gui_main.c:103
__info_user_event
static SDL_Event __info_user_event
Definition gui_main.c:130
LSHIFT
bool LSHIFT
Definition gui_main.c:104
__flush_user_event
static SDL_Event __flush_user_event
Definition gui_main.c:131
FilterMouseMotionEvents
int FilterMouseMotionEvents(void *data, SDL_Event *event)
Definition gui_main.c:577
info_user_event
static SDL_Event * info_user_event
Definition gui_main.c:136
main_mouse_button_down_handler
static Uint16 main_mouse_button_down_handler(SDL_MouseButtonEvent *button_event, void *data)
Definition gui_main.c:373
__net_user_event
static SDL_Event __net_user_event
Definition gui_main.c:128
enable_focus_animation
void enable_focus_animation(void)
Definition gui_main.c:1187
editgui_popdown_all
void editgui_popdown_all(void)
Definition gui_main.c:1263
flush_event
bool flush_event(void)
Definition gui_main.c:1332
MAP_SCROLL_TIMER_INTERVAL
#define MAP_SCROLL_TIMER_INTERVAL
Definition gui_main.c:87
real_resize_window_callback
static void real_resize_window_callback(void *data)
Definition gui_main.c:889
draw_goto_patrol_lines
bool draw_goto_patrol_lines
Definition mapctrl.c:104
UNITS_TIMER_INTERVAL
#define UNITS_TIMER_INTERVAL
Definition gui_main.c:86
update_button_hold_state
static void update_button_hold_state(void)
Definition gui_main.c:486
is_map_scrolling
static bool is_map_scrolling
Definition gui_main.c:122
map_scroll_user_event
static SDL_Event * map_scroll_user_event
Definition gui_main.c:138
RSHIFT
bool RSHIFT
Definition gui_main.c:105
MOVE_STEP_Y
int MOVE_STEP_Y
Definition gui_main.c:101
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:598
main_finger_down_handler
static Uint16 main_finger_down_handler(SDL_TouchFingerEvent *touch_event, void *data)
Definition gui_main.c:321
SCROLL_MAP_AREA
#define SCROLL_MAP_AREA
Definition gui_main.c:429
widget_info_counter
Uint32 widget_info_counter
Definition gui_main.c:99
main_mouse_motion_handler
static Uint16 main_mouse_motion_handler(SDL_MouseMotionEvent *motion_event, void *data)
Definition gui_main.c:435
anim_user_event
static SDL_Event * anim_user_event
Definition gui_main.c:135
autoconnect
static bool autoconnect
Definition gui_main.c:121
check_scroll_area
static bool check_scroll_area(int x, int y)
Definition gui_main.c:514
net_socket
static int net_socket
Definition gui_main.c:120
main_finger_up_handler
static Uint16 main_finger_up_handler(SDL_TouchFingerEvent *touch_event, void *data)
Definition gui_main.c:349
update_font_from_theme
void update_font_from_theme(int theme_font_size)
Definition gui_main.c:1315
city_productions_font_size
static int city_productions_font_size
Definition gui_main.c:110
LALT
bool LALT
Definition gui_main.c:108
LCTRL
bool LCTRL
Definition gui_main.c:106
default_font_size
unsigned default_font_size(struct theme *act_theme)
Definition gui_main.c:1305
clear_double_messages_call
static void clear_double_messages_call(void)
Definition gui_main.c:981
force_exit_from_event_loop
void force_exit_from_event_loop(void)
Definition gui_main.c:561
disable_focus_animation
void disable_focus_animation(void)
Definition gui_main.c:1196
scroll_dir
static enum direction8 scroll_dir
Definition gui_main.c:123
font_size_parameter
static unsigned font_size_parameter
Definition gui_main.c:117
client_font_sizes
int * client_font_sizes[FONT_COUNT]
Definition gui_main.c:111
editgui_refresh
void editgui_refresh(void)
Definition gui_main.c:1251
user_event_type
int user_event_type
Definition gui_main.c:144
__map_scroll_user_event
static SDL_Event __map_scroll_user_event
Definition gui_main.c:132
flush_user_event
static SDL_Event * flush_user_event
Definition gui_main.c:137
callbacks
struct callback_list * callbacks
Definition gui_main.c:166
USER_EVENT_ID
USER_EVENT_ID
Definition gui_main.c:146
NET
@ NET
Definition gui_main.c:148
ANIM
@ ANIM
Definition gui_main.c:149
TRY_AUTO_CONNECT
@ TRY_AUTO_CONNECT
Definition gui_main.c:150
MAP_SCROLL
@ MAP_SCROLL
Definition gui_main.c:153
FLUSH
@ FLUSH
Definition gui_main.c:152
EVENT_ERROR
@ EVENT_ERROR
Definition gui_main.c:147
EXIT_FROM_EVENT_LOOP
@ EXIT_FROM_EVENT_LOOP
Definition gui_main.c:154
SHOW_WIDGET_INFO_LABEL
@ SHOW_WIDGET_INFO_LABEL
Definition gui_main.c:151
main_key_up_handler
static Uint16 main_key_up_handler(SDL_Keysym key, void *data)
Definition gui_main.c:310
editgui_tileset_changed
void editgui_tileset_changed(void)
Definition gui_main.c:1245
main_mouse_button_up_handler
static Uint16 main_mouse_button_up_handler(SDL_MouseButtonEvent *button_event, void *data)
Definition gui_main.c:409
MOVE_STEP_X
int MOVE_STEP_X
Definition gui_main.c:100
RCTRL
bool RCTRL
Definition gui_main.c:107
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:1002
sdl3_client_flags
Uint32 sdl3_client_flags
Definition gui_main.c:93
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
spaceshipdlg.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:666
scroll_mapview
void scroll_mapview(enum direction8 gui_dir)
Definition mapctrl_common.c:553
init_mapcanvas_and_overview
void init_mapcanvas_and_overview(void)
Definition mapview_common.c:3698
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:3707
map_canvas_resized
bool map_canvas_resized(int width, int height)
Definition mapview_common.c:3607
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:5039
gui_options
struct client_options gui_options
Definition options.c:71
MW_MESSAGES
#define MW_MESSAGES
Definition options.h:579
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:551
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:2404
callback::data
void * data
Definition gui_main.c:2406
callback::callback
void(* callback)(void *data)
Definition gui_main.c:2405
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:137
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:478
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:481
unit
Definition unit.h:138
widget
Definition widget.h:112
widget::key
SDL_Keycode key
Definition widget.h:153
widget::widget
struct widget * widget
Definition widget.h:132
widget::data
union widget::@192 data
widget::size
SDL_Rect size
Definition widget.h:145
fc_snprintf
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:974
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:88
tileset_load_tiles
void tileset_load_tiles(struct tileset *t)
Definition tilespec.c:3632
tileset_use_preferred_theme
void tileset_use_preferred_theme(const struct tileset *t)
Definition tilespec.c:7073
tileset_init
void tileset_init(struct tileset *t)
Definition tilespec.c:7130
tilespec.h
CURSOR_DEFAULT
@ CURSOR_DEFAULT
Definition tilespec.h:300
unit_tile
#define unit_tile(_pu)
Definition unit.h:390
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