From: Severin Meyer Date: Fri, 23 Jan 2015 21:19:01 +0000 (+0100) Subject: Play OPEN/CLOSE sound when opening/closing dialog X-Git-Tag: xonotic-v0.8.1~147^2~6 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=0ab40a64692367248105ef06286e1226084d7483;p=xonotic%2Fxonotic-data.pk3dir.git Play OPEN/CLOSE sound when opening/closing dialog --- diff --git a/qcsrc/menu/classes.c b/qcsrc/menu/classes.c index 9f01ee3fb..857f071b2 100644 --- a/qcsrc/menu/classes.c +++ b/qcsrc/menu/classes.c @@ -9,12 +9,12 @@ #include "item/modalcontroller.c" #include "item/image.c" #include "item/label.c" +#include "item/dialog.c" #include "item/button.c" #include "item/checkbox.c" #include "item/radiobutton.c" #include "item/borderimage.c" #include "item/slider.c" -#include "item/dialog.c" #include "item/tab.c" #include "item/textslider.c" #include "item/listbox.c" diff --git a/qcsrc/menu/command/menu_cmd.qc b/qcsrc/menu/command/menu_cmd.qc index c7499e58e..890864066 100644 --- a/qcsrc/menu/command/menu_cmd.qc +++ b/qcsrc/menu/command/menu_cmd.qc @@ -85,7 +85,10 @@ void GameCommand(string theCommand) } } else if(argc == 2 && !isdemo()) // don't allow this command in demos + { + m_play_click_sound(MENU_SOUND_OPEN); m_goto(strcat(filter, argv(1))); // switch to a menu item + } if(filter) strunzone(filter); return; diff --git a/qcsrc/menu/item/button.c b/qcsrc/menu/item/button.c index d2cb969f2..385064e5d 100644 --- a/qcsrc/menu/item/button.c +++ b/qcsrc/menu/item/button.c @@ -167,6 +167,11 @@ void Button_draw(entity me) } void Button_playClickSound(entity me) { - m_play_click_sound(MENU_SOUND_EXECUTE); + if(me.onClick == DialogOpenButton_Click) + m_play_click_sound(MENU_SOUND_OPEN); + else if(me.onClick == Dialog_Close) + m_play_click_sound(MENU_SOUND_CLOSE); + else + m_play_click_sound(MENU_SOUND_EXECUTE); } #endif diff --git a/qcsrc/menu/item/dialog.c b/qcsrc/menu/item/dialog.c index 383578781..f60550103 100644 --- a/qcsrc/menu/item/dialog.c +++ b/qcsrc/menu/item/dialog.c @@ -182,6 +182,7 @@ float Dialog_keyDown(entity me, float key, float ascii, float shift) { if(key == K_ESCAPE) { + m_play_click_sound(MENU_SOUND_CLOSE); me.close(me); return 1; } diff --git a/qcsrc/menu/item/nexposee.c b/qcsrc/menu/item/nexposee.c index ca7ab8fc3..0adc399e0 100644 --- a/qcsrc/menu/item/nexposee.c +++ b/qcsrc/menu/item/nexposee.c @@ -219,6 +219,7 @@ float Nexposee_mousePress(entity me, vector pos) Nexposee_mouseMove(me, pos); if(me.mouseFocusedChild) { + m_play_click_sound(MENU_SOUND_OPEN); me.animationState = 1; SUPER(Nexposee).setFocus(me, NULL); } @@ -230,6 +231,7 @@ float Nexposee_mousePress(entity me, vector pos) { if (!(SUPER(Nexposee).mousePress(me, pos))) { + m_play_click_sound(MENU_SOUND_CLOSE); me.animationState = 3; SUPER(Nexposee).setFocus(me, NULL); } @@ -322,10 +324,12 @@ float Nexposee_keyDown(entity me, float scan, float ascii, float shift) default: case 0: case 3: + m_play_click_sound(MENU_SOUND_OPEN); me.animationState = 1; break; case 1: case 2: + m_play_click_sound(MENU_SOUND_CLOSE); me.animationState = 3; break; } diff --git a/qcsrc/menu/menu.qh b/qcsrc/menu/menu.qh index f336198a3..b5b12e2ef 100644 --- a/qcsrc/menu/menu.qh +++ b/qcsrc/menu/menu.qh @@ -42,7 +42,9 @@ void m_sync(); // sounds const string MENU_SOUND_CLEAR = "sound/menu/clear.wav"; +const string MENU_SOUND_CLOSE = "sound/menu/close.wav"; const string MENU_SOUND_EXECUTE = "sound/menu/execute.wav"; +const string MENU_SOUND_OPEN = "sound/menu/open.wav"; const string MENU_SOUND_SELECT = "sound/menu/select.wav"; const string MENU_SOUND_SLIDE = "sound/menu/slide.wav"; diff --git a/qcsrc/menu/xonotic/maplist.c b/qcsrc/menu/xonotic/maplist.c index 0497fa08d..54166f6e0 100644 --- a/qcsrc/menu/xonotic/maplist.c +++ b/qcsrc/menu/xonotic/maplist.c @@ -153,6 +153,7 @@ void XonoticMapList_doubleClickListBoxItem(entity me, float i, vector where) if(where_x <= 1) { // pop up map info screen + m_play_click_sound(MENU_SOUND_OPEN); main.mapInfoDialog.loadMapInfo(main.mapInfoDialog, i, me); DialogOpenButton_Click_withCoords(NULL, main.mapInfoDialog, me.origin + eX * (me.columnNameOrigin * me.size_x) + eY * ((me.itemHeight * i - me.scrollPos) * me.size_y), eY * me.itemAbsSize_y + eX * (me.itemAbsSize_x * me.columnNameSize)); } @@ -299,6 +300,7 @@ float XonoticMapList_keyDown(entity me, float scan, float ascii, float shift) if(scan == K_MOUSE2 || scan == K_SPACE || scan == K_ENTER || scan == K_KP_ENTER) { // pop up map info screen + m_play_click_sound(MENU_SOUND_OPEN); main.mapInfoDialog.loadMapInfo(main.mapInfoDialog, me.selectedItem, me); DialogOpenButton_Click_withCoords(NULL, main.mapInfoDialog, me.origin + eX * (me.columnNameOrigin * me.size_x) + eY * ((me.itemHeight * me.selectedItem - me.scrollPos) * me.size_y), eY * me.itemAbsSize_y + eX * (me.itemAbsSize_x * me.columnNameSize)); } diff --git a/qcsrc/menu/xonotic/serverlist.c b/qcsrc/menu/xonotic/serverlist.c index 641efbf22..3d848c9c5 100644 --- a/qcsrc/menu/xonotic/serverlist.c +++ b/qcsrc/menu/xonotic/serverlist.c @@ -1247,6 +1247,7 @@ float XonoticServerList_keyDown(entity me, float scan, float ascii, float shift) { if(me.nItems != 0) { + m_play_click_sound(MENU_SOUND_OPEN); main.serverInfoDialog.loadServerInfo(main.serverInfoDialog, me.selectedItem); DialogOpenButton_Click_withCoords(me, main.serverInfoDialog, org, sz); return 1;