use ::rltk::prelude::*; use ::specs::prelude::*; use super::{get_item_display_name, item_result_menu, ItemMenuResult}; use crate::components::InBackpack; use crate::State; pub fn remove_item_menu(gs: &mut State, ctx: &mut Rltk) -> (ItemMenuResult, Option) { let mut draw_batch = DrawBatch::new(); let player_entity = gs.ecs.fetch::(); let backpack = gs.ecs.read_storage::(); let entities = gs.ecs.entities(); let mut items: Vec<(Entity, String)> = Vec::new(); (&entities, &backpack) .join() .filter(|item| item.1.owner == *player_entity) .for_each(|item| items.push((item.0, get_item_display_name(&gs.ecs, item.0)))); let result = item_result_menu( &mut draw_batch, "Remove which item?", items.len(), &items, ctx.key, ); draw_batch .submit(6000) .expect("Failed to batch render Remove Item Menu"); result }