clean up HUD creation

This commit is contained in:
yuni 2024-04-15 02:27:11 +02:00
parent 73beb451dd
commit b857d46119

View file

@ -163,142 +163,34 @@ fn setup(
} else {
Visibility::Hidden
};
let style = TextStyle {
font: asset_server.load(FONT),
font_size: settings.font_size_hud,
color: Color::GRAY,
..default()
};
let style_choices = TextStyle {
font: asset_server.load(FONT),
font_size: settings.font_size_hud,
color: Color::WHITE,
..default()
};
let mut bundle_fps = TextBundle::from_sections([
TextSection::new(
"",
TextStyle {
font: asset_server.load(FONT),
font_size: settings.font_size_hud,
color: Color::GRAY,
..default()
}
),
TextSection::new(
"",
TextStyle {
font: asset_server.load(FONT),
font_size: settings.font_size_hud,
color: Color::GRAY,
..default()
},
),
TextSection::new(
"",
TextStyle {
font: asset_server.load(FONT),
font_size: settings.font_size_hud,
color: Color::GRAY,
..default()
}
),
TextSection::new(
"",
TextStyle {
font: asset_server.load(FONT),
font_size: settings.font_size_hud,
color: Color::GRAY,
..default()
},
),
TextSection::new(
"",
TextStyle {
font: asset_server.load(FONT),
font_size: settings.font_size_hud,
color: Color::GRAY,
..default()
}
),
TextSection::new(
"",
TextStyle {
font: asset_server.load(FONT),
font_size: settings.font_size_hud,
color: Color::GRAY,
..default()
}
),
TextSection::new(
"\n氧 OXYGEN ",
TextStyle {
font: asset_server.load(FONT),
font_size: settings.font_size_hud,
color: Color::GRAY,
..default()
},
),
TextSection::new(
"",
TextStyle {
font: asset_server.load(FONT),
font_size: settings.font_size_hud,
color: Color::MAROON,
..default()
}
),
TextSection::new(
"\nProximity 警告 ",
TextStyle {
font: asset_server.load(FONT),
font_size: settings.font_size_hud,
color: Color::GRAY,
..default()
},
),
TextSection::new(
"",
TextStyle {
font: asset_server.load(FONT),
font_size: settings.font_size_hud,
color: Color::GRAY,
..default()
}
),
TextSection::new(
"\nSuit Integrity ",
TextStyle {
font: asset_server.load(FONT),
font_size: settings.font_size_hud,
color: Color::GRAY,
..default()
},
),
TextSection::new(
"",
TextStyle {
font: asset_server.load(FONT),
font_size: settings.font_size_hud,
color: Color::GRAY,
..default()
}
),
TextSection::new(
"\nVitals ",
TextStyle {
font: asset_server.load(FONT),
font_size: settings.font_size_hud,
color: Color::GRAY,
..default()
},
),
TextSection::new(
"",
TextStyle {
font: asset_server.load(FONT),
font_size: settings.font_size_hud,
color: Color::GRAY,
..default()
}
),
TextSection::new( // Target
"",
TextStyle {
font: asset_server.load(FONT),
font_size: settings.font_size_hud,
color: Color::GRAY,
..default()
}
),
TextSection::new("", style.clone()),
TextSection::new("", style.clone()),
TextSection::new("", style.clone()),
TextSection::new("", style.clone()),
TextSection::new("", style.clone()),
TextSection::new("", style.clone()),
TextSection::new("\n氧 OXYGEN ", style.clone()),
TextSection::new("", style.clone()),
TextSection::new("\nProximity 警告 ", style.clone()),
TextSection::new("", style.clone()),
TextSection::new("\nSuit Integrity ", style.clone()),
TextSection::new("", style.clone()),
TextSection::new("\nVitals ", style.clone()),
TextSection::new("", style.clone()),
TextSection::new("", style.clone()), // Target
]).with_style(Style {
top: Val::VMin(2.0),
left: Val::VMin(3.0),
@ -313,33 +205,9 @@ fn setup(
// Add Chat Box
let bundle_chatbox = TextBundle::from_sections([
TextSection::new(
"Warning: System Log Uninitialized",
TextStyle {
font: asset_server.load(FONT),
font_size: settings.font_size_hud,
color: Color::rgb(0.7, 0.7, 0.7),
..default()
}
),
TextSection::new(
"\n",
TextStyle {
font: asset_server.load(FONT),
font_size: settings.font_size_hud,
color: Color::WHITE,
..default()
}
),
TextSection::new(
"\n\n\n",
TextStyle {
font: asset_server.load(FONT),
font_size: settings.font_size_hud,
color: Color::WHITE,
..default()
}
),
TextSection::new("\n\n\n", style_choices),
TextSection::new("\n", style.clone()),
TextSection::new("Warning: System Log Uninitialized", style.clone()),
]).with_style(Style {
position_type: PositionType::Absolute,
bottom: Val::VMin(0.0),
@ -440,9 +308,11 @@ fn update_hud(
if suit.oxygen > nature::OXY_H {
let oxy_hour = suit.oxygen / nature::OXY_H;
text.sections[7].value = format!("{oxy_percent:.1}% [lasts {oxy_hour:.1} hours]");
text.sections[7].style.color = Color::GRAY;
} else {
let oxy_min = suit.oxygen / nature::OXY_M;
text.sections[7].value = format!("{oxy_percent:.1}% [lasts {oxy_min:.1} min]");
text.sections[7].style.color = Color::MAROON;
}
//let adrenaline = lifeform.adrenaline * 990.0 + 10.0;
//text.sections[11].value = format!("{adrenaline:.0}pg/mL");