mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-21 06:53:53 +00:00
Added support for multiple ini files
This commit is contained in:
parent
63a13cf9ca
commit
150d4a7a72
2 changed files with 21 additions and 20 deletions
|
@ -180,7 +180,7 @@ bool MainDialog::showFirstRunDialog()
|
||||||
|
|
||||||
if (msgBox.clickedButton() == importerButton) {
|
if (msgBox.clickedButton() == importerButton) {
|
||||||
|
|
||||||
QString iniPath;
|
QStringList iniPaths;
|
||||||
|
|
||||||
foreach (const QString &path, mGameSettings.getDataDirs()) {
|
foreach (const QString &path, mGameSettings.getDataDirs()) {
|
||||||
QDir dir(path);
|
QDir dir(path);
|
||||||
|
@ -190,10 +190,10 @@ bool MainDialog::showFirstRunDialog()
|
||||||
continue; // Cannot move from Data Files
|
continue; // Cannot move from Data Files
|
||||||
|
|
||||||
if (dir.exists(QString("Morrowind.ini")))
|
if (dir.exists(QString("Morrowind.ini")))
|
||||||
iniPath = dir.absoluteFilePath(QString("Morrowind.ini"));
|
iniPaths.append(dir.absoluteFilePath(QString("Morrowind.ini")));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (iniPath.isEmpty()) {
|
if (iniPaths.isEmpty()) {
|
||||||
QMessageBox msgBox;
|
QMessageBox msgBox;
|
||||||
msgBox.setWindowTitle(tr("Error reading Morrowind configuration file"));
|
msgBox.setWindowTitle(tr("Error reading Morrowind configuration file"));
|
||||||
msgBox.setIcon(QMessageBox::Warning);
|
msgBox.setIcon(QMessageBox::Warning);
|
||||||
|
@ -205,6 +205,21 @@ bool MainDialog::showFirstRunDialog()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (iniPaths.count() > 1) {
|
||||||
|
// Multiple Morrowind.ini files found
|
||||||
|
bool ok;
|
||||||
|
QString path = QInputDialog::getItem(this, tr("Multiple configurations found"),
|
||||||
|
tr("<br><b>There are multiple Morrowind.ini files found.</b><br><br> \
|
||||||
|
Please select the one you wish to import from:"), iniPaths, 0, false, &ok);
|
||||||
|
if (ok && !path.isEmpty()) {
|
||||||
|
iniPaths.clear();
|
||||||
|
iniPaths.append(path);
|
||||||
|
} else {
|
||||||
|
// Cancel was clicked TODO: should we abort here?
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Create the file if it doesn't already exist, else the importer will fail
|
// Create the file if it doesn't already exist, else the importer will fail
|
||||||
QString path = QString::fromStdString(mCfgMgr.getUserPath().string()) + QString("openmw.cfg");
|
QString path = QString::fromStdString(mCfgMgr.getUserPath().string()) + QString("openmw.cfg");
|
||||||
QFile file(path);
|
QFile file(path);
|
||||||
|
@ -232,7 +247,7 @@ bool MainDialog::showFirstRunDialog()
|
||||||
if (msgBox.isChecked())
|
if (msgBox.isChecked())
|
||||||
arguments.append(QString("-g"));
|
arguments.append(QString("-g"));
|
||||||
|
|
||||||
arguments.append(iniPath);
|
arguments.append(iniPaths.first());
|
||||||
arguments.append(path);
|
arguments.append(path);
|
||||||
|
|
||||||
if (!startProgram(QString("mwiniimport"), arguments, false))
|
if (!startProgram(QString("mwiniimport"), arguments, false))
|
||||||
|
|
|
@ -21,11 +21,10 @@ GameSettings::~GameSettings()
|
||||||
|
|
||||||
void GameSettings::validatePaths()
|
void GameSettings::validatePaths()
|
||||||
{
|
{
|
||||||
if (mSettings.isEmpty())
|
if (mSettings.isEmpty() || !mDataDirs.isEmpty())
|
||||||
return;
|
return; // Don't re-validate paths if they are already parsed
|
||||||
|
|
||||||
QStringList paths = mSettings.values(QString("data"));
|
QStringList paths = mSettings.values(QString("data"));
|
||||||
qDebug() << "paths " << paths;
|
|
||||||
Files::PathContainer dataDirs;
|
Files::PathContainer dataDirs;
|
||||||
|
|
||||||
foreach (const QString &path, paths) {
|
foreach (const QString &path, paths) {
|
||||||
|
@ -89,19 +88,6 @@ bool GameSettings::readFile(QTextStream &stream)
|
||||||
QString key = keyRe.cap(1).simplified();
|
QString key = keyRe.cap(1).simplified();
|
||||||
QString value = keyRe.cap(2).simplified();
|
QString value = keyRe.cap(2).simplified();
|
||||||
|
|
||||||
// // There can be multiple keys
|
|
||||||
// if (key == QLatin1String("data") ||
|
|
||||||
// key == QLatin1String("master") ||
|
|
||||||
// key == QLatin1String("plugin"))
|
|
||||||
// {
|
|
||||||
// // Remove keys from previous config and overwrite them
|
|
||||||
// mSettings.remove(key);
|
|
||||||
// QStringList values = cache.values(key);
|
|
||||||
// if (!values.contains(value)) // Do not insert duplicate values
|
|
||||||
// cache.insertMulti(key, value);
|
|
||||||
// } else {
|
|
||||||
// cache.insert(key, value);
|
|
||||||
// }
|
|
||||||
mSettings.remove(key);
|
mSettings.remove(key);
|
||||||
|
|
||||||
QStringList values = cache.values(key);
|
QStringList values = cache.values(key);
|
||||||
|
|
Loading…
Reference in a new issue