diff options
Diffstat (limited to 'apps/gui/option_select.c')
-rw-r--r-- | apps/gui/option_select.c | 104 |
1 files changed, 53 insertions, 51 deletions
diff --git a/apps/gui/option_select.c b/apps/gui/option_select.c index c6136ebf17..43b5fa6ea1 100644 --- a/apps/gui/option_select.c +++ b/apps/gui/option_select.c | |||
@@ -60,7 +60,7 @@ static const char *unit_strings[] = | |||
60 | /* these two vars are needed so arbitrary values can be added to the | 60 | /* these two vars are needed so arbitrary values can be added to the |
61 | TABLE_SETTING settings if the F_ALLOW_ARBITRARY_VALS flag is set */ | 61 | TABLE_SETTING settings if the F_ALLOW_ARBITRARY_VALS flag is set */ |
62 | static int table_setting_oldval = 0, table_setting_array_position = 0; | 62 | static int table_setting_oldval = 0, table_setting_array_position = 0; |
63 | static char *option_get_valuestring(struct settings_list *setting, | 63 | char *option_get_valuestring(struct settings_list *setting, |
64 | char *buffer, int buf_len, | 64 | char *buffer, int buf_len, |
65 | intptr_t temp_var) | 65 | intptr_t temp_var) |
66 | { | 66 | { |
@@ -210,56 +210,37 @@ static int option_talk(int selected_item, void * data) | |||
210 | } | 210 | } |
211 | return 0; | 211 | return 0; |
212 | } | 212 | } |
213 | #if 0 | ||
214 | int option_select_next_val(struct settings_list *setting, | ||
215 | intptr_t temp_var) | ||
216 | { | ||
217 | int val = 0; | ||
218 | if ((setting->flags & F_BOOL_SETTING) == F_BOOL_SETTING) | ||
219 | { | ||
220 | val = (bool)temp_var ? 0 : 1; | ||
221 | } | ||
222 | else if ((setting->flags & F_INT_SETTING) == F_INT_SETTING) | ||
223 | { | ||
224 | struct int_setting *info = setting->int_setting; | ||
225 | val = (int)temp_var + info->step; | ||
226 | if (val > info->max) | ||
227 | val = info->min; | ||
228 | } | ||
229 | else if ((setting->flags & F_T_SOUND) == F_T_SOUND) | ||
230 | { | ||
231 | int setting_id = setting->sound_setting->setting; | ||
232 | int steps = sound_steps(setting_id); | ||
233 | int min = sound_min(setting_id); | ||
234 | int max = sound_max(setting_id); | ||
235 | val = (int)temp_var + steps; | ||
236 | if (val > max) | ||
237 | val = min; | ||
238 | } | ||
239 | else if ((setting->flags & F_CHOICE_SETTING) == F_CHOICE_SETTING) | ||
240 | { | ||
241 | struct choice_setting *info = setting->choice_setting; | ||
242 | val = (int)temp_var; | ||
243 | if (val > info->count) | ||
244 | val = 0; | ||
245 | } | ||
246 | return val; | ||
247 | } | ||
248 | 213 | ||
249 | int option_select_prev_val(struct settings_list *setting, | 214 | #ifdef HAVE_QUICKSCREEN /* only the quickscreen uses this so far */ |
250 | intptr_t temp_var) | 215 | void option_select_next_val(struct settings_list *setting, |
216 | bool previous, bool apply) | ||
251 | { | 217 | { |
252 | int val = 0; | 218 | int val = 0; |
219 | int *value = setting->setting; | ||
253 | if ((setting->flags & F_BOOL_SETTING) == F_BOOL_SETTING) | 220 | if ((setting->flags & F_BOOL_SETTING) == F_BOOL_SETTING) |
254 | { | 221 | { |
255 | val = (bool)temp_var ? 0 : 1; | 222 | *(bool*)value = !*(bool*)value; |
223 | if (apply && setting->bool_setting->option_callback) | ||
224 | setting->bool_setting->option_callback(*(bool*)value); | ||
225 | return; | ||
256 | } | 226 | } |
257 | else if ((setting->flags & F_INT_SETTING) == F_INT_SETTING) | 227 | else if ((setting->flags & F_INT_SETTING) == F_INT_SETTING) |
258 | { | 228 | { |
259 | struct int_setting *info = setting->int_setting; | 229 | struct int_setting *info = (struct int_setting *)setting->int_setting; |
260 | val = (int)temp_var - info->step; | 230 | if (!previous) |
261 | if (val < info->min) | 231 | { |
262 | val = info->max; | 232 | val = *value + info->step; |
233 | if (val > info->max) | ||
234 | val = info->min; | ||
235 | } | ||
236 | else | ||
237 | { | ||
238 | val = *value - info->step; | ||
239 | if (val < info->min) | ||
240 | val = info->max; | ||
241 | } | ||
242 | if (apply && info->option_callback) | ||
243 | info->option_callback(*(int*)value); | ||
263 | } | 244 | } |
264 | else if ((setting->flags & F_T_SOUND) == F_T_SOUND) | 245 | else if ((setting->flags & F_T_SOUND) == F_T_SOUND) |
265 | { | 246 | { |
@@ -267,18 +248,39 @@ int option_select_prev_val(struct settings_list *setting, | |||
267 | int steps = sound_steps(setting_id); | 248 | int steps = sound_steps(setting_id); |
268 | int min = sound_min(setting_id); | 249 | int min = sound_min(setting_id); |
269 | int max = sound_max(setting_id); | 250 | int max = sound_max(setting_id); |
270 | val = (int)temp_var -+ steps; | 251 | if (!previous) |
271 | if (val < min) | 252 | { |
272 | val = max; | 253 | val = *value + steps; |
254 | if (val >= max) | ||
255 | val = min; | ||
256 | } | ||
257 | else | ||
258 | { | ||
259 | val = *value - steps; | ||
260 | if (val < min) | ||
261 | val = max; | ||
262 | } | ||
273 | } | 263 | } |
274 | else if ((setting->flags & F_CHOICE_SETTING) == F_CHOICE_SETTING) | 264 | else if ((setting->flags & F_CHOICE_SETTING) == F_CHOICE_SETTING) |
275 | { | 265 | { |
276 | struct choice_setting *info = setting->choice_setting; | 266 | struct choice_setting *info = (struct choice_setting *)setting->choice_setting; |
277 | val = (int)temp_var; | 267 | val = *value + 1; |
278 | if (val < 0) | 268 | if (!previous) |
279 | val = info->count - 1; | 269 | { |
270 | val = *value + 1; | ||
271 | if (val >= info->count) | ||
272 | val = 0; | ||
273 | } | ||
274 | else | ||
275 | { | ||
276 | val = *value - 1; | ||
277 | if (val < 0) | ||
278 | val = info->count-1; | ||
279 | } | ||
280 | if (apply && info->option_callback) | ||
281 | info->option_callback(*(int*)value); | ||
280 | } | 282 | } |
281 | return val; | 283 | *value = val; |
282 | } | 284 | } |
283 | #endif | 285 | #endif |
284 | 286 | ||