|
|
|
@ -334,13 +334,12 @@ bool Launcher::MainDialog::setupGameSettings()
|
|
|
|
|
QString userPath = QString::fromUtf8(mCfgMgr.getUserConfigPath().string().c_str());
|
|
|
|
|
QString globalPath = QString::fromUtf8(mCfgMgr.getGlobalPath().string().c_str());
|
|
|
|
|
|
|
|
|
|
// Load the user config file first, separately
|
|
|
|
|
// So we can write it properly, uncontaminated
|
|
|
|
|
QString path = userPath + QLatin1String("openmw.cfg");
|
|
|
|
|
QFile file(path);
|
|
|
|
|
QFile file;
|
|
|
|
|
|
|
|
|
|
auto loadFile = [&] (const QString& path, bool(Config::GameSettings::*reader)(QTextStream&, bool), bool ignoreContent = false)
|
|
|
|
|
{
|
|
|
|
|
qDebug() << "Loading config file:" << path.toUtf8().constData();
|
|
|
|
|
|
|
|
|
|
file.setFileName(path);
|
|
|
|
|
if (file.exists()) {
|
|
|
|
|
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
|
|
|
|
cfgError(tr("Error opening OpenMW configuration file"),
|
|
|
|
@ -352,36 +351,19 @@ bool Launcher::MainDialog::setupGameSettings()
|
|
|
|
|
QTextStream stream(&file);
|
|
|
|
|
stream.setCodec(QTextCodec::codecForName("UTF-8"));
|
|
|
|
|
|
|
|
|
|
mGameSettings.readUserFile(stream);
|
|
|
|
|
(mGameSettings.*reader)(stream, ignoreContent);
|
|
|
|
|
file.close();
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Now the rest - priority: user > local > global
|
|
|
|
|
QStringList paths;
|
|
|
|
|
paths.append(globalPath + QString("openmw.cfg"));
|
|
|
|
|
paths.append(localPath + QString("openmw.cfg"));
|
|
|
|
|
paths.append(userPath + QString("openmw.cfg"));
|
|
|
|
|
|
|
|
|
|
for (const QString &path2 : paths)
|
|
|
|
|
{
|
|
|
|
|
qDebug() << "Loading config file:" << path2.toUtf8().constData();
|
|
|
|
|
|
|
|
|
|
file.setFileName(path2);
|
|
|
|
|
if (file.exists()) {
|
|
|
|
|
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
|
|
|
|
cfgError(tr("Error opening OpenMW configuration file"),
|
|
|
|
|
tr("<br><b>Could not open %0 for reading</b><br><br> \
|
|
|
|
|
Please make sure you have the right permissions \
|
|
|
|
|
and try again.<br>").arg(file.fileName()));
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
QTextStream stream(&file);
|
|
|
|
|
stream.setCodec(QTextCodec::codecForName("UTF-8"));
|
|
|
|
|
// Load the user config file first, separately
|
|
|
|
|
// So we can write it properly, uncontaminated
|
|
|
|
|
loadFile(userPath + QLatin1String("openmw.cfg"), &Config::GameSettings::readUserFile);
|
|
|
|
|
|
|
|
|
|
mGameSettings.readFile(stream);
|
|
|
|
|
file.close();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// Now the rest - priority: user > local > global
|
|
|
|
|
loadFile(globalPath + QString("openmw.cfg"), &Config::GameSettings::readFile, true);
|
|
|
|
|
loadFile(localPath + QString("openmw.cfg"), &Config::GameSettings::readFile, true);
|
|
|
|
|
loadFile(userPath + QString("openmw.cfg"), &Config::GameSettings::readFile);
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|