pre-api removal

This commit is contained in:
Llywelwyn 2023-07-10 11:46:21 +01:00
parent 7eb0e0ad64
commit 85881db62f
8 changed files with 95 additions and 15 deletions

33
src/gamelog/logstore.rs Normal file
View file

@ -0,0 +1,33 @@
use super::LogFragment;
use rltk::prelude::*;
use std::sync::Mutex;
lazy_static! {
static ref LOG: Mutex<Vec<Vec<LogFragment>>> = Mutex::new(Vec::new());
}
pub fn append_fragment(fragment: LogFragment) {
LOG.lock().unwrap().push(vec![fragment]);
}
pub fn append_entry(fragments: Vec<LogFragment>) {
LOG.lock().unwrap().push(fragments);
}
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| {
log.iter().for_each(|frag| {
buf.fg(frag.colour);
buf.line_wrap(&frag.text);
});
buf.ln();
});
return buf;
}