add move sound to ui
authorhgn <hgodden00@gmail.com>
Tue, 9 Apr 2024 16:10:20 +0000 (17:10 +0100)
committerhgn <hgodden00@gmail.com>
Tue, 9 Apr 2024 16:10:20 +0000 (17:10 +0100)
audio.c
menu.c
models_src/rs_menu.mdl
sound_src/ui_move.ogg [new file with mode: 0644]

diff --git a/audio.c b/audio.c
index 1b0a2cf95b93e5d6b52ff7861125813ca89651d0..a5080cd526674040ba03d2d6cb49ac8475ce420c 100644 (file)
--- a/audio.c
+++ b/audio.c
@@ -127,7 +127,8 @@ audio_clip audio_rewind[] = {
 audio_clip audio_ui[] = {
    { .path = "sound/ui_click.ogg" },
    { .path = "sound/ui_ding.ogg" },
-   { .path = "sound/teleport.ogg" }
+   { .path = "sound/teleport.ogg" },
+   { .path = "sound/ui_move.ogg" }
 };
 
 audio_clip audio_challenge[] = {
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();
          }
       }
    }
index 048afcbc4b3c98b26d75f331f7f924c1cfe17a0c..0c85cc9aa8a583c3277e7fb145f472c28a5664fd 100644 (file)
Binary files a/models_src/rs_menu.mdl and b/models_src/rs_menu.mdl differ
diff --git a/sound_src/ui_move.ogg b/sound_src/ui_move.ogg
new file mode 100644 (file)
index 0000000..fe3fb86
Binary files /dev/null and b/sound_src/ui_move.ogg differ