Add version info to bluescreen

This commit is contained in:
Tamás Bálint Misius 2023-09-30 22:15:38 +02:00
parent 146fb4b549
commit 5584acd189
No known key found for this signature in database
GPG Key ID: 5B472A12F6ECA9F2
2 changed files with 39 additions and 29 deletions

View File

@ -17,6 +17,7 @@
#include "gui/Style.h"
#include "gui/game/GameController.h"
#include "gui/game/GameView.h"
#include "gui/game/IntroText.h"
#include "gui/dialogues/ConfirmPrompt.h"
#include "gui/dialogues/ErrorMessage.h"
#include "gui/interface/Engine.h"
@ -102,6 +103,7 @@ void BlueScreen(String detailMessage)
String errorTitle = "ERROR";
String errorDetails = "Details: " + detailMessage;
String errorHelp = String("An unrecoverable fault has occurred, please report the error by visiting the website below\n") + SCHEME + SERVER;
auto versionInfo = ByteString::Build("Version: ", VersionInfo(), "\nTag: ", VCS_TAG).FromUtf8();
// We use the width of errorHelp to center, but heights of the individual texts for vertical spacing
auto pos = engine.g->Size() / 2 - Vec2(Graphics::TextSize(errorHelp).X / 2, 100);
@ -110,6 +112,8 @@ void BlueScreen(String detailMessage)
engine.g->BlendText(pos, errorDetails, 0xFFFFFF_rgb .WithAlpha(0xFF));
pos.Y += 4 + Graphics::TextSize(errorDetails).Y;
engine.g->BlendText(pos, errorHelp, 0xFFFFFF_rgb .WithAlpha(0xFF));
pos.Y += 4 + Graphics::TextSize(errorHelp).Y;
engine.g->BlendText(pos, versionInfo, 0xFFFFFF_rgb .WithAlpha(0xFF));
//Death loop
SDL_Event event;

View File

@ -2,6 +2,40 @@
#include "Config.h"
#include "common/String.h"
inline ByteString VersionInfo()
{
ByteStringBuilder sb;
sb << SAVE_VERSION << "." << MINOR_VERSION << "." << BUILD_NUM << " " << IDENT;
if constexpr (SNAPSHOT)
{
sb << " SNAPSHOT " << SNAPSHOT_ID;
}
else if constexpr (MOD)
{
sb << " MODVER " << SNAPSHOT_ID;
}
if constexpr (LUACONSOLE)
{
sb << " LUACONSOLE";
}
#ifdef REALISTIC
sb << " REALISTIC";
#endif
if constexpr (NOHTTP)
{
sb << " NOHTTP";
}
else if constexpr (ENFORCE_HTTPS)
{
sb << " HTTPS";
}
if constexpr (DEBUG)
{
sb << " DEBUG";
}
return sb.Build();
}
inline ByteString IntroText()
{
ByteStringBuilder sb;
@ -37,34 +71,6 @@ inline ByteString IntroText()
{
sb << "\bgTo use online features such as saving, you need to register at: \brhttps://powdertoy.co.uk/Register.html\n";
}
sb << "\n"
<< "\bt" << SAVE_VERSION << "." << MINOR_VERSION << "." << BUILD_NUM << " " << IDENT;
if constexpr (SNAPSHOT)
{
sb << " SNAPSHOT " << SNAPSHOT_ID;
}
else if constexpr (MOD)
{
sb << " MODVER " << SNAPSHOT_ID;
}
if constexpr (LUACONSOLE)
{
sb << " LUACONSOLE";
}
#ifdef REALISTIC
sb << " REALISTIC";
#endif
if constexpr (NOHTTP)
{
sb << " NOHTTP";
}
else if constexpr (ENFORCE_HTTPS)
{
sb << " HTTPS";
}
if constexpr (DEBUG)
{
sb << " DEBUG";
}
sb << "\n\bt" << VersionInfo();
return sb.Build();
}