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

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

34 lines
881 B
C++
Raw Normal View History

2021-11-18 15:19:54 +00:00
#include "content.hpp"
namespace LuaUi::Content
2021-11-18 15:19:54 +00:00
{
namespace
2021-11-18 15:19:54 +00:00
{
sol::table loadMetatable(sol::state_view sol)
2021-11-18 15:19:54 +00:00
{
std::string scriptBody =
#include "content.lua"
;
auto result = sol.safe_script(scriptBody);
if (result.get_type() != sol::type::table)
throw std::logic_error("Expected a meta table");
return result.get<sol::table>();
2021-11-18 15:19:54 +00:00
}
}
sol::protected_function makeFactory(sol::state_view sol)
2021-11-18 15:19:54 +00:00
{
sol::table metatable = loadMetatable(sol);
if (metatable["new"].get_type() != sol::type::function)
throw std::logic_error("Expected function");
return metatable["new"].get<sol::protected_function>();
2021-11-18 15:19:54 +00:00
}
int64_t View::sInstanceCount = 0;
2021-11-18 15:19:54 +00:00
int64_t getInstanceCount()
2021-11-18 15:19:54 +00:00
{
return View::sInstanceCount;
2021-11-18 15:19:54 +00:00
}
}