Remove version text, add toggleable debug info(with commit hash!)

This commit is contained in:
erorcun 2021-02-12 01:49:09 +03:00
parent c7dae2aca6
commit 9e1c048e20
9 changed files with 121 additions and 5 deletions

2
.gitignore vendored
View file

@ -358,3 +358,5 @@ sdk/
codewarrior/re3_Data/ codewarrior/re3_Data/
codewarrior/Release/ codewarrior/Release/
codewarrior/Debug/ codewarrior/Debug/
src/extras/GitSHA1.cpp

View file

@ -313,7 +313,7 @@ project "re3"
filter {} filter {}
if(os.getenv("GTA_III_RE_DIR")) then if(os.getenv("GTA_III_RE_DIR")) then
setpaths("$(GTA_III_RE_DIR)/", "%(cfg.buildtarget.name)") setpaths(os.getenv("GTA_III_RE_DIR") .. "/", "%(cfg.buildtarget.name)")
end end
filter "platforms:win*" filter "platforms:win*"
@ -327,6 +327,10 @@ project "re3"
-- external librw is dynamic -- external librw is dynamic
staticruntime "on" staticruntime "on"
end end
prebuildcommands { '"%{prj.location}..\\printHash.bat" "%{prj.location}..\\src\\extras\\GitSHA1.cpp"' }
filter "platforms:not win*"
prebuildcommands { '"%{prj.location}../printHash.sh" "%{prj.location}../src/extras/GitSHA1.cpp"' }
filter "platforms:win*glfw*" filter "platforms:win*glfw*"
staticruntime "off" staticruntime "off"

26
printHash.bat Normal file
View file

@ -0,0 +1,26 @@
@echo off
REM creates version.h with HEAD commit hash
REM params: $1=full path to output file (usually points version.h)
setlocal enableextensions enabledelayedexpansion
cd /d "%~dp0"
break> %1
<nul set /p=^"#define GIT_SHA1 ^"^"> %1
where git
if "%errorlevel%" == "0" ( goto :havegit ) else ( goto :writeending )
:havegit
for /f %%v in ('git rev-parse --short HEAD') do set version=%%v
<nul set /p="%version%" >> %1
:writeending
echo ^" >> %1
echo const char* g_GIT_SHA1 = GIT_SHA1; >> %1
EXIT /B

14
printHash.sh Normal file
View file

@ -0,0 +1,14 @@
#!/usr/bin/bash
> $1
echo -n "#define GIT_SHA1 \"" > $1
git --version 2>&1 >/dev/null
GIT_IS_AVAILABLE=$?
if [ $GIT_IS_AVAILABLE -ne 0 ]; then
git rev-parse --short HEAD | tr -d '\n' >> $1
fi
echo "\"" >> $1
echo "const char* g_GIT_SHA1 = GIT_SHA1;" >> $1

View file

@ -183,7 +183,11 @@ enum Config {
// those infamous texts // those infamous texts
#define DRAW_GAME_VERSION_TEXT #define DRAW_GAME_VERSION_TEXT
#define DRAW_MENU_VERSION_TEXT #ifdef DRAW_GAME_VERSION_TEXT
#define TOGGLEABLE_VERSION_TEXT
#define USE_OUR_VERSIONING // If you disable this then game will fetch version peds.col, as R* did while in development
#endif
//#define DRAW_MENU_VERSION_TEXT
// Memory allocation and compression // Memory allocation and compression
// #define USE_CUSTOM_ALLOCATOR // use CMemoryHeap for allocation. use with care, not finished yet // #define USE_CUSTOM_ALLOCATOR // use CMemoryHeap for allocation. use with care, not finished yet

View file

@ -70,6 +70,9 @@
#include "custompipes.h" #include "custompipes.h"
#include "screendroplets.h" #include "screendroplets.h"
#include "MemoryHeap.h" #include "MemoryHeap.h"
#ifdef USE_OUR_VERSIONING
#include "GitSHA1.h"
#endif
GlobalScene Scene; GlobalScene Scene;
@ -86,6 +89,9 @@ bool gbModelViewer;
#ifdef TIMEBARS #ifdef TIMEBARS
bool gbShowTimebars; bool gbShowTimebars;
#endif #endif
#ifdef TOGGLEABLE_VERSION_TEXT
bool gDrawVersionText;
#endif
volatile int32 frameCount; volatile int32 frameCount;
@ -1090,12 +1096,57 @@ DisplayGameDebugText()
#ifdef DRAW_GAME_VERSION_TEXT #ifdef DRAW_GAME_VERSION_TEXT
wchar ver[200]; wchar ver[200];
#ifdef TOGGLEABLE_VERSION_TEXT
if(gDrawVersionText)
#endif
{
#ifdef USE_OUR_VERSIONING
char verA[200];
sprintf(verA,
#if defined _WIN32
"Win "
#elif defined __linux__
"Linux "
#elif defined __APPLE__
"Mac OS X "
#elif defined __FreeBSD__
"FreeBSD "
#else
"Posix-compliant "
#endif
#if defined __LP64__ || defined _WIN64
"64-bit "
#else
"32-bit "
#endif
#if defined RW_D3D9
"D3D9 "
#elif defined RWLIBS
"D3D8 "
#elif defined RW_GL3
"OpenGL "
#endif
#if defined AUDIO_OAL
"OAL "
#elif defined AUDIO_MSS
"MSS "
#endif
#if defined _DEBUG || defined DEBUG
"DEBUG "
#endif
"%.8s",
g_GIT_SHA1);
AsciiToUnicode(verA, ver);
CFont::SetScale(SCREEN_SCALE_X(0.5f), SCREEN_SCALE_Y(0.7f));
#else
AsciiToUnicode(version_name, ver); AsciiToUnicode(version_name, ver);
CFont::SetScale(SCREEN_SCALE_X(0.5f), SCREEN_SCALE_Y(0.5f));
#endif
CFont::SetPropOn(); CFont::SetPropOn();
CFont::SetBackgroundOff(); CFont::SetBackgroundOff();
CFont::SetFontStyle(FONT_BANK); CFont::SetFontStyle(FONT_BANK);
CFont::SetScale(SCREEN_SCALE_X(0.5f), SCREEN_SCALE_Y(0.5f));
CFont::SetCentreOff(); CFont::SetCentreOff();
CFont::SetRightJustifyOff(); CFont::SetRightJustifyOff();
CFont::SetWrapx(SCREEN_WIDTH); CFont::SetWrapx(SCREEN_WIDTH);
@ -1107,6 +1158,7 @@ DisplayGameDebugText()
#else #else
CFont::PrintString(10.0f, 10.0f, ver); CFont::PrintString(10.0f, 10.0f, ver);
#endif #endif
}
#endif // #ifdef DRAW_GAME_VERSION_TEXT #endif // #ifdef DRAW_GAME_VERSION_TEXT
FrameSamples++; FrameSamples++;

View file

@ -508,6 +508,10 @@ bool LoadINISettings()
#ifdef FIX_SPRITES #ifdef FIX_SPRITES
ReadIniIfExists("Draw", "FixSprites", &CDraw::ms_bFixSprites); ReadIniIfExists("Draw", "FixSprites", &CDraw::ms_bFixSprites);
#endif #endif
#ifdef TOGGLEABLE_VERSION_TEXT
extern bool gDrawVersionText;
ReadIniIfExists("General", "DrawVersionText", &gDrawVersionText);
#endif
#ifdef CUSTOM_FRONTEND_OPTIONS #ifdef CUSTOM_FRONTEND_OPTIONS
bool migrate = cfg.category_size("FrontendOptions") != 0; bool migrate = cfg.category_size("FrontendOptions") != 0;
@ -595,6 +599,10 @@ void SaveINISettings()
#ifdef FIX_SPRITES #ifdef FIX_SPRITES
StoreIni("Draw", "FixSprites", CDraw::ms_bFixSprites); StoreIni("Draw", "FixSprites", CDraw::ms_bFixSprites);
#endif #endif
#ifdef TOGGLEABLE_VERSION_TEXT
extern bool gDrawVersionText;
StoreIni("General", "DrawVersionText", gDrawVersionText);
#endif
#ifdef CUSTOM_FRONTEND_OPTIONS #ifdef CUSTOM_FRONTEND_OPTIONS
for (int i = 0; i < MENUPAGES; i++) { for (int i = 0; i < MENUPAGES; i++) {
for (int j = 0; j < NUM_MENUROWS; j++) { for (int j = 0; j < NUM_MENUROWS; j++) {
@ -985,7 +993,10 @@ extern bool gbRenderWorld2;
#endif #endif
#ifdef TOGGLEABLE_VERSION_TEXT
extern bool gDrawVersionText;
DebugMenuAddVarBool8("Debug", "Version Text", &gDrawVersionText, nil);
#endif
#ifndef FINAL #ifndef FINAL
DebugMenuAddVarBool8("Debug", "Print Memory Usage", &gbPrintMemoryUsage, nil); DebugMenuAddVarBool8("Debug", "Print Memory Usage", &gbPrintMemoryUsage, nil);
#ifdef USE_CUSTOM_ALLOCATOR #ifdef USE_CUSTOM_ALLOCATOR

2
src/extras/GitSHA1.cpp Normal file
View file

@ -0,0 +1,2 @@
#define GIT_SHA1 ""
const char* g_GIT_SHA1 = GIT_SHA1;

1
src/extras/GitSHA1.h Normal file
View file

@ -0,0 +1 @@
extern const char* g_GIT_SHA1;