diff --git a/CHANGELOG-III.md b/CHANGELOG-III.md index 1d651bf..b71dd2e 100644 --- a/CHANGELOG-III.md +++ b/CHANGELOG-III.md @@ -49,6 +49,7 @@ All the remaining, non-critical fixes. * Credits now scale to resolution correctly, and they don't cut to an empty screen at the very end anymore. * Mission title and 'Mission Passed' texts now stay on screen for the same duration, regardless of screen resolution. * The inner padding of the text boxes with a background now scales to resolution correctly. +* The position of the dialog question text in the main menu now scales to resolution correctly. * `FILE_FLAG_NO_BUFFERING` flag has been removed from IMG reading functions - speeding up streaming. * Free resprays will not carry on a New Game now. * Fixed ambulance and firetruck dispatch timers - they reset on New Game now. diff --git a/CHANGELOG-VC.md b/CHANGELOG-VC.md index 247dc1c..0dfebc9 100644 --- a/CHANGELOG-VC.md +++ b/CHANGELOG-VC.md @@ -45,6 +45,7 @@ All the remaining, non-critical fixes. * Credits now scale to resolution correctly. * Mission title and 'Mission Passed' texts now stay on screen for the same duration, regardless of screen resolution. * The inner padding of the text boxes with a background now scales to resolution correctly. +* The vertical offset of the weapon name text in Ammu-Nation now scales to resolution correctly. * `FILE_FLAG_NO_BUFFERING` flag has been removed from IMG reading functions - speeding up streaming. * Free resprays will not carry on a New Game now. * Fixed ambulance and firetruck dispatch timers - they reset on New Game now. diff --git a/SilentPatchIII/SilentPatchIII.cpp b/SilentPatchIII/SilentPatchIII.cpp index 11b1263..e0c04e7 100644 --- a/SilentPatchIII/SilentPatchIII.cpp +++ b/SilentPatchIII/SilentPatchIII.cpp @@ -1165,6 +1165,18 @@ namespace TextRectPaddingScalingFixes HOOK_EACH_INIT(WrapX, orgWrapX, WrapX_Recalculated); } + +// ============= Fix menu texts not scaling to resolution ============= +namespace MenuManagerScalingFixes +{ + static void (*orgPrintString)(float,float,const wchar_t*); + static void PrintString_Scale(float fX, float fY, const wchar_t* pText) + { + orgPrintString(fX * GetWidthMult() * RsGlobal->MaximumWidth, fY * GetHeightMult() * RsGlobal->MaximumHeight, pText); + } +} + + namespace ModelIndicesReadyHook { static void (*orgInitialiseObjectData)(const char*); @@ -1607,6 +1619,17 @@ void InjectDelayedPatches_III_Common( bool bHasDebugMenu, const wchar_t* wcModul } TXN_CATCH(); + + // ============= Fix menu texts not scaling to resolution ============= + try + { + using namespace MenuManagerScalingFixes; + + auto printStringMenuText = get_pattern("E8 ? ? ? ? 83 C4 0C DB 05 ? ? ? ? 50"); + InterceptCall(printStringMenuText, orgPrintString, PrintString_Scale); + } + TXN_CATCH(); + FLAUtils::Init(moduleList); } diff --git a/SilentPatchVC/SilentPatchVC.cpp b/SilentPatchVC/SilentPatchVC.cpp index 7cd1b9b..0914b55 100644 --- a/SilentPatchVC/SilentPatchVC.cpp +++ b/SilentPatchVC/SilentPatchVC.cpp @@ -619,6 +619,35 @@ namespace TextRectPaddingScalingFixes } +// ============= Fix ammunation text (big message type 3) Y position offset not scaling to resolution ============= +namespace BigMessage3ScalingFixes +{ + template + static const float* orgOffsetY; + + template + static float OffsetY_Recalculated; + + template + static void RecalculateYOffset(std::index_sequence) + { + const float multiplier = GetHeightMult() * RsGlobal->MaximumHeight; + ((OffsetY_Recalculated = *orgOffsetY * multiplier), ...); + } + + static void (*orgSetDropColor)(const CRGBA&); + + template + static void SetDropColor_Scale(const CRGBA& color) + { + RecalculateYOffset(std::make_index_sequence{}); + orgSetDropColor(color); + } + + HOOK_EACH_INIT(MessageYOffset, orgOffsetY, OffsetY_Recalculated); +} + + float FixedRefValue() { return 1.0f; @@ -2022,6 +2051,22 @@ void InjectDelayedPatches_VC_Common( bool bHasDebugMenu, const wchar_t* wcModule } TXN_CATCH(); + + // Fix ammunation text (big message type 3) Y position offset not scaling to resolution + try + { + using namespace BigMessage3ScalingFixes; + + auto setDropColor = get_pattern("E8 ? ? ? ? 59 8D 4C 24 40"); + std::array YOffset = { + get_pattern("D8 25 ? ? ? ? D9 1C 24 A1", 2), + }; + + HookEach_MessageYOffset(YOffset, PatchFloat); + InterceptCall(setDropColor, orgSetDropColor, SetDropColor_Scale); + } + TXN_CATCH(); + FLAUtils::Init(moduleList); }