Fixed soldier tooltips showing attachments when they shouldn't be

Cleaned up PxItems code to not be so messy, and be more flexible later once we can figure out a way to enable P4-P9items again

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@5253 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
MaddMugsy
2012-05-03 03:34:11 +00:00
parent c237ca4dff
commit 003ada4d4c
5 changed files with 45 additions and 399 deletions
+4 -92
View File
@@ -125,7 +125,7 @@ BOOLEAN LoadGraphicForItem( ENCYCLOPEDIA_LOCATION *pEncy, UINT32 i )
{
CHAR8 zName[ 100 ];
// UINT32 uiVo;
UINT16 ubGraphic;
UINT16 ubGraphic, ubGraphicType;
CHAR8 zString[512];
// CHAR8 zString2[512];
@@ -135,6 +135,7 @@ BOOLEAN LoadGraphicForItem( ENCYCLOPEDIA_LOCATION *pEncy, UINT32 i )
// CHECK SUBCLASS
ubGraphic = Item[i].ubGraphicNum;
ubGraphicType = Item[i].ubGraphicType;
if ( Item[i].ubGraphicType == 0 )
{
@@ -150,104 +151,15 @@ BOOLEAN LoadGraphicForItem( ENCYCLOPEDIA_LOCATION *pEncy, UINT32 i )
sprintf( zName, "gun%d", ubGraphic );
}
}
else if ( Item[i].ubGraphicType == 1 )
{
if ( ubGraphic < 10 )
{
sprintf( zName, "p1item0%d", ubGraphic );
}
else
{
sprintf( zName, "p1item%d", ubGraphic );
}
}
else if ( Item[i].ubGraphicType == 2 )
{
if ( ubGraphic < 10 )
{
sprintf( zName, "p2item0%d", ubGraphic );
}
else
{
sprintf( zName, "p2item%d", ubGraphic );
}
}
else if ( Item[i].ubGraphicType == 3 )
{
if ( ubGraphic < 10 )
{
sprintf( zName, "p3item0%d", ubGraphic );
}
else
{
sprintf( zName, "p3item%d", ubGraphic );
}
}
//MM: New item tileslots start here
else if ( Item[i].ubGraphicType == 4 )
{
if ( ubGraphic < 10 )
{
sprintf( zName, "p4item0%d", ubGraphic );
}
else
{
sprintf( zName, "p4item%d", ubGraphic );
}
}
else if ( Item[i].ubGraphicType == 5 )
{
if ( ubGraphic < 10 )
{
sprintf( zName, "p5item0%d", ubGraphic );
}
else
{
sprintf( zName, "p5item%d", ubGraphic );
}
}
else if ( Item[i].ubGraphicType == 6 )
{
if ( ubGraphic < 10 )
{
sprintf( zName, "p6item0%d", ubGraphic );
}
else
{
sprintf( zName, "p6item%d", ubGraphic );
}
}
else if ( Item[i].ubGraphicType == 7 )
{
if ( ubGraphic < 10 )
{
sprintf( zName, "p7item0%d", ubGraphic );
}
else
{
sprintf( zName, "p7item%d", ubGraphic );
}
}
else if ( Item[i].ubGraphicType == 8 )
{
if ( ubGraphic < 10 )
{
sprintf( zName, "p8item0%d", ubGraphic );
}
else
{
sprintf( zName, "p8item%d", ubGraphic );
}
}
else
{
if ( ubGraphic < 10 )
{
sprintf( zName, "p9item0%d", ubGraphic );
sprintf( zName, "p%ditem0%d", ubGraphicType, ubGraphic );
}
else
{
sprintf( zName, "p9item%d", ubGraphic );
sprintf( zName, "p%ditem%d", ubGraphicType, ubGraphic );
}
}
+14 -137
View File
@@ -9214,58 +9214,19 @@ void DeleteKeyRingPopup( )
UINT32 GetInterfaceGraphicForItem( INVTYPE *pItem )
{
UINT32 id;
UINT8 ubGraphicType = pItem->ubGraphicType;
// CHECK SUBCLASS
if ( pItem->ubGraphicType == 0 )
if ( ubGraphicType == 0 )
{
SGP_TRYCATCH_RETHROW( id = g_bUsePngItemImages ? g_oGUNSM.getVObjectForItem(pItem->ubGraphicNum) : guiGUNSM,
L"Failed to retrieve gun image" );
}
else if ( pItem->ubGraphicType == 1 )
else
{
SGP_TRYCATCH_RETHROW( id = g_bUsePngItemImages ? g_oP1ITEMS.getVObjectForItem(pItem->ubGraphicNum) : guiP1ITEMS,
L"Failed to retrieve P1 item image" );
SGP_TRYCATCH_RETHROW( id = g_bUsePngItemImages ? g_oPITEMS[ubGraphicType-1].getVObjectForItem(pItem->ubGraphicNum) : guiPITEMS[ubGraphicType-1],
String("Failed to retrieve interface image, graphic type = %d",ubGraphicType) );
}
else if ( pItem->ubGraphicType == 2 )
{
SGP_TRYCATCH_RETHROW( id = g_bUsePngItemImages ? g_oP2ITEMS.getVObjectForItem(pItem->ubGraphicNum) : guiP2ITEMS,
L"Failed to retrieve P2 item image" );
}
else if ( pItem->ubGraphicType == 3 )
{
SGP_TRYCATCH_RETHROW( id = g_bUsePngItemImages ? g_oP3ITEMS.getVObjectForItem(pItem->ubGraphicNum) : guiP3ITEMS,
L"Failed to retrieve P3 item image" );
}
////MM: New item tileslots start here
//else if ( pItem->ubGraphicType == 4 )
//{
// SGP_TRYCATCH_RETHROW( id = g_bUsePngItemImages ? g_oP4ITEMS.getVObjectForItem(pItem->ubGraphicNum) : guiP4ITEMS,
// L"Failed to retrieve P4 item image" );
//}
//else if ( pItem->ubGraphicType == 5 )
//{
// SGP_TRYCATCH_RETHROW( id = g_bUsePngItemImages ? g_oP5ITEMS.getVObjectForItem(pItem->ubGraphicNum) : guiP5ITEMS,
// L"Failed to retrieve P5 item image" );
//}
//else if ( pItem->ubGraphicType == 6 )
//{
// SGP_TRYCATCH_RETHROW( id = g_bUsePngItemImages ? g_oP6ITEMS.getVObjectForItem(pItem->ubGraphicNum) : guiP6ITEMS,
// L"Failed to retrieve P6 item image" );
//}
//else if ( pItem->ubGraphicType == 7 )
//{
// SGP_TRYCATCH_RETHROW( id = g_bUsePngItemImages ? g_oP7ITEMS.getVObjectForItem(pItem->ubGraphicNum) : guiP7ITEMS,
// L"Failed to retrieve P7 item image" );
//}
//else if ( pItem->ubGraphicType == 8 )
//{
// SGP_TRYCATCH_RETHROW( id = g_bUsePngItemImages ? g_oP8ITEMS.getVObjectForItem(pItem->ubGraphicNum) : guiP8ITEMS,
// L"Failed to retrieve P8 item image" );
//}
//else
//{
// SGP_TRYCATCH_RETHROW( id = g_bUsePngItemImages ? g_oP9ITEMS.getVObjectForItem(pItem->ubGraphicNum) : guiP9ITEMS,
// L"Failed to retrieve P9 item image" );
//}
return id;
}
@@ -9320,8 +9281,10 @@ UINT16 GetTileGraphicForItem( INVTYPE *pItem )
// GetTileIndexFromTypeSubIndex( P9ITEMS, (INT16)(pItem->ubGraphicNum+1), &usIndex );
//}
if ( pItem->ubClassIndex >= M900 )
DebugMsg(TOPIC_JA2, DBG_LEVEL_3, String("GetTileGraphicForItem: db index %d",usIndex));
return( usIndex );
}
@@ -9332,6 +9295,7 @@ BOOLEAN LoadTileGraphicForItem( INVTYPE *pItem, UINT32 *puiVo )
UINT32 uiVo;
VOBJECT_DESC VObjectDesc;
UINT16 ubGraphic;
UINT8 ubGraphicType;
DebugMsg(TOPIC_JA2,DBG_LEVEL_3,String("LoadTileGraphicForItem"));
@@ -9339,6 +9303,7 @@ BOOLEAN LoadTileGraphicForItem( INVTYPE *pItem, UINT32 *puiVo )
// CHECK SUBCLASS
ubGraphic = pItem->ubGraphicNum;
ubGraphicType = pItem->ubGraphicType;
if ( pItem->ubGraphicType == 0 )
{
@@ -9354,106 +9319,18 @@ BOOLEAN LoadTileGraphicForItem( INVTYPE *pItem, UINT32 *puiVo )
sprintf( zName, "gun%d", ubGraphic );
}
}
else if ( pItem->ubGraphicType == 1 )
else
{
if ( ubGraphic < 10 )
{
sprintf( zName, "p1item0%d", ubGraphic );
sprintf( zName, "p%ditem0%d", ubGraphicType, ubGraphic );
}
else
{
sprintf( zName, "p1item%d", ubGraphic );
sprintf( zName, "p%ditem%d", ubGraphicType, ubGraphic );
}
}
else if ( pItem->ubGraphicType == 2 )
{
if ( ubGraphic < 10 )
{
sprintf( zName, "p2item0%d", ubGraphic );
}
else
{
sprintf( zName, "p2item%d", ubGraphic );
}
}
else if ( pItem->ubGraphicType == 3 )
{
if ( ubGraphic < 10 )
{
sprintf( zName, "p3item0%d", ubGraphic );
}
else
{
sprintf( zName, "p3item%d", ubGraphic );
}
}
////MM: New item tileslots start here
//else if ( pItem->ubGraphicType == 4 )
//{
// if ( ubGraphic < 10 )
// {
// sprintf( zName, "p4item0%d", ubGraphic );
// }
// else
// {
// sprintf( zName, "p4item%d", ubGraphic );
// }
//}
//else if ( pItem->ubGraphicType == 5 )
//{
// if ( ubGraphic < 10 )
// {
// sprintf( zName, "p5item0%d", ubGraphic );
// }
// else
// {
// sprintf( zName, "p5item%d", ubGraphic );
// }
//}
//else if ( pItem->ubGraphicType == 6 )
//{
// if ( ubGraphic < 10 )
// {
// sprintf( zName, "p6item0%d", ubGraphic );
// }
// else
// {
// sprintf( zName, "p6item%d", ubGraphic );
// }
//}
//else if ( pItem->ubGraphicType == 7 )
//{
// if ( ubGraphic < 10 )
// {
// sprintf( zName, "p7item0%d", ubGraphic );
// }
// else
// {
// sprintf( zName, "p7item%d", ubGraphic );
// }
//}
//else if ( pItem->ubGraphicType == 8 )
//{
// if ( ubGraphic < 10 )
// {
// sprintf( zName, "p8item0%d", ubGraphic );
// }
// else
// {
// sprintf( zName, "p8item%d", ubGraphic );
// }
//}
//else
//{
// if ( ubGraphic < 10 )
// {
// sprintf( zName, "p9item0%d", ubGraphic );
// }
// else
// {
// sprintf( zName, "p9item%d", ubGraphic );
// }
//}
//Load item
VObjectDesc.fCreateFlags = VOBJECT_CREATE_FROMFILE;
+16 -137
View File
@@ -13,31 +13,11 @@ extern void WriteMessageToFile( const STR16 pString );
bool g_bUsePngItemImages = false;
// old item image handles
UINT32 guiGUNSM;
UINT32 guiP1ITEMS;
UINT32 guiP2ITEMS;
UINT32 guiP3ITEMS;
//MM: New item tileslots start here
UINT32 guiP4ITEMS;
UINT32 guiP5ITEMS;
UINT32 guiP6ITEMS;
UINT32 guiP7ITEMS;
UINT32 guiP8ITEMS;
UINT32 guiP9ITEMS;
UINT32 guiPITEMS[MAX_PITEMS];
// new item image handles
MDItemVideoObjects g_oGUNSM;
MDItemVideoObjects g_oP1ITEMS;
MDItemVideoObjects g_oP2ITEMS;
MDItemVideoObjects g_oP3ITEMS;
//MM: New item tileslots start here
MDItemVideoObjects g_oP4ITEMS;
MDItemVideoObjects g_oP5ITEMS;
MDItemVideoObjects g_oP6ITEMS;
MDItemVideoObjects g_oP7ITEMS;
MDItemVideoObjects g_oP8ITEMS;
MDItemVideoObjects g_oP9ITEMS;
MDItemVideoObjects g_oPITEMS[MAX_PITEMS];
/******************************************************************************/
@@ -132,123 +112,22 @@ bool RegisterItemImages()
return false;
}
// LOAD INTERFACE ITEM PICTURES
if(!g_bUsePngItemImages)
for (UINT8 ubLoop = 0; ubLoop < MAX_PITEMS; ubLoop++)
{
VObjectDesc.fCreateFlags = VOBJECT_CREATE_FROMFILE;
FilenameForBPP("INTERFACE\\mdp1items.sti", VObjectDesc.ImageFile);
if( !AddVideoObject( &VObjectDesc, &guiP1ITEMS ) )
AssertMsg(0, "Missing INTERFACE\\mdplitems.sti" );
// LOAD INTERFACE ITEM PICTURES
if(!g_bUsePngItemImages)
{
VObjectDesc.fCreateFlags = VOBJECT_CREATE_FROMFILE;
FilenameForBPP(String("INTERFACE\\mdp%ditems.sti",ubLoop+1), VObjectDesc.ImageFile);
if( !AddVideoObject( &VObjectDesc, &guiPITEMS[ubLoop] ) )
AssertMsg(0, String("Missing INTERFACE\\mdp%ditems.sti",ubLoop+1) );
}
else if(!g_oPITEMS[ubLoop].registerItemsFromFilePattern(String("INTERFACE/MDP%dITEMS/*.png",ubLoop+1)))
{
return false;
}
}
else if(!g_oP1ITEMS.registerItemsFromFilePattern(L"INTERFACE/MDP1ITEMS/*.png"))
{
return false;
}
// LOAD INTERFACE ITEM PICTURES
if(!g_bUsePngItemImages)
{
VObjectDesc.fCreateFlags = VOBJECT_CREATE_FROMFILE;
FilenameForBPP("INTERFACE\\mdp2items.sti", VObjectDesc.ImageFile);
if( !AddVideoObject( &VObjectDesc, &guiP2ITEMS ) )
AssertMsg(0, "Missing INTERFACE\\mdp2items.sti" );
}
else if(!g_oP2ITEMS.registerItemsFromFilePattern(L"INTERFACE/MDP2ITEMS/*.png"))
{
return false;
}
// LOAD INTERFACE ITEM PICTURES
if(!g_bUsePngItemImages)
{
VObjectDesc.fCreateFlags = VOBJECT_CREATE_FROMFILE;
FilenameForBPP("INTERFACE\\mdp3items.sti", VObjectDesc.ImageFile);
if( !AddVideoObject( &VObjectDesc, &guiP3ITEMS ) )
AssertMsg(0, "Missing INTERFACE\\mdp3items.sti" );
}
else if(!g_oP3ITEMS.registerItemsFromFilePattern(L"INTERFACE/MDP3ITEMS/*.png"))
{
return false;
}
//MM: New item tileslots start here
// LOAD INTERFACE ITEM PICTURES
//if(!g_bUsePngItemImages)
//{
// VObjectDesc.fCreateFlags = VOBJECT_CREATE_FROMFILE;
// FilenameForBPP("INTERFACE\\mdp4items.sti", VObjectDesc.ImageFile);
// if( !AddVideoObject( &VObjectDesc, &guiP4ITEMS ) )
// AssertMsg(0, "Missing INTERFACE\\mdp4items.sti" );
//}
//else if(!g_oP4ITEMS.registerItemsFromFilePattern(L"INTERFACE/MDP4ITEMS/*.png"))
//{
// return false;
//}
// // LOAD INTERFACE ITEM PICTURES
//if(!g_bUsePngItemImages)
//{
// VObjectDesc.fCreateFlags = VOBJECT_CREATE_FROMFILE;
// FilenameForBPP("INTERFACE\\mdp5items.sti", VObjectDesc.ImageFile);
// if( !AddVideoObject( &VObjectDesc, &guiP5ITEMS ) )
// AssertMsg(0, "Missing INTERFACE\\mdp5items.sti" );
//}
//else if(!g_oP5ITEMS.registerItemsFromFilePattern(L"INTERFACE/MDP5ITEMS/*.png"))
//{
// return false;
//}
// // LOAD INTERFACE ITEM PICTURES
//if(!g_bUsePngItemImages)
//{
// VObjectDesc.fCreateFlags = VOBJECT_CREATE_FROMFILE;
// FilenameForBPP("INTERFACE\\mdp6items.sti", VObjectDesc.ImageFile);
// if( !AddVideoObject( &VObjectDesc, &guiP6ITEMS ) )
// AssertMsg(0, "Missing INTERFACE\\mdp6items.sti" );
//}
//else if(!g_oP6ITEMS.registerItemsFromFilePattern(L"INTERFACE/MDP6ITEMS/*.png"))
//{
// return false;
//}
// // LOAD INTERFACE ITEM PICTURES
//if(!g_bUsePngItemImages)
//{
// VObjectDesc.fCreateFlags = VOBJECT_CREATE_FROMFILE;
// FilenameForBPP("INTERFACE\\mdp7items.sti", VObjectDesc.ImageFile);
// if( !AddVideoObject( &VObjectDesc, &guiP7ITEMS ) )
// AssertMsg(0, "Missing INTERFACE\\mdp7items.sti" );
//}
//else if(!g_oP7ITEMS.registerItemsFromFilePattern(L"INTERFACE/MDP7ITEMS/*.png"))
//{
// return false;
//}
// // LOAD INTERFACE ITEM PICTURES
//if(!g_bUsePngItemImages)
//{
// VObjectDesc.fCreateFlags = VOBJECT_CREATE_FROMFILE;
// FilenameForBPP("INTERFACE\\mdp8items.sti", VObjectDesc.ImageFile);
// if( !AddVideoObject( &VObjectDesc, &guiP8ITEMS ) )
// AssertMsg(0, "Missing INTERFACE\\mdp8items.sti" );
//}
//else if(!g_oP8ITEMS.registerItemsFromFilePattern(L"INTERFACE/MDP8ITEMS/*.png"))
//{
// return false;
//}
// // LOAD INTERFACE ITEM PICTURES
//if(!g_bUsePngItemImages)
//{
// VObjectDesc.fCreateFlags = VOBJECT_CREATE_FROMFILE;
// FilenameForBPP("INTERFACE\\mdp9items.sti", VObjectDesc.ImageFile);
// if( !AddVideoObject( &VObjectDesc, &guiP9ITEMS ) )
// AssertMsg(0, "Missing INTERFACE\\mdp9items.sti" );
//}
//else if(!g_oP9ITEMS.registerItemsFromFilePattern(L"INTERFACE/MDP9ITEMS/*.png"))
//{
// return false;
//}
return true;
}
+3 -22
View File
@@ -21,33 +21,14 @@ private:
extern bool g_bUsePngItemImages;
const UINT8 MAX_PITEMS = 3;
// old item image handles
extern UINT32 guiGUNSM;
extern UINT32 guiP1ITEMS;
extern UINT32 guiP2ITEMS;
extern UINT32 guiP3ITEMS;
//MM: New item tileslots start here
extern UINT32 guiP4ITEMS;
extern UINT32 guiP5ITEMS;
extern UINT32 guiP6ITEMS;
extern UINT32 guiP7ITEMS;
extern UINT32 guiP8ITEMS;
extern UINT32 guiP9ITEMS;
extern UINT32 guiPITEMS[MAX_PITEMS];
// new item image handles
extern MDItemVideoObjects g_oGUNSM;
extern MDItemVideoObjects g_oP1ITEMS;
extern MDItemVideoObjects g_oP2ITEMS;
extern MDItemVideoObjects g_oP3ITEMS;
//MM: New item tileslots start here
extern MDItemVideoObjects g_oP4ITEMS;
extern MDItemVideoObjects g_oP5ITEMS;
extern MDItemVideoObjects g_oP6ITEMS;
extern MDItemVideoObjects g_oP7ITEMS;
extern MDItemVideoObjects g_oP8ITEMS;
extern MDItemVideoObjects g_oP9ITEMS;
extern MDItemVideoObjects g_oPITEMS[MAX_PITEMS];
bool RegisterItemImages();
+8 -11
View File
@@ -514,19 +514,17 @@ void DisplayWeaponInfo( SOLDIERTYPE* pSoldier, CHAR16* pStrInfo, UINT8 ubSlot, U
// display weapon attachments
for (attachmentList::iterator iter = pSoldier->inv[ubSlot][0]->attachments.begin(); iter != pSoldier->inv[ubSlot][0]->attachments.end(); ++iter) {
if(iter->exists()){
if ( ubTooltipDetailLevel == DL_Basic )
fDisplayAttachment = FALSE; //Madd: changed this, it was incorrectly showing attachments when it shouldn't be
if ( ubTooltipDetailLevel == DL_Basic || ubTooltipDetailLevel == DL_Full ) // Madd: also hidden attachments should be hidden at the full level as well... unless the mercs have x-ray vision to see that rod&spring inside the gun!! :p
{
// display only externally-visible weapon attachments
if ( !Item[iter->usItem].hiddenattachment )
{
fDisplayAttachment = TRUE;
}
}
else
{
// display all weapon attachments
fDisplayAttachment = TRUE;
if ( Item[iter->usItem].hiddenattachment )
fDisplayAttachment = FALSE;
else
fDisplayAttachment = TRUE;
}
if ( fDisplayAttachment )
{
iNumAttachments++;
@@ -535,7 +533,6 @@ void DisplayWeaponInfo( SOLDIERTYPE* pSoldier, CHAR16* pStrInfo, UINT8 ubSlot, U
else
wcscat( pStrInfo, L", " );
wcscat( pStrInfo, ItemNames[ iter->usItem ] );
fDisplayAttachment = FALSE; // clear flag for next loop iteration
}
}
} // for