diff --git a/SilentPatchSA/GeneralSA.h b/SilentPatchSA/GeneralSA.h index 6f070c9..584a8a2 100644 --- a/SilentPatchSA/GeneralSA.h +++ b/SilentPatchSA/GeneralSA.h @@ -47,6 +47,7 @@ public: // SilentPatch CRGBA* BlendGangColour(uint8_t r, uint8_t g, uint8_t b, uint8_t a); + CRGBA* BlendGangColour_Dynamic(uint8_t r, uint8_t g, uint8_t b, uint8_t a); }; class CRect diff --git a/SilentPatchSA/SilentPatchSA.cpp b/SilentPatchSA/SilentPatchSA.cpp index 7694c37..edf22a9 100644 --- a/SilentPatchSA/SilentPatchSA.cpp +++ b/SilentPatchSA/SilentPatchSA.cpp @@ -664,6 +664,21 @@ void DrawMoonWithPhases(int moonColor, float* screenPos, float sizeX, float size //D3DPERF_EndEvent(); } +static bool bColouredZoneNames; +CRGBA* CRGBA::BlendGangColour_Dynamic(uint8_t r, uint8_t g, uint8_t b, uint8_t a) +{ + if ( bColouredZoneNames ) + { + const double colourIntensity = std::min( static_cast(pCurrZoneInfo->ZoneColour.a) / 120.0, 1.0 ); + *this = CRGBA(BlendSqr( HudColour[3], CRGBA(r, g, b), colourIntensity ), a); + } + else + { + *this = HudColour[3]; + } + return this; +} + CRGBA* CRGBA::BlendGangColour(uint8_t r, uint8_t g, uint8_t b, uint8_t a) { const double colourIntensity = std::min( static_cast(pCurrZoneInfo->ZoneColour.a) / 120.0, 1.0 ); @@ -2256,19 +2271,19 @@ BOOL InjectDelayedPatches_10() Patch(0x4E9F38, &fSteamRadioNameSizeX); } + if ( int INIoption = GetPrivateProfileIntW(L"SilentPatch", L"ColouredZoneNames", -1, wcModulePath); INIoption != -1 ) { - int INIoption = GetPrivateProfileIntW(L"SilentPatch", L"ColouredZoneNames", -1, wcModulePath); - if ( INIoption == 1 ) - { - // Coloured zone names - Patch(0x58ADBE, 0x0E75); - Patch(0x58ADC5, 0x0775); + // Coloured zone names + bColouredZoneNames = INIoption != 0; - InjectHook(0x58ADE4, &CRGBA::BlendGangColour); - } - else if ( INIoption == 0 ) + Patch(0x58ADBE, 0x0E75); + Patch(0x58ADC5, 0x0775); + + InjectHook(0x58ADE4, &CRGBA::BlendGangColour_Dynamic); + + if ( bHasDebugMenu ) { - Patch(0x58ADAE, 0xEB); + DebugMenuAddVar( "SilentPatch", "Coloured zone names", &bColouredZoneNames, nullptr ); } } @@ -2589,20 +2604,17 @@ BOOL InjectDelayedPatches_11() Patch(0x4EA388, &fSteamRadioNameSizeX); } + if ( int INIoption = GetPrivateProfileIntW(L"SilentPatch", L"ColouredZoneNames", -1, wcModulePath); INIoption == 1 ) { - int INIoption = GetPrivateProfileIntW(L"SilentPatch", L"ColouredZoneNames", -1, wcModulePath); - if ( INIoption == 1 ) - { - // Coloured zone names - Patch(0x58B58E, 0x0E75); - Patch(0x58B595, 0x0775); + // Coloured zone names + Patch(0x58B58E, 0x0E75); + Patch(0x58B595, 0x0775); - InjectHook(0x58B5B4, &CRGBA::BlendGangColour); - } - else if ( INIoption == 0 ) - { - Patch(0x58B57E, 0xEB); - } + InjectHook(0x58B5B4, &CRGBA::BlendGangColour); + } + else if ( INIoption == 0 ) + { + Patch(0x58B57E, 0xEB); } // ImVehFt conflicts @@ -2754,20 +2766,17 @@ BOOL InjectDelayedPatches_Steam() Patch(0x4F59BF, &dRetailRadioNameSizeX); } + if ( int INIoption = GetPrivateProfileIntW(L"SilentPatch", L"ColouredZoneNames", -1, wcModulePath); INIoption == 1 ) { - int INIoption = GetPrivateProfileIntW(L"SilentPatch", L"ColouredZoneNames", -1, wcModulePath); - if ( INIoption == 1 ) - { - // Coloured zone names - Patch(0x598F65, 0x0C75); - Patch(0x598F6B, 0x0675); + // Coloured zone names + Patch(0x598F65, 0x0C75); + Patch(0x598F6B, 0x0675); - InjectHook(0x598F87, &CRGBA::BlendGangColour); - } - else if ( INIoption == 0 ) - { - Patch(0x598F56, 0xEB); - } + InjectHook(0x598F87, &CRGBA::BlendGangColour); + } + else if ( INIoption == 0 ) + { + Patch(0x598F56, 0xEB); } // ImVehFt conflicts