how only the 3 most recent log entries

This commit is contained in:
yuni 2024-04-15 02:35:00 +02:00
parent 51089049ae
commit e47e175fc5

View file

@ -426,13 +426,17 @@ fn update_hud(
_ => false _ => false
}} }}
}; };
let logs_vec: Vec<String> = log.logs.iter() let mut logs_vec: Vec<String> = log.logs.iter()
.filter(logfilter) .filter(logfilter)
.map(|s| if s.sender.is_empty() { .map(|s| if s.sender.is_empty() {
format!("{}", s.text) format!("{}", s.text)
} else { } else {
format!("{}: {}", s.sender, s.text) format!("{}: {}", s.sender, s.text)
}).collect(); })
.rev()
.take(3)
.collect();
logs_vec.reverse();
chat.sections[0].value = logs_vec.join("\n"); chat.sections[0].value = logs_vec.join("\n");
} }
log.needs_rerendering = false; log.needs_rerendering = false;