mirror of
https://github.com/OpenMW/openmw.git
synced 2025-06-27 12:11:35 +00:00
Only load global cfg if local wasn't found
This commit is contained in:
parent
c081b8cfa9
commit
478ad07607
1 changed files with 16 additions and 6 deletions
|
@ -336,7 +336,7 @@ bool Launcher::MainDialog::setupGameSettings()
|
||||||
|
|
||||||
QFile file;
|
QFile file;
|
||||||
|
|
||||||
auto loadFile = [&] (const QString& path, bool(Config::GameSettings::*reader)(QTextStream&, bool), bool ignoreContent = false)
|
auto loadFile = [&] (const QString& path, bool(Config::GameSettings::*reader)(QTextStream&, bool), bool ignoreContent = false) -> std::optional<bool>
|
||||||
{
|
{
|
||||||
qDebug() << "Loading config file:" << path.toUtf8().constData();
|
qDebug() << "Loading config file:" << path.toUtf8().constData();
|
||||||
file.setFileName(path);
|
file.setFileName(path);
|
||||||
|
@ -346,24 +346,34 @@ bool Launcher::MainDialog::setupGameSettings()
|
||||||
tr("<br><b>Could not open %0 for reading</b><br><br> \
|
tr("<br><b>Could not open %0 for reading</b><br><br> \
|
||||||
Please make sure you have the right permissions \
|
Please make sure you have the right permissions \
|
||||||
and try again.<br>").arg(file.fileName()));
|
and try again.<br>").arg(file.fileName()));
|
||||||
return false;
|
return {};
|
||||||
}
|
}
|
||||||
QTextStream stream(&file);
|
QTextStream stream(&file);
|
||||||
stream.setCodec(QTextCodec::codecForName("UTF-8"));
|
stream.setCodec(QTextCodec::codecForName("UTF-8"));
|
||||||
|
|
||||||
(mGameSettings.*reader)(stream, ignoreContent);
|
(mGameSettings.*reader)(stream, ignoreContent);
|
||||||
file.close();
|
file.close();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Load the user config file first, separately
|
// Load the user config file first, separately
|
||||||
// So we can write it properly, uncontaminated
|
// So we can write it properly, uncontaminated
|
||||||
loadFile(userPath + QLatin1String("openmw.cfg"), &Config::GameSettings::readUserFile);
|
if(!loadFile(userPath + QLatin1String("openmw.cfg"), &Config::GameSettings::readUserFile))
|
||||||
|
return false;
|
||||||
|
|
||||||
// Now the rest - priority: user > local > global
|
// Now the rest - priority: user > local > global
|
||||||
loadFile(globalPath + QString("openmw.cfg"), &Config::GameSettings::readFile, true);
|
if(auto result = loadFile(localPath + QString("openmw.cfg"), &Config::GameSettings::readFile, true))
|
||||||
loadFile(localPath + QString("openmw.cfg"), &Config::GameSettings::readFile, true);
|
{
|
||||||
loadFile(userPath + QString("openmw.cfg"), &Config::GameSettings::readFile);
|
// Load global if local wasn't found
|
||||||
|
if(!*result && !loadFile(globalPath + QString("openmw.cfg"), &Config::GameSettings::readFile, true))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
if(!loadFile(userPath + QString("openmw.cfg"), &Config::GameSettings::readFile))
|
||||||
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue