From 51717edaaa09bfbe83ab09d6b5ca355c059f6b4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mika=C3=ABl=20Capelle?= Date: Sun, 30 Jun 2024 15:18:45 +0200 Subject: [PATCH] Switch VersionInfo -> Version for ModOrganizer2. --- src/env.cpp | 2 +- src/mainwindow.cpp | 15 ++-- src/moapplication.cpp | 4 +- src/modinfo.h | 2 +- src/nexusinterface.cpp | 3 +- src/nexusinterface.h | 1 - src/organizer_en.ts | 149 +++++++++++++++++----------------- src/organizercore.cpp | 2 +- src/organizercore.h | 46 ++++++----- src/organizerproxy.cpp | 46 ++++++++++- src/organizerproxy.h | 112 +++++++++++++------------ src/selfupdater.cpp | 17 ++-- src/selfupdater.h | 10 +-- src/settingsdialoggeneral.cpp | 2 +- src/shared/util.cpp | 34 +++++--- src/shared/util.h | 7 +- 16 files changed, 251 insertions(+), 201 deletions(-) diff --git a/src/env.cpp b/src/env.cpp index 9e67ef884..5dab489ed 100644 --- a/src/env.cpp +++ b/src/env.cpp @@ -1081,7 +1081,7 @@ std::wstring safeVersion() { try { // this can throw - return MOShared::createVersionInfo().displayString(3).toStdWString() + L"-"; + return MOShared::createVersionInfo().string().toStdWString() + L"-"; } catch (...) { return {}; } diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 0fc01eb5c..8156f69c0 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -648,7 +648,7 @@ void MainWindow::updateWindowTitle(const APIUserAccount& user) //"\xe2\x80\x93" is an "em dash", a longer "-" QString title = QString("%1 \xe2\x80\x93 Mod Organizer v%2") .arg(m_OrganizerCore.managedGame()->displayGameName(), - m_OrganizerCore.getVersion().displayString(3)); + m_OrganizerCore.getVersion().string()); if (!user.name().isEmpty()) { const QString premium = (user.type() == APIUserAccountTypes::Premium ? "*" : ""); @@ -1051,7 +1051,7 @@ void MainWindow::checkForProblemsImpl() void MainWindow::about() { - AboutDialog(m_OrganizerCore.getVersion().displayString(3), this).exec(); + AboutDialog(m_OrganizerCore.getVersion().string(), this).exec(); } void MainWindow::createEndorseMenu() @@ -2175,8 +2175,9 @@ void MainWindow::processUpdates() auto& settings = m_OrganizerCore.settings(); const auto earliest = QVersionNumber::fromString("2.1.2").normalized(); - const auto lastVersion = settings.version().value_or(earliest); - const auto currentVersion = m_OrganizerCore.getVersion().asQVersionNumber(); + const auto lastVersion = settings.version().value_or(earliest); + const auto currentVersion = + QVersionNumber::fromString(m_OrganizerCore.getVersion().string()).normalized(); m_LastVersion = lastVersion; @@ -2979,8 +2980,7 @@ void MainWindow::actionEndorseMO() QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) { NexusInterface::instance().requestToggleEndorsement( game->gameShortName(), game->nexusModOrganizerID(), - m_OrganizerCore.getVersion().canonicalString(), true, this, QVariant(), - QString()); + m_OrganizerCore.getVersion().string(), true, this, QVariant(), QString()); } } @@ -3001,8 +3001,7 @@ void MainWindow::actionWontEndorseMO() QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) { NexusInterface::instance().requestToggleEndorsement( game->gameShortName(), game->nexusModOrganizerID(), - m_OrganizerCore.getVersion().canonicalString(), false, this, QVariant(), - QString()); + m_OrganizerCore.getVersion().string(), false, this, QVariant(), QString()); } } diff --git a/src/moapplication.cpp b/src/moapplication.cpp index e131d3d96..3fb0fadf4 100644 --- a/src/moapplication.cpp +++ b/src/moapplication.cpp @@ -202,8 +202,8 @@ int MOApplication::setup(MOMultiProcess& multiProcess, bool forceSelect) log::debug("command line: '{}'", QString::fromWCharArray(GetCommandLineW())); log::info("starting Mod Organizer version {} revision {} in {}, usvfs: {}", - createVersionInfo().displayString(3), GITID, - QCoreApplication::applicationDirPath(), MOShared::getUsvfsVersionString()); + createVersionInfo().string(), GITID, QCoreApplication::applicationDirPath(), + MOShared::getUsvfsVersionString()); if (multiProcess.secondary()) { log::debug("another instance of MO is running but --multiple was given"); diff --git a/src/modinfo.h b/src/modinfo.h index d9e87ae05..bbb1aae3c 100644 --- a/src/modinfo.h +++ b/src/modinfo.h @@ -732,7 +732,7 @@ class ModInfo : public QObject, public MOBase::IModInterface * * @note Currently, this changes the color of the cell under the "Notes" column. */ - virtual void setColor(QColor color) {} + virtual void setColor([[maybe_unused]] QColor color) {} /** * @brief Adds the information that a file has been installed into this mod. diff --git a/src/nexusinterface.cpp b/src/nexusinterface.cpp index 6a39128f4..2516a5ada 100644 --- a/src/nexusinterface.cpp +++ b/src/nexusinterface.cpp @@ -274,9 +274,8 @@ NexusInterface::NexusInterface(Settings* s) : m_PluginContainer(nullptr) g_instance = this; m_User.limits(defaultAPILimits()); - m_MOVersion = createVersionInfo(); - m_AccessManager = new NXMAccessManager(this, s, m_MOVersion.displayString(3)); + m_AccessManager = new NXMAccessManager(this, s, createVersionInfo().string()); m_DiskCache = new QNetworkDiskCache(this); diff --git a/src/nexusinterface.h b/src/nexusinterface.h index 5fab222f1..f6efef1d9 100644 --- a/src/nexusinterface.h +++ b/src/nexusinterface.h @@ -681,7 +681,6 @@ private slots: NXMAccessManager* m_AccessManager; std::list m_ActiveRequest; QQueue m_RequestQueue; - MOBase::VersionInfo m_MOVersion; PluginContainer* m_PluginContainer; APIUserAccount m_User; }; diff --git a/src/organizer_en.ts b/src/organizer_en.ts index 9464b47b0..643e09ebc 100644 --- a/src/organizer_en.ts +++ b/src/organizer_en.ts @@ -3003,7 +3003,7 @@ This is likely due to a corrupted or incompatible download or unrecognized archi - + Sort the plugins using LOOT. @@ -3395,7 +3395,7 @@ This is likely due to a corrupted or incompatible download or unrecognized archi - + Endorse Mod Organizer @@ -3712,112 +3712,112 @@ As a final option, you can disable Nexus category mapping altogether, which can - + Notice: Your current MO version (%1) is lower than the previously used one (%2). The GUI may not downgrade gracefully, so you may experience oddities. However, there should be no serious issues. - + failed to change origin name: %1 - + failed to move "%1" from mod "%2" to "%3": %4 - + Open Game folder - + Open MyGames folder - + Open INIs folder - + Open Instance folder - + Open Mods folder - + Open Profile folder - + Open Downloads folder - + Open MO2 Install folder - + Open MO2 Plugins folder - + Open MO2 Stylesheets folder - + Open MO2 Logs folder - + Restart Mod Organizer - + Mod Organizer must restart to finish configuration changes - + Restart - + Continue - + Some things might be weird. - + Can't change download directory while downloads are in progress! - + Update available - + Do you want to endorse Mod Organizer on %1 now? @@ -3833,140 +3833,140 @@ You will have to visit the mod page on the %1 Nexus site to change your mind. - + Thank you for endorsing MO2! :) - + Please reconsider endorsing MO2 on Nexus! - + There is no supported sort mechanism for this game. You will probably have to use a third-party tool. - + None of your %1 mods appear to have had recent file updates. - + All of your mods have been checked recently. We restrict update checks to help preserve your available API requests. - + Thank you! - + Thank you for your endorsement! - + Mod ID %1 no longer seems to be available on Nexus. - + Error %1: Request to Nexus failed: %2 - - + + failed to read %1: %2 - + Error - + failed to extract %1 (errorcode %2) - + Extract BSA - + This archive contains invalid hashes. Some files may be broken. - + Extract... - + Remove '%1' from the toolbar - + Backup of load order created - + Choose backup to restore - + No Backups - + There are no backups to restore - - + + Restore failed - - + + Failed to restore the backup. Errorcode: %1 - + Backup of mod list created - + A file with the same name has already been downloaded. What would you like to do? - + Overwrite - + Rename new file - + Ignore file @@ -5510,32 +5510,32 @@ Please enter a name: NexusInterface - + Please pick the mod ID for "%1" - + You must authorize MO2 in Settings -> Nexus to use the Nexus API. - + You've exceeded the Nexus API rate limit and requests are now being throttled. Your next batch of requests will be available in approximately %1 minutes and %2 seconds. - + Aborting download: Either you clicked on a premium-only link and your account is not premium, or the download link was generated by a different account than the one stored in Mod Organizer. - + empty response - + invalid response @@ -6270,7 +6270,6 @@ Continue? <table cellspacing="6"><tr><th>Type</th><th>Active </th><th>Total</th></tr><tr><td>All plugins:</td><td align=right>%1 </td><td align=right>%2</td></tr><tr><td>ESMs:</td><td align=right>%3 </td><td align=right>%4</td></tr><tr><td>ESPs:</td><td align=right>%7 </td><td align=right>%8</td></tr><tr><td>ESMs+ESPs:</td><td align=right>%9 </td><td align=right>%10</td></tr><tr><td>ESHs:</td><td align=right>%11 </td><td align=right>%12</td></tr><tr><td>ESLs:</td><td align=right>%5 </td><td align=right>%6</td></tr></table> - <table cellspacing="6"><tr><th>Type</th><th>Active </th><th>Total</th></tr><tr><td>All plugins:</td><td align=right>%1 </td><td align=right>%2</td></tr><tr><td>ESMs:</td><td align=right>%3 </td><td align=right>%4</td></tr><tr><td>ESPs:</td><td align=right>%7 </td><td align=right>%8</td></tr><tr><td>ESMs+ESPs:</td><td align=right>%9 </td><td align=right>%10</td></tr><tr><td>ESLs:</td><td align=right>%5 </td><td align=right>%6</td></tr><tr><td>Overlay:</td><td align=right>%11 </td><td align=right>%12</td></tr></table> @@ -7363,7 +7362,7 @@ Destination: - + <Manage...> @@ -8215,42 +8214,42 @@ p, li { white-space: pre-wrap; } SelfUpdater - + Download failed - + Failed to find correct download, please try again later. - + Update - + Download in progress - + Download failed: %1 - + Failed to install update: %1 - + Failed to start %1: %2 - + Error @@ -9029,6 +9028,11 @@ p, li { white-space: pre-wrap; } + + + Back-date BSAs + + Add executables to the blacklist to prevent them from @@ -9048,11 +9052,6 @@ programs you are intentionally running. Executables Blacklist - - - Back-date BSAs - - diff --git a/src/organizercore.cpp b/src/organizercore.cpp index a8926dc65..88166c8e6 100644 --- a/src/organizercore.cpp +++ b/src/organizercore.cpp @@ -646,7 +646,7 @@ QString OrganizerCore::modsPath() const return QDir::fromNativeSeparators(m_Settings.paths().mods()); } -MOBase::VersionInfo OrganizerCore::appVersion() const +MOBase::Version OrganizerCore::version() const { return m_Updater.getVersion(); } diff --git a/src/organizercore.h b/src/organizercore.h index 923adc12d..fe80da240 100644 --- a/src/organizercore.h +++ b/src/organizercore.h @@ -1,14 +1,32 @@ #ifndef ORGANIZERCORE_H #define ORGANIZERCORE_H +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + #include "downloadmanager.h" #include "envdump.h" -#include "executableinfo.h" #include "executableslist.h" -#include "guessedvalue.h" #include "installationmanager.h" -#include "memoizedlock.h" -#include "moddatacontent.h" #include "modinfo.h" #include "modlist.h" #include "moshortcut.h" @@ -18,22 +36,6 @@ #include "settings.h" #include "uilocker.h" #include "usvfsconnector.h" -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include class ModListSortProxy; class PluginListSortProxy; @@ -270,7 +272,7 @@ class OrganizerCore : public QObject, public MOBase::IPluginDiagnose std::vector enabledArchives(); - MOBase::VersionInfo getVersion() const { return m_Updater.getVersion(); } + MOBase::Version getVersion() const { return m_Updater.getVersion(); } // return the plugin container // @@ -358,7 +360,7 @@ class OrganizerCore : public QObject, public MOBase::IPluginDiagnose QString overwritePath() const; QString basePath() const; QString modsPath() const; - MOBase::VersionInfo appVersion() const; + MOBase::Version version() const; MOBase::IPluginGame* getGame(const QString& gameName) const; MOBase::IModInterface* createMod(MOBase::GuessedValue& name); void modDataChanged(MOBase::IModInterface* mod); diff --git a/src/organizerproxy.cpp b/src/organizerproxy.cpp index 6edbdbab7..22a8a0234 100644 --- a/src/organizerproxy.cpp +++ b/src/organizerproxy.cpp @@ -114,9 +114,53 @@ QString OrganizerProxy::modsPath() const return m_Proxied->modsPath(); } +Version OrganizerProxy::version() const +{ + return m_Proxied->version(); +} + VersionInfo OrganizerProxy::appVersion() const { - return m_Proxied->appVersion(); + const auto version = m_Proxied->version(); + const int major = version.major(), minor = version.minor(), + subminor = version.patch(); + int subsubminor = 0; + VersionInfo::ReleaseType infoReleaseType = VersionInfo::RELEASE_FINAL; + + // make a copy + auto prereleases = version.preReleases(); + + if (!prereleases.empty()) { + // check if the first pre-release entry is a number + if (prereleases.front().index() == 0) { + subsubminor = std::get(prereleases.front()); + prereleases.erase(prereleases.begin()); + } + + if (!prereleases.empty()) { + const auto releaseType = std::get(prereleases.front()); + switch (releaseType) { + case Version::Development: + infoReleaseType = VersionInfo::RELEASE_PREALPHA; + break; + case Version::Alpha: + infoReleaseType = VersionInfo::RELEASE_ALPHA; + break; + case Version::Beta: + infoReleaseType = VersionInfo::RELEASE_BETA; + break; + case Version::ReleaseCandidate: + infoReleaseType = VersionInfo::RELEASE_CANDIDATE; + break; + default: + infoReleaseType = VersionInfo::RELEASE_PREALPHA; + } + } + + // there is no way to differentiate two pre-releases? + } + + return VersionInfo(major, minor, subminor, subsubminor, infoReleaseType); } IPluginGame* OrganizerProxy::getGame(const QString& gameName) const diff --git a/src/organizerproxy.h b/src/organizerproxy.h index fbae7cde6..2c70cb2c3 100644 --- a/src/organizerproxy.h +++ b/src/organizerproxy.h @@ -29,69 +29,67 @@ class OrganizerProxy : public MOBase::IOrganizer MOBase::IPlugin* plugin() const { return m_Plugin; } public: // IOrganizer interface - virtual MOBase::IModRepositoryBridge* createNexusBridge() const; - virtual QString profileName() const; - virtual QString profilePath() const; - virtual QString downloadsPath() const; - virtual QString overwritePath() const; - virtual QString basePath() const; - virtual QString modsPath() const; - virtual MOBase::VersionInfo appVersion() const; - virtual MOBase::IPluginGame* getGame(const QString& gameName) const; - virtual MOBase::IModInterface* createMod(MOBase::GuessedValue& name); - virtual void modDataChanged(MOBase::IModInterface* mod); - virtual QVariant persistent(const QString& pluginName, const QString& key, - const QVariant& def = QVariant()) const; - virtual void setPersistent(const QString& pluginName, const QString& key, - const QVariant& value, bool sync = true); - virtual QString pluginDataPath() const; - virtual MOBase::IModInterface* installMod(const QString& fileName, - const QString& nameSuggestion = QString()); - virtual QString resolvePath(const QString& fileName) const; - virtual QStringList listDirectories(const QString& directoryName) const; - virtual QStringList + MOBase::IModRepositoryBridge* createNexusBridge() const override; + QString profileName() const override; + QString profilePath() const override; + QString downloadsPath() const override; + QString overwritePath() const override; + QString basePath() const override; + QString modsPath() const override; + MOBase::Version version() const override; + MOBase::VersionInfo appVersion() const override; + MOBase::IPluginGame* getGame(const QString& gameName) const override; + MOBase::IModInterface* createMod(MOBase::GuessedValue& name) override; + void modDataChanged(MOBase::IModInterface* mod) override; + QVariant persistent(const QString& pluginName, const QString& key, + const QVariant& def = QVariant()) const override; + void setPersistent(const QString& pluginName, const QString& key, + const QVariant& value, bool sync = true) override; + QString pluginDataPath() const override; + MOBase::IModInterface* installMod(const QString& fileName, + const QString& nameSuggestion = QString()); + QString resolvePath(const QString& fileName) const override; + QStringList listDirectories(const QString& directoryName) const override; + QStringList findFiles(const QString& path, const std::function& filter) const override; - virtual QStringList findFiles(const QString& path, - const QStringList& globFilters) const override; - virtual QStringList getFileOrigins(const QString& fileName) const override; - virtual QList + QStringList findFiles(const QString& path, + const QStringList& globFilters) const override; + QStringList getFileOrigins(const QString& fileName) const override; + QList findFileInfos(const QString& path, const std::function& filter) const override; - virtual std::shared_ptr virtualFileTree() const override; - - virtual MOBase::IDownloadManager* downloadManager() const override; - virtual MOBase::IPluginList* pluginList() const override; - virtual MOBase::IModList* modList() const override; - virtual MOBase::IProfile* profile() const override; - virtual MOBase::IGameFeatures* gameFeatures() const override; - - virtual HANDLE startApplication(const QString& executable, - const QStringList& args = QStringList(), - const QString& cwd = "", const QString& profile = "", - const QString& forcedCustomOverwrite = "", - bool ignoreCustomOverwrite = false); - virtual bool waitForApplication(HANDLE handle, bool refresh = true, - LPDWORD exitCode = nullptr) const; - virtual void refresh(bool saveChanges); - - virtual bool onAboutToRun(const std::function& func) override; - virtual bool onAboutToRun(const std::function& func) override; - virtual bool + std::shared_ptr virtualFileTree() const override; + + MOBase::IDownloadManager* downloadManager() const override; + MOBase::IPluginList* pluginList() const override; + MOBase::IModList* modList() const override; + MOBase::IProfile* profile() const override; + MOBase::IGameFeatures* gameFeatures() const override; + + HANDLE startApplication(const QString& executable, + const QStringList& args = QStringList(), + const QString& cwd = "", const QString& profile = "", + const QString& forcedCustomOverwrite = "", + bool ignoreCustomOverwrite = false) override; + bool waitForApplication(HANDLE handle, bool refresh = true, + LPDWORD exitCode = nullptr) const override; + void refresh(bool saveChanges) override; + + bool onAboutToRun(const std::function& func) override; + bool onAboutToRun(const std::function& func) override; + bool onFinishedRun(const std::function& func) override; - virtual bool + bool onUserInterfaceInitialized(std::function const& func) override; - virtual bool onNextRefresh(const std::function& func, - bool immediateIfPossible) override; - virtual bool - onProfileCreated(std::function const& func) override; - virtual bool onProfileRenamed( - std::function const& - func) override; - virtual bool - onProfileRemoved(std::function const& func) override; - virtual bool onProfileChanged( + bool onNextRefresh(const std::function& func, + bool immediateIfPossible) override; + bool onProfileCreated(std::function const& func) override; + bool onProfileRenamed(std::function const& func) override; + bool onProfileRemoved(std::function const& func) override; + bool onProfileChanged( std::function const& func) override; // Plugin related: diff --git a/src/selfupdater.cpp b/src/selfupdater.cpp index 7762c9004..43992e707 100644 --- a/src/selfupdater.cpp +++ b/src/selfupdater.cpp @@ -69,10 +69,9 @@ using namespace MOBase; using namespace MOShared; SelfUpdater::SelfUpdater(NexusInterface* nexusInterface) - : m_Parent(nullptr), m_Interface(nexusInterface), m_Reply(nullptr), m_Attempts(3) -{ - m_MOVersion = createVersionInfo(); -} + : m_Parent(nullptr), m_MOVersion(createVersionInfo()), m_Interface(nexusInterface), + m_Reply(nullptr), m_Attempts(3) +{} SelfUpdater::~SelfUpdater() {} @@ -115,7 +114,8 @@ void SelfUpdater::testForUpdate(const Settings& settings) QJsonObject release = releaseVal.toObject(); if (!release["draft"].toBool() && (Settings::instance().usePrereleases() || !release["prerelease"].toBool())) { - auto version = VersionInfo(release["tag_name"].toString()); + auto version = Version::parse(release["tag_name"].toString(), + Version::ParseMode::MO2); mreleases[version] = release; } } @@ -132,14 +132,13 @@ void SelfUpdater::testForUpdate(const Settings& settings) m_UpdateCandidates.insert(p); } } - log::info("update available: {} -> {}", - this->m_MOVersion.displayString(3), lastKey.displayString(3)); + log::info("update available: {} -> {}", this->m_MOVersion, lastKey); emit updateAvailable(); } else if (lastKey < this->m_MOVersion) { // this could happen if the user switches from using prereleases to // stable builds. Should we downgrade? log::debug("This version is newer than the latest released one: {} -> {}", - this->m_MOVersion.displayString(3), lastKey.displayString(3)); + this->m_MOVersion, lastKey); } } }); @@ -158,7 +157,7 @@ void SelfUpdater::startUpdate() auto latestRelease = m_UpdateCandidates.begin()->second; UpdateDialog dialog(m_Parent); - dialog.setVersions(MOShared::createVersionInfo().displayString(3), + dialog.setVersions(MOShared::createVersionInfo().string(), latestRelease["tag_name"].toString()); // We concatenate release details. We only include pre-release if those are diff --git a/src/selfupdater.h b/src/selfupdater.h index 612e70238..b39340849 100644 --- a/src/selfupdater.h +++ b/src/selfupdater.h @@ -22,8 +22,6 @@ along with Mod Organizer. If not, see . #include -#include - class Archive; class NexusInterface; class PluginContainer; @@ -42,6 +40,8 @@ class QNetworkReply; class QProgressDialog; class Settings; +#include + #include "github.h" /** @@ -99,7 +99,7 @@ class SelfUpdater : public QObject /** * @return current version of Mod Organizer **/ - MOBase::VersionInfo getVersion() const { return m_MOVersion; } + MOBase::Version getVersion() const { return m_MOVersion; } signals: @@ -135,7 +135,7 @@ private slots: private: QWidget* m_Parent; - MOBase::VersionInfo m_MOVersion; + MOBase::Version m_MOVersion; NexusInterface* m_Interface; QFile m_UpdateFile; QNetworkReply* m_Reply; @@ -147,7 +147,7 @@ private slots: // Map from version to release, in decreasing order (first element is the latest // release): - using CandidatesMap = std::map>; + using CandidatesMap = std::map>; CandidatesMap m_UpdateCandidates; }; diff --git a/src/settingsdialoggeneral.cpp b/src/settingsdialoggeneral.cpp index 7acaa190b..265c9db90 100644 --- a/src/settingsdialoggeneral.cpp +++ b/src/settingsdialoggeneral.cpp @@ -111,7 +111,7 @@ void GeneralSettingsTab::addLanguages() QString languageString = QString("%1 (%2)") .arg(locale.nativeLanguageName()) - .arg(locale.nativeCountryName()); + .arg(locale.nativeTerritoryName()); if (locale.language() == QLocale::Chinese) { if (languageCode == "zh_TW") { diff --git a/src/shared/util.cpp b/src/shared/util.cpp index d3c6e2011..0d9788a29 100644 --- a/src/shared/util.cpp +++ b/src/shared/util.cpp @@ -208,10 +208,12 @@ std::wstring GetFileVersionString(const std::wstring& fileName) } } -VersionInfo createVersionInfo() +Version createVersionInfo() { VS_FIXEDFILEINFO version = GetFileVersion(env::thisProcessPath().native()); + std::optional releaseType; + if (version.dwFileFlags & VS_FF_PRERELEASE) { // Pre-release builds need annotating QString versionString = @@ -227,21 +229,29 @@ VersionInfo createVersionInfo() } } + if (!noLetters) { + // trust the string to make sense + return Version::parse(versionString, Version::ParseMode::MO2); + } + if (noLetters) { - // Default to pre-alpha when release type is unspecified - return VersionInfo( - version.dwFileVersionMS >> 16, version.dwFileVersionMS & 0xFFFF, - version.dwFileVersionLS >> 16, version.dwFileVersionLS & 0xFFFF, - VersionInfo::RELEASE_PREALPHA); + // default to development when release type is unspecified + releaseType = Version::Development; } else { - // Trust the string to make sense - return VersionInfo(versionString); } - } else { - // Non-pre-release builds just need their version numbers reading - return VersionInfo(version.dwFileVersionMS >> 16, version.dwFileVersionMS & 0xFFFF, - version.dwFileVersionLS >> 16, version.dwFileVersionLS & 0xFFFF); } + + const int major = version.dwFileVersionMS >> 16, + minor = version.dwFileVersionMS & 0xFFFF, + patch = version.dwFileVersionLS >> 16, + subpatch = version.dwFileVersionLS & 0xFFFF; + + std::vector> prereleases; + if (releaseType) { + prereleases.push_back(*releaseType); + } + + return Version(major, minor, patch, subpatch, std::move(prereleases)); } QString getUsvfsDLLVersion() diff --git a/src/shared/util.h b/src/shared/util.h index 1bc6bd47a..4764643e1 100644 --- a/src/shared/util.h +++ b/src/shared/util.h @@ -21,9 +21,10 @@ along with Mod Organizer. If not, see . #define UTIL_H #include -#include #include -#include + +#include +#include class Executable; @@ -48,7 +49,7 @@ std::wstring ToLowerCopy(std::wstring_view text); bool CaseInsensitiveEqual(const std::wstring& lhs, const std::wstring& rhs); -MOBase::VersionInfo createVersionInfo(); +MOBase::Version createVersionInfo(); QString getUsvfsVersionString(); void SetThisThreadName(const QString& s);