From 8f76a31cfac6d44be38555e39ea94cdc4ce8cafc Mon Sep 17 00:00:00 2001 From: hut Date: Tue, 14 May 2024 19:08:18 +0200 Subject: [PATCH] show version in menu --- src/menu.rs | 38 ++++++++++++++++++++++++++++++++++++++ src/var.rs | 6 +++++- 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/src/menu.rs b/src/menu.rs index 964b1d5..c4498b5 100644 --- a/src/menu.rs +++ b/src/menu.rs @@ -278,6 +278,44 @@ pub fn setup( }, )); }); + + let style_version = TextStyle { + font: font_handle.clone(), + font_size: settings.font_size_version, + color: settings.hud_color_version, + ..default() + }; + + commands.spawn(( + MenuElement, + NodeBundle { + style: Style { + width: Val::Percent(96.0), + height: Val::Percent(96.0), + left: Val::Percent(2.0), + top: Val::Percent(2.0), + align_items: AlignItems::End, + justify_content: JustifyContent::End, + ..default() + }, + visibility: Visibility::Hidden, + ..default() + }, + )).with_children(|builder| { + builder.spawn(( + TextBundle { + text: Text { + sections: vec![ + TextSection::new("OutFly ".to_string() + + settings.version.as_str(), style_version), + ], + justify: JustifyText::Right, + ..default() + }, + ..default() + }, + )); + }); } pub fn show_deathscreen( diff --git a/src/var.rs b/src/var.rs index 8449bf3..84a7a6f 100644 --- a/src/var.rs +++ b/src/var.rs @@ -60,6 +60,7 @@ pub struct Settings { pub font_size_achievement: f32, pub font_size_achievement_header: f32, pub font_size_keybindings: f32, + pub font_size_version: f32, pub hud_color: Color, pub hud_color_fps: Color, pub hud_color_console: Color, @@ -77,6 +78,7 @@ pub struct Settings { pub hud_color_death: Color, pub hud_color_death_achievements: Color, pub hud_color_keybindings: Color, + pub hud_color_version: Color, pub chat_speed: f32, pub flashlight_active: bool, pub hud_active: bool, @@ -154,7 +156,7 @@ impl Default for Settings { let version = if let Some(version) = option_env!("CARGO_PKG_VERSION") { version.to_string() } else { - "13.37".to_string() + "".to_string() }; Settings { @@ -184,6 +186,7 @@ impl Default for Settings { font_size_achievement: 24.0, font_size_achievement_header: 32.0, font_size_keybindings: 20.0, + font_size_version: 20.0, hud_color: Color::hex("#BE1251").unwrap(), hud_color_fps: Color::hex("#181818").unwrap(), hud_color_console: Color::hex("#BE1251").unwrap(), @@ -201,6 +204,7 @@ impl Default for Settings { hud_color_death: Color::hex("#CCCCCC").unwrap(), hud_color_death_achievements: Color::hex("#CCCCCC").unwrap(), hud_color_keybindings: Color::hex("#666666").unwrap(), + hud_color_version: Color::hex("#BE1251").unwrap(), chat_speed: DEFAULT_CHAT_SPEED * if dev_mode { 2.5 } else { 1.0 }, flashlight_active: false, hud_active: true,