From: hgn Date: Tue, 9 Apr 2024 16:10:20 +0000 (+0100) Subject: add move sound to ui X-Git-Url: https://harrygodden.com/git/?p=carveJwlIkooP6JGAAIwe30JlM.git;a=commitdiff_plain;h=f3277e0e363fa8c486816072fc0467204f620c32 add move sound to ui --- diff --git a/audio.c b/audio.c index 1b0a2cf..a5080cd 100644 --- 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 d5c8d5e..d3e97a7 100644 --- 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(); } } } diff --git a/models_src/rs_menu.mdl b/models_src/rs_menu.mdl index 048afcb..0c85cc9 100644 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 index 0000000..fe3fb86 Binary files /dev/null and b/sound_src/ui_move.ogg differ