From 258ae9d98e77c6321119f3d9b1648d91513beaf1 Mon Sep 17 00:00:00 2001 From: elsid Date: Mon, 10 Apr 2023 17:24:57 +0200 Subject: [PATCH] Add settings index to provide lookup by category and name --- apps/benchmarks/settings/access.cpp | 34 +- .../openmw_test_suite/settings/testvalues.cpp | 49 ++- components/settings/categories/camera.hpp | 18 +- components/settings/categories/cells.hpp | 33 +- components/settings/categories/fog.hpp | 29 +- components/settings/categories/game.hpp | 90 +++--- components/settings/categories/general.hpp | 22 +- .../settings/categories/groundcover.hpp | 15 +- components/settings/categories/gui.hpp | 35 ++- components/settings/categories/hud.hpp | 6 +- components/settings/categories/input.hpp | 39 ++- components/settings/categories/lua.hpp | 20 +- components/settings/categories/map.hpp | 21 +- components/settings/categories/models.hpp | 54 ++-- components/settings/categories/navigator.hpp | 77 ++--- components/settings/categories/physics.hpp | 8 +- .../settings/categories/postprocessing.hpp | 12 +- components/settings/categories/saves.hpp | 12 +- components/settings/categories/shaders.hpp | 50 +-- components/settings/categories/shadows.hpp | 49 +-- components/settings/categories/sound.hpp | 24 +- components/settings/categories/stereo.hpp | 16 +- components/settings/categories/stereoview.hpp | 52 ++-- components/settings/categories/terrain.hpp | 32 +- components/settings/categories/video.hpp | 28 +- components/settings/categories/water.hpp | 19 +- components/settings/categories/windows.hpp | 290 +++++++++--------- components/settings/settings.cpp | 4 +- components/settings/settingvalue.hpp | 269 +++++++++++++++- components/settings/values.cpp | 21 +- components/settings/values.hpp | 84 +++-- 31 files changed, 961 insertions(+), 551 deletions(-) diff --git a/apps/benchmarks/settings/access.cpp b/apps/benchmarks/settings/access.cpp index 83c1199aa0..aecac2dac8 100644 --- a/apps/benchmarks/settings/access.cpp +++ b/apps/benchmarks/settings/access.cpp @@ -93,19 +93,49 @@ namespace benchmark::DoNotOptimize(Settings::water().mReflectionDetail.get()); } } + + void settingsStorageGet(benchmark::State& state) + { + for (auto _ : state) + { + benchmark::DoNotOptimize(Settings::get("Fog", "sky blending start")); + } + } + + void settingsStorageGet2(benchmark::State& state) + { + for (auto _ : state) + { + benchmark::DoNotOptimize(Settings::get("Post Processing", "transparent postpass")); + benchmark::DoNotOptimize(Settings::get("Camera", "near clip")); + } + } + + void settingsStorageGet3(benchmark::State& state) + { + for (auto _ : state) + { + benchmark::DoNotOptimize(Settings::get("Post Processing", "transparent postpass")); + benchmark::DoNotOptimize(Settings::get("Camera", "near clip")); + benchmark::DoNotOptimize(Settings::get("Water", "reflection detail")); + } + } } BENCHMARK(settingsManager); BENCHMARK(localStatic); BENCHMARK(settingsStorage); +BENCHMARK(settingsStorageGet); BENCHMARK(settingsManager2); BENCHMARK(localStatic2); BENCHMARK(settingsStorage2); +BENCHMARK(settingsStorageGet2); BENCHMARK(settingsManager3); BENCHMARK(localStatic3); BENCHMARK(settingsStorage3); +BENCHMARK(settingsStorageGet3); int main(int argc, char* argv[]) { @@ -115,14 +145,14 @@ int main(int argc, char* argv[]) Settings::SettingsFileParser parser; parser.loadSettingsFile(settingsDefaultPath, Settings::Manager::mDefaultSettings); - Settings::Values::initDefaults(); + Settings::StaticValues::initDefaults(); Settings::Manager::mUserSettings = Settings::Manager::mDefaultSettings; Settings::Manager::mUserSettings.erase({ "Camera", "near clip" }); Settings::Manager::mUserSettings.erase({ "Post Processing", "transparent postpass" }); Settings::Manager::mUserSettings.erase({ "Water", "reflection detail" }); - Settings::Values::init(); + Settings::StaticValues::init(); benchmark::Initialize(&argc, argv); benchmark::RunSpecifiedBenchmarks(); diff --git a/apps/openmw_test_suite/settings/testvalues.cpp b/apps/openmw_test_suite/settings/testvalues.cpp index 38154ae039..81af308795 100644 --- a/apps/openmw_test_suite/settings/testvalues.cpp +++ b/apps/openmw_test_suite/settings/testvalues.cpp @@ -32,26 +32,37 @@ namespace Settings TEST_F(SettingsValuesTest, shouldLoadFromSettingsManager) { - Values values; + Index index; + Values values(index); EXPECT_EQ(values.mCamera.mFieldOfView.get(), 60); } + TEST_F(SettingsValuesTest, shouldFillIndexOnLoad) + { + Index index; + Values values(index); + EXPECT_EQ(index.get("Camera", "field of view").get(), 60); + } + TEST_F(SettingsValuesTest, constructorShouldThrowExceptionOnMissingSetting) { Manager::mDefaultSettings.erase({ "Camera", "field of view" }); - EXPECT_THROW([] { Values values; }(), std::runtime_error); + Index index; + EXPECT_THROW([&] { Values values(index); }(), std::runtime_error); } TEST_F(SettingsValuesTest, constructorShouldSanitize) { Manager::mUserSettings[std::make_pair("Camera", "field of view")] = "-1"; - Values values; + Index index; + Values values(index); EXPECT_EQ(values.mCamera.mFieldOfView.get(), 1); } TEST_F(SettingsValuesTest, moveConstructorShouldSetDefaults) { - Values defaultValues; + Index index; + Values defaultValues(index); Manager::mUserSettings.emplace(std::make_pair("Camera", "field of view"), "61"); Values values(std::move(defaultValues)); EXPECT_EQ(values.mCamera.mFieldOfView.get(), 61); @@ -61,15 +72,38 @@ namespace Settings TEST_F(SettingsValuesTest, moveConstructorShouldSanitize) { - Values defaultValues; + Index index; + Values defaultValues(index); Manager::mUserSettings[std::make_pair("Camera", "field of view")] = "-1"; Values values(std::move(defaultValues)); EXPECT_EQ(values.mCamera.mFieldOfView.get(), 1); } + TEST_F(SettingsValuesTest, findShouldThrowExceptionOnTypeMismatch) + { + Index index; + Values values(index); + EXPECT_THROW(index.find("Camera", "field of view"), std::invalid_argument); + } + + TEST_F(SettingsValuesTest, findShouldReturnNullptrForAbsentSetting) + { + Index index; + Values values(index); + EXPECT_EQ(index.find("foo", "bar"), nullptr); + } + + TEST_F(SettingsValuesTest, getShouldThrowExceptionForAbsentSetting) + { + Index index; + Values values(index); + EXPECT_THROW(index.get("foo", "bar").get(), std::invalid_argument); + } + TEST_F(SettingsValuesTest, setShouldChangeManagerUserSettings) { - Values values; + Index index; + Values values(index); values.mCamera.mFieldOfView.set(42); EXPECT_EQ(Manager::mUserSettings.at({ "Camera", "field of view" }), "42"); EXPECT_THAT(Manager::mChangedSettings, ElementsAre(std::make_pair("Camera", "field of view"))); @@ -77,7 +111,8 @@ namespace Settings TEST_F(SettingsValuesTest, setShouldNotChangeManagerChangedSettingsForNoChange) { - Values values; + Index index; + Values values(index); values.mCamera.mFieldOfView.set(values.mCamera.mFieldOfView.get()); EXPECT_THAT(Manager::mChangedSettings, ElementsAre()); } diff --git a/components/settings/categories/camera.hpp b/components/settings/categories/camera.hpp index d9a2aef75c..4712f88b45 100644 --- a/components/settings/categories/camera.hpp +++ b/components/settings/categories/camera.hpp @@ -14,17 +14,19 @@ namespace Settings { - struct CameraCategory + struct CameraCategory : WithIndex { - SettingValue mNearClip{ "Camera", "near clip", makeMaxSanitizerFloat(0.005f) }; - SettingValue mSmallFeatureCulling{ "Camera", "small feature culling" }; - SettingValue mSmallFeatureCullingPixelSize{ "Camera", "small feature culling pixel size", + using WithIndex::WithIndex; + + SettingValue mNearClip{ mIndex, "Camera", "near clip", makeMaxSanitizerFloat(0.005f) }; + SettingValue mSmallFeatureCulling{ mIndex, "Camera", "small feature culling" }; + SettingValue mSmallFeatureCullingPixelSize{ mIndex, "Camera", "small feature culling pixel size", makeMaxStrictSanitizerFloat(0) }; - SettingValue mViewingDistance{ "Camera", "viewing distance", makeMaxStrictSanitizerFloat(0) }; - SettingValue mFieldOfView{ "Camera", "field of view", makeClampSanitizerFloat(1, 179) }; - SettingValue mFirstPersonFieldOfView{ "Camera", "first person field of view", + SettingValue mViewingDistance{ mIndex, "Camera", "viewing distance", makeMaxStrictSanitizerFloat(0) }; + SettingValue mFieldOfView{ mIndex, "Camera", "field of view", makeClampSanitizerFloat(1, 179) }; + SettingValue mFirstPersonFieldOfView{ mIndex, "Camera", "first person field of view", makeClampSanitizerFloat(1, 179) }; - SettingValue mReverseZ{ "Camera", "reverse z" }; + SettingValue mReverseZ{ mIndex, "Camera", "reverse z" }; }; } diff --git a/components/settings/categories/cells.hpp b/components/settings/categories/cells.hpp index c6d7fe05d4..723004d674 100644 --- a/components/settings/categories/cells.hpp +++ b/components/settings/categories/cells.hpp @@ -14,22 +14,25 @@ namespace Settings { - struct CellsCategory + struct CellsCategory : WithIndex { - SettingValue mPreloadEnabled{ "Cells", "preload enabled" }; - SettingValue mPreloadNumThreads{ "Cells", "preload num threads", makeMaxSanitizerInt(1) }; - SettingValue mPreloadExteriorGrid{ "Cells", "preload exterior grid" }; - SettingValue mPreloadFastTravel{ "Cells", "preload fast travel" }; - SettingValue mPreloadDoors{ "Cells", "preload doors" }; - SettingValue mPreloadDistance{ "Cells", "preload distance", makeMaxStrictSanitizerFloat(0) }; - SettingValue mPreloadInstances{ "Cells", "preload instances" }; - SettingValue mPreloadCellCacheMin{ "Cells", "preload cell cache min", makeMaxSanitizerInt(1) }; - SettingValue mPreloadCellCacheMax{ "Cells", "preload cell cache max", makeMaxSanitizerInt(1) }; - SettingValue mPreloadCellExpiryDelay{ "Cells", "preload cell expiry delay", makeMaxSanitizerFloat(0) }; - SettingValue mPredictionTime{ "Cells", "prediction time", makeMaxSanitizerFloat(0) }; - SettingValue mCacheExpiryDelay{ "Cells", "cache expiry delay", makeMaxSanitizerFloat(0) }; - SettingValue mTargetFramerate{ "Cells", "target framerate", makeMaxStrictSanitizerFloat(0) }; - SettingValue mPointersCacheSize{ "Cells", "pointers cache size", makeClampSanitizerInt(40, 1000) }; + using WithIndex::WithIndex; + + SettingValue mPreloadEnabled{ mIndex, "Cells", "preload enabled" }; + SettingValue mPreloadNumThreads{ mIndex, "Cells", "preload num threads", makeMaxSanitizerInt(1) }; + SettingValue mPreloadExteriorGrid{ mIndex, "Cells", "preload exterior grid" }; + SettingValue mPreloadFastTravel{ mIndex, "Cells", "preload fast travel" }; + SettingValue mPreloadDoors{ mIndex, "Cells", "preload doors" }; + SettingValue mPreloadDistance{ mIndex, "Cells", "preload distance", makeMaxStrictSanitizerFloat(0) }; + SettingValue mPreloadInstances{ mIndex, "Cells", "preload instances" }; + SettingValue mPreloadCellCacheMin{ mIndex, "Cells", "preload cell cache min", makeMaxSanitizerInt(1) }; + SettingValue mPreloadCellCacheMax{ mIndex, "Cells", "preload cell cache max", makeMaxSanitizerInt(1) }; + SettingValue mPreloadCellExpiryDelay{ mIndex, "Cells", "preload cell expiry delay", + makeMaxSanitizerFloat(0) }; + SettingValue mPredictionTime{ mIndex, "Cells", "prediction time", makeMaxSanitizerFloat(0) }; + SettingValue mCacheExpiryDelay{ mIndex, "Cells", "cache expiry delay", makeMaxSanitizerFloat(0) }; + SettingValue mTargetFramerate{ mIndex, "Cells", "target framerate", makeMaxStrictSanitizerFloat(0) }; + SettingValue mPointersCacheSize{ mIndex, "Cells", "pointers cache size", makeClampSanitizerInt(40, 1000) }; }; } diff --git a/components/settings/categories/fog.hpp b/components/settings/categories/fog.hpp index c9fe03aca3..5acf3d20c6 100644 --- a/components/settings/categories/fog.hpp +++ b/components/settings/categories/fog.hpp @@ -14,20 +14,23 @@ namespace Settings { - struct FogCategory + struct FogCategory : WithIndex { - SettingValue mUseDistantFog{ "Fog", "use distant fog" }; - SettingValue mDistantLandFogStart{ "Fog", "distant land fog start" }; - SettingValue mDistantLandFogEnd{ "Fog", "distant land fog end" }; - SettingValue mDistantUnderwaterFogStart{ "Fog", "distant underwater fog start" }; - SettingValue mDistantUnderwaterFogEnd{ "Fog", "distant underwater fog end" }; - SettingValue mDistantInteriorFogStart{ "Fog", "distant interior fog start" }; - SettingValue mDistantInteriorFogEnd{ "Fog", "distant interior fog end" }; - SettingValue mRadialFog{ "Fog", "radial fog" }; - SettingValue mExponentialFog{ "Fog", "exponential fog" }; - SettingValue mSkyBlending{ "Fog", "sky blending" }; - SettingValue mSkyBlendingStart{ "Fog", "sky blending start", makeClampStrictMaxSanitizerFloat(0, 1) }; - SettingValue mSkyRttResolution{ "Fog", "sky rtt resolution" }; + using WithIndex::WithIndex; + + SettingValue mUseDistantFog{ mIndex, "Fog", "use distant fog" }; + SettingValue mDistantLandFogStart{ mIndex, "Fog", "distant land fog start" }; + SettingValue mDistantLandFogEnd{ mIndex, "Fog", "distant land fog end" }; + SettingValue mDistantUnderwaterFogStart{ mIndex, "Fog", "distant underwater fog start" }; + SettingValue mDistantUnderwaterFogEnd{ mIndex, "Fog", "distant underwater fog end" }; + SettingValue mDistantInteriorFogStart{ mIndex, "Fog", "distant interior fog start" }; + SettingValue mDistantInteriorFogEnd{ mIndex, "Fog", "distant interior fog end" }; + SettingValue mRadialFog{ mIndex, "Fog", "radial fog" }; + SettingValue mExponentialFog{ mIndex, "Fog", "exponential fog" }; + SettingValue mSkyBlending{ mIndex, "Fog", "sky blending" }; + SettingValue mSkyBlendingStart{ mIndex, "Fog", "sky blending start", + makeClampStrictMaxSanitizerFloat(0, 1) }; + SettingValue mSkyRttResolution{ mIndex, "Fog", "sky rtt resolution" }; }; } diff --git a/components/settings/categories/game.hpp b/components/settings/categories/game.hpp index 3d7cc852d8..3eec91dd22 100644 --- a/components/settings/categories/game.hpp +++ b/components/settings/categories/game.hpp @@ -14,56 +14,62 @@ namespace Settings { - struct GameCategory + struct GameCategory : WithIndex { - SettingValue mShowOwned{ "Game", "show owned", makeEnumSanitizerInt({ 0, 1, 2, 3 }) }; - SettingValue mShowProjectileDamage{ "Game", "show projectile damage" }; - SettingValue mShowMeleeInfo{ "Game", "show melee info" }; - SettingValue mShowEnchantChance{ "Game", "show enchant chance" }; - SettingValue mBestAttack{ "Game", "best attack" }; - SettingValue mDifficulty{ "Game", "difficulty", makeClampSanitizerInt(-500, 500) }; - SettingValue mActorsProcessingRange{ "Game", "actors processing range", + using WithIndex::WithIndex; + + SettingValue mShowOwned{ mIndex, "Game", "show owned", makeEnumSanitizerInt({ 0, 1, 2, 3 }) }; + SettingValue mShowProjectileDamage{ mIndex, "Game", "show projectile damage" }; + SettingValue mShowMeleeInfo{ mIndex, "Game", "show melee info" }; + SettingValue mShowEnchantChance{ mIndex, "Game", "show enchant chance" }; + SettingValue mBestAttack{ mIndex, "Game", "best attack" }; + SettingValue mDifficulty{ mIndex, "Game", "difficulty", makeClampSanitizerInt(-500, 500) }; + SettingValue mActorsProcessingRange{ mIndex, "Game", "actors processing range", makeClampSanitizerInt(3584, 7168) }; - SettingValue mClassicReflectedAbsorbSpellsBehavior{ "Game", "classic reflected absorb spells behavior" }; - SettingValue mClassicCalmSpellsBehavior{ "Game", "classic calm spells behavior" }; - SettingValue mShowEffectDuration{ "Game", "show effect duration" }; - SettingValue mPreventMerchantEquipping{ "Game", "prevent merchant equipping" }; - SettingValue mEnchantedWeaponsAreMagical{ "Game", "enchanted weapons are magical" }; - SettingValue mFollowersAttackOnSight{ "Game", "followers attack on sight" }; - SettingValue mCanLootDuringDeathAnimation{ "Game", "can loot during death animation" }; - SettingValue mRebalanceSoulGemValues{ "Game", "rebalance soul gem values" }; - SettingValue mUseAdditionalAnimSources{ "Game", "use additional anim sources" }; - SettingValue mBarterDispositionChangeIsPermanent{ "Game", "barter disposition change is permanent" }; - SettingValue mStrengthInfluencesHandToHand{ "Game", "strength influences hand to hand", + SettingValue mClassicReflectedAbsorbSpellsBehavior{ mIndex, "Game", + "classic reflected absorb spells behavior" }; + SettingValue mClassicCalmSpellsBehavior{ mIndex, "Game", "classic calm spells behavior" }; + SettingValue mShowEffectDuration{ mIndex, "Game", "show effect duration" }; + SettingValue mPreventMerchantEquipping{ mIndex, "Game", "prevent merchant equipping" }; + SettingValue mEnchantedWeaponsAreMagical{ mIndex, "Game", "enchanted weapons are magical" }; + SettingValue mFollowersAttackOnSight{ mIndex, "Game", "followers attack on sight" }; + SettingValue mCanLootDuringDeathAnimation{ mIndex, "Game", "can loot during death animation" }; + SettingValue mRebalanceSoulGemValues{ mIndex, "Game", "rebalance soul gem values" }; + SettingValue mUseAdditionalAnimSources{ mIndex, "Game", "use additional anim sources" }; + SettingValue mBarterDispositionChangeIsPermanent{ mIndex, "Game", + "barter disposition change is permanent" }; + SettingValue mStrengthInfluencesHandToHand{ mIndex, "Game", "strength influences hand to hand", makeEnumSanitizerInt({ 0, 1, 2 }) }; - SettingValue mWeaponSheathing{ "Game", "weapon sheathing" }; - SettingValue mShieldSheathing{ "Game", "shield sheathing" }; - SettingValue mOnlyAppropriateAmmunitionBypassesResistance{ "Game", + SettingValue mWeaponSheathing{ mIndex, "Game", "weapon sheathing" }; + SettingValue mShieldSheathing{ mIndex, "Game", "shield sheathing" }; + SettingValue mOnlyAppropriateAmmunitionBypassesResistance{ mIndex, "Game", "only appropriate ammunition bypasses resistance" }; - SettingValue mUseMagicItemAnimations{ "Game", "use magic item animations" }; - SettingValue mNormaliseRaceSpeed{ "Game", "normalise race speed" }; - SettingValue mProjectilesEnchantMultiplier{ "Game", "projectiles enchant multiplier", + SettingValue mUseMagicItemAnimations{ mIndex, "Game", "use magic item animations" }; + SettingValue mNormaliseRaceSpeed{ mIndex, "Game", "normalise race speed" }; + SettingValue mProjectilesEnchantMultiplier{ mIndex, "Game", "projectiles enchant multiplier", makeClampSanitizerFloat(0, 1) }; - SettingValue mUncappedDamageFatigue{ "Game", "uncapped damage fatigue" }; - SettingValue mTurnToMovementDirection{ "Game", "turn to movement direction" }; - SettingValue mSmoothMovement{ "Game", "smooth movement" }; - SettingValue mSmoothMovementPlayerTurningDelay{ "Game", "smooth movement player turning delay", + SettingValue mUncappedDamageFatigue{ mIndex, "Game", "uncapped damage fatigue" }; + SettingValue mTurnToMovementDirection{ mIndex, "Game", "turn to movement direction" }; + SettingValue mSmoothMovement{ mIndex, "Game", "smooth movement" }; + SettingValue mSmoothMovementPlayerTurningDelay{ mIndex, "Game", "smooth movement player turning delay", makeMaxSanitizerFloat(0.01f) }; - SettingValue mNPCsAvoidCollisions{ "Game", "NPCs avoid collisions" }; - SettingValue mNPCsGiveWay{ "Game", "NPCs give way" }; - SettingValue mSwimUpwardCorrection{ "Game", "swim upward correction" }; - SettingValue mSwimUpwardCoef{ "Game", "swim upward coef", makeClampSanitizerFloat(-1, 1) }; - SettingValue mTrainersTrainingSkillsBasedOnBaseSkill{ "Game", + SettingValue mNPCsAvoidCollisions{ mIndex, "Game", "NPCs avoid collisions" }; + SettingValue mNPCsGiveWay{ mIndex, "Game", "NPCs give way" }; + SettingValue mSwimUpwardCorrection{ mIndex, "Game", "swim upward correction" }; + SettingValue mSwimUpwardCoef{ mIndex, "Game", "swim upward coef", makeClampSanitizerFloat(-1, 1) }; + SettingValue mTrainersTrainingSkillsBasedOnBaseSkill{ mIndex, "Game", "trainers training skills based on base skill" }; - SettingValue mAlwaysAllowStealingFromKnockedOutActors{ "Game", + SettingValue mAlwaysAllowStealingFromKnockedOutActors{ mIndex, "Game", "always allow stealing from knocked out actors" }; - SettingValue mGraphicHerbalism{ "Game", "graphic herbalism" }; - SettingValue mAllowActorsToFollowOverWaterSurface{ "Game", "allow actors to follow over water surface" }; - SettingValue mDefaultActorPathfindHalfExtents{ "Game", "default actor pathfind half extents", - makeMaxStrictSanitizerVec3f(osg::Vec3f(0, 0, 0)) }; - SettingValue mDayNightSwitches{ "Game", "day night switches" }; - SettingValue mUnarmedCreatureAttacksDamageArmor{ "Game", "unarmed creature attacks damage armor" }; - SettingValue mActorCollisionShapeType{ "Game", "actor collision shape type", + SettingValue mGraphicHerbalism{ mIndex, "Game", "graphic herbalism" }; + SettingValue mAllowActorsToFollowOverWaterSurface{ mIndex, "Game", + "allow actors to follow over water surface" }; + SettingValue mDefaultActorPathfindHalfExtents{ mIndex, "Game", + "default actor pathfind half extents", makeMaxStrictSanitizerVec3f(osg::Vec3f(0, 0, 0)) }; + SettingValue mDayNightSwitches{ mIndex, "Game", "day night switches" }; + SettingValue mUnarmedCreatureAttacksDamageArmor{ mIndex, "Game", + "unarmed creature attacks damage armor" }; + SettingValue mActorCollisionShapeType{ mIndex, "Game", "actor collision shape type", makeEnumSanitizerInt({ 0, 1, 2 }) }; }; } diff --git a/components/settings/categories/general.hpp b/components/settings/categories/general.hpp index 405db5167b..d6a0f267a9 100644 --- a/components/settings/categories/general.hpp +++ b/components/settings/categories/general.hpp @@ -14,21 +14,23 @@ namespace Settings { - struct GeneralCategory + struct GeneralCategory : WithIndex { - SettingValue mAnisotropy{ "General", "anisotropy", makeClampSanitizerInt(0, 16) }; - SettingValue mScreenshotFormat{ "General", "screenshot format", + using WithIndex::WithIndex; + + SettingValue mAnisotropy{ mIndex, "General", "anisotropy", makeClampSanitizerInt(0, 16) }; + SettingValue mScreenshotFormat{ mIndex, "General", "screenshot format", makeEnumSanitizerString({ "jpg", "png", "tga" }) }; - SettingValue mTextureMagFilter{ "General", "texture mag filter", + SettingValue mTextureMagFilter{ mIndex, "General", "texture mag filter", makeEnumSanitizerString({ "nearest", "linear" }) }; - SettingValue mTextureMinFilter{ "General", "texture min filter", + SettingValue mTextureMinFilter{ mIndex, "General", "texture min filter", makeEnumSanitizerString({ "nearest", "linear" }) }; - SettingValue mTextureMipmap{ "General", "texture mipmap", + SettingValue mTextureMipmap{ mIndex, "General", "texture mipmap", makeEnumSanitizerString({ "none", "nearest", "linear" }) }; - SettingValue mNotifyOnSavedScreenshot{ "General", "notify on saved screenshot" }; - SettingValue mPreferredLocales{ "General", "preferred locales" }; - SettingValue mLogBufferSize{ "General", "log buffer size" }; - SettingValue mConsoleHistoryBufferSize{ "General", "console history buffer size" }; + SettingValue mNotifyOnSavedScreenshot{ mIndex, "General", "notify on saved screenshot" }; + SettingValue mPreferredLocales{ mIndex, "General", "preferred locales" }; + SettingValue mLogBufferSize{ mIndex, "General", "log buffer size" }; + SettingValue mConsoleHistoryBufferSize{ mIndex, "General", "console history buffer size" }; }; } diff --git a/components/settings/categories/groundcover.hpp b/components/settings/categories/groundcover.hpp index 5e90baa4fb..48f97037ae 100644 --- a/components/settings/categories/groundcover.hpp +++ b/components/settings/categories/groundcover.hpp @@ -14,13 +14,16 @@ namespace Settings { - struct GroundcoverCategory + struct GroundcoverCategory : WithIndex { - SettingValue mEnabled{ "Groundcover", "enabled" }; - SettingValue mDensity{ "Groundcover", "density", makeClampSanitizerFloat(0, 1) }; - SettingValue mRenderingDistance{ "Groundcover", "rendering distance", makeMaxSanitizerFloat(0) }; - SettingValue mStompMode{ "Groundcover", "stomp mode", makeEnumSanitizerInt({ 0, 1, 2 }) }; - SettingValue mStompIntensity{ "Groundcover", "stomp intensity", makeEnumSanitizerInt({ 0, 1, 2 }) }; + using WithIndex::WithIndex; + + SettingValue mEnabled{ mIndex, "Groundcover", "enabled" }; + SettingValue mDensity{ mIndex, "Groundcover", "density", makeClampSanitizerFloat(0, 1) }; + SettingValue mRenderingDistance{ mIndex, "Groundcover", "rendering distance", makeMaxSanitizerFloat(0) }; + SettingValue mStompMode{ mIndex, "Groundcover", "stomp mode", makeEnumSanitizerInt({ 0, 1, 2 }) }; + SettingValue mStompIntensity{ mIndex, "Groundcover", "stomp intensity", + makeEnumSanitizerInt({ 0, 1, 2 }) }; }; } diff --git a/components/settings/categories/gui.hpp b/components/settings/categories/gui.hpp index cb2995fb69..6c5b97556e 100644 --- a/components/settings/categories/gui.hpp +++ b/components/settings/categories/gui.hpp @@ -14,22 +14,27 @@ namespace Settings { - struct GUICategory + struct GUICategory : WithIndex { - SettingValue mScalingFactor{ "GUI", "scaling factor", makeClampSanitizerFloat(0.5f, 8) }; - SettingValue mFontSize{ "GUI", "font size", makeClampSanitizerInt(12, 18) }; - SettingValue mMenuTransparency{ "GUI", "menu transparency", makeClampSanitizerFloat(0, 1) }; - SettingValue mTooltipDelay{ "GUI", "tooltip delay", makeMaxSanitizerFloat(0) }; - SettingValue mStretchMenuBackground{ "GUI", "stretch menu background" }; - SettingValue mSubtitles{ "GUI", "subtitles" }; - SettingValue mHitFader{ "GUI", "hit fader" }; - SettingValue mWerewolfOverlay{ "GUI", "werewolf overlay" }; - SettingValue mColorBackgroundOwned{ "GUI", "color background owned", makeClampSanitizerFloat(0, 1) }; - SettingValue mColorCrosshairOwned{ "GUI", "color crosshair owned", makeClampSanitizerFloat(0, 1) }; - SettingValue mKeyboardNavigation{ "GUI", "keyboard navigation" }; - SettingValue mColorTopicEnable{ "GUI", "color topic enable" }; - SettingValue mColorTopicSpecific{ "GUI", "color topic specific", makeClampSanitizerFloat(0, 1) }; - SettingValue mColorTopicExhausted{ "GUI", "color topic exhausted", makeClampSanitizerFloat(0, 1) }; + using WithIndex::WithIndex; + + SettingValue mScalingFactor{ mIndex, "GUI", "scaling factor", makeClampSanitizerFloat(0.5f, 8) }; + SettingValue mFontSize{ mIndex, "GUI", "font size", makeClampSanitizerInt(12, 18) }; + SettingValue mMenuTransparency{ mIndex, "GUI", "menu transparency", makeClampSanitizerFloat(0, 1) }; + SettingValue mTooltipDelay{ mIndex, "GUI", "tooltip delay", makeMaxSanitizerFloat(0) }; + SettingValue mStretchMenuBackground{ mIndex, "GUI", "stretch menu background" }; + SettingValue mSubtitles{ mIndex, "GUI", "subtitles" }; + SettingValue mHitFader{ mIndex, "GUI", "hit fader" }; + SettingValue mWerewolfOverlay{ mIndex, "GUI", "werewolf overlay" }; + SettingValue mColorBackgroundOwned{ mIndex, "GUI", "color background owned", + makeClampSanitizerFloat(0, 1) }; + SettingValue mColorCrosshairOwned{ mIndex, "GUI", "color crosshair owned", + makeClampSanitizerFloat(0, 1) }; + SettingValue mKeyboardNavigation{ mIndex, "GUI", "keyboard navigation" }; + SettingValue mColorTopicEnable{ mIndex, "GUI", "color topic enable" }; + SettingValue mColorTopicSpecific{ mIndex, "GUI", "color topic specific", makeClampSanitizerFloat(0, 1) }; + SettingValue mColorTopicExhausted{ mIndex, "GUI", "color topic exhausted", + makeClampSanitizerFloat(0, 1) }; }; } diff --git a/components/settings/categories/hud.hpp b/components/settings/categories/hud.hpp index 085939512e..af2b28f447 100644 --- a/components/settings/categories/hud.hpp +++ b/components/settings/categories/hud.hpp @@ -14,9 +14,11 @@ namespace Settings { - struct HUDCategory + struct HUDCategory : WithIndex { - SettingValue mCrosshair{ "HUD", "crosshair" }; + using WithIndex::WithIndex; + + SettingValue mCrosshair{ mIndex, "HUD", "crosshair" }; }; } diff --git a/components/settings/categories/input.hpp b/components/settings/categories/input.hpp index 280279dccb..7dbd326952 100644 --- a/components/settings/categories/input.hpp +++ b/components/settings/categories/input.hpp @@ -14,25 +14,30 @@ namespace Settings { - struct InputCategory + struct InputCategory : WithIndex { - SettingValue mGrabCursor{ "Input", "grab cursor" }; - SettingValue mCameraSensitivity{ "Input", "camera sensitivity", makeMaxStrictSanitizerFloat(0) }; - SettingValue mCameraYMultiplier{ "Input", "camera y multiplier", makeMaxStrictSanitizerFloat(0) }; - SettingValue mInvertXAxis{ "Input", "invert x axis" }; - SettingValue mInvertYAxis{ "Input", "invert y axis" }; - SettingValue mEnableController{ "Input", "enable controller" }; - SettingValue mGamepadCursorSpeed{ "Input", "gamepad cursor speed", makeMaxStrictSanitizerFloat(0) }; - SettingValue mJoystickDeadZone{ "Input", "joystick dead zone", makeClampSanitizerFloat(0, 0.5f) }; - SettingValue mEnableGyroscope{ "Input", "enable gyroscope" }; - SettingValue mGyroHorizontalAxis{ "Input", "gyro horizontal axis", - makeEnumSanitizerString({ "x", "y", "z", "-x", "-y", "-z" }) }; - SettingValue mGyroVerticalAxis{ "Input", "gyro vertical axis", - makeEnumSanitizerString({ "x", "y", "z", "-x", "-y", "-z" }) }; - SettingValue mGyroInputThreshold{ "Input", "gyro input threshold", makeMaxSanitizerFloat(0) }; - SettingValue mGyroHorizontalSensitivity{ "Input", "gyro horizontal sensitivity", + using WithIndex::WithIndex; + + SettingValue mGrabCursor{ mIndex, "Input", "grab cursor" }; + SettingValue mCameraSensitivity{ mIndex, "Input", "camera sensitivity", makeMaxStrictSanitizerFloat(0) }; + SettingValue mCameraYMultiplier{ mIndex, "Input", "camera y multiplier", makeMaxStrictSanitizerFloat(0) }; - SettingValue mGyroVerticalSensitivity{ "Input", "gyro vertical sensitivity", + SettingValue mInvertXAxis{ mIndex, "Input", "invert x axis" }; + SettingValue mInvertYAxis{ mIndex, "Input", "invert y axis" }; + SettingValue mEnableController{ mIndex, "Input", "enable controller" }; + SettingValue mGamepadCursorSpeed{ mIndex, "Input", "gamepad cursor speed", + makeMaxStrictSanitizerFloat(0) }; + SettingValue mJoystickDeadZone{ mIndex, "Input", "joystick dead zone", + makeClampSanitizerFloat(0, 0.5f) }; + SettingValue mEnableGyroscope{ mIndex, "Input", "enable gyroscope" }; + SettingValue mGyroHorizontalAxis{ mIndex, "Input", "gyro horizontal axis", + makeEnumSanitizerString({ "x", "y", "z", "-x", "-y", "-z" }) }; + SettingValue mGyroVerticalAxis{ mIndex, "Input", "gyro vertical axis", + makeEnumSanitizerString({ "x", "y", "z", "-x", "-y", "-z" }) }; + SettingValue mGyroInputThreshold{ mIndex, "Input", "gyro input threshold", makeMaxSanitizerFloat(0) }; + SettingValue mGyroHorizontalSensitivity{ mIndex, "Input", "gyro horizontal sensitivity", + makeMaxStrictSanitizerFloat(0) }; + SettingValue mGyroVerticalSensitivity{ mIndex, "Input", "gyro vertical sensitivity", makeMaxStrictSanitizerFloat(0) }; }; } diff --git a/components/settings/categories/lua.hpp b/components/settings/categories/lua.hpp index 02ef4a4936..da11a605eb 100644 --- a/components/settings/categories/lua.hpp +++ b/components/settings/categories/lua.hpp @@ -14,17 +14,19 @@ namespace Settings { - struct LuaCategory + struct LuaCategory : WithIndex { - SettingValue mLuaDebug{ "Lua", "lua debug" }; - SettingValue mLuaNumThreads{ "Lua", "lua num threads", makeEnumSanitizerInt({ 0, 1 }) }; - SettingValue mLuaProfiler{ "Lua", "lua profiler" }; - SettingValue mSmallAllocMaxSize{ "Lua", "small alloc max size" }; - SettingValue mMemoryLimit{ "Lua", "memory limit" }; - SettingValue mLogMemoryUsage{ "Lua", "log memory usage" }; - SettingValue mInstructionLimitPerCall{ "Lua", "instruction limit per call", + using WithIndex::WithIndex; + + SettingValue mLuaDebug{ mIndex, "Lua", "lua debug" }; + SettingValue mLuaNumThreads{ mIndex, "Lua", "lua num threads", makeEnumSanitizerInt({ 0, 1 }) }; + SettingValue mLuaProfiler{ mIndex, "Lua", "lua profiler" }; + SettingValue mSmallAllocMaxSize{ mIndex, "Lua", "small alloc max size" }; + SettingValue mMemoryLimit{ mIndex, "Lua", "memory limit" }; + SettingValue mLogMemoryUsage{ mIndex, "Lua", "log memory usage" }; + SettingValue mInstructionLimitPerCall{ mIndex, "Lua", "instruction limit per call", makeMaxSanitizerUInt64(1001) }; - SettingValue mGcStepsPerFrame{ "Lua", "gc steps per frame", makeMaxSanitizerInt(0) }; + SettingValue mGcStepsPerFrame{ mIndex, "Lua", "gc steps per frame", makeMaxSanitizerInt(0) }; }; } diff --git a/components/settings/categories/map.hpp b/components/settings/categories/map.hpp index 9234c60772..d7120eb4b6 100644 --- a/components/settings/categories/map.hpp +++ b/components/settings/categories/map.hpp @@ -14,16 +14,19 @@ namespace Settings { - struct MapCategory + struct MapCategory : WithIndex { - SettingValue mGlobalMapCellSize{ "Map", "global map cell size", makeMaxSanitizerInt(1) }; - SettingValue mLocalMapHudWidgetSize{ "Map", "local map hud widget size", makeMaxSanitizerInt(1) }; - SettingValue mLocalMapHudFogOfWar{ "Map", "local map hud fog of war" }; - SettingValue mLocalMapResolution{ "Map", "local map resolution", makeMaxSanitizerInt(1) }; - SettingValue mLocalMapWidgetSize{ "Map", "local map widget size", makeMaxSanitizerInt(1) }; - SettingValue mGlobal{ "Map", "global" }; - SettingValue mAllowZooming{ "Map", "allow zooming" }; - SettingValue mMaxLocalViewingDistance{ "Map", "max local viewing distance", makeMaxSanitizerInt(1) }; + using WithIndex::WithIndex; + + SettingValue mGlobalMapCellSize{ mIndex, "Map", "global map cell size", makeMaxSanitizerInt(1) }; + SettingValue mLocalMapHudWidgetSize{ mIndex, "Map", "local map hud widget size", makeMaxSanitizerInt(1) }; + SettingValue mLocalMapHudFogOfWar{ mIndex, "Map", "local map hud fog of war" }; + SettingValue mLocalMapResolution{ mIndex, "Map", "local map resolution", makeMaxSanitizerInt(1) }; + SettingValue mLocalMapWidgetSize{ mIndex, "Map", "local map widget size", makeMaxSanitizerInt(1) }; + SettingValue mGlobal{ mIndex, "Map", "global" }; + SettingValue mAllowZooming{ mIndex, "Map", "allow zooming" }; + SettingValue mMaxLocalViewingDistance{ mIndex, "Map", "max local viewing distance", + makeMaxSanitizerInt(1) }; }; } diff --git a/components/settings/categories/models.hpp b/components/settings/categories/models.hpp index cd2d403a0c..48f56e3bfa 100644 --- a/components/settings/categories/models.hpp +++ b/components/settings/categories/models.hpp @@ -14,33 +14,35 @@ namespace Settings { - struct ModelsCategory + struct ModelsCategory : WithIndex { - SettingValue mLoadUnsupportedNifFiles{ "Models", "load unsupported nif files" }; - SettingValue mXbaseanim{ "Models", "xbaseanim" }; - SettingValue mBaseanim{ "Models", "baseanim" }; - SettingValue mXbaseanim1st{ "Models", "xbaseanim1st" }; - SettingValue mBaseanimkna{ "Models", "baseanimkna" }; - SettingValue mBaseanimkna1st{ "Models", "baseanimkna1st" }; - SettingValue mXbaseanimfemale{ "Models", "xbaseanimfemale" }; - SettingValue mBaseanimfemale{ "Models", "baseanimfemale" }; - SettingValue mBaseanimfemale1st{ "Models", "baseanimfemale1st" }; - SettingValue mWolfskin{ "Models", "wolfskin" }; - SettingValue mWolfskin1st{ "Models", "wolfskin1st" }; - SettingValue mXargonianswimkna{ "Models", "xargonianswimkna" }; - SettingValue mXbaseanimkf{ "Models", "xbaseanimkf" }; - SettingValue mXbaseanim1stkf{ "Models", "xbaseanim1stkf" }; - SettingValue mXbaseanimfemalekf{ "Models", "xbaseanimfemalekf" }; - SettingValue mXargonianswimknakf{ "Models", "xargonianswimknakf" }; - SettingValue mSkyatmosphere{ "Models", "skyatmosphere" }; - SettingValue mSkyclouds{ "Models", "skyclouds" }; - SettingValue mSkynight01{ "Models", "skynight01" }; - SettingValue mSkynight02{ "Models", "skynight02" }; - SettingValue mWeatherashcloud{ "Models", "weatherashcloud" }; - SettingValue mWeatherblightcloud{ "Models", "weatherblightcloud" }; - SettingValue mWeathersnow{ "Models", "weathersnow" }; - SettingValue mWeatherblizzard{ "Models", "weatherblizzard" }; - SettingValue mWriteNifDebugLog{ "Models", "write nif debug log" }; + using WithIndex::WithIndex; + + SettingValue mLoadUnsupportedNifFiles{ mIndex, "Models", "load unsupported nif files" }; + SettingValue mXbaseanim{ mIndex, "Models", "xbaseanim" }; + SettingValue mBaseanim{ mIndex, "Models", "baseanim" }; + SettingValue mXbaseanim1st{ mIndex, "Models", "xbaseanim1st" }; + SettingValue mBaseanimkna{ mIndex, "Models", "baseanimkna" }; + SettingValue mBaseanimkna1st{ mIndex, "Models", "baseanimkna1st" }; + SettingValue mXbaseanimfemale{ mIndex, "Models", "xbaseanimfemale" }; + SettingValue mBaseanimfemale{ mIndex, "Models", "baseanimfemale" }; + SettingValue mBaseanimfemale1st{ mIndex, "Models", "baseanimfemale1st" }; + SettingValue mWolfskin{ mIndex, "Models", "wolfskin" }; + SettingValue mWolfskin1st{ mIndex, "Models", "wolfskin1st" }; + SettingValue mXargonianswimkna{ mIndex, "Models", "xargonianswimkna" }; + SettingValue mXbaseanimkf{ mIndex, "Models", "xbaseanimkf" }; + SettingValue mXbaseanim1stkf{ mIndex, "Models", "xbaseanim1stkf" }; + SettingValue mXbaseanimfemalekf{ mIndex, "Models", "xbaseanimfemalekf" }; + SettingValue mXargonianswimknakf{ mIndex, "Models", "xargonianswimknakf" }; + SettingValue mSkyatmosphere{ mIndex, "Models", "skyatmosphere" }; + SettingValue mSkyclouds{ mIndex, "Models", "skyclouds" }; + SettingValue mSkynight01{ mIndex, "Models", "skynight01" }; + SettingValue mSkynight02{ mIndex, "Models", "skynight02" }; + SettingValue mWeatherashcloud{ mIndex, "Models", "weatherashcloud" }; + SettingValue mWeatherblightcloud{ mIndex, "Models", "weatherblightcloud" }; + SettingValue mWeathersnow{ mIndex, "Models", "weathersnow" }; + SettingValue mWeatherblizzard{ mIndex, "Models", "weatherblizzard" }; + SettingValue mWriteNifDebugLog{ mIndex, "Models", "write nif debug log" }; }; } diff --git a/components/settings/categories/navigator.hpp b/components/settings/categories/navigator.hpp index e3766370f3..9dcf08d299 100644 --- a/components/settings/categories/navigator.hpp +++ b/components/settings/categories/navigator.hpp @@ -14,50 +14,55 @@ namespace Settings { - struct NavigatorCategory + struct NavigatorCategory : WithIndex { - SettingValue mEnable{ "Navigator", "enable" }; - SettingValue mRecastScaleFactor{ "Navigator", "recast scale factor", makeMaxStrictSanitizerFloat(0) }; - SettingValue mCellHeight{ "Navigator", "cell height", makeMaxStrictSanitizerFloat(0) }; - SettingValue mCellSize{ "Navigator", "cell size", makeMaxStrictSanitizerFloat(0) }; - SettingValue mDetailSampleDist{ "Navigator", "detail sample dist", + using WithIndex::WithIndex; + + SettingValue mEnable{ mIndex, "Navigator", "enable" }; + SettingValue mRecastScaleFactor{ mIndex, "Navigator", "recast scale factor", + makeMaxStrictSanitizerFloat(0) }; + SettingValue mCellHeight{ mIndex, "Navigator", "cell height", makeMaxStrictSanitizerFloat(0) }; + SettingValue mCellSize{ mIndex, "Navigator", "cell size", makeMaxStrictSanitizerFloat(0) }; + SettingValue mDetailSampleDist{ mIndex, "Navigator", "detail sample dist", makeEqualOrMaxSanitizerFloat(0, 0.9f) }; - SettingValue mDetailSampleMaxError{ "Navigator", "detail sample max error", makeMaxSanitizerFloat(0) }; - SettingValue mMaxSimplificationError{ "Navigator", "max simplification error", + SettingValue mDetailSampleMaxError{ mIndex, "Navigator", "detail sample max error", makeMaxSanitizerFloat(0) }; - SettingValue mTileSize{ "Navigator", "tile size", makeMaxSanitizerInt(1) }; - SettingValue mBorderSize{ "Navigator", "border size", makeMaxSanitizerInt(0) }; - SettingValue mMaxEdgeLen{ "Navigator", "max edge len", makeMaxSanitizerInt(0) }; - SettingValue mMaxNavMeshQueryNodes{ "Navigator", "max nav mesh query nodes", + SettingValue mMaxSimplificationError{ mIndex, "Navigator", "max simplification error", + makeMaxSanitizerFloat(0) }; + SettingValue mTileSize{ mIndex, "Navigator", "tile size", makeMaxSanitizerInt(1) }; + SettingValue mBorderSize{ mIndex, "Navigator", "border size", makeMaxSanitizerInt(0) }; + SettingValue mMaxEdgeLen{ mIndex, "Navigator", "max edge len", makeMaxSanitizerInt(0) }; + SettingValue mMaxNavMeshQueryNodes{ mIndex, "Navigator", "max nav mesh query nodes", makeClampSanitizerInt(1, 65535) }; - SettingValue mMaxPolygonsPerTile{ "Navigator", "max polygons per tile", + SettingValue mMaxPolygonsPerTile{ mIndex, "Navigator", "max polygons per tile", makeClampSanitizerInt(1, 1 << 21) }; - SettingValue mMaxVertsPerPoly{ "Navigator", "max verts per poly", makeMaxSanitizerInt(3) }; - SettingValue mRegionMergeArea{ "Navigator", "region merge area", makeMaxSanitizerInt(0) }; - SettingValue mRegionMinArea{ "Navigator", "region min area", makeMaxSanitizerInt(0) }; - SettingValue mAsyncNavMeshUpdaterThreads{ "Navigator", "async nav mesh updater threads", + SettingValue mMaxVertsPerPoly{ mIndex, "Navigator", "max verts per poly", makeMaxSanitizerInt(3) }; + SettingValue mRegionMergeArea{ mIndex, "Navigator", "region merge area", makeMaxSanitizerInt(0) }; + SettingValue mRegionMinArea{ mIndex, "Navigator", "region min area", makeMaxSanitizerInt(0) }; + SettingValue mAsyncNavMeshUpdaterThreads{ mIndex, "Navigator", "async nav mesh updater threads", makeMaxSanitizerSize(1) }; - SettingValue mMaxNavMeshTilesCacheSize{ "Navigator", "max nav mesh tiles cache size" }; - SettingValue mMaxPolygonPathSize{ "Navigator", "max polygon path size" }; - SettingValue mMaxSmoothPathSize{ "Navigator", "max smooth path size" }; - SettingValue mEnableWriteRecastMeshToFile{ "Navigator", "enable write recast mesh to file" }; - SettingValue mEnableWriteNavMeshToFile{ "Navigator", "enable write nav mesh to file" }; - SettingValue mEnableRecastMeshFileNameRevision{ "Navigator", "enable recast mesh file name revision" }; - SettingValue mEnableNavMeshFileNameRevision{ "Navigator", "enable nav mesh file name revision" }; - SettingValue mRecastMeshPathPrefix{ "Navigator", "recast mesh path prefix" }; - SettingValue mNavMeshPathPrefix{ "Navigator", "nav mesh path prefix" }; - SettingValue mEnableNavMeshRender{ "Navigator", "enable nav mesh render" }; - SettingValue mNavMeshRenderMode{ "Navigator", "nav mesh render mode", + SettingValue mMaxNavMeshTilesCacheSize{ mIndex, "Navigator", "max nav mesh tiles cache size" }; + SettingValue mMaxPolygonPathSize{ mIndex, "Navigator", "max polygon path size" }; + SettingValue mMaxSmoothPathSize{ mIndex, "Navigator", "max smooth path size" }; + SettingValue mEnableWriteRecastMeshToFile{ mIndex, "Navigator", "enable write recast mesh to file" }; + SettingValue mEnableWriteNavMeshToFile{ mIndex, "Navigator", "enable write nav mesh to file" }; + SettingValue mEnableRecastMeshFileNameRevision{ mIndex, "Navigator", + "enable recast mesh file name revision" }; + SettingValue mEnableNavMeshFileNameRevision{ mIndex, "Navigator", "enable nav mesh file name revision" }; + SettingValue mRecastMeshPathPrefix{ mIndex, "Navigator", "recast mesh path prefix" }; + SettingValue mNavMeshPathPrefix{ mIndex, "Navigator", "nav mesh path prefix" }; + SettingValue mEnableNavMeshRender{ mIndex, "Navigator", "enable nav mesh render" }; + SettingValue mNavMeshRenderMode{ mIndex, "Navigator", "nav mesh render mode", makeEnumSanitizerString({ "area type", "update frequency" }) }; - SettingValue mEnableAgentsPathsRender{ "Navigator", "enable agents paths render" }; - SettingValue mEnableRecastMeshRender{ "Navigator", "enable recast mesh render" }; - SettingValue mMaxTilesNumber{ "Navigator", "max tiles number", makeMaxSanitizerInt(0) }; - SettingValue mMinUpdateIntervalMs{ "Navigator", "min update interval ms", makeMaxSanitizerInt(0) }; - SettingValue mWaitUntilMinDistanceToPlayer{ "Navigator", "wait until min distance to player", + SettingValue mEnableAgentsPathsRender{ mIndex, "Navigator", "enable agents paths render" }; + SettingValue mEnableRecastMeshRender{ mIndex, "Navigator", "enable recast mesh render" }; + SettingValue mMaxTilesNumber{ mIndex, "Navigator", "max tiles number", makeMaxSanitizerInt(0) }; + SettingValue mMinUpdateIntervalMs{ mIndex, "Navigator", "min update interval ms", makeMaxSanitizerInt(0) }; + SettingValue mWaitUntilMinDistanceToPlayer{ mIndex, "Navigator", "wait until min distance to player", makeMaxSanitizerInt(0) }; - SettingValue mEnableNavMeshDiskCache{ "Navigator", "enable nav mesh disk cache" }; - SettingValue mWriteToNavmeshdb{ "Navigator", "write to navmeshdb" }; - SettingValue mMaxNavmeshdbFileSize{ "Navigator", "max navmeshdb file size" }; + SettingValue mEnableNavMeshDiskCache{ mIndex, "Navigator", "enable nav mesh disk cache" }; + SettingValue mWriteToNavmeshdb{ mIndex, "Navigator", "write to navmeshdb" }; + SettingValue mMaxNavmeshdbFileSize{ mIndex, "Navigator", "max navmeshdb file size" }; }; } diff --git a/components/settings/categories/physics.hpp b/components/settings/categories/physics.hpp index db02f72a98..41005a06cf 100644 --- a/components/settings/categories/physics.hpp +++ b/components/settings/categories/physics.hpp @@ -14,10 +14,12 @@ namespace Settings { - struct PhysicsCategory + struct PhysicsCategory : WithIndex { - SettingValue mAsyncNumThreads{ "Physics", "async num threads", makeMaxSanitizerInt(0) }; - SettingValue mLineofsightKeepInactiveCache{ "Physics", "lineofsight keep inactive cache", + using WithIndex::WithIndex; + + SettingValue mAsyncNumThreads{ mIndex, "Physics", "async num threads", makeMaxSanitizerInt(0) }; + SettingValue mLineofsightKeepInactiveCache{ mIndex, "Physics", "lineofsight keep inactive cache", makeMaxSanitizerInt(-1) }; }; } diff --git a/components/settings/categories/postprocessing.hpp b/components/settings/categories/postprocessing.hpp index 327ea95df4..b1e217b611 100644 --- a/components/settings/categories/postprocessing.hpp +++ b/components/settings/categories/postprocessing.hpp @@ -14,13 +14,15 @@ namespace Settings { - struct PostProcessingCategory + struct PostProcessingCategory : WithIndex { - SettingValue mEnabled{ "Post Processing", "enabled" }; - SettingValue mChain{ "Post Processing", "chain" }; - SettingValue mAutoExposureSpeed{ "Post Processing", "auto exposure speed", + using WithIndex::WithIndex; + + SettingValue mEnabled{ mIndex, "Post Processing", "enabled" }; + SettingValue mChain{ mIndex, "Post Processing", "chain" }; + SettingValue mAutoExposureSpeed{ mIndex, "Post Processing", "auto exposure speed", makeMaxStrictSanitizerFloat(0.0001f) }; - SettingValue mTransparentPostpass{ "Post Processing", "transparent postpass" }; + SettingValue mTransparentPostpass{ mIndex, "Post Processing", "transparent postpass" }; }; } diff --git a/components/settings/categories/saves.hpp b/components/settings/categories/saves.hpp index ecaf93fd20..e565d98564 100644 --- a/components/settings/categories/saves.hpp +++ b/components/settings/categories/saves.hpp @@ -14,12 +14,14 @@ namespace Settings { - struct SavesCategory + struct SavesCategory : WithIndex { - SettingValue mCharacter{ "Saves", "character" }; - SettingValue mAutosave{ "Saves", "autosave" }; - SettingValue mTimeplayed{ "Saves", "timeplayed" }; - SettingValue mMaxQuicksaves{ "Saves", "max quicksaves", makeMaxSanitizerInt(1) }; + using WithIndex::WithIndex; + + SettingValue mCharacter{ mIndex, "Saves", "character" }; + SettingValue mAutosave{ mIndex, "Saves", "autosave" }; + SettingValue mTimeplayed{ mIndex, "Saves", "timeplayed" }; + SettingValue mMaxQuicksaves{ mIndex, "Saves", "max quicksaves", makeMaxSanitizerInt(1) }; }; } diff --git a/components/settings/categories/shaders.hpp b/components/settings/categories/shaders.hpp index 3e04793c01..e7d1e34713 100644 --- a/components/settings/categories/shaders.hpp +++ b/components/settings/categories/shaders.hpp @@ -14,34 +14,36 @@ namespace Settings { - struct ShadersCategory + struct ShadersCategory : WithIndex { - SettingValue mForceShaders{ "Shaders", "force shaders" }; - SettingValue mForcePerPixelLighting{ "Shaders", "force per pixel lighting" }; - SettingValue mClampLighting{ "Shaders", "clamp lighting" }; - SettingValue mAutoUseObjectNormalMaps{ "Shaders", "auto use object normal maps" }; - SettingValue mAutoUseObjectSpecularMaps{ "Shaders", "auto use object specular maps" }; - SettingValue mAutoUseTerrainNormalMaps{ "Shaders", "auto use terrain normal maps" }; - SettingValue mAutoUseTerrainSpecularMaps{ "Shaders", "auto use terrain specular maps" }; - SettingValue mNormalMapPattern{ "Shaders", "normal map pattern" }; - SettingValue mNormalHeightMapPattern{ "Shaders", "normal height map pattern" }; - SettingValue mSpecularMapPattern{ "Shaders", "specular map pattern" }; - SettingValue mTerrainSpecularMapPattern{ "Shaders", "terrain specular map pattern" }; - SettingValue mApplyLightingToEnvironmentMaps{ "Shaders", "apply lighting to environment maps" }; - SettingValue mLightingMethod{ "Shaders", "lighting method", + using WithIndex::WithIndex; + + SettingValue mForceShaders{ mIndex, "Shaders", "force shaders" }; + SettingValue mForcePerPixelLighting{ mIndex, "Shaders", "force per pixel lighting" }; + SettingValue mClampLighting{ mIndex, "Shaders", "clamp lighting" }; + SettingValue mAutoUseObjectNormalMaps{ mIndex, "Shaders", "auto use object normal maps" }; + SettingValue mAutoUseObjectSpecularMaps{ mIndex, "Shaders", "auto use object specular maps" }; + SettingValue mAutoUseTerrainNormalMaps{ mIndex, "Shaders", "auto use terrain normal maps" }; + SettingValue mAutoUseTerrainSpecularMaps{ mIndex, "Shaders", "auto use terrain specular maps" }; + SettingValue mNormalMapPattern{ mIndex, "Shaders", "normal map pattern" }; + SettingValue mNormalHeightMapPattern{ mIndex, "Shaders", "normal height map pattern" }; + SettingValue mSpecularMapPattern{ mIndex, "Shaders", "specular map pattern" }; + SettingValue mTerrainSpecularMapPattern{ mIndex, "Shaders", "terrain specular map pattern" }; + SettingValue mApplyLightingToEnvironmentMaps{ mIndex, "Shaders", "apply lighting to environment maps" }; + SettingValue mLightingMethod{ mIndex, "Shaders", "lighting method", makeEnumSanitizerString({ "legacy", "shaders compatibility", "shaders" }) }; - SettingValue mLightBoundsMultiplier{ "Shaders", "light bounds multiplier", + SettingValue mLightBoundsMultiplier{ mIndex, "Shaders", "light bounds multiplier", makeClampSanitizerFloat(0, 5) }; - SettingValue mMaximumLightDistance{ "Shaders", "maximum light distance" }; - SettingValue mLightFadeStart{ "Shaders", "light fade start", makeClampSanitizerFloat(0, 1) }; - SettingValue mMaxLights{ "Shaders", "max lights", makeClampSanitizerInt(2, 64) }; - SettingValue mMinimumInteriorBrightness{ "Shaders", "minimum interior brightness", + SettingValue mMaximumLightDistance{ mIndex, "Shaders", "maximum light distance" }; + SettingValue mLightFadeStart{ mIndex, "Shaders", "light fade start", makeClampSanitizerFloat(0, 1) }; + SettingValue mMaxLights{ mIndex, "Shaders", "max lights", makeClampSanitizerInt(2, 64) }; + SettingValue mMinimumInteriorBrightness{ mIndex, "Shaders", "minimum interior brightness", makeClampSanitizerFloat(0, 1) }; - SettingValue mAntialiasAlphaTest{ "Shaders", "antialias alpha test" }; - SettingValue mAdjustCoverageForAlphaTest{ "Shaders", "adjust coverage for alpha test" }; - SettingValue mSoftParticles{ "Shaders", "soft particles" }; - SettingValue mWeatherParticleOcclusion{ "Shaders", "weather particle occlusion" }; - SettingValue mWeatherParticleOcclusionSmallFeatureCullingPixelSize{ "Shaders", + SettingValue mAntialiasAlphaTest{ mIndex, "Shaders", "antialias alpha test" }; + SettingValue mAdjustCoverageForAlphaTest{ mIndex, "Shaders", "adjust coverage for alpha test" }; + SettingValue mSoftParticles{ mIndex, "Shaders", "soft particles" }; + SettingValue mWeatherParticleOcclusion{ mIndex, "Shaders", "weather particle occlusion" }; + SettingValue mWeatherParticleOcclusionSmallFeatureCullingPixelSize{ mIndex, "Shaders", "weather particle occlusion small feature culling pixel size" }; }; } diff --git a/components/settings/categories/shadows.hpp b/components/settings/categories/shadows.hpp index 111f3ae5b4..d716272bce 100644 --- a/components/settings/categories/shadows.hpp +++ b/components/settings/categories/shadows.hpp @@ -14,32 +14,35 @@ namespace Settings { - struct ShadowsCategory + struct ShadowsCategory : WithIndex { - SettingValue mEnableShadows{ "Shadows", "enable shadows" }; - SettingValue mNumberOfShadowMaps{ "Shadows", "number of shadow maps", makeClampSanitizerInt(1, 8) }; - SettingValue mMaximumShadowMapDistance{ "Shadows", "maximum shadow map distance" }; - SettingValue mShadowFadeStart{ "Shadows", "shadow fade start", makeClampSanitizerFloat(0, 1) }; - SettingValue mAllowShadowMapOverlap{ "Shadows", "allow shadow map overlap" }; - SettingValue mSplitPointUniformLogarithmicRatio{ "Shadows", "split point uniform logarithmic ratio", - makeClampSanitizerFloat(0, 1) }; - SettingValue mSplitPointBias{ "Shadows", "split point bias" }; - SettingValue mEnableDebugHud{ "Shadows", "enable debug hud" }; - SettingValue mEnableDebugOverlay{ "Shadows", "enable debug overlay" }; - SettingValue mComputeSceneBounds{ "Shadows", "compute scene bounds", + using WithIndex::WithIndex; + + SettingValue mEnableShadows{ mIndex, "Shadows", "enable shadows" }; + SettingValue mNumberOfShadowMaps{ mIndex, "Shadows", "number of shadow maps", + makeClampSanitizerInt(1, 8) }; + SettingValue mMaximumShadowMapDistance{ mIndex, "Shadows", "maximum shadow map distance" }; + SettingValue mShadowFadeStart{ mIndex, "Shadows", "shadow fade start", makeClampSanitizerFloat(0, 1) }; + SettingValue mAllowShadowMapOverlap{ mIndex, "Shadows", "allow shadow map overlap" }; + SettingValue mSplitPointUniformLogarithmicRatio{ mIndex, "Shadows", + "split point uniform logarithmic ratio", makeClampSanitizerFloat(0, 1) }; + SettingValue mSplitPointBias{ mIndex, "Shadows", "split point bias" }; + SettingValue mEnableDebugHud{ mIndex, "Shadows", "enable debug hud" }; + SettingValue mEnableDebugOverlay{ mIndex, "Shadows", "enable debug overlay" }; + SettingValue mComputeSceneBounds{ mIndex, "Shadows", "compute scene bounds", makeEnumSanitizerString({ "primitives", "bounds", "none" }) }; - SettingValue mShadowMapResolution{ "Shadows", "shadow map resolution" }; - SettingValue mMinimumLispsmNearFarRatio{ "Shadows", "minimum lispsm near far ratio", + SettingValue mShadowMapResolution{ mIndex, "Shadows", "shadow map resolution" }; + SettingValue mMinimumLispsmNearFarRatio{ mIndex, "Shadows", "minimum lispsm near far ratio", makeMaxStrictSanitizerFloat(0) }; - SettingValue mPolygonOffsetFactor{ "Shadows", "polygon offset factor" }; - SettingValue mPolygonOffsetUnits{ "Shadows", "polygon offset units" }; - SettingValue mNormalOffsetDistance{ "Shadows", "normal offset distance" }; - SettingValue mUseFrontFaceCulling{ "Shadows", "use front face culling" }; - SettingValue mActorShadows{ "Shadows", "actor shadows" }; - SettingValue mPlayerShadows{ "Shadows", "player shadows" }; - SettingValue mTerrainShadows{ "Shadows", "terrain shadows" }; - SettingValue mObjectShadows{ "Shadows", "object shadows" }; - SettingValue mEnableIndoorShadows{ "Shadows", "enable indoor shadows" }; + SettingValue mPolygonOffsetFactor{ mIndex, "Shadows", "polygon offset factor" }; + SettingValue mPolygonOffsetUnits{ mIndex, "Shadows", "polygon offset units" }; + SettingValue mNormalOffsetDistance{ mIndex, "Shadows", "normal offset distance" }; + SettingValue mUseFrontFaceCulling{ mIndex, "Shadows", "use front face culling" }; + SettingValue mActorShadows{ mIndex, "Shadows", "actor shadows" }; + SettingValue mPlayerShadows{ mIndex, "Shadows", "player shadows" }; + SettingValue mTerrainShadows{ mIndex, "Shadows", "terrain shadows" }; + SettingValue mObjectShadows{ mIndex, "Shadows", "object shadows" }; + SettingValue mEnableIndoorShadows{ mIndex, "Shadows", "enable indoor shadows" }; }; } diff --git a/components/settings/categories/sound.hpp b/components/settings/categories/sound.hpp index f8cb59a43a..f4ce7e0269 100644 --- a/components/settings/categories/sound.hpp +++ b/components/settings/categories/sound.hpp @@ -14,18 +14,20 @@ namespace Settings { - struct SoundCategory + struct SoundCategory : WithIndex { - SettingValue mDevice{ "Sound", "device" }; - SettingValue mMasterVolume{ "Sound", "master volume", makeClampSanitizerFloat(0, 1) }; - SettingValue mFootstepsVolume{ "Sound", "footsteps volume", makeClampSanitizerFloat(0, 1) }; - SettingValue mMusicVolume{ "Sound", "music volume", makeClampSanitizerFloat(0, 1) }; - SettingValue mSfxVolume{ "Sound", "sfx volume", makeClampSanitizerFloat(0, 1) }; - SettingValue mVoiceVolume{ "Sound", "voice volume", makeClampSanitizerFloat(0, 1) }; - SettingValue mBufferCacheMin{ "Sound", "buffer cache min", makeMaxSanitizerInt(1) }; - SettingValue mBufferCacheMax{ "Sound", "buffer cache max", makeMaxSanitizerInt(1) }; - SettingValue mHrtfEnable{ "Sound", "hrtf enable", makeEnumSanitizerInt({ -1, 0, 1 }) }; - SettingValue mHrtf{ "Sound", "hrtf" }; + using WithIndex::WithIndex; + + SettingValue mDevice{ mIndex, "Sound", "device" }; + SettingValue mMasterVolume{ mIndex, "Sound", "master volume", makeClampSanitizerFloat(0, 1) }; + SettingValue mFootstepsVolume{ mIndex, "Sound", "footsteps volume", makeClampSanitizerFloat(0, 1) }; + SettingValue mMusicVolume{ mIndex, "Sound", "music volume", makeClampSanitizerFloat(0, 1) }; + SettingValue mSfxVolume{ mIndex, "Sound", "sfx volume", makeClampSanitizerFloat(0, 1) }; + SettingValue mVoiceVolume{ mIndex, "Sound", "voice volume", makeClampSanitizerFloat(0, 1) }; + SettingValue mBufferCacheMin{ mIndex, "Sound", "buffer cache min", makeMaxSanitizerInt(1) }; + SettingValue mBufferCacheMax{ mIndex, "Sound", "buffer cache max", makeMaxSanitizerInt(1) }; + SettingValue mHrtfEnable{ mIndex, "Sound", "hrtf enable", makeEnumSanitizerInt({ -1, 0, 1 }) }; + SettingValue mHrtf{ mIndex, "Sound", "hrtf" }; }; } diff --git a/components/settings/categories/stereo.hpp b/components/settings/categories/stereo.hpp index 4c24e5762f..46814f9458 100644 --- a/components/settings/categories/stereo.hpp +++ b/components/settings/categories/stereo.hpp @@ -14,14 +14,16 @@ namespace Settings { - struct StereoCategory + struct StereoCategory : WithIndex { - SettingValue mStereoEnabled{ "Stereo", "stereo enabled" }; - SettingValue mMultiview{ "Stereo", "multiview" }; - SettingValue mSharedShadowMaps{ "Stereo", "shared shadow maps" }; - SettingValue mAllowDisplayListsForMultiview{ "Stereo", "allow display lists for multiview" }; - SettingValue mUseCustomView{ "Stereo", "use custom view" }; - SettingValue mUseCustomEyeResolution{ "Stereo", "use custom eye resolution" }; + using WithIndex::WithIndex; + + SettingValue mStereoEnabled{ mIndex, "Stereo", "stereo enabled" }; + SettingValue mMultiview{ mIndex, "Stereo", "multiview" }; + SettingValue mSharedShadowMaps{ mIndex, "Stereo", "shared shadow maps" }; + SettingValue mAllowDisplayListsForMultiview{ mIndex, "Stereo", "allow display lists for multiview" }; + SettingValue mUseCustomView{ mIndex, "Stereo", "use custom view" }; + SettingValue mUseCustomEyeResolution{ mIndex, "Stereo", "use custom eye resolution" }; }; } diff --git a/components/settings/categories/stereoview.hpp b/components/settings/categories/stereoview.hpp index 492ea30d47..1e9d35ace8 100644 --- a/components/settings/categories/stereoview.hpp +++ b/components/settings/categories/stereoview.hpp @@ -14,47 +14,49 @@ namespace Settings { - struct StereoViewCategory + struct StereoViewCategory : WithIndex { - SettingValue mEyeResolutionX{ "Stereo View", "eye resolution x", makeMaxSanitizerInt(1) }; - SettingValue mEyeResolutionY{ "Stereo View", "eye resolution y", makeMaxSanitizerInt(1) }; - SettingValue mLeftEyeOffsetX{ "Stereo View", "left eye offset x" }; - SettingValue mLeftEyeOffsetY{ "Stereo View", "left eye offset y" }; - SettingValue mLeftEyeOffsetZ{ "Stereo View", "left eye offset z" }; - SettingValue mLeftEyeOrientationX{ "Stereo View", "left eye orientation x", + using WithIndex::WithIndex; + + SettingValue mEyeResolutionX{ mIndex, "Stereo View", "eye resolution x", makeMaxSanitizerInt(1) }; + SettingValue mEyeResolutionY{ mIndex, "Stereo View", "eye resolution y", makeMaxSanitizerInt(1) }; + SettingValue mLeftEyeOffsetX{ mIndex, "Stereo View", "left eye offset x" }; + SettingValue mLeftEyeOffsetY{ mIndex, "Stereo View", "left eye offset y" }; + SettingValue mLeftEyeOffsetZ{ mIndex, "Stereo View", "left eye offset z" }; + SettingValue mLeftEyeOrientationX{ mIndex, "Stereo View", "left eye orientation x", makeClampSanitizerDouble(-1, 1) }; - SettingValue mLeftEyeOrientationY{ "Stereo View", "left eye orientation y", + SettingValue mLeftEyeOrientationY{ mIndex, "Stereo View", "left eye orientation y", makeClampSanitizerDouble(-1, 1) }; - SettingValue mLeftEyeOrientationZ{ "Stereo View", "left eye orientation z", + SettingValue mLeftEyeOrientationZ{ mIndex, "Stereo View", "left eye orientation z", makeClampSanitizerDouble(-1, 1) }; - SettingValue mLeftEyeOrientationW{ "Stereo View", "left eye orientation w", + SettingValue mLeftEyeOrientationW{ mIndex, "Stereo View", "left eye orientation w", makeClampSanitizerDouble(-1, 1) }; - SettingValue mLeftEyeFovLeft{ "Stereo View", "left eye fov left", + SettingValue mLeftEyeFovLeft{ mIndex, "Stereo View", "left eye fov left", makeClampSanitizerDouble(-osg::PI, osg::PI) }; - SettingValue mLeftEyeFovRight{ "Stereo View", "left eye fov right", + SettingValue mLeftEyeFovRight{ mIndex, "Stereo View", "left eye fov right", makeClampSanitizerDouble(-osg::PI, osg::PI) }; - SettingValue mLeftEyeFovUp{ "Stereo View", "left eye fov up", + SettingValue mLeftEyeFovUp{ mIndex, "Stereo View", "left eye fov up", makeClampSanitizerDouble(-osg::PI, osg::PI) }; - SettingValue mLeftEyeFovDown{ "Stereo View", "left eye fov down", + SettingValue mLeftEyeFovDown{ mIndex, "Stereo View", "left eye fov down", makeClampSanitizerDouble(-osg::PI, osg::PI) }; - SettingValue mRightEyeOffsetX{ "Stereo View", "right eye offset x" }; - SettingValue mRightEyeOffsetY{ "Stereo View", "right eye offset y" }; - SettingValue mRightEyeOffsetZ{ "Stereo View", "right eye offset z" }; - SettingValue mRightEyeOrientationX{ "Stereo View", "right eye orientation x", + SettingValue mRightEyeOffsetX{ mIndex, "Stereo View", "right eye offset x" }; + SettingValue mRightEyeOffsetY{ mIndex, "Stereo View", "right eye offset y" }; + SettingValue mRightEyeOffsetZ{ mIndex, "Stereo View", "right eye offset z" }; + SettingValue mRightEyeOrientationX{ mIndex, "Stereo View", "right eye orientation x", makeClampSanitizerDouble(-1, 1) }; - SettingValue mRightEyeOrientationY{ "Stereo View", "right eye orientation y", + SettingValue mRightEyeOrientationY{ mIndex, "Stereo View", "right eye orientation y", makeClampSanitizerDouble(-1, 1) }; - SettingValue mRightEyeOrientationZ{ "Stereo View", "right eye orientation z", + SettingValue mRightEyeOrientationZ{ mIndex, "Stereo View", "right eye orientation z", makeClampSanitizerDouble(-1, 1) }; - SettingValue mRightEyeOrientationW{ "Stereo View", "right eye orientation w", + SettingValue mRightEyeOrientationW{ mIndex, "Stereo View", "right eye orientation w", makeClampSanitizerDouble(-1, 1) }; - SettingValue mRightEyeFovLeft{ "Stereo View", "right eye fov left", + SettingValue mRightEyeFovLeft{ mIndex, "Stereo View", "right eye fov left", makeClampSanitizerDouble(-osg::PI, osg::PI) }; - SettingValue mRightEyeFovRight{ "Stereo View", "right eye fov right", + SettingValue mRightEyeFovRight{ mIndex, "Stereo View", "right eye fov right", makeClampSanitizerDouble(-osg::PI, osg::PI) }; - SettingValue mRightEyeFovUp{ "Stereo View", "right eye fov up", + SettingValue mRightEyeFovUp{ mIndex, "Stereo View", "right eye fov up", makeClampSanitizerDouble(-osg::PI, osg::PI) }; - SettingValue mRightEyeFovDown{ "Stereo View", "right eye fov down", + SettingValue mRightEyeFovDown{ mIndex, "Stereo View", "right eye fov down", makeClampSanitizerDouble(-osg::PI, osg::PI) }; }; } diff --git a/components/settings/categories/terrain.hpp b/components/settings/categories/terrain.hpp index 6c8d1b035c..c2eef9dc20 100644 --- a/components/settings/categories/terrain.hpp +++ b/components/settings/categories/terrain.hpp @@ -14,25 +14,29 @@ namespace Settings { - struct TerrainCategory + struct TerrainCategory : WithIndex { - SettingValue mDistantTerrain{ "Terrain", "distant terrain" }; - SettingValue mLodFactor{ "Terrain", "lod factor", makeMaxStrictSanitizerFloat(0) }; - SettingValue mVertexLodMod{ "Terrain", "vertex lod mod" }; - SettingValue mCompositeMapLevel{ "Terrain", "composite map level", makeMaxSanitizerInt(-3) }; - SettingValue mCompositeMapResolution{ "Terrain", "composite map resolution", makeMaxSanitizerInt(1) }; - SettingValue mMaxCompositeGeometrySize{ "Terrain", "max composite geometry size", + using WithIndex::WithIndex; + + SettingValue mDistantTerrain{ mIndex, "Terrain", "distant terrain" }; + SettingValue mLodFactor{ mIndex, "Terrain", "lod factor", makeMaxStrictSanitizerFloat(0) }; + SettingValue mVertexLodMod{ mIndex, "Terrain", "vertex lod mod" }; + SettingValue mCompositeMapLevel{ mIndex, "Terrain", "composite map level", makeMaxSanitizerInt(-3) }; + SettingValue mCompositeMapResolution{ mIndex, "Terrain", "composite map resolution", + makeMaxSanitizerInt(1) }; + SettingValue mMaxCompositeGeometrySize{ mIndex, "Terrain", "max composite geometry size", makeMaxSanitizerFloat(1) }; - SettingValue mDebugChunks{ "Terrain", "debug chunks" }; - SettingValue mObjectPaging{ "Terrain", "object paging" }; - SettingValue mObjectPagingActiveGrid{ "Terrain", "object paging active grid" }; - SettingValue mObjectPagingMergeFactor{ "Terrain", "object paging merge factor", + SettingValue mDebugChunks{ mIndex, "Terrain", "debug chunks" }; + SettingValue mObjectPaging{ mIndex, "Terrain", "object paging" }; + SettingValue mObjectPagingActiveGrid{ mIndex, "Terrain", "object paging active grid" }; + SettingValue mObjectPagingMergeFactor{ mIndex, "Terrain", "object paging merge factor", makeMaxStrictSanitizerFloat(0) }; - SettingValue mObjectPagingMinSize{ "Terrain", "object paging min size", makeMaxStrictSanitizerFloat(0) }; - SettingValue mObjectPagingMinSizeMergeFactor{ "Terrain", "object paging min size merge factor", + SettingValue mObjectPagingMinSize{ mIndex, "Terrain", "object paging min size", makeMaxStrictSanitizerFloat(0) }; - SettingValue mObjectPagingMinSizeCostMultiplier{ "Terrain", "object paging min size cost multiplier", + SettingValue mObjectPagingMinSizeMergeFactor{ mIndex, "Terrain", "object paging min size merge factor", makeMaxStrictSanitizerFloat(0) }; + SettingValue mObjectPagingMinSizeCostMultiplier{ mIndex, "Terrain", + "object paging min size cost multiplier", makeMaxStrictSanitizerFloat(0) }; }; } diff --git a/components/settings/categories/video.hpp b/components/settings/categories/video.hpp index 430785f804..a91a6c8b03 100644 --- a/components/settings/categories/video.hpp +++ b/components/settings/categories/video.hpp @@ -14,20 +14,22 @@ namespace Settings { - struct VideoCategory + struct VideoCategory : WithIndex { - SettingValue mResolutionX{ "Video", "resolution x", makeMaxSanitizerInt(1) }; - SettingValue mResolutionY{ "Video", "resolution y", makeMaxSanitizerInt(1) }; - SettingValue mWindowMode{ "Video", "window mode", makeEnumSanitizerInt({ 0, 1, 2 }) }; - SettingValue mScreen{ "Video", "screen", makeMaxSanitizerInt(0) }; - SettingValue mMinimizeOnFocusLoss{ "Video", "minimize on focus loss" }; - SettingValue mWindowBorder{ "Video", "window border" }; - SettingValue mAntialiasing{ "Video", "antialiasing", makeEnumSanitizerInt({ 0, 2, 4, 8, 16 }) }; - SettingValue mVsyncMode{ "Video", "vsync mode", makeEnumSanitizerInt({ 0, 1, 2 }) }; - SettingValue mFramerateLimit{ "Video", "framerate limit", makeMaxSanitizerFloat(0) }; - SettingValue mContrast{ "Video", "contrast", makeMaxStrictSanitizerFloat(0) }; - SettingValue mGamma{ "Video", "gamma", makeMaxStrictSanitizerFloat(0) }; - SettingValue mScreenshotType{ "Video", "screenshot type" }; + using WithIndex::WithIndex; + + SettingValue mResolutionX{ mIndex, "Video", "resolution x", makeMaxSanitizerInt(1) }; + SettingValue mResolutionY{ mIndex, "Video", "resolution y", makeMaxSanitizerInt(1) }; + SettingValue mWindowMode{ mIndex, "Video", "window mode", makeEnumSanitizerInt({ 0, 1, 2 }) }; + SettingValue mScreen{ mIndex, "Video", "screen", makeMaxSanitizerInt(0) }; + SettingValue mMinimizeOnFocusLoss{ mIndex, "Video", "minimize on focus loss" }; + SettingValue mWindowBorder{ mIndex, "Video", "window border" }; + SettingValue mAntialiasing{ mIndex, "Video", "antialiasing", makeEnumSanitizerInt({ 0, 2, 4, 8, 16 }) }; + SettingValue mVsyncMode{ mIndex, "Video", "vsync mode", makeEnumSanitizerInt({ 0, 1, 2 }) }; + SettingValue mFramerateLimit{ mIndex, "Video", "framerate limit", makeMaxSanitizerFloat(0) }; + SettingValue mContrast{ mIndex, "Video", "contrast", makeMaxStrictSanitizerFloat(0) }; + SettingValue mGamma{ mIndex, "Video", "gamma", makeMaxStrictSanitizerFloat(0) }; + SettingValue mScreenshotType{ mIndex, "Video", "screenshot type" }; }; } diff --git a/components/settings/categories/water.hpp b/components/settings/categories/water.hpp index 97c466bc61..02b5f0c5dd 100644 --- a/components/settings/categories/water.hpp +++ b/components/settings/categories/water.hpp @@ -14,16 +14,19 @@ namespace Settings { - struct WaterCategory + struct WaterCategory : WithIndex { - SettingValue mShader{ "Water", "shader" }; - SettingValue mRttSize{ "Water", "rtt size", makeMaxSanitizerInt(1) }; - SettingValue mRefraction{ "Water", "refraction" }; - SettingValue mReflectionDetail{ "Water", "reflection detail", makeEnumSanitizerInt({ 0, 1, 2, 3, 4, 5 }) }; - SettingValue mRainRippleDetail{ "Water", "rain ripple detail", makeEnumSanitizerInt({ 0, 1, 2 }) }; - SettingValue mSmallFeatureCullingPixelSize{ "Water", "small feature culling pixel size", + using WithIndex::WithIndex; + + SettingValue mShader{ mIndex, "Water", "shader" }; + SettingValue mRttSize{ mIndex, "Water", "rtt size", makeMaxSanitizerInt(1) }; + SettingValue mRefraction{ mIndex, "Water", "refraction" }; + SettingValue mReflectionDetail{ mIndex, "Water", "reflection detail", + makeEnumSanitizerInt({ 0, 1, 2, 3, 4, 5 }) }; + SettingValue mRainRippleDetail{ mIndex, "Water", "rain ripple detail", makeEnumSanitizerInt({ 0, 1, 2 }) }; + SettingValue mSmallFeatureCullingPixelSize{ mIndex, "Water", "small feature culling pixel size", makeMaxStrictSanitizerFloat(0) }; - SettingValue mRefractionScale{ "Water", "refraction scale", makeClampSanitizerFloat(0, 1) }; + SettingValue mRefractionScale{ mIndex, "Water", "refraction scale", makeClampSanitizerFloat(0, 1) }; }; } diff --git a/components/settings/categories/windows.hpp b/components/settings/categories/windows.hpp index f472166ab5..77927c1204 100644 --- a/components/settings/categories/windows.hpp +++ b/components/settings/categories/windows.hpp @@ -14,151 +14,153 @@ namespace Settings { - struct WindowsCategory + struct WindowsCategory : WithIndex { - SettingValue mStatsX{ "Windows", "stats x" }; - SettingValue mStatsY{ "Windows", "stats y" }; - SettingValue mStatsW{ "Windows", "stats w" }; - SettingValue mStatsH{ "Windows", "stats h" }; - SettingValue mStatsMaximizedX{ "Windows", "stats maximized x" }; - SettingValue mStatsMaximizedY{ "Windows", "stats maximized y" }; - SettingValue mStatsMaximizedW{ "Windows", "stats maximized w" }; - SettingValue mStatsMaximizedH{ "Windows", "stats maximized h" }; - SettingValue mStatsPin{ "Windows", "stats pin" }; - SettingValue mStatsHidden{ "Windows", "stats hidden" }; - SettingValue mStatsMaximized{ "Windows", "stats maximized" }; - SettingValue mSpellsX{ "Windows", "spells x" }; - SettingValue mSpellsY{ "Windows", "spells y" }; - SettingValue mSpellsW{ "Windows", "spells w" }; - SettingValue mSpellsH{ "Windows", "spells h" }; - SettingValue mSpellsMaximizedX{ "Windows", "spells maximized x" }; - SettingValue mSpellsMaximizedY{ "Windows", "spells maximized y" }; - SettingValue mSpellsMaximizedW{ "Windows", "spells maximized w" }; - SettingValue mSpellsMaximizedH{ "Windows", "spells maximized h" }; - SettingValue mSpellsPin{ "Windows", "spells pin" }; - SettingValue mSpellsHidden{ "Windows", "spells hidden" }; - SettingValue mSpellsMaximized{ "Windows", "spells maximized" }; - SettingValue mMapX{ "Windows", "map x" }; - SettingValue mMapY{ "Windows", "map y" }; - SettingValue mMapW{ "Windows", "map w" }; - SettingValue mMapH{ "Windows", "map h" }; - SettingValue mMapMaximizedX{ "Windows", "map maximized x" }; - SettingValue mMapMaximizedY{ "Windows", "map maximized y" }; - SettingValue mMapMaximizedW{ "Windows", "map maximized w" }; - SettingValue mMapMaximizedH{ "Windows", "map maximized h" }; - SettingValue mMapPin{ "Windows", "map pin" }; - SettingValue mMapHidden{ "Windows", "map hidden" }; - SettingValue mMapMaximized{ "Windows", "map maximized" }; - SettingValue mInventoryX{ "Windows", "inventory x" }; - SettingValue mInventoryY{ "Windows", "inventory y" }; - SettingValue mInventoryW{ "Windows", "inventory w" }; - SettingValue mInventoryH{ "Windows", "inventory h" }; - SettingValue mInventoryMaximizedX{ "Windows", "inventory maximized x" }; - SettingValue mInventoryMaximizedY{ "Windows", "inventory maximized y" }; - SettingValue mInventoryMaximizedW{ "Windows", "inventory maximized w" }; - SettingValue mInventoryMaximizedH{ "Windows", "inventory maximized h" }; - SettingValue mInventoryPin{ "Windows", "inventory pin" }; - SettingValue mInventoryHidden{ "Windows", "inventory hidden" }; - SettingValue mInventoryMaximized{ "Windows", "inventory maximized" }; - SettingValue mInventoryContainerX{ "Windows", "inventory container x" }; - SettingValue mInventoryContainerY{ "Windows", "inventory container y" }; - SettingValue mInventoryContainerW{ "Windows", "inventory container w" }; - SettingValue mInventoryContainerH{ "Windows", "inventory container h" }; - SettingValue mInventoryContainerMaximizedX{ "Windows", "inventory container maximized x" }; - SettingValue mInventoryContainerMaximizedY{ "Windows", "inventory container maximized y" }; - SettingValue mInventoryContainerMaximizedW{ "Windows", "inventory container maximized w" }; - SettingValue mInventoryContainerMaximizedH{ "Windows", "inventory container maximized h" }; - SettingValue mInventoryContainerMaximized{ "Windows", "inventory container maximized" }; - SettingValue mInventoryBarterX{ "Windows", "inventory barter x" }; - SettingValue mInventoryBarterY{ "Windows", "inventory barter y" }; - SettingValue mInventoryBarterW{ "Windows", "inventory barter w" }; - SettingValue mInventoryBarterH{ "Windows", "inventory barter h" }; - SettingValue mInventoryBarterMaximizedX{ "Windows", "inventory barter maximized x" }; - SettingValue mInventoryBarterMaximizedY{ "Windows", "inventory barter maximized y" }; - SettingValue mInventoryBarterMaximizedW{ "Windows", "inventory barter maximized w" }; - SettingValue mInventoryBarterMaximizedH{ "Windows", "inventory barter maximized h" }; - SettingValue mInventoryBarterMaximized{ "Windows", "inventory barter maximized" }; - SettingValue mInventoryCompanionX{ "Windows", "inventory companion x" }; - SettingValue mInventoryCompanionY{ "Windows", "inventory companion y" }; - SettingValue mInventoryCompanionW{ "Windows", "inventory companion w" }; - SettingValue mInventoryCompanionH{ "Windows", "inventory companion h" }; - SettingValue mInventoryCompanionMaximizedX{ "Windows", "inventory companion maximized x" }; - SettingValue mInventoryCompanionMaximizedY{ "Windows", "inventory companion maximized y" }; - SettingValue mInventoryCompanionMaximizedW{ "Windows", "inventory companion maximized w" }; - SettingValue mInventoryCompanionMaximizedH{ "Windows", "inventory companion maximized h" }; - SettingValue mInventoryCompanionMaximized{ "Windows", "inventory companion maximized" }; - SettingValue mDialogueX{ "Windows", "dialogue x" }; - SettingValue mDialogueY{ "Windows", "dialogue y" }; - SettingValue mDialogueW{ "Windows", "dialogue w" }; - SettingValue mDialogueH{ "Windows", "dialogue h" }; - SettingValue mDialogueMaximizedX{ "Windows", "dialogue maximized x" }; - SettingValue mDialogueMaximizedY{ "Windows", "dialogue maximized y" }; - SettingValue mDialogueMaximizedW{ "Windows", "dialogue maximized w" }; - SettingValue mDialogueMaximizedH{ "Windows", "dialogue maximized h" }; - SettingValue mDialogueMaximized{ "Windows", "dialogue maximized" }; - SettingValue mAlchemyX{ "Windows", "alchemy x" }; - SettingValue mAlchemyY{ "Windows", "alchemy y" }; - SettingValue mAlchemyW{ "Windows", "alchemy w" }; - SettingValue mAlchemyH{ "Windows", "alchemy h" }; - SettingValue mAlchemyMaximizedX{ "Windows", "alchemy maximized x" }; - SettingValue mAlchemyMaximizedY{ "Windows", "alchemy maximized y" }; - SettingValue mAlchemyMaximizedW{ "Windows", "alchemy maximized w" }; - SettingValue mAlchemyMaximizedH{ "Windows", "alchemy maximized h" }; - SettingValue mAlchemyMaximized{ "Windows", "alchemy maximized" }; - SettingValue mConsoleX{ "Windows", "console x" }; - SettingValue mConsoleY{ "Windows", "console y" }; - SettingValue mConsoleW{ "Windows", "console w" }; - SettingValue mConsoleH{ "Windows", "console h" }; - SettingValue mConsoleMaximizedX{ "Windows", "console maximized x" }; - SettingValue mConsoleMaximizedY{ "Windows", "console maximized y" }; - SettingValue mConsoleMaximizedW{ "Windows", "console maximized w" }; - SettingValue mConsoleMaximizedH{ "Windows", "console maximized h" }; - SettingValue mConsoleMaximized{ "Windows", "console maximized" }; - SettingValue mContainerX{ "Windows", "container x" }; - SettingValue mContainerY{ "Windows", "container y" }; - SettingValue mContainerW{ "Windows", "container w" }; - SettingValue mContainerH{ "Windows", "container h" }; - SettingValue mContainerMaximizedX{ "Windows", "container maximized x" }; - SettingValue mContainerMaximizedY{ "Windows", "container maximized y" }; - SettingValue mContainerMaximizedW{ "Windows", "container maximized w" }; - SettingValue mContainerMaximizedH{ "Windows", "container maximized h" }; - SettingValue mContainerMaximized{ "Windows", "container maximized" }; - SettingValue mBarterX{ "Windows", "barter x" }; - SettingValue mBarterY{ "Windows", "barter y" }; - SettingValue mBarterW{ "Windows", "barter w" }; - SettingValue mBarterH{ "Windows", "barter h" }; - SettingValue mBarterMaximizedX{ "Windows", "barter maximized x" }; - SettingValue mBarterMaximizedY{ "Windows", "barter maximized y" }; - SettingValue mBarterMaximizedW{ "Windows", "barter maximized w" }; - SettingValue mBarterMaximizedH{ "Windows", "barter maximized h" }; - SettingValue mBarterMaximized{ "Windows", "barter maximized" }; - SettingValue mCompanionX{ "Windows", "companion x" }; - SettingValue mCompanionY{ "Windows", "companion y" }; - SettingValue mCompanionW{ "Windows", "companion w" }; - SettingValue mCompanionH{ "Windows", "companion h" }; - SettingValue mCompanionMaximizedX{ "Windows", "companion maximized x" }; - SettingValue mCompanionMaximizedY{ "Windows", "companion maximized y" }; - SettingValue mCompanionMaximizedW{ "Windows", "companion maximized w" }; - SettingValue mCompanionMaximizedH{ "Windows", "companion maximized h" }; - SettingValue mCompanionMaximized{ "Windows", "companion maximized" }; - SettingValue mSettingsX{ "Windows", "settings x" }; - SettingValue mSettingsY{ "Windows", "settings y" }; - SettingValue mSettingsW{ "Windows", "settings w" }; - SettingValue mSettingsH{ "Windows", "settings h" }; - SettingValue mSettingsMaximizedX{ "Windows", "settings maximized x" }; - SettingValue mSettingsMaximizedY{ "Windows", "settings maximized y" }; - SettingValue mSettingsMaximizedW{ "Windows", "settings maximized w" }; - SettingValue mSettingsMaximizedH{ "Windows", "settings maximized h" }; - SettingValue mSettingsMaximized{ "Windows", "settings maximized" }; - SettingValue mPostprocessorH{ "Windows", "postprocessor h" }; - SettingValue mPostprocessorW{ "Windows", "postprocessor w" }; - SettingValue mPostprocessorX{ "Windows", "postprocessor x" }; - SettingValue mPostprocessorY{ "Windows", "postprocessor y" }; - SettingValue mPostprocessorMaximizedX{ "Windows", "postprocessor maximized x" }; - SettingValue mPostprocessorMaximizedY{ "Windows", "postprocessor maximized y" }; - SettingValue mPostprocessorMaximizedW{ "Windows", "postprocessor maximized w" }; - SettingValue mPostprocessorMaximizedH{ "Windows", "postprocessor maximized h" }; - SettingValue mPostprocessorMaximized{ "Windows", "postprocessor maximized" }; + using WithIndex::WithIndex; + + SettingValue mStatsX{ mIndex, "Windows", "stats x" }; + SettingValue mStatsY{ mIndex, "Windows", "stats y" }; + SettingValue mStatsW{ mIndex, "Windows", "stats w" }; + SettingValue mStatsH{ mIndex, "Windows", "stats h" }; + SettingValue mStatsMaximizedX{ mIndex, "Windows", "stats maximized x" }; + SettingValue mStatsMaximizedY{ mIndex, "Windows", "stats maximized y" }; + SettingValue mStatsMaximizedW{ mIndex, "Windows", "stats maximized w" }; + SettingValue mStatsMaximizedH{ mIndex, "Windows", "stats maximized h" }; + SettingValue mStatsPin{ mIndex, "Windows", "stats pin" }; + SettingValue mStatsHidden{ mIndex, "Windows", "stats hidden" }; + SettingValue mStatsMaximized{ mIndex, "Windows", "stats maximized" }; + SettingValue mSpellsX{ mIndex, "Windows", "spells x" }; + SettingValue mSpellsY{ mIndex, "Windows", "spells y" }; + SettingValue mSpellsW{ mIndex, "Windows", "spells w" }; + SettingValue mSpellsH{ mIndex, "Windows", "spells h" }; + SettingValue mSpellsMaximizedX{ mIndex, "Windows", "spells maximized x" }; + SettingValue mSpellsMaximizedY{ mIndex, "Windows", "spells maximized y" }; + SettingValue mSpellsMaximizedW{ mIndex, "Windows", "spells maximized w" }; + SettingValue mSpellsMaximizedH{ mIndex, "Windows", "spells maximized h" }; + SettingValue mSpellsPin{ mIndex, "Windows", "spells pin" }; + SettingValue mSpellsHidden{ mIndex, "Windows", "spells hidden" }; + SettingValue mSpellsMaximized{ mIndex, "Windows", "spells maximized" }; + SettingValue mMapX{ mIndex, "Windows", "map x" }; + SettingValue mMapY{ mIndex, "Windows", "map y" }; + SettingValue mMapW{ mIndex, "Windows", "map w" }; + SettingValue mMapH{ mIndex, "Windows", "map h" }; + SettingValue mMapMaximizedX{ mIndex, "Windows", "map maximized x" }; + SettingValue mMapMaximizedY{ mIndex, "Windows", "map maximized y" }; + SettingValue mMapMaximizedW{ mIndex, "Windows", "map maximized w" }; + SettingValue mMapMaximizedH{ mIndex, "Windows", "map maximized h" }; + SettingValue mMapPin{ mIndex, "Windows", "map pin" }; + SettingValue mMapHidden{ mIndex, "Windows", "map hidden" }; + SettingValue mMapMaximized{ mIndex, "Windows", "map maximized" }; + SettingValue mInventoryX{ mIndex, "Windows", "inventory x" }; + SettingValue mInventoryY{ mIndex, "Windows", "inventory y" }; + SettingValue mInventoryW{ mIndex, "Windows", "inventory w" }; + SettingValue mInventoryH{ mIndex, "Windows", "inventory h" }; + SettingValue mInventoryMaximizedX{ mIndex, "Windows", "inventory maximized x" }; + SettingValue mInventoryMaximizedY{ mIndex, "Windows", "inventory maximized y" }; + SettingValue mInventoryMaximizedW{ mIndex, "Windows", "inventory maximized w" }; + SettingValue mInventoryMaximizedH{ mIndex, "Windows", "inventory maximized h" }; + SettingValue mInventoryPin{ mIndex, "Windows", "inventory pin" }; + SettingValue mInventoryHidden{ mIndex, "Windows", "inventory hidden" }; + SettingValue mInventoryMaximized{ mIndex, "Windows", "inventory maximized" }; + SettingValue mInventoryContainerX{ mIndex, "Windows", "inventory container x" }; + SettingValue mInventoryContainerY{ mIndex, "Windows", "inventory container y" }; + SettingValue mInventoryContainerW{ mIndex, "Windows", "inventory container w" }; + SettingValue mInventoryContainerH{ mIndex, "Windows", "inventory container h" }; + SettingValue mInventoryContainerMaximizedX{ mIndex, "Windows", "inventory container maximized x" }; + SettingValue mInventoryContainerMaximizedY{ mIndex, "Windows", "inventory container maximized y" }; + SettingValue mInventoryContainerMaximizedW{ mIndex, "Windows", "inventory container maximized w" }; + SettingValue mInventoryContainerMaximizedH{ mIndex, "Windows", "inventory container maximized h" }; + SettingValue mInventoryContainerMaximized{ mIndex, "Windows", "inventory container maximized" }; + SettingValue mInventoryBarterX{ mIndex, "Windows", "inventory barter x" }; + SettingValue mInventoryBarterY{ mIndex, "Windows", "inventory barter y" }; + SettingValue mInventoryBarterW{ mIndex, "Windows", "inventory barter w" }; + SettingValue mInventoryBarterH{ mIndex, "Windows", "inventory barter h" }; + SettingValue mInventoryBarterMaximizedX{ mIndex, "Windows", "inventory barter maximized x" }; + SettingValue mInventoryBarterMaximizedY{ mIndex, "Windows", "inventory barter maximized y" }; + SettingValue mInventoryBarterMaximizedW{ mIndex, "Windows", "inventory barter maximized w" }; + SettingValue mInventoryBarterMaximizedH{ mIndex, "Windows", "inventory barter maximized h" }; + SettingValue mInventoryBarterMaximized{ mIndex, "Windows", "inventory barter maximized" }; + SettingValue mInventoryCompanionX{ mIndex, "Windows", "inventory companion x" }; + SettingValue mInventoryCompanionY{ mIndex, "Windows", "inventory companion y" }; + SettingValue mInventoryCompanionW{ mIndex, "Windows", "inventory companion w" }; + SettingValue mInventoryCompanionH{ mIndex, "Windows", "inventory companion h" }; + SettingValue mInventoryCompanionMaximizedX{ mIndex, "Windows", "inventory companion maximized x" }; + SettingValue mInventoryCompanionMaximizedY{ mIndex, "Windows", "inventory companion maximized y" }; + SettingValue mInventoryCompanionMaximizedW{ mIndex, "Windows", "inventory companion maximized w" }; + SettingValue mInventoryCompanionMaximizedH{ mIndex, "Windows", "inventory companion maximized h" }; + SettingValue mInventoryCompanionMaximized{ mIndex, "Windows", "inventory companion maximized" }; + SettingValue mDialogueX{ mIndex, "Windows", "dialogue x" }; + SettingValue mDialogueY{ mIndex, "Windows", "dialogue y" }; + SettingValue mDialogueW{ mIndex, "Windows", "dialogue w" }; + SettingValue mDialogueH{ mIndex, "Windows", "dialogue h" }; + SettingValue mDialogueMaximizedX{ mIndex, "Windows", "dialogue maximized x" }; + SettingValue mDialogueMaximizedY{ mIndex, "Windows", "dialogue maximized y" }; + SettingValue mDialogueMaximizedW{ mIndex, "Windows", "dialogue maximized w" }; + SettingValue mDialogueMaximizedH{ mIndex, "Windows", "dialogue maximized h" }; + SettingValue mDialogueMaximized{ mIndex, "Windows", "dialogue maximized" }; + SettingValue mAlchemyX{ mIndex, "Windows", "alchemy x" }; + SettingValue mAlchemyY{ mIndex, "Windows", "alchemy y" }; + SettingValue mAlchemyW{ mIndex, "Windows", "alchemy w" }; + SettingValue mAlchemyH{ mIndex, "Windows", "alchemy h" }; + SettingValue mAlchemyMaximizedX{ mIndex, "Windows", "alchemy maximized x" }; + SettingValue mAlchemyMaximizedY{ mIndex, "Windows", "alchemy maximized y" }; + SettingValue mAlchemyMaximizedW{ mIndex, "Windows", "alchemy maximized w" }; + SettingValue mAlchemyMaximizedH{ mIndex, "Windows", "alchemy maximized h" }; + SettingValue mAlchemyMaximized{ mIndex, "Windows", "alchemy maximized" }; + SettingValue mConsoleX{ mIndex, "Windows", "console x" }; + SettingValue mConsoleY{ mIndex, "Windows", "console y" }; + SettingValue mConsoleW{ mIndex, "Windows", "console w" }; + SettingValue mConsoleH{ mIndex, "Windows", "console h" }; + SettingValue mConsoleMaximizedX{ mIndex, "Windows", "console maximized x" }; + SettingValue mConsoleMaximizedY{ mIndex, "Windows", "console maximized y" }; + SettingValue mConsoleMaximizedW{ mIndex, "Windows", "console maximized w" }; + SettingValue mConsoleMaximizedH{ mIndex, "Windows", "console maximized h" }; + SettingValue mConsoleMaximized{ mIndex, "Windows", "console maximized" }; + SettingValue mContainerX{ mIndex, "Windows", "container x" }; + SettingValue mContainerY{ mIndex, "Windows", "container y" }; + SettingValue mContainerW{ mIndex, "Windows", "container w" }; + SettingValue mContainerH{ mIndex, "Windows", "container h" }; + SettingValue mContainerMaximizedX{ mIndex, "Windows", "container maximized x" }; + SettingValue mContainerMaximizedY{ mIndex, "Windows", "container maximized y" }; + SettingValue mContainerMaximizedW{ mIndex, "Windows", "container maximized w" }; + SettingValue mContainerMaximizedH{ mIndex, "Windows", "container maximized h" }; + SettingValue mContainerMaximized{ mIndex, "Windows", "container maximized" }; + SettingValue mBarterX{ mIndex, "Windows", "barter x" }; + SettingValue mBarterY{ mIndex, "Windows", "barter y" }; + SettingValue mBarterW{ mIndex, "Windows", "barter w" }; + SettingValue mBarterH{ mIndex, "Windows", "barter h" }; + SettingValue mBarterMaximizedX{ mIndex, "Windows", "barter maximized x" }; + SettingValue mBarterMaximizedY{ mIndex, "Windows", "barter maximized y" }; + SettingValue mBarterMaximizedW{ mIndex, "Windows", "barter maximized w" }; + SettingValue mBarterMaximizedH{ mIndex, "Windows", "barter maximized h" }; + SettingValue mBarterMaximized{ mIndex, "Windows", "barter maximized" }; + SettingValue mCompanionX{ mIndex, "Windows", "companion x" }; + SettingValue mCompanionY{ mIndex, "Windows", "companion y" }; + SettingValue mCompanionW{ mIndex, "Windows", "companion w" }; + SettingValue mCompanionH{ mIndex, "Windows", "companion h" }; + SettingValue mCompanionMaximizedX{ mIndex, "Windows", "companion maximized x" }; + SettingValue mCompanionMaximizedY{ mIndex, "Windows", "companion maximized y" }; + SettingValue mCompanionMaximizedW{ mIndex, "Windows", "companion maximized w" }; + SettingValue mCompanionMaximizedH{ mIndex, "Windows", "companion maximized h" }; + SettingValue mCompanionMaximized{ mIndex, "Windows", "companion maximized" }; + SettingValue mSettingsX{ mIndex, "Windows", "settings x" }; + SettingValue mSettingsY{ mIndex, "Windows", "settings y" }; + SettingValue mSettingsW{ mIndex, "Windows", "settings w" }; + SettingValue mSettingsH{ mIndex, "Windows", "settings h" }; + SettingValue mSettingsMaximizedX{ mIndex, "Windows", "settings maximized x" }; + SettingValue mSettingsMaximizedY{ mIndex, "Windows", "settings maximized y" }; + SettingValue mSettingsMaximizedW{ mIndex, "Windows", "settings maximized w" }; + SettingValue mSettingsMaximizedH{ mIndex, "Windows", "settings maximized h" }; + SettingValue mSettingsMaximized{ mIndex, "Windows", "settings maximized" }; + SettingValue mPostprocessorH{ mIndex, "Windows", "postprocessor h" }; + SettingValue mPostprocessorW{ mIndex, "Windows", "postprocessor w" }; + SettingValue mPostprocessorX{ mIndex, "Windows", "postprocessor x" }; + SettingValue mPostprocessorY{ mIndex, "Windows", "postprocessor y" }; + SettingValue mPostprocessorMaximizedX{ mIndex, "Windows", "postprocessor maximized x" }; + SettingValue mPostprocessorMaximizedY{ mIndex, "Windows", "postprocessor maximized y" }; + SettingValue mPostprocessorMaximizedW{ mIndex, "Windows", "postprocessor maximized w" }; + SettingValue mPostprocessorMaximizedH{ mIndex, "Windows", "postprocessor maximized h" }; + SettingValue mPostprocessorMaximized{ mIndex, "Windows", "postprocessor maximized" }; }; } diff --git a/components/settings/settings.cpp b/components/settings/settings.cpp index 690f9fd593..c9e0daccad 100644 --- a/components/settings/settings.cpp +++ b/components/settings/settings.cpp @@ -142,7 +142,7 @@ namespace Settings } if (!loadEditorSettings) - Settings::Values::initDefaults(); + Settings::StaticValues::initDefaults(); // Load "settings.cfg" or "openmw-cs.cfg" from the last config dir as user settings. This path will be used to // save modified settings. @@ -151,7 +151,7 @@ namespace Settings parser.loadSettingsFile(settingspath, mUserSettings, false, false); if (!loadEditorSettings) - Settings::Values::init(); + Settings::StaticValues::init(); for (const auto& [key, value] : originalDefaultSettings) if (!sInitialized.contains(key)) diff --git a/components/settings/settingvalue.hpp b/components/settings/settingvalue.hpp index bdc91c4a21..1ad92fe6a7 100644 --- a/components/settings/settingvalue.hpp +++ b/components/settings/settingvalue.hpp @@ -8,28 +8,241 @@ #include +#include #include #include +#include #include +#include namespace Settings { + enum class SettingValueType + { + Bool, + Int, + UnsignedInt, + Long, + UnsignedLong, + LongLong, + UnsignedLongLong, + Float, + Double, + String, + Vec2f, + Vec3f, + }; + template - class SettingValue + constexpr SettingValueType getSettingValueType(); + + template <> + inline constexpr SettingValueType getSettingValueType() + { + return SettingValueType::Bool; + } + + template <> + inline constexpr SettingValueType getSettingValueType() + { + return SettingValueType::Int; + } + + template <> + inline constexpr SettingValueType getSettingValueType() + { + return SettingValueType::UnsignedInt; + } + + template <> + inline constexpr SettingValueType getSettingValueType() + { + return SettingValueType::Long; + } + + template <> + inline constexpr SettingValueType getSettingValueType() + { + return SettingValueType::UnsignedLong; + } + + template <> + inline constexpr SettingValueType getSettingValueType() + { + return SettingValueType::LongLong; + } + + template <> + inline constexpr SettingValueType getSettingValueType() + { + return SettingValueType::UnsignedLongLong; + } + + template <> + inline constexpr SettingValueType getSettingValueType() + { + return SettingValueType::Float; + } + + template <> + inline constexpr SettingValueType getSettingValueType() + { + return SettingValueType::Double; + } + + template <> + inline constexpr SettingValueType getSettingValueType() + { + return SettingValueType::String; + } + + template <> + inline constexpr SettingValueType getSettingValueType() + { + return SettingValueType::Vec2f; + } + + template <> + inline constexpr SettingValueType getSettingValueType() + { + return SettingValueType::Vec3f; + } + + inline constexpr std::string_view getSettingValueTypeName(SettingValueType type) + { + switch (type) + { + case SettingValueType::Bool: + return "bool"; + case SettingValueType::Int: + return "int"; + case SettingValueType::UnsignedInt: + return "unsigned int"; + case SettingValueType::Long: + return "long"; + case SettingValueType::UnsignedLong: + return "unsigned long"; + case SettingValueType::LongLong: + return "long long"; + case SettingValueType::UnsignedLongLong: + return "unsigned long long"; + case SettingValueType::Float: + return "float"; + case SettingValueType::Double: + return "double"; + case SettingValueType::String: + return "string"; + case SettingValueType::Vec2f: + return "vec2f"; + case SettingValueType::Vec3f: + return "vec3f"; + } + return "unsupported"; + } + + template + constexpr std::string_view getSettingValueTypeName() + { + return getSettingValueTypeName(getSettingValueType()); + } + + inline std::string getSettingDescription(SettingValueType type, std::string_view category, std::string_view name) + { + return std::string(getSettingValueTypeName(type)) + " [" + std::string(category) + "] " + std::string(name) + + " setting"; + } + + template + std::string getSettingDescription(std::string_view category, std::string_view name) + { + return getSettingDescription(getSettingValueType(), category, name); + } + + class Index; + + class BaseSettingValue { public: - explicit SettingValue( - std::string_view category, std::string_view name, std::unique_ptr>&& sanitizer = nullptr) - : mCategory(category) - , mName(name) + const SettingValueType mType; + const std::string_view mCategory; + const std::string_view mName; + + explicit BaseSettingValue( + SettingValueType type, std::string_view category, std::string_view name, Index& index); + + BaseSettingValue(const BaseSettingValue& other) = delete; + + BaseSettingValue(BaseSettingValue&& other); + + BaseSettingValue& operator=(const BaseSettingValue& other) = delete; + + BaseSettingValue& operator=(BaseSettingValue&& other) = delete; + + private: + Index& mIndex; + }; + + template + class SettingValue; + + class Index + { + public: + template + SettingValue* find(std::string_view category, std::string_view name) const; + + template + SettingValue& get(std::string_view category, std::string_view name) const; + + void insert(BaseSettingValue* value) + { + if (!mValues.emplace(std::make_pair(value->mCategory, value->mName), value).second) + throw std::invalid_argument("Duplicated setting definition: " + + getSettingDescription(value->mType, value->mCategory, value->mName)); + } + + void insertOrAssign(BaseSettingValue* value) + { + mValues.insert_or_assign(std::make_pair(value->mCategory, value->mName), value); + } + + private: + std::map, BaseSettingValue*> mValues; + }; + + inline BaseSettingValue::BaseSettingValue( + SettingValueType type, std::string_view category, std::string_view name, Index& index) + : mType(type) + , mCategory(category) + , mName(name) + , mIndex(index) + { + mIndex.insert(this); + } + + inline BaseSettingValue::BaseSettingValue(BaseSettingValue&& other) + : mType(other.mType) + , mCategory(other.mCategory) + , mName(other.mName) + , mIndex(other.mIndex) + { + mIndex.insertOrAssign(this); + } + + template + class SettingValue final : public BaseSettingValue + { + public: + explicit SettingValue(Index& index, std::string_view category, std::string_view name, + std::unique_ptr>&& sanitizer = nullptr) + : BaseSettingValue(getSettingValueType(), category, name, index) , mSanitizer(std::move(sanitizer)) , mValue(sanitize(Settings::Manager::get(mName, mCategory))) { } SettingValue(SettingValue&& other) - : mCategory(other.mCategory) - , mName(other.mName) + : BaseSettingValue(std::move(other)) , mSanitizer(std::move(other.mSanitizer)) , mDefaultValue(std::move(other.mValue)) , mValue(sanitize(Settings::Manager::get(mName, mCategory))) @@ -57,8 +270,6 @@ namespace Settings void reset() { set(mDefaultValue); } private: - const std::string_view mCategory; - const std::string_view mName; std::unique_ptr> mSanitizer; T mDefaultValue{}; T mValue{}; @@ -71,18 +282,52 @@ namespace Settings { T sanitizedValue = mSanitizer->apply(value); if (sanitizedValue != value) - Log(Debug::Warning) << "Setting [" << mCategory << "] " << mName + Log(Debug::Warning) << getSettingDescription(mCategory, mName) << " value is out of allowed values set: " << value << ", sanitized to " << sanitizedValue; return sanitizedValue; } catch (const std::exception& e) { - throw std::runtime_error("Invalid setting [" + std::string(mCategory) + "] " + std::string(mName) - + " value: " + std::string(e.what())); + throw std::runtime_error( + "Invalid " + getSettingDescription(mCategory, mName) + " value: " + std::string(e.what())); } } }; + + template + SettingValue* Index::find(std::string_view category, std::string_view name) const + { + const auto it = mValues.find({ category, name }); + if (it == mValues.end()) + return nullptr; + BaseSettingValue* const value = it->second; + if (value->mType != getSettingValueType()) + throw std::invalid_argument(getSettingDescription(value->mType, category, name) + + " does not match requested type: " + std::string(getSettingValueTypeName())); + return static_cast*>(value); + } + + template + SettingValue& Index::get(std::string_view category, std::string_view name) const + { + SettingValue* const result = find(category, name); + if (result == nullptr) + throw std::invalid_argument(getSettingDescription(category, name) + " is not found"); + return *result; + } + + class WithIndex + { + public: + explicit WithIndex(Index& index) + : mIndex(index) + { + } + + protected: + Index& mIndex; + }; } #endif diff --git a/components/settings/values.cpp b/components/settings/values.cpp index 99ca0bcb9b..66460beb9a 100644 --- a/components/settings/values.cpp +++ b/components/settings/values.cpp @@ -4,21 +4,24 @@ namespace Settings { - Values* Values::sValues = nullptr; + Index* StaticValues::sIndex = nullptr; + Values* StaticValues::sValues = nullptr; - void Values::initDefaults() + void StaticValues::initDefaults() { - if (Values::sValues != nullptr) + if (sValues != nullptr) throw std::logic_error("Default settings already initialized"); - static Values values; - Values::sValues = &values; + static Index index; + static Values values(index); + sIndex = &index; + sValues = &values; } - void Values::init() + void StaticValues::init() { - if (Values::sValues == nullptr) + if (sValues == nullptr) throw std::logic_error("Default settings are not initialized"); - static Values values(std::move(*Values::sValues)); - Values::sValues = &values; + static Values values(std::move(*sValues)); + sValues = &values; } } diff --git a/components/settings/values.hpp b/components/settings/values.hpp index b5b26a97fe..323be2e866 100644 --- a/components/settings/values.hpp +++ b/components/settings/values.hpp @@ -26,54 +26,68 @@ #include "categories/video.hpp" #include "categories/water.hpp" #include "categories/windows.hpp" +#include "settingvalue.hpp" #include +#include namespace Settings { - class Values + struct Values : WithIndex + { + using WithIndex::WithIndex; + + CameraCategory mCamera{ mIndex }; + CellsCategory mCells{ mIndex }; + TerrainCategory mTerrain{ mIndex }; + FogCategory mFog{ mIndex }; + MapCategory mMap{ mIndex }; + GUICategory mGUI{ mIndex }; + HUDCategory mHUD{ mIndex }; + GameCategory mGame{ mIndex }; + GeneralCategory mGeneral{ mIndex }; + ShadersCategory mShaders{ mIndex }; + InputCategory mInput{ mIndex }; + SavesCategory mSaves{ mIndex }; + SoundCategory mSound{ mIndex }; + VideoCategory mVideo{ mIndex }; + WaterCategory mWater{ mIndex }; + WindowsCategory mWindows{ mIndex }; + NavigatorCategory mNavigator{ mIndex }; + ShadowsCategory mShadows{ mIndex }; + PhysicsCategory mPhysics{ mIndex }; + ModelsCategory mModels{ mIndex }; + GroundcoverCategory mGroundcover{ mIndex }; + LuaCategory mLua{ mIndex }; + StereoCategory mStereo{ mIndex }; + StereoViewCategory mStereoView{ mIndex }; + PostProcessingCategory mPostProcessing{ mIndex }; + }; + + class StaticValues { public: - CameraCategory mCamera; - CellsCategory mCells; - TerrainCategory mTerrain; - FogCategory mFog; - MapCategory mMap; - GUICategory mGUI; - HUDCategory mHUD; - GameCategory mGame; - GeneralCategory mGeneral; - ShadersCategory mShaders; - InputCategory mInput; - SavesCategory mSaves; - SoundCategory mSound; - VideoCategory mVideo; - WaterCategory mWater; - WindowsCategory mWindows; - NavigatorCategory mNavigator; - ShadowsCategory mShadows; - PhysicsCategory mPhysics; - ModelsCategory mModels; - GroundcoverCategory mGroundcover; - LuaCategory mLua; - StereoCategory mStereo; - StereoViewCategory mStereoView; - PostProcessingCategory mPostProcessing; - static void initDefaults(); static void init(); private: + static Index* sIndex; static Values* sValues; friend Values& values(); + + template + friend SettingValue* find(std::string_view category, std::string_view name); + + template + friend SettingValue& get(std::string_view category, std::string_view name); }; inline Values& values() { - assert(Values::sValues != nullptr); - return *Values::sValues; + assert(StaticValues::sValues != nullptr); + return *StaticValues::sValues; } inline CameraCategory& camera() @@ -200,6 +214,18 @@ namespace Settings { return values().mPostProcessing; } + + template + SettingValue* find(std::string_view category, std::string_view name) + { + return StaticValues::sIndex->find(category, name); + } + + template + SettingValue& get(std::string_view category, std::string_view name) + { + return StaticValues::sIndex->get(category, name); + } } #endif