toggling hud toggles bloom setting

This commit is contained in:
yuni 2024-03-18 04:57:17 +01:00
parent ba28b9470d
commit 872142946c
3 changed files with 17 additions and 10 deletions

View file

@ -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<GaugesText>>,
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<ButtonInput<KeyCode>>,
mut settings: ResMut<settings::Settings>,
mut query: Query<&mut Visibility, With<GaugesText>>,
mut query_bloomsettings: Query<&mut BloomSettings>,
mut evwriter: EventWriter<audio::AudioSwitchEvent>,
mut evwriter_togglemusic: EventWriter<audio::ToggleMusicEvent>,
) {
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());
}
}
}

View file

@ -33,7 +33,6 @@ impl Plugin for OutFlyPlugin {
}
fn setup(
//mut commands: Commands,
mut windows: Query<&mut Window, With<PrimaryWindow>>
) {
for mut window in &mut windows {

View file

@ -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 {