diff --git a/lib/menu.c b/lib/menu.c index 212a49a..3ca0100 100644 --- a/lib/menu.c +++ b/lib/menu.c @@ -149,8 +149,8 @@ calc_menu ( struct eMenu* menu, int sp_select_button ) else if ( spGetInput()->button[SP_BUTTON_UP] ) menu_select_up( menu ); else - return -1; - return 0; + return CALCMENU_NOINPUT; + return CALCMENU_MOVED; } // ------------------------------------------------------------------- diff --git a/lib/menu.h b/lib/menu.h index 142f8c0..69375d1 100644 --- a/lib/menu.h +++ b/lib/menu.h @@ -1,5 +1,8 @@ #include +#define CALCMENU_NOINPUT -1 +#define CALCMENU_MOVED 0 + struct eMenu; struct eMenuElement; diff --git a/tests/test-menu.c b/tests/test-menu.c index d99fcf6..d40817f 100644 --- a/tests/test-menu.c +++ b/tests/test-menu.c @@ -46,11 +46,13 @@ draw_test ( void ) testMenu->surface ); spFontDrawMiddle( spGetWindowSurface()->w/2, - spGetWindowSurface()->h-fonts[0]->maxheight*2.5, 0, - "Press [S] to select", fonts[0] ); + spGetWindowSurface()->h + - fonts[FN_COZETTE]->maxheight * 2.5, 0, + "Press [S] to select", fonts[FN_COZETTE] ); spFontDrawMiddle( spGetWindowSurface()->w/2, - spGetWindowSurface()->h-fonts[0]->maxheight-2, 0, - "Press [E] to exit", fonts[0] ); + spGetWindowSurface()->h + - fonts[FN_COZETTE]->maxheight -2, 0, + "Press [E] to exit", fonts[FN_COZETTE] ); spFlip(); } @@ -59,13 +61,15 @@ int calc_test ( Uint32 steps ) { int menucode = calc_menu ( testMenu, SP_BUTTON_START ); - if ( menucode == -1 ) + // no input? interpret keypress as our own + if ( menucode == CALCMENU_NOINPUT ) if ( spGetInput()->button[SP_BUTTON_SELECT] ) return -1; else return 0; - if ( menucode > 0 ) + // greater than _moved means it returned the inc'd menu selection index + if ( menucode > CALCMENU_MOVED ) spSleep(700000); // sleep long enough after selection to play selection sound lol return menucode; @@ -96,12 +100,13 @@ init ( void ) void init_test_menu ( struct eMenu* menu ) { - init_menu( menu, "what do you do? <3", &fonts[1], &fonts[0], + init_menu( menu, "what do you do? <3", + &fonts[FN_LOVEMECHAIN], &fonts[FN_COZETTE], spGetRGB(80,80,80), spGetRGB(35,71,107) ); menu->titleCentered = 0; menu->textCentered = 0; - menu->moveSound = sounds[0]; - menu->selectSound = sounds[1]; + menu->moveSound = sounds[SF_TAMBORINE]; + menu->selectSound = sounds[SF_EEUH]; add_menu_element(menu, "give up"); add_menu_element(menu, "run away"); add_menu_element(menu, "eat a baby"); diff --git a/tests/test-menu.h b/tests/test-menu.h index 6d51d3b..c96b247 100644 --- a/tests/test-menu.h +++ b/tests/test-menu.h @@ -1,5 +1,10 @@ #include +#define FN_COZETTE 0 +#define FN_LOVEMECHAIN 1 +#define SF_TAMBORINE 0 +#define SF_EEUH 1 + int calc_test ( Uint32 ); void draw_test ( void ); void resize ( Uint16, Uint16 );