cleanup
This commit is contained in:
parent
db29b60551
commit
65ec5c1b15
3 changed files with 12 additions and 17 deletions
|
|
@ -5,11 +5,20 @@ use std::collections::BTreeMap;
|
||||||
use notan::prelude::*;
|
use notan::prelude::*;
|
||||||
use notan::text::CreateText;
|
use notan::text::CreateText;
|
||||||
use crate::consts::{ TILESIZE, FONTSIZE };
|
use crate::consts::{ TILESIZE, FONTSIZE };
|
||||||
|
use crate::consts::visuals::VIEWPORT_W;
|
||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
pub static ref LOG: Mutex<BTreeMap<i32, Vec<LogFragment>>> = Mutex::new(BTreeMap::new());
|
pub static ref LOG: Mutex<BTreeMap<i32, Vec<LogFragment>>> = Mutex::new(BTreeMap::new());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Render with defaults, to avoid having to pass so many args.
|
||||||
|
pub fn render(draw: bool, gfx: &mut Graphics, font: ¬an::draw::Font) {
|
||||||
|
if draw {
|
||||||
|
render_log(gfx, &font, &(TILESIZE, TILESIZE * 8.0 + 4.0), (VIEWPORT_W as f32) * TILESIZE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Render with specific params.
|
||||||
pub fn render_log(gfx: &mut Graphics, font: ¬an::draw::Font, pos: &(f32, f32), width: f32) {
|
pub fn render_log(gfx: &mut Graphics, font: ¬an::draw::Font, pos: &(f32, f32), width: f32) {
|
||||||
let mut text = gfx.create_text();
|
let mut text = gfx.create_text();
|
||||||
let log = LOG.lock().unwrap();
|
let log = LOG.lock().unwrap();
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ mod builder;
|
||||||
pub use builder::*;
|
pub use builder::*;
|
||||||
mod logstore;
|
mod logstore;
|
||||||
use logstore::*;
|
use logstore::*;
|
||||||
pub use logstore::{ LOG, clear_log, clone_log, render_log, restore_log, setup_log };
|
pub use logstore::{ LOG, clear_log, clone_log, render, render_log, restore_log, setup_log };
|
||||||
mod events;
|
mod events;
|
||||||
pub use events::*;
|
pub use events::*;
|
||||||
|
|
||||||
|
|
|
||||||
18
src/main.rs
18
src/main.rs
|
|
@ -437,7 +437,7 @@ fn draw_bg(_ecs: &World, draw: &mut Draw, atlas: &HashMap<String, Texture>) {
|
||||||
draw_spritebox(sidebox, draw, atlas);
|
draw_spritebox(sidebox, draw, atlas);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn draw(app: &mut App, gfx: &mut Graphics, gs: &mut State) {
|
fn draw(_app: &mut App, gfx: &mut Graphics, gs: &mut State) {
|
||||||
let mut draw = gfx.create_draw();
|
let mut draw = gfx.create_draw();
|
||||||
draw.clear(Color::BLACK);
|
draw.clear(Color::BLACK);
|
||||||
let mut log = false;
|
let mut log = false;
|
||||||
|
|
@ -481,21 +481,7 @@ fn draw(app: &mut App, gfx: &mut Graphics, gs: &mut State) {
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
gfx.render(&draw);
|
gfx.render(&draw);
|
||||||
if log {
|
gamelog::render(log, gfx, &gs.font);
|
||||||
gamelog::render_log(
|
|
||||||
gfx,
|
|
||||||
&gs.font,
|
|
||||||
&(TILESIZE, TILESIZE * 8.0 + 4.0),
|
|
||||||
(VIEWPORT_W as f32) * TILESIZE
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn idx_to_px(idx: usize, map: &Map) -> (f32, f32) {
|
|
||||||
(
|
|
||||||
((idx % (map.width as usize)) as f32) * (TILESIZE as f32),
|
|
||||||
((idx / (map.width as usize)) as f32) * (TILESIZE as f32),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update(ctx: &mut App, state: &mut State) {
|
fn update(ctx: &mut App, state: &mut State) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue