|
|
@ -1,5 +1,6 @@
|
|
|
|
#include "uibindings.hpp"
|
|
|
|
#include "uibindings.hpp"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include <components/lua/util.hpp>
|
|
|
|
#include <components/lua_ui/alignment.hpp>
|
|
|
|
#include <components/lua_ui/alignment.hpp>
|
|
|
|
#include <components/lua_ui/content.hpp>
|
|
|
|
#include <components/lua_ui/content.hpp>
|
|
|
|
#include <components/lua_ui/element.hpp>
|
|
|
|
#include <components/lua_ui/element.hpp>
|
|
|
@ -36,16 +37,6 @@ namespace MWLua
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Lua arrays index from 1
|
|
|
|
|
|
|
|
inline size_t fromLuaIndex(size_t i)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return i - 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
inline size_t toLuaIndex(size_t i)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return i + 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const std::unordered_map<MWGui::GuiMode, std::string_view> modeToName{
|
|
|
|
const std::unordered_map<MWGui::GuiMode, std::string_view> modeToName{
|
|
|
|
{ MWGui::GM_Inventory, "Interface" },
|
|
|
|
{ MWGui::GM_Inventory, "Interface" },
|
|
|
|
{ MWGui::GM_Container, "Container" },
|
|
|
|
{ MWGui::GM_Container, "Container" },
|
|
|
@ -149,7 +140,7 @@ namespace MWLua
|
|
|
|
if (index == LuaUi::Layer::count())
|
|
|
|
if (index == LuaUi::Layer::count())
|
|
|
|
return sol::nullopt;
|
|
|
|
return sol::nullopt;
|
|
|
|
else
|
|
|
|
else
|
|
|
|
return toLuaIndex(index);
|
|
|
|
return LuaUtil::toLuaIndex(index);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
layersTable["insertAfter"] = [context](
|
|
|
|
layersTable["insertAfter"] = [context](
|
|
|
|
std::string_view afterName, std::string_view name, const sol::object& opt) {
|
|
|
|
std::string_view afterName, std::string_view name, const sol::object& opt) {
|
|
|
@ -175,7 +166,7 @@ namespace MWLua
|
|
|
|
layersMeta[sol::meta_function::length] = []() { return LuaUi::Layer::count(); };
|
|
|
|
layersMeta[sol::meta_function::length] = []() { return LuaUi::Layer::count(); };
|
|
|
|
layersMeta[sol::meta_function::index] = sol::overload(
|
|
|
|
layersMeta[sol::meta_function::index] = sol::overload(
|
|
|
|
[](const sol::object& self, size_t index) {
|
|
|
|
[](const sol::object& self, size_t index) {
|
|
|
|
index = fromLuaIndex(index);
|
|
|
|
index = LuaUtil::fromLuaIndex(index);
|
|
|
|
return LuaUi::Layer(index);
|
|
|
|
return LuaUi::Layer(index);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
[layersTable](
|
|
|
|
[layersTable](
|
|
|
@ -242,7 +233,7 @@ namespace MWLua
|
|
|
|
= [windowManager, luaManager = context.mLuaManager](sol::table modes, sol::optional<LObject> arg) {
|
|
|
|
= [windowManager, luaManager = context.mLuaManager](sol::table modes, sol::optional<LObject> arg) {
|
|
|
|
std::vector<MWGui::GuiMode> newStack(modes.size());
|
|
|
|
std::vector<MWGui::GuiMode> newStack(modes.size());
|
|
|
|
for (unsigned i = 0; i < newStack.size(); ++i)
|
|
|
|
for (unsigned i = 0; i < newStack.size(); ++i)
|
|
|
|
newStack[i] = nameToMode.at(LuaUtil::cast<std::string_view>(modes[i + 1]));
|
|
|
|
newStack[i] = nameToMode.at(LuaUtil::cast<std::string_view>(modes[LuaUtil::toLuaIndex(i)]));
|
|
|
|
luaManager->addAction(
|
|
|
|
luaManager->addAction(
|
|
|
|
[windowManager, newStack = std::move(newStack), arg = std::move(arg)]() {
|
|
|
|
[windowManager, newStack = std::move(newStack), arg = std::move(arg)]() {
|
|
|
|
MWWorld::Ptr ptr;
|
|
|
|
MWWorld::Ptr ptr;
|
|
|
|