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

2529 lines
81 KiB
C++

#include "stdafx.h"
#include "KUIWndManager.h"
#include "KUIDragAndDrop.h"
//#include "KUIControl.h"
#include "KUIControlStatic.h"
#include "KUIControlScroll.h"
#include "KUIControlButton.h"
#include "KUITabControl.h"
#include "SUIShopWnd.h"
#include "SGameManager.h"
//#include "SGameMessageUI.h"
#include "SItemDB.h"
#include "SStringDB.h"
#include "SkillBaseFile.h"
//#include "Util.h"
#include "ErrorCode/ErrorCode.h"
#include "SUISysMsgDefine.h"
#include "SStoreMgr.h"
#include "SPlayerInfoMgr.h"
#include "SInventoryMgr.h"
#include "SUIDisplayInfo.h"
// 2010.07.06 - prodongi
//#include "SUIUtil.h"
#include "SGameInterface.h" // 2012. 2. 21 - marine
#include "SNpcResourceDB.h"
#include "SGameNpc.h"
#include "SGame.h"
#include "SUILazyTooltip.h"
#include "SGameSystem.h"
extern SGameSystem * g_pCurrentGameSystem;
namespace
{
const int c_nInvenWndMaxHeight = 600;
const int c_nInvenWndResizeUnitY = 38;
const int c_nInvenSlotReduceCount = 12;
const int c_nMaxShopSlotCount = 12;
const int c_nMaxKartSlotCount = 13;
// const int c_nEquipSetTabCorrection = 9;
// const int c_nCategoryTabCorrection = 19;
// const int c_nItemIconCorrection = 240;
// const int c_nToKartButtonCorrection = 13;
// const int c_nIconSelectionCorrectX = (-5);
// const int c_nIconSelectionCorrectY = (-6);
// const int c_nNameSelectinCorrectX = (-5);
// const char* c_szTabTradeMode = "tab_tradetype";
const char* c_szTabItemCategory = "tab_itemcategory";
const char* c_szScrollInven = "vscroll_inven";
const char* c_szStaticItemBG = "static_common_itemslot";
const char* c_szIconControl = "icon_item";
const char* c_szStaticNameControl = "static_item";
const char* c_szStaticCountControl = "static_itemcount";
const char* c_szStaticPriceControl = "static_price";
const char* c_szStaticUnitControl = "text_unit";
const char* c_szButtonBuySell = "button_buysell";
const char* c_szTooltipSprName = c_szDEF_SPR_NAME;
// --;; 서버에서 int 사용하더라는 OTL -N4-
const int c_nBuySellCountLimit = 70000; // 매매갯수는 70000로 제한한다. ( 패킷에 갯수를 unsigned short을 사용하고 있음. )
};
void setBuyItemPriceCaption(SShopSlot* slot, count_t itemCount, KUIWnd* wnd)
{
money_t price;
if (slot->GetArenaPoint() > 0)
price = slot->GetArenaPoint() * itemCount;
else if (slot->GetHuntaHolicPoint() > 0)
price = slot->GetHuntaHolicPoint() * itemCount;
else
price = slot->GetPrice() * itemCount;
std::string strPrice;
strPrice = CStringUtil::StringFormat( "<size:10><right>%s", CStringUtil::GetCommaNumberString( price.getAmount()).c_str());
wnd->SetCaption(strPrice.c_str());
}
void setBuyItemUnitCaption(SShopSlot* slot, KUIWnd* wnd)
{
std::string strUnit;
if (slot->GetArenaPoint() > 0)
{
XStringUtil::Format(strUnit, "%s%s", "<font:font_default><size:10><#1288d5>", S(2342));
}
else if (slot->GetHuntaHolicPoint() > 0)
{
XStringUtil::Format(strUnit, "%s%s", "<font:font_default><size:10><#ca4470>", S(9708));
}
else
{
XStringUtil::Format(strUnit, "%s%s", "<font:font_default><size:10><#fdec00>", S(6618));
}
wnd->SetCaption(strUnit.c_str());
}
/// 팔때는 루피단위이다
void setSellItemUnitCaption(KUIWnd* wnd)
{
std::string strUnit;
XStringUtil::Format(strUnit, "%s%s", "<font:font_default><size:10><#fdec00>", S(6618));
wnd->SetCaption(strUnit.c_str());
}
SUIShopWnd::SUIShopWnd( class SGameManager* pGameManager, SUIDisplayInfo* pDisplayInfo )
: SUIWnd( pGameManager )
, m_pDisplayInfo( pDisplayInfo )
, m_bCtrlKey(false)
, m_bShiptKey(false)
{
m_pSlotControlIDs = new SLOT_INFO[ c_nMaxShopSlotCount ];
for( int n( 0 ); n < c_nMaxShopSlotCount; ++n )
{
std::string strNum = CStringUtil::StringFormat( "%02d", n );
m_pSlotControlIDs[ n ].strIconControl = c_szIconControl + strNum;
m_pSlotControlIDs[ n ].strStaticNameControl = c_szStaticNameControl + strNum;
m_pSlotControlIDs[ n ].strStaticCountControl = c_szStaticCountControl + strNum;
m_pSlotControlIDs[ n ].strStaticPriceControl = c_szStaticPriceControl + strNum;
m_pSlotControlIDs[ n ].strStaticUnitControl = c_szStaticUnitControl + strNum;
}
}
SUIShopWnd::~SUIShopWnd()
{
delete [] m_pSlotControlIDs;
}
bool SUIShopWnd::InitControls( KPoint kPos )
{
// 커스텀 윈도우 move 영역 설정
SetCustomMovingRect( KRect( 0, 0, 310, 20 ) );
// 카트에 담기 버튼 영역 보정 ( Resize버튼과 겹치기 때문에 적당히 줄여준다. )
// SetValidRect( "button_tokart", KRect( 0, 0, -c_nToKartButtonCorrection, 0 ) );
// // 장비 Set탭 설정
// KUISimpleTabControl* pTabTradeMode = (KUISimpleTabControl*)GetChild( c_szTabTradeMode );
// if( NULL != pTabTradeMode )
// {
//// pTabTradeMode->SetTabProperty( -20 );
// pTabTradeMode->AddTabItem( "구입", "" );
// pTabTradeMode->AddTabItem( "매각", "" );
// pTabTradeMode->SetCorrectionRect( KRect( c_nEquipSetTabCorrection, 0, -c_nEquipSetTabCorrection, 0 ) );
// pTabTradeMode->SetSelectedItem( 0 );
// }
{
RECT rc;
rc.left = 0; rc.top = c_nInvenWndResizeUnitY; rc.right = 0; rc.bottom = c_nInvenWndResizeUnitY;
int n = 0;
for( n = 0; n < c_nMaxShopSlotCount-1; n++ )
{
CopyControl( CStringUtil::StringFormat("icon_item%02d" , n).c_str(), CStringUtil::StringFormat("icon_item%02d" , n+1).c_str(), rc );
CopyControl( CStringUtil::StringFormat("static_item%02d" , n).c_str(), CStringUtil::StringFormat("static_item%02d" , n+1).c_str(), rc );
CopyControl( CStringUtil::StringFormat("static_itemcount%02d" , n).c_str(), CStringUtil::StringFormat("static_itemcount%02d" , n+1).c_str(), rc );
CopyControl( CStringUtil::StringFormat("static_price%02d" , n).c_str(), CStringUtil::StringFormat("static_price%02d" , n+1).c_str(), rc );
CopyControl( CStringUtil::StringFormat("text_unit%02d" , n).c_str(), CStringUtil::StringFormat("text_unit%02d" , n+1).c_str(), rc );
}
for( n = 0; n < c_nMaxShopSlotCount; n++ )
{
KUIControlMultiIcon* pIcon = dynamicCast<KUIControlMultiIcon*>(GetChild( CStringUtil::StringFormat("icon_item%02d" , n).c_str() ));
if( pIcon )
{
pIcon->SetIconLayer( 10 );
pIcon->SetCorrectionRect( KRect( 0, 0, 250, 0 ) );
}
}
}
// 아이템 category 탭 설정
KUISimpleTabControl* pTabItemCategory = dynamicCast<KUISimpleTabControl*>(GetChild( c_szTabItemCategory ));
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( c_nCategoryTabCorrection, 0, -c_nCategoryTabCorrection, 0 ) );
pTabItemCategory->SetSelectedItem( 0 );
}
//// 슬롯 icon 툴팁 스프라이트 설정, 클릭 영역 보정
//for( int nSlot( 0 ); nSlot < c_nMaxShopSlotCount; ++nSlot )
//{
// KUIControl* pItemIconControl = (KUIControl*)GetChild( m_pSlotControlIDs[ nSlot ].strIconControl.c_str() );
// if( NULL != pItemIconControl )
// pItemIconControl->SetCorrectionRect( KRect( 0, 0, c_nItemIconCorrection, 0 ) );
//}
SetChildShow( "static_select_over_back", false );
SetChildShow( "static_select_over" , false );
SetChildShow( "icon_select_over" , false );
return SUIWnd::InitControls( kPos );
}
bool SUIShopWnd::InitData( bool bReload )
{
m_nScrollBarBottomOffset = 0;
m_nScrollBarTopOffset = 0;
m_CurrentCategory = UI_ITEM_ALL;
m_nCurrentSelect = -1;
m_nSlotStartIndex = 0;
m_nSlotCountY = c_nMaxShopSlotCount;
// 스크롤바 영역 조사
KUIControlVScroll* pScrollBar = dynamicCast<KUIControlVScroll*>(GetChild( c_szScrollInven ));
if( NULL != pScrollBar )
{
m_nScrollBarTopOffset = (pScrollBar->GetRectWithBtn().top - GetRect().top );
m_nScrollBarBottomOffset = (pScrollBar->GetRectWithBtn().bottom - GetRect().bottom);
}
int nInvenWndWidth = GetRect().GetWidth();
int nInvenWndMaxHeight = GetRect().GetHeight();
KUIWnd* pBottomWnd = GetChild( "static_inven_info" );
KUIWnd* pTopWnd = GetChild( "tab_itemcategory" );
int nTop = nInvenWndMaxHeight;
if( pTopWnd )
nTop = pTopWnd->GetRect().bottom;
int nInvenWndMinHeight = nTop + (c_nInvenWndResizeUnitY * c_nInvenSlotReduceCount);
if( pBottomWnd )
nInvenWndMinHeight += (nInvenWndMaxHeight-pBottomWnd->GetRect().top);
// 리사이즈 설정
KSize sizMin( nInvenWndWidth, nInvenWndMinHeight );
KSize sizMax( nInvenWndWidth, c_nInvenWndMaxHeight );
SetResizeUnit( 0, c_nInvenWndResizeUnitY, sizMin, sizMax );
Resize( KRect( KPoint( 0, 0 ), sizMin ) );
SetChildAsTop( "icon_select_over" );
// int nDelta = nInvenWndMinHeight - nPrevHeight + 7; //7는 타이틀 높이
KUIWnd * pOutfram = GetChild( "outframe" );
if( pOutfram )
{
KRect rcChild = pOutfram->GetRect();
rcChild.bottom = nInvenWndMinHeight + 5;
pOutfram->Resize( rcChild );
}
KUIWnd * pInfram = GetChild( "inframe" );
if( pInfram )
{
KRect rcChild = pInfram->GetRect();
rcChild.bottom = nInvenWndMinHeight - 1;
pInfram->Resize( rcChild );
}
RefreshScrollBar();
if( !bReload )
SetBuyModeShoppingKartWindow();
return SUIWnd::InitData(bReload);
}
void SUIShopWnd::OnNotifyUIWindowOpen( bool bOpen, bool bLimitWnd )
{
SUIWnd::OnNotifyUIWindowOpen(bOpen);
if( bOpen )
{
//2012. 2. 20 - marine 열린 파괴창, 수리창, 조합창, 강화창 닫기,
m_pGameManager->GetGameInterface()->CloseAgainstUi();
m_pGameManager->StartSound( "ui_popup_window01.wav" );
MoveShoppingKartWindow();
RefreshGold();
RefreshWeight();
}
m_pGameManager->PostMsgAtDynamic( new SIMSG_SHOW_UIWINDOW( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_SHOPKART, bOpen ) );
}
void* SUIShopWnd::Perform( KID id, KArg& msg )
{
_CID( UI_BEGIN_DRAG );
_CID( UI_SEND_DROP );
if ( id == id_UI_BEGIN_DRAG )
{
KUIBeginDragMessage* pBeginMsg = static_cast<KUIBeginDragMessage*>( &msg );
const char* szControlID = pBeginMsg->sDragControlID.c_str();
KUIWnd* pWnd = GetChild( szControlID );
if( NULL != pWnd )
{
// 구입 상태인 경우
if( IsBuyMode() )
{
SShopSlot* pSlot = GetSlotBuyItem( GetSlotControlNum(szControlID) );
if( NULL != pSlot )
{
m_pDisplayInfo->SetUIDragInfo( new SUIShopBuyItemDragInfo( pSlot->GetItemCode() ) );
m_pDragAndDropIcon->SetStateIcon( pWnd->GetSprName(), pWnd->GetAniName(), pWnd->GetFrameIndex(), STATE_NORMAL );
pBeginMsg->pDragAndDropRenderer = m_pDragAndDropIcon;
}
}
// 판매 상태인 경우
else
{
SInventorySlot* pSlot = GetSlotSellItem( GetSlotControlNum(szControlID) );
if( NULL != pSlot )
{
m_pDisplayInfo->SetUIDragInfo( new SUIShopSellItemDragInfo( pSlot->GetHandle() ) );
m_pDragAndDropIcon->SetStateIcon( pWnd->GetSprName(), pWnd->GetAniName(), pWnd->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( NULL != pUIDragInfo )
{
// Drag & Drop 정보 제거
m_pDisplayInfo->SetUIDragInfo();
}
return NULL;
}
return SUIWnd::Perform( id, msg );
}
void SUIShopWnd::PumpUpMessage( LPCSTR lpszControlID, DWORD nMessage, DWORD lparam, DWORD wparam )
{
switch( nMessage )
{
case KUI_MESSAGE::KICON_PRESSING:
{
int nInvenIndex = IsBuyMode()
? GetSlotBuyItemIndex( GetSlotControlNum( lpszControlID ) )
: GetSlotSellItemIndex( GetSlotControlNum( lpszControlID ) );
if( (-1) != nInvenIndex )
{
if( m_nSlotStartIndex <= nInvenIndex && nInvenIndex < (m_nSlotStartIndex + m_nSlotCountY) )
{
m_nCurrentSelect = nInvenIndex;
RefreshSelection();
}
}
if( ::_stricmp( lpszControlID, GetID() ) != 0 && (m_bCtrlKey || m_bShiptKey) )
SelectItemSendToKart();
}
break;
case KUI_MESSAGE::KICON_DBLCLK:
{
//m_pGameManager->PlaySound( "iconClick_iconmove_target.wav" );
if( ::_stricmp( lpszControlID, GetID() ) != 0 && (!m_bCtrlKey && !m_bShiptKey) )
SelectItemSendToKart();
}
break;
case KUI_MESSAGE::KBUTTON_CLICK:
{
if( 0 == ::_stricmp( lpszControlID, "button_tokart" ) )
SelectItemSendToKart();
else if( 0 == ::_stricmp( lpszControlID, "button_close" ) )
m_pGameManager->PostMsgAtDynamic( new SIMSG_SHOW_UIWINDOW( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_SHOP, false ) );
m_pGameManager->PostMsgAtDynamic( new SIMSG_SHOW_UIWINDOW( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_INPUTNUMBER, false ) );
}
break;
case KUI_MESSAGE::KSCROLL_SELECT:
{
m_nSlotStartIndex = int(lparam);
RefreshSlots();
RefreshSelection();
}
break;
case KUI_MESSAGE::KCHECK_CHANGE:
{
if( 0 == ::_stricmp( lpszControlID, "button_sell" ) )
{
KUIControlButtonCheck* pBtnSell = dynamicCast<KUIControlButtonCheck*>(GetChild("button_sell"));
KUIControlButtonCheck* pBtnBuy = dynamicCast<KUIControlButtonCheck*>(GetChild("button_buy"));
if( !pBtnSell || !pBtnBuy ) return;
if( pBtnBuy->GetCheck() && pBtnSell->GetCheck() )
{
pBtnBuy->SetCheck( !pBtnSell->GetCheck() );
RefreshItems();
SetBuyModeShoppingKartWindow();
}
else
{ //변동 없음
pBtnSell->SetCheck( true );
}
}
else if( 0 == ::_stricmp( lpszControlID, "button_buy" ) )
{
KUIControlButtonCheck* pBtnSell = dynamicCast<KUIControlButtonCheck*>(GetChild("button_sell"));
KUIControlButtonCheck* pBtnBuy = dynamicCast<KUIControlButtonCheck*>(GetChild("button_buy"));
if( !pBtnSell || !pBtnBuy ) return;
if( pBtnSell->GetCheck() && pBtnBuy->GetCheck() )
{
pBtnSell->SetCheck( !pBtnBuy->GetCheck() );
RefreshItems();
SetBuyModeShoppingKartWindow();
}
else
{ //변동 없음
pBtnBuy->SetCheck( true );
}
}
}
break;
case KUI_MESSAGE::KTAB_SELECT:
{
/* if( 0 == ::_stricmp( lpszControlID, c_szTabTradeMode ) )
{
RefreshItems();
SetBuyModeShoppingKartWindow();
}
else */if( 0 == ::_stricmp( lpszControlID, c_szTabItemCategory ) )
{
KUISimpleTabControl* pTabItemCategory = dynamicCast<KUISimpleTabControl*>(GetChild( lpszControlID ));
if( pTabItemCategory != NULL )
{
switch( pTabItemCategory->GetSelectedItem() )
{
case 0: m_CurrentCategory = UI_ITEM_ALL; break;
case 1: m_CurrentCategory = UI_ITEM_EQUIP; break;
case 2: m_CurrentCategory = UI_ITEM_CARD; break;
case 3: m_CurrentCategory = UI_ITEM_EXPEND; break;
case 4: m_CurrentCategory = UI_ITEM_ETC; break;
}
RefreshItems();
}
}
}
break;
case KUI_MESSAGE::KGENWND_RESIZE:
{
int nDelta = GetRect().GetHeight() - static_cast<int>(wparam);
KUIWnd * pOutfram = GetChild( "outframe" );
if( pOutfram )
{
KRect rcChild = pOutfram->GetRect();
rcChild.bottom += nDelta;
pOutfram->Resize( rcChild );
}
KUIWnd * pInfram = GetChild( "inframe" );
if( pInfram )
{
KRect rcChild = pInfram->GetRect();
rcChild.bottom += nDelta;
pInfram->Resize( rcChild );
}
RefreshScrollBar();
RefreshSlots();
RefreshSelection();
MoveShoppingKartWindow();
}
break;
case KUI_MESSAGE::KGENWND_MOVE:
{
LimitMoveWnd();
MoveShoppingKartWindow();
}
break;
}
SUIWnd::PumpUpMessage( lpszControlID, nMessage, lparam, wparam );
}
void SUIShopWnd::ProcMsgAtStatic( SGameMessage* pMsg )
{
switch( pMsg->nType )
{
case MSG_UPDATE_ITEM_COUNT:
case MSG_ITEM_DESTROY:
case MSG_ITEM_INVEN:
case MSG_ITEM_WEAR_INFO:
case MSG_SKILLCARD_INFO:
case MSG_BELT_SLOT_INFO: /// 2011.05.13 - prodongi
if( !IsBuyMode() && IsShow() )
{
RefreshItems();
}
break;
case MSG_MARKET:
{
//KUISimpleTabControl* pTabTradeMode = (KUISimpleTabControl*)GetChild( c_szTabTradeMode );
//if( NULL != pTabTradeMode ) pTabTradeMode->SetSelectedItem( 0 );
KUIControlButtonCheck* pBtnSell = dynamicCast<KUIControlButtonCheck*>(GetChild("button_sell"));
KUIControlButtonCheck* pBtnBuy = dynamicCast<KUIControlButtonCheck*>(GetChild("button_buy"));
if( pBtnSell ) pBtnSell->SetCheck( false );
if( pBtnBuy ) pBtnBuy->SetCheck( true );
KUISimpleTabControl* pTabItemCategory = dynamicCast<KUISimpleTabControl*>(GetChild( c_szTabItemCategory ));
if( NULL != pTabItemCategory )
{
pTabItemCategory->SetSelectedItem( 0 );
m_CurrentCategory = UI_ITEM_ALL;
}
RefreshItems();
SetBuyModeShoppingKartWindow();
}
break;
case IMSG_UI_INPUTNUMBER:
{
SIMSG_UI_INPUTNUMBER* pInputNumberMsg = (SIMSG_UI_INPUTNUMBER*)pMsg;
if( IsBuyMode() )
{
if( 0 <= m_nCurrentSelect && m_nCurrentSelect < m_vecBuyItemList.size() )
{
if( pInputNumberMsg->m_nValue > 0 )
m_pGameManager->PostMsgAtDynamic( new SIMSG_UI_SHOP_BUYITEM_TOKART( m_vecBuyItemList[ m_nCurrentSelect ]->GetItemCode(), pInputNumberMsg->m_nValue ) );
}
}
else
{
if( 0 <= m_nCurrentSelect && m_nCurrentSelect < m_vecSellItemList.size() )
{
if( pInputNumberMsg->m_nValue > 0 )
m_pGameManager->PostMsgAtDynamic( new SIMSG_UI_SHOP_SELLITEM_TOKART( m_vecSellItemList[ m_nCurrentSelect ]->GetHandle(), pInputNumberMsg->m_nValue ) );
}
}
}
break;
case IMSG_HOTKEY_EX:
{
SIMSG_HOTKEY_EX* pHotKey = dynamicCast<SIMSG_HOTKEY_EX*>(pMsg);
if( pHotKey->wParam == VK_CONTROL )
m_bCtrlKey = (pHotKey->bUp == 0);
if( pHotKey->wParam == VK_SHIFT )
m_bShiptKey = (pHotKey->bUp == 0);
if( pHotKey->wParam == VK_MENU )
{
bool bPreState = m_bAltKey;
m_bAltKey = (pHotKey->bUp == 0);
if( bPreState != m_bAltKey && IsShow() )
{
RefreshSlots();
}
}
}
break;
}
}
void SUIShopWnd::RefreshGold()
{
KUIWnd* pWnd = GetChild("static_rupy_value");
__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>";
if (NULL != pWnd)
{
std::string strGold = "<right>";
strGold += S(6425);
strGold += strString;
strGold += CStringUtil::GetCommaNumberString(nGold);
pWnd->SetCaption(strGold.c_str());
}
}
//void SUIShopWnd::RefreshGold()
//{
// KUIWnd* pWnd = GetChild( "static_rupy_value" );
//
// if( NULL != pWnd )
// {
// std::string strGold = "<right>";
// strGold += S(6425);
// strGold += CStringUtil::GetCommaNumberString( m_PlayerInfoMgr.GetPlayerInfo().GetGold().getAmount() );
//
// pWnd->SetCaption( strGold.c_str() );
// }
//}
void SUIShopWnd::RefreshWeight()
{
float fInvenWeight = m_PlayerInfoMgr.GetPlayerInfo().GetInvenWeigth();
int nMaxWeight = m_PlayerInfoMgr.GetPlayerInfo().GetWeight();
float fWeightRatio = fInvenWeight / float(nMaxWeight) * 100.f;
KUIWnd* pWnd = GetChild( "static_weight_value" );
if( NULL != pWnd )
{
std::string strWeight = CStringUtil::StringFormat( "%s<right>%d%% (", S(6425), int(fWeightRatio) );
strWeight += CStringUtil::GetCommaNumberString( fInvenWeight );
strWeight += "/";
strWeight += CStringUtil::GetCommaNumberString( nMaxWeight );
strWeight += ")";
pWnd->SetCaption( strWeight.c_str() );
}
}
void SUIShopWnd::RefreshScrollBar()
{
KUIControlVScroll* pScrollBar = dynamicCast<KUIControlVScroll*>(GetChild( c_szScrollInven ));
if( NULL != pScrollBar )
{
KRect rcScrollBar = pScrollBar->GetRectWithBtn();
rcScrollBar.top = (GetRect().top + m_nScrollBarTopOffset );
rcScrollBar.bottom = (GetRect().bottom + m_nScrollBarBottomOffset);
m_nSlotCountY = (rcScrollBar.bottom - rcScrollBar.top) / c_nInvenWndResizeUnitY + 1;
if( m_nSlotCountY > c_nMaxShopSlotCount ) m_nSlotCountY = c_nMaxShopSlotCount;
int nLineCount = int(IsBuyMode() ? m_vecBuyItemList.size() : m_vecSellItemList.size()) - 1;
if( 0 > nLineCount ) nLineCount = 0;
int nScrollRange = (nLineCount - m_nSlotCountY) + 1;
if( 0 > nScrollRange ) nScrollRange = 0;
pScrollBar->Resize( rcScrollBar );
pScrollBar->SetMaxRange( DWORD(nScrollRange + 1) );
m_nSlotStartIndex = pScrollBar->GetPosition();
}
}
void SUIShopWnd::RefreshSlots()
{
// 구입 상태인 경우
if( IsBuyMode() )
{
for( int nSlot( 0 ); nSlot < c_nMaxShopSlotCount/*m_nSlotCountY*/; ++nSlot )
{
KUIControlMultiIcon* pItemIconControl = dynamicCast<KUIControlMultiIcon*>(GetChild( m_pSlotControlIDs[ nSlot ].strIconControl.c_str() ));
KUIWnd* pItemNameControl = GetChild( m_pSlotControlIDs[ nSlot ].strStaticNameControl.c_str() );
KUIWnd* pItemCountControl = GetChild( m_pSlotControlIDs[ nSlot ].strStaticCountControl.c_str() );
KUIWnd* pItemPriceControl = GetChild( m_pSlotControlIDs[ nSlot ].strStaticPriceControl.c_str() );
KUIWnd* pItemUnitControl = GetChild( m_pSlotControlIDs[ nSlot ].strStaticUnitControl.c_str() );
if( pItemCountControl ) pItemCountControl->SetShow(false); //보여질 필요 없음
if( nSlot >= m_nSlotCountY )
{
if( pItemIconControl ) pItemIconControl->SetShow(false);
if( pItemNameControl ) pItemNameControl->SetShow(false);
// if( pItemCountControl ) pItemCountControl->SetShow(false);
if( pItemPriceControl ) pItemPriceControl->SetShow(false);
if( pItemUnitControl ) pItemUnitControl->SetShow(false);
continue;
}
if( NULL != pItemIconControl && NULL != pItemNameControl && NULL != pItemCountControl && NULL != pItemPriceControl && NULL != pItemUnitControl )
{
ResetMultiIcon( pItemIconControl, 0, 10 ); ///icon test
SShopSlot* pSlot = GetSlotBuyItem( nSlot );
if( NULL != pSlot )
{
if( pItemIconControl ) pItemIconControl->SetShow(true);
if( pItemNameControl ) pItemNameControl->SetShow(true);
if( pItemPriceControl ) pItemPriceControl->SetShow(true);
if( pItemUnitControl ) pItemUnitControl->SetShow(true);
const ItemBaseEx_info* rItemBase = GetItemDB().GetItemData( pSlot->GetItemCode() );
unsigned char byItemLevel = (ItemBase::TYPE_ARMOR == rItemBase->nType) ? rItemBase->level : 0;
// sonador 3.9.5 상점 판매 크리처 봉인 카드 켑션 수정
ItemBase::BaseFlag baseFlag;
baseFlag.CopyFrom( &rItemBase->status_flag );
int soket[ ItemBase::MAX_SOCKET_NUMBER ];
::memset( soket, 0, sizeof( soket ) );
//!!!!
/// 2011.08.03 - prodongi
if (!setSkillCardIcon(pItemIconControl, pSlot->GetItemCode()))
{
// 채워진 슬롯
pItemIconControl->SetIcon( 0, c_szDEF_SPR_NAME, GetItemDB().GetIconName(pSlot->GetItemCode()) );
////2010.01.19. 아이템내구도처리sfreer - 상점에선 '파괴' 인걸 팔진 않겠지..??;
pItemIconControl->SetIcon( 2, c_szDEF_SPR_NAME, NULL);
}
pItemIconControl->SetIcon( 1, c_szDEF_SPR_NAME, NULL );
EquipItemAddtionalIconSetter icon_setter( pItemIconControl, pSlot->GetItemCode(), rItemBase->enhance, rItemBase->nEthereal_durability, baseFlag );
// 상점 크루샵 아이템의 스텟 보이게 수정
// 2009-03-02: hunee
pItemIconControl->SetTooltip( m_pDisplayInfo->GetItemTooltipText(
pSlot->GetItemCode(),
true,
rItemBase->enhance,
byItemLevel,
baseFlag,
rItemBase->available_time,
soket,
0,
0,
0,
0,
0,
0,
0,
true,
0,
rItemBase->nEndurance,
0,
rItemBase->nSummonId,
0
).c_str()
);
if( m_bAltKey )
{
m_pDisplayInfo->SetComparableEquipItemSubTooltip( pItemIconControl, pSlot->GetItemCode() );
}
pItemNameControl->SetCaption( CStringUtil::StringFormat( "<size:10><#fbe6ad><b>%s", m_pDisplayInfo->GetItemName( pSlot->GetItemCode(), true, rItemBase->enhance, byItemLevel, baseFlag ).c_str() ).c_str() );
setBuyItemPriceCaption(pSlot, count_t(1), pItemPriceControl);
setBuyItemUnitCaption(pSlot, pItemUnitControl);
}
else
{
// 빈 슬롯
pItemIconControl->SetIcon( 0, c_szDEF_SPR_NAME, c_szStaticItemBG );
pItemIconControl->SetIcon( 1, c_szDEF_SPR_NAME, c_szStaticItemBG );
pItemIconControl->SetIcon( 2 );
pItemIconControl->SetIcon( 3 );
pItemIconControl->SetTooltip();
pItemNameControl->SetCaption( "" );
pItemCountControl->SetShow(false);
pItemPriceControl->SetCaption( "" );
pItemUnitControl->SetShow(false);
}
}
}
}
// 판매 상태인 경우
else
{
for( int nSlot( 0 ); nSlot < c_nMaxShopSlotCount/*m_nSlotCountY*/; ++nSlot )
{
KUIControlMultiIcon* pItemIconControl = dynamicCast<KUIControlMultiIcon*>(GetChild( m_pSlotControlIDs[ nSlot ].strIconControl.c_str() ));
KUIWnd* pItemNameControl = GetChild( m_pSlotControlIDs[ nSlot ].strStaticNameControl.c_str() );
KUIWnd* pItemCountControl = GetChild( m_pSlotControlIDs[ nSlot ].strStaticCountControl.c_str() );
KUIWnd* pItemPriceControl = GetChild( m_pSlotControlIDs[ nSlot ].strStaticPriceControl.c_str() );
KUIWnd* pItemUnitControl = GetChild( m_pSlotControlIDs[ nSlot ].strStaticUnitControl.c_str() );
if( nSlot >= m_nSlotCountY )
{
if( pItemIconControl ) pItemIconControl->SetShow(false);
if( pItemNameControl ) pItemNameControl->SetShow(false);
if( pItemCountControl ) pItemCountControl->SetShow(false);
if( pItemPriceControl ) pItemPriceControl->SetShow(false);
if( pItemUnitControl ) pItemUnitControl->SetShow(false);
continue;
}
if( NULL != pItemIconControl && NULL != pItemNameControl && NULL != pItemCountControl && NULL != pItemPriceControl && NULL != pItemUnitControl )
{
ResetMultiIcon( pItemIconControl, 0, 10 ); ////icon test
SInventorySlot* pSlot = GetSlotSellItem( nSlot );
if( NULL != pSlot )
{
if( pItemIconControl ) pItemIconControl->SetShow(true);
if( pItemNameControl ) pItemNameControl->SetShow(true);
if( pItemCountControl ) pItemCountControl->SetShow(true);
if( pItemPriceControl ) pItemPriceControl->SetShow(true);
if( pItemUnitControl ) pItemUnitControl->SetShow(true);
setSellItemUnitCaption(pItemUnitControl);
// 채워진 슬롯
// 2010.07.06 - prodongi
//pItemIconControl->SetIcon( 0, c_szDEF_SPR_NAME, GetItemDB().GetIconName(pSlot->GetItemCode()) );
/// 2011.08.03 - prodongi
if( !setSkillCardIcon(pItemIconControl, pSlot->GetItemCode()) && !setSummonCardIcon( pItemIconControl, pSlot ) )
{
std::string iconName;
getIconNameAtDurability(pSlot, iconName);
pItemIconControl->SetIcon(0, c_szDEF_SPR_NAME, iconName.c_str());
pItemIconControl->SetIcon(2, c_szDEF_SPR_NAME, NULL);
pItemIconControl->SetIcon(3, c_szDEF_SPR_NAME, NULL);
/// 빈카 표시 - prodongi
//gmpbigsun( 20130225 ) 빈카드 표시 제거예정
//if( GetItemDB().GetUseType(pSlot->GetItemCode()) == ItemBase::TYPE_CARD )
//{
// if( GetItemDB().GetGroup( pSlot->GetItemCode() ) == ItemBase::GROUP_SUMMONCARD )
// {
// bool isSummon = pSlot->GetXFlag().IsOn( ItemInstance::ITEM_FLAG_SUMMON );
// if (!isSummon)
// {
// /// 2011.06.29 빈카드 표시 - prodongi
// pItemIconControl->SetIcon( 2, c_szDEF_SPR_NAME, "common_mark_titanium_empty_card");
// }
// }
//}
}
pItemIconControl->SetIcon( 1, c_szDEF_SPR_NAME, pSlot->GetXFlag().IsOn( ItemInstance::ITEM_FLAG_CARD ) ? "static_common_useunitcardicon" : NULL );
EquipItemAddtionalIconSetter icon_setter( pItemIconControl, pSlot );
// 상점 크루샵 아이템의 스텟 보이게 수정
// 2009-03-02: hunee
pItemIconControl->SetLazyTooltip( new rp::KLazyItemTooltip( *m_pDisplayInfo, pSlot, true ) );
if( m_bAltKey )
{
m_pDisplayInfo->SetComparableEquipItemSubTooltip( pItemIconControl, pSlot );
}
pItemNameControl->SetCaption( CStringUtil::StringFormat( "<size:10><#fbe6ad><b>%s", m_pDisplayInfo->GetItemName(pSlot->GetItemCode(), true, pSlot->GetEnhance(), pSlot->GetLevel(), pSlot->GetXFlag()).c_str() ).c_str() );
pItemCountControl->SetShow( GetItemDB().IsJoin( pSlot->GetItemCode(), IsInstanceUnstackable( pSlot ) ) ? pSlot->GetItemCount().getAmount() : 0 );
pItemCountControl->SetCaption( CStringUtil::StringFormat( "<shadow><right>%I64d", GetItemDB().IsJoin( pSlot->GetItemCode(), IsInstanceUnstackable( pSlot ) ) ? pSlot->GetItemCount().getAmount() : 0 ).c_str() );
// 2010.07.14 - prodongi
pItemPriceControl->SetCaption( CStringUtil::StringFormat( "<size:10><right>%s", CStringUtil::GetCommaNumberString( m_pDisplayInfo->GetItemSellPrice(pSlot->GetItemCode(), pSlot->GetLevel(), pSlot->isExhausted()).getAmount() ).c_str() ).c_str() );
//pItemPriceControl->SetCaption( CStringUtil::StringFormat( "<size:10><right>%s", CStringUtil::GetCommaNumberString( m_pDisplayInfo->GetItemSellPrice(pSlot->GetItemCode(), pSlot->GetLevel()).getAmount() ).c_str() ).c_str() );
}
else
{
// 빈 슬롯
pItemIconControl->SetIcon( 0, c_szDEF_SPR_NAME, c_szStaticItemBG );
pItemIconControl->SetIcon( 1, c_szDEF_SPR_NAME, c_szStaticItemBG );
pItemIconControl->SetTooltip();
pItemNameControl->SetCaption( "" );
pItemCountControl->SetShow( false );
pItemPriceControl->SetCaption( "" );
pItemUnitControl->SetShow(false);
}
}
}
}
}
void SUIShopWnd::RefreshSelection()
{
KUIWnd* pSelectIcon = GetChild( "icon_select_over" );
KUIWnd* pSelectOver = GetChild( "static_select_over" );
KUIWnd* pSelectBG = GetChild( "static_select_over_back" );
if( NULL != pSelectIcon && NULL != pSelectOver && NULL != pSelectBG )
{
if( 0 <= m_nCurrentSelect && m_nCurrentSelect < (IsBuyMode() ? m_vecBuyItemList.size() : m_vecSellItemList.size()) )
{
int nSlot = (m_nCurrentSelect - m_nSlotStartIndex);
if( 0 <= nSlot && nSlot < m_nSlotCountY && nSlot < c_nMaxShopSlotCount )
{
KUIWnd* pItemIconControl = GetChild( m_pSlotControlIDs[ nSlot ].strIconControl.c_str() );
if( NULL != pItemIconControl )
{
const KRect& rIconRect = pItemIconControl->GetRect();
pSelectIcon->MovePos( rIconRect.left /*+ c_nIconSelectionCorrectX*/, rIconRect.top /*+ c_nIconSelectionCorrectY*/ );
pSelectOver->MovePos( rIconRect.left /*+ c_nNameSelectinCorrectX*/, rIconRect.top - 3 );
pSelectBG->MovePos( rIconRect.left /*+ c_nNameSelectinCorrectX*/, rIconRect.top - 3 );
pSelectIcon->SetShow( true );
pSelectOver->SetShow( true );
pSelectBG->SetShow( true );
}
}
else
{
pSelectIcon->SetShow( false );
pSelectOver->SetShow( false );
pSelectBG->SetShow( false );
}
}
else
{
m_nCurrentSelect = (-1);
pSelectIcon->SetShow( false );
pSelectOver->SetShow( false );
pSelectBG->SetShow( false );
}
}
}
namespace
{
struct BuyItemRankCompareFN
{
bool operator() ( SShopSlot *pr1, SShopSlot *pr2 )
{
return pr1->GetItemRank() < pr2->GetItemRank();
}
};
}
void SUIShopWnd::RefreshItems()
{
m_nCurrentSelect = (-1);
if( IsBuyMode() )
{
m_InventoryMgr.GetShopDataList( m_CurrentCategory, m_vecBuyItemList );
//빼달라고 요청됨.
// std::sort( m_vecBuyItemList.begin(), m_vecBuyItemList.end(), BuyItemRankCompareFN() );
}
else
{
/// 2010.11.24 카드의 장착 여부도 체크해야 됨 - prodongi
m_InventoryMgr.GetInvenDataList( m_CurrentCategory, m_vecSellItemList, m_CreatureSlotMgr, true, true );
//m_InventoryMgr.GetInvenDataList( m_CurrentCategory, m_vecSellItemList, true, true );
}
KUIControlVScroll* pScrollBar = dynamicCast<KUIControlVScroll*>(GetChild( c_szScrollInven ));
if( NULL != pScrollBar )
{
m_nSlotStartIndex = 0;
pScrollBar->SetPosition( 0 );
}
RefreshScrollBar();
RefreshSlots();
RefreshSelection();
}
void SUIShopWnd::SelectItemSendToKart()
{
int nItemCode(0);
if( IsBuyMode() )
{
if( 0 <= m_nCurrentSelect && m_nCurrentSelect < m_vecBuyItemList.size() )
{
nItemCode = m_vecBuyItemList[ m_nCurrentSelect ]->GetItemCode();
if( m_bShiptKey && GetItemDB().IsJoin( nItemCode, false ) )
m_pGameManager->PostMsgAtDynamic( new SIMSG_UI_REQ_INPUTNUMBER( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_SHOP, count_t( 1 ) ));//, SIMSG_UI_REQ_INPUTNUMBER::TYPE_NUMBER ) );
else if( m_bCtrlKey && GetItemDB().IsJoin( nItemCode, false ) ) //10개씩 증가
m_pGameManager->PostMsgAtDynamic( new SIMSG_UI_SHOP_BUYITEM_TOKART( m_vecBuyItemList[ m_nCurrentSelect ]->GetItemCode(), count_t( 10 ) ) );
else // 구입할 아이템 즉시 추가
m_pGameManager->PostMsgAtDynamic( new SIMSG_UI_SHOP_BUYITEM_TOKART( m_vecBuyItemList[ m_nCurrentSelect ]->GetItemCode(), count_t( 1 ) ) );
//if( GetItemDB().IsJoin( nItemCode ) )
//{
// m_pGameManager->PostMsgAtDynamic( new SIMSG_UI_REQ_INPUTNUMBER( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_SHOP, 1 ));//, SIMSG_UI_REQ_INPUTNUMBER::TYPE_NUMBER ) );
//}
//else // 구입할 아이템 즉시 추가
// m_pGameManager->PostMsgAtDynamic( new SIMSG_UI_SHOP_BUYITEM_TOKART( m_vecBuyItemList[ m_nCurrentSelect ]->GetItemCode(), 1 ) );
}
}
else
{
if( 0 <= m_nCurrentSelect && m_nCurrentSelect < m_vecSellItemList.size() )
{
SInventorySlot* pSlot = m_vecSellItemList[ m_nCurrentSelect ];
if( NULL == pSlot )
return;
nItemCode = pSlot->GetItemCode();
const XFlag<int> vFlages = pSlot->GetXFlag();
count_t ItemCount = pSlot->GetItemCount();
if( ItemCount < 1 )
return;
if( m_bShiptKey && GetItemDB().IsJoin( nItemCode, IsInstanceUnstackable( vFlages ) ) )
m_pGameManager->PostMsgAtDynamic( new SIMSG_UI_REQ_INPUTNUMBER( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_SHOP, ItemCount ));//, SIMSG_UI_REQ_INPUTNUMBER::TYPE_NUMBER ) );
else if( m_bCtrlKey && GetItemDB().IsJoin( nItemCode, IsInstanceUnstackable( vFlages ) ) ) //10개씩 증가
{
count_t nMin = std::min( count_t( 10 ), ItemCount );
m_pGameManager->PostMsgAtDynamic( new SIMSG_UI_SHOP_SELLITEM_TOKART( m_vecSellItemList[ m_nCurrentSelect ]->GetHandle(), nMin ) );
}
else //아이템 즉시 추가
m_pGameManager->PostMsgAtDynamic( new SIMSG_UI_SHOP_SELLITEM_TOKART( m_vecSellItemList[ m_nCurrentSelect ]->GetHandle(), count_t( 1 ) ) );
/*
if( ItemCount > 1 && GetItemDB().IsJoin( nItemCode ) )
{
m_pGameManager->PostMsgAtDynamic( new SIMSG_UI_REQ_INPUTNUMBER( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_SHOP, ItemCount ));//, SIMSG_UI_REQ_INPUTNUMBER::TYPE_NUMBER ) );
}
else if( ItemCount == 1 ) // 구입할 아이템 즉시 추가
m_pGameManager->PostMsgAtDynamic( new SIMSG_UI_SHOP_SELLITEM_TOKART( m_vecSellItemList[ m_nCurrentSelect ]->GetHandle(), 1 ) );
else //여기 들어오는 것 자체가 이상한거다. 아이템이 없는데 어떻게 파니...
{}
*/
}
}
m_pGameManager->StartSound( m_pDisplayInfo->GetMaterialSound( GetItemDB().GetMaterial( nItemCode ) ) );
}
void SUIShopWnd::MoveShoppingKartWindow()
{
m_pGameManager->PostMsgAtDynamic( new SIMSG_UI_MOVE( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_SHOPKART, GetRect().right, GetRect().bottom ) );
}
void SUIShopWnd::SetBuyModeShoppingKartWindow()
{
m_pGameManager->PostMsgAtDynamic( new SIMSG_UI_SHOP_BUYMODECHANGE( IsBuyMode() ) );
}
int SUIShopWnd::GetSlotSellItemIndex( int nSlotControlNum ) const
{
if( 0 <= nSlotControlNum && nSlotControlNum < c_nMaxShopSlotCount )
{
int nInvenIndex = (nSlotControlNum + m_nSlotStartIndex);
if( 0 <= nInvenIndex && nInvenIndex < m_vecSellItemList.size() )
return nInvenIndex;
}
return (-1);
}
int SUIShopWnd::GetSlotBuyItemIndex( int nSlotControlNum ) const
{
if( 0 <= nSlotControlNum && nSlotControlNum < c_nMaxShopSlotCount )
{
int nInvenIndex = (nSlotControlNum + m_nSlotStartIndex);
if( 0 <= nInvenIndex && nInvenIndex < m_vecBuyItemList.size() )
return nInvenIndex;
}
return (-1);
}
SInventorySlot* SUIShopWnd::GetSlotSellItem( int nSlotControlNum ) const
{
int nInvenIndex = GetSlotSellItemIndex( nSlotControlNum );
return ((-1) != nInvenIndex) ? m_vecSellItemList[ nInvenIndex ] : NULL;
}
SShopSlot* SUIShopWnd::GetSlotBuyItem( int nSlotControlNum ) const
{
int nInvenIndex = GetSlotBuyItemIndex( nSlotControlNum );
return ((-1) != nInvenIndex) ? m_vecBuyItemList[ nInvenIndex ] : NULL;
}
bool SUIShopWnd::IsBuyMode() const
{
KUIControlButtonCheck* pBtnBuy = dynamicCast<KUIControlButtonCheck*>(GetChild("button_buy"));
if( !pBtnBuy ) return false;
return pBtnBuy->GetCheck();
}
int SUIShopWnd::GetSlotControlNum( const char* szSlotControlID ) const
{
for( int nIndex( 0 ); nIndex < c_nMaxShopSlotCount; ++nIndex )
{
if( 0 == ::_stricmp( m_pSlotControlIDs[ nIndex ].strIconControl.c_str(), szSlotControlID ) )
return nIndex;
}
return (-1);
}
namespace
{
const char* c_szStaticWt = "static_wt";
const char* c_szStaticRupy = "static_rupy";
};
SUIShopKartWnd::SUIShopKartWnd( SGameManager* pGameManager, SUIDisplayInfo* pDisplayInfo )
: SUIWnd( pGameManager ), m_pDisplayInfo( pDisplayInfo )
, m_nSlotStartIndex( 0 )
, m_bIsShop( true )
, m_bBuyMode( true )
, m_ReserveState( KART_NO_RESERVE )
, m_ReserveBuyItemID( 0 )
, m_ReserveSellItemHandle( NULL )
, m_bCtrlKey(false)
, m_bShiptKey(false)
, m_nCurrentSelect(-1)
, m_bAct(FALSE)
, m_PrevProcessTime(0)
{
m_pSlotControlIDs = new SLOT_INFO[ c_nMaxKartSlotCount ];
for( int n( 0 ); n < c_nMaxKartSlotCount; ++n )
{
std::string strNum = CStringUtil::StringFormat( "%02d", n );
m_pSlotControlIDs[ n ].strIconControl = c_szIconControl + strNum;
m_pSlotControlIDs[ n ].strStaticNameControl = c_szStaticNameControl + strNum;
m_pSlotControlIDs[ n ].strStaticCountControl = c_szStaticCountControl + strNum;
m_pSlotControlIDs[ n ].strStaticPriceControl = c_szStaticPriceControl + strNum;
m_pSlotControlIDs[ n ].strStaticUnitControl = c_szStaticUnitControl + strNum;
}
}
SUIShopKartWnd::~SUIShopKartWnd()
{
delete [] m_pSlotControlIDs;
}
bool SUIShopKartWnd::InitControls( KPoint kPos )
{
//// 슬롯 icon 툴팁 스프라이트 설정, 클릭 영역 보정
//for( int nSlot( 0 ); nSlot < c_nMaxKartSlotCount; ++nSlot )
//{
// KUIControl* pItemIconControl = (KUIControl*)GetChild( m_pSlotControlIDs[ nSlot ].strIconControl.c_str() );
// if( NULL != pItemIconControl )
// pItemIconControl->SetCorrectionRect( KRect( 0, 0, c_nItemIconCorrection, 0 ) );
//}
{
RECT rc;
rc.left = 0; rc.top = c_nInvenWndResizeUnitY; rc.right = 0; rc.bottom = c_nInvenWndResizeUnitY;
int n = 0;
for( n = 0; n < c_nMaxKartSlotCount-1; n++ )
{
CopyControl( CStringUtil::StringFormat("icon_item%02d" , n).c_str(), CStringUtil::StringFormat("icon_item%02d" , n+1).c_str(), rc );
CopyControl( CStringUtil::StringFormat("static_item%02d" , n).c_str(), CStringUtil::StringFormat("static_item%02d" , n+1).c_str(), rc );
CopyControl( CStringUtil::StringFormat("static_itemcount%02d" , n).c_str(), CStringUtil::StringFormat("static_itemcount%02d" , n+1).c_str(), rc );
CopyControl( CStringUtil::StringFormat("static_price%02d" , n).c_str(), CStringUtil::StringFormat("static_price%02d" , n+1).c_str(), rc );
CopyControl( CStringUtil::StringFormat("text_unit%02d" , n).c_str(), CStringUtil::StringFormat("text_unit%02d" , n+1).c_str(), rc );
}
for( n = 0; n < c_nMaxKartSlotCount; n++ )
{
KUIControlMultiIcon* pIcon = dynamicCast<KUIControlMultiIcon*>(GetChild( CStringUtil::StringFormat("icon_item%02d" , n).c_str() ));
if( pIcon )
{
pIcon->SetIconLayer( 10 );
pIcon->SetCorrectionRect( KRect( 0, 0, 200, 0 ) );
}
}
}
SetChildCaption( c_szStaticWt, GetStringDB().GetString( STRING_WT ) );
SetChildCaption( c_szStaticRupy, GetStringDB().GetString( STRING_ITEMBUSINESSSHOP_TEXT ) );
return SUIWnd::InitControls( kPos );
}
bool SUIShopKartWnd::InitData( bool bReload )
{
SetChildShow( "static_select_over_back", false );
SetChildShow( "static_select_over" , false );
SetChildShow( "icon_select_over" , false );
SetChildAsTop( "icon_select_over" );
return SUIWnd::InitData(bReload);
}
void SUIShopKartWnd::OnNotifyUIWindowOpen( bool bOpen, bool bLimitWnd )
{
SUIWnd::OnNotifyUIWindowOpen(bOpen);
if( bOpen )
{
m_bAct = FALSE;
m_KartBuyItemsVector.clear();
m_KartSellItemsVector.clear();
RefreshSlots();
RefreshGoldAndWeight();
}
}
void* SUIShopKartWnd::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();
KUIWnd* pWnd = GetChild( szControlID );
if( NULL != pWnd )
{
int nKartItemIndex = IsBuyMode()
? GetSlotKartBuyItemIndex( GetSlotControlNum( szControlID ) )
: GetSlotKartSellItemIndex( GetSlotControlNum( szControlID ) );
if( (-1) != nKartItemIndex )
{
m_pDisplayInfo->SetUIDragInfo( new SUIShoppingKartDragInfo( IsBuyMode(), nKartItemIndex ) );
m_pDragAndDropIcon->SetStateIcon( pWnd->GetSprName(), pWnd->GetAniName(), pWnd->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( NULL != pUIDragInfo )
{
// 동일한 창이 아닌 곳에 드롭했다면
if( pSendMsg->sRecvDropParentID != std::string(GetID()) )
{
if( SUIDragInfo::DRAGTYPE_SHOPPINGKART == pUIDragInfo->m_type )
{
SUIShoppingKartDragInfo* pShopKartDragInfo = (SUIShoppingKartDragInfo*)pUIDragInfo;
if( pShopKartDragInfo->m_bBuyMode )
{
// 구입할 아이템을 찾아서 제거한다.
RemoveBuyItem( pShopKartDragInfo->m_nIndex );
}
else
{
// 판매할 아이템을 찾아서 제거한다.
RemoveSellItem( pShopKartDragInfo->m_nIndex );
}
}
}
// 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( NULL != pUIDragInfo )
{
switch( pUIDragInfo->m_type )
{
case SUIDragInfo::DRAGTYPE_BOOTH:
{
}
break;
case SUIDragInfo::DRAGTYPE_SHOPBUYITEM:
{
SUIShopBuyItemDragInfo* pBuyItemDragInfo = (SUIShopBuyItemDragInfo*)pUIDragInfo;
AddBuyItem( pBuyItemDragInfo->m_ItemID, count_t( 1 ) ); // 구입할 아이템 즉시 추가
m_pGameManager->StartSound( m_pDisplayInfo->GetDragMaterialSound() );
}
break;
case SUIDragInfo::DRAGTYPE_SHOPSELLITEM:
{
SUIShopSellItemDragInfo* pSellItemDragInfo = (SUIShopSellItemDragInfo*)pUIDragInfo;
SInventorySlot* pSlot = m_InventoryMgr.GetItemInfo( pSellItemDragInfo->m_hItem );
if( NULL != pSlot )
{
// 중첩 가능한 아이템인 경우
//if( GetItemDB().IsJoin( pSlot->GetItemCode() ) )
//{
// if( 1 < pSlot->GetItemCount() )
// {
// // 판매 예약한 후 숫자입력 윈도우를 호출한다.
// m_ReserveState = KART_SELLITEM_RESERVE;
// m_ReserveSellItemHandle = pSlot->GetHandle();
// int nSellMaxCount = (pSlot->GetItemCount() < c_nBuySellCountLimit) ? pSlot->GetItemCount() : c_nBuySellCountLimit;
// m_pGameManager->PostMsgAtDynamic( new SIMSG_UI_REQ_INPUTNUMBER( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_SHOPKART, nSellMaxCount ));//, SIMSG_UI_REQ_INPUTNUMBER::TYPE_NUMBER ) );
// }
// else
// AddSellItem( pSlot->GetHandle(), 1, -1 ); // 판매할 아이템 즉시 추가
//}
//else
AddSellItem( pSlot->GetHandle(), count_t( 1 ), -1 ); // 판매할 아이템 즉시 추가
m_pGameManager->StartSound( m_pDisplayInfo->GetDragMaterialSound() );
}
}
break;
}
}
return NULL;
}
return SUIWnd::Perform( id, msg );
}
void SUIShopKartWnd::PumpUpMessage( LPCSTR lpszControlID, DWORD nMessage, DWORD lparam, DWORD wparam )
{
switch( nMessage )
{
case KUI_MESSAGE::KICON_PRESSING:
{
int nIndex = GetSlotControlNum( lpszControlID );
if( nIndex != -1 )
{
KUIWnd * pWnd = GetChild( lpszControlID );
if( pWnd )
{
KUIWnd * pWnd01 = GetChild( "static_select_over_back" );
KUIWnd * pWnd02 = GetChild( "static_select_over" );
KUIWnd * pWnd03 = GetChild( "icon_select_over" );
const KRect& rIconRect = pWnd->GetRect();
if( pWnd01 ) { pWnd01->MovePos( rIconRect.left , rIconRect.top - 3 ); pWnd01->SetShow(true); }
if( pWnd02 ) { pWnd02->MovePos( rIconRect.left , rIconRect.top - 3 ); pWnd02->SetShow(true); }
if( pWnd03 ) { pWnd03->MovePos( rIconRect.left , rIconRect.top ); pWnd03->SetShow(true); }
}
}
else
{
SetChildShow( "static_select_over_back", false );
SetChildShow( "static_select_over" , false );
SetChildShow( "icon_select_over" , false );
}
int nInvenIndex = IsBuyMode()
? GetSlotKartBuyItemIndex( GetSlotControlNum( lpszControlID ) )
: GetSlotKartSellItemIndex( GetSlotControlNum( lpszControlID ) );
if( (-1) != nInvenIndex )
{
if( m_nSlotStartIndex <= nInvenIndex && nInvenIndex < (m_nSlotStartIndex + c_nMaxKartSlotCount) )
m_nCurrentSelect = nInvenIndex;
}
if( m_bCtrlKey || m_bShiptKey )
{
if( IsBuyMode() )
RemoveBuyItem( nInvenIndex );
else RemoveSellItem( nInvenIndex );
}
}
break;
case KUI_MESSAGE::KBUTTON_CLICK:
{
if( 0 == ::_stricmp( lpszControlID, c_szButtonBuySell ) )
{
if( IsBuyMode() )
ShopBuyOrder(); // 구입
else
ShopSellOrder(); // 판매
}
}
break;
case KUI_MESSAGE::KICON_DBLCLK:
{
//m_pGameManager->PlaySound( "iconClick_iconmove_target.wav" );
if( !m_bCtrlKey && !m_bShiptKey )
{
int nInvenIndex(-1);
if( IsBuyMode() )
{
nInvenIndex = GetSlotKartBuyItemIndex( GetSlotControlNum( lpszControlID ) );
RemoveBuyItem( nInvenIndex );
}
else
{
nInvenIndex = GetSlotKartSellItemIndex( GetSlotControlNum( lpszControlID ) );
RemoveSellItem( nInvenIndex );
}
}
}
break;
case KUI_MESSAGE::KSCROLL_SELECT:
{
m_nSlotStartIndex = int(lparam);
RefreshSlots();
}
break;
}
SUIWnd::PumpUpMessage( lpszControlID, nMessage, lparam, wparam );
}
void SUIShopKartWnd::ProcMsgAtStatic( SGameMessage* pMsg )
{
switch( pMsg->nType )
{
case IMSG_UI_SEND_DATA:
{
if( static_cast< SIMSG_UI_SEND_DATA* >( pMsg )->m_strString == "set_booth_mode" )
{
m_bIsShop = !static_cast< SIMSG_UI_SEND_DATA* >( pMsg )->m_nNumber;
}
if( static_cast< SIMSG_UI_SEND_DATA* >( pMsg )->m_strString == "shopkart_clear" )
{
m_KartBuyItemsVector.clear();
m_KartSellItemsVector.clear();
RefreshSlots();
RefreshGoldAndWeight();
}
break;
}
case MSG_UPDATE_ITEM_COUNT:
case MSG_ITEM_DESTROY:
case MSG_ITEM_INVEN:
case MSG_ITEM_WEAR_INFO:
case MSG_BELT_SLOT_INFO: /// 2011.05.13 - prodongi
if( !IsBuyMode() )
{
bool bRemoved = false;
KARTSELLITEM_VECTOR::iterator itItem = m_KartSellItemsVector.begin();
while( itItem != m_KartSellItemsVector.end() )
{
SInventorySlot* pSlot = m_InventoryMgr.GetItemInfo( (*itItem).handle );
/// 2011.05.13 벨트 슬롯 체크 - prodongi
if( pSlot && !pSlot->IsEquipItem() && !m_InventoryMgr.IsBeltSlotCard((*itItem).handle) )
{
// 카트에 올려놓은 양보다 실제 인벤아이템의 양이 줄어있는 경우
if( pSlot->GetItemCount() < (*itItem).nItemCount )
(*itItem).nItemCount = pSlot->GetItemCount();
// 존재하고 장착하지 않은 것은 그대로 유지
itItem++;
}
else
{
// 없어졌거나 장착된 아이템은 카트에서 제거한다.
itItem = m_KartSellItemsVector.erase( itItem );
bRemoved = true;
}
}
if( bRemoved )
{
RefreshSlots();
RefreshGoldAndWeight();
RefreshScrollBar();
}
}
break;
case MSG_MARKET:
RemoveAllKartItems();
break;
// 카트에 담기
case IMSG_UI_STORE_BUYITEM_TOKART:
{
m_bIsShop = false;
m_bBuyMode = true;
SIMSG_UI_STORE_BUYITEM_TOKART* pBuyToKartMsg = (SIMSG_UI_STORE_BUYITEM_TOKART*)pMsg;
AddBuyItem(
KART_BUYITEM(
pBuyToKartMsg->m_ItemInfo.Code,
pBuyToKartMsg->m_ItemInfo.summon_id,
pBuyToKartMsg->m_byCount,
pBuyToKartMsg->m_ItemInfo.enhance,
pBuyToKartMsg->m_ItemInfo.level,
pBuyToKartMsg->m_ItemInfo.Flag,
pBuyToKartMsg->m_ItemInfo.endurance,
pBuyToKartMsg->m_ItemInfo.socket,
pBuyToKartMsg->m_nIndex,
pBuyToKartMsg->m_ItemInfo.remain_time,
pBuyToKartMsg->m_ItemInfo.elemental_effect_type,
pBuyToKartMsg->m_ItemInfo.elemental_effect_remain_time,
pBuyToKartMsg->m_ItemInfo.elemental_effect_attack_point,
pBuyToKartMsg->m_ItemInfo.elemental_effect_magic_point,
pBuyToKartMsg->m_ItemInfo.ethereal_durability,
0,
&(pBuyToKartMsg->m_ItemInfo.awakenoption),
&(pBuyToKartMsg->m_ItemInfo.random_option)
)
);
}
break;
case IMSG_UI_STORE_SELLITEM_TOKART:
{
m_bIsShop = false;
m_bBuyMode = false;
SIMSG_UI_STORE_SELLITEM_TOKART* pSellToKartMsg = (SIMSG_UI_STORE_SELLITEM_TOKART*)pMsg;
AddSellItem( pSellToKartMsg->m_hItem, pSellToKartMsg->m_byCount, pSellToKartMsg->m_nIndex );
}
break;
case IMSG_UI_SHOP_BUYITEM_TOKART:
{
m_bIsShop = true;
m_bBuyMode = true;
SIMSG_UI_SHOP_BUYITEM_TOKART* pBuyToKartMsg = (SIMSG_UI_SHOP_BUYITEM_TOKART*)pMsg;
AddBuyItem( pBuyToKartMsg->m_ItemID, pBuyToKartMsg->m_byCount );
}
break;
case IMSG_UI_SHOP_SELLITEM_TOKART:
{
m_bIsShop = true;
m_bBuyMode = false;
SIMSG_UI_SHOP_SELLITEM_TOKART* pSellToKartMsg = (SIMSG_UI_SHOP_SELLITEM_TOKART*)pMsg;
AddSellItem( pSellToKartMsg->m_hItem, pSellToKartMsg->m_byCount, -1 );
}
break;
case IMSG_UI_INPUTNUMBER:
{
SIMSG_UI_INPUTNUMBER* pInputNumberMsg = (SIMSG_UI_INPUTNUMBER*)pMsg;
if( pInputNumberMsg->m_nValue > 0 )
{
count_t nValue = (pInputNumberMsg->m_nValue < c_nBuySellCountLimit) ? pInputNumberMsg->m_nValue : count_t( c_nBuySellCountLimit );
switch( m_ReserveState )
{
case KART_BUYITEM_RESERVE:
{
//AddBuyItem( m_ReserveBuyItemID, nValue );
RemoveBuyItem(m_nCurrentSelect, nValue);
}
break;
case KART_SELLITEM_RESERVE:
{
//AddSellItem( m_ReserveSellItemHandle, nValue, -1 );
RemoveSellItem(m_nCurrentSelect, nValue);
}
break;
}
}
m_ReserveState = KART_NO_RESERVE;
}
break;
case MSG_PROPERTY:
{
SMSG_PROPERTY* pPropertyMsg = (SMSG_PROPERTY*)pMsg;
if( m_PlayerInfoMgr.IsLocalPlayer(pPropertyMsg->handle) )
{
switch( pPropertyMsg->nPropertyType )
{
case SMSG_PROPERTY::PROPERTY_WEIGHT:
RefreshGoldAndWeight();
break;
}
}
}
break;
case MSG_RESULT:
{
SMSG_RESULT* pResultMsg = (SMSG_RESULT*)pMsg;
int nGroupID = -1;
switch( pResultMsg->request_msg_id )
{
case TM_CS_BUY_FROM_BOOTH:
if( pResultMsg->result == RESULT_SUCCESS )
RemoveAllKartItems();
break;
case TM_CS_SELL_TO_BOOTH:
if( pResultMsg->result == RESULT_SUCCESS )
RemoveAllKartItems();
break;
}
}
break;
case IMSG_UI_MOVE:
{
SIMSG_UI_MOVE* pMoveMsg = (SIMSG_UI_MOVE*)pMsg;
MovePos( pMoveMsg->m_nX, pMoveMsg->m_nY - GetRect().GetHeight() );
pMsg->bUse = true;
}
break;
case IMSG_UI_SHOP_BUYMODECHANGE:
{
m_bBuyMode = ((SIMSG_UI_SHOP_BUYMODECHANGE*)pMsg)->m_bBuyMode;
RemoveAllKartItems();
pMsg->bUse = true;
}
break;
case IMSG_HOTKEY_EX:
{
SIMSG_HOTKEY_EX* pHotKey = dynamicCast<SIMSG_HOTKEY_EX*>(pMsg);
if( pHotKey->wParam == VK_CONTROL )
m_bCtrlKey = (pHotKey->bUp == 0);
if( pHotKey->wParam == VK_SHIFT )
m_bShiptKey = (pHotKey->bUp == 0);
if( pHotKey->wParam == VK_MENU )
{
bool bPreState = m_bAltKey;
m_bAltKey = (pHotKey->bUp == 0);
if( bPreState != m_bAltKey && IsShow() )
{
RefreshSlots();
}
}
}
break;
case IMSG_UI_STORE_SELL_WARNING:
{
SIMSG_UI_STORE_SELL_WARNING* pSellWarning = dynamicCast<SIMSG_UI_STORE_SELL_WARNING*>(pMsg);
if( !pSellWarning->bOK )
ShopSellbyUser();
}
break;
}
}
SUIShopKartWnd::KARTBUYITEM_VECTOR::iterator SUIShopKartWnd::GetBuyItem( ItemBase::ItemCode ItemID )
{
for( KARTBUYITEM_VECTOR::iterator itKartBuy = m_KartBuyItemsVector.begin(); itKartBuy != m_KartBuyItemsVector.end(); itKartBuy++ )
if( (*itKartBuy).ItemID == ItemID ) return itKartBuy;
return m_KartBuyItemsVector.end();
}
SUIShopKartWnd::KARTSELLITEM_VECTOR::iterator SUIShopKartWnd::GetSellItem( AR_HANDLE hItem )
{
for( KARTSELLITEM_VECTOR::iterator itKartSell = m_KartSellItemsVector.begin(); itKartSell != m_KartSellItemsVector.end(); itKartSell++ )
if( (*itKartSell).handle == hItem ) return itKartSell;
return m_KartSellItemsVector.end();
}
void SUIShopKartWnd::CheckWeightOver( int nItemCode, count_t& nItemCnt )
{
money_t nTotalPrice;
float fTotalWeight;
GetTotalPriceAndWeight( nTotalPrice, fTotalWeight );
fTotalWeight += m_PlayerInfoMgr.GetPlayerInfo().GetInvenWeigth();
int nMaxWeight = m_PlayerInfoMgr.GetPlayerInfo().GetWeight();
float fExtraWeight(0.0f);
if( !IsShop() ) fExtraWeight = (float)nMaxWeight*0.9f - fTotalWeight; //노점만 90%
else fExtraWeight = (float)nMaxWeight*1.0f - fTotalWeight;
if( fExtraWeight <= 0 )
{
if( !IsShop() ) //노점일때만 메세지 출력
m_pGameManager->PostMsgAtDynamic( new SIMSG_REQ_OPEN_MSGBOX(SIMSG_REQ_OPEN_MSGBOX::MSGBOX_STORE_WEIGHT_OVER, S(952), true) );
nItemCnt = count_t( 0 );
return;
}
// if( !IsShop() ) //노점일때만 메세지 출력
{
float fItemWeight = GetItemDB().GetWeight( nItemCode );
float fInputItemWeight = fItemWeight * nItemCnt.getAmount();
if( fInputItemWeight > fExtraWeight )
{
nItemCnt = count_t( fExtraWeight / fItemWeight );
std::string strErr = SR( 951, "#@item_count@#", nItemCnt.getAmount() );
m_pGameManager->PostMsgAtDynamic( new SIMSG_REQ_OPEN_MSGBOX(SIMSG_REQ_OPEN_MSGBOX::MSGBOX_STORE_WEIGHT_OVER, strErr.c_str(), true) );
}
}
}
void SUIShopKartWnd::AddBuyItem( const KART_BUYITEM & itemInfo )
{
if( 0 == itemInfo.ItemID ) return;
KART_BUYITEM ResultItemInfo = itemInfo;
if( IsBuyMode() ) CheckWeightOver( itemInfo.ItemID, ResultItemInfo.nItemCount );
if( ResultItemInfo.nItemCount == 0 ) return;
// 중첩 가능한 아이템인 경우
if( GetItemDB().IsJoin( itemInfo.ItemID, false ) )
{
KARTBUYITEM_VECTOR::iterator itKartBuy = GetBuyItem( itemInfo.ItemID );
if( m_KartBuyItemsVector.end() != itKartBuy )
{
// 기존 아이템의 갯수를 증가시킨다.
count_t nTotalCount = (*itKartBuy).nItemCount + ResultItemInfo.nItemCount;
if( nTotalCount > c_nBuySellCountLimit ) nTotalCount = count_t( c_nBuySellCountLimit );
(*itKartBuy).nItemCount = nTotalCount;
RefreshSlots();
RefreshGoldAndWeight();
return;
}
}
// 이미 있는 아이템이면 KIN
if( itemInfo.nIndex != -1 )
{
for( KARTBUYITEM_VECTOR::iterator itKartBuy = m_KartBuyItemsVector.begin(); itKartBuy != m_KartBuyItemsVector.end(); itKartBuy++ )
{
if( (*itKartBuy).nIndex == itemInfo.nIndex ) return;
}
}
// 카트에 추가
m_KartBuyItemsVector.push_back( ResultItemInfo );
RefreshSlots();
RefreshGoldAndWeight();
RefreshScrollBar();
}
void SUIShopKartWnd::AddBuyItem( ItemBase::ItemCode ItemID, count_t nItemCount )
{
const ItemBaseEx_info* ItemInfo = GetItemDB().GetItemData( ItemID );
if (!ItemInfo)
return ;
// sonador 3.9.5 상점 판매 크리처 봉인 카드 켑션 수정
int nItemFlag = 0;
if( ItemInfo )
nItemFlag = ItemInfo->status_flag;
//sfreer 상점 및 카트에 담긴 아이템 비정상적인 수치출력관련 버그 수정 2009.03.05
AddBuyItem( KART_BUYITEM( ItemID, ItemInfo->nSummonId, nItemCount, ItemInfo->enhance, ItemInfo->level, nItemFlag, 0, NULL, -1 ) );
}
void SUIShopKartWnd::RemoveBuyItem( int nIndex )
{
if( 0 <= nIndex && nIndex < int(m_KartBuyItemsVector.size()) )
{
int nitemID(0);
// 카트에서 삭제
if( m_KartBuyItemsVector[nIndex].nItemCount > 1 )
{
if( m_bShiptKey )
{
m_ReserveState = KART_BUYITEM_RESERVE;
m_ReserveBuyItemID = m_KartBuyItemsVector[nIndex].ItemID;
nitemID = m_KartBuyItemsVector[nIndex].ItemID;
count_t nMaxCount = m_KartBuyItemsVector[nIndex].nItemCount;
m_pGameManager->PostMsgAtDynamic( new SIMSG_UI_REQ_INPUTNUMBER( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_SHOPKART, nMaxCount ));//, SIMSG_UI_REQ_INPUTNUMBER::TYPE_NUMBER ) );
}
else if( m_bCtrlKey ) //10개씩 증가
{
if( m_KartBuyItemsVector[nIndex].nItemCount > 10 )
m_KartBuyItemsVector[nIndex].nItemCount -= count_t( 10 );
else m_KartBuyItemsVector.erase( m_KartBuyItemsVector.begin() + nIndex );
}
else // 아이템 즉시 추가
m_KartBuyItemsVector[nIndex].nItemCount--;
}
else if( m_KartBuyItemsVector[nIndex].nItemCount == 1 )
m_KartBuyItemsVector.erase( m_KartBuyItemsVector.begin() + nIndex );
else //아이템이 0개인데 어떻게 vector에 등록되있는감...
{}
// m_KartBuyItemsVector.erase( m_KartBuyItemsVector.begin() + nIndex );
RefreshSlots();
RefreshGoldAndWeight();
RefreshScrollBar();
m_pGameManager->StartSound( m_pDisplayInfo->GetMaterialSound( m_pDisplayInfo->GetMaterial_code( nitemID ) ) );
}
}
void SUIShopKartWnd::RemoveBuyItem( int nIndex, count_t nCount )
{
if( 0 <= nIndex && nIndex < int(m_KartBuyItemsVector.size()) )
{
// 카트에서 삭제
if( m_KartBuyItemsVector[nIndex].nItemCount > nCount )
{
m_KartBuyItemsVector[nIndex].nItemCount -= nCount;
}
else if( m_KartBuyItemsVector[nIndex].nItemCount <= nCount )
m_KartBuyItemsVector.erase( m_KartBuyItemsVector.begin() + nIndex );
else //아이템이 0개인데 어떻게 vector에 등록되있는감...
{}
RefreshSlots();
RefreshGoldAndWeight();
RefreshScrollBar();
}
}
void SUIShopKartWnd::AddSellItem( AR_HANDLE hItem, count_t nItemCount, int index )
{
SInventorySlot* pSlot = m_InventoryMgr.GetItemInfo( hItem );
if( NULL != pSlot )
{
// 임시 !!! ... 소환카드는 팔 수 없게 함 .. ( 현재 서버도 임시 처리중 .. )
//if( ItemBase::GROUP_SUMMONCARD != GetItemDB().GetGroup( pItem->nID ) )
//{
count_t SellCount = nItemCount;
//팔고자 하는 아이템수보다 팔려는 아이템이 많으면 안되지...
if( !IsShop() && index != -1 ) //개인상점이 아닌 일반 npc상점에서는 index값이 -1이다.
{
SellCount = SStoreMgr::GetInstance().GetItemCount(index);
nItemCount = ( SellCount < nItemCount ) ? SellCount : nItemCount;
}
// 동일한 아이템이 이미 있는 경우
KARTSELLITEM_VECTOR::iterator itKartSell = GetSellItem( hItem );
if( m_KartSellItemsVector.end() != itKartSell )
{
// 중첩 가능한 아이템인 경우
if( GetItemDB().IsJoin( pSlot->GetItemCode(), IsInstanceUnstackable( pSlot ) ) )
{
// 기존 아이템의 개수를 증가시킨다.
count_t nTotalCount = (*itKartSell).nItemCount + nItemCount;
if( !IsShop() ) //노점에서 사려는 아이템 수보다 많이 팔 수 없으니 체크
if( nTotalCount > SellCount ) nTotalCount = SellCount;
if( nTotalCount > pSlot->GetItemCount() ) nTotalCount = pSlot->GetItemCount(); // 갖고있는 아이템의 전체 갯수보다 커지지 않도록 조정
if( nTotalCount > c_nBuySellCountLimit ) nTotalCount = count_t( c_nBuySellCountLimit );
(*itKartSell).nItemCount = nTotalCount;
RefreshSlots();
RefreshGoldAndWeight();
}
}
// 처음으로 추가하는 경우
else
{
// 중첩 가능한 아이템인 경우
if( GetItemDB().IsJoin( pSlot->GetItemCode(), IsInstanceUnstackable( pSlot ) ) )
{
// 갖고있는 아이템의 전체 갯수보다 커지지 않도록 조정
if( nItemCount > pSlot->GetItemCount() ) nItemCount = pSlot->GetItemCount();
}
else
{
// 한개만 가능
if( nItemCount > 1 ) nItemCount = count_t( 1 );
}
// 카트에 추가
m_KartSellItemsVector.push_back( KART_SELLITEM( hItem, nItemCount, index ) );
RefreshSlots();
RefreshGoldAndWeight();
RefreshScrollBar();
}
//}
//else
// m_pGameManager->PostMsgAtDynamic( new SIMSG_REQ_OPEN_MSGBOX( SIMSG_REQ_OPEN_MSGBOX::MSGBOX_GENERAL, SYS_MSG_INVEN_NOTHROWITEM, true ) );
}
}
void SUIShopKartWnd::RemoveSellItem( int nIndex )
{
if( 0 <= nIndex && nIndex < int(m_KartSellItemsVector.size()) )
{
int nHandle(0);
// 카트에서 삭제
if( m_KartSellItemsVector[nIndex].nItemCount > 1 )
{
if( m_bShiptKey )
{
m_ReserveState = KART_SELLITEM_RESERVE;
m_ReserveSellItemHandle = m_KartSellItemsVector[nIndex].handle;
nHandle = m_KartSellItemsVector[nIndex].handle;
count_t nMaxCount = m_KartSellItemsVector[nIndex].nItemCount;
m_pGameManager->PostMsgAtDynamic( new SIMSG_UI_REQ_INPUTNUMBER( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_SHOPKART, nMaxCount ));//, SIMSG_UI_REQ_INPUTNUMBER::TYPE_NUMBER ) );
}
else if( m_bCtrlKey ) //10개씩 증가
{
if( m_KartSellItemsVector[nIndex].nItemCount > 10 )
m_KartSellItemsVector[nIndex].nItemCount -= count_t( 10 );
else m_KartSellItemsVector.erase( m_KartSellItemsVector.begin() + nIndex );
}
else // 아이템 즉시 추가
m_KartSellItemsVector[nIndex].nItemCount--;
}
else if( m_KartSellItemsVector[nIndex].nItemCount == 1 )
m_KartSellItemsVector.erase( m_KartSellItemsVector.begin() + nIndex );
else //아이템이 0개인데 어떻게 vector에 등록되있는감...
{}
// m_KartSellItemsVector.erase( m_KartSellItemsVector.begin() + nIndex );
RefreshSlots();
RefreshGoldAndWeight();
RefreshScrollBar();
m_pGameManager->StartSound( m_pDisplayInfo->GetMaterialSound( m_pDisplayInfo->GetMaterial( nHandle ) ) );
}
}
void SUIShopKartWnd::RemoveSellItem( int nIndex, count_t nCount )
{
if( 0 <= nIndex && nIndex < int(m_KartSellItemsVector.size()) )
{
// 카트에서 삭제
if( m_KartSellItemsVector[nIndex].nItemCount > nCount )
{
m_KartSellItemsVector[nIndex].nItemCount -= nCount;
}
else if( m_KartSellItemsVector[nIndex].nItemCount <= nCount )
m_KartSellItemsVector.erase( m_KartSellItemsVector.begin() + nIndex );
else //아이템이 0개인데 어떻게 vector에 등록되있는감...
{}
RefreshSlots();
RefreshGoldAndWeight();
RefreshScrollBar();
}
}
void SUIShopKartWnd::RemoveAllKartItems()
{
m_KartBuyItemsVector.clear();
m_KartSellItemsVector.clear();
RefreshSlots();
RefreshGoldAndWeight();
RefreshScrollBar();
m_bAct = FALSE;
}
void SUIShopKartWnd::StoreBuyOrder()
{
// SIMSG_UI_ACT_BUYITEMS_FROM_STORE
if( 0 < m_KartBuyItemsVector.size() )
{
money_t nTotalPrice;
float fTotalWeight;
GetTotalPriceAndWeight( nTotalPrice, fTotalWeight );
if( nTotalPrice <= m_PlayerInfoMgr.GetPlayerInfo().GetGold() )
{
SIMSG_UI_ACT_BUYITEMS buyMsg;
for( KARTBUYITEM_VECTOR::iterator itKartBuy = m_KartBuyItemsVector.begin(); itKartBuy != m_KartBuyItemsVector.end(); itKartBuy++ )
buyMsg.vtBuyItems.push_back( SIMSG_UI_ACT_BUYITEMS::BuyItemInfo( (*itKartBuy).ItemID, (*itKartBuy).nItemCount ) );
m_pGameManager->ProcMsgAtStatic( &buyMsg );
RemoveAllKartItems();
}
else
{
m_pDisplayInfo->AddSystemMessage( S(283), 99 ); // You do not have enough Rupees.
}
}
}
void SUIShopKartWnd::ShopBuyOrder()
{
if( m_KartBuyItemsVector.empty() ) return;
money_t nTotalPrice;
float fTotalWeight;
GetTotalPriceAndWeight( nTotalPrice, fTotalWeight );
if( nTotalPrice > m_PlayerInfoMgr.GetPlayerInfo().GetGold() )
{
m_pDisplayInfo->AddSystemMessage( S(283), 99); // You do not have enough Rupees.
return;
}
if( IsShop() )
{
m_bAct = TRUE;
}
else
{
SIMSG_UI_ACT_BUYITEMS_FROM_STORE msg;
msg.hTarget = SStoreMgr::GetInstance().GetTargetHandle();
for( KARTBUYITEM_VECTOR::iterator itKartBuy = m_KartBuyItemsVector.begin(); itKartBuy != m_KartBuyItemsVector.end(); itKartBuy++ )
{
if( ((*itKartBuy).nIndex != -1) && (*itKartBuy).ItemID && (*itKartBuy).nItemCount.getAmount() )
msg.vList.push_back(
TS_SC_WATCH_BOOTH::TS_BOOTH_ITEM_INFO(
SStoreMgr::GetInstance().GetItemHandle( (*itKartBuy).nIndex ),
(*itKartBuy).ItemID,
(*itKartBuy).nItemCount.getAmount(),
SStoreMgr::GetInstance().GetItemPrice( (*itKartBuy).nIndex ).getAmount(),
(*itKartBuy).nLevel,
(*itKartBuy).nEnhance,
(*itKartBuy).nEndurance,
(*itKartBuy).nFlag,
(*itKartBuy).nSocket,
(*itKartBuy).elemental_effect_type,
(*itKartBuy).elemental_effect_attack_point,
(*itKartBuy).elemental_effect_magic_point,
(*itKartBuy).ethereal_durability,
(*itKartBuy).appearanceCode,
(*itKartBuy).stAwakenOption,
(*itKartBuy).stRandomOption,
(*itKartBuy).nSummonID,
(*itKartBuy).nAdditionalItemEffect // Fraun Sky Accessories 7/12/2025
)
);
}
if( !msg.vList.empty() )
m_pGameManager->ProcMsgAtStatic( &msg );
m_pGameManager->PostMsgAtDynamic( new SIMSG_SHOW_UIWINDOW( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_INPUTNUMBER, false ) );
}
}
void SUIShopKartWnd::ShopSellbyUser()
{
if( IsShop() ) return;
SIMSG_UI_ACT_SELLITEMS_TO_STORE msg;
SIMSG_UI_ACT_SELLITEMS_TO_STORE::SellItemToStoreInfo SellInfo;
for( KARTSELLITEM_VECTOR::iterator itKartSell = m_KartSellItemsVector.begin(); itKartSell != m_KartSellItemsVector.end(); itKartSell++ )
{
SellInfo.target = SStoreMgr::GetInstance().GetTargetHandle();
SellInfo.item_handle = (*itKartSell).handle;
SellInfo.cnt = (*itKartSell).nItemCount;
msg.vList.push_back( SellInfo );
}
if( !msg.vList.empty() )
m_pGameManager->ProcMsgAtStatic( &msg );
}
void SUIShopKartWnd::ShopSellOrder()
{
if( IsShop() )
{
m_bAct = TRUE;
}
else
{
m_pGameManager->PostMsgAtDynamic( new SIMSG_REQ_OPEN_MSGBOX(SIMSG_REQ_OPEN_MSGBOX::MSGBOX_SELL_WARNING, S(6432), false) );
m_pGameManager->PostMsgAtDynamic( new SIMSG_SHOW_UIWINDOW( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_INPUTNUMBER, false ) );
}
}
void SUIShopKartWnd::RefreshScrollBar()
{
KUIControlVScroll* pScrollBar = dynamicCast<KUIControlVScroll*>(GetChild( c_szScrollInven ));
if( NULL != pScrollBar )
{
int nLineCount = int(IsBuyMode() ? m_KartBuyItemsVector.size() : m_KartSellItemsVector.size()) - 1;
if( 0 > nLineCount ) nLineCount = 0;
int nScrollRange = (nLineCount - c_nMaxKartSlotCount) + 1;
if( 0 > nScrollRange ) nScrollRange = 0;
pScrollBar->SetMaxRange( DWORD(nScrollRange + 1) );
m_nSlotStartIndex = pScrollBar->GetPosition();
}
}
void SUIShopKartWnd::Process( DWORD time )
{
if ( m_bAct && ( m_PrevProcessTime == 0 || time - m_PrevProcessTime > 50 ) )
{
//loop
SIMSG_UI_ACT_BUYITEMS buyMsg;
SIMSG_UI_ACT_SELLITEMS SellMsg;
int sz = m_KartBuyItemsVector.size() + m_KartSellItemsVector.size();
if (sz==0)
{ RemoveAllKartItems();
m_pGameManager->PostMsgAtDynamic( new SIMSG_SHOW_UIWINDOW( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_SHOP, false ) );
m_pGameManager->PostMsgAtDynamic( new SIMSG_SHOW_UIWINDOW( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_INPUTNUMBER, false ) );
} else
{
if( !m_KartBuyItemsVector.empty() )
{
KARTBUYITEM_VECTOR::iterator itItem = m_KartBuyItemsVector.begin();
buyMsg.vtBuyItems.push_back( SIMSG_UI_ACT_BUYITEMS::BuyItemInfo( (*itItem).ItemID, (*itItem).nItemCount ) );
itItem = m_KartBuyItemsVector.erase( itItem );
}
if ( !m_KartSellItemsVector.empty() )
{
KARTSELLITEM_VECTOR::iterator itItem = m_KartSellItemsVector.begin();
SellMsg.vtSellItems.push_back( SIMSG_UI_ACT_SELLITEMS::SellItemInfo( (*itItem).handle, (*itItem).nItemCount ) );
itItem = m_KartSellItemsVector.erase( itItem );
}
RefreshSlots();
RefreshGoldAndWeight();
RefreshScrollBar();
if( !buyMsg.vtBuyItems.empty() ) m_pGameManager->ProcMsgAtStatic( &buyMsg );
if( !SellMsg.vtSellItems.empty() ) m_pGameManager->ProcMsgAtStatic( &SellMsg );
}
m_PrevProcessTime = time;
}
}
static void SetItemControl( SUIDisplayInfo* pDisplayInfo,
KUIControlMultiIcon* pIcon,
KUIWnd* pName,
KUIWnd* pCount,
ItemBase::ItemCode nItemCode,
int nLevel,
int nEnhance,
int nFlag,
int remain_time,
int* pLevel,
count_t nCount,
int nSummonID,
char elemental_effect_type = 0,
int elemental_effect_remain_time = 0,
int elemental_effect_attack_point = 0,
int elemental_effect_magic_point = 0,
int ethereal_durability = 0,
int endurance = 0,
int etherealDurability = -1,
TS_ITEM_BASE_INFO::AwakenOption* pAwakenOption = NULL,
TS_ITEM_BASE_INFO::RANDOM_OPTION* pRandomOption = NULL,
int nAdditionalItemEffect = 0) // Fraun Sky Accessories 7/12/2025
{
XFlag<int> itemFlag;
itemFlag.CopyFrom( &nFlag );
const ItemBaseEx_info * pItemBase = GetItemDB().GetItemData( nItemCode );
if( pItemBase == NULL ) return;
// pIcon->SetIcon( 0, c_szDEF_SPR_NAME, (itemFlag.IsOn( ItemInstance::ITEM_FLAG_CARD ) ? "static_common_skillcardicon" : pItemBase->pIcon_name ) );
// 2010.07.06 - prodongi
std::string iconName;
getIconNameAtDurability(nItemCode, nEnhance, etherealDurability, iconName);
//pIcon->SetIcon( 0, c_szDEF_SPR_NAME, pItemBase->pIcon_name );
/// 2011.08.03 - prodongi
if( !setSkillCardIcon(pIcon, nItemCode) && !setSummonCardIcon( pIcon, nItemCode, nSummonID, nEnhance, nFlag, etherealDurability ) )
{
pIcon->SetIcon(0, c_szDEF_SPR_NAME, iconName.c_str());
pIcon->SetIcon(2);
pIcon->SetIcon(3);
pIcon->SetIcon(4);
pIcon->SetIcon(5);
pIcon->SetIcon(6);
pIcon->SetIcon(7);
}
pIcon->SetIcon( 1, c_szDEF_SPR_NAME, itemFlag.IsOn( ItemInstance::ITEM_FLAG_CARD ) ? "static_common_useunitcardicon" : NULL );
EquipItemAddtionalIconSetter icon_setter( pIcon, nItemCode, nEnhance, ethereal_durability, itemFlag );
pIcon->SetTooltip( pDisplayInfo->GetItemTooltipText( nItemCode,
true,
nEnhance,
nLevel,
itemFlag,
remain_time,
pLevel,
0,
0,
0,
elemental_effect_type,
elemental_effect_remain_time,
elemental_effect_attack_point,
elemental_effect_magic_point,
true,
ethereal_durability,
endurance,
0,
nSummonID,
false,
false,
0,
pAwakenOption,
pRandomOption,
0,
nAdditionalItemEffect ).c_str() // Fraun Sky Accessories 7/12/2025
);
pName->SetCaption( CStringUtil::StringFormat( "<size:10><#fbe6ad><b>%s", pDisplayInfo->GetItemName( nItemCode, true, nEnhance, nLevel, itemFlag, false, 0, false, pRandomOption ).c_str() ).c_str() );
if( pCount )
{
if( pItemBase->CheckFlag( ItemBase::FLAG_JOIN ) && !IsInstanceUnstackable(itemFlag) )
{
pCount->SetCaption( CStringUtil::StringFormat( "<RIGHT><shadow>%I64d", (nCount > 0 ) ? nCount.getAmount() : 0 ).c_str() );
pCount->SetShow( ( nCount > 0 ) ? true : false );
}
else
{
pCount->SetShow( false );
}
}
}
void SUIShopKartWnd::RefreshSlots()
{
// 판매/구매하는 수량보다 많이 올렸으면 조절해주자
if( !IsShop() )
{
for( KARTBUYITEM_VECTOR::iterator itKartBuy = m_KartBuyItemsVector.begin(); itKartBuy != m_KartBuyItemsVector.end(); itKartBuy++ )
{
count_t cnt = SStoreMgr::GetInstance().GetItemCount( (*itKartBuy).nIndex );
if( cnt < (*itKartBuy).nItemCount ) (*itKartBuy).nItemCount = cnt;
}
}
// 구입 상태인 경우
if( IsBuyMode() )
{
for( int nSlot( 0 ); nSlot < c_nMaxKartSlotCount; ++nSlot )
{
KUIControlMultiIcon* pItemIconControl = dynamicCast<KUIControlMultiIcon*>(GetChild( m_pSlotControlIDs[ nSlot ].strIconControl.c_str() ));
KUIWnd* pItemNameControl = GetChild( m_pSlotControlIDs[ nSlot ].strStaticNameControl.c_str() );
KUIWnd* pItemCountControl = GetChild( m_pSlotControlIDs[ nSlot ].strStaticCountControl.c_str() );
KUIWnd* pItemPriceControl = GetChild( m_pSlotControlIDs[ nSlot ].strStaticPriceControl.c_str() );
KUIWnd* pItemUnitControl = GetChild( m_pSlotControlIDs[ nSlot ].strStaticUnitControl.c_str() );
if( NULL == pItemIconControl || NULL == pItemNameControl || NULL == pItemCountControl || NULL == pItemPriceControl || NULL == pItemUnitControl ) continue;
ResetMultiIcon( pItemIconControl, 0, 10 ); ////icon test
const SUIShopKartWnd::KART_BUYITEM* pKartBuyItem = GetSlotKartBuyItem( nSlot );
SShopSlot* pSlot = (pKartBuyItem && IsShop()) ? m_InventoryMgr.GetShopItem( pKartBuyItem->ItemID ) : NULL;
if( NULL != pKartBuyItem )
{
const ItemBaseEx_info * pItemBase = GetItemDB().GetItemData( pKartBuyItem->ItemID );
// 채워진 슬롯
int nSocket[ ItemBase::MAX_SOCKET_NUMBER ];
::memcpy(nSocket, &pKartBuyItem->nSocket[0], sizeof(nSocket));
TS_ITEM_BASE_INFO::AwakenOption stAwakenOption;
::memcpy( &stAwakenOption, &pKartBuyItem->stAwakenOption, sizeof(stAwakenOption) );
TS_ITEM_BASE_INFO::RANDOM_OPTION stRandomOption;
::memcpy( &stRandomOption, &pKartBuyItem->stRandomOption, sizeof(stRandomOption) );
SetItemControl( m_pDisplayInfo,
pItemIconControl,
pItemNameControl,
pItemCountControl,
pKartBuyItem->ItemID,
pKartBuyItem->nLevel,
pKartBuyItem->nEnhance,
pKartBuyItem->nFlag,
pKartBuyItem->remain_time,
nSocket,
pKartBuyItem->nItemCount,
pKartBuyItem->nSummonID,
pKartBuyItem->elemental_effect_type,
pKartBuyItem->elemental_effect_remain_time,
pKartBuyItem->elemental_effect_attack_point,
pKartBuyItem->elemental_effect_magic_point,
pKartBuyItem->ethereal_durability,
pKartBuyItem->nEndurance,
-1,
&stAwakenOption,
&stRandomOption,
pKartBuyItem->nAdditionalItemEffect); // Fraun Sky Accessories 7/12/2025
if( m_bAltKey )
{
m_pDisplayInfo->SetComparableEquipItemSubTooltip( pItemIconControl, pKartBuyItem->ItemID );
}
if( IsShop() )
{
setBuyItemPriceCaption(pSlot, pKartBuyItem->nItemCount, pItemPriceControl);
setBuyItemUnitCaption(pSlot, pItemUnitControl);
pItemUnitControl->SetShow(true);
}
}
else
{
// 빈 슬롯
pItemIconControl->SetIcon( 0, c_szDEF_SPR_NAME, c_szStaticItemBG );
pItemIconControl->SetIcon( 1, c_szDEF_SPR_NAME, c_szStaticItemBG );
pItemIconControl->SetIcon( 2 );
pItemIconControl->SetIcon( 3 );
pItemIconControl->SetTooltip();
pItemNameControl->SetCaption( "" );
pItemCountControl->SetShow(false);
pItemPriceControl->SetCaption( "" );
pItemUnitControl->SetShow(false);
}
}
}
// 판매 상태인 경우
else
{
for( int nSlot( 0 ); nSlot < c_nMaxKartSlotCount; ++nSlot )
{
KUIControlMultiIcon* pItemIconControl = dynamicCast<KUIControlMultiIcon*>(GetChild( m_pSlotControlIDs[ nSlot ].strIconControl.c_str() ));
KUIWnd* pItemNameControl = GetChild( m_pSlotControlIDs[ nSlot ].strStaticNameControl.c_str() );
KUIWnd* pItemCountControl = GetChild( m_pSlotControlIDs[ nSlot ].strStaticCountControl.c_str() );
KUIWnd* pItemPriceControl = GetChild( m_pSlotControlIDs[ nSlot ].strStaticPriceControl.c_str() );
KUIWnd* pItemUnitControl = GetChild( m_pSlotControlIDs[ nSlot ].strStaticUnitControl.c_str() );
if( NULL == pItemIconControl || NULL == pItemNameControl || NULL == pItemCountControl || NULL == pItemPriceControl || NULL == pItemUnitControl ) continue;
ResetMultiIcon( pItemIconControl, 0, 10 ); ///icon test
const SUIShopKartWnd::KART_SELLITEM* pKartSellItem = GetSlotKartSellItem( nSlot );
SInventorySlot* pSlot = (NULL != pKartSellItem) ? m_InventoryMgr.GetItemInfo( pKartSellItem->handle ) : NULL;
if( NULL != pKartSellItem && NULL != pSlot )
{
// 채워진 슬롯
SetItemControl( m_pDisplayInfo,
pItemIconControl,
pItemNameControl,
pItemCountControl,
pSlot->GetItemCode(),
pSlot->GetLevel(),
pSlot->GetEnhance(),
*pSlot->GetXFlag().GetRawData(),
pSlot->GetItem()->remain_time,
pSlot->GetItem()->socket,
pKartSellItem->nItemCount,
pSlot->GetSummonID(),
pSlot->GetItem()->elemental_effect_type,
pSlot->GetItem()->elemental_effect_remain_time,
pSlot->GetItem()->elemental_effect_attack_point,
pSlot->GetItem()->elemental_effect_magic_point,
pSlot->GetItem()->ethereal_durability,
pSlot->GetItem()->endurance,
pSlot->GetEtherealDurability(),
pSlot->GetAwakening(),
pSlot->GetRandomOption()
);
if( m_bAltKey )
{
m_pDisplayInfo->SetComparableEquipItemSubTooltip( pItemIconControl, pSlot );
}
if( IsShop() )
{
// 2010.07.14 - prodongi
money_t nPrice = m_pDisplayInfo->GetItemSellPrice(pSlot->GetItemCode(), pSlot->GetLevel(), pSlot->isExhausted()) * pKartSellItem->nItemCount;
//money_t nPrice = m_pDisplayInfo->GetItemSellPrice(pSlot->GetItemCode(), pSlot->GetLevel()) * pKartSellItem->nItemCount;
pItemPriceControl->SetCaption( CStringUtil::StringFormat( "<size:10><right>%s", CStringUtil::GetCommaNumberString( nPrice.getAmount() ).c_str() ).c_str() );
pItemUnitControl->SetShow( true );
setSellItemUnitCaption(pItemUnitControl);
}
EquipItemAddtionalIconSetter icon_setter( pItemIconControl, pSlot );
}
else
{
// 빈 슬롯
pItemIconControl->SetIcon( 0, c_szDEF_SPR_NAME, c_szStaticItemBG );
pItemIconControl->SetIcon( 1, c_szDEF_SPR_NAME, c_szStaticItemBG );
pItemIconControl->SetIcon( 2 );
pItemIconControl->SetIcon( 3 );
pItemIconControl->SetTooltip();
pItemNameControl->SetCaption( "" );
pItemCountControl->SetShow(false);
pItemPriceControl->SetCaption( "" );
pItemUnitControl->SetShow( false );
}
}
}
}
void SUIShopKartWnd::RefreshGoldAndWeight()
{
money_t nTotalPrice;
float fTotalWeight;
GetTotalPriceAndWeight( nTotalPrice, fTotalWeight );
if( IsBuyMode() )
fTotalWeight += m_PlayerInfoMgr.GetPlayerInfo().GetInvenWeigth();
else
fTotalWeight = m_PlayerInfoMgr.GetPlayerInfo().GetInvenWeigth() - fTotalWeight;
KUIWnd* pWndGold = GetChild( "static_rupy_value" );
std::string strGold = " <right>";
strGold += S(6425);
strGold += CStringUtil::GetCommaNumberString( nTotalPrice.getAmount() );
strGold += " ";
if( NULL != pWndGold ) pWndGold->SetCaption( strGold.c_str() );
int nMaxWeight = m_PlayerInfoMgr.GetPlayerInfo().GetWeight();
float fWeightRatio = fTotalWeight / float(nMaxWeight) * 100.f;
KUIWnd* pWndWeight = GetChild( "static_wt_value" );
if( NULL != pWndWeight ) pWndWeight->SetCaption( CStringUtil::StringFormat( " %s<right>%d%% (%d/%d) ", S(6425), int(fWeightRatio), int(fTotalWeight), nMaxWeight ).c_str() );
}
int SUIShopKartWnd::GetSlotKartSellItemIndex( int nSlotControlNum ) const
{
if( 0 <= nSlotControlNum && nSlotControlNum < c_nMaxKartSlotCount )
{
int nInvenIndex = (nSlotControlNum + m_nSlotStartIndex);
if( 0 <= nInvenIndex && nInvenIndex < m_KartSellItemsVector.size() )
return nInvenIndex;
}
return (-1);
}
int SUIShopKartWnd::GetSlotKartBuyItemIndex( int nSlotControlNum ) const
{
if( 0 <= nSlotControlNum && nSlotControlNum < c_nMaxKartSlotCount )
{
int nInvenIndex = (nSlotControlNum + m_nSlotStartIndex);
if( 0 <= nInvenIndex && nInvenIndex < m_KartBuyItemsVector.size() )
return nInvenIndex;
}
return (-1);
}
const SUIShopKartWnd::KART_SELLITEM* SUIShopKartWnd::GetSlotKartSellItem( int nSlotControlNum ) const
{
int nInvenIndex = GetSlotKartSellItemIndex( nSlotControlNum );
return ((-1) != nInvenIndex) ? &m_KartSellItemsVector[ nInvenIndex ] : NULL;
}
const SUIShopKartWnd::KART_BUYITEM* SUIShopKartWnd::GetSlotKartBuyItem( int nSlotControlNum ) const
{
int nInvenIndex = GetSlotKartBuyItemIndex( nSlotControlNum );
return ((-1) != nInvenIndex) ? &m_KartBuyItemsVector[ nInvenIndex ] : NULL;
}
int SUIShopKartWnd::GetSlotControlNum( const char* szSlotControlID ) const
{
for( int nIndex( 0 ); nIndex < c_nMaxKartSlotCount; ++nIndex )
{
if( 0 == ::_stricmp( m_pSlotControlIDs[ nIndex ].strIconControl.c_str(), szSlotControlID ) )
return nIndex;
}
return (-1);
}
void SUIShopKartWnd::GetTotalPriceAndWeight( money_t& rTotalPrice, float& rTotalWeight ) const
{
rTotalPrice = money_t( 0 );
rTotalWeight = 0;
if( IsBuyMode() )
{
for( KARTBUYITEM_VECTOR::const_iterator itKartBuy = m_KartBuyItemsVector.begin(); itKartBuy != m_KartBuyItemsVector.end(); itKartBuy++ )
{
money_t nPrice = money_t( 0 );
if( IsShop() )
{
SShopSlot* pSlot = m_InventoryMgr.GetShopItem( (*itKartBuy).ItemID );
if( !pSlot ) continue;
nPrice = pSlot->GetPrice();
}
else
{
nPrice = SStoreMgr::GetInstance().GetItemPrice( (*itKartBuy).nIndex );
}
float fWeight = GetItemDB().GetWeight( (*itKartBuy).ItemID );
count_t nCount = (*itKartBuy).nItemCount;
rTotalPrice += (nPrice * nCount);
rTotalWeight += (fWeight * nCount.getAmount());
}
}
else
{
for( KARTSELLITEM_VECTOR::const_iterator itKartSell = m_KartSellItemsVector.begin(); itKartSell != m_KartSellItemsVector.end(); itKartSell++ )
{
SInventorySlot* pSlot = m_InventoryMgr.GetItemInfo( (*itKartSell).handle );
if( NULL != pSlot )
{
money_t nPrice(0);
if( IsShop() )
{
// 2010.07.16 - prodongi
nPrice = m_pDisplayInfo->GetItemSellPrice( pSlot->GetItemCode(), pSlot->GetLevel(), pSlot->isExhausted() );
//nPrice = m_pDisplayInfo->GetItemSellPrice( pSlot->GetItemCode(), pSlot->GetLevel() );
}
else
{
int SellListSize( SStoreMgr::GetInstance().GetListCount() );
for( int i(0); i<SellListSize; ++i )
{
if( (*itKartSell).nIndex != -1 )
{
nPrice = SStoreMgr::GetInstance().GetItemPrice((*itKartSell).nIndex);
break;
}
}
}
float fWeight = GetItemDB().GetWeight( pSlot->GetItemCode() );
count_t nCount = (*itKartSell).nItemCount;
rTotalPrice += (nPrice * nCount);
rTotalWeight += (fWeight * nCount.getAmount());
}
}
}
}