From 32357cacb072daeb2fe60fcfefd8058becfc913d Mon Sep 17 00:00:00 2001 From: nox7 <36878742-nox7@users.noreply.gitlab.com> Date: Sat, 11 Jul 2026 12:18:41 -0500 Subject: [PATCH] Add foreach helper to return element pointer, which is what Lua receives from ui.create. This keeps the object returned from getElements the same across memory. --- components/lua_ui/element.hpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/components/lua_ui/element.hpp b/components/lua_ui/element.hpp index 4ac9cd97b5..b276bf9bcc 100644 --- a/components/lua_ui/element.hpp +++ b/components/lua_ui/element.hpp @@ -1,6 +1,8 @@ #ifndef OPENMW_LUAUI_ELEMENT #define OPENMW_LUAUI_ELEMENT +#include +#include #include #include "widget.hpp" @@ -20,6 +22,14 @@ namespace LuaUi callback(element.get()); } + template + static void forEachShared(bool menu, Callback callback) + { + auto& container = menu ? sMenuElements : sGameElements; + for (auto& [_, element] : container) + callback(element); + } + static const std::vector& allLayoutProperties(); WidgetExtension* mRoot;