Replace usage of DOUBLE with FLOAT in configs.

This commit is contained in:
Themaister 2012-01-30 15:14:30 +01:00
parent bbd6e16bbe
commit ce08251f53
5 changed files with 31 additions and 18 deletions

View File

@ -427,7 +427,12 @@ bool config_get_float(config_file_t *conf, const char *key, float *in)
{
if (strcmp(key, list->key) == 0)
{
#ifdef __cplusplus
// strtof() is C99/POSIX.
*in = (float)strtod(list->value, NULL);
#else
*in = strtof(list->value, NULL);
#endif
return true;
}
list = list->next;
@ -612,6 +617,13 @@ void config_set_double(config_file_t *conf, const char *key, double val)
config_set_string(conf, key, buf);
}
void config_set_float(config_file_t *conf, const char *key, float val)
{
char buf[128];
snprintf(buf, sizeof(buf), "%f", val);
config_set_string(conf, key, buf);
}
void config_set_int(config_file_t *conf, const char *key, int val)
{
char buf[128];

View File

@ -69,6 +69,7 @@ bool config_get_bool(config_file_t *conf, const char *entry, bool *in);
// Setters. Similar to the getters. Will not write to entry if the entry
// was obtained from an #include.
void config_set_double(config_file_t *conf, const char *entry, double value);
void config_set_float(config_file_t *conf, const char *entry, float value);
void config_set_int(config_file_t *conf, const char *entry, int val);
void config_set_char(config_file_t *conf, const char *entry, char val);
void config_set_string(config_file_t *conf, const char *entry, const char *val);

View File

@ -33,9 +33,9 @@
base.var = tmp; \
} while(0)
#define CONFIG_GET_DOUBLE_BASE(conf, base, var, key) do { \
double tmp; \
if (config_get_double(conf, key, &tmp)) \
#define CONFIG_GET_FLOAT_BASE(conf, base, var, key) do { \
float tmp; \
if (config_get_float(conf, key, &tmp)) \
base.var = tmp; \
} while(0)
@ -44,18 +44,18 @@
#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_FLOAT(var, key) CONFIG_GET_FLOAT_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_FLOAT_EXTERN(var, key) CONFIG_GET_FLOAT_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) CONFIG_GET_BOOL_BASE(conf, g_console, var, key)
#define CONFIG_GET_INT_CONSOLE(var, key) CONFIG_GET_INT_BASE(conf, g_console, var, key)
#define CONFIG_GET_DOUBLE_CONSOLE(var, key) CONFIG_GET_DOUBLE_BASE(conf, g_console, var, key)
#define CONFIG_GET_FLOAT_CONSOLE(var, key) CONFIG_GET_FLOAT_BASE(conf, g_console, var, key)
#define CONFIG_GET_STRING_CONSOLE(var, key) CONFIG_GET_STRING_BASE(conf, g_console, var, key)
#endif

View File

@ -133,8 +133,8 @@ static void init_settings(void)
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");
CONFIG_GET_DOUBLE(video.fbo_scale_x, "video_fbo_scale_x");
CONFIG_GET_DOUBLE(video.fbo_scale_y, "video_fbo_scale_y");
CONFIG_GET_FLOAT(video.fbo_scale_x, "video_fbo_scale_x");
CONFIG_GET_FLOAT(video.fbo_scale_y, "video_fbo_scale_y");
CONFIG_GET_BOOL(video.render_to_texture, "video_render_to_texture");
CONFIG_GET_BOOL(video.second_pass_smooth, "video_second_pass_smooth");
CONFIG_GET_BOOL(video.smooth, "video_smooth");

View File

@ -341,8 +341,8 @@ bool config_load_file(const char *path)
char tmp_str[PATH_MAX];
CONFIG_GET_DOUBLE(video.xscale, "video_xscale");
CONFIG_GET_DOUBLE(video.yscale, "video_yscale");
CONFIG_GET_FLOAT(video.xscale, "video_xscale");
CONFIG_GET_FLOAT(video.yscale, "video_yscale");
CONFIG_GET_INT(video.fullscreen_x, "video_fullscreen_x");
CONFIG_GET_INT(video.fullscreen_y, "video_fullscreen_y");
@ -355,15 +355,15 @@ bool config_load_file(const char *path)
CONFIG_GET_BOOL(video.smooth, "video_smooth");
CONFIG_GET_BOOL(video.force_aspect, "video_force_aspect");
CONFIG_GET_BOOL(video.crop_overscan, "video_crop_overscan");
CONFIG_GET_DOUBLE(video.aspect_ratio, "video_aspect_ratio");
CONFIG_GET_DOUBLE(video.refresh_rate, "video_refresh_rate");
CONFIG_GET_FLOAT(video.aspect_ratio, "video_aspect_ratio");
CONFIG_GET_FLOAT(video.refresh_rate, "video_refresh_rate");
CONFIG_GET_STRING(video.cg_shader_path, "video_cg_shader");
CONFIG_GET_STRING(video.bsnes_shader_path, "video_bsnes_shader");
CONFIG_GET_STRING(video.second_pass_shader, "video_second_pass_shader");
CONFIG_GET_BOOL(video.render_to_texture, "video_render_to_texture");
CONFIG_GET_DOUBLE(video.fbo_scale_x, "video_fbo_scale_x");
CONFIG_GET_DOUBLE(video.fbo_scale_y, "video_fbo_scale_y");
CONFIG_GET_FLOAT(video.fbo_scale_x, "video_fbo_scale_x");
CONFIG_GET_FLOAT(video.fbo_scale_y, "video_fbo_scale_y");
CONFIG_GET_BOOL(video.second_pass_smooth, "video_second_pass_smooth");
#ifdef HAVE_FREETYPE
@ -371,8 +371,8 @@ bool config_load_file(const char *path)
CONFIG_GET_INT(video.font_size, "video_font_size");
CONFIG_GET_BOOL(video.font_enable, "video_font_enable");
CONFIG_GET_BOOL(video.font_scale, "video_font_scale");
CONFIG_GET_DOUBLE(video.msg_pos_x, "video_message_pos_x");
CONFIG_GET_DOUBLE(video.msg_pos_y, "video_message_pos_y");
CONFIG_GET_FLOAT(video.msg_pos_x, "video_message_pos_x");
CONFIG_GET_FLOAT(video.msg_pos_y, "video_message_pos_y");
unsigned msg_color;
if (config_get_hex(conf, "video_message_color", &msg_color))
@ -410,7 +410,7 @@ bool config_load_file(const char *path)
CONFIG_GET_STRING(video.shader_dir, "video_shader_dir");
#endif
CONFIG_GET_DOUBLE(input.axis_threshold, "input_axis_threshold");
CONFIG_GET_FLOAT(input.axis_threshold, "input_axis_threshold");
CONFIG_GET_BOOL(input.netplay_client_swap_input, "netplay_client_swap_input");
CONFIG_GET_INT(input.joypad_map[0], "input_player1_joypad_index");
CONFIG_GET_INT(input.joypad_map[1], "input_player2_joypad_index");
@ -421,7 +421,7 @@ bool config_load_file(const char *path)
// Audio settings.
CONFIG_GET_BOOL(audio.enable, "audio_enable");
CONFIG_GET_INT(audio.out_rate, "audio_out_rate");
CONFIG_GET_DOUBLE(audio.rate_step, "audio_rate_step");
CONFIG_GET_FLOAT(audio.rate_step, "audio_rate_step");
CONFIG_GET_STRING(audio.device, "audio_device");
CONFIG_GET_INT(audio.latency, "audio_latency");
CONFIG_GET_BOOL(audio.sync, "audio_sync");