1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-05 15:55:45 +00:00
OpenMW/components/lua_ui/element.hpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

51 lines
1.2 KiB
C++
Raw Normal View History

2021-11-18 15:19:54 +00:00
#ifndef OPENMW_LUAUI_ELEMENT
#define OPENMW_LUAUI_ELEMENT
#include "widget.hpp"
namespace LuaUi
{
struct Element
{
2024-01-07 22:29:20 +00:00
static std::shared_ptr<Element> makeGameElement(sol::table layout);
static std::shared_ptr<Element> makeMenuElement(sol::table layout);
2021-11-18 15:19:54 +00:00
template <class Callback>
2024-01-07 22:29:20 +00:00
static void forEachGameElement(Callback callback)
{
2024-01-07 22:29:20 +00:00
for (auto& [e, _] : sGameElements)
callback(e);
}
template <class Callback>
static void forEachMenuElement(Callback callback)
{
for (auto& [e, _] : sMenuElements)
callback(e);
}
WidgetExtension* mRoot;
2023-02-26 12:51:41 +00:00
sol::object mLayout;
std::string mLayer;
2021-11-18 15:19:54 +00:00
bool mUpdate;
bool mDestroy;
void create();
void update();
void destroy();
2022-01-18 08:12:56 +00:00
2024-01-07 22:29:20 +00:00
friend void clearGameInterface();
friend void clearMenuInterface();
2022-01-18 08:12:56 +00:00
private:
Element(sol::table layout);
sol::table layout() { return LuaUtil::cast<sol::table>(mLayout); }
2024-01-07 22:29:20 +00:00
static std::map<Element*, std::shared_ptr<Element>> sGameElements;
static std::map<Element*, std::shared_ptr<Element>> sMenuElements;
2021-11-18 15:19:54 +00:00
};
}
#endif // !OPENMW_LUAUI_ELEMENT