Do wraparound of settings

This commit is contained in:
twinaphex 2015-07-04 19:58:43 +02:00
parent 665cbbd39e
commit e438dd3263
4 changed files with 46 additions and 7 deletions

View File

@ -570,6 +570,7 @@ static void config_set_defaults(void)
settings->menu.dpi.override_enable = menu_dpi_override_enable;
settings->menu.dpi.override_value = menu_dpi_override_value;
settings->menu.navigation.wraparound.setting_enable = true;
settings->menu.navigation.wraparound.horizontal_enable = true;
settings->menu.navigation.wraparound.vertical_enable = true;
settings->menu.navigation.browser.filter.supported_extensions_enable = true;

View File

@ -132,6 +132,7 @@ typedef struct settings
{
bool horizontal_enable;
bool vertical_enable;
bool setting_enable;
} wraparound;
struct
{

View File

@ -106,7 +106,7 @@ bool core_info_list_get_display_name(core_info_list_t *list,
bool core_info_get_display_name_from_file(const char *path, char *buf, size_t size);
void core_info_get_name(const char *path, char *s, size_t len);
bool core_info_get_display_name(const char *path, char *s, size_t len);
#ifdef __cplusplus
}

View File

@ -508,8 +508,15 @@ int setting_set_with_string_representation(rarch_setting_t* setting,
if (setting->enforce_minrange && *setting->value.integer < setting->min)
*setting->value.integer = setting->min;
if (setting->enforce_maxrange && *setting->value.integer > setting->max)
{
settings_t *settings = config_get_ptr();
if (settings && settings->menu.navigation.wraparound.setting_enable)
*setting->value.integer = setting->min;
else
*setting->value.integer = setting->max;
}
}
break;
case ST_UINT:
sscanf(value, "%u", setting->value.unsigned_integer);
@ -518,8 +525,15 @@ int setting_set_with_string_representation(rarch_setting_t* setting,
if (setting->enforce_minrange && *setting->value.unsigned_integer < setting->min)
*setting->value.unsigned_integer = setting->min;
if (setting->enforce_maxrange && *setting->value.unsigned_integer > setting->max)
{
settings_t *settings = config_get_ptr();
if (settings && settings->menu.navigation.wraparound.setting_enable)
*setting->value.unsigned_integer = setting->min;
else
*setting->value.unsigned_integer = setting->max;
}
}
break;
case ST_FLOAT:
sscanf(value, "%f", setting->value.fraction);
@ -528,8 +542,15 @@ int setting_set_with_string_representation(rarch_setting_t* setting,
if (setting->enforce_minrange && *setting->value.fraction < setting->min)
*setting->value.fraction = setting->min;
if (setting->enforce_maxrange && *setting->value.fraction > setting->max)
{
settings_t *settings = config_get_ptr();
if (settings && settings->menu.navigation.wraparound.setting_enable)
*setting->value.fraction = setting->min;
else
*setting->value.fraction = setting->max;
}
}
break;
case ST_PATH:
case ST_DIR:
@ -975,8 +996,15 @@ static int setting_uint_action_right_default(void *data, bool wraparound)
if (setting->enforce_maxrange)
{
if (*setting->value.unsigned_integer > setting->max)
{
settings_t *settings = config_get_ptr();
if (settings && settings->menu.navigation.wraparound.setting_enable)
*setting->value.unsigned_integer = setting->min;
else
*setting->value.unsigned_integer = setting->max;
}
}
return 0;
}
@ -1015,8 +1043,15 @@ static int setting_fraction_action_right_default(
if (setting->enforce_maxrange)
{
if (*setting->value.fraction > setting->max)
{
settings_t *settings = config_get_ptr();
if (settings && settings->menu.navigation.wraparound.setting_enable)
*setting->value.fraction = setting->min;
else
*setting->value.fraction = setting->max;
}
}
return 0;
}
@ -1050,7 +1085,9 @@ static int setting_string_action_right_driver(void *data,
if (!find_next_driver(setting->name, setting->value.string, setting->size))
{
if (wraparound)
settings_t *settings = config_get_ptr();
if (settings && settings->menu.navigation.wraparound.setting_enable)
find_first_driver(setting->name, setting->value.string, setting->size);
}