From dcac2c616f7e87ac3f444ecc3893107f7a91ef22 Mon Sep 17 00:00:00 2001 From: Aidan MacDonald Date: Sun, 21 Nov 2021 16:30:38 +0000 Subject: Add setting for numeric list sort order The sort order of numeric lists can now be changed with the new "List Order" setting. It defaults to ascending for most scrollwheel targets and descending for all others, matching the old hardcoded behavior. Change-Id: I4866f04ec5995158edf9e40badf7f661b3ddea81 --- apps/gui/option_select.c | 62 ++++++++++++++++++++++++++---------------------- 1 file changed, 33 insertions(+), 29 deletions(-) (limited to 'apps/gui/option_select.c') diff --git a/apps/gui/option_select.c b/apps/gui/option_select.c index 9f1f0a64e3..7068fee510 100644 --- a/apps/gui/option_select.c +++ b/apps/gui/option_select.c @@ -334,29 +334,35 @@ static int selection_to_val(const struct settings_list *setting, int selection) else if ((setting->flags & F_T_SOUND) == F_T_SOUND) { int setting_id = setting->sound_setting->setting; -#ifndef ASCENDING_INT_SETTINGS - step = sound_steps(setting_id); - max = (setting_id == SOUND_VOLUME) ? - global_settings.volume_limit : sound_max(setting_id); - /* min = sound_min(setting_id); */ -#else - step = -sound_steps(setting_id); - /* min = sound_max(setting_id); */ - max = sound_min(setting_id); -#endif + if(global_settings.list_order == LIST_ORDER_DESCENDING) + { + step = sound_steps(setting_id); + max = (setting_id == SOUND_VOLUME) ? + global_settings.volume_limit : sound_max(setting_id); + /* min = sound_min(setting_id); */ + } + else + { + step = -sound_steps(setting_id); + /* min = sound_max(setting_id); */ + max = sound_min(setting_id); + } } else if ((setting->flags & F_INT_SETTING) == F_INT_SETTING) { const struct int_setting *info = setting->int_setting; -#ifndef ASCENDING_INT_SETTINGS - /* min = info->min; */ - max = info->max; - step = info->step; -#else - max = info->min; - /* min = info->max; */ - step = -info->step; -#endif + if(global_settings.list_order == LIST_ORDER_DESCENDING) + { + /* min = info->min; */ + max = info->max; + step = info->step; + } + else + { + max = info->min; + /* min = info->max; */ + step = -info->step; + } } return max- (selection * step); } @@ -424,11 +430,10 @@ static void val_to_selection(const struct settings_list *setting, int oldvalue, int max = (setting_id == SOUND_VOLUME) ? global_settings.volume_limit : sound_max(setting_id); *nb_items = (max-min)/steps + 1; -#ifndef ASCENDING_INT_SETTINGS - *selected = (max - oldvalue) / steps; -#else - *selected = (oldvalue - min) / steps; -#endif + if (global_settings.list_order == LIST_ORDER_DESCENDING) + *selected = (max - oldvalue) / steps; + else + *selected = (oldvalue - min) / steps; *function = sound_get_fn(setting_id); } else @@ -439,11 +444,10 @@ static void val_to_selection(const struct settings_list *setting, int oldvalue, min = info->min; step = info->step; *nb_items = (max-min)/step + 1; -#ifndef ASCENDING_INT_SETTINGS - *selected = (max - oldvalue) / step; -#else - *selected = (oldvalue - min) / step; -#endif + if(global_settings.list_order == LIST_ORDER_DESCENDING) + *selected = (max - oldvalue) / step; + else + *selected = (oldvalue - min) / step; *function = info->option_callback; } } -- cgit v1.2.3