add move sound to ui
[carveJwlIkooP6JGAAIwe30JlM.git] / menu.c
diff --git a/menu.c b/menu.c
index d5c8d5ed1d11401a3c5aac45a1635b7cc5d0f800..d3e97a77099d7d3f90ac6d3bf112cbc33d5e0450 100644 (file)
--- a/menu.c
+++ b/menu.c
@@ -217,10 +217,16 @@ void menu_open_page( const char *name,
  */
 static void menu_trigger_item( ent_menuitem *item )
 {
-   if     ( item->type == k_ent_menuitem_type_event_button ){
+   audio_lock();
+   audio_oneshot( &audio_ui[0], 1.0f, 0.0f );
+   audio_unlock();
+
+   if     ( item->type == k_ent_menuitem_type_event_button )
+   {
       u32 q = item->button.pstr;
 
-      if( MDL_CONST_PSTREQ( &menu.model, q, "quit" ) ){
+      if( MDL_CONST_PSTREQ( &menu.model, q, "quit" ) )
+      {
          vg.window_should_close = 1;
       }
       else if( MDL_CONST_PSTREQ( &menu.model, q, "map" ) ){
@@ -469,7 +475,8 @@ void menu_update(void)
          menu_back_page();
       }
       else if( menu.loc ){
-         if( ui_click_down( UI_MOUSE_LEFT ) ){
+         if( ui_click_down( UI_MOUSE_LEFT ) )
+         {
             menu_trigger_item( menu.loc );
          }
       }
@@ -510,16 +517,21 @@ void menu_update(void)
          mh = 0;
       }
       
-      if( escape ){
+      if( escape )
+      {
          menu_back_page();
+         audio_lock();
+         audio_oneshot( &audio_ui[3], 1.0f, 0.0f );
+         audio_unlock();
       }
-      else if( enter ){
+      else if( enter )
+      {
          menu_trigger_item( menu.loc );
       }
       else if( mh||mv ){
          v3f opt; 
          v3_zero( opt );
-         f32 best = 0.707f;
+         f32 best = 0.5f;
          ent_menuitem *nextpos = NULL;
 
          opt[0] += mh;
@@ -543,8 +555,12 @@ void menu_update(void)
             }
          }
 
-         if( nextpos ){
+         if( nextpos )
+         {
             menu.loc = nextpos;
+            audio_lock();
+            audio_oneshot( &audio_ui[3], 1.0f, 0.0f );
+            audio_unlock();
          }
       }
    }