rudimentary reimplementation of the log
This commit is contained in:
parent
1cd9f75ecc
commit
cdf0257598
3 changed files with 28 additions and 5 deletions
|
|
@ -3,7 +3,7 @@ use bracket_lib::prelude::*;
|
|||
use std::sync::Mutex;
|
||||
|
||||
lazy_static! {
|
||||
static ref LOG: Mutex<Vec<Vec<LogFragment>>> = Mutex::new(Vec::new());
|
||||
pub static ref LOG: Mutex<Vec<Vec<LogFragment>>> = Mutex::new(Vec::new());
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ mod builder;
|
|||
pub use builder::*;
|
||||
mod logstore;
|
||||
use logstore::*;
|
||||
pub use logstore::{ clear_log, clone_log, print_log, restore_log, setup_log };
|
||||
pub use logstore::{ LOG, clear_log, clone_log, print_log, restore_log, setup_log };
|
||||
mod events;
|
||||
pub use events::*;
|
||||
|
||||
|
|
|
|||
29
src/main.rs
29
src/main.rs
|
|
@ -448,7 +448,9 @@ fn draw(app: &mut App, gfx: &mut Graphics, gs: &mut State) {
|
|||
_ => {
|
||||
draw_bg(&gs.ecs, &mut draw, &gs.atlas);
|
||||
draw_camera(&gs.ecs, &mut draw, &gs.atlas, &gs.font);
|
||||
crate::gui::draw_ui2(&gs.ecs, &mut draw, &gs.atlas, &gs.font);
|
||||
gui::draw_ui2(&gs.ecs, &mut draw, &gs.atlas, &gs.font);
|
||||
// print_log
|
||||
draw_log(&mut draw, &gs.font);
|
||||
}
|
||||
}
|
||||
match *gs.ecs.fetch::<RunState>() {
|
||||
|
|
@ -456,11 +458,11 @@ fn draw(app: &mut App, gfx: &mut Graphics, gs: &mut State) {
|
|||
draw.text(&gs.font, "RunState::Farlook")
|
||||
.position(((x + 2) as f32) * TILESIZE, (y as f32) * TILESIZE)
|
||||
.size(FONTSIZE);
|
||||
crate::gui::draw_farlook(x, y, &mut draw, &gs.atlas);
|
||||
gui::draw_farlook(x, y, &mut draw, &gs.atlas);
|
||||
//draw_tooltips(&gs.ecs, ctx, Some((x, y))); TODO: Put this in draw loop
|
||||
}
|
||||
RunState::ShowCheatMenu => {
|
||||
crate::gui::draw_cheat_menu(&mut draw, &gs.atlas, &gs.font);
|
||||
gui::draw_cheat_menu(&mut draw, &gs.atlas, &gs.font);
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
|
@ -478,3 +480,24 @@ fn idx_to_px(idx: usize, map: &Map) -> (f32, f32) {
|
|||
fn update(ctx: &mut App, state: &mut State) {
|
||||
state.update(ctx);
|
||||
}
|
||||
|
||||
// TODO: This is *very* temporary, like with the rest of the UI rendering. It
|
||||
// needs returning to how it was pre-port to Notan, eventually.
|
||||
fn draw_log(draw: &mut notan::draw::Draw, font: ¬an::draw::Font) {
|
||||
let log = gamelog::LOG.lock().unwrap();
|
||||
let mut text: String = Default::default();
|
||||
log.iter()
|
||||
.rev()
|
||||
.take(9)
|
||||
.for_each(|log| {
|
||||
log.iter().for_each(|frag| {
|
||||
text += &frag.text.to_string();
|
||||
});
|
||||
text += "\n";
|
||||
});
|
||||
draw.text(font, &text)
|
||||
.position(TILESIZE, TILESIZE)
|
||||
.size(FONTSIZE)
|
||||
.color(Color::WHITE)
|
||||
.max_width((VIEWPORT_W as f32) * TILESIZE);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue