- Joined
- Feb 2, 2012
- Messages
- 163
- Reaction score
- 56
I wrote this a few minutes ago and figure it was worth a share since maiet originally hard coded based on item ID and gave no scaleable solution imho. This will give an example of usage with the page13 rendering it a different color. I recommend replacing all type parameters with icon using notepad++ or similar. type="page" should now read icon="page" or type="skull" should read icon="skull"; This will allow the original icons to parse correctly;
Different color page 13:
in zquestitem.xml we now have an xml attribute called icon, we can set this to an end of file string and have it interpolated for faster editing. So my File name is "slot_icon_page13.tga" in my default.mrs;
EDIT: I also added ice crystal custom texture. Attached below.
in ZGameInterface.cpp Above MBitmap* ZGameInterface::GetQuestItemIcon( int nItemID, bool bSmallIcon) add:
Cool now we have a function, set the .h as follows:
I dont like replacing functions, I write extenders that invoke differently so I can revert changes for other options;
In MQuestItem.h
In MQuestItem.cpp in the ParseQuestItem function:
Now comes the fun part, find all references of GetQuestItemIcon and Replace with GetQuestItemIconEx;
But wait your targets have changed!!!!! Change the first parameter target from an Item id to a pDesc;
example for ZShopEquipItem_Quest
See how you've got to target a pDesc now? Do that for all of them;
One more example: in ZQuest.cpp -> void ZQuest::GetMyObtainQuestItemList
There are 9 References in total after you add this function;
Results: attached();
edit: Additional info: type="necklace" needs to be changed to icon="neck"
Different color page 13:
in zquestitem.xml we now have an xml attribute called icon, we can set this to an end of file string and have it interpolated for faster editing. So my File name is "slot_icon_page13.tga" in my default.mrs;
EDIT: I also added ice crystal custom texture. Attached below.
XML:
<ITEM id="200001" name="STR:QITEM_NAME_200001" level="0" icon="page13" desc="STR:QITEM_DESC_200001"
unique="0" price="100" secrifice="1" param="0" />
<ITEM id="200035" name="STR:QITEM_NAME_200035" level="0" icon="ice" desc="STR:QITEM_DESC_200035"
unique="0" price="1600" secrifice="1" param="0" />
in ZGameInterface.cpp Above MBitmap* ZGameInterface::GetQuestItemIcon( int nItemID, bool bSmallIcon) add:
C++:
MBitmap* ZGameInterface::GetQuestItemIconEx(MQuestItemDesc* pDesc, bool bSmallIcon)
{
char szFileName[64] = "";
char prefix[16] = "slot_icon_"; //If you decide to use a different prefix remember to change it, this is for compatibility with the default theme.
sprintf(szFileName, "%s%s", prefix, pDesc->m_szIcon); // Probably could strcat twice, but whatever
strcat(szFileName, ".tga");
return MBitmapManager::Get(szFileName);
}
Cool now we have a function, set the .h as follows:
C++:
MBitmap* GetQuestItemIcon( int nItemID, bool bSmallIcon);
MBitmap* GetQuestItemIconEx(MQuestItemDesc* pDesc, bool bSmallIcon);
I dont like replacing functions, I write extenders that invoke differently so I can revert changes for other options;
In MQuestItem.h
C++:
//Near the top add
#define MQICTOK_ICON "icon" // This parses the xml tag icon for use
struct MQuestItemDesc
{
unsigned long int m_nItemID;
char m_szQuestItemName[ 32 ];
int m_nLevel;
MQuestItemType m_nType;
int m_nPrice;
bool m_bUnique;
bool m_bSecrifice;
char m_szDesc[ 8192 ];
char m_szIcon[256]; // Add this;
int m_nLifeTime;
int m_nParam;
int GetSellBountyValue(int nCnt) { return int(m_nPrice * 0.5 * nCnt); }
};
C++:
else if( 0 == strcmp(MQICTOK_DESC, szAttrName) ) //FIND
{
strcpy( pNewQuestItemDesc->m_szDesc, MGetStringResManager()->GetStringFromXml(szAttrValue) );
}
else if (0 == strcmp(MQICTOK_ICON, szAttrName)) //ADD THIS BELOW MQICTOK_DESC
{
strcpy(pNewQuestItemDesc->m_szIcon, MGetStringResManager()->GetStringFromXml(szAttrValue));
}
But wait your targets have changed!!!!! Change the first parameter target from an Item id to a pDesc;
example for ZShopEquipItem_Quest
C++:
ZShopEquipItem_Quest::ZShopEquipItem_Quest( MQuestItemDesc* pDesc ) : m_pItemDesc(pDesc)
{
//_ASSERT(m_pItemDesc);
//m_pIconBitmap = ZApplication::GetGameInterface()->GetQuestItemIcon(pDesc->m_nItemID, true);
m_pIconBitmap = ZApplication::GetGameInterface()->GetQuestItemIconEx(pDesc, true);
}
See how you've got to target a pDesc now? Do that for all of them;
One more example: in ZQuest.cpp -> void ZQuest::GetMyObtainQuestItemList
C++:
if ( pListBox && (pQuestItemNode->m_nCount > 0))
{
MQuestItemDesc* pQuestItemDesc = GetQuestItemDescMgr().FindQItemDesc( pQuestItemNode->m_nItemID);
char szNum[ 10];
sprintf( szNum, "%d", pQuestItemNode->m_nCount);
char szMsg[ 128];
ZTransMsg( szMsg, MSG_GAME_GET_QUEST_ITEM2, 2, pQuestItemDesc->m_szQuestItemName, szNum);
//pListBox->Add( new ObtainItemListBoxItem( ZGetGameInterface()->GetQuestItemIcon( pQuestItemNode->m_nItemID, true), szMsg));
pListBox->Add(new ObtainItemListBoxItem(ZGetGameInterface()->GetQuestItemIconEx(pQuestItemDesc, true), szMsg));
}
Results: attached();
edit: Additional info: type="necklace" needs to be changed to icon="neck"
Attachments
You must be registered for see attachments list
Last edited: