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-12 23:47:08 +00:00
|
|
|
static std::shared_ptr<Element> make(sol::table layout, bool menu);
|
|
|
|
static void erase(Element* element);
|
2021-11-18 15:19:54 +00:00
|
|
|
|
2022-05-03 17:36:49 +00:00
|
|
|
template <class Callback>
|
2024-01-12 23:47:08 +00:00
|
|
|
static void forEach(bool menu, Callback callback)
|
2022-05-03 17:36:49 +00:00
|
|
|
{
|
2024-01-12 23:47:08 +00:00
|
|
|
auto& container = menu ? sMenuElements : sGameElements;
|
|
|
|
for (auto& [_, element] : container)
|
|
|
|
callback(element.get());
|
2022-05-03 17:36:49 +00:00
|
|
|
}
|
|
|
|
|
2022-01-28 20:35:05 +00:00
|
|
|
WidgetExtension* mRoot;
|
2023-02-26 12:51:41 +00:00
|
|
|
sol::object mLayout;
|
2022-01-28 20:35:05 +00:00
|
|
|
std::string mLayer;
|
2021-11-18 15:19:54 +00:00
|
|
|
|
2024-03-06 21:01:26 +00:00
|
|
|
enum State
|
|
|
|
{
|
|
|
|
New,
|
|
|
|
Created,
|
|
|
|
Update,
|
|
|
|
Destroy,
|
|
|
|
Destroyed,
|
|
|
|
};
|
|
|
|
State mState;
|
|
|
|
|
|
|
|
void create(uint64_t dept = 0);
|
2021-11-18 15:19:54 +00:00
|
|
|
|
|
|
|
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);
|
2023-04-25 20:11:04 +00:00
|
|
|
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
|