From c0c81bf22b84b762774efcfcfec37e7afb9d4135 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 5 Jan 2013 22:18:59 +0100 Subject: [PATCH] (RARCH_CONSOLE) Move rarch_config_save to settings.c - rename to config_save_file --- console/rarch_console_config.c | 83 +--------------------------------- console/rarch_console_config.h | 1 - general.h | 3 ++ gx/frontend/main.c | 2 +- ps3/frontend/main.c | 2 +- psp/frontend/main.c | 2 +- settings.c | 80 ++++++++++++++++++++++++++++++++ xdk/frontend/main.c | 2 +- 8 files changed, 88 insertions(+), 87 deletions(-) diff --git a/console/rarch_console_config.c b/console/rarch_console_config.c index 1b278ba079..e82587a353 100644 --- a/console/rarch_console_config.c +++ b/console/rarch_console_config.c @@ -111,87 +111,6 @@ void rarch_config_load(const char *path, bool upgrade_core_succeeded) { //save config file with new libretro path snprintf(g_settings.libretro, sizeof(g_settings.libretro), libretro_path_tmp); - rarch_config_save(path); + config_save_file(path); } } - -void rarch_config_save(const char *path) -{ - config_file_t * conf = config_file_new(path); - - if(!conf) - { - RARCH_ERR("Failed to write config file to \"%s\". Check permissions.\n", path); - return; - } - - // 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_int(conf, "aspect_ratio_index", g_settings.video.aspect_ratio_idx); - config_set_string(conf, "audio_device", g_settings.audio.device); - config_set_bool(conf, "audio_rate_control", g_settings.audio.rate_control); - config_set_float(conf, "audio_rate_control_delta", g_settings.audio.rate_control_delta); - config_set_string(conf, "system_directory", g_settings.system_directory); - - 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]); - snprintf(cfg, sizeof(cfg), "input_device_p%u", i + 1); - config_set_int(conf, cfg, g_settings.input.device[i]); - } - - config_set_bool(conf, "overscan_enable", g_extern.console.screen.state.overscan.enable); - config_set_bool(conf, "screenshots_enable", g_extern.console.screen.state.screenshots.enable); - config_set_bool(conf, "gamma_correction", g_extern.console.screen.gamma_correction); -#ifdef _XBOX1 - config_set_int(conf, "flicker_filter", g_extern.console.screen.state.flicker_filter.value); - config_set_int(conf, "sound_volume_level", g_extern.console.sound.volume_level); -#endif - config_set_bool(conf, "throttle_enable", g_extern.console.screen.state.throttle.enable); - config_set_bool(conf, "triple_buffering_enable", g_extern.console.screen.state.triple_buffering.enable); - config_set_bool(conf, "info_msg_enable", g_extern.console.rmenu.state.msg_info.enable); - config_set_int(conf, "current_resolution_id", g_extern.console.screen.resolutions.current.id); - config_set_int(conf, "custom_viewport_width", g_extern.console.screen.viewports.custom_vp.width); - config_set_int(conf, "custom_viewport_height", g_extern.console.screen.viewports.custom_vp.height); - config_set_int(conf, "custom_viewport_x", g_extern.console.screen.viewports.custom_vp.x); - config_set_int(conf, "custom_viewport_y", g_extern.console.screen.viewports.custom_vp.y); - config_set_string(conf, "default_rom_startup_dir", g_extern.console.main_wrap.paths.default_rom_startup_dir); - config_set_float(conf, "menu_font_size", g_extern.console.rmenu.font_size); - config_set_float(conf, "overscan_amount", g_extern.console.screen.overscan_amount); -#ifdef HAVE_ZLIB - config_set_int(conf, "zip_extract_mode", g_extern.file_state.zip_extract_mode); -#endif - - // g_extern - 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); - config_set_bool(conf, "soft_display_filter_enable", g_extern.console.screen.state.soft_filter.enable); - config_set_int(conf, "screen_orientation", g_extern.console.screen.orientation); - config_set_bool(conf, "custom_bgm_enable", g_extern.console.sound.custom_bgm.enable); - - config_set_bool(conf, "sram_dir_enable", g_extern.console.main_wrap.state.default_sram_dir.enable); - config_set_bool(conf, "savestate_dir_enable", g_extern.console.main_wrap.state.default_savestate_dir.enable); - - if (!config_file_write(conf, path)) - RARCH_ERR("Failed to write config file to \"%s\". Check permissions.\n", path); - - free(conf); -} diff --git a/console/rarch_console_config.h b/console/rarch_console_config.h index bf337ab83a..dcfa2e920d 100644 --- a/console/rarch_console_config.h +++ b/console/rarch_console_config.h @@ -25,6 +25,5 @@ enum }; void rarch_config_load(const char *path, bool upgrade_core_succeeded); -void rarch_config_save(const char *path); #endif diff --git a/general.h b/general.h index f98a1fc3fb..530f6aeec3 100644 --- a/general.h +++ b/general.h @@ -608,6 +608,9 @@ const char *config_get_default_input(void); #include "conf/config_file.h" bool config_load_file(const char *path); +#ifdef RARCH_CONSOLE +bool config_save_file(const char *path); +#endif bool config_read_keybinds(const char *path); bool config_save_keybinds(const char *path); diff --git a/gx/frontend/main.c b/gx/frontend/main.c index 9a6233f8a6..51ce6e36c8 100644 --- a/gx/frontend/main.c +++ b/gx/frontend/main.c @@ -593,7 +593,7 @@ begin_loop: goto begin_loop; begin_shutdown: - rarch_config_save(default_paths.config_file); + config_save_file(default_paths.config_file); config_save_keybinds(input_path); if(g_extern.console.emulator_initialized) diff --git a/ps3/frontend/main.c b/ps3/frontend/main.c index 983063786e..fbf0154cb2 100644 --- a/ps3/frontend/main.c +++ b/ps3/frontend/main.c @@ -365,7 +365,7 @@ begin_loop: goto begin_loop; begin_shutdown: - rarch_config_save(default_paths.config_file); + config_save_file(default_paths.config_file); if(g_extern.console.emulator_initialized) rarch_main_deinit(); diff --git a/psp/frontend/main.c b/psp/frontend/main.c index 3d8286ae05..f3173f3a71 100644 --- a/psp/frontend/main.c +++ b/psp/frontend/main.c @@ -191,7 +191,7 @@ begin_loop: goto begin_loop; begin_shutdown: - rarch_config_save(default_paths.config_file); + config_save_file(default_paths.config_file); if(g_extern.console.emulator_initialized) rarch_main_deinit(); diff --git a/settings.c b/settings.c index 846a5b3cd7..b60cfe129c 100644 --- a/settings.c +++ b/settings.c @@ -941,6 +941,8 @@ static void save_keybind(config_file_t *conf, save_keybind_key(conf, map, bind); save_keybind_joykey(conf, map, bind); save_keybind_axis(conf, map, bind); +#ifdef RARCH_CONSOLE +#endif } static void save_keybinds_player(config_file_t *conf, unsigned i) @@ -949,6 +951,84 @@ static void save_keybinds_player(config_file_t *conf, unsigned i) save_keybind(conf, &bind_maps[i][j], &g_settings.input.binds[i][j]); } +#ifdef RARCH_CONSOLE +bool config_save_file(const char *path) +{ + config_file_t *conf = config_file_new(path); + if (!conf) + conf = config_file_new(NULL); + if (!conf) + return false; + + 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_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_int(conf, "aspect_ratio_index", g_settings.video.aspect_ratio_idx); + config_set_string(conf, "audio_device", g_settings.audio.device); + config_set_bool(conf, "audio_rate_control", g_settings.audio.rate_control); + config_set_float(conf, "audio_rate_control_delta", g_settings.audio.rate_control_delta); + config_set_string(conf, "system_directory", g_settings.system_directory); + + config_set_bool(conf, "overscan_enable", g_extern.console.screen.state.overscan.enable); + config_set_bool(conf, "screenshots_enable", g_extern.console.screen.state.screenshots.enable); + config_set_bool(conf, "gamma_correction", g_extern.console.screen.gamma_correction); +#ifdef _XBOX1 + config_set_int(conf, "flicker_filter", g_extern.console.screen.state.flicker_filter.value); + config_set_int(conf, "sound_volume_level", g_extern.console.sound.volume_level); +#endif + config_set_bool(conf, "throttle_enable", g_extern.console.screen.state.throttle.enable); + config_set_bool(conf, "triple_buffering_enable", g_extern.console.screen.state.triple_buffering.enable); + config_set_bool(conf, "info_msg_enable", g_extern.console.rmenu.state.msg_info.enable); + config_set_int(conf, "current_resolution_id", g_extern.console.screen.resolutions.current.id); + config_set_int(conf, "custom_viewport_width", g_extern.console.screen.viewports.custom_vp.width); + config_set_int(conf, "custom_viewport_height", g_extern.console.screen.viewports.custom_vp.height); + config_set_int(conf, "custom_viewport_x", g_extern.console.screen.viewports.custom_vp.x); + config_set_int(conf, "custom_viewport_y", g_extern.console.screen.viewports.custom_vp.y); + config_set_string(conf, "default_rom_startup_dir", g_extern.console.main_wrap.paths.default_rom_startup_dir); + config_set_float(conf, "menu_font_size", g_extern.console.rmenu.font_size); + config_set_float(conf, "overscan_amount", g_extern.console.screen.overscan_amount); +#ifdef HAVE_ZLIB + config_set_int(conf, "zip_extract_mode", g_extern.file_state.zip_extract_mode); +#endif + + // g_extern + 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); + config_set_bool(conf, "soft_display_filter_enable", g_extern.console.screen.state.soft_filter.enable); + config_set_int(conf, "screen_orientation", g_extern.console.screen.orientation); + config_set_bool(conf, "custom_bgm_enable", g_extern.console.sound.custom_bgm.enable); + + config_set_bool(conf, "sram_dir_enable", g_extern.console.main_wrap.state.default_sram_dir.enable); + config_set_bool(conf, "savestate_dir_enable", g_extern.console.main_wrap.state.default_savestate_dir.enable); + + for (unsigned i = 0; i < MAX_PLAYERS; 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]); + snprintf(cfg, sizeof(cfg), "input_device_p%u", i + 1); + config_set_int(conf, cfg, g_settings.input.device[i]); + } + + config_file_write(conf, path); + config_file_free(conf); + + return true; +} +#endif + bool config_save_keybinds(const char *path) { config_file_t *conf = config_file_new(path); diff --git a/xdk/frontend/main.c b/xdk/frontend/main.c index c912813c80..3729e052e9 100644 --- a/xdk/frontend/main.c +++ b/xdk/frontend/main.c @@ -204,7 +204,7 @@ begin_loop: goto begin_loop; begin_shutdown: - rarch_config_save(default_paths.config_file); + config_save_file(default_paths.config_file); menu_free(); #if defined(HAVE_D3D8) || defined(HAVE_D3D9)