#include "stdafx.h"
#include "KUIControlStatic.h"
#include "KUIDragAndDrop.h"
#include "SGameManager.h"
#include "SGameMessage.h"
//#include "SGameMessageUI.h"
#include "SItemDB.h"
#include "SkillBaseFile.h"
#include "SUIStoreWnd.h"
#include "SStringDB.h"
#include "SPlayerInfoMgr.h"
#include "SGameOtherPlayer.h"
#include "SGame.h"
#include "GameRule.h"
#include "ErrorCode/ErrorCode.h"
#include "SInventoryMgr.h"
#include "SUIDisplayInfo.h"
#include "KUIControlEdit.h"
#include "SStoreMgr.h"
#include "SNetMessage.h"
// 2010.06.14 - prodongi
// 2010.07.20 - prodongi
//#include "SUIUtil.h"
#include "SGameInterface.h" // 2012. 2. 21 - marine
#include "SSummonSlotMgr.h"
#include "SUILazyTooltip.h"
#include "SGameSystem.h"
extern SGameSystem * g_pCurrentGameSystem;
const size_t DEFAULT_ADD_COUNT = 8; // 기본적으로 올릴 수 있는 아이템 갯수
static int GetSlotControlNum( const char* szSlotControlID );
static const int SLOT_Y_DELTA = 46; // 슬롯당 거리
static const int INPUT_NUMBER_PRICE_LIMIT = 13;
static const int INPUT_NUMBER_COUNT_LIMIT = 5;
static const int ITEM_MAX_COUNT = 70000; // 아이템 한번에 최고로 거래 가능한 개수
static const unsigned __int64 ITEM_MAX_PRICE = 9223372036854775807; // 아이템 최대 가격
static const char* c_ItemMaxPrice = "9223372036854775807"; // 아이템 최대 가격
static const __int64 PRICE_COLOR_CUT_1 = 1000000000000; // 가격 색갈 나누는 구간 1
static const __int64 PRICE_COLOR_CUT_2 = 100000000000; // 가격 색갈 나누는 구간 2
static const __int64 PRICE_COLOR_CUT_3 = 10000000000; // 가격 색갈 나누는 구간 3
static const __int64 PRICE_COLOR_CUT_4 = 1000000000; // 가격 색갈 나누는 구간 4
static const __int64 PRICE_COLOR_CUT_5 = 100000000; // 가격 색갈 나누는 구간 5
static const __int64 PRICE_COLOR_CUT_6 = 10000000; // 가격 색갈 나누는 구간 6
static const __int64 PRICE_COLOR_CUT_7 = 1000000; // 가격 색갈 나누는 구간 7
const int nLayer = 8;
enum
{
RIGHT = 0,
LEFT = 1,
CENTER = 2,
};
enum
{
START = 0,
CLICK = 1,
LEAVE = 2,
};
const short c_nFillterTagCnt = 12;
const char* c_szFillterTag[] =
{
"
" ,//01
"
" ,//02
"
" ,//03
"
" ,//04
"" ,//05
"" ,//06
"" ,//07
"" ,//08
"" ,//09
"" ,//10
"" ,//11
"" ,//12
};
// { 각 슬롯의 컨트롤에 편하게 접근하기 위해 만든 것들
namespace SLOT_CONTROL_INDEX
{
static const size_t NAME = 0;
static const size_t ICON = 1;
static const size_t INVENCNT = 2;
static const size_t PRICE = 3;
static const size_t COUNT = 4;
static const size_t DISABLE = 5;
};
static char *s_szSlotControlName[ CONTROL_PER_SLOT ]
= {
"booth_itemname_text%02d",
"booth_item_icon%02d",
"booth_static_cnt%02d",
"booth_item_inputgold%02d",
"booth_item_inputnumber%02d",
"booth_disable%02d",
};
static char *s_szSlotControlfilter[ CONTROL_PER_SLOT ]
= {
"booth_itemname_text",
"booth_item_icon",
"booth_static_cnt",
"booth_item_inputgold",
"booth_item_inputnumber",
"booth_disable",
};
// }
std::string getGoldString( money_t nGold, bool bAdddRupy = true )
{
std::string strString = "";
if( nGold >= PRICE_COLOR_CUT_1 ) strString += "<#FF0000>";
else if( nGold >= PRICE_COLOR_CUT_2 ) strString += "<#FF00F3>";
else if( nGold >= PRICE_COLOR_CUT_3 ) strString += "<#FF1493>";
else if( nGold >= PRICE_COLOR_CUT_4 ) strString += "<#00FFFC>";
else if( nGold >= PRICE_COLOR_CUT_5 ) strString += "<#FF8C00>";
else if( nGold >= PRICE_COLOR_CUT_6 ) strString += "<#FFFF00>";
else if( nGold >= PRICE_COLOR_CUT_7 ) strString += "<#4AD55D>";
else strString += "<#FFFFFF>";
strString += CStringUtil::GetCommaNumberString( nGold.getAmount() );
if( bAdddRupy )
{
strString += "<#FFEA00>";
strString += GetStringDB().GetString(6618);//"R";
}
return strString;
}
// 2011. 9 .2 - marine 거래시만 사용되는 함수
std::string getGoldStringInTrade( money_t nGold, bool bAdddRupy = true )
{
std::string strString = "";
if( nGold >= PRICE_COLOR_CUT_1 ) strString += "<#FF0000>";
else if( nGold >= PRICE_COLOR_CUT_2 ) strString += "<#FF00F3>";
else if( nGold >= PRICE_COLOR_CUT_3 ) strString += "<#FF1493>";
else if( nGold >= PRICE_COLOR_CUT_4 ) strString += "<#00FFFC>";
else if( nGold >= PRICE_COLOR_CUT_5 ) strString += "<#FF8C00>";
else if( nGold >= PRICE_COLOR_CUT_6 ) strString += "<#FFFF00>";
else if( nGold >= PRICE_COLOR_CUT_7 ) strString += "<#4AD55D>";
else strString += "<#FFFFFF>";
strString += CStringUtil::GetCommaNumberString( nGold.getAmount() );
if( bAdddRupy )
{
strString += "<#FFEA00>";
strString += GetStringDB().GetString(6618);//"R";
}
return strString;
}
std::string getGoldStringColor( money_t nGold )
{
if( nGold >= money_t( PRICE_COLOR_CUT_1 ) ) return "<#FF0000>";
else if( nGold >= money_t( PRICE_COLOR_CUT_2 ) ) return "<#FF00F3>";
else if( nGold >= money_t( PRICE_COLOR_CUT_3 ) ) return "<#FF1493>";
else if( nGold >= money_t( PRICE_COLOR_CUT_4 ) ) return "<#00FFFC>";
else if( nGold >= money_t( PRICE_COLOR_CUT_5 ) ) return "<#FF8C00>";
else if( nGold >= money_t( PRICE_COLOR_CUT_6 ) ) return "<#FFFF00>";
else if( nGold >= money_t( PRICE_COLOR_CUT_7 ) ) return "<#4AD55D>";
return "<#FFFFFF>";
}
static void SetEditNumText( KUIControlEdit* pEdit, money_t nGold, bool bConvertStr, bool bConvertColor, int Pos, char* pSize )
{
if( pEdit )
{
std::string strString = CStringUtil::StringFormat("%I64d",nGold.getAmount());
pEdit->SetText( strString.c_str() );
strString.clear();
std::string strGoldColor = "<#FFFFFF>";
if( bConvertColor )
strString = strGoldColor = getGoldStringColor(nGold);
if( pSize )
strString += pSize;
if( bConvertStr )
strString += CStringUtil::GetCommaNumberString(nGold.getAmount());
else strString += CStringUtil::StringFormat("%I64d",nGold.getAmount());
if( Pos == RIGHT ) strString += "";
else if( Pos == LEFT ) strString += "";
else if( Pos == CENTER ) strString += "";
pEdit->SetDisableColor( strGoldColor.c_str() );
pEdit->SetCaption( strString.c_str() );
}
}
static void GetEditSlotControl( const char* szSlotControlID, int& rSlotIndex, int& rCtrIndex )
{
for( int nSlotIndex( 0 ); nSlotIndex < MAX_SLOT_COUNT; ++nSlotIndex )
{
for( int nIndex( 0 ); nIndex < CONTROL_PER_SLOT; ++nIndex )
{
if( 0 == ::_stricmp( CStringUtil::StringFormat( s_szSlotControlName[ nIndex ], nSlotIndex ).c_str(), szSlotControlID ) )
{
rSlotIndex = nSlotIndex;
rCtrIndex = nIndex;
return;
}
}
}
}
void OutputBoothTradeMessage( SUIDisplayInfo *pDisplayInfo, const std::string & strTargetName, struct SMSG_BOOTH_TRADE_INFO * pMsg )
{
// Fraun performance tweak
std::string strString;
if( pMsg->bIsSell )
{
strString = GetStringDB().GetString(911);
}
else
{
strString = GetStringDB().GetString(912);
}
for( size_t i = 0; i < pMsg->vList.size(); ++i )
{
TS_ITEM_BASE_INFO & info = pMsg->vList[ i ];
XFlag flag;
flag.CopyFrom( &info.Flag );
std::string strItemName = pDisplayInfo->GetItemName( info.Code, true, info.enhance, info.level, flag );
std::string strResult = SStringDB::ParseString( strString.c_str(), "#@item_name@#", strItemName.c_str(), "#@item_num@#", SStringDB::ToString( info.count ).c_str(), "#@user_name@#", strTargetName.c_str() );
pDisplayInfo->AddSystemMessage( strResult.c_str(), 99 );
}
}
////////////////////////////////////////////////////////////////////////////////////////////
//
// Host wnd
//
SUIStoreHostWnd::SUIStoreHostWnd( SGameManager* pGameManager, SUIDisplayInfo* pDisplayInfo )
: SUIWnd( pGameManager )
, m_pDisplayInfo( pDisplayInfo )
, m_unCount( 0 )
, m_unPrice( 0 )
, m_nMode( MODE_READY_TO_SELL )
, m_nFocus( -1 )
, m_hCurrentDragItem( NULL )
, m_hCurrentAddingItem( NULL )
, m_bItemDrag( false ) //servantes 2010.10.19
{
::memset( m_OldInvenItemList, 0x00, sizeof(m_OldInvenItemList));
}
bool SUIStoreHostWnd::InitControls( KPoint kPos )
{
// 슬롯 컨트롤들 복사
CreateControls();
KUIControl *pControl;
pControl = dynamicCast< KUIControl * >( GetChild( "button_sell" ) );
if( pControl ) { pControl->SetEnableColor( "<#7EBFFC>" ); pControl->SetDisableColor( "<#8E8E8E>" ); }
pControl = dynamicCast< KUIControl * >( GetChild( "button_buy" ) );
if( pControl )
pControl->SetEnableColor( "<#FFEA00>" ); pControl->SetDisableColor( "<#8E8E8E>" );
// 커스텀 윈도우 move 영역 설정
SetCustomMovingRect( KRect( 0, 0, 313, 20 ) );
// { 일단 모든 슬롯이 안보이도록..
for( size_t i = 0; i < MAX_SLOT_COUNT; ++i )
{
KUIControlMultiIcon* pIcon = dynamicCast< KUIControlMultiIcon* >( GetChild( CStringUtil::StringFormat( s_szSlotControlName[ SLOT_CONTROL_INDEX::ICON ], i ).c_str() ) );
if( pIcon )
{
pIcon->SetIconLayer( nLayer );
ResetMultiIcon( pIcon, 0, 8 );
pIcon->SetIcon( 0, c_szDEF_SPR_NAME, "static_common_itemslot" );
}
KUIControlEdit* pEdit(NULL);
pEdit = dynamicCast< KUIControlEdit* >( GetChild( CStringUtil::StringFormat( s_szSlotControlName[ SLOT_CONTROL_INDEX::COUNT ], i ).c_str() ) );
if( pEdit )
{
pEdit->SetOnlyNumber(true);
pEdit->SetLimitation( INPUT_NUMBER_COUNT_LIMIT );
((KUIControl*)pEdit)->Disable();
}
pEdit = dynamicCast< KUIControlEdit* >( GetChild( CStringUtil::StringFormat( s_szSlotControlName[ SLOT_CONTROL_INDEX::PRICE ], i ).c_str() ) );
if( pEdit )
{
pEdit->SetOnlyNumber(true);
pEdit->SetLimitation( INPUT_NUMBER_PRICE_LIMIT );
((KUIControl*)pEdit)->Disable();
}
KUIWnd* pWnd = GetChild( CStringUtil::StringFormat( s_szSlotControlName[ SLOT_CONTROL_INDEX::DISABLE ], i ).c_str() );
if( pWnd ) pWnd->SetShow( i >= DEFAULT_ADD_COUNT );
SetSlotShowMode( i, true );
}
MoveFocus( -1 );
// }
return SUIWnd::InitControls(kPos);
}
bool SUIStoreHostWnd::InitData( bool bReload )
{
// 노점 판매 구매 버튼 초기화
// data Initialize
return SUIWnd::InitData(bReload);
}
void SUIStoreHostWnd::CreateControls()
{
size_t i;
RECT rc = { 0, SLOT_Y_DELTA, 0, SLOT_Y_DELTA };
KUIWnd* pWnd = GetChild("booth_disable00");
if( pWnd )
{
pWnd->MovePos(pWnd->GetRect().left, pWnd->GetRect().top-SLOT_Y_DELTA);
}
for( i = 1; i < MAX_SLOT_COUNT; ++i )
{
CopyControl( CStringUtil::StringFormat( "booth_static_r%02d", i-1).c_str(),
CStringUtil::StringFormat( "booth_static_r%02d", i).c_str(),
rc );
for( size_t x = 0; x < CONTROL_PER_SLOT; ++x )
{
CopyControl( CStringUtil::StringFormat( s_szSlotControlName[x], i-1).c_str(),
CStringUtil::StringFormat( s_szSlotControlName[x], i).c_str(),
rc );
}
}
}
//return -> -1:상점 오픈 불가 / 1:상점오픈가능 / 0:가격 차이 불어보는 메세지 박스의 결과에 따라 오픈
int SUIStoreHostWnd::StartBoothPossibilityCheck()
{
std::string strNoothName = (dynamicCast(GetChild( "edit_booth_name" )))->GetText();
if( strNoothName.size() > 40 )
{
m_pDisplayInfo->AddSystemMessage( S(925), 99); // Your store name is too long. It must be no more than 40 characters.
return -1;
}
if( SStoreMgr::GetInstance().GetListCount() < 1 )
{
m_pDisplayInfo->AddSystemMessage( S(926), 99); // You must have at least 1 item for sale to open a store.
return -1;
}
money_t nInvenGold = m_PlayerInfoMgr.GetPlayerInfo().GetGold();
if( m_nMode == MODE_READY_TO_BUY || m_nMode == MODE_BUYING )
{
money_t nGold(0); float fWeightRate(0);
if( GetPresumptionGoldWeight(nGold, fWeightRate) == false )
{
m_pDisplayInfo->AddSystemMessage( S(910), 99); // You do not have enough RP.
return -1;
}
if( (nGold * money_t( -1 )) > nInvenGold )
{
m_pDisplayInfo->AddSystemMessage( S(910), 99); // You do not have enough RP.
return -1;
}
if( fWeightRate >= 90 )
{
m_pDisplayInfo->AddSystemMessage( S(909), 99); // You will exceed 90% of your max carry weight(WT) after this purchase.
return -1;
}
}
else
{
money_t nGold(0); float fWeightRate(0);
if( GetPresumptionGoldWeight(nGold, fWeightRate) == false || (money_t( ITEM_MAX_PRICE ) - nInvenGold < nGold) )
{
// Wtf is this bullshit???
m_pDisplayInfo->AddSystemMessage( S(521), 99); // You will exceed the rupee limit (2,147,483,647RP) when completing the trade.
return -1;
}
}
int nResult(0);
int nListCnt( SStoreMgr::GetInstance().GetListCount() );
for( int i(0); i -1:컨트롤 포인터 에러 / 1:가격 체크 성공 / 0:가격이 상점가보다 차이 큼
return nResult;
}
return 1;
}
void SUIStoreHostWnd::SendStartBoothMsg()
{
// 상점이름 색 바꾸지 못하게 함. [2015.2.27]
KUIControlEdit* pEdit = (dynamicCast(GetChild( "edit_booth_name" )));
if(NULL == pEdit)
{
return;
}
std::string strBoothName = pEdit->GetText();
TagFillter(strBoothName);
SMSG_UI_BOOTH msg;
//msg.strBoothName = (dynamicCast(GetChild( "edit_booth_name" )))->GetText();
msg.strBoothName = strBoothName;
msg.nBoothType = SMSG_UI_BOOTH::START_BOOTH;
msg.nMode = !SStoreMgr::GetInstance().IsSellMode();
for( size_t idx = 0; idx < SStoreMgr::GetInstance().GetListCount(); ++idx )
{
msg.vItemList.push_back( SStoreMgr::GetInstance().GetItemHandle( idx ) );
msg.vPriceList.push_back( SStoreMgr::GetInstance().GetItemPrice( idx ) );
msg.vCountList.push_back( SStoreMgr::GetInstance().GetItemCount( idx ) );
}
m_pGameManager->ProcMsgAtStatic( &msg );
}
void SUIStoreHostWnd::SendEndBoothMsg()
{
SMSG_UI_BOOTH msg;
msg.nBoothType = SMSG_UI_BOOTH::END_BOOTH;
m_pGameManager->ProcMsgAtStatic( &msg );
}
void SUIStoreHostWnd::OnNotifyUIWindowOpen( bool bOpen, bool bLimitWnd )
{
SUIWnd::OnNotifyUIWindowOpen( bOpen );
if( !bOpen )
{
// 노점 운영중에 닫혔다면 서버에 노점 종료 메세지를 보낸다.
if( IsStarted() )
{
SendEndBoothMsg();
RemoveAllItem(false);
}
}
else
{
//2012. 2. 17 - marine 열린 파괴창, 수리창, 조합창, 강화창 닫기,
m_pGameManager->GetGameInterface()->CloseAgainstUi();
m_pGameManager->StartSound( "ui_popup_window01.wav" );
SwitchStoreMode( MODE_READY_TO_SELL );
KUIControlEdit* pEdit(NULL);
pEdit = dynamicCast< KUIControlEdit* >( GetChild("edit_booth_name") );
if(pEdit) pEdit->SetText( S(946) ); //S(946) "[ 노점 이름을 입력하세요. ]"
}
// 어쨌든 슬롯의 데이터는 무의미하므로 날려 버린다.
SStoreMgr::GetInstance().Clear();
}
void* SUIStoreHostWnd::Perform( KID id, KArg& msg )
{
_CID( UI_BEGIN_DRAG );
_CID( UI_SEND_DROP );
_CID( UI_RECV_DROP );
if ( id == id_UI_BEGIN_DRAG )
{
if( IsStarted() ) return SUIWnd::Perform( id, msg );
m_hCurrentDragItem = NULL;
KUIBeginDragMessage* pBeginMsg = static_cast( &msg );
const char* szControlID = pBeginMsg->sDragControlID.c_str();
m_hCurrentDragItem = SStoreMgr::GetInstance().GetItemHandle( atoi( szControlID + strlen(szControlID)-2 ) );
if( !m_hCurrentDragItem ) return SUIWnd::Perform( id, msg );
KUIControlMultiIcon* pWndMultiIcon = dynamicCast< KUIControlMultiIcon* >( GetChild( szControlID ) );
if( NULL == pWndMultiIcon ) return SUIWnd::Perform( id, msg );
SInventorySlot* pSlot = m_InventoryMgr.GetItemInfo( m_hCurrentDragItem );
const KUIControlMultiIcon::ICON_INFO& rIconInfo = pWndMultiIcon->GetIconInfoByLayer(0);
// TODO : 장비 아이템은 KIN 시켜야 된다.
// { 드랙앤 드롭 정보 세팅
m_pDragAndDropIcon->SetStateIcon( pWndMultiIcon->GetSprName(), rIconInfo.sAniName.c_str(), rIconInfo.nFrameIndex, STATE_NORMAL );
pBeginMsg->pDragAndDropRenderer = m_pDragAndDropIcon;
// }
return NULL;
}
else if ( id == id_UI_SEND_DROP )
{
if( m_hCurrentDragItem )
{
SStoreMgr::GetInstance().RemoveItem( m_hCurrentDragItem );
Refresh();
}
}
else if ( id == id_UI_RECV_DROP )
{
if( SStoreMgr::GetInstance().GetListCount() >= DEFAULT_ADD_COUNT )
return NULL;
if( IsStarted() )
{
m_pDisplayInfo->AddSystemMessage( S(916), 99); // You may not add items while your store is open.
return NULL;
}
KUISendRecvDropMessage* pSendMsg = static_cast( &msg );
SUIDragInfo* pUIDragInfo = m_pDisplayInfo->GetUIDragInfo();
if( !pUIDragInfo || pUIDragInfo->m_type != SUIDragInfo::DRAGTYPE_INVENITEM )
return SUIWnd::Perform( id, msg );
SUIInvenItemDragInfo* pItemDragInfo = static_cast< SUIInvenItemDragInfo* >( pUIDragInfo );
SInventorySlot* pSlot = m_InventoryMgr.GetItemInfo( pItemDragInfo->m_hItem );
if( pSlot == NULL ) return SUIWnd::Perform( id, msg );
/// 2011.05.16 함수로 뺌 - prodongi
if (!isEnableSell(pSlot))
return NULL;
m_hCurrentAddingItem = pItemDragInfo->m_hItem;
m_unPrice = money_t( 0 );
for( int i = 0; i < SStoreMgr::GetInstance().GetListCount(); ++i )
{
if( SStoreMgr::GetInstance().GetItemHandle(i) == m_hCurrentAddingItem )
{
m_pDisplayInfo->AddSystemMessage( S(919), 99); // This item has been put in the store.
return NULL;
}
}
// SIMSG_UI_INPUTNUMBER* pInputNumberMsg = static_cast< SIMSG_UI_INPUTNUMBER* >( pMsg );
// if( pInputNumberMsg->m_nValue < 1 ) break;
// SInventorySlot* pSlot = m_pInvenMgr->GetItemInfo( m_hCurrentAddingItem );
money_t nMarketPrice( m_pDisplayInfo->GetItemSellPrice( pSlot->GetItemCode(), pSlot->GetLevel() ) ); // sonador 3.4.4 환금성 아이템 거래 관련 수정
// 올릴 가격을 받은 경우
// if( !m_unPrice )
// {
// m_unPrice = pInputNumberMsg->m_nValue;
// if( GetItemDB().IsJoin( pSlot->GetItemCode() ) && 1 < pSlot->GetItemCount() )
// {
//이미 등록한 아이템
// m_unCount = 0;
// m_pGameManager->PostMsgAtDynamic( new SIMSG_UI_REQ_INPUTNUMBER( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_STORE_HOST, pSlot->GetItemCount() ) );
// }
// 중첩 불가능한 아이템이거나 갯수가 1개인 경우
// else
{
m_bItemDrag = false; //servantes 2010.10.19
int nCnt = pSlot->GetItemCount().getAmount();
if(nCnt > 1)
{
m_unCount = count_t( nCnt );
if( m_unCount > ITEM_MAX_COUNT )
{
m_unCount = count_t( ITEM_MAX_COUNT );
}
m_pGameManager->PostMsgAtDynamic( new SIMSG_UI_REQ_INPUTNUMBER( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_STORE_HOST, m_unCount ) );
m_bItemDrag = true;
return SUIWnd::Perform( id, msg );
}
else if(nCnt == 1)
{
m_unCount = count_t( 1 );
}
else
{
return NULL; // error
}
AddItem( m_hCurrentAddingItem, pSlot->GetItemCode(), m_unCount, nMarketPrice, pSlot->GetLevel(), pSlot->GetEnhance(), pSlot->GetEndurance(), *pSlot->GetXFlag().GetRawData(), pSlot->GetSocketInfo(), pSlot->GetRemainTime(), pSlot->GetEET(), pSlot->GetEERT(), pSlot->GetEEAP(), pSlot->GetEEMP(), pSlot->GetEtherealDurability(), pSlot->GetItemAppearance(), pSlot->GetAwakening(), pSlot->GetRandomOption(), pSlot->GetSummonID(), pSlot->GetAdditionalItemEffect() ); // Fraun Sky Accessories 7/12/2025
// bintitle. 2011.11.11. 노점에 아이템 등록할때 EditControl활성화 & Sound출력.
AddSaleItem();
}
}
return SUIWnd::Perform( id, msg );
}
void SUIStoreHostWnd::onMsgResult( SMSG_RESULT* pMsg )
{
if( pMsg->request_msg_id == TM_CS_START_BOOTH )
{
if( pMsg->result == RESULT_SUCCESS )
StartBooth();
else
{ // TODO : 노점 개설 실패 창 띄우고 창 다 닫자
}
}
if( pMsg->request_msg_id == TM_CS_STOP_BOOTH )
{
if( pMsg->result == RESULT_SUCCESS )
{
if( SStoreMgr::GetInstance().GetListCount() == 0 )
StopBooth(true);
else StopBooth(false);
}
else
{
}
}
}
void SUIStoreHostWnd::onBoothTradeInfo( struct SMSG_BOOTH_TRADE_INFO * pMsg )
{
if( !IsShow() ) return;
SGameObject * pObject = m_pGameManager->GetActiveGame()->GetGameObject( pMsg->hTarget );
if( pObject )
{
OutputBoothTradeMessage( m_pDisplayInfo,static_cast< SGameOtherPlayer* >( pObject )->GetName(), pMsg );
}
for( size_t i = 0; i < pMsg->vList.size(); ++i )
{
TS_ITEM_BASE_INFO & info = pMsg->vList[ i ];
SStoreMgr::GetInstance().DecItemCount( info.handle, count_t( info.count ) );
}
Refresh();
if( SStoreMgr::GetInstance().GetListCount() == 0 )
SendEndBoothMsg();
}
void SUIStoreHostWnd::onBoothInfo( struct SMSG_BOOTH_INFO *pMsg )
{
/*
if( !IsShow() ) return;
for( size_t idx = 0; idx < pMsg->vList.size(); ++idx )
{
SStoreMgr::GetInstance().SetItemCount( pMsg->vList[idx].handle, pMsg->vList[idx].count );
}
Refresh();
*/
}
void SUIStoreHostWnd::ProcMsgAtStatic( SGameMessage* pMsg )
{
switch( pMsg->nType )
{
case MSG_BOOTH_CLOSED:
//int k;
//k=0;
break;
case IMSG_UI_SEND_DATA:
// 일어서면 노점 중단
if( dynamicCast< SIMSG_UI_SEND_DATA* >( pMsg )->m_strString == "stand_up" )
{
m_pGameManager->PostMsgAtDynamic( new SIMSG_SHOW_UIWINDOW( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_STORE_HOST, false) );
}
break;
case MSG_RESULT:
onMsgResult( dynamicCast< SMSG_RESULT* >( pMsg ) );
break;
case MSG_BOOTH_TRADE_INFO: onBoothTradeInfo( dynamicCast< SMSG_BOOTH_TRADE_INFO * >( pMsg ) ); break;
case MSG_BOOTH_INFO: onBoothInfo( dynamicCast< SMSG_BOOTH_INFO * >( pMsg ) ); break;
case IMSG_UI_INPUTNUMBER:
{
SIMSG_UI_INPUTNUMBER* pInputNumberMsg = dynamicCast< SIMSG_UI_INPUTNUMBER* >( pMsg );
if( pInputNumberMsg->m_nValue < 1 ) break;
SInventorySlot* pSlot = m_InventoryMgr.GetItemInfo( m_hCurrentAddingItem );
if( NULL == pSlot )
break;
if(m_bItemDrag) //servantes 2010.10.19
{
money_t MarketPrice( m_pDisplayInfo->GetItemSellPrice( pSlot->GetItemCode(), pSlot->GetLevel() ) ); // sonador 3.4.4 환금성 아이템 거래 관련 수정;
m_unCount = pInputNumberMsg->m_nValue;
AddItem( m_hCurrentAddingItem, pSlot->GetItemCode(), m_unCount, MarketPrice, pSlot->GetLevel(), pSlot->GetEnhance(), pSlot->GetEndurance(), *pSlot->GetXFlag().GetRawData(), pSlot->GetSocketInfo(), pSlot->GetRemainTime(), pSlot->GetEET(), pSlot->GetEERT(), pSlot->GetEEAP(), pSlot->GetEEMP(), pSlot->GetEtherealDurability(), pSlot->GetItemAppearance(), pSlot->GetAwakening(), pSlot->GetRandomOption(), pSlot->GetSummonID(), pSlot->GetAdditionalItemEffect() ); // Fraun Sky Accessories 7/12/2025
}
else
{
// 올릴 가격을 받은 경우
if( !m_unPrice )
{
m_unPrice = pInputNumberMsg->m_nValue;
if( GetItemDB().IsJoin( pSlot->GetItemCode(), IsInstanceUnstackable( pSlot ) ) && pSlot->GetItemCount() > 1 )
{
m_unCount = count_t( 0 );
count_t item_count = pSlot->GetItemCount();
if( item_count > ITEM_MAX_COUNT )
{
item_count = count_t( ITEM_MAX_COUNT );
}
m_pGameManager->PostMsgAtDynamic( new SIMSG_UI_REQ_INPUTNUMBER( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_STORE_HOST, item_count ) );
}
// 중첩 불가능한 아이템이거나 갯수가 1개인 경우
else
{
m_unCount = count_t( 1 );
AddItem( m_hCurrentAddingItem, pSlot->GetItemCode(), m_unCount, m_unPrice, pSlot->GetLevel(), pSlot->GetEnhance(), pSlot->GetEndurance(), *pSlot->GetXFlag().GetRawData(), pSlot->GetSocketInfo(), pSlot->GetRemainTime(), pSlot->GetEET(), pSlot->GetEERT(), pSlot->GetEEAP(), pSlot->GetEEMP(), pSlot->GetEtherealDurability(), pSlot->GetItemAppearance(), pSlot->GetAwakening(), pSlot->GetRandomOption(), pSlot->GetSummonID(), pSlot->GetAdditionalItemEffect() ); // Fraun Sky Accessories 7/12/2025
}
break;
}
}
// 가격이 있으면 갯수를 받은 것임
if( m_unPrice.getAmount() )
{
count_t nValue = (pInputNumberMsg->m_nValue < pSlot->GetItemCount()) ? pInputNumberMsg->m_nValue : pSlot->GetItemCount();
m_unCount = nValue;
AddItem( m_hCurrentAddingItem, pSlot->GetItemCode(), m_unCount, m_unPrice, pSlot->GetLevel(), pSlot->GetEnhance(), pSlot->GetEndurance(), *pSlot->GetXFlag().GetRawData(), pSlot->GetSocketInfo(), pSlot->GetRemainTime(), pSlot->GetEET(), pSlot->GetEERT(), pSlot->GetEEAP(), pSlot->GetEEMP(), pSlot->GetEtherealDurability(), pSlot->GetItemAppearance(), pSlot->GetAwakening(), pSlot->GetRandomOption(), pSlot->GetSummonID(), pSlot->GetAdditionalItemEffect() ); // Fraun Sky Accessories 7/12/2025
}
// bintitle. 2011.11.11. 노점에 아이템 등록할때 EditControl활성화 & Sound출력.
AddSaleItem();
Refresh();
}
break;
case IMSG_UI_STORE_UNDER: //등록된 아이템중에 가격이 5 or 1/5인 상품이 있을때 메세지 박스 출력되고 확인을 눌렀을때 이 메세지 발생
case IMSG_UI_STORE_OVER: //즉, 이 메세지들이 발생하면 상점 오픈하겠다는 의미.
SendStartBoothMsg();
break;
case MSG_UPDATE_ITEM_COUNT: //창 열고 있는데 인벤의 정보가 바뀌면 아이템이 서로 꼬일 가능성이 있기 때문에 닫아버린다.
case MSG_ITEM_INVEN:
if( IsShow() )
SUIWnd::OnNotifyUIWindowOpen( false );
break;
case IMSG_NOJUM_HOST_MOVEITEM: //servantes 2010.10.19
{
SIMSG_NOJUM_HOST_MOVEITEM* pMsgData = (SIMSG_NOJUM_HOST_MOVEITEM*)pMsg;
SInventorySlot* pSlot = m_InventoryMgr.GetItemInfo( pMsgData->m_handle );
if( NULL == pSlot )
break;
/// 2011.05.16 판매 가능 체크 - prodongi
if (!isEnableSell(pSlot))
break;
count_t nValue = count_t(0);
if(pMsgData->m_nValue < pSlot->GetItemCount())
nValue = pMsgData->m_nValue;
else
nValue = pSlot->GetItemCount();
if(nValue > count_t(1))
{
if(pMsgData->m_bMove10)
{
m_hCurrentAddingItem = pMsgData->m_handle;
int tc = GetItemSlotCount(m_hCurrentAddingItem);
if(tc == -1) //새로 아이템 등록할 때
{
tc = nValue.getAmount();
}
else // 있는데 개수를 추가할 때
{
if(tc + 10 > pSlot->GetItemCount().getAmount())
tc = pSlot->GetItemCount().getAmount();
else
tc += 10;
}
nValue = count_t(tc);
if( nValue > ITEM_MAX_COUNT )
{
nValue = count_t( ITEM_MAX_COUNT );
}
}
else
{
m_hCurrentAddingItem = pMsgData->m_handle;
int tc = GetItemSlotCount(m_hCurrentAddingItem);
if(tc == -1) //새로 아이템 등록할 때
{
tc = nValue.getAmount();
}
else // 있는데 개수를 추가할 때
{
if(tc + pMsgData->m_nValue.getAmount() > pSlot->GetItemCount().getAmount())
tc = pSlot->GetItemCount().getAmount();
else
tc += pMsgData->m_nValue.getAmount();
}
m_unPrice = money_t( m_pDisplayInfo->GetItemSellPrice( pSlot->GetItemCode(), pSlot->GetLevel() ) ); // sonador 3.4.4 환금성 아이템 거래 관련 수정;
nValue = count_t(tc);
if( nValue > ITEM_MAX_COUNT )
{
nValue = count_t( ITEM_MAX_COUNT );
}
m_pGameManager->PostMsgAtDynamic( new SIMSG_UI_REQ_INPUTNUMBER( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_STORE_HOST, nValue) );
break;
}
}
/// 2011.08.05 nMarketPrice 설정 - prodongi
money_t MarketPrice( m_pDisplayInfo->GetItemSellPrice( pSlot->GetItemCode(), pSlot->GetLevel() ) ); // sonador 3.4.4 환금성 아이템 거래 관련 수정;
AddItem( pMsgData->m_handle, pSlot->GetItemCode(), nValue, MarketPrice/*money_t(0)*/, pSlot->GetLevel(), pSlot->GetEnhance(), pSlot->GetEndurance(), *pSlot->GetXFlag().GetRawData(), pSlot->GetSocketInfo(), pSlot->GetRemainTime(), pSlot->GetEET(), pSlot->GetEERT(), pSlot->GetEEAP(), pSlot->GetEEMP(), pSlot->GetEtherealDurability(), pSlot->GetItemAppearance(), pSlot->GetAwakening(), pSlot->GetRandomOption(), pSlot->GetSummonID(), pSlot->GetAdditionalItemEffect() ); // Fraun Sky Accessories 7/12/2025
AddSaleItem(); // 2012. 2. 14 - marine 더블클릭으로 등록하면 edit 컨트롤이 enable 되지 않아서 호출
}
break;
case IMSG_HOTKEY_EX: //servantes 2010.10.15
{
SIMSG_HOTKEY_EX* pHotKey = dynamicCast(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() )
{
Refresh();
}
}
break;
}
}
}
void SUIStoreHostWnd::OpenStore()
{
Refresh();
if( StartBoothPossibilityCheck() == 1 ) //1:성공 , -1:실패 , 0:가격 차이 심해서 메세지박스 출력
SendStartBoothMsg();
}
int SUIStoreHostWnd::CheckPrice( int index )
{
std::string EditName = CStringUtil::StringFormat( s_szSlotControlName[ SLOT_CONTROL_INDEX::PRICE ], index );
KUIControlEdit* pEdit = (KUIControlEdit*)( GetChild(EditName.c_str()) );
if( pEdit == NULL ) return -1;
money_t Price( ::_atoi64( pEdit->GetText() ) );
int ItemCode = SStoreMgr::GetInstance().GetItemCode(index);
int ItemRank = GetItemDB().GetItemRank(ItemCode);
int ItemLevel = SStoreMgr::GetInstance().GetEnhance(index);
money_t MarketPrice( m_pDisplayInfo->GetItemSellPrice( ItemCode, ItemLevel ).getAmount() ); // sonador 3.4.4 환금성 아이템 거래 관련 수정
if( (MarketPrice.getAmount()*5 < Price.getAmount()) || (MarketPrice.getAmount()/5 > Price.getAmount()) )
{
m_pGameManager->PostMsgAtDynamic( new SIMSG_REQ_OPEN_MSGBOX(SIMSG_REQ_OPEN_MSGBOX::MSGBOX_STORE_PRICE_OVER, S(908), true) );
return 0;
}
return 1;
}
void SUIStoreHostWnd::PumpUpMessage( LPCSTR lpszControlID, DWORD nMessage, DWORD lparam, DWORD wparam )
{
KUIWnd* pWnd(NULL);
switch(nMessage)
{
case KUI_MESSAGE::KBUTTON_CLICK:
{
// { 모드 변경일 경우
if( !IsStarted() )
{
if( ::_stricmp( lpszControlID, "button_sell" ) == 0 ) { SwitchStoreMode( MODE_READY_TO_SELL ); }
else if( ::_stricmp( lpszControlID, "button_buy" ) == 0 ) { SwitchStoreMode( MODE_READY_TO_BUY ); }
}
if( ::_stricmp( lpszControlID, "button_close" ) == 0 )
{
RemoveAllItem(true);
m_pGameManager->PostMsgAtDynamic( new SIMSG_TOGGLE_UIWINDOW( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_STORE_HOST ) );
m_pGameManager->PostMsgAtDynamic( new SIMSG_SHOW_UIWINDOW( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_INPUTNUMBER, false ) );
}
else if( ::_stricmp( lpszControlID, "button_item_del" ) == 0 )
{
if( IsStarted() )
{
SendEndBoothMsg(); // 노점 운영 중에는 "일시중지" 버튼이고
EditControlEnable();
}
else RemoveItem( m_nFocus ); // 노점 준비 중에는 "항목삭제" 버튼이다.
Refresh();
}
else if( ::_stricmp( lpszControlID, "button_decision" ) == 0 )
{
if( IsStarted() )
{
m_pGameManager->PostMsgAtDynamic( new SIMSG_SHOW_UIWINDOW( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_STORE_HOST, false) ); // 노점 운영 중에는 "중지" 버튼이다.
Refresh();
}
else OpenStore(); //노점 열기
}
}
break;
case KUI_MESSAGE::KGENWND_RESIZE:
break;
case KUI_MESSAGE::KICON_CLICK:
{
for( size_t i = 0; i < SStoreMgr::GetInstance().GetListCount(); ++i )
{
if( ::_stricmp( lpszControlID, CStringUtil::StringFormat( s_szSlotControlName[ SLOT_CONTROL_INDEX::ICON ], i ).c_str() ) != 0 ) continue;
MoveFocus( (int)i );
Refresh();
}
}
break;
// { sonador 3.9.1 크리쳐 카드 상세 정보창 우클릭 오픈 기능 구현
case KUI_MESSAGE::KICON_RCLICK:
{
for( size_t i = 0; i < SStoreMgr::GetInstance().GetListCount(); ++i )
{
if( ::_stricmp( lpszControlID, CStringUtil::StringFormat( s_szSlotControlName[ SLOT_CONTROL_INDEX::ICON ], i ).c_str() ) != 0 ) continue;
MoveFocus( (int)i );
Refresh();
SInventorySlot* pInvenSlot = m_InventoryMgr.GetItemInfo( SStoreMgr::GetInstance().GetItemHandle( i ) );
if( pInvenSlot && GetItemDB().GetGroup( pInvenSlot->GetItemCode() ) == ItemBase::GROUP_SUMMONCARD )
{
// 2010.08.03 정리 - prodongi
if( m_pGameManager->IsShow( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_CREATURE_CARD_FRONT ) == false )
{
m_pGameManager->PostMsgAtDynamic( new SIMSG_UI_MOVE_EX( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_CREATURE_CARD_FRONT,
GetRect().left,
GetRect().top,
GetRect().right,
GetRect().bottom ) );
}
SMSG_SUMMON_CARD creatureCardMsg;
int insert( -1 );
AR_HANDLE arhandleCard( 0 );
arhandleCard = pInvenSlot->GetHandle();
if( arhandleCard )
{
creatureCardMsg.card_handle = arhandleCard;
m_pGameManager->ProcMsgAtStatic( &creatureCardMsg );
}
}
else
{
//크리처 카드 윈도우 닫기
if( m_pGameManager == NULL ) break;
// 2010.08.03 정리 - prodongi
if( m_pGameManager->IsShow( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_CREATURE_CARD_FRONT ) )
{
m_pGameManager->PostMsgAtDynamic( new SIMSG_SHOW_UIWINDOW( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_CREATURE_CARD_FRONT, false ) );
if( m_pGameManager->IsShow( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_CREATURE_CARD_BACK ) )
m_pGameManager->PostMsgAtDynamic( new SIMSG_SHOW_UIWINDOW( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_CREATURE_CARD_BACK, false ) );
}
}
break;
}
}
break;
// }
case KUI_MESSAGE::KGENWND_MOVE: // 윈도우 이동
LimitMoveWnd(); // 게임 외부로 나가지 못하게 제한
break;
case KUI_MESSAGE::KEDIT_IME_CHANGE:
if( m_strLastEditBox != lpszControlID )
{
int idx = GetSlotControlNum( m_strLastEditBox.c_str() );
Refresh();
m_strLastEditBox = lpszControlID;
}
break;
case KUI_MESSAGE::KEDIT_CHANGE:
if( ::_stricmp( lpszControlID, "edit_booth_name" ) != 0 )
{
KUIControlEdit* pEdit = dynamicCast(GetChild(lpszControlID));
if( pEdit == NULL ) break;
int idx = GetSlotControlNum( lpszControlID );
if( idx != -1 )
{
std::string strTemp = lpszControlID;
std::string strText;
if( strTemp.find(s_szSlotControlfilter[ SLOT_CONTROL_INDEX::PRICE ]) != -1 )
{
strText = pEdit->GetText();
money_t Price( ::_atoi64( strText.c_str() ) );
if( Price == money_t( ITEM_MAX_PRICE ) && strText != c_ItemMaxPrice )
pEdit->SetText( CStringUtil::StringFormat("%I64u",ITEM_MAX_PRICE).c_str() );
SStoreMgr::GetInstance().ChangeItemPrice(idx, Price);
}
else if( strTemp.find(s_szSlotControlfilter[ SLOT_CONTROL_INDEX::COUNT ]) != -1 )
{
strText = pEdit->GetText();
count_t count( ::atoi( strText.c_str() ) );
if( m_nMode == MODE_READY_TO_SELL )
{
SInventorySlot* pSlot = m_InventoryMgr.GetItemInfo( SStoreMgr::GetInstance().GetItemHandle( idx ) );
if( pSlot )
{
if( !GetItemDB().IsJoin( SStoreMgr::GetInstance().GetItemCode(idx), IsInstanceUnstackable( pSlot ) ) )
count = count_t( 1 );
else
{
count_t InvenItemCnt(0);
InvenItemCnt = pSlot->GetItemCount();
if( InvenItemCnt < count ) count = InvenItemCnt;
if( count_t( ITEM_MAX_COUNT ) < count ) count = count_t( ITEM_MAX_COUNT );
}
}
}
else if( m_nMode == MODE_READY_TO_BUY )
{
if( !GetItemDB().IsJoin( SStoreMgr::GetInstance().GetItemCode(idx), false ) )
count = count_t( 1 );
else
{ if( count > ITEM_MAX_COUNT ) count = count_t( ITEM_MAX_COUNT );
}
}
pEdit->SetText( CStringUtil::StringFormat("%d",count).c_str() );
SStoreMgr::GetInstance().ChangeItemCount(idx, count);
}
Refresh();
}
}
else
{
KUIControlEdit* pEdit = dynamicCast(GetChild("edit_booth_name"));
if( pEdit )
{
std::string strEdit = pEdit->GetText();
int pos = strEdit.find(S(946));
if( pos != -1 )
{
int strSize = ::strlen(S(946));
strEdit.erase( pos, pos+strSize );
}
}
}
break;
case KUI_MESSAGE::KFOCUS_ACTIVATED:
pWnd = GetChild( m_strLastEditBox.c_str() );
if( pWnd && pWnd->IsInRect(lparam, wparam) == false )
{
int idx = GetSlotControlNum( m_strLastEditBox.c_str() );
Refresh();
m_strLastEditBox.clear();
}
pWnd = GetChild("edit_booth_name");
if( pWnd && pWnd->IsInRect(lparam, wparam) == true )
{
KUIControlEdit* pEdit = dynamicCast(GetChild("edit_booth_name"));
std::string strEdit = pEdit->GetText();
if( strEdit == S(946) )
pEdit->SetText("");
}
break;
}
SUIWnd::PumpUpMessage( lpszControlID, nMessage, lparam, wparam );
}
//오든 에디트 컨트롤 비활성화
void SUIStoreHostWnd::EnableEditAll(bool bAble, bool bStrClear)
{
KUIControlEdit* pEdit(NULL);
int nListCnt( SStoreMgr::GetInstance().GetListCount() );
for( int i = 0; i < MAX_SLOT_COUNT; ++i )
{
pEdit = (KUIControlEdit*)( GetChild( CStringUtil::StringFormat( s_szSlotControlName[ SLOT_CONTROL_INDEX::PRICE ], i ).c_str() ) );
if( pEdit )
{
if( bAble && i < DEFAULT_ADD_COUNT )
((KUIControl*)pEdit)->Enable();
else ((KUIControl*)pEdit)->Disable();
if( bStrClear ) pEdit->SetText("");
}
pEdit = (KUIControlEdit*)( GetChild( CStringUtil::StringFormat( s_szSlotControlName[ SLOT_CONTROL_INDEX::COUNT ], i ).c_str() ) );
if( pEdit )
{
if( bAble && i < DEFAULT_ADD_COUNT )
((KUIControl*)pEdit)->Enable();
else ((KUIControl*)pEdit)->Disable();
if( bStrClear ) pEdit->SetText("");
}
}
}
//1 : 추가가능함 / -1 : 이미등록된 아이템 / -2 : 최대 한계 액수 초과 / 0 : 중복안되는 아이템 (장비는 같은 레벨 같은 인첸은 등록 불가)
int SUIStoreHostWnd::CheckAddItem( AR_HANDLE handle, ItemBase::ItemCode code, int nLevel, int nEnhance, count_t nCount, money_t nPrice, int nFlag )
{
money_t nTotalPrice(0);
int ListSize( SStoreMgr::GetInstance().GetListCount() );
for( int i(0); i (money_t( ITEM_MAX_PRICE ) - nTotalPrice) ) //추가가능한 여분의 금액
return -2;
return 1;
}
void SUIStoreHostWnd::AddItem( AR_HANDLE handle, ItemBase::ItemCode code, count_t count, money_t price, int nLevel, int nEnhance, int nEndurance, int nFlag, const int aSocket[ ItemBase::MAX_SOCKET_NUMBER ], int remain_time,
char eet, int eert, int eeap, int eemp, int ed, ItemBase::ItemCode apCode, TS_ITEM_BASE_INFO::AwakenOption* pAwakenOption, TS_ITEM_BASE_INFO::LPRANDOM_OPTION const pRandomOption, int nSummonID, int nAdditionalItemEffect ) // Fraun Sky Accessories 7/12/2025
{
// TODO : 만약 구매 노점일경우 여기서 돈이 충분한지 검사해야한다.
if( m_nMode == MODE_READY_TO_BUY || m_nMode == MODE_BUYING )
{
//1 : 추가가능함 / -1 : 이미등록된 아이템 / -2 : 보유액수 초과 / 0 : 중복안되는 아이템 (장비는 같은 레벨 같은 인첸은 못등록)
int nResult = CheckAddItem( handle, code, nLevel, nEnhance, count, price, nFlag );
if( nResult == -1 )
{
//S(919) "이미 노점에 등록되어진 아이템입니다."
m_pDisplayInfo->AddSystemMessage( S(919), 99); // This item has been put in the store.
Refresh();
return;
}
else if( nResult == 0 )
{
//S(954) /*"구매노점에는 동일한 종류의 아이템을 중복등록 할 수 없습니다."*/
m_pDisplayInfo->AddSystemMessage( S(954), 99); // You cannot register the same type of item at the purchasing store.
Refresh();
return;
}
else
__noop;
}
else
{
int nResult = CheckAddItem( handle, code, nLevel, nEnhance, count, price, nFlag );
if( nResult == -1 ){
//S(919) "이미 노점에 등록되어진 아이템입니다."
m_pDisplayInfo->AddSystemMessage( S(919), 99); // This item has been put in the store.
Refresh();
return;
}
else if( nResult == -2 ){
//S(521) /*"거래 완료 될 시의 루피소유량이 한계치[2147483647]를 넘습니다."*/
m_pDisplayInfo->AddSystemMessage( S(521), 99); // You will exceed the rupee limit (2,147,483,647RP) when completing the trade.
Refresh();
return;
}
}
// 아이템을 추가
int Index = SStoreMgr::GetInstance().AddItem( STORE_ITEM( handle, code, count.getAmount(), price.getAmount(), nLevel, nEnhance, nEndurance, nFlag, aSocket, remain_time, eet, eert, eeap, eemp, ed,apCode, pAwakenOption, pRandomOption, nSummonID, nAdditionalItemEffect ) ); // Fraun Sky Accessories 7/12/2025
if( Index > 0 )
{
// 기존 정보 제거
m_hCurrentAddingItem = NULL;
m_unPrice = money_t( 0 );
m_unCount = count_t( 0 );
//Index-1 -> 위에서 리턴하는 값은 총 갯수이다. 따라서 인덱스는 -1
KUIWnd* pWnd(NULL);
pWnd = GetChild( CStringUtil::StringFormat( s_szSlotControlName[ SLOT_CONTROL_INDEX::COUNT ], Index-1 ).c_str() );
if( pWnd ) ((KUIControlEdit*)pWnd)->SetText( CStringUtil::StringFormat("%d", count).c_str() );
pWnd = GetChild( CStringUtil::StringFormat( s_szSlotControlName[ SLOT_CONTROL_INDEX::PRICE ], Index-1 ).c_str() );
if( pWnd ) ((KUIControlEdit*)pWnd)->SetText( CStringUtil::StringFormat("%d", price).c_str() );
Refresh();
}
}
void SUIStoreHostWnd::RemoveAllItem( bool bRefresh )
{
SStoreMgr::GetInstance().Clear();
EnableEditAll(false, true);
MoveFocus( -1 );
if( bRefresh )
Refresh();
}
void SUIStoreHostWnd::RemoveItem( int idx )
{
int nListCnt = SStoreMgr::GetInstance().GetListCount();
assert( idx < nListCnt );
SStoreMgr::GetInstance().RemoveItem( SStoreMgr::GetInstance().GetItemHandle( idx ) );
KUIWnd* pWnd(NULL);
if( m_nFocus >= nListCnt )
{
pWnd = GetChild( CStringUtil::StringFormat( s_szSlotControlName[ SLOT_CONTROL_INDEX::PRICE ], idx ).c_str() );
if( pWnd )
{
((KUIControlEdit*)pWnd)->SetText("");
((KUIControl*)pWnd)->Disable();
}
pWnd = GetChild( CStringUtil::StringFormat( s_szSlotControlName[ SLOT_CONTROL_INDEX::COUNT ], idx ).c_str() );
if( pWnd )
{
((KUIControlEdit*)pWnd)->SetText("");
((KUIControl*)pWnd)->Disable();
}
MoveFocus( -1 );
}
else
{
int i(idx);
KUIControlEdit* pLastEdit(NULL);
for( i; iGetText();
pWnd = GetChild( CStringUtil::StringFormat( s_szSlotControlName[ SLOT_CONTROL_INDEX::PRICE ], i ).c_str() );
if( pWnd ) ((KUIControlEdit*)pWnd)->SetText( strPrice.c_str() );
pWnd = GetChild( CStringUtil::StringFormat( s_szSlotControlName[ SLOT_CONTROL_INDEX::COUNT ], i+1 ).c_str() );
if( pWnd )
{
pLastEdit = ((KUIControlEdit*)pWnd);
strCount = ((KUIControlEdit*)pWnd)->GetText();
}
pWnd = GetChild( CStringUtil::StringFormat( s_szSlotControlName[ SLOT_CONTROL_INDEX::COUNT ], i ).c_str() );
if( pWnd ) ((KUIControlEdit*)pWnd)->SetText( strCount.c_str() );
}
if( pLastEdit )
((KUIControl*)pLastEdit)->Disable();
}
Refresh();
EditControlEnable();
}
int SUIStoreHostWnd::GetItemSlotCount( AR_HANDLE hHandle ) //servantes 2010.10.19
{
int nListCnt = SStoreMgr::GetInstance().GetListCount();
//assert( idx < nListCnt );
int i = 0;
KUIControlEdit* pLastEdit(NULL);
for( i; i < nListCnt; i++ )
{
if(SStoreMgr::GetInstance().GetItemHandle(i) == hHandle)
{
std::string strCount;
KUIWnd* pWnd = GetChild( CStringUtil::StringFormat( s_szSlotControlName[ SLOT_CONTROL_INDEX::COUNT ], i ).c_str() );
if( pWnd )
{
strCount = ((KUIControlEdit*)pWnd)->GetText();
return ::atoi(strCount.c_str());
}
}
}
return -1;
}
/// 2011.05.16 - prodongi
bool SUIStoreHostWnd::isEnableSell(SInventorySlot* slot)
{
if (!slot)
return false;
//에테리얼 내구도가 0이면 파괴 상태임으로 거부한다.
const ItemBaseEx_info * pItemBase = GetItemDB().GetItemData( slot->GetItemCode() );
if(pItemBase)
{
if(slot->getMaxEtherealDurability() > 0)
{
int ethereal = slot->GetItem()->ethereal_durability;
if(ethereal == 0)
{
m_pDisplayInfo->AddSystemMessage( S(7904), 0 ); // Destroyed items cannot be stored, or added or traded in the Auction House.
return false;
}
}
}
/// 2011.05.16 벨트 체크 추가 - prodongi
if( slot->IsEquipItem() || m_InventoryMgr.IsBeltSlotCard(slot->GetHandle()))
{
m_pDisplayInfo->AddSystemMessage( S(917), 99); // You cannot add an item that is currently equipped.
return false;
}
if( slot->GetXFlag().IsOn( ItemInstance::ITEM_FLAG_FAILED ) ) //실패작
{
m_pDisplayInfo->AddSystemMessage( S(977), 99); // You can't add failed enchantment items to your store.
return false;
}
if( GetItemDB().GetItemData( slot->GetItemCode() )->CheckFlag( ItemBase::FLAG_CANT_TRADE ) ||
GetItemDB().GetItemData( slot->GetItemCode() )->CheckFlag( ItemBase::FLAG_QUEST ) )
{
m_pDisplayInfo->AddSystemMessage( S(282), 99); // You cannot sell that item.
return false;
}
return true;
}
void SUIStoreHostWnd::SwitchStoreMode( int nNewMode, bool bNeedClear )
{
KUIWnd *pWnd = NULL;
pWnd = GetChild( "booth_title_font00" );
if( pWnd ) pWnd->MoveToOriginalPosition();
(dynamicCast(GetChild("edit_booth_name")))->Enable();
// 데이터 정리
if( bNeedClear )
{
RemoveAllItem(false);
(dynamicCast(GetChild("edit_booth_name")))->SetText("");
}
if( nNewMode == MODE_READY_TO_SELL || nNewMode == MODE_READY_TO_BUY )
{
SetChildCaption( "button_item_del", S(6314)); /*"<<#000000>품목삭제"*/ // 품목 삭제 버튼
SetChildCaption( "button_decision", S(6315)); /*"<<#000000>결정"*/ // 결정 버튼
SetChildCaption( "expect_money", S(6082)); /*"<#fbe7b4>예상금액"*/ // 예상금액
}
if( nNewMode == MODE_READY_TO_SELL )
{
SStoreMgr::GetInstance().SwitchStoreMode( true );
// 탭 활성화
KUIControl* pControl(NULL);
pControl = dynamicCast< KUIControl* >( GetChild( "button_sell" ) );
pControl->SetEnableColor("<#7ebffc>");
pControl->Enable();
pControl = dynamicCast< KUIControl* >( GetChild( "button_buy" ) );
pControl->SetEnableColor("<#8E8E8E>");
pControl->Enable();
SetChildAniName( "booth_title_font00", "font_title_streetstallsellopen" );
}
else if( nNewMode == MODE_READY_TO_BUY )
{
SStoreMgr::GetInstance().SwitchStoreMode( false );
KUIControl* pControl(NULL);
pControl = dynamicCast< KUIControl* >( GetChild( "button_sell" ) );
pControl->SetEnableColor("<#8E8E8E>");
pControl->Enable();
pControl = dynamicCast< KUIControl* >( GetChild( "button_buy" ) );
pControl->SetEnableColor("<#FFEA00>");
pControl->Enable();
SetChildAniName( "booth_title_font00", "font_title_streetstallbuyopen" );
}
else
{
KUIControlEdit* pControl = dynamicCast< KUIControlEdit* >( GetChild( "edit_booth_name" ) );
std::string strBoothText = pControl->GetText();
strBoothText.insert(0, "");
if( nNewMode == MODE_BUYING ) pControl->SetDisableColor( "<#FFEA00>" );
else if( nNewMode == MODE_SELLING) pControl->SetDisableColor( "<#7EBFFC>" );
pControl->SetCaption(strBoothText.c_str());
pControl->Disable();
EnableEditAll(false, false);
SetChildCaption( "button_decision", S(6317)); /*"<#000000>중단"*/ // 중단 버튼
SetChildCaption( "button_item_del", S(6318)); /*"<#000000>일시중지"*/ // 일시중지 버튼
SetChildCaption( "expect_money", S(6319)); /*"<#fbe7b4>변동금액"*/ // 변동금액
// SetChildShow( "expect_money", true);
// 타이틀
if( nNewMode == MODE_BUYING ) SetChildAniName( "booth_title_font00", "font_title_streetstallbuy" );
else if( nNewMode == MODE_SELLING) SetChildAniName( "booth_title_font00", "font_title_streetstallsell" );
if( pWnd ) pWnd->MovePos( pWnd->GetRect().left + 25, pWnd->GetRect().top );
}
m_nMode = nNewMode;
Refresh();
}
void SUIStoreHostWnd::SetSlotShowMode( size_t idx, bool bShow )
{
assert( idx < MAX_SLOT_COUNT );
for( size_t x = 0; x < CONTROL_PER_SLOT; ++x )
{
if( x == SLOT_CONTROL_INDEX::DISABLE )
continue;
bool bTmpShow = bShow;
std::string strControlName( CStringUtil::StringFormat( s_szSlotControlName[x], idx ) );
if( !bTmpShow )
{
KUIWnd* pWnd = GetChild( strControlName.c_str() );
if( pWnd ) pWnd->SetCaption( "" );
}
if( x == SLOT_CONTROL_INDEX::ICON && bShow == false )
{
KUIControlMultiIcon* pIcon = dynamicCast< KUIControlMultiIcon* >( GetChild( CStringUtil::StringFormat( s_szSlotControlName[x], idx ).c_str() ) );
if( pIcon )
{
ResetMultiIcon( pIcon, 0, 8 );
//pIcon->SetIconLayer( 4 );
pIcon->SetIcon( 0, c_szDEF_SPR_NAME, "static_common_itemslot" );
pIcon->SetTooltip( "" );
pIcon->SetTooltipOff();
}
}
if( x == SLOT_CONTROL_INDEX::PRICE || x == SLOT_CONTROL_INDEX::ICON || x == SLOT_CONTROL_INDEX::COUNT )
{
bTmpShow = true;
}
SetChildShow( strControlName.c_str(), bTmpShow );
}
}
bool SUIStoreHostWnd::GetPresumptionGoldWeight( money_t& rGold, float& rfWeight )
{
float fWeight(0.0f);
rGold = money_t( 0 );
int nListCnt( SStoreMgr::GetInstance().GetListCount() );
for( int i(0); ifWeight * SStoreMgr::GetInstance().GetItemCount(i).getAmount();
}
int nMaxWeight = m_PlayerInfoMgr.GetPlayerInfo().GetWeight();
rfWeight = fWeight / float(nMaxWeight) * 100.f;
return true;
}
void SUIStoreHostWnd::Refresh( int index/*=-1*/ )
{
//보여지지도 않는데 필요없이 갱신할 필요 없다. 어차피 열릴때 한번은 호출해준다.
//다른 곳에서 메세지 발생한 경우에도 이곳이 들어올 수 있으니 처리한다. OTL 별로 좋지 않은 현상...
if( !IsShow() ) return;
money_t nGold( 0 ); // 예상금액
bool bOverGold(false); //예상금액이 액수 한도가 넘었는지 체크
size_t idx = index;
int count(MAX_SLOT_COUNT);
if( index == -1 ) idx = 0;
else count = index+1;
int nListCnt( SStoreMgr::GetInstance().GetListCount() );
KUIWnd* pWnd = NULL;
for( idx; idx < count; ++idx )
{
if( idx < nListCnt )
{
SInventorySlot* pSlot = m_InventoryMgr.GetItemInfo( SStoreMgr::GetInstance().GetItemHandle( idx ) );
if( !pSlot )
continue;
std::string strItemName, strString;
// 이름 변경
pWnd = GetChild( CStringUtil::StringFormat( s_szSlotControlName[ SLOT_CONTROL_INDEX::NAME ], idx ).c_str() );
strString = "<#FBE6AE>";
strItemName = m_pDisplayInfo->GetItemName( pSlot->GetItemCode(), true, pSlot->GetEnhance(), pSlot->GetLevel(), pSlot->GetXFlag(), false, 0, false, pSlot->GetRandomOption() );
strString += strItemName;
if( pWnd ) pWnd->SetCaption( strString.c_str() );
// 수량 변경
pWnd = GetChild( CStringUtil::StringFormat( s_szSlotControlName[ SLOT_CONTROL_INDEX::COUNT ], idx ).c_str() );
if( pWnd )
{
count_t count = SStoreMgr::GetInstance().GetItemCount( idx );
SetEditNumText( (KUIControlEdit*)pWnd, count, true, false, RIGHT, "" );
}
// 가격 변경
pWnd = GetChild( CStringUtil::StringFormat( s_szSlotControlName[ SLOT_CONTROL_INDEX::PRICE ], idx ).c_str() );
if( pWnd )
{
money_t Price = SStoreMgr::GetInstance().GetItemPrice( idx );
SetEditNumText( (KUIControlEdit*)pWnd, Price, true, true, RIGHT, "" );
}
// 아이콘 변경
KUIControlMultiIcon* pIcon = dynamicCast< KUIControlMultiIcon* >( GetChild( CStringUtil::StringFormat( s_szSlotControlName[ SLOT_CONTROL_INDEX::ICON ], idx ).c_str() ) );
if( pIcon )
{
ResetMultiIcon( pIcon, 0, 8 );
/// 2011.08.03 - prodongi
if( !setSkillCardIcon(pIcon, pSlot->GetItemCode()) && !setSummonCardIcon( pIcon, pSlot ) )
{
pIcon->SetIcon( 0, c_szDEF_SPR_NAME, GetItemDB().GetIconName(pSlot->GetItemCode()) );
}
if( pSlot->GetItemAppearance() )
pIcon->SetIcon( 4, c_szDEF_SPR_NAME, g_strLookChangeIcon ); // 2012. 7. 27 - marine 아이템 형상변환 아이콘
//pIcon->SetIcon( 0, c_szDEF_SPR_NAME, iconName.c_str());
pIcon->SetIcon( 1, c_szDEF_SPR_NAME, pSlot->GetXFlag().IsOn( ItemInstance::ITEM_FLAG_CARD ) ? "static_common_usecreaturecardicon" : NULL );
EquipItemAddtionalIconSetter icon_setter( pIcon, pSlot );
pIcon->SetLazyTooltip( new rp::KLazyItemTooltip( *m_pDisplayInfo, pSlot, true ) );
pIcon->SetCorrectionRect( KRect( 0, 0, 150, 0 ) );
if( m_bAltKey )
{
m_pDisplayInfo->SetComparableEquipItemSubTooltip( pIcon, pSlot );
}
}
//현재 인벤에 있는 아이템 갯수 표시해주는 부분 변경
strString = S(6321)/*"<#FFFFFF>"*/;
pWnd = GetChild( CStringUtil::StringFormat( s_szSlotControlName[ SLOT_CONTROL_INDEX::INVENCNT ], idx ).c_str() );
if( pWnd )
{
m_OldInvenItemList[idx] = pSlot->GetItemCount();
if( m_OldInvenItemList[idx] > 0 )
{
strString = S(6425); //""
strString += "";
strString += CStringUtil::StringFormat( "%I64d", m_OldInvenItemList[idx].getAmount() );
pWnd->SetCaption( strString.c_str() );
pWnd->SetShow(true);
}
else pWnd->SetShow(false);
}
SetSlotShowMode( idx, true );
money_t nTmp = SStoreMgr::GetInstance().GetItemCount( idx ) * SStoreMgr::GetInstance().GetItemPrice( idx );
if( SStoreMgr::GetInstance().IsSellMode() )
{
if(money_t( ITEM_MAX_PRICE ) - nGold < nTmp) bOverGold = true;
else nGold += nTmp;
}
else
{
if(money_t( ITEM_MAX_PRICE ) - (nGold*money_t( -1 )) < nTmp) bOverGold = true;
nGold -= nTmp;
}
}
else
{
SetSlotShowMode( idx, false );
}
}
MoveFocus( m_nFocus );
// { 예상금액 업데이트
if( index == -1 )
{
std::string strGold;
pWnd = GetChild( "edit_expect_money" );
if( !bOverGold )
{
strGold = "0";
if( nGold < 0 ) strGold = std::string( "-" ) + CStringUtil::GetCommaNumberString( ( money_t( 0 ) - nGold ).getAmount() ).c_str();
else if( nGold > 0 ) strGold = std::string( "+" ) + CStringUtil::GetCommaNumberString( nGold.getAmount() ).c_str();
strGold += " <#FFEA00>";//
strGold += GetStringDB().GetString(6618); //"R ";
strGold += " ";
}
else
{
strGold = "<#EE0000>";
strGold += S(522);
}
if( pWnd ) pWnd->SetCaption( strGold.c_str() );
}
// }
}
void SUIStoreHostWnd::ShowDisableBackGround( int nCnt )
{
for( int i = 0; i < MAX_SLOT_COUNT; ++i )
{
KUIWnd* pWnd(NULL);
pWnd = GetChild( CStringUtil::StringFormat( s_szSlotControlName[ SLOT_CONTROL_INDEX::DISABLE ], i ).c_str() );
if( pWnd ) pWnd->SetShow( i >= nCnt );
}
}
void SUIStoreHostWnd::EditControlEnable()
{
int nListCnt( SStoreMgr::GetInstance().GetListCount() );
for( int i = 0; i < MAX_SLOT_COUNT; ++i )
{
KUIWnd* pWnd(NULL);
pWnd = GetChild( CStringUtil::StringFormat( s_szSlotControlName[ SLOT_CONTROL_INDEX::COUNT ], i ).c_str() );
if( pWnd && nListCnt <= i )
{
((KUIControlEdit*)pWnd)->SetText("");
((KUIControl*)pWnd)->Disable();
}
else ((KUIControlEdit*)pWnd)->Enable();
pWnd = GetChild( CStringUtil::StringFormat( s_szSlotControlName[ SLOT_CONTROL_INDEX::PRICE ], i ).c_str() );
if( pWnd && nListCnt <= i )
{
((KUIControlEdit*)pWnd)->SetText("");
((KUIControl*)pWnd)->Disable();
}
else ((KUIControlEdit*)pWnd)->Enable();
}
}
bool SUIStoreHostWnd::IsBoothNameFocus()
{
KUIControlEdit* pEdit = dynamicCast(GetChild( "edit_booth_name" ));
if( pEdit )
{
return pEdit->HasFocus();
}
return false;
}
void SUIStoreHostWnd::TagFillter( std::string& strChat )
{
EraseColorTag(strChat);
for( int i(0); i", nsPos);
int eraseCnt(0);
while( nsPos != -1 && nePos != -1 && nePos > nsPos )
{
eraseCnt = nePos - nsPos + 1;
strChat.erase( nsPos, eraseCnt );
//nsPos = strChat.find("<#");
nsPos = strChat.find("<");
nePos = strChat.find(">", nsPos);
}
}
void SUIStoreHostWnd::EraseTag( std::string& strChat, const char* lpTag )
{
int nPos = strChat.find(lpTag);
while( nPos != -1 )
{
strChat.erase( nPos, nPos+sizeof(lpTag) );
nPos = strChat.find(lpTag);
}
}
void SUIStoreHostWnd::StartBooth()
{
// TODO : 내 Booth Name 세팅 해야됨
KUIControlEdit* pEdit = (dynamicCast(GetChild( "edit_booth_name" )));
if( pEdit )
{
std::string strBoothName = pEdit->GetText();
TagFillter(strBoothName);
pEdit->SetText(strBoothName.c_str());
if( m_nMode == MODE_READY_TO_SELL )
SwitchStoreMode( MODE_SELLING, false );
else if( m_nMode == MODE_READY_TO_BUY )
SwitchStoreMode( MODE_BUYING, false );
m_pGameManager->InterfaceMsg( &SMSG_BOOTH_NAME_CHANGED( m_pDisplayInfo->GetPlayerInfoManager()->GetPlayerHandle(), strBoothName.c_str() ) );
strBoothName = S(953);
SetChildCaption( "titlebar", strBoothName.c_str() );
// static_cast< KUIControl* >( GetChild( "edit_booth_name" ) )->Disable();
}
}
void SUIStoreHostWnd::StopBooth( bool bEnd )
{
if( !bEnd )
{
if( m_nMode == MODE_SELLING ) SwitchStoreMode( MODE_READY_TO_SELL, false );
else if( m_nMode == MODE_BUYING ) SwitchStoreMode( MODE_READY_TO_BUY, false );
SetChildCaption( "titlebar", S(6006)/*"<#242424>노점개설"*/ );
//SUIWnd::OnNotifyUIWindowOpen( false );
}
else
{
m_pGameManager->PostMsgAtDynamic( new SIMSG_SHOW_UIWINDOW( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_STORE_HOST, false) );
m_pDisplayInfo->AddSystemMessage( S(914), 99); // The store is closed.
}
m_pGameManager->InterfaceMsg( &SMSG_BOOTH_NAME_CHANGED( m_pDisplayInfo->GetPlayerInfoManager()->GetPlayerHandle(), std::string("") ) );
}
void SUIStoreHostWnd::MoveFocus( int idx )
{
m_nFocus = idx;
KUIWnd *pBackWnd = GetChild( "item_overbackground" );
KUIWnd *pIconOverWnd = GetChild( "icon_over" );
KUIWnd *pSelectWnd = GetChild( "item_selectover" );
if( !pBackWnd ) return;
if( !pIconOverWnd ) return;
if( !pSelectWnd ) return;
if( m_nFocus >= 0 && m_nFocus < SStoreMgr::GetInstance().GetListCount() )
{
KUIWnd *pTopIcon = GetChild( "booth_item_icon00" );
KUIWnd *pLeftIcon = GetChild( "booth_itemname_text00" );
pIconOverWnd->MovePos( pTopIcon->GetRect().left, pTopIcon->GetRect().top + m_nFocus * SLOT_Y_DELTA );
SetChildAsTop( "icon_over" );
pBackWnd->MovePos( pTopIcon->GetRect().left - 5, pTopIcon->GetRect().top + m_nFocus * SLOT_Y_DELTA - 6 );
pSelectWnd->MovePos( pTopIcon->GetRect().left - 5, pTopIcon->GetRect().top + m_nFocus * SLOT_Y_DELTA - 6 );
pBackWnd->SetShow( true );
pIconOverWnd->SetShow( true );
pSelectWnd->SetShow( true );
}
else
{
pBackWnd->SetShow( false );
pIconOverWnd->SetShow( false );
pSelectWnd->SetShow( false );
}
}
// bintitle. 2011.11.11. 노점에 아이템 등록.
void SUIStoreHostWnd::AddSaleItem()
{
EditControlEnable();
m_pGameManager->StartSound( m_pDisplayInfo->GetDragMaterialSound() );
}
////////////////////////////////////////////////////////////////////////////////////////////
//
// Client wnd
//
bool SUIStoreClientWnd::InitControls( KPoint kPos )
{
// 생성
// 0 번째 : KUIWnd::CopyControl()
CreateControls();
// move rect : SetCustomMovingRect
// 커스텀 윈도우 move 영역 설정
SetCustomMovingRect( KRect( 0, 0, 313, 20 ) );
// button click : SetValidRect
// { 컨트롤 안보이도록..
for( size_t i = 0; i < MAX_SLOT_COUNT; ++i )
{
KUIControlMultiIcon* pIcon = dynamicCast< KUIControlMultiIcon* >( GetChild( CStringUtil::StringFormat( s_szSlotControlName[ SLOT_CONTROL_INDEX::ICON ], i ).c_str() ) );
if( pIcon )
{
pIcon->SetIconLayer( nLayer );
ResetMultiIcon( pIcon, 0, 8 );
pIcon->SetIcon( 0, c_szDEF_SPR_NAME, "static_common_itemslot" );
}
SetSlotShowMode( i, true );
}
SetChildShow( "booth_disable", false );
SetChildShow( "booth_item_select", false );
// }
return SUIWnd::InitControls(kPos);
}
bool SUIStoreClientWnd::InitData( bool bReload )
{
// 노점 판매 구매 버튼 초기화
// data Initialize
return SUIWnd::InitData(bReload);
}
void SUIStoreClientWnd::CreateControls()
{
size_t i;
RECT rc = { 0, SLOT_Y_DELTA, 0, SLOT_Y_DELTA };
KUIWnd* pWnd = GetChild("booth_disable00");
if( pWnd )
{
pWnd->MovePos(pWnd->GetRect().left, pWnd->GetRect().top-SLOT_Y_DELTA);
}
for( i = 1; i < MAX_SLOT_COUNT; ++i )
{
for( size_t x = 0; x < CONTROL_PER_SLOT; ++x )
{
CopyControl( CStringUtil::StringFormat( s_szSlotControlName[x], i-1).c_str(),
CStringUtil::StringFormat( s_szSlotControlName[x], i).c_str(),
rc );
}
}
}
void SUIStoreClientWnd::OnNotifyUIWindowOpen( bool bOpen, bool bLimitWnd )
{
if( !bOpen )
{
StopBooth();
// 어쨌든 슬롯의 데이터는 무의미하므로 날려 버린다.
SStoreMgr::GetInstance().Clear();
}
else
{
Refresh();
}
m_pGameManager->PostMsgAtDynamic( new SIMSG_UI_SEND_DATA( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_SHOPKART, number_t( bOpen ), "set_booth_mode" ) );
m_pGameManager->PostMsgAtDynamic( new SIMSG_SHOW_UIWINDOW( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_SHOPKART, bOpen ) );
m_pGameManager->PostMsgAtDynamic( new SIMSG_UI_MOVE( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_SHOPKART, GetRect().right, GetRect().bottom ) );
//m_bSellStore StoreClient가 (m_bSellStore == true) 즉, 판매 노점이면
//카드창쪽의 사용유저는 구매상태가 되는 것이다.
//사용자의 관점에 따라서 모드가 다르니 유념해서 코딩하자 -N4-
//여기서 sell모드가 true이면 카트창에는 buy모드가 true가 되는 것
m_pGameManager->PostMsgAtDynamic( new SIMSG_UI_SHOP_BUYMODECHANGE( m_bSellStore ) );
}
void SUIStoreClientWnd::onBoothTradeInfo( struct SMSG_BOOTH_TRADE_INFO * pMsg )
{
if( !IsShow() ) return;
SGameObject * pObject = m_pGameManager->GetActiveGame()->GetGameObject( pMsg->hTarget );
if( pObject )
OutputBoothTradeMessage( m_pDisplayInfo,static_cast< SGameOtherPlayer* >( pObject )->GetName(), pMsg );
Refresh();
if( SStoreMgr::GetInstance().GetListCount() == 0 )
StopBooth();
}
void SUIStoreClientWnd::onBoothInfo( struct SMSG_BOOTH_INFO *pMsg )
{
SStoreMgr::GetInstance().Clear();
if( m_bSellStore != pMsg->bIsSell )
m_pGameManager->PostMsgAtDynamic( new SIMSG_UI_SEND_DATA( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_SHOPKART, "shopkart_clear" ) );
m_hTarget = pMsg->hTarget;
m_bSellStore = pMsg->bIsSell;
KUIControl* pBuyButtonControl = (dynamicCast(GetChild("button_buy01")));
KUIControl* pSellButtonControl = (dynamicCast(GetChild("button_sell01")));
if( m_bSellStore )
{
pBuyButtonControl->SetDisableColor("<#8e8e8e>");
pBuyButtonControl->Disable();
pSellButtonControl->SetEnableColor("<#7ebffc>");
pSellButtonControl->Enable();
}
else
{
pBuyButtonControl->SetEnableColor("<#ffea00>");
pBuyButtonControl->Enable();
pSellButtonControl->SetDisableColor("<#8e8e8e>");
pSellButtonControl->Disable();
}
SStoreMgr::GetInstance().SetTargetHandle( m_hTarget );
for( size_t idx = 0; idx < pMsg->vList.size(); ++idx )
{
count_t nCnt = GetItemCountInven( pMsg->vList[idx].Code, pMsg->vList[idx].level, pMsg->vList[idx].enhance, pMsg->vList[idx].Flag );
//if( m_nMode == MODE_READY_TO_BUY && nCnt == 0 ) continue;
SStoreMgr::GetInstance().AddItem(
STORE_ITEM(
pMsg->vList[idx].handle,
pMsg->vList[idx].Code,
pMsg->vList[idx].count,
pMsg->vList[idx].gold,
pMsg->vList[idx].level,
pMsg->vList[idx].enhance,
pMsg->vList[idx].endurance,
pMsg->vList[idx].Flag,
pMsg->vList[idx].socket,
pMsg->vList[idx].remain_time,
pMsg->vList[idx].elemental_effect_type,
pMsg->vList[idx].elemental_effect_remain_time,
pMsg->vList[idx].elemental_effect_attack_point,
pMsg->vList[idx].elemental_effect_magic_point,
pMsg->vList[idx].ethereal_durability,
pMsg->vList[idx].appearance_code,
&pMsg->vList[idx].awakenoption,
&pMsg->vList[idx].random_option,
pMsg->vList[idx].summon_id,
pMsg->vList[idx].nAdditionalItemEffect // Fraun Sky Accessories 7/12/2025
)
);
}
SGameObject * pObject = m_pGameManager->GetActiveGame()->GetGameObject( pMsg->hTarget );
if( pObject )
{
std::string strTitle;
std::string strBoothName = static_cast< SGameOtherPlayer* >( pObject )->GetBoothName();
std::string StoreName = ((SGameAvatarEx*)pObject)->GetName();
if( m_bSellStore )
{ strBoothName.insert(0, "<#7EBFFC>");
strTitle = SR(949, "#@char_name@#", StoreName.c_str()); //S(949) "#@char_name@#의 판매노점"
}
else
{ strBoothName.insert(0, "<#FFEA00>");
strTitle = SR(950, "#@char_name@#", StoreName.c_str()); //S(950) "#@char_name@#의 구매노점"
}
SetChildCaption( "static_booth_name", strBoothName.c_str() );
strTitle.insert(0, "<#242424>");
SetChildCaption( "titlebar", strTitle.c_str() );
}
Refresh();
}
void SUIStoreClientWnd::onMsgResult( struct SMSG_RESULT* pMsg )
{
if( pMsg->request_msg_id == TM_CS_STOP_WATCH_BOOTH )
{
if( pMsg->result == RESULT_SUCCESS ) SUIWnd::OnNotifyUIWindowOpen(false);
else assert( 0 );
}
if( pMsg->request_msg_id == TM_CS_BUY_FROM_BOOTH )
{
}
if( pMsg->request_msg_id == TM_CS_SELL_TO_BOOTH )
{
if( pMsg->result == RESULT_SUCCESS )
{
}
else if( pMsg->result == RESULT_TOO_HEAVY )
{
//S(943) "노점개설자의 무게한도를 초과하였습니다."
m_pGameManager->PostMsgAtDynamic( new SIMSG_REQ_OPEN_MSGBOX(SIMSG_REQ_OPEN_MSGBOX::MSGBOX_STORE_WEIGHT_OVER, S(943), true) );
}
else if( pMsg->result == RESULT_NOT_ENOUGH_MONEY )
{
m_pDisplayInfo->AddSystemMessage( S(283), 99); // You do not have enough Rupees.
}
}
}
void SUIStoreClientWnd::ProcMsgAtStatic( SGameMessage* pMsg )
{
switch( pMsg->nType )
{
case MSG_BOOTH_CLOSED:
{
if( dynamicCast< SMSG_BOOTH_CLOSED* >( pMsg )->hTarget == SStoreMgr::GetInstance().GetTargetHandle() )
{
m_pGameManager->PostMsgAtDynamic( new SIMSG_SHOW_UIWINDOW( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_STORE_CLIENT, false) );
m_pGameManager->PostMsgAtDynamic( new SIMSG_SHOW_UIWINDOW( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_INPUTNUMBER, false ) );
m_pDisplayInfo->AddSystemMessage( S(914), 99); // The store is closed.
}
}
break;
case MSG_BOOTH_TRADE_INFO: onBoothTradeInfo( dynamicCast< SMSG_BOOTH_TRADE_INFO * >( pMsg ) ); break;
case MSG_BOOTH_INFO: onBoothInfo( dynamicCast< SMSG_BOOTH_INFO * >( pMsg ) ); break;
case MSG_RESULT:
onMsgResult( dynamicCast< SMSG_RESULT* >( pMsg ) );
break;
case IMSG_UI_INPUTNUMBER:
{
SIMSG_UI_INPUTNUMBER* pInputNumberMsg = dynamicCast< SIMSG_UI_INPUTNUMBER* >( pMsg );
if( pInputNumberMsg->m_nValue < 1 ) break;
if( m_nFocus < 0 || m_nFocus >= SStoreMgr::GetInstance().GetListCount() ) break;
// for( int i = 0; i < pInputNumberMsg->m_nValue; ++i )
count_t nStoreItemCount = SStoreMgr::GetInstance().GetItemCount(m_nFocus);
MoveItemToKart( (int)m_nFocus, std::min(nStoreItemCount, pInputNumberMsg->m_nValue) );
}
break;
case MSG_BOOTH_NAME_CHANGED:
{
SMSG_BOOTH_NAME_CHANGED* pBoothNameChange = dynamicCast< SMSG_BOOTH_NAME_CHANGED* >( pMsg );
SetChildCaption("static_booth_name", pBoothNameChange->strBoothName.c_str());
}
break;
case IMSG_NOJUM_CLIENT_MOVEITEM: //servantes 2010.10.19
{
SIMSG_NOJUM_CLIENT_MOVEITEM* pMsgData = (SIMSG_NOJUM_CLIENT_MOVEITEM*)pMsg;
SInventorySlot* pSlot = m_InventoryMgr.GetItemInfo( pMsgData->m_handle );
if( NULL == pSlot )
break;
int kk=0;
}
break;
case IMSG_HOTKEY_EX: //servantes 2010.10.15
{
SIMSG_HOTKEY_EX* pHotKey = dynamicCast(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() )
{
Refresh();
}
}
break;
}
}
}
void SUIStoreClientWnd::StopBooth()
{
// 서버에 노점 중지 요청 보내자
SendEndWatchBoothMsg();
}
static int GetSlotControlNum( const char* szSlotControlID )
{
for( int nSlotIndex( 0 ); nSlotIndex < MAX_SLOT_COUNT; ++nSlotIndex )
{
for( int nIndex( 0 ); nIndex < CONTROL_PER_SLOT; ++nIndex )
{
if( 0 == ::_stricmp( CStringUtil::StringFormat( s_szSlotControlName[ nIndex ], nSlotIndex ).c_str(), szSlotControlID ) )
return nSlotIndex;
}
}
return (-1);
}
void SUIStoreClientWnd::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_TOGGLE_UIWINDOW( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_STORE_CLIENT ) );
m_pGameManager->PostMsgAtDynamic( new SIMSG_SHOW_UIWINDOW( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_INPUTNUMBER, false ) );
break;
}
int nIndex = GetSlotControlNum( lpszControlID );
if( nIndex >= 0 ) MoveFocus( nIndex );
if( ::_stricmp( lpszControlID, "button_item_put" ) == 0 )
{
if( GetMoveItemCount( (int)m_nFocus, m_bSellStore ) )
MoveItemToKart( (int)m_nFocus, count_t( 1 ) );
}
Refresh();
}
break;
case KUI_MESSAGE::KGENWND_RESIZE:
break;
case KUI_MESSAGE::KICON_CLICK:
{
int nIndex = GetSlotControlNum( lpszControlID );
MoveFocus( nIndex );
Refresh();
}
break;
// { sonador 3.9.1 크리쳐 카드 상세 정보창 우클릭 오픈 기능 구현
case KUI_MESSAGE::KICON_RCLICK:
{
int nIndex = GetSlotControlNum( lpszControlID );
MoveFocus( nIndex );
Refresh();
SInventorySlot* pItemSlot = m_InventoryMgr.GetItemInfo( SStoreMgr::GetInstance().GetItemHandle( nIndex ) );
if( pItemSlot && GetItemDB().GetGroup( pItemSlot->GetItemCode() ) == ItemBase::GROUP_SUMMONCARD )
{
// 2010.08.03 정리 - prodongi
if( m_pGameManager->IsShow( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_CREATURE_CARD_FRONT ) == false )
{
m_pGameManager->PostMsgAtDynamic( new SIMSG_UI_MOVE_EX( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_CREATURE_CARD_FRONT,
GetRect().left,
GetRect().top,
GetRect().right,
GetRect().bottom ) );
}
SMSG_SUMMON_CARD creatureCardMsg;
int insert( -1 );
AR_HANDLE arhandleCard( 0 );
arhandleCard = pItemSlot->GetHandle();
if( arhandleCard )
{
creatureCardMsg.card_handle = arhandleCard;
m_pGameManager->ProcMsgAtStatic( &creatureCardMsg );
}
}
else
{
/// 2011.05.13 - prodongi
int itemCode = SStoreMgr::GetInstance().GetItemCode(nIndex);
if (GetItemDB().GetGroup(itemCode) == ItemBase::GROUP_SUMMONCARD)
{
STORE_ITEM const& info = SStoreMgr::GetInstance().GetBoothItemInfo(nIndex);
SMSG_SUMMON_CARD_ITEM_INFO msg;
msg.level = info.level;
memcpy(&msg.item_info, &info, sizeof (msg.item_info));
m_pGameManager->ProcMsgAtStatic(&msg);
}
}
}
break;
// }
case KUI_MESSAGE::KGENWND_MOVE: // 윈도우 이동
LimitMoveWnd(); // 게임 외부로 나가지 못하게 제한
m_pGameManager->PostMsgAtDynamic( new SIMSG_UI_MOVE( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_SHOPKART, GetRect().right, GetRect().bottom ) );
break;
}
SUIWnd::PumpUpMessage( lpszControlID, nMessage, lparam, wparam );
}
void SUIStoreClientWnd::AddItem()
{
}
void SUIStoreClientWnd::RemoveItem( int idx )
{
assert( idx < SStoreMgr::GetInstance().GetListCount() );
SStoreMgr::GetInstance().RemoveItem( SStoreMgr::GetInstance().GetItemHandle( idx ) );
if( m_nFocus >= SStoreMgr::GetInstance().GetListCount() )
{
MoveFocus( -1 );
}
Refresh();
}
void SUIStoreClientWnd::SetSlotShowMode( size_t idx, bool bShow )
{
assert( idx < MAX_SLOT_COUNT );
for( size_t x = 0; x < CONTROL_PER_SLOT-1; ++x ) //-1한 이유는 disable은 따로 컨트롤 하기 위해서
{
if( bShow && x == SLOT_CONTROL_INDEX::COUNT ) continue;
std::string strControlName( CStringUtil::StringFormat( s_szSlotControlName[x], idx ) );
if( !bShow )
{
KUIWnd* pWnd = GetChild( strControlName.c_str() );
if( pWnd ) pWnd->SetCaption( "" );
}
SetChildShow( strControlName.c_str(), bShow );
}
}
void SUIStoreClientWnd::Refresh()
{
if( SStoreMgr::GetInstance().IsSellMode() ) SetChildAniName( "booth_title_font00", "font_title_streetstallbuy" );
else SetChildAniName( "booth_title_font00", "font_title_streetstallsell" );
KUIWnd* pWnd = NULL;
for( size_t idx = 0; idx < MAX_SLOT_COUNT; ++idx )
{
int StoreItemListCnt( SStoreMgr::GetInstance().GetListCount() );
if( idx < StoreItemListCnt )
{
// 이름 변경
pWnd = GetChild( CStringUtil::StringFormat( s_szSlotControlName[ SLOT_CONTROL_INDEX::NAME ], idx ).c_str() );
std::string strItemName = "<#FBE6AE>";
strItemName += m_pDisplayInfo->GetItemName( SStoreMgr::GetInstance().GetItemCode( idx ), true, SStoreMgr::GetInstance().GetEnhance( idx ), SStoreMgr::GetInstance().GetLevel( idx ), SStoreMgr::GetInstance().GetItemFlag( idx ), false, 0, false, SStoreMgr::GetInstance().GetRandomOption( idx ) );
if( pWnd ) pWnd->SetCaption( strItemName.c_str() );
// 수량 변경 (상점에 등록되있는 수)
pWnd = GetChild( CStringUtil::StringFormat( s_szSlotControlName[ SLOT_CONTROL_INDEX::COUNT ], idx ).c_str() );
if( pWnd )
{
count_t nCount = SStoreMgr::GetInstance().GetItemCount( idx );
if( nCount.getAmount() )
{
std::string strCount = "";
strCount += CStringUtil::GetCommaNumberString( nCount.getAmount() );
pWnd->SetCaption( strCount.c_str() );
pWnd->SetShow( true );
}
else pWnd->SetShow( false );
}
// 가격 변경
std::string strGold = "";
strGold += getGoldString( SStoreMgr::GetInstance().GetItemPrice( idx ) );
pWnd = GetChild( CStringUtil::StringFormat( s_szSlotControlName[ SLOT_CONTROL_INDEX::PRICE ], idx ).c_str() );
if( pWnd ) pWnd->SetCaption( strGold.c_str() );
// 아이콘 변경
KUIControlMultiIcon* pIcon = dynamicCast< KUIControlMultiIcon* >( GetChild( CStringUtil::StringFormat( s_szSlotControlName[ SLOT_CONTROL_INDEX::ICON ], idx ).c_str() ) );
if( pIcon )
{
ResetMultiIcon( pIcon, 0, 8 );
SStoreMgr & storemgr = SStoreMgr::GetInstance();
// 2010.06.14 - prodongi
// 2010.07.08 - prodongi
//SInventorySlot* pSlot = m_InventoryMgr.GetItemInfo( storemgr.GetItemHandle( idx ) );
//std::string iconName;
//getIconNameAtDurability(pSlot, iconName);
/// 2011.08.03 - prodongi
SInventorySlot* pSlot = m_InventoryMgr.GetItemInfo( storemgr.GetItemHandle( idx ) );
if (pSlot)
{
EquipItemAddtionalIconSetter icon_setter( pIcon, pSlot );
}
if( !setSkillCardIcon(pIcon, storemgr.GetItemCode( idx )) )
{
if( pSlot )
{
if( !setSummonCardIcon( pIcon, pSlot ) )
pIcon->SetIcon( 0, c_szDEF_SPR_NAME, GetItemDB().GetIconName( storemgr.GetItemCode( idx ) ) );
}
else
{
if( !setSummonCardIcon( pIcon, storemgr.GetItemCode(idx), storemgr.GetSummonID(idx), storemgr.GetEnhance( idx ), storemgr.GetItemFlag( idx ), storemgr.GetEtherealDurability( idx ) ) )
pIcon->SetIcon( 0, c_szDEF_SPR_NAME, GetItemDB().GetIconName( storemgr.GetItemCode( idx ) ) );
}
}
if( storemgr.GetItemAppearanceCode( idx ) )
pIcon->SetIcon( 4, c_szDEF_SPR_NAME, g_strLookChangeIcon ); // 2012. 7. 27 - marine 아이템 형상변환 아이콘
//pIcon->SetIcon( 0, c_szDEF_SPR_NAME, iconName.c_str());
pIcon->SetIcon( 1, c_szDEF_SPR_NAME, storemgr.GetItemFlag( idx ).IsOn( ItemInstance::ITEM_FLAG_CARD ) ? "static_common_usecreaturecardicon" : NULL );
EquipItemAddtionalIconSetter icon_setter( pIcon, storemgr.GetItemCode( idx ), storemgr.GetEnhance( idx ), storemgr.GetEtherealDurability(idx), storemgr.GetItemFlag( idx ) );
pIcon->SetTooltip( m_pDisplayInfo->GetItemTooltipText(storemgr.GetItemCode( idx ),
true,
storemgr.GetEnhance( idx ),
storemgr.GetLevel( idx ),
storemgr.GetItemFlag( idx ),
storemgr.GetItemRemainTime( idx ),
storemgr.GetItemSocket( idx ),
0,
0,
0,
storemgr.GetItemElementalEffectType(idx),
storemgr.GetItemElementalEffectRemainTime(idx),
storemgr.GetItemElementalEffectAttackPoint(idx),
storemgr.GetItemElementalEffectMagicPoint(idx),
true, // bintitle
storemgr.GetEtherealDurability(idx), //
storemgr.GetEndurance(idx)
,-1
,storemgr.GetSummonID(idx)
,false
,false
,storemgr.GetItemAppearanceCode(idx) // 2012. 7. 26 - marine
,storemgr.GetAwakening(idx)
,storemgr.GetRandomOption(idx)
,storemgr.GetAdditionalItemEffect(idx) // Fraun Sky Accessories 7/12/2025
).c_str() //
);
pIcon->SetCorrectionRect( KRect( 0, 0, 150, 0 ) );
if( m_bAltKey )
{
m_pDisplayInfo->SetComparableEquipItemSubTooltip( pIcon, storemgr.GetItemCode( idx ) );
}
}
SInventorySlot* pSlot(NULL);
count_t nInvenCount(0);
AR_HANDLE hItem = GetItemHandle( SStoreMgr::GetInstance().GetItemCode(idx), SStoreMgr::GetInstance().GetLevel(idx), SStoreMgr::GetInstance().GetEnhance(idx), count_t( 1 ) );
if( hItem ) pSlot = m_InventoryMgr.GetItemInfo( hItem );
if( pSlot ) nInvenCount = pSlot->GetItemCount();
// 수량 변경 (아이콘 위)
pWnd = GetChild( CStringUtil::StringFormat( s_szSlotControlName[ SLOT_CONTROL_INDEX::INVENCNT ], idx ).c_str() );
if( pWnd )
{
if( nInvenCount > 0 )
{
bool bJoin = GetItemDB().IsJoin( SStoreMgr::GetInstance().GetItemCode( idx ), IsInstanceUnstackable(pSlot) );
if( m_bSellStore && !bJoin )
{
pWnd->SetCaption( "" );
pWnd->SetShow( false );
}
else
{
std::string strInvenCnt = S(6425); //""
strInvenCnt += "";
strInvenCnt += CStringUtil::StringFormat( "%I64d", nInvenCount.getAmount() );
pWnd->SetCaption( strInvenCnt.c_str() );
pWnd->SetShow( true );
}
}
else
{
pWnd->SetCaption( "" );
pWnd->SetShow( false );
}
}
//아이템 판매/구매 가능한 갯수만큼의 슬롯 활성화
pWnd = GetChild( CStringUtil::StringFormat( s_szSlotControlName[ SLOT_CONTROL_INDEX::DISABLE ], idx ).c_str() );
if( pWnd )
{
if( !m_bSellStore && !nInvenCount )
pWnd->SetShow(true);
else pWnd->SetShow(false);
}
SetSlotShowMode( idx, true );
}
else
{
KUIWnd* pWnd = GetChild( CStringUtil::StringFormat( s_szSlotControlName[ SLOT_CONTROL_INDEX::DISABLE ], idx ).c_str() );
if( pWnd ) pWnd->SetShow( true );
SetSlotShowMode( idx, false );
}
}
MoveFocus( m_nFocus );
RefreshGold();
RefreshWeight();
}
void SUIStoreClientWnd::MoveFocus( int idx )
{
m_nFocus = idx;
KUIWnd *pBackWnd = GetChild( "item_overback" );
KUIWnd *pIconOverWnd = GetChild( "icon_over" );
KUIWnd *pSelectWnd = GetChild( "item_selectover" );
if( !pBackWnd ) return;
if( !pIconOverWnd ) return;
if( !pSelectWnd ) return;
if( m_nFocus >= 0 && m_nFocus < SStoreMgr::GetInstance().GetListCount() )
{
AR_HANDLE hItem = GetItemHandle( SStoreMgr::GetInstance().GetItemCode(idx), SStoreMgr::GetInstance().GetLevel(idx), SStoreMgr::GetInstance().GetEnhance(idx), count_t( 1 ) );
SInventorySlot* pSlot = m_InventoryMgr.GetItemInfo( hItem );
count_t nInvenItemCnt(0);
if( pSlot )
nInvenItemCnt = pSlot->GetItemCount();
if( !m_bSellStore && nInvenItemCnt <= 0 ) return;
KUIWnd *pTopIcon = GetChild( "booth_item_icon00" );
KUIWnd *pLeftIcon = GetChild( "booth_itemname_text00" );
pIconOverWnd->MovePos( pTopIcon->GetRect().left, pTopIcon->GetRect().top + m_nFocus * SLOT_Y_DELTA );
SetChildAsTop( "icon_over" );
pBackWnd->MovePos( pTopIcon->GetRect().left - 5, pTopIcon->GetRect().top + m_nFocus * SLOT_Y_DELTA - 6 );
pSelectWnd->MovePos( pTopIcon->GetRect().left - 5, pTopIcon->GetRect().top + m_nFocus * SLOT_Y_DELTA - 6 );
pBackWnd->SetShow( true );
pIconOverWnd->SetShow( true );
pSelectWnd->SetShow( true );
}
else
{
pBackWnd->SetShow( false );
pIconOverWnd->SetShow( false );
pSelectWnd->SetShow( false );
}
}
void SUIStoreClientWnd::RefreshGold()
{
KUIWnd* pWnd = GetChild( "static_item_rp_value" );
if( NULL != pWnd )
{
std::string strGold = "";
strGold += S(6301);
strGold += CStringUtil::GetCommaNumberString( m_PlayerInfoMgr.GetPlayerInfo().GetGold().getAmount() );
pWnd->SetCaption( strGold.c_str() );
}
}
void SUIStoreClientWnd::RefreshWeight()
{
float fInvenWeight = m_PlayerInfoMgr.GetPlayerInfo().GetInvenWeigth();
int nMaxWeight = m_PlayerInfoMgr.GetPlayerInfo().GetWeight();
float fWeightRatio = fInvenWeight / float(nMaxWeight) * 100.f;
KUIWnd* pWnd = GetChild( "static_item_wt_value" );
if( NULL != pWnd )
{
std::string strWeight = CStringUtil::StringFormat( "%s%d%% (", S(6301), int(fWeightRatio) );
strWeight += CStringUtil::GetCommaNumberString( fInvenWeight );
strWeight += "/";
strWeight += CStringUtil::GetCommaNumberString( nMaxWeight );
strWeight += ")";
pWnd->SetCaption( strWeight.c_str() );
}
}
void SUIStoreClientWnd::SendEndWatchBoothMsg()
{
SMSG_WATCH_BOOTH msg( m_hTarget, false );
m_pGameManager->ProcMsgAtStatic( &msg );
}
bool SUIStoreClientWnd::GetMoveItemCount( int idx, bool bSellStore )
{
if( idx == -1 || SStoreMgr::GetInstance().GetListCount() <= idx ) return false;
count_t nMaxCnt = SStoreMgr::GetInstance().GetItemCount(idx);
if( !bSellStore )
{
AR_HANDLE hItem = GetItemHandle( SStoreMgr::GetInstance().GetItemCode(idx), SStoreMgr::GetInstance().GetLevel(idx), SStoreMgr::GetInstance().GetEnhance(idx), count_t( 1 ) );
SInventorySlot* pSlot = m_InventoryMgr.GetItemInfo( hItem );
count_t nInvenItemCnt(0);
if( pSlot ) nInvenItemCnt = pSlot->GetItemCount();
if( nInvenItemCnt <= 0 ) return false;
nMaxCnt = std::min(nMaxCnt, nInvenItemCnt);
}
if( nMaxCnt == 0 ) return false;
else if( nMaxCnt != 1 )
{
m_pGameManager->PostMsgAtDynamic( new SIMSG_UI_REQ_INPUTNUMBER( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_STORE_CLIENT, nMaxCnt ) );
return false;
}
return true;
}
void SUIStoreClientWnd::MoveItemToKart( int idx, count_t nItemCnt )
{
if( idx >= 0 && idx < SStoreMgr::GetInstance().GetListCount() )
{
if( nItemCnt.getAmount() )
{
if( m_bSellStore )
m_pGameManager->PostMsgAtDynamic( new SIMSG_UI_STORE_BUYITEM_TOKART( SStoreMgr::GetInstance().GetBoothItemInfo(idx), nItemCnt, idx ) );
else
{
AR_HANDLE hItem = GetItemHandle( SStoreMgr::GetInstance().GetItemCode(idx), SStoreMgr::GetInstance().GetLevel(idx), SStoreMgr::GetInstance().GetEnhance(idx), nItemCnt );
if( hItem )
m_pGameManager->PostMsgAtDynamic( new SIMSG_UI_STORE_SELLITEM_TOKART( hItem, nItemCnt, idx ) );
}
}
}
}
void* SUIStoreClientWnd::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( &msg );
const char* szControlID = pBeginMsg->sDragControlID.c_str();
KUIControlMultiIcon* pWndMultiIcon = dynamicCast< KUIControlMultiIcon* >( GetChild( szControlID ) );
if( NULL == pWndMultiIcon ) goto PASS;
const KUIControlMultiIcon::ICON_INFO& rIconInfo = pWndMultiIcon->GetIconInfoByLayer(0);
int nDragIndex = atoi( szControlID + strlen(szControlID)-2 );
if( nDragIndex >= SStoreMgr::GetInstance().GetListCount() ) goto PASS;
// { 드랙앤 드롭 정보 세팅
m_nDragIndex = nDragIndex;
m_pDragAndDropIcon->SetStateIcon( pWndMultiIcon->GetSprName(), rIconInfo.sAniName.c_str(), rIconInfo.nFrameIndex, STATE_NORMAL );
pBeginMsg->pDragAndDropRenderer = m_pDragAndDropIcon;
m_pDisplayInfo->SetUIDragInfo( new SUIStoreItemDragInfo( SStoreMgr::GetInstance().GetItemCode( m_nDragIndex ),
!SStoreMgr::GetInstance().IsSellMode(),
SStoreMgr::GetInstance().GetLevel( m_nDragIndex ),
SStoreMgr::GetInstance().GetEnhance( m_nDragIndex ),
SStoreMgr::GetInstance().GetEndurance( m_nDragIndex ),
*SStoreMgr::GetInstance().GetItemFlag( m_nDragIndex ).GetRawData(),
m_nDragIndex)
);
// }
return NULL;
}
else if ( id == id_UI_SEND_DROP )
{
// 대상이 카트가 아니라면 KIN 해야함.
// m_nDragIndex 를 카트로 옮기세~
if( m_nDragIndex < 0 || m_nDragIndex >= SStoreMgr::GetInstance().GetListCount() ) goto PASS;
if( SStoreMgr::GetInstance().GetItemCount( m_nDragIndex ) > 1 )
{
m_pGameManager->PostMsgAtDynamic( new SIMSG_UI_REQ_INPUTNUMBER( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_STORE_CLIENT, SStoreMgr::GetInstance().GetItemCount( m_nDragIndex ), SIMSG_UI_REQ_INPUTNUMBER::TYPE_NUMBER ) );
}
else
{
MoveItemToKart( (int)m_nDragIndex, count_t( 1 ) );
}
}
PASS:
return SUIWnd::Perform( id, msg );
}
count_t SUIStoreClientWnd::GetItemCountInven( ItemBase::ItemCode code, int level, int enhance, int nFlag )
{
count_t itemCnt(0);
std::vector ItemList;
m_InventoryMgr.GetItemInfo( ItemList, code, level, enhance );
int nCnt( ItemList.size() );
if( nCnt == 0 ) return count_t( 0 );
if( nCnt && !GetItemDB().IsJoin(code, IsInstanceUnstackable(nFlag) ) )
{
ItemList.clear();
return count_t( 1 );
}
for( int i(0); iIsStorageItem() && !ItemList[i]->IsEquipItem() ) //인벤에 있으면서 장착하지 않은 아이템이어야 한다
itemCnt = std::max(itemCnt, ItemList[i]->GetItemCount()); //중첩되는 아이템이 있다면 그중에 가장 많은 수를 가진 것을 리턴
}
ItemList.clear();
return itemCnt;
}
AR_HANDLE SUIStoreClientWnd::GetItemHandle( ItemBase::ItemCode code, int level, int enhance, count_t byCount )
{
std::vector ItemList;
m_InventoryMgr.GetItemInfo( ItemList, code, level, enhance );
int nCnt( ItemList.size() );
if( nCnt == 0 ) return 0;
for( int i(0); iGetItemCount() >= byCount && // 개수가 맞지 않거나
false == ItemList[i]->IsStorageItem() && // 창고 아이템 이거나
false == ItemList[i]->IsEquipItem() && // 장착 되어이쓴 아이템 이거나
NULL == m_CreatureSlotMgr.GetCreatureInfoByCardHandle( ItemList[i]->GetHandle() ) // 한번도 편성되지 않은 크리쳐 카드라면 등록!
)
{
AR_HANDLE handle = ItemList[i]->GetHandle();
ItemList.clear();
return handle;
}
}
ItemList.clear();
return NULL;
}