-
Notifications
You must be signed in to change notification settings - Fork 81
[GEN][ZH] Generate git version information and print it in the Game Window title, Options Menu (and Main Menu) #1219
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
3314261
87ea8e8
0f0352e
31a01c6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,6 +31,8 @@ | |
#include "GameClient/GameText.h" | ||
#include "Common/version.h" | ||
|
||
#include "gitinfo.h" | ||
|
||
Version *TheVersion = NULL; ///< The Version singleton | ||
|
||
Version::Version() | ||
|
@@ -39,8 +41,14 @@ Version::Version() | |
m_minor = 0; | ||
m_buildNum = 0; | ||
m_localBuildNum = 0; | ||
m_buildUser = AsciiString("somebody"); | ||
m_buildLocation = AsciiString("somewhere"); | ||
m_buildUser = "somebody"; | ||
m_buildLocation = "somewhere"; | ||
m_asciiGitRevision = buildAsciiGitRevision(); | ||
m_asciiGitVersion = buildAsciiGitVersion(); | ||
m_asciiGitCommitTime = buildAsciiGitCommitTime(); | ||
m_unicodeGitRevision = buildUnicodeGitRevision(); | ||
m_unicodeGitVersion = buildUnicodeGitVersion(); | ||
m_unicodeGitCommitTime = buildUnicodeGitCommitTime(); | ||
#if defined RTS_DEBUG || defined RTS_INTERNAL | ||
m_showFullVersion = TRUE; | ||
#else | ||
|
@@ -62,12 +70,12 @@ void Version::setVersion(Int major, Int minor, Int buildNum, | |
m_buildDate = buildDate; | ||
} | ||
|
||
UnsignedInt Version::getVersionNumber( void ) | ||
UnsignedInt Version::getVersionNumber( void ) const | ||
{ | ||
return m_major << 16 | m_minor; | ||
} | ||
|
||
AsciiString Version::getAsciiVersion( void ) | ||
AsciiString Version::getAsciiVersion( void ) const | ||
{ | ||
AsciiString version; | ||
#if defined RTS_DEBUG || defined RTS_INTERNAL | ||
|
@@ -83,19 +91,22 @@ AsciiString Version::getAsciiVersion( void ) | |
return version; | ||
} | ||
|
||
UnicodeString Version::getUnicodeVersion( void ) | ||
UnicodeString Version::getUnicodeVersion( void ) const | ||
{ | ||
UnicodeString version; | ||
|
||
#if defined RTS_DEBUG || defined RTS_INTERNAL | ||
if (!m_localBuildNum) | ||
version.format(TheGameText->fetch("Version:Format3").str(), m_major, m_minor, m_buildNum); | ||
if (m_showFullVersion) | ||
{ | ||
if (!m_localBuildNum) | ||
version.format(TheGameText->fetch("Version:Format3").str(), m_major, m_minor, m_buildNum); | ||
else | ||
version.format(TheGameText->fetch("Version:Format4").str(), m_major, m_minor, m_buildNum, m_localBuildNum, | ||
m_buildUser.getCharAt(0), m_buildUser.getCharAt(1)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd be inclined to change this to use the git commit author. You hard code this elsewhere to be "SuperHackers" which I assume is intended to be like a nintendo seal of approval, but anyone forking the repo and building it without changing that will also make a SuperHackers stamped binary. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes this Build User thing needs more work, because as you say, it is not really unique to us publishing it, if it is embedded as a plain string. I do not know what to do with it at this time. Using Git Commit Author does not work, because that name is not stable. At least not for the CI builds. For local builds it probably would be fine. We can use Git Commit Author, and override that with the build user if that is set (from CI). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the original game, it seems that the build user was effectively the username of whoever authored the final build which the commit author is kind of an analog to. I like the idea of passing something from the CI which will differ if built on someone elses such as the repo owner and then falling back to commit author for local builds. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Improved. Now, VERSION_BUILDUSER (and VERSION_BUILDLOC) are empty strings, so build user will default to last git commit author name. I do not yet know how we generate VERSION_BUILDUSER and VERSION_BUILDLOC, but that can be another change in the future. |
||
} | ||
else | ||
version.format(TheGameText->fetch("Version:Format4").str(), m_major, m_minor, m_buildNum, m_localBuildNum, | ||
m_buildUser.getCharAt(0), m_buildUser.getCharAt(1)); | ||
#else // defined RTS_DEBUG || defined RTS_INTERNAL | ||
version.format(TheGameText->fetch("Version:Format2").str(), m_major, m_minor); | ||
#endif // defined RTS_DEBUG || defined RTS_INTERNAL | ||
{ | ||
version.format(TheGameText->fetch("Version:Format2").str(), m_major, m_minor); | ||
} | ||
|
||
#ifdef RTS_DEBUG | ||
version.concat(UnicodeString(L" Debug")); | ||
|
@@ -108,36 +119,15 @@ UnicodeString Version::getUnicodeVersion( void ) | |
return version; | ||
} | ||
|
||
UnicodeString Version::getFullUnicodeVersion( void ) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I removed this function because it was almost a duplicate of the one above. I combined what it does with the function above. |
||
{ | ||
UnicodeString version; | ||
|
||
if (!m_localBuildNum) | ||
version.format(TheGameText->fetch("Version:Format3").str(), m_major, m_minor, m_buildNum); | ||
else | ||
version.format(TheGameText->fetch("Version:Format4").str(), m_major, m_minor, m_buildNum, m_localBuildNum, | ||
m_buildUser.getCharAt(0), m_buildUser.getCharAt(1)); | ||
|
||
#ifdef RTS_DEBUG | ||
version.concat(UnicodeString(L" Debug")); | ||
#endif | ||
|
||
#ifdef RTS_INTERNAL | ||
version.concat(UnicodeString(L" Internal")); | ||
#endif | ||
|
||
return version; | ||
} | ||
|
||
AsciiString Version::getAsciiBuildTime( void ) | ||
AsciiString Version::getAsciiBuildTime( void ) const | ||
{ | ||
AsciiString timeStr; | ||
timeStr.format("%s %s", m_buildDate.str(), m_buildTime.str()); | ||
|
||
return timeStr; | ||
} | ||
|
||
UnicodeString Version::getUnicodeBuildTime( void ) | ||
UnicodeString Version::getUnicodeBuildTime( void ) const | ||
{ | ||
UnicodeString build; | ||
UnicodeString dateStr; | ||
|
@@ -150,34 +140,117 @@ UnicodeString Version::getUnicodeBuildTime( void ) | |
return build; | ||
} | ||
|
||
AsciiString Version::getAsciiBuildLocation( void ) | ||
AsciiString Version::getAsciiBuildLocation( void ) const | ||
{ | ||
return AsciiString(m_buildLocation); | ||
return m_buildLocation; | ||
} | ||
|
||
UnicodeString Version::getUnicodeBuildLocation( void ) | ||
UnicodeString Version::getUnicodeBuildLocation( void ) const | ||
{ | ||
UnicodeString build; | ||
UnicodeString machine; | ||
|
||
machine.translate(AsciiString(m_buildLocation)); | ||
machine.translate(m_buildLocation); | ||
build.format(TheGameText->fetch("Version:BuildMachine").str(), machine.str()); | ||
|
||
return build; | ||
} | ||
|
||
AsciiString Version::getAsciiBuildUser( void ) | ||
AsciiString Version::getAsciiBuildUser( void ) const | ||
{ | ||
return AsciiString(m_buildUser); | ||
return m_buildUser; | ||
} | ||
|
||
UnicodeString Version::getUnicodeBuildUser( void ) | ||
UnicodeString Version::getUnicodeBuildUser( void ) const | ||
{ | ||
UnicodeString build; | ||
UnicodeString user; | ||
|
||
user.translate(AsciiString(m_buildUser)); | ||
user.translate(m_buildUser); | ||
build.format(TheGameText->fetch("Version:BuildUser").str(), user.str()); | ||
|
||
return build; | ||
} | ||
|
||
Int Version::getGitRevision() | ||
{ | ||
return GitRevision; | ||
} | ||
|
||
time_t Version::getGitCommitTime() | ||
{ | ||
return GitCommitTimeStamp; | ||
} | ||
|
||
UnicodeString Version::getUnicodeGameAndGitVersion( void ) const | ||
{ | ||
UnicodeString str; | ||
if (m_showFullVersion) | ||
{ | ||
str.format(L"%s %s %s", | ||
getUnicodeVersion().str(), | ||
getUnicodeGitRevision().str(), | ||
getUnicodeGitVersion().str()); | ||
} | ||
else | ||
{ | ||
str.format(L"%s %s", | ||
getUnicodeVersion().str(), | ||
getUnicodeGitRevision().str()); | ||
} | ||
return str; | ||
} | ||
|
||
AsciiString Version::buildAsciiGitRevision() | ||
{ | ||
AsciiString str; | ||
str.format("R %s%d", | ||
GitUncommittedChanges ? "~" : "", | ||
GitRevision); | ||
return str; | ||
} | ||
|
||
AsciiString Version::buildAsciiGitVersion() | ||
{ | ||
AsciiString str; | ||
str.format("%s%s", | ||
GitUncommittedChanges ? "~" : "", | ||
GitTag[0] ? GitTag : GitShortSHA1); | ||
return str; | ||
} | ||
|
||
AsciiString Version::buildAsciiGitCommitTime() | ||
{ | ||
const Int len = 19; | ||
AsciiString str; | ||
Char* buf = str.getBufferForRead(len); | ||
tm* time = gmtime(&GitCommitTimeStamp); | ||
strftime(buf, len+1, "%Y-%m-%d %H:%M:%S", time); | ||
return str; | ||
} | ||
|
||
UnicodeString Version::buildUnicodeGitRevision() | ||
{ | ||
UnicodeString str; | ||
str.format(L"R %s%d", | ||
GitUncommittedChanges ? L"~" : L"", | ||
GitRevision); | ||
return str; | ||
} | ||
|
||
UnicodeString Version::buildUnicodeGitVersion() | ||
{ | ||
UnicodeString str; | ||
str.translate(buildAsciiGitVersion()); | ||
return str; | ||
} | ||
|
||
UnicodeString Version::buildUnicodeGitCommitTime() | ||
{ | ||
const Int len = 19; | ||
UnicodeString str; | ||
WideChar* buf = str.getBufferForRead(len); | ||
tm* time = gmtime(&GitCommitTimeStamp); | ||
wcsftime(buf, len+1, L"%Y-%m-%d %H:%M:%S", time); | ||
return str; | ||
} |
Uh oh!
There was an error while loading. Please reload this page.