mirror of
https://github.com/OpenMW/openmw.git
synced 2025-06-01 06:41:32 +00:00
Merge branch 'layer_desync' into 'master'
Prevent conflicts between UI layer insertions See merge request OpenMW/openmw!4696
This commit is contained in:
commit
b0d389319c
2 changed files with 19 additions and 14 deletions
|
@ -82,7 +82,7 @@ message(STATUS "Configuring OpenMW...")
|
|||
set(OPENMW_VERSION_MAJOR 0)
|
||||
set(OPENMW_VERSION_MINOR 49)
|
||||
set(OPENMW_VERSION_RELEASE 0)
|
||||
set(OPENMW_LUA_API_REVISION 74)
|
||||
set(OPENMW_LUA_API_REVISION 75)
|
||||
set(OPENMW_POSTPROCESSING_API_REVISION 2)
|
||||
|
||||
set(OPENMW_VERSION_COMMITHASH "")
|
||||
|
|
|
@ -160,26 +160,31 @@ namespace MWLua
|
|||
else
|
||||
return LuaUtil::toLuaIndex(index);
|
||||
};
|
||||
layersTable["insertAfter"] = [context](
|
||||
std::string_view afterName, std::string_view name, const sol::object& opt) {
|
||||
layersTable["insertAfter"] = [context](std::string afterName, std::string_view name, const sol::object& opt) {
|
||||
LuaUi::Layer::Options options;
|
||||
options.mInteractive = LuaUtil::getValueOrDefault(LuaUtil::getFieldOrNil(opt, "interactive"), true);
|
||||
size_t index = LuaUi::Layer::indexOf(afterName);
|
||||
if (index == LuaUi::Layer::count())
|
||||
throw std::logic_error(std::string("Layer not found"));
|
||||
index++;
|
||||
context.mLuaManager->addAction(
|
||||
[=, name = std::string(name)]() { LuaUi::Layer::insert(index, name, options); }, "Insert UI layer");
|
||||
[=]() {
|
||||
size_t index = LuaUi::Layer::indexOf(afterName);
|
||||
if (index == LuaUi::Layer::count())
|
||||
throw std::logic_error(
|
||||
Misc::StringUtils::format("Couldn't insert after non-existent layer %s", afterName));
|
||||
LuaUi::Layer::insert(index + 1, name, options);
|
||||
},
|
||||
"Insert after UI layer");
|
||||
};
|
||||
layersTable["insertBefore"] = [context](
|
||||
std::string_view beforename, std::string_view name, const sol::object& opt) {
|
||||
layersTable["insertBefore"] = [context](std::string beforeName, std::string_view name, const sol::object& opt) {
|
||||
LuaUi::Layer::Options options;
|
||||
options.mInteractive = LuaUtil::getValueOrDefault(LuaUtil::getFieldOrNil(opt, "interactive"), true);
|
||||
size_t index = LuaUi::Layer::indexOf(beforename);
|
||||
if (index == LuaUi::Layer::count())
|
||||
throw std::logic_error(std::string("Layer not found"));
|
||||
context.mLuaManager->addAction(
|
||||
[=, name = std::string(name)]() { LuaUi::Layer::insert(index, name, options); }, "Insert UI layer");
|
||||
[=]() {
|
||||
size_t index = LuaUi::Layer::indexOf(beforeName);
|
||||
if (index == LuaUi::Layer::count())
|
||||
throw std::logic_error(
|
||||
Misc::StringUtils::format("Couldn't insert before non-existent layer %s", beforeName));
|
||||
LuaUi::Layer::insert(index, name, options);
|
||||
},
|
||||
"Insert before UI layer");
|
||||
};
|
||||
sol::table layers = LuaUtil::makeReadOnly(layersTable);
|
||||
sol::table layersMeta = layers[sol::metatable_key];
|
||||
|
|
Loading…
Reference in a new issue