added option to scale tooltip rendering

This commit is contained in:
NorthFury
2023-05-27 21:52:35 -03:00
committed by majcosta
parent c13a44c445
commit 456cfa18cf
10 changed files with 232 additions and 248 deletions
+1
View File
@@ -4,6 +4,7 @@ int iResolution; // INI file
int iPlayIntro; int iPlayIntro;
int iDisableMouseScrolling; int iDisableMouseScrolling;
int iUseWinFonts; int iUseWinFonts;
float fTooltipScaleFactor;
/* WANNE, Sgt.Kolja /* WANNE, Sgt.Kolja
* INI file (Windowed or Fullscreen) * INI file (Windowed or Fullscreen)
* REPLACE all defines WINDOWED_MODE with this variable * REPLACE all defines WINDOWED_MODE with this variable
+1 -1
View File
@@ -721,7 +721,7 @@ UINT16 GetFontHeight(INT32 FontNum)
MapFont = WinFontMap[FontNum]; MapFont = WinFontMap[FontNum];
if (FontNum != -1) if (FontNum != -1)
{ {
return (GetWinFontHeight(L"A", MapFont)); return (GetWinFontHeight(MapFont));
} }
} }
return((UINT16)GetHeight(FontObjs[FontNum], 0)); return((UINT16)GetHeight(FontObjs[FontNum], 0));
+48 -58
View File
@@ -26,11 +26,6 @@
#include <vfs/Tools/vfs_property_container.h> #include <vfs/Tools/vfs_property_container.h>
INT32 FindFreeWinFont( void ); INT32 FindFreeWinFont( void );
BOOLEAN gfEnumSucceed = FALSE;
#ifdef CHINESE
#define DEC_INTERNAL_LEADING
#endif
// Private struct not to be exported // Private struct not to be exported
// to other modules // to other modules
@@ -41,13 +36,12 @@ typedef struct
COLORVAL ForeColor; COLORVAL ForeColor;
COLORVAL BackColor; COLORVAL BackColor;
UINT8 Height; UINT8 Height;
UINT8 Width[0x80];
#ifdef DEC_INTERNAL_LEADING
UINT8 InternalLeading; UINT8 InternalLeading;
#ifdef CHINESE
UINT8 Width[0x80];
#endif #endif
} HWINFONT; } HWINFONT;
LOGFONT gLogFont;
LONG gWinFontAdjust; LONG gWinFontAdjust;
HWINFONT WinFonts[WIN_LASTFONT]; 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)} {"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 ) void Convert16BitStringTo8Bit( CHAR8 *dst, CHAR16 *src )
{ {
//hope 'dst' is big enough //hope 'dst' is big enough
@@ -288,6 +286,29 @@ void ShutdownWinFonts( )
{DeleteWinFont(i);} {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, &regularColor);
SetWinFontForeColor(TOOLTIP_IFONT_BOLD, &boldColor);
}
void ShutdownTooltipFonts()
{
ShutdownWinFonts();
}
INT32 FindFreeWinFont( void ) INT32 FindFreeWinFont( void )
{ {
INT32 iCount; INT32 iCount;
@@ -347,8 +368,10 @@ INT32 CreateWinFont( LOGFONT &logfont )
WinFonts[ iFont ].hFont = hFont; WinFonts[ iFont ].hFont = hFont;
HDC hdc = GetDC(NULL); HDC hdc = GetDC(NULL);
SelectObject(hdc, hFont);
#ifdef CHINESE
SIZE RectSize; SIZE RectSize;
SelectObject(hdc, hFont );
wchar_t str[2]=L"\1"; wchar_t str[2]=L"\1";
for (int i = 1; i<0x80; i++) for (int i = 1; i<0x80; i++)
{ {
@@ -359,12 +382,12 @@ INT32 CreateWinFont( LOGFONT &logfont )
str[0] = L''; str[0] = L'';
GetTextExtentPoint32W( hdc, str, 1, &RectSize ); GetTextExtentPoint32W( hdc, str, 1, &RectSize );
WinFonts[iFont].Width[0] = (UINT8)RectSize.cx; WinFonts[iFont].Width[0] = (UINT8)RectSize.cx;
#endif
TEXTMETRIC tm; TEXTMETRIC tm;
GetTextMetrics(hdc, &tm); GetTextMetrics(hdc, &tm);
WinFonts[ iFont ].Height = (UINT8)tm.tmAscent; WinFonts[ iFont ].Height = (UINT8)tm.tmAscent;
#ifdef DEC_INTERNAL_LEADING
WinFonts[ iFont ].InternalLeading = (UINT8)tm.tmInternalLeading; WinFonts[ iFont ].InternalLeading = (UINT8)tm.tmInternalLeading;
#endif
ReleaseDC(NULL, hdc); ReleaseDC(NULL, hdc);
return( iFont ); return( iFont );
@@ -444,12 +467,10 @@ void PrintWinFont( UINT32 uiDestBuf, INT32 iFont, INT32 x, INT32 y, STR16 pFontS
SetBkMode(hdc, TRANSPARENT); SetBkMode(hdc, TRANSPARENT);
SetTextAlign(hdc, TA_TOP|TA_LEFT); SetTextAlign(hdc, TA_TOP|TA_LEFT);
#ifdef DEC_INTERNAL_LEADING
if (y - pWinFont->InternalLeading >=0) if (y - pWinFont->InternalLeading >=0)
{ {
y -= pWinFont->InternalLeading; y -= pWinFont->InternalLeading;
} }
#endif
TextOutW( hdc, x, y, string, len ); TextOutW( hdc, x, y, string, len );
IDirectDrawSurface2_ReleaseDC( pDDSurface, hdc ); 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 ) INT16 WinFontStringPixLength( STR16 string2, INT32 iFont )
{ {
HWINFONT *pWinFont; HWINFONT *pWinFont;
#ifndef CHINESE
HDC hdc;
SIZE RectSize;
#endif
pWinFont = GetWinFont( iFont ); pWinFont = GetWinFont( iFont );
if ( pWinFont == NULL ) if (pWinFont == NULL) return(0);
{
return( 0 );
}
#ifdef CHINESE #ifdef CHINESE
wchar_t *p=string2; wchar_t *p=string2;
@@ -486,7 +500,9 @@ INT16 WinFontStringPixLength( STR16 string2, INT32 iFont )
} }
return size; return size;
#else #else
hdc = GetDC(NULL); SIZE RectSize;
HDC hdc = GetDC(NULL);
SelectObject(hdc, pWinFont->hFont ); SelectObject(hdc, pWinFont->hFont );
GetTextExtentPoint32W( hdc, string2, lstrlenW(string2), &RectSize ); GetTextExtentPoint32W( hdc, string2, lstrlenW(string2), &RectSize );
ReleaseDC(NULL, hdc); 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; HWINFONT* pWinFont;
// HDC hdc;
// SIZE RectSize;
pWinFont = GetWinFont( iFont ); pWinFont = GetWinFont(iFont);
if ( pWinFont == NULL ) if (pWinFont == NULL) return(0);
{
return( 0 );
}
else
{
#ifdef CHINESE //zwwooooo: Correct tactical interface font height to fixed Chinese characters smearing bug #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 #endif
return pWinFont->Height; 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 );
} }
+6 -2
View File
@@ -5,6 +5,9 @@
void InitWinFonts( ); void InitWinFonts( );
void ShutdownWinFonts( ); void ShutdownWinFonts( );
void InitTooltipFonts();
void ShutdownTooltipFonts();
INT32 CreateWinFont( LOGFONT &logfont ); INT32 CreateWinFont( LOGFONT &logfont );
void DeleteWinFont( INT32 iFont ); 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, ...); void PrintWinFont( UINT32 uiDestBuf, INT32 iFont, INT32 x, INT32 y, STR16 pFontString, ...);
INT16 WinFontStringPixLength( STR16 string, INT32 iFont ); INT16 WinFontStringPixLength( STR16 string, INT32 iFont );
INT16 GetWinFontHeight( STR16 string, INT32 iFont ); INT16 GetWinFontHeight( INT32 iFont );
UINT32 WinFont_mprintf( INT32 iFont, INT32 x, INT32 y, STR16 pFontString, ...);
//if you cahnge this enum, you must change FontInfo struct in WinFont.cpp too. //if you cahnge this enum, you must change FontInfo struct in WinFont.cpp too.
enum { enum {
@@ -43,5 +45,7 @@ WIN_LASTFONT
}; };
#define MAX_WINFONTMAP 25 #define MAX_WINFONTMAP 25
extern INT32 WinFontMap[MAX_WINFONTMAP]; extern INT32 WinFontMap[MAX_WINFONTMAP];
extern INT32 TOOLTIP_IFONT;
extern INT32 TOOLTIP_IFONT_BOLD;
#endif #endif
+148 -83
View File
@@ -1361,32 +1361,32 @@ void SetRegionFastHelpText( MOUSE_REGION *region, const STR16 szText )
//region->FastHelpTimer = gsFastHelpDelay; //region->FastHelpTimer = gsFastHelpDelay;
} }
INT16 GetNumberOfLinesInHeight( const STR16 pStringA ) bool isScalingEnabled() {
return fTooltipScaleFactor > 1;
}
UINT16 GetScaledFontHeight()
{ {
STR16 pToken; return isScalingEnabled()
INT16 sCounter = 0; ? GetWinFontHeight(TOOLTIP_IFONT)
CHAR16 pString[ 4096 ]; : 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 INT32 i;
pToken = wcstok( pString, L"\n" ); INT32 count = 1;
INT32 stringLength = (INT32)wcslen(inputString);
while( pToken != NULL ) for (i = 0; i < stringLength && count * (fontHeight + 1) < (SCREEN_HEIGHT - 10); i++) {
{ if (inputString[i] == '\n' && i + 1 < stringLength) {
// WANNE: Fix by Headrock count++;
if ( (sCounter+1) * (GetFontHeight(FONT10ARIAL)+1) > (SCREEN_HEIGHT - 10) ) }
{
break;
}
pToken = wcstok( NULL, L"\n" );
sCounter++;
/*pToken = wcstok( NULL, L"\n" );
sCounter++;*/
} }
return( sCounter ); return(count);
} }
@@ -1398,17 +1398,14 @@ INT16 GetNumberOfLinesInHeight( const STR16 pStringA )
// //
void DisplayFastHelp( MOUSE_REGION *region ) void DisplayFastHelp( MOUSE_REGION *region )
{ {
UINT16 usFillColor;
INT32 iX,iY,iW,iH; INT32 iX,iY,iW,iH;
if ( region->uiFlags & MSYS_FASTHELP ) 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; iX = (INT32)region->RegionTopLeftX + 10 * fTooltipScaleFactor;
iH = (INT32)( GetNumberOfLinesInHeight( region->FastHelpText ) * (GetFontHeight(FONT10ARIAL)+1) + 8 );
iX = (INT32)region->RegionTopLeftX + 10;
if (iX < 0) if (iX < 0)
iX = 0; iX = 0;
@@ -1424,7 +1421,7 @@ void DisplayFastHelp( MOUSE_REGION *region )
iY = 0; iY = 0;
if ( (iY + iH) >= SCREEN_HEIGHT ) if ( (iY + iH) >= SCREEN_HEIGHT )
iY = (SCREEN_HEIGHT - iH - 15); iY = (SCREEN_HEIGHT - iH - 10);
if ( !(region->uiFlags & MSYS_GOT_BACKGROUND) ) 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 );
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 ); DisplayHelpTokenizedString(
SetFontShadow( FONT_NEARBLACK ); region->FastHelpText,
DisplayHelpTokenizedString( region->FastHelpText ,( INT16 )( iX + 5 ), ( INT16 )( iY + 5 ) ); (INT16)(iX + (isScalingEnabled() ? 5 * fTooltipScaleFactor : 5)),
(INT16)(iY + (isScalingEnabled() ? 4 * fTooltipScaleFactor : 5))
);
InvalidateRegion( iX, iY, (iX + iW) , (iY + iH) ); InvalidateRegion( iX, iY, (iX + iW) , (iY + iH) );
} }
} }
} }
INT16 GetWidthOfString( const STR16 pStringA ) INT16 GetWidthOfString(const STR16 inputString)
{ {
CHAR16 pString[ 4096 ]; INT16 width = 0;
STR16 pToken; CHAR16 stringBuffer[256] = L"";
INT16 sWidth = 0; INT32 bufferIndex = 0;
wcscpy( pString, pStringA ); bool isBold = false;
// tokenize INT32 iFontHeight = GetScaledFontHeight();
pToken = wcstok( pString, L"\n" );
while( pToken != NULL ) INT16 lineWidth = 0;
{
if( sWidth < StringPixLength( pToken, FONT10ARIAL ) ) INT32 lineCounter = 0;
{ INT32 i;
sWidth = StringPixLength( pToken, FONT10ARIAL ); 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; SetFontShadow(FONT_NEARBLACK);
INT32 iCounter = 0, i;
UINT32 uiCursorXPos;
CHAR16 pString[ 4096 ];
INT32 iLength;
wcscpy( pString, pStringA ); INT32 fontHeight = GetScaledFontHeight();
// tokenize CHAR16 stringBuffer[256] = L"";
pToken = wcstok( pString, L"\n" ); INT32 bufferIndex = 0;
bool isBold = false;
while( pToken != NULL ) INT16 xDelta = 0;
{
// 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 );
//iLength = (INT32)wcslen( pToken ); INT32 lineCounter = 0;
for( i = 0; i < iLength; i++ ) INT32 i;
{ INT32 stringLength = (INT32)wcslen(inputString);
uiCursorXPos = StringPixLengthArgFastHelp( FONT10ARIAL, FONT10ARIALBOLD, i, pToken ); for (i = 0; i < stringLength; i++) {
if( pToken[ i ] == '|' ) if (inputString[i] == '\n') {
{ // if the lines don't fit the screen the last line is ...
i++; if ((lineCounter + 2) * (fontHeight + 1) > (SCREEN_HEIGHT - 10)) {
SetFont( FONT10ARIALBOLD ); if (isScalingEnabled()) {
SetFontForeground( 146 ); 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() void RenderFastHelp()
@@ -1819,4 +1884,4 @@ MOUSE_REGION *get_next_entry_in_MSYS_RegList(MOUSE_REGION *current_region)
void ResetWheelState( MOUSE_REGION *region ) void ResetWheelState( MOUSE_REGION *region )
{ {
region->WheelState = 0; region->WheelState = 0;
} }
+4
View File
@@ -1329,6 +1329,8 @@ void GetRuntimeSettings( )
// WANNE: Should we play the intro? // WANNE: Should we play the intro?
iPlayIntro = (int) GetPrivateProfileInt( "Ja2 Settings","PLAY_INTRO", iPlayIntro, INIFile ); iPlayIntro = (int) GetPrivateProfileInt( "Ja2 Settings","PLAY_INTRO", iPlayIntro, INIFile );
iUseWinFonts = (int) GetPrivateProfileInt( "Ja2 Settings","USE_WINFONTS", iUseWinFonts, 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 // haydent: mouse scrolling
iDisableMouseScrolling = (int) GetPrivateProfileInt( "Ja2 Settings","DISABLE_MOUSE_SCROLLING", iDisableMouseScrolling, INIFile ); 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); iPlayIntro = (int)oProps.getIntProperty("Ja2 Settings","PLAY_INTRO", iPlayIntro);
iUseWinFonts= (int)oProps.getIntProperty("Ja2 Settings","USE_WINFONTS", iUseWinFonts); 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 // haydent: mouse scrolling
iDisableMouseScrolling = (int)oProps.getIntProperty("Ja2 Settings","DISABLE_MOUSE_SCROLLING", iDisableMouseScrolling); iDisableMouseScrolling = (int)oProps.getIntProperty("Ja2 Settings","DISABLE_MOUSE_SCROLLING", iDisableMouseScrolling);
-79
View File
@@ -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 ) void DisplayFastHelpForInitialTripInToMapScreen( FASTHELPREGION *pRegion )
{ {
if( gTacticalStatus.fDidGameJustStart ) if( gTacticalStatus.fDidGameJustStart )
+20 -24
View File
@@ -752,29 +752,23 @@ 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
? GetWinFontHeight(TOOLTIP_IFONT)
: GetFontHeight(FONT10ARIAL);
iX = mouseTT.iX;iY = mouseTT.iY; iX = mouseTT.iX;iY = mouseTT.iY;
iW = (INT32)GetWidthOfString( mouseTT.FastHelpText ) + 10; iW = (INT32)(GetWidthOfString(mouseTT.FastHelpText) + 10 * fTooltipScaleFactor);
iH = (INT32)( GetNumberOfLinesInHeight( mouseTT.FastHelpText ) * (GetFontHeight(FONT10ARIAL)+1) + 8 ); iH = (INT32)(GetNumberOfLinesInHeight(mouseTT.FastHelpText) * (fontHeight + 1) + 8 * fTooltipScaleFactor);
if(1)//draw at cursor iY -= (iH / 2);
{ if (gusMouseXPos > (SCREEN_WIDTH / 2))
iY -= (iH / 2); iX = gusMouseXPos - iW - 24;
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;
}
else else
{ //draw in panel iX = gusMouseXPos + 24;
//502,485 658,596 160*110 580,540 //if (gusMouseYPos > (SCREEN_HEIGHT / 2))
iX = 580 - (iW / 2); // iY -= 32;
iY = 540 - (iH/2);
if (iY + iH > SCREEN_HEIGHT) iY = SCREEN_HEIGHT - iH - 3 ; if (iY <= 0) iY += 32;
}
pDestBuf = LockVideoSurface( FRAME_BUFFER, &uiDestPitchBYTES ); pDestBuf = LockVideoSurface( FRAME_BUFFER, &uiDestPitchBYTES );
SetClippingRegionAndImageWidth( uiDestPitchBYTES, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT ); 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 );
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 ); DisplayHelpTokenizedString(
SetFontShadow( FONT_NEARBLACK ); mouseTT.FastHelpText,
DisplayHelpTokenizedString( mouseTT.FastHelpText ,( INT16 )( iX + 5 ), ( INT16 )( iY + 5 ) ); (INT16)(iX + (fTooltipScaleFactor > 1 ? 5 * fTooltipScaleFactor : 5)),
(INT16)(iY + (fTooltipScaleFactor > 1 ? 4 * fTooltipScaleFactor : 5))
);
InvalidateRegion( iX, iY, (iX + iW) , (iY + iH) ); InvalidateRegion( iX, iY, (iX + iW) , (iY + iH) );
//InvalidateScreen(); //InvalidateScreen();
} }
+2
View File
@@ -231,6 +231,7 @@ BOOLEAN InitializeFonts( )
if ( iUseWinFonts ) { if ( iUseWinFonts ) {
InitWinFonts( ); InitWinFonts( );
} }
InitTooltipFonts();
return( TRUE ); return( TRUE );
} }
@@ -261,6 +262,7 @@ void ShutdownFonts( )
if ( iUseWinFonts ) { if ( iUseWinFonts ) {
ShutdownWinFonts(); ShutdownWinFonts();
} }
ShutdownTooltipFonts();
} }
// Set shades for fonts // Set shades for fonts
+2 -1
View File
@@ -32,6 +32,7 @@ extern UINT16 SCREEN_HEIGHT;
extern int iResolution; // Resolution id from the ini file extern int iResolution; // Resolution id from the ini file
extern int iPlayIntro; extern int iPlayIntro;
extern int iUseWinFonts; extern int iUseWinFonts;
extern float fTooltipScaleFactor;
extern int iDisableMouseScrolling; extern int iDisableMouseScrolling;
extern INT16 iScreenWidthOffset; extern INT16 iScreenWidthOffset;
extern INT16 iScreenHeightOffset; extern INT16 iScreenHeightOffset;
@@ -82,4 +83,4 @@ extern BOOLEAN fDisplayOverheadMap;
#define PIXEL_DEPTH 16 #define PIXEL_DEPTH 16
#endif #endif