Freeciv-3.1
|
#include "fc_prehdrs.h"
#include <errno.h>
#include <SDL2/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_sdl2_##opt = gui_options.gui_sdl_##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 int | check_scroll_area (int x, int y) |
static Uint16 | main_key_down_handler (SDL_Keysym key, void *data) |
static Uint16 | main_key_up_handler (SDL_Keysym 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) |
int | FilterMouseMotionEvents (void *data, SDL_Event *event) |
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)) |
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_sdl (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) |
#define CHECK_FONT | ( | client_font, | |
action | |||
) |
#define MAP_SCROLL_TIMER_INTERVAL 500 |
Definition at line 87 of file gui_main.c.
#define MIGRATE_OPTION | ( | opt | ) | gui_options.gui_sdl2_##opt = gui_options.gui_sdl_##opt; |
#define option_var_set_callback | ( | var, | |
callback | |||
) |
#define SCROLL_MAP_AREA 1 |
Definition at line 428 of file gui_main.c.
#define SPECLIST_TAG callback |
Definition at line 162 of file gui_main.c.
#define SPECLIST_TYPE struct callback |
Definition at line 163 of file gui_main.c.
#define UNITS_TIMER_INTERVAL 128 /* milliseconds */ |
Definition at line 86 of file gui_main.c.
enum 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.
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 1220 of file gui_main.c.
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 1195 of file gui_main.c.
|
static |
Check if coordinate is in scroll area.
Definition at line 513 of file gui_main.c.
Referenced by main_mouse_button_down_handler(), and main_mouse_motion_handler().
|
static |
Remove double messages caused by message configured to both MW_MESSAGES and MW_OUTPUT.
Definition at line 975 of file gui_main.c.
Referenced by ui_main().
unsigned default_font_size | ( | struct theme * | act_theme | ) |
Return default font size, from any source.
Definition at line 1295 of file gui_main.c.
Referenced by gui_load_theme().
void disable_focus_animation | ( | void | ) |
Don't show Focused Unit Animation.
Definition at line 1186 of file gui_main.c.
Referenced by end_turn_callback(), main_key_down_handler(), remove_net_input(), and update_unit_info_label().
void editgui_notify_object_changed | ( | int | objtype, |
int | object_id, | ||
bool | removal | ||
) |
Stub for editor function
Definition at line 1259 of file gui_main.c.
void editgui_notify_object_created | ( | int | tag, |
int | id | ||
) |
Stub for editor function
Definition at line 1265 of file gui_main.c.
void editgui_popdown_all | ( | void | ) |
Stub for editor function
Definition at line 1253 of file gui_main.c.
void editgui_popup_properties | ( | const struct tile_list * | tiles, |
int | objtype | ||
) |
Stub for editor function
Definition at line 1247 of file gui_main.c.
void editgui_refresh | ( | void | ) |
Stub for editor function
Definition at line 1241 of file gui_main.c.
void editgui_tileset_changed | ( | void | ) |
Stub for editor function
Definition at line 1235 of file gui_main.c.
void enable_focus_animation | ( | void | ) |
Show Focused Unit Animation.
Definition at line 1177 of file gui_main.c.
Referenced by add_net_input(), and update_unit_info_label().
int 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 572 of file gui_main.c.
Referenced by factor_horiz_cma_callback(), horiz_taxrate_callback(), min_horiz_cma_callback(), move_window(), and vertic_scroll_widget_list().
bool flush_event | ( | void | ) |
Queue a flush event to be handled later by SDL.
Definition at line 1321 of file gui_main.c.
Referenced by queue_flush().
void force_exit_from_event_loop | ( | void | ) |
Instruct event loop to exit.
Definition at line 556 of file gui_main.c.
Referenced by exit_callback(), popdown_conn_list_dialog(), and races_toggles_set_sensitive().
|
static |
Change fullscreen status after option changed.
Definition at line 927 of file gui_main.c.
Referenced by options_extra_init().
enum gui_type get_gui_type | ( | void | ) |
Return our GUI type
Definition at line 1160 of file gui_main.c.
Uint16 gui_event_loop | ( | void * | data, |
void(*)(void *data) | loop_action, | ||
Uint16(*)(SDL_Keysym key, void *data) | key_down_handler, | ||
Uint16(*)(SDL_Keysym key, void *data) | key_up_handler, | ||
Uint16(*)(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 | ||
) |
SDL2-client main loop.
Definition at line 593 of file gui_main.c.
Referenced by down_scroll_widget_list(), edit_field(), factor_horiz_cma_callback(), horiz_taxrate_callback(), min_horiz_cma_callback(), move_window(), ui_main(), up_scroll_widget_list(), and vertic_scroll_widget_list().
void gui_update_font | ( | const char * | font_name, |
const char * | font_value | ||
) |
Updates a gui font style.
Definition at line 1271 of file gui_main.c.
void insert_client_build_info | ( | char * | outbuf, |
size_t | outlen | ||
) |
Insert build information to help
Definition at line 1313 of file gui_main.c.
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 992 of file gui_main.c.
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
Main mouse button release handler.
Definition at line 408 of file gui_main.c.
Referenced by ui_main().
|
static |
Main handler for mouse movement handling.
Definition at line 434 of file gui_main.c.
Referenced by ui_main().
|
static |
Migrate sdl2 client specific options from sdl client options.
Definition at line 1000 of file gui_main.c.
Referenced by ui_main().
void options_extra_init | ( | void | ) |
Extra initializers for client options. Here we make set the callback for the specific gui-sdl2 options.
Definition at line 955 of file gui_main.c.
|
static |
Search for gui-specific command-line options.
Definition at line 191 of file gui_main.c.
|
static |
Print extra usage information, including one line help on each option, to stderr.
Definition at line 174 of file gui_main.c.
|
static |
Really resize the main window.
Definition at line 884 of file gui_main.c.
Referenced by fullscreen_callback(), and resize_window_callback().
void remove_net_input | ( | void | ) |
Stop waiting for any server network data. See add_net_input().
Definition at line 1206 of file gui_main.c.
|
static |
Resize the main window after option changed.
Definition at line 919 of file gui_main.c.
Referenced by options_extra_init().
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 1169 of file gui_main.c.
void ui_exit | ( | void | ) |
Do any necessary UI-specific cleanup
Definition at line 1153 of file gui_main.c.
void ui_init | ( | void | ) |
Do any necessary pre-initialization of the UI, if necessary.
Definition at line 866 of file gui_main.c.
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 1021 of file gui_main.c.
|
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.
Referenced by gui_event_loop().
void update_font_from_theme | ( | int | theme_font_size | ) |
Update font sizes based on theme.
Definition at line 1304 of file gui_main.c.
Referenced by gui_load_theme().
|
static |
Definition at line 129 of file gui_main.c.
Referenced by ui_main().
|
static |
Definition at line 131 of file gui_main.c.
Referenced by ui_main().
|
static |
Definition at line 130 of file gui_main.c.
Referenced by ui_main().
|
static |
Definition at line 132 of file gui_main.c.
Referenced by ui_main().
|
static |
Definition at line 128 of file gui_main.c.
Referenced by ui_main().
|
static |
Definition at line 135 of file gui_main.c.
Referenced by enable_focus_animation(), gui_event_loop(), and ui_main().
Definition at line 121 of file gui_main.c.
Referenced by add_net_input(), and gui_event_loop().
|
static |
Definition at line 126 of file gui_main.c.
Referenced by button_down_on_map(), button_up_on_map(), main_mouse_button_down_handler(), main_mouse_button_up_handler(), main_mouse_motion_handler(), ui_init(), ui_main(), and update_button_hold_state().
struct callback_list* callbacks = NULL |
Definition at line 166 of file gui_main.c.
Referenced by add_idle_callback(), gui_event_loop(), and ui_main().
|
static |
Definition at line 109 of file gui_main.c.
|
static |
Definition at line 110 of file gui_main.c.
int* client_font_sizes[FONT_COUNT] |
Definition at line 111 of file gui_main.c.
Referenced by canvas_put_text(), get_text_size(), and update_font_from_theme().
const char* client_string = "gui-sdl2" |
Definition at line 89 of file gui_main.c.
|
extern |
Definition at line 104 of file mapctrl.c.
Referenced by button_down_on_map(), button_up_on_map(), create_line_at_mouse_pos(), main_mouse_motion_handler(), map_event_handler(), and remove_net_input().
|
static |
Definition at line 125 of file gui_main.c.
|
static |
Definition at line 137 of file gui_main.c.
Referenced by flush_event(), and ui_main().
|
static |
Definition at line 117 of file gui_main.c.
Referenced by default_font_size(), and parse_options().
const char* const gui_character_encoding = "UTF-8" |
Definition at line 94 of file gui_main.c.
Definition at line 95 of file gui_main.c.
|
static |
Definition at line 136 of file gui_main.c.
Referenced by gui_event_loop(), and ui_main().
Definition at line 122 of file gui_main.c.
Referenced by check_scroll_area(), gui_event_loop(), main_finger_up_handler(), and main_mouse_button_up_handler().
bool is_unit_move_blocked |
Definition at line 103 of file gui_main.c.
Referenced by exit_unit_select_callback(), map_event_handler(), popdown_advanced_terrain_dialog(), popdown_bribe_dialog(), popdown_connect_dialog(), popdown_diplomat_dialog(), popdown_incite_dialog(), popdown_pillage_dialog(), popup_action_selection(), popup_advanced_terrain_dialog(), popup_bribe_dialog(), popup_incite_dialog(), popup_pillage_dialog(), popup_sabotage_dialog(), ui_main(), unit_select_dialog_popdown(), and unit_select_dialog_popup().
bool LALT |
Definition at line 108 of file gui_main.c.
Referenced by button_up_on_map(), and gui_event_loop().
bool LCTRL |
Definition at line 106 of file gui_main.c.
Referenced by button_up_on_map(), gui_event_loop(), and map_event_handler().
bool LSHIFT |
Definition at line 104 of file gui_main.c.
Referenced by button_up_on_map(), gui_event_loop(), main_key_down_handler(), and map_event_handler().
|
static |
Definition at line 138 of file gui_main.c.
Referenced by gui_event_loop(), and ui_main().
int MOVE_STEP_X = DEFAULT_MOVE_STEP |
Definition at line 100 of file gui_main.c.
Referenced by factor_horiz_cma_callback(), FilterMouseMotionEvents(), min_horiz_cma_callback(), and vertic_scroll_widget_list().
int MOVE_STEP_Y = DEFAULT_MOVE_STEP |
Definition at line 101 of file gui_main.c.
Referenced by factor_horiz_cma_callback(), FilterMouseMotionEvents(), horiz_taxrate_callback(), min_horiz_cma_callback(), and vertic_scroll_widget_list().
|
static |
Definition at line 120 of file gui_main.c.
Referenced by add_net_input(), gui_event_loop(), and remove_net_input().
|
static |
Definition at line 134 of file gui_main.c.
Referenced by gui_event_loop(), and ui_main().
bool RCTRL |
Definition at line 107 of file gui_main.c.
Referenced by gui_event_loop(), and map_event_handler().
bool RSHIFT |
Definition at line 105 of file gui_main.c.
Referenced by gui_event_loop(), main_key_down_handler(), and map_event_handler().
|
static |
Definition at line 123 of file gui_main.c.
Referenced by check_scroll_area(), and gui_event_loop().
Uint32 sdl2_client_flags = 0 |
Definition at line 97 of file gui_main.c.
Referenced by close_game_page(), create_surfaces(), create_units_order_widgets(), delete_units_order_widgets(), disable_focus_animation(), economy_report_dialog_popup(), enable_focus_animation(), horiz_taxrate_callback(), is_focus_anim_enabled(), minimap_window_callback(), new_name_city_dlg_callback(), parse_options(), popdown_city_dialog(), popdown_minimap_window(), popdown_unitinfo_window(), popup_minimap_window(), popup_players_dialog(), popup_unitinfo_window(), real_city_dialog_popup(), real_menus_update(), real_players_dialog_update(), redraw_city_dialog(), redraw_unit_info_label(), refresh_city_names(), refresh_overview(), set_new_unitinfo_window_pos(), show_game_page(), toggle_block_callback(), toggle_draw_alliance_status_callback(), toggle_draw_ceasefire_status_callback(), toggle_draw_neutral_status_callback(), toggle_draw_peace_status_callback(), toggle_draw_war_status_callback(), toggle_map_window_callback(), toggle_unit_info_window_callback(), ui_init(), and ui_main().
int user_event_type |
Definition at line 144 of file gui_main.c.
Referenced by force_exit_from_event_loop(), gui_event_loop(), and ui_main().
Uint32 widget_info_counter = 0 |
Definition at line 99 of file gui_main.c.
Referenced by gui_event_loop(), unselect_widget_action(), widget_pressed_action(), and widget_selected_action().