From 20e17e8faaa36c571c6f4ba25a443f8d6f39b5cf Mon Sep 17 00:00:00 2001 From: yuni Date: Mon, 17 Jun 2024 01:48:46 +0200 Subject: [PATCH] fix hud toggling when starting the game with disabled hud --- src/hud.rs | 43 +++++++++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/src/hud.rs b/src/hud.rs index e0ab981..6c8f2f5 100644 --- a/src/hud.rs +++ b/src/hud.rs @@ -442,6 +442,7 @@ pub fn setup( }, gauge.clone(), GaugeLength(bar_length), + ToggleableHudElement, )); }); @@ -465,29 +466,35 @@ pub fn setup( )) .with_children(|builder| { // The gauge symbol - builder.spawn((ImageBundle { - image: UiImage::new(asset_server.load(sprite.to_string())), - style: Style { - width: Val::Px(icon_size), - height: Val::Px(icon_size), + builder.spawn(( + ImageBundle { + image: UiImage::new(asset_server.load(sprite.to_string())), + style: Style { + width: Val::Px(icon_size), + height: Val::Px(icon_size), + ..Default::default() + }, + visibility, ..Default::default() }, - visibility, - ..Default::default() - },)); + ToggleableHudElement, + )); // The gauge bar border - builder.spawn((ImageBundle { - image: UiImage::new(gauges_handle.clone()), - style: Style { - width: Val::Px(bar_length), - height: Val::Px(10.0), - bottom: Val::Px(8.0), - left: Val::Px(gauge_bar_padding_left), + builder.spawn(( + ImageBundle { + image: UiImage::new(gauges_handle.clone()), + style: Style { + width: Val::Px(bar_length), + height: Val::Px(10.0), + bottom: Val::Px(8.0), + left: Val::Px(gauge_bar_padding_left), + ..Default::default() + }, + visibility, ..Default::default() }, - visibility, - ..Default::default() - },)); + ToggleableHudElement, + )); }); }