mirror of
https://github.com/PixelGuys/Cubyz.git
synced 2025-08-03 19:28:49 -04:00
Return to the game when pressing escape while the mouse isn't grabbed.
This seems to be more intuitive than clicking on the background. Fixes #179
This commit is contained in:
parent
e1c5a30a0d
commit
55034b769e
@ -297,6 +297,10 @@ pub fn setNextKeypressListener(listener: ?*const fn(c_int, c_int, c_int) void) !
|
||||
if(nextKeypressListener != null) return error.AlreadyUsed;
|
||||
nextKeypressListener = listener;
|
||||
}
|
||||
fn escape() void {
|
||||
if(game.world == null) return;
|
||||
Window.setMouseGrabbed(!Window.grabbed);
|
||||
}
|
||||
fn ungrabMouse() void {
|
||||
Window.setMouseGrabbed(false);
|
||||
}
|
||||
@ -359,7 +363,7 @@ pub const KeyBoard = struct {
|
||||
Key{.name = "takeBackgroundImage", .key = c.GLFW_KEY_PRINT_SCREEN, .releaseAction = &takeBackgroundImageFn},
|
||||
|
||||
// Gui:
|
||||
Key{.name = "escape", .key = c.GLFW_KEY_ESCAPE, .releaseAction = &ungrabMouse},
|
||||
Key{.name = "escape", .key = c.GLFW_KEY_ESCAPE, .releaseAction = &escape},
|
||||
Key{.name = "openInventory", .key = c.GLFW_KEY_I, .releaseAction = &openInventory},
|
||||
Key{.name = "openWorkbench", .key = c.GLFW_KEY_K, .releaseAction = &openWorkbench}, // TODO: Remove
|
||||
Key{.name = "openCreativeInventory(aka cheat inventory)", .key = c.GLFW_KEY_C, .releaseAction = &openCreativeInventory},
|
||||
|
Loading…
x
Reference in New Issue
Block a user