diff --git a/src/gui/inventory.rs b/src/gui/inventory.rs new file mode 100644 index 0000000..e3eeb77 --- /dev/null +++ b/src/gui/inventory.rs @@ -0,0 +1,16 @@ +use notan::prelude::*; +use notan::draw::{ Draw, Font }; +use specs::prelude::*; +use super::TILESIZE; + +pub fn draw_inventory(ecs: &World, draw: &mut Draw, font: &Font) { + let inv = super::get_player_inventory(ecs); + let offsets = crate::camera::get_offset(); + super::print_options( + draw, + font, + &inv, + (offsets.x as f32) * TILESIZE, + (offsets.y as f32) * TILESIZE + ); +} diff --git a/src/gui/mod.rs b/src/gui/mod.rs index b3684e6..8af53c3 100644 --- a/src/gui/mod.rs +++ b/src/gui/mod.rs @@ -66,6 +66,8 @@ mod farlook; pub use farlook::*; mod main_menu; pub use main_menu::*; +mod inventory; +pub use inventory::*; /// Gives a popup box with a message and a title, and waits for a keypress. #[allow(unused)] @@ -995,8 +997,7 @@ pub fn print_options( //let this_width = x - initial_x + (item.display_name.singular.len() as i32); //width = if width > this_width { width } else { this_width }; } - - y = draw.last_text_bounds().max_y(); + y += TILESIZE; j += 1; } return (y, width); @@ -1330,10 +1331,6 @@ pub fn get_player_inventory(ecs: &World) -> PlayerInventory { return player_inventory; } -pub fn draw_inventory() { - // Draw -} - pub fn show_inventory(gs: &mut State, ctx: &mut App) -> (ItemMenuResult, Option) { let player_inventory = get_player_inventory(&gs.ecs); let on_overmap = gs.ecs.fetch::().overmap; diff --git a/src/main.rs b/src/main.rs index a22224c..d1f8a0a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -534,6 +534,9 @@ fn draw(_app: &mut App, gfx: &mut Graphics, gs: &mut State) { RunState::GameOver => { corner_text("Create morgue file? [Y/N]", &mut draw, &gs.font); } + RunState::ShowInventory => { + gui::draw_inventory(&gs.ecs, &mut draw, &gs.font); + } _ => {} } gfx.render(&draw);