From 0cd9ebfb8b8d85c500f823a412833b5da6e3fe15 Mon Sep 17 00:00:00 2001 From: Nebuleon Fumika Date: Sat, 19 Jan 2013 23:01:36 -0500 Subject: GUI touch handling improvements. * Don't select items defined with type HIDEN_TYPE. That's for items like the card capacity display. * Don't change current_option and current_option_num until we're sure of what's going on. * Don't select an item from another menu if you touch a phantom menu item below the last one of the active menu. For example, Video & audio's item 5 would call up the ROM loading dialog. This is now fixed. * Handle NUMBER_SELECTION_TYPE and STRING_SELECTION_TYPE as invocations of CURSOR_RIGHT. This fixes the language selector not updating the language in the GUI when touched. * Handle ACTION_TYPE. This fixes the Load cheat file menu item not working when touched. --- source/nds/gui.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/source/nds/gui.c b/source/nds/gui.c index 1582b16..969925f 100644 --- a/source/nds/gui.c +++ b/source/nds/gui.c @@ -2566,7 +2566,7 @@ u32 menu(u16 *screen) void save_screen_snapshot() { - if((gui_action == CURSOR_SELECT)) + if(gui_action == CURSOR_SELECT) { if(bg_screenp != NULL) { @@ -3574,16 +3574,21 @@ u32 menu(u16 *screen) // ___ 60 above or below these are ignored. // . . . (+27) The row between 33 and 60 is [1], though! // ___ 192 - current_option_num = (inputdata.y - 33) / 27 + 1; + u32 next_option_num = (inputdata.y - 33) / 27 + 1; + struct _MENU_OPTION_TYPE *next_option = current_menu->options + next_option_num; - current_option = current_menu->options + current_option_num; + if (next_option_num >= current_menu->num_options) + break; - if(!current_option) + if(!next_option) break; - if(current_option -> option_type & HIDEN_TYPE) + if(next_option -> option_type & HIDEN_TYPE) break; + current_option_num = next_option_num; + current_option = current_menu->options + current_option_num; + if(current_menu->key_function) { gui_action = CURSOR_RIGHT; @@ -3591,6 +3596,7 @@ u32 menu(u16 *screen) } else if(current_option->option_type & (NUMBER_SELECTION_TYPE | STRING_SELECTION_TYPE)) { + gui_action = CURSOR_RIGHT; u32 current_option_val = *(current_option->current_option); if(current_option_val < current_option->num_options -1) @@ -3602,6 +3608,8 @@ u32 menu(u16 *screen) if(current_option->action_function) current_option->action_function(); } + else if(current_option->option_type & ACTION_TYPE) + current_option->action_function(); } /* Save states */ else if(current_menu == (main_menu.options + 1)->sub_menu) -- cgit v1.2.3