draw showinventory

This commit is contained in:
Llywelwyn 2023-09-30 08:53:16 +01:00
parent b524cc3b08
commit 0d834f5e23
3 changed files with 22 additions and 6 deletions

16
src/gui/inventory.rs Normal file
View file

@ -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
);
}

View file

@ -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<Entity>) {
let player_inventory = get_player_inventory(&gs.ecs);
let on_overmap = gs.ecs.fetch::<Map>().overmap;

View file

@ -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);