Compare commits
11 commits
97141ed73a
...
6c8cdf9af8
Author | SHA1 | Date | |
---|---|---|---|
yuni | 6c8cdf9af8 | ||
yuni | 32537315d0 | ||
yuni | 2d5348956e | ||
yuni | 2a7714661f | ||
yuni | a46d29715e | ||
yuni | e47e175fc5 | ||
yuni | 51089049ae | ||
yuni | eb3353bb07 | ||
yuni | b857d46119 | ||
yuni | 73beb451dd | ||
yuni | ba1269627d |
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -2769,7 +2769,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "outfly"
|
name = "outfly"
|
||||||
version = "0.6.1"
|
version = "0.7.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bevy",
|
"bevy",
|
||||||
"bevy_embedded_assets",
|
"bevy_embedded_assets",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "outfly"
|
name = "outfly"
|
||||||
version = "0.6.1"
|
version = "0.7.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
homepage = "https://codeberg.org/hut/outfly"
|
homepage = "https://codeberg.org/hut/outfly"
|
||||||
repository = "https://codeberg.org/hut/outfly"
|
repository = "https://codeberg.org/hut/outfly"
|
||||||
|
|
|
@ -154,6 +154,12 @@ python -m http.server -d wasm
|
||||||
|
|
||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
- v0.7.0:
|
||||||
|
- Overhaul conversation system, now defined in YAML files
|
||||||
|
- Implement conversation variables and if-branches
|
||||||
|
- Improve dialogues
|
||||||
|
- Improve HUD
|
||||||
|
- Add teleport-to-target cheat
|
||||||
- v0.6.1:
|
- v0.6.1:
|
||||||
- Implement free public transport with 3 bus stations
|
- Implement free public transport with 3 bus stations
|
||||||
- Implement Clippy™ Convenience Companion drone
|
- Implement Clippy™ Convenience Companion drone
|
||||||
|
|
|
@ -661,6 +661,7 @@ pub fn handle_chat_events(
|
||||||
time: Res<Time>,
|
time: Res<Time>,
|
||||||
settings: Res<var::Settings>,
|
settings: Res<var::Settings>,
|
||||||
) {
|
) {
|
||||||
|
let mut choice_key = q_choices.iter().len();
|
||||||
for event in er_chatevent.read() {
|
for event in er_chatevent.read() {
|
||||||
let now = time.elapsed_seconds_f64();
|
let now = time.elapsed_seconds_f64();
|
||||||
let chat_maybe = q_chats.get_single_mut();
|
let chat_maybe = q_chats.get_single_mut();
|
||||||
|
@ -674,6 +675,7 @@ pub fn handle_chat_events(
|
||||||
for entity in &q_choices {
|
for entity in &q_choices {
|
||||||
commands.entity(entity).despawn();
|
commands.entity(entity).despawn();
|
||||||
}
|
}
|
||||||
|
choice_key = 0;
|
||||||
}
|
}
|
||||||
ChatEvent::DespawnAllChats => {
|
ChatEvent::DespawnAllChats => {
|
||||||
commands.entity(chat_entity).despawn();
|
commands.entity(chat_entity).despawn();
|
||||||
|
@ -695,7 +697,7 @@ pub fn handle_chat_events(
|
||||||
let sfx = audio::str2sfx(sound);
|
let sfx = audio::str2sfx(sound);
|
||||||
ew_sfx.send(audio::PlaySfxEvent(sfx));
|
ew_sfx.send(audio::PlaySfxEvent(sfx));
|
||||||
}
|
}
|
||||||
ChatEvent::SpawnChoice(replytext, key, goto, nowait, condition) => {
|
ChatEvent::SpawnChoice(replytext, _key, goto, nowait, condition) => {
|
||||||
'out: {
|
'out: {
|
||||||
if let Some(condition) = condition {
|
if let Some(condition) = condition {
|
||||||
if !vars.evaluate_condition(condition, &chat.talker.actor_id) {
|
if !vars.evaluate_condition(condition, &chat.talker.actor_id) {
|
||||||
|
@ -706,10 +708,11 @@ pub fn handle_chat_events(
|
||||||
world::DespawnOnPlayerDeath,
|
world::DespawnOnPlayerDeath,
|
||||||
Choice {
|
Choice {
|
||||||
text: replytext.into(),
|
text: replytext.into(),
|
||||||
key: *key,
|
key: choice_key,
|
||||||
goto: goto.clone(),
|
goto: goto.clone(),
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
|
choice_key += 1;
|
||||||
if !nowait {
|
if !nowait {
|
||||||
chat.timer = now + CHOICE_TIMER / settings.chat_speed as f64;
|
chat.timer = now + CHOICE_TIMER / settings.chat_speed as f64;
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,17 +53,23 @@
|
||||||
- But take care, your suit seems to be leaking. I'd patch it up if I were you.
|
- But take care, your suit seems to be leaking. I'd patch it up if I were you.
|
||||||
- I'm all out of SuitPatch™ SuperGlue™ right now, otherwise I'd share.
|
- I'm all out of SuitPatch™ SuperGlue™ right now, otherwise I'd share.
|
||||||
- Can I help you with anything else, maybe?
|
- Can I help you with anything else, maybe?
|
||||||
|
- goto: help
|
||||||
- I got this apocalyptic headache...:
|
- I got this apocalyptic headache...:
|
||||||
- set: friends
|
- set: friends
|
||||||
- Heh, probably related to why you were passed out.
|
- Heh, probably related to why you were passed out.
|
||||||
- Go easy on yourself, I'm sure things will turn for the better.
|
- Go easy on yourself, I'm sure things will turn for the better.
|
||||||
- Meanwhile, can I help you with anything?
|
- Meanwhile, can I help you with anything?
|
||||||
|
- goto: help
|
||||||
- I... don't know, I'm pretty disoriented.:
|
- I... don't know, I'm pretty disoriented.:
|
||||||
- set: friends
|
- set: friends
|
||||||
- Oh no. Do you need a lowdown on reality?
|
- Oh no. Do you need a lowdown on reality?
|
||||||
|
- goto: help
|
||||||
- I just want to be alone right now:
|
- I just want to be alone right now:
|
||||||
- Oh, sure. Ping me if you need anything. I'll go back to playing my VR game.
|
- Oh, sure. Ping me if you need anything. I'll go back to playing my VR game.
|
||||||
- goto: EXIT
|
- goto: EXIT
|
||||||
|
- Not so chatty right now?
|
||||||
|
- I... guess I'll go back to playing my VR game. Ping me if you need anything.
|
||||||
|
- goto: EXIT
|
||||||
|
|
||||||
|
|
||||||
- label: help
|
- label: help
|
||||||
|
@ -252,7 +258,6 @@
|
||||||
- It's really delicious:
|
- It's really delicious:
|
||||||
- Right, of course.
|
- Right, of course.
|
||||||
- Nevermind:
|
- Nevermind:
|
||||||
- So?
|
|
||||||
- set: $knows-pineapple
|
- set: $knows-pineapple
|
||||||
- goto: eat
|
- goto: eat
|
||||||
- I made up my mind.:
|
- I made up my mind.:
|
||||||
|
|
337
src/hud.rs
337
src/hud.rs
|
@ -9,8 +9,9 @@ use std::time::SystemTime;
|
||||||
|
|
||||||
pub const HUD_REFRESH_TIME: f32 = 0.1;
|
pub const HUD_REFRESH_TIME: f32 = 0.1;
|
||||||
pub const FONT: &str = "fonts/Yupiter-Regular.ttf";
|
pub const FONT: &str = "fonts/Yupiter-Regular.ttf";
|
||||||
pub const LOG_MAX: usize = 20;
|
pub const LOG_MAX: usize = 4;
|
||||||
pub const LOG_MAX_TIME_S: u64 = 20;
|
pub const LOG_MAX_TIME_S: f64 = 15.0;
|
||||||
|
pub const LOG_MAX_ROWS: usize = 30;
|
||||||
pub const AMBIENT_LIGHT: f32 = 0.0; // Space is DARK
|
pub const AMBIENT_LIGHT: f32 = 0.0; // Space is DARK
|
||||||
pub const AMBIENT_LIGHT_AR: f32 = 15.0;
|
pub const AMBIENT_LIGHT_AR: f32 = 15.0;
|
||||||
//pub const REPLY_NUMBERS: [char; 10] = ['❶', '❷', '❸', '❹', '❺', '❻', '❼', '❽', '❾', '⓿'];
|
//pub const REPLY_NUMBERS: [char; 10] = ['❶', '❷', '❸', '❹', '❺', '❻', '❼', '❽', '❾', '⓿'];
|
||||||
|
@ -83,7 +84,15 @@ struct Message {
|
||||||
text: String,
|
text: String,
|
||||||
sender: String,
|
sender: String,
|
||||||
level: LogLevel,
|
level: LogLevel,
|
||||||
time: u64,
|
time: f64,
|
||||||
|
}
|
||||||
|
impl Message {
|
||||||
|
pub fn get_freshness(&self) -> f64 {
|
||||||
|
if let Ok(epoch) = SystemTime::now().duration_since(SystemTime::UNIX_EPOCH) {
|
||||||
|
return (1.0 - (epoch.as_secs_f64() - self.time) / LOG_MAX_TIME_S).clamp(0.0, 1.0);
|
||||||
|
}
|
||||||
|
return 1.0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
|
@ -128,16 +137,17 @@ impl Log {
|
||||||
text,
|
text,
|
||||||
sender,
|
sender,
|
||||||
level,
|
level,
|
||||||
time: epoch.as_secs(),
|
time: epoch.as_secs_f64(),
|
||||||
});
|
});
|
||||||
self.needs_rerendering = true;
|
self.needs_rerendering = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
pub fn remove_old(&mut self) {
|
pub fn remove_old(&mut self) {
|
||||||
if let Some(message) = self.logs.front() {
|
if let Some(message) = self.logs.front() {
|
||||||
if let Ok(epoch) = SystemTime::now().duration_since(SystemTime::UNIX_EPOCH) {
|
if let Ok(epoch) = SystemTime::now().duration_since(SystemTime::UNIX_EPOCH) {
|
||||||
if epoch.as_secs() - message.time > LOG_MAX_TIME_S {
|
if epoch.as_secs_f64() - message.time > LOG_MAX_TIME_S {
|
||||||
self.logs.pop_front();
|
self.logs.pop_front();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -163,147 +173,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 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 {
|
||||||
|
position_type: PositionType::Absolute,
|
||||||
top: Val::VMin(2.0),
|
top: Val::VMin(2.0),
|
||||||
left: Val::VMin(3.0),
|
right: Val::VMin(3.0),
|
||||||
..default()
|
..default()
|
||||||
});
|
}).with_text_justify(JustifyText::Right);
|
||||||
bundle_fps.visibility = visibility;
|
bundle_fps.visibility = visibility;
|
||||||
commands.spawn((
|
commands.spawn((
|
||||||
GaugesText,
|
GaugesText,
|
||||||
|
@ -313,47 +210,50 @@ fn setup(
|
||||||
|
|
||||||
// Add Chat Box
|
// Add Chat Box
|
||||||
let bundle_chatbox = TextBundle::from_sections([
|
let bundle_chatbox = TextBundle::from_sections([
|
||||||
TextSection::new(
|
TextSection::new("", style.clone()),
|
||||||
"Warning: System Log Uninitialized",
|
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::rgb(0.7, 0.7, 0.7),
|
TextSection::new("", style.clone()),
|
||||||
..default()
|
TextSection::new("", style.clone()),
|
||||||
}
|
TextSection::new("", style.clone()),
|
||||||
),
|
TextSection::new("", style.clone()),
|
||||||
TextSection::new(
|
TextSection::new("", style.clone()),
|
||||||
"\n",
|
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::WHITE,
|
TextSection::new("", style.clone()),
|
||||||
..default()
|
TextSection::new("", style.clone()),
|
||||||
}
|
TextSection::new("", style.clone()),
|
||||||
),
|
TextSection::new("", style.clone()),
|
||||||
TextSection::new(
|
TextSection::new("", style.clone()),
|
||||||
"\n\n\n",
|
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::WHITE,
|
TextSection::new("", style.clone()),
|
||||||
..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()),
|
||||||
]).with_style(Style {
|
]).with_style(Style {
|
||||||
position_type: PositionType::Absolute,
|
position_type: PositionType::Absolute,
|
||||||
bottom: Val::VMin(0.0),
|
top: Val::VMin(0.0),
|
||||||
left: Val::VMin(0.0),
|
left: Val::VMin(0.0),
|
||||||
..default()
|
..default()
|
||||||
}).with_text_justify(JustifyText::Left);
|
}).with_text_justify(JustifyText::Left);
|
||||||
commands.spawn((
|
commands.spawn((
|
||||||
NodeBundle {
|
NodeBundle {
|
||||||
style: Style {
|
style: Style {
|
||||||
width: Val::Percent(50.),
|
width: Val::Percent(45.0),
|
||||||
align_items: AlignItems::Start,
|
align_items: AlignItems::Start,
|
||||||
position_type: PositionType::Absolute,
|
position_type: PositionType::Absolute,
|
||||||
bottom: Val::Vh(10.0),
|
top: Val::VMin(2.0),
|
||||||
left: Val::Vw(25.0),
|
left: Val::VMin(3.0),
|
||||||
..default()
|
..default()
|
||||||
},
|
},
|
||||||
..default()
|
..default()
|
||||||
|
@ -421,6 +321,7 @@ fn update_hud(
|
||||||
if timer.0.tick(time.delta()).just_finished() || log.needs_rerendering {
|
if timer.0.tick(time.delta()).just_finished() || log.needs_rerendering {
|
||||||
let q_camera_result = q_camera.get_single();
|
let q_camera_result = q_camera.get_single();
|
||||||
let player = player.get_single();
|
let player = player.get_single();
|
||||||
|
let mut freshest_line: f64 = 0.0;
|
||||||
if player.is_ok() && q_camera_result.is_ok() {
|
if player.is_ok() && q_camera_result.is_ok() {
|
||||||
let (hp, suit, gforce) = player.unwrap();
|
let (hp, suit, gforce) = player.unwrap();
|
||||||
let (pos, cam_v) = q_camera_result.unwrap();
|
let (pos, cam_v) = q_camera_result.unwrap();
|
||||||
|
@ -440,18 +341,30 @@ 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");
|
||||||
let vitals = 100.0 * hp.current / hp.max;
|
let vitals = 100.0 * hp.current / hp.max;
|
||||||
text.sections[13].value = format!("{vitals:.0}%");
|
text.sections[13].value = format!("{vitals:.0}%");
|
||||||
|
if vitals < 50.0 {
|
||||||
|
text.sections[13].style.color = Color::MAROON;
|
||||||
|
} else {
|
||||||
|
text.sections[13].style.color = Color::GRAY;
|
||||||
|
}
|
||||||
let all_actors = query_all_actors.iter().len();
|
let all_actors = query_all_actors.iter().len();
|
||||||
text.sections[9].value = format!("{all_actors:.0}");
|
text.sections[9].value = format!("{all_actors:.0}");
|
||||||
let integrity = suit.integrity * 100.0;
|
let integrity = suit.integrity * 100.0;
|
||||||
text.sections[11].value = format!("{integrity:.0}%");
|
text.sections[11].value = format!("{integrity:.0}%");
|
||||||
|
if integrity < 50.0 {
|
||||||
|
text.sections[11].style.color = Color::MAROON;
|
||||||
|
} else {
|
||||||
|
text.sections[11].style.color = Color::GRAY;
|
||||||
|
}
|
||||||
//text.sections[17].value = format!("{speed_readable}/s / {kmh:.0}km/h / {gforce:.1}g");
|
//text.sections[17].value = format!("{speed_readable}/s / {kmh:.0}km/h / {gforce:.1}g");
|
||||||
|
|
||||||
// Target display
|
// Target display
|
||||||
|
@ -514,6 +427,49 @@ fn update_hud(
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Ok(mut chat) = query_chat.get_single_mut() {
|
if let Ok(mut chat) = query_chat.get_single_mut() {
|
||||||
|
let mut row = 0;
|
||||||
|
let bright = Color::rgb(0.8, 0.75, 0.78);
|
||||||
|
|
||||||
|
// Chat Log and System Log
|
||||||
|
let logfilter = if settings.hud_active {
|
||||||
|
|_msg: &&Message| { true }
|
||||||
|
} else {
|
||||||
|
|msg: &&Message| { match msg.level {
|
||||||
|
LogLevel::Chat => true,
|
||||||
|
LogLevel::Warning => true,
|
||||||
|
LogLevel::Info => true,
|
||||||
|
_ => false
|
||||||
|
}}
|
||||||
|
};
|
||||||
|
let mut messages: Vec<&Message> = log.logs.iter()
|
||||||
|
.filter(logfilter)
|
||||||
|
.rev()
|
||||||
|
.take(15)
|
||||||
|
.collect();
|
||||||
|
messages.reverse();
|
||||||
|
for msg in &messages {
|
||||||
|
if msg.sender.is_empty() {
|
||||||
|
chat.sections[row].value = msg.text.clone() + "\n";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
chat.sections[row].value = format!("{}: {}\n", msg.sender, msg.text);
|
||||||
|
}
|
||||||
|
let freshness = msg.get_freshness();
|
||||||
|
let clr: f32 = (freshness.powf(1.5) as f32).clamp(0.1, 1.0);
|
||||||
|
freshest_line = freshest_line.max(freshness);
|
||||||
|
chat.sections[row].style.color = Color::rgba(0.7, 0.7, 0.7, clr);
|
||||||
|
row += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Highlight most recent line if in a conversation
|
||||||
|
if row > 0 && (q_choices.is_empty() || freshest_line > 0.5) {
|
||||||
|
chat.sections[row-1].style.color = bright;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add padding between chat and choices
|
||||||
|
chat.sections[row].value = "\n".to_string();
|
||||||
|
row += 1;
|
||||||
|
|
||||||
// Choices
|
// Choices
|
||||||
let mut choices: Vec<String> = Vec::new();
|
let mut choices: Vec<String> = Vec::new();
|
||||||
let mut count = 0;
|
let mut count = 0;
|
||||||
|
@ -533,31 +489,24 @@ fn update_hud(
|
||||||
choices.push(" ".to_string());
|
choices.push(" ".to_string());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
chat.sections[2].value = choices.join("\n");
|
for choice in choices {
|
||||||
|
chat.sections[row].value = choice + "\n";
|
||||||
|
chat.sections[row].style.color = bright;
|
||||||
|
row += 1;
|
||||||
|
}
|
||||||
|
|
||||||
// Chat Log and System Log
|
// Blank the remaining rows
|
||||||
let logfilter = if settings.hud_active {
|
while row < LOG_MAX_ROWS {
|
||||||
|_msg: &&Message| { true }
|
chat.sections[row].value = "".to_string();
|
||||||
} else {
|
row += 1;
|
||||||
|msg: &&Message| { match msg.level {
|
}
|
||||||
LogLevel::Chat => true,
|
|
||||||
LogLevel::Warning => true,
|
|
||||||
LogLevel::Info => true,
|
|
||||||
_ => false
|
|
||||||
}}
|
|
||||||
};
|
|
||||||
let logs_vec: Vec<String> = log.logs.iter()
|
|
||||||
.filter(logfilter)
|
|
||||||
.map(|s| if s.sender.is_empty() {
|
|
||||||
format!("{}", s.text)
|
|
||||||
} else {
|
|
||||||
format!("{}: {}", s.sender, s.text)
|
|
||||||
}).collect();
|
|
||||||
chat.sections[0].value = logs_vec.join("\n");
|
|
||||||
}
|
}
|
||||||
log.needs_rerendering = false;
|
log.needs_rerendering = false;
|
||||||
|
|
||||||
|
if q_choices.is_empty() && freshest_line < 0.2 {
|
||||||
log.remove_old();
|
log.remove_old();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_input(
|
fn handle_input(
|
||||||
|
@ -649,7 +598,7 @@ fn update_target_selectagon(
|
||||||
}
|
}
|
||||||
selectagon_trans.translation = target_trans.translation;
|
selectagon_trans.translation = target_trans.translation;
|
||||||
selectagon_trans.scale = target_trans.scale;
|
selectagon_trans.scale = target_trans.scale;
|
||||||
selectagon_trans.rotation = camera_trans.rotation;
|
selectagon_trans.rotation = Quat::from_rotation_arc(Vec3::Z, (-selectagon_trans.translation).normalize());
|
||||||
|
|
||||||
// Enlarge Selectagon to a minimum angular diameter
|
// Enlarge Selectagon to a minimum angular diameter
|
||||||
let (angular_diameter, _, _) = camera::calc_angular_diameter(
|
let (angular_diameter, _, _) = camera::calc_angular_diameter(
|
||||||
|
|
Loading…
Reference in a new issue