|
|
|
@ -20,29 +20,44 @@ void Manager::clear()
|
|
|
|
|
mChangedSettings.clear();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::string Manager::load(const Files::ConfigurationManager& cfgMgr)
|
|
|
|
|
std::string Manager::load(const Files::ConfigurationManager& cfgMgr, bool loadEditorSettings)
|
|
|
|
|
{
|
|
|
|
|
SettingsFileParser parser;
|
|
|
|
|
const std::vector<boost::filesystem::path>& paths = cfgMgr.getActiveConfigPaths();
|
|
|
|
|
if (paths.empty())
|
|
|
|
|
throw std::runtime_error("No config dirs! ConfigurationManager::readConfiguration must be called first.");
|
|
|
|
|
|
|
|
|
|
// Create file name strings for either the engine or the editor.
|
|
|
|
|
std::string defaultSettingsFile = "";
|
|
|
|
|
std::string userSettingsFile = "";
|
|
|
|
|
|
|
|
|
|
if (!loadEditorSettings)
|
|
|
|
|
{
|
|
|
|
|
defaultSettingsFile = "defaults.bin";
|
|
|
|
|
userSettingsFile = "settings.cfg";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
defaultSettingsFile = "defaults-cs.bin";
|
|
|
|
|
userSettingsFile = "openmw-cs.cfg";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Create the settings manager and load default settings file.
|
|
|
|
|
const std::string defaultsBin = (paths.front() / "defaults.bin").string();
|
|
|
|
|
const std::string defaultsBin = (paths.front() / defaultSettingsFile).string();
|
|
|
|
|
if (!boost::filesystem::exists(defaultsBin))
|
|
|
|
|
throw std::runtime_error ("No default settings file found! Make sure the file \"defaults.bin\" was properly installed.");
|
|
|
|
|
throw std::runtime_error ("No default settings file found! Make sure the file \"" + defaultSettingsFile + "\" was properly installed.");
|
|
|
|
|
parser.loadSettingsFile(defaultsBin, mDefaultSettings, true, false);
|
|
|
|
|
|
|
|
|
|
// Load "settings.cfg" from every config dir except the last one as additional default settings.
|
|
|
|
|
// Load "settings.cfg" or "openmw-cs.cfg" from every config dir except the last one as additional default settings.
|
|
|
|
|
for (int i = 0; i < static_cast<int>(paths.size()) - 1; ++i)
|
|
|
|
|
{
|
|
|
|
|
const std::string additionalDefaults = (paths[i] / "settings.cfg").string();
|
|
|
|
|
const std::string additionalDefaults = (paths[i] / userSettingsFile).string();
|
|
|
|
|
if (boost::filesystem::exists(additionalDefaults))
|
|
|
|
|
parser.loadSettingsFile(additionalDefaults, mDefaultSettings, false, true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Load "settings.cfg" from the last config as user settings if they exist. This path will be used to save modified settings.
|
|
|
|
|
std::string settingspath = (paths.back() / "settings.cfg").string();
|
|
|
|
|
// Load "settings.cfg" or "openmw-cs.cfg" from the last config dir as user settings. This path will be used to save modified settings.
|
|
|
|
|
std::string settingspath = (paths.back() / userSettingsFile).string();
|
|
|
|
|
if (boost::filesystem::exists(settingspath))
|
|
|
|
|
parser.loadSettingsFile(settingspath, mUserSettings, false, false);
|
|
|
|
|
|
|
|
|
|