Atrinik Client  4.0
Functions | Variables
settings.c File Reference
#include <global.h>
#include <toolkit/packet.h>
#include <toolkit/string.h>
#include <toolkit/path.h>

Go to the source code of this file.

Functions

static void setting_load_value (setting_struct *setting, const char *str)
 
void settings_init (void)
 
void settings_load (void)
 
void settings_save (void)
 
void settings_deinit (void)
 
void * setting_get (setting_struct *setting)
 
const char * setting_get_str (int cat, int setting)
 
int64_t setting_get_int (int cat, int setting)
 
static int setting_apply_always (int cat, int setting)
 
static void setting_apply_runtime (int cat, int setting)
 
void settings_apply (void)
 
void settings_apply_change (void)
 
void setting_set_int (int cat, int setting, int64_t val)
 
void setting_set_str (int cat, int setting, const char *val)
 
int setting_is_text (setting_struct *setting)
 
int64_t category_from_name (const char *name)
 
int64_t setting_from_name (const char *name)
 

Variables

static const char *const opt_types [OPT_TYPE_NUM]
 
setting_category ** setting_categories = NULL
 
size_t setting_categories_num = 0
 
static uint8_t setting_update_mapsize = 0
 

Detailed Description

Handles client settings.

Author
Alex Tokar

Definition in file settings.c.

Function Documentation

int64_t category_from_name ( const char *  name)

Find a category ID by its name.

Parameters
nameThe name.
Returns
Category ID if found, -1 otherwise.

Definition at line 654 of file settings.c.

static int setting_apply_always ( int  cat,
int  setting 
)
static

Apply a setting change, which needs to be handled regardless of whether it's changed at runtime or at startup.

Parameters
catID of the category the setting is in.
settingSetting ID inside the category.
Returns
1 if the change was handled, 0 otherwise.

Definition at line 429 of file settings.c.

static void setting_apply_runtime ( int  cat,
int  setting 
)
static

Apply a setting change at run-time.

Parameters
catID of the category the setting is in.
settingSetting ID inside the category.

Definition at line 467 of file settings.c.

int64_t setting_from_name ( const char *  name)

Find a setting ID by its name.

Note
All categories are checked.
Parameters
nameThe name.
Returns
Setting ID if found, -1 otherwise.

Definition at line 676 of file settings.c.

void* setting_get ( setting_struct setting)

Get pointer to a setting's value.

Parameters
settingThe setting.
Returns
Pointer to the setting's value.

Definition at line 373 of file settings.c.

int64_t setting_get_int ( int  cat,
int  setting 
)

Get setting's integer value.

Parameters
catID of the category the setting is in.
settingSetting ID inside the category.
Returns
The setting's integer value.

Definition at line 414 of file settings.c.

const char* setting_get_str ( int  cat,
int  setting 
)

Get setting's string value.

Parameters
catID of the category the setting is in.
settingSetting ID inside the category.
Returns
The setting's string value.

Definition at line 400 of file settings.c.

int setting_is_text ( setting_struct setting)

Check if the specified setting has a string value.

Parameters
settingThe setting.
Returns
1 if it has a string value, 0 otherwise.

Definition at line 636 of file settings.c.

static void setting_load_value ( setting_struct setting,
const char *  str 
)
static

Load a setting value from file.

Parameters
settingThe setting to load the value into.
strThe value to load.

Definition at line 59 of file settings.c.

void setting_set_int ( int  cat,
int  setting,
int64_t  val 
)

Set setting's integer value.

Parameters
catID of the category the setting is in.
settingSetting ID inside the category.
valValue to set.

Definition at line 592 of file settings.c.

void setting_set_str ( int  cat,
int  setting,
const char *  val 
)

Set settings's string value.

Parameters
catID of the category the setting is in.
settingSetting ID inside the category.
valValue to set.

Definition at line 616 of file settings.c.

void settings_apply ( void  )

Apply all settings that need to be applied at start-time (after everything has been initialized successfully).

Definition at line 557 of file settings.c.

void settings_apply_change ( void  )

Apply a change of settings at run-time (through the settings GUI, for example).

Definition at line 572 of file settings.c.

void settings_deinit ( void  )

Deinitialize the settings.

User's settings are also saved to file using settings_save().

Definition at line 310 of file settings.c.

void settings_init ( void  )

Initialize the setting defaults.

Definition at line 96 of file settings.c.

void settings_load ( void  )

Load user's settings (if any).

Definition at line 217 of file settings.c.

void settings_save ( void  )

Save the user's settings to file.

Definition at line 273 of file settings.c.

Variable Documentation

const char* const opt_types[OPT_TYPE_NUM]
static
Initial value:
= {
"bool", "input_num", "input_text", "range", "select", "int", "color"
}

Text representations of the setting types.

Definition at line 38 of file settings.c.

setting_category** setting_categories = NULL

List of setting categories.

Definition at line 43 of file settings.c.

size_t setting_categories_num = 0

Number of setting_categories.

Definition at line 45 of file settings.c.

uint8_t setting_update_mapsize = 0
static

Whether we need to send a setup command to server to request mapsize change.

Definition at line 50 of file settings.c.