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

550 lines
20 KiB
C++

#include "stdafx.h"
// messages...
#include "SGameMessage.h"
//#include "SGameMessageUI.h"
#include "ErrorCode/ErrorCode.h"
// managers...
#include "SGameManager.h"
#include "KUIWndManager.h"
#include "SInventoryMgr.h"
// DBs...
#include "SItemDB.h"
#include "SStringDB.h"
// Utils...
#include <toolkit/XStringUtil.h>
// gui controls...
#include "SUIDisplayInfo.h"
#include "KUITabControl.h"
#include "KUIControlStatic.h"
#include "KUIControlEdit.h"
#include "KUIControlButton.h"
#include "KUIControlList.h"
#include "SUIAuctionWnd.h"
#include "SDebug_Util.h"
namespace auction {
namespace deposit {
// column...
const char* column_item = "button_01";
const char* column_storabletime = "button_02";
const char* column_state = "button_03";
// item list...
const char* list_select = "selectbar_on";
const char* list_back = "selectbar_back_%.2d";
const char* list_icon = "itemslot_%.2d";
const char* list_item_count = "itemslot_count_%.2d";
const char* list_item_s = "static_itemtexts01_%.2d";
const char* list_item_n = "static_itemtextn01_%.2d";
const char* list_item_l = "static_itemtextl01_%.2d";
const char* list_storabletime = "static_itemtext04_%.2d";
const char* list_state = "static_itemtext05_%.2d";
// selected...
const char* selected_back = "selected_back_%.2d";
const char* selected_icon = "selected_itemslot_%.2d";
const char* selected_item_count = "selected_itemslot_count_%.2d";
const char* selected_item_s = "static_selected_itemtexts01_%.2d";
const char* selected_item_n = "static_selected_itemtextn01_%.2d";
const char* selected_item_l = "static_selected_itemtextl01_%.2d";
const char* selected_storabletime = "static_selected_itemtext04_%.2d";
const char* selected_state = "static_selected_itemtext05_%.2d";
// etc...
const char* list_scrollbar = "auction_scrollbar";
const char* withdraw = "button_common01_01";
const char* page_now = "static_page_01";
const char* page_max = "static_page_02";
const char* page_left = "button_page_left";
const char* page_right = "button_page_right";
// deco...
const char* deco_list_item_s = "<#ffeab1><vcenter><left><size:10><shadow>+%s";
const char* deco_list_item_n = "<#ffeab1><vcenter><left><size:10><shadow>%s";
//'Lv'을 String DB 9501로 참조하도록 한다 2009.09.25. sfreer
char* deco_list_item_l = NULL;//"<#ffeab1><vcenter><left><size:10><shadow>La%s";
const char* deco_list_storabletime = "<hcenter><vcenter><size:10><shadow>%s";
const char* deco_list_state = "<hcenter><vcenter><size:10><shadow>%s";
const char* deco_list_item_count = "<right><vcenter><size:8><font:돋움><shadow>%s";
const char* deco_rupy = "<#fec530><vcenter><hcenter><size:10><shadow>%s";
const char* deco_page_now = "<right><vcenter><size:10><shadow>%d /";
const char* deco_page_max = "<right><vcenter><size:10><shadow>%d";
}
}
// 2010.04.22 - prodongi
SUIAuctionDepositWnd::~SUIAuctionDepositWnd()
{
SAFE_DELETE_ARRAY(auction::deposit::deco_list_item_l);
}
// diposit window ---------------------------------------------------------------------------------
void SUIAuctionDepositWnd::ItemImporter::operator()( item_t& item )
{
// sonador 7.0.23 Mantis 0002812: [경매장] 불필요한 대장장이 Lv 표시 제거 요청
const ItemBaseEx_info* itemBaseInfo = GetItemDB().GetItemData( item.item_info.Code );
if( !itemBaseInfo )
return;
sui::proxy_list::item_t* element = new sui::proxy_list::item_t();
element->add( &( new sui::property( "id" ) )->set_value( item.keeping_uid ) );
element->add( &( new sui::property( "icon" ) )->set_resource( &item.item_info ) );
if( GetItemDB().IsJoin( item.item_info.Code, IsInstanceUnstackable( item.item_info.Flag ) ) && item.item_info.count > 0 )
element->add( &( new sui::property( "item_count" ) )->set_value< count_t::value_t >( item.item_info.count ) );
if( item.item_info.Code == 0 ) // if code is 0, then it must be coins...
{
std::string strRacAmount( sui::helper::int_to_comma_numeric( item.item_info.count ).c_str() );
strRacAmount += " ";
strRacAmount += S( 6618 );
element->add( &( new sui::property( "item_n" ) )->set_value( strRacAmount.c_str() ) );
}
else
{
int nEnhance = (int)item.item_info.enhance;
if( nEnhance > 0 )
{
element->add( &( new sui::property( "item_s" ) )->set_value( nEnhance ) );
}
element->add( &( new sui::property( "item_n" ) )->set_value( GetStringDB().GetString( itemBaseInfo->nNameId ) ) );
// sonador 7.0.23 Mantis 0002812: [경매장] 불필요한 대장장이 Lv 표시 제거 요청
// sonador 7.0.28 카오스 스톤 Lv 표시 활성화
if( SUIDisplayInfo::IsEnhanceableItem( item.item_info.Code, itemBaseInfo ) && itemBaseInfo->nGroup != ItemBase::GROUP_SKILLCARD )
{
element->add( &( new sui::property( "item_l" ) )->set_value( (int)item.item_info.level ) );
}
}
element->add( &( new sui::property( "storabletime" ) )->set_value( item.duration ) );
typedef auction::kui_window_deposit_status_caption_property::StatusInfo status_info_t;
element->add( &( new sui::property( "status" ) )->set_resource(
&status_info_t( item.keeping_type
, ( item.item_info.Code == 0 ) ? true : false
, item.related_item_code
, item.related_item_enhance
, item.related_item_level ) ) );
m_target_list.add( element );
}
bool SUIAuctionDepositWnd::InitControls( KPoint kPos )
{
// init controls here...
// auction::deposit::deco_list_item_l 변수 할당은 하는데 안지워줌
// hunee : 2010.2.10
//'Lv'을 String DB 9501로 참조하도록 한다 2009.09.25. sfreer
if(auction::deposit::deco_list_item_l == NULL)
{
std::string str_deco_list_item_l = "<#ffeab1><vcenter><left><size:10><shadow>";
str_deco_list_item_l += GetStringDB().GetString( 9501 );
str_deco_list_item_l += "%s";
auction::deposit::deco_list_item_l = new char[str_deco_list_item_l.length()+1];
memset(auction::deposit::deco_list_item_l,0,str_deco_list_item_l.length()+1);
strcpy(auction::deposit::deco_list_item_l,str_deco_list_item_l.c_str());
}
// item list view
m_ItemList.initialize( auction::deposit::list_back, auction::deposit::list_select, auction::deposit::list_scrollbar );
m_ItemList.add_column( auction::deposit::list_icon , new auction::kui_window_item_icon_property( "icon", m_pDisplayInfo, this, m_InventoryMgr ) );
m_ItemList.add_column( auction::deposit::list_item_count , new sui::kui_window_caption_property( "item_count", auction::deposit::deco_list_item_count ) );
m_ItemList.add_column( auction::deposit::list_item_s , new sui::kui_window_caption_property( "item_s", auction::deposit::deco_list_item_s ) );
m_ItemList.add_column( auction::deposit::list_item_n , new sui::kui_window_caption_property( "item_n", auction::deposit::deco_list_item_n ) );
m_ItemList.add_column( auction::deposit::list_item_l , new sui::kui_window_caption_property( "item_l", auction::deposit::deco_list_item_l ) ); // str_deco_list_item_l.c_str() ) );
m_ItemList.add_column( auction::deposit::list_storabletime , new auction::kui_window_storabletime_caption_property( "storabletime", auction::deposit::deco_list_storabletime ) );
m_ItemList.add_column( auction::deposit::list_state , new auction::kui_window_deposit_status_caption_property( "status", auction::deposit::deco_list_state ) );
// selected item view
m_SelectedItem.initialize( auction::deposit::selected_back, 0, 0 );
m_SelectedItem.add_column( auction::deposit::selected_icon , new auction::kui_window_item_icon_property( "icon", m_pDisplayInfo, this, m_InventoryMgr ) );
m_SelectedItem.add_column( auction::deposit::selected_item_count , new sui::kui_window_caption_property( "item_count", auction::deposit::deco_list_item_count ) );
m_SelectedItem.add_column( auction::deposit::selected_item_s , new sui::kui_window_caption_property( "item_s", auction::deposit::deco_list_item_s ) );
m_SelectedItem.add_column( auction::deposit::selected_item_n , new sui::kui_window_caption_property( "item_n", auction::deposit::deco_list_item_n ) );
m_SelectedItem.add_column( auction::deposit::selected_item_l , new sui::kui_window_caption_property( "item_l", auction::deposit::deco_list_item_l ) ); // str_deco_list_item_l.c_str() ) );
m_SelectedItem.add_column( auction::deposit::selected_storabletime , new auction::kui_window_storabletime_caption_property( "storabletime", auction::deposit::deco_list_storabletime ) );
m_SelectedItem.add_column( auction::deposit::selected_state , new auction::kui_window_deposit_status_caption_property( "status", auction::deposit::deco_list_state ) );
// pages..
m_pCtrlCurrentPage = dynamicCast< KUIControlStatic* >( GetChild( auction::deposit::page_now ) );
m_pCtrlEndPage = dynamicCast< KUIControlStatic* >( GetChild( auction::deposit::page_max ) );
// page button
KUIControlSimpleButton* pPrevButton = dynamicCast< KUIControlSimpleButton* >( GetChild( auction::deposit::page_left ) ); // 2011.11.24 - servantes : KUIControlButton -> KUIControlSimpleButton 으로 변경
KUIControlSimpleButton* pNextButton = dynamicCast< KUIControlSimpleButton* >( GetChild( auction::deposit::page_right ) ); // 2011.11.24 - servantes : KUIControlButton -> KUIControlSimpleButton 으로 변경
m_Page.SetButton( pPrevButton, pNextButton );
// ticking buttons..
KUIControlButton* pWithdrawButton = dynamicCast< KUIControlButton* >( GetChild( auction::deposit::withdraw ) );
m_LazyMsgPoster.AppendAction( new sui::ActionBinder( new sui::ActionDisableControl( pWithdrawButton ), new sui::ActionEnableControl( pWithdrawButton ), 0 ) );
m_LazyMsgPoster.AppendAction( new sui::ActionBinder( new sui::ActionHideControl( pPrevButton ), new sui::ActionShowControl( pPrevButton ), 0 ) );
m_LazyMsgPoster.AppendAction( new sui::ActionBinder( new sui::ActionHideControl( pNextButton ), new sui::ActionShowControl( pNextButton ), 0 ) );
m_LazyMsgPoster.AppendAction( new sui::ActionBinder( new auction::ActionDisableProxyListMouseProc( m_ItemList ), new auction::ActionEnableProxyListMouseProc( m_ItemList ), 0 ) );
m_LazyMsgPoster.AppendAction( new sui::ActionBinder( new auction::ActionClearProxyList( m_SelectedItem ), 0, 0 ) );
return SUIWnd::InitControls( kPos );
}
bool SUIAuctionDepositWnd::InitData( bool bReload )
{
// init data here...
return SUIWnd::InitData( bReload );
}
void* SUIAuctionDepositWnd::Perform( KID id, KArg& msg )
{
// process perform message here...
return SUIWnd::Perform( id, msg );
}
void SUIAuctionDepositWnd::PumpUpMessage( LPCTSTR lpszControlID, DWORD nMessage, DWORD lparam, DWORD wparam )
{
// process control message here...
m_ItemList.proc_pumpup( lpszControlID, nMessage, lparam, wparam );
switch( nMessage )
{
case KUI_MESSAGE::KBUTTON_CLICK:
{
if( ::_stricmp( lpszControlID, "IDOK" ) == 0 )
{
// 요청한 윈도우로 보내준다.
}
else if( ::stricmp( lpszControlID, auction::deposit::column_item ) == 0 )
{
_SortItemListByColumn( COLUMN::ITEM );
m_ItemList.update_data();
m_SelectedItem.clear();
m_SelectedItem.update_data();
}
else if( ::stricmp( lpszControlID, auction::deposit::column_storabletime ) == 0 )
{
_SortItemListByColumn( COLUMN::STORABLETIME );
m_ItemList.update_data();
m_SelectedItem.clear();
m_SelectedItem.update_data();
}
else if( ::stricmp( lpszControlID, auction::deposit::column_state ) == 0 )
{
_SortItemListByColumn( COLUMN::STATE );
m_ItemList.update_data();
m_SelectedItem.clear();
m_SelectedItem.update_data();
}
else if( ::stricmp( lpszControlID, auction::deposit::page_left ) == 0 )
{
_RequestKeepingList( m_Page.Prev() );
m_bMaintainListState = false;
}
else if( ::stricmp( lpszControlID, auction::deposit::page_right ) == 0 )
{
_RequestKeepingList( m_Page.Next() );
m_bMaintainListState = false;
}
else if( ::stricmp( lpszControlID, auction::deposit::withdraw ) == 0 )
{
if( m_ItemList.empty() )
break;
item_list_t::iterator i = m_ItemList.begin(), e = m_ItemList.end();
for( ; i != e; ++i )
{
item_list_t::item_t& item_prop = *( *i );
_RequestDrawingItem( item_prop[ "id" ].get_int_value() );
}
_RequestKeepingList( m_Page.Prev() );
m_SelectedItem.clear();
m_SelectedItem.update_data();
m_bMaintainListState = false;
}
}
break;
case KUI_MESSAGE::KLIST_ITEM_SELECT:
{
// message from item list...
if( ::stricmp( lpszControlID, "item_list" ) == 0 )
{
int index = static_cast< int >( lparam );
sui::proxy_list::item_t* item = m_ItemList.at( index );
if( item )
{
m_SelectedItem.clear();
m_SelectedItem.add( new sui::proxy_list::item_t( *item ) );
m_SelectedItem.update_data();
}
}
}
break;
case KUI_MESSAGE::KLIST_ITEM_LDBLCLK:
{
//m_NoticeBox.AppendUrgent( "더블클릭하셨습니다..." );
// message from item list...
if( ::stricmp( lpszControlID, "item_list" ) == 0 )
{
int index = static_cast< int >( lparam );
sui::proxy_list::item_t* item = m_ItemList.at( index );
if( item )
{
_RequestDrawingItem( item->get( "id" ).get_int_value() );
_RequestKeepingList();
m_SelectedItem.clear();
m_SelectedItem.update_data();
}
}
}
break;
/// 2011.05.13 - prodongi
case KUI_MESSAGE::KICON_RCLICK:
{
if( ::stricmp( lpszControlID, "item_list" ) == 0 )
{
int index = static_cast< int >( lparam );
sui::proxy_list::item_t* item = m_ItemList.at( index );
if( item )
{
TS_ITEM_BASE_INFO* info = 0;
item->get( "icon" ).get_resource( info );
if(info && GetItemDB().GetGroup(info->Code) == ItemBase::GROUP_SUMMONCARD )
{
SMSG_SUMMON_CARD_ITEM_INFO msg;
msg.level = info->level;
memcpy(&msg.item_info, info, sizeof (msg.item_info));
m_pGameManager->ProcMsgAtStatic(&msg);
}
}
}
}
break;
}
SUIWnd::PumpUpMessage( lpszControlID, nMessage, lparam, wparam );
}
void SUIAuctionDepositWnd::ProcMsgAtStatic( SGameMessage* pMsg )
{
// process game message here...
switch( pMsg->nType )
{
case IMSG_RES_AUCTION_ITEM_KEEPING_LIST:
{
SIMSG_RES_AUCTION_ITEM_KEEPING_LIST* msg = dynamicCast< SIMSG_RES_AUCTION_ITEM_KEEPING_LIST* >( pMsg );
if( !msg )
break;
// update page
_UpdatePage( msg->page_num, msg->total_page_count );
// import auction items to list
if( m_bMaintainListState )
m_ItemList.save_state();
m_ItemList.clear();
if( msg->keeping_info_count > 0 )
{
std::for_each( msg->keeping_info, msg->keeping_info + msg->keeping_info_count, ItemImporter( m_ItemList ) );
_SortItemListByColumn( m_nSavedSortingState, true );
if( m_bMaintainListState )
m_ItemList.load_state();
}
m_bMaintainListState = true;
m_ItemList.update_data();
m_SelectedItem.clear();
m_SelectedItem.update_data();
}
break;
case MSG_RESULT:
{
SMSG_RESULT* msg = dynamicCast< SMSG_RESULT* >( pMsg );
switch( msg->request_msg_id )
{
case TM_CS_ITEM_KEEPING_LIST:
if( msg->result == RESULT_NOT_EXIST )
{
m_ItemList.clear();
m_ItemList.update_data();
m_SelectedItem.clear();
m_SelectedItem.update_data();
}
break;
}
}
break;
case IMSG_HOTKEY_EX:
{
SIMSG_HOTKEY_EX* pHotKey = dynamicCast<SIMSG_HOTKEY_EX*>(pMsg);
if( pHotKey->wParam == VK_SHIFT )
m_bShiftKey = (pHotKey->bUp == 0); //servantes 2010.10.15
if( pHotKey->wParam == VK_CONTROL ) //servantes 2010.10.15
m_bControlKey = (pHotKey->bUp == 0);
if( pHotKey->wParam == VK_MENU )
{
bool bPreState = m_bAltKey;
m_bAltKey = (pHotKey->bUp == 0);
if( bPreState != m_bAltKey && IsShow() )
{
m_ItemList.update_data();
m_SelectedItem.update_data();
}
}
}
break;
}
}
void SUIAuctionDepositWnd::OnNotifyUIWindowOpen( bool bOpen, bool bLimitWnd )
{
SUIWnd::OnNotifyUIWindowOpen( bOpen, bLimitWnd );
if( bOpen )
{
// temporary import data
RefreshCategory();
_RequestKeepingList();
//m_NoticeBox.AppendUrgent( "창고..." );
}
else
{
m_ItemList.clear();
m_SelectedItem.clear();
}
}
DWORD SUIAuctionDepositWnd::OnMouseMessage( DWORD dwMessage, int x, int y )
{
DWORD dwRet = SUIWnd::OnMouseMessage( dwMessage, x, y );
if( KMR_NO_GET & dwRet )
return dwRet;
m_ItemList.proc_mouse( dwMessage, x, y );
return dwRet;
}
void SUIAuctionDepositWnd::RefreshCategory()
{
m_ItemList.clear();
m_ItemList.update_data();
m_SelectedItem.clear();
m_SelectedItem.update_data();
_UpdatePage();
m_bMaintainListState = false;
}
void SUIAuctionDepositWnd::_UpdatePage( int nCurrent, int nTotal )
{
std::string strCurrentPage, strEndPage;
m_Page.Update( nCurrent, nTotal );
XStringUtil::Format( strCurrentPage, auction::deposit::deco_page_now, m_Page.Current() );
XStringUtil::Format( strEndPage, auction::deposit::deco_page_max, m_Page.End() );
m_pCtrlCurrentPage->SetCaption( strCurrentPage.c_str() );
m_pCtrlEndPage->SetCaption( strEndPage.c_str() );
}
void SUIAuctionDepositWnd::_GetTemporaryListData()
{
//m_ItemList.clear();
//// temporary
//std::vector< SInventorySlot* > auction_items;
//m_pInvenMgr->GetInvenDataList( UI_ITEM_CATEGORY::UI_ITEM_ALL, auction_items );
//struct AuctionItemImporter {
// AuctionItemImporter ( item_list_t& list ) : m_target_list( list ) { }
// void operator()( SInventorySlot* slot ) {
// sui::proxy_list::item_t* item = new sui::proxy_list::item_t();
// int nHandle = slot->GetHandle();
// item->add( &( new sui::property( "icon" ) )->set_value( nHandle ) );
// if( GetItemDB().IsJoin( slot->GetItemCode() ) && slot->GetItemCount() > 0 )
// item->add( &( new sui::property( "item_count" ) )->set_value( slot->GetItemCount() ) );
// item->add( &( new sui::property( "item_s" ) )->set_value( slot->GetEnhance() ) );
// item->add( &( new sui::property( "item_n" ) )->set_value( GetStringDB().GetString( GetItemDB().GetItemData( slot->GetItemCode() )->nNameId ) ) );
// item->add( &( new sui::property( "item_l" ) )->set_value( slot->GetLevel() ) );
// item->add( &( new sui::property( "storabletime" ) )->set_value( 0 + ::rand() % 48 ) );
// m_target_list.add( item );
// }
// item_list_t& m_target_list;
//};
//std::for_each( auction_items.begin(), auction_items.end(), AuctionItemImporter( m_ItemList ) );
//m_ItemList.update_data();
}
void SUIAuctionDepositWnd::_RequestKeepingList( int nPage )
{
SIMSG_REQ_AUCTION_ITEM_KEEPING_LIST* pMsg = new SIMSG_REQ_AUCTION_ITEM_KEEPING_LIST( nPage );
m_LazyMsgPoster.PostMsgAtDynamic( pMsg );
}
void SUIAuctionDepositWnd::_RequestDrawingItem( int nKeepingID )
{
SIMSG_REQ_AUCTION_ITEM_KEEPING_TAKE* msg = new SIMSG_REQ_AUCTION_ITEM_KEEPING_TAKE();
msg->keeping_uid = nKeepingID;
m_pGameManager->PostMsgAtDynamic( msg );
}
void SUIAuctionDepositWnd::_SortItemListByColumn( COLUMN id, bool maintain )
{
typedef auction::kui_window_deposit_status_caption_property::StatusInfo status_info_t;
if( !maintain )
m_bSortButtonState[ id ] = !m_bSortButtonState[ id ];
// default sorting... by auction id
m_ItemList.sort< int >( "id", auction::ColumnCompareLessThen< int >() );
switch( id )
{
case COLUMN::ITEM:
m_ItemList.stable_sort< int >( "item_l", auction::ColumnCompareLessThen< int >() );
if( m_bSortButtonState[ id ] == 0 )
m_ItemList.stable_sort< std::string >( "item_n", auction::ColumnCompareLessThen< std::string >() );
else
m_ItemList.stable_sort< std::string >( "item_n", auction::ColumnCompareMoreThen< std::string >() );
break;
case COLUMN::STORABLETIME:
if( m_bSortButtonState[ id ] == 0 )
m_ItemList.stable_sort< int >( "storabletime", auction::ColumnCompareMoreThen< int >() );
else
m_ItemList.stable_sort< int >( "storabletime", auction::ColumnCompareLessThen< int >() );
break;
case COLUMN::STATE:
if( m_bSortButtonState[ id ] == 0 )
m_ItemList.stable_sort_resource< status_info_t >( "status", auction::ColumnCompareLessThen< status_info_t >() );
else
m_ItemList.stable_sort_resource< status_info_t >( "status", auction::ColumnCompareMoreThen< status_info_t >() );
break;
default:
return;
}
m_nSavedSortingState = id;
}