From f104173c7e521c808a499d54bfa5eb2c044729d7 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 26 Sep 2015 20:05:00 +0200 Subject: [PATCH] Change internal state of custom viewport --- configuration.c | 30 ++++++++---------------------- configuration.h | 2 ++ gfx/video_viewport.c | 5 ++--- 3 files changed, 12 insertions(+), 25 deletions(-) diff --git a/configuration.c b/configuration.c index d49e277a17..a2abc4c361 100644 --- a/configuration.c +++ b/configuration.c @@ -1189,13 +1189,10 @@ static bool config_load_file(const char *path, bool set_defaults) const char *extra_path = NULL; char tmp_str[PATH_MAX_LENGTH] = {0}; char tmp_append_path[PATH_MAX_LENGTH] = {0}; /* Don't destroy append_config_path. */ - int vp_width = 0, vp_height = 0, vp_x = 0, vp_y = 0; unsigned msg_color = 0; config_file_t *conf = NULL; settings_t *settings = config_get_ptr(); global_t *global = global_get_ptr(); - video_viewport_t *custom_vp = (video_viewport_t*) - video_viewport_get_custom(); if (path) { @@ -1369,19 +1366,10 @@ static bool config_load_file(const char *path, bool set_defaults) #endif CONFIG_GET_INT_BASE(conf, settings, state_slot, "state_slot"); - - config_get_int(conf, "custom_viewport_width", &vp_width); - config_get_int(conf, "custom_viewport_height", &vp_height); - config_get_int(conf, "custom_viewport_x", &vp_x); - config_get_int(conf, "custom_viewport_y", &vp_y); - - if (custom_vp) - { - custom_vp->width = vp_width; - custom_vp->height = vp_height; - custom_vp->x = vp_x; - custom_vp->y = vp_y; - } + CONFIG_GET_INT_BASE(conf, settings, video_viewport_custom.width, "custom_viewport_width"); + CONFIG_GET_INT_BASE(conf, settings, video_viewport_custom.height, "custom_viewport_height"); + CONFIG_GET_INT_BASE(conf, settings, video_viewport_custom.x, "custom_viewport_x"); + CONFIG_GET_INT_BASE(conf, settings, video_viewport_custom.y, "custom_viewport_y"); if (config_get_hex(conf, "video_message_color", &msg_color)) { @@ -2421,8 +2409,6 @@ bool config_save_file(const char *path) config_file_t *conf = config_file_new(path); settings_t *settings = config_get_ptr(); global_t *global = global_get_ptr(); - const video_viewport_t *custom_vp = (const video_viewport_t*) - video_viewport_get_custom(); if (!conf) conf = config_file_new(NULL); @@ -2697,13 +2683,13 @@ bool config_save_file(const char *path) config_set_int(conf, "current_resolution_id", global->console.screen.resolutions.current.id); config_set_int(conf, "custom_viewport_width", - custom_vp->width); + settings->video_viewport_custom.width); config_set_int(conf, "custom_viewport_height", - custom_vp->height); + settings->video_viewport_custom.height); config_set_int(conf, "custom_viewport_x", - custom_vp->x); + settings->video_viewport_custom.x); config_set_int(conf, "custom_viewport_y", - custom_vp->y); + settings->video_viewport_custom.y); config_set_float(conf, "video_font_size", settings->video.font_size); diff --git a/configuration.h b/configuration.h index 493c723aff..e9952f5dd2 100644 --- a/configuration.h +++ b/configuration.h @@ -33,6 +33,8 @@ extern "C" { typedef struct settings { + video_viewport_t video_viewport_custom; + struct { char driver[32]; diff --git a/gfx/video_viewport.c b/gfx/video_viewport.c index 4cb94c2055..282e8902bf 100644 --- a/gfx/video_viewport.c +++ b/gfx/video_viewport.c @@ -16,8 +16,6 @@ #include "../general.h" -static video_viewport_t video_viewport_custom; - struct aspect_ratio_elem aspectratio_lut[ASPECT_RATIO_END] = { { "4:3", 1.3333f }, { "16:9", 1.7778f }, @@ -230,7 +228,8 @@ struct retro_system_av_info *video_viewport_get_system_av_info(void) struct video_viewport *video_viewport_get_custom(void) { - return &video_viewport_custom; + settings_t *settings = config_get_ptr(); + return &settings->video_viewport_custom; } void video_viewport_reset_custom(void)