mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-05-01 22:38:00 +03:00
Read settings.cfg from all active config dirs
This commit is contained in:
parent
5ca56a4f8a
commit
1bcc4a8bcc
6 changed files with 28 additions and 17 deletions
|
@ -9,7 +9,8 @@
|
|||
|
||||
#include <Base64.h>
|
||||
|
||||
void Settings::SettingsFileParser::loadSettingsFile(const std::string& file, CategorySettingValueMap& settings, bool base64Encoded)
|
||||
void Settings::SettingsFileParser::loadSettingsFile(const std::string& file, CategorySettingValueMap& settings,
|
||||
bool base64Encoded, bool overrideExisting)
|
||||
{
|
||||
mFile = file;
|
||||
boost::filesystem::ifstream fstream;
|
||||
|
@ -73,7 +74,9 @@ void Settings::SettingsFileParser::loadSettingsFile(const std::string& file, Cat
|
|||
std::string value = line.substr(valueBegin);
|
||||
Misc::StringUtils::trim(value);
|
||||
|
||||
if (settings.insert(std::make_pair(std::make_pair(currentCategory, setting), value)).second == false)
|
||||
if (overrideExisting)
|
||||
settings[std::make_pair(currentCategory, setting)] = value;
|
||||
else if (settings.insert(std::make_pair(std::make_pair(currentCategory, setting), value)).second == false)
|
||||
fail(std::string("duplicate setting: [" + currentCategory + "] " + setting));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,8 @@ namespace Settings
|
|||
class SettingsFileParser
|
||||
{
|
||||
public:
|
||||
void loadSettingsFile(const std::string& file, CategorySettingValueMap& settings, bool base64encoded = false);
|
||||
void loadSettingsFile(const std::string& file, CategorySettingValueMap& settings,
|
||||
bool base64encoded = false, bool overrideExisting = false);
|
||||
|
||||
void saveSettingsFile(const std::string& file, const CategorySettingValueMap& settings);
|
||||
|
||||
|
|
|
@ -19,10 +19,10 @@ void Manager::clear()
|
|||
mChangedSettings.clear();
|
||||
}
|
||||
|
||||
void Manager::loadDefault(const std::string &file)
|
||||
void Manager::loadDefault(const std::string &file, bool overrideExisting)
|
||||
{
|
||||
SettingsFileParser parser;
|
||||
parser.loadSettingsFile(file, mDefaultSettings, true);
|
||||
parser.loadSettingsFile(file, mDefaultSettings, true, overrideExisting);
|
||||
}
|
||||
|
||||
void Manager::loadUser(const std::string &file)
|
||||
|
|
|
@ -26,7 +26,7 @@ namespace Settings
|
|||
void clear();
|
||||
///< clears all settings and default settings
|
||||
|
||||
void loadDefault (const std::string& file);
|
||||
void loadDefault (const std::string& file, bool overrideExisting = false);
|
||||
///< load file as the default settings (can be overridden by user settings)
|
||||
|
||||
void loadUser (const std::string& file);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue