fix selectagon flickering on hud toggle

This commit is contained in:
yuni 2024-04-24 03:55:27 +02:00
parent fe89308a94
commit 366500e928

View file

@ -195,6 +195,7 @@ fn setup(
settings: Res<var::Settings>, settings: Res<var::Settings>,
asset_server: Res<AssetServer>, asset_server: Res<AssetServer>,
mut ambient_light: ResMut<AmbientLight>, mut ambient_light: ResMut<AmbientLight>,
mut ew_updateoverlays: EventWriter<UpdateOverlayVisibility>,
) { ) {
let visibility = if settings.hud_active { let visibility = if settings.hud_active {
Visibility::Inherited Visibility::Inherited
@ -375,6 +376,8 @@ fn setup(
} else { } else {
AMBIENT_LIGHT AMBIENT_LIGHT
}; };
ew_updateoverlays.send(UpdateOverlayVisibility);
} }
fn update_hud( fn update_hud(
@ -661,7 +664,6 @@ fn handle_input(
} }
} }
if keyboard_input.just_pressed(settings.key_togglehud) { if keyboard_input.just_pressed(settings.key_togglehud) {
ew_updateoverlays.send(UpdateOverlayVisibility);
settings.hud_active ^= true; settings.hud_active ^= true;
if settings.hud_active { if settings.hud_active {
ambient_light.brightness = AMBIENT_LIGHT_AR; ambient_light.brightness = AMBIENT_LIGHT_AR;
@ -670,6 +672,7 @@ fn handle_input(
} }
ew_sfx.send(audio::PlaySfxEvent(audio::Sfx::Switch)); ew_sfx.send(audio::PlaySfxEvent(audio::Sfx::Switch));
ew_togglemusic.send(audio::ToggleMusicEvent()); ew_togglemusic.send(audio::ToggleMusicEvent());
ew_updateoverlays.send(UpdateOverlayVisibility);
} }
if settings.hud_active && mouse_input.just_pressed(settings.key_selectobject) { if settings.hud_active && mouse_input.just_pressed(settings.key_selectobject) {
if let Ok(camtrans) = q_camera.get_single() { if let Ok(camtrans) = q_camera.get_single() {