mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-12 22:41:49 +00:00
move 'key:escape' handler to Lua
This commit is contained in:
parent
2adfbdb192
commit
a45487b3c7
2 changed files with 9 additions and 11 deletions
|
|
@ -385,6 +385,15 @@ function __vc_on_hud_open()
|
||||||
hud.show_overlay("core:console", false, {"chat"})
|
hud.show_overlay("core:console", false, {"chat"})
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
input.add_callback("key:escape", function()
|
||||||
|
if hud.is_paused() then
|
||||||
|
hud.resume()
|
||||||
|
elseif hud.is_inventory_open() then
|
||||||
|
hud.close_inventory()
|
||||||
|
else
|
||||||
|
hud.pause()
|
||||||
|
end
|
||||||
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
local RULES_FILE = "world:rules.toml"
|
local RULES_FILE = "world:rules.toml"
|
||||||
|
|
|
||||||
|
|
@ -201,17 +201,6 @@ Hud::Hud(Engine& engine, LevelFrontend& frontend, Player& player)
|
||||||
"' pos='0' size='256' gravity='top-right' margin='0,20,0,0'/>"
|
"' pos='0' size='256' gravity='top-right' margin='0,20,0,0'/>"
|
||||||
);
|
);
|
||||||
add(HudElement(hud_element_mode::permanent, nullptr, debugMinimap, true));
|
add(HudElement(hud_element_mode::permanent, nullptr, debugMinimap, true));
|
||||||
|
|
||||||
keepAlive(Events::keyCallbacks[keycode::ESCAPE].add([this]() -> bool {
|
|
||||||
if (pause) {
|
|
||||||
setPause(false);
|
|
||||||
} else if (inventoryOpen) {
|
|
||||||
closeInventory();
|
|
||||||
} else {
|
|
||||||
setPause(true);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Hud::~Hud() {
|
Hud::~Hud() {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue