diff options
Diffstat (limited to 'src/installationmanager.cpp')
| -rw-r--r-- | src/installationmanager.cpp | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/src/installationmanager.cpp b/src/installationmanager.cpp index 6ab051b2..7c54828e 100644 --- a/src/installationmanager.cpp +++ b/src/installationmanager.cpp @@ -29,6 +29,7 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>. #include "iplugininstallercustom.h"
#include "nexusinterface.h"
#include "selectiondialog.h"
+#include "modinfo.h"
#include <scopeguard.h>
#include <installationtester.h>
#include <gameinfo.h>
@@ -462,11 +463,11 @@ bool InstallationManager::testOverwrite(GuessedValue<QString> &modName, bool *me if (!ensureValidModName(modName)) {
return false;
}
- targetDirectory = QDir::fromNativeSeparators(m_ModsDirectory.mid(0).append("\\").append(modName));
+ targetDirectory = QDir::fromNativeSeparators(m_ModsDirectory) + "/" + modName;
}
} else if (overwriteDialog.action() == QueryOverwriteDialog::ACT_REPLACE) {
// save original settings like categories. Because it makes sense
- QString metaFilename = targetDirectory.mid(0).append("/meta.ini");
+ QString metaFilename = targetDirectory + "/meta.ini";
QFile settingsFile(metaFilename);
QByteArray originalSettings;
if (settingsFile.open(QIODevice::ReadOnly)) {
@@ -520,7 +521,8 @@ bool InstallationManager::ensureValidModName(GuessedValue<QString> &name) const }
bool InstallationManager::doInstall(GuessedValue<QString> &modName, int modID,
- const QString &version, const QString &newestVersion, int categoryID)
+ const QString &version, const QString &newestVersion,
+ int categoryID, const QString &repository)
{
if (!ensureValidModName(modName)) {
return false;
@@ -532,7 +534,7 @@ bool InstallationManager::doInstall(GuessedValue<QString> &modName, int modID, return false;
}
- QString targetDirectoryNative = m_ModsDirectory.mid(0).append("\\").append(modName);
+ QString targetDirectoryNative = m_ModsDirectory + "\\" + modName;
QString targetDirectory = QDir::fromNativeSeparators(targetDirectoryNative);
qDebug("installing to \"%s\"", targetDirectoryNative.toUtf8().constData());
@@ -556,7 +558,7 @@ bool InstallationManager::doInstall(GuessedValue<QString> &modName, int modID, m_InstallationProgress.hide();
- QSettings settingsFile(targetDirectory.mid(0).append("/meta.ini"), QSettings::IniFormat);
+ QSettings settingsFile(targetDirectory + "/meta.ini", QSettings::IniFormat);
// overwrite settings only if they are actually are available or haven't been set before
if ((modID != 0) || !settingsFile.contains("modid")) {
@@ -575,6 +577,15 @@ bool InstallationManager::doInstall(GuessedValue<QString> &modName, int modID, settingsFile.setValue("category", QString::number(categoryID));
}
settingsFile.setValue("installationFile", m_CurrentFile);
+ settingsFile.setValue("repository", repository);
+
+ if (!merge) {
+ // this does not clear the list we have in memory but the mod is going to have to be re-read anyway
+ // btw.: installedFiles were written with beginWriteArray but we can still clear it with beginGroup. nice
+ settingsFile.beginGroup("installedFiles");
+ settingsFile.remove("");
+ settingsFile.endGroup();
+ }
return true;
}
@@ -630,6 +641,7 @@ bool InstallationManager::install(const QString &fileName, GuessedValue<QString> QString version = "";
QString newestVersion = "";
int categoryID = 0;
+ QString repository = "Nexus";
QString metaName = fileName.mid(0).append(".meta");
if (QFile(metaName).exists()) {
@@ -642,6 +654,7 @@ bool InstallationManager::install(const QString &fileName, GuessedValue<QString> newestVersion = metaFile.value("newestVersion", "").toString();
unsigned int categoryIndex = CategoryFactory::instance().resolveNexusID(metaFile.value("category", 0).toInt());
categoryID = CategoryFactory::instance().getCategoryID(categoryIndex);
+ repository = metaFile.value("repository", "").toString();
}
if (version.isEmpty()) {
@@ -706,7 +719,7 @@ bool InstallationManager::install(const QString &fileName, GuessedValue<QString> if (installResult == IPluginInstaller::RESULT_SUCCESS) {
mapToArchive(filesTree.data());
// the simple installer only prepares the installation, the rest works the same for all installers
- if (!doInstall(modName, modID, version, newestVersion, categoryID)) {
+ if (!doInstall(modName, modID, version, newestVersion, categoryID, repository)) {
installResult = IPluginInstaller::RESULT_FAILED;
}
}
@@ -721,6 +734,11 @@ bool InstallationManager::install(const QString &fileName, GuessedValue<QString> std::set<QString> installerExtensions = installerCustom->supportedExtensions();
if (installerExtensions.find(fileInfo.suffix()) != installerExtensions.end()) {
installResult = installerCustom->install(modName, fileName, version, modID);
+ unsigned int idx = ModInfo::getIndex(modName);
+ if (idx != UINT_MAX) {
+ ModInfo::Ptr info = ModInfo::getByIndex(idx);
+ info->setRepository(repository);
+ }
}
}
}
|
