Added more options to debug menu (rotor fix, small steam texts, minimal HUD)

This commit is contained in:
Silent 2019-02-03 14:09:29 +01:00
parent 9dbbcb42cf
commit 30c10a9a25
No known key found for this signature in database
GPG key ID: AE53149BB0C45AF1
3 changed files with 99 additions and 21 deletions

View file

@ -2331,6 +2331,48 @@ static const float fSteamRadioNamePosY = 33.0f;
static const float fSteamRadioNameSizeX = 0.4f; static const float fSteamRadioNameSizeX = 0.4f;
static const float fSteamRadioNameSizeY = 0.6f; static const float fSteamRadioNameSizeY = 0.6f;
static float* orgSubtitleSizeX;
static float* orgSubtitleSizeY;
static float* orgRadioNamePosY;
static float* orgRadioNameSizeX;
static float* orgRadioNameSizeY;
static void ToggleSteamTexts( bool enable )
{
using namespace Memory::VP;
if ( enable )
{
Patch<const void*>(0x58C387, &fSteamSubtitleSizeY);
Patch<const void*>(0x58C40F, &fSteamSubtitleSizeY);
Patch<const void*>(0x58C4CE, &fSteamSubtitleSizeY);
Patch<const void*>(0x58C39D, &fSteamSubtitleSizeX);
Patch<const void*>(0x58C425, &fSteamSubtitleSizeX);
Patch<const void*>(0x58C4E4, &fSteamSubtitleSizeX);
Patch<const void*>(0x4E9FD8, &fSteamRadioNamePosY);
Patch<const void*>(0x4E9F22, &fSteamRadioNameSizeY);
Patch<const void*>(0x4E9F38, &fSteamRadioNameSizeX);
}
else
{
assert( orgSubtitleSizeY != nullptr && orgSubtitleSizeX != nullptr && orgRadioNamePosY != nullptr && orgRadioNameSizeY != nullptr && orgRadioNameSizeX != nullptr );
Patch<const void*>(0x58C387, orgSubtitleSizeY);
Patch<const void*>(0x58C40F, orgSubtitleSizeY);
Patch<const void*>(0x58C4CE, orgSubtitleSizeY);
Patch<const void*>(0x58C39D, orgSubtitleSizeX);
Patch<const void*>(0x58C425, orgSubtitleSizeX);
Patch<const void*>(0x58C4E4, orgSubtitleSizeX);
Patch<const void*>(0x4E9FD8, orgRadioNamePosY);
Patch<const void*>(0x4E9F22, orgRadioNameSizeY);
Patch<const void*>(0x4E9F38, orgRadioNameSizeX);
}
}
static const double dRetailSubtitleSizeX = 0.58; static const double dRetailSubtitleSizeX = 0.58;
static const double dRetailSubtitleSizeY = 1.2; static const double dRetailSubtitleSizeY = 1.2;
static const double dRetailSubtitleSizeY2 = 1.22; static const double dRetailSubtitleSizeY2 = 1.22;
@ -2425,20 +2467,29 @@ BOOL InjectDelayedPatches_10()
Patch<WORD>(AddressByRegion_10<DWORD>(0x748AA8), 0x3DEB); Patch<WORD>(AddressByRegion_10<DWORD>(0x748AA8), 0x3DEB);
} }
{
static bool bSmallSteamTexts = false;
if ( bHasDebugMenu )
{
orgSubtitleSizeX = *(float**)0x58C39D;
orgSubtitleSizeY = *(float**)0x58C387;
orgRadioNamePosY = *(float**)0x4E9FD8;
orgRadioNameSizeY = *(float**)0x4E9F22;
orgRadioNameSizeX = *(float**)0x4E9F38;
DebugMenuAddVar( "SilentPatch", "Small Steam texts", &bSmallSteamTexts, []() {
ToggleSteamTexts( bSmallSteamTexts );
} );
}
if ( GetPrivateProfileIntW(L"SilentPatch", L"SmallSteamTexts", -1, wcModulePath) == 1 ) if ( GetPrivateProfileIntW(L"SilentPatch", L"SmallSteamTexts", -1, wcModulePath) == 1 )
{ {
// We're on 1.0 - make texts smaller // We're on 1.0 - make texts smaller
Patch<const void*>(0x58C387, &fSteamSubtitleSizeY); ToggleSteamTexts( true );
Patch<const void*>(0x58C40F, &fSteamSubtitleSizeY);
Patch<const void*>(0x58C4CE, &fSteamSubtitleSizeY);
Patch<const void*>(0x58C39D, &fSteamSubtitleSizeX); bSmallSteamTexts = true;
Patch<const void*>(0x58C425, &fSteamSubtitleSizeX); }
Patch<const void*>(0x58C4E4, &fSteamSubtitleSizeX);
Patch<const void*>(0x4E9FD8, &fSteamRadioNamePosY);
Patch<const void*>(0x4E9F22, &fSteamRadioNameSizeY);
Patch<const void*>(0x4E9F38, &fSteamRadioNameSizeX);
} }
if ( const int INIoption = GetPrivateProfileIntW(L"SilentPatch", L"ColouredZoneNames", -1, wcModulePath); INIoption != -1 ) if ( const int INIoption = GetPrivateProfileIntW(L"SilentPatch", L"ColouredZoneNames", -1, wcModulePath); INIoption != -1 )
@ -2602,6 +2653,24 @@ BOOL InjectDelayedPatches_10()
Patch<int32_t>( 0x588905 + 1, 0 ); Patch<int32_t>( 0x588905 + 1, 0 );
} }
if ( bHasDebugMenu )
{
static bool bMinimalHUDEnabled = INIoption == 1;
DebugMenuAddVar( "SilentPatch", "Minimal HUD", &bMinimalHUDEnabled, []() {
if ( bMinimalHUDEnabled )
{
Memory::VP::Patch<int32_t>( 0x588905 + 1, 0 );
}
else
{
Memory::VP::Patch<int32_t>( 0x588905 + 1, 5 );
}
// Call CHud::ReInitialise
auto ReInitialise = (void(*)())0x588880;
ReInitialise();
} );
}
} }
// Moonphases // Moonphases
@ -2690,7 +2759,11 @@ BOOL InjectDelayedPatches_10()
if ( bHasDebugMenu ) if ( bHasDebugMenu )
{ {
static const char * const str[] = { "Off", "Default", "On" }; static const char * const str[] = { "Off", "Default", "On" };
DebugMenuEntry *e = DebugMenuAddVar( "SilentPatch", "Lightbeam fix", &CVehicle::ms_lightbeamFixOverride, nullptr, 1, -1, 1, str);
DebugMenuEntry *e = DebugMenuAddVar( "SilentPatch", "Rotors fix", &CVehicle::ms_rotorFixOverride, nullptr, 1, -1, 1, str);
DebugMenuEntrySetWrap(e, true);
e = DebugMenuAddVar( "SilentPatch", "Lightbeam fix", &CVehicle::ms_lightbeamFixOverride, nullptr, 1, -1, 1, str);
DebugMenuEntrySetWrap(e, true); DebugMenuEntrySetWrap(e, true);
} }

View file

@ -233,9 +233,13 @@ bool __stdcall CheckDoubleRWheelsList( void* modelInfo, uint8_t* handlingData )
// Now left only for "backwards compatibility" // Now left only for "backwards compatibility"
static bool ShouldIgnoreRotor( int32_t id ) bool CVehicle::IgnoresRotorFix() const
{ {
return SVF::ModelHasFeature( id, SVF::Feature::NO_ROTOR_FADE ); if ( ms_rotorFixOverride != 0 )
{
return ms_rotorFixOverride < 0;
}
return SVF::ModelHasFeature( m_nModelIndex.Get(), SVF::Feature::NO_ROTOR_FADE );
} }
static void* varVehicleRender = AddressByVersion<void*>(0x6D0E60, 0x6D1680, 0x70C0B0); static void* varVehicleRender = AddressByVersion<void*>(0x6D0E60, 0x6D1680, 0x70C0B0);
@ -482,9 +486,9 @@ CPed* CVehicle::PickRandomPassenger()
void CHeli::Render() void CHeli::Render()
{ {
double dRotorsSpeed, dMovingRotorSpeed; double dRotorsSpeed, dMovingRotorSpeed;
bool bDisplayRotors = !ShouldIgnoreRotor( m_nModelIndex.Get() ); const bool bDisplayRotors = !IgnoresRotorFix();
bool bHasMovingRotor = m_pCarNode[13] != nullptr && bDisplayRotors; const bool bHasMovingRotor = m_pCarNode[13] != nullptr && bDisplayRotors;
bool bHasMovingRotor2 = m_pCarNode[15] != nullptr && bDisplayRotors; const bool bHasMovingRotor2 = m_pCarNode[15] != nullptr && bDisplayRotors;
m_nTimeTillWeNeedThisCar = CTimer::m_snTimeInMilliseconds + 3000; m_nTimeTillWeNeedThisCar = CTimer::m_snTimeInMilliseconds + 3000;
@ -534,9 +538,9 @@ void CHeli::Render()
void CPlane::Render() void CPlane::Render()
{ {
double dRotorsSpeed, dMovingRotorSpeed; double dRotorsSpeed, dMovingRotorSpeed;
bool bDisplayRotors = !ShouldIgnoreRotor( m_nModelIndex.Get() ); const bool bDisplayRotors = !IgnoresRotorFix();
bool bHasMovingProp = m_pCarNode[13] != nullptr && bDisplayRotors; const bool bHasMovingProp = m_pCarNode[13] != nullptr && bDisplayRotors;
bool bHasMovingProp2 = m_pCarNode[15] != nullptr && bDisplayRotors; const bool bHasMovingProp2 = m_pCarNode[15] != nullptr && bDisplayRotors;
m_nTimeTillWeNeedThisCar = CTimer::m_snTimeInMilliseconds + 3000; m_nTimeTillWeNeedThisCar = CTimer::m_snTimeInMilliseconds + 3000;

View file

@ -271,8 +271,9 @@ public:
static inline void (CVehicle::*orgDoHeadLightBeam)( int type, CMatrix& m, bool right ); static inline void (CVehicle::*orgDoHeadLightBeam)( int type, CMatrix& m, bool right );
static inline int8_t ms_lightbeamFixOverride = 0; // 0 - normal, 1 - always on, -1 - always off static inline int8_t ms_lightbeamFixOverride = 0, ms_rotorFixOverride = 0; // 0 - normal, 1 - always on, -1 - always off
bool IgnoresLightbeamFix() const; bool IgnoresLightbeamFix() const;
bool IgnoresRotorFix() const;
void DoHeadLightBeam( int type, CMatrix& m, bool right ) void DoHeadLightBeam( int type, CMatrix& m, bool right )
{ {