extends log builder, swaps away from textblocks

line wrapping no longer works, but in return the message log can easily be swapped between ascending/descending, and spaces/no spaces between entries.

realistically nobody wants to read a huge wrapped line anyway so those can just be avoided
This commit is contained in:
Llywelwyn 2023-07-11 02:41:01 +01:00
parent b562e093ea
commit 42901b984e
9 changed files with 89 additions and 30 deletions

View file

@ -19,18 +19,22 @@ pub fn clear_log() {
LOG.lock().unwrap().clear();
}
pub fn log_display() -> TextBuilder {
let mut buf = TextBuilder::empty();
LOG.lock().unwrap().iter().rev().take(12).for_each(|log| {
pub fn print_log(console: &mut Box<dyn Console>, pos: Point, descending: bool, len: usize) {
let mut y = pos.y;
let mut x = pos.x;
LOG.lock().unwrap().iter().rev().take(len).for_each(|log| {
log.iter().for_each(|frag| {
buf.fg(frag.colour);
buf.line_wrap(&frag.text);
console.print_color(x, y, frag.colour.into(), RGB::named(rltk::BLACK).into(), &frag.text);
x += frag.text.len() as i32;
x += 0;
});
buf.ln();
if descending {
y += 1;
} else {
y -= 1;
}
x = pos.x;
});
return buf;
}
pub fn clone_log() -> Vec<Vec<crate::gamelog::LogFragment>> {