71 lines
2.6 KiB
Rust
71 lines
2.6 KiB
Rust
use super::super::components::{ButtonType, 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>,
|
|
) {
|
|
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)),
|
|
GlobalTransform::default(),
|
|
))
|
|
.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("Inventar", 40.0, Color::WHITE),
|
|
pill_button(
|
|
ButtonType::InventoryClose,
|
|
ButtonVariant::Destructive,
|
|
Node {
|
|
width: px(40),
|
|
height: px(40),
|
|
..default()
|
|
},
|
|
|color| text("X", 24.0, color)
|
|
),
|
|
],
|
|
));
|
|
|
|
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, game_config, asset_server));
|
|
}
|
|
});
|
|
});
|
|
});
|
|
}
|