feat: Add inventory display popup (#48)
This commit is contained in:
83
src/features/inventory/ui/inventory.rs
Normal file
83
src/features/inventory/ui/inventory.rs
Normal file
@@ -0,0 +1,83 @@
|
||||
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),
|
||||
justify_content: JustifyContent::Center,
|
||||
align_items: AlignItems::Center,
|
||||
..default()
|
||||
},
|
||||
ZIndex(1),
|
||||
BackgroundColor(Color::srgba(0.0, 0.0, 0.0, 0.8)),
|
||||
))
|
||||
.with_children(|parent| {
|
||||
parent
|
||||
.spawn((
|
||||
Node {
|
||||
flex_direction: FlexDirection::Column,
|
||||
align_items: AlignItems::Center,
|
||||
padding: UiRect::all(px(20.0)),
|
||||
..default()
|
||||
},
|
||||
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,
|
||||
align_items: AlignItems::Center,
|
||||
margin: UiRect::bottom(px(20.0)),
|
||||
column_gap: px(20.0),
|
||||
..default()
|
||||
},
|
||||
children![
|
||||
(
|
||||
Text::new("Inventar"),
|
||||
TextFont::from_font_size(40.0),
|
||||
TextColor(Color::WHITE),
|
||||
),
|
||||
(
|
||||
Button,
|
||||
ButtonType::InventoryClose,
|
||||
Node {
|
||||
width: px(40.0),
|
||||
height: px(40.0),
|
||||
justify_content: JustifyContent::Center,
|
||||
align_items: AlignItems::Center,
|
||||
..default()
|
||||
},
|
||||
BackgroundColor(Color::srgb(0.8, 0.2, 0.2)),
|
||||
BorderRadius::MAX,
|
||||
children![(
|
||||
Text::new("X"),
|
||||
TextFont::from_font_size(24.0),
|
||||
TextColor(Color::WHITE),
|
||||
)]
|
||||
)
|
||||
],
|
||||
));
|
||||
|
||||
parent
|
||||
.spawn(Node {
|
||||
width: percent(100),
|
||||
flex_direction: FlexDirection::Column,
|
||||
margin: UiRect::top(px(10.0)),
|
||||
row_gap: px(10.0),
|
||||
..default()
|
||||
})
|
||||
.with_children(|parent| {
|
||||
for itemstack in items.iter() {
|
||||
parent.spawn(list_itemstack(itemstack));
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user