- Bobby Ray Tooltips (Fixes) (by Headrock)

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@3172 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
Wanne
2009-09-03 07:39:34 +00:00
parent 1f3882f378
commit a20ac7fb1c
2 changed files with 91 additions and 9 deletions
+69 -3
View File
@@ -2346,7 +2346,12 @@ void CreateMouseRegionForBigImage( UINT16 usPosY, UINT8 ubCount, INT16 *pItemNum
UINT8 i;
CHAR16 zItemName[ SIZE_ITEM_NAME ];
UINT8 ubItemCount=0;
CHAR16 pStr[ 250 ];
// HEADROCK HAM 3: Increased size, to allow larger tooltips. Used for Attachments Shown on Tooltips feature.
// Please note, if a mod introduces a weapon that can take several hundred attachments, this value MIGHT overflow.
// I do not have the expertise to think of a better solution. Still, 5000 is enough for around 200 possible attachments,
// so overflow will first be felt ON-SCREEN. I consider that scenario extremely unlikely.
//CHAR16 pStr[ 250 ];
CHAR16 pStr[ 5000 ];
if( gfBigImageMouseRegionCreated )
return;
@@ -2412,6 +2417,16 @@ void CreateMouseRegionForBigImage( UINT16 usPosY, UINT8 ubCount, INT16 *pItemNum
CHAR16 apStr2[20];
OBJECTTYPE pObject;
// HEADROCK HAM 3: Variables for "Possible Attachment List"
BOOLEAN fAttachmentsFound = FALSE;
// Contains entire string of attachment names
CHAR16 attachStr[3900];
// Contains current attachment string
CHAR16 attachStr2[100];
// Contains temporary attachment list before added to string constant from text.h
CHAR16 attachStr3[3900];
UINT16 usAttachment;
CreateItem(pItemNumbers[ i ], 100, &pObject);
UINT16 ubAttackAPs = BaseAPsToShootOrStab( APBPConstants[DEFAULT_APS], APBPConstants[DEFAULT_AIMSKILL], &pObject );
@@ -2436,7 +2451,57 @@ void CreateMouseRegionForBigImage( UINT16 usPosY, UINT8 ubCount, INT16 *pItemNum
else
wcscat( apStr, L" / -" );
swprintf( pStr, L"%s (%s)\n%s %d\n%s %d\n%s %d\n%s (%d) %s\n%s %1.1f %s",
// HEADROCK HAM 3: Empty these strings first, to avoid crashes. Please keep this here.
swprintf( attachStr, L"" );
swprintf( attachStr2, L"" );
swprintf( attachStr3, L"" );
// HEADROCK HAM 3: Generate list of possible attachments to a gun (Guns only!)
//if (gGameExternalOptions.fBobbyRayTooltipsShowAttachments)
{
// Check entire attachment list
UINT16 iLoop = 0;
while( 1 )
{
// Is the weapon we're checking the same as the one we're tooltipping?
if (Attachment[iLoop][1] == Item[pItemNumbers[ i ]].uiIndex)
{
usAttachment = Attachment[iLoop][0];
// If the attachment is not hidden
if (!Item[ usAttachment ].hiddenaddon && !Item[ usAttachment ].hiddenattachment)
{
if (wcslen( attachStr3 ) + wcslen(Item[usAttachment].szItemName) > 3800)
{
// End list early to avoid stack overflow
wcscat( attachStr3, L"\n..." );
break;
}
else
{// Add the attachment's name to the list.
fAttachmentsFound = TRUE;
swprintf( attachStr2, L"\n%s", Item[ usAttachment ].szItemName );
wcscat( attachStr3, attachStr2);
}
}
}
iLoop++;
if (Attachment[iLoop][0] == 0)
{
// Reached end of list
break;
}
}
if (fAttachmentsFound)
{
// Add extra empty line and attachment list title
swprintf( attachStr, L"\n \n%s", gWeaponStatsDesc[ 14 ] );
wcscat( attachStr, attachStr3 );
}
}
// HEADROCK HAM 3: Added last string (attachStr), for display of the possible attachment list.
// If the feature is deactivated, the attachStr will simply be empty at this point
// (remember? we emptied it earlier!).
swprintf( pStr, L"%s (%s)\n%s %d\n%s %d\n%s %d\n%s (%d) %s\n%s %1.1f %s%s",
ItemNames[ pItemNumbers[ i ] ],
AmmoCaliber[ Weapon[ pItemNumbers[ i ] ].ubCalibre ],
gWeaponStatsDesc[ 9 ], //Accuracy String
@@ -2451,7 +2516,8 @@ void CreateMouseRegionForBigImage( UINT16 usPosY, UINT8 ubCount, INT16 *pItemNum
//L"- / - / -",
gWeaponStatsDesc[ 12 ], //Weight String
fWeight, //Weight
GetWeightUnitString() //Weight units
GetWeightUnitString(), //Weight units
attachStr
);
}
break;
+22 -6
View File
@@ -1296,7 +1296,7 @@ INT16 GetNumberOfLinesInHeight( const STR16 pStringA )
{
STR16 pToken;
INT16 sCounter = 0;
CHAR16 pString[ 512 ];
CHAR16 pString[ 4096 ];
wcscpy( pString, pStringA );
@@ -1305,8 +1305,16 @@ INT16 GetNumberOfLinesInHeight( const STR16 pStringA )
while( pToken != NULL )
{
pToken = wcstok( NULL, L"\n" );
sCounter++;
// 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++;*/
}
return( sCounter );
@@ -1376,7 +1384,7 @@ void DisplayFastHelp( MOUSE_REGION *region )
INT16 GetWidthOfString( const STR16 pStringA )
{
CHAR16 pString[ 512 ];
CHAR16 pString[ 4096 ];
STR16 pToken;
INT16 sWidth = 0;
wcscpy( pString, pStringA );
@@ -1403,7 +1411,7 @@ void DisplayHelpTokenizedString( const STR16 pStringA, INT16 sX, INT16 sY )
STR16 pToken;
INT32 iCounter = 0, i;
UINT32 uiCursorXPos;
CHAR16 pString[ 512 ];
CHAR16 pString[ 4096 ];
INT32 iLength;
wcscpy( pString, pStringA );
@@ -1413,7 +1421,15 @@ void DisplayHelpTokenizedString( const STR16 pStringA, INT16 sX, INT16 sY )
while( pToken != NULL )
{
iLength = (INT32)wcslen( pToken );
// 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 );
for( i = 0; i < iLength; i++ )
{
uiCursorXPos = StringPixLengthArgFastHelp( FONT10ARIAL, FONT10ARIALBOLD, i, pToken );