diff --git a/data/sound/eeuh.ogg b/data/sound/eeuh.ogg new file mode 100644 index 0000000..f3defcc Binary files /dev/null and b/data/sound/eeuh.ogg differ diff --git a/lib/menu.c b/lib/menu.c index 8022dac..212a49a 100644 --- a/lib/menu.c +++ b/lib/menu.c @@ -143,7 +143,7 @@ calc_menu ( struct eMenu* menu, int sp_select_button ) { spSleep(50000); if ( spGetInput()->button[sp_select_button] ) - return menu->selection + 1; + return menu_select( menu ); else if ( spGetInput()->button[SP_BUTTON_DOWN] ) menu_select_down( menu ); else if ( spGetInput()->button[SP_BUTTON_UP] ) @@ -154,6 +154,15 @@ calc_menu ( struct eMenu* menu, int sp_select_button ) } // ------------------------------------------------------------------- +// returns selected menu item, and plays proper sound +int +menu_select ( struct eMenu* menu ) +{ + if ( menu->moveSound != NULL ) + spSoundPlay( menu->selectSound, menu->soundChannel,0,0,-1 ); + return menu->selection + 1; +} + // move an eMenu's selected element up by one (if possible) void menu_select_up ( struct eMenu* menu ) diff --git a/lib/menu.h b/lib/menu.h index b319bf9..142f8c0 100644 --- a/lib/menu.h +++ b/lib/menu.h @@ -51,8 +51,9 @@ int calc_menu ( struct eMenu*, int ); void resize_menu ( struct eMenu* ); -void menu_select_up (struct eMenu* ); -void menu_select_down (struct eMenu* ); +int menu_select ( struct eMenu* ); +void menu_select_up ( struct eMenu* ); +void menu_select_down ( struct eMenu* ); int ideal_menu_height ( struct eMenu* ); int ideal_menu_width ( struct eMenu* ); diff --git a/tests/test-menu.c b/tests/test-menu.c index 9648482..d99fcf6 100644 --- a/tests/test-menu.c +++ b/tests/test-menu.c @@ -65,6 +65,9 @@ calc_test ( Uint32 steps ) else return 0; + if ( menucode > 0 ) + spSleep(700000); + // sleep long enough after selection to play selection sound lol return menucode; } @@ -98,6 +101,7 @@ init_test_menu ( struct eMenu* menu ) menu->titleCentered = 0; menu->textCentered = 0; menu->moveSound = sounds[0]; + menu->selectSound = sounds[1]; add_menu_element(menu, "give up"); add_menu_element(menu, "run away"); add_menu_element(menu, "eat a baby"); @@ -128,6 +132,7 @@ init_sounds ( void ) { spSoundInit(); add_sound("data/sound/tamborine.ogg"); + add_sound("data/sound/eeuh.ogg"); }