34 lines
986 B
Rust
34 lines
986 B
Rust
use super::super::components::RootMarker;
|
|
use crate::prelude::GameConfig;
|
|
use crate::{features::inventory::ui::list_itemstack, prelude::*};
|
|
|
|
pub fn open_inventory(
|
|
commands: &mut Commands,
|
|
items: Query<&ItemStack>,
|
|
game_config: &Res<GameConfig>,
|
|
asset_server: &Res<AssetServer>,
|
|
) {
|
|
spawn_popup(
|
|
commands,
|
|
RootMarker::Inventory,
|
|
"Inventar",
|
|
Node::default(),
|
|
|parent| {
|
|
parent
|
|
.spawn(Node {
|
|
width: percent(100),
|
|
margin: UiRect::top(px(10.0)),
|
|
..Node::vstack(px(10))
|
|
})
|
|
.with_children(|parent| {
|
|
items
|
|
.iter()
|
|
.map(|item| list_itemstack(item, game_config, asset_server))
|
|
.for_each(|itemstack| {
|
|
parent.spawn(itemstack);
|
|
});
|
|
});
|
|
},
|
|
);
|
|
}
|