diff options
| author | Jonathan Feenstra <26406078+JonathanFeenstra@users.noreply.github.com> | 2026-05-14 08:43:46 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-05-14 01:43:46 -0500 |
| commit | 22b169570140a0ec8f827471d9218f6461c7ac44 (patch) | |
| tree | 6405195013ccf8ece22dcf45892df38aefc9c127 | |
| parent | 3efaf7c9463261fb2d182a7ae00d9045a2b273b8 (diff) | |
Install manager metadata updates
* Fix missing author and uploader when installing mods
* Refactor doInstall parameters into a struct
| -rw-r--r-- | src/installationmanager.cpp | 55 | ||||
| -rw-r--r-- | src/installationmanager.h | 20 |
2 files changed, 47 insertions, 28 deletions
diff --git a/src/installationmanager.cpp b/src/installationmanager.cpp index 87c4681f..1158ae1a 100644 --- a/src/installationmanager.cpp +++ b/src/installationmanager.cpp @@ -480,28 +480,23 @@ bool InstallationManager::ensureValidModName(GuessedValue<QString>& name) const return true; } -InstallationResult InstallationManager::doInstall(GuessedValue<QString>& modName, - QString gameName, int modID, - const QString& version, - const QString& newestVersion, - int categoryID, int fileCategoryID, - const QString& repository) +InstallationResult InstallationManager::doInstall(ModInstallationInfo& info) { - if (!ensureValidModName(modName)) { + if (!ensureValidModName(info.modName)) { return {IPluginInstaller::RESULT_FAILED}; } // determine target directory - InstallationResult result = testOverwrite(modName); + InstallationResult result = testOverwrite(info.modName); if (!result) { return result; } const bool merge = result.merged(); - result.m_name = modName; + result.m_name = info.modName; - QString targetDirectory = QDir(m_ModsDirectory + "/" + modName).canonicalPath(); + QString targetDirectory = QDir(m_ModsDirectory + "/" + info.modName).canonicalPath(); QString targetDirectoryNative = QDir::toNativeSeparators(targetDirectory); log::debug("installing to \"{}\"", targetDirectoryNative); @@ -532,28 +527,31 @@ InstallationResult InstallationManager::doInstall(GuessedValue<QString>& modName // overwrite settings only if they are actually are available or haven't been set // before - if ((gameName != "") || !settingsFile.contains("gameName")) { - settingsFile.setValue("gameName", gameName); + if ((info.gameName != "") || !settingsFile.contains("gameName")) { + settingsFile.setValue("gameName", info.gameName); } - if ((modID != 0) || !settingsFile.contains("modid")) { - settingsFile.setValue("modid", modID); + if ((info.modID != 0) || !settingsFile.contains("modid")) { + settingsFile.setValue("modid", info.modID); } if (!settingsFile.contains("version") || - (!version.isEmpty() && - (!merge || (VersionInfo(version) >= + (!info.version.isEmpty() && + (!merge || (VersionInfo(info.version) >= VersionInfo(settingsFile.value("version").toString()))))) { - settingsFile.setValue("version", version); + settingsFile.setValue("version", info.version); } - if (!newestVersion.isEmpty() || !settingsFile.contains("newestVersion")) { - settingsFile.setValue("newestVersion", newestVersion); + if (!info.newestVersion.isEmpty() || !settingsFile.contains("newestVersion")) { + settingsFile.setValue("newestVersion", info.newestVersion); } // issue #51 used to overwrite the manually set categories if (!settingsFile.contains("category")) { - settingsFile.setValue("category", QString::number(categoryID)); + settingsFile.setValue("category", QString::number(info.categoryID)); } - settingsFile.setValue("nexusFileStatus", fileCategoryID); + settingsFile.setValue("nexusFileStatus", info.fileCategoryID); settingsFile.setValue("installationFile", m_CurrentFile); - settingsFile.setValue("repository", repository); + settingsFile.setValue("repository", info.repository); + settingsFile.setValue("author", info.author); + settingsFile.setValue("uploader", info.uploader); + settingsFile.setValue("uploaderUrl", info.uploaderUrl); if (!merge) { // this does not clear the list we have in memory but the mod is going to have to be @@ -650,6 +648,9 @@ InstallationResult InstallationManager::install(const QString& fileName, int categoryID = 0; int fileCategoryID = 1; QString repository = "Nexus"; + QString author = ""; + QString uploader = ""; + QString uploaderUrl = ""; QString metaName = fileName + ".meta"; if (QFile(metaName).exists()) { @@ -690,6 +691,9 @@ InstallationResult InstallationManager::install(const QString& fileName, } repository = metaFile.value("repository", "").toString(); fileCategoryID = metaFile.value("fileCategory", 1).toInt(); + author = metaFile.value("author", "").toString(); + uploader = metaFile.value("uploader", "").toString(); + uploaderUrl = metaFile.value("uploaderUrl", "").toString(); } if (version.isEmpty()) { @@ -807,8 +811,11 @@ InstallationResult InstallationManager::install(const QString& fileName, // the simple installer only prepares the installation, the rest // works the same for all installers - installResult = doInstall(modName, gameName, modID, version, newestVersion, - categoryID, fileCategoryID, repository); + ModInstallationInfo info{ + modName, gameName, modID, version, newestVersion, categoryID, + fileCategoryID, repository, author, uploader, uploaderUrl}; + + installResult = doInstall(info); } } } diff --git a/src/installationmanager.h b/src/installationmanager.h index e125bbe9..367a3c24 100644 --- a/src/installationmanager.h +++ b/src/installationmanager.h @@ -263,13 +263,25 @@ public: QString generateBackupName(const QString& directoryName) const; private: + struct ModInstallationInfo + { + MOBase::GuessedValue<QString> modName; + const QString gameName; + const int modID; + const QString version; + const QString newestVersion; + const int categoryID; + const int fileCategoryID; + const QString repository; + const QString author; + const QString uploader; + const QString uploaderUrl; + }; + // actually perform the installation (write files to the disk, etc.), returns the // installation result // - InstallationResult doInstall(MOBase::GuessedValue<QString>& modName, QString gameName, - int modID, const QString& version, - const QString& newestVersion, int categoryID, - int fileCategoryID, const QString& repository); + InstallationResult doInstall(ModInstallationInfo& info); /** * @brief Clean the list of created files by removing all entries that are not |
