mirror of
https://github.com/libretro/RetroArch
synced 2025-04-17 02:43:03 +00:00
(360/PS3) Both ports use rarch_config_save now for saving
settings to config file
This commit is contained in:
parent
944ddc589b
commit
593376b9aa
50
360/main.c
50
360/main.c
@ -190,7 +190,7 @@ static void init_settings (bool load_libretro_path)
|
||||
char fname_tmp[PATH_MAX];
|
||||
|
||||
if(!path_file_exists(SYS_CONFIG_FILE))
|
||||
rarch_create_default_config_file(SYS_CONFIG_FILE);
|
||||
rarch_config_create_default(SYS_CONFIG_FILE);
|
||||
|
||||
config_file_t * conf = config_file_new(SYS_CONFIG_FILE);
|
||||
|
||||
@ -273,52 +273,6 @@ static void init_settings (bool load_libretro_path)
|
||||
CONFIG_GET_INT_EXTERN(audio_data.mute, "audio_mute");
|
||||
}
|
||||
|
||||
static void save_settings (void)
|
||||
{
|
||||
if(!path_file_exists(SYS_CONFIG_FILE))
|
||||
rarch_create_default_config_file(SYS_CONFIG_FILE);
|
||||
|
||||
config_file_t * conf = config_file_new(SYS_CONFIG_FILE);
|
||||
|
||||
if(conf == NULL)
|
||||
conf = config_file_new(NULL);
|
||||
|
||||
// g_settings
|
||||
config_set_string(conf, "libretro_path", g_settings.libretro);
|
||||
config_set_bool(conf, "rewind_enable", g_settings.rewind_enable);
|
||||
config_set_string(conf, "video_cg_shader", g_settings.video.cg_shader_path);
|
||||
config_set_string(conf, "video_second_pass_shader", g_settings.video.second_pass_shader);
|
||||
config_set_float(conf, "video_aspect_ratio", g_settings.video.aspect_ratio);
|
||||
config_set_float(conf, "video_fbo_scale_x", g_settings.video.fbo_scale_x);
|
||||
config_set_float(conf, "video_fbo_scale_y", g_settings.video.fbo_scale_y);
|
||||
config_set_bool(conf, "video_render_to_texture", g_settings.video.render_to_texture);
|
||||
config_set_bool(conf, "video_second_pass_smooth", g_settings.video.second_pass_smooth);
|
||||
config_set_bool(conf, "video_smooth", g_settings.video.smooth);
|
||||
config_set_bool(conf, "video_vsync", g_settings.video.vsync);
|
||||
|
||||
// g_console
|
||||
config_set_bool(conf, "fbo_enabled", g_console.fbo_enabled);
|
||||
config_set_string(conf, "default_rom_startup_dir", g_console.default_rom_startup_dir);
|
||||
config_set_bool(conf, "gamma_correction_enable", g_console.gamma_correction_enable);
|
||||
config_set_bool(conf, "throttle_enable", g_console.throttle_enable);
|
||||
config_set_int(conf, "aspect_ratio_index", g_console.aspect_ratio_index);
|
||||
config_set_int(conf, "custom_viewport_width", g_console.viewports.custom_vp.width);
|
||||
config_set_int(conf, "custom_viewport_height", g_console.viewports.custom_vp.height);
|
||||
config_set_int(conf, "custom_viewport_x", g_console.viewports.custom_vp.x);
|
||||
config_set_int(conf, "custom_viewport_y", g_console.viewports.custom_vp.y);
|
||||
config_set_int(conf, "screen_orientation", g_console.screen_orientation);
|
||||
config_set_int(conf, "color_format", g_console.color_format);
|
||||
|
||||
// g_extern
|
||||
config_set_int(conf, "state_slot", g_extern.state_slot);
|
||||
config_set_int(conf, "audio_mute", g_extern.audio_data.mute);
|
||||
|
||||
if (!config_file_write(conf, SYS_CONFIG_FILE))
|
||||
RARCH_ERR("Failed to write config file to \"%s\". Check permissions.\n", SYS_CONFIG_FILE);
|
||||
|
||||
free(conf);
|
||||
}
|
||||
|
||||
static void get_environment_settings (void)
|
||||
{
|
||||
DWORD ret;
|
||||
@ -443,7 +397,7 @@ begin_loop:
|
||||
|
||||
begin_shutdown:
|
||||
if(path_file_exists(SYS_CONFIG_FILE))
|
||||
save_settings();
|
||||
rarch_config_save(SYS_CONFIG_FILE);
|
||||
|
||||
menu_deinit();
|
||||
video_xdk360.stop();
|
||||
|
@ -794,10 +794,82 @@ const char * rarch_convert_wchar_to_const_char(const wchar_t * wstr)
|
||||
CONFIG
|
||||
============================================================ */
|
||||
|
||||
void rarch_create_default_config_file(const char * conf_name)
|
||||
void rarch_config_create_default(const char * conf_name)
|
||||
{
|
||||
FILE * f;
|
||||
RARCH_WARN("Config file \"%s\" doesn't exist. Creating...\n", conf_name);
|
||||
f = fopen(conf_name, "w");
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
void rarch_config_save(const char * conf_name)
|
||||
{
|
||||
if(!path_file_exists(conf_name))
|
||||
rarch_config_create_default(conf_name);
|
||||
else
|
||||
{
|
||||
config_file_t * conf = config_file_new(conf_name);
|
||||
|
||||
if(conf == NULL)
|
||||
conf = config_file_new(NULL);
|
||||
|
||||
// g_settings
|
||||
config_set_string(conf, "libretro_path", g_settings.libretro);
|
||||
#ifdef HAVE_XML
|
||||
config_set_string(conf, "cheat_database_path", g_settings.cheat_database);
|
||||
#endif
|
||||
config_set_bool(conf, "rewind_enable", g_settings.rewind_enable);
|
||||
config_set_string(conf, "video_cg_shader", g_settings.video.cg_shader_path);
|
||||
config_set_float(conf, "video_aspect_ratio", g_settings.video.aspect_ratio);
|
||||
#ifdef HAVE_FBO
|
||||
config_set_float(conf, "video_fbo_scale_x", g_settings.video.fbo_scale_x);
|
||||
config_set_float(conf, "video_fbo_scale_y", g_settings.video.fbo_scale_y);
|
||||
config_set_string(conf, "video_second_pass_shader", g_settings.video.second_pass_shader);
|
||||
config_set_bool(conf, "video_render_to_texture", g_settings.video.render_to_texture);
|
||||
config_set_bool(conf, "video_second_pass_smooth", g_settings.video.second_pass_smooth);
|
||||
#endif
|
||||
config_set_bool(conf, "video_smooth", g_settings.video.smooth);
|
||||
config_set_bool(conf, "video_vsync", g_settings.video.vsync);
|
||||
config_set_string(conf, "audio_device", g_settings.audio.device);
|
||||
|
||||
for (unsigned i = 0; i < 7; i++)
|
||||
{
|
||||
char cfg[64];
|
||||
snprintf(cfg, sizeof(cfg), "input_dpad_emulation_p%u", i + 1);
|
||||
config_set_int(conf, cfg, g_settings.input.dpad_emulation[i]);
|
||||
}
|
||||
|
||||
#ifdef RARCH_CONSOLE
|
||||
config_set_bool(conf, "fbo_enabled", g_console.fbo_enabled);
|
||||
config_set_bool(conf, "custom_bgm_enable", g_console.custom_bgm_enable);
|
||||
config_set_bool(conf, "overscan_enable", g_console.overscan_enable);
|
||||
config_set_bool(conf, "screenshots_enable", g_console.screenshots_enable);
|
||||
#ifdef _XBOX
|
||||
config_set_bool(conf, "gamma_correction_enable", g_console.gamma_correction_enable);
|
||||
config_set_int(conf, "color_format", g_console.color_format);
|
||||
#endif
|
||||
config_set_bool(conf, "throttle_enable", g_console.throttle_enable);
|
||||
config_set_bool(conf, "triple_buffering_enable", g_console.triple_buffering_enable);
|
||||
config_set_int(conf, "sound_mode", g_console.sound_mode);
|
||||
config_set_int(conf, "aspect_ratio_index", g_console.aspect_ratio_index);
|
||||
config_set_int(conf, "current_resolution_id", g_console.current_resolution_id);
|
||||
config_set_int(conf, "custom_viewport_width", g_console.viewports.custom_vp.width);
|
||||
config_set_int(conf, "custom_viewport_height", g_console.viewports.custom_vp.height);
|
||||
config_set_int(conf, "custom_viewport_x", g_console.viewports.custom_vp.x);
|
||||
config_set_int(conf, "custom_viewport_y", g_console.viewports.custom_vp.y);
|
||||
config_set_int(conf, "screen_orientation", g_console.screen_orientation);
|
||||
config_set_string(conf, "default_rom_startup_dir", g_console.default_rom_startup_dir);
|
||||
config_set_float(conf, "menu_font_size", g_console.menu_font_size);
|
||||
config_set_float(conf, "overscan_amount", g_console.overscan_amount);
|
||||
#endif
|
||||
|
||||
// g_extern
|
||||
config_set_int(conf, "state_slot", g_extern.state_slot);
|
||||
config_set_int(conf, "audio_mute", g_extern.audio_data.mute);
|
||||
|
||||
if (!config_file_write(conf, conf_name))
|
||||
RARCH_ERR("Failed to write config file to \"%s\". Check permissions.\n", conf_name);
|
||||
|
||||
free(conf);
|
||||
}
|
||||
}
|
||||
|
@ -138,6 +138,7 @@ wchar_t * rarch_convert_char_to_wchar(const char * str);
|
||||
|
||||
const char * rarch_convert_wchar_to_const_char(const wchar_t * wstr);
|
||||
|
||||
void rarch_create_default_config_file(const char * conf_name);
|
||||
void rarch_config_create_default(const char * conf_name);
|
||||
void rarch_config_save(const char * conf_name);
|
||||
|
||||
#endif
|
||||
|
69
ps3/main.c
69
ps3/main.c
@ -156,7 +156,7 @@ static void set_default_settings(void)
|
||||
static void init_settings(bool load_libretro_path)
|
||||
{
|
||||
if(!path_file_exists(SYS_CONFIG_FILE))
|
||||
rarch_create_default_config_file(SYS_CONFIG_FILE);
|
||||
rarch_config_create_default(SYS_CONFIG_FILE);
|
||||
else
|
||||
{
|
||||
config_file_t * conf = config_file_new(SYS_CONFIG_FILE);
|
||||
@ -241,69 +241,6 @@ static void init_settings(bool load_libretro_path)
|
||||
}
|
||||
}
|
||||
|
||||
static void save_settings(void)
|
||||
{
|
||||
if(!path_file_exists(SYS_CONFIG_FILE))
|
||||
rarch_create_default_config_file(SYS_CONFIG_FILE);
|
||||
else
|
||||
{
|
||||
config_file_t * conf = config_file_new(SYS_CONFIG_FILE);
|
||||
|
||||
if(conf == NULL)
|
||||
conf = config_file_new(NULL);
|
||||
|
||||
// g_settings
|
||||
config_set_string(conf, "libretro_path", g_settings.libretro);
|
||||
config_set_string(conf, "cheat_database_path", g_settings.cheat_database);
|
||||
config_set_bool(conf, "rewind_enable", g_settings.rewind_enable);
|
||||
config_set_string(conf, "video_cg_shader", g_settings.video.cg_shader_path);
|
||||
config_set_string(conf, "video_second_pass_shader", g_settings.video.second_pass_shader);
|
||||
config_set_float(conf, "video_aspect_ratio", g_settings.video.aspect_ratio);
|
||||
config_set_float(conf, "video_fbo_scale_x", g_settings.video.fbo_scale_x);
|
||||
config_set_float(conf, "video_fbo_scale_y", g_settings.video.fbo_scale_y);
|
||||
config_set_bool(conf, "video_render_to_texture", g_settings.video.render_to_texture);
|
||||
config_set_bool(conf, "video_second_pass_smooth", g_settings.video.second_pass_smooth);
|
||||
config_set_bool(conf, "video_smooth", g_settings.video.smooth);
|
||||
config_set_bool(conf, "video_vsync", g_settings.video.vsync);
|
||||
config_set_string(conf, "audio_device", g_settings.audio.device);
|
||||
|
||||
for (unsigned i = 0; i < 7; i++)
|
||||
{
|
||||
char cfg[64];
|
||||
snprintf(cfg, sizeof(cfg), "input_dpad_emulation_p%u", i + 1);
|
||||
config_set_int(conf, cfg, g_settings.input.dpad_emulation[i]);
|
||||
}
|
||||
|
||||
// g_console
|
||||
config_set_bool(conf, "fbo_enabled", g_console.fbo_enabled);
|
||||
config_set_bool(conf, "custom_bgm_enable", g_console.custom_bgm_enable);
|
||||
config_set_bool(conf, "overscan_enable", g_console.overscan_enable);
|
||||
config_set_bool(conf, "screenshots_enable", g_console.screenshots_enable);
|
||||
config_set_bool(conf, "throttle_enable", g_console.throttle_enable);
|
||||
config_set_bool(conf, "triple_buffering_enable", g_console.triple_buffering_enable);
|
||||
config_set_int(conf, "sound_mode", g_console.sound_mode);
|
||||
config_set_int(conf, "aspect_ratio_index", g_console.aspect_ratio_index);
|
||||
config_set_int(conf, "current_resolution_id", g_console.current_resolution_id);
|
||||
config_set_int(conf, "custom_viewport_width", g_console.viewports.custom_vp.width);
|
||||
config_set_int(conf, "custom_viewport_height", g_console.viewports.custom_vp.height);
|
||||
config_set_int(conf, "custom_viewport_x", g_console.viewports.custom_vp.x);
|
||||
config_set_int(conf, "custom_viewport_y", g_console.viewports.custom_vp.y);
|
||||
config_set_int(conf, "screen_orientation", g_console.screen_orientation);
|
||||
config_set_string(conf, "default_rom_startup_dir", g_console.default_rom_startup_dir);
|
||||
config_set_float(conf, "menu_font_size", g_console.menu_font_size);
|
||||
config_set_float(conf, "overscan_amount", g_console.overscan_amount);
|
||||
|
||||
// g_extern
|
||||
config_set_int(conf, "state_slot", g_extern.state_slot);
|
||||
config_set_int(conf, "audio_mute", g_extern.audio_data.mute);
|
||||
|
||||
if (!config_file_write(conf, SYS_CONFIG_FILE))
|
||||
RARCH_ERR("Failed to write config file to \"%s\". Check permissions.\n", SYS_CONFIG_FILE);
|
||||
|
||||
free(conf);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef HAVE_SYSUTILS
|
||||
static void callback_sysutil_exit(uint64_t status, uint64_t param, void *userdata)
|
||||
{
|
||||
@ -546,9 +483,11 @@ begin_loop:
|
||||
|
||||
begin_shutdown:
|
||||
if(path_file_exists(SYS_CONFIG_FILE))
|
||||
save_settings();
|
||||
rarch_config_save(SYS_CONFIG_FILE);
|
||||
|
||||
if(g_console.emulator_initialized)
|
||||
rarch_main_deinit();
|
||||
|
||||
input_ps3.free(NULL);
|
||||
|
||||
video_gl.stop();
|
||||
|
Loading…
x
Reference in New Issue
Block a user