From daf8bab1367334bb7f2332d4256f31c9db5ecec8 Mon Sep 17 00:00:00 2001 From: Tannin Date: Thu, 23 May 2013 20:03:35 +0200 Subject: - bugfix: installation using custom installer always created mod directory - batch installer now displays progress during mod installation --- src/installationmanager.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'src/installationmanager.cpp') diff --git a/src/installationmanager.cpp b/src/installationmanager.cpp index fee6361a..98a8a760 100644 --- a/src/installationmanager.cpp +++ b/src/installationmanager.cpp @@ -716,9 +716,7 @@ bool InstallationManager::install(const QString &fileName, GuessedValue ((filesTree == NULL) && installerCustom->isArchiveSupported(fileName)))) { std::set installerExtensions = installerCustom->supportedExtensions(); if (installerExtensions.find(fileInfo.suffix()) != installerExtensions.end()) { - if (testOverwrite(modName)) { - installResult = installerCustom->install(modName, fileName); - } + installResult = installerCustom->install(modName, fileName); } } } -- cgit v1.3.1 From 1606c1366f5d0ba304334b0e57680fb99feb88b9 Mon Sep 17 00:00:00 2001 From: Tannin Date: Wed, 5 Jun 2013 09:51:48 +0200 Subject: - install plugins now get a chance to update name, version and modid of mods - NCC now makes name, version and modid from the info.xml file available to the installer - integrated fomod installer also uses version and modid from the info.xml - mods can now be renamed during installation - configurator plugin now highlights changed keys and saves changes --- src/installationmanager.cpp | 7 +++---- src/mainwindow.cpp | 16 ++++++++++------ src/modinfo.cpp | 25 ++++++++++++++++--------- src/modinfo.h | 12 ------------ 4 files changed, 29 insertions(+), 31 deletions(-) (limited to 'src/installationmanager.cpp') diff --git a/src/installationmanager.cpp b/src/installationmanager.cpp index 98a8a760..75ab11a3 100644 --- a/src/installationmanager.cpp +++ b/src/installationmanager.cpp @@ -68,7 +68,7 @@ template T resolveFunction(QLibrary &lib, const char *name) InstallationManager::InstallationManager(QWidget *parent) : QObject(parent), m_ParentWidget(parent), - m_InstallationProgress(parent), m_SupportedExtensions() //boost::assign::list_of("zip")("rar")("7z")("fomod") + m_InstallationProgress(parent), m_SupportedExtensions(boost::assign::list_of("zip")("rar")("7z")("fomod")) { QLibrary archiveLib("dlls\\archive.dll"); if (!archiveLib.load()) { @@ -695,10 +695,9 @@ bool InstallationManager::install(const QString &fileName, GuessedValue try { { // simple case IPluginInstallerSimple *installerSimple = dynamic_cast(installer); - if ((installerSimple != NULL) && (filesTree != NULL) && (installer->isArchiveSupported(*filesTree))) { - installResult = installerSimple->install(modName, *filesTree); + installResult = installerSimple->install(modName, *filesTree, version, modID); if (installResult == IPluginInstaller::RESULT_SUCCESS) { mapToArchive(filesTree); // the simple installer only prepares the installation, the rest works the same for all installers @@ -716,7 +715,7 @@ bool InstallationManager::install(const QString &fileName, GuessedValue ((filesTree == NULL) && installerCustom->isArchiveSupported(fileName)))) { std::set installerExtensions = installerCustom->supportedExtensions(); if (installerExtensions.find(fileInfo.suffix()) != installerExtensions.end()) { - installResult = installerCustom->install(modName, fileName); + installResult = installerCustom->install(modName, fileName, version, modID); } } } diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 5cbfa72a..fb88bbad 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -967,13 +967,17 @@ bool MainWindow::registerPlugin(QObject *plugin) if (verifyPlugin(proxy)) { QStringList pluginNames = proxy->pluginList(QCoreApplication::applicationDirPath() + "/" + ToQString(AppConfig::pluginPath())); foreach (const QString &pluginName, pluginNames) { - QObject *proxiedPlugin = proxy->instantiate(pluginName); - if (proxiedPlugin != NULL) { - if (registerPlugin(proxiedPlugin)) { - qDebug("loaded plugin \"%s\"", pluginName.toUtf8().constData()); - } else { - qWarning("plugin \"%s\" failed to load", pluginName.toUtf8().constData()); + try { + QObject *proxiedPlugin = proxy->instantiate(pluginName); + if (proxiedPlugin != NULL) { + if (registerPlugin(proxiedPlugin)) { + qDebug("loaded plugin \"%s\"", pluginName.toUtf8().constData()); + } else { + qWarning("plugin \"%s\" failed to load", pluginName.toUtf8().constData()); + } } + } catch (const std::exception &e) { + reportError(tr("failed to init plugin %1: %2").arg(pluginName).arg(e.what())); } } return true; diff --git a/src/modinfo.cpp b/src/modinfo.cpp index a08a4ccd..e3e0487b 100644 --- a/src/modinfo.cpp +++ b/src/modinfo.cpp @@ -509,6 +509,7 @@ bool ModInfoRegular::setName(const QString &name) QString newPath = m_Path.mid(0).replace(m_Path.length() - m_Name.length(), m_Name.length(), name); QDir modDir(m_Path.mid(0, m_Path.length() - m_Name.length())); + if (m_Name.compare(name, Qt::CaseInsensitive) == 0) { QString tempName = name; tempName.append("_temp"); @@ -524,23 +525,29 @@ bool ModInfoRegular::setName(const QString &name) return false; } } else { - if (!modDir.rename(m_Name, name)) { + if (!shellRename(modDir.absoluteFilePath(m_Name), modDir.absoluteFilePath(name))) { + qCritical("failed to rename mod %s (errorcode %d)", + qPrintable(name), ::GetLastError()); return false; } } std::map::iterator nameIter = s_ModsByName.find(m_Name); - unsigned int index = nameIter->second; - s_ModsByName.erase(nameIter); - - m_Name = name; - m_Path = newPath; + if (nameIter != s_ModsByName.end()) { + unsigned int index = nameIter->second; + s_ModsByName.erase(nameIter); - s_ModsByName[m_Name] = index; + m_Name = name; + m_Path = newPath; - std::sort(s_Collection.begin(), s_Collection.end(), ByName); + s_ModsByName[m_Name] = index; - updateIndices(); + std::sort(s_Collection.begin(), s_Collection.end(), ByName); + updateIndices(); + } else { // otherwise mod isn't registered yet? + m_Name = name; + m_Path = newPath; + } return true; } diff --git a/src/modinfo.h b/src/modinfo.h index faf33f0d..a261296b 100644 --- a/src/modinfo.h +++ b/src/modinfo.h @@ -214,18 +214,6 @@ public: **/ virtual void setCategory(int categoryID, bool active) = 0; - /** - * @brief set the name of this mod - * - * set the name of this mod. This will also update the name of the - * directory that contains this mod - * - * @param name new name of the mod - * @return true on success, false if the new name can't be used (i.e. because the new - * directory name wouldn't be valid) - **/ - virtual bool setName(const QString &name) = 0; - /** * @brief change the notes (manually set information) for this mod * @param notes new notes -- cgit v1.3.1