From 1ede1a813d441b61ae241d6423ecaa32cc94d363 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/nexusinterface.cpp | 3 +- src/nexusinterface.h | 1 - src/organizer_en.ts | 429 ++++++++++++++++++++++++----------------- src/organizercore.cpp | 2 +- src/organizercore.h | 6 +- src/organizerproxy.cpp | 46 ++++- src/organizerproxy.h | 112 ++++++----- src/selfupdater.cpp | 17 +- src/selfupdater.h | 8 +- src/shared/util.cpp | 37 ++-- src/shared/util.h | 4 +- 14 files changed, 403 insertions(+), 283 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 b14a14a1b..add4b9fbe 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; @@ -2973,8 +2974,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()); } } @@ -2995,8 +2995,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/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 362ccd892..2a0c5ae4d 100644 --- a/src/organizer_en.ts +++ b/src/organizer_en.ts @@ -2398,11 +2398,17 @@ Right now the only case I know of where this needs to be overwritten is for the + None + Missing ESHs + + + + Missing ESLs @@ -3261,7 +3267,7 @@ This is likely due to a corrupted or incompatible download or unrecognized archi - + Sort the plugins using LOOT. @@ -3653,7 +3659,7 @@ This is likely due to a corrupted or incompatible download or unrecognized archi - + Endorse Mod Organizer @@ -3970,112 +3976,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? @@ -4091,140 +4097,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 @@ -4662,22 +4668,22 @@ p, li { white-space: pre-wrap; } ModInfoForeign - + This pseudo mod represents content managed outside MO. It isn't modified by MO. - + DLC: - + Creation Club: - + Unmanaged: @@ -5768,32 +5774,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 @@ -5919,172 +5925,172 @@ Please enter a name: - + The selected profile '%1' does not exist. The profile '%2' will be used instead - + Installation cancelled - + Another installation is currently in progress. - + Installation successful - + Configure Mod - + This mod contains ini tweaks. Do you want to configure them now? - + mod not found: %1 - + Extraction cancelled - + The installation was cancelled while extracting files. If this was prior to a FOMOD setup, this warning may be ignored. However, if this was during installation, the mod will likely be missing files. - + file not found: %1 - + failed to generate preview for %1 - + Sorry - + Sorry, can't preview anything. This function currently does not support extracting from bsas. - + File '%1' not found. - + Failed to generate preview for %1 - + Failed to refresh list of esps: %1 - + Multiple esps/esls activated, please check that they don't conflict. - + You need to be logged in with Nexus - + Download? - + A download has been started but no installed page plugin recognizes it. If you download anyway no information (i.e. version) will be associated with the download. Continue? - - + + failed to update mod list: %1 - - + + login successful - + Login failed - + Login failed, try again? - + login failed: %1. Download will not be associated with an account - + login failed: %1 - + login failed: %1. You need to log-in with Nexus to update MO. - + MO1 "Script Extender" load mechanism has left hook.dll in your game folder - - + + Description missing - + <a href="%1">hook.dll</a> has been found in your game folder (right click to copy the full path). This is most likely a leftover of setting the ModOrganizer 1 load mechanism to "Script Extender", in which case you must remove this file either by changing the load mechanism in ModOrganizer 1 or manually removing the file, otherwise the game is likely to crash and burn. - + failed to save load order: %1 - + Error - + The designated write target "%1" is not enabled. @@ -6310,107 +6316,117 @@ Continue? - + Plugin not found: %1 - + Origin - + This plugin can't be disabled or moved (enforced by the game). - + This plugin can't be disabled (enforced by the game). - + Author - + Description - + Missing Masters - + Enabled Masters - + Loads Archives - + There are Archives connected to this plugin. Their assets will be added to your game, overwriting in case of conflicts following the plugin order. Loose files will always overwrite assets from Archives. (This flag only checks for Archives from the same mod as the plugin) - + Loads INI settings - + There is an ini file connected to this plugin. Its settings will be added to your game settings, overwriting in case of conflicts. - - This %1 is flagged as an ESL. It will adhere to the %1 load order but the records will be loaded in ESL space. + + This %1 is flagged as a light plugin (ESL). It will adhere to the %1 load order but the records will be loaded in ESL space (FE/FF). You can have up to 4096 light plugins in addition to other plugin types. - + + This ESM is flagged as a medium plugin (ESH). It adheres to the ESM load order but loads records in ESH space (FD). You can have 256 medium plugins in addition to other plugin types. + + + + + WARNING: This plugin is both light and medium flagged. This could indicate that the file was saved improperly and may have mismatched record references. Use it at your own risk. + + + + This is a dummy plugin. It contains no records and is typically used to load a paired archive file. - + Light plugins (ESL) are not supported by this game. - + This game does not currently permit custom plugin loading. There may be manual workarounds. - + Incompatible with %1 - + Depends on missing %1 - + Warning - + Error - + failed to restore load order for %1 @@ -6516,7 +6532,7 @@ Continue? PluginListView - <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> + <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> @@ -7230,7 +7246,7 @@ p, li { white-space: pre-wrap; } - + @@ -7449,22 +7465,22 @@ Destination: - + Cannot open instance '%1', failed to read INI file %2. - + Cannot open instance '%1', the managed game was not found in the INI file %2. Select the game managed by this instance. - + Cannot open instance '%1', the game plugin '%2' doesn't exist. It may have been deleted by an antivirus. Select another instance. - + Cannot open instance '%1', the game directory '%2' doesn't exist or the game plugin '%3' doesn't recognize it. Select the game managed by this instance. @@ -7611,7 +7627,7 @@ Destination: - + <Manage...> @@ -7764,12 +7780,12 @@ Destination: - + failed to access %1 - + failed to set file time %1 @@ -7822,19 +7838,19 @@ This program is known to cause issues with Mod Organizer, such as freezing or bl - - - + + + attempt to store setting for unknown plugin "%1" - + Failed - + Failed to start the helper application: %1 @@ -7989,12 +8005,12 @@ This program is known to cause issues with Mod Organizer, such as freezing or bl - + Executables Blacklist - + Enter one executable per line to be blacklisted from the virtual file system. Mods and other virtualized files will not be visible to these executables and any executables launched by them. @@ -8005,19 +8021,48 @@ Example: - - - + + Skip File Suffixes + + + + + Enter one file suffix per line to be skipped / ignored from the virtual file system. +Not to be confused with file extensions, file suffixes are simply how the filename ends. + +Example: + .txt - Would skip all files that end with .txt, <any text>.txt + some_file.txt - Would skip all files that end with some_file.txt, <any text>some_file.txt + + + + + Skip Directories + + + + + Enter one directory per line to be skipped / ignored from the virtual file system. + +Example: + .git + instructions + + + + + + Restart Mod Organizer - + Geometries will be reset to their default values. - + unexpected end of path @@ -8297,17 +8342,17 @@ You can restart Mod Organizer as administrator and try launching the program aga - + %1, #%2, Level %3, %4 - + failed to open %1 - + wrong file format - expected %1 got '%2' for %3 @@ -8322,7 +8367,7 @@ You can restart Mod Organizer as administrator and try launching the program aga - + invalid nxm-link: %1 @@ -8658,42 +8703,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 @@ -9465,6 +9510,20 @@ p, li { white-space: pre-wrap; } + + + For Skyrim, this can be used instead of Archive Invalidation. It should make AI redundant for all Profiles. + For the other games this is not a sufficient replacement for AI! + + + + + + Back-date BSAs + + + + Add executables to the blacklist to prevent them from accessing the virtual file system. This is useful to prevent unintended programs from being hooked. Hooking unintended @@ -9473,54 +9532,64 @@ programs you are intentionally running. - + Add executables to the blacklist to prevent them from accessing the virtual file system. This is useful to prevent unintended programs from being hooked. Hooking unintended programs may affect the execution of these programs or the programs you are intentionally running. - + Executables Blacklist - - - For Skyrim, this can be used instead of Archive Invalidation. It should make AI redundant for all Profiles. -For the other games this is not a sufficient replacement for AI! + + + Files to skip or ignore from the virtual file system. - - Back-date BSAs + + Skip File Suffixes + + + + + + Directories to skip or ignore from the virtual file system. + + + + + Skip Directories - + These are workarounds for problems with Mod Organizer. Please make sure you read the help text before changing anything here. - + Diagnostics - + Logs and Crashes - + Log Level - + Decides the amount of data printed to "ModOrganizer.log" - + Decides the amount of data printed to "ModOrganizer.log". "Debug" produces very useful information for finding problems. There is usually no noteworthy performance impact but the file may become rather large. If this is a problem you may prefer the "Info" level for regular use. On the "Error" level the log file usually remains empty. @@ -9528,17 +9597,17 @@ For the other games this is not a sufficient replacement for AI! - + Crash Dumps - + Decides which type of crash dumps are collected when injected processes crash. - + Decides which type of crash dumps are collected when injected processes crash. "None" Disables the generation of crash dumps by MO. @@ -9549,17 +9618,17 @@ For the other games this is not a sufficient replacement for AI! - + Max Dumps To Keep - + Maximum number of crash dumps to keep on disk. Use 0 for unlimited. - + Maximum number of crash dumps to keep on disk. Use 0 for unlimited. Set "Crash Dumps" above to None to disable crash dump collection. @@ -9567,22 +9636,22 @@ For the other games this is not a sufficient replacement for AI! - + Integrated LOOT - + LOOT Log Level - + Click a link to open the location - + Logs and crash dumps are stored under your current instance in the <a href="LOGS_FULL_PATH">LOGS_DIR</a> and <a href="DUMPS_FULL_PATH">DUMPS_DIR</a> folders. @@ -9839,7 +9908,7 @@ On Windows XP: UsvfsConnector - + Preparing vfs diff --git a/src/organizercore.cpp b/src/organizercore.cpp index f471ead19..15283bc13 100644 --- a/src/organizercore.cpp +++ b/src/organizercore.cpp @@ -644,7 +644,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..840fbcdda 100644 --- a/src/organizercore.h +++ b/src/organizercore.h @@ -23,7 +23,7 @@ #include #include #include -#include +#include #include #include @@ -270,7 +270,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 +358,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 cc68ad275..e514aa53b 100644 --- a/src/selfupdater.h +++ b/src/selfupdater.h @@ -23,7 +23,7 @@ along with Mod Organizer. If not, see . #include #include -#include +#include class Archive; class NexusInterface; @@ -98,7 +98,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: @@ -134,7 +134,7 @@ private slots: private: QWidget* m_Parent; - MOBase::VersionInfo m_MOVersion; + MOBase::Version m_MOVersion; NexusInterface* m_Interface; QFile m_UpdateFile; QNetworkReply* m_Reply; @@ -146,7 +146,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/shared/util.cpp b/src/shared/util.cpp index 55a76c235..bb4225d57 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,32 @@ 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 (subpatch) { + prereleases.push_back(subpatch); + } + if (releaseType) { + prereleases.push_back(*releaseType); + } + + return Version(major, minor, patch, std::move(prereleases)); } QString getUsvfsDLLVersion() diff --git a/src/shared/util.h b/src/shared/util.h index 1bc6bd47a..e39e53fdd 100644 --- a/src/shared/util.h +++ b/src/shared/util.h @@ -23,7 +23,7 @@ along with Mod Organizer. If not, see . #include #include #include -#include +#include class Executable; @@ -48,7 +48,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);