From 19bb86a870a88b65cce0eca2b6b71348d2769f51 Mon Sep 17 00:00:00 2001 From: Silarn Date: Wed, 11 Dec 2019 14:02:33 -0600 Subject: Update installer status handling --- src/installationmanager.cpp | 52 +++++++++---------- src/installationmanager.h | 4 +- src/organizer_en.ts | 123 +++++++++++++++++++++++++------------------- src/organizercore.cpp | 16 ++++-- 4 files changed, 107 insertions(+), 88 deletions(-) (limited to 'src') diff --git a/src/installationmanager.cpp b/src/installationmanager.cpp index 8ea2bac7..1bfc846e 100644 --- a/src/installationmanager.cpp +++ b/src/installationmanager.cpp @@ -328,14 +328,9 @@ IPluginInstaller::EInstallResult InstallationManager::installArchive(GuessedValu // a problem if this is called by the bundle installer and the bundled installer adds additional names that then end up being used, // because the caller will then not have the right name. bool iniTweaks; - if (install(archiveName, modName, iniTweaks, modId)) { - return IPluginInstaller::RESULT_SUCCESS; - } else { - return IPluginInstaller::RESULT_FAILED; - } + return install(archiveName, modName, iniTweaks, modId); } - DirectoryTree *InstallationManager::createFilesTree() { FileData* const *data; @@ -573,18 +568,18 @@ bool InstallationManager::ensureValidModName(GuessedValue &name) const return true; } -bool InstallationManager::doInstall(GuessedValue &modName, QString gameName, int modID, +IPluginInstaller::EInstallResult InstallationManager::doInstall(GuessedValue &modName, QString gameName, int modID, const QString &version, const QString &newestVersion, int categoryID, int fileCategoryID, const QString &repository) { if (!ensureValidModName(modName)) { - return false; + return IPluginInstaller::RESULT_FAILED; } bool merge = false; // determine target directory if (!testOverwrite(modName, &merge)) { - return false; + return IPluginInstaller::RESULT_FAILED; } QString targetDirectory = QDir(m_ModsDirectory + "/" + modName).canonicalPath(); @@ -627,7 +622,7 @@ bool InstallationManager::doInstall(GuessedValue &modName, QString game if (!m_ErrorMessage.isEmpty()) { throw MyException(tr("Extraction failed: %1").arg(m_ErrorMessage)); } else { - return false; + return IPluginInstaller::RESULT_CANCELED; } } else { throw MyException(tr("Extraction failed: %1").arg(m_ArchiveHandler->getLastError())); @@ -671,7 +666,7 @@ bool InstallationManager::doInstall(GuessedValue &modName, QString game settingsFile.endGroup(); } - return true; + return IPluginInstaller::RESULT_SUCCESS; } @@ -721,7 +716,7 @@ void InstallationManager::postInstallCleanup() } } -bool InstallationManager::install(const QString &fileName, +IPluginInstaller::EInstallResult InstallationManager::install(const QString &fileName, GuessedValue &modName, bool &hasIniTweaks, int modID) @@ -732,7 +727,7 @@ bool InstallationManager::install(const QString &fileName, QFileInfo fileInfo(fileName); if (m_SupportedExtensions.find(fileInfo.suffix()) == m_SupportedExtensions.end()) { reportError(tr("File format \"%1\" not supported").arg(fileInfo.suffix())); - return false; + return IPluginInstaller::RESULT_FAILED; } modName.setFilter(&fixDirectoryName); @@ -840,10 +835,7 @@ bool InstallationManager::install(const QString &fileName, mapToArchive(filesTree.data()); // the simple installer only prepares the installation, the rest // works the same for all installers - if (!doInstall(modName, gameName, modID, version, newestVersion, categoryID, - fileCategoryID, repository)) { - installResult = IPluginInstaller::RESULT_FAILED; - } + installResult = doInstall(modName, gameName, modID, version, newestVersion, categoryID, fileCategoryID, repository); } } } @@ -876,28 +868,34 @@ bool InstallationManager::install(const QString &fileName, // act upon the installation result. at this point the files have already been // extracted to the correct location switch (installResult) { - case IPluginInstaller::RESULT_CANCELED: case IPluginInstaller::RESULT_FAILED: { - return false; + QMessageBox::information(qApp->activeWindow(), tr("Installation failed"), + tr("Something went wrong while installing this mod."), + QMessageBox::Ok); + return installResult; } break; case IPluginInstaller::RESULT_SUCCESS: case IPluginInstaller::RESULT_SUCCESSCANCEL: { if (filesTree != nullptr) { DirectoryTree::node_iterator iniTweakNode = filesTree->nodeFind(DirectoryTreeInformation("INI Tweaks")); hasIniTweaks = (iniTweakNode != filesTree->nodesEnd()) && - ((*iniTweakNode)->numLeafs() != 0); - return true; - } else { - return false; + ((*iniTweakNode)->numLeafs() != 0); } + return installResult; } break; + case IPluginInstaller::RESULT_NOTATTEMPTED: { + continue; + } + default: + return installResult; } } + if (installResult == IPluginInstaller::RESULT_NOTATTEMPTED) { + reportError(tr("None of the available installer plugins were able to handle that archive.\n" + "This is likely due to a corrupted or incompatible download or unrecognized archive format.")); + } - reportError(tr("None of the available installer plugins were able to handle that archive.\n" - "This is likely due to a corrupted or incompatible download or unrecognized archive format.")); - - return false; + return installResult; } diff --git a/src/installationmanager.h b/src/installationmanager.h index 6e4f5925..199a0f82 100644 --- a/src/installationmanager.h +++ b/src/installationmanager.h @@ -82,7 +82,7 @@ public: * @return true if the archive was installed, false if installation failed or was refused * @exception std::exception an exception may be thrown if the archive can't be opened (maybe the format is invalid or the file is damaged) **/ - bool install(const QString &fileName, MOBase::GuessedValue &modName, bool &hasIniTweaks, int modID = 0); + MOBase::IPluginInstaller::EInstallResult install(const QString &fileName, MOBase::GuessedValue &modName, bool &hasIniTweaks, int modID = 0); /** * @return true if the installation was canceled @@ -175,7 +175,7 @@ private: bool isSimpleArchiveTopLayer(const MOBase::DirectoryTree::Node *node, bool bainStyle); MOBase::DirectoryTree::Node *getSimpleArchiveBase(MOBase::DirectoryTree *dataTree); - bool doInstall(MOBase::GuessedValue &modName, QString gameName, + MOBase::IPluginInstaller::EInstallResult doInstall(MOBase::GuessedValue &modName, QString gameName, int modID, const QString &version, const QString &newestVersion, int categoryID, int fileCategoryID, const QString &repository); //QString generateBackupName(const QString &directoryName) const; diff --git a/src/organizer_en.ts b/src/organizer_en.ts index d8995973..95854200 100644 --- a/src/organizer_en.ts +++ b/src/organizer_en.ts @@ -1529,89 +1529,100 @@ Right now the only case I know of where this needs to be overwritten is for the + - Extraction failed: %1 - + Failed to create backup - + Mod Name - + Name - + Invalid name - + The name you entered is invalid, please enter a different one. - + File format "%1" not supported - + + Installation failed + + + + + Something went wrong while installing this mod. + The mod was not installed completely. + + + + None of the available installer plugins were able to handle that archive. This is likely due to a corrupted or incompatible download or unrecognized archive format. - + no error - + 7z.dll not found - + 7z.dll isn't valid - + archive not found - + failed to open archive - + unsupported archive type - + internal library error - + archive invalid - + unknown archive error @@ -4600,170 +4611,174 @@ p, li { white-space: pre-wrap; } - - - + Installation cancelled - + Another installation is currently in progress. - + Installation successful - + Configure Mod - + This mod contains ini tweaks. Do you want to configure them now? - + mod not found: %1 + + + + Extraction cancelled + + - - The mod was not installed completely. + + The installation was cancelled while extracting files. If this was prior to a FOMOD setup, this warning may be ignored. However, if this was during installation, the mod will likely be missing files. - + file not found: %1 - + failed to generate preview for %1 - + Sorry - + Sorry, can't preview anything. This function currently does not support extracting from bsas. - + File '%1' not found. - + Failed to generate preview for %1 - + Failed to refresh list of esps: %1 - + Multiple esps/esls activated, please check that they don't conflict. - + You need to be logged in with Nexus - + Download? - + A download has been started but no installed page plugin recognizes it. If you download anyway no information (i.e. version) will be associated with the download. Continue? - - + + failed to update mod list: %1 - - + + login successful - + Login failed - + Login failed, try again? - + login failed: %1. Download will not be associated with an account - + login failed: %1 - + login failed: %1. You need to log-in with Nexus to update MO. - + MO1 "Script Extender" load mechanism has left hook.dll in your game folder - - + + Description missing - + <a href="%1">hook.dll</a> has been found in your game folder (right click to copy the full path). This is most likely a leftover of setting the ModOrganizer 1 load mechanism to "Script Extender", in which case you must remove this file either by changing the load mechanism in ModOrganizer 1 or manually removing the file, otherwise the game is likely to crash and burn. - + failed to save load order: %1 - + Error - + The designated write target "%1" is not enabled. diff --git a/src/organizercore.cpp b/src/organizercore.cpp index 55cb82ff..4ba38dbb 100644 --- a/src/organizercore.cpp +++ b/src/organizercore.cpp @@ -735,9 +735,12 @@ MOBase::IModInterface *OrganizerCore::installMod(const QString &fileName, reportError(tr("mod not found: %1").arg(qUtf8Printable(modName))); } } else if (m_InstallationManager.wasCancelled()) { - QMessageBox::information(qApp->activeWindow(), tr("Installation cancelled"), - tr("The mod was not installed completely."), + QMessageBox::information(qApp->activeWindow(), tr("Extraction cancelled"), + tr("The installation was cancelled while extracting files. " + "If this was prior to a FOMOD setup, this warning may be ignored. " + "However, if this was during installation, the mod will likely be missing files."), QMessageBox::Ok); + refreshModList(); } return nullptr; } @@ -803,9 +806,12 @@ void OrganizerCore::installDownload(int index) emit modInstalled(modName); } else if (m_InstallationManager.wasCancelled()) { - QMessageBox::information( - qApp->activeWindow(), tr("Installation cancelled"), - tr("The mod was not installed completely."), QMessageBox::Ok); + QMessageBox::information(qApp->activeWindow(), tr("Extraction cancelled"), + tr("The installation was cancelled while extracting files. " + "If this was prior to a FOMOD setup, this warning may be ignored. " + "However, if this was during installation, the mod will likely be missing files."), + QMessageBox::Ok); + refreshModList(); } } catch (const std::exception &e) { reportError(e.what()); -- cgit v1.3.1