move 'key:escape' handler to Lua

This commit is contained in:
MihailRis 2025-01-16 23:11:00 +03:00
parent 2adfbdb192
commit a45487b3c7
2 changed files with 9 additions and 11 deletions

View File

@ -385,6 +385,15 @@ function __vc_on_hud_open()
hud.show_overlay("core:console", false, {"chat"})
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
local RULES_FILE = "world:rules.toml"

View File

@ -201,17 +201,6 @@ Hud::Hud(Engine& engine, LevelFrontend& frontend, Player& player)
"' pos='0' size='256' gravity='top-right' margin='0,20,0,0'/>"
);
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() {