diff --git a/src/gui/components/ItemSlot.zig b/src/gui/components/ItemSlot.zig index 10211930..41416d89 100644 --- a/src/gui/components/ItemSlot.zig +++ b/src/gui/components/ItemSlot.zig @@ -16,6 +16,8 @@ const ItemSlot = @This(); const border: f32 = 2; +pub const sizeWithBorder = 32 + 2*border; + const Mode = enum { normal, takeOnly, @@ -23,7 +25,7 @@ const Mode = enum { }; pos: Vec2f, -size: Vec2f = .{32 + 2*border, 32 + 2*border}, +size: Vec2f = @splat(sizeWithBorder), inventory: Inventory, itemSlot: u32, lastItemAmount: u16 = 0, diff --git a/src/gui/windows/workbench.zig b/src/gui/windows/workbench.zig index a49a4059..a677b65a 100644 --- a/src/gui/windows/workbench.zig +++ b/src/gui/windows/workbench.zig @@ -35,8 +35,6 @@ const padding: f32 = 8; var inv: Inventory = undefined; -var craftingResult: *ItemSlot = undefined; - var itemSlots: [25]*ItemSlot = undefined; var toolTypes: main.ListUnmanaged(*const main.items.ToolType) = .{}; @@ -108,6 +106,18 @@ pub fn update() void { } } +pub fn render() void { + const currentResult = inv._items[25].item orelse return; + + const offsetX = 5*ItemSlot.sizeWithBorder + 20; + const offsetY = 4*ItemSlot.sizeWithBorder; + const fontSize = 16; + + main.graphics.draw.print("#ffffff{} durability", .{@as(usize, @intFromFloat(currentResult.tool.maxDurability))}, offsetX, offsetY, fontSize, .left); + main.graphics.draw.print("#ffffff{d:.1} swings/s", .{1.0/currentResult.tool.swingTime}, offsetX, offsetY + fontSize, fontSize, .left); + main.graphics.draw.print("#ffffff{d:.1} damage", .{currentResult.tool.damage}, offsetX, offsetY + 2*fontSize, fontSize, .left); +} + pub fn onOpen() void { currentToolType = 0; var iterator = main.items.toolTypeIterator();