diff --git a/.gitignore b/.gitignore index fd67d9b..d8bb166 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ +version.hpp + ## Ignore Visual Studio temporary files, build results, and ## files generated by popular Visual Studio add-ons. ## diff --git a/GlosSIConfig/UIModel.cpp b/GlosSIConfig/UIModel.cpp index f75ac62..4f3190c 100644 --- a/GlosSIConfig/UIModel.cpp +++ b/GlosSIConfig/UIModel.cpp @@ -26,6 +26,8 @@ limitations under the License. #include #endif +#include "../version.hpp" + UIModel::UIModel() : QObject(nullptr) { auto path = std::filesystem::temp_directory_path() @@ -362,6 +364,11 @@ void UIModel::writeTarget(const QJsonObject& json, const QString& name) const file.close(); } +QString UIModel::getVersionString() const +{ + return QString(version::VERSION_STR); +} + std::filesystem::path UIModel::getSteamPath() const { try { diff --git a/GlosSIConfig/UIModel.h b/GlosSIConfig/UIModel.h index 4ec241a..5c35259 100644 --- a/GlosSIConfig/UIModel.h +++ b/GlosSIConfig/UIModel.h @@ -30,6 +30,9 @@ class UIModel : public QObject { Q_PROPERTY(bool foundSteam READ foundSteam CONSTANT) Q_PROPERTY(bool steamInputXboxSupportEnabled READ isSteamInputXboxSupportEnabled CONSTANT) + + Q_PROPERTY(QString versionString READ getVersionString CONSTANT) + public: UIModel(); @@ -84,6 +87,8 @@ class UIModel : public QObject { void writeTarget(const QJsonObject& json, const QString& name) const; + QString getVersionString() const; + std::filesystem::path getSteamPath() const; std::wstring getSteamUserId() const; bool foundSteam() const; diff --git a/GlosSIConfig/qml/main.qml b/GlosSIConfig/qml/main.qml index 3be4d08..a643ec5 100644 --- a/GlosSIConfig/qml/main.qml +++ b/GlosSIConfig/qml/main.qml @@ -258,6 +258,15 @@ Window { } } + Label { + id: versionInfo + anchors.bottom: parent.bottom + anchors.left: parent.left + anchors.margins: 8 + opacity: 0.5 + text: uiModel.versionString + } + AddSelectTypeDialog { id: selectTypeDialog visible: false diff --git a/version_help.ps1 b/version_help.ps1 index 83d14a3..8adf13d 100644 --- a/version_help.ps1 +++ b/version_help.ps1 @@ -10,6 +10,29 @@ $commatag = $commatag -replace "[A-z]","0" ((Get-Content -path ./Resource.rc -Raw) -replace '"FileVersion", ".*"', ('"FileVersion", "' + $tag + '"')) | Set-Content -Path ./Resource.rc ((Get-Content -path ./Resource.rc -Raw) -replace '"ProductVersion", ".*"', ('"ProductVersion", "' + $tag + '"')) | Set-Content -Path ./Resource.rc +$cleanTag = git describe --tags --abbrev=0 +$versionFileText = " +/* Autogenerated version info file */ +#pragma once + +namespace version { +inline const auto VERSION_STR = ""$tag""; +inline const auto IS_SNAPSHOT = $( If ($tag.Length -gt 10) {'true'} Else {'false'}); +inline const auto VERSION_MAJOR = $($cleanTag.Split('.')[0]); +inline const auto VERSION_MINOR = $($cleanTag.Split('.')[1]); +inline const auto VERSION_PATCH = $($cleanTag.Split('.')[2]); +inline const auto VERSION_REVISION = $($cleanTag.Split('.')[3]); +} + +" + +if (!(Test-Path '../version.hpp')) { + New-Item -Path ".." -Name "version.hpp" -ItemType "file" -Value $versionFileText +} else { + Set-Content -Path "../version.hpp" -Value $versionFileText +} + + if ((Test-Path '../Installer/Installer.nsi')) { ((Get-Content -path '../Installer/Installer.nsi' -Raw) -replace '!define VERSION ".*"', ('!define VERSION "' + $tag + '"')) | Set-Content -Path '../Installer/Installer.nsi' } \ No newline at end of file