cleaner menu, with greyed-out entries that are not applicable

This commit is contained in:
yuni 2024-11-18 02:13:39 +01:00
parent 560b673a30
commit 6926a0f4f9
3 changed files with 76 additions and 46 deletions

View file

@ -45,7 +45,7 @@ pub const DASHBOARD_DEF: &[(Dashboard, &str)] = &[
// Player avatars: [(Avatar, model name, scale, in-game name)] // Player avatars: [(Avatar, model name, scale, in-game name)]
pub const PLAYER_AR_AVATARS: &[(Avatar, &str, f32, &str)] = &[ pub const PLAYER_AR_AVATARS: &[(Avatar, &str, f32, &str)] = &[
(Avatar::None, "", 1.0, "No Avatar"), (Avatar::None, "", 1.0, "Off"),
(Avatar::ChefHat, "suit_ar_chefhat", 1.0, "Chef Hat"), (Avatar::ChefHat, "suit_ar_chefhat", 1.0, "Chef Hat"),
(Avatar::Hoodie, "suit_ar_hoodie", 1.0, "Hoodie"), (Avatar::Hoodie, "suit_ar_hoodie", 1.0, "Hoodie"),
(Avatar::HoodieUp, "suit_ar_hoodie_up", 1.0, "Hoodie Up"), (Avatar::HoodieUp, "suit_ar_hoodie_up", 1.0, "Hoodie Up"),
@ -65,7 +65,7 @@ pub const PLAYER_AR_AVATARS: &[(Avatar, &str, f32, &str)] = &[
pub const POINTERS: &[(Pointer, Option<&str>, &str)] = &[ pub const POINTERS: &[(Pointer, Option<&str>, &str)] = &[
(Pointer::None, None, "Off"), (Pointer::None, None, "Off"),
(Pointer::Tri, Some("sprites/pointer_tri.png"), "Default"), (Pointer::Tri, Some("sprites/pointer_tri.png"), "On"),
(Pointer::Dot, Some("sprites/pointer_dot.png"), "Dot"), (Pointer::Dot, Some("sprites/pointer_dot.png"), "Dot"),
]; ];

View file

@ -64,26 +64,36 @@ pub enum DeathScreenEvent {
Hide, Hide,
} }
pub const MENUDEF: &[(&str, MenuAction)] = &[ pub const MENUDEF: &[(&str, MenuAction, MenuType)] = &[
("✆ Phone", MenuAction::PhoneCall), ("✆ Phone", MenuAction::PhoneCall, MenuType::Always),
("✯ Map\n", MenuAction::ToggleMap), ("✯ Map\n", MenuAction::ToggleMap, MenuType::Always),
("", MenuAction::ToggleAR), ("", MenuAction::ToggleAR, MenuType::Always),
("", MenuAction::ChangeARAvatar), ("", MenuAction::ChangeARAvatar, MenuType::AROnly),
("", MenuAction::ChangePointer), ("", MenuAction::ChangePointer, MenuType::AROnly),
("", MenuAction::ModLightAmp), ("", MenuAction::ModLightAmp, MenuType::AROnly),
("", MenuAction::ModFlashlightPower), ("", MenuAction::ModFlashlightPower, MenuType::Always),
("", MenuAction::ModThrusterBoost), ("", MenuAction::ModThrusterBoost, MenuType::SuitOnly),
("", MenuAction::ModReactor), ("", MenuAction::ModReactor, MenuType::SuitOnly),
("", MenuAction::ToggleSound), ("", MenuAction::ToggleSound, MenuType::Always),
("", MenuAction::ToggleMusic), ("", MenuAction::ToggleMusic, MenuType::Always),
//("", MenuAction::ToggleCamera), //("", MenuAction::ToggleCamera),
("", MenuAction::ToggleShadows), ("", MenuAction::ToggleShadows, MenuType::Always),
//("Fullscreen [F11]", MenuAction::ToggleFullscreen), //("Fullscreen [F11]", MenuAction::ToggleFullscreen),
("⚠ FACTORY RESET ⚠", MenuAction::ResetSettings), (
("⚠ Take Off Helmet ⚠", MenuAction::Restart), "⚠ FACTORY RESET ⚠",
("Quit", MenuAction::Quit), MenuAction::ResetSettings,
MenuType::Always,
),
("⚠ Take Off Helmet ⚠", MenuAction::Restart, MenuType::Always),
("Quit", MenuAction::Quit, MenuType::Always),
]; ];
pub enum MenuType {
Always,
AROnly,
SuitOnly,
}
#[derive(Component)] #[derive(Component)]
pub enum MenuAction { pub enum MenuAction {
ToggleMap, ToggleMap,
@ -195,7 +205,7 @@ pub fn setup(
let sections: Vec<TextSection> = Vec::from_iter( let sections: Vec<TextSection> = Vec::from_iter(
MENUDEF MENUDEF
.iter() .iter()
.map(|(label, _)| TextSection::new(label.to_string() + "\n", style_menu.clone())), .map(|(label, _, _)| TextSection::new(label.to_string() + "\n", style_menu.clone())),
); );
commands.spawn(( commands.spawn((
@ -452,6 +462,7 @@ pub fn update_menu(
), ),
>, >,
mut q_vis: Query<&mut Visibility, With<menu::MenuElement>>, mut q_vis: Query<&mut Visibility, With<menu::MenuElement>>,
q_bike: Query<&actor::PlayerDrivesThis>,
id2pos: Res<game::Id2Pos>, id2pos: Res<game::Id2Pos>,
achievement_tracker: Res<var::AchievementTracker>, achievement_tracker: Res<var::AchievementTracker>,
menustate: Res<MenuState>, menustate: Res<MenuState>,
@ -461,9 +472,6 @@ pub fn update_menu(
for mut vis in &mut q_vis { for mut vis in &mut q_vis {
*vis = bool2vis(settings.menu_active); *vis = bool2vis(settings.menu_active);
} }
fn bool2string(boolean: bool) -> String {
if boolean { "On" } else { "Off" }.to_string()
}
// Footer // Footer
if let (Ok(mut text), Some(player_pos), Some(jupiter_pos)) = ( if let (Ok(mut text), Some(player_pos), Some(jupiter_pos)) = (
@ -507,10 +515,18 @@ pub fn update_menu(
// Menu // Menu
if let Ok(mut text) = q_text.get_single_mut() { if let Ok(mut text) = q_text.get_single_mut() {
for i in 0..text.sections.len() { for i in 0..text.sections.len() {
let active = match MENUDEF[i].2 {
MenuType::SuitOnly => q_bike.is_empty(),
MenuType::AROnly => settings.hud_active,
_ => true,
};
if menustate.cursor == i { if menustate.cursor == i {
text.sections[i].style.color = settings.hud_color_subtitles; text.sections[i].style.color = settings.hud_color_menu_selected;
} else if active {
text.sections[i].style.color = settings.hud_color_menu_active;
} else { } else {
text.sections[i].style.color = settings.hud_color; text.sections[i].style.color = settings.hud_color_menu_inactive;
} }
match MENUDEF[i].1 { match MENUDEF[i].1 {
@ -523,7 +539,7 @@ pub fn update_menu(
} else { } else {
&settings.noise_cancellation_modes[0].0 &settings.noise_cancellation_modes[0].0
}; };
text.sections[i].value = format!("\nNoise Cancellation: {noisecancel}\n"); text.sections[i].value = format!("\nSound: {noisecancel}\n");
} }
MenuAction::ToggleMusic => { MenuAction::ToggleMusic => {
let station = let station =
@ -532,59 +548,63 @@ pub fn update_menu(
} else { } else {
&settings.radio_modes[0] &settings.radio_modes[0]
}; };
text.sections[i].value = format!("Speakers: {station}\n"); text.sections[i].value = format!("Stereo: {station}\n");
} }
MenuAction::ToggleAR => { MenuAction::ToggleAR => {
let onoff = bool2string(settings.hud_active);
let p = if settings.hud_active { let p = if settings.hud_active {
actor::POWER_DRAIN_AR actor::POWER_DRAIN_AR
} else { } else {
0.0 0.0
}; };
let w = if p > 0.0 { let w = if p > 0.0 {
format!(" ({p}W)") format!("{p}W")
} else { } else {
String::from("") String::from("Off")
}; };
text.sections[i].value = format!("Augmented Reality: {onoff}{w} [TAB]\n"); text.sections[i].value = format!("Augmented Reality: {w}\n");
} }
MenuAction::ModLightAmp => { MenuAction::ModLightAmp => {
let p = actor::POWER_DRAIN_LIGHTAMP[prefs.light_amp]; let p = actor::POWER_DRAIN_LIGHTAMP[prefs.light_amp];
text.sections[i].value = format!("\nLight Amplification: {p}W\n"); let w = if p > 0.0 {
format!("{p}W")
} else {
String::from("Off")
};
text.sections[i].value = format!("Night Vision: {w}\n");
} }
MenuAction::ModFlashlightPower => { MenuAction::ModFlashlightPower => {
let p = actor::POWER_DRAIN_FLASHLIGHT[prefs.flashlight_power]; let p = actor::POWER_DRAIN_FLASHLIGHT[prefs.flashlight_power];
text.sections[i].value = format!("Flashlight Power: {p}W\n"); text.sections[i].value = format!("Flashlight: {p}W\n");
} }
MenuAction::ModThrusterBoost => { MenuAction::ModThrusterBoost => {
let state = match prefs.thruster_boost { let state = match prefs.thruster_boost {
0 => "For braking", 0 => " (when slowing)",
1 => "Always", 1 => " (always)",
2 => "Off", 2 => "Off",
_ => "ERROR", _ => "ERROR",
}; };
let p = actor::POWER_DRAIN_THRUSTER[prefs.thruster_boost]; let p = actor::POWER_DRAIN_THRUSTER[prefs.thruster_boost];
let w = if p > 0.0 { let w = if p > 0.0 {
format!(" ({p}W)") format!(" {p}W")
} else { } else {
String::from("") String::from("")
}; };
text.sections[i].value = format!("Thruster Boost: {state}{w}\n"); text.sections[i].value = format!("Nitro: {w}{state}\n");
} }
MenuAction::ModReactor => { MenuAction::ModReactor => {
let state = match settings.reactor_state { let state = match settings.reactor_state {
0 => "Off", 0 => "Off",
1 => "On", 1 => "",
2 => "OVERLOAD", 2 => "OVERLOAD",
_ => "ERROR", _ => "ERROR",
}; };
let p = actor::POWER_GAIN_REACTOR[settings.reactor_state]; let p = actor::POWER_GAIN_REACTOR[settings.reactor_state];
let w = if p > 0.0 { let w = if p > 0.0 {
format!(" (+{p}W)") format!("+{p}W")
} else { } else {
String::from("") String::from("")
}; };
text.sections[i].value = format!("Reactor: {state}{w}\n"); text.sections[i].value = format!("Reactor: {w}{state}\n");
} }
MenuAction::ChangeARAvatar => { MenuAction::ChangeARAvatar => {
if let Some(ava) = hud::PLAYER_AR_AVATARS.get(settings.ar_avatar) { if let Some(ava) = hud::PLAYER_AR_AVATARS.get(settings.ar_avatar) {
@ -609,8 +629,12 @@ pub fn update_menu(
text.sections[i].value = format!("\nCamera: {onoff} [C]\n"); text.sections[i].value = format!("\nCamera: {onoff} [C]\n");
} }
MenuAction::ToggleShadows => { MenuAction::ToggleShadows => {
let onoff = if settings.shadows_sun { "High" } else { "Low" }; let onoff = if settings.shadows_sun {
text.sections[i].value = format!("Shadows: {onoff}\n"); "On"
} else {
"Simplified"
};
text.sections[i].value = format!("\nShadows: {onoff}\n");
} }
_ => {} _ => {}
} }

View file

@ -80,6 +80,9 @@ pub struct Settings {
pub hud_color_deathpoem: Color, pub hud_color_deathpoem: Color,
pub hud_color_achievement: Color, pub hud_color_achievement: Color,
pub hud_color_achievement_header: Color, pub hud_color_achievement_header: Color,
pub hud_color_menu_active: Color,
pub hud_color_menu_inactive: Color,
pub hud_color_menu_selected: Color,
pub hud_color_achievement_accomplished: Color, pub hud_color_achievement_accomplished: Color,
pub hud_color_death: Color, pub hud_color_death: Color,
pub hud_color_death_achievements: Color, pub hud_color_death_achievements: Color,
@ -176,10 +179,10 @@ impl Default for Settings {
mute_sfx: false, mute_sfx: false,
noise_cancellation_mode: 0, noise_cancellation_mode: 0,
noise_cancellation_modes: vec![ noise_cancellation_modes: vec![
("Off".to_string(), 1.0), ("On".to_string(), 1.0),
("33%".to_string(), 0.66), ("66%".to_string(), 0.66),
("66%".to_string(), 0.33), ("33%".to_string(), 0.33),
("100%".to_string(), 0.0), ("Off".to_string(), 0.0),
], ],
radio_mode: 1, radio_mode: 1,
radio_modes: vec![ radio_modes: vec![
@ -225,6 +228,9 @@ impl Default for Settings {
hud_color_achievement: Srgba::hex(COLOR_DIM).unwrap().into(), hud_color_achievement: Srgba::hex(COLOR_DIM).unwrap().into(),
hud_color_achievement_accomplished: Srgba::hex(COLOR_SUCCESS).unwrap().into(), hud_color_achievement_accomplished: Srgba::hex(COLOR_SUCCESS).unwrap().into(),
hud_color_achievement_header: Srgba::hex(COLOR_PRIMARY).unwrap().into(), hud_color_achievement_header: Srgba::hex(COLOR_PRIMARY).unwrap().into(),
hud_color_menu_active: Srgba::hex(COLOR_PRIMARY).unwrap().into(),
hud_color_menu_inactive: Srgba::hex(COLOR_DIM).unwrap().into(),
hud_color_menu_selected: Srgba::hex(COLOR_SECONDARY).unwrap().into(),
hud_color_death: Srgba::hex(COLOR_SECONDARY).unwrap().into(), hud_color_death: Srgba::hex(COLOR_SECONDARY).unwrap().into(),
hud_color_death_achievements: Srgba::hex(COLOR_SECONDARY).unwrap().into(), hud_color_death_achievements: Srgba::hex(COLOR_SECONDARY).unwrap().into(),
hud_color_keybindings: Srgba::hex(COLOR_DIM).unwrap().into(), hud_color_keybindings: Srgba::hex(COLOR_DIM).unwrap().into(),