Merge branch 'settings_values_general' into 'master'

Use settings values for General settings (#6876)

See merge request OpenMW/openmw!3198
revert-6246b479
psi29a 2 years ago
commit cab47d0a2a

@ -645,9 +645,8 @@ void OMW::Engine::prepareEngine()
mResourceSystem->getSceneManager()->getShaderManager().setMaxTextureUnits(mGlMaxTextureImageUnits);
mResourceSystem->getSceneManager()->setUnRefImageDataAfterApply(
false); // keep to Off for now to allow better state sharing
mResourceSystem->getSceneManager()->setFilterSettings(Settings::Manager::getString("texture mag filter", "General"),
Settings::Manager::getString("texture min filter", "General"),
Settings::Manager::getString("texture mipmap", "General"), Settings::Manager::getInt("anisotropy", "General"));
mResourceSystem->getSceneManager()->setFilterSettings(Settings::general().mTextureMagFilter,
Settings::general().mTextureMinFilter, Settings::general().mTextureMipmap, Settings::general().mAnisotropy);
mEnvironment.setResourceSystem(*mResourceSystem);
mWorkQueue = new SceneUtil::WorkQueue(Settings::cells().mPreloadNumThreads);
@ -655,8 +654,8 @@ void OMW::Engine::prepareEngine()
mScreenCaptureOperation = new SceneUtil::AsyncScreenCaptureOperation(mWorkQueue,
new SceneUtil::WriteScreenshotToFileOperation(mCfgMgr.getScreenshotPath(),
Settings::Manager::getString("screenshot format", "General"),
Settings::Manager::getBool("notify on saved screenshot", "General")
Settings::general().mScreenshotFormat,
Settings::general().mNotifyOnSavedScreenshot
? std::function<void(std::string)>(ScheduleNonDialogMessageBox{})
: std::function<void(std::string)>(IgnoreString{})));
@ -665,8 +664,7 @@ void OMW::Engine::prepareEngine()
mViewer->addEventHandler(mScreenCaptureHandler);
mL10nManager = std::make_unique<l10n::Manager>(mVFS.get());
mL10nManager->setPreferredLocales(Settings::Manager::getStringArray("preferred locales", "General"),
Settings::Manager::getBool("gmst overrides l10n", "General"));
mL10nManager->setPreferredLocales(Settings::general().mPreferredLocales, Settings::general().mGmstOverridesL10n);
mEnvironment.setL10nManager(*mL10nManager);
mLuaManager = std::make_unique<MWLua::LuaManager>(mVFS.get(), mResDir / "lua_libs");

@ -16,7 +16,7 @@
#include <components/files/conversion.hpp>
#include <components/interpreter/interpreter.hpp>
#include <components/misc/utf8stream.hpp>
#include <components/settings/settings.hpp>
#include <components/settings/values.hpp>
#include "../mwscript/extensions.hpp"
#include "../mwscript/interpretercontext.hpp"
@ -709,7 +709,7 @@ namespace MWGui
void Console::initConsoleHistory()
{
const auto filePath = mCfgMgr.getUserConfigPath() / "console_history.txt";
const size_t retrievalLimit = Settings::Manager::getSize("console history buffer size", "General");
const size_t retrievalLimit = Settings::general().mConsoleHistoryBufferSize;
// Read the previous session's commands from the file
if (retrievalLimit > 0)

@ -6,7 +6,7 @@
#include <LinearMath/btQuickprof.h>
#include <components/debug/debugging.hpp>
#include <components/settings/settings.hpp>
#include <components/settings/values.hpp>
#include "../mwbase/environment.hpp"
#include "../mwbase/luamanager.hpp"
@ -132,7 +132,7 @@ namespace MWGui
void DebugWindow::startLogRecording()
{
sLogCircularBuffer.resize(Settings::Manager::getSize("log buffer size", "General"));
sLogCircularBuffer.resize(Settings::general().mLogBufferSize);
Debug::setLogListener([](Debug::Level level, std::string_view prefix, std::string_view msg) {
if (sLogCircularBuffer.empty())
return; // Log viewer is disabled.

@ -367,7 +367,7 @@ namespace MWGui
}
highlightCurrentResolution();
const std::string& tmip = Settings::Manager::getString("texture mipmap", "General");
const std::string& tmip = Settings::general().mTextureMipmap;
mTextureFilteringButton->setCaptionWithReplacing(textureMipmappingToStr(tmip));
int waterTextureSize = Settings::Manager::getInt("rtt size", "Water");
@ -416,7 +416,7 @@ namespace MWGui
std::sort(availableLanguages.begin(), availableLanguages.end());
std::vector<std::string> currentLocales = Settings::Manager::getStringArray("preferred locales", "General");
std::vector<std::string> currentLocales = Settings::general().mPreferredLocales;
if (currentLocales.empty())
currentLocales.push_back("en");
@ -563,7 +563,7 @@ namespace MWGui
MWBase::Environment::get().getWindowManager()->interactiveMessageBox(
"#{OMWEngine:ChangeRequiresRestart}", { "#{Interface:OK}" }, true);
std::vector<std::string> currentLocales = Settings::Manager::getStringArray("preferred locales", "General");
std::vector<std::string> currentLocales = Settings::general().mPreferredLocales;
if (currentLocales.size() <= langPriority)
currentLocales.resize(langPriority + 1, "en");
@ -573,7 +573,7 @@ namespace MWGui
else
currentLocales.resize(1);
Settings::Manager::setStringArray("preferred locales", "General", currentLocales);
Settings::general().mPreferredLocales.set(currentLocales);
}
void SettingsWindow::onGmstOverridesL10nChanged(MyGUI::Widget*)
@ -681,9 +681,9 @@ namespace MWGui
void SettingsWindow::onTextureFilteringChanged(MyGUI::ComboBox* _sender, size_t pos)
{
if (pos == 0)
Settings::Manager::setString("texture mipmap", "General", "nearest");
Settings::general().mTextureMipmap.set("nearest");
else if (pos == 1)
Settings::Manager::setString("texture mipmap", "General", "linear");
Settings::general().mTextureMipmap.set("linear");
else
Log(Debug::Warning) << "Unexpected option pos " << pos;
apply();

@ -1292,11 +1292,8 @@ namespace MWRender
{
mViewer->stopThreading();
mResourceSystem->getSceneManager()->setFilterSettings(
Settings::Manager::getString("texture mag filter", "General"),
Settings::Manager::getString("texture min filter", "General"),
Settings::Manager::getString("texture mipmap", "General"),
Settings::Manager::getInt("anisotropy", "General"));
mResourceSystem->getSceneManager()->setFilterSettings(Settings::general().mTextureMagFilter,
Settings::general().mTextureMinFilter, Settings::general().mTextureMipmap, Settings::general().mAnisotropy);
mTerrain->updateTextureFiltering();
mWater->processChangedSettings({});

@ -28,7 +28,7 @@ namespace Settings
SettingValue<std::string> mTextureMipmap{ mIndex, "General", "texture mipmap",
makeEnumSanitizerString({ "none", "nearest", "linear" }) };
SettingValue<bool> mNotifyOnSavedScreenshot{ mIndex, "General", "notify on saved screenshot" };
SettingValue<std::string> mPreferredLocales{ mIndex, "General", "preferred locales" };
SettingValue<std::vector<std::string>> mPreferredLocales{ mIndex, "General", "preferred locales" };
SettingValue<bool> mGmstOverridesL10n{ mIndex, "General", "gmst overrides l10n" };
SettingValue<std::size_t> mLogBufferSize{ mIndex, "General", "log buffer size" };
SettingValue<std::size_t> mConsoleHistoryBufferSize{ mIndex, "General", "console history buffer size" };

@ -449,6 +449,11 @@ namespace Settings
setInt(setting, category, static_cast<int>(value));
}
void Manager::set(std::string_view setting, std::string_view category, const std::vector<std::string>& value)
{
setStringArray(setting, category, value);
}
void Manager::recordInit(std::string_view setting, std::string_view category)
{
sInitialized.emplace(category, setting);

@ -104,12 +104,13 @@ namespace Settings
static void set(std::string_view setting, std::string_view category, const osg::Vec2f& value);
static void set(std::string_view setting, std::string_view category, const osg::Vec3f& value);
static void set(std::string_view setting, std::string_view category, DetourNavigator::CollisionShapeType value);
static void set(std::string_view setting, std::string_view category, const std::vector<std::string>& value);
private:
static std::set<std::pair<std::string_view, std::string_view>> sInitialized;
template <class T>
static T getImpl(std::string_view setting, std::string_view category);
static T getImpl(std::string_view setting, std::string_view category) = delete;
static void recordInit(std::string_view setting, std::string_view category);
};
@ -180,6 +181,13 @@ namespace Settings
{
return DetourNavigator::toCollisionShapeType(getInt(setting, category));
}
template <>
inline std::vector<std::string> Manager::getImpl<std::vector<std::string>>(
std::string_view setting, std::string_view category)
{
return getStringArray(setting, category);
}
}
#endif // COMPONENTS_SETTINGS_H

@ -15,6 +15,7 @@
#include <string>
#include <string_view>
#include <utility>
#include <vector>
namespace Settings
{
@ -33,6 +34,7 @@ namespace Settings
Vec2f,
Vec3f,
CollisionShapeType,
StringArray,
};
template <class T>
@ -116,6 +118,12 @@ namespace Settings
return SettingValueType::CollisionShapeType;
}
template <>
inline constexpr SettingValueType getSettingValueType<std::vector<std::string>>()
{
return SettingValueType::StringArray;
}
inline constexpr std::string_view getSettingValueTypeName(SettingValueType type)
{
switch (type)
@ -146,6 +154,8 @@ namespace Settings
return "vec3f";
case SettingValueType::CollisionShapeType:
return "collision shape type";
case SettingValueType::StringArray:
return "string array";
}
return "unsupported";
}
@ -292,6 +302,18 @@ namespace Settings
{
if constexpr (std::is_enum_v<T>)
return stream << static_cast<std::underlying_type_t<T>>(value.mValue);
else if constexpr (std::is_same_v<T, std::vector<std::string>>)
{
bool first = true;
for (const std::string& v : value.mValue)
{
if (std::exchange(first, false))
stream << v;
else
stream << "," << v;
}
return stream;
}
else
return stream << value.mValue;
}

Loading…
Cancel
Save