mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
added active inventory slots
This commit is contained in:
parent
d9ab3ef76c
commit
12e7d749ec
@ -15,12 +15,13 @@ widget_ids! {
|
||||
inv_scrollbar,
|
||||
inv_slot_0,
|
||||
map_title,
|
||||
inv_slot[],
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(WidgetCommon)]
|
||||
pub struct Bag<'a> {
|
||||
inventory_space: u32,
|
||||
inventory_space: usize,
|
||||
|
||||
imgs: &'a Imgs,
|
||||
_fonts: &'a Fonts,
|
||||
@ -29,7 +30,7 @@ pub struct Bag<'a> {
|
||||
}
|
||||
|
||||
impl<'a> Bag<'a> {
|
||||
pub fn new(inventory_space: u32, imgs: &'a Imgs, _fonts: &'a Fonts) -> Self {
|
||||
pub fn new(inventory_space: usize, imgs: &'a Imgs, fonts: &'a Fonts) -> Self {
|
||||
Self {
|
||||
inventory_space,
|
||||
imgs,
|
||||
@ -91,13 +92,24 @@ impl<'a> Widget for Bag<'a> {
|
||||
.rgba(0.33, 0.33, 0.33, 1.0)
|
||||
.set(state.ids.inv_scrollbar, ui);
|
||||
|
||||
if self.inventory_space > 0 {
|
||||
// First Slot
|
||||
// Create available inventory slot widgets
|
||||
|
||||
|
||||
|
||||
dbg!(self.inventory_space);
|
||||
if state.ids.inv_slot.len() < self.inventory_space {
|
||||
state.update(|s| { s.ids.inv_slot.resize(self.inventory_space, &mut ui.widget_id_generator());});}
|
||||
for i in 0..self.inventory_space {
|
||||
let x = i % 5;
|
||||
let y = i / 5;
|
||||
Button::image(self.imgs.inv_slot)
|
||||
.top_left_with_margins_on(state.ids.inv_grid_1, 4.0, 4.0)
|
||||
.w_h(10.0 * 4.0, 10.0 * 4.0)
|
||||
.set(state.ids.inv_slot_0, ui);
|
||||
}
|
||||
.top_left_with_margins_on(state.ids.inv_alignment, 4.0 + y as f64 * (40.0 + 4.0), 4.0 + x as f64 * (40.0 + 4.0))
|
||||
.w_h(40.0, 40.0)
|
||||
.set(state.ids.inv_slot[i], ui);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// X-button
|
||||
if Button::image(self.imgs.close_button)
|
||||
|
@ -256,7 +256,7 @@ pub struct Hud {
|
||||
imgs: Imgs,
|
||||
fonts: Fonts,
|
||||
new_messages: VecDeque<String>,
|
||||
inventory_space: u32,
|
||||
inventory_space: usize,
|
||||
show: Show,
|
||||
to_focus: Option<Option<widget::Id>>,
|
||||
force_ungrab: bool,
|
||||
@ -486,7 +486,7 @@ impl Hud {
|
||||
.set(self.ids.bag_space_add, ui_widgets)
|
||||
.was_clicked()
|
||||
{
|
||||
self.inventory_space += 1;
|
||||
if self.inventory_space < 91 {self.inventory_space += 10;} else {}
|
||||
};
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user