Freeciv-3.2
Loading...
Searching...
No Matches
Data Structures | Macros | Enumerations | Functions | Variables
gui_main.c File Reference
#include "fc_prehdrs.h"
#include <errno.h>
#include <SDL3/SDL.h>
#include "fc_cmdline.h"
#include "fciconv.h"
#include "fcintl.h"
#include "log.h"
#include "netintf.h"
#include "unitlist.h"
#include "client_main.h"
#include "climisc.h"
#include "clinet.h"
#include "editgui_g.h"
#include "tilespec.h"
#include "update_queue.h"
#include "zoom.h"
#include "chatline.h"
#include "citydlg.h"
#include "cityrep.h"
#include "diplodlg.h"
#include "graphics.h"
#include "gui_id.h"
#include "gui_mouse.h"
#include "gui_tilespec.h"
#include "inteldlg.h"
#include "mapctrl.h"
#include "mapview.h"
#include "menu.h"
#include "messagewin.h"
#include "optiondlg.h"
#include "repodlgs.h"
#include "themespec.h"
#include "spaceshipdlg.h"
#include "widget.h"
#include "gui_main.h"
#include "speclist.h"

Go to the source code of this file.

Data Structures

struct  callback
 

Macros

#define UNITS_TIMER_INTERVAL   128 /* milliseconds */
 
#define MAP_SCROLL_TIMER_INTERVAL   500
 
#define SPECLIST_TAG   callback
 
#define SPECLIST_TYPE   struct callback
 
#define SCROLL_MAP_AREA   1
 
#define option_var_set_callback(var, callback)
 
#define MIGRATE_OPTION(opt)   gui_options.gui_sdl3_##opt = gui_options.gui_sdl2_##opt;
 
#define MIGRATE_STR_OPTION(opt)
 
#define CHECK_FONT(client_font, action)
 

Enumerations

enum  USER_EVENT_ID {
  EVENT_ERROR = 0 , NET , ANIM , TRY_AUTO_CONNECT ,
  SHOW_WIDGET_INFO_LABEL , FLUSH , MAP_SCROLL , EXIT_FROM_EVENT_LOOP
}
 

Functions

static void print_usage (void)
 
static bool parse_options (int argc, char **argv)
 
static bool check_scroll_area (int x, int y)
 
static Uint16 main_key_down_handler (SDL_KeyboardEvent *key, void *data)
 
static Uint16 main_key_up_handler (SDL_KeyboardEvent *key, void *data)
 
static Uint16 main_finger_down_handler (SDL_TouchFingerEvent *touch_event, void *data)
 
static Uint16 main_finger_up_handler (SDL_TouchFingerEvent *touch_event, void *data)
 
static Uint16 main_mouse_button_down_handler (SDL_MouseButtonEvent *button_event, void *data)
 
static Uint16 main_mouse_button_up_handler (SDL_MouseButtonEvent *button_event, void *data)
 
static Uint16 main_mouse_motion_handler (SDL_MouseMotionEvent *motion_event, void *data)
 
static void update_button_hold_state (void)
 
void force_exit_from_event_loop (void)
 
bool FilterMouseMotionEvents (void *data, SDL_Event *event)
 
Uint16 gui_event_loop (void *data, void(*loop_action)(void *data), Uint16(*key_down_handler)(SDL_KeyboardEvent *key, void *data), Uint16(*key_up_handler)(SDL_KeyboardEvent *key, void *data), Uint16(*textinput_handler)(const char *text, void *data), Uint16(*finger_down_handler)(SDL_TouchFingerEvent *touch_event, void *data), Uint16(*finger_up_handler)(SDL_TouchFingerEvent *touch_event, void *data), Uint16(*finger_motion_handler)(SDL_TouchFingerEvent *touch_event, void *data), Uint16(*mouse_button_down_handler)(SDL_MouseButtonEvent *button_event, void *data), Uint16(*mouse_button_up_handler)(SDL_MouseButtonEvent *button_event, void *data), Uint16(*mouse_motion_handler)(SDL_MouseMotionEvent *motion_event, void *data))
 
void ui_init (void)
 
static void real_resize_window_callback (void *data)
 
static void resize_window_callback (struct option *poption)
 
static void fullscreen_callback (struct option *poption)
 
void options_extra_init (void)
 
static void clear_double_messages_call (void)
 
int main (int argc, char **argv)
 
static void migrate_options_from_sdl2 (void)
 
int ui_main (int argc, char *argv[])
 
void ui_exit (void)
 
enum gui_type get_gui_type (void)
 
void sound_bell (void)
 
void enable_focus_animation (void)
 
void disable_focus_animation (void)
 
void add_net_input (int sock)
 
void remove_net_input (void)
 
void add_idle_callback (void(callback)(void *), void *data)
 
void editgui_tileset_changed (void)
 
void editgui_refresh (void)
 
void editgui_popup_properties (const struct tile_list *tiles, int objtype)
 
void editgui_popdown_all (void)
 
void editgui_notify_object_changed (int objtype, int object_id, bool removal)
 
void editgui_notify_object_created (int tag, int id)
 
void gui_update_font (const char *font_name, const char *font_value)
 
unsigned default_font_size (struct theme *act_theme)
 
void update_font_from_theme (int theme_font_size)
 
void insert_client_build_info (char *outbuf, size_t outlen)
 
bool flush_event (void)
 

Variables

const charclient_string = "gui-sdl3"
 
const char *const gui_character_encoding = "UTF-8"
 
const bool gui_use_transliteration = FALSE
 
Uint32 sdl3_client_flags = 0
 
Uint32 widget_info_counter = 0
 
int MOVE_STEP_X = DEFAULT_MOVE_STEP
 
int MOVE_STEP_Y = DEFAULT_MOVE_STEP
 
bool draw_goto_patrol_lines
 
bool is_unit_move_blocked
 
bool LSHIFT
 
bool RSHIFT
 
bool LCTRL
 
bool RCTRL
 
bool LALT
 
static int city_names_font_size = 10
 
static int city_productions_font_size = 10
 
intclient_font_sizes [FONT_COUNT]
 
static unsigned font_size_parameter = 0
 
static int net_socket = -1
 
static bool autoconnect = FALSE
 
static bool is_map_scrolling = FALSE
 
static enum direction8 scroll_dir
 
static struct finger_behavior finger_behavior
 
static struct mouse_button_behavior button_behavior
 
static SDL_Event __net_user_event
 
static SDL_Event __anim_user_event
 
static SDL_Event __info_user_event
 
static SDL_Event __flush_user_event
 
static SDL_Event __map_scroll_user_event
 
static SDL_Eventnet_user_event = NULL
 
static SDL_Eventanim_user_event = NULL
 
static SDL_Eventinfo_user_event = NULL
 
static SDL_Eventflush_user_event = NULL
 
static SDL_Eventmap_scroll_user_event = NULL
 
int user_event_type
 
struct callback_list * callbacks = NULL
 

Macro Definition Documentation

◆ CHECK_FONT

#define CHECK_FONT (   client_font,
  action 
)
Value:
do { \
char *end; \
long size = strtol(font_value, &end, 10); \
if (end && *end == '\0' && size > 0) { \
action; \
} \
} \
} while (FALSE)
char * incite_cost
Definition comments.c:75
int * client_font_sizes[FONT_COUNT]
Definition gui_main.c:115
const char * font_name
Definition gui_main_g.h:43
size_t size
Definition specvec.h:72
#define FALSE
Definition support.h:47

◆ MAP_SCROLL_TIMER_INTERVAL

#define MAP_SCROLL_TIMER_INTERVAL   500

Definition at line 87 of file gui_main.c.

◆ MIGRATE_OPTION

#define MIGRATE_OPTION (   opt)    gui_options.gui_sdl3_##opt = gui_options.gui_sdl2_##opt;

◆ MIGRATE_STR_OPTION

#define MIGRATE_STR_OPTION (   opt)
Value:
strncpy(gui_options.gui_sdl3_##opt, gui_options.gui_sdl2_##opt, \
sizeof(gui_options.gui_sdl3_##opt));
struct client_options gui_options
Definition options.c:71

◆ option_var_set_callback

#define option_var_set_callback (   var,
  callback 
)
Value:
} else { \
log_error("Didn't find option %s!", GUI_SDL_OPTION_STR(var)); \
}
#define GUI_SDL_OPTION_STR(optname)
Definition gui_main.h:38
const struct option_set * client_optset
Definition options.c:1280
struct option * optset_option_by_name(const struct option_set *poptset, const char *name)
Definition options.c:431

◆ SCROLL_MAP_AREA

#define SCROLL_MAP_AREA   1

Definition at line 428 of file gui_main.c.

◆ SPECLIST_TAG

#define SPECLIST_TAG   callback

Definition at line 162 of file gui_main.c.

◆ SPECLIST_TYPE

#define SPECLIST_TYPE   struct callback

Definition at line 163 of file gui_main.c.

◆ UNITS_TIMER_INTERVAL

#define UNITS_TIMER_INTERVAL   128 /* milliseconds */

Definition at line 86 of file gui_main.c.

Enumeration Type Documentation

◆ USER_EVENT_ID

Enumerator
EVENT_ERROR 
NET 
ANIM 
TRY_AUTO_CONNECT 
SHOW_WIDGET_INFO_LABEL 
FLUSH 
MAP_SCROLL 
EXIT_FROM_EVENT_LOOP 

Definition at line 146 of file gui_main.c.

Function Documentation

◆ add_idle_callback()

void add_idle_callback ( void(callback)(void *)  ,
void data 
)

Enqueue a callback to be called during an idle moment. The 'callback' function should be called sometimes soon, and passed the 'data' pointer as its data.

Definition at line 1240 of file gui_main.c.

◆ add_net_input()

void add_net_input ( int  sock)

Wait for data on the given socket. Call input_from_server() when data is ready to be read.

Definition at line 1215 of file gui_main.c.

◆ check_scroll_area()

static bool check_scroll_area ( int  x,
int  y 
)
static

Check if coordinate is in scroll area.

Definition at line 513 of file gui_main.c.

◆ clear_double_messages_call()

static void clear_double_messages_call ( void  )
static

Remove double messages caused by message configured to both MW_MESSAGES and MW_OUTPUT.

Definition at line 984 of file gui_main.c.

◆ default_font_size()

unsigned default_font_size ( struct theme act_theme)

Return default font size, from any source.

Definition at line 1315 of file gui_main.c.

◆ disable_focus_animation()

void disable_focus_animation ( void  )

Don't show Focused Unit Animation.

Definition at line 1206 of file gui_main.c.

◆ editgui_notify_object_changed()

void editgui_notify_object_changed ( int  objtype,
int  object_id,
bool  removal 
)

Stub for editor function

Definition at line 1279 of file gui_main.c.

◆ editgui_notify_object_created()

void editgui_notify_object_created ( int  tag,
int  id 
)

Stub for editor function

Definition at line 1285 of file gui_main.c.

◆ editgui_popdown_all()

void editgui_popdown_all ( void  )

Stub for editor function

Definition at line 1273 of file gui_main.c.

◆ editgui_popup_properties()

void editgui_popup_properties ( const struct tile_list tiles,
int  objtype 
)

Stub for editor function

Definition at line 1267 of file gui_main.c.

◆ editgui_refresh()

void editgui_refresh ( void  )

Stub for editor function

Definition at line 1261 of file gui_main.c.

◆ editgui_tileset_changed()

void editgui_tileset_changed ( void  )

Stub for editor function

Definition at line 1255 of file gui_main.c.

◆ enable_focus_animation()

void enable_focus_animation ( void  )

Show Focused Unit Animation.

Definition at line 1197 of file gui_main.c.

◆ FilterMouseMotionEvents()

bool FilterMouseMotionEvents ( void data,
SDL_Event event 
)

Filter out mouse motion events for too small movement to react to. This function may run in a separate event thread.

Definition at line 576 of file gui_main.c.

◆ flush_event()

bool flush_event ( void  )

Queue a flush event to be handled later by SDL.

Definition at line 1342 of file gui_main.c.

◆ force_exit_from_event_loop()

void force_exit_from_event_loop ( void  )

Instruct event loop to exit.

Definition at line 560 of file gui_main.c.

◆ fullscreen_callback()

static void fullscreen_callback ( struct option poption)
static

Change fullscreen status after option changed.

Definition at line 935 of file gui_main.c.

◆ get_gui_type()

enum gui_type get_gui_type ( void  )

Return our GUI type

Definition at line 1180 of file gui_main.c.

◆ gui_event_loop()

Uint16 gui_event_loop ( void data,
void(*)(void *data)  loop_action,
Uint16(*)(SDL_KeyboardEvent *key, void *data)  key_down_handler,
Uint16(*)(SDL_KeyboardEvent *key, void *data)  key_up_handler,
Uint16(*)(const char *text, void *data)  textinput_handler,
Uint16(*)(SDL_TouchFingerEvent *touch_event, void *data)  finger_down_handler,
Uint16(*)(SDL_TouchFingerEvent *touch_event, void *data)  finger_up_handler,
Uint16(*)(SDL_TouchFingerEvent *touch_event, void *data)  finger_motion_handler,
Uint16(*)(SDL_MouseButtonEvent *button_event, void *data)  mouse_button_down_handler,
Uint16(*)(SDL_MouseButtonEvent *button_event, void *data)  mouse_button_up_handler,
Uint16(*)(SDL_MouseMotionEvent *motion_event, void *data)  mouse_motion_handler 
)

SDL3-client main loop.

Definition at line 597 of file gui_main.c.

◆ gui_update_font()

void gui_update_font ( const char font_name,
const char font_value 
)

Updates a gui font style.

Definition at line 1291 of file gui_main.c.

◆ insert_client_build_info()

void insert_client_build_info ( char outbuf,
size_t  outlen 
)

Insert build information to help

Definition at line 1334 of file gui_main.c.

◆ main()

int main ( int  argc,
char **  argv 
)

Entry point for freeciv client program. SDL has macro magic to turn this in to function named SDL_main() and it provides actual main() itself.

Definition at line 1001 of file gui_main.c.

◆ main_finger_down_handler()

static Uint16 main_finger_down_handler ( SDL_TouchFingerEvent touch_event,
void data 
)
static

Main finger down handler.

Definition at line 319 of file gui_main.c.

◆ main_finger_up_handler()

static Uint16 main_finger_up_handler ( SDL_TouchFingerEvent touch_event,
void data 
)
static

Main finger release handler.

Definition at line 348 of file gui_main.c.

◆ main_key_down_handler()

static Uint16 main_key_down_handler ( SDL_KeyboardEvent key,
void data 
)
static

Main handler for key presses

Definition at line 226 of file gui_main.c.

◆ main_key_up_handler()

static Uint16 main_key_up_handler ( SDL_KeyboardEvent key,
void data 
)
static

Main key release handler.

Definition at line 307 of file gui_main.c.

◆ main_mouse_button_down_handler()

static Uint16 main_mouse_button_down_handler ( SDL_MouseButtonEvent button_event,
void data 
)
static

Main mouse click handler.

Definition at line 372 of file gui_main.c.

◆ main_mouse_button_up_handler()

static Uint16 main_mouse_button_up_handler ( SDL_MouseButtonEvent button_event,
void data 
)
static

Main mouse button release handler.

Definition at line 408 of file gui_main.c.

◆ main_mouse_motion_handler()

static Uint16 main_mouse_motion_handler ( SDL_MouseMotionEvent motion_event,
void data 
)
static

Main handler for mouse movement handling.

Definition at line 434 of file gui_main.c.

◆ migrate_options_from_sdl2()

static void migrate_options_from_sdl2 ( void  )
static

Migrate sdl3 client specific options from sdl2 client options.

Definition at line 1009 of file gui_main.c.

Referenced by ui_main().

◆ options_extra_init()

void options_extra_init ( void  )

Extra initializers for client options. Here we make set the callback for the specific gui-sdl3 options.

Definition at line 963 of file gui_main.c.

◆ parse_options()

static bool parse_options ( int  argc,
char **  argv 
)
static

Search for gui-specific command-line options.

Definition at line 190 of file gui_main.c.

◆ print_usage()

static void print_usage ( void  )
static

Print extra usage information, including one line help on each option, to stderr.

Definition at line 174 of file gui_main.c.

◆ real_resize_window_callback()

static void real_resize_window_callback ( void data)
static

Really resize the main window.

Definition at line 892 of file gui_main.c.

◆ remove_net_input()

void remove_net_input ( void  )

Stop waiting for any server network data. See add_net_input().

Definition at line 1226 of file gui_main.c.

◆ resize_window_callback()

static void resize_window_callback ( struct option poption)
static

Resize the main window after option changed.

Definition at line 927 of file gui_main.c.

◆ sound_bell()

void sound_bell ( void  )

Make a bell noise (beep). This provides low-level sound alerts even if there is no real sound support.

Definition at line 1189 of file gui_main.c.

◆ ui_exit()

void ui_exit ( void  )

Do any necessary UI-specific cleanup

Definition at line 1173 of file gui_main.c.

◆ ui_init()

void ui_init ( void  )

Do any necessary pre-initialization of the UI, if necessary.

Definition at line 874 of file gui_main.c.

◆ ui_main()

int ui_main ( int  argc,
char argv[] 
)

The main loop for the UI. This is called from main(), and when it exits the client will exit.

Definition at line 1037 of file gui_main.c.

◆ update_button_hold_state()

static void update_button_hold_state ( void  )
static

This is called every TIMER_INTERVAL milliseconds whilst we are in gui_main_loop() (which is all of the time) TIMER_INTERVAL needs to be .5s

Definition at line 485 of file gui_main.c.

◆ update_font_from_theme()

void update_font_from_theme ( int  theme_font_size)

Update font sizes based on theme.

Definition at line 1325 of file gui_main.c.

Variable Documentation

◆ __anim_user_event

SDL_Event __anim_user_event
static

Definition at line 129 of file gui_main.c.

◆ __flush_user_event

SDL_Event __flush_user_event
static

Definition at line 131 of file gui_main.c.

◆ __info_user_event

SDL_Event __info_user_event
static

Definition at line 130 of file gui_main.c.

◆ __map_scroll_user_event

SDL_Event __map_scroll_user_event
static

Definition at line 132 of file gui_main.c.

◆ __net_user_event

SDL_Event __net_user_event
static

Definition at line 128 of file gui_main.c.

◆ anim_user_event

SDL_Event* anim_user_event = NULL
static

Definition at line 135 of file gui_main.c.

◆ autoconnect

bool autoconnect = FALSE
static

Definition at line 121 of file gui_main.c.

◆ button_behavior

struct mouse_button_behavior button_behavior
static

Definition at line 126 of file gui_main.c.

◆ callbacks

struct callback_list* callbacks = NULL

Definition at line 166 of file gui_main.c.

◆ city_names_font_size

int city_names_font_size = 10
static

Definition at line 109 of file gui_main.c.

◆ city_productions_font_size

int city_productions_font_size = 10
static

Definition at line 110 of file gui_main.c.

◆ client_font_sizes

int* client_font_sizes[FONT_COUNT]
Initial value:
= {
}
static int city_names_font_size
Definition gui_main.c:113
static int city_productions_font_size
Definition gui_main.c:114

Definition at line 111 of file gui_main.c.

◆ client_string

const char* client_string = "gui-sdl3"

Definition at line 89 of file gui_main.c.

◆ draw_goto_patrol_lines

bool draw_goto_patrol_lines
extern

◆ finger_behavior

Definition at line 125 of file gui_main.c.

◆ flush_user_event

SDL_Event* flush_user_event = NULL
static

Definition at line 137 of file gui_main.c.

◆ font_size_parameter

unsigned font_size_parameter = 0
static

Definition at line 117 of file gui_main.c.

◆ gui_character_encoding

const char* const gui_character_encoding = "UTF-8"

Definition at line 94 of file gui_main.c.

◆ gui_use_transliteration

const bool gui_use_transliteration = FALSE

Definition at line 95 of file gui_main.c.

◆ info_user_event

SDL_Event* info_user_event = NULL
static

Definition at line 136 of file gui_main.c.

◆ is_map_scrolling

bool is_map_scrolling = FALSE
static

Definition at line 122 of file gui_main.c.

◆ is_unit_move_blocked

bool is_unit_move_blocked

◆ LALT

bool LALT

Definition at line 108 of file gui_main.c.

◆ LCTRL

bool LCTRL

Definition at line 106 of file gui_main.c.

◆ LSHIFT

bool LSHIFT

Definition at line 104 of file gui_main.c.

◆ map_scroll_user_event

SDL_Event* map_scroll_user_event = NULL
static

Definition at line 138 of file gui_main.c.

◆ MOVE_STEP_X

int MOVE_STEP_X = DEFAULT_MOVE_STEP

Definition at line 100 of file gui_main.c.

◆ MOVE_STEP_Y

int MOVE_STEP_Y = DEFAULT_MOVE_STEP

Definition at line 101 of file gui_main.c.

◆ net_socket

int net_socket = -1
static

Definition at line 120 of file gui_main.c.

◆ net_user_event

SDL_Event* net_user_event = NULL
static

Definition at line 134 of file gui_main.c.

◆ RCTRL

bool RCTRL

Definition at line 107 of file gui_main.c.

◆ RSHIFT

bool RSHIFT

Definition at line 105 of file gui_main.c.

◆ scroll_dir

enum direction8 scroll_dir
static

Definition at line 123 of file gui_main.c.

◆ sdl3_client_flags

Uint32 sdl3_client_flags = 0

◆ user_event_type

int user_event_type

Definition at line 144 of file gui_main.c.

◆ widget_info_counter

Uint32 widget_info_counter = 0