From 1bc169899c6aa98d13d485d390a7f0cda10452b0 Mon Sep 17 00:00:00 2001 From: Silent Date: Fri, 4 Oct 2024 23:17:27 +0200 Subject: [PATCH] VC: Scale loading bar outline to resolution --- SilentPatchVC/SilentPatchVC.cpp | 71 +++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) diff --git a/SilentPatchVC/SilentPatchVC.cpp b/SilentPatchVC/SilentPatchVC.cpp index d1ba14a..4d31843 100644 --- a/SilentPatchVC/SilentPatchVC.cpp +++ b/SilentPatchVC/SilentPatchVC.cpp @@ -383,6 +383,53 @@ namespace RadarTraceOutlineFixes HOOK_EACH_INIT(YPos, orgYPos, YPos_Recalculated); } + +// ============= Fix the loading bar outline not scaling to resolution============= +namespace LoadingBarOutlineFixes +{ + template + static const float* orgXPos; + + template + static float XPos_Recalculated; + + template + static const float* orgYPos; + + template + static float YPos_Recalculated; + + template + static void RecalculateXPositions(std::index_sequence) + { + const float multiplier = GetWidthMult() * RsGlobal->MaximumWidth; + ((XPos_Recalculated = *orgXPos * multiplier), ...); + } + + template + static void RecalculateYPositions(std::index_sequence) + { + const float multiplier = GetHeightMult() * RsGlobal->MaximumHeight; + ((YPos_Recalculated = *orgYPos * multiplier), ...); + } + + static CRGBA* (__fastcall* orgRGBACtor)(CRGBA* obj, void*, unsigned char r, unsigned char g, unsigned char b, unsigned char a); + + template + static CRGBA* __fastcall RGBACtor_RecalculatePositions(CRGBA* obj, void*, unsigned char r, unsigned char g, unsigned char b, unsigned char a) + { + RecalculateXPositions(std::make_index_sequence{}); + RecalculateYPositions(std::make_index_sequence{}); + + return orgRGBACtor(obj, nullptr, r, g, b, a); + } + + + HOOK_EACH_INIT(XPos, orgXPos, XPos_Recalculated); + HOOK_EACH_INIT(YPos, orgYPos, YPos_Recalculated); +} + + float FixedRefValue() { return 1.0f; @@ -1483,6 +1530,30 @@ void InjectDelayedPatches_VC_Common( bool bHasDebugMenu, const wchar_t* wcModule TXN_CATCH(); + // Fix the loading bar outline not scaling to resolution + try + { + using namespace LoadingBarOutlineFixes; + + auto rgbaCtor = get_pattern("6A 00 E8 ? ? ? ? 8B 0D ? ? ? ? A1", 2); + + std::array XPositions = { + get_pattern("D9 C1 D8 25 ? ? ? ? DD DC", 2 + 2), + get_pattern(" D8 C2 D8 05 ? ? ? ? D9 5C 24 38", 2 + 2), + }; + + std::array YPositions = { + get_pattern("DD D1 D8 25 ? ? ? ? D9 5C 24 3C", 2 + 2), + get_pattern("D8 05 ? ? ? ? D9 5C 24 34 DE D9", 2), + }; + + HookEach_XPos(XPositions, PatchFloat); + HookEach_YPos(YPositions, PatchFloat); + InterceptCall(rgbaCtor, orgRGBACtor, RGBACtor_RecalculatePositions); + } + TXN_CATCH(); + + FLAUtils::Init(moduleList); }