#include "stdafx.h"
#include "MNewGameSlot.h"
#include "MDefine.h"
#include "WinUtil.h"
#include "MVarious.h"
#include <gl\GL.h>
#include "MKeyboard.h"
void (MUNewEquipUI::*MUNewEquipUI::OriInitSpritePosition)() = nullptr;
MUNewEquipUI* (MUNewEquipUI::*MUNewEquipUI::OriConstruct)() = nullptr;
void (MUNewEquipUI::*MUNewEquipUI::OriDestruct)() = nullptr;
void (MUNewEquipUI::*MUNewEquipUI::OriDrawSpriteSlot)() = nullptr;
char (MUNewEquipUI::*MUNewEquipUI::OriUpdate)() = nullptr;
MUItemFlyInfo * (*MUItemFlyInfo::OriGetInstance)() = nullptr;
MUItemInfo * (MUItemFlyInfo::*MUItemFlyInfo::OriGetItemInfo)() = nullptr;
void (MUNewEqipUI_Equipment::*MUNewEqipUI_Equipment::OriDraw3DItemEquip)() = nullptr;
void (MUNewEquipUI::*MUNewEquipUI::OriRenderInfoItemChoose)( int iNumItem ) = nullptr;
void (MUDynamicUIManager::*MUDynamicUIManager::OriRegisterRenderUIText)( float fFloatUnk, void (__cdecl *fnFunction)(void *, int, int), void *ptr, int arg1, int arg2) = nullptr;
MUItemInfo *(MUUIItemManager::*MUUIItemManager::OriMakeItemInfoFromByteInfo)( BYTE *lpInfoByte ) = nullptr;
void (MUUIItemManager::*MUUIItemManager::OriDelRefItem)( MUItemInfo *pItem ) = nullptr;
MUUIPaneMng *(*MUUIPaneMng::OriGetInstance)() = nullptr;
MUUIItemManager * (MUUIPaneMng::*MUUIPaneMng::OriGetMUUIItemManager)() = nullptr;
MUUIShowItemInfo * (MUUIPaneMng::*MUUIPaneMng::OriGetUIShowItemInfo)() = nullptr;
int (MUUIShowItemInfo::*MUUIShowItemInfo::OriShowItemInfo)( int posx, int posy, MUItemInfo *pItem, int a4, int a5, int a6) = nullptr;
char (MUNewEquipUI::*MUNewEquipUI::OriCheckClickEqiupItem)() = nullptr;
void (MUNewEquipUI::*MUNewEquipUI::OriOnItemRemove)( MUItemInfo *pItem) = nullptr;
void (MUNewEquipUI::*MUNewEquipUI::OriOnItemChanged)() = nullptr;
class MUNewEquipUI_MUUIItemTable *(MUItemFlyInfo::*MUItemFlyInfo::OriGetUITableBase)() = nullptr;
MUNewEquipUI *(MUUIPaneMng::*MUUIPaneMng::OriGetMUNewEquipUI)() = nullptr;
int (MUNewEquipUI::*MUNewEquipUI::OriIsTableFromThis)( class MUNewEquipUI_MUUIItemTable *pTableUI) = nullptr;
int (MUNewEquipUI::*MUNewEquipUI::OriGetNewPos)( int nBase, int nInventory) = nullptr;
int (MUItemFlyInfo::*MUItemFlyInfo::OriGetBoxCurrentItemPosIndex)() = nullptr;
MUUIChaosBox * (MUUIPaneMng::*MUUIPaneMng::OriGetUIChaosBox)() = nullptr;
MUNewEquipUI_MUUIItemTable *(MUUIChaosBox::*MUUIChaosBox::OriGetItemTable)() = nullptr;
int (MUUnkChaoBox::*MUUnkChaoBox::OriGetCurrentChaoBoxType)() =nullptr;
MUUIWarehouse *(MUUIWarehouse::*MUUIPaneMng::OriGetUIWarehouse)() = nullptr;
int (MUUIWarehouse::*MUUIWarehouse::OriGetItemTablePosition)( MUNewEquipUI_MUUIItemTable *pTable) = nullptr;
int (MUUIWarehouse::*MUUIWarehouse::OriGetItemPos)( int nBasePos, MUNewEquipUI_MUUIItemTable *pTableBase ) = nullptr;
void (MUUIWarehouse::*MUUIWarehouse::OriCheckAndSendMoveItem)( MUItemInfo *pItem, int nFrom, int nTo ) = nullptr;
MUUITrade *(MUUIPaneMng::*MUUIPaneMng::OriGetUITrade)() = nullptr;
MUNewEquipUI_MUUIItemTable *(MUUITrade::*MUUITrade::OriGetItemTable)() = nullptr;
int (MUUITrade::*MUUITrade::OriSendMoveItem)( MUItemInfo *pItem, BYTE btFrom, BYTE btTo) = nullptr;
MUNewEquipUI_MUUIItemTable * (MUUIPShop::*MUUIPShop::OriGetItemTable)() = nullptr;
MUUIPShop * (MUUIPaneMng::*MUUIPaneMng::OriGetUIPShop)() = nullptr;
void (*OriMUCheckUnFlyItem)() = nullptr;
void (MUNewEquipUI::*MUNewEquipUI::OriOnItemUnflyToEquipUpdate)( MUItemInfo *pItem ) = nullptr;
int (*OriMUGCPacketMovedItem)(PMSG_ITEMOVE_RESULT *pMsg, int iOpt) = nullptr;
void (MUUICastleSiegeNPCAttack::*MUUICastleSiegeNPCAttack::OriGetBallTargetPos)( MUFloat3 *vPos ) = nullptr;
MUUICastleSiegeNPCAttack * (MUUIPaneMng::*MUUIPaneMng::OriGetUICastleSiegeNPCAttack)() = nullptr;
MUItemFlyInfo * MUItemFlyInfo::GetInstance()
{
return MUItemFlyInfo::OriGetInstance();
}
MUItemInfo * MUItemFlyInfo::GetItemInfo()
{
return (this->*MUItemFlyInfo::OriGetItemInfo)();
}
class MUNewEquipUI_MUUIItemTable * MUItemFlyInfo::GetUITableBase()
{
return (this->*MUItemFlyInfo::OriGetUITableBase)();
}
int MUItemFlyInfo::GetBoxCurrentItemPosIndex()
{
return (this->*MUItemFlyInfo::OriGetBoxCurrentItemPosIndex)();
}
int MUItemFlyInfo::GetBoxCurrentItemPosIndex_FixEquip()
{
int iRet = this->GetBoxCurrentItemPosIndex();
return (iRet >= 12) ? (iRet - 12 + 236) : (iRet);
}
int MUItemFlyInfo::GetBoxCurrentItemPosIndex_FixPShop()
{
if ( this->GetUITableBase() == nullptr )
{
int iRet = this->GetBoxCurrentItemPosIndex();
return (iRet >= 12) ? (iRet - 12 + 236) : (iRet);
}
return this->GetBoxCurrentItemPosIndex();
}
void MUNewEqipUI_Equipment::Draw3DItemEquip()
{
(this->*MUNewEqipUI_Equipment::OriDraw3DItemEquip)();
for ( int i=0;i<2;i++)
{
MUSpriteInfo * pCurr = &m_pNewSpriteSlot[i];
MUItemInfo * pItem = &m_tNewItemInfo[i];
if ( pItem->wItemType != -1 )
{
MUDrawItemInventory((float)(pCurr->m_fX + 1), (float)pCurr->m_fY, (float)(pCurr->m_nWidth - 4), (float)(pCurr->m_nHeight - 4),
pItem->wItemType, pItem->m_level, pItem->m_exl, pItem->m_hion, 0);
}
}
}
void MUDynamicUIManager::RegisterRenderUIText( float fFloatUnk, void (__cdecl *fnFunction)(void *, int, int), void *ptr, int arg1, int arg2 )
{
(this->*MUDynamicUIManager::OriRegisterRenderUIText)(fFloatUnk, fnFunction, ptr, arg1, arg2);
}
MUItemInfo * MUUIItemManager::MakeItemInfoFromByteInfo( BYTE *lpInfoByte )
{
return (this->*MUUIItemManager::OriMakeItemInfoFromByteInfo)( lpInfoByte );
}
void MUUIItemManager::DelRefItem( MUItemInfo *pItem )
{
(this->*MUUIItemManager::OriDelRefItem)(pItem);
}
MUUIPaneMng * MUUIPaneMng::GetInstance()
{
return MUUIPaneMng::OriGetInstance();
}
MUUIItemManager * MUUIPaneMng::GetMUUIItemManager()
{
return (this->*MUUIPaneMng::OriGetMUUIItemManager)();
}
MUUIShowItemInfo * MUUIPaneMng::GetUIShowItemInfo()
{
return (this->*MUUIPaneMng::OriGetUIShowItemInfo)();
}
MUNewEquipUI * MUUIPaneMng::GetMUNewEquipUI()
{
return (this->*MUUIPaneMng::OriGetMUNewEquipUI)();
}
MUUIChaosBox * MUUIPaneMng::GetUIChaosBox()
{
return (this->*MUUIPaneMng::OriGetUIChaosBox)();
}
MUUIWarehouse * MUUIPaneMng::GetUIWarehouse()
{
return (this->*MUUIPaneMng::OriGetUIWarehouse)();
}
MUUITrade * MUUIPaneMng::GetUITrade()
{
return (this->*MUUIPaneMng::OriGetUITrade)();
}
MUUIPShop * MUUIPaneMng::GetUIPShop()
{
return (this->*MUUIPaneMng::OriGetUIPShop)();
}
MUUIItemDropManager * MUUIPaneMng::GetUIItemDropManager()
{
return m_pUIGlobal;
}
MUUICastleSiegeNPCAttack * MUUIPaneMng::GetUICastleSiegeNPCAttack()
{
return (this->*MUUIPaneMng::OriGetUICastleSiegeNPCAttack)();
}
int MUUIShowItemInfo::ShowItemInfo( int posx, int posy, MUItemInfo *pItem, int a4, int a5, int a6 )
{
return (this->*MUUIShowItemInfo::OriShowItemInfo)(posx, posy, pItem, a4, a5, a6);
}
MUNewEquipUI_MUUIItemTable * MUUIChaosBox::GetItemTable()
{
return (this->*MUUIChaosBox::OriGetItemTable)();
}
int MUUnkChaoBox::GetCurrentChaoBoxType()
{
return (this->*MUUnkChaoBox::OriGetCurrentChaoBoxType)();
}
int MUUIWarehouse::GetItemTablePosition( MUNewEquipUI_MUUIItemTable *pTable )
{
return (this->*MUUIWarehouse::OriGetItemTablePosition)(pTable);
}
int MUUIWarehouse::GetItemPos( int nBasePos, MUNewEquipUI_MUUIItemTable *pTableBase )
{
return (this->*MUUIWarehouse::OriGetItemPos)( nBasePos, pTableBase );
}
void MUUIWarehouse::CheckAndSendMoveItem( MUItemInfo *pItem, int nFrom, int nTo )
{
return (this->*MUUIWarehouse::OriCheckAndSendMoveItem)( pItem, nFrom, nTo);
}
MUNewEquipUI_MUUIItemTable * MUUITrade::GetItemTable()
{
return (this->*MUUITrade::OriGetItemTable)();
}
int MUUITrade::SendMoveItem( MUItemInfo *pItem, BYTE btFrom, BYTE btTo )
{
return (this->*MUUITrade::OriSendMoveItem)( pItem, btFrom, btTo );
}
MUNewEquipUI_MUUIItemTable * MUUIPShop::GetItemTable()
{
return (this->*MUUIPShop::OriGetItemTable)();
}
char CheckNewslotHook2_MUSendPacketMoveItem(BYTE sFlag, BYTE btSource, MUItemInfo *pItem, BYTE tFlag, BYTE btTarget)
{
return ( sFlag == 0 && btSource >= 12 ) ?
MUSendPacketMoveItem( 0, btSource - 12 + 236, pItem, tFlag, btTarget ) :
MUSendPacketMoveItem(sFlag, btSource, pItem, tFlag, btTarget );
}
void MUUICastleSiegeNPCAttack::GetBallTargetPos( MUFloat3 *vPos )
{
(this->*MUUICastleSiegeNPCAttack::OriGetBallTargetPos)( vPos );
}
void MUNewEquipUI::InitSpritePosition()
{
// helper
MUSpriteInfo * pSprite = &m_tEquipment.m_arrPriteInfo[0];
MUSpriteInfo * pSpriteNew = &m_tEquipment.m_pNewSpriteSlot[0];
int nBaseX = m_tEquipment.m_fBaseOffX;
int nBaseY = m_tEquipment.m_fBaseOffY;
pSprite[8].m_fX = nBaseX + 13;
pSprite[8].m_fY = nBaseY + 44;
pSprite[8].m_nWidth = 46;
pSprite[8].m_nHeight = 46;
pSprite[8].m_iTex = 31360;
//==============================================================================
// CENTER
// Helm
pSprite[2].m_fX = nBaseX + 60;
pSprite[2].m_fY = nBaseY + 44;
pSprite[2].m_nWidth = 46;
pSprite[2].m_nHeight = 46;
pSprite[2].m_iTex = 31359;
// Armor
pSprite[3].m_fX = nBaseX + 60;
pSprite[3].m_fY = nBaseY + 87;
pSprite[3].m_nWidth = 46;
pSprite[3].m_nHeight = 66;
pSprite[3].m_iTex = 31364;
// Pants
pSprite[4].m_fX = nBaseX + 60; // -12
pSprite[4].m_fY = nBaseY + 150;
pSprite[4].m_nWidth = 46;
pSprite[4].m_nHeight = 46;
pSprite[4].m_iTex = 31366;
//==============================================================================
// LEFT
// Left Hand
pSprite[1].m_fX = nBaseX + 108;
pSprite[1].m_fY = nBaseY + 87;
pSprite[1].m_nWidth = 46;
pSprite[1].m_nHeight = 66;
pSprite[1].m_iTex = 31363;
// Wing
pSprite[7].m_fX = nBaseX + 108;
pSprite[7].m_fY = nBaseY + 44;
pSprite[7].m_nWidth = 46;
pSprite[7].m_nHeight = 46;
pSprite[7].m_iTex = 31361;
// Boots
pSprite[6].m_fX = nBaseX + 108;
pSprite[6].m_fY = nBaseY + 150;
pSprite[6].m_nWidth = 46;
pSprite[6].m_nHeight = 46;
pSprite[6].m_iTex = 31358;
// Right Hand
pSprite[0].m_fX = nBaseX + 13;
pSprite[0].m_fY = nBaseY + 87;
pSprite[0].m_nWidth = 46;
pSprite[0].m_nHeight = 66;
pSprite[0].m_iTex = 31362;
// Gloves
pSprite[5].m_fX = nBaseX + 13;
pSprite[5].m_fY = nBaseY + 150;
pSprite[5].m_nWidth = 46;
pSprite[5].m_nHeight = 46;
pSprite[5].m_iTex = 31365;
//==============================================================================
// LEFT - LEFT
// Pedan
pSprite[9].m_fX = nBaseX + 156;
pSprite[9].m_fY = nBaseY + 44;
pSprite[9].m_nWidth = 28;
pSprite[9].m_nHeight = 28;
pSprite[9].m_iTex = 31368;
// Rings L
pSprite[11].m_fX = nBaseX + 156;
pSprite[11].m_fY = nBaseY + 72;
pSprite[11].m_nWidth = 28;
pSprite[11].m_nHeight = 28;
pSprite[11].m_iTex = 31367;
//Ring R
pSprite[10].m_fX = nBaseX + 156;
pSprite[10].m_fY = nBaseY + 100;
pSprite[10].m_nWidth = 28;
pSprite[10].m_nHeight = 28;
pSprite[10].m_iTex = 31367;
// My Custom
pSpriteNew[0].m_fX = nBaseX + 156;
pSpriteNew[0].m_fY = nBaseY + 128;
pSpriteNew[0].m_nWidth = 28;
pSpriteNew[0].m_nHeight = 28;
pSpriteNew[0].m_iTex = 31367;
pSpriteNew[1].m_fX = nBaseX + 156;
pSpriteNew[1].m_fY = nBaseY + 156;
pSpriteNew[1].m_nWidth = 28;
pSpriteNew[1].m_nHeight = 28;
pSpriteNew[1].m_iTex = 31367;
}
MUNewEquipUI * MUNewEquipUI::Construct()
{
MUNewEquipUI * pRet = (this->*MUNewEquipUI::OriConstruct)();
m_tEquipment.m_pNewSpriteSlot = new MUSpriteInfo[2];
// For test
m_tEquipment.m_tNewItemInfo[0].Clear();
m_tEquipment.m_tNewItemInfo[1].Clear();
#if _WALL_DEBUG == 1
printf("Constructor Run\n");
#endif
return this;
}
void MUNewEquipUI::Destruct()
{
(this->*MUNewEquipUI::OriDestruct)();
delete m_tEquipment.m_pNewSpriteSlot;
for ( int i=0;i<ARRAYSIZE(m_tEquipment.m_tNewItemInfo);i++)
{
if( m_tEquipment.m_tNewItemInfo[i].wItemType != -1 )
{
m_tEquipment.m_tNewItemInfo[i].Clear();
}
}
#if _WALL_DEBUG == 1
printf("Destructor Run\n");
#endif
}
void MUNewEquipUI::DrawSpriteSlot()
{
(this->*MUNewEquipUI::OriDrawSpriteSlot)();
for ( int i=0;i<2;i++)
{
MUSpriteInfo * pCur = &m_tEquipment.m_pNewSpriteSlot[i];
MUSetGL_TEX_ALPHA_NoCULL_BLEND2(1);
MUDrawUIE(pCur->m_iTex, (float)pCur->m_fX, (float)pCur->m_fY, (float)pCur->m_nWidth, (float)pCur->m_nHeight);
MUSetGL_TEX_NoTEST_CULL_DEPTH_NoBLEND();
MUItemInfo * pItem = &m_tEquipment.m_tNewItemInfo[i];
if ( pItem->wItemType != -1 )
{
if ( this->IsNewItemCanbeEquip( i, pItem ) == FALSE )
{
glColor4f(0.9f, 0.1f, 0.1f, 0.4f);
MUSetGL_TEX_ALPHA_NoCULL_BLEND2(1);
MUDrawUIA((float)(pCur->m_fX + 1), (float)pCur->m_fY, (float)(pCur->m_nWidth - 4), (float)(pCur->m_nHeight - 4), 0.0f, 0);
MUSetGL_TEX();
}
}
}
if( MUItemFlyInfo::GetInstance() != nullptr && m_tEquipment.m_nMouseInNewSlotPos != -1 )
{
MUItemInfo * pItemFly = MUItemFlyInfo::GetInstance()->GetItemInfo();
MUSpriteInfo * pCur = &m_tEquipment.m_pNewSpriteSlot[m_tEquipment.m_nMouseInNewSlotPos];
MUItemInfo *pCurrentItem = &m_tEquipment.m_tNewItemInfo[m_tEquipment.m_nMouseInNewSlotPos];
BOOL bRedAlert = FALSE;
if ( pItemFly != nullptr && pCurrentItem->wItemType != -1 )
{
bRedAlert = TRUE;
}
else if ( this->IsNewItemCanbeEquip( m_tEquipment.m_nMouseInNewSlotPos, pItemFly ) == FALSE )
{
bRedAlert = TRUE;
}
if ( bRedAlert == TRUE )
{
glColor4f(0.9f, 0.1f, 0.1f, 0.4f);
MUSetGL_TEX_ALPHA_NoCULL_BLEND2(1);
MUDrawUIA((float)(pCur->m_fX + 1), (float)pCur->m_fY, (float)(pCur->m_nWidth - 4), (float)(pCur->m_nHeight - 4), 0.0f, 0);
MUSetGL_TEX();
}
}
if ( m_tEquipment.m_nMouseInNewSlotPos != -1 && m_tEquipment.m_pDynamicUIMng != nullptr )
{
m_tEquipment.m_pDynamicUIMng->RegisterRenderUIText( 5.5f, (void (__cdecl *)(void *, int, int))MUNewEquipUI__RenderInfoString, this, m_tEquipment.m_nMouseInNewSlotPos + 12, 0 );
}
}
char MUNewEquipUI::Update()
{
char cRet = (this->*MUNewEquipUI::OriUpdate)();
if ( cRet == 0 )
{
return 0;
}
m_tEquipment.m_nMouseInNewSlotPos = -1;
for (int i = 0; i < 2; i++ )
{
MUSpriteInfo * pCur = &m_tEquipment.m_pNewSpriteSlot[i];
if ( MUCheckMouseInBox( pCur->m_fX + 1, pCur->m_fY, pCur->m_nWidth - 4, pCur->m_nHeight - 4) )
{
m_tEquipment.m_nMouseInNewSlotPos = i;
return 1;
}
}
return cRet;
}
void MUNewEquipUI::RenderInfoItemChoose( int iNumItem )
{
if ( iNumItem < 12 )
{
(this->*MUNewEquipUI::OriRenderInfoItemChoose)( iNumItem );
}
else
{
if ( m_tEquipment.m_nMouseInNewSlotPos != -1)
{
int iReal = iNumItem - 12;
MUItemInfo *pItem = &m_tEquipment.m_tNewItemInfo[iReal];
MUSpriteInfo *pSlot = &m_tEquipment.m_pNewSpriteSlot[iReal];
if ( pItem->wItemType != -1 )
{
if ( m_tEquipment.m_bIsShowRepair == 1 )
{
MUShowItemRepairInfo( pSlot->m_fX + (pSlot->m_nWidth / 2),pSlot->m_fY + (pSlot->m_nHeight / 2), pItem );
}
else
{
MUUIPaneMng::GetInstance()->GetUIShowItemInfo()->ShowItemInfo( pSlot->m_fX + (pSlot->m_nWidth / 2),pSlot->m_fY + (pSlot->m_nHeight / 2), pItem, 0,0,0 );
}
}
}
}
}
char MUNewEquipUI::CheckClickEqiupItem()
{
if ( (this->*MUNewEquipUI::OriCheckClickEqiupItem)() == 1 )
{
return 1;
}
if ( m_tEquipment.m_nMouseInNewSlotPos == -1 || MUKeyManager::GetInstance()->IsKeyUPressOnce( VK_LBUTTON ) == 0 )
{
return 0;
}
MUItemFlyInfo * pFlyItemInstance = MUItemFlyInfo::GetInstance();
if ( pFlyItemInstance != nullptr )
{
MUItemInfo * pItemCurr = &m_tEquipment.m_tNewItemInfo[m_tEquipment.m_nMouseInNewSlotPos];
MUItemInfo * pItemFly = pFlyItemInstance->GetItemInfo();
if ( pItemCurr->wItemType != -1 )
{
return 1;
}
if (this->IsNewItemCanbeEquip( m_tEquipment.m_nMouseInNewSlotPos, pItemFly ) == FALSE)
{
return 1;
}
// Check Main Inventory
class MUNewEquipUI_MUUIItemTable * pUITableParent = pFlyItemInstance->GetUITableBase();
int iInvNum = MUUIPaneMng::GetInstance()->GetMUNewEquipUI()->IsTableFromThis( pUITableParent );
if ( iInvNum != -1 )
{
int iFromPos = this->GetNewPos( pFlyItemInstance->GetBoxCurrentItemPosIndex(), iInvNum) + 12;
MUSendPacketMoveItem(0, iFromPos , pItemFly, 0, m_tEquipment.m_nMouseInNewSlotPos + 236);
#if _WALL_DEBUG == 1
printf("Main Inventory Equip (From: %d, To %d)\n",iFromPos,m_tEquipment.m_nMouseInNewSlotPos);
#endif
return 1;
}
// Check Chaos Box
if ( pFlyItemInstance->GetUITableBase() == MUUIPaneMng::GetInstance()->GetUIChaosBox()->GetItemTable() )
{
int iFromPos = pFlyItemInstance->GetBoxCurrentItemPosIndex();
MUSendPacketMoveItem(g_UnkChaosBox.GetCurrentChaoBoxType(), iFromPos, pItemFly, 0, m_tEquipment.m_nMouseInNewSlotPos + 236);
#if _WALL_DEBUG == 1
printf("Trade Equip (From: %d, To %d)\n",iFromPos,m_tEquipment.m_nMouseInNewSlotPos);
#endif
return 1;
}
// Check Warehouse
if ( MUUIPaneMng::GetInstance()->GetUIWarehouse()->GetItemTablePosition( pFlyItemInstance->GetUITableBase()) != -1 )
{
int iFromPos = MUUIPaneMng::GetInstance()->GetUIWarehouse()->GetItemPos( pFlyItemInstance->GetBoxCurrentItemPosIndex(), pFlyItemInstance->GetUITableBase());
MUUIPaneMng::GetInstance()->GetUIWarehouse()->CheckAndSendMoveItem( pItemFly, iFromPos, 236 + m_tEquipment.m_nMouseInNewSlotPos);
#if _WALL_DEBUG == 1
printf("Warehouse Equip (From: %d, To %d)\n",iFromPos,m_tEquipment.m_nMouseInNewSlotPos);
#endif
return 1;
}
if ( pFlyItemInstance->GetUITableBase() == MUUIPaneMng::GetInstance()->GetUITrade()->GetItemTable() )
{
int iFromPos = pFlyItemInstance->GetBoxCurrentItemPosIndex();
MUUIPaneMng::GetInstance()->GetUITrade()->SendMoveItem(pItemFly, pFlyItemInstance->GetBoxCurrentItemPosIndex(), 236 + m_tEquipment.m_nMouseInNewSlotPos);
#if _WALL_DEBUG == 1
printf("Trade Equip (From: %d, To %d)\n",iFromPos,m_tEquipment.m_nMouseInNewSlotPos);
#endif
return 1;
}
if ( pFlyItemInstance->GetUITableBase() == MUUIPaneMng::GetInstance()->GetUIPShop()->GetItemTable() )
{
int iFromPos = pFlyItemInstance->GetBoxCurrentItemPosIndex() + 204;
MUSendPacketMoveItem(4, iFromPos, pItemFly, 0, m_tEquipment.m_nMouseInNewSlotPos + 236);
#if _WALL_DEBUG == 1
printf("PShop Equip (From: %d, To %d)\n",iFromPos,m_tEquipment.m_nMouseInNewSlotPos);
#endif
return 1;
}
if ( pItemFly->m_nPosY == 1 && !g_bSendingPacketMoveItem )
{
if ( pFlyItemInstance->GetBoxCurrentItemPosIndex() != (m_tEquipment.m_nMouseInNewSlotPos + 12) )
{
if ( pItemFly->m_nPosX >= 12 )
{
MUSendPacketMoveItem( 0, pItemFly->m_nPosX - 12 + 236, pItemFly, 0, m_tEquipment.m_nMouseInNewSlotPos + 236);
}
else
{
MUSendPacketMoveItem( 0, pItemFly->m_nPosX , pItemFly, 0, m_tEquipment.m_nMouseInNewSlotPos + 236);
}
return 1;
}
MUCheckUnFlyItem();
}
return 0;
}
if ( m_tEquipment.m_bIsShowRepair != 1 )
{
MUItemInfo * pItem = &m_tEquipment.m_tNewItemInfo[m_tEquipment.m_nMouseInNewSlotPos];
if ( pItem->wItemType == -1)
{
return 0;
}
pItem->m_nPosX = m_tEquipment.m_nMouseInNewSlotPos + 12;
pItem->m_nPosY = 1;
if ( MUCreateFlyItem( nullptr, pItem ))
{
this->RemoveNewItemEquip( m_tEquipment.m_nMouseInNewSlotPos );
}
return 0;
}
return 0;
}
void MUNewEquipUI::RemoveNewItemEquip( int iPos )
{
if ( iPos < 0 || iPos >= ARRAYSIZE(m_tEquipment.m_tNewItemInfo) )
{
return;
}
if ( m_tEquipment.m_tNewItemInfo[iPos].wItemType != -1 )
{
this->OnItemRemove( &m_tEquipment.m_tNewItemInfo[iPos] );
m_tEquipment.m_tNewItemInfo[iPos].Clear();
}
this->OnItemChanged();
}
void MUNewEquipUI::SetNewItemEquip( int iPos, BYTE * pData )
{
MUItemInfo * pItemEquip = &m_tEquipment.m_tNewItemInfo[iPos];
if ( pItemEquip->wItemType != -1 )
{
this->RemoveNewItemEquip( iPos );
}
MUItemInfo * pItem = MUUIPaneMng::GetInstance()->GetMUUIItemManager()->MakeItemInfoFromByteInfo(pData);
memcpy(pItemEquip, pItem, sizeof(m_tEquipment.m_tNewItemInfo[1]));
MUUIPaneMng::GetInstance()->GetMUUIItemManager()->DelRefItem( pItem );
if ( g_MainCharacterInfo != nullptr )
{
this->OnItemUnflyToEquipUpdate( pItemEquip );
}
}
void MUNewEquipUI::OnItemRemove( MUItemInfo *pItem )
{
(this->*MUNewEquipUI::OriOnItemRemove)(pItem);
}
void MUNewEquipUI::OnItemChanged()
{
(this->*MUNewEquipUI::OriOnItemChanged)();
}
BOOL MUNewEquipUI::IsNewItemCanbeEquip( int iNewSlotIndex, MUItemInfo * pItem )
{
return TRUE;
}
int MUNewEquipUI::IsTableFromThis( class MUNewEquipUI_MUUIItemTable *pTableUI )
{
return (this->*MUNewEquipUI::OriIsTableFromThis)( pTableUI );
}
int MUNewEquipUI::GetNewPos( int nBase, int nInventory )
{
return (this->*MUNewEquipUI::OriGetNewPos)(nBase, nInventory);
}
void MUNewEquipUI::OnItemUnflyToEquipUpdate( MUItemInfo *pItem )
{
(this->*MUNewEquipUI::OriOnItemUnflyToEquipUpdate)( pItem );
}
void MUCheckUnFlyItem()
{
BOOL bProcessed = FALSE;
if( MUItemFlyInfo::GetInstance() != nullptr && g_bSendingPacketMoveItem == FALSE )
{
MUNewEquipUI_MUUIItemTable * pTableItem = MUItemFlyInfo::GetInstance()->GetUITableBase();
if ( pTableItem == nullptr )
{
MUItemInfo * pItem = MUItemFlyInfo::GetInstance()->GetItemInfo();
MUNewEquipUI * pUIEquip = MUUIPaneMng::GetInstance()->GetMUNewEquipUI();
if ( pUIEquip != nullptr && pItem != nullptr && pItem->m_nPosY == 1 && pItem->m_nPosX >= 12 )
{
MUItemInfo * pEquipItem = &pUIEquip->m_tEquipment.m_tNewItemInfo[pItem->m_nPosX - 12];
memcpy( pEquipItem, pItem, sizeof(MUItemInfo) );
pUIEquip->OnItemUnflyToEquipUpdate( pEquipItem );
MUDestroyFlyItem();
bProcessed = TRUE;
}
}
}
if ( bProcessed == FALSE )
{
OriMUCheckUnFlyItem();
}
}
int MUGCPacketMovedItem(PMSG_ITEMOVE_RESULT *pMsg, int iOpt)
{
printf("Test Moving: %d,%d\n", pMsg->btTargetFlag, pMsg->btPosition);
BOOL bProcessed = FALSE;
int iRet = 0;
if ( iOpt )
{
if ( pMsg->btTargetFlag == 0 && pMsg->btPosition >= 236 )
{
int iRealPos = pMsg->btPosition - 236;
if ( iRealPos >= 0 && iRealPos < 2)
{
MUDestroyFlyItem();
MUNewEquipUI * pUIEquip = MUUIPaneMng::GetInstance()->GetMUNewEquipUI();
pUIEquip->SetNewItemEquip( iRealPos, pMsg->szInfo );
bProcessed = TRUE;
g_bSendingPacketMoveItem = 0;
iRet = 0;
}
}
}
if ( bProcessed == FALSE )
{
iRet = OriMUGCPacketMovedItem( pMsg, iOpt );
}
return iRet;
}