move 'devtools:console' binding handler to __vc_on_hud_open
This commit is contained in:
parent
e842b217da
commit
f4f479d389
@ -269,7 +269,7 @@ function _rules.clear()
|
||||
_rules.create("allow-cheats", true)
|
||||
end
|
||||
|
||||
function __vc_create_hud_rules()
|
||||
function __vc_on_hud_open()
|
||||
_rules.create("allow-content-access", hud._is_content_access(), function(value)
|
||||
hud._set_content_access(value)
|
||||
input.set_enabled("player.pick", value)
|
||||
@ -295,6 +295,14 @@ function __vc_create_hud_rules()
|
||||
_rules.create("allow-debug-cheats", true, function(value)
|
||||
hud._set_debug_cheats(value)
|
||||
end)
|
||||
input.add_callback("devtools.console", function()
|
||||
if hud.is_paused() then
|
||||
return
|
||||
end
|
||||
time.post_runnable(function()
|
||||
hud.show_overlay("core:console", false, {"console"})
|
||||
end)
|
||||
end)
|
||||
end
|
||||
|
||||
local RULES_FILE = "world:rules.toml"
|
||||
|
||||
@ -10,7 +10,6 @@ inline const std::string CORE_STRUCT_AIR = "core:struct_air";
|
||||
inline const std::string TEXTURE_NOTFOUND = "notfound";
|
||||
|
||||
// built-in bindings
|
||||
inline const std::string BIND_DEVTOOLS_CONSOLE = "devtools.console";
|
||||
inline const std::string BIND_CHUNKS_RELOAD = "chunks.reload";
|
||||
inline const std::string BIND_MOVE_FORWARD = "movement.forward";
|
||||
inline const std::string BIND_MOVE_BACK = "movement.back";
|
||||
|
||||
@ -229,17 +229,9 @@ void Hud::processInput(bool visible) {
|
||||
setPause(true);
|
||||
}
|
||||
}
|
||||
if (!pause && Events::jactive(BIND_DEVTOOLS_CONSOLE)) {
|
||||
showOverlay(
|
||||
assets->get<UiDocument>("core:console"),
|
||||
false,
|
||||
dv::list({std::string("console")})
|
||||
);
|
||||
}
|
||||
if (!Window::isFocused() && !pause && !isInventoryOpen()) {
|
||||
setPause(true);
|
||||
}
|
||||
|
||||
if (!pause && visible && Events::jactive(BIND_HUD_INVENTORY)) {
|
||||
if (inventoryOpen) {
|
||||
closeInventory();
|
||||
|
||||
@ -37,7 +37,7 @@ void scripting::on_frontend_init(Hud* hud, WorldRenderer* renderer) {
|
||||
|
||||
load_script("hud_classes.lua");
|
||||
|
||||
if (lua::getglobal(L, "__vc_create_hud_rules")) {
|
||||
if (lua::getglobal(L, "__vc_on_hud_open")) {
|
||||
lua::call_nothrow(L, 0, 0);
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user