mirror of
https://github.com/PixelGuys/Cubyz.git
synced 2025-09-07 11:10:52 -04:00
Increase hotbar size to 12. (Inventory size is still the same)
Fixes #342
This commit is contained in:
parent
a575edae45
commit
e68f49ed89
@ -257,8 +257,8 @@ pub fn update(deltaTime: f64) void {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Player.selectedSlot -%= @bitCast(@as(i32, @intFromFloat(main.Window.scrollOffset)));
|
const newSlot: i32 = @as(i32, @intCast(Player.selectedSlot)) -% @as(i32, @intFromFloat(main.Window.scrollOffset));
|
||||||
Player.selectedSlot %= 8;
|
Player.selectedSlot = @intCast(@mod(newSlot, 12));
|
||||||
main.Window.scrollOffset = 0;
|
main.Window.scrollOffset = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,14 +18,14 @@ pub var window = GuiWindow {
|
|||||||
.{ .attachedToFrame = .{.selfAttachmentPoint = .middle, .otherAttachmentPoint = .middle} },
|
.{ .attachedToFrame = .{.selfAttachmentPoint = .middle, .otherAttachmentPoint = .middle} },
|
||||||
.{ .attachedToFrame = .{.selfAttachmentPoint = .upper, .otherAttachmentPoint = .upper} },
|
.{ .attachedToFrame = .{.selfAttachmentPoint = .upper, .otherAttachmentPoint = .upper} },
|
||||||
},
|
},
|
||||||
.contentSize = Vec2f{64*8, 64},
|
.contentSize = Vec2f{64*12, 64},
|
||||||
.isHud = true,
|
.isHud = true,
|
||||||
.showTitleBar = false,
|
.showTitleBar = false,
|
||||||
.hasBackground = false,
|
.hasBackground = false,
|
||||||
.hideIfMouseIsGrabbed = false,
|
.hideIfMouseIsGrabbed = false,
|
||||||
};
|
};
|
||||||
|
|
||||||
var itemSlots: [8]*ItemSlot = undefined;
|
var itemSlots: [12]*ItemSlot = undefined;
|
||||||
|
|
||||||
pub fn tryAddingItems(index: usize, source: *ItemStack, desiredAmount: u16) void {
|
pub fn tryAddingItems(index: usize, source: *ItemStack, desiredAmount: u16) void {
|
||||||
Player.mutex.lock();
|
Player.mutex.lock();
|
||||||
@ -70,7 +70,7 @@ const vtable = ItemSlot.VTable {
|
|||||||
|
|
||||||
pub fn onOpen() void {
|
pub fn onOpen() void {
|
||||||
const list = HorizontalList.init();
|
const list = HorizontalList.init();
|
||||||
for(0..8) |i| {
|
for(0..12) |i| {
|
||||||
itemSlots[i] = ItemSlot.init(.{0, 0}, Player.inventory__SEND_CHANGES_TO_SERVER.items[i], &vtable, i, .default, .normal);
|
itemSlots[i] = ItemSlot.init(.{0, 0}, Player.inventory__SEND_CHANGES_TO_SERVER.items[i], &vtable, i, .default, .normal);
|
||||||
list.add(itemSlots[i]);
|
list.add(itemSlots[i]);
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ pub var window = GuiWindow {
|
|||||||
.{ .attachedToWindow = .{.reference = &hotbar.window, .selfAttachmentPoint = .middle, .otherAttachmentPoint = .middle} },
|
.{ .attachedToWindow = .{.reference = &hotbar.window, .selfAttachmentPoint = .middle, .otherAttachmentPoint = .middle} },
|
||||||
.{ .attachedToWindow = .{.reference = &hotbar.window, .selfAttachmentPoint = .upper, .otherAttachmentPoint = .lower} },
|
.{ .attachedToWindow = .{.reference = &hotbar.window, .selfAttachmentPoint = .upper, .otherAttachmentPoint = .lower} },
|
||||||
},
|
},
|
||||||
.contentSize = Vec2f{64*8, 64*4},
|
.contentSize = Vec2f{64*10, 64*3},
|
||||||
};
|
};
|
||||||
|
|
||||||
const padding: f32 = 8;
|
const padding: f32 = 8;
|
||||||
@ -36,7 +36,7 @@ pub fn deinit() void {
|
|||||||
craftingIcon.deinit();
|
craftingIcon.deinit();
|
||||||
}
|
}
|
||||||
|
|
||||||
var itemSlots: [24]*ItemSlot = undefined;
|
var itemSlots: [20]*ItemSlot = undefined;
|
||||||
|
|
||||||
pub fn tryAddingItems(index: usize, source: *ItemStack, desiredAmount: u16) void {
|
pub fn tryAddingItems(index: usize, source: *ItemStack, desiredAmount: u16) void {
|
||||||
Player.mutex.lock();
|
Player.mutex.lock();
|
||||||
@ -88,13 +88,12 @@ pub fn onOpen() void {
|
|||||||
row.add(Button.initIcon(.{0, 0}, .{24, 24}, craftingIcon, true, gui.openWindowCallback("inventory_crafting")));
|
row.add(Button.initIcon(.{0, 0}, .{24, 24}, craftingIcon, true, gui.openWindowCallback("inventory_crafting")));
|
||||||
list.add(row);
|
list.add(row);
|
||||||
}
|
}
|
||||||
// Inventory:
|
for(0..2) |y| {
|
||||||
for(1..4) |y| {
|
|
||||||
const row = HorizontalList.init();
|
const row = HorizontalList.init();
|
||||||
for(0..8) |x| {
|
for(0..10) |x| {
|
||||||
const index: usize = y*8 + x;
|
const index: usize = 12 + y*10 + x;
|
||||||
const slot = ItemSlot.init(.{0, 0}, Player.inventory__SEND_CHANGES_TO_SERVER.items[index], &vtable, index, .default, .normal);
|
const slot = ItemSlot.init(.{0, 0}, Player.inventory__SEND_CHANGES_TO_SERVER.items[index], &vtable, index, .default, .normal);
|
||||||
itemSlots[index - 8] = slot;
|
itemSlots[index - 12] = slot;
|
||||||
row.add(slot);
|
row.add(slot);
|
||||||
}
|
}
|
||||||
list.add(row);
|
list.add(row);
|
||||||
@ -114,7 +113,7 @@ pub fn onClose() void {
|
|||||||
pub fn update() void {
|
pub fn update() void {
|
||||||
Player.mutex.lock();
|
Player.mutex.lock();
|
||||||
defer Player.mutex.unlock();
|
defer Player.mutex.unlock();
|
||||||
for(&itemSlots, 8..) |slot, i| {
|
for(&itemSlots, 12..) |slot, i| {
|
||||||
slot.updateItemStack(Player.inventory__SEND_CHANGES_TO_SERVER.items[i]);
|
slot.updateItemStack(Player.inventory__SEND_CHANGES_TO_SERVER.items[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user