mirror of
https://gitlab.com/dosowisko.net/libsuperderpy.git
synced 2024-12-05 00:38:00 +01:00
config: store the config file instantly after setting a new value
This commit is contained in:
parent
94de1c5975
commit
5757c5170a
1 changed files with 14 additions and 10 deletions
24
src/config.c
24
src/config.c
|
@ -32,8 +32,22 @@ SYMBOL_EXPORT void InitConfig(struct Game* game) {
|
|||
al_set_new_file_interface(iface);
|
||||
}
|
||||
|
||||
static void StoreConfig(struct Game* game) {
|
||||
const ALLEGRO_FILE_INTERFACE* iface = al_get_new_file_interface();
|
||||
al_set_standard_file_interface();
|
||||
ALLEGRO_PATH* path = al_get_standard_path(ALLEGRO_USER_SETTINGS_PATH);
|
||||
ALLEGRO_PATH* data = al_create_path("SuperDerpy.ini");
|
||||
al_make_directory(al_path_cstr(path, ALLEGRO_NATIVE_PATH_SEP));
|
||||
al_join_paths(path, data);
|
||||
al_save_config_file(al_path_cstr(path, ALLEGRO_NATIVE_PATH_SEP), game->_priv.config);
|
||||
al_destroy_path(path);
|
||||
al_destroy_path(data);
|
||||
al_set_new_file_interface(iface);
|
||||
}
|
||||
|
||||
SYMBOL_EXPORT void SetConfigOption(struct Game* game, char* section, char* name, char* value) {
|
||||
al_set_config_value(game->_priv.config, section, name, value);
|
||||
StoreConfig(game);
|
||||
}
|
||||
|
||||
SYMBOL_EXPORT const char* GetConfigOption(struct Game* game, char* section, char* name) {
|
||||
|
@ -49,15 +63,5 @@ SYMBOL_EXPORT const char* GetConfigOptionDefault(struct Game* game, char* sectio
|
|||
}
|
||||
|
||||
SYMBOL_EXPORT void DeinitConfig(struct Game* game) {
|
||||
const ALLEGRO_FILE_INTERFACE* iface = al_get_new_file_interface();
|
||||
al_set_standard_file_interface();
|
||||
ALLEGRO_PATH* path = al_get_standard_path(ALLEGRO_USER_SETTINGS_PATH);
|
||||
ALLEGRO_PATH* data = al_create_path("SuperDerpy.ini");
|
||||
al_make_directory(al_path_cstr(path, ALLEGRO_NATIVE_PATH_SEP));
|
||||
al_join_paths(path, data);
|
||||
al_save_config_file(al_path_cstr(path, ALLEGRO_NATIVE_PATH_SEP), game->_priv.config);
|
||||
al_destroy_path(path);
|
||||
al_destroy_path(data);
|
||||
al_destroy_config(game->_priv.config);
|
||||
al_set_new_file_interface(iface);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue