From 92f226cbcf7dda264fcf3472288b772d4d686559 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Mon, 20 Jan 2025 04:39:37 +0300 Subject: [PATCH] miscellaneous fixes --- res/layouts/ingame_chat.xml.lua | 4 +++- res/modules/internal/gui_util.lua | 2 +- res/modules/internal/stdcomp.lua | 3 +++ res/scripts/stdlib.lua | 7 ++++--- src/frontend/screens/LevelScreen.cpp | 4 +++- 5 files changed, 14 insertions(+), 6 deletions(-) diff --git a/res/layouts/ingame_chat.xml.lua b/res/layouts/ingame_chat.xml.lua index 52f38ce72..ec4e12b09 100644 --- a/res/layouts/ingame_chat.xml.lua +++ b/res/layouts/ingame_chat.xml.lua @@ -9,7 +9,9 @@ local animation_fps = 30 local function remove_line(line) document[line[1]]:destruct() - time.post_runnable(function() document.root:reposition() end) + time.post_runnable(function() + if world.is_open() then document.root:reposition() end + end) end local function update_line(line, uptime) diff --git a/res/modules/internal/gui_util.lua b/res/modules/internal/gui_util.lua index 3cf84a33b..294a7c79e 100644 --- a/res/modules/internal/gui_util.lua +++ b/res/modules/internal/gui_util.lua @@ -47,7 +47,7 @@ function gui_util.add_page_dispatcher(dispatcher) table.insert(gui_util.local_dispatchers, dispatcher) end -function gui_util.reset_local() +function gui_util.__reset_local() gui_util.local_dispatchers = {} end diff --git a/res/modules/internal/stdcomp.lua b/res/modules/internal/stdcomp.lua index 9e208038a..bdb2468fc 100644 --- a/res/modules/internal/stdcomp.lua +++ b/res/modules/internal/stdcomp.lua @@ -132,5 +132,8 @@ return { end return values end + end, + __reset = function() + entities = {} end } diff --git a/res/scripts/stdlib.lua b/res/scripts/stdlib.lua index 78228254c..9ee20241d 100644 --- a/res/scripts/stdlib.lua +++ b/res/scripts/stdlib.lua @@ -343,8 +343,8 @@ function __vc_on_hud_open() end) end) input.add_callback("key:escape", function() - if hud.is_paused() then - hud.resume() + if menu.page ~= "" then + menu:reset() elseif hud.is_inventory_open() then hud.close_inventory() else @@ -375,7 +375,8 @@ end function __vc_on_world_quit() _rules.clear() - gui_util:reset_local() + gui_util:__reset_local() + stdcomp.__reset() end local __vc_coroutines = {} diff --git a/src/frontend/screens/LevelScreen.cpp b/src/frontend/screens/LevelScreen.cpp index 0dce2bc03..0e9eb6095 100644 --- a/src/frontend/screens/LevelScreen.cpp +++ b/src/frontend/screens/LevelScreen.cpp @@ -117,7 +117,9 @@ void LevelScreen::initializePack(ContentPackRuntime* pack) { } LevelScreen::~LevelScreen() { - saveWorldPreview(); + if (!controller->getLevel()->getWorld()->isNameless()) { + saveWorldPreview(); + } scripting::on_frontend_close(); // unblock all bindings Events::enableBindings();