From 344d70800fd104a430dcc4fd8a6d271886645def Mon Sep 17 00:00:00 2001 From: Silent Date: Sat, 23 Dec 2017 18:38:45 +0100 Subject: [PATCH] Thin templates for margin fixes for III/VC --- SilentPatchIII/SilentPatchIII.cpp | 34 ++++++++++++++++++------------- SilentPatchVC/SilentPatchVC.cpp | 34 ++++++++++++++++++------------- 2 files changed, 40 insertions(+), 28 deletions(-) diff --git a/SilentPatchIII/SilentPatchIII.cpp b/SilentPatchIII/SilentPatchIII.cpp index 362d5f2..ef02a66 100644 --- a/SilentPatchIII/SilentPatchIII.cpp +++ b/SilentPatchIII/SilentPatchIII.cpp @@ -187,34 +187,40 @@ void __stdcall Recalculate(signed int nShadow) fShadowYSize = nShadow * GetHeightMult() * RsGlobal->MaximumHeight; } -template -void AlteredPrintString(float fX, float fY, const wchar_t* pText) +static void AlteredPrintString_Internal(float fX, float fY, float fMarginX, float fMarginY, const wchar_t* pText) { - float fMarginX = **reinterpret_cast(pFltX); - float fMarginY = **reinterpret_cast(pFltY); PrintString(fX - fMarginX + (fMarginX * GetWidthMult() * RsGlobal->MaximumWidth), fY - fMarginY + (fMarginY * GetHeightMult() * RsGlobal->MaximumHeight), pText); } -template +template +void AlteredPrintString(float fX, float fY, const wchar_t* pText) +{ + const float fMarginX = **reinterpret_cast(pFltX); + const float fMarginY = **reinterpret_cast(pFltY); + AlteredPrintString_Internal(fX, fY, fMarginX, fMarginY, pText); +} + +template void AlteredPrintStringMinus(float fX, float fY, const wchar_t* pText) { - float fMarginX = **reinterpret_cast(pFltX); - float fMarginY = **reinterpret_cast(pFltY); - PrintString(fX + fMarginX - (fMarginX * GetWidthMult() * RsGlobal->MaximumWidth), fY + fMarginY - (fMarginY * GetHeightMult() * RsGlobal->MaximumHeight), pText); + const float fMarginX = **reinterpret_cast(pFltX); + const float fMarginY = **reinterpret_cast(pFltY); + AlteredPrintString_Internal(fX, fY, -fMarginX, -fMarginY, pText); } -template +template void AlteredPrintStringXOnly(float fX, float fY, const wchar_t* pText) { - float fMarginX = **reinterpret_cast(pFltX); - PrintString(fX - fMarginX + (fMarginX * GetWidthMult() * RsGlobal->MaximumWidth), fY, pText); + const float fMarginX = **reinterpret_cast(pFltX); + AlteredPrintString_Internal(fX, fY, fMarginX, 0.0f, pText); } -template +template void AlteredPrintStringYOnly(float fX, float fY, const wchar_t* pText) { - float fMarginY = **reinterpret_cast(pFltY); - PrintString(fX, fY - fMarginY + (fMarginY * GetHeightMult() * RsGlobal->MaximumHeight), pText); + const float fMarginY = **reinterpret_cast(pFltY); + AlteredPrintString_Internal(fX, fY, 0.0f, fMarginY, pText); + } float FixedRefValue() diff --git a/SilentPatchVC/SilentPatchVC.cpp b/SilentPatchVC/SilentPatchVC.cpp index f942569..2a1e491 100644 --- a/SilentPatchVC/SilentPatchVC.cpp +++ b/SilentPatchVC/SilentPatchVC.cpp @@ -95,34 +95,40 @@ void __stdcall Recalculate(float& fX, float& fY, signed int nShadow) fY = nShadow * GetHeightMult() * RsGlobal->MaximumHeight; } -template -void AlteredPrintString(float fX, float fY, const wchar_t* pText) +static void AlteredPrintString_Internal(float fX, float fY, float fMarginX, float fMarginY, const wchar_t* pText) { - float fMarginX = **reinterpret_cast(pFltX); - float fMarginY = **reinterpret_cast(pFltY); PrintString(fX - fMarginX + (fMarginX * GetWidthMult() * RsGlobal->MaximumWidth), fY - fMarginY + (fMarginY * GetHeightMult() * RsGlobal->MaximumHeight), pText); } -template +template +void AlteredPrintString(float fX, float fY, const wchar_t* pText) +{ + const float fMarginX = **reinterpret_cast(pFltX); + const float fMarginY = **reinterpret_cast(pFltY); + AlteredPrintString_Internal(fX, fY, fMarginX, fMarginY, pText); +} + +template void AlteredPrintStringMinus(float fX, float fY, const wchar_t* pText) { - float fMarginX = **reinterpret_cast(pFltX); - float fMarginY = **reinterpret_cast(pFltY); - PrintString(fX + fMarginX - (fMarginX * GetWidthMult() * RsGlobal->MaximumWidth), fY + fMarginY - (fMarginY * GetHeightMult() * RsGlobal->MaximumHeight), pText); + const float fMarginX = **reinterpret_cast(pFltX); + const float fMarginY = **reinterpret_cast(pFltY); + AlteredPrintString_Internal(fX, fY, -fMarginX, -fMarginY, pText); } -template +template void AlteredPrintStringXOnly(float fX, float fY, const wchar_t* pText) { - float fMarginX = **reinterpret_cast(pFltX); - PrintString(fX - fMarginX + (fMarginX * GetWidthMult() * RsGlobal->MaximumWidth), fY, pText); + const float fMarginX = **reinterpret_cast(pFltX); + AlteredPrintString_Internal(fX, fY, fMarginX, 0.0f, pText); } -template +template void AlteredPrintStringYOnly(float fX, float fY, const wchar_t* pText) { - float fMarginY = **reinterpret_cast(pFltY); - PrintString(fX, fY - fMarginY + (fMarginY * GetHeightMult() * RsGlobal->MaximumHeight), pText); + const float fMarginY = **reinterpret_cast(pFltY); + AlteredPrintString_Internal(fX, fY, 0.0f, fMarginY, pText); + } float FixedRefValue()