-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Qol shortcuts #382
Qol shortcuts #382
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for working on this!
Please fix the format check, which is failing and the other comments. Most of them are just small things and should be easy to fix.
src/blocks.zig
Outdated
@@ -190,10 +190,12 @@ pub fn finishBlocks(jsonElements: std.StringHashMap(JsonElement)) void { | |||
|
|||
pub fn reset() void { | |||
size = 0; | |||
ores.clearRetainingCapacity(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is unnecessary since you do clearAndFree
in the next line.
src/blocks.zig
Outdated
@@ -534,6 +536,7 @@ pub const meshes = struct { | |||
} | |||
|
|||
pub fn register(assetFolder: []const u8, _: []const u8, json: JsonElement) void { | |||
std.debug.print("size {d}", .{meshes.size}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Print leftover from debugging, please remove
src/gui/windows/main.zig
Outdated
@@ -15,12 +15,16 @@ pub var window = GuiWindow { | |||
|
|||
const padding: f32 = 8; | |||
|
|||
fn exitGame(p:usize) void { | |||
_ = p; | |||
std.process.exit(0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This closes the entire application which has some unintended side-effects:
All the defer ...deinit()
calls in main won't be executed. This means that the settings won't be saved and, important for development, the leak check of zig's general purpose allocator won't be executed.
A better solution would be to close the glfw window(it that possible) or otherwise to add a running
flag to the main loop.
src/gui/windows/main.zig
Outdated
pub fn onOpen() void { | ||
const list = VerticalList.init(.{padding, 16 + padding}, 300, 16); | ||
list.add(Button.initText(.{0, 0}, 128, "Singleplayer", gui.openWindowCallback("save_selection"))); | ||
list.add(Button.initText(.{0, 0}, 128, "Multiplayer", gui.openWindowCallback("multiplayer"))); | ||
list.add(Button.initText(.{0, 0}, 128, "Settings", gui.openWindowCallback("settings"))); | ||
list.add(Button.initText(.{0, 0}, 128, "Exit TODO", .{})); | ||
list.add(Button.initText(.{0, 0}, 128, "Exit TODO", .{.callback = &exitGame})); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you seem to be fixing it, you should probably remove the TODO on the button.
src/gui/windows/pause.zig
Outdated
@@ -15,11 +15,21 @@ pub var window = GuiWindow { | |||
|
|||
const padding: f32 = 8; | |||
|
|||
fn exitMenuCallbackFunction(useless: usize) void { | |||
_ = useless; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to put this into a new line, better directly discard it with fn exitMenuCallbackFunction(_: usize) void {
src/gui/windows/main.zig
Outdated
@@ -15,12 +15,16 @@ pub var window = GuiWindow { | |||
|
|||
const padding: f32 = 8; | |||
|
|||
fn exitGame(p:usize) void { | |||
_ = p; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comment in pause.zig
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unintended line removal?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's an empty line, does it matter?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, just looked like it was unintentionally removed. If you made this change intentionally then I would like to know the intention though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah i remember, that was when i made the "reset" function, but then we decided to just make the already existing deinit function use clearAndFree() , thus removing the need for the reset function
while deleting the reset() function, i also deleted one line to much
src/gui/windows/main.zig
Outdated
pub fn onOpen() void { | ||
const list = VerticalList.init(.{padding, 16 + padding}, 300, 16); | ||
list.add(Button.initText(.{0, 0}, 128, "Singleplayer", gui.openWindowCallback("save_selection"))); | ||
list.add(Button.initText(.{0, 0}, 128, "Multiplayer", gui.openWindowCallback("multiplayer"))); | ||
list.add(Button.initText(.{0, 0}, 128, "Settings", gui.openWindowCallback("settings"))); | ||
list.add(Button.initText(.{0, 0}, 128, "Exit TODO", .{})); | ||
list.add(Button.initText(.{0, 0}, 128, "TODO", .{.callback = &exitGame})); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed the wrong word xD
src/gui/windows/main.zig
Outdated
@@ -15,12 +15,15 @@ pub var window = GuiWindow { | |||
|
|||
const padding: f32 = 8; | |||
|
|||
fn exitGame(_:usize) void { | |||
main.Window.deinit(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This solution does not seem to work.
When I press the exit button it crashes with:
Segmentation fault at address 0x88
???:?:?: 0x163c44a in _glfwPollEventsX11 (/home/mint/.cache/zig/p/1220c46ebcac607065f942193b82a21b87213fca4b0d50c83461f8f5e22955fcb88f/src/x11_window.c)
/home/mint/Desktop/Cubyz/src/graphics/Window.zig:343:18: 0x1312194 in handleEvents (Cubyzig)
c.glfwPollEvents();
^
/home/mint/Desktop/Cubyz/src/main.zig:416:22: 0x130ae68 in main (Cubyzig)
Window.handleEvents();
^
/home/mint/Cubyz/compiler/zig/lib/std/start.zig:501:22: 0x130a579 in main (Cubyzig)
root.main();
^
../sysdeps/nptl/libc_start_call_main.h:58:16: 0x7fd96cd9ed8f in __libc_start_call_main (../sysdeps/x86/libc-start.c)
../csu/libc-start.c:392:3: 0x7fd96cd9ee3f in __libc_start_main_impl (../sysdeps/x86/libc-start.c)
???:?:?: 0x130a224 in ??? (???)
???:?:?: 0x0 in ??? (???)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah oops, didnt see the segfault under all of the thread sanitizers stuff.
@@ -106,6 +106,7 @@ pub fn deinit() void { | |||
} | |||
clearList.clearAndFree(); | |||
} | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reintroduced the line, just 4u!
better shortcuts and most importantly: makes exiting the world possible. With this revolutionary and long awaited feature you can finally stop playing 馃コ. Now people can go outside and touch some grass!