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