mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-16 09:29:55 +00:00
Use settings values for General settings
This commit is contained in:
parent
1d73780621
commit
ebb8fdc698
9 changed files with 54 additions and 24 deletions
|
@ -645,9 +645,8 @@ void OMW::Engine::prepareEngine()
|
||||||
mResourceSystem->getSceneManager()->getShaderManager().setMaxTextureUnits(mGlMaxTextureImageUnits);
|
mResourceSystem->getSceneManager()->getShaderManager().setMaxTextureUnits(mGlMaxTextureImageUnits);
|
||||||
mResourceSystem->getSceneManager()->setUnRefImageDataAfterApply(
|
mResourceSystem->getSceneManager()->setUnRefImageDataAfterApply(
|
||||||
false); // keep to Off for now to allow better state sharing
|
false); // keep to Off for now to allow better state sharing
|
||||||
mResourceSystem->getSceneManager()->setFilterSettings(Settings::Manager::getString("texture mag filter", "General"),
|
mResourceSystem->getSceneManager()->setFilterSettings(Settings::general().mTextureMagFilter,
|
||||||
Settings::Manager::getString("texture min filter", "General"),
|
Settings::general().mTextureMinFilter, Settings::general().mTextureMipmap, Settings::general().mAnisotropy);
|
||||||
Settings::Manager::getString("texture mipmap", "General"), Settings::Manager::getInt("anisotropy", "General"));
|
|
||||||
mEnvironment.setResourceSystem(*mResourceSystem);
|
mEnvironment.setResourceSystem(*mResourceSystem);
|
||||||
|
|
||||||
mWorkQueue = new SceneUtil::WorkQueue(Settings::cells().mPreloadNumThreads);
|
mWorkQueue = new SceneUtil::WorkQueue(Settings::cells().mPreloadNumThreads);
|
||||||
|
@ -655,8 +654,8 @@ void OMW::Engine::prepareEngine()
|
||||||
|
|
||||||
mScreenCaptureOperation = new SceneUtil::AsyncScreenCaptureOperation(mWorkQueue,
|
mScreenCaptureOperation = new SceneUtil::AsyncScreenCaptureOperation(mWorkQueue,
|
||||||
new SceneUtil::WriteScreenshotToFileOperation(mCfgMgr.getScreenshotPath(),
|
new SceneUtil::WriteScreenshotToFileOperation(mCfgMgr.getScreenshotPath(),
|
||||||
Settings::Manager::getString("screenshot format", "General"),
|
Settings::general().mScreenshotFormat,
|
||||||
Settings::Manager::getBool("notify on saved screenshot", "General")
|
Settings::general().mNotifyOnSavedScreenshot
|
||||||
? std::function<void(std::string)>(ScheduleNonDialogMessageBox{})
|
? std::function<void(std::string)>(ScheduleNonDialogMessageBox{})
|
||||||
: std::function<void(std::string)>(IgnoreString{})));
|
: std::function<void(std::string)>(IgnoreString{})));
|
||||||
|
|
||||||
|
@ -665,8 +664,7 @@ void OMW::Engine::prepareEngine()
|
||||||
mViewer->addEventHandler(mScreenCaptureHandler);
|
mViewer->addEventHandler(mScreenCaptureHandler);
|
||||||
|
|
||||||
mL10nManager = std::make_unique<l10n::Manager>(mVFS.get());
|
mL10nManager = std::make_unique<l10n::Manager>(mVFS.get());
|
||||||
mL10nManager->setPreferredLocales(Settings::Manager::getStringArray("preferred locales", "General"),
|
mL10nManager->setPreferredLocales(Settings::general().mPreferredLocales, Settings::general().mGmstOverridesL10n);
|
||||||
Settings::Manager::getBool("gmst overrides l10n", "General"));
|
|
||||||
mEnvironment.setL10nManager(*mL10nManager);
|
mEnvironment.setL10nManager(*mL10nManager);
|
||||||
|
|
||||||
mLuaManager = std::make_unique<MWLua::LuaManager>(mVFS.get(), mResDir / "lua_libs");
|
mLuaManager = std::make_unique<MWLua::LuaManager>(mVFS.get(), mResDir / "lua_libs");
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
#include <components/files/conversion.hpp>
|
#include <components/files/conversion.hpp>
|
||||||
#include <components/interpreter/interpreter.hpp>
|
#include <components/interpreter/interpreter.hpp>
|
||||||
#include <components/misc/utf8stream.hpp>
|
#include <components/misc/utf8stream.hpp>
|
||||||
#include <components/settings/settings.hpp>
|
#include <components/settings/values.hpp>
|
||||||
|
|
||||||
#include "../mwscript/extensions.hpp"
|
#include "../mwscript/extensions.hpp"
|
||||||
#include "../mwscript/interpretercontext.hpp"
|
#include "../mwscript/interpretercontext.hpp"
|
||||||
|
@ -709,7 +709,7 @@ namespace MWGui
|
||||||
void Console::initConsoleHistory()
|
void Console::initConsoleHistory()
|
||||||
{
|
{
|
||||||
const auto filePath = mCfgMgr.getUserConfigPath() / "console_history.txt";
|
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
|
// Read the previous session's commands from the file
|
||||||
if (retrievalLimit > 0)
|
if (retrievalLimit > 0)
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
#include <LinearMath/btQuickprof.h>
|
#include <LinearMath/btQuickprof.h>
|
||||||
#include <components/debug/debugging.hpp>
|
#include <components/debug/debugging.hpp>
|
||||||
#include <components/settings/settings.hpp>
|
#include <components/settings/values.hpp>
|
||||||
|
|
||||||
#include "../mwbase/environment.hpp"
|
#include "../mwbase/environment.hpp"
|
||||||
#include "../mwbase/luamanager.hpp"
|
#include "../mwbase/luamanager.hpp"
|
||||||
|
@ -132,7 +132,7 @@ namespace MWGui
|
||||||
|
|
||||||
void DebugWindow::startLogRecording()
|
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) {
|
Debug::setLogListener([](Debug::Level level, std::string_view prefix, std::string_view msg) {
|
||||||
if (sLogCircularBuffer.empty())
|
if (sLogCircularBuffer.empty())
|
||||||
return; // Log viewer is disabled.
|
return; // Log viewer is disabled.
|
||||||
|
|
|
@ -367,7 +367,7 @@ namespace MWGui
|
||||||
}
|
}
|
||||||
highlightCurrentResolution();
|
highlightCurrentResolution();
|
||||||
|
|
||||||
const std::string& tmip = Settings::Manager::getString("texture mipmap", "General");
|
const std::string& tmip = Settings::general().mTextureMipmap;
|
||||||
mTextureFilteringButton->setCaptionWithReplacing(textureMipmappingToStr(tmip));
|
mTextureFilteringButton->setCaptionWithReplacing(textureMipmappingToStr(tmip));
|
||||||
|
|
||||||
int waterTextureSize = Settings::Manager::getInt("rtt size", "Water");
|
int waterTextureSize = Settings::Manager::getInt("rtt size", "Water");
|
||||||
|
@ -416,7 +416,7 @@ namespace MWGui
|
||||||
|
|
||||||
std::sort(availableLanguages.begin(), availableLanguages.end());
|
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())
|
if (currentLocales.empty())
|
||||||
currentLocales.push_back("en");
|
currentLocales.push_back("en");
|
||||||
|
|
||||||
|
@ -563,7 +563,7 @@ namespace MWGui
|
||||||
MWBase::Environment::get().getWindowManager()->interactiveMessageBox(
|
MWBase::Environment::get().getWindowManager()->interactiveMessageBox(
|
||||||
"#{OMWEngine:ChangeRequiresRestart}", { "#{Interface:OK}" }, true);
|
"#{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)
|
if (currentLocales.size() <= langPriority)
|
||||||
currentLocales.resize(langPriority + 1, "en");
|
currentLocales.resize(langPriority + 1, "en");
|
||||||
|
|
||||||
|
@ -573,7 +573,7 @@ namespace MWGui
|
||||||
else
|
else
|
||||||
currentLocales.resize(1);
|
currentLocales.resize(1);
|
||||||
|
|
||||||
Settings::Manager::setStringArray("preferred locales", "General", currentLocales);
|
Settings::general().mPreferredLocales.set(currentLocales);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SettingsWindow::onGmstOverridesL10nChanged(MyGUI::Widget*)
|
void SettingsWindow::onGmstOverridesL10nChanged(MyGUI::Widget*)
|
||||||
|
@ -681,9 +681,9 @@ namespace MWGui
|
||||||
void SettingsWindow::onTextureFilteringChanged(MyGUI::ComboBox* _sender, size_t pos)
|
void SettingsWindow::onTextureFilteringChanged(MyGUI::ComboBox* _sender, size_t pos)
|
||||||
{
|
{
|
||||||
if (pos == 0)
|
if (pos == 0)
|
||||||
Settings::Manager::setString("texture mipmap", "General", "nearest");
|
Settings::general().mTextureMipmap.set("nearest");
|
||||||
else if (pos == 1)
|
else if (pos == 1)
|
||||||
Settings::Manager::setString("texture mipmap", "General", "linear");
|
Settings::general().mTextureMipmap.set("linear");
|
||||||
else
|
else
|
||||||
Log(Debug::Warning) << "Unexpected option pos " << pos;
|
Log(Debug::Warning) << "Unexpected option pos " << pos;
|
||||||
apply();
|
apply();
|
||||||
|
|
|
@ -1292,11 +1292,8 @@ namespace MWRender
|
||||||
{
|
{
|
||||||
mViewer->stopThreading();
|
mViewer->stopThreading();
|
||||||
|
|
||||||
mResourceSystem->getSceneManager()->setFilterSettings(
|
mResourceSystem->getSceneManager()->setFilterSettings(Settings::general().mTextureMagFilter,
|
||||||
Settings::Manager::getString("texture mag filter", "General"),
|
Settings::general().mTextureMinFilter, Settings::general().mTextureMipmap, Settings::general().mAnisotropy);
|
||||||
Settings::Manager::getString("texture min filter", "General"),
|
|
||||||
Settings::Manager::getString("texture mipmap", "General"),
|
|
||||||
Settings::Manager::getInt("anisotropy", "General"));
|
|
||||||
|
|
||||||
mTerrain->updateTextureFiltering();
|
mTerrain->updateTextureFiltering();
|
||||||
mWater->processChangedSettings({});
|
mWater->processChangedSettings({});
|
||||||
|
|
|
@ -28,7 +28,7 @@ namespace Settings
|
||||||
SettingValue<std::string> mTextureMipmap{ mIndex, "General", "texture mipmap",
|
SettingValue<std::string> mTextureMipmap{ mIndex, "General", "texture mipmap",
|
||||||
makeEnumSanitizerString({ "none", "nearest", "linear" }) };
|
makeEnumSanitizerString({ "none", "nearest", "linear" }) };
|
||||||
SettingValue<bool> mNotifyOnSavedScreenshot{ mIndex, "General", "notify on saved screenshot" };
|
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<bool> mGmstOverridesL10n{ mIndex, "General", "gmst overrides l10n" };
|
||||||
SettingValue<std::size_t> mLogBufferSize{ mIndex, "General", "log buffer size" };
|
SettingValue<std::size_t> mLogBufferSize{ mIndex, "General", "log buffer size" };
|
||||||
SettingValue<std::size_t> mConsoleHistoryBufferSize{ mIndex, "General", "console history 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));
|
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)
|
void Manager::recordInit(std::string_view setting, std::string_view category)
|
||||||
{
|
{
|
||||||
sInitialized.emplace(category, setting);
|
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::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, 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, DetourNavigator::CollisionShapeType value);
|
||||||
|
static void set(std::string_view setting, std::string_view category, const std::vector<std::string>& value);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static std::set<std::pair<std::string_view, std::string_view>> sInitialized;
|
static std::set<std::pair<std::string_view, std::string_view>> sInitialized;
|
||||||
|
|
||||||
template <class T>
|
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);
|
static void recordInit(std::string_view setting, std::string_view category);
|
||||||
};
|
};
|
||||||
|
@ -180,6 +181,13 @@ namespace Settings
|
||||||
{
|
{
|
||||||
return DetourNavigator::toCollisionShapeType(getInt(setting, category));
|
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
|
#endif // COMPONENTS_SETTINGS_H
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <string_view>
|
#include <string_view>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
namespace Settings
|
namespace Settings
|
||||||
{
|
{
|
||||||
|
@ -33,6 +34,7 @@ namespace Settings
|
||||||
Vec2f,
|
Vec2f,
|
||||||
Vec3f,
|
Vec3f,
|
||||||
CollisionShapeType,
|
CollisionShapeType,
|
||||||
|
StringArray,
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
|
@ -116,6 +118,12 @@ namespace Settings
|
||||||
return SettingValueType::CollisionShapeType;
|
return SettingValueType::CollisionShapeType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <>
|
||||||
|
inline constexpr SettingValueType getSettingValueType<std::vector<std::string>>()
|
||||||
|
{
|
||||||
|
return SettingValueType::StringArray;
|
||||||
|
}
|
||||||
|
|
||||||
inline constexpr std::string_view getSettingValueTypeName(SettingValueType type)
|
inline constexpr std::string_view getSettingValueTypeName(SettingValueType type)
|
||||||
{
|
{
|
||||||
switch (type)
|
switch (type)
|
||||||
|
@ -146,6 +154,8 @@ namespace Settings
|
||||||
return "vec3f";
|
return "vec3f";
|
||||||
case SettingValueType::CollisionShapeType:
|
case SettingValueType::CollisionShapeType:
|
||||||
return "collision shape type";
|
return "collision shape type";
|
||||||
|
case SettingValueType::StringArray:
|
||||||
|
return "string array";
|
||||||
}
|
}
|
||||||
return "unsupported";
|
return "unsupported";
|
||||||
}
|
}
|
||||||
|
@ -292,6 +302,18 @@ namespace Settings
|
||||||
{
|
{
|
||||||
if constexpr (std::is_enum_v<T>)
|
if constexpr (std::is_enum_v<T>)
|
||||||
return stream << static_cast<std::underlying_type_t<T>>(value.mValue);
|
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
|
else
|
||||||
return stream << value.mValue;
|
return stream << value.mValue;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue