From 889194c9ca701356e84daaa5af7b286585643586 Mon Sep 17 00:00:00 2001 From: Jaidyn Ann Date: Sun, 31 May 2020 02:31:32 -0500 Subject: [PATCH] Add selectionSound to eMenus --- data/sound/eeuh.ogg | Bin 0 -> 11345 bytes lib/menu.c | 11 ++++++++++- lib/menu.h | 5 +++-- tests/test-menu.c | 5 +++++ 4 files changed, 18 insertions(+), 3 deletions(-) create mode 100644 data/sound/eeuh.ogg diff --git a/data/sound/eeuh.ogg b/data/sound/eeuh.ogg new file mode 100644 index 0000000000000000000000000000000000000000..f3defcc4e2d75dfca4dc04d2d27169e3ac93cde9 GIT binary patch literal 11345 zcmcI}cRXEB*YDQ5=q(6BID#mL{N*TYex_uhqYIMJd-5G`7WgXq1Bh(zz5Ac$xY zAw&z}?jz6dd7t~f_jB)GcbhYxwP(%DnzhzL?oq3kcGs{C)4CM+$?$bUbWkrlEu6n2po;AF`f+2G9`d9!V*hxs8tqV1pfB*mr0I=YMkiW1~ffOX?@dTtND`TiG z!RYkl=q?89IHB%;DmJJMEdbyGC?2Bt{B;$lVVFGwcf40F%u(}R5gS2_&N7Us^YE6n zTVY+Hv)eF)i;&C+4*<<5qs$&b1IJWWQS6ZnVD*&QtCzhf%Zr%zO>QW$a4%b!y6_hI zg{Jt{oBVk3Z#;FQawPn9-E7jSsfZUs~)K$o94yM;%V6Sn)Bg?P>8;nWV zh>|!UN%<;;c1{(JnGFu54Xy(M4S6x5|;9^z-){*Pj3lxq9`E;0_iynqa7 z%N|eW9#75(aLyhtK7uO?_X40#W#D{WUQi`(XpgrfSd@Ge`jXX$eyLyk#|ap>1AvSW zbC)M`A7~9Y|Ad#Qfw$C*x5f-;3XDbm@6VGfynu?ZXWOMZp$J71EU(Oh0;grjBa|oo zD+%lnmG_k`V>IJn2u7ZqgD%62tDr9-{V%(6Uyf#Y537)7 z6#S(Es4@x4i^st>#*HlUZbnP6pW}E2LGhd+IM!%1WBpAt4M;^NXL8p!>;0YYU$7`P z%Nl+UTLDKzf68=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GU<5Db7yDo`( z==W5a#2VL_r%dTBJuf$&9Sh=r+~ot$G7IOegceCRcsL@El~rN8IOS`;tT9m2Gzh9k z`jLGl`3!w2b5Zbx7t_0Y((iVk>A&B0s^83Kr9W-$cF65gUNtwJoi5Trw=a&~*(Vy~ zFF#3qQ|=|hgk-nX&<~Y**x%KfGxmevEW*eFKhO`d@ z&mFdYy=kda+TT@+NYB`>LmygN-5TP{3FX$SXnayC2Y)Fc;lgXm`Y<4wFH2v-c&3%Q z-J`Ujmt^gzZ_&vSs3!K4JR$dMo<^vAz;76PKd45Upm7pgIod7r3(Fb!bL;$Agt%%C zt0RcvlxdDD_kn^!IF(c(pm(3?LFFGeU(G1@AH!+cjyp`5KMvK#$BipWG?((HoxAkp@bo^d?om{f*WM5WCtR>{T*XvQl^2y)`$3bRLd}OXxQAPLVCXU6$Nbutton[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"); }