Crossfire Client, Trunk
Macros | Functions | Variables
config.c File Reference
#include "client.h"
#include <ctype.h>
#include <gtk/gtk.h>
#include "image.h"
#include "main.h"
#include "mapdata.h"
#include "gtk2proto.h"
Include dependency graph for config.c:

Go to the source code of this file.

Macros

#define THEME_DEFAULT   CF_DATADIR "/themes/Standard"
 

Functions

static void combo_box_text_remove_all (GtkComboBoxText *combo_box)
 
static int combobox_get_value (GtkComboBox *combobox, int column)
 
void config_check ()
 
void config_init (GtkWidget *window_root)
 
void config_load ()
 
static void config_load_legacy ()
 
void init_theme ()
 
static bool IS_DIFFERENT (int type)
 
void load_theme (int reload)
 
void load_window_positions (GtkWidget *window_root)
 
static void on_config_close (GtkButton *button, gpointer user_data)
 
void on_configure_activate (GtkWidget *menuitem, gpointer user_data)
 
void on_save_window_position_activate (GtkMenuItem *menuitem, gpointer user_data)
 
static void read_config_dialog (void)
 
void save_defaults ()
 
void save_winpos ()
 
static void setup_config_dialog ()
 
static char * ui_name ()
 

Variables

static GKeyFile * config
 
GtkWidget * config_button_cache
 
GtkWidget * config_button_download
 
GtkWidget * config_button_echo
 
GtkWidget * config_button_fasttcp
 
GtkWidget * config_button_fog
 
GtkWidget * config_button_foodbeep
 
GtkWidget * config_button_grad_color
 
GtkWidget * config_button_smoothing
 
GtkWidget * config_button_sound
 
GtkWidget * config_button_timestamp
 
GtkComboBox * config_combobox_displaymode
 
GtkComboBoxText * config_combobox_faceset
 
GtkComboBox * config_combobox_lighting
 
GtkWidget * config_dialog
 
static GString * config_path
 
static char ** default_files = NULL
 
char * last_server
 
int predict_alpha = 10
 
static char * theme
 
GtkFileChooser * theme_filechooser
 
bool time_map_redraw = false
 
GtkFileChooser * ui_filechooser
 

Detailed Description

Implement client configuration dialog

Definition in file config.c.

Macro Definition Documentation

◆ THEME_DEFAULT

#define THEME_DEFAULT   CF_DATADIR "/themes/Standard"

Definition at line 41 of file config.c.

Function Documentation

◆ combo_box_text_remove_all()

static void combo_box_text_remove_all ( GtkComboBoxText *  combo_box)
static

Removes all the text entries from the combo box. This function is not available in GTK+2, so implement it ourselves.

Definition at line 608 of file config.c.

Referenced by setup_config_dialog().

Here is the caller graph for this function:

◆ combobox_get_value()

static int combobox_get_value ( GtkComboBox *  combobox,
int  column 
)
static

Get an integer value from 'column' of the active field in 'combobox'.

Definition at line 688 of file config.c.

Referenced by read_config_dialog().

Here is the caller graph for this function:

◆ config_init()

void config_init ( GtkWidget *  window_root)

◆ config_load()

void config_load ( )

Load settings from the user's configuration file into want_config.

Definition at line 442 of file config.c.

References config, config_dir, config_load_legacy(), config_names, CONFIG_NUMS, config_path, face_info, last_server, LOG(), LOG_DEBUG, predict_alpha, theme, THEME_DEFAULT, use_config, want_config, Face_Information_struct::want_faceset, and window_xml_file.

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ config_load_legacy()

static void config_load_legacy ( )
static

Load settings from the legacy file format.

Definition at line 217 of file config.c.

References CFG_DM_SDL, CFG_LT_PIXEL, CFG_LT_TILE, CONFIG_DISPLAYMODE, CONFIG_LIGHTING, CONFIG_MAPHEIGHT, CONFIG_MAPWIDTH, config_names, CONFIG_NUMS, CONFIG_POPUPS, CONFIG_RESISTS, CONFIG_SPLASH, face_info, LOG(), LOG_INFO, LOG_WARNING, MAX_BUF, theme, want_config, Face_Information_struct::want_faceset, and window_xml_file.

Referenced by config_load().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ init_theme()

void init_theme ( )

Definition at line 92 of file config.c.

References config_dir, default_files, MAX_BUF, and ui_name().

Referenced by init_ui().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ IS_DIFFERENT()

static bool IS_DIFFERENT ( int  type)
static

Definition at line 58 of file config.c.

References use_config, and want_config.

Referenced by read_config_dialog().

Here is the caller graph for this function:

◆ load_theme()

void load_theme ( int  reload)

◆ load_window_positions()

void load_window_positions ( GtkWidget *  window_root)

Resize the client window and its panels using saved window positions.

Parameters
window_rootThe client's main window.

Definition at line 848 of file config.c.

References config, ui_name(), window_root, and window_xml.

Referenced by init_ui().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ on_config_close()

static void on_config_close ( GtkButton *  button,
gpointer  user_data 
)
static

Definition at line 783 of file config.c.

References config_check(), config_dialog, read_config_dialog(), and save_defaults().

Referenced by config_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ on_configure_activate()

void on_configure_activate ( GtkWidget *  menuitem,
gpointer  user_data 
)

Definition at line 778 of file config.c.

References config_dialog, and setup_config_dialog().

Referenced by init_menu_items(), and metaserver_ui_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ on_save_window_position_activate()

void on_save_window_position_activate ( GtkMenuItem *  menuitem,
gpointer  user_data 
)

Handles saving of the window positions when the Client | Save Window Position menu item is activated.

Parameters
menuitem
user_data

Definition at line 834 of file config.c.

References save_winpos().

Referenced by init_menu_items().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ read_config_dialog()

static void read_config_dialog ( void  )
static

This is basically the opposite of setup_config_dialog() above - instead of setting the display state appropriately, we read the display state and update the want_config values.

Since the combo box does not have the "has-entry" property set to TRUE, we cannot use gtk_combo_box_text_get_active_text to get the currently selected option. Since we really have no good reason to turn that on and open up the box for arbitrary faceset strings, we can treat it more like a regular combo box. We need to use an iterator retrieval and gtk_tree_model_get to fetch the text, which is significantly more of a pain in the posterior.

Daniel Hawkins – 2020-11-21

Definition at line 703 of file config.c.

References combobox_get_value(), config_button_cache, config_button_download, config_button_echo, config_button_fasttcp, config_button_fog, config_button_foodbeep, config_button_grad_color, config_button_smoothing, config_button_sound, config_button_timestamp, CONFIG_CACHE, config_combobox_displaymode, config_combobox_faceset, config_combobox_lighting, CONFIG_DISPLAYMODE, CONFIG_DOWNLOAD, CONFIG_ECHO, CONFIG_FASTTCP, CONFIG_FOGWAR, CONFIG_FOODBEEP, CONFIG_GRAD_COLOR, CONFIG_LIGHTING, CONFIG_SMOOTH, CONFIG_SOUND, CONFIG_TIMESTAMP, draw_stats(), face_info, IS_DIFFERENT(), load_theme(), LOG(), LOG_ERROR, theme, theme_filechooser, ui_filechooser, want_config, Face_Information_struct::want_faceset, and window_xml_file.

Referenced by on_config_close().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ save_defaults()

void save_defaults ( )

This function saves user settings chosen using the configuration popup dialog.

Definition at line 513 of file config.c.

References config, config_names, CONFIG_NUMS, config_path, draw_ext_info(), face_info, last_server, MSG_TYPE_CLIENT, MSG_TYPE_CLIENT_CONFIG, NDI_RED, predict_alpha, theme, want_config, Face_Information_struct::want_faceset, and window_xml_file.

Referenced by do_savedefaults(), metaserver_connect_to(), on_auto_afk_response(), on_config_close(), and save_winpos().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ save_winpos()

void save_winpos ( )

Save client window positions to a file unique to each layout.

Definition at line 793 of file config.c.

References config, draw_ext_info(), get_window_coord(), MSG_TYPE_CLIENT, MSG_TYPE_CLIENT_CONFIG, NDI_BLUE, save_defaults(), ui_name(), window_root, and window_xml.

Referenced by do_savewinpos(), and on_save_window_position_activate().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setup_config_dialog()

static void setup_config_dialog ( )
static

◆ ui_name()

static char* ui_name ( )
static

Return the basename of the current UI file.

Definition at line 65 of file config.c.

References window_xml_file.

Referenced by init_theme(), load_window_positions(), and save_winpos().

Here is the caller graph for this function:

Variable Documentation

◆ config

GKeyFile* config
static

Definition at line 29 of file config.c.

Referenced by config_load(), load_window_positions(), save_defaults(), and save_winpos().

◆ config_button_cache

GtkWidget * config_button_cache

Definition at line 34 of file config.c.

Referenced by config_init(), read_config_dialog(), and setup_config_dialog().

◆ config_button_download

GtkWidget * config_button_download

Definition at line 35 of file config.c.

Referenced by config_init(), read_config_dialog(), and setup_config_dialog().

◆ config_button_echo

GtkWidget * config_button_echo

Definition at line 32 of file config.c.

Referenced by config_init(), read_config_dialog(), and setup_config_dialog().

◆ config_button_fasttcp

GtkWidget * config_button_fasttcp

Definition at line 32 of file config.c.

Referenced by config_init(), read_config_dialog(), and setup_config_dialog().

◆ config_button_fog

GtkWidget * config_button_fog

Definition at line 35 of file config.c.

Referenced by config_init(), read_config_dialog(), and setup_config_dialog().

◆ config_button_foodbeep

GtkWidget * config_button_foodbeep

Definition at line 34 of file config.c.

Referenced by config_init(), read_config_dialog(), and setup_config_dialog().

◆ config_button_grad_color

GtkWidget * config_button_grad_color

Definition at line 33 of file config.c.

Referenced by config_init(), read_config_dialog(), and setup_config_dialog().

◆ config_button_smoothing

GtkWidget * config_button_smoothing

Definition at line 35 of file config.c.

Referenced by config_init(), read_config_dialog(), and setup_config_dialog().

◆ config_button_sound

GtkWidget * config_button_sound

Definition at line 34 of file config.c.

Referenced by config_init(), read_config_dialog(), and setup_config_dialog().

◆ config_button_timestamp

GtkWidget * config_button_timestamp

Definition at line 33 of file config.c.

Referenced by config_init(), read_config_dialog(), and setup_config_dialog().

◆ config_combobox_displaymode

GtkComboBox* config_combobox_displaymode

Definition at line 39 of file config.c.

Referenced by config_init(), read_config_dialog(), and setup_config_dialog().

◆ config_combobox_faceset

GtkComboBoxText* config_combobox_faceset

Definition at line 38 of file config.c.

Referenced by config_init(), read_config_dialog(), and setup_config_dialog().

◆ config_combobox_lighting

GtkComboBox * config_combobox_lighting

Definition at line 39 of file config.c.

Referenced by config_init(), read_config_dialog(), and setup_config_dialog().

◆ config_dialog

GtkWidget* config_dialog

Definition at line 32 of file config.c.

Referenced by config_init(), on_config_close(), and on_configure_activate().

◆ config_path

GString* config_path
static

Definition at line 30 of file config.c.

Referenced by config_load(), and save_defaults().

◆ default_files

char** default_files = NULL
static

Sets up player-specific client and layout rc files and handles loading of a client theme if one is selected. First, the player-specific rc files are added to the GTK rc default files list. ${HOME}/.crossfire/gtkrc is added first. All client sessions are affected by this rc file if it exists. Next, ${HOME}/.crossfire/[layout].gtkrc is added, where [layout] is the name of the layout file that is loaded. IE. If gtk-v2.ui is loaded, [layout] is "gtk-v2". This sets up the possibility for a player to make a layout-specific rc file. Finally, if the client theme is not "None", the client theme file is added. In most cases, the player-specific files are probably not going to exist, so the theme system will continue to work the way it always has. The player will have to "do something" to get the extra functionality. At some point, conceptually the client itself could be enhanced to allow it to save some basic settings to either or both of the player-specific rc files.

Parameters
reloadIf true, user has changed theme after initial startup. In this mode, we need to call the routines that store away private theme data. When program is starting up, this is false, because all the widgets haven't been realized yet, and the initialize routines will get the theme data at that time.

Definition at line 91 of file config.c.

Referenced by init_theme(), and load_theme().

◆ last_server

char* last_server

Definition at line 45 of file config.c.

Referenced by config_load(), metaserver_connect_to(), metaserver_show_prompt(), and save_defaults().

◆ predict_alpha

int predict_alpha = 10

Speed of local map prediction scrolling, 0-100 (0 to disable).

Definition at line 54 of file config.c.

Referenced by config_load(), save_defaults(), and update_global_offset().

◆ theme

char* theme
static

◆ theme_filechooser

GtkFileChooser * theme_filechooser

Definition at line 37 of file config.c.

Referenced by config_init(), read_config_dialog(), and setup_config_dialog().

◆ time_map_redraw

bool time_map_redraw = false

Definition at line 51 of file config.c.

Referenced by draw_map().

◆ ui_filechooser

GtkFileChooser* ui_filechooser

Definition at line 37 of file config.c.

Referenced by config_init(), read_config_dialog(), and setup_config_dialog().