pre-api removal
This commit is contained in:
parent
7eb0e0ad64
commit
85881db62f
8 changed files with 95 additions and 15 deletions
27
src/gamelog/builder.rs
Normal file
27
src/gamelog/builder.rs
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
use super::{append_entry, LogFragment};
|
||||
use rltk::prelude::*;
|
||||
|
||||
pub struct Logger {
|
||||
current_colour: RGB,
|
||||
fragments: Vec<LogFragment>,
|
||||
}
|
||||
|
||||
impl Logger {
|
||||
pub fn new() -> Self {
|
||||
Logger { current_colour: RGB::named(rltk::WHITE), fragments: Vec::new() }
|
||||
}
|
||||
|
||||
pub fn colour(mut self, colour: (u8, u8, u8)) -> Self {
|
||||
self.current_colour = RGB::named(colour);
|
||||
return self;
|
||||
}
|
||||
|
||||
pub fn append<T: ToString>(mut self, text: T) -> Self {
|
||||
self.fragments.push(LogFragment { colour: self.current_colour, text: text.to_string() });
|
||||
return self;
|
||||
}
|
||||
|
||||
pub fn log(self) {
|
||||
append_entry(self.fragments)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue