diff --git a/src/audio.zig b/src/audio.zig index f8e464bc3..717e1fbb0 100644 --- a/src/audio.zig +++ b/src/audio.zig @@ -153,7 +153,7 @@ pub fn init() !void { 0, // input channels 2, // stereo output c.paFloat32, - sampleRate, // TODO: There must be some target dependant value to put here. + sampleRate, c.paFramesPerBufferUnspecified, &patestCallback, null diff --git a/src/gui/GuiWindow.zig b/src/gui/GuiWindow.zig index 82f2c5a12..181b7c5d1 100644 --- a/src/gui/GuiWindow.zig +++ b/src/gui/GuiWindow.zig @@ -316,7 +316,7 @@ fn positionRelativeToConnectedWindow(self: *GuiWindow, other: *GuiWindow, i: usi .otherAttachmentPoint = .upper, }}; } else { - self.relativePosition[i] = .{.relativeToWindow = .{ + relPos.* = .{.relativeToWindow = .{ .reference = other, .ratio = (self.pos[i] + self.size[i]/2 - other.pos[i])/otherSize[i] }}; diff --git a/src/gui/gui.zig b/src/gui/gui.zig index 48639e530..cb7479964 100644 --- a/src/gui/gui.zig +++ b/src/gui/gui.zig @@ -235,6 +235,7 @@ fn load() !void { for(windowList.items) |window| { const windowJson = json.getChild(window.id); + if(windowJson == .JsonNull) continue; for(&window.relativePosition, 0..) |*relPos, i| { const relPosJson = windowJson.getChild(([_][]const u8{"relPos0", "relPos1"})[i]); const typ = relPosJson.get([]const u8, "type", "ratio"); diff --git a/src/gui/windows/chat.zig b/src/gui/windows/chat.zig index 28a8b0527..dd7c133b4 100644 --- a/src/gui/windows/chat.zig +++ b/src/gui/windows/chat.zig @@ -14,6 +14,11 @@ const TextInput = GuiComponent.TextInput; const VerticalList = @import("../components/VerticalList.zig"); pub var window: GuiWindow = GuiWindow { + .relativePosition = .{ + .{ .attachedToFrame = .{.selfAttachmentPoint = .lower, .otherAttachmentPoint = .lower} }, + .{ .attachedToFrame = .{.selfAttachmentPoint = .upper, .otherAttachmentPoint = .upper} }, + }, + .scale = 0.75, .contentSize = Vec2f{128, 256}, .id = "chat", .showTitleBar = false, diff --git a/src/gui/windows/creative_inventory.zig b/src/gui/windows/creative_inventory.zig index ea637d41d..db8da05ef 100644 --- a/src/gui/windows/creative_inventory.zig +++ b/src/gui/windows/creative_inventory.zig @@ -15,6 +15,10 @@ const VerticalList = GuiComponent.VerticalList; const ItemSlot = GuiComponent.ItemSlot; pub var window = GuiWindow { + .relativePosition = .{ + .{ .attachedToFrame = .{.selfAttachmentPoint = .lower, .otherAttachmentPoint = .lower} }, + .{ .attachedToFrame = .{.selfAttachmentPoint = .middle, .otherAttachmentPoint = .middle} }, + }, .contentSize = Vec2f{64*8, 64*4}, .id = "creative_inventory", }; diff --git a/src/gui/windows/debug.zig b/src/gui/windows/debug.zig index 50710c4ec..f78c02596 100644 --- a/src/gui/windows/debug.zig +++ b/src/gui/windows/debug.zig @@ -12,6 +12,10 @@ const GuiWindow = gui.GuiWindow; const GuiComponent = gui.GuiComponent; pub var window = GuiWindow { + .relativePosition = .{ + .{ .attachedToFrame = .{.selfAttachmentPoint = .lower, .otherAttachmentPoint = .lower} }, + .{ .attachedToFrame = .{.selfAttachmentPoint = .lower, .otherAttachmentPoint = .lower} }, + }, .contentSize = Vec2f{128, 16}, .id = "debug", .isHud = false, diff --git a/src/gui/windows/gpu_performance_measuring.zig b/src/gui/windows/gpu_performance_measuring.zig index 1247c9e7a..9f0176d4b 100644 --- a/src/gui/windows/gpu_performance_measuring.zig +++ b/src/gui/windows/gpu_performance_measuring.zig @@ -77,6 +77,10 @@ pub fn stopQuery() void { } pub var window = GuiWindow { + .relativePosition = .{ + .{ .attachedToFrame = .{.selfAttachmentPoint = .upper, .otherAttachmentPoint = .upper} }, + .{ .attachedToFrame = .{.selfAttachmentPoint = .lower, .otherAttachmentPoint = .lower} }, + }, .contentSize = Vec2f{256, 16}, .id = "gpu_performance_measuring", .isHud = false, diff --git a/src/gui/windows/healthbar.zig b/src/gui/windows/healthbar.zig index 64aa7ed0f..8f6c96df6 100644 --- a/src/gui/windows/healthbar.zig +++ b/src/gui/windows/healthbar.zig @@ -11,7 +11,14 @@ const gui = @import("../gui.zig"); const GuiWindow = gui.GuiWindow; const GuiComponent = gui.GuiComponent; +const hotbar = @import("hotbar.zig"); + pub var window = GuiWindow { + .scale = 0.75, + .relativePosition = .{ + .{ .attachedToWindow = .{.reference = &hotbar.window, .selfAttachmentPoint = .upper, .otherAttachmentPoint = .upper} }, + .{ .attachedToWindow = .{.reference = &hotbar.window, .selfAttachmentPoint = .upper, .otherAttachmentPoint = .lower} }, + }, .contentSize = Vec2f{128, 16}, .id = "healthbar", .isHud = true, diff --git a/src/gui/windows/hotbar.zig b/src/gui/windows/hotbar.zig index 2c9476e26..4230b69fd 100644 --- a/src/gui/windows/hotbar.zig +++ b/src/gui/windows/hotbar.zig @@ -15,6 +15,10 @@ const ItemSlot = GuiComponent.ItemSlot; const Icon = GuiComponent.Icon; pub var window = GuiWindow { + .relativePosition = .{ + .{ .attachedToFrame = .{.selfAttachmentPoint = .middle, .otherAttachmentPoint = .middle} }, + .{ .attachedToFrame = .{.selfAttachmentPoint = .upper, .otherAttachmentPoint = .upper} }, + }, .contentSize = Vec2f{64*8, 64}, .id = "hotbar", .isHud = true, diff --git a/src/gui/windows/inventory.zig b/src/gui/windows/inventory.zig index 9851f450a..3f676630a 100644 --- a/src/gui/windows/inventory.zig +++ b/src/gui/windows/inventory.zig @@ -15,7 +15,13 @@ const HorizontalList = GuiComponent.HorizontalList; const VerticalList = GuiComponent.VerticalList; const ItemSlot = GuiComponent.ItemSlot; +const hotbar = @import("hotbar.zig"); + pub var window = GuiWindow { + .relativePosition = .{ + .{ .attachedToWindow = .{.reference = &hotbar.window, .selfAttachmentPoint = .middle, .otherAttachmentPoint = .middle} }, + .{ .attachedToWindow = .{.reference = &hotbar.window, .selfAttachmentPoint = .upper, .otherAttachmentPoint = .lower} }, + }, .contentSize = Vec2f{64*8, 64*4}, .id = "inventory", }; diff --git a/src/gui/windows/inventory_crafting.zig b/src/gui/windows/inventory_crafting.zig index 4d063424e..c620fc33a 100644 --- a/src/gui/windows/inventory_crafting.zig +++ b/src/gui/windows/inventory_crafting.zig @@ -19,7 +19,13 @@ const Icon = GuiComponent.Icon; const CraftingResultSlot = GuiComponent.CraftingResultSlot; const ImmutableItemSlot = GuiComponent.ImmutableItemSlot; +const inventory = @import("inventory.zig"); + pub var window = GuiWindow { + .relativePosition = .{ + .{ .attachedToWindow = .{.reference = &inventory.window, .selfAttachmentPoint = .lower, .otherAttachmentPoint = .upper} }, + .{ .attachedToWindow = .{.reference = &inventory.window, .selfAttachmentPoint = .middle, .otherAttachmentPoint = .middle} }, + }, .contentSize = Vec2f{64*8, 64*4}, .id = "inventory_crafting", }; diff --git a/src/gui/windows/performance_graph.zig b/src/gui/windows/performance_graph.zig index 5bd270fb0..9589f2a5d 100644 --- a/src/gui/windows/performance_graph.zig +++ b/src/gui/windows/performance_graph.zig @@ -11,8 +11,14 @@ const gui = @import("../gui.zig"); const GuiWindow = gui.GuiWindow; const GuiComponent = gui.GuiComponent; +const chat = @import("chat.zig"); + pub var window = GuiWindow { .contentSize = Vec2f{128, 64}, + .relativePosition = .{ + .{ .attachedToFrame = .{.selfAttachmentPoint = .lower, .otherAttachmentPoint = .lower} }, + .{ .attachedToWindow = .{.reference = &chat.window, .selfAttachmentPoint = .upper, .otherAttachmentPoint = .lower} }, + }, .id = "performance_graph", .isHud = false, .showTitleBar = false, diff --git a/src/gui/windows/workbench.zig b/src/gui/windows/workbench.zig index 5bcc8b808..557311438 100644 --- a/src/gui/windows/workbench.zig +++ b/src/gui/windows/workbench.zig @@ -22,9 +22,14 @@ const ItemSlot = GuiComponent.ItemSlot; const CraftingResultSlot = GuiComponent.CraftingResultSlot; const ImmutableItemSlot = GuiComponent.ImmutableItemSlot; +const inventory = @import("inventory.zig"); const inventory_crafting = @import("inventory_crafting.zig"); pub var window = GuiWindow { + .relativePosition = .{ + .{ .attachedToWindow = .{.reference = &inventory.window, .selfAttachmentPoint = .middle, .otherAttachmentPoint = .middle} }, + .{ .attachedToWindow = .{.reference = &inventory.window, .selfAttachmentPoint = .upper, .otherAttachmentPoint = .lower} }, + }, .contentSize = Vec2f{64*8, 64*4}, .id = "workbench", };