Skip to content

Commit

Permalink
III/VC: Two more minor scaling fixes
Browse files Browse the repository at this point in the history
III: The position of the dialog question text in the main menu now
scales to resolution correctly.
VC: The vertical offset of the weapon name text in Ammu-Nation
now scales to resolution correctly.
  • Loading branch information
CookiePLMonster committed Nov 1, 2024
1 parent fd67cb4 commit 7d055f9
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG-III.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG-VC.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
23 changes: 23 additions & 0 deletions SilentPatchIII/SilentPatchIII.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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*);
Expand Down Expand Up @@ -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);
}

Expand Down
45 changes: 45 additions & 0 deletions SilentPatchVC/SilentPatchVC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,35 @@ namespace TextRectPaddingScalingFixes
}


// ============= Fix ammunation text (big message type 3) Y position offset not scaling to resolution =============
namespace BigMessage3ScalingFixes
{
template<std::size_t Index>
static const float* orgOffsetY;

template<std::size_t Index>
static float OffsetY_Recalculated;

template<std::size_t... I>
static void RecalculateYOffset(std::index_sequence<I...>)
{
const float multiplier = GetHeightMult() * RsGlobal->MaximumHeight;
((OffsetY_Recalculated<I> = *orgOffsetY<I> * multiplier), ...);
}

static void (*orgSetDropColor)(const CRGBA&);

template<std::size_t NumXOffsets>
static void SetDropColor_Scale(const CRGBA& color)
{
RecalculateYOffset(std::make_index_sequence<NumXOffsets>{});
orgSetDropColor(color);
}

HOOK_EACH_INIT(MessageYOffset, orgOffsetY, OffsetY_Recalculated);
}


float FixedRefValue()
{
return 1.0f;
Expand Down Expand Up @@ -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<float**, 1> YOffset = {
get_pattern<float*>("D8 25 ? ? ? ? D9 1C 24 A1", 2),
};

HookEach_MessageYOffset(YOffset, PatchFloat);
InterceptCall(setDropColor, orgSetDropColor, SetDropColor_Scale<YOffset.size()>);
}
TXN_CATCH();

FLAUtils::Init(moduleList);
}

Expand Down

0 comments on commit 7d055f9

Please sign in to comment.