Files
Leviathan/Client/Game/game/Interface/SUIStorageWnd.cpp
T
2026-06-01 12:46:52 +02:00

2005 lines
62 KiB
C++

#include "stdafx.h"
#include "KUIDragAndDrop.h"
#include "KUITabControl.h"
#include "KUIControlScroll.h"
#include "KUIControlStatic.h"
#include "KUIControlButton.h"
#include "SUISysMsgDefine.h"
#include "SGameManager.h"
#include "SGameMessage.h"
//#include "SGameMessageUI.h"
#include "SUIStorageWnd.h"
//#include "SUIUtil.h"
#include "ErrorCode/ErrorCode.h"
#include "SItemDB.h"
#include "SStringDB.h"
#include "SPlayerInfoMgr.h"
#include "SStorageMgr.h"
#include "SUIDisplayInfo.h"
#include "GameUrlDefine.h"
#include <toolkit/XStringUtil.h>
#include "SInventoryMgr.h"
#include "SGameInterface.h"
#include "SUILazyTooltip.h"
#include "SGameSystem.h"
extern SGameSystem * g_pCurrentGameSystem;
extern KPoint g_Help_url;
namespace
{
const int c_nMaxX_Count = 9;
const int c_nMaxY_Count = 11;
const int c_nCashMaxX_Count = 5;
const int c_nCashMaxY_Count = 3;
const int c_nCashMax_Count = c_nCashMaxX_Count * c_nCashMaxY_Count;
const int c_nMax_Count = c_nMaxX_Count * c_nMaxY_Count;
const int c_nDelta = 36; // 리사이즈 단위
const int c_nMaxHeight = 502;
// const int c_nMaxSlot = 20;
// const int c_nMinslot = 12;
const int nLayer = 8;
const char* c_szStaticRp = "static_rp";
const char* c_szArrangeButton = "button_arrange"; // sonador 1.9.1 인벤토리 및 창고 정렬 기능 구현
const char* g_strEmptyCardIcon = "common_mark_titanium_empty_card"; /// 2012. 1. 18 빈 카드 표시 - marine
};
extern void MsgSplit( const char* szMsg, std::vector<std::string>& vecText, const wchar_t* lpDelimiter, bool bProcSpecialCharacter=false );
// sonador 1.9.1 인벤토리 및 창고 정렬 기능 구현
SUIStorageWnd::~SUIStorageWnd()
{
SAFE_DELETE( m_pArrangeButtonAction );
}
void SUIStorageWnd::Process( DWORD dwTime )
{
SUIWnd::Process( dwTime );
tick( dwTime );
if(m_bIsSetChildTop)
SetChildTopStorage();
}
// 2011. 9. 9 - marine
void SUIStorageWnd::SetChildTopStorage()
{
SetChildAsTop( "select_list_cyan" );
/*
switch(m_nTabMode)
{
case UI_ITEM_ALL: SetChildAsTop("button_tab_01"); break;
case UI_ITEM_EQUIP: SetChildAsTop("button_tab_02"); break;
case UI_ITEM_USE: SetChildAsTop("button_tab_03"); break;
case UI_ITEM_CARD: SetChildAsTop("button_tab_04"); break;
case UI_ITEM_CREATURE: SetChildAsTop("button_tab_05"); break;
case UI_ITEM_EXPEND: SetChildAsTop("button_tab_06"); break;
case UI_ITEM_ETC: SetChildAsTop("button_tab_07"); break;
case UI_ITEM_QUEST: SetChildAsTop("button_tab_08"); break;
case UI_ITEM_CRU: SetChildAsTop("button_tab_09"); break;
}
*/
RefreshSlots();
m_bIsSetChildTop = false;
/*
SetChildTooltip( "button_tab_01", GetStringDB().GetString(9843) );
SetChildTooltip( "button_tab_02", GetStringDB().GetString(9844) );
SetChildTooltip( "button_tab_03", GetStringDB().GetString(9845) );
SetChildTooltip( "button_tab_04", GetStringDB().GetString(9846) );
SetChildTooltip( "button_tab_05", GetStringDB().GetString(9847) );
SetChildTooltip( "button_tab_06", GetStringDB().GetString(9848) );
SetChildTooltip( "button_tab_07", GetStringDB().GetString(9849) );
SetChildTooltip( "button_tab_08", GetStringDB().GetString(9850) );
SetChildTooltip( "button_tab_09", GetStringDB().GetString(9851) );
*/
}
// 2011. 9 . 14 - marine 슬롯텍스트
void SUIStorageWnd::UpdateSlot()
{
const vec_inventoryslot& vecItemList = m_StorageMgr.GetItemList();
//////////////////////////// 슬롯 텍스트 설정 /////////////////////////////////
int nSlotNum = vecItemList.size();
if(nSlotNum > m_iMaxSlot)
m_pSlotStatic->SetCaption( CStringUtil::StringFormat( "<font:font_02><size:9><right><#d0d0d0>%d <#ffffff>/ %d",nSlotNum, m_iMaxSlot ).c_str() );
else
m_pSlotStatic->SetCaption( CStringUtil::StringFormat( "<font:font_02><size:9><right><#ffffff>%d <#ffffff>/ %d",nSlotNum, m_iMaxSlot ).c_str() );
// 2011. 9 .14 - marine
//////////////////////////// 슬롯 게이지바 설정 //////////////////////////////
/*
float fSloatRatio = (float)nSlotNum/(float)m_iMaxSlot;
if(fSloatRatio > 1.0f) fSloatRatio = 1.0f; // Max 슬롯 보다 높을 수 있는 경우가 있을 수 있음..
if( m_pCtrlSlotGauge )
{
if(fSloatRatio > 0.8f)
m_pCtrlSlotGauge->SetAniName( "common_guage_titanium_line_red" );
else if(fSloatRatio > 0.6f)
m_pCtrlSlotGauge->SetAniName( "common_guage_titanium_line_orange" );
else
m_pCtrlSlotGauge->SetAniName( "common_guage_titanium_line_yellowgreen" );
KRect rt = m_pCtrlSlotGauge->GetRect();
rt.right = rt.left + m_fSlotGaugeWidth * fSloatRatio;
m_pCtrlSlotGauge->ClipRect( rt );
m_pCtrlSlotGauge->Resize( rt );
}
*/
}
bool SUIStorageWnd::InitControls( KPoint kPos )
{
SetCustomMovingRect( KRect( 0, 0, 310, 20 ) ); // 타이틀 바 선택 영역, 이동위해 클릭 Area
// 리사이즈 할때 단위 설정, ( 세로, 가로, 위드, 헤잇 )
SetResizeUnit( 0, c_nDelta, KSize((GetRect().right-GetRect().left), (GetRect().bottom-GetRect().top)), KSize((GetRect().right-GetRect().left), c_nMaxHeight) );
// 2011. 9. 14 - marine 잔여슬롯 표시
m_pSlotStatic = dynamicCast< KUIControlStatic* >( GetChild( "static_rp_rest" ) );
/*
m_pCtrlSlotGauge = GetChild( "gauge_bag_line_yellowgreen" );
m_fSlotGaugeWidth = (float)m_pCtrlSlotGauge->GetRect().GetWidth();
m_pCtrlSlotGauge->SetShow(false); // 안쓰임
*/
// 2011. 9. 21 - marie
KUIControlSimpleButton *pDestroy = dynamicCast< KUIControlSimpleButton* >( GetChild("button_arrange") );
if(pDestroy)
{
pDestroy->SetEnableColor( "<#ffffff>" );
pDestroy->SetDisableColor( "<#a0a0a0>" );
}
CreateControls();
SetChildAsTop( "storage_selectslot01" );
SetChildShow( "storage_selectslot01", false );
m_nTabMode = UI_ITEM_ALL;
m_bIsSetChildTop = true;
// SetChildCaption( c_szStaticRp, GetStringDB().GetString( STRING_R ) ); // #2.1.11
// 버튼 클릭 영역
// SetValidRect( "storage_button_receipts", KRect(0, 0, -11, 0) );
// SetValidRect( "storage_button_payingout", KRect(8, 0, -10, 0) );
// sonador 1.9.1 인벤토리 및 창고 정렬 기능 구현
m_pArrangeButton = dynamicCast<KUIControlSimpleButton*>(GetChild( c_szArrangeButton ));
m_pArrangeButtonAction = new sui::ActionBinder( new sui::ActionDisableControl( m_pArrangeButton ), new sui::ActionEnableControl( m_pArrangeButton ), 0 );
m_ActionTicker.append_tickable( m_pArrangeButtonAction );
/*
SetChildTooltip( "button_tab_01", GetStringDB().GetString(9843) );
SetChildTooltip( "button_tab_02", GetStringDB().GetString(9844) );
SetChildTooltip( "button_tab_03", GetStringDB().GetString(9845) );
SetChildTooltip( "button_tab_04", GetStringDB().GetString(9846) );
SetChildTooltip( "button_tab_05", GetStringDB().GetString(9847) );
SetChildTooltip( "button_tab_06", GetStringDB().GetString(9848) );
SetChildTooltip( "button_tab_07", GetStringDB().GetString(9849) );
SetChildTooltip( "button_tab_08", GetStringDB().GetString(9850) );
SetChildTooltip( "button_tab_09", GetStringDB().GetString(9851) );
*/
return SUIWnd::InitControls( kPos );
}
bool SUIStorageWnd::InitData( bool bReload )
{
m_n64Gold = money_t( 0 ); // { [sonador][3.4.1]소지금 한도 증가 관련 서버 메시지 변경
m_nTabMode = 0;
m_hSelItem = NULL;
m_nInvenSlotStartIndex = 0;
InitStaticText();
m_nScrollPos = 0;
m_nSelectSlot = -1;
m_nViewSlot = c_nMaxX_Count * c_nMaxY_Count;
m_rtOldRect = GetRect();
m_lastItemCountAtRefreshScroll = -1;
return SUIWnd::InitData(bReload);
}
void* SUIStorageWnd::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();
KUIControlMultiIcon* pIcon = dynamicCast<KUIControlMultiIcon*>(GetChild( szControlID ));
if( pIcon == NULL ) return NULL;
AR_HANDLE hItem = GetItemHandle( szControlID );
SInventorySlot* pSlot = GetItemInfo( hItem );
if( pSlot )
{
m_StorageMgr.SetMode(TS_CS_STORAGE::STORAGE_TO_INVENTORY);
m_StorageMgr.SetDragItem(m_hSelItem);
m_pDisplayInfo->SetUIDragInfo( new SUIStorageDragInfo( hItem ) );
const KUIControlMultiIcon::ICON_INFO & icon_info = pIcon->GetIconInfoByLayer(0);
m_pDragAndDropIcon->SetStateIcon( icon_info.sSprName.c_str(), icon_info.sAniName.c_str(), pIcon->GetFrameIndex(), 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( pUIDragInfo && SUIDragInfo::DRAGTYPE_STORAGE == pUIDragInfo->m_type )
{
SUIStorageDragInfo* pStorageDragInfo = (SUIStorageDragInfo*)pUIDragInfo;
// 동일한 창
if( pSendMsg->sRecvDropParentID == std::string(GetID()) ) return NULL;
// Drag & Drop 정보 제거
m_pDisplayInfo->SetUIDragInfo();
}
return NULL;
}
else if ( id == id_UI_RECV_DROP )
{
KUISendRecvDropMessage* pSendMsg = static_cast<KUISendRecvDropMessage*>( &msg );
SUIDragInfo* pUIDragInfo = m_pDisplayInfo->GetUIDragInfo();
if( NULL == pUIDragInfo ) return NULL;
SUIInvenItemDragInfo* pItemDragInfo = (SUIInvenItemDragInfo*)pUIDragInfo;
if( pItemDragInfo == NULL ) return NULL;
if( SUIDragInfo::DRAGTYPE_INVENITEM == pUIDragInfo->m_type )
{
// 2011. 9. 20 - marine 파괴창이 열려있을때는 받지 않는다.
if(m_pGameManager->GetSUI(SIMSG_TOGGLE_UIWINDOW::UIWINDOW_DESTRUCTION)->IsShow() == false)
{
//2011. 9. 6 - marine 창고 nui 아이디 변경
if( ::_stricmp( pSendMsg->sSendDropParentID.c_str(), "window_main_inventory_bag" ) == 0 && ::_stricmp( pSendMsg->sRecvDropParentID.c_str(), "window_business_warehouse" ) == 0)
{
if( pItemDragInfo && pItemDragInfo->m_hItem == -1 ) return NULL;
m_pDisplayInfo->ChangeStorageItem( pItemDragInfo->m_hItem, true ); //인벤에서 -> 창고로
//Sound
SInventorySlot* pItem = GetItemInfo( pItemDragInfo->m_hItem );
if( pItem )
{
m_pGameManager->StartSound( m_pDisplayInfo->GetMaterialSound( GetItemDB().GetMaterial(pItem->GetItemCode()) ) );
}
}
}
}
else if( SUIDragInfo::DRAGTYPE_STORAGE == pUIDragInfo->m_type )
{
AR_HANDLE hItem = GetItemHandle( pSendMsg->sRecvDropControlID.c_str() );
if( pItemDragInfo )
ReqSwapItem( pItemDragInfo->m_hItem, hItem );
}
return NULL;
}
return SUIWnd::Perform( id, msg );
}
void SUIStorageWnd::OnNotifyUIWindowOpen( bool bOpen, bool bLimitWnd )
{
SUIWnd::OnNotifyUIWindowOpen(bOpen);
if( !bOpen )
{
m_pDisplayInfo->RequestStorageItem( NULL, count_t( 0 ), TS_CS_STORAGE::CLOSE_STORAGE );
m_pGameManager->PostMsgAtDynamic( new SIMSG_SHOW_UIWINDOW( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_INPUTNUMBER, false ) ); // servantes 2011.01.03
}
else
{
m_pGameManager->StartSound( "ui_popup_window01.wav" );
RefreshScrollBar();
RefreshSlots(m_nScrollPos);
m_pGameManager->PostMsgAtDynamic( new SIMSG_SHOW_UIWINDOW( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_EQUIPMENT, false ) ); // servantes 2010.11.19 // 장비창.
}
}
void SUIStorageWnd::PumpUpMessage( LPCSTR lpszControlID, DWORD nMessage, DWORD lparam, DWORD wparam )
{
switch( nMessage )
{
case KUI_MESSAGE::KBUTTON_CLICK:
{
if( ::_stricmp( lpszControlID, "button_close" ) == 0 )
{
m_pGameManager->PostMsgAtDynamic( new SIMSG_SHOW_UIWINDOW( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_STORAGE, false) );
}
// 입출금
else if( ::_stricmp( lpszControlID, "storage_button_receipts" ) == 0 || ::_stricmp( lpszControlID, "storage_button_payingout" ) == 0 )
{
m_StorageMgr.SetMode(TS_CS_STORAGE::GOLD_STORAGE_TO_INVENTORY);
money_t nGold = m_n64Gold; // { [sonador][3.4.1]소지금 한도 증가 관련 서버 메시지 변경
if( ::_stricmp( lpszControlID, "storage_button_receipts" ) == 0 )
{
m_StorageMgr.SetMode(TS_CS_STORAGE::GOLD_INVENTORY_TO_STORAGE);
nGold = m_PlayerInfoMgr.GetPlayerInfo().GetGold();
}
m_pGameManager->PostMsgAtDynamic( new SIMSG_UI_REQ_INPUTNUMBER( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_STORAGE, nGold, SIMSG_UI_REQ_INPUTNUMBER::TYPE_GOLD ) );
}
else if( !::_stricmp( lpszControlID, "button_warning" ) )
m_pGameManager->PostMsgAtDynamic( new SIMSG_TOGGLE_UIWINDOW( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_DESTRUCTION ) );
// sonador 1.9.1 인벤토리 및 창고 정렬 기능 구현
else if( ::_stricmp( lpszControlID, c_szArrangeButton ) == 0 )
{
_ReqArrange();
}
}
break;
case KUI_MESSAGE::KICON_DBLCLK:
case KUI_MESSAGE::KICON_PRESSING:
{
if(m_pGameManager->IsShow(SIMSG_TOGGLE_UIWINDOW::UIWINDOW_DESTRUCTION))
break;
m_hSelItem = NULL;
for( int i = 0; i < m_nViewSlot; i++ )
{
if( ::_stricmp( lpszControlID, CStringUtil::StringFormat("storage_slot%02d", i).c_str() ) == 0 )
{
m_hSelItem = GetSelectHandle(m_nInvenSlotStartIndex + i);
if( m_hSelItem ) EnableSelectBar();
break;
}
}
if( nMessage == KUI_MESSAGE::KICON_DBLCLK && m_hSelItem )
{
if(m_bControlKey) //servantes 2010.12.02
break ;
m_pDisplayInfo->ChangeStorageItem(m_hSelItem, false);
}
else //servantes 2010.10.15
{
if(m_bShiftKey)
{
SInventorySlot* pSlot = m_StorageMgr.GetItemInfo( m_hSelItem );
if(pSlot == NULL)
break;
count_t nCnt = pSlot->GetItemCount();
if(nCnt > 1) // 여러개가 있을 경우
{
m_StorageMgr.SetDragItem( m_hSelItem );
m_StorageMgr.SetMode(TS_CS_STORAGE::STORAGE_TO_INVENTORY);
m_pGameManager->PostMsgAtDynamic( new SIMSG_UI_REQ_INPUTNUMBER( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_STORAGE, nCnt ) ); //수입력기가 뜬다
m_bOpenNumberInputDlg_moveItemtoInventory = true;
}
else // 한 개일 경우
{
m_pDisplayInfo->ChangeStorageItem( m_hSelItem, false ); // 1개를 옮긴다
}
}
if(m_bControlKey)
{
SInventorySlot* pSlot = m_StorageMgr.GetItemInfo( m_hSelItem );
if(pSlot == NULL)
break;
count_t nCnt = pSlot->GetItemCount();
if(nCnt >= 1 && nCnt < 10) // 1-10 개가 있을 경우
{
m_pDisplayInfo->SetControlPushState(true);
m_pDisplayInfo->ChangeStorageItem( m_hSelItem, false, count_t( 1 ) ); // 1개를 옮긴다
m_pDisplayInfo->SetControlPushState(false);
}
else if(nCnt >= 10) // 10 개 이상 있을 경우
{
m_pDisplayInfo->SetControlPushState(true);
m_pDisplayInfo->ChangeStorageItem( m_hSelItem, false, count_t( 10 ) );
m_pDisplayInfo->SetControlPushState(false);
}
else
{
//assert(0); //error
}
}
// AziaMafia Zentrix Alt
if (m_bAltKey)
{
SInventorySlot* pSlot = m_StorageMgr.GetItemInfo(m_hSelItem);
if (pSlot == NULL)
break;
count_t nCnt = pSlot->GetItemCount();
if (nCnt >= 1 )
{
m_pDisplayInfo->SetAltPushState(true);
m_pDisplayInfo->ChangeStorageItem(m_hSelItem, false, nCnt );
m_pDisplayInfo->SetAltPushState(false);
}
}
}
}
break;
case KUI_MESSAGE::KGENWND_MOVE: // 윈도우 이동
{
LimitMoveWnd();
}
break;
case KUI_MESSAGE::KSCROLL_SELECT: // 스크롤 선택
{
int nPos = int(lparam);
nPos = max( nPos, 0 );
RefreshSlots(nPos);
}
break;
case KUI_MESSAGE::KGENWND_RESIZE: // 윈도우 리사이즈
ResizeScrollBar();
break;
/// 2011.05.13 - prodongi
case KUI_MESSAGE::KICON_RCLICK:
{
AR_HANDLE handle = 0;
for( int i = 0; i < m_nViewSlot; i++ )
{
if( ::_stricmp( lpszControlID, CStringUtil::StringFormat("storage_slot%02d", i).c_str() ) == 0 )
{
handle = GetSelectHandle(m_nInvenSlotStartIndex + i);
break;
}
}
if (handle)
{
SInventorySlot* pSlot = m_StorageMgr.GetItemInfo( handle );
TS_ITEM_INFO* info = pSlot->GetItem();
if(info && GetItemDB().GetGroup(info->Code) == ItemBase::GROUP_SUMMONCARD )
{
SMSG_SUMMON_CARD_ITEM_INFO msg;
msg.level = info->level;
memcpy(&msg.item_info, info, sizeof (msg.item_info));
m_pGameManager->ProcMsgAtStatic(&msg);
}
}
}
break;
}
SUIWnd::PumpUpMessage( lpszControlID, nMessage, lparam, wparam );
}
void SUIStorageWnd::ProcMsgAtStatic( SGameMessage* pMsg )
{
switch( pMsg->nType )
{
case MSG_OPEN_STORAGE:
{
m_pGameManager->PostMsgAtDynamic( new SIMSG_SHOW_UIWINDOW( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_INVENTORY, false) );
m_pGameManager->PostMsgAtDynamic( new SIMSG_SHOW_UIWINDOW( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_STORAGE, false) );
//int x = GetRect().right, y = GetRect().bottom;
int x = GetRect().right, y = GetRect().top; // bintitle. 2010.10.04.
m_pGameManager->ProcMsgAtStatic( &SIMSG_UI_MOVE( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_INVENTORY, x, y ) );
m_pGameManager->PostMsgAtDynamic( new SIMSG_SHOW_UIWINDOW( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_INVENTORY, true) );
m_pGameManager->PostMsgAtDynamic( new SIMSG_SHOW_UIWINDOW( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_STORAGE, true) );
SUIWnd* pWnd = m_pGameManager->GetSUI(SIMSG_TOGGLE_UIWINDOW::UIWINDOW_EQUIPMENT); // servantes 2010.11.17
if(pWnd)
{
if( pWnd->IsShow() )
m_pGameManager->PostMsgAtDynamic( new SIMSG_SHOW_UIWINDOW( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_EQUIPMENT, false ) ); // 장비창.
}
m_lastItemCountAtRefreshScroll = -1;
m_nSelectSlot = -1;
RefreshSlots(m_nScrollPos);
m_iMaxSlot = m_StorageMgr.GetMaxSlotNum(); //2011. 9. 15 - marine
pMsg->bUse = true;
}
break;
case IMSG_HOTKEY_EX: //servantes 2010.10.15
{
SIMSG_HOTKEY_EX* pHotKey = dynamicCast<SIMSG_HOTKEY_EX*>(pMsg);
if( pHotKey->wParam == VK_SHIFT )
m_bShiftKey = (pHotKey->bUp == 0);
if( pHotKey->wParam == VK_CONTROL )
m_bControlKey = (pHotKey->bUp == 0);
if( pHotKey->wParam == VK_MENU )
{
bool bPreState = m_bAltKey;
m_bAltKey = (pHotKey->bUp == 0);
if( bPreState != m_bAltKey && IsShow() )
{
RefreshSlots(m_nScrollPos); // TODO 최적화
}
}
break;
}
case IMSG_UI_INPUTNUMBER:
{
SIMSG_UI_INPUTNUMBER* pInputNumberMsg = (SIMSG_UI_INPUTNUMBER*)pMsg;
if(m_bOpenNumberInputDlg_moveItemtoInventory) //servantes 2010.10.27
{
SInventorySlot* pSlot = m_StorageMgr.GetItemInfo( m_StorageMgr.GetDragItem() );
if( pSlot == NULL )
break;
if(pSlot->GetItemCount() < pInputNumberMsg->m_nValue)
pInputNumberMsg->m_nValue = pSlot->GetItemCount();
m_pDisplayInfo->RequestStorageItem( m_StorageMgr.GetDragItem(), pInputNumberMsg->m_nValue, m_StorageMgr.GetMode() );
m_bOpenNumberInputDlg_moveItemtoInventory = false;
}
else
{
if( pInputNumberMsg->m_nValue > 0 )
{
count_t nValue = pInputNumberMsg->m_nValue;
switch(m_StorageMgr.GetMode())
{
case TS_CS_STORAGE::GOLD_INVENTORY_TO_STORAGE:
{
if( nValue > m_PlayerInfoMgr.GetPlayerInfo().GetGold() )
nValue = m_PlayerInfoMgr.GetPlayerInfo().GetGold();
}
break;
case TS_CS_STORAGE::GOLD_STORAGE_TO_INVENTORY:
{
if( nValue > m_n64Gold )
nValue = m_n64Gold; // { [sonador][3.4.1]소지금 한도 증가 관련 서버 메시지 변경
}
break;
case TS_CS_STORAGE::INVENTORY_TO_STORAGE:
{
SInventorySlot* pSlot = m_InventoryMgr.GetItemInfo( m_StorageMgr.GetDragItem() );
if( pSlot == NULL ) break;
if( nValue > pSlot->GetItemCount() )
nValue = pSlot->GetItemCount();
}
break;
case TS_CS_STORAGE::STORAGE_TO_INVENTORY:
{
SInventorySlot* pSlot = m_StorageMgr.GetItemInfo( m_StorageMgr.GetDragItem() );
if( pSlot == NULL ) break;
if( nValue > pSlot->GetItemCount() )
nValue = pSlot->GetItemCount();
}
break;
}
m_pDisplayInfo->RequestStorageItem( m_StorageMgr.GetDragItem(), nValue, m_StorageMgr.GetMode() );
}
}
}
break;
case IMSG_UI_STATE_UPDATE:
{
//Lending Item ToolTip 갱신
RefreshLendingItemTooltip();
}
break;
case MSG_UPDATE_ITEM_COUNT:
case MSG_ITEM_DESTROY:
case MSG_ITEM_INVEN:
{
if( IsShow() )
{
m_nSelectSlot = -1;
RefreshSlots(m_nScrollPos);
}
}
break;
case MSG_PROPERTY:
{
SMSG_PROPERTY* pPropertyMsg = (SMSG_PROPERTY*)pMsg;
if( pPropertyMsg->nPropertyType == SMSG_PROPERTY::PROPERTY_STORAGE_GOLD )
{
m_n64Gold = count_t( ::_atoi64( pPropertyMsg->strValue.c_str() ) ); // { [sonador][3.4.1]소지금 한도 증가 관련 서버 메시지 변경
RefreshGold();
}
}
break;
case MSG_RESULT: // sonador 1.9.1 인벤토리 및 창고 정렬 기능 구현
{
SMSG_RESULT* pMsgResult = dynamicCast<SMSG_RESULT*>(pMsg);
switch( pMsgResult->request_msg_id )
{
case TM_CS_ARRANGE_ITEM:
{
switch( pMsgResult->result )
{
case RESULT_SUCCESS:
case RESULT_NOT_ACTABLE:
case RESULT_COOL_TIME:
m_ActionTicker.satisfy();
break;
}
}
break;
}
pMsg->bUse = true;
}
break;
case IMSG_UI_TAB_UPDATE:
{
SMSG_RESULT* pMsgResult = dynamicCast<SMSG_RESULT*>( pMsg );
m_nTabMode = pMsgResult->value;
m_bIsSetChildTop = true;
ResetScrollBar();
}
break;
}
}
// create
void SUIStorageWnd::CreateControls()
{
// // 아이템 category 탭 설정
// KUISimpleTabControl* pTabItemCategory = dynamicCast<KUISimpleTabControl*>(GetChild( "storage_itemcategory00" ));
// if( NULL != pTabItemCategory )
// {
//// pTabItemCategory->SetTabProperty( -37 );
// pTabItemCategory->SetTabProperty( 0, false, 5 );
// pTabItemCategory->AddTabItem( S(6242)/*"<size:10>전체"*/, "" );
// pTabItemCategory->AddTabItem( S(6241)/*"<size:10>장비"*/, "" );
// pTabItemCategory->AddTabItem( S(6247)/*"<size:10>카드"*/, "" );
// pTabItemCategory->AddTabItem( S(6227)/*"<size:10>소비"*/, "" );
// pTabItemCategory->AddTabItem( S(6216)/*"<size:10>기타"*/, "" );
//// pTabItemCategory->SetCorrectionRect( KRect( 19, 0, -19, 0 ) );
// pTabItemCategory->SetSelectedItem( 0 );
// }
RECT rc; rc.left = c_nDelta-1; rc.top = 0; rc.right = c_nDelta-1; rc.bottom = 0;
std::string strName, strNewName;
//첫줄 가로로 복사
for( int i = 0; i < c_nMaxX_Count-1; i++ )
{
// 아이콘
CopyControl( CStringUtil::StringFormat( "storage_slot%02d", i ).c_str() , CStringUtil::StringFormat( "storage_slot%02d", i+1 ).c_str() , rc );
// 카운트
CopyControl( CStringUtil::StringFormat( "storage_itemcount%02d", i ).c_str(), CStringUtil::StringFormat( "storage_itemcount%02d", i+1 ).c_str(), rc );
}
//세로로 복사
rc.left = 0; rc.top = c_nDelta; rc.right = 0; rc.bottom = c_nDelta;
for( int n = 1; n < c_nMaxY_Count; n++ )
{
for( int i = 0; i < c_nMaxX_Count; i++ )
{
int nIndex = i+(n*c_nMaxX_Count);
int nPrevIndex = nIndex-c_nMaxX_Count;
// _oprint( "Storage - prev : %d, index : %d\n", nPrevIndex, nIndex );
// 아이콘
CopyControl( CStringUtil::StringFormat( "storage_slot%02d", nPrevIndex ).c_str() , CStringUtil::StringFormat( "storage_slot%02d", nIndex ).c_str() , rc );
// 카운트
CopyControl( CStringUtil::StringFormat( "storage_itemcount%02d", nPrevIndex ).c_str(), CStringUtil::StringFormat( "storage_itemcount%02d", nIndex ).c_str(), rc );
}
}
for( int n = 0; n < c_nMax_Count; n++ )
{
KUIControlMultiIcon* pItemIconControl = dynamicCast<KUIControlMultiIcon*>(GetChild( CStringUtil::StringFormat("storage_slot%02d", n).c_str() ));
if( NULL != pItemIconControl )
{
pItemIconControl->SetIconLayer( nLayer );
}
}
this->MovePos( 300, 200 ); // servantes 2010.11.23
}
// init
void SUIStorageWnd::InitStaticText()
{
int nMaxCount = c_nMaxX_Count * c_nMaxY_Count;
for( int i = 0; i < nMaxCount; i++ )
{
SetChildShow( CStringUtil::StringFormat( "storage_itemcount%02d", i ).c_str(), false );
}
SetChildCaption( "static_rp_value", CStringUtil::StringFormat( "%s<font:font_02><size:9><#d0d0d0><right>%d", S(6425),0 ).c_str() );
}
// selectbar
void SUIStorageWnd::EnableSelectBar()
{
int nSlot = (m_nSelectSlot-m_nInvenSlotStartIndex);
if( nSlot > -1 && nSlot < c_nMax_Count )
{
KUIWnd* pWnd = GetChild( CStringUtil::StringFormat( "storage_slot%02d", nSlot ).c_str() );
if( pWnd ) SetMovePos( "storage_selectslot01", pWnd->GetRect().left, pWnd->GetRect().top );
SetChildShow( "storage_selectslot01", true );
}
else
SetChildShow( "storage_selectslot01", false );
}
AR_HANDLE SUIStorageWnd::GetSelectHandle( int nIndex )
{
m_nSelectSlot = -1;
m_hSelItem = NULL;
int size = static_cast<int>(m_vecItemList.size());
if( nIndex < size )
{
m_hSelItem = m_vecItemList[nIndex]->GetHandle();
m_nSelectSlot = nIndex;
}
return m_hSelItem;
}
// resize
void SUIStorageWnd::ResizeScrollBar()
{
KUIControlVScroll* pScrollBar = dynamicCast<KUIControlVScroll*>(GetChild( "storage_scroll" ));
if( NULL != pScrollBar )
{
KRect kt = pScrollBar->GetRect();
int nBottom = kt.bottom;
KUIWnd* pWnd;
pWnd = GetChild( "storage_itemcategory01" );
if( pWnd != NULL )
kt.top = pWnd->GetRect().bottom;
//kt.top = pWnd->GetRect().bottom - 7; //sfreer 2009.07.13 스크롤바
pWnd = GetChild( "storage_rpinput_bg" ); if( pWnd != NULL ) kt.bottom = pWnd->GetRect().top;
int nDelta = GetRect().GetHeight() - m_rtOldRect.GetHeight();
if( nDelta > 0 ) m_nViewSlot += ( nDelta/c_nDelta )*2;
else if( nDelta < 0 ) m_nViewSlot -= ( (nDelta*-1)/c_nDelta )*2;
int nMaxCount = c_nMaxX_Count * c_nMaxY_Count;
int nMinCount = c_nMaxX_Count * c_nMaxY_Count;
m_nViewSlot = max( m_nViewSlot, nMinCount );
m_nViewSlot = min( m_nViewSlot, nMaxCount );
pWnd = GetChild( "storage_inframe01" );
if( pWnd != NULL )
pWnd->Resize( KRect( pWnd->GetRect().left, pWnd->GetRect().top, pWnd->GetRect().right, kt.bottom ) );
kt.top = kt.top + 4;
kt.bottom = kt.bottom - 4;
pScrollBar->Resize( kt );
RefreshSlots(m_nScrollPos); // 슬롯
m_rtOldRect = GetRect();
}
}
void SUIStorageWnd::RefreshLendingItemTooltip()
{
int nSlotStart = m_nScrollPos * c_nMaxX_Count;
int nMaxSlotCount = c_nMaxX_Count * c_nMaxY_Count; //전체 슬롯 갯수
int nMaxCount = ( nMaxSlotCount < static_cast<int>(m_vecItemList.size())) ? nMaxSlotCount : static_cast<int>(m_vecItemList.size());
for( int i = 0; i < nMaxCount; i++ )
{
int nIdx = i+nSlotStart;
if( nIdx >= m_vecItemList.size() )
{
break;
}
SInventorySlot* pSlot = m_vecItemList[nIdx];
if( !pSlot || pSlot->GetItem()->remain_time <= 0 ) continue;
KUIControlMultiIcon* pIcon = dynamicCast<KUIControlMultiIcon*>(GetChild( CStringUtil::StringFormat("storage_slot%02d", i).c_str() ));
if( pIcon == NULL ) continue;
if( pSlot )
{
/// 2011.03.28 - prodongi
pIcon->SetLazyTooltip( new rp::KLazyItemTooltip( *m_pDisplayInfo, pSlot, true, NULL, true ) ); // sonador #2.1.2.4.3 팻 조작 UI 연동
if( m_bAltKey )
{
m_pDisplayInfo->SetComparableEquipItemSubTooltip( pIcon, pSlot );
}
}
}
}
// scrollbar
void SUIStorageWnd::RefreshScrollBar()
{
int nCurCount = static_cast<int>( m_vecItemList.size() );
int nScrollRange = max(nCurCount - m_nViewSlot, 0);
int nScrollPos = 0;
KUIControlVScrollSmallEx* pScrollBar = dynamicCast<KUIControlVScrollSmallEx*>(GetChild( "storage_scroll" ));
if( NULL != pScrollBar )
{
//pScrollBar->SetMaxRange( DWORD(nScrollRange)+1 ); // 2011. 12. 13 - marine 계산이 이상하게 됨...
SetScrollRange(nCurCount); // 위에 주석잡은거 수정한거..
nScrollPos = pScrollBar->GetPosition();
pScrollBar->SetPosition( nScrollPos );
m_nScrollPos = nScrollPos;
m_nInvenSlotStartIndex = m_nScrollPos * c_nMaxX_Count;
}
}
void SUIStorageWnd::SetScrollRange(const int nCurCount)
{
if(m_lastItemCountAtRefreshScroll == nCurCount )
return;
m_lastItemCountAtRefreshScroll = nCurCount;
KUIControlVScrollSmallEx* pScrollBar = dynamicCast<KUIControlVScrollSmallEx*>(GetChild( "storage_scroll" ));
if(pScrollBar)
{
int nSize = nCurCount;
int nLineCount = nSize / c_nMaxX_Count;
if( ( nSize % c_nMaxX_Count ) > 0 )
nLineCount += 1;
if (nLineCount < c_nMaxY_Count)
pScrollBar->SetScrollRange(0, 0);
else
pScrollBar->SetScrollRange( c_nMaxY_Count, nLineCount );
}
}
void SUIStorageWnd::ResetScrollBar()
{
// 스크롤바를 리셋..
KUIControlVScrollSmallEx* pScrollBar = dynamicCast<KUIControlVScrollSmallEx*>(GetChild( "storage_scroll" ));
if( NULL != pScrollBar )
{
pScrollBar->SetPosition( 0 );
m_nScrollPos = 0;
m_nInvenSlotStartIndex = m_nScrollPos * c_nMaxX_Count;
RefreshScrollBar();
RefreshSlots(0);
}
}
void SUIStorageWnd::RefreshGold()
{
// { [sonador][3.4.1]소지금 한도 증가 관련 서버 메시지 변경
__int64 nGold = m_PlayerInfoMgr.GetPlayerInfo().GetGold().getAmount();
std::string strString = "";
if (nGold >= 1000000000000) strString += "<#FF0000>";
else if (nGold >= 100000000000) strString += "<#FF00F3>";
else if (nGold >= 10000000000) strString += "<#FF1493>";
else if (nGold >= 1000000000) strString += "<#00FFFC>";
else if (nGold >= 100000000) strString += "<#FF8C00>";
else if (nGold >= 10000000) strString += "<#FFFF00>";
else if (nGold >= 1000000) strString += "<#4AD55D>";
std::string strGold = "%s<font:font_02><size:9>";
strGold += strString.c_str();
strGold += "<right>%s";
SetChildCaption("static_rp_value", CStringUtil::StringFormat(strGold.c_str(), S(6425), CStringUtil::GetCommaNumberString(m_n64Gold.getAmount()).c_str()).c_str());
}
// slot
//void SUIStorageWnd::RefreshGold()
//{
// // { [sonador][3.4.1]소지금 한도 증가 관련 서버 메시지 변경
// // 2011. 9. 21 - marine
// SetChildCaption( "static_rp_value", CStringUtil::StringFormat( "%s<font:font_02><size:9><#d0d0d0><right>%s", S(6425), CStringUtil::GetCommaNumberString( m_n64Gold.getAmount() ).c_str() ).c_str() );
// //SetChildCaption( "static_rp_value", CStringUtil::StringFormat( "%s<right>%s", S(6425), CStringUtil::GetCommaNumberString( m_n64Gold.getAmount() ).c_str() ).c_str() );
//}
int SUIStorageWnd::GetMode()
{
switch(m_nTabMode)
{
case UI_ITEM_ALL: return (-1);
case UI_ITEM_EQUIP: return UI_ITEM_NEW_1;
case UI_ITEM_USE: return UI_ITEM_NEW_2;
case UI_ITEM_CARD: return UI_ITEM_NEW_3;
case UI_ITEM_CREATURE: return UI_ITEM_NEW_4;
case UI_ITEM_EXPEND: return UI_ITEM_NEW_5;
case UI_ITEM_ETC: return UI_ITEM_NEW_6;
case UI_ITEM_QUEST: return UI_ITEM_NEW_7;
case UI_ITEM_CRU: return UI_ITEM_NEW_8;
default:
return -1;
}
return -1;
}
void SUIStorageWnd::SetItemList()
{
m_vecItemList.clear();
const vec_inventoryslot& vecItemList = m_StorageMgr.GetItemList();
//UpdateSlot(); // 2011. 9 .14 슬롯 텍스트 업데이트
if( vecItemList.empty() )
return;
int nMode = GetMode();
cit_inventoryslot iter = vecItemList.begin();
for( ;iter != vecItemList.end(); ++iter)
{
SInventorySlot* pSlot = (*iter);
if( NULL == pSlot )
continue;
const ItemBaseEx_info * pItem = GetItemDB().GetItemData( pSlot->GetItemCode() );
if( NULL == pItem )
continue;
if( -1 == nMode || pItem->nCategory_Bitset & nMode )
{
m_vecItemList.push_back(pSlot);
}
} //for
RefreshScrollBar();
UpdateSlot();
}
void SUIStorageWnd::RefreshSlots( int nSlotStart )
{
SetItemList();
EnableSelectBar();
int nMaxSlotCount = c_nMaxX_Count * c_nMaxY_Count; //전체 슬롯 갯수
nSlotStart *= c_nMaxX_Count; //한줄에 8개
int nMaxCount = ( nMaxSlotCount > static_cast<int>(m_vecItemList.size())) ? nMaxSlotCount : static_cast<int>(m_vecItemList.size());
for( int i = 0; i < nMaxCount; i++ )
{
if( i >= m_nViewSlot ) EnableSlots( i, false );
else if( i+nSlotStart >= static_cast<int>(m_vecItemList.size()) || static_cast<int>(m_vecItemList.size()) == 0 )
DisableSlot(i);
else
{
SInventorySlot* pSlot = m_vecItemList[i+nSlotStart];
EnableSlots( i, true );
SetSlotData( i, pSlot );
}
}
}
void SUIStorageWnd::SetSlotData( int nSlot, SInventorySlot* pSlot )
{
KUIControlMultiIcon* pIcon = dynamicCast<KUIControlMultiIcon*>(GetChild( CStringUtil::StringFormat( "storage_slot%02d", nSlot ).c_str() ));
if( pIcon )
{
ResetMultiIcon( pIcon, 0, 8 );
/// 2011.08.03 - prodongi
if( !setSkillCardIcon(pIcon, pSlot->GetItemCode()) && !setSummonCardIcon( pIcon, pSlot ) )
{
std::string iconName;
getIconNameAtDurability(pSlot, iconName);
pIcon->SetIcon( 0, c_szDEF_SPR_NAME, iconName.c_str() );
}
if(pSlot->GetItemAppearance())
pIcon->SetIcon( 4 , c_szDEF_SPR_NAME, g_strLookChangeIcon); // 2012. 7. 27 - marine 형상변환 아이콘
pIcon->SetIcon( 1, c_szDEF_SPR_NAME, pSlot->GetXFlag().IsOn( ItemInstance::ITEM_FLAG_CARD ) ? "static_common_useunitcardicon" : NULL );
// gmpbigsun( 20130325 ) : 빈카드 표시 제거예정
// if( GetItemDB().GetGroup( pSlot->GetItemCode() ) == ItemBase::GROUP_SUMMONCARD )
// {
// 2012. 1. 18 - marine 크리쳐 빈카드 이미지가 안나와서 추가
// bool isSummon = pSlot->GetXFlag().IsOn( ItemInstance::ITEM_FLAG_SUMMON );
// if (isSummon == 0)
// {
// pIcon->SetIcon( 2, c_szDEF_SPR_NAME, g_strEmptyCardIcon);
// }
// }
EquipItemAddtionalIconSetter icon_setter( pIcon, pSlot );
/// 2010.10.15 빠진것 같아서 다른 부분에서 갖고 옴(중복 코드,,,)- prodongi
unsigned int nEndurancePer = 0;
//
// 헌터홀릭 포인트 카드일 경우
// 내구도를 포인트 점수로 처리.
// 따라서 내구도를 percentage 로 나타내면 안된다.
//
if( pSlot->GetItemCode() == 806808 )
{
nEndurancePer = pSlot->GetEndurance();
}
else
{
int nResult = pSlot->GetCrrEndurancePer(nEndurancePer);
if( nResult != SInventorySlot::ENDURANCE_SUCCESS )
nEndurancePer = nResult;
}
pIcon->SetLazyTooltip( new rp::KLazyItemTooltip( *m_pDisplayInfo, pSlot, true, NULL, true ) );
if( m_bAltKey )
{
m_pDisplayInfo->SetComparableEquipItemSubTooltip( pIcon, pSlot );
}
}
// SetChildCaption( CStringUtil::StringFormat( "storage_itemname%02d", nSlot ).c_str(), m_pDisplayInfo->GetItemName(pSlot->GetItemCode(), pSlot->GetEnhance(), pSlot->GetLevel(), pSlot->GetXFlag()).c_str() );
SetChildShow( CStringUtil::StringFormat( "storage_itemcount%02d", nSlot ).c_str(), !(!GetItemDB().IsJoin( pSlot->GetItemCode(),IsInstanceUnstackable(pSlot)) || pSlot->GetItemCount() <= 0) );
SetChildCaption( CStringUtil::StringFormat( "storage_itemcount%02d", nSlot ).c_str(), CStringUtil::StringFormat( "%s<right><size:8><shadow>%d", S(6425), pSlot->GetItemCount() ).c_str() );
}
void SUIStorageWnd::EnableSlots( int nSlot, bool bEnable )
{
SetChildShow( CStringUtil::StringFormat( "storage_slot%02d", nSlot ).c_str(), bEnable );
// SetChildShow( CStringUtil::StringFormat( "storage_itemname%02d", nSlot ).c_str(), bEnable );
SetChildShow( CStringUtil::StringFormat( "storage_itemcount%02d", nSlot ).c_str(), bEnable );
}
void SUIStorageWnd::DisableSlot( int nSlot )
{
KUIControlMultiIcon* pIcon = dynamicCast<KUIControlMultiIcon*>(GetChild( CStringUtil::StringFormat( "storage_slot%02d", nSlot ).c_str() ));
if( pIcon )
{
ResetMultiIcon( pIcon, 0, 8 );
pIcon->SetIcon( 0, c_szDEF_SPR_NAME, "static_common_itemslot" );
pIcon->SetTooltip();
}
// SetChildShow( CStringUtil::StringFormat( "storage_itemname%02d", nSlot ).c_str(), false );
SetChildShow( CStringUtil::StringFormat( "storage_itemcount%02d", nSlot ).c_str(), false );
}
AR_HANDLE SUIStorageWnd::GetItemHandle( const char* szControlID )
{
if( m_vecItemList.size() <= 0 ) return NULL;
int nIndex = 0;
it_inventoryslot it = m_vecItemList.begin();
while( it != m_vecItemList.end() )
{
if( ::_stricmp( szControlID, CStringUtil::StringFormat( "storage_slot%02d", nIndex ).c_str() ) == 0 )
{
if( nIndex+m_nInvenSlotStartIndex >= static_cast<int>(m_vecItemList.size()) )
return NULL;
return m_vecItemList[nIndex+m_nInvenSlotStartIndex]->GetHandle();
}
nIndex++;
it++;
}
return NULL;
}
SInventorySlot* SUIStorageWnd::GetItemInfo( AR_HANDLE hItem )
{
if( hItem == 0 ) return NULL;
if( m_vecItemList.empty() ) return NULL;
it_inventoryslot it = m_vecItemList.begin();
while( it != m_vecItemList.end() )
{
if( (*it)->GetHandle() == hItem )
return (*it);
++it;
}
return NULL;
}
void SUIStorageWnd::ReqSwapItem( AR_HANDLE hBEGIN_DRAG, AR_HANDLE hRECV_DROP )
{
if( hBEGIN_DRAG && hRECV_DROP )
m_pGameManager->PostMsgAtDynamic( new SIMSG_REQ_CHANGE_ITEM_POSITION(true, hBEGIN_DRAG, hRECV_DROP) );
}
// sonaodr 1.9.1 인벤토리 및 창고 정렬 기능 구현
void SUIStorageWnd::_ReqArrange()
{
if( m_pGameManager && !m_ActionTicker.is_on_tick() )
{
m_pGameManager->PostMsgAtDynamic( new SIMSG_REQ_ARRANGE_ITEM( true ) );
append_tickable( &m_ActionTicker );
m_ActionTicker.satisfy();
}
}
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////
//캐쉬 아이템 창고
bool SUICashStorageWnd::InitControls( KPoint kPos )
{
// SetCustomMovingRect( KRect( 0, 0, 310, 20 ) ); // 타이틀 바 선택 영역, 이동위해 클릭 Area
// 리사이즈 할때 단위 설정, ( 세로, 가로, 위드, 헤잇 )
SetResizeUnit( 0, c_nDelta, KSize((GetRect().right-GetRect().left), (GetRect().bottom-GetRect().top)), KSize((GetRect().right-GetRect().left), c_nMaxHeight) );
CreateControls();
SetChildAsTop( "storage_selectslot01" );
SetChildShow( "storage_selectslot01", false );
// 버튼 클릭 영역
// SetValidRect( "storage_button_receipts", KRect(0, 0, -11, 0) );
// SetValidRect( "storage_button_payingout", KRect(8, 0, -10, 0) );
this->MovePos( 300, 200 ); // servantes 2010.11.23
return SUIWnd::InitControls( kPos );
}
bool SUICashStorageWnd::InitData( bool bReload )
{
m_nTabMode = 0;
m_hSelItem = NULL;
m_nInvenSlotStartIndex = 0;
InitStaticText();
m_nScrollPos = 0;
m_nSelectSlot = -1;
m_nViewSlot = c_nCashMaxX_Count * c_nCashMaxY_Count;
m_rtOldRect = GetRect();
return SUIWnd::InitData(bReload);
}
void* SUICashStorageWnd::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();
KUIControlMultiIcon* pIcon = dynamicCast<KUIControlMultiIcon*>(GetChild( szControlID ));
if( pIcon == NULL ) return NULL;
if( !IsTakeAble( szControlID ) ) return NULL;
count_t count( 0 );
unsigned int hItemUID = GetItemUID( szControlID, count );
if( hItemUID )
{
m_pDisplayInfo->SetUIDragInfo( new SUICashItemDragInfo( hItemUID, count ) );
m_InventoryMgr.SetCashDragItem(hItemUID);
const KUIControlMultiIcon::ICON_INFO & icon_info = pIcon->GetIconInfoByLayer(0);
m_pDragAndDropIcon->SetStateIcon( icon_info.sSprName.c_str(), icon_info.sAniName.c_str(), pIcon->GetFrameIndex(), 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( pUIDragInfo && SUIDragInfo::DRAGTYPE_CASHITEM == pUIDragInfo->m_type )
{
SUIStorageDragInfo* pStorageDragInfo = (SUIStorageDragInfo*)pUIDragInfo;
// 동일한 창
if( pSendMsg->sRecvDropParentID == std::string(GetID()) ) return NULL;
// Drag & Drop 정보 제거
m_pDisplayInfo->SetUIDragInfo();
}
return NULL;
}
else if ( id == id_UI_RECV_DROP )
{
KUISendRecvDropMessage* pSendMsg = static_cast<KUISendRecvDropMessage*>( &msg );
SUIDragInfo* pUIDragInfo = m_pDisplayInfo->GetUIDragInfo();
//if( NULL != pUIDragInfo && SUIDragInfo::DRAGTYPE_INVENITEM == pUIDragInfo->m_type )
//{
// SUIInvenItemDragInfo* pItemDragInfo = (SUIInvenItemDragInfo*)pUIDragInfo;
// if( ::_stricmp( pSendMsg->sSendDropParentID.c_str(), "window_inventory" ) == 0 && ::_stricmp( pSendMsg->sRecvDropParentID.c_str(), "window_warehouse" ) == 0 )
// {
// if( pItemDragInfo && pItemDragInfo->m_hItem == -1 ) return NULL;
// m_pDisplayInfo->ChangeStorageItem( pItemDragInfo->m_hItem );
// m_pGameManager->StartSound( "ui_icon_drag.wav" );
// }
//}
return NULL;
}
return SUIWnd::Perform( id, msg );
}
void SUICashStorageWnd::OnNotifyUIWindowOpen( bool bOpen, bool bLimitWnd )
{
SUIWnd::OnNotifyUIWindowOpen(bOpen);
if( bOpen )
RefreshSlots();
}
void SUICashStorageWnd::PumpUpMessage( LPCSTR lpszControlID, DWORD nMessage, DWORD lparam, DWORD wparam )
{
switch( nMessage )
{
case KUI_MESSAGE::KBUTTON_CLICK:
{
if( ::_stricmp( lpszControlID, "button_close" ) == 0 )
m_pGameManager->PostMsgAtDynamic( new SIMSG_SHOW_UIWINDOW( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_CASH_STORAGE, false) );
else if( ::_stricmp( lpszControlID, "button_02" ) == 0 ) //수령 //servantes 2010.10.13 / 2011.08.29 button_ok -> button_02
{
//선택 된 아이템 있는가?
if( !m_hSelItem ) return;
//설정
m_InventoryMgr.SetCashDragItem(m_hSelItem);
count_t nItemCount = GetItemCount( m_hSelItem );
//아이템 갯수는?
if( nItemCount > 1 )
{
m_pGameManager->PostMsgAtDynamic( new SIMSG_UI_REQ_INPUTNUMBER( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_CASH_STORAGE, nItemCount, SIMSG_UI_REQ_INPUTNUMBER::TYPE_NUMBER ) );
}
else
{
//아이템 추가 요청
m_pDisplayInfo->RequestTakeOutCashItem( m_hSelItem, nItemCount );
}
}
}
break;
case KUI_MESSAGE::KICON_DBLCLK:
case KUI_MESSAGE::KICON_PRESSING:
{
if( ::strstr( lpszControlID, "storage_slot" ) )
{
m_hSelItem = NULL;
SetChildShow( "storage_selectslot01", false );
for( int i = 0; i < m_nViewSlot; i++ )
{
if( ::_stricmp( lpszControlID, CStringUtil::StringFormat("storage_slot%02d", i).c_str() ) == 0 )
{
m_hSelItem = GetSelectUID(m_nInvenSlotStartIndex + i);
if( m_hSelItem )
EnableSelectBar();
break;
}
}
if( nMessage == KUI_MESSAGE::KICON_DBLCLK && m_hSelItem )
{
m_pDisplayInfo->ChangeStorageItem(m_hSelItem, false);
}
}
}
break;
case KUI_MESSAGE::KGENWND_MOVE: // 윈도우 이동
{
LimitMoveWnd();
}
break;
case KUI_MESSAGE::KSCROLL_SELECT: // 스크롤 선택
{
int nPos = int(lparam);
nPos = max( nPos, 0 );
RefreshSlots(nPos);
}
break;
case KUI_MESSAGE::KGENWND_RESIZE: // 윈도우 리사이즈
ResizeScrollBar();
break;
/*
case KUI_MESSAGE::KTAB_SELECT:
{
KUIDetailTabControl* pTab = dynamicCast<KUIDetailTabControl*>(GetChild( lpszControlID ));
if( pTab != NULL )
{
m_nSelectSlot = -1;
m_nTabMode = -1;
switch( pTab->GetSelectedItem() )
{
case 0: m_nTabMode = UI_ITEM_ALL; break;
case 1: m_nTabMode = UI_ITEM_EQUIP; break;
case 2: m_nTabMode = UI_ITEM_CARD; break;
case 3: m_nTabMode = UI_ITEM_EXPEND; break;
case 4: m_nTabMode = UI_ITEM_ETC; break;
}
RefreshSlots();
}
}
break;
*/
}
SUIWnd::PumpUpMessage( lpszControlID, nMessage, lparam, wparam );
}
void SUICashStorageWnd::ProcMsgAtStatic( SGameMessage* pMsg )
{
switch( pMsg->nType )
{
case MSG_SEND_DATA:
{
SMSG_SEND_DATA* pSendMsg = (SMSG_SEND_DATA*)pMsg;
if( pSendMsg->strMessage == "cash_shop_open" )
{
m_pGameManager->PostMsgAtDynamic( new SMSG_CHAT_COMMAND( SMSG_CHAT_COMMAND::CHAT_CASHSHOP_OPEN ) );
}
}
break;
case IMSG_UI_MOVE:
{
SIMSG_UI_MOVE* pMoveMsg = ( SIMSG_UI_MOVE* )pMsg;
MovePos( pMoveMsg->m_nX-GetRect().GetWidth()+2, pMoveMsg->m_nY-GetRect().GetHeight()-60 );
pMsg->bUse = true;
}
break;
case MSG_COMMERCIAL_STORAGE_LIST:
{
RefreshSlots(m_nScrollPos);
pMsg->bUse = true;
}
break;
case IMSG_UI_INPUTNUMBER:
{
SIMSG_UI_INPUTNUMBER* pInputNumberMsg = (SIMSG_UI_INPUTNUMBER*)pMsg;
if( pInputNumberMsg->m_nValue > 0 )
{
count_t nValue = pInputNumberMsg->m_nValue;
m_pDisplayInfo->RequestTakeOutCashItem( m_InventoryMgr.GetCashDragItem(), nValue );
}
}
break;
case IMSG_HOTKEY_EX: //servantes 2010.10.15
{
SIMSG_HOTKEY_EX* pHotKey = dynamicCast<SIMSG_HOTKEY_EX*>(pMsg);
if( pHotKey->wParam == VK_SHIFT )
m_bShiftKey = (pHotKey->bUp == 0);
if( pHotKey->wParam == VK_CONTROL )
m_bControlKey = (pHotKey->bUp == 0);
if( pHotKey->wParam == VK_MENU )
{
bool bPreState = m_bAltKey;
m_bAltKey = (pHotKey->bUp == 0);
if( bPreState != m_bAltKey && IsShow() )
{
RefreshSlots(m_nScrollPos);
}
}
break;
}
}
}
// create
void SUICashStorageWnd::CreateControls()
{
// 2011.11.29 - servantes : "storage_itemcategory00" 컨트롤 nui에 없어서 주석처리
//// 아이템 category 탭 설정
//KUISimpleTabControl* pTabItemCategory = dynamicCast<KUISimpleTabControl*>(GetChild( "storage_itemcategory00" ));
//if( NULL != pTabItemCategory )
//{
// // pTabItemCategory->SetTabProperty( -37 );
// pTabItemCategory->SetTabProperty( 0, false, 5 );
// pTabItemCategory->AddTabItem( S(6242)/*"<size:10>전체"*/, "" );
// pTabItemCategory->AddTabItem( S(6241)/*"<size:10>장비"*/, "" );
// pTabItemCategory->AddTabItem( S(6247)/*"<size:10>카드"*/, "" );
// pTabItemCategory->AddTabItem( S(6227)/*"<size:10>소비"*/, "" );
// pTabItemCategory->AddTabItem( S(6216)/*"<size:10>기타"*/, "" );
// // pTabItemCategory->SetCorrectionRect( KRect( 19, 0, -19, 0 ) );
// pTabItemCategory->SetSelectedItem( 0 );
//}
RECT rc; rc.left = c_nDelta-1; rc.top = 0; rc.right = c_nDelta-1; rc.bottom = 0;
std::string strName, strNewName;
//첫줄 가로로 복사
for( int i = 0; i < c_nCashMaxX_Count-1; i++ )
{
// 아이콘
CopyControl( CStringUtil::StringFormat( "storage_slot%02d", i ).c_str() , CStringUtil::StringFormat( "storage_slot%02d", i+1 ).c_str() , rc );
// 카운트
CopyControl( CStringUtil::StringFormat( "storage_itemcount%02d", i ).c_str(), CStringUtil::StringFormat( "storage_itemcount%02d", i+1 ).c_str(), rc );
}
//세로로 복사
rc.left = 0; rc.top = c_nDelta; rc.right = 0; rc.bottom = c_nDelta;
for( int n = 1; n < c_nCashMaxY_Count; n++ )
{
for( int i = 0; i < c_nCashMaxX_Count; i++ )
{
int nIndex = i+(n*c_nCashMaxX_Count);
int nPrevIndex = nIndex-c_nCashMaxX_Count;
// _oprint( "Storage - prev : %d, index : %d\n", nPrevIndex, nIndex );
// 아이콘
CopyControl( CStringUtil::StringFormat( "storage_slot%02d", nPrevIndex ).c_str() , CStringUtil::StringFormat( "storage_slot%02d", nIndex ).c_str() , rc );
// 카운트
CopyControl( CStringUtil::StringFormat( "storage_itemcount%02d", nPrevIndex ).c_str(), CStringUtil::StringFormat( "storage_itemcount%02d", nIndex ).c_str(), rc );
}
}
for( int n = 0; n < c_nCashMax_Count; n++ )
{
KUIControlMultiIcon* pItemIconControl = dynamicCast<KUIControlMultiIcon*>(GetChild( CStringUtil::StringFormat("storage_slot%02d", n).c_str() ));
if( NULL != pItemIconControl )
{
pItemIconControl->SetIconLayer( nLayer );
}
}
SetChildAsTop( "storage_selectslot01" );
this->MovePos( 300, 200 ); // servantes 2010.11.23
}
// init
void SUICashStorageWnd::InitStaticText()
{
int nMaxCount = c_nCashMaxX_Count * c_nCashMaxY_Count;
for( int i = 0; i < nMaxCount; i++ )
{
SetChildShow( CStringUtil::StringFormat( "storage_itemcount%02d", i ).c_str(), false );
}
}
// selectbar
void SUICashStorageWnd::EnableSelectBar()
{
int nSlot = (m_nSelectSlot-m_nInvenSlotStartIndex);
if( nSlot > -1 && nSlot < c_nCashMax_Count )
{
KUIWnd* pWnd = GetChild( CStringUtil::StringFormat( "storage_slot%02d", nSlot ).c_str() );
if( pWnd ) SetMovePos( "storage_selectslot01", pWnd->GetRect().left, pWnd->GetRect().top );
SetChildShow( "storage_selectslot01", true );
}
else
SetChildShow( "storage_selectslot01", false );
}
unsigned int SUICashStorageWnd::GetSelectUID( int nIndex )
{
m_nSelectSlot = -1;
m_hSelItem = NULL;
if( nIndex >= 0 && nIndex < static_cast<int>(m_vecItemList.size()) )
{
m_hSelItem = m_vecItemList[nIndex].commercial_item_uid;
m_nSelectSlot = nIndex;
}
return m_hSelItem;
}
// resize
void SUICashStorageWnd::ResizeScrollBar()
{
//KUIControlVScroll* pScrollBar = (KUIControlVScroll*)GetChild( "storage_scroll" );
KUIControlVScrollSmallEx * pScrollBar = dynamicCast<KUIControlVScrollSmallEx*>(GetChild( "storage_scroll" ));
if( NULL != pScrollBar )
{
KRect kt = pScrollBar->GetRect();
int nDelta = GetRect().GetHeight() - m_rtOldRect.GetHeight();
if( nDelta > 0 ) m_nViewSlot += ( nDelta/c_nDelta )*2;
else if( nDelta < 0 ) m_nViewSlot -= ( (nDelta*-1)/c_nDelta )*2;
int nMaxCount = c_nCashMaxX_Count * c_nCashMaxY_Count;
int nMinCount = c_nCashMaxX_Count * c_nCashMaxY_Count;
m_nViewSlot = max( m_nViewSlot, nMinCount );
m_nViewSlot = min( m_nViewSlot, nMaxCount );
kt.top = kt.top + 4;
kt.bottom = kt.bottom - 4;
pScrollBar->Resize( kt );
RefreshSlots(m_nScrollPos); // 슬롯
m_rtOldRect = GetRect();
}
}
// scrollbar
void SUICashStorageWnd::RefreshScrollBar()
{
int nCurCount = static_cast<int>( m_vecItemList.size() );
// int nScrollRange = max(nCurCount - m_nViewSlot, 0);
int nScrollPos = 0;
//KUIControlVScroll* pScrollBar = (KUIControlVScroll*)GetChild( "storage_scroll" );
KUIControlVScrollSmallEx * pScrollBar = dynamicCast<KUIControlVScrollSmallEx*>(GetChild( "storage_scroll" ));
if( NULL != pScrollBar )
{
int nInvenSlotCountY = (pScrollBar->GetRect().bottom - pScrollBar->GetRect().top) / 38;
int nLineCount = (static_cast<int>(m_vecItemList.size())) / c_nCashMaxX_Count;
int nLineRest = (static_cast<int>(m_vecItemList.size())) % c_nCashMaxX_Count;
if( nLineCount < 0 ) nLineCount = c_nCashMaxY_Count;
if( nLineRest ) nLineCount++;
int nScrollRange = max(nLineCount - c_nCashMaxY_Count, 0);
pScrollBar->SetScrollRange( c_nCashMaxY_Count, nLineCount ); // sonador #2.3.1.40
m_nScrollPos = pScrollBar->GetPosition();
m_nInvenSlotStartIndex = m_nScrollPos * c_nCashMaxX_Count;
}
}
int SUICashStorageWnd::GetMode()
{
switch(m_nTabMode)
{
case UI_ITEM_EQUIP: return ItemBase::TYPE_ARMOR;
case UI_ITEM_CARD: return ItemBase::TYPE_CARD;
case UI_ITEM_EXPEND: return ItemBase::TYPE_USEABLE;
case UI_ITEM_ETC: return ItemBase::TYPE_ETC;
case UI_ITEM_USE: return ItemBase::TYPE_USE;
}
return -1;
}
void SUICashStorageWnd::SetItemList()
{
m_vecItemList.clear();
vec_commercial_list & vecItemList = m_InventoryMgr.GetCashItemList();
if( vecItemList.size() <= 0 ) return;
it_commercial_list it = vecItemList.begin();
while( it != vecItemList.end() )
{
m_vecItemList.push_back( (*it) );
++it;
}
RefreshScrollBar();
}
void SUICashStorageWnd::RefreshSlots( int nNewScrollPos )
{
// sonador #2.3.1.40
m_nScrollPos = nNewScrollPos;
// sonador #2.3.1.40
// 아래 메소드 SetItemList() 에서 호출하는 RefreshScrollBar() 메소드에서
// m_nScrollPos 를 변경할 가능성이 있다.
SetItemList();
EnableSelectBar();
int nMaxSlotCount = c_nCashMaxX_Count * c_nCashMaxY_Count; //전체 슬롯 갯수
int nSlotStart = m_nScrollPos * c_nCashMaxX_Count;
//int nMaxCount = ( nMaxSlotCount > static_cast<int>(m_vecItemList.size())) ? nMaxSlotCount : static_cast<int>(m_vecItemList.size());
for( int i = 0; i < nMaxSlotCount; ++i )
{
int nItemIndex = nSlotStart + i;
if( nItemIndex >= 0 && nItemIndex < m_vecItemList.size() )
{
TS_SC_COMMERCIAL_STORAGE_LIST::CommercialItemInfo* pSlot = &m_vecItemList[ nItemIndex ];
EnableSlots( i, true );
SetSlotData( i, pSlot );
}
else
{
DisableSlot( i );
}
}
}
void SUICashStorageWnd::SetSlotData( int nSlot, TS_SC_COMMERCIAL_STORAGE_LIST::CommercialItemInfo* pSlot )
{
KUIControlMultiIcon* pIcon = dynamicCast<KUIControlMultiIcon*>(GetChild( CStringUtil::StringFormat( "storage_slot%02d", nSlot ).c_str() ));
if( pIcon )
{
ResetMultiIcon( pIcon, 0, 8 );
const ItemBaseEx_info* rItemBase = GetItemDB().GetItemData( pSlot->code );
unsigned char byItemLevel = (ItemBase::TYPE_ARMOR == rItemBase->nType) ? rItemBase->level : 0;
ItemBase::BaseFlag baseFlag;
baseFlag.CopyFrom( &rItemBase->status_flag );
int soket[ ItemBase::MAX_SOCKET_NUMBER ];
::memset( soket, 0, sizeof( soket ) );
pIcon->SetIcon( 0, c_szDEF_SPR_NAME, GetItemDB().GetIconName( pSlot->code ) );
pIcon->SetIcon( 1, c_szDEF_SPR_NAME, NULL );
EquipItemAddtionalIconSetter icon_setter( pIcon, pSlot->code, rItemBase->enhance, rItemBase->nEthereal_durability, baseFlag );
pIcon->SetTooltip( m_pDisplayInfo->GetItemTooltipText( pSlot->code,
true,
rItemBase->enhance,
byItemLevel,
baseFlag,
rItemBase->available_time,
soket,
0,
0,
0,
0,
0,
0,
0,
true,
rItemBase->nEthereal_durability,
rItemBase->nEndurance,
0,
rItemBase->nSummonId,
0
).c_str()
);
if( m_bAltKey )
{
m_pDisplayInfo->SetComparableEquipItemSubTooltip( pIcon, pSlot->code );
}
}
// SetChildCaption( CStringUtil::StringFormat( "storage_itemname%02d", nSlot ).c_str(), m_pDisplayInfo->GetItemName(pSlot->GetItemCode(), pSlot->GetEnhance(), pSlot->GetLevel(), pSlot->GetXFlag()).c_str() );
// SetChildShow( CStringUtil::StringFormat( "storage_itemcount%02d", nSlot ).c_str(), !(!GetItemDB().IsJoin( pSlot->code ) || pSlot->count <= 0) );
SetChildShow( CStringUtil::StringFormat( "storage_itemcount%02d", nSlot ).c_str(), (pSlot->count > 1) ? true : false );
SetChildCaption( CStringUtil::StringFormat( "storage_itemcount%02d", nSlot ).c_str(), CStringUtil::StringFormat( "%s<right>%d", S(6425), pSlot->count ).c_str() );
}
void SUICashStorageWnd::EnableSlots( int nSlot, bool bEnable )
{
SetChildShow( CStringUtil::StringFormat( "storage_slot%02d", nSlot ).c_str(), bEnable );
// SetChildShow( CStringUtil::StringFormat( "storage_itemname%02d", nSlot ).c_str(), bEnable );
SetChildShow( CStringUtil::StringFormat( "storage_itemcount%02d", nSlot ).c_str(), bEnable );
}
void SUICashStorageWnd::DisableSlot( int nSlot )
{
KUIControlMultiIcon* pIcon = dynamicCast<KUIControlMultiIcon*>(GetChild( CStringUtil::StringFormat( "storage_slot%02d", nSlot ).c_str() ));
if( pIcon )
{
pIcon->SetIcon( 0, c_szDEF_SPR_NAME, "static_common_itemslot" );
pIcon->SetIcon( 1 );
pIcon->SetIcon( 2 );
pIcon->SetIcon( 3 );
pIcon->SetIcon( 4 );
pIcon->SetTooltip();
}
// SetChildShow( CStringUtil::StringFormat( "storage_itemname%02d", nSlot ).c_str(), false );
SetChildShow( CStringUtil::StringFormat( "storage_itemcount%02d", nSlot ).c_str(), false );
}
bool SUICashStorageWnd::IsTakeAble( const char* szControlID )
{
if( m_vecItemList.size() <= 0 ) return false;
int nIndex = 0;
it_commercial_list it = m_vecItemList.begin();
while( it != m_vecItemList.end() )
{
if( ::_stricmp( szControlID, CStringUtil::StringFormat( "storage_slot%02d", nIndex ).c_str() ) == 0 )
{
if( nIndex+m_nInvenSlotStartIndex >= static_cast<int>(m_vecItemList.size()) ) return false;
//가이아 상인 연합권
if( m_vecItemList[nIndex+m_nInvenSlotStartIndex].code == 910000 ) return false;
// //TODO : 캐쉬템에서 뺄 수 있는 것인지 검사 하는것 추가 해야 됨. 아직 DB 없음
// GetItemDB().GetItemData( m_vecItemList[nIndex+m_nInvenSlotStartIndex].code );
return true;
}
nIndex++;
it++;
}
return false;
}
count_t SUICashStorageWnd::GetItemCount( unsigned int uitemUID )
{
if( m_vecItemList.size() <= 0 ) return count_t( 0 );
int nIndex = 0;
it_commercial_list it = m_vecItemList.begin();
while( it != m_vecItemList.end() )
{
if( nIndex+m_nInvenSlotStartIndex >= static_cast<int>(m_vecItemList.size()) ) return count_t( 0 );
if( uitemUID == m_vecItemList[nIndex+m_nInvenSlotStartIndex].commercial_item_uid )
return count_t( m_vecItemList[nIndex+m_nInvenSlotStartIndex].count );
nIndex++;
it++;
}
return count_t( 0 );
}
unsigned int SUICashStorageWnd::GetItemUID( const char* szControlID, count_t & count )
{
if( m_vecItemList.size() <= 0 ) return NULL;
int nIndex = 0;
it_commercial_list it = m_vecItemList.begin();
while( it != m_vecItemList.end() )
{
if( ::_stricmp( szControlID, CStringUtil::StringFormat( "storage_slot%02d", nIndex ).c_str() ) == 0 )
{
if( nIndex+m_nInvenSlotStartIndex >= static_cast<int>(m_vecItemList.size()) ) return NULL;
count = count_t( m_vecItemList[nIndex+m_nInvenSlotStartIndex].count );
return m_vecItemList[nIndex+m_nInvenSlotStartIndex].commercial_item_uid;
}
nIndex++;
it++;
}
return NULL;
}
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
//캐쉬 아이템 상점 타이틀
SUICashTitleWnd::SUICashTitleWnd( SGameManager* pGameManager, SUIDisplayInfo* pDisplayInfo )
: SUIWnd( pGameManager )
, m_pDisplayInfo ( pDisplayInfo )
{
/// 2011.06.14 mantis 13132 - prodongi
setIsWeb(true);
// gmpbigsun, 2012_09_14 : 크루샵 열때 ClientInfo전송
if( pDisplayInfo )
pDisplayInfo->SaveQuickSlots();
};
void SUICashTitleWnd::OnNotifyUIWindowOpen( bool bOpen, bool bLimitWnd /* = true */ )
{
SUIWnd::OnNotifyUIWindowOpen(bOpen);
// 2012. 2. 1 - marine 캐쉬창이 열려있는데 메세지 박스가 열려있는 경우가 있다... 이럴때 캐쉬창을 닫을수가 없어서 강제로 메세지 박스를 닫아줌..
m_pGameManager->GetGameInterface()->CloseMessgeBoxWithID(SIMSG_REQ_OPEN_MSGBOX::MSGBOX_CASHSHOP_OPEN);
}
void SUICashTitleWnd::PumpUpMessage( LPCSTR lpszControlID, DWORD nMessage, DWORD lparam, DWORD wparam )
{
switch( nMessage )
{
case KUI_MESSAGE::KBUTTON_CLICK:
if( ::_stricmp( lpszControlID, "button_close" ) == 0 ) //servantes 2010.10.13
{
m_pGameManager->PostMsgAtDynamic( new SIMSG_SHOW_UIWINDOW( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_CASH_TITLE, false) );
m_pGameManager->PostMsgAtDynamic( new SMSG_SEND_DATA( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_CASH_TITLE, "close_item_shop" ) );
}
break;
}
}
void SUICashTitleWnd::ProcMsgAtStatic( SGameMessage* pMsg )
{
//switch( pMsg->nType )
//{
//}
}
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
//길드 웹 타이틀
bool SUIGuildTitleWnd::InitControls( KPoint kPos )
{
SetCustomMovingRect( KRect( 0, 0, 244, 20 ) ); // 이동
SetRect( KRect( 0, 0, 244, 350 ) );
return SUIWnd::InitControls( kPos );
}
void SUIGuildTitleWnd::PumpUpMessage( LPCSTR lpszControlID, DWORD nMessage, DWORD lparam, DWORD wparam )
{
switch( nMessage )
{
case KUI_MESSAGE::KBUTTON_CLICK:
if( ::_stricmp( lpszControlID, "button00" ) == 0 )
{
m_pGameManager->PostMsgAtDynamic( new SIMSG_SHOW_UIWINDOW( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_GUILD_TITLE, false) );
m_pGameManager->PostMsgAtDynamic( new SMSG_SEND_DATA( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_GUILD_TITLE, "close_guild_web" ) );
}
break;
case KUI_MESSAGE::KGENWND_MOVE:
{
LimitMoveWnd();
m_pGameManager->PostMsgAtDynamic( new SMSG_SEND_DATA( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_CASH_TITLE, "move_guild_web" ) );
}
break;
}
}
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
//
bool SUIHelpTitleWnd::InitControls( KPoint kPos )
{
SetCustomMovingRect( KRect( 0, 0, g_Help_url.x, 20 ) ); // 이동
SetRect( KRect( 0, 0, g_Help_url.x, 20 ) );
return SUIWnd::InitControls( kPos );
}
void SUIHelpTitleWnd::PumpUpMessage( LPCSTR lpszControlID, DWORD nMessage, DWORD lparam, DWORD wparam )
{
switch( nMessage )
{
case KUI_MESSAGE::KBUTTON_PRESSING: //servantes 2010.10.13
if( ::_stricmp( lpszControlID, "button_close" ) == 0 )
{
m_pGameManager->PostMsgAtDynamic( new SIMSG_SHOW_UIWINDOW( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_HELP_TITLE, false) );
m_pGameManager->PostMsgAtDynamic( new SMSG_SEND_DATA( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_HELP_TITLE, "close_help_web" ) );
}
break;
case KUI_MESSAGE::KGENWND_MOVE:
{
LimitMoveWnd();
m_pGameManager->PostMsgAtDynamic( new SMSG_SEND_DATA( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_HELP_TITLE, "move_help_web" ) );
}
break;
}
}
//servantes 2010.10.13
void SUIHelpTitleWnd::OnNotifyUIWindowOpen( bool bOpen, bool bLimitWnd )
{
SUIWnd::OnNotifyUIWindowOpen(bOpen);
if( !bOpen )
{
m_pGameManager->PostMsgAtDynamic( new SIMSG_SHOW_UIWINDOW( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_HELP_TITLE, false) );
m_pGameManager->PostMsgAtDynamic( new SMSG_SEND_DATA( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_HELP_TITLE, "close_help_web" ) );
}
}
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
//
const int c_nURL_Width = 622;
const int c_nURL_Height = 653;
bool SUIPopURLTitleWnd::InitControls( KPoint kPos )
{
SetCustomMovingRect( KRect( 0, 0, c_nURL_Width, 20 ) ); // 이동
SetRect( KRect( 0, 0, c_nURL_Width, c_nURL_Height ) );
m_nURL_Width = c_nURL_Width;
m_nURL_Height = c_nURL_Height;
return SUIWnd::InitControls( kPos );
}
void SUIPopURLTitleWnd::PumpUpMessage( LPCSTR lpszControlID, DWORD nMessage, DWORD lparam, DWORD wparam )
{
switch( nMessage )
{
case KUI_MESSAGE::KBUTTON_CLICK:
if( ::_stricmp( lpszControlID, "button00" ) == 0 )
{
if( !m_vURL_List.empty() )
{
m_pGameManager->PostMsgAtDynamic( new SMSG_SEND_DATA( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_POPURL_TITLE,
"re_popurl_web",
m_nURL_Width,
m_nURL_Height,
m_vURL_List[0].c_str() ) );
m_vURL_List.erase( m_vURL_List.begin() );
}
else
{
m_pGameManager->PostMsgAtDynamic( new SIMSG_SHOW_UIWINDOW( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_POPURL_TITLE, false) );
m_pGameManager->PostMsgAtDynamic( new SMSG_SEND_DATA( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_POPURL_TITLE, "close_popurl_web" ) );
}
}
break;
case KUI_MESSAGE::KGENWND_MOVE:
{
LimitMoveWnd();
m_pGameManager->PostMsgAtDynamic( new SMSG_SEND_DATA( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_POPURL_TITLE, "move_popurl_web" ) );
}
break;
}
}
void SUIPopURLTitleWnd::ProcMsgAtStatic( SGameMessage* pMsg )
{
switch( pMsg->nType )
{
case MSG_OPEN_URL :
{
SMSG_OPEN_URL* pOpenURL = (SMSG_OPEN_URL*)pMsg;
pMsg->bUse = true;
if( !pOpenURL->m_strURL.empty() )
{
MsgSplit( pOpenURL->m_strURL.c_str(), m_vURL_List, L"|" );
if( m_vURL_List.size() > 1 )
m_vURL_List.erase( m_vURL_List.begin() ); //0번은 이미 처리 되어 있다.
else
m_vURL_List.clear();
if( pOpenURL->width && pOpenURL->height )
{
m_nURL_Width = pOpenURL->width;
m_nURL_Height = pOpenURL->height;
}
else
{
m_nURL_Width = c_nURL_Width;
m_nURL_Height = c_nURL_Height;
}
ResizeWnd();
}
else
{
m_nURL_Width = 0;
m_nURL_Height = 0;
}
}
break;
}
}
void SUIPopURLTitleWnd::ResizeWnd()
{
KRect rc = GetRect();
rc.right = rc.left + m_nURL_Width + 3;
rc.bottom = rc.top + m_nURL_Height;
Resize( rc );
SetCustomMovingRect( KRect( rc.left, rc.top, rc.right, rc.top + 20 ) ); // 이동
KUIWnd* pTitleWnd = GetChild("static00");
if( pTitleWnd )
pTitleWnd->Resize( KRect(rc.left, rc.top, pTitleWnd->GetRect().left + rc.GetWidth(), pTitleWnd->GetRect().top + rc.GetHeight()) );
KUIWnd* pButtonWnd = GetChild("button00");
if( pButtonWnd )
pButtonWnd->MovePos( rc.right - ( pButtonWnd->GetRect().GetWidth() + 3 ), rc.top + 3 );
}