diff --git a/assets/ui/down_button_1.ogg b/assets/ui/down_button_1.ogg new file mode 100644 index 00000000..fc792950 Binary files /dev/null and b/assets/ui/down_button_1.ogg differ diff --git a/assets/ui/down_button_2.ogg b/assets/ui/down_button_2.ogg new file mode 100644 index 00000000..d4286019 Binary files /dev/null and b/assets/ui/down_button_2.ogg differ diff --git a/assets/ui/down_button_3.ogg b/assets/ui/down_button_3.ogg new file mode 100644 index 00000000..85ef394e Binary files /dev/null and b/assets/ui/down_button_3.ogg differ diff --git a/assets/ui/down_play_button.ogg b/assets/ui/down_play_button.ogg new file mode 100644 index 00000000..735cd2c2 Binary files /dev/null and b/assets/ui/down_play_button.ogg differ diff --git a/assets/ui/focused_button_1.ogg b/assets/ui/focused_button_1.ogg new file mode 100644 index 00000000..6cfb2a27 Binary files /dev/null and b/assets/ui/focused_button_1.ogg differ diff --git a/assets/ui/focused_button_2.ogg b/assets/ui/focused_button_2.ogg new file mode 100644 index 00000000..4b8f4f1c Binary files /dev/null and b/assets/ui/focused_button_2.ogg differ diff --git a/assets/ui/focused_button_3.ogg b/assets/ui/focused_button_3.ogg new file mode 100644 index 00000000..cf512a6e Binary files /dev/null and b/assets/ui/focused_button_3.ogg differ diff --git a/src/audio.rs b/src/audio.rs index d83ab219..6c6f4775 100644 --- a/src/audio.rs +++ b/src/audio.rs @@ -2,6 +2,7 @@ // Also for cleanness (named channels have evident function), we don't use the default channel. use bevy::{prelude::*, utils::HashMap}; +use bevy_egui::{egui::output::OutputEvent, EguiContext}; use bevy_kira_audio::{AudioApp, AudioChannel, AudioSource}; use iyes_loopless::prelude::*; @@ -92,6 +93,26 @@ pub fn animation_audio_playback( } } +/// Plays main menu sounds +pub fn main_menu_sounds( + mut context: ResMut, + effects_channel: Res>, + asset_server: Res, +) { + for event in &context.ctx_mut().output().events { + println!("{:?}", event); + if let OutputEvent::Clicked(info) = event { + if info.label.as_ref().unwrap() == "Start Game" { + //Play down_play_button + effects_channel.play(asset_server.load("ui/down_play_button.ogg")); + } else { + //Play one of the down button audios, except down_play_button + effects_channel.play(asset_server.load("ui/down_button_1.ogg")); + } + } + } +} + pub fn play_menu_music(game_meta: Res, music_channel: Res>) { // This is a workaround for a Bevy Kira bug where stopping a sound immediately after // playing it doesn't work. We run into this issue when the menu starts and immediately diff --git a/src/main.rs b/src/main.rs index 2df91ad8..10194be1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -97,7 +97,6 @@ fn main() { asset_server_settings.asset_folder = asset_dir.clone(); } app.insert_resource(asset_server_settings); - // Add default plugins #[cfg(feature = "schedule_graph")] app.add_plugins_with(DefaultPlugins, |plugins| { @@ -132,6 +131,10 @@ fn main() { .run_in_state(GameState::InGame) .with_system(game_over_on_players_death) .into(), + ) + .add_system_to_stage( + CoreStage::PostUpdate, + main_menu_sounds.before(bevy_egui::EguiSystem::ProcessOutput), ); // Register reflect types that don't come from plugins