From 5d1154c24e2475ed2b7ac248de27ab7b501a1e5e Mon Sep 17 00:00:00 2001 From: Tannin Date: Sat, 16 Feb 2013 19:09:57 +0100 Subject: - hooks for CreateHardLink - createprocess hook will now reroute the cwd (fixes SUM, may break other tools?) - profile code moved to separate file - executables can now be linked to toolbar - category filters are now represented as a tree - csv export of mod list - ModInfoDialog is now "window modal" instead of "application modal" - nexus dialog now updates the mod-id field while browsing - right-click in nexus browser allows to open in external browser - ini viewer is no longer modal - bugfix: another attempt to fix processing of invalid header lines in fomod xmls (bom now handled) - bugfix: integrated fomod installer will no longer overwrite detected mod name by the one from the xml - bugfix: "hide file" from conflicted files list now updates that list - bugfix: conflicted files list no longer offers to hide files in BSAs - bugfix: pressing delete on the mod list with multiplie files selected offered to delete the wrong files - regression: mod name guessing with the old regular expression was less likely to lead to an empty mod name. Now both are tried --- src/installationmanager.cpp | 94 +++++++++++++++++++++++---------------------- 1 file changed, 48 insertions(+), 46 deletions(-) (limited to 'src/installationmanager.cpp') diff --git a/src/installationmanager.cpp b/src/installationmanager.cpp index e7784771..a6f062de 100644 --- a/src/installationmanager.cpp +++ b/src/installationmanager.cpp @@ -499,9 +499,9 @@ bool InstallationManager::testOverwrite(const QString &modsDirectory, QString &m QLineEdit::Normal, modName, &ok); if (ok && !name.isEmpty()) { modName = name; - if (!ensureValidModName(modName)) { - return false; - } + if (!ensureValidModName(modName)) { + return false; + } targetDirectory = QDir::fromNativeSeparators(modsDirectory.mid(0).append("\\").append(modName)); } } else if (overwriteDialog.action() == QueryOverwriteDialog::ACT_REPLACE) { @@ -547,46 +547,46 @@ void InstallationManager::fixModName(QString &name) { // name = name.remove("^[ ]*").trimmed(); name = name.simplified(); - while (name.endsWith('.')) name.chop(1); - - name.replace(QRegExp("[<>:\"/\\|?*]"), ""); - - static QString invalidNames[] = { "CON", "PRN", "AUX", "NUL", "COM1", "COM2", "COM3", "COM4", "COM5", "COM6", "COM7", "COM8", "COM9", - "LPT1", "LPT2", "LPT3", "LPT4", "LPT5", "LPT6", "LPT7", "LPT8", "LPT9" }; - for (int i = 0; i < sizeof(invalidNames) / sizeof(QString); ++i) { - if (name == invalidNames[i]) { - name = ""; - break; - } - } + while (name.endsWith('.')) name.chop(1); + + name.replace(QRegExp("[<>:\"/\\|?*]"), ""); + + static QString invalidNames[] = { "CON", "PRN", "AUX", "NUL", "COM1", "COM2", "COM3", "COM4", "COM5", "COM6", "COM7", "COM8", "COM9", + "LPT1", "LPT2", "LPT3", "LPT4", "LPT5", "LPT6", "LPT7", "LPT8", "LPT9" }; + for (int i = 0; i < sizeof(invalidNames) / sizeof(QString); ++i) { + if (name == invalidNames[i]) { + name = ""; + break; + } + } +} + + +bool InstallationManager::ensureValidModName(QString &name) +{ + fixModName(name); + + while (name.isEmpty()) { + bool ok; + name = QInputDialog::getText(m_ParentWidget, tr("Invalid name"), + tr("The name you entered is invalid, please enter a different one."), + QLineEdit::Normal, "", &ok); + if (!ok) { + return false; + } + fixModName(name); + } + return true; } -bool InstallationManager::ensureValidModName(QString &name) -{ - fixModName(name); - - while (name.isEmpty()) { - bool ok; - name = QInputDialog::getText(m_ParentWidget, tr("Invalid name"), - tr("The name you entered is invalid, please enter a different one."), - QLineEdit::Normal, "", &ok); - if (!ok) { - return false; - } - fixModName(name); - } - return true; -} - - -bool InstallationManager::doInstall(const QString &modsDirectory, QString &modName, int modID, +bool InstallationManager::doInstall(const QString &modsDirectory, QString &modName, int modID, const QString &version, const QString &newestVersion, int categoryID) { - if (!ensureValidModName(modName)) { - return false; - } - + if (!ensureValidModName(modName)) { + return false; + } + // determine target directory if (!testOverwrite(modsDirectory, modName)) { return false; @@ -679,7 +679,7 @@ bool EndsWith(LPCWSTR string, LPCWSTR subString) bool InstallationManager::installFomodInternal(DirectoryTree *&baseNode, const QString &fomodPath, const QString &modsDirectory, int modID, const QString &version, const QString &newestVersion, int categoryID, - QString &modName, bool &manualRequest) + QString &modName, bool nameGuessed, bool &manualRequest) { qDebug("treating as fomod archive"); @@ -740,7 +740,7 @@ bool InstallationManager::installFomodInternal(DirectoryTree *&baseNode, const Q bool success = false; try { - FomodInstallerDialog dialog(modName, fomodPath); + FomodInstallerDialog dialog(modName, nameGuessed, fomodPath); FileData* const *data; size_t size; @@ -924,6 +924,7 @@ bool InstallationManager::install(const QString &fileName, const QString &plugin QString version = ""; QString newestVersion = ""; int categoryID = 0; + bool nameGuessed = false; QString metaName = fileName.mid(0).append(".meta"); if (QFile(metaName).exists()) { @@ -945,9 +946,9 @@ bool InstallationManager::install(const QString &fileName, const QString &plugin { // guess the mod name and mod if from the file name if there was no meta information QString guessedModName; - int guessedModID = modID; - NexusInterface::interpretNexusFileName(QFileInfo(fileName).baseName(), guessedModName, guessedModID, false); - if ((modID == 0) && (guessedModID != -1)) { + int guessedModID = modID; + NexusInterface::interpretNexusFileName(QFileInfo(fileName).baseName(), guessedModName, guessedModID, false); + if ((modID == 0) && (guessedModID != -1)) { modID = guessedModID; } else if (modID != guessedModID) { qDebug("passed mod id: %d, guessed id: %d", modID, guessedModID); @@ -955,6 +956,7 @@ bool InstallationManager::install(const QString &fileName, const QString &plugin if (modName.isEmpty()) { modName = guessedModName; + nameGuessed = true; } } fixModName(modName); @@ -1090,8 +1092,8 @@ bool InstallationManager::install(const QString &fileName, const QString &plugin if (xmlInstaller || nmmInstaller) { if (!xmlInstaller || (nmmInstaller && !preferIntegrated)) { - if (!ensureValidModName(modName) || - !testOverwrite(modsDirectory, modName)) { + if (!ensureValidModName(modName) || + !testOverwrite(modsDirectory, modName)) { return false; } @@ -1120,7 +1122,7 @@ bool InstallationManager::install(const QString &fileName, const QString &plugin } else { if (installFomodInternal(baseNode, fomodPath, modsDirectory, modID, version, newestVersion, categoryID, - modName, manualRequest)) { + modName, nameGuessed, manualRequest)) { success = true; } } -- cgit v1.3.1