From 4e24a9b50a4725b4dc7db96c30cc61a1713028b1 Mon Sep 17 00:00:00 2001 From: Llywelwyn Date: Mon, 25 Sep 2023 01:41:01 +0100 Subject: [PATCH] equip list - placeholder --- src/gui/mod.rs | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/src/gui/mod.rs b/src/gui/mod.rs index 323c9c6..5786b04 100644 --- a/src/gui/mod.rs +++ b/src/gui/mod.rs @@ -212,6 +212,50 @@ pub fn draw_ui2( .color(Color::YELLOW) .size(FONTSIZE); } + // Equipment + let renderables = ecs.read_storage::(); + let mut equipment: Vec<(String, RGB, RGB, FontCharType)> = Vec::new(); + let entities = ecs.entities(); + for (entity, _equipped, renderable) in (&entities, &equipped, &renderables) + .join() + .filter(|item| item.1.owner == *player_entity) { + equipment.push(( + obfuscate_name_ecs(ecs, entity).0, + RGB::named(item_colour_ecs(ecs, entity)), + renderable.fg, + renderable.glyph, + )); + } + let mut y = 1; + // TODO: Fix all of this to work with notan colours, and sprites. + if !equipment.is_empty() { + draw.text(&font, "Equipment") + .position(((VIEWPORT_W + 3) as f32) * TILESIZE, (y as f32) * TILESIZE) + .size(FONTSIZE); + let mut j: u8 = 0; + for item in equipment { + y += 1; + x = ((VIEWPORT_W + 3) as f32) * TILESIZE; + draw.text(&font, &format!("{}", (97 + j) as char)) + .position(x, (y as f32) * TILESIZE) + .color(Color::YELLOW) + .size(FONTSIZE); + j += 1; + x = draw.last_text_bounds().max_x() + 2.0 * TILESIZE; + draw.text(&font, &format!("{}", item.3 as u8 as char)) + .position(x, (y as f32) * TILESIZE) + .size(FONTSIZE); // Colours here - and below. + x = draw.last_text_bounds().max_x() + 2.0 * TILESIZE; + draw.text(&font, &item.0) + .position(x, (y as f32) * TILESIZE) + .size(FONTSIZE); + x = draw.last_text_bounds().max_x() + 1.0 * TILESIZE; + draw.text(&font, "(worn)") + .position(x, (y as f32) * TILESIZE) + .size(FONTSIZE); + } + //y += 2; + } } }