diff --git a/src/hud.rs b/src/hud.rs index d532f73..147adb8 100644 --- a/src/hud.rs +++ b/src/hud.rs @@ -1,6 +1,7 @@ use crate::{settings, actor, audio}; use bevy::prelude::*; use bevy::diagnostic::{DiagnosticsStore, FrameTimeDiagnosticsPlugin}; +use bevy::core_pipeline::bloom::{BloomCompositeMode, BloomSettings}; use std::collections::VecDeque; use std::time::SystemTime; @@ -202,6 +203,7 @@ fn update( mut query: Query<&mut Text, With>, query_all_actors: Query<&actor::Actor>, ) { + // TODO only when hud is actually on if timer.0.tick(time.delta()).just_finished() { let player = player.get_single(); if player.is_ok() { @@ -236,20 +238,25 @@ fn handle_input( keyboard_input: Res>, mut settings: ResMut, mut query: Query<&mut Visibility, With>, + mut query_bloomsettings: Query<&mut BloomSettings>, mut evwriter: EventWriter, mut evwriter_togglemusic: EventWriter, ) { if keyboard_input.just_pressed(settings.key_togglehud) { for mut vis in &mut query { - if *vis == Visibility::Inherited { - *vis = Visibility::Hidden; - settings.hud_active = false; - } else { - *vis = Visibility::Inherited; - settings.hud_active = true; + if let Ok(mut bloomsettings) = query_bloomsettings.get_single_mut() { + if *vis == Visibility::Inherited { + *vis = Visibility::Hidden; + settings.hud_active = false; + bloomsettings.composite_mode = BloomCompositeMode::EnergyConserving; + } else { + *vis = Visibility::Inherited; + settings.hud_active = true; + bloomsettings.composite_mode = BloomCompositeMode::Additive; + } + evwriter.send(audio::AudioSwitchEvent()); + evwriter_togglemusic.send(audio::ToggleMusicEvent()); } - evwriter.send(audio::AudioSwitchEvent()); - evwriter_togglemusic.send(audio::ToggleMusicEvent()); } } } diff --git a/src/main.rs b/src/main.rs index afcfae1..e04f43d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -33,7 +33,6 @@ impl Plugin for OutFlyPlugin { } fn setup( - //mut commands: Commands, mut windows: Query<&mut Window, With> ) { for mut window in &mut windows { diff --git a/src/world.rs b/src/world.rs index d7d1da0..7bda9db 100644 --- a/src/world.rs +++ b/src/world.rs @@ -13,6 +13,7 @@ const MARS_SIZE: f32 = 10.0; const SUN_SIZE: f32 = 5000.0; const ASTRONAUT_SIZE: f32 = 5.0; +const SUN_BRIGHTNESS: f32 = 1e5; const SKYBOX_BRIGHTNESS: f32 = 300.0; const ASSET_CUBEMAP: &str = "textures/stars_cubemap.png"; @@ -147,7 +148,7 @@ pub fn setup( // Add THE SUN let hydrogenfusion_handle = materials.add(StandardMaterial { - emissive: Color::rgb_linear(1e6, 0.9e6, 1e6), + emissive: Color::rgb_linear(SUN_BRIGHTNESS, 0.9 * SUN_BRIGHTNESS, SUN_BRIGHTNESS), ..default() }); commands.spawn(PbrBundle {