use isTooltipScalingEnabled for soldier tooltips

This commit is contained in:
NorthFury
2023-05-27 21:52:35 -03:00
committed by majcosta
parent 52d8135709
commit 1c82efb797
2 changed files with 13 additions and 11 deletions
+9 -8
View File
@@ -56,6 +56,7 @@ extern void ReleaseAnchorMode(); //private function used here (implemented in Bu
INT16 GetNumberOfLinesInHeight( const STR16 pStringA ); INT16 GetNumberOfLinesInHeight( const STR16 pStringA );
INT16 GetWidthOfString( const STR16 pStringA ); INT16 GetWidthOfString( const STR16 pStringA );
void DisplayHelpTokenizedString( const STR16 pStringA, INT16 sX, INT16 sY ); 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; //region->FastHelpTimer = gsFastHelpDelay;
} }
bool isScalingEnabled() { bool isTooltipScalingEnabled() {
return fTooltipScaleFactor > 1; return fTooltipScaleFactor > 1;
} }
UINT16 GetScaledFontHeight() UINT16 GetScaledFontHeight()
{ {
return isScalingEnabled() return isTooltipScalingEnabled()
? GetWinFontHeight(TOOLTIP_IFONT) ? GetWinFontHeight(TOOLTIP_IFONT)
: GetFontHeight(FONT10ARIAL); : GetFontHeight(FONT10ARIAL);
} }
@@ -1443,8 +1444,8 @@ void DisplayFastHelp( MOUSE_REGION *region )
DisplayHelpTokenizedString( DisplayHelpTokenizedString(
region->FastHelpText, region->FastHelpText,
(INT16)(iX + (isScalingEnabled() ? 5 * fTooltipScaleFactor : 5)), (INT16)(iX + (isTooltipScalingEnabled() ? 5 * fTooltipScaleFactor : 5)),
(INT16)(iY + (isScalingEnabled() ? 4 * fTooltipScaleFactor : 5)) (INT16)(iY + (isTooltipScalingEnabled() ? 4 * fTooltipScaleFactor : 5))
); );
InvalidateRegion( iX, iY, (iX + iW) , (iY + iH) ); InvalidateRegion( iX, iY, (iX + iW) , (iY + iH) );
} }
@@ -1469,7 +1470,7 @@ INT16 GetWidthOfString(const STR16 inputString)
if (inputString[i] == '\n') { if (inputString[i] == '\n') {
// if the lines don't fit the screen the last line is ... // if the lines don't fit the screen the last line is ...
if ((lineCounter + 2) * (iFontHeight + 1) > (SCREEN_HEIGHT - 10)) { if ((lineCounter + 2) * (iFontHeight + 1) > (SCREEN_HEIGHT - 10)) {
lineWidth = isScalingEnabled() lineWidth = isTooltipScalingEnabled()
? WinFontStringPixLength(L"...", TOOLTIP_IFONT) ? WinFontStringPixLength(L"...", TOOLTIP_IFONT)
: StringPixLength(L"...", FONT10ARIAL); : StringPixLength(L"...", FONT10ARIAL);
if (width < lineWidth) { if (width < lineWidth) {
@@ -1495,7 +1496,7 @@ INT16 GetWidthOfString(const STR16 inputString)
// set string ending character // set string ending character
stringBuffer[bufferIndex] = '\0'; stringBuffer[bufferIndex] = '\0';
if (isScalingEnabled()) { if (isTooltipScalingEnabled()) {
INT32 iFont = isBold ? TOOLTIP_IFONT_BOLD : TOOLTIP_IFONT; INT32 iFont = isBold ? TOOLTIP_IFONT_BOLD : TOOLTIP_IFONT;
lineWidth += WinFontStringPixLength(stringBuffer, iFont); lineWidth += WinFontStringPixLength(stringBuffer, iFont);
} }
@@ -1537,7 +1538,7 @@ void DisplayHelpTokenizedString(const STR16 inputString, INT16 sX, INT16 sY)
if (inputString[i] == '\n') { if (inputString[i] == '\n') {
// if the lines don't fit the screen the last line is ... // if the lines don't fit the screen the last line is ...
if ((lineCounter + 2) * (fontHeight + 1) > (SCREEN_HEIGHT - 10)) { if ((lineCounter + 2) * (fontHeight + 1) > (SCREEN_HEIGHT - 10)) {
if (isScalingEnabled()) { if (isTooltipScalingEnabled()) {
PrintWinFont(FontDestBuffer, TOOLTIP_IFONT, sX, sY + lineCounter * (fontHeight + 1), L"..."); PrintWinFont(FontDestBuffer, TOOLTIP_IFONT, sX, sY + lineCounter * (fontHeight + 1), L"...");
} }
else { else {
@@ -1564,7 +1565,7 @@ void DisplayHelpTokenizedString(const STR16 inputString, INT16 sX, INT16 sY)
// set string ending character // set string ending character
stringBuffer[bufferIndex] = '\0'; stringBuffer[bufferIndex] = '\0';
if (isScalingEnabled()) { if (isTooltipScalingEnabled()) {
// the font color is set on font initialization // the font color is set on font initialization
INT32 iFont = isBold ? TOOLTIP_IFONT_BOLD : TOOLTIP_IFONT; INT32 iFont = isBold ? TOOLTIP_IFONT_BOLD : TOOLTIP_IFONT;
PrintWinFont(FontDestBuffer, iFont, sX + xDelta, sY + lineCounter * (fontHeight + 1), L"%s", stringBuffer); PrintWinFont(FontDestBuffer, iFont, sX + xDelta, sY + lineCounter * (fontHeight + 1), L"%s", stringBuffer);
+4 -3
View File
@@ -743,6 +743,7 @@ void DrawMouseTooltip()
UINT32 uiDestPitchBYTES; UINT32 uiDestPitchBYTES;
static INT32 iX, iY, iW, iH; static INT32 iX, iY, iW, iH;
extern bool isTooltipScalingEnabled();
extern INT16 GetWidthOfString(const STR16); extern INT16 GetWidthOfString(const STR16);
extern INT16 GetNumberOfLinesInHeight(const STR16); extern INT16 GetNumberOfLinesInHeight(const STR16);
extern void DisplayHelpTokenizedString(const STR16,INT16,INT16); 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 DisplayTooltipString( const STR16 pStringA, INT16 sX, INT16 sY );
extern void j_log(PTR,...); extern void j_log(PTR,...);
UINT16 fontHeight = fTooltipScaleFactor > 1 UINT16 fontHeight = isTooltipScalingEnabled()
? GetWinFontHeight(TOOLTIP_IFONT) ? GetWinFontHeight(TOOLTIP_IFONT)
: GetFontHeight(FONT10ARIAL); : GetFontHeight(FONT10ARIAL);
@@ -780,8 +781,8 @@ void DrawMouseTooltip()
DisplayHelpTokenizedString( DisplayHelpTokenizedString(
mouseTT.FastHelpText, mouseTT.FastHelpText,
(INT16)(iX + (fTooltipScaleFactor > 1 ? 5 * fTooltipScaleFactor : 5)), (INT16)(iX + (isTooltipScalingEnabled() ? 5 * fTooltipScaleFactor : 5)),
(INT16)(iY + (fTooltipScaleFactor > 1 ? 4 * fTooltipScaleFactor : 5)) (INT16)(iY + (isTooltipScalingEnabled() ? 4 * fTooltipScaleFactor : 5))
); );
InvalidateRegion( iX, iY, (iX + iW) , (iY + iH) ); InvalidateRegion( iX, iY, (iX + iW) , (iY + iH) );