From 346239ae6d30fa35117b558ef625cc3dcc17448e Mon Sep 17 00:00:00 2001 From: hut Date: Sat, 30 Mar 2024 20:11:11 +0100 Subject: [PATCH] add log level "Notice", hide startup messages --- src/hud.rs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/hud.rs b/src/hud.rs index 582a0cb..5e63661 100644 --- a/src/hud.rs +++ b/src/hud.rs @@ -54,6 +54,7 @@ pub enum LogLevel { //Debug, Chat, //Ping, + Notice, } struct Message { @@ -82,6 +83,10 @@ impl Log { self.add(message, "WARNING".to_string(), LogLevel::Warning); } + pub fn notice(&mut self, message: String) { + self.add(message, "".to_string(), LogLevel::Notice); + } + pub fn add(&mut self, message: String, sender: String, level: LogLevel) { if self.logs.len() == LOG_MAX { self.logs.pop_front(); @@ -115,8 +120,8 @@ fn setup( mut log: ResMut, mut ambient_light: ResMut, ) { - log.info("Resuming from suspend".to_string()); - log.warning("Oxygen Low".to_string()); + log.notice("Resuming from suspend".to_string()); + log.notice("WARNING: Oxygen Low".to_string()); let visibility = if settings.hud_active { Visibility::Inherited } else { @@ -449,12 +454,16 @@ fn update( LogLevel::Chat => true, LogLevel::Warning => true, LogLevel::Info => true, - //_ => false + _ => false }} }; let logs_vec: Vec = log.logs.iter() .filter(logfilter) - .map(|s| format!("{}: {}", s.sender, s.text)).collect(); + .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;