From 07ff2a5c016bd0fbfed1ac7b3172a872eab1317e Mon Sep 17 00:00:00 2001 From: grorp Date: Wed, 9 Oct 2024 15:08:15 +0200 Subject: [PATCH] ContentDB dialog: React to window info changes immediately (#15248) --- builtin/mainmenu/content/dlg_contentdb.lua | 5 +++++ builtin/mainmenu/content/dlg_package.lua | 13 ++++++++++++- src/gui/guiEngine.cpp | 7 +++++++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/builtin/mainmenu/content/dlg_contentdb.lua b/builtin/mainmenu/content/dlg_contentdb.lua index a86815b77..8f232e490 100644 --- a/builtin/mainmenu/content/dlg_contentdb.lua +++ b/builtin/mainmenu/content/dlg_contentdb.lua @@ -496,6 +496,11 @@ local function handle_events(event) return true end + if event == "WindowInfoChange" then + ui.update() + return true + end + return false end diff --git a/builtin/mainmenu/content/dlg_package.lua b/builtin/mainmenu/content/dlg_package.lua index 5b9db4860..404e950c4 100644 --- a/builtin/mainmenu/content/dlg_package.lua +++ b/builtin/mainmenu/content/dlg_package.lua @@ -305,12 +305,23 @@ local function handle_submit(this, fields) end +local function handle_events(event) + if event == "WindowInfoChange" then + ui.update() + return true + end + + return false +end + + function create_package_dialog(package) assert(package) local dlg = dialog_create("package_dialog_" .. package.id, get_formspec, - handle_submit) + handle_submit, + handle_events) local data = dlg.data data.package = package diff --git a/src/gui/guiEngine.cpp b/src/gui/guiEngine.cpp index 4a3d53f51..8a4e22b1d 100644 --- a/src/gui/guiEngine.cpp +++ b/src/gui/guiEngine.cpp @@ -24,6 +24,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "client/renderingengine.h" #include "client/shader.h" #include "client/tile.h" +#include "clientdynamicinfo.h" #include "config.h" #include "content/content.h" #include "content/mods.h" @@ -316,6 +317,7 @@ void GUIEngine::run() ); const bool initial_window_maximized = !g_settings->getBool("fullscreen") && g_settings->getBool("window_maximized"); + auto last_window_info = ClientDynamicInfo::getCurrent(); FpsControl fps_control; f32 dtime = 0.0f; @@ -335,6 +337,11 @@ void GUIEngine::run() updateTopLeftTextSize(); text_height = g_fontengine->getTextHeight(); } + auto window_info = ClientDynamicInfo::getCurrent(); + if (!window_info.equal(last_window_info)) { + m_script->handleMainMenuEvent("WindowInfoChange"); + last_window_info = window_info; + } driver->beginScene(true, true, RenderingEngine::MENU_SKY_COLOR);