mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-19 19:53:53 +00:00
Make settings loader differentiate between engine and editor (fixes #6658).
This commit is contained in:
parent
3afa46b25e
commit
96e48e5492
3 changed files with 24 additions and 9 deletions
|
@ -16,7 +16,7 @@ CSMPrefs::State *CSMPrefs::State::sThis = nullptr;
|
||||||
|
|
||||||
void CSMPrefs::State::load()
|
void CSMPrefs::State::load()
|
||||||
{
|
{
|
||||||
mSettings.load(mConfigurationManager);
|
mSettings.load(mConfigurationManager, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSMPrefs::State::declare()
|
void CSMPrefs::State::declare()
|
||||||
|
|
|
@ -20,29 +20,44 @@ void Manager::clear()
|
||||||
mChangedSettings.clear();
|
mChangedSettings.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Manager::load(const Files::ConfigurationManager& cfgMgr)
|
std::string Manager::load(const Files::ConfigurationManager& cfgMgr, bool loadEditorSettings)
|
||||||
{
|
{
|
||||||
SettingsFileParser parser;
|
SettingsFileParser parser;
|
||||||
const std::vector<boost::filesystem::path>& paths = cfgMgr.getActiveConfigPaths();
|
const std::vector<boost::filesystem::path>& paths = cfgMgr.getActiveConfigPaths();
|
||||||
if (paths.empty())
|
if (paths.empty())
|
||||||
throw std::runtime_error("No config dirs! ConfigurationManager::readConfiguration must be called first.");
|
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.
|
// 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))
|
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);
|
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)
|
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))
|
if (boost::filesystem::exists(additionalDefaults))
|
||||||
parser.loadSettingsFile(additionalDefaults, mDefaultSettings, false, true);
|
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.
|
// 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() / "settings.cfg").string();
|
std::string settingspath = (paths.back() / userSettingsFile).string();
|
||||||
if (boost::filesystem::exists(settingspath))
|
if (boost::filesystem::exists(settingspath))
|
||||||
parser.loadSettingsFile(settingspath, mUserSettings, false, false);
|
parser.loadSettingsFile(settingspath, mUserSettings, false, false);
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@ namespace Settings
|
||||||
void clear();
|
void clear();
|
||||||
///< clears all settings and default settings
|
///< clears all settings and default settings
|
||||||
|
|
||||||
std::string load(const Files::ConfigurationManager& cfgMgr);
|
std::string load(const Files::ConfigurationManager& cfgMgr, bool loadEditorSettings = false);
|
||||||
///< load settings from all active config dirs. Returns the path of the last loaded file.
|
///< load settings from all active config dirs. Returns the path of the last loaded file.
|
||||||
|
|
||||||
void saveUser (const std::string& file);
|
void saveUser (const std::string& file);
|
||||||
|
|
Loading…
Reference in a new issue