(PS3) Saves to config file now

This commit is contained in:
TwinAphex51224 2012-01-30 15:59:15 +01:00
parent 4a9e7f7b7e
commit ec97970206
4 changed files with 51 additions and 4 deletions

View File

@ -73,7 +73,6 @@ $(PPU_TARGET): $(OBJ)
$(CXX) $(INCDIRS) $(CXXFLAGS) -c -o $@ $<
pkg: $(PPU_TARGET)
cp ssnes.cfg ps3/pkg/USRDIR/
ifeq ($(DOWNLOAD_SHADERS),1)
rm -rf ps3/pkg/USRDIR/shaders
git clone git://github.com/twinaphex/common-shaders.git ps3/pkg/USRDIR/shaders

View File

@ -176,6 +176,7 @@ struct console_settings
bool screenshots_enable;
bool throttle_enable;
bool triple_buffering_enable;
uint32_t screen_orientation;
uint32_t current_resolution_index;
uint32_t current_resolution_id;
uint32_t initial_resolution_id;

View File

@ -106,6 +106,8 @@ static void set_default_settings(void)
g_settings.video.smooth = true;
g_settings.video.vsync = true;
strlcpy(g_settings.cheat_database, usrDirPath, sizeof(g_settings.cheat_database));
g_settings.video.msg_pos_x = 0.09f;
g_settings.video.msg_pos_y = 0.90f;
// g_console
g_console.screenshots_enable = false;
@ -116,12 +118,14 @@ static void set_default_settings(void)
// g_extern
g_extern.state_slot = 0;
g_extern.audio_data.mute = 0;
}
static void init_settings(void)
{
if(!file_exists(SYS_CONFIG_FILE))
{
SSNES_ERR("Config file \"%s\" doesn't exist! Creating...\n", SYS_CONFIG_FILE);
FILE * f;
f = fopen(SYS_CONFIG_FILE, "w");
fclose(f);
@ -131,7 +135,7 @@ static void init_settings(void)
// g_settings
CONFIG_GET_STRING(cheat_database, "cheat_database_path");
CONFIG_GET_STRING(cheat_database, "cheat_database");
CONFIG_GET_BOOL(rewind_enable, "rewind_enable");
CONFIG_GET_STRING(video.cg_shader_path, "video_cg_shader");
CONFIG_GET_STRING(video.second_pass_shader, "video_second_pass_shader");
@ -148,9 +152,50 @@ static void init_settings(void)
CONFIG_GET_BOOL_CONSOLE(throttle_enable, "throttle_enable");
CONFIG_GET_BOOL_CONSOLE(triple_buffering_enable, "triple_buffering_enable");
CONFIG_GET_INT_CONSOLE(current_resolution_id, "current_resolution_id");
CONFIG_GET_STRING_CONSOLE(default_rom_startup_dir, "default_rom_startup_dir");
// g_extern
CONFIG_GET_INT_EXTERN(state_slot, "state_slot");
CONFIG_GET_INT_EXTERN(audio_data.mute, "audio_mute");
}
static void save_settings(void)
{
fprintf(stderr, "Attempting to save config file...\n");
if(!file_exists(SYS_CONFIG_FILE))
{
FILE * f;
f = fopen(SYS_CONFIG_FILE, "w");
fclose(f);
}
config_file_t * conf = config_file_new(SYS_CONFIG_FILE);
// g_settings
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_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, "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, "current_resolution_id", g_console.current_resolution_id);
config_set_string(conf, "default_rom_startup_dir", g_console.default_rom_startup_dir);
// 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))
SSNES_ERR("Failed to write config file to \"%s\"! Check permissions!\n", SYS_CONFIG_FILE);
}
static void get_path_settings(bool multiman_support)
@ -599,6 +644,8 @@ begin_loop:
goto begin_loop;
begin_shutdown:
if(file_exists(SYS_CONFIG_FILE))
save_settings();
ps3_input_deinit();
ps3_video_deinit();
sys_process_exit(0);

View File

@ -728,8 +728,8 @@ static bool gl_frame(void *data, const void *frame, unsigned width, unsigned hei
if (msg)
{
cellDbgFontPrintf(0.09f, 0.90f, 1.51f, BLUE, msg);
cellDbgFontPrintf(0.09f, 0.90f, 1.50f, WHITE, msg);
cellDbgFontPrintf(g_settings.video.msg_pos_x, g_settings.video.msg_pos_y, 1.51f, BLUE, msg);
cellDbgFontPrintf(g_settings.video.msg_pos_x, g_settings.video.msg_pos_y, 1.50f, WHITE, msg);
cellDbgFontDraw();
}