962 lines
25 KiB
C++
962 lines
25 KiB
C++
|
|
#include "stdafx.h"
|
|
#include <toolkit/XStringUtil.h>
|
|
#include "SStringDB.h"
|
|
#include "SItemDB.h"
|
|
//#include "SUIUtil.h"
|
|
#include "SUIDisplayInfo.h"
|
|
#include "SGameManager.h"
|
|
#include "SGameSystem.h"
|
|
#include "SGameMessage.h"
|
|
//#include "SGameMessageUI.h"
|
|
#include "SInventoryMgr.h"
|
|
#include "KUIDragAndDrop.h"
|
|
#include "KUIControlStatic.h"
|
|
#include "SUIDestructionWnd.h"
|
|
#include "SStorageMgr.h"
|
|
#include "SUILazyTooltip.h"
|
|
|
|
extern SGameSystem * g_pCurrentGameSystem;
|
|
const int nLayer = 8;
|
|
//
|
|
// ID 에 해당하는 Slot Index 반환.
|
|
//
|
|
int GetSlotIndex( std::string strID )
|
|
{
|
|
int index = -1;
|
|
|
|
std::string::size_type fPos = strID.find( "icon_item" );
|
|
if( fPos != std::string::npos )
|
|
{
|
|
/// 2010.12.20 - prodongi
|
|
//index = ::atoi( strID.substr( fPos + 1, strID.size() ).c_str() );
|
|
std::string strIndex = strID.substr( fPos + strlen("icon_item"), strID.size());
|
|
index = ::atoi(strIndex.c_str());
|
|
}
|
|
|
|
return index;
|
|
}
|
|
|
|
|
|
// 파괴할 아이템의 유효성 검사.
|
|
bool SUIDestructionWnd::ValidateDestructionItem( AR_HANDLE hItem )
|
|
{
|
|
SInventorySlot* pSlot = m_InventoryMgr.GetItemInfo( hItem );
|
|
if( pSlot )
|
|
{
|
|
// 파괴불가 아이템.
|
|
const ItemBase* pItem = (ItemBase*)GetItemDB().GetItemData( pSlot->GetItemCode() );
|
|
if( pItem->CheckFlag( ItemBase::ITEM_FLAG::FLAG_CANT_DESTRUCTION ) )
|
|
{
|
|
return false;
|
|
}
|
|
|
|
// 장착중인 아이템은 불가. (카드, 장비)
|
|
int nType = GetItemDB().GetUseType(pSlot->GetItemCode());
|
|
if( nType == ItemBase::TYPE_CARD || nType == ItemBase::TYPE_ARMOR )
|
|
{
|
|
if( m_InventoryMgr.IsEquipCard( hItem ) || m_InventoryMgr.IsEquip( hItem ) )
|
|
{
|
|
//m_pGameManager->PostMsgAtDynamic( new SIMSG_REQ_OPEN_MSGBOX( SIMSG_REQ_OPEN_MSGBOX::MSGBOX_GENERAL, S(297), true ) );
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/// 2011.05.13 벨트 슬롯 체크 - prodongi
|
|
if (m_InventoryMgr.IsBeltSlotCard(hItem))
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
|
|
|
|
//
|
|
// Destruction.
|
|
//
|
|
SUIDestructionWnd::~SUIDestructionWnd()
|
|
{
|
|
Release();
|
|
}
|
|
|
|
|
|
//
|
|
// Release.
|
|
//
|
|
void SUIDestructionWnd::Release()
|
|
{
|
|
m_arrItems.clear(); // 아이템묶음 이중배열.
|
|
m_arrSlotControl.clear(); // 슬롯컨트롤 배열.
|
|
m_arrCountControl.clear(); // 아이템 개수 컨트롤 배열.
|
|
}
|
|
|
|
|
|
//
|
|
// CreateWnd.
|
|
//
|
|
SUIWnd * SUIDestructionWnd::CreateWnd( const char * szNUIFileName, KUIWndManager * pWndManager, KPoint kPos, int nWindowID )
|
|
{
|
|
SUIWnd::CreateWnd( szNUIFileName, pWndManager, kPos, nWindowID );
|
|
|
|
m_ReserveDropItemHandle = 0;
|
|
m_decreaseIndex = -1; // 개수 감소시킬 아이템 인덱스.
|
|
|
|
// 슬롯컨트롤 배열, 아이템개수 컨트롤 배열.
|
|
m_arrSlotControl.resize( DESTRUCTION_TOTAL );
|
|
m_arrCountControl.resize( DESTRUCTION_TOTAL );
|
|
for( int i=0; i<DESTRUCTION_TOTAL; ++i )
|
|
{
|
|
m_arrSlotControl[ i ] = dynamicCast< KUIControlMultiIcon * >( GetChild( CStringUtil::StringFormat("icon_item%02d", i).c_str() ) );
|
|
m_arrCountControl[ i ] = GetChild( CStringUtil::StringFormat("static_itemcount%02d", i).c_str() );
|
|
m_arrCountControl[ i ]->SetShow( false );
|
|
m_arrSlotControl[ i ]->SetIconLayer(nLayer);
|
|
}
|
|
|
|
this->MovePos( 300, 200 ); //servantes 2010.11.23 OnNotifyUIWindowOpen에 있던 걸 갖 고옴
|
|
|
|
return this;
|
|
}
|
|
|
|
|
|
//
|
|
// InitControls.
|
|
//
|
|
bool SUIDestructionWnd::InitControls( KPoint kPos )
|
|
{
|
|
return SUIWnd::InitControls( kPos );
|
|
}
|
|
|
|
|
|
//
|
|
// Perform.
|
|
//
|
|
void * SUIDestructionWnd::Perform( KID id, KArg & msg )
|
|
{
|
|
_CID( UI_BEGIN_DRAG );
|
|
_CID( UI_SEND_DROP );
|
|
_CID( UI_RECV_DROP );
|
|
|
|
if ( id == id_UI_BEGIN_DRAG )
|
|
{
|
|
KUIBeginDragMessage* pBeginMsg = static_cast<KUIBeginDragMessage*>( &msg );
|
|
const char* szControlID = pBeginMsg->sDragControlID.c_str();
|
|
|
|
SInventorySlot * pSlot = NULL;
|
|
int slotIndex = GetSlotIndex( szControlID );
|
|
if( slotIndex < m_arrItems.size() )
|
|
pSlot = m_InventoryMgr.GetItemInfo( m_arrItems[ slotIndex ].handle );
|
|
|
|
// ★ Drag Start.
|
|
if( pSlot )
|
|
{
|
|
KUIControlMultiIcon* pWndMultiIcon = m_arrSlotControl[ slotIndex ];
|
|
if( pWndMultiIcon )
|
|
{
|
|
const KUIControlMultiIcon::ICON_INFO& rIconInfo = pWndMultiIcon->GetIconInfoByLayer(0);
|
|
|
|
m_pDisplayInfo->SetUIDragInfo( new SUIDestructionItemDragInfo( pSlot->GetHandle() ) );
|
|
m_pDragAndDropIcon->SetStateIcon( pWndMultiIcon->GetSprName(), rIconInfo.sAniName.c_str(), rIconInfo.nFrameIndex, STATE_NORMAL );
|
|
|
|
pBeginMsg->pDragAndDropRenderer = m_pDragAndDropIcon;
|
|
}
|
|
}
|
|
return NULL;
|
|
}
|
|
else if ( id == id_UI_SEND_DROP )
|
|
{
|
|
KUISendRecvDropMessage* pSendMsg = static_cast<KUISendRecvDropMessage*>( &msg );
|
|
|
|
SUIDragInfo* pUIDragInfo = m_pDisplayInfo->GetUIDragInfo();
|
|
if( NULL != pUIDragInfo && SUIDragInfo::DRAGTYPE_DESTRUCTION == pUIDragInfo->m_type )
|
|
{
|
|
SUIDestructionItemDragInfo* pDestructionDragInfo = (SUIDestructionItemDragInfo*)pUIDragInfo;
|
|
|
|
// 동일한 창이 아닌 곳에 드롭했다면 슬롯을 비운다. // 2010.10.13 - servantes
|
|
if( pSendMsg->sRecvDropParentID != std::string(GetID()) )
|
|
{
|
|
int nCnt = GetItemCount( pSendMsg->sSendDropControlID.c_str() );
|
|
if(nCnt > 1) // 여러개가 있을 경우
|
|
{
|
|
m_bDeleteItemFlag = true;
|
|
m_strDeleteItem = pSendMsg->sSendDropControlID;
|
|
m_pGameManager->PostMsgAtDynamic( new SIMSG_UI_REQ_INPUTNUMBER( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_DESTRUCTION, count_t(nCnt) ) ); //수입력기가 뜬다
|
|
}
|
|
else // 한 개일 경우
|
|
{
|
|
DecreaseItem( pSendMsg->sSendDropControlID.c_str() );
|
|
}
|
|
}
|
|
|
|
// Drag & Drop 정보 제거
|
|
m_pDisplayInfo->SetUIDragInfo();
|
|
}
|
|
return NULL;
|
|
}
|
|
else if ( id == id_UI_RECV_DROP )
|
|
{
|
|
KUISendRecvDropMessage* pRecvMsg = static_cast<KUISendRecvDropMessage*>( &msg );
|
|
|
|
SUIDragInfo* pUIDragInfo = m_pDisplayInfo->GetUIDragInfo();
|
|
|
|
if( pUIDragInfo && SUIDragInfo::DRAGTYPE_INVENITEM == pUIDragInfo->m_type ) // 아이템인 경우만
|
|
{
|
|
SUIInvenItemDragInfo* pItemDragInfo = (SUIInvenItemDragInfo*)pUIDragInfo;
|
|
const char* szDropControlID = pRecvMsg->sRecvDropControlID.c_str();
|
|
|
|
SInventorySlot* pSlot = m_InventoryMgr.GetItemInfo( pItemDragInfo->m_hItem );
|
|
if( !pSlot )
|
|
return NULL;
|
|
|
|
// ★ 파괴할 아이템의 유효성 검사.
|
|
if( !ValidateDestructionItem( pSlot->GetHandle() ) )
|
|
{
|
|
return NULL;
|
|
}
|
|
|
|
// 개수가 여러개인 경우 계산기 열기.
|
|
if( pSlot->GetItemCount() > 1 )
|
|
{
|
|
m_ReserveDropItemHandle = pItemDragInfo->m_hItem;
|
|
m_pGameManager->PostMsgAtDynamic( new SIMSG_UI_REQ_INPUTNUMBER( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_DESTRUCTION, pSlot->GetItemCount() ) );
|
|
}
|
|
|
|
// 1개, 바로 추가.
|
|
else
|
|
{
|
|
AddItem( pItemDragInfo->m_hItem, count_t( 1 ), FROM_INVENTORY ); // 2011. 9. 19 - marine
|
|
//AddItem( pItemDragInfo->m_hItem, count_t( 1 ) );
|
|
m_pGameManager->StartSound( m_pDisplayInfo->GetMaterialSound( GetItemDB().GetMaterial(pSlot->GetItemCode()) ) );
|
|
}
|
|
}
|
|
// 2011. 9. 16 - marine 창고에서도 파괴 가능하게..
|
|
else if( pUIDragInfo && SUIDragInfo::DRAGTYPE_STORAGE == pUIDragInfo->m_type ) // 아이템인 경우만
|
|
{
|
|
SUIStorageDragInfo* pItemDragInfo = (SUIStorageDragInfo*)pUIDragInfo;
|
|
const char* szDropControlID = pRecvMsg->sRecvDropControlID.c_str();
|
|
|
|
SInventorySlot* pSlot = m_StorageMgr.GetItemInfo( pItemDragInfo->m_hItem );
|
|
|
|
//SUIInvenItemDragInfo* pItemDragInfo = (SUIInvenItemDragInfo*)pUIDragInfo;
|
|
//const char* szDropControlID = pRecvMsg->sRecvDropControlID.c_str();
|
|
|
|
//SInventorySlot* pSlot = m_InventoryMgr.GetItemInfo( pItemDragInfo->m_hItem );
|
|
if( !pSlot )
|
|
return NULL;
|
|
|
|
// ★ 파괴할 아이템의 유효성 검사.
|
|
if( !ValidateDestructionItem( pSlot->GetHandle() ) )
|
|
{
|
|
return NULL;
|
|
}
|
|
|
|
// 개수가 여러개인 경우 계산기 열기.
|
|
if( pSlot->GetItemCount() > 1 )
|
|
{
|
|
m_ReserveDropItemHandle = pItemDragInfo->m_hItem;
|
|
m_pGameManager->PostMsgAtDynamic( new SIMSG_UI_REQ_INPUTNUMBER( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_DESTRUCTION, pSlot->GetItemCount() ) );
|
|
}
|
|
|
|
// 1개, 바로 추가.
|
|
else
|
|
{
|
|
AddItem( pItemDragInfo->m_hItem, count_t( 1 ), FROM_STORAGE ); // 2011. 9. 19 - marine
|
|
//AddItem( pItemDragInfo->m_hItem, count_t( 1 ) );
|
|
m_pGameManager->StartSound( m_pDisplayInfo->GetMaterialSound( GetItemDB().GetMaterial(pSlot->GetItemCode()) ) );
|
|
}
|
|
}
|
|
|
|
return NULL;
|
|
}
|
|
|
|
return SUIWnd::Perform( id, msg );
|
|
}
|
|
|
|
|
|
//
|
|
// PumpUpMessage.
|
|
//
|
|
void SUIDestructionWnd::PumpUpMessage( LPCSTR lpszControlID, DWORD nMessage, DWORD lparam, DWORD wparam )
|
|
{
|
|
switch( nMessage )
|
|
{
|
|
// KBUTTON_CLICK.
|
|
case KUI_MESSAGE::KBUTTON_CLICK :
|
|
|
|
// 닫기.
|
|
if( !::_stricmp( lpszControlID, "button_close_trim_01" ) )
|
|
m_pGameManager->PostMsgAtDynamic( new SIMSG_SHOW_UIWINDOW( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_DESTRUCTION, false ) );
|
|
|
|
// 파괴.
|
|
else if( !::_stricmp( lpszControlID, "button_inchant" ) )
|
|
m_pGameManager->PostMsgAtDynamic( new SIMSG_REQ_OPEN_MSGBOX( SIMSG_REQ_OPEN_MSGBOX::MSGBOX_ITEMDESTRUCTION, S( 731 ), true ) );
|
|
break;
|
|
|
|
//servantes 2010.10.25
|
|
case KUI_MESSAGE::KICON_PRESSING:
|
|
{
|
|
if(m_bShiftKey)
|
|
{
|
|
int nCnt = GetItemCount( lpszControlID );
|
|
if(nCnt > 1) // 여러개가 있을 경우
|
|
{
|
|
m_bDeleteItemFlag = true;
|
|
m_strDeleteItem = lpszControlID;
|
|
m_pGameManager->PostMsgAtDynamic( new SIMSG_UI_REQ_INPUTNUMBER( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_DESTRUCTION, count_t(nCnt) ) ); //수입력기가 뜬다
|
|
}
|
|
else // 한 개일 경우
|
|
{
|
|
DecreaseItem( lpszControlID );
|
|
}
|
|
}
|
|
else if(m_bControlKey)
|
|
{
|
|
int nCnt = GetItemCount( lpszControlID );
|
|
|
|
if(nCnt == 1)
|
|
DecreaseItem( lpszControlID );
|
|
else if(nCnt <= 10)
|
|
{
|
|
std::string strCtrl = lpszControlID;
|
|
int index = ::atoi( strCtrl.substr( strlen( "icon_item" ) ).c_str() );
|
|
EraseItem( index );
|
|
RefreshAllSlot();
|
|
}
|
|
else if(nCnt > 10)
|
|
{
|
|
int tc = nCnt - 10;
|
|
SetItemCount( lpszControlID, tc );
|
|
RefreshAllSlot();
|
|
}
|
|
else
|
|
break;
|
|
}
|
|
}
|
|
break;
|
|
|
|
|
|
// KICON_DBLCLK.
|
|
case KUI_MESSAGE::KICON_DBLCLK:
|
|
{
|
|
//servantes 2010.10.25
|
|
if(m_bControlKey) //servantes 2011.01.05
|
|
break;
|
|
|
|
int nCnt = GetItemCount( lpszControlID );
|
|
if(nCnt > 1) // 여러개가 있을 경우
|
|
{
|
|
m_bDeleteItemFlag = true;
|
|
m_strDeleteItem = lpszControlID;
|
|
m_pGameManager->PostMsgAtDynamic( new SIMSG_UI_REQ_INPUTNUMBER( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_DESTRUCTION, count_t(nCnt) ) ); //수입력기가 뜬다
|
|
}
|
|
else // 한 개일 경우
|
|
{
|
|
DecreaseItem( lpszControlID );
|
|
}
|
|
}
|
|
break;
|
|
|
|
case KUI_MESSAGE::KGENWND_MOVE:
|
|
{
|
|
LimitMoveWnd();
|
|
}
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
//
|
|
// ProcMsgAtStatic.
|
|
//
|
|
void SUIDestructionWnd::ProcMsgAtStatic( SGameMessage * pMsg )
|
|
{
|
|
switch( pMsg->nType )
|
|
{
|
|
|
|
// 아이템파괴 결정. ( 메세지박스에서 확인선택 ).
|
|
case IMSG_UI_DESTRUCTIONITEM:
|
|
ItemDestroy();
|
|
break;
|
|
|
|
|
|
// 인벤토리에서 파괴할 아이템정보 전달.
|
|
case IMSG_DESTRY_ITEM :
|
|
{
|
|
pMsg->bUse = true;
|
|
|
|
//AddItem( pMsg ); // 아이템추가.
|
|
SIMSG_UI_DESTROY_ITEM * pItemData = dynamicCast< SIMSG_UI_DESTROY_ITEM * >( pMsg );
|
|
AddItem( pItemData->handle, pItemData->count );
|
|
}
|
|
break;
|
|
|
|
//servantes 2010.10.25
|
|
case IMSG_HOTKEY_EX:
|
|
{
|
|
SIMSG_HOTKEY_EX* pHotKey = dynamicCast<SIMSG_HOTKEY_EX*>(pMsg);
|
|
|
|
if( pHotKey->wParam == VK_SHIFT )
|
|
m_bShiftKey = (pHotKey->bUp == 0); //servantes 2010.10.15
|
|
if( pHotKey->wParam == VK_CONTROL ) //servantes 2010.10.15
|
|
m_bControlKey = (pHotKey->bUp == 0);
|
|
if( pHotKey->wParam == VK_MENU )
|
|
{
|
|
bool bPreState = m_bAltKey;
|
|
m_bAltKey = (pHotKey->bUp == 0);
|
|
|
|
if( bPreState != m_bAltKey && IsShow() )
|
|
{
|
|
RefreshAllSlot();
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
|
|
case IMSG_DESTROY_MOVEITEM:
|
|
{
|
|
SIMSG_DESTROY_MOVEITEM * pItemData = dynamicCast< SIMSG_DESTROY_MOVEITEM * >( pMsg );
|
|
|
|
/// 2011.05.13 유효성 검사 - prodongi
|
|
if(!ValidateDestructionItem(pItemData->m_handle))
|
|
{
|
|
pMsg->bUse = true;
|
|
return ;
|
|
}
|
|
|
|
// 2012. 8. 6 - marine 수입력기 호출 플래그 추가
|
|
if( pItemData->m_bCallNumberInput )
|
|
{
|
|
m_ReserveDropItemHandle = pItemData->m_handle;
|
|
m_pGameManager->PostMsgAtDynamic( new SIMSG_UI_REQ_INPUTNUMBER( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_DESTRUCTION, pItemData->m_nMax ) );
|
|
}
|
|
else
|
|
AddItem( pItemData->m_handle, pItemData->m_nValue );
|
|
|
|
pMsg->bUse = true;
|
|
}
|
|
break;
|
|
case IMSG_UI_INPUTNUMBER:
|
|
{
|
|
SIMSG_UI_INPUTNUMBER* pInputNumberMsg = (SIMSG_UI_INPUTNUMBER*)pMsg;
|
|
if(m_bDeleteItemFlag) // 2010.10.13 - servnates
|
|
{
|
|
int tc = GetItemCount(m_strDeleteItem.c_str());
|
|
if(tc - pInputNumberMsg->m_nValue.getAmount() <=0)
|
|
{
|
|
DecreaseItem( m_strDeleteItem.c_str() );
|
|
}
|
|
else
|
|
{
|
|
tc -= pInputNumberMsg->m_nValue.getAmount();
|
|
SetItemCount( m_strDeleteItem.c_str(), tc );
|
|
RefreshAllSlot();
|
|
}
|
|
|
|
m_strDeleteItem = "";
|
|
m_bDeleteItemFlag = false;
|
|
}
|
|
else
|
|
{
|
|
if( pInputNumberMsg->m_nValue > 0 )
|
|
{
|
|
if(m_ReserveDropItemHandle != 0)
|
|
{
|
|
int FromWhere = FROM_INVENTORY; // 2011. 9 .19 - marine AddItem 함수 호출시 창고아이템인지 가방아이템인지 알려줘야 한다.
|
|
SInventorySlot* pSlot = m_InventoryMgr.GetItemInfo( m_ReserveDropItemHandle );
|
|
if( !pSlot )
|
|
{
|
|
pSlot = m_StorageMgr.GetItemInfo(m_ReserveDropItemHandle); // 2011. 9 .19 - marine 인벤토리에서 찾을 수 없다면 창고에서 한번더 찾자..
|
|
FromWhere = FROM_STORAGE;
|
|
}
|
|
|
|
if( !pSlot )
|
|
break;
|
|
count_t nCount(pSlot->GetItemCount()); //servantes 2012.12.20
|
|
if(pInputNumberMsg->m_nValue > pSlot->GetItemCount())
|
|
pInputNumberMsg->m_nValue = nCount;
|
|
AddItem( m_ReserveDropItemHandle, pInputNumberMsg->m_nValue, FromWhere);
|
|
//AddItem( m_ReserveDropItemHandle, pInputNumberMsg->m_nValue );
|
|
m_pGameManager->StartSound( m_pDisplayInfo->GetMaterialSound( GetItemDB().GetMaterial(pSlot->GetItemCode()) ) );
|
|
|
|
m_ReserveDropItemHandle = 0;
|
|
}
|
|
|
|
}
|
|
}
|
|
pMsg->bUse = true;
|
|
}
|
|
break;
|
|
/// 2011.05.16 - prodongi
|
|
case MSG_ITEM_WEAR_INFO:
|
|
case MSG_BELT_SLOT_INFO:
|
|
{
|
|
RefreshAllSlot();
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
|
|
|
|
//
|
|
// OnNotifyUIWindowOpen.
|
|
//
|
|
void SUIDestructionWnd::OnNotifyUIWindowOpen( bool bOpen, bool bLimitWnd )
|
|
{
|
|
// Open.
|
|
if( bOpen )
|
|
{
|
|
RefreshAllSlot();
|
|
m_pManager->SetMouseClickWnd(this); //servantes 2010.12.17
|
|
}
|
|
// Close.
|
|
else
|
|
{
|
|
m_decreaseIndex = -1; // 개수 감소시킬 아이템 인덱스.
|
|
|
|
// 아이템제거.
|
|
ReleaseAllSlot();
|
|
|
|
m_pManager->SetMouseClickWnd(NULL); //servantes 2010.12.17
|
|
}
|
|
}
|
|
|
|
|
|
//// 아이템추가.
|
|
//void SUIDestructionWnd::AddItem( SGameMessage * pMsg )
|
|
//{
|
|
// // 아이템이 꽉찼음.
|
|
// if( m_arrItems.size() >= DESTRUCTION_TOTAL )
|
|
// return;
|
|
//
|
|
// SIMSG_UI_DESTROY_ITEM * pItemData = static_cast< SIMSG_UI_DESTROY_ITEM * >( pMsg );
|
|
// SInventorySlot * pSlot = m_InventoryMgr.GetItemInfo( pItemData->handle );
|
|
// if( pSlot )
|
|
// {
|
|
// // 추가되어있는 아이템이면 중첩여부에 따라 처리.
|
|
// int index = 0;
|
|
// for( std::vector< SItemSet >::iterator it=m_arrItems.begin(); it!=m_arrItems.end(); ++it, ++index )
|
|
// {
|
|
// if( (*it).handle == pItemData->handle ) // 존재.
|
|
// {
|
|
// // 중첩가능한 아이템.
|
|
// if( GetItemDB().IsJoin( pSlot->GetItemCode() ) )
|
|
// {
|
|
// count_t count = (*it).count + pItemData->count;
|
|
// count = count > pSlot->GetItemCount() ? pSlot->GetItemCount() : count;
|
|
//
|
|
// if( (*it).count != count )
|
|
// {
|
|
// (*it).count = count;
|
|
// RefreshSlot( index, pSlot );
|
|
// }
|
|
//
|
|
// // 추가처리됐으므로 함수종료.
|
|
// return;
|
|
// }
|
|
// // 중첩불가 아이템.
|
|
// else
|
|
// {
|
|
// return;
|
|
// }
|
|
// }
|
|
// }
|
|
//
|
|
// // 아이템 추가.
|
|
// SItemSet itemSet( pItemData->handle, pItemData->count );
|
|
// m_arrItems.push_back( itemSet );
|
|
// RefreshSlot( m_arrItems.size() - 1, pSlot );
|
|
//
|
|
// }
|
|
//
|
|
//}
|
|
|
|
// 아이템추가.
|
|
void SUIDestructionWnd::AddItem(AR_HANDLE handle, count_t _count , int FromWhere /* = 0 */)
|
|
{
|
|
// 아이템이 꽉찼음.
|
|
if( m_arrItems.size() >= DESTRUCTION_TOTAL )
|
|
return;
|
|
|
|
// 2011. 9. 19 - marine
|
|
//SInventorySlot *pSlot = m_InventoryMgr.GetItemInfo( handle );
|
|
|
|
SInventorySlot * pSlot = NULL;
|
|
|
|
if(FromWhere == FROM_INVENTORY)
|
|
pSlot = m_InventoryMgr.GetItemInfo( handle );
|
|
else
|
|
pSlot = m_StorageMgr.GetItemInfo( handle );
|
|
|
|
if( pSlot )
|
|
{
|
|
// 추가되어있는 아이템이면 중첩여부에 따라 처리.
|
|
int index = 0;
|
|
for( std::vector< SItemSet >::iterator it=m_arrItems.begin(); it!=m_arrItems.end(); ++it, ++index )
|
|
{
|
|
if( (*it).handle == handle ) // 존재.
|
|
{
|
|
if(it->FromWhere == FromWhere) // 2011. 9. 19 - marine 같은데서 온 아이템이어야 함..
|
|
{ // 같은 아이템인데 하나는 인벤토리 하나는 창고일 경우 카운트만 증가하면 안됨.
|
|
// 중첩가능한 아이템.
|
|
if( GetItemDB().IsJoin( pSlot->GetItemCode(), IsInstanceUnstackable(pSlot) ) )
|
|
{
|
|
count_t count = (*it).count + _count;
|
|
count = count > pSlot->GetItemCount() ? pSlot->GetItemCount() : count;
|
|
|
|
if( (*it).count != count )
|
|
{
|
|
(*it).count = count;
|
|
RefreshSlot( index, pSlot );
|
|
}
|
|
|
|
// 추가처리됐으므로 함수종료.
|
|
return;
|
|
}
|
|
// 중첩불가 아이템.
|
|
else
|
|
{
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// 아이템 추가.
|
|
SItemSet itemSet( handle, _count, FromWhere ); // 2011. 9. 19 - marine
|
|
//SItemSet itemSet( handle, _count );
|
|
|
|
m_arrItems.push_back( itemSet );
|
|
RefreshSlot( m_arrItems.size() - 1, pSlot );
|
|
|
|
}
|
|
}
|
|
|
|
// 아이템 감소.
|
|
void SUIDestructionWnd::DecreaseItem( std::string strID )
|
|
{
|
|
int index = -1;
|
|
std::string::size_type fPos = strID.find( "icon_item" );
|
|
if( fPos != std::string::npos )
|
|
{
|
|
// 2012. 2. 13 - marine substr 함수의 인자가 잘못쓰여서 두자리수 이상의 숫자가 제대로 읽히지 않음
|
|
index = ::atoi( strID.substr( strlen( "icon_item" ) ).c_str() );
|
|
//index = ::atoi( strID.substr( strlen( "icon_item" ) + 1, strID.size() ).c_str() );
|
|
}
|
|
else
|
|
return;
|
|
|
|
if( index != -1 && index < m_arrItems.size() )
|
|
{
|
|
//// 계산기를 열자.
|
|
//if( m_arrItems[ index ].count.getAmount() > 1 )
|
|
//{
|
|
// m_decreaseIndex = index; // 개수 감소시킬 아이템 인덱스.
|
|
// m_pGameManager->PostMsgAtDynamic( new SIMSG_UI_REQ_INPUTNUMBER( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_DESTRUCTION,
|
|
// m_arrItems[ index ].count ) );
|
|
//}
|
|
// 한개뿐이므로 제거.
|
|
//else
|
|
//{
|
|
EraseItem( index );
|
|
//}
|
|
}
|
|
}
|
|
|
|
|
|
// 아이템묶음 배열의 해당인덱스의 요소 제거.
|
|
void SUIDestructionWnd::EraseItem( int index, count_t count )
|
|
{
|
|
if( index < m_arrItems.size() )
|
|
{
|
|
//m_arrItems[ index ].count = m_arrItems[ index ].count - count; // 감소.
|
|
|
|
// 개수가 1개 이하면 제거.
|
|
//if( m_arrItems[ index ].count.getAmount() < 1 )
|
|
//{
|
|
std::vector< SItemSet >::iterator it=m_arrItems.begin();
|
|
while( index )
|
|
{
|
|
++it;
|
|
--index;
|
|
}
|
|
|
|
if( it != m_arrItems.end() )
|
|
m_arrItems.erase( it );
|
|
//}
|
|
|
|
//m_decreaseIndex = -1;
|
|
|
|
// Refresh.
|
|
RefreshAllSlot();
|
|
}
|
|
}
|
|
|
|
//
|
|
// RefreshSlot.
|
|
//
|
|
void SUIDestructionWnd::RefreshSlot( int index, SInventorySlot * pSlot )
|
|
{
|
|
KUIControlMultiIcon * pMultiIcon = m_arrSlotControl[ index ];
|
|
|
|
if( pMultiIcon )
|
|
{
|
|
ResetMultiIcon( pMultiIcon, 0, 8 );
|
|
if( pSlot )
|
|
{
|
|
/// 2011.08.03 - prodongi
|
|
if( !setSkillCardIcon(pMultiIcon, pSlot->GetItemCode()) && !setSummonCardIcon( pMultiIcon, pSlot ) )
|
|
{
|
|
std::string iconName;
|
|
getIconNameAtDurability( pSlot, iconName );
|
|
pMultiIcon->SetIcon( 0, "ui_frame.spr", iconName.c_str() );
|
|
}
|
|
|
|
if( pSlot->GetItemAppearance() )
|
|
pMultiIcon->SetIcon( 4, c_szDEF_SPR_NAME, g_strLookChangeIcon );
|
|
|
|
pMultiIcon->SetIcon( 1, "ui_frame.spr", pSlot->GetXFlag().IsOn( ItemInstance::ITEM_FLAG_CARD ) ? "static_common_useunitcardicon" : NULL );
|
|
|
|
EquipItemAddtionalIconSetter icon_setter( pMultiIcon, pSlot );
|
|
|
|
pMultiIcon->SetLazyTooltip( new rp::KLazyItemTooltip( *m_pDisplayInfo, pSlot, true ) );
|
|
|
|
if( m_bAltKey )
|
|
{
|
|
m_pDisplayInfo->SetComparableEquipItemSubTooltip( pMultiIcon, pSlot );
|
|
}
|
|
|
|
if( m_arrItems[ index ].count >= 1 ) // 2010.10.25
|
|
{
|
|
m_arrCountControl[ index ]->SetShow( true );
|
|
/// 2011.01.20 - prodongi
|
|
//m_arrCountControl[ index ]->SetCaption( CStringUtil::StringFormat( "%d", m_arrItems[ index ].count ).c_str() );
|
|
m_arrCountControl[ index ]->SetCaption( CStringUtil::StringFormat( "<font:font_01><right><vcenter><size:8><shadow>%d", m_arrItems[ index ].count ).c_str() );
|
|
}
|
|
else
|
|
{
|
|
m_arrCountControl[ index ]->SetShow( false );
|
|
}
|
|
}
|
|
|
|
else
|
|
{
|
|
pMultiIcon->SetIcon( 0, c_szDEF_SPR_NAME, "static_common_itemslot" );
|
|
pMultiIcon->SetTooltip();
|
|
m_arrCountControl[ index ]->SetShow( false );
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
|
|
//
|
|
// RefreshAllSlot.
|
|
//
|
|
void SUIDestructionWnd::RefreshAllSlot()
|
|
{
|
|
/*int index = 0;
|
|
for( std::vector< SItemSet >::iterator it=m_arrItems.begin(); it!=m_arrItems.end(); ++it, ++index )
|
|
RefreshSlot( index, m_InventoryMgr.GetItemInfo( (*it).handle ) );*/
|
|
|
|
/// 2011.05.16 아이템의 유효 검사 추가 - prodongi
|
|
/*
|
|
SInventorySlot * pSlot = NULL;
|
|
int size = m_arrItems.size();
|
|
for( int i=0; i<DESTRUCTION_TOTAL; ++i )
|
|
{
|
|
if( i < size )
|
|
pSlot = m_InventoryMgr.GetItemInfo( m_arrItems[ i ].handle );
|
|
else
|
|
pSlot = NULL;
|
|
|
|
RefreshSlot( i, pSlot );
|
|
}
|
|
*/
|
|
SInventorySlot * pSlot = NULL;
|
|
int index = 0;
|
|
std::vector<SItemSet>::iterator it = m_arrItems.begin();
|
|
for (; it != m_arrItems.end();)
|
|
{
|
|
if (ValidateDestructionItem(it->handle))
|
|
{
|
|
// 2011. 9 . 19 - marine
|
|
//pSlot = m_InventoryMgr.GetItemInfo(it->handle);
|
|
if(it->FromWhere == FROM_INVENTORY)
|
|
pSlot = m_InventoryMgr.GetItemInfo(it->handle);
|
|
else
|
|
pSlot = m_StorageMgr.GetItemInfo(it->handle);
|
|
|
|
RefreshSlot( index++, pSlot );
|
|
++it;
|
|
}
|
|
else
|
|
{
|
|
it = m_arrItems.erase(it);
|
|
}
|
|
}
|
|
for( int i=index; i<DESTRUCTION_TOTAL; ++i )
|
|
{
|
|
RefreshSlot( i, NULL );
|
|
}
|
|
}
|
|
|
|
|
|
// 아이템 파괴 패킷 전송.
|
|
void SUIDestructionWnd::ItemDestroy()
|
|
{
|
|
// 패킷전송.
|
|
int size = m_arrItems.size();
|
|
|
|
if( size > 0 )
|
|
{
|
|
// Item 의 요청상태.
|
|
this->m_InventoryMgr.SetItemRqState( RQ_ITEM_STATE::RQ_ITEM_STATE_ERASE );
|
|
|
|
TS_CS_ERASE_ITEM::EraseItemInfo * arrItems = new TS_CS_ERASE_ITEM::EraseItemInfo[ size ];
|
|
|
|
for( int i=0; i<size; ++i )
|
|
{
|
|
arrItems[ i ].item_handle = m_arrItems[ i ].handle;
|
|
arrItems[ i ].count = (__int64)m_arrItems[ i ].count.getAmount();
|
|
arrItems[ i ].is_in_storage = (char)m_arrItems[ i ].FromWhere; // 2011. 9 .20 - marine >> 0 일경우 인벤토리에 있는 아이템 1 일경우 창고 아이템
|
|
}
|
|
g_pCurrentGameSystem->Rq_DestroyItem( arrItems, size );
|
|
|
|
// 아이템제거.
|
|
ReleaseAllSlot();
|
|
}
|
|
}
|
|
|
|
// 아이템제거.
|
|
void SUIDestructionWnd::ReleaseAllSlot()
|
|
{
|
|
m_arrItems.clear();
|
|
|
|
KUIWnd * pCountControl;
|
|
KUIControlMultiIcon * pMultiIcon;
|
|
|
|
for( int i=0; i<DESTRUCTION_TOTAL; ++i )
|
|
{
|
|
// ICON.
|
|
pMultiIcon = m_arrSlotControl[ i ];
|
|
if( pMultiIcon )
|
|
{
|
|
ResetMultiIcon( pMultiIcon, 0, 8 );
|
|
pMultiIcon->SetIcon( 0, c_szDEF_SPR_NAME, "static_common_itemslot" );
|
|
pMultiIcon->SetTooltip();
|
|
}
|
|
|
|
// Count Control.
|
|
pCountControl = m_arrCountControl[ i ];
|
|
if( pCountControl )
|
|
pCountControl->SetShow( false );
|
|
}
|
|
}
|
|
|
|
//servantes 2010.10.25
|
|
SInventorySlot* SUIDestructionWnd::GetItemSlot(LPCSTR lpszControlID)
|
|
{
|
|
int index = -1;
|
|
std::string strID = lpszControlID;
|
|
std::string::size_type fPos = strID.find( "icon_item" );
|
|
if( fPos != std::string::npos )
|
|
{
|
|
index = ::atoi( strID.substr( strlen( "icon_item" ) + 1, strID.size() ).c_str() );
|
|
}
|
|
else
|
|
return NULL;
|
|
|
|
if( index != -1 && index < m_arrItems.size() )
|
|
{
|
|
if( index < m_arrItems.size() )
|
|
{
|
|
std::vector< SItemSet >::iterator it=m_arrItems.begin();
|
|
while( index )
|
|
{
|
|
++it;
|
|
--index;
|
|
}
|
|
|
|
if( it != m_arrItems.end() )
|
|
{
|
|
SItemSet itSet = *it;
|
|
// 2011. 9. 19 - marine
|
|
//return m_InventoryMgr.GetItemInfo( itSet.handle );
|
|
if(itSet.FromWhere == FROM_INVENTORY)
|
|
return m_InventoryMgr.GetItemInfo( itSet.handle );
|
|
else
|
|
return m_StorageMgr.GetItemInfo( itSet.handle );
|
|
}
|
|
}
|
|
}
|
|
return NULL;
|
|
}
|
|
|
|
int SUIDestructionWnd::GetItemCount(LPCSTR lpszControlID)
|
|
{
|
|
int index = -1;
|
|
std::string strID = lpszControlID;
|
|
std::string::size_type fPos = strID.find( "icon_item" );
|
|
if( fPos != std::string::npos )
|
|
{
|
|
index = ::atoi( strID.substr( strlen( "icon_item" ) + 1, strID.size() ).c_str() );
|
|
}
|
|
else
|
|
return NULL;
|
|
|
|
if( index != -1 && index < m_arrItems.size() )
|
|
{
|
|
if( index < m_arrItems.size() )
|
|
{
|
|
std::vector< SItemSet >::iterator it=m_arrItems.begin();
|
|
while( index )
|
|
{
|
|
++it;
|
|
--index;
|
|
}
|
|
|
|
if( it != m_arrItems.end() )
|
|
{
|
|
SItemSet itSet = *it;
|
|
return itSet.count.getAmount();
|
|
}
|
|
}
|
|
}
|
|
return NULL;
|
|
}
|
|
|
|
int SUIDestructionWnd::SetItemCount(LPCSTR lpszControlID, int nCnt)
|
|
{
|
|
int index = -1;
|
|
std::string strID = lpszControlID;
|
|
std::string::size_type fPos = strID.find( "icon_item" );
|
|
if( fPos != std::string::npos )
|
|
{
|
|
index = ::atoi( strID.substr( strlen( "icon_item" ) + 1, strID.size() ).c_str() );
|
|
}
|
|
else
|
|
return NULL;
|
|
|
|
if( index != -1 && index < m_arrItems.size() )
|
|
{
|
|
if( index < m_arrItems.size() )
|
|
{
|
|
std::vector< SItemSet >::iterator it=m_arrItems.begin();
|
|
while( index )
|
|
{
|
|
++it;
|
|
--index;
|
|
}
|
|
|
|
if( it != m_arrItems.end() )
|
|
{
|
|
(*it).count = count_t(nCnt);
|
|
}
|
|
}
|
|
}
|
|
return NULL;
|
|
} |