Use typed settings storage in the launcher settings page

depth-refraction
elsid 2 years ago
parent 121b75212f
commit ec01d3cd0c
No known key found for this signature in database
GPG Key ID: 4DE04C198CBA7625

@ -10,49 +10,40 @@
#include <components/config/gamesettings.hpp> #include <components/config/gamesettings.hpp>
#include <components/settings/settings.hpp> #include <components/settings/values.hpp>
#include "utils/openalutil.hpp" #include "utils/openalutil.hpp"
namespace namespace
{ {
void loadSettingBool(QCheckBox* checkbox, const std::string& setting, const std::string& group) void loadSettingBool(const Settings::SettingValue<bool>& value, QCheckBox& checkbox)
{ {
if (Settings::Manager::getBool(setting, group)) checkbox.setCheckState(value ? Qt::Checked : Qt::Unchecked);
checkbox->setCheckState(Qt::Checked);
} }
void saveSettingBool(QCheckBox* checkbox, const std::string& setting, const std::string& group) void saveSettingBool(const QCheckBox& checkbox, Settings::SettingValue<bool>& value)
{ {
const bool cValue = checkbox->checkState(); value.set(checkbox.checkState() == Qt::Checked);
if (cValue != Settings::Manager::getBool(setting, group))
Settings::Manager::setBool(setting, group, cValue);
} }
void loadSettingInt(QComboBox* comboBox, const std::string& setting, const std::string& group) void loadSettingInt(const Settings::SettingValue<int>& value, QComboBox& comboBox)
{ {
const int currentIndex = Settings::Manager::getInt(setting, group); comboBox.setCurrentIndex(value);
comboBox->setCurrentIndex(currentIndex);
} }
void saveSettingInt(QComboBox* comboBox, const std::string& setting, const std::string& group) void saveSettingInt(const QComboBox& comboBox, Settings::SettingValue<int>& value)
{ {
const int currentIndex = comboBox->currentIndex(); value.set(comboBox.currentIndex());
if (currentIndex != Settings::Manager::getInt(setting, group))
Settings::Manager::setInt(setting, group, currentIndex);
} }
void loadSettingInt(QSpinBox* spinBox, const std::string& setting, const std::string& group) void loadSettingInt(const Settings::SettingValue<int>& value, QSpinBox& spinBox)
{ {
const int value = Settings::Manager::getInt(setting, group); spinBox.setValue(value);
spinBox->setValue(value);
} }
void saveSettingInt(QSpinBox* spinBox, const std::string& setting, const std::string& group) void saveSettingInt(const QSpinBox& spinBox, Settings::SettingValue<int>& value)
{ {
const int value = spinBox->value(); value.set(spinBox.value());
if (value != Settings::Manager::getInt(setting, group))
Settings::Manager::setInt(setting, group, value);
} }
} }
@ -128,88 +119,79 @@ bool Launcher::SettingsPage::loadSettings()
{ {
// Game mechanics // Game mechanics
{ {
loadSettingBool(canLootDuringDeathAnimationCheckBox, "can loot during death animation", "Game"); loadSettingBool(Settings::game().mCanLootDuringDeathAnimation, *canLootDuringDeathAnimationCheckBox);
loadSettingBool(followersAttackOnSightCheckBox, "followers attack on sight", "Game"); loadSettingBool(Settings::game().mFollowersAttackOnSight, *followersAttackOnSightCheckBox);
loadSettingBool(rebalanceSoulGemValuesCheckBox, "rebalance soul gem values", "Game"); loadSettingBool(Settings::game().mRebalanceSoulGemValues, *rebalanceSoulGemValuesCheckBox);
loadSettingBool(enchantedWeaponsMagicalCheckBox, "enchanted weapons are magical", "Game"); loadSettingBool(Settings::game().mEnchantedWeaponsAreMagical, *enchantedWeaponsMagicalCheckBox);
loadSettingBool(permanentBarterDispositionChangeCheckBox, "barter disposition change is permanent", "Game");
loadSettingBool(classicReflectedAbsorbSpellsCheckBox, "classic reflected absorb spells behavior", "Game");
loadSettingBool(classicCalmSpellsCheckBox, "classic calm spells behavior", "Game");
loadSettingBool( loadSettingBool(
requireAppropriateAmmunitionCheckBox, "only appropriate ammunition bypasses resistance", "Game"); Settings::game().mBarterDispositionChangeIsPermanent, *permanentBarterDispositionChangeCheckBox);
loadSettingBool(uncappedDamageFatigueCheckBox, "uncapped damage fatigue", "Game"); loadSettingBool(Settings::game().mClassicReflectedAbsorbSpellsBehavior, *classicReflectedAbsorbSpellsCheckBox);
loadSettingBool(normaliseRaceSpeedCheckBox, "normalise race speed", "Game"); loadSettingBool(Settings::game().mClassicCalmSpellsBehavior, *classicCalmSpellsCheckBox);
loadSettingBool(swimUpwardCorrectionCheckBox, "swim upward correction", "Game"); loadSettingBool(
loadSettingBool(avoidCollisionsCheckBox, "NPCs avoid collisions", "Game"); Settings::game().mOnlyAppropriateAmmunitionBypassesResistance, *requireAppropriateAmmunitionCheckBox);
int unarmedFactorsStrengthIndex = Settings::Manager::getInt("strength influences hand to hand", "Game"); loadSettingBool(Settings::game().mUncappedDamageFatigue, *uncappedDamageFatigueCheckBox);
if (unarmedFactorsStrengthIndex >= 0 && unarmedFactorsStrengthIndex <= 2) loadSettingBool(Settings::game().mNormaliseRaceSpeed, *normaliseRaceSpeedCheckBox);
unarmedFactorsStrengthComboBox->setCurrentIndex(unarmedFactorsStrengthIndex); loadSettingBool(Settings::game().mSwimUpwardCorrection, *swimUpwardCorrectionCheckBox);
loadSettingBool(stealingFromKnockedOutCheckBox, "always allow stealing from knocked out actors", "Game"); loadSettingBool(Settings::game().mNPCsAvoidCollisions, *avoidCollisionsCheckBox);
loadSettingBool(enableNavigatorCheckBox, "enable", "Navigator"); loadSettingInt(Settings::game().mStrengthInfluencesHandToHand, *unarmedFactorsStrengthComboBox);
int numPhysicsThreads = Settings::Manager::getInt("async num threads", "Physics"); loadSettingBool(Settings::game().mAlwaysAllowStealingFromKnockedOutActors, *stealingFromKnockedOutCheckBox);
if (numPhysicsThreads >= 0) loadSettingBool(Settings::navigator().mEnable, *enableNavigatorCheckBox);
physicsThreadsSpinBox->setValue(numPhysicsThreads); loadSettingInt(Settings::physics().mAsyncNumThreads, *physicsThreadsSpinBox);
loadSettingBool(allowNPCToFollowOverWaterSurfaceCheckBox, "allow actors to follow over water surface", "Game"); loadSettingBool(
loadSettingBool(unarmedCreatureAttacksDamageArmorCheckBox, "unarmed creature attacks damage armor", "Game"); Settings::game().mAllowActorsToFollowOverWaterSurface, *allowNPCToFollowOverWaterSurfaceCheckBox);
const int actorCollisionShapeType = Settings::Manager::getInt("actor collision shape type", "Game"); loadSettingBool(
if (0 <= actorCollisionShapeType && actorCollisionShapeType < actorCollisonShapeTypeComboBox->count()) Settings::game().mUnarmedCreatureAttacksDamageArmor, *unarmedCreatureAttacksDamageArmorCheckBox);
actorCollisonShapeTypeComboBox->setCurrentIndex(actorCollisionShapeType); loadSettingInt(Settings::game().mActorCollisionShapeType, *actorCollisonShapeTypeComboBox);
} }
// Visuals // Visuals
{ {
loadSettingBool(autoUseObjectNormalMapsCheckBox, "auto use object normal maps", "Shaders"); loadSettingBool(Settings::shaders().mAutoUseObjectNormalMaps, *autoUseObjectNormalMapsCheckBox);
loadSettingBool(autoUseObjectSpecularMapsCheckBox, "auto use object specular maps", "Shaders"); loadSettingBool(Settings::shaders().mAutoUseObjectSpecularMaps, *autoUseObjectSpecularMapsCheckBox);
loadSettingBool(autoUseTerrainNormalMapsCheckBox, "auto use terrain normal maps", "Shaders"); loadSettingBool(Settings::shaders().mAutoUseTerrainNormalMaps, *autoUseTerrainNormalMapsCheckBox);
loadSettingBool(autoUseTerrainSpecularMapsCheckBox, "auto use terrain specular maps", "Shaders"); loadSettingBool(Settings::shaders().mAutoUseTerrainSpecularMaps, *autoUseTerrainSpecularMapsCheckBox);
loadSettingBool(bumpMapLocalLightingCheckBox, "apply lighting to environment maps", "Shaders"); loadSettingBool(Settings::shaders().mApplyLightingToEnvironmentMaps, *bumpMapLocalLightingCheckBox);
loadSettingBool(softParticlesCheckBox, "soft particles", "Shaders"); loadSettingBool(Settings::shaders().mSoftParticles, *softParticlesCheckBox);
loadSettingBool(antialiasAlphaTestCheckBox, "antialias alpha test", "Shaders"); loadSettingBool(Settings::shaders().mAntialiasAlphaTest, *antialiasAlphaTestCheckBox);
if (Settings::Manager::getInt("antialiasing", "Video") == 0) if (Settings::shaders().mAntialiasAlphaTest == 0)
{
antialiasAlphaTestCheckBox->setCheckState(Qt::Unchecked); antialiasAlphaTestCheckBox->setCheckState(Qt::Unchecked);
} loadSettingBool(Settings::shaders().mAdjustCoverageForAlphaTest, *adjustCoverageForAlphaTestCheckBox);
loadSettingBool(adjustCoverageForAlphaTestCheckBox, "adjust coverage for alpha test", "Shaders"); loadSettingBool(Settings::shaders().mWeatherParticleOcclusion, *weatherParticleOcclusionCheckBox);
loadSettingBool(weatherParticleOcclusionCheckBox, "weather particle occlusion", "Shaders"); loadSettingBool(Settings::game().mUseMagicItemAnimations, *magicItemAnimationsCheckBox);
loadSettingBool(magicItemAnimationsCheckBox, "use magic item animations", "Game");
connect(animSourcesCheckBox, &QCheckBox::toggled, this, &SettingsPage::slotAnimSourcesToggled); connect(animSourcesCheckBox, &QCheckBox::toggled, this, &SettingsPage::slotAnimSourcesToggled);
loadSettingBool(animSourcesCheckBox, "use additional anim sources", "Game"); loadSettingBool(Settings::game().mUseAdditionalAnimSources, *animSourcesCheckBox);
if (animSourcesCheckBox->checkState() != Qt::Unchecked) if (animSourcesCheckBox->checkState() != Qt::Unchecked)
{ {
loadSettingBool(weaponSheathingCheckBox, "weapon sheathing", "Game"); loadSettingBool(Settings::game().mWeaponSheathing, *weaponSheathingCheckBox);
loadSettingBool(shieldSheathingCheckBox, "shield sheathing", "Game"); loadSettingBool(Settings::game().mShieldSheathing, *shieldSheathingCheckBox);
} }
loadSettingBool(turnToMovementDirectionCheckBox, "turn to movement direction", "Game"); loadSettingBool(Settings::game().mTurnToMovementDirection, *turnToMovementDirectionCheckBox);
loadSettingBool(smoothMovementCheckBox, "smooth movement", "Game"); loadSettingBool(Settings::game().mSmoothMovement, *smoothMovementCheckBox);
const bool distantTerrain = Settings::Manager::getBool("distant terrain", "Terrain"); distantLandCheckBox->setCheckState(
const bool objectPaging = Settings::Manager::getBool("object paging", "Terrain"); Settings::terrain().mDistantTerrain && Settings::terrain().mObjectPaging ? Qt::Checked : Qt::Unchecked);
if (distantTerrain && objectPaging)
{
distantLandCheckBox->setCheckState(Qt::Checked);
}
loadSettingBool(activeGridObjectPagingCheckBox, "object paging active grid", "Terrain"); loadSettingBool(Settings::terrain().mObjectPagingActiveGrid, *activeGridObjectPagingCheckBox);
viewingDistanceComboBox->setValue(convertToCells(Settings::Manager::getInt("viewing distance", "Camera"))); viewingDistanceComboBox->setValue(convertToCells(Settings::camera().mViewingDistance));
objectPagingMinSizeComboBox->setValue(Settings::Manager::getDouble("object paging min size", "Terrain")); objectPagingMinSizeComboBox->setValue(Settings::terrain().mObjectPagingMinSize);
loadSettingBool(nightDaySwitchesCheckBox, "day night switches", "Game"); loadSettingBool(Settings::game().mDayNightSwitches, *nightDaySwitchesCheckBox);
connect(postprocessEnabledCheckBox, &QCheckBox::toggled, this, &SettingsPage::slotPostProcessToggled); connect(postprocessEnabledCheckBox, &QCheckBox::toggled, this, &SettingsPage::slotPostProcessToggled);
loadSettingBool(postprocessEnabledCheckBox, "enabled", "Post Processing"); loadSettingBool(Settings::postProcessing().mEnabled, *postprocessEnabledCheckBox);
loadSettingBool(postprocessTransparentPostpassCheckBox, "transparent postpass", "Post Processing"); loadSettingBool(Settings::postProcessing().mTransparentPostpass, *postprocessTransparentPostpassCheckBox);
postprocessHDRTimeComboBox->setValue(Settings::Manager::getDouble("auto exposure speed", "Post Processing")); postprocessHDRTimeComboBox->setValue(Settings::postProcessing().mAutoExposureSpeed);
connect(skyBlendingCheckBox, &QCheckBox::toggled, this, &SettingsPage::slotSkyBlendingToggled); connect(skyBlendingCheckBox, &QCheckBox::toggled, this, &SettingsPage::slotSkyBlendingToggled);
loadSettingBool(radialFogCheckBox, "radial fog", "Fog"); loadSettingBool(Settings::fog().mRadialFog, *radialFogCheckBox);
loadSettingBool(exponentialFogCheckBox, "exponential fog", "Fog"); loadSettingBool(Settings::fog().mExponentialFog, *exponentialFogCheckBox);
loadSettingBool(skyBlendingCheckBox, "sky blending", "Fog"); loadSettingBool(Settings::fog().mSkyBlending, *skyBlendingCheckBox);
skyBlendingStartComboBox->setValue(Settings::Manager::getDouble("sky blending start", "Fog")); skyBlendingStartComboBox->setValue(Settings::fog().mSkyBlendingStart);
} }
// Audio // Audio
{ {
const std::string& selectedAudioDevice = Settings::Manager::getString("device", "Sound"); const std::string& selectedAudioDevice = Settings::sound().mDevice;
if (selectedAudioDevice.empty() == false) if (selectedAudioDevice.empty() == false)
{ {
int audioDeviceIndex = audioDeviceSelectorComboBox->findData(QString::fromStdString(selectedAudioDevice)); int audioDeviceIndex = audioDeviceSelectorComboBox->findData(QString::fromStdString(selectedAudioDevice));
@ -218,12 +200,12 @@ bool Launcher::SettingsPage::loadSettings()
audioDeviceSelectorComboBox->setCurrentIndex(audioDeviceIndex); audioDeviceSelectorComboBox->setCurrentIndex(audioDeviceIndex);
} }
} }
int hrtfEnabledIndex = Settings::Manager::getInt("hrtf enable", "Sound"); const int hrtfEnabledIndex = Settings::sound().mHrtfEnable;
if (hrtfEnabledIndex >= -1 && hrtfEnabledIndex <= 1) if (hrtfEnabledIndex >= -1 && hrtfEnabledIndex <= 1)
{ {
enableHRTFComboBox->setCurrentIndex(hrtfEnabledIndex + 1); enableHRTFComboBox->setCurrentIndex(hrtfEnabledIndex + 1);
} }
const std::string& selectedHRTFProfile = Settings::Manager::getString("hrtf", "Sound"); const std::string& selectedHRTFProfile = Settings::sound().mHrtf;
if (selectedHRTFProfile.empty() == false) if (selectedHRTFProfile.empty() == false)
{ {
int hrtfProfileIndex = hrtfProfileSelectorComboBox->findData(QString::fromStdString(selectedHRTFProfile)); int hrtfProfileIndex = hrtfProfileSelectorComboBox->findData(QString::fromStdString(selectedHRTFProfile));
@ -236,48 +218,44 @@ bool Launcher::SettingsPage::loadSettings()
// Interface Changes // Interface Changes
{ {
loadSettingBool(showEffectDurationCheckBox, "show effect duration", "Game"); loadSettingBool(Settings::game().mShowEffectDuration, *showEffectDurationCheckBox);
loadSettingBool(showEnchantChanceCheckBox, "show enchant chance", "Game"); loadSettingBool(Settings::game().mShowEnchantChance, *showEnchantChanceCheckBox);
loadSettingBool(showMeleeInfoCheckBox, "show melee info", "Game"); loadSettingBool(Settings::game().mShowMeleeInfo, *showMeleeInfoCheckBox);
loadSettingBool(showProjectileDamageCheckBox, "show projectile damage", "Game"); loadSettingBool(Settings::game().mShowProjectileDamage, *showProjectileDamageCheckBox);
loadSettingBool(changeDialogTopicsCheckBox, "color topic enable", "GUI"); loadSettingBool(Settings::gui().mColorTopicEnable, *changeDialogTopicsCheckBox);
int showOwnedIndex = Settings::Manager::getInt("show owned", "Game"); showOwnedComboBox->setCurrentIndex(Settings::game().mShowOwned);
// Match the index with the option (only 0, 1, 2, or 3 are valid). Will default to 0 if invalid. loadSettingBool(Settings::gui().mStretchMenuBackground, *stretchBackgroundCheckBox);
if (showOwnedIndex >= 0 && showOwnedIndex <= 3) loadSettingBool(Settings::map().mAllowZooming, *useZoomOnMapCheckBox);
showOwnedComboBox->setCurrentIndex(showOwnedIndex); loadSettingBool(Settings::game().mGraphicHerbalism, *graphicHerbalismCheckBox);
loadSettingBool(stretchBackgroundCheckBox, "stretch menu background", "GUI"); scalingSpinBox->setValue(Settings::gui().mScalingFactor);
loadSettingBool(useZoomOnMapCheckBox, "allow zooming", "Map"); fontSizeSpinBox->setValue(Settings::gui().mFontSize);
loadSettingBool(graphicHerbalismCheckBox, "graphic herbalism", "Game");
scalingSpinBox->setValue(Settings::Manager::getFloat("scaling factor", "GUI"));
fontSizeSpinBox->setValue(Settings::Manager::getInt("font size", "GUI"));
} }
// Bug fixes // Bug fixes
{ {
loadSettingBool(preventMerchantEquippingCheckBox, "prevent merchant equipping", "Game"); loadSettingBool(Settings::game().mPreventMerchantEquipping, *preventMerchantEquippingCheckBox);
loadSettingBool( loadSettingBool(
trainersTrainingSkillsBasedOnBaseSkillCheckBox, "trainers training skills based on base skill", "Game"); Settings::game().mTrainersTrainingSkillsBasedOnBaseSkill, *trainersTrainingSkillsBasedOnBaseSkillCheckBox);
} }
// Miscellaneous // Miscellaneous
{ {
// Saves // Saves
loadSettingBool(timePlayedCheckbox, "timeplayed", "Saves"); loadSettingBool(Settings::saves().mTimeplayed, *timePlayedCheckbox);
loadSettingInt(maximumQuicksavesComboBox, "max quicksaves", "Saves"); loadSettingInt(Settings::saves().mMaxQuicksaves, *maximumQuicksavesComboBox);
// Other Settings // Other Settings
QString screenshotFormatString QString screenshotFormatString = QString::fromStdString(Settings::general().mScreenshotFormat).toUpper();
= QString::fromStdString(Settings::Manager::getString("screenshot format", "General")).toUpper();
if (screenshotFormatComboBox->findText(screenshotFormatString) == -1) if (screenshotFormatComboBox->findText(screenshotFormatString) == -1)
screenshotFormatComboBox->addItem(screenshotFormatString); screenshotFormatComboBox->addItem(screenshotFormatString);
screenshotFormatComboBox->setCurrentIndex(screenshotFormatComboBox->findText(screenshotFormatString)); screenshotFormatComboBox->setCurrentIndex(screenshotFormatComboBox->findText(screenshotFormatString));
loadSettingBool(notifyOnSavedScreenshotCheckBox, "notify on saved screenshot", "General"); loadSettingBool(Settings::general().mNotifyOnSavedScreenshot, *notifyOnSavedScreenshotCheckBox);
} }
// Testing // Testing
{ {
loadSettingBool(grabCursorCheckBox, "grab cursor", "Input"); loadSettingBool(Settings::input().mGrabCursor, *grabCursorCheckBox);
bool skipMenu = mGameSettings.value("skip-menu").toInt() == 1; bool skipMenu = mGameSettings.value("skip-menu").toInt() == 1;
if (skipMenu) if (skipMenu)
@ -297,158 +275,121 @@ void Launcher::SettingsPage::saveSettings()
{ {
// Game mechanics // Game mechanics
{ {
saveSettingBool(canLootDuringDeathAnimationCheckBox, "can loot during death animation", "Game"); saveSettingBool(*canLootDuringDeathAnimationCheckBox, Settings::game().mCanLootDuringDeathAnimation);
saveSettingBool(followersAttackOnSightCheckBox, "followers attack on sight", "Game"); saveSettingBool(*followersAttackOnSightCheckBox, Settings::game().mFollowersAttackOnSight);
saveSettingBool(rebalanceSoulGemValuesCheckBox, "rebalance soul gem values", "Game"); saveSettingBool(*rebalanceSoulGemValuesCheckBox, Settings::game().mRebalanceSoulGemValues);
saveSettingBool(enchantedWeaponsMagicalCheckBox, "enchanted weapons are magical", "Game"); saveSettingBool(*enchantedWeaponsMagicalCheckBox, Settings::game().mEnchantedWeaponsAreMagical);
saveSettingBool(permanentBarterDispositionChangeCheckBox, "barter disposition change is permanent", "Game");
saveSettingBool(classicReflectedAbsorbSpellsCheckBox, "classic reflected absorb spells behavior", "Game");
saveSettingBool(classicCalmSpellsCheckBox, "classic calm spells behavior", "Game");
saveSettingBool( saveSettingBool(
requireAppropriateAmmunitionCheckBox, "only appropriate ammunition bypasses resistance", "Game"); *permanentBarterDispositionChangeCheckBox, Settings::game().mBarterDispositionChangeIsPermanent);
saveSettingBool(uncappedDamageFatigueCheckBox, "uncapped damage fatigue", "Game"); saveSettingBool(*classicReflectedAbsorbSpellsCheckBox, Settings::game().mClassicReflectedAbsorbSpellsBehavior);
saveSettingBool(normaliseRaceSpeedCheckBox, "normalise race speed", "Game"); saveSettingBool(*classicCalmSpellsCheckBox, Settings::game().mClassicCalmSpellsBehavior);
saveSettingBool(swimUpwardCorrectionCheckBox, "swim upward correction", "Game"); saveSettingBool(
saveSettingBool(avoidCollisionsCheckBox, "NPCs avoid collisions", "Game"); *requireAppropriateAmmunitionCheckBox, Settings::game().mOnlyAppropriateAmmunitionBypassesResistance);
saveSettingInt(unarmedFactorsStrengthComboBox, "strength influences hand to hand", "Game"); saveSettingBool(*uncappedDamageFatigueCheckBox, Settings::game().mUncappedDamageFatigue);
saveSettingBool(stealingFromKnockedOutCheckBox, "always allow stealing from knocked out actors", "Game"); saveSettingBool(*normaliseRaceSpeedCheckBox, Settings::game().mNormaliseRaceSpeed);
saveSettingBool(enableNavigatorCheckBox, "enable", "Navigator"); saveSettingBool(*swimUpwardCorrectionCheckBox, Settings::game().mSwimUpwardCorrection);
saveSettingInt(physicsThreadsSpinBox, "async num threads", "Physics"); saveSettingBool(*avoidCollisionsCheckBox, Settings::game().mNPCsAvoidCollisions);
saveSettingBool(allowNPCToFollowOverWaterSurfaceCheckBox, "allow actors to follow over water surface", "Game"); saveSettingInt(*unarmedFactorsStrengthComboBox, Settings::game().mStrengthInfluencesHandToHand);
saveSettingBool(unarmedCreatureAttacksDamageArmorCheckBox, "unarmed creature attacks damage armor", "Game"); saveSettingBool(*stealingFromKnockedOutCheckBox, Settings::game().mAlwaysAllowStealingFromKnockedOutActors);
saveSettingInt(actorCollisonShapeTypeComboBox, "actor collision shape type", "Game"); saveSettingBool(*enableNavigatorCheckBox, Settings::navigator().mEnable);
saveSettingInt(*physicsThreadsSpinBox, Settings::physics().mAsyncNumThreads);
saveSettingBool(
*allowNPCToFollowOverWaterSurfaceCheckBox, Settings::game().mAllowActorsToFollowOverWaterSurface);
saveSettingBool(
*unarmedCreatureAttacksDamageArmorCheckBox, Settings::game().mUnarmedCreatureAttacksDamageArmor);
saveSettingInt(*actorCollisonShapeTypeComboBox, Settings::game().mActorCollisionShapeType);
} }
// Visuals // Visuals
{ {
saveSettingBool(autoUseObjectNormalMapsCheckBox, "auto use object normal maps", "Shaders"); saveSettingBool(*autoUseObjectNormalMapsCheckBox, Settings::shaders().mAutoUseObjectNormalMaps);
saveSettingBool(autoUseObjectSpecularMapsCheckBox, "auto use object specular maps", "Shaders"); saveSettingBool(*autoUseObjectSpecularMapsCheckBox, Settings::shaders().mAutoUseObjectSpecularMaps);
saveSettingBool(autoUseTerrainNormalMapsCheckBox, "auto use terrain normal maps", "Shaders"); saveSettingBool(*autoUseTerrainNormalMapsCheckBox, Settings::shaders().mAutoUseTerrainNormalMaps);
saveSettingBool(autoUseTerrainSpecularMapsCheckBox, "auto use terrain specular maps", "Shaders"); saveSettingBool(*autoUseTerrainSpecularMapsCheckBox, Settings::shaders().mAutoUseTerrainSpecularMaps);
saveSettingBool(bumpMapLocalLightingCheckBox, "apply lighting to environment maps", "Shaders"); saveSettingBool(*bumpMapLocalLightingCheckBox, Settings::shaders().mApplyLightingToEnvironmentMaps);
saveSettingBool(radialFogCheckBox, "radial fog", "Fog"); saveSettingBool(*radialFogCheckBox, Settings::fog().mRadialFog);
saveSettingBool(softParticlesCheckBox, "soft particles", "Shaders"); saveSettingBool(*softParticlesCheckBox, Settings::shaders().mSoftParticles);
saveSettingBool(antialiasAlphaTestCheckBox, "antialias alpha test", "Shaders"); saveSettingBool(*antialiasAlphaTestCheckBox, Settings::shaders().mAntialiasAlphaTest);
saveSettingBool(adjustCoverageForAlphaTestCheckBox, "adjust coverage for alpha test", "Shaders"); saveSettingBool(*adjustCoverageForAlphaTestCheckBox, Settings::shaders().mAdjustCoverageForAlphaTest);
saveSettingBool(weatherParticleOcclusionCheckBox, "weather particle occlusion", "Shaders"); saveSettingBool(*weatherParticleOcclusionCheckBox, Settings::shaders().mWeatherParticleOcclusion);
saveSettingBool(magicItemAnimationsCheckBox, "use magic item animations", "Game"); saveSettingBool(*magicItemAnimationsCheckBox, Settings::game().mUseMagicItemAnimations);
saveSettingBool(animSourcesCheckBox, "use additional anim sources", "Game"); saveSettingBool(*animSourcesCheckBox, Settings::game().mUseAdditionalAnimSources);
saveSettingBool(weaponSheathingCheckBox, "weapon sheathing", "Game"); saveSettingBool(*weaponSheathingCheckBox, Settings::game().mWeaponSheathing);
saveSettingBool(shieldSheathingCheckBox, "shield sheathing", "Game"); saveSettingBool(*shieldSheathingCheckBox, Settings::game().mShieldSheathing);
saveSettingBool(turnToMovementDirectionCheckBox, "turn to movement direction", "Game"); saveSettingBool(*turnToMovementDirectionCheckBox, Settings::game().mTurnToMovementDirection);
saveSettingBool(smoothMovementCheckBox, "smooth movement", "Game"); saveSettingBool(*smoothMovementCheckBox, Settings::game().mSmoothMovement);
const bool distantTerrain = Settings::Manager::getBool("distant terrain", "Terrain"); const bool wantDistantLand = distantLandCheckBox->checkState() == Qt::Checked;
const bool objectPaging = Settings::Manager::getBool("object paging", "Terrain"); if (wantDistantLand != (Settings::terrain().mDistantTerrain && Settings::terrain().mObjectPaging))
const bool wantDistantLand = distantLandCheckBox->checkState();
if (wantDistantLand != (distantTerrain && objectPaging))
{ {
Settings::Manager::setBool("distant terrain", "Terrain", wantDistantLand); Settings::terrain().mDistantTerrain.set(wantDistantLand);
Settings::Manager::setBool("object paging", "Terrain", wantDistantLand); Settings::terrain().mObjectPaging.set(wantDistantLand);
} }
saveSettingBool(activeGridObjectPagingCheckBox, "object paging active grid", "Terrain"); saveSettingBool(*activeGridObjectPagingCheckBox, Settings::terrain().mObjectPagingActiveGrid);
int viewingDistance = convertToUnits(viewingDistanceComboBox->value()); Settings::camera().mViewingDistance.set(convertToUnits(viewingDistanceComboBox->value()));
if (viewingDistance != Settings::Manager::getInt("viewing distance", "Camera")) Settings::terrain().mObjectPagingMinSize.set(objectPagingMinSizeComboBox->value());
{ saveSettingBool(*nightDaySwitchesCheckBox, Settings::game().mDayNightSwitches);
Settings::Manager::setInt("viewing distance", "Camera", viewingDistance); saveSettingBool(*postprocessEnabledCheckBox, Settings::postProcessing().mEnabled);
} saveSettingBool(*postprocessTransparentPostpassCheckBox, Settings::postProcessing().mTransparentPostpass);
double objectPagingMinSize = objectPagingMinSizeComboBox->value(); Settings::postProcessing().mAutoExposureSpeed.set(postprocessHDRTimeComboBox->value());
if (objectPagingMinSize != Settings::Manager::getDouble("object paging min size", "Terrain")) saveSettingBool(*radialFogCheckBox, Settings::fog().mRadialFog);
Settings::Manager::setDouble("object paging min size", "Terrain", objectPagingMinSize); saveSettingBool(*exponentialFogCheckBox, Settings::fog().mExponentialFog);
saveSettingBool(*skyBlendingCheckBox, Settings::fog().mSkyBlending);
saveSettingBool(nightDaySwitchesCheckBox, "day night switches", "Game"); Settings::fog().mSkyBlendingStart.set(skyBlendingStartComboBox->value());
saveSettingBool(postprocessEnabledCheckBox, "enabled", "Post Processing");
saveSettingBool(postprocessTransparentPostpassCheckBox, "transparent postpass", "Post Processing");
double hdrExposureTime = postprocessHDRTimeComboBox->value();
if (hdrExposureTime != Settings::Manager::getDouble("auto exposure speed", "Post Processing"))
Settings::Manager::setDouble("auto exposure speed", "Post Processing", hdrExposureTime);
saveSettingBool(radialFogCheckBox, "radial fog", "Fog");
saveSettingBool(exponentialFogCheckBox, "exponential fog", "Fog");
saveSettingBool(skyBlendingCheckBox, "sky blending", "Fog");
Settings::Manager::setDouble("sky blending start", "Fog", skyBlendingStartComboBox->value());
} }
// Audio // Audio
{ {
int audioDeviceIndex = audioDeviceSelectorComboBox->currentIndex(); if (audioDeviceSelectorComboBox->currentIndex() != 0)
const std::string& prevAudioDevice = Settings::Manager::getString("device", "Sound"); Settings::sound().mDevice.set(audioDeviceSelectorComboBox->currentText().toStdString());
if (audioDeviceIndex != 0) else
{ Settings::sound().mDevice.set({});
const std::string& newAudioDevice = audioDeviceSelectorComboBox->currentText().toUtf8().constData();
if (newAudioDevice != prevAudioDevice) Settings::sound().mHrtfEnable.set(enableHRTFComboBox->currentIndex() - 1);
Settings::Manager::setString("device", "Sound", newAudioDevice);
} if (hrtfProfileSelectorComboBox->currentIndex() != 0)
else if (!prevAudioDevice.empty()) Settings::sound().mHrtf.set(hrtfProfileSelectorComboBox->currentText().toStdString());
{ else
Settings::Manager::setString("device", "Sound", {}); Settings::sound().mHrtf.set({});
}
int hrtfEnabledIndex = enableHRTFComboBox->currentIndex() - 1;
if (hrtfEnabledIndex != Settings::Manager::getInt("hrtf enable", "Sound"))
{
Settings::Manager::setInt("hrtf enable", "Sound", hrtfEnabledIndex);
}
int selectedHRTFProfileIndex = hrtfProfileSelectorComboBox->currentIndex();
const std::string& prevHRTFProfile = Settings::Manager::getString("hrtf", "Sound");
if (selectedHRTFProfileIndex != 0)
{
const std::string& newHRTFProfile = hrtfProfileSelectorComboBox->currentText().toUtf8().constData();
if (newHRTFProfile != prevHRTFProfile)
Settings::Manager::setString("hrtf", "Sound", newHRTFProfile);
}
else if (!prevHRTFProfile.empty())
{
Settings::Manager::setString("hrtf", "Sound", {});
}
} }
// Interface Changes // Interface Changes
{ {
saveSettingBool(showEffectDurationCheckBox, "show effect duration", "Game"); saveSettingBool(*showEffectDurationCheckBox, Settings::game().mShowEffectDuration);
saveSettingBool(showEnchantChanceCheckBox, "show enchant chance", "Game"); saveSettingBool(*showEnchantChanceCheckBox, Settings::game().mShowEnchantChance);
saveSettingBool(showMeleeInfoCheckBox, "show melee info", "Game"); saveSettingBool(*showMeleeInfoCheckBox, Settings::game().mShowMeleeInfo);
saveSettingBool(showProjectileDamageCheckBox, "show projectile damage", "Game"); saveSettingBool(*showProjectileDamageCheckBox, Settings::game().mShowProjectileDamage);
saveSettingBool(changeDialogTopicsCheckBox, "color topic enable", "GUI"); saveSettingBool(*changeDialogTopicsCheckBox, Settings::gui().mColorTopicEnable);
saveSettingInt(showOwnedComboBox, "show owned", "Game"); saveSettingInt(*showOwnedComboBox, Settings::game().mShowOwned);
saveSettingBool(stretchBackgroundCheckBox, "stretch menu background", "GUI"); saveSettingBool(*stretchBackgroundCheckBox, Settings::gui().mStretchMenuBackground);
saveSettingBool(useZoomOnMapCheckBox, "allow zooming", "Map"); saveSettingBool(*useZoomOnMapCheckBox, Settings::map().mAllowZooming);
saveSettingBool(graphicHerbalismCheckBox, "graphic herbalism", "Game"); saveSettingBool(*graphicHerbalismCheckBox, Settings::game().mGraphicHerbalism);
Settings::gui().mScalingFactor.set(scalingSpinBox->value());
float uiScalingFactor = scalingSpinBox->value(); Settings::gui().mFontSize.set(fontSizeSpinBox->value());
if (uiScalingFactor != Settings::Manager::getFloat("scaling factor", "GUI"))
Settings::Manager::setFloat("scaling factor", "GUI", uiScalingFactor);
int fontSize = fontSizeSpinBox->value();
if (fontSize != Settings::Manager::getInt("font size", "GUI"))
Settings::Manager::setInt("font size", "GUI", fontSize);
} }
// Bug fixes // Bug fixes
{ {
saveSettingBool(preventMerchantEquippingCheckBox, "prevent merchant equipping", "Game"); saveSettingBool(*preventMerchantEquippingCheckBox, Settings::game().mPreventMerchantEquipping);
saveSettingBool( saveSettingBool(
trainersTrainingSkillsBasedOnBaseSkillCheckBox, "trainers training skills based on base skill", "Game"); *trainersTrainingSkillsBasedOnBaseSkillCheckBox, Settings::game().mTrainersTrainingSkillsBasedOnBaseSkill);
} }
// Miscellaneous // Miscellaneous
{ {
// Saves Settings // Saves Settings
saveSettingBool(timePlayedCheckbox, "timeplayed", "Saves"); saveSettingBool(*timePlayedCheckbox, Settings::saves().mTimeplayed);
saveSettingInt(maximumQuicksavesComboBox, "max quicksaves", "Saves"); saveSettingInt(*maximumQuicksavesComboBox, Settings::saves().mMaxQuicksaves);
// Other Settings // Other Settings
std::string screenshotFormatString = screenshotFormatComboBox->currentText().toLower().toStdString(); Settings::general().mScreenshotFormat.set(screenshotFormatComboBox->currentText().toLower().toStdString());
if (screenshotFormatString != Settings::Manager::getString("screenshot format", "General")) saveSettingBool(*notifyOnSavedScreenshotCheckBox, Settings::general().mNotifyOnSavedScreenshot);
Settings::Manager::setString("screenshot format", "General", screenshotFormatString);
saveSettingBool(notifyOnSavedScreenshotCheckBox, "notify on saved screenshot", "General");
} }
// Testing // Testing
{ {
saveSettingBool(grabCursorCheckBox, "grab cursor", "Input"); saveSettingBool(*grabCursorCheckBox, Settings::input().mGrabCursor);
int skipMenu = skipMenuCheckBox->checkState() == Qt::Checked; int skipMenu = skipMenuCheckBox->checkState() == Qt::Checked;
if (skipMenu != mGameSettings.value("skip-menu").toInt()) if (skipMenu != mGameSettings.value("skip-menu").toInt())

Loading…
Cancel
Save