1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-04-03 03:06:40 +00:00

Make Settings::Manager::getString return a reference

This commit is contained in:
Evil Eye 2022-08-28 16:38:11 +02:00
parent dfcd34372d
commit 2222b47e3d
14 changed files with 24 additions and 24 deletions

View file

@ -164,7 +164,7 @@ bool Launcher::AdvancedPage::loadSettings()
// Audio
{
std::string selectedAudioDevice = Settings::Manager::getString("device", "Sound");
const std::string& selectedAudioDevice = Settings::Manager::getString("device", "Sound");
if (selectedAudioDevice.empty() == false)
{
int audioDeviceIndex = audioDeviceSelectorComboBox->findData(QString::fromStdString(selectedAudioDevice));
@ -178,7 +178,7 @@ bool Launcher::AdvancedPage::loadSettings()
{
enableHRTFComboBox->setCurrentIndex(hrtfEnabledIndex + 1);
}
std::string selectedHRTFProfile = Settings::Manager::getString("hrtf", "Sound");
const std::string& selectedHRTFProfile = Settings::Manager::getString("hrtf", "Sound");
if (selectedHRTFProfile.empty() == false)
{
int hrtfProfileIndex = hrtfProfileSelectorComboBox->findData(QString::fromStdString(selectedHRTFProfile));
@ -324,7 +324,7 @@ void Launcher::AdvancedPage::saveSettings()
// Audio
{
int audioDeviceIndex = audioDeviceSelectorComboBox->currentIndex();
std::string prevAudioDevice = Settings::Manager::getString("device", "Sound");
const std::string& prevAudioDevice = Settings::Manager::getString("device", "Sound");
if (audioDeviceIndex != 0)
{
const std::string& newAudioDevice = audioDeviceSelectorComboBox->currentText().toUtf8().constData();
@ -341,7 +341,7 @@ void Launcher::AdvancedPage::saveSettings()
Settings::Manager::setInt("hrtf enable", "Sound", hrtfEnabledIndex);
}
int selectedHRTFProfileIndex = hrtfProfileSelectorComboBox->currentIndex();
std::string prevHRTFProfile = Settings::Manager::getString("hrtf", "Sound");
const std::string& prevHRTFProfile = Settings::Manager::getString("hrtf", "Sound");
if (selectedHRTFProfileIndex != 0)
{
const std::string& newHRTFProfile = hrtfProfileSelectorComboBox->currentText().toUtf8().constData();

View file

@ -49,7 +49,7 @@ namespace CSMPrefs
{
if (mButton)
{
std::string shortcut = Settings::Manager::getString(getKey(), getParent()->getKey());
const std::string& shortcut = Settings::Manager::getString(getKey(), getParent()->getKey());
int modifier;
State::get().getShortcutManager().convertFromString(shortcut, modifier);

View file

@ -55,7 +55,7 @@ namespace CSMPrefs
{
if (mButton)
{
std::string shortcut = Settings::Manager::getString(getKey(), getParent()->getKey());
const std::string& shortcut = Settings::Manager::getString(getKey(), getParent()->getKey());
QKeySequence sequence;
State::get().getShortcutManager().convertFromString(shortcut, sequence);

View file

@ -745,8 +745,8 @@ namespace MWGui
if (!Settings::Manager::getBool("color topic enable", "GUI"))
return;
std::string specialColour = Settings::Manager::getString("color topic specific", "GUI");
std::string oldColour = Settings::Manager::getString("color topic exhausted", "GUI");
const std::string& specialColour = Settings::Manager::getString("color topic specific", "GUI");
const std::string& oldColour = Settings::Manager::getString("color topic exhausted", "GUI");
for (const std::string& keyword : mKeywords)
{

View file

@ -338,7 +338,7 @@ namespace MWGui
}
highlightCurrentResolution();
std::string tmip = Settings::Manager::getString("texture mipmap", "General");
const std::string& tmip = Settings::Manager::getString("texture mipmap", "General");
mTextureFilteringButton->setCaptionWithReplacing(textureMipmappingToStr(tmip));
int waterTextureSize = Settings::Manager::getInt("rtt size", "Water");

View file

@ -514,7 +514,7 @@ void NpcAnimation::updateNpcBase()
if(!is1stPerson)
{
const std::string base = Settings::Manager::getString("xbaseanim", "Models");
const std::string& base = Settings::Manager::getString("xbaseanim", "Models");
if (smodel != base && !isWerewolf)
addAnimSource(base, smodel);
@ -528,7 +528,7 @@ void NpcAnimation::updateNpcBase()
}
else
{
const std::string base = Settings::Manager::getString("xbaseanim1st", "Models");
const std::string& base = Settings::Manager::getString("xbaseanim1st", "Models");
if (smodel != base && !isWerewolf)
addAnimSource(base, smodel);

View file

@ -493,9 +493,9 @@ namespace MWRender
mEffectManager = std::make_unique<EffectManager>(sceneRoot, mResourceSystem);
const std::string normalMapPattern = Settings::Manager::getString("normal map pattern", "Shaders");
const std::string heightMapPattern = Settings::Manager::getString("normal height map pattern", "Shaders");
const std::string specularMapPattern = Settings::Manager::getString("terrain specular map pattern", "Shaders");
const std::string& normalMapPattern = Settings::Manager::getString("normal map pattern", "Shaders");
const std::string& heightMapPattern = Settings::Manager::getString("normal height map pattern", "Shaders");
const std::string& specularMapPattern = Settings::Manager::getString("terrain specular map pattern", "Shaders");
const bool useTerrainNormalMaps = Settings::Manager::getBool("auto use terrain normal maps", "Shaders");
const bool useTerrainSpecularMaps = Settings::Manager::getBool("auto use terrain specular maps", "Shaders");

View file

@ -96,12 +96,12 @@ namespace MWSound
return;
}
std::string hrtfname = Settings::Manager::getString("hrtf", "Sound");
const std::string& hrtfname = Settings::Manager::getString("hrtf", "Sound");
int hrtfstate = Settings::Manager::getInt("hrtf enable", "Sound");
HrtfMode hrtfmode = hrtfstate < 0 ? HrtfMode::Auto :
hrtfstate > 0 ? HrtfMode::Enable : HrtfMode::Disable;
std::string devname = Settings::Manager::getString("device", "Sound");
const std::string& devname = Settings::Manager::getString("device", "Sound");
if(!mOutput->init(devname, hrtfname, hrtfmode))
{
Log(Debug::Error) << "Failed to initialize audio output, sound disabled";

View file

@ -4,7 +4,7 @@
namespace SceneUtil
{
std::string getActorSkeleton(bool firstPerson, bool isFemale, bool isBeast, bool isWerewolf)
const std::string& getActorSkeleton(bool firstPerson, bool isFemale, bool isBeast, bool isWerewolf)
{
if (!firstPerson)
{

View file

@ -5,7 +5,7 @@
namespace SceneUtil
{
std::string getActorSkeleton(bool firstPerson, bool female, bool beast, bool werewolf);
const std::string& getActorSkeleton(bool firstPerson, bool female, bool beast, bool werewolf);
}
#endif

View file

@ -814,7 +814,7 @@ namespace SceneUtil
return;
}
std::string lightingMethodString = Settings::Manager::getString("lighting method", "Shaders");
const std::string& lightingMethodString = Settings::Manager::getString("lighting method", "Shaders");
auto lightingMethod = LightManager::getLightingMethodFromString(lightingMethodString);
static bool hasLoggedWarnings = false;

View file

@ -43,10 +43,10 @@ namespace SceneUtil
mShadowSettings->setMinimumShadowMapNearFarRatio(Settings::Manager::getFloat("minimum lispsm near far ratio", "Shadows"));
std::string computeSceneBounds = Settings::Manager::getString("compute scene bounds", "Shadows");
if (Misc::StringUtils::lowerCase(computeSceneBounds) == "primitives")
const std::string& computeSceneBounds = Settings::Manager::getString("compute scene bounds", "Shadows");
if (Misc::StringUtils::ciEqual(computeSceneBounds, "primitives"))
mShadowSettings->setComputeNearFarModeOverride(osg::CullSettings::COMPUTE_NEAR_FAR_USING_PRIMITIVES);
else if (Misc::StringUtils::lowerCase(computeSceneBounds) == "bounds")
else if (Misc::StringUtils::ciEqual(computeSceneBounds, "bounds"))
mShadowSettings->setComputeNearFarModeOverride(osg::CullSettings::COMPUTE_NEAR_FAR_USING_BOUNDING_VOLUMES);
int mapres = Settings::Manager::getInt("shadow map resolution", "Shadows");

View file

@ -71,7 +71,7 @@ void Manager::saveUser(const std::string &file)
parser.saveSettingsFile(file, mUserSettings);
}
std::string Manager::getString(std::string_view setting, std::string_view category)
const std::string& Manager::getString(std::string_view setting, std::string_view category)
{
const auto key = std::make_pair(category, setting);
CategorySettingValueMap::iterator it = mUserSettings.find(key);

View file

@ -63,7 +63,7 @@ namespace Settings
static std::int64_t getInt64(std::string_view setting, std::string_view category);
static float getFloat(std::string_view setting, std::string_view category);
static double getDouble(std::string_view setting, std::string_view category);
static std::string getString(std::string_view setting, std::string_view category);
static const std::string& getString(std::string_view setting, std::string_view category);
static std::vector<std::string> getStringArray(std::string_view setting, std::string_view category);
static bool getBool(std::string_view setting, std::string_view category);
static osg::Vec2f getVector2(std::string_view setting, std::string_view category);