mirror of
https://github.com/PixelGuys/Cubyz.git
synced 2025-08-03 19:28:49 -04:00
Remove redundant window ids. They were asserted to be equal to the file name, now they are initialized to the file name, removing the need for setting it manually.
This makes adding new windows simpler, also affects #273.
This commit is contained in:
parent
4ea46a6cde
commit
899083569d
@ -293,7 +293,6 @@ pub const Chunk = struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn getNeighbors(self: *const Chunk, x: i32, y: i32, z: i32, neighborsArray: *[6]Block) void {
|
pub fn getNeighbors(self: *const Chunk, x: i32, y: i32, z: i32, neighborsArray: *[6]Block) void {
|
||||||
std.debug.assert(neighborsArray.length == 6);
|
|
||||||
x &= chunkMask;
|
x &= chunkMask;
|
||||||
y &= chunkMask;
|
y &= chunkMask;
|
||||||
z &= chunkMask;
|
z &= chunkMask;
|
||||||
|
@ -52,7 +52,7 @@ contentSize: Vec2f,
|
|||||||
scale: f32 = 1,
|
scale: f32 = 1,
|
||||||
spacing: f32 = 0,
|
spacing: f32 = 0,
|
||||||
relativePosition: [2]RelativePosition = .{.{.ratio = 0.5}, .{.ratio = 0.5}},
|
relativePosition: [2]RelativePosition = .{.{.ratio = 0.5}, .{.ratio = 0.5}},
|
||||||
id: []const u8,
|
id: []const u8 = undefined,
|
||||||
rootComponent: ?GuiComponent = null,
|
rootComponent: ?GuiComponent = null,
|
||||||
showTitleBar: bool = true,
|
showTitleBar: bool = true,
|
||||||
titleBarExpanded: bool = false,
|
titleBarExpanded: bool = false,
|
||||||
|
@ -131,7 +131,7 @@ pub fn init() void {
|
|||||||
openWindows = List(*GuiWindow).init(main.globalAllocator);
|
openWindows = List(*GuiWindow).init(main.globalAllocator);
|
||||||
inline for(@typeInfo(windowlist).Struct.decls) |decl| {
|
inline for(@typeInfo(windowlist).Struct.decls) |decl| {
|
||||||
const windowStruct = @field(windowlist, decl.name);
|
const windowStruct = @field(windowlist, decl.name);
|
||||||
std.debug.assert(std.mem.eql(u8, decl.name, windowStruct.window.id)); // id and file name should be the same.
|
windowStruct.window.id = decl.name;
|
||||||
addWindow(&windowStruct.window);
|
addWindow(&windowStruct.window);
|
||||||
if(@hasDecl(windowStruct, "init")) {
|
if(@hasDecl(windowStruct, "init")) {
|
||||||
windowStruct.init();
|
windowStruct.init();
|
||||||
|
@ -14,7 +14,6 @@ const VerticalList = @import("../components/VerticalList.zig");
|
|||||||
|
|
||||||
pub var window = GuiWindow {
|
pub var window = GuiWindow {
|
||||||
.contentSize = Vec2f{128, 256},
|
.contentSize = Vec2f{128, 256},
|
||||||
.id = "change_name",
|
|
||||||
};
|
};
|
||||||
var textComponent: *TextInput = undefined;
|
var textComponent: *TextInput = undefined;
|
||||||
|
|
||||||
|
@ -19,7 +19,6 @@ pub var window: GuiWindow = GuiWindow {
|
|||||||
},
|
},
|
||||||
.scale = 0.75,
|
.scale = 0.75,
|
||||||
.contentSize = Vec2f{128, 256},
|
.contentSize = Vec2f{128, 256},
|
||||||
.id = "chat",
|
|
||||||
.showTitleBar = false,
|
.showTitleBar = false,
|
||||||
.hasBackground = false,
|
.hasBackground = false,
|
||||||
.isHud = true,
|
.isHud = true,
|
||||||
|
@ -13,7 +13,6 @@ const VerticalList = @import("../components/VerticalList.zig");
|
|||||||
|
|
||||||
pub var window = GuiWindow {
|
pub var window = GuiWindow {
|
||||||
.contentSize = Vec2f{128, 256},
|
.contentSize = Vec2f{128, 256},
|
||||||
.id = "controls",
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const padding: f32 = 8;
|
const padding: f32 = 8;
|
||||||
|
@ -19,7 +19,6 @@ pub var window = GuiWindow {
|
|||||||
.{ .attachedToFrame = .{.selfAttachmentPoint = .middle, .otherAttachmentPoint = .middle} },
|
.{ .attachedToFrame = .{.selfAttachmentPoint = .middle, .otherAttachmentPoint = .middle} },
|
||||||
},
|
},
|
||||||
.contentSize = Vec2f{64*8, 64*4},
|
.contentSize = Vec2f{64*8, 64*4},
|
||||||
.id = "creative_inventory",
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const padding: f32 = 8;
|
const padding: f32 = 8;
|
||||||
|
@ -13,7 +13,6 @@ const GuiComponent = gui.GuiComponent;
|
|||||||
const size: f32 = 64;
|
const size: f32 = 64;
|
||||||
pub var window = GuiWindow {
|
pub var window = GuiWindow {
|
||||||
.contentSize = Vec2f{size, size},
|
.contentSize = Vec2f{size, size},
|
||||||
.id = "crosshair",
|
|
||||||
.showTitleBar = false,
|
.showTitleBar = false,
|
||||||
.hasBackground = false,
|
.hasBackground = false,
|
||||||
.isHud = true,
|
.isHud = true,
|
||||||
|
@ -16,7 +16,6 @@ pub var window = GuiWindow {
|
|||||||
.{ .attachedToFrame = .{.selfAttachmentPoint = .lower, .otherAttachmentPoint = .lower} },
|
.{ .attachedToFrame = .{.selfAttachmentPoint = .lower, .otherAttachmentPoint = .lower} },
|
||||||
},
|
},
|
||||||
.contentSize = Vec2f{128, 16},
|
.contentSize = Vec2f{128, 16},
|
||||||
.id = "debug",
|
|
||||||
.isHud = false,
|
.isHud = false,
|
||||||
.showTitleBar = false,
|
.showTitleBar = false,
|
||||||
.hasBackground = false,
|
.hasBackground = false,
|
||||||
|
@ -17,7 +17,6 @@ pub var window = GuiWindow {
|
|||||||
.{ .attachedToFrame = .{.selfAttachmentPoint = .upper, .otherAttachmentPoint = .upper} },
|
.{ .attachedToFrame = .{.selfAttachmentPoint = .upper, .otherAttachmentPoint = .upper} },
|
||||||
},
|
},
|
||||||
.contentSize = Vec2f{192, 128},
|
.contentSize = Vec2f{192, 128},
|
||||||
.id = "debug_network",
|
|
||||||
.isHud = false,
|
.isHud = false,
|
||||||
.showTitleBar = false,
|
.showTitleBar = false,
|
||||||
.hasBackground = false,
|
.hasBackground = false,
|
||||||
|
@ -77,7 +77,6 @@ pub var window = GuiWindow {
|
|||||||
.{ .attachedToFrame = .{.selfAttachmentPoint = .lower, .otherAttachmentPoint = .lower} },
|
.{ .attachedToFrame = .{.selfAttachmentPoint = .lower, .otherAttachmentPoint = .lower} },
|
||||||
},
|
},
|
||||||
.contentSize = Vec2f{256, 16},
|
.contentSize = Vec2f{256, 16},
|
||||||
.id = "gpu_performance_measuring",
|
|
||||||
.isHud = false,
|
.isHud = false,
|
||||||
.showTitleBar = false,
|
.showTitleBar = false,
|
||||||
.hasBackground = false,
|
.hasBackground = false,
|
||||||
|
@ -14,7 +14,6 @@ const VerticalList = @import("../components/VerticalList.zig");
|
|||||||
|
|
||||||
pub var window = GuiWindow {
|
pub var window = GuiWindow {
|
||||||
.contentSize = Vec2f{128, 256},
|
.contentSize = Vec2f{128, 256},
|
||||||
.id = "graphics",
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const padding: f32 = 8;
|
const padding: f32 = 8;
|
||||||
|
@ -19,7 +19,6 @@ pub var window = GuiWindow {
|
|||||||
.{ .attachedToWindow = .{.reference = &hotbar.window, .selfAttachmentPoint = .upper, .otherAttachmentPoint = .lower} },
|
.{ .attachedToWindow = .{.reference = &hotbar.window, .selfAttachmentPoint = .upper, .otherAttachmentPoint = .lower} },
|
||||||
},
|
},
|
||||||
.contentSize = Vec2f{128, 16},
|
.contentSize = Vec2f{128, 16},
|
||||||
.id = "healthbar",
|
|
||||||
.isHud = true,
|
.isHud = true,
|
||||||
.showTitleBar = false,
|
.showTitleBar = false,
|
||||||
.hasBackground = false,
|
.hasBackground = false,
|
||||||
|
@ -19,7 +19,6 @@ pub var window = GuiWindow {
|
|||||||
.{ .attachedToFrame = .{.selfAttachmentPoint = .upper, .otherAttachmentPoint = .upper} },
|
.{ .attachedToFrame = .{.selfAttachmentPoint = .upper, .otherAttachmentPoint = .upper} },
|
||||||
},
|
},
|
||||||
.contentSize = Vec2f{64*8, 64},
|
.contentSize = Vec2f{64*8, 64},
|
||||||
.id = "hotbar",
|
|
||||||
.isHud = true,
|
.isHud = true,
|
||||||
.showTitleBar = false,
|
.showTitleBar = false,
|
||||||
.hasBackground = false,
|
.hasBackground = false,
|
||||||
|
@ -22,7 +22,6 @@ pub var window = GuiWindow {
|
|||||||
.{ .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*8, 64*4},
|
||||||
.id = "inventory",
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const padding: f32 = 8;
|
const padding: f32 = 8;
|
||||||
|
@ -25,7 +25,6 @@ pub var window = GuiWindow {
|
|||||||
.{ .attachedToWindow = .{.reference = &inventory.window, .selfAttachmentPoint = .middle, .otherAttachmentPoint = .middle} },
|
.{ .attachedToWindow = .{.reference = &inventory.window, .selfAttachmentPoint = .middle, .otherAttachmentPoint = .middle} },
|
||||||
},
|
},
|
||||||
.contentSize = Vec2f{64*8, 64*4},
|
.contentSize = Vec2f{64*8, 64*4},
|
||||||
.id = "inventory_crafting",
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const padding: f32 = 8;
|
const padding: f32 = 8;
|
||||||
|
@ -11,7 +11,6 @@ const VerticalList = @import("../components/VerticalList.zig");
|
|||||||
|
|
||||||
pub var window = GuiWindow {
|
pub var window = GuiWindow {
|
||||||
.contentSize = Vec2f{128, 256},
|
.contentSize = Vec2f{128, 256},
|
||||||
.id = "main",
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const padding: f32 = 8;
|
const padding: f32 = 8;
|
||||||
|
@ -15,7 +15,6 @@ const VerticalList = @import("../components/VerticalList.zig");
|
|||||||
|
|
||||||
pub var window = GuiWindow {
|
pub var window = GuiWindow {
|
||||||
.contentSize = Vec2f{128, 256},
|
.contentSize = Vec2f{128, 256},
|
||||||
.id = "multiplayer",
|
|
||||||
};
|
};
|
||||||
|
|
||||||
var ipAddressLabel: *Label = undefined;
|
var ipAddressLabel: *Label = undefined;
|
||||||
|
@ -18,7 +18,6 @@ pub var window = GuiWindow {
|
|||||||
.{ .attachedToFrame = .{.selfAttachmentPoint = .lower, .otherAttachmentPoint = .lower} },
|
.{ .attachedToFrame = .{.selfAttachmentPoint = .lower, .otherAttachmentPoint = .lower} },
|
||||||
.{ .attachedToWindow = .{.reference = &chat.window, .selfAttachmentPoint = .upper, .otherAttachmentPoint = .lower} },
|
.{ .attachedToWindow = .{.reference = &chat.window, .selfAttachmentPoint = .upper, .otherAttachmentPoint = .lower} },
|
||||||
},
|
},
|
||||||
.id = "performance_graph",
|
|
||||||
.isHud = false,
|
.isHud = false,
|
||||||
.showTitleBar = false,
|
.showTitleBar = false,
|
||||||
.hasBackground = false,
|
.hasBackground = false,
|
||||||
|
@ -17,7 +17,6 @@ const VerticalList = @import("../components/VerticalList.zig");
|
|||||||
|
|
||||||
pub var window = GuiWindow {
|
pub var window = GuiWindow {
|
||||||
.contentSize = Vec2f{128, 256},
|
.contentSize = Vec2f{128, 256},
|
||||||
.id = "save_selection",
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const padding: f32 = 8;
|
const padding: f32 = 8;
|
||||||
|
@ -11,7 +11,6 @@ const VerticalList = @import("../components/VerticalList.zig");
|
|||||||
|
|
||||||
pub var window: GuiWindow = GuiWindow {
|
pub var window: GuiWindow = GuiWindow {
|
||||||
.contentSize = Vec2f{128, 256},
|
.contentSize = Vec2f{128, 256},
|
||||||
.id = "settings",
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const padding: f32 = 8;
|
const padding: f32 = 8;
|
||||||
|
@ -14,7 +14,6 @@ const VerticalList = @import("../components/VerticalList.zig");
|
|||||||
|
|
||||||
pub var window = GuiWindow {
|
pub var window = GuiWindow {
|
||||||
.contentSize = Vec2f{128, 256},
|
.contentSize = Vec2f{128, 256},
|
||||||
.id = "sound",
|
|
||||||
};
|
};
|
||||||
|
|
||||||
fn musicCallback(newValue: f32) void {
|
fn musicCallback(newValue: f32) void {
|
||||||
|
@ -28,7 +28,6 @@ pub var window = GuiWindow {
|
|||||||
.{ .attachedToWindow = .{.reference = &inventory.window, .selfAttachmentPoint = .upper, .otherAttachmentPoint = .lower} },
|
.{ .attachedToWindow = .{.reference = &inventory.window, .selfAttachmentPoint = .upper, .otherAttachmentPoint = .lower} },
|
||||||
},
|
},
|
||||||
.contentSize = Vec2f{64*8, 64*4},
|
.contentSize = Vec2f{64*8, 64*4},
|
||||||
.id = "workbench",
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const padding: f32 = 8;
|
const padding: f32 = 8;
|
||||||
|
@ -139,8 +139,8 @@ pub const std_options: std.Options = .{
|
|||||||
}
|
}
|
||||||
types = &[_]type{[]const u8} ++ types ++ &[_]type{[]const u8};
|
types = &[_]type{[]const u8} ++ types ++ &[_]type{[]const u8};
|
||||||
|
|
||||||
comptime var comptimeTuple: std.meta.Tuple(types) = undefined;
|
const ArgsType = std.meta.Tuple(types);
|
||||||
comptime std.debug.assert(std.meta.Tuple(types) == std.meta.Tuple(types));
|
comptime var comptimeTuple: ArgsType = undefined;
|
||||||
comptime var len: usize = 0;
|
comptime var len: usize = 0;
|
||||||
i_1 = 0;
|
i_1 = 0;
|
||||||
i_2 = 0;
|
i_2 = 0;
|
||||||
@ -156,7 +156,7 @@ pub const std_options: std.Options = .{
|
|||||||
}
|
}
|
||||||
comptimeTuple[0] = filePrefix;
|
comptimeTuple[0] = filePrefix;
|
||||||
comptimeTuple[comptimeTuple.len - 1] = fileSuffix;
|
comptimeTuple[comptimeTuple.len - 1] = fileSuffix;
|
||||||
var resultArgs: std.meta.Tuple(types) = comptimeTuple;
|
var resultArgs: ArgsType = comptimeTuple;
|
||||||
len = 0;
|
len = 0;
|
||||||
i_1 = 0;
|
i_1 = 0;
|
||||||
i_2 = 0;
|
i_2 = 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user