Default gui positions

Resolves #131
This commit is contained in:
IntegratedQuantum 2023-10-15 22:26:02 +02:00
parent 998fd96a7b
commit f3a197f6d4
13 changed files with 54 additions and 2 deletions

View File

@ -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

View File

@ -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]
}};

View File

@ -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");

View File

@ -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,

View File

@ -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",
};

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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",
};

View File

@ -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",
};

View File

@ -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,

View File

@ -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",
};