From 39210af3e59c929cba6de2d39ef1c32835f6388b Mon Sep 17 00:00:00 2001 From: Mikaƫl Capelle Date: Thu, 29 May 2025 11:04:36 +0200 Subject: Move to VCPKG (#2068) * Remove SConscript related files. * Force-load translations from uibase and gamebryo/creation. * Bring githubpp here and add a standalone preset. * Switch VersionInfo -> Version for ModOrganizer2. (#2063) * Add pre-commit hook. * Use 7zip build from VCPKG registry. * Use archive.dll from the bin folder instead of dlls. --- src/shared/util.cpp | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) (limited to 'src/shared/util.cpp') diff --git a/src/shared/util.cpp b/src/shared/util.cpp index f17c21b9..0d9788a2 100644 --- a/src/shared/util.cpp +++ b/src/shared/util.cpp @@ -21,7 +21,7 @@ along with Mod Organizer. If not, see . #include "../env.h" #include "../mainwindow.h" #include "windows_error.h" -#include +#include #include #include @@ -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() -- cgit v1.3.1