From 1c82efb79707cf0f04ac7d8aadd32e983e1760ff Mon Sep 17 00:00:00 2001 From: NorthFury Date: Sat, 27 May 2023 17:41:38 +0200 Subject: [PATCH] use isTooltipScalingEnabled for soldier tooltips --- Standard Gaming Platform/mousesystem.cpp | 17 +++++++++-------- Tactical/SoldierTooltips.cpp | 7 ++++--- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/Standard Gaming Platform/mousesystem.cpp b/Standard Gaming Platform/mousesystem.cpp index 55109c57..a9fb22c2 100644 --- a/Standard Gaming Platform/mousesystem.cpp +++ b/Standard Gaming Platform/mousesystem.cpp @@ -56,6 +56,7 @@ extern void ReleaseAnchorMode(); //private function used here (implemented in Bu INT16 GetNumberOfLinesInHeight( const STR16 pStringA ); INT16 GetWidthOfString( const STR16 pStringA ); void DisplayHelpTokenizedString( const STR16 pStringA, INT16 sX, INT16 sY ); +bool isTooltipScalingEnabled(); @@ -1361,13 +1362,13 @@ void SetRegionFastHelpText( MOUSE_REGION *region, const STR16 szText ) //region->FastHelpTimer = gsFastHelpDelay; } -bool isScalingEnabled() { +bool isTooltipScalingEnabled() { return fTooltipScaleFactor > 1; } UINT16 GetScaledFontHeight() { - return isScalingEnabled() + return isTooltipScalingEnabled() ? GetWinFontHeight(TOOLTIP_IFONT) : GetFontHeight(FONT10ARIAL); } @@ -1443,8 +1444,8 @@ void DisplayFastHelp( MOUSE_REGION *region ) DisplayHelpTokenizedString( region->FastHelpText, - (INT16)(iX + (isScalingEnabled() ? 5 * fTooltipScaleFactor : 5)), - (INT16)(iY + (isScalingEnabled() ? 4 * fTooltipScaleFactor : 5)) + (INT16)(iX + (isTooltipScalingEnabled() ? 5 * fTooltipScaleFactor : 5)), + (INT16)(iY + (isTooltipScalingEnabled() ? 4 * fTooltipScaleFactor : 5)) ); InvalidateRegion( iX, iY, (iX + iW) , (iY + iH) ); } @@ -1469,7 +1470,7 @@ INT16 GetWidthOfString(const STR16 inputString) if (inputString[i] == '\n') { // if the lines don't fit the screen the last line is ... if ((lineCounter + 2) * (iFontHeight + 1) > (SCREEN_HEIGHT - 10)) { - lineWidth = isScalingEnabled() + lineWidth = isTooltipScalingEnabled() ? WinFontStringPixLength(L"...", TOOLTIP_IFONT) : StringPixLength(L"...", FONT10ARIAL); if (width < lineWidth) { @@ -1495,7 +1496,7 @@ INT16 GetWidthOfString(const STR16 inputString) // set string ending character stringBuffer[bufferIndex] = '\0'; - if (isScalingEnabled()) { + if (isTooltipScalingEnabled()) { INT32 iFont = isBold ? TOOLTIP_IFONT_BOLD : TOOLTIP_IFONT; lineWidth += WinFontStringPixLength(stringBuffer, iFont); } @@ -1537,7 +1538,7 @@ void DisplayHelpTokenizedString(const STR16 inputString, INT16 sX, INT16 sY) if (inputString[i] == '\n') { // if the lines don't fit the screen the last line is ... if ((lineCounter + 2) * (fontHeight + 1) > (SCREEN_HEIGHT - 10)) { - if (isScalingEnabled()) { + if (isTooltipScalingEnabled()) { PrintWinFont(FontDestBuffer, TOOLTIP_IFONT, sX, sY + lineCounter * (fontHeight + 1), L"..."); } else { @@ -1564,7 +1565,7 @@ void DisplayHelpTokenizedString(const STR16 inputString, INT16 sX, INT16 sY) // set string ending character stringBuffer[bufferIndex] = '\0'; - if (isScalingEnabled()) { + if (isTooltipScalingEnabled()) { // the font color is set on font initialization INT32 iFont = isBold ? TOOLTIP_IFONT_BOLD : TOOLTIP_IFONT; PrintWinFont(FontDestBuffer, iFont, sX + xDelta, sY + lineCounter * (fontHeight + 1), L"%s", stringBuffer); diff --git a/Tactical/SoldierTooltips.cpp b/Tactical/SoldierTooltips.cpp index 706d64e8..b1b08ccf 100644 --- a/Tactical/SoldierTooltips.cpp +++ b/Tactical/SoldierTooltips.cpp @@ -743,6 +743,7 @@ void DrawMouseTooltip() UINT32 uiDestPitchBYTES; static INT32 iX, iY, iW, iH; + extern bool isTooltipScalingEnabled(); extern INT16 GetWidthOfString(const STR16); extern INT16 GetNumberOfLinesInHeight(const STR16); extern void DisplayHelpTokenizedString(const STR16,INT16,INT16); @@ -752,7 +753,7 @@ void DrawMouseTooltip() extern void DisplayTooltipString( const STR16 pStringA, INT16 sX, INT16 sY ); extern void j_log(PTR,...); - UINT16 fontHeight = fTooltipScaleFactor > 1 + UINT16 fontHeight = isTooltipScalingEnabled() ? GetWinFontHeight(TOOLTIP_IFONT) : GetFontHeight(FONT10ARIAL); @@ -780,8 +781,8 @@ void DrawMouseTooltip() DisplayHelpTokenizedString( mouseTT.FastHelpText, - (INT16)(iX + (fTooltipScaleFactor > 1 ? 5 * fTooltipScaleFactor : 5)), - (INT16)(iY + (fTooltipScaleFactor > 1 ? 4 * fTooltipScaleFactor : 5)) + (INT16)(iX + (isTooltipScalingEnabled() ? 5 * fTooltipScaleFactor : 5)), + (INT16)(iY + (isTooltipScalingEnabled() ? 4 * fTooltipScaleFactor : 5)) ); InvalidateRegion( iX, iY, (iX + iW) , (iY + iH) );