diff --git a/src/game.zig b/src/game.zig index 64eea8f3..9393f428 100644 --- a/src/game.zig +++ b/src/game.zig @@ -257,8 +257,8 @@ pub fn update(deltaTime: f64) void { } } } - Player.selectedSlot -%= @bitCast(@as(i32, @intFromFloat(main.Window.scrollOffset))); - Player.selectedSlot %= 8; + const newSlot: i32 = @as(i32, @intCast(Player.selectedSlot)) -% @as(i32, @intFromFloat(main.Window.scrollOffset)); + Player.selectedSlot = @intCast(@mod(newSlot, 12)); main.Window.scrollOffset = 0; } diff --git a/src/gui/windows/hotbar.zig b/src/gui/windows/hotbar.zig index 5efa3a9f..fa311044 100644 --- a/src/gui/windows/hotbar.zig +++ b/src/gui/windows/hotbar.zig @@ -18,14 +18,14 @@ pub var window = GuiWindow { .{ .attachedToFrame = .{.selfAttachmentPoint = .middle, .otherAttachmentPoint = .middle} }, .{ .attachedToFrame = .{.selfAttachmentPoint = .upper, .otherAttachmentPoint = .upper} }, }, - .contentSize = Vec2f{64*8, 64}, + .contentSize = Vec2f{64*12, 64}, .isHud = true, .showTitleBar = false, .hasBackground = false, .hideIfMouseIsGrabbed = false, }; -var itemSlots: [8]*ItemSlot = undefined; +var itemSlots: [12]*ItemSlot = undefined; pub fn tryAddingItems(index: usize, source: *ItemStack, desiredAmount: u16) void { Player.mutex.lock(); @@ -70,7 +70,7 @@ const vtable = ItemSlot.VTable { pub fn onOpen() void { 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); list.add(itemSlots[i]); } diff --git a/src/gui/windows/inventory.zig b/src/gui/windows/inventory.zig index 7ef26cc5..8d6cb6a2 100644 --- a/src/gui/windows/inventory.zig +++ b/src/gui/windows/inventory.zig @@ -21,7 +21,7 @@ pub var window = GuiWindow { .{ .attachedToWindow = .{.reference = &hotbar.window, .selfAttachmentPoint = .middle, .otherAttachmentPoint = .middle} }, .{ .attachedToWindow = .{.reference = &hotbar.window, .selfAttachmentPoint = .upper, .otherAttachmentPoint = .lower} }, }, - .contentSize = Vec2f{64*8, 64*4}, + .contentSize = Vec2f{64*10, 64*3}, }; const padding: f32 = 8; @@ -36,7 +36,7 @@ pub fn deinit() void { craftingIcon.deinit(); } -var itemSlots: [24]*ItemSlot = undefined; +var itemSlots: [20]*ItemSlot = undefined; pub fn tryAddingItems(index: usize, source: *ItemStack, desiredAmount: u16) void { 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"))); list.add(row); } - // Inventory: - for(1..4) |y| { + for(0..2) |y| { const row = HorizontalList.init(); - for(0..8) |x| { - const index: usize = y*8 + x; + for(0..10) |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); - itemSlots[index - 8] = slot; + itemSlots[index - 12] = slot; row.add(slot); } list.add(row); @@ -114,7 +113,7 @@ pub fn onClose() void { pub fn update() void { Player.mutex.lock(); defer Player.mutex.unlock(); - for(&itemSlots, 8..) |slot, i| { + for(&itemSlots, 12..) |slot, i| { slot.updateItemStack(Player.inventory__SEND_CHANGES_TO_SERVER.items[i]); } } \ No newline at end of file