mirror of
https://github.com/libretro/RetroArch.git
synced 2024-11-27 18:20:27 +00:00
Cleanup settings handling a bit to avoid lots of dummy variables.
This commit is contained in:
parent
b56b09af35
commit
0bb1f7292c
@ -16,49 +16,48 @@
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef _CONFIG_FILE_MACROS_H
|
||||
#define _CONFIG_FILE_MACROS_H
|
||||
#ifndef CONFIG_FILE_MACROS_H__
|
||||
#define CONFIG_FILE_MACROS_H__
|
||||
|
||||
/* Macros to ease config getting. */
|
||||
|
||||
#define CONFIG_GET_BOOL(var, key) if (config_get_bool(conf, key, &tmp_bool)) \
|
||||
g_settings.var = tmp_bool
|
||||
#define CONFIG_GET_BOOL_BASE(conf, base, var, key) do { \
|
||||
bool tmp; \
|
||||
if (config_get_bool(conf, key, &tmp)) \
|
||||
base.var = tmp; \
|
||||
} while(0)
|
||||
|
||||
#define CONFIG_GET_INT(var, key) if (config_get_int(conf, key, &tmp_int)) \
|
||||
g_settings.var = tmp_int
|
||||
#define CONFIG_GET_INT_BASE(conf, base, var, key) do { \
|
||||
int tmp; \
|
||||
if (config_get_int(conf, key, &tmp)) \
|
||||
base.var = tmp; \
|
||||
} while(0)
|
||||
|
||||
#define CONFIG_GET_DOUBLE(var, key) if (config_get_double(conf, key, &tmp_double)) \
|
||||
g_settings.var = tmp_double
|
||||
#define CONFIG_GET_DOUBLE_BASE(conf, base, var, key) do { \
|
||||
double tmp; \
|
||||
if (config_get_double(conf, key, &tmp)) \
|
||||
base.var = tmp; \
|
||||
} while(0)
|
||||
|
||||
#define CONFIG_GET_STRING(var, key) \
|
||||
config_get_array(conf, key, g_settings.var, sizeof(g_settings.var))
|
||||
#define CONFIG_GET_STRING_BASE(conf, base, var, key) \
|
||||
config_get_array(conf, key, base.var, sizeof(base.var))
|
||||
|
||||
#define CONFIG_GET_BOOL(var, key) CONFIG_GET_BOOL_BASE(conf, g_settings, var, key)
|
||||
#define CONFIG_GET_INT(var, key) CONFIG_GET_INT_BASE(conf, g_settings, var, key)
|
||||
#define CONFIG_GET_DOUBLE(var, key) CONFIG_GET_DOUBLE_BASE(conf, g_settings, var, key)
|
||||
#define CONFIG_GET_STRING(var, key) CONFIG_GET_STRING_BASE(conf, g_settings, var, key)
|
||||
|
||||
#define CONFIG_GET_BOOL_EXTERN(var, key) CONFIG_GET_BOOL_BASE(conf, g_extern, var, key)
|
||||
#define CONFIG_GET_INT_EXTERN(var, key) CONFIG_GET_INT_BASE(conf, g_extern, var, key)
|
||||
#define CONFIG_GET_DOUBLE_EXTERN(var, key) CONFIG_GET_DOUBLE_BASE(conf, g_extern, var, key)
|
||||
#define CONFIG_GET_STRING_EXTERN(var, key) CONFIG_GET_STRING_BASE(conf, g_extern, var, key)
|
||||
|
||||
#ifdef SSNES_CONSOLE
|
||||
|
||||
#define CONFIG_GET_BOOL_CONSOLE(var, key) if (config_get_bool(conf, key, &tmp_bool)) \
|
||||
g_console.var = tmp_bool
|
||||
|
||||
#define CONFIG_GET_INT_CONSOLE(var, key) if (config_get_int(conf, key, &tmp_int)) \
|
||||
g_console.var = tmp_int
|
||||
|
||||
#define CONFIG_GET_DOUBLE_CONSOLE(var, key) if (config_get_double(conf, key, &tmp_double)) \
|
||||
g_console.var = tmp_double
|
||||
|
||||
#define CONFIG_GET_STRING_CONSOLE(var, key) \
|
||||
config_get_array(conf, key, g_console.var, sizeof(g_console.var))
|
||||
#define CONFIG_GET_BOOL_EXTERN(var, key) CONFIG_GET_BOOL_BASE(conf, g_console, var, key)
|
||||
#define CONFIG_GET_INT_EXTERN(var, key) CONFIG_GET_INT_BASE(conf, g_console, var, key)
|
||||
#define CONFIG_GET_DOUBLE_EXTERN(var, key) CONFIG_GET_DOUBLE_BASE(conf, g_console, var, key)
|
||||
#define CONFIG_GET_STRING_EXTERN(var, key) CONFIG_GET_STRING_BASE(conf, g_console, var, key)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#define CONFIG_GET_BOOL_EXTERN(var, key) if (config_get_bool(conf, key, &tmp_bool)) \
|
||||
g_extern.var = tmp_bool
|
||||
|
||||
#define CONFIG_GET_INT_EXTERN(var, key) if (config_get_int(conf, key, &tmp_int)) \
|
||||
g_extern.var = tmp_int
|
||||
|
||||
#define CONFIG_GET_DOUBLE_EXTERN(var, key) if (config_get_double(conf, key, &tmp_double)) \
|
||||
g_extern.var = tmp_double
|
||||
|
||||
#define CONFIG_GET_STRING_EXTERN(var, key) \
|
||||
config_get_array(conf, key, g_extern.var, sizeof(g_extern.var))
|
||||
|
||||
#endif
|
||||
|
@ -120,11 +120,6 @@ static bool init_settings(void)
|
||||
if (!conf)
|
||||
return 1;
|
||||
|
||||
int tmp_int;
|
||||
double tmp_double;
|
||||
bool tmp_bool;
|
||||
char tmp_str[PATH_MAX];
|
||||
|
||||
CONFIG_GET_BOOL(video.smooth, "video_smooth");
|
||||
CONFIG_GET_BOOL(video.second_pass_smooth, "video_second_pass_smooth");
|
||||
CONFIG_GET_STRING(video.cg_shader_path, "video_cg_shader");
|
||||
|
13
settings.c
13
settings.c
@ -351,9 +351,6 @@ bool config_load_file(const char *path)
|
||||
fprintf(stderr, "=== Config end ===\n");
|
||||
}
|
||||
|
||||
int tmp_int;
|
||||
double tmp_double;
|
||||
bool tmp_bool;
|
||||
char tmp_str[PATH_MAX];
|
||||
|
||||
CONFIG_GET_DOUBLE(video.xscale, "video_xscale");
|
||||
@ -362,9 +359,7 @@ bool config_load_file(const char *path)
|
||||
CONFIG_GET_INT(video.fullscreen_y, "video_fullscreen_y");
|
||||
|
||||
if (!g_extern.force_fullscreen)
|
||||
{
|
||||
CONFIG_GET_BOOL(video.fullscreen, "video_fullscreen");
|
||||
}
|
||||
|
||||
CONFIG_GET_BOOL(video.force_16bit, "video_force_16bit");
|
||||
CONFIG_GET_BOOL(video.disable_composition, "video_disable_composition");
|
||||
@ -449,9 +444,7 @@ bool config_load_file(const char *path)
|
||||
CONFIG_GET_STRING(input.driver, "input_driver");
|
||||
|
||||
if (!*g_settings.libsnes)
|
||||
{
|
||||
CONFIG_GET_STRING(libsnes, "libsnes_path");
|
||||
}
|
||||
|
||||
CONFIG_GET_STRING(screenshot_directory, "screenshot_directory");
|
||||
if (*g_settings.screenshot_directory && !path_is_directory(g_settings.screenshot_directory))
|
||||
@ -462,8 +455,9 @@ bool config_load_file(const char *path)
|
||||
|
||||
CONFIG_GET_BOOL(rewind_enable, "rewind_enable");
|
||||
|
||||
if (config_get_int(conf, "rewind_buffer_size", &tmp_int))
|
||||
g_settings.rewind_buffer_size = tmp_int * UINT64_C(1000000);
|
||||
int buffer_size;
|
||||
if (config_get_int(conf, "rewind_buffer_size", &buffer_size))
|
||||
g_settings.rewind_buffer_size = buffer_size * UINT64_C(1000000);
|
||||
|
||||
CONFIG_GET_INT(rewind_granularity, "rewind_granularity");
|
||||
|
||||
@ -776,3 +770,4 @@ static void read_keybinds(config_file_t *conf)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user