summaryrefslogtreecommitdiff
path: root/src/shared/util.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/shared/util.cpp')
-rw-r--r--src/shared/util.cpp36
1 files changed, 23 insertions, 13 deletions
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 <http://www.gnu.org/licenses/>.
#include "../env.h"
#include "../mainwindow.h"
#include "windows_error.h"
-#include <log.h>
+#include <uibase/log.h>
#include <usvfs/usvfs.h>
#include <usvfs/usvfs_version.h>
@@ -208,10 +208,12 @@ std::wstring GetFileVersionString(const std::wstring& fileName)
}
}
-VersionInfo createVersionInfo()
+Version createVersionInfo()
{
VS_FIXEDFILEINFO version = GetFileVersion(env::thisProcessPath().native());
+ std::optional<Version::ReleaseType> 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<std::variant<int, Version::ReleaseType>> prereleases;
+ if (releaseType) {
+ prereleases.push_back(*releaseType);
+ }
+
+ return Version(major, minor, patch, subpatch, std::move(prereleases));
}
QString getUsvfsDLLVersion()