69 lines
2.6 KiB
Rust
69 lines
2.6 KiB
Rust
use super::super::components::{ButtonType, RootMarker};
|
|
use crate::{features::inventory::ui::list_itemstack, prelude::*};
|
|
|
|
pub fn open_inventory(commands: &mut Commands, items: Query<&ItemStack>) {
|
|
commands
|
|
.spawn((
|
|
RootMarker::Inventory,
|
|
Node {
|
|
position_type: PositionType::Absolute,
|
|
width: percent(100),
|
|
height: percent(100),
|
|
..Node::center()
|
|
},
|
|
ZIndex(1),
|
|
BackgroundColor(Color::srgba(0.0, 0.0, 0.0, 0.8)),
|
|
))
|
|
.with_children(|parent| {
|
|
parent
|
|
.spawn((
|
|
Node {
|
|
padding: UiRect::all(px(20.0)),
|
|
..Node::vstack(px(0))
|
|
},
|
|
BackgroundColor(Color::srgb(0.2, 0.2, 0.2)),
|
|
BorderRadius::all(px(10.0)),
|
|
))
|
|
.with_children(|parent| {
|
|
parent.spawn((
|
|
Node {
|
|
width: percent(100.0),
|
|
justify_content: JustifyContent::SpaceBetween,
|
|
margin: UiRect::bottom(px(20.0)),
|
|
..Node::hstack(px(20))
|
|
},
|
|
children![
|
|
(
|
|
Text::new("Inventar"),
|
|
TextFont::from_font_size(40.0),
|
|
TextColor(Color::WHITE),
|
|
),
|
|
pill_button(
|
|
ButtonType::InventoryClose,
|
|
ButtonVariant::Destructive,
|
|
Node {
|
|
width: px(40),
|
|
height: px(40),
|
|
..default()
|
|
},
|
|
"X",
|
|
24.0
|
|
),
|
|
],
|
|
));
|
|
|
|
parent
|
|
.spawn(Node {
|
|
width: percent(100),
|
|
margin: UiRect::top(px(10.0)),
|
|
..Node::vstack(px(10))
|
|
})
|
|
.with_children(|parent| {
|
|
for itemstack in items.iter() {
|
|
parent.spawn(list_itemstack(itemstack));
|
|
}
|
|
});
|
|
});
|
|
});
|
|
}
|