add various sound effects to key presses

This commit is contained in:
yuni 2024-04-25 03:52:32 +02:00
parent d70e22678e
commit 1f3f0eec7a
3 changed files with 5 additions and 1 deletions

View file

@ -284,6 +284,7 @@ pub fn handle_input(
settings.third_person ^= true; settings.third_person ^= true;
} }
if keyboard_input.just_pressed(settings.key_shadows) { if keyboard_input.just_pressed(settings.key_shadows) {
ew_sfx.send(audio::PlaySfxEvent(audio::Sfx::Click));
settings.shadows_sun ^= true; settings.shadows_sun ^= true;
for mut light in &mut q_light { for mut light in &mut q_light {
light.shadows_enabled = settings.shadows_sun; light.shadows_enabled = settings.shadows_sun;
@ -298,7 +299,7 @@ pub fn handle_input(
ew_updateoverlays.send(hud::UpdateOverlayVisibility); ew_updateoverlays.send(hud::UpdateOverlayVisibility);
} }
if keyboard_input.just_pressed(settings.key_rotation_stabilizer) { if keyboard_input.just_pressed(settings.key_rotation_stabilizer) {
ew_sfx.send(audio::PlaySfxEvent(audio::Sfx::Click)); ew_sfx.send(audio::PlaySfxEvent(audio::Sfx::Switch));
settings.rotation_stabilizer_active ^= true; settings.rotation_stabilizer_active ^= true;
} }
} }

View file

@ -647,6 +647,7 @@ fn handle_input(
q_camera: Query<&Transform, With<Camera>>, q_camera: Query<&Transform, With<Camera>>,
) { ) {
if keyboard_input.just_pressed(settings.key_help) { if keyboard_input.just_pressed(settings.key_help) {
ew_sfx.send(audio::PlaySfxEvent(audio::Sfx::Click));
for line in include_str!("data/keybindings.in").trim().lines().rev() { for line in include_str!("data/keybindings.in").trim().lines().rev() {
log.add(line.to_string(), "".to_string(), LogLevel::Always); log.add(line.to_string(), "".to_string(), LogLevel::Always);
} }

View file

@ -154,11 +154,13 @@ fn handle_input(
opt: Res<CommandLineOptions>, opt: Res<CommandLineOptions>,
mut app_exit_events: ResMut<Events<bevy::app::AppExit>>, mut app_exit_events: ResMut<Events<bevy::app::AppExit>>,
mut windows: Query<&mut Window, With<PrimaryWindow>>, mut windows: Query<&mut Window, With<PrimaryWindow>>,
mut ew_sfx: EventWriter<audio::PlaySfxEvent>,
) { ) {
if keyboard_input.pressed(settings.key_exit) { if keyboard_input.pressed(settings.key_exit) {
app_exit_events.send(bevy::app::AppExit); app_exit_events.send(bevy::app::AppExit);
} }
if keyboard_input.just_pressed(settings.key_fullscreen) { if keyboard_input.just_pressed(settings.key_fullscreen) {
ew_sfx.send(audio::PlaySfxEvent(audio::Sfx::Click));
for mut window in &mut windows { for mut window in &mut windows {
window.mode = if window.mode == WindowMode::Windowed { window.mode = if window.mode == WindowMode::Windowed {
opt.window_mode_fullscreen opt.window_mode_fullscreen