Move Fallback->GMST to Lua
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
#include <components/esm3/loadsoun.hpp>
|
||||
#include <components/esm3/loadspel.hpp>
|
||||
#include <components/esm3/loadstat.hpp>
|
||||
#include <components/fallback/fallback.hpp>
|
||||
#include <components/lua/util.hpp>
|
||||
|
||||
#include "context.hpp"
|
||||
@@ -153,6 +154,16 @@ namespace MWLua
|
||||
});
|
||||
sol::table api(lua, sol::create);
|
||||
api["records"] = MutableStore<ESM::GameSetting>{ store };
|
||||
api["getFallbacks"] = [](sol::this_state state) {
|
||||
sol::table out(state, sol::create);
|
||||
for (auto& [key, value] : Fallback::Map::getIntFallbackMap())
|
||||
out[key] = sol::make_object(state, value);
|
||||
for (auto& [key, value] : Fallback::Map::getFloatFallbackMap())
|
||||
out[key] = sol::make_object(state, value);
|
||||
for (auto& [key, value] : Fallback::Map::getNonNumericFallbackMap())
|
||||
out[key] = sol::make_object(state, value);
|
||||
return out;
|
||||
};
|
||||
return LuaUtil::makeReadOnly(api);
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
#include <components/esm3/esmreader.hpp>
|
||||
#include <components/esm3/esmwriter.hpp>
|
||||
|
||||
#include <components/fallback/fallback.hpp>
|
||||
#include <components/loadinglistener/loadinglistener.hpp>
|
||||
#include <components/misc/rng.hpp>
|
||||
|
||||
@@ -952,27 +951,6 @@ namespace MWWorld
|
||||
return TypedDynamicStore::search(ESM::RefId::stringRefId(id));
|
||||
}
|
||||
|
||||
void Store<ESM::GameSetting>::setUp()
|
||||
{
|
||||
auto addSetting = [&](const std::string& key, ESM::Variant value) {
|
||||
auto id = ESM::RefId::stringRefId(key);
|
||||
ESM::GameSetting setting;
|
||||
setting.blank();
|
||||
setting.mId = id;
|
||||
setting.mValue = std::move(value);
|
||||
auto [iter, inserted] = mStatic.insert_or_assign(id, std::move(setting));
|
||||
if (inserted)
|
||||
mShared.push_back(&iter->second);
|
||||
};
|
||||
for (auto& [key, value] : Fallback::Map::getIntFallbackMap())
|
||||
addSetting(key, ESM::Variant(value));
|
||||
for (auto& [key, value] : Fallback::Map::getFloatFallbackMap())
|
||||
addSetting(key, ESM::Variant(value));
|
||||
for (auto& [key, value] : Fallback::Map::getNonNumericFallbackMap())
|
||||
addSetting(key, ESM::Variant(value));
|
||||
TypedDynamicStore<ESM::GameSetting>::setUp();
|
||||
}
|
||||
|
||||
// Attribute
|
||||
//=========================================================================
|
||||
|
||||
|
||||
@@ -278,8 +278,6 @@ namespace MWWorld
|
||||
|
||||
const ESM::GameSetting* find(const std::string_view id) const;
|
||||
const ESM::GameSetting* search(const std::string_view id) const;
|
||||
|
||||
void setUp() override;
|
||||
};
|
||||
|
||||
template <>
|
||||
|
||||
@@ -65,6 +65,10 @@ local function generateDefaultGMSTs()
|
||||
store[id] = value
|
||||
end
|
||||
end
|
||||
local fallbacks = content.gameSettings.getFallbacks()
|
||||
for id, value in pairs(fallbacks) do
|
||||
store[id] = value
|
||||
end
|
||||
end
|
||||
|
||||
local function generateDefaultDoors()
|
||||
|
||||
@@ -43,6 +43,11 @@
|
||||
--- @{#GMSTContent}: GMST manipulation.
|
||||
-- @field [parent=#content] #GMSTContent gameSettings
|
||||
|
||||
---
|
||||
-- Returns a table containing all fallback values defined in `openmw.cfg`.
|
||||
-- @function [parent=#GMSTContent] getFallbacks
|
||||
-- @return #table
|
||||
|
||||
---
|
||||
-- A mutable list of all game settings.
|
||||
-- @field [parent=#GMSTContent] #map<#string, #any> records
|
||||
|
||||
Reference in New Issue
Block a user