mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-30 09:15:38 +00:00
Merge branch 'settings_values_game' into 'master'
Use settings values for Game settings (#6876) See merge request OpenMW/openmw!3188
This commit is contained in:
commit
050fc20379
45 changed files with 180 additions and 239 deletions
|
@ -31,11 +31,21 @@ namespace
|
|||
comboBox.setCurrentIndex(value);
|
||||
}
|
||||
|
||||
void loadSettingInt(const Settings::SettingValue<DetourNavigator::CollisionShapeType>& value, QComboBox& comboBox)
|
||||
{
|
||||
comboBox.setCurrentIndex(static_cast<int>(value.get()));
|
||||
}
|
||||
|
||||
void saveSettingInt(const QComboBox& comboBox, Settings::SettingValue<int>& value)
|
||||
{
|
||||
value.set(comboBox.currentIndex());
|
||||
}
|
||||
|
||||
void saveSettingInt(const QComboBox& comboBox, Settings::SettingValue<DetourNavigator::CollisionShapeType>& value)
|
||||
{
|
||||
value.set(static_cast<DetourNavigator::CollisionShapeType>(comboBox.currentIndex()));
|
||||
}
|
||||
|
||||
void loadSettingInt(const Settings::SettingValue<int>& value, QSpinBox& spinBox)
|
||||
{
|
||||
spinBox.setValue(value);
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
#include <components/resource/imagemanager.hpp>
|
||||
#include <components/resource/niffilemanager.hpp>
|
||||
#include <components/resource/scenemanager.hpp>
|
||||
#include <components/settings/settings.hpp>
|
||||
#include <components/settings/values.hpp>
|
||||
#include <components/to_utf8/to_utf8.hpp>
|
||||
#include <components/version/version.hpp>
|
||||
#include <components/vfs/manager.hpp>
|
||||
|
@ -196,11 +196,10 @@ namespace NavMeshTool
|
|||
|
||||
Settings::Manager::load(config);
|
||||
|
||||
const auto agentCollisionShape = DetourNavigator::toCollisionShapeType(
|
||||
Settings::Manager::getInt("actor collision shape type", "Game"));
|
||||
const osg::Vec3f agentHalfExtents
|
||||
= Settings::Manager::getVector3("default actor pathfind half extents", "Game");
|
||||
const DetourNavigator::AgentBounds agentBounds{ agentCollisionShape, agentHalfExtents };
|
||||
const DetourNavigator::AgentBounds agentBounds{
|
||||
Settings::game().mActorCollisionShapeType,
|
||||
Settings::game().mDefaultActorPathfindHalfExtents,
|
||||
};
|
||||
const std::uint64_t maxDbFileSize = Settings::Manager::getUInt64("max navmeshdb file size", "Navigator");
|
||||
const auto dbPath = Files::pathToUnicodeString(config.getUserDataPath() / "navmesh.db");
|
||||
|
||||
|
|
|
@ -239,8 +239,6 @@ namespace MWBase
|
|||
|
||||
virtual void processChangedSettings(const std::set<std::pair<std::string, std::string>>& settings) = 0;
|
||||
|
||||
virtual float getActorsProcessingRange() const = 0;
|
||||
|
||||
virtual void notifyDied(const MWWorld::Ptr& actor) = 0;
|
||||
|
||||
virtual bool onOpen(const MWWorld::Ptr& ptr) = 0;
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#include <components/esm3/containerstate.hpp>
|
||||
#include <components/esm3/loadcont.hpp>
|
||||
#include <components/esm3/loadsoun.hpp>
|
||||
#include <components/settings/settings.hpp>
|
||||
#include <components/settings/values.hpp>
|
||||
|
||||
#include "../mwbase/environment.hpp"
|
||||
#include "../mwbase/soundmanager.hpp"
|
||||
|
@ -61,7 +61,6 @@ namespace MWClass
|
|||
|
||||
Container::Container()
|
||||
: MWWorld::RegisteredClass<Container>(ESM::Container::sRecordId)
|
||||
, mHarvestEnabled(Settings::Manager::getBool("graphic herbalism", "Game"))
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -80,7 +79,7 @@ namespace MWClass
|
|||
|
||||
bool Container::canBeHarvested(const MWWorld::ConstPtr& ptr) const
|
||||
{
|
||||
if (!mHarvestEnabled)
|
||||
if (!Settings::game().mGraphicHerbalism)
|
||||
return false;
|
||||
const MWRender::Animation* animation = MWBase::Environment::get().getWorld()->getAnimation(ptr);
|
||||
if (animation == nullptr)
|
||||
|
|
|
@ -31,8 +31,6 @@ namespace MWClass
|
|||
{
|
||||
friend MWWorld::RegisteredClass<Container>;
|
||||
|
||||
const bool mHarvestEnabled;
|
||||
|
||||
Container();
|
||||
|
||||
void ensureCustomData(const MWWorld::Ptr& ptr) const;
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#include <components/esm3/loadsndg.hpp>
|
||||
#include <components/esm3/loadsoun.hpp>
|
||||
#include <components/misc/rng.hpp>
|
||||
#include <components/settings/settings.hpp>
|
||||
#include <components/settings/values.hpp>
|
||||
|
||||
#include "../mwmechanics/actorutil.hpp"
|
||||
#include "../mwmechanics/aisetting.hpp"
|
||||
|
@ -484,10 +484,8 @@ namespace MWClass
|
|||
|
||||
if (stats.isDead())
|
||||
{
|
||||
bool canLoot = Settings::Manager::getBool("can loot during death animation", "Game");
|
||||
|
||||
// by default user can loot friendly actors during death animation
|
||||
if (canLoot && !stats.getAiSequence().isInCombat())
|
||||
if (Settings::game().mCanLootDuringDeathAnimation && !stats.getAiSequence().isInCombat())
|
||||
return std::make_unique<MWWorld::ActionOpen>(ptr);
|
||||
|
||||
// otherwise wait until death animation
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#include <components/esm3/loadnpc.hpp>
|
||||
#include <components/esm3/objectstate.hpp>
|
||||
#include <components/esm4/loadligh.hpp>
|
||||
#include <components/settings/settings.hpp>
|
||||
#include <components/settings/values.hpp>
|
||||
|
||||
#include "../mwbase/environment.hpp"
|
||||
#include "../mwbase/soundmanager.hpp"
|
||||
|
@ -166,8 +166,7 @@ namespace MWClass
|
|||
std::string text;
|
||||
|
||||
// Don't show duration for infinite light sources.
|
||||
if (Settings::Manager::getBool("show effect duration", "Game")
|
||||
&& ptr.getClass().getRemainingUsageTime(ptr) != -1)
|
||||
if (Settings::game().mShowEffectDuration && ptr.getClass().getRemainingUsageTime(ptr) != -1)
|
||||
text += MWGui::ToolTips::getDurationString(ptr.getClass().getRemainingUsageTime(ptr), "\n#{sDuration}");
|
||||
|
||||
text += MWGui::ToolTips::getWeightString(ref->mBase->mData.mWeight, "#{sWeight}");
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#include <components/esm3/loadmisc.hpp>
|
||||
#include <components/esm3/loadnpc.hpp>
|
||||
|
||||
#include <components/settings/settings.hpp>
|
||||
#include <components/settings/values.hpp>
|
||||
|
||||
#include "../mwbase/environment.hpp"
|
||||
#include "../mwbase/windowmanager.hpp"
|
||||
|
@ -90,7 +90,7 @@ namespace MWClass
|
|||
if (creature)
|
||||
{
|
||||
int soul = creature->mData.mSoul;
|
||||
if (Settings::Manager::getBool("rebalance soul gem values", "Game"))
|
||||
if (Settings::game().mRebalanceSoulGemValues)
|
||||
{
|
||||
// use the 'soul gem value rebalance' formula from the Morrowind Code Patch
|
||||
float soulValue = 0.0001 * pow(soul, 3) + 2 * soul;
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
#include <components/esm3/loadrace.hpp>
|
||||
#include <components/esm3/loadsoun.hpp>
|
||||
#include <components/esm3/npcstate.hpp>
|
||||
#include <components/settings/settings.hpp>
|
||||
#include <components/settings/values.hpp>
|
||||
|
||||
#include "../mwbase/dialoguemanager.hpp"
|
||||
#include "../mwbase/environment.hpp"
|
||||
|
@ -826,12 +826,10 @@ namespace MWClass
|
|||
}
|
||||
if (hasArmor)
|
||||
{
|
||||
static const bool creatureDamage
|
||||
= Settings::Manager::getBool("unarmed creature attacks damage armor", "Game");
|
||||
|
||||
// Unarmed creature attacks don't affect armor condition unless it was
|
||||
// explicitly requested.
|
||||
if (!object.isEmpty() || attacker.isEmpty() || attacker.getClass().isNpc()
|
||||
|| creatureDamage) // Unarmed creature attacks don't affect armor condition unless it was
|
||||
// explicitly requested.
|
||||
|| Settings::game().mUnarmedCreatureAttacksDamageArmor)
|
||||
{
|
||||
int armorhealth = armor.getClass().getItemHealth(armor);
|
||||
armorhealth -= std::min(damageDiff, armorhealth);
|
||||
|
@ -919,10 +917,8 @@ namespace MWClass
|
|||
|
||||
if (stats.isDead())
|
||||
{
|
||||
bool canLoot = Settings::Manager::getBool("can loot during death animation", "Game");
|
||||
|
||||
// by default user can loot friendly actors during death animation
|
||||
if (canLoot && !stats.getAiSequence().isInCombat())
|
||||
if (Settings::game().mCanLootDuringDeathAnimation && !stats.getAiSequence().isInCombat())
|
||||
return std::make_unique<MWWorld::ActionOpen>(ptr);
|
||||
|
||||
// otherwise wait until death animation
|
||||
|
@ -940,9 +936,7 @@ namespace MWClass
|
|||
}
|
||||
else // In combat
|
||||
{
|
||||
const bool stealingInCombat
|
||||
= Settings::Manager::getBool("always allow stealing from knocked out actors", "Game");
|
||||
if (stealingInCombat && stats.getKnockedDown())
|
||||
if (Settings::game().mAlwaysAllowStealingFromKnockedOutActors && stats.getKnockedDown())
|
||||
return std::make_unique<MWWorld::ActionOpen>(ptr); // stealing
|
||||
}
|
||||
|
||||
|
@ -1090,9 +1084,7 @@ namespace MWClass
|
|||
if (!customData.mNpcStats.getAiSequence().isInCombat())
|
||||
return true;
|
||||
|
||||
const bool stealingInCombat
|
||||
= Settings::Manager::getBool("always allow stealing from knocked out actors", "Game");
|
||||
if (stealingInCombat && customData.mNpcStats.getKnockedDown())
|
||||
if (Settings::game().mAlwaysAllowStealingFromKnockedOutActors && customData.mNpcStats.getKnockedDown())
|
||||
return true;
|
||||
|
||||
return false;
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#include <components/esm3/loadnpc.hpp>
|
||||
#include <components/esm3/loadweap.hpp>
|
||||
#include <components/misc/constants.hpp>
|
||||
#include <components/settings/settings.hpp>
|
||||
#include <components/settings/values.hpp>
|
||||
|
||||
#include "../mwbase/environment.hpp"
|
||||
#include "../mwbase/mechanicsmanager.hpp"
|
||||
|
@ -160,8 +160,7 @@ namespace MWClass
|
|||
std::string text;
|
||||
|
||||
// weapon type & damage
|
||||
if (weaponType->mWeaponClass != ESM::WeaponType::Ammo
|
||||
|| Settings::Manager::getBool("show projectile damage", "Game"))
|
||||
if (weaponType->mWeaponClass != ESM::WeaponType::Ammo || Settings::game().mShowProjectileDamage)
|
||||
{
|
||||
text += "\n#{sType} ";
|
||||
|
||||
|
@ -215,7 +214,7 @@ namespace MWClass
|
|||
+ MWGui::ToolTips::toString(ref->mBase->mData.mHealth);
|
||||
}
|
||||
|
||||
const bool verbose = Settings::Manager::getBool("show melee info", "Game");
|
||||
const bool verbose = Settings::game().mShowMeleeInfo;
|
||||
// add reach for melee weapon
|
||||
if (weaponType->mWeaponClass == ESM::WeaponType::Melee && verbose)
|
||||
{
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
#include <components/interpreter/defines.hpp>
|
||||
#include <components/interpreter/interpreter.hpp>
|
||||
|
||||
#include <components/settings/settings.hpp>
|
||||
#include <components/settings/values.hpp>
|
||||
|
||||
#include "../mwbase/environment.hpp"
|
||||
#include "../mwbase/journal.hpp"
|
||||
|
@ -583,7 +583,7 @@ namespace MWDialogue
|
|||
updateOriginalDisposition();
|
||||
mCurrentDisposition += delta;
|
||||
mActor.getClass().getNpcStats(mActor).setBaseDisposition(mCurrentDisposition);
|
||||
if (Settings::Manager::getBool("barter disposition change is permanent", "Game"))
|
||||
if (Settings::game().mBarterDispositionChangeIsPermanent)
|
||||
mPermanentDispositionChange += delta;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#include <MyGUI_ScrollView.h>
|
||||
|
||||
#include <components/misc/strings/format.hpp>
|
||||
#include <components/settings/settings.hpp>
|
||||
#include <components/settings/values.hpp>
|
||||
#include <components/widgets/list.hpp>
|
||||
|
||||
#include <components/esm3/loadgmst.hpp>
|
||||
|
@ -158,8 +158,7 @@ namespace MWGui
|
|||
mEnchanting.setSelfEnchanting(true);
|
||||
mEnchanting.setEnchanter(MWMechanics::getPlayer());
|
||||
mBuyButton->setCaptionWithReplacing("#{sCreate}");
|
||||
bool enabled = Settings::Manager::getBool("show enchant chance", "Game");
|
||||
mChanceLayout->setVisible(enabled);
|
||||
mChanceLayout->setVisible(Settings::game().mShowEnchantChance);
|
||||
mPtr = MWMechanics::getPlayer();
|
||||
setSoulGem(ptr);
|
||||
mPrice->setVisible(false);
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#include <components/esm3/loadmgef.hpp>
|
||||
#include <components/misc/resourcehelpers.hpp>
|
||||
#include <components/resource/resourcesystem.hpp>
|
||||
#include <components/settings/settings.hpp>
|
||||
#include <components/settings/values.hpp>
|
||||
|
||||
#include "../mwbase/environment.hpp"
|
||||
#include "../mwbase/windowmanager.hpp"
|
||||
|
@ -136,7 +136,7 @@ namespace MWGui
|
|||
+= MWBase::Environment::get().getWindowManager()->getGameSettingString("spoint", {});
|
||||
}
|
||||
}
|
||||
if (effectInfo.mRemainingTime > -1 && Settings::Manager::getBool("show effect duration", "Game"))
|
||||
if (effectInfo.mRemainingTime > -1 && Settings::game().mShowEffectDuration)
|
||||
sourcesDescription
|
||||
+= MWGui::ToolTips::getDurationString(effectInfo.mRemainingTime, " #{sDuration}");
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#include <components/esm/records.hpp>
|
||||
#include <components/l10n/manager.hpp>
|
||||
#include <components/misc/resourcehelpers.hpp>
|
||||
#include <components/settings/settings.hpp>
|
||||
#include <components/settings/values.hpp>
|
||||
#include <components/widgets/box.hpp>
|
||||
|
||||
#include "../mwbase/environment.hpp"
|
||||
|
@ -42,7 +42,6 @@ namespace MWGui
|
|||
, mLastMouseY(0)
|
||||
, mEnabled(true)
|
||||
, mFullHelp(false)
|
||||
, mShowOwned(0)
|
||||
, mFrameDuration(0.f)
|
||||
{
|
||||
getWidget(mDynamicToolTipBox, "DynamicToolTipBox");
|
||||
|
@ -61,8 +60,6 @@ namespace MWGui
|
|||
{
|
||||
mMainWidget->getChildAt(i)->setVisible(false);
|
||||
}
|
||||
|
||||
mShowOwned = Settings::Manager::getInt("show owned", "Game");
|
||||
}
|
||||
|
||||
void ToolTips::setEnabled(bool enabled)
|
||||
|
@ -402,7 +399,8 @@ namespace MWGui
|
|||
{
|
||||
mDynamicToolTipBox->setVisible(true);
|
||||
|
||||
if ((mShowOwned == 1 || mShowOwned == 3) && isOwned)
|
||||
const int showOwned = Settings::game().mShowOwned;
|
||||
if ((showOwned == 1 || showOwned == 3) && isOwned)
|
||||
mDynamicToolTipBox->changeWidgetSkin(MWBase::Environment::get().getWindowManager()->isGuiMode()
|
||||
? "HUD_Box_NoTransp_Owned"
|
||||
: "HUD_Box_Owned");
|
||||
|
|
|
@ -134,8 +134,6 @@ namespace MWGui
|
|||
|
||||
bool mFullHelp;
|
||||
|
||||
int mShowOwned;
|
||||
|
||||
float mFrameDuration;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include "tradeitemmodel.hpp"
|
||||
|
||||
#include <components/misc/strings/algorithm.hpp>
|
||||
#include <components/settings/settings.hpp>
|
||||
#include <components/settings/values.hpp>
|
||||
|
||||
#include "../mwworld/class.hpp"
|
||||
#include "../mwworld/containerstore.hpp"
|
||||
|
@ -140,9 +140,8 @@ namespace MWGui
|
|||
throw std::runtime_error("The borrowed item disappeared");
|
||||
|
||||
const ItemStack& item = sourceModel->getItem(i);
|
||||
static const bool prevent = Settings::Manager::getBool("prevent merchant equipping", "Game");
|
||||
// copy the borrowed items to our model
|
||||
copyItem(item, itemStack.mCount, !prevent);
|
||||
copyItem(item, itemStack.mCount, !Settings::game().mPreventMerchantEquipping);
|
||||
// then remove them from the source model
|
||||
sourceModel->removeItem(item, itemStack.mCount);
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
#include "../mwmechanics/npcstats.hpp"
|
||||
|
||||
#include <components/esm3/loadclas.hpp>
|
||||
#include <components/settings/settings.hpp>
|
||||
#include <components/settings/values.hpp>
|
||||
|
||||
#include "tooltips.hpp"
|
||||
|
||||
|
@ -27,8 +27,6 @@ namespace MWGui
|
|||
TrainingWindow::TrainingWindow()
|
||||
: WindowBase("openmw_trainingwindow.layout")
|
||||
, mTimeAdvancer(0.05f)
|
||||
, mTrainingSkillBasedOnBaseSkill(
|
||||
Settings::Manager::getBool("trainers training skills based on base skill", "Game"))
|
||||
{
|
||||
getWidget(mTrainingOptions, "TrainingOptions");
|
||||
getWidget(mCancelButton, "CancelButton");
|
||||
|
@ -199,7 +197,7 @@ namespace MWGui
|
|||
|
||||
float TrainingWindow::getSkillForTraining(const MWMechanics::NpcStats& stats, ESM::RefId id) const
|
||||
{
|
||||
if (mTrainingSkillBasedOnBaseSkill)
|
||||
if (Settings::game().mTrainersTrainingSkillsBasedOnBaseSkill)
|
||||
return stats.getSkill(id).getBase();
|
||||
return stats.getSkill(id).getModified();
|
||||
}
|
||||
|
|
|
@ -50,7 +50,6 @@ namespace MWGui
|
|||
|
||||
WaitDialogProgressBar mProgressBar;
|
||||
TimeAdvancer mTimeAdvancer;
|
||||
bool mTrainingSkillBasedOnBaseSkill; // corresponds to the setting 'training skills based on base skill'
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -196,7 +196,6 @@ namespace MWGui
|
|||
, mForceHidden(GW_None)
|
||||
, mAllowed(GW_ALL)
|
||||
, mRestAllowed(true)
|
||||
, mShowOwned(0)
|
||||
, mEncoding(encoding)
|
||||
, mVersionDescription(versionDescription)
|
||||
, mWindowVisible(true)
|
||||
|
@ -297,8 +296,6 @@ namespace MWGui
|
|||
MyGUI::ClipboardManager::getInstance().eventClipboardRequested
|
||||
+= MyGUI::newDelegate(this, &WindowManager::onClipboardRequested);
|
||||
|
||||
mShowOwned = Settings::Manager::getInt("show owned", "Game");
|
||||
|
||||
mVideoWrapper = std::make_unique<SDLUtil::VideoWrapper>(window, viewer);
|
||||
mVideoWrapper->setGammaContrast(
|
||||
Settings::Manager::getFloat("gamma", "Video"), Settings::Manager::getFloat("contrast", "Video"));
|
||||
|
@ -1040,7 +1037,8 @@ namespace MWGui
|
|||
{
|
||||
mToolTips->setFocusObject(focus);
|
||||
|
||||
if (mHud && (mShowOwned == 2 || mShowOwned == 3))
|
||||
const int showOwned = Settings::game().mShowOwned;
|
||||
if (mHud && (showOwned == 2 || showOwned == 3))
|
||||
{
|
||||
bool owned = mToolTips->checkOwned();
|
||||
mHud->setCrosshairOwned(owned);
|
||||
|
|
|
@ -515,8 +515,6 @@ namespace MWGui
|
|||
|
||||
void updateMap();
|
||||
|
||||
int mShowOwned;
|
||||
|
||||
ToUTF8::FromType mEncoding;
|
||||
|
||||
std::string mVersionDescription;
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#include <components/detournavigator/navigator.hpp>
|
||||
#include <components/detournavigator/navigatorutils.hpp>
|
||||
#include <components/lua/luastate.hpp>
|
||||
#include <components/settings/settings.hpp>
|
||||
#include <components/settings/values.hpp>
|
||||
|
||||
#include "../mwbase/environment.hpp"
|
||||
#include "../mwbase/world.hpp"
|
||||
|
@ -166,8 +166,8 @@ namespace MWLua
|
|||
}));
|
||||
|
||||
static const DetourNavigator::AgentBounds defaultAgentBounds{
|
||||
DetourNavigator::toCollisionShapeType(Settings::Manager::getInt("actor collision shape type", "Game")),
|
||||
Settings::Manager::getVector3("default actor pathfind half extents", "Game"),
|
||||
Settings::game().mActorCollisionShapeType,
|
||||
Settings::game().mDefaultActorPathfindHalfExtents,
|
||||
};
|
||||
static const float defaultStepSize
|
||||
= 2 * std::max(defaultAgentBounds.mHalfExtents.x(), defaultAgentBounds.mHalfExtents.y());
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#include <components/esm3/loadmgef.hpp>
|
||||
#include <components/esm3/loadstat.hpp>
|
||||
|
||||
#include <components/settings/settings.hpp>
|
||||
#include <components/settings/values.hpp>
|
||||
|
||||
#include "actorutil.hpp"
|
||||
#include "creaturestats.hpp"
|
||||
|
@ -289,9 +289,7 @@ namespace MWMechanics
|
|||
{
|
||||
if (!reflected)
|
||||
{
|
||||
static const bool keepOriginalCaster
|
||||
= Settings::Manager::getBool("classic reflected absorb spells behavior", "Game");
|
||||
if (keepOriginalCaster)
|
||||
if (Settings::game().mClassicReflectedAbsorbSpellsBehavior)
|
||||
reflected = { *spellIt, caster };
|
||||
else
|
||||
reflected = { *spellIt, ptr };
|
||||
|
@ -369,8 +367,7 @@ namespace MWMechanics
|
|||
++spellIt;
|
||||
}
|
||||
|
||||
static const bool keepCalm = Settings::Manager::getBool("classic calm spells behavior", "Game");
|
||||
if (keepCalm)
|
||||
if (Settings::game().mClassicCalmSpellsBehavior)
|
||||
{
|
||||
ESM::MagicEffect::Effects effect
|
||||
= ptr.getClass().isNpc() ? ESM::MagicEffect::CalmHumanoid : ESM::MagicEffect::CalmCreature;
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#include <components/misc/resourcehelpers.hpp>
|
||||
#include <components/misc/rng.hpp>
|
||||
#include <components/sceneutil/positionattitudetransform.hpp>
|
||||
#include <components/settings/settings.hpp>
|
||||
#include <components/settings/values.hpp>
|
||||
|
||||
#include <components/esm3/loadcrea.hpp>
|
||||
#include <components/esm3/loadgmst.hpp>
|
||||
|
@ -425,7 +425,7 @@ namespace MWMechanics
|
|||
|
||||
void Actors::updateMovementSpeed(const MWWorld::Ptr& actor) const
|
||||
{
|
||||
if (mSmoothMovement)
|
||||
if (Settings::game().mSmoothMovement)
|
||||
return;
|
||||
|
||||
const auto& actorClass = actor.getClass();
|
||||
|
@ -559,7 +559,7 @@ namespace MWMechanics
|
|||
float angle = std::atan2(from, to);
|
||||
actorState.setAngleToPlayer(angle);
|
||||
float deltaAngle = Misc::normalizeAngle(angle - actor.getRefData().getPosition().rot[2]);
|
||||
if (!mSmoothMovement || std::abs(deltaAngle) > osg::DegreesToRadians(60.f))
|
||||
if (!Settings::game().mSmoothMovement || std::abs(deltaAngle) > osg::DegreesToRadians(60.f))
|
||||
actorState.setTurningToPlayer(true);
|
||||
}
|
||||
}
|
||||
|
@ -598,8 +598,9 @@ namespace MWMechanics
|
|||
const osg::Vec3f actor1Pos(actor1.getRefData().getPosition().asVec3());
|
||||
const osg::Vec3f actor2Pos(actor2.getRefData().getPosition().asVec3());
|
||||
const float sqrDist = (actor1Pos - actor2Pos).length2();
|
||||
const int actorsProcessingRange = Settings::game().mActorsProcessingRange;
|
||||
|
||||
if (sqrDist > mActorsProcessingRange * mActorsProcessingRange)
|
||||
if (sqrDist > actorsProcessingRange * actorsProcessingRange)
|
||||
return;
|
||||
|
||||
// If this is set to true, actor1 will start combat with actor2 if the awareness check at the end of the method
|
||||
|
@ -677,8 +678,7 @@ namespace MWMechanics
|
|||
|
||||
// If set in the settings file, player followers and escorters will become aggressive toward enemies in combat
|
||||
// with them or the player
|
||||
static const bool followersAttackOnSight = Settings::Manager::getBool("followers attack on sight", "Game");
|
||||
if (!aggressive && isPlayerFollowerOrEscorter && followersAttackOnSight)
|
||||
if (!aggressive && isPlayerFollowerOrEscorter && Settings::game().mFollowersAttackOnSight)
|
||||
{
|
||||
if (creatureStats2.getAiSequence().isInCombat(actor1))
|
||||
aggressive = true;
|
||||
|
@ -1161,31 +1161,6 @@ namespace MWMechanics
|
|||
}
|
||||
}
|
||||
|
||||
Actors::Actors()
|
||||
: mSmoothMovement(Settings::Manager::getBool("smooth movement", "Game"))
|
||||
{
|
||||
mTimerDisposeSummonsCorpses
|
||||
= 0.2f; // We should add a delay between summoned creature death and its corpse despawning
|
||||
|
||||
updateProcessingRange();
|
||||
}
|
||||
|
||||
float Actors::getProcessingRange() const
|
||||
{
|
||||
return mActorsProcessingRange;
|
||||
}
|
||||
|
||||
void Actors::updateProcessingRange()
|
||||
{
|
||||
// We have to cap it since using high values (larger than 7168) will make some quests harder or impossible to
|
||||
// complete (bug #1876)
|
||||
static constexpr float maxRange = 7168.f;
|
||||
static constexpr float minRange = maxRange / 2.f;
|
||||
|
||||
mActorsProcessingRange
|
||||
= std::clamp(Settings::Manager::getFloat("actors processing range", "Game"), minRange, maxRange);
|
||||
}
|
||||
|
||||
void Actors::addActor(const MWWorld::Ptr& ptr, bool updateImmediately)
|
||||
{
|
||||
removeActor(ptr, true);
|
||||
|
@ -1216,7 +1191,8 @@ namespace MWMechanics
|
|||
|
||||
const float dist
|
||||
= (player.getRefData().getPosition().asVec3() - ptr.getRefData().getPosition().asVec3()).length();
|
||||
if (dist > mActorsProcessingRange)
|
||||
const int actorsProcessingRange = Settings::game().mActorsProcessingRange;
|
||||
if (dist > actorsProcessingRange)
|
||||
{
|
||||
ptr.getRefData().getBaseNode()->setNodeMask(0);
|
||||
return;
|
||||
|
@ -1226,8 +1202,8 @@ namespace MWMechanics
|
|||
|
||||
// Fade away actors on large distance (>90% of actor's processing distance)
|
||||
float visibilityRatio = 1.0;
|
||||
const float fadeStartDistance = mActorsProcessingRange * 0.9f;
|
||||
const float fadeEndDistance = mActorsProcessingRange;
|
||||
const float fadeStartDistance = actorsProcessingRange * 0.9f;
|
||||
const float fadeEndDistance = actorsProcessingRange;
|
||||
const float fadeRatio = (dist - fadeStartDistance) / (fadeEndDistance - fadeStartDistance);
|
||||
if (fadeRatio > 0)
|
||||
visibilityRatio -= std::max(0.f, fadeRatio);
|
||||
|
@ -1271,7 +1247,7 @@ namespace MWMechanics
|
|||
// Otherwise check if any actor in AI processing range sees the target actor
|
||||
std::vector<MWWorld::Ptr> neighbors;
|
||||
osg::Vec3f position(actor.getRefData().getPosition().asVec3());
|
||||
getObjectsInRange(position, mActorsProcessingRange, neighbors);
|
||||
getObjectsInRange(position, Settings::game().mActorsProcessingRange, neighbors);
|
||||
for (const MWWorld::Ptr& neighbor : neighbors)
|
||||
{
|
||||
if (neighbor == actor)
|
||||
|
@ -1318,13 +1294,15 @@ namespace MWMechanics
|
|||
|
||||
if (aiActive)
|
||||
{
|
||||
const int actorsProcessingRange = Settings::game().mActorsProcessingRange;
|
||||
for (const Actor& actor : mActors)
|
||||
{
|
||||
if (actor.getPtr() == player)
|
||||
continue;
|
||||
|
||||
bool inProcessingRange = (playerPos - actor.getPtr().getRefData().getPosition().asVec3()).length2()
|
||||
<= mActorsProcessingRange * mActorsProcessingRange;
|
||||
const bool inProcessingRange
|
||||
= (playerPos - actor.getPtr().getRefData().getPosition().asVec3()).length2()
|
||||
<= actorsProcessingRange * actorsProcessingRange;
|
||||
if (inProcessingRange)
|
||||
{
|
||||
MWMechanics::CreatureStats& stats = actor.getPtr().getClass().getCreatureStats(actor.getPtr());
|
||||
|
@ -1361,7 +1339,7 @@ namespace MWMechanics
|
|||
const float maxDistForPartialAvoiding = 200.f;
|
||||
const float maxDistForStrictAvoiding = 100.f;
|
||||
const float maxTimeToCheck = 2.0f;
|
||||
static const bool giveWayWhenIdle = Settings::Manager::getBool("NPCs give way", "Game");
|
||||
const bool giveWayWhenIdle = Settings::game().mNPCsGiveWay;
|
||||
|
||||
const MWWorld::Ptr player = getPlayer();
|
||||
const MWBase::World* const world = MWBase::Environment::get().getWorld();
|
||||
|
@ -1546,6 +1524,7 @@ namespace MWMechanics
|
|||
player.getClass().getCreatureStats(player).setHitAttemptActorId(-1);
|
||||
}
|
||||
const bool godmode = MWBase::Environment::get().getWorld()->getGodModeState();
|
||||
const int actorsProcessingRange = Settings::game().mActorsProcessingRange;
|
||||
|
||||
// AI and magic effects update
|
||||
for (Actor& actor : mActors)
|
||||
|
@ -1557,7 +1536,7 @@ namespace MWMechanics
|
|||
|
||||
const float distSqr = (playerPos - actor.getPtr().getRefData().getPosition().asVec3()).length2();
|
||||
// AI processing is only done within given distance to the player.
|
||||
const bool inProcessingRange = distSqr <= mActorsProcessingRange * mActorsProcessingRange;
|
||||
const bool inProcessingRange = distSqr <= actorsProcessingRange * actorsProcessingRange;
|
||||
|
||||
// If dead or no longer in combat, no longer store any actors who attempted to hit us. Also remove for
|
||||
// the player.
|
||||
|
@ -1656,8 +1635,7 @@ namespace MWMechanics
|
|||
}
|
||||
}
|
||||
|
||||
static const bool avoidCollisions = Settings::Manager::getBool("NPCs avoid collisions", "Game");
|
||||
if (avoidCollisions)
|
||||
if (Settings::game().mNPCsAvoidCollisions)
|
||||
predictAndAvoidCollisions(duration);
|
||||
|
||||
mTimerUpdateHeadTrack += duration;
|
||||
|
@ -1679,7 +1657,7 @@ namespace MWMechanics
|
|||
MWMechanics::AiSequence& seq = stats.getAiSequence();
|
||||
alwaysActive = !seq.isEmpty() && seq.getActivePackage().alwaysActive();
|
||||
}
|
||||
const bool inRange = isPlayer || dist <= mActorsProcessingRange || alwaysActive;
|
||||
const bool inRange = isPlayer || dist <= actorsProcessingRange || alwaysActive;
|
||||
const int activeFlag = isPlayer ? 2 : 1; // Can be changed back to '2' to keep updating bounding boxes
|
||||
// off screen (more accurate, but slower)
|
||||
const int active = inRange ? activeFlag : 0;
|
||||
|
@ -1893,6 +1871,7 @@ namespace MWMechanics
|
|||
|
||||
const MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
||||
const osg::Vec3f playerPos = player.getRefData().getPosition().asVec3();
|
||||
const int actorsProcessingRange = Settings::game().mActorsProcessingRange;
|
||||
|
||||
for (const Actor& actor : mActors)
|
||||
{
|
||||
|
@ -1907,7 +1886,7 @@ namespace MWMechanics
|
|||
|
||||
if ((!actor.getPtr().getRefData().getBaseNode())
|
||||
|| (playerPos - actor.getPtr().getRefData().getPosition().asVec3()).length2()
|
||||
> mActorsProcessingRange * mActorsProcessingRange)
|
||||
> actorsProcessingRange * actorsProcessingRange)
|
||||
continue;
|
||||
|
||||
adjustMagicEffects(actor.getPtr(), duration);
|
||||
|
@ -1955,7 +1934,7 @@ namespace MWMechanics
|
|||
|
||||
std::vector<MWWorld::Ptr> observers;
|
||||
const osg::Vec3f position(player.getRefData().getPosition().asVec3());
|
||||
const float radius = std::min(fSneakUseDist, mActorsProcessingRange);
|
||||
const float radius = std::min<float>(fSneakUseDist, Settings::game().mActorsProcessingRange);
|
||||
getObjectsInRange(position, radius, observers);
|
||||
|
||||
std::set<MWWorld::Ptr> sidingActors;
|
||||
|
@ -2239,7 +2218,7 @@ namespace MWMechanics
|
|||
std::vector<MWWorld::Ptr> list;
|
||||
std::vector<MWWorld::Ptr> neighbors;
|
||||
const osg::Vec3f position(actor.getRefData().getPosition().asVec3());
|
||||
getObjectsInRange(position, mActorsProcessingRange, neighbors);
|
||||
getObjectsInRange(position, Settings::game().mActorsProcessingRange, neighbors);
|
||||
for (const MWWorld::Ptr& neighbor : neighbors)
|
||||
{
|
||||
if (neighbor == actor)
|
||||
|
@ -2260,7 +2239,7 @@ namespace MWMechanics
|
|||
std::vector<MWWorld::Ptr> list;
|
||||
std::vector<MWWorld::Ptr> neighbors;
|
||||
osg::Vec3f position(actor.getRefData().getPosition().asVec3());
|
||||
getObjectsInRange(position, mActorsProcessingRange, neighbors);
|
||||
getObjectsInRange(position, Settings::game().mActorsProcessingRange, neighbors);
|
||||
|
||||
std::set<MWWorld::Ptr> followers;
|
||||
getActorsFollowing(actor, followers);
|
||||
|
|
|
@ -40,8 +40,6 @@ namespace MWMechanics
|
|||
class Actors
|
||||
{
|
||||
public:
|
||||
Actors();
|
||||
|
||||
std::list<Actor>::const_iterator begin() const { return mActors.begin(); }
|
||||
std::list<Actor>::const_iterator end() const { return mActors.end(); }
|
||||
std::size_t size() const { return mActors.size(); }
|
||||
|
@ -56,9 +54,6 @@ namespace MWMechanics
|
|||
/// paused we may want to do it manually (after equipping permanent enchantment)
|
||||
void updateMagicEffects(const MWWorld::Ptr& ptr) const;
|
||||
|
||||
void updateProcessingRange();
|
||||
float getProcessingRange() const;
|
||||
|
||||
void addActor(const MWWorld::Ptr& ptr, bool updateImmediately = false);
|
||||
///< Register an actor for stats management
|
||||
///
|
||||
|
@ -180,14 +175,13 @@ namespace MWMechanics
|
|||
std::map<ESM::RefId, int> mDeathCount;
|
||||
std::list<Actor> mActors;
|
||||
std::map<const MWWorld::LiveCellRefBase*, std::list<Actor>::iterator> mIndex;
|
||||
float mTimerDisposeSummonsCorpses;
|
||||
// We should add a delay between summoned creature death and its corpse despawning
|
||||
float mTimerDisposeSummonsCorpses = 0.2f;
|
||||
float mTimerUpdateHeadTrack = 0;
|
||||
float mTimerUpdateEquippedLight = 0;
|
||||
float mTimerUpdateHello = 0;
|
||||
float mSneakTimer = 0; // Times update of sneak icon
|
||||
float mSneakSkillTimer = 0; // Times sneak skill progress from "avoid notice"
|
||||
float mActorsProcessingRange;
|
||||
bool mSmoothMovement;
|
||||
MusicType mCurrentMusic = MusicType::Title;
|
||||
|
||||
void updateVisibility(const MWWorld::Ptr& ptr, CharacterController& ctrl) const;
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#include <components/esm3/loadcell.hpp>
|
||||
#include <components/esm3/loadland.hpp>
|
||||
#include <components/misc/coordinateconverter.hpp>
|
||||
#include <components/settings/settings.hpp>
|
||||
#include <components/settings/values.hpp>
|
||||
|
||||
#include "../mwbase/environment.hpp"
|
||||
#include "../mwbase/world.hpp"
|
||||
|
@ -190,7 +190,7 @@ bool MWMechanics::AiPackage::pathTo(const MWWorld::Ptr& actor, const osg::Vec3f&
|
|||
const float pointTolerance
|
||||
= getPointTolerance(actor.getClass().getMaxSpeed(actor), duration, world->getHalfExtents(actor));
|
||||
|
||||
static const bool smoothMovement = Settings::Manager::getBool("smooth movement", "Game");
|
||||
const bool smoothMovement = Settings::game().mSmoothMovement;
|
||||
|
||||
PathFinder::UpdateFlags updateFlags{};
|
||||
|
||||
|
@ -469,15 +469,12 @@ bool MWMechanics::AiPackage::isReachableRotatingOnTheRun(const MWWorld::Ptr& act
|
|||
|
||||
DetourNavigator::Flags MWMechanics::AiPackage::getNavigatorFlags(const MWWorld::Ptr& actor) const
|
||||
{
|
||||
static const bool allowToFollowOverWaterSurface
|
||||
= Settings::Manager::getBool("allow actors to follow over water surface", "Game");
|
||||
|
||||
const MWWorld::Class& actorClass = actor.getClass();
|
||||
DetourNavigator::Flags result = DetourNavigator::Flag_none;
|
||||
|
||||
if ((actorClass.isPureWaterCreature(actor)
|
||||
|| (getTypeId() != AiPackageTypeId::Wander
|
||||
&& ((allowToFollowOverWaterSurface && getTypeId() == AiPackageTypeId::Follow)
|
||||
&& ((Settings::game().mAllowActorsToFollowOverWaterSurface && getTypeId() == AiPackageTypeId::Follow)
|
||||
|| actorClass.canSwim(actor) || hasWaterWalking(actor))))
|
||||
&& actorClass.getSwimSpeed(actor) > 0)
|
||||
result |= DetourNavigator::Flag_swim;
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
#include <components/misc/strings/algorithm.hpp>
|
||||
#include <components/misc/strings/conversion.hpp>
|
||||
|
||||
#include <components/settings/settings.hpp>
|
||||
#include <components/settings/values.hpp>
|
||||
|
||||
#include <components/sceneutil/positionattitudetransform.hpp>
|
||||
|
||||
|
@ -1509,9 +1509,7 @@ namespace MWMechanics
|
|||
}
|
||||
}
|
||||
|
||||
static const bool useCastingAnimations
|
||||
= Settings::Manager::getBool("use magic item animations", "Game");
|
||||
if (isMagicItem && !useCastingAnimations)
|
||||
if (isMagicItem && !Settings::game().mUseMagicItemAnimations)
|
||||
{
|
||||
world->breakInvisibility(mPtr);
|
||||
// Enchanted items by default do not use casting animations
|
||||
|
@ -1619,7 +1617,7 @@ namespace MWMechanics
|
|||
mAttackType = "shoot";
|
||||
else if (mPtr == getPlayer())
|
||||
{
|
||||
if (Settings::Manager::getBool("best attack", "Game"))
|
||||
if (Settings::game().mBestAttack)
|
||||
{
|
||||
if (!mWeapon.isEmpty() && mWeapon.getType() == ESM::Weapon::sRecordId)
|
||||
{
|
||||
|
@ -1864,8 +1862,7 @@ namespace MWMechanics
|
|||
|
||||
float scale = mPtr.getCellRef().getScale();
|
||||
|
||||
static const bool normalizeSpeed = Settings::Manager::getBool("normalise race speed", "Game");
|
||||
if (!normalizeSpeed && cls.isNpc())
|
||||
if (!Settings::game().mNormaliseRaceSpeed && cls.isNpc())
|
||||
{
|
||||
const ESM::NPC* npc = mPtr.get<ESM::NPC>()->mBase;
|
||||
const ESM::Race* race = world->getStore().get<ESM::Race>().find(npc->mRace);
|
||||
|
@ -1913,11 +1910,9 @@ namespace MWMechanics
|
|||
movementSettings.mSpeedFactor = std::min(vec.length(), 1.f);
|
||||
vec.normalize();
|
||||
|
||||
static const bool smoothMovement = Settings::Manager::getBool("smooth movement", "Game");
|
||||
const bool smoothMovement = Settings::game().mSmoothMovement;
|
||||
if (smoothMovement)
|
||||
{
|
||||
static const float playerTurningCoef = 1.0
|
||||
/ std::max(0.01f, Settings::Manager::getFloat("smooth movement player turning delay", "Game"));
|
||||
float angle = mPtr.getRefData().getPosition().rot[2];
|
||||
osg::Vec2f targetSpeed
|
||||
= Misc::rotateVec2f(osg::Vec2f(vec.x(), vec.y()), -angle) * movementSettings.mSpeedFactor;
|
||||
|
@ -1930,7 +1925,7 @@ namespace MWMechanics
|
|||
maxDelta = 1;
|
||||
else if (std::abs(speedDelta) < deltaLen / 2)
|
||||
// Turning is smooth for player and less smooth for NPCs (otherwise NPC can miss a path point).
|
||||
maxDelta = duration * (isPlayer ? playerTurningCoef : 6.f);
|
||||
maxDelta = duration * (isPlayer ? 1.0 / Settings::game().mSmoothMovementPlayerTurningDelay : 6.f);
|
||||
else if (isPlayer && speedDelta < -deltaLen / 2)
|
||||
// As soon as controls are released, mwinput switches player from running to walking.
|
||||
// So stopping should be instant for player, otherwise it causes a small twitch.
|
||||
|
@ -1964,8 +1959,7 @@ namespace MWMechanics
|
|||
|
||||
float effectiveRotation = rot.z();
|
||||
bool canMove = cls.getMaxSpeed(mPtr) > 0;
|
||||
static const bool turnToMovementDirection
|
||||
= Settings::Manager::getBool("turn to movement direction", "Game");
|
||||
const bool turnToMovementDirection = Settings::game().mTurnToMovementDirection;
|
||||
if (!turnToMovementDirection || isFirstPersonPlayer)
|
||||
{
|
||||
movementSettings.mIsStrafing = std::abs(vec.x()) > std::abs(vec.y()) * 2;
|
||||
|
@ -2230,13 +2224,11 @@ namespace MWMechanics
|
|||
else
|
||||
mAnimation->setBodyPitchRadians(0);
|
||||
|
||||
static const bool swimUpwardCorrection = Settings::Manager::getBool("swim upward correction", "Game");
|
||||
if (inwater && isPlayer && !isFirstPersonPlayer && swimUpwardCorrection)
|
||||
if (inwater && isPlayer && !isFirstPersonPlayer && Settings::game().mSwimUpwardCorrection)
|
||||
{
|
||||
static const float swimUpwardCoef = Settings::Manager::getFloat("swim upward coef", "Game");
|
||||
static const float swimForwardCoef = sqrtf(1.0f - swimUpwardCoef * swimUpwardCoef);
|
||||
const float swimUpwardCoef = Settings::game().mSwimUpwardCoef;
|
||||
vec.z() = std::abs(vec.y()) * swimUpwardCoef;
|
||||
vec.y() *= swimForwardCoef;
|
||||
vec.y() *= std::sqrt(1.0f - swimUpwardCoef * swimUpwardCoef);
|
||||
}
|
||||
|
||||
// Player can not use smooth turning as NPCs, so we play turning animation a bit to avoid jittering
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#include "combat.hpp"
|
||||
|
||||
#include <components/misc/rng.hpp>
|
||||
#include <components/settings/settings.hpp>
|
||||
#include <components/settings/values.hpp>
|
||||
|
||||
#include <components/sceneutil/positionattitudetransform.hpp>
|
||||
|
||||
|
@ -174,8 +174,7 @@ namespace MWMechanics
|
|||
bool isMagical = flags & ESM::Weapon::Magical;
|
||||
bool isEnchanted = !weapon.getClass().getEnchantment(weapon).empty();
|
||||
|
||||
return !isSilver && !isMagical
|
||||
&& (!isEnchanted || !Settings::Manager::getBool("enchanted weapons are magical", "Game"));
|
||||
return !isSilver && !isMagical && (!isEnchanted || !Settings::game().mEnchantedWeaponsAreMagical);
|
||||
}
|
||||
|
||||
void resistNormalWeapon(
|
||||
|
@ -251,8 +250,7 @@ namespace MWMechanics
|
|||
|
||||
if (validVictim)
|
||||
{
|
||||
if (weapon == projectile
|
||||
|| Settings::Manager::getBool("only appropriate ammunition bypasses resistance", "Game")
|
||||
if (weapon == projectile || Settings::game().mOnlyAppropriateAmmunitionBypassesResistance
|
||||
|| isNormalWeapon(weapon))
|
||||
resistNormalWeapon(victim, attacker, projectile, damage);
|
||||
applyWerewolfDamageMult(victim, projectile, damage);
|
||||
|
@ -469,7 +467,7 @@ namespace MWMechanics
|
|||
// 0 = Do not factor strength into hand-to-hand combat.
|
||||
// 1 = Factor into werewolf hand-to-hand combat.
|
||||
// 2 = Ignore werewolves.
|
||||
int factorStrength = Settings::Manager::getInt("strength influences hand to hand", "Game");
|
||||
const int factorStrength = Settings::game().mStrengthInfluencesHandToHand;
|
||||
if (factorStrength == 1 || (factorStrength == 2 && !isWerewolf))
|
||||
{
|
||||
damage
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "difficultyscaling.hpp"
|
||||
|
||||
#include <components/settings/settings.hpp>
|
||||
#include <components/settings/values.hpp>
|
||||
|
||||
#include "../mwbase/environment.hpp"
|
||||
#include "../mwbase/world.hpp"
|
||||
|
@ -12,13 +12,10 @@ float scaleDamage(float damage, const MWWorld::Ptr& attacker, const MWWorld::Ptr
|
|||
{
|
||||
const MWWorld::Ptr& player = MWMechanics::getPlayer();
|
||||
|
||||
// [-500, 500]
|
||||
const int difficultySetting = std::clamp(Settings::Manager::getInt("difficulty", "Game"), -500, 500);
|
||||
|
||||
static const float fDifficultyMult
|
||||
= MWBase::Environment::get().getESMStore()->get<ESM::GameSetting>().find("fDifficultyMult")->mValue.getFloat();
|
||||
|
||||
float difficultyTerm = 0.01f * difficultySetting;
|
||||
const float difficultyTerm = 0.01f * Settings::game().mDifficulty;
|
||||
|
||||
float x = 0;
|
||||
if (victim == player)
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#include <components/esm3/loadcrea.hpp>
|
||||
#include <components/esm3/loadmgef.hpp>
|
||||
#include <components/misc/rng.hpp>
|
||||
#include <components/settings/settings.hpp>
|
||||
#include <components/settings/values.hpp>
|
||||
|
||||
#include "../mwworld/class.hpp"
|
||||
#include "../mwworld/containerstore.hpp"
|
||||
|
@ -368,11 +368,10 @@ namespace MWMechanics
|
|||
ESM::WeaponType::Class weapclass = MWMechanics::getWeaponType(mWeaponType)->mWeaponClass;
|
||||
if (weapclass == ESM::WeaponType::Thrown || weapclass == ESM::WeaponType::Ammo)
|
||||
{
|
||||
static const float multiplier
|
||||
= std::clamp(Settings::Manager::getFloat("projectiles enchant multiplier", "Game"), 0.f, 1.f);
|
||||
MWWorld::Ptr player = getPlayer();
|
||||
count = player.getClass().getContainerStore(player).count(mOldItemPtr.getCellRef().getRefId());
|
||||
count = std::clamp<int>(getGemCharge() * multiplier / enchantPoints, 1, count);
|
||||
count = std::clamp<int>(
|
||||
getGemCharge() * Settings::game().mProjectilesEnchantMultiplier / enchantPoints, 1, count);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -381,8 +380,7 @@ namespace MWMechanics
|
|||
|
||||
float Enchanting::getTypeMultiplier() const
|
||||
{
|
||||
static const bool useMultiplier = Settings::Manager::getFloat("projectiles enchant multiplier", "Game") > 0;
|
||||
if (useMultiplier && mWeaponType != -1 && getEnchantPoints() > 0)
|
||||
if (Settings::game().mProjectilesEnchantMultiplier > 0 && mWeaponType != -1 && getEnchantPoints() > 0)
|
||||
{
|
||||
ESM::WeaponType::Class weapclass = MWMechanics::getWeaponType(mWeaponType)->mWeaponClass;
|
||||
if (weapclass == ESM::WeaponType::Thrown || weapclass == ESM::WeaponType::Ammo)
|
||||
|
|
|
@ -350,8 +350,6 @@ namespace MWMechanics
|
|||
if (state != MWBase::StateManager::State_Running)
|
||||
continue;
|
||||
|
||||
mActors.updateProcessingRange();
|
||||
|
||||
// Update mechanics for new processing range immediately
|
||||
update(0.f, false);
|
||||
}
|
||||
|
@ -363,11 +361,6 @@ namespace MWMechanics
|
|||
mActors.notifyDied(actor);
|
||||
}
|
||||
|
||||
float MechanicsManager::getActorsProcessingRange() const
|
||||
{
|
||||
return mActors.getProcessingRange();
|
||||
}
|
||||
|
||||
bool MechanicsManager::isActorDetected(const MWWorld::Ptr& actor, const MWWorld::Ptr& observer)
|
||||
{
|
||||
return mActors.isActorDetected(actor, observer);
|
||||
|
|
|
@ -193,8 +193,6 @@ namespace MWMechanics
|
|||
|
||||
void processChangedSettings(const Settings::CategorySettingVector& settings) override;
|
||||
|
||||
float getActorsProcessingRange() const override;
|
||||
|
||||
void notifyDied(const MWWorld::Ptr& actor) override;
|
||||
|
||||
/// Check if the target actor was detected by an observer
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#include <components/esm3/loadstat.hpp>
|
||||
#include <components/misc/resourcehelpers.hpp>
|
||||
#include <components/misc/rng.hpp>
|
||||
#include <components/settings/settings.hpp>
|
||||
#include <components/settings/values.hpp>
|
||||
|
||||
#include "../mwbase/environment.hpp"
|
||||
#include "../mwbase/mechanicsmanager.hpp"
|
||||
|
@ -649,9 +649,8 @@ namespace MWMechanics
|
|||
modDynamicStat(target, index, -effect.mMagnitude);
|
||||
else
|
||||
{
|
||||
static const bool uncappedDamageFatigue
|
||||
= Settings::Manager::getBool("uncapped damage fatigue", "Game");
|
||||
adjustDynamicStat(target, index, -effect.mMagnitude, index == 2 && uncappedDamageFatigue);
|
||||
adjustDynamicStat(
|
||||
target, index, -effect.mMagnitude, index == 2 && Settings::game().mUncappedDamageFatigue);
|
||||
if (index == 0)
|
||||
receivedMagicDamage = affectedHealth = true;
|
||||
}
|
||||
|
@ -716,10 +715,9 @@ namespace MWMechanics
|
|||
case ESM::MagicEffect::DrainFatigue:
|
||||
if (!godmode)
|
||||
{
|
||||
static const bool uncappedDamageFatigue
|
||||
= Settings::Manager::getBool("uncapped damage fatigue", "Game");
|
||||
int index = effect.mEffectId - ESM::MagicEffect::DrainHealth;
|
||||
adjustDynamicStat(target, index, -effect.mMagnitude, uncappedDamageFatigue && index == 2);
|
||||
adjustDynamicStat(
|
||||
target, index, -effect.mMagnitude, Settings::game().mUncappedDamageFatigue && index == 2);
|
||||
if (index == 0)
|
||||
receivedMagicDamage = affectedHealth = true;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include "steering.hpp"
|
||||
|
||||
#include <components/misc/mathutil.hpp>
|
||||
#include <components/settings/settings.hpp>
|
||||
#include <components/settings/values.hpp>
|
||||
|
||||
#include "../mwworld/class.hpp"
|
||||
#include "../mwworld/ptr.hpp"
|
||||
|
@ -26,8 +26,7 @@ namespace MWMechanics
|
|||
|
||||
float limit
|
||||
= getAngularVelocity(actor.getClass().getMaxSpeed(actor)) * MWBase::Environment::get().getFrameDuration();
|
||||
static const bool smoothMovement = Settings::Manager::getBool("smooth movement", "Game");
|
||||
if (smoothMovement)
|
||||
if (Settings::game().mSmoothMovement)
|
||||
limit *= std::min(absDiff / osg::PI + 0.1, 0.5);
|
||||
|
||||
if (absDiff > limit)
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
#include <components/misc/strings/conversion.hpp>
|
||||
#include <components/resource/bulletshapemanager.hpp>
|
||||
#include <components/resource/resourcesystem.hpp>
|
||||
#include <components/settings/settings.hpp>
|
||||
#include <components/settings/values.hpp>
|
||||
|
||||
#include "../mwbase/environment.hpp"
|
||||
#include "../mwbase/world.hpp"
|
||||
|
@ -104,8 +104,6 @@ namespace MWPhysics
|
|||
, mWaterEnabled(false)
|
||||
, mParentNode(parentNode)
|
||||
, mPhysicsDt(1.f / 60.f)
|
||||
, mActorCollisionShapeType(
|
||||
DetourNavigator::toCollisionShapeType(Settings::Manager::getInt("actor collision shape type", "Game")))
|
||||
{
|
||||
mResourceSystem->addResourceManager(mShapeManager.get());
|
||||
|
||||
|
@ -668,7 +666,8 @@ namespace MWPhysics
|
|||
const MWMechanics::MagicEffects& effects = ptr.getClass().getCreatureStats(ptr).getMagicEffects();
|
||||
const bool canWaterWalk = effects.getOrDefault(ESM::MagicEffect::WaterWalking).getMagnitude() > 0;
|
||||
|
||||
auto actor = std::make_shared<Actor>(ptr, shape, mTaskScheduler.get(), canWaterWalk, mActorCollisionShapeType);
|
||||
auto actor = std::make_shared<Actor>(
|
||||
ptr, shape, mTaskScheduler.get(), canWaterWalk, Settings::game().mActorCollisionShapeType);
|
||||
|
||||
mActors.emplace(ptr.mRef, std::move(actor));
|
||||
}
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
#include <osg/Timer>
|
||||
#include <osg/ref_ptr>
|
||||
|
||||
#include <components/detournavigator/collisionshapetype.hpp>
|
||||
#include <components/esm/util.hpp>
|
||||
|
||||
#include "../mwworld/ptr.hpp"
|
||||
|
@ -342,8 +341,6 @@ namespace MWPhysics
|
|||
|
||||
float mPhysicsDt;
|
||||
|
||||
DetourNavigator::CollisionShapeType mActorCollisionShapeType;
|
||||
|
||||
std::size_t mSimulationsCounter = 0;
|
||||
std::array<std::vector<Simulation>, 2> mSimulations;
|
||||
std::vector<std::pair<MWWorld::Ptr, osg::Vec3f>> mActorsPositions;
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
#include <components/misc/resourcehelpers.hpp>
|
||||
|
||||
#include <components/settings/settings.hpp>
|
||||
#include <components/settings/values.hpp>
|
||||
|
||||
#include <components/vfs/manager.hpp>
|
||||
|
||||
|
@ -163,8 +163,7 @@ namespace MWRender
|
|||
|
||||
bool ActorAnimation::updateCarriedLeftVisible(const int weaptype) const
|
||||
{
|
||||
static const bool shieldSheathing = Settings::Manager::getBool("shield sheathing", "Game");
|
||||
if (shieldSheathing)
|
||||
if (Settings::game().mShieldSheathing)
|
||||
{
|
||||
const MWWorld::Class& cls = mPtr.getClass();
|
||||
MWMechanics::CreatureStats& stats = cls.getCreatureStats(mPtr);
|
||||
|
@ -189,8 +188,7 @@ namespace MWRender
|
|||
|
||||
void ActorAnimation::updateHolsteredShield(bool showCarriedLeft)
|
||||
{
|
||||
static const bool shieldSheathing = Settings::Manager::getBool("shield sheathing", "Game");
|
||||
if (!shieldSheathing)
|
||||
if (!Settings::game().mShieldSheathing)
|
||||
return;
|
||||
|
||||
if (!mPtr.getClass().hasInventoryStore(mPtr))
|
||||
|
@ -256,8 +254,7 @@ namespace MWRender
|
|||
|
||||
bool ActorAnimation::useShieldAnimations() const
|
||||
{
|
||||
static const bool shieldSheathing = Settings::Manager::getBool("shield sheathing", "Game");
|
||||
if (!shieldSheathing)
|
||||
if (!Settings::game().mShieldSheathing)
|
||||
return false;
|
||||
|
||||
const MWWorld::Class& cls = mPtr.getClass();
|
||||
|
@ -325,8 +322,7 @@ namespace MWRender
|
|||
|
||||
void ActorAnimation::updateHolsteredWeapon(bool showHolsteredWeapons)
|
||||
{
|
||||
static const bool weaponSheathing = Settings::Manager::getBool("weapon sheathing", "Game");
|
||||
if (!weaponSheathing)
|
||||
if (!Settings::game().mWeaponSheathing)
|
||||
return;
|
||||
|
||||
if (!mPtr.getClass().hasInventoryStore(mPtr))
|
||||
|
@ -405,8 +401,7 @@ namespace MWRender
|
|||
|
||||
void ActorAnimation::updateQuiver()
|
||||
{
|
||||
static const bool weaponSheathing = Settings::Manager::getBool("weapon sheathing", "Game");
|
||||
if (!weaponSheathing)
|
||||
if (!Settings::game().mWeaponSheathing)
|
||||
return;
|
||||
|
||||
if (!mPtr.getClass().hasInventoryStore(mPtr))
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
#include <components/sceneutil/util.hpp>
|
||||
#include <components/sceneutil/visitor.hpp>
|
||||
|
||||
#include <components/settings/settings.hpp>
|
||||
#include <components/settings/values.hpp>
|
||||
|
||||
#include "../mwbase/environment.hpp"
|
||||
#include "../mwbase/world.hpp"
|
||||
|
@ -616,8 +616,7 @@ namespace MWRender
|
|||
|
||||
addSingleAnimSource(kfname, baseModel);
|
||||
|
||||
static const bool useAdditionalSources = Settings::Manager::getBool("use additional anim sources", "Game");
|
||||
if (useAdditionalSources)
|
||||
if (Settings::game().mUseAdditionalAnimSources)
|
||||
loadAllAnimationsInFolder(kfname, baseModel);
|
||||
}
|
||||
|
||||
|
@ -1388,11 +1387,10 @@ namespace MWRender
|
|||
mAccumRoot = nullptr;
|
||||
mAccumCtrl = nullptr;
|
||||
|
||||
static const bool useAdditionalSources = Settings::Manager::getBool("use additional anim sources", "Game");
|
||||
std::string defaultSkeleton;
|
||||
bool inject = false;
|
||||
|
||||
if (useAdditionalSources && mPtr.getClass().isActor())
|
||||
if (Settings::game().mUseAdditionalAnimSources && mPtr.getClass().isActor())
|
||||
{
|
||||
if (isCreature)
|
||||
{
|
||||
|
@ -1867,8 +1865,7 @@ namespace MWRender
|
|||
visitor.remove();
|
||||
}
|
||||
|
||||
if (Settings::Manager::getBool("day night switches", "Game")
|
||||
&& SceneUtil::hasUserDescription(mObjectRoot, Constants::NightDayLabel))
|
||||
if (Settings::game().mDayNightSwitches && SceneUtil::hasUserDescription(mObjectRoot, Constants::NightDayLabel))
|
||||
{
|
||||
AddSwitchCallbacksVisitor visitor;
|
||||
mObjectRoot->accept(visitor);
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
#include <components/sceneutil/keyframe.hpp>
|
||||
#include <components/sceneutil/lightcommon.hpp>
|
||||
#include <components/sceneutil/visitor.hpp>
|
||||
#include <components/settings/settings.hpp>
|
||||
#include <components/settings/values.hpp>
|
||||
|
||||
#include <components/vfs/manager.hpp>
|
||||
|
||||
|
@ -297,8 +297,7 @@ namespace MWRender
|
|||
rebuild();
|
||||
setRenderBin();
|
||||
|
||||
static const bool shieldSheathing = Settings::Manager::getBool("shield sheathing", "Game");
|
||||
if (viewChange && shieldSheathing)
|
||||
if (viewChange && Settings::game().mShieldSheathing)
|
||||
{
|
||||
int weaptype = ESM::Weapon::None;
|
||||
MWMechanics::getActiveWeapon(mPtr, &weaptype);
|
||||
|
@ -988,8 +987,7 @@ namespace MWRender
|
|||
|
||||
bool NpcAnimation::updateCarriedLeftVisible(const int weaptype) const
|
||||
{
|
||||
static const bool shieldSheathing = Settings::Manager::getBool("shield sheathing", "Game");
|
||||
if (shieldSheathing)
|
||||
if (Settings::game().mShieldSheathing)
|
||||
{
|
||||
const MWWorld::Class& cls = mPtr.getClass();
|
||||
MWMechanics::CreatureStats& stats = cls.getCreatureStats(mPtr);
|
||||
|
@ -1125,8 +1123,7 @@ namespace MWRender
|
|||
|
||||
void NpcAnimation::equipmentChanged()
|
||||
{
|
||||
static const bool shieldSheathing = Settings::Manager::getBool("shield sheathing", "Game");
|
||||
if (shieldSheathing)
|
||||
if (Settings::game().mShieldSheathing)
|
||||
{
|
||||
int weaptype = ESM::Weapon::None;
|
||||
MWMechanics::getActiveWeapon(mPtr, &weaptype);
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
#include <components/sceneutil/nodecallback.hpp>
|
||||
#include <components/sceneutil/visitor.hpp>
|
||||
|
||||
#include <components/settings/settings.hpp>
|
||||
#include <components/settings/values.hpp>
|
||||
|
||||
#include "../mwworld/class.hpp"
|
||||
#include "../mwworld/esmstore.hpp"
|
||||
|
@ -431,7 +431,7 @@ namespace MWWorld
|
|||
|
||||
void ProjectileManager::moveMagicBolts(float duration)
|
||||
{
|
||||
static const bool normaliseRaceSpeed = Settings::Manager::getBool("normalise race speed", "Game");
|
||||
const bool normaliseRaceSpeed = Settings::game().mNormaliseRaceSpeed;
|
||||
for (auto& magicBoltState : mMagicBolts)
|
||||
{
|
||||
if (magicBoltState.mToDelete)
|
||||
|
|
|
@ -53,6 +53,8 @@
|
|||
#include <components/files/conversion.hpp>
|
||||
#include <components/loadinglistener/loadinglistener.hpp>
|
||||
|
||||
#include <components/settings/values.hpp>
|
||||
|
||||
#include "../mwbase/environment.hpp"
|
||||
#include "../mwbase/luamanager.hpp"
|
||||
#include "../mwbase/mechanicsmanager.hpp"
|
||||
|
@ -256,9 +258,6 @@ namespace MWWorld
|
|||
, mDiscardMovements(true)
|
||||
, mContentFiles(contentFiles)
|
||||
, mUserDataPath(userDataPath)
|
||||
, mDefaultHalfExtents(Settings::Manager::getVector3("default actor pathfind half extents", "Game"))
|
||||
, mDefaultActorCollisionShapeType(
|
||||
DetourNavigator::toCollisionShapeType(Settings::Manager::getInt("actor collision shape type", "Game")))
|
||||
, mActivationDistanceOverride(activationDistanceOverride)
|
||||
, mStartCell(startCell)
|
||||
, mDistanceToFacedObject(-1.f)
|
||||
|
@ -3808,7 +3807,8 @@ namespace MWWorld
|
|||
{
|
||||
const MWPhysics::Actor* physicsActor = mPhysics->getActor(actor);
|
||||
if (physicsActor == nullptr || !actor.isInCell() || actor.getCell()->isExterior())
|
||||
return DetourNavigator::AgentBounds{ mDefaultActorCollisionShapeType, mDefaultHalfExtents };
|
||||
return DetourNavigator::AgentBounds{ Settings::game().mActorCollisionShapeType,
|
||||
Settings::game().mDefaultActorPathfindHalfExtents };
|
||||
else
|
||||
return DetourNavigator::AgentBounds{ physicsActor->getCollisionShapeType(),
|
||||
physicsActor->getHalfExtents() };
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
#include <osg/Timer>
|
||||
#include <osg/ref_ptr>
|
||||
|
||||
#include <components/detournavigator/collisionshapetype.hpp>
|
||||
#include <components/esm3/readerscache.hpp>
|
||||
#include <components/misc/rng.hpp>
|
||||
#include <components/settings/settings.hpp>
|
||||
|
@ -114,9 +113,6 @@ namespace MWWorld
|
|||
|
||||
std::filesystem::path mUserDataPath;
|
||||
|
||||
osg::Vec3f mDefaultHalfExtents;
|
||||
DetourNavigator::CollisionShapeType mDefaultActorCollisionShapeType;
|
||||
|
||||
int mActivationDistanceOverride;
|
||||
|
||||
std::string mStartCell;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#ifndef OPENMW_COMPONENTS_SETTINGS_CATEGORIES_GAME_H
|
||||
#define OPENMW_COMPONENTS_SETTINGS_CATEGORIES_GAME_H
|
||||
|
||||
#include "components/detournavigator/collisionshapetype.hpp"
|
||||
#include "components/settings/sanitizerimpl.hpp"
|
||||
#include "components/settings/settingvalue.hpp"
|
||||
|
||||
|
@ -24,6 +25,8 @@ namespace Settings
|
|||
SettingValue<bool> mShowEnchantChance{ mIndex, "Game", "show enchant chance" };
|
||||
SettingValue<bool> mBestAttack{ mIndex, "Game", "best attack" };
|
||||
SettingValue<int> mDifficulty{ mIndex, "Game", "difficulty", makeClampSanitizerInt(-500, 500) };
|
||||
// We have to cap it since using high values (larger than 7168) will make some quests harder or impossible to
|
||||
// complete (bug #1876)
|
||||
SettingValue<int> mActorsProcessingRange{ mIndex, "Game", "actors processing range",
|
||||
makeClampSanitizerInt(3584, 7168) };
|
||||
SettingValue<bool> mClassicReflectedAbsorbSpellsBehavior{ mIndex, "Game",
|
||||
|
@ -69,8 +72,8 @@ namespace Settings
|
|||
SettingValue<bool> mDayNightSwitches{ mIndex, "Game", "day night switches" };
|
||||
SettingValue<bool> mUnarmedCreatureAttacksDamageArmor{ mIndex, "Game",
|
||||
"unarmed creature attacks damage armor" };
|
||||
SettingValue<int> mActorCollisionShapeType{ mIndex, "Game", "actor collision shape type",
|
||||
makeEnumSanitizerInt({ 0, 1, 2 }) };
|
||||
SettingValue<DetourNavigator::CollisionShapeType> mActorCollisionShapeType{ mIndex, "Game",
|
||||
"actor collision shape type" };
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -444,6 +444,11 @@ namespace Settings
|
|||
setVector3(setting, category, value);
|
||||
}
|
||||
|
||||
void Manager::set(std::string_view setting, std::string_view category, DetourNavigator::CollisionShapeType value)
|
||||
{
|
||||
setInt(setting, category, static_cast<int>(value));
|
||||
}
|
||||
|
||||
void Manager::recordInit(std::string_view setting, std::string_view category)
|
||||
{
|
||||
sInitialized.emplace(category, setting);
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
|
||||
#include "categories.hpp"
|
||||
|
||||
#include "components/detournavigator/collisionshapetype.hpp"
|
||||
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
@ -101,6 +103,7 @@ namespace Settings
|
|||
static void set(std::string_view setting, std::string_view category, bool value);
|
||||
static void set(std::string_view setting, std::string_view category, const osg::Vec2f& value);
|
||||
static void set(std::string_view setting, std::string_view category, const osg::Vec3f& value);
|
||||
static void set(std::string_view setting, std::string_view category, DetourNavigator::CollisionShapeType value);
|
||||
|
||||
private:
|
||||
static std::set<std::pair<std::string_view, std::string_view>> sInitialized;
|
||||
|
@ -170,6 +173,13 @@ namespace Settings
|
|||
{
|
||||
return getVector3(setting, category);
|
||||
}
|
||||
|
||||
template <>
|
||||
inline DetourNavigator::CollisionShapeType Manager::getImpl<DetourNavigator::CollisionShapeType>(
|
||||
std::string_view setting, std::string_view category)
|
||||
{
|
||||
return DetourNavigator::toCollisionShapeType(getInt(setting, category));
|
||||
}
|
||||
}
|
||||
|
||||
#endif // COMPONENTS_SETTINGS_H
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include "settings.hpp"
|
||||
|
||||
#include "components/debug/debuglog.hpp"
|
||||
#include "components/detournavigator/collisionshapetype.hpp"
|
||||
|
||||
#include <osg/io_utils>
|
||||
|
||||
|
@ -31,10 +32,11 @@ namespace Settings
|
|||
String,
|
||||
Vec2f,
|
||||
Vec3f,
|
||||
CollisionShapeType,
|
||||
};
|
||||
|
||||
template <class T>
|
||||
constexpr SettingValueType getSettingValueType();
|
||||
constexpr SettingValueType getSettingValueType() = delete;
|
||||
|
||||
template <>
|
||||
inline constexpr SettingValueType getSettingValueType<bool>()
|
||||
|
@ -108,6 +110,12 @@ namespace Settings
|
|||
return SettingValueType::Vec3f;
|
||||
}
|
||||
|
||||
template <>
|
||||
inline constexpr SettingValueType getSettingValueType<DetourNavigator::CollisionShapeType>()
|
||||
{
|
||||
return SettingValueType::CollisionShapeType;
|
||||
}
|
||||
|
||||
inline constexpr std::string_view getSettingValueTypeName(SettingValueType type)
|
||||
{
|
||||
switch (type)
|
||||
|
@ -136,6 +144,8 @@ namespace Settings
|
|||
return "vec2f";
|
||||
case SettingValueType::Vec3f:
|
||||
return "vec3f";
|
||||
case SettingValueType::CollisionShapeType:
|
||||
return "collision shape type";
|
||||
}
|
||||
return "unsupported";
|
||||
}
|
||||
|
@ -274,6 +284,19 @@ namespace Settings
|
|||
T mDefaultValue{};
|
||||
T mValue{};
|
||||
|
||||
struct WriteValue
|
||||
{
|
||||
const T& mValue;
|
||||
|
||||
friend std::ostream& operator<<(std::ostream& stream, const WriteValue& value)
|
||||
{
|
||||
if constexpr (std::is_enum_v<T>)
|
||||
return stream << static_cast<std::underlying_type_t<T>>(value.mValue);
|
||||
else
|
||||
return stream << value.mValue;
|
||||
}
|
||||
};
|
||||
|
||||
T sanitize(const T& value) const
|
||||
{
|
||||
if (mSanitizer == nullptr)
|
||||
|
@ -283,8 +306,8 @@ namespace Settings
|
|||
T sanitizedValue = mSanitizer->apply(value);
|
||||
if (sanitizedValue != value)
|
||||
Log(Debug::Warning) << getSettingDescription<T>(mCategory, mName)
|
||||
<< " value is out of allowed values set: " << value << ", sanitized to "
|
||||
<< sanitizedValue;
|
||||
<< " value is out of allowed values set: " << WriteValue{ value }
|
||||
<< ", sanitized to " << WriteValue{ sanitizedValue };
|
||||
return sanitizedValue;
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
|
|
Loading…
Reference in a new issue