Added support for multiple ini files

pull/37/head
Pieter van der Kloet 12 years ago
parent 63a13cf9ca
commit 150d4a7a72

@ -180,7 +180,7 @@ bool MainDialog::showFirstRunDialog()
if (msgBox.clickedButton() == importerButton) {
QString iniPath;
QStringList iniPaths;
foreach (const QString &path, mGameSettings.getDataDirs()) {
QDir dir(path);
@ -190,10 +190,10 @@ bool MainDialog::showFirstRunDialog()
continue; // Cannot move from Data Files
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;
msgBox.setWindowTitle(tr("Error reading Morrowind configuration file"));
msgBox.setIcon(QMessageBox::Warning);
@ -205,6 +205,21 @@ bool MainDialog::showFirstRunDialog()
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
QString path = QString::fromStdString(mCfgMgr.getUserPath().string()) + QString("openmw.cfg");
QFile file(path);
@ -232,7 +247,7 @@ bool MainDialog::showFirstRunDialog()
if (msgBox.isChecked())
arguments.append(QString("-g"));
arguments.append(iniPath);
arguments.append(iniPaths.first());
arguments.append(path);
if (!startProgram(QString("mwiniimport"), arguments, false))

@ -21,11 +21,10 @@ GameSettings::~GameSettings()
void GameSettings::validatePaths()
{
if (mSettings.isEmpty())
return;
if (mSettings.isEmpty() || !mDataDirs.isEmpty())
return; // Don't re-validate paths if they are already parsed
QStringList paths = mSettings.values(QString("data"));
qDebug() << "paths " << paths;
Files::PathContainer dataDirs;
foreach (const QString &path, paths) {
@ -89,19 +88,6 @@ bool GameSettings::readFile(QTextStream &stream)
QString key = keyRe.cap(1).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);
QStringList values = cache.values(key);

Loading…
Cancel
Save