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.

This commit is contained in:
nox7
2026-07-11 12:18:41 -05:00
parent 8d2a3c792e
commit 32357cacb0
+10
View File
@@ -1,6 +1,8 @@
#ifndef OPENMW_LUAUI_ELEMENT
#define OPENMW_LUAUI_ELEMENT
#include <map>
#include <memory>
#include <vector>
#include "widget.hpp"
@@ -20,6 +22,14 @@ namespace LuaUi
callback(element.get());
}
template <class Callback>
static void forEachShared(bool menu, Callback callback)
{
auto& container = menu ? sMenuElements : sGameElements;
for (auto& [_, element] : container)
callback(element);
}
static const std::vector<std::string_view>& allLayoutProperties();
WidgetExtension* mRoot;