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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user