Skip to content

Commit

Permalink
GUI touch handling improvements.
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
Nebuleon committed Jan 20, 2013
1 parent 88135c5 commit 0cd9ebf
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions source/nds/gui.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -3574,23 +3574,29 @@ 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;
current_menu->key_function();
}
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)
Expand All @@ -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)
Expand Down

0 comments on commit 0cd9ebf

Please sign in to comment.