]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Revise focus sound, use a time guard to prevent "Geiger counter" effect
authorSeverin Meyer <sev.ch@web.de>
Fri, 23 Jan 2015 18:05:11 +0000 (19:05 +0100)
committerSeverin Meyer <sev.ch@web.de>
Fri, 23 Jan 2015 18:05:11 +0000 (19:05 +0100)
qcsrc/menu/item.c
qcsrc/menu/item/button.c
qcsrc/menu/item/inputbox.c
qcsrc/menu/item/listbox.c
qcsrc/menu/item/slider.c
qcsrc/menu/menu.qc
qcsrc/menu/menu.qh
qcsrc/menu/xonotic/serverlist.c

index d055b1a051d535dbfd18736751eb2357c25003a0..d0bd40b03884c30d4e83c6727e82d89ac23019a3 100644 (file)
@@ -17,6 +17,7 @@ CLASS(Item) EXTENDS(Object)
        METHOD(Item, destroy, void(entity))
        ATTRIB(Item, focused, float, 0)
        ATTRIB(Item, focusable, float, 0)
+       ATTRIB(Item, allowFocusSound, float, 0)
        ATTRIB(Item, parent, entity, NULL)
        ATTRIB(Item, preferredFocusPriority, float, 0)
        ATTRIB(Item, origin, vector, '0 0 0')
@@ -121,6 +122,8 @@ float Item_mouseRelease(entity me, vector pos)
 
 void Item_focusEnter(entity me)
 {
+       if(me.allowFocusSound)
+               m_play_focus_sound();
 }
 
 void Item_focusLeave(entity me)
index 8bbdfa70406e125083dc6572acedf2f123aeb120..3af4d4787d3cae0f0d056401cf3a467d752d9132 100644 (file)
@@ -8,7 +8,6 @@ CLASS(Button) EXTENDS(Label)
        METHOD(Button, mousePress, float(entity, vector))
        METHOD(Button, mouseDrag, float(entity, vector))
        METHOD(Button, mouseRelease, float(entity, vector))
-       METHOD(Button, focusEnter, void(entity))
        ATTRIB(Button, onClick, void(entity, entity), func_null)
        ATTRIB(Button, onClickEntity, entity, NULL)
        ATTRIB(Button, src, string, string_null)
@@ -18,6 +17,7 @@ CLASS(Button) EXTENDS(Label)
        ATTRIB(Button, srcMulti, float, 1) // 0: button square left, text right; 1: button stretched, text over it
        ATTRIB(Button, buttonLeftOfText, float, 0)
        ATTRIB(Button, focusable, float, 1)
+       ATTRIB(Button, allowFocusSound, float, 1)
        ATTRIB(Button, pressed, float, 0)
        ATTRIB(Button, clickTime, float, 0)
        ATTRIB(Button, disabled, float, 0)
@@ -92,12 +92,6 @@ void Button_showNotify(entity me)
 {
        me.focusable = !me.disabled;
 }
-void Button_focusEnter(entity me)
-{
-       if(cvar("menu_sounds") > 1)
-               localsound("sound/misc/menu1.wav");
-       SUPER(Button).focusEnter(me);
-}
 void Button_draw(entity me)
 {
        vector bOrigin, bSize;
index 1c1bf5189bc34a48a824a46f132e96e79e2f83cb..e4ad0ef272de67e3b6d0f8a45872075ec50729fe 100644 (file)
@@ -18,6 +18,7 @@ CLASS(InputBox) EXTENDS(Label)
        ATTRIB(InputBox, scrollPos, float, 0) // widths
 
        ATTRIB(InputBox, focusable, float, 1)
+       ATTRIB(InputBox, allowFocusSound, float, 1)
        ATTRIB(InputBox, disabled, float, 0)
        ATTRIB(InputBox, lastChangeTime, float, 0)
        ATTRIB(InputBox, dragScrollTimer, float, 0)
index 275b99735b72529f974f015519770192fdb51509..3466b134bd708890b490879cf607dd4c824fff9d 100644 (file)
@@ -9,6 +9,7 @@ CLASS(ListBox) EXTENDS(Item)
        METHOD(ListBox, mouseRelease, float(entity, vector))
        METHOD(ListBox, focusLeave, void(entity))
        ATTRIB(ListBox, focusable, float, 1)
+       ATTRIB(ListBox, allowFocusSound, float, 1)
        ATTRIB(ListBox, selectedItem, float, 0)
        ATTRIB(ListBox, size, vector, '0 0 0')
        ATTRIB(ListBox, origin, vector, '0 0 0')
index c92db27e984f84be22a86ff2ae8049d190c3d478..1f7c287c740e3542fe02bd8a65058cd747267bff 100644 (file)
@@ -10,7 +10,6 @@ CLASS(Slider) EXTENDS(Label)
        METHOD(Slider, mousePress, float(entity, vector))
        METHOD(Slider, mouseDrag, float(entity, vector))
        METHOD(Slider, mouseRelease, float(entity, vector))
-       METHOD(Slider, focusEnter, void(entity))
        METHOD(Slider, valueToText, string(entity, float))
        METHOD(Slider, toString, string(entity))
        METHOD(Slider, setValue, void(entity, float))
@@ -18,6 +17,7 @@ CLASS(Slider) EXTENDS(Label)
        METHOD(Slider, showNotify, void(entity))
        ATTRIB(Slider, src, string, string_null)
        ATTRIB(Slider, focusable, float, 1)
+       ATTRIB(Slider, allowFocusSound, float, 1)
        ATTRIB(Slider, value, float, 0)
        ATTRIB(Slider, animated, float, 1)
        ATTRIB(Slider, sliderValue, float, 0)
@@ -250,12 +250,6 @@ void Slider_showNotify(entity me)
 {
        me.focusable = !me.disabled;
 }
-void Slider_focusEnter(entity me)
-{
-       if(cvar("menu_sounds") > 1)
-               localsound("sound/misc/menu1.wav");
-       SUPER(Slider).focusEnter(me);
-}
 void Slider_draw(entity me)
 {
        float controlLeft;
index aa771649d663fa705e6980d4870ef3d5174624b0..0a93992efa9d20c42a920c195ae299737b7cdf23 100644 (file)
@@ -1001,3 +1001,14 @@ void m_goto(string itemname)
                }
        }
 }
+
+float menuLastFocusSoundTime;
+void m_play_focus_sound()
+{
+       if(cvar("menu_sounds") > 1)
+               if(time - menuLastFocusSoundTime > 0.25)
+               {
+                       localsound("sound/menu/focus.wav");
+                       menuLastFocusSoundTime = time;
+               }
+}
index b6c0795a8544424d505b8392d8d7f4f7cec59825..17c4291faadaa788cf3b514d27a204f650439980 100644 (file)
@@ -38,3 +38,7 @@ void preMenuDraw(); // this is run before the menu is drawn. You may put some st
 void postMenuDraw(); // this is run just after the menu is drawn (or not). Useful to draw something over everything else.
 
 void m_sync();
+
+// sounds
+
+void m_play_focus_sound();
index c78cba0e0667c931bb7d5ed23b40a256adf0c4da..fdbe9c3dd7cd976a8f1b07fa1bb3711ce7cbff9a 100644 (file)
@@ -561,6 +561,7 @@ void XonoticServerList_refreshServerList(entity me, float mode)
 }
 void XonoticServerList_focusEnter(entity me)
 {
+       SUPER(XonoticServerList).focusEnter(me);
        if(time < me.nextRefreshTime)
        {
                //print("sorry, no refresh yet\n");