diff --git a/Screens.cpp b/Screens.cpp index 723e2126..6ddd8c47 100644 --- a/Screens.cpp +++ b/Screens.cpp @@ -4,6 +4,7 @@ int iResolution; // INI file int iPlayIntro; int iDisableMouseScrolling; int iUseWinFonts; +float fTooltipScaleFactor; /* WANNE, Sgt.Kolja * INI file (Windowed or Fullscreen) * REPLACE all defines WINDOWED_MODE with this variable diff --git a/Standard Gaming Platform/Font.cpp b/Standard Gaming Platform/Font.cpp index 89bb60fc..5caa433b 100644 --- a/Standard Gaming Platform/Font.cpp +++ b/Standard Gaming Platform/Font.cpp @@ -721,7 +721,7 @@ UINT16 GetFontHeight(INT32 FontNum) MapFont = WinFontMap[FontNum]; if (FontNum != -1) { - return (GetWinFontHeight(L"A", MapFont)); + return (GetWinFontHeight(MapFont)); } } return((UINT16)GetHeight(FontObjs[FontNum], 0)); diff --git a/Standard Gaming Platform/WinFont.cpp b/Standard Gaming Platform/WinFont.cpp index 73689871..aa97f278 100644 --- a/Standard Gaming Platform/WinFont.cpp +++ b/Standard Gaming Platform/WinFont.cpp @@ -26,11 +26,6 @@ #include INT32 FindFreeWinFont( void ); -BOOLEAN gfEnumSucceed = FALSE; - -#ifdef CHINESE -#define DEC_INTERNAL_LEADING -#endif // Private struct not to be exported // to other modules @@ -41,13 +36,12 @@ typedef struct COLORVAL ForeColor; COLORVAL BackColor; UINT8 Height; - UINT8 Width[0x80]; -#ifdef DEC_INTERNAL_LEADING UINT8 InternalLeading; +#ifdef CHINESE + UINT8 Width[0x80]; #endif } HWINFONT; -LOGFONT gLogFont; LONG gWinFontAdjust; HWINFONT WinFonts[WIN_LASTFONT]; @@ -80,6 +74,10 @@ struct { {"HugeFont", {-19, 0, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, ANTIALIASED_QUALITY, VARIABLE_PITCH | FF_DONTCARE, "ja2font3"}, FROMRGB(0, 255, 0)} }; +LOGFONT TooltipLogFont = { -11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, ANTIALIASED_QUALITY, VARIABLE_PITCH | FF_DONTCARE, "Arial" }; +INT32 TOOLTIP_IFONT = -1; +INT32 TOOLTIP_IFONT_BOLD = -1; + void Convert16BitStringTo8Bit( CHAR8 *dst, CHAR16 *src ) { //hope 'dst' is big enough @@ -288,6 +286,29 @@ void ShutdownWinFonts( ) {DeleteWinFont(i);} } +void InitTooltipFonts() +{ + LOGFONT adjustedLogFont = TooltipLogFont; + adjustedLogFont.lfHeight = adjustedLogFont.lfHeight * fTooltipScaleFactor; + + LOGFONT adjustedBoldTooltipLogFont = adjustedLogFont; + adjustedBoldTooltipLogFont.lfWeight = FW_BOLD; + + + TOOLTIP_IFONT = CreateWinFont(adjustedLogFont); + TOOLTIP_IFONT_BOLD = CreateWinFont(adjustedBoldTooltipLogFont); + + COLORVAL regularColor = FROMRGB(201, 197, 143); + COLORVAL boldColor = FROMRGB(223, 176, 1); + SetWinFontForeColor(TOOLTIP_IFONT, ®ularColor); + SetWinFontForeColor(TOOLTIP_IFONT_BOLD, &boldColor); +} + +void ShutdownTooltipFonts() +{ + ShutdownWinFonts(); +} + INT32 FindFreeWinFont( void ) { INT32 iCount; @@ -347,8 +368,10 @@ INT32 CreateWinFont( LOGFONT &logfont ) WinFonts[ iFont ].hFont = hFont; HDC hdc = GetDC(NULL); + SelectObject(hdc, hFont); + +#ifdef CHINESE SIZE RectSize; - SelectObject(hdc, hFont ); wchar_t str[2]=L"\1"; for (int i = 1; i<0x80; i++) { @@ -359,12 +382,12 @@ INT32 CreateWinFont( LOGFONT &logfont ) str[0] = L'啊'; GetTextExtentPoint32W( hdc, str, 1, &RectSize ); WinFonts[iFont].Width[0] = (UINT8)RectSize.cx; +#endif + TEXTMETRIC tm; GetTextMetrics(hdc, &tm); WinFonts[ iFont ].Height = (UINT8)tm.tmAscent; -#ifdef DEC_INTERNAL_LEADING WinFonts[ iFont ].InternalLeading = (UINT8)tm.tmInternalLeading; -#endif ReleaseDC(NULL, hdc); return( iFont ); @@ -444,12 +467,10 @@ void PrintWinFont( UINT32 uiDestBuf, INT32 iFont, INT32 x, INT32 y, STR16 pFontS SetBkMode(hdc, TRANSPARENT); SetTextAlign(hdc, TA_TOP|TA_LEFT); -#ifdef DEC_INTERNAL_LEADING if (y - pWinFont->InternalLeading >=0) { y -= pWinFont->InternalLeading; } -#endif TextOutW( hdc, x, y, string, len ); IDirectDrawSurface2_ReleaseDC( pDDSurface, hdc ); @@ -458,17 +479,10 @@ void PrintWinFont( UINT32 uiDestBuf, INT32 iFont, INT32 x, INT32 y, STR16 pFontS INT16 WinFontStringPixLength( STR16 string2, INT32 iFont ) { - HWINFONT *pWinFont; -#ifndef CHINESE - HDC hdc; - SIZE RectSize; -#endif + HWINFONT *pWinFont; pWinFont = GetWinFont( iFont ); - if ( pWinFont == NULL ) - { - return( 0 ); - } + if (pWinFont == NULL) return(0); #ifdef CHINESE wchar_t *p=string2; @@ -486,7 +500,9 @@ INT16 WinFontStringPixLength( STR16 string2, INT32 iFont ) } return size; #else - hdc = GetDC(NULL); + SIZE RectSize; + HDC hdc = GetDC(NULL); + SelectObject(hdc, pWinFont->hFont ); GetTextExtentPoint32W( hdc, string2, lstrlenW(string2), &RectSize ); ReleaseDC(NULL, hdc); @@ -496,44 +512,18 @@ INT16 WinFontStringPixLength( STR16 string2, INT32 iFont ) } -INT16 GetWinFontHeight( STR16 string2, INT32 iFont ) +INT16 GetWinFontHeight(INT32 iFont) { - HWINFONT *pWinFont; -// HDC hdc; -// SIZE RectSize; + HWINFONT* pWinFont; - pWinFont = GetWinFont( iFont ); + pWinFont = GetWinFont(iFont); - if ( pWinFont == NULL ) - { - return( 0 ); - } - else - { + if (pWinFont == NULL) return(0); #ifdef CHINESE //zwwooooo: Correct tactical interface font height to fixed Chinese characters smearing bug - if (iFont==WIN_TINYFONT1 || iFont==WIN_SMALLFONT1 || iFont==WIN_14POINTARIAL) return pWinFont->Height+2; + if (iFont == WinFontMap[TINYFONT1] || iFont == WinFontMap[SMALLFONT1] || iFont == WinFontMap[WIN_14POINTARIAL]) + { + return pWinFont->Height + 2; + } #endif - return pWinFont->Height; - } - /* - hdc = GetDC(NULL); - SelectObject(hdc, pWinFont->hFont ); - GetTextExtentPoint32W( hdc, string2, lstrlenW(string2), &RectSize ); - ReleaseDC(NULL, hdc); - - return( (INT16)RectSize.cy );*/ -} - -UINT32 WinFont_mprintf( INT32 iFont, INT32 x, INT32 y, STR16 pFontString, ...) -{ - va_list argptr; - CHAR16 string[512]; - - va_start(argptr, pFontString); // Set up variable argument pointer - vswprintf(string, pFontString, argptr); // process gprintf string (get output str) - va_end(argptr); - - PrintWinFont( FontDestBuffer, iFont, x, y, string ); - - return( 1 ); + return pWinFont->Height; } diff --git a/Standard Gaming Platform/WinFont.h b/Standard Gaming Platform/WinFont.h index 77fceb6a..751e42e3 100644 --- a/Standard Gaming Platform/WinFont.h +++ b/Standard Gaming Platform/WinFont.h @@ -5,6 +5,9 @@ void InitWinFonts( ); void ShutdownWinFonts( ); +void InitTooltipFonts(); +void ShutdownTooltipFonts(); + INT32 CreateWinFont( LOGFONT &logfont ); void DeleteWinFont( INT32 iFont ); @@ -14,8 +17,7 @@ void SetWinFontForeColor( INT32 iFont, COLORVAL *pColor ); void PrintWinFont( UINT32 uiDestBuf, INT32 iFont, INT32 x, INT32 y, STR16 pFontString, ...); INT16 WinFontStringPixLength( STR16 string, INT32 iFont ); -INT16 GetWinFontHeight( STR16 string, INT32 iFont ); -UINT32 WinFont_mprintf( INT32 iFont, INT32 x, INT32 y, STR16 pFontString, ...); +INT16 GetWinFontHeight( INT32 iFont ); //if you cahnge this enum, you must change FontInfo struct in WinFont.cpp too. enum { @@ -43,5 +45,7 @@ WIN_LASTFONT }; #define MAX_WINFONTMAP 25 extern INT32 WinFontMap[MAX_WINFONTMAP]; +extern INT32 TOOLTIP_IFONT; +extern INT32 TOOLTIP_IFONT_BOLD; #endif diff --git a/Standard Gaming Platform/mousesystem.cpp b/Standard Gaming Platform/mousesystem.cpp index d6cb3828..ffa479b8 100644 --- a/Standard Gaming Platform/mousesystem.cpp +++ b/Standard Gaming Platform/mousesystem.cpp @@ -1361,32 +1361,32 @@ void SetRegionFastHelpText( MOUSE_REGION *region, const STR16 szText ) //region->FastHelpTimer = gsFastHelpDelay; } -INT16 GetNumberOfLinesInHeight( const STR16 pStringA ) +bool isScalingEnabled() { + return fTooltipScaleFactor > 1; +} + +UINT16 GetScaledFontHeight() { - STR16 pToken; - INT16 sCounter = 0; - CHAR16 pString[ 4096 ]; + return isScalingEnabled() + ? GetWinFontHeight(TOOLTIP_IFONT) + : GetFontHeight(FONT10ARIAL); +} - wcscpy( pString, pStringA ); +// this function returns the number of lines the input string has +// that can be renderered within the screen height +INT16 GetNumberOfLinesInHeight(const STR16 inputString) { + INT32 fontHeight = GetScaledFontHeight(); - // tokenize - pToken = wcstok( pString, L"\n" ); - - while( pToken != NULL ) - { - // WANNE: Fix by Headrock - if ( (sCounter+1) * (GetFontHeight(FONT10ARIAL)+1) > (SCREEN_HEIGHT - 10) ) - { - break; - } - pToken = wcstok( NULL, L"\n" ); - sCounter++; - - /*pToken = wcstok( NULL, L"\n" ); - sCounter++;*/ + INT32 i; + INT32 count = 1; + INT32 stringLength = (INT32)wcslen(inputString); + for (i = 0; i < stringLength && count * (fontHeight + 1) < (SCREEN_HEIGHT - 10); i++) { + if (inputString[i] == '\n' && i + 1 < stringLength) { + count++; + } } - return( sCounter ); + return(count); } @@ -1398,17 +1398,14 @@ INT16 GetNumberOfLinesInHeight( const STR16 pStringA ) // void DisplayFastHelp( MOUSE_REGION *region ) { - UINT16 usFillColor; INT32 iX,iY,iW,iH; if ( region->uiFlags & MSYS_FASTHELP ) { - usFillColor = Get16BPPColor(FROMRGB(250, 240, 188)); + iW = (INT32)GetWidthOfString(region->FastHelpText) + 10 * fTooltipScaleFactor; + iH = (INT32)(GetNumberOfLinesInHeight(region->FastHelpText) * (GetScaledFontHeight() + 1) + 8 * fTooltipScaleFactor); - iW = (INT32)GetWidthOfString( region->FastHelpText ) + 10; - iH = (INT32)( GetNumberOfLinesInHeight( region->FastHelpText ) * (GetFontHeight(FONT10ARIAL)+1) + 8 ); - - iX = (INT32)region->RegionTopLeftX + 10; + iX = (INT32)region->RegionTopLeftX + 10 * fTooltipScaleFactor; if (iX < 0) iX = 0; @@ -1424,7 +1421,7 @@ void DisplayFastHelp( MOUSE_REGION *region ) iY = 0; if ( (iY + iH) >= SCREEN_HEIGHT ) - iY = (SCREEN_HEIGHT - iH - 15); + iY = (SCREEN_HEIGHT - iH - 10); if ( !(region->uiFlags & MSYS_GOT_BACKGROUND) ) { @@ -1445,83 +1442,151 @@ void DisplayFastHelp( MOUSE_REGION *region ) ShadowVideoSurfaceRect( FRAME_BUFFER, iX + 2, iY + 2, iX + iW - 3, iY + iH - 3 ); ShadowVideoSurfaceRect( FRAME_BUFFER, iX + 2, iY + 2, iX + iW - 3, iY + iH - 3 ); - SetFont( FONT10ARIAL ); - SetFontShadow( FONT_NEARBLACK ); - DisplayHelpTokenizedString( region->FastHelpText ,( INT16 )( iX + 5 ), ( INT16 )( iY + 5 ) ); + DisplayHelpTokenizedString( + region->FastHelpText, + (INT16)(iX + (isScalingEnabled() ? 5 * fTooltipScaleFactor : 5)), + (INT16)(iY + (isScalingEnabled() ? 4 * fTooltipScaleFactor : 5)) + ); InvalidateRegion( iX, iY, (iX + iW) , (iY + iH) ); } } } -INT16 GetWidthOfString( const STR16 pStringA ) +INT16 GetWidthOfString(const STR16 inputString) { - CHAR16 pString[ 4096 ]; - STR16 pToken; - INT16 sWidth = 0; - wcscpy( pString, pStringA ); + INT16 width = 0; + CHAR16 stringBuffer[256] = L""; + INT32 bufferIndex = 0; + bool isBold = false; - // tokenize - pToken = wcstok( pString, L"\n" ); + INT32 iFontHeight = GetScaledFontHeight(); - while( pToken != NULL ) - { - if( sWidth < StringPixLength( pToken, FONT10ARIAL ) ) - { - sWidth = StringPixLength( pToken, FONT10ARIAL ); + INT16 lineWidth = 0; + + INT32 lineCounter = 0; + INT32 i; + INT32 stringLength = (INT32)wcslen(inputString); + for (i = 0; i < stringLength; i++) { + 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() + ? WinFontStringPixLength(L"...", TOOLTIP_IFONT) + : StringPixLength(L"...", FONT10ARIAL); + if (width < lineWidth) { + width = lineWidth; + } + break; + } + lineWidth = 0; + lineCounter++; } + else if (inputString[i] == '|') { + isBold = true; + } + else { + stringBuffer[bufferIndex++] = inputString[i]; - pToken = wcstok( NULL, L"\n" ); + // look ahead to see if we need to flush the string buffer + if (i + 1 >= stringLength + || inputString[i + 1] == '\n' + || (isBold && inputString[i + 1] != '|') + || (!isBold && inputString[i + 1] == '|')) { + + // set string ending character + stringBuffer[bufferIndex] = '\0'; + + if (isScalingEnabled()) { + INT32 iFont = isBold ? TOOLTIP_IFONT_BOLD : TOOLTIP_IFONT; + lineWidth += WinFontStringPixLength(stringBuffer, iFont); + } + else { + INT32 iFont = isBold ? FONT10ARIALBOLD : FONT10ARIAL; + SetFont(iFont); + lineWidth += StringPixLength(stringBuffer, iFont); + } + bufferIndex = 0; + isBold = false; + + if (i + 1 >= stringLength || inputString[i + 1] == '\n') { + if (width < lineWidth) { + width = lineWidth; + } + } + } + } } - return( sWidth ); - + return width; } -void DisplayHelpTokenizedString( const STR16 pStringA, INT16 sX, INT16 sY ) +void DisplayHelpTokenizedString(const STR16 inputString, INT16 sX, INT16 sY) { - STR16 pToken; - INT32 iCounter = 0, i; - UINT32 uiCursorXPos; - CHAR16 pString[ 4096 ]; - INT32 iLength; + SetFontShadow(FONT_NEARBLACK); - wcscpy( pString, pStringA ); + INT32 fontHeight = GetScaledFontHeight(); - // tokenize - pToken = wcstok( pString, L"\n" ); + CHAR16 stringBuffer[256] = L""; + INT32 bufferIndex = 0; + bool isBold = false; - while( pToken != NULL ) - { - // WANNE: Fix by Headrock - if ( (iCounter+2) * (GetFontHeight(FONT10ARIAL)+1) > (SCREEN_HEIGHT - 10) ) - { - mprintf( sX, sY + iCounter * (GetFontHeight(FONT10ARIAL)+1), L"..." ); - break; - } - iLength = (INT32)wcslen( pToken ); + INT16 xDelta = 0; - //iLength = (INT32)wcslen( pToken ); - for( i = 0; i < iLength; i++ ) - { - uiCursorXPos = StringPixLengthArgFastHelp( FONT10ARIAL, FONT10ARIALBOLD, i, pToken ); - if( pToken[ i ] == '|' ) - { - i++; - SetFont( FONT10ARIALBOLD ); - SetFontForeground( 146 ); + INT32 lineCounter = 0; + INT32 i; + INT32 stringLength = (INT32)wcslen(inputString); + for (i = 0; i < stringLength; i++) { + 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()) { + PrintWinFont(FontDestBuffer, TOOLTIP_IFONT, sX, sY + lineCounter * (fontHeight + 1), L"..."); + } + else { + SetFont(FONT10ARIAL); + mprintf(sX, sY + lineCounter * (fontHeight + 1), L"..."); + } + break; + } + xDelta = 0; + lineCounter++; + } + else if (inputString[i] == '|') { + isBold = true; + } + else { + stringBuffer[bufferIndex++] = inputString[i]; + + // look ahead to see if we need to flush the string buffer + if (i + 1 >= stringLength + || inputString[i + 1] == '\n' + || (isBold && inputString[i + 1] != '|') + || (!isBold && inputString[i + 1] == '|')) { + + // set string ending character + stringBuffer[bufferIndex] = '\0'; + + if (isScalingEnabled()) { + // 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); + xDelta += WinFontStringPixLength(stringBuffer, iFont); + } + else { + INT32 iFont = isBold ? FONT10ARIALBOLD : FONT10ARIAL; + SetFont(iFont); + SetFontForeground(isBold ? 146 : FONT_BEIGE); + mprintf(sX + xDelta, sY + lineCounter * (fontHeight + 1), L"%s", stringBuffer); + xDelta += StringPixLength(stringBuffer, iFont); + } + bufferIndex = 0; + isBold = false; } - else - { - SetFont( FONT10ARIAL ); - SetFontForeground( FONT_BEIGE ); - } - mprintf( sX + uiCursorXPos, sY + iCounter * (GetFontHeight(FONT10ARIAL)+1), L"%c", pToken[ i ] ); } - pToken = wcstok( NULL, L"\n" ); - iCounter++; } - SetFontDestBuffer( FRAME_BUFFER, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, FALSE ); + + SetFontDestBuffer(FRAME_BUFFER, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, FALSE); } void RenderFastHelp() @@ -1819,4 +1884,4 @@ MOUSE_REGION *get_next_entry_in_MSYS_RegList(MOUSE_REGION *current_region) void ResetWheelState( MOUSE_REGION *region ) { region->WheelState = 0; -} \ No newline at end of file +} diff --git a/Standard Gaming Platform/sgp.cpp b/Standard Gaming Platform/sgp.cpp index daa082fe..91f5d545 100644 --- a/Standard Gaming Platform/sgp.cpp +++ b/Standard Gaming Platform/sgp.cpp @@ -1329,6 +1329,8 @@ void GetRuntimeSettings( ) // WANNE: Should we play the intro? iPlayIntro = (int) GetPrivateProfileInt( "Ja2 Settings","PLAY_INTRO", iPlayIntro, INIFile ); iUseWinFonts = (int) GetPrivateProfileInt( "Ja2 Settings","USE_WINFONTS", iUseWinFonts, INIFile,); + fTooltipScaleFactor = ((int)GetPrivateProfileInt("Ja2 Settings", "TOOLTIP_SCALE_FACTOR", 100, INIFile, )) / 100; + if (fTooltipScaleFactor < 1) fTooltipScaleFactor = 1; // haydent: mouse scrolling iDisableMouseScrolling = (int) GetPrivateProfileInt( "Ja2 Settings","DISABLE_MOUSE_SCROLLING", iDisableMouseScrolling, INIFile ); @@ -1371,6 +1373,8 @@ void GetRuntimeSettings( ) iPlayIntro = (int)oProps.getIntProperty("Ja2 Settings","PLAY_INTRO", iPlayIntro); iUseWinFonts= (int)oProps.getIntProperty("Ja2 Settings","USE_WINFONTS", iUseWinFonts); + fTooltipScaleFactor = ((float)oProps.getFloatProperty("Ja2 Settings", "TOOLTIP_SCALE_FACTOR", 100)) / 100; + if (fTooltipScaleFactor < 1) fTooltipScaleFactor = 1; // haydent: mouse scrolling iDisableMouseScrolling = (int)oProps.getIntProperty("Ja2 Settings","DISABLE_MOUSE_SCROLLING", iDisableMouseScrolling); diff --git a/Strategic/Map Screen Interface.cpp b/Strategic/Map Screen Interface.cpp index 95315861..37eb3087 100644 --- a/Strategic/Map Screen Interface.cpp +++ b/Strategic/Map Screen Interface.cpp @@ -2959,85 +2959,6 @@ void DisplayUserDefineHelpTextRegions( FASTHELPREGION *pRegion ) -extern void DisplayHelpTokenizedString( const STR16 pStringA, INT16 sX, INT16 sY ); -extern INT16 GetNumberOfLinesInHeight( const STR16 pStringA ); -extern INT16 GetWidthOfString( const STR16 pStringA ); - -void DisplaySoldierToolTip( FASTHELPREGION *pRegion ) -{ - UINT16 usFillColor; - INT32 iX,iY,iW,iH; - UINT8 *pDestBuf; - UINT32 uiDestPitchBYTES; - - - // grab the color for the background region - usFillColor = Get16BPPColor(FROMRGB(250, 240, 188)); - - - iX = pRegion->iX; - iY = pRegion->iY; - // get the width and height of the string - //iW = (INT32)( pRegion->iW ) + 14; - iW = (INT32)GetWidthOfString( pRegion->FastHelpText ) + 10; - - //iH = IanWrappedStringHeight( ( UINT16 )iX, ( UINT16 )iY, ( UINT16 )( pRegion->iW ), 0, FONT10ARIAL, FONT_BLACK, pRegion->FastHelpText, FONT_BLACK, TRUE, 0 ); - iH = (INT32)( GetNumberOfLinesInHeight( pRegion->FastHelpText ) * (GetFontHeight(FONT10ARIAL)+1) + 8 ); - - // tack on the outer border - iH += 14; - - // gone not far enough? - if ( iX < 0 ) - iX = 0; - - // gone too far - if ( ( pRegion->iX + iW ) >= SCREEN_WIDTH ) - iX = (SCREEN_WIDTH - iW - 4); - - // what about the y value? - iY = (INT32)pRegion->iY - ( iH * 3 / 4); - - // not far enough - if (iY < 0) - iY = 0; - - // too far - if ( (iY + iH) >= SCREEN_HEIGHT ) - iY = (SCREEN_HEIGHT - iH - 15); - - pDestBuf = LockVideoSurface( FRAME_BUFFER, &uiDestPitchBYTES ); - SetClippingRegionAndImageWidth( uiDestPitchBYTES, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT ); - RectangleDraw( TRUE, iX + 1, iY + 1, iX + iW - 1, iY + iH - 1, Get16BPPColor( FROMRGB( 65, 57, 15 ) ), pDestBuf ); - RectangleDraw( TRUE, iX, iY, iX + iW - 2, iY + iH - 2, Get16BPPColor( FROMRGB( 227, 198, 88 ) ), pDestBuf ); - UnLockVideoSurface( FRAME_BUFFER ); - ShadowVideoSurfaceRect( FRAME_BUFFER, iX + 2, iY + 2, iX + iW - 3, iY + iH - 3 ); - ShadowVideoSurfaceRect( FRAME_BUFFER, iX + 2, iY + 2, iX + iW - 3, iY + iH - 3 ); - - // fillt he video surface areas - //ColorFillVideoSurfaceArea(FRAME_BUFFER, iX, iY, (iX + iW), (iY + iH), 0); - //ColorFillVideoSurfaceArea(FRAME_BUFFER, (iX + 1), (iY + 1), (iX + iW - 1), (iY + iH - 1), usFillColor); - - SetFont( FONT10ARIAL ); - SetFontForeground( FONT_BEIGE ); - - //iH = ( INT32 )DisplayWrappedString( ( INT16 )( iX + 10 ), ( INT16 )( iY + 6 ), ( INT16 )pRegion->iW, 0, FONT10ARIAL, FONT_BEIGE, pRegion->FastHelpText, FONT_NEARBLACK, TRUE, 0 ); - - DisplayHelpTokenizedString( pRegion->FastHelpText ,( INT16 )( iX + 5 ), ( INT16 )( iY + 5 ) ); - - iHeightOfInitFastHelpText = iH + 20; - - InvalidateRegion( iX, iY, (iX + iW) , (iY + iH + 20 ) ); -} - - - - - - - - - void DisplayFastHelpForInitialTripInToMapScreen( FASTHELPREGION *pRegion ) { if( gTacticalStatus.fDidGameJustStart ) diff --git a/Tactical/SoldierTooltips.cpp b/Tactical/SoldierTooltips.cpp index 06517851..706d64e8 100644 --- a/Tactical/SoldierTooltips.cpp +++ b/Tactical/SoldierTooltips.cpp @@ -752,29 +752,23 @@ void DrawMouseTooltip() extern void DisplayTooltipString( const STR16 pStringA, INT16 sX, INT16 sY ); extern void j_log(PTR,...); + UINT16 fontHeight = fTooltipScaleFactor > 1 + ? GetWinFontHeight(TOOLTIP_IFONT) + : GetFontHeight(FONT10ARIAL); + iX = mouseTT.iX;iY = mouseTT.iY; - iW = (INT32)GetWidthOfString( mouseTT.FastHelpText ) + 10; - iH = (INT32)( GetNumberOfLinesInHeight( mouseTT.FastHelpText ) * (GetFontHeight(FONT10ARIAL)+1) + 8 ); + iW = (INT32)(GetWidthOfString(mouseTT.FastHelpText) + 10 * fTooltipScaleFactor); + iH = (INT32)(GetNumberOfLinesInHeight(mouseTT.FastHelpText) * (fontHeight + 1) + 8 * fTooltipScaleFactor); - if(1)//draw at cursor - { - iY -= (iH / 2); - if (gusMouseXPos > (SCREEN_WIDTH / 2)) - iX = gusMouseXPos - iW - 24; - else - iX = gusMouseXPos + 24; - //if (gusMouseYPos > (SCREEN_HEIGHT / 2)) - // iY -= 32; - - if (iY <= 0) iY += 32; - } + iY -= (iH / 2); + if (gusMouseXPos > (SCREEN_WIDTH / 2)) + iX = gusMouseXPos - iW - 24; else - { //draw in panel - //502,485 658,596 160*110 580,540 - iX = 580 - (iW / 2); - iY = 540 - (iH/2); - if (iY + iH > SCREEN_HEIGHT) iY = SCREEN_HEIGHT - iH - 3 ; - } + iX = gusMouseXPos + 24; + //if (gusMouseYPos > (SCREEN_HEIGHT / 2)) + // iY -= 32; + + if (iY <= 0) iY += 32; pDestBuf = LockVideoSurface( FRAME_BUFFER, &uiDestPitchBYTES ); SetClippingRegionAndImageWidth( uiDestPitchBYTES, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT ); @@ -784,10 +778,12 @@ void DrawMouseTooltip() ShadowVideoSurfaceRect( FRAME_BUFFER, iX + 2, iY + 2, iX + iW - 3, iY + iH - 3 ); ShadowVideoSurfaceRect( FRAME_BUFFER, iX + 2, iY + 2, iX + iW - 3, iY + iH - 3 ); - SetFont( FONT10ARIAL ); - SetFontShadow( FONT_NEARBLACK ); - DisplayHelpTokenizedString( mouseTT.FastHelpText ,( INT16 )( iX + 5 ), ( INT16 )( iY + 5 ) ); + DisplayHelpTokenizedString( + mouseTT.FastHelpText, + (INT16)(iX + (fTooltipScaleFactor > 1 ? 5 * fTooltipScaleFactor : 5)), + (INT16)(iY + (fTooltipScaleFactor > 1 ? 4 * fTooltipScaleFactor : 5)) + ); InvalidateRegion( iX, iY, (iX + iW) , (iY + iH) ); //InvalidateScreen(); -} \ No newline at end of file +} diff --git a/Utils/Font Control.cpp b/Utils/Font Control.cpp index 945fe2a3..87c140f5 100644 --- a/Utils/Font Control.cpp +++ b/Utils/Font Control.cpp @@ -231,6 +231,7 @@ BOOLEAN InitializeFonts( ) if ( iUseWinFonts ) { InitWinFonts( ); } + InitTooltipFonts(); return( TRUE ); } @@ -261,6 +262,7 @@ void ShutdownFonts( ) if ( iUseWinFonts ) { ShutdownWinFonts(); } + ShutdownTooltipFonts(); } // Set shades for fonts diff --git a/local.h b/local.h index cf0bba6f..c52e262f 100644 --- a/local.h +++ b/local.h @@ -32,6 +32,7 @@ extern UINT16 SCREEN_HEIGHT; extern int iResolution; // Resolution id from the ini file extern int iPlayIntro; extern int iUseWinFonts; +extern float fTooltipScaleFactor; extern int iDisableMouseScrolling; extern INT16 iScreenWidthOffset; extern INT16 iScreenHeightOffset; @@ -82,4 +83,4 @@ extern BOOLEAN fDisplayOverheadMap; #define PIXEL_DEPTH 16 -#endif \ No newline at end of file +#endif