different colors for different console log levels
This commit is contained in:
parent
8533b689b2
commit
f01fd06bac
|
@ -685,7 +685,7 @@ pub fn handle_chat_events(
|
||||||
hud::LogLevel::Chat => {
|
hud::LogLevel::Chat => {
|
||||||
log.chat(message.into(), chat.talker.name.clone().unwrap_or("".to_string()));
|
log.chat(message.into(), chat.talker.name.clone().unwrap_or("".to_string()));
|
||||||
}
|
}
|
||||||
hud::LogLevel::Info | hud::LogLevel::Notice => {
|
hud::LogLevel::Info => {
|
||||||
log.info(message.into());
|
log.info(message.into());
|
||||||
}
|
}
|
||||||
hud::LogLevel::Warning => {
|
hud::LogLevel::Warning => {
|
||||||
|
|
26
src/hud.rs
26
src/hud.rs
|
@ -80,7 +80,6 @@ pub enum LogLevel {
|
||||||
//Debug,
|
//Debug,
|
||||||
Chat,
|
Chat,
|
||||||
//Ping,
|
//Ping,
|
||||||
Notice,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Message {
|
struct Message {
|
||||||
|
@ -135,10 +134,6 @@ impl Log {
|
||||||
self.add(message, "WARNING".to_string(), LogLevel::Warning);
|
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, text: String, sender: String, level: LogLevel) {
|
pub fn add(&mut self, text: String, sender: String, level: LogLevel) {
|
||||||
if self.logs.len() == LOG_MAX {
|
if self.logs.len() == LOG_MAX {
|
||||||
self.logs.pop_front();
|
self.logs.pop_front();
|
||||||
|
@ -174,11 +169,8 @@ fn setup(
|
||||||
mut commands: Commands,
|
mut commands: Commands,
|
||||||
settings: Res<var::Settings>,
|
settings: Res<var::Settings>,
|
||||||
asset_server: Res<AssetServer>,
|
asset_server: Res<AssetServer>,
|
||||||
mut log: ResMut<Log>,
|
|
||||||
mut ambient_light: ResMut<AmbientLight>,
|
mut ambient_light: ResMut<AmbientLight>,
|
||||||
) {
|
) {
|
||||||
log.notice("Resuming from suspend".to_string());
|
|
||||||
log.notice("WARNING: Oxygen Low".to_string());
|
|
||||||
let visibility = if settings.hud_active {
|
let visibility = if settings.hud_active {
|
||||||
Visibility::Inherited
|
Visibility::Inherited
|
||||||
} else {
|
} else {
|
||||||
|
@ -508,20 +500,9 @@ fn update_hud(
|
||||||
let mut row = 0;
|
let mut row = 0;
|
||||||
|
|
||||||
// Chat Log and System Log
|
// 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 messages: Vec<&Message> = log.logs.iter()
|
let messages: Vec<&Message> = log.logs.iter()
|
||||||
.filter(logfilter)
|
|
||||||
.rev()
|
.rev()
|
||||||
.take(15)
|
.take(LOG_MAX_ROWS)
|
||||||
.collect();
|
.collect();
|
||||||
//messages.reverse();
|
//messages.reverse();
|
||||||
for msg in &messages {
|
for msg in &messages {
|
||||||
|
@ -529,6 +510,11 @@ fn update_hud(
|
||||||
let freshness = msg.get_freshness();
|
let freshness = msg.get_freshness();
|
||||||
let clr: f32 = (freshness.powf(1.5) as f32).clamp(0.1, 1.0);
|
let clr: f32 = (freshness.powf(1.5) as f32).clamp(0.1, 1.0);
|
||||||
freshest_line = freshest_line.max(freshness);
|
freshest_line = freshest_line.max(freshness);
|
||||||
|
chat.sections[row].style.color = match msg.level {
|
||||||
|
LogLevel::Warning => settings.hud_color_console_warn,
|
||||||
|
LogLevel::Info => settings.hud_color_console_system,
|
||||||
|
_ => settings.hud_color_console,
|
||||||
|
};
|
||||||
chat.sections[row].style.color.set_a(clr);
|
chat.sections[row].style.color.set_a(clr);
|
||||||
row += 1;
|
row += 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,6 +33,8 @@ pub struct Settings {
|
||||||
pub font_size_console: f32,
|
pub font_size_console: f32,
|
||||||
pub hud_color: Color,
|
pub hud_color: Color,
|
||||||
pub hud_color_console: Color,
|
pub hud_color_console: Color,
|
||||||
|
pub hud_color_console_warn: Color,
|
||||||
|
pub hud_color_console_system: Color,
|
||||||
pub hud_color_alert: Color,
|
pub hud_color_alert: Color,
|
||||||
pub hud_color_subtitles: Color,
|
pub hud_color_subtitles: Color,
|
||||||
pub hud_color_choices: Color,
|
pub hud_color_choices: Color,
|
||||||
|
@ -126,6 +128,8 @@ impl Default for Settings {
|
||||||
font_size_console: 20.0,
|
font_size_console: 20.0,
|
||||||
hud_color: Color::rgb(0.2, 0.5, 0.2),
|
hud_color: Color::rgb(0.2, 0.5, 0.2),
|
||||||
hud_color_console: Color::rgb(0.2, 0.5, 0.2),
|
hud_color_console: Color::rgb(0.2, 0.5, 0.2),
|
||||||
|
hud_color_console_warn: Color::rgb(1.0, 0.3, 0.3),
|
||||||
|
hud_color_console_system: Color::rgb(0.5, 0.5, 0.5),
|
||||||
hud_color_alert: Color::rgb(0.7, 0.3, 0.3),
|
hud_color_alert: Color::rgb(0.7, 0.3, 0.3),
|
||||||
hud_color_subtitles: Color::rgb(0.8, 0.8, 0.8),
|
hud_color_subtitles: Color::rgb(0.8, 0.8, 0.8),
|
||||||
hud_color_choices: Color::rgb(0.45, 0.45, 0.45),
|
hud_color_choices: Color::rgb(0.45, 0.45, 0.45),
|
||||||
|
|
Loading…
Reference in a new issue