Introduce config_save_on_exit

This commit is contained in:
twinaphex 2013-05-22 15:35:28 +02:00
parent 82b6ab3ec7
commit 79ea30f54f
10 changed files with 44 additions and 2 deletions

View File

@ -259,6 +259,9 @@ static unsigned aspect_ratio_idx = ASPECT_RATIO_4_3;
static unsigned aspect_ratio_idx = ASPECT_RATIO_CONFIG; // Use g_settings.video.aspect_ratio.
#endif
// Save configuration file on exit
static bool config_save_on_exit = true;
// Crop overscanned frames.
static const bool crop_overscan = true;

View File

@ -98,6 +98,16 @@ int main(int argc, char *argv[])
}
menu_free();
// TODO: Commented for now since this conflicts with Phoenix config saving.
// Either Phoenix frontend needs to have the same amount of options as RGUI
// or we should slim down Phoenix even more (in terms of taking away the options)
// and do that with RGUI so that we can uncomment that without Phoenix modifying
// the config file on its own based on user preferences.
//if (g_extern.config_save_on_exit)
//config_save_file(g_extern.config_path);
if (g_extern.main_is_init)
rarch_main_deinit();
#else

View File

@ -263,6 +263,9 @@ exit:
menu_free();
if (g_extern.config_save_on_exit)
config_save_file(g_extern.config_path);
if (g_extern.main_is_init)
rarch_main_deinit();

View File

@ -93,7 +93,8 @@ int rarch_main(int argc, char *argv[])
menu_free();
config_save_file(g_extern.config_path);
if (g_extern.config_save_on_exit)
config_save_file(g_extern.config_path);
if (g_extern.main_is_init)
rarch_main_deinit();

View File

@ -213,7 +213,8 @@ int rarch_main(int argc, char *argv[])
menu_free();
config_save_file(g_extern.config_path);
if (g_extern.config_save_on_exit)
config_save_file(g_extern.config_path);
#ifdef GEKKO
/* Per-core input config saving */

View File

@ -151,6 +151,10 @@ void* rarch_main_ios(void* args)
g_extern.system.shutdown = false;
menu_free();
if (g_extern.config_save_on_exit)
config_save_file(g_extern.config_path);
if (g_extern.main_is_init)
rarch_main_deinit();

View File

@ -141,6 +141,7 @@ typedef enum
RGUI_SETTINGS_OPTIONS,
RGUI_SETTINGS_REWIND_ENABLE,
RGUI_SETTINGS_REWIND_GRANULARITY,
RGUI_SETTINGS_CONFIG_SAVE_ON_EXIT,
RGUI_SETTINGS_SRAM_AUTOSAVE,
RGUI_SETTINGS_SAVESTATE_SAVE,
RGUI_SETTINGS_SAVESTATE_LOAD,

View File

@ -619,6 +619,9 @@ static void render_text(rgui_handle_t *rgui)
case RGUI_SETTINGS_REWIND_GRANULARITY:
snprintf(type_str, sizeof(type_str), "%u", g_settings.rewind_granularity);
break;
case RGUI_SETTINGS_CONFIG_SAVE_ON_EXIT:
strlcpy(type_str, g_extern.config_save_on_exit ? "ON" : "OFF", sizeof(type_str));
break;
case RGUI_SETTINGS_SRAM_AUTOSAVE:
strlcpy(type_str, g_settings.autosave_interval ? "ON" : "OFF", sizeof(type_str));
break;
@ -914,6 +917,15 @@ static int rgui_settings_toggle_setting(rgui_handle_t *rgui, unsigned setting, r
else if (action == RGUI_ACTION_START)
g_settings.rewind_granularity = 1;
break;
case RGUI_SETTINGS_CONFIG_SAVE_ON_EXIT:
if (action == RGUI_ACTION_OK || action == RGUI_ACTION_RIGHT
|| action == RGUI_ACTION_LEFT)
{
g_extern.config_save_on_exit = !g_extern.config_save_on_exit;
}
else if (action == RGUI_ACTION_START)
g_extern.config_save_on_exit = true;
break;
#if defined(HAVE_THREADS) && !defined(RARCH_CONSOLE)
case RGUI_SETTINGS_SRAM_AUTOSAVE:
if (action == RGUI_ACTION_OK || action == RGUI_ACTION_RIGHT || action == RGUI_ACTION_LEFT)
@ -1383,6 +1395,7 @@ static void rgui_settings_options_populate_entries(rgui_handle_t *rgui)
rgui_list_clear(rgui->selection_buf);
rgui_list_push(rgui->selection_buf, "Rewind", RGUI_SETTINGS_REWIND_ENABLE, 0);
rgui_list_push(rgui->selection_buf, "Rewind Granularity", RGUI_SETTINGS_REWIND_GRANULARITY, 0);
rgui_list_push(rgui->selection_buf, "Config Save On Exit", RGUI_SETTINGS_CONFIG_SAVE_ON_EXIT, 0);
#if defined(HAVE_THREADS) && !defined(RARCH_CONSOLE)
rgui_list_push(rgui->selection_buf, "SRAM Autosave", RGUI_SETTINGS_SRAM_AUTOSAVE, 0);
#endif

View File

@ -583,6 +583,7 @@ struct global
bool main_is_init;
bool error_in_init;
bool config_save_on_exit;
char error_string[1024];
jmp_buf error_sjlj_context;
unsigned menu_toggle_behavior;

View File

@ -292,6 +292,8 @@ void config_set_defaults(void)
#endif
#endif
g_extern.config_save_on_exit = config_save_on_exit;
#if defined(HAVE_RMENU) || defined(HAVE_RGUI)
/* Avoid reloading config on every ROM load */
g_extern.block_config_read = true;
@ -673,6 +675,8 @@ bool config_load_file(const char *path)
CONFIG_GET_INT(input.icade_profile[3], "input_autodetect_icade_profile_pad4");
#endif
CONFIG_GET_BOOL_EXTERN(config_save_on_exit, "config_save_on_exit");
if (!g_extern.has_set_save_path && config_get_path(conf, "savefile_directory", tmp_str, sizeof(tmp_str)))
{
if (!strcmp(tmp_str, "default"))
@ -1002,6 +1006,7 @@ bool config_save_file(const char *path)
config_set_float(conf, "video_font_size", g_settings.video.font_size);
// g_extern
config_set_bool(conf, "config_save_on_exit", g_extern.config_save_on_exit);
config_set_int(conf, "sound_mode", g_extern.console.sound.mode);
config_set_int(conf, "state_slot", g_extern.state_slot);
config_set_int(conf, "audio_mute", g_extern.audio_data.mute);