diff options
| -rw-r--r-- | src/installationmanager.cpp | 8 | ||||
| -rw-r--r-- | src/mainwindow.cpp | 8 | ||||
| -rw-r--r-- | src/modinfo.cpp | 23 | ||||
| -rw-r--r-- | src/modinfo.h | 14 |
4 files changed, 53 insertions, 0 deletions
diff --git a/src/installationmanager.cpp b/src/installationmanager.cpp index d6435e57..25866cb9 100644 --- a/src/installationmanager.cpp +++ b/src/installationmanager.cpp @@ -568,6 +568,14 @@ bool InstallationManager::doInstall(GuessedValue<QString> &modName, int modID, }
settingsFile.setValue("installationFile", m_CurrentFile);
+ 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;
}
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 101c8f81..809da989 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -2446,6 +2446,12 @@ IModInterface *MainWindow::createMod(GuessedValue<QString> &name) settingsFile.setValue("newestVersion", ""); settingsFile.setValue("category", 0); settingsFile.setValue("installationFile", ""); + + if (!merge) { + settingsFile.beginWriteArray("installedFiles", 0); + settingsFile.endArray(); + } + return ModInfo::createFrom(QDir(targetDirectory), &m_DirectoryStructure).data(); } @@ -4371,6 +4377,7 @@ void MainWindow::installDownload(int index) try { QString fileName = m_DownloadManager.getFilePath(index); int modID = m_DownloadManager.getModID(index); + int fileID = m_DownloadManager.getFileInfo(index)->fileID; GuessedValue<QString> modName; // see if there already are mods with the specified mod id @@ -4400,6 +4407,7 @@ void MainWindow::installDownload(int index) int modIndex = ModInfo::getIndex(modName); if (modIndex != UINT_MAX) { ModInfo::Ptr modInfo = ModInfo::getByIndex(modIndex); + modInfo->addInstalledFile(modID, fileID); if (hasIniTweaks && (QMessageBox::question(this, tr("Configure Mod"), diff --git a/src/modinfo.cpp b/src/modinfo.cpp index de103cb0..28a906fa 100644 --- a/src/modinfo.cpp +++ b/src/modinfo.cpp @@ -525,6 +525,13 @@ void ModInfoRegular::readMeta() } } + int numFiles = metaFile.beginReadArray("installedFiles"); + for (int i = 0; i < numFiles; ++i) { + metaFile.setArrayIndex(i); + m_InstalledFileIDs.insert(std::make_pair(metaFile.value("modid").toInt(), metaFile.value("fileid").toInt())); + } + metaFile.endArray(); + m_MetaInfoChanged = false; } @@ -547,6 +554,16 @@ void ModInfoRegular::saveMeta() if (m_EndorsedState != ENDORSED_UNKNOWN) { metaFile.setValue("endorsed", m_EndorsedState); } + + metaFile.beginWriteArray("installedFiles"); + int idx = 0; + for (auto iter = m_InstalledFileIDs.begin(); iter != m_InstalledFileIDs.end(); ++iter) { + metaFile.setArrayIndex(idx++); + metaFile.setValue("modid", iter->first); + metaFile.setValue("fileid", iter->second); + } + metaFile.endArray(); + metaFile.sync(); // sync needs to be called to ensure the file is created if (metaFile.status() == QSettings::NoError) { @@ -882,6 +899,12 @@ QStringList ModInfoRegular::archives() const return result; } +void ModInfoRegular::addInstalledFile(int modId, int fileId) +{ + m_InstalledFileIDs.insert(std::make_pair(modId, fileId)); + m_MetaInfoChanged = true; +} + std::vector<QString> ModInfoRegular::getIniTweaks() const { QString metaFileName = absolutePath().append("/meta.ini"); diff --git a/src/modinfo.h b/src/modinfo.h index a9da3897..4d70d22d 100644 --- a/src/modinfo.h +++ b/src/modinfo.h @@ -446,6 +446,13 @@ public: virtual QStringList archives() const = 0;
/**
+ * @brief adds the information that a file has been installed into this mod
+ * @param modId id of the mod installed
+ * @param fileId id of the file installed
+ */
+ virtual void addInstalledFile(int modId, int fileId) = 0;
+
+ /**
* @brief test if the mod belongs to the specified category
*
* @param categoryID the category to test for.
@@ -847,6 +854,8 @@ public: virtual QStringList archives() const;
+ virtual void addInstalledFile(int modId, int fileId);
+
/**
* @brief stores meta information back to disk
*/
@@ -876,6 +885,7 @@ private: QDateTime m_LastNexusQuery;
int m_NexusID;
+ std::set<std::pair<int, int>> m_InstalledFileIDs;
bool m_MetaInfoChanged;
MOBase::VersionInfo m_NewestVersion;
@@ -913,6 +923,8 @@ public: QList<MOBase::ModRepositoryFileInfo*>::const_iterator&) {}
virtual QString getNexusDescription() const { return QString(); }
+ virtual void addInstalledFile(int, int) {}
+
private:
ModInfoBackup(const QDir &path, MOShared::DirectoryEntry **directoryStructure);
@@ -962,6 +974,7 @@ public: virtual QDateTime getLastNexusQuery() const { return QDateTime(); }
virtual QString getNexusDescription() const { return QString(); }
virtual QStringList archives() const;
+ virtual void addInstalledFile(int, int) {}
private:
@@ -1022,6 +1035,7 @@ public: virtual QStringList archives() const { return m_Archives; }
virtual QStringList stealFiles() const { return m_Archives + QStringList(m_ReferenceFile); }
virtual bool alwaysEnabled() const { return true; }
+ virtual void addInstalledFile(int, int) {}
protected:
|
