Files
2026-06-01 12:46:52 +02:00

1131 lines
36 KiB
C++

#pragma once
#include <queue>
//#include "SUIWnd.h"
#include "SUIProperty.h" // sonador #2.1.2.4.3 팻 조작 UI 연동
// forward declaration
class SUIDisplayInfo;
class SUIAuctionSearchWnd;
class SUIAuctionRegisterWnd;
class SUIAuctionTenderWnd;
class SUIAuctionDepositWnd;
class KUIControIStringList;
class KUIControlEdit;
class KUIControlCheck;
class SInventorySlot;
/// auction components
namespace auction {
namespace rule {
const DWORD DEFAULT_REQ_DELAY = 1000;
const DWORD SEARCH_REQ_DELAY = 3000;
const int INPUT_NUMBER_LIMIT = 17; // 숫자 12개 "," 3개
const unsigned __int64 MAX_PRICE = 9223372036854775807; ///< 아이템 최대 가격
const __int64 PRICE_COLOR_CUT_1 = 1000000000000; // Price color division section 1
const __int64 PRICE_COLOR_CUT_2 = 100000000000; // Price color division section 2
const __int64 PRICE_COLOR_CUT_3 = 10000000000; // Price color division section 3
const __int64 PRICE_COLOR_CUT_4 = 1000000000; // Price color division section 4
const __int64 PRICE_COLOR_CUT_5 = 100000000; // Price color division section 5
const __int64 PRICE_COLOR_CUT_6 = 10000000; // Price color division section 6
const __int64 PRICE_COLOR_CUT_7 = 1000000; // Price color division section 7
//AziaMafia HDV Taxe Time
const float COMMISSION_SHORT_RATIO = 0.03f;
const float COMMISSION_MIDDLE_RATIO = 0.04f;
const float COMMISSION_LONG_RATIO = 0.05f;
const float PURCHASE_RATIO = 0.0f;
const float TENDER_RATIO = 0.01f;
/*
const float COMMISSION_SHORT_RATIO = 0.00f;
const float COMMISSION_MIDDLE_RATIO = 0.00f;
const float COMMISSION_LONG_RATIO = 0.00f;
const float PURCHASE_RATIO = 0.0f;
const float TENDER_RATIO = 0.01f;
*/
//AziaMafia HDV Taxe Time
enum DURATION {
DUR_SHORT,
DUR_MIDDLE,
DUR_LONG,
DUR_MAX,
};
void NormalizeBasePrice( money_t& nPrice );
void NormalizePurchasePrice( money_t& nPrice );
std::string GetColorTagByPrice( money_t nGold );
KColor GetColorValueByPrice( money_t nGold );
money_t GetBiddablePrice( money_t nBasePrice );
money_t GetPurchasePriceBasedOn( money_t nBasePrice );
money_t GetGuaranteeBasedOn( DURATION dur, money_t nBasePrice );
money_t GetPriceFrom( KUIControlEdit* pEdit );
void SetPriceTo( KUIControlEdit* pEdit, money_t nPrice );
void SetPriceTo( KUIControlStatic* pStatic, money_t nPrice );
}
template< typename T >
struct ColumnCompareLessThen { bool operator()( const T& lhs, const T& rhs ) const { return lhs < rhs; } };
template< typename T >
struct ColumnCompareMoreThen { bool operator()( const T& lhs, const T& rhs ) const { return rhs < lhs; } };
struct RankCompareLessThen { bool operator()( const std::string& lhs, const std::string& rhs ) const
{ if (lhs == GetStringDB().GetString( 6370 )) return true; if (rhs == GetStringDB().GetString( 6370 )) return false; return lhs < rhs; } };
struct RankCompareMoreThen { bool operator()( const std::string& lhs, const std::string& rhs ) const
{ if (lhs == GetStringDB().GetString( 6370 )) return false; if (rhs == GetStringDB().GetString( 6370 )) return true; else return rhs < lhs; } };
const char* GetAuctionDuration( int nAuctionDurationType );
const char* GetAuctionStatus( unsigned char ucAuctionStatus );
const char* GetAuctionBiddedStatus( unsigned char ucAuctionBiddedStatus );
const char* GetAuctionDepositStatus( unsigned char ucAuctionKeepingType );
class kui_window_item_icon_property : public sui::kui_window_property
{
public:
kui_window_item_icon_property( const char* name, SUIDisplayInfo* display, SUIWnd* pParent, SInventoryMgr& inven )
: kui_window_property( name ), m_display( display ), m_pParent( pParent ), m_InventoryMgr( inven ) {}
kui_window_item_icon_property( const kui_window_item_icon_property& rhs )
: kui_window_property( rhs ), m_display( rhs.m_display ), m_pParent( rhs.m_pParent ), m_InventoryMgr( rhs.m_InventoryMgr ) {}
virtual ~kui_window_item_icon_property() {}
virtual void on_update( property& data );
virtual sui::kui_window_property& set_value( KUIWnd* value );
protected:
SUIDisplayInfo* m_display;
SUIWnd* m_pParent;
class SInventoryMgr& m_InventoryMgr;
};
class kui_window_purchase_price_caption_property : public sui::kui_window_caption_property
{
public:
kui_window_purchase_price_caption_property( const char* name, const char* caption_decorator = 0, const char* alternative_string = 0 )
: kui_window_caption_property( name, caption_decorator )
, m_alternative_string( alternative_string )
{
}
kui_window_purchase_price_caption_property( const kui_window_purchase_price_caption_property& rhs )
: kui_window_caption_property( rhs )
, m_alternative_string( rhs.m_alternative_string )
{}
virtual ~kui_window_purchase_price_caption_property() {}
virtual void get_caption_string( property& data, std::string& caption )
{
//assert( data.get_class() == CID_INT );
if( data.get_class() == CID_INT )
{
int nPurchasePrice = data.get_int_value();
if( nPurchasePrice > 0 )
caption += sui::helper::int_to_comma_numeric( nPurchasePrice );
}
else if( data.get_class() == CID_INT64 )
{
money_t nPurchasePrice = money_t( data.get_int64_value() );
if( nPurchasePrice > 0 )
caption += sui::helper::int_to_comma_numeric( nPurchasePrice.getAmount() );
}
else
caption += m_alternative_string;
}
protected:
std::string m_alternative_string;
};
class kui_window_limittime_caption_property : public sui::kui_window_caption_property
{
public:
kui_window_limittime_caption_property( const char* name, const char* caption_decorator = 0 ) : kui_window_caption_property( name, caption_decorator ) {}
kui_window_limittime_caption_property( const kui_window_limittime_caption_property& rhs ) : kui_window_caption_property( rhs ) {}
virtual ~kui_window_limittime_caption_property() {}
virtual void get_caption_string( property& data, std::string& caption )
{
assert( data.get_class() == CID_INT );
int nDuration = data.get_int_value();
const char* szDuration = GetAuctionDuration( nDuration );
if( szDuration )
caption += szDuration;
}
};
class kui_window_status_caption_property : public sui::kui_window_caption_property
{
public:
kui_window_status_caption_property( const char* name, const char* caption_decorator = 0 ) : kui_window_caption_property( name, caption_decorator ) {}
kui_window_status_caption_property( const kui_window_status_caption_property& rhs ) : kui_window_caption_property( rhs ) {}
virtual ~kui_window_status_caption_property() {}
virtual void get_caption_string( property& data, std::string& caption )
{
assert( data.get_class() == CID_UCHAR );
unsigned char status = data.get_uchar_value();
const char* szStatus = GetAuctionStatus( status );
if( szStatus )
caption += szStatus;
}
};
class kui_window_bidded_status_caption_property : public sui::kui_window_caption_property
{
public:
kui_window_bidded_status_caption_property( const char* name, const char* caption_decorator = 0 ) : kui_window_caption_property( name, caption_decorator ) {}
kui_window_bidded_status_caption_property( const kui_window_bidded_status_caption_property& rhs ) : kui_window_caption_property( rhs ) {}
virtual ~kui_window_bidded_status_caption_property() {}
virtual void get_caption_string( property& data, std::string& caption )
{
assert( data.get_class() == CID_UCHAR );
unsigned char status = data.get_uchar_value();
const char* szStatus = GetAuctionBiddedStatus( status );
if( szStatus )
caption += szStatus;
}
};
class kui_window_deposit_status_caption_property : public sui::kui_window_caption_property
{
public:
struct StatusInfo
{
StatusInfo( int nKeepingType, bool bIsExistRelatedItem = false, int nRelatedItemCode = 0, int nRelatedItemEnhance = 0, int nRelatedItemLevel = 0 )
: keeping_type ( nKeepingType )
, is_exist_related_item ( bIsExistRelatedItem )
, related_item_code ( nRelatedItemCode )
, related_item_enhance ( nRelatedItemEnhance )
, related_item_level ( nRelatedItemLevel )
{
}
StatusInfo( const StatusInfo& other )
: keeping_type ( other.keeping_type )
, is_exist_related_item ( other.is_exist_related_item )
, related_item_code ( other.related_item_code )
, related_item_enhance ( other.related_item_enhance )
, related_item_level ( other.related_item_level )
{
}
// sonador 7.0.25 proxy_list 정렬 타입 불일치 문제 수정
bool operator < ( const StatusInfo& rhs ) const
{
return keeping_type < rhs.keeping_type;
}
unsigned char keeping_type; ///< 보관 타입(AuctionBase.h의 enum KEEPING_TYPE 참조)
bool is_exist_related_item; ///< 관련 아이템 정보가 있는가?
ItemBase::ItemCode related_item_code; ///< 관련 아이템 코드(보관 아이템이 돈일 경우만 사용됨)
int related_item_enhance; ///< 관련 아이템 강화 레벨(보관 아이템이 돈일 경우만 사용됨)
int related_item_level; ///< 관련 아이템 대장작 레벨(보관 아이템이 돈일 경우만 사용됨)
};
kui_window_deposit_status_caption_property( const char* name, const char* caption_decorator = 0 ) : kui_window_caption_property( name, caption_decorator ) {}
kui_window_deposit_status_caption_property( const kui_window_deposit_status_caption_property& rhs ) : kui_window_caption_property( rhs ) {}
virtual ~kui_window_deposit_status_caption_property() {}
virtual void get_caption_string( property& data, std::string& caption );
};
class kui_window_storabletime_caption_property : public sui::kui_window_caption_property
{
public:
kui_window_storabletime_caption_property( const char* name, const char* caption_decorator = 0 ) : kui_window_caption_property( name, caption_decorator ) {}
kui_window_storabletime_caption_property( const kui_window_storabletime_caption_property& rhs ) : kui_window_caption_property( rhs ) {}
virtual ~kui_window_storabletime_caption_property() {}
virtual void get_caption_string( property& data, std::string& caption )
{
assert( data.get_class() == CID_INT );
int second = data.get_int_value();
int day = (int)( (float)second / 86400.0f );
if( day > 0 )
{
char buffer[ 32 ];
itoa( day, buffer, 10 );
caption += buffer;
caption += S( 9103 ); // 일
}
else
{
caption += S( 9104 ); // 하루 이내
}
}
};
class NoticeBox
{
public:
NoticeBox( DWORD dwFrequency = 10000 ) : m_dwCurrentTime( 0 ), m_dwFrequency( dwFrequency ), m_nIndex( 0 ), m_pOutput( 0 )
{
}
~NoticeBox()
{
}
void Initialize( KUIWnd* pOutput );
void Process( DWORD dwTime );
void RandomShuffle();
NoticeBox& Append( const char* lpszTip );
NoticeBox& AppendUrgent( const char* lpszTip );
bool IsFrozen() const;
void Freeze( const char* lpszTip );
void Warm();
void Pass();
void Output( const char* lpszTip );
private:
int _GetNextIndex();
typedef std::vector< std::string > tip_container_t;
typedef std::queue< std::string > urgent_tip_container_t;
DWORD m_dwCurrentTime;
DWORD m_dwFrequency;
tip_container_t m_ctTips;
urgent_tip_container_t m_ctUrgentTipsQueue;
int m_nIndex;
KUIWnd* m_pOutput;
std::string m_strFreezeMessage;
};
// #2.1.2.12
struct ActionEnableProxyListMouseProc : public sui::Action
{
ActionEnableProxyListMouseProc( sui::proxy_list& ProxyList ) : Action(), m_ProxyList( ProxyList ) {}
void operator()() { m_ProxyList.activate_mouse_proc( true ); }
sui::proxy_list& m_ProxyList;
};
struct ActionDisableProxyListMouseProc : public sui::Action
{
ActionDisableProxyListMouseProc( sui::proxy_list& ProxyList ) : Action(), m_ProxyList( ProxyList ) {}
void operator()() { m_ProxyList.activate_mouse_proc( false ); }
sui::proxy_list& m_ProxyList;
};
struct ActionClearProxyList : public sui::Action
{
ActionClearProxyList( sui::proxy_list& ProxyList ) : Action(), m_ProxyList( ProxyList ) {}
void operator()() { m_ProxyList.clear(); m_ProxyList.update_data(); }
sui::proxy_list& m_ProxyList;
};
struct ActionNotice : public sui::Action
{
ActionNotice( NoticeBox& noticeBox, const char* lpszMessage ) : m_NoticeBox( noticeBox ), m_strMessage( lpszMessage ) {}
void operator()() { m_NoticeBox.AppendUrgent( m_strMessage.c_str() ); }
std::string m_strMessage;
NoticeBox& m_NoticeBox;
};
struct ActionMsgPost : public sui::Action
{
ActionMsgPost( SGameManager* pGameManager ) : Action(), m_pGameManager( pGameManager ), m_pMessage( 0 ) {}
virtual ~ActionMsgPost()
{
SAFE_DELETE( m_pMessage );
}
virtual void operator()()
{
if( m_pMessage )
{
m_pGameManager->PostMsgAtDynamic( m_pMessage );
m_pMessage = 0;
}
}
void SetMsg( SGameMessage* pMessage )
{
SAFE_DELETE( m_pMessage );
m_pMessage = pMessage;
}
protected:
SGameManager* m_pGameManager;
SGameMessage* m_pMessage;
};
class LazyMsgProc : public sui::ticker
{
public:
struct TypeSatisfier {
TypeSatisfier( int nMsgType ) : m_nMsgType( nMsgType ) {}
virtual ~TypeSatisfier() {}
virtual bool IsSatisfied( SGameMessage* pMessage ) { return ( pMessage->nType == m_nMsgType ) ? true : false; }
int m_nMsgType;
};
struct ResultSatisfier : public TypeSatisfier
{
ResultSatisfier( int nRequestMsgID ) : TypeSatisfier( MSG_RESULT ), m_nRequestMsgID( nRequestMsgID ) {}
virtual ~ResultSatisfier() {}
virtual bool IsSatisfied( SGameMessage* pMessage );
int m_nRequestMsgID;
};
struct LazyMsg
{
LazyMsg() : delay( 0 ), message( 0 ) {}
~LazyMsg() { SAFE_DELETE( message ); }
void Clear() { delay = 0; message = 0; }
void Set( DWORD dwDelay, SGameMessage* pMessage ) { delay = dwDelay; SAFE_DELETE( message ); message = pMessage; }
DWORD delay;
SGameMessage* message;
};
virtual void Process( DWORD dwTime )
{
ticker::tick( dwTime );
if( _IsIdle() && m_LazyMessage.message )
{
m_pPostAction->SetMsg( m_LazyMessage.message );
_DoActionsInFrequency( m_LazyMessage.delay );
m_LazyMessage.Clear();
}
}
void PostMsgAtDynamic( SGameMessage* pMessage, DWORD dwDelay = auction::rule::DEFAULT_REQ_DELAY )
{
if( _IsIdle() )
{
m_pPostAction->SetMsg( pMessage );
_DoActionsInFrequency( dwDelay );
}
else
{
m_LazyMessage.Set( dwDelay, pMessage );
// notice waiting message & freeze notice box
m_NoticeBox.Pass();
m_NoticeBox.Freeze( S( 9108 ) );
}
}
void CancelLazyMessage()
{
if( m_LazyMessage.message )
{
m_LazyMessage.message = 0;
m_LazyMessage.delay = 0;
}
}
void AppendAction( sui::ActionBinder* pAction )
{
m_ActionBinders.push_back( pAction );
m_ActionTicker.append_tickable( pAction );
}
void AppendSatisfier( TypeSatisfier* pSatisfier )
{
m_Satisfiers.push_back( pSatisfier );
}
void ProcMsgAtStatic( SGameMessage* pMessage )
{
if( !m_Satisfiers.empty() )
{
// ticking condition is satisfid ?
std::vector< TypeSatisfier* >::iterator i = m_Satisfiers.begin(), e = m_Satisfiers.end();
for( ; i != e; ++i )
{
TypeSatisfier* pSatisfier = *i;
if( pSatisfier && pSatisfier->IsSatisfied( pMessage ) )
{
_Satisfy();
// warm notice box & show next message
if( m_NoticeBox.IsFrozen() )
{
m_NoticeBox.Warm();
m_NoticeBox.Pass();
}
break;
}
}
}
else
{
_Satisfy();
// warm notice box & show next message
if( m_NoticeBox.IsFrozen() )
{
m_NoticeBox.Warm();
m_NoticeBox.Pass();
}
}
}
// ctor & dtor
LazyMsgProc( SGameManager* pGameManager, NoticeBox& noticeBox )
: m_pGameManager ( pGameManager )
, m_NoticeBox ( noticeBox )
, m_pPostAction ( 0 )
, m_pPoster ( 0 )
, m_pCurrentFreqTicker ( 0 )
{
m_pPostAction = new ActionMsgPost( pGameManager );
m_pPoster = new sui::ActionBinder( m_pPostAction, 0, 0 );
AppendAction( m_pPoster );
enter();
}
~LazyMsgProc()
{
sui::wipe_seq( m_ActionBinders );
sui::wipe_seq( m_Satisfiers );
sui::wipe_seq( m_FreqTickers );
leave();
}
private:
typedef sui::conditional_fixed_rate_one_time_ticker freq_ticker_t;
SGameManager* m_pGameManager;
NoticeBox& m_NoticeBox;
LazyMsg m_LazyMessage;
ActionMsgPost* m_pPostAction;
sui::ActionBinder* m_pPoster;
sui::ticker m_ActionTicker;
freq_ticker_t* m_pCurrentFreqTicker;
std::vector< sui::ActionBinder* > m_ActionBinders;
std::vector< TypeSatisfier* > m_Satisfiers;
std::vector< freq_ticker_t* > m_FreqTickers;
void _DoActionsInFrequency( DWORD dwFrequency )
{
if( m_pCurrentFreqTicker )
remove_tickable( m_pCurrentFreqTicker );
m_pCurrentFreqTicker = _GetFreqTicker( dwFrequency );
if( m_pCurrentFreqTicker )
{
m_pCurrentFreqTicker->append_tickable( &m_ActionTicker );
append_tickable( m_pCurrentFreqTicker );
}
}
freq_ticker_t* _GetFreqTicker( DWORD dwFrequency )
{
if( !m_FreqTickers.empty() )
{
std::vector< sui::conditional_fixed_rate_one_time_ticker* >::iterator i = m_FreqTickers.begin(), e = m_FreqTickers.end();
for( ; i != e; ++i )
{
sui::conditional_fixed_rate_one_time_ticker* pFreqTicker = *i;
if( pFreqTicker && dwFrequency == pFreqTicker->frequency() )
return pFreqTicker;
}
}
freq_ticker_t* pFreqTicker = new sui::conditional_fixed_rate_one_time_ticker( dwFrequency );
m_FreqTickers.push_back( pFreqTicker );
return pFreqTicker;
}
void _Satisfy()
{
if( m_pCurrentFreqTicker )
m_pCurrentFreqTicker->satisfy();
}
bool _IsIdle() const
{
return m_ActionTicker.is_on_tick() ? false : true;
}
};
class CategoryInterface : public SUIWnd
{
public:
CategoryInterface( SGameManager* pGameManager ) : SUIWnd( pGameManager ) {}
virtual ~CategoryInterface() {}
virtual void RefreshCategory() = 0;
};
// { 3.1.5 검색 카테고리 수정.sonador
// namespace dummy auction category resource
/*namespace acr {
class AuctionCategoryResourceDB
{
public:
struct CategoryInfo
{
CategoryInfo()
: category_id ( 0 )
, sub_category_id ( -1 )
, name_id ( 0 )
, local_flag ( 0 )
{
}
int category_id;
int sub_category_id;
int name_id;
int local_flag;
// help methods
bool is_main_category() const { return ( sub_category_id == -1 ) ? true : false; }
bool is_sub_category() const { return !is_main_category(); }
};
typedef std::vector< CategoryInfo* > category_info_container_t;
AuctionCategoryResourceDB()
{
Load();
}
~AuctionCategoryResourceDB()
{
sui::wipe_seq( m_CategoryInfos );
}
void GetCategoryInfo( category_info_container_t& out, int nLocalFlag )
{
category_info_container_t::iterator it = m_CategoryInfos.begin(), end = m_CategoryInfos.end();
for( ; it != end; ++it )
{
CategoryInfo* pInfo = *it;
if( pInfo && pInfo->local_flag == nLocalFlag )
{
out.push_back( pInfo );
}
}
}
private:
void Load()
{
// import dummy resource for testing
CategoryInfo* pInfo = 0;
// #1
pInfo = new CategoryInfo;
pInfo->category_id = 0;
pInfo->sub_category_id = -1;
pInfo->name_id = 0;
pInfo->local_flag = 0;
m_CategoryInfos.push_back( pInfo );
// #2
pInfo = new CategoryInfo;
pInfo->category_id = 0;
pInfo->sub_category_id = 0;
pInfo->name_id = 0;
pInfo->local_flag = 0;
m_CategoryInfos.push_back( pInfo );
// #3
pInfo = new CategoryInfo;
pInfo->category_id = 0;
pInfo->sub_category_id = 1;
pInfo->name_id = 0;
pInfo->local_flag = 0;
m_CategoryInfos.push_back( pInfo );
// #4
pInfo = new CategoryInfo;
pInfo->category_id = 1;
pInfo->sub_category_id = -1;
pInfo->name_id = 0;
pInfo->local_flag = 1;
m_CategoryInfos.push_back( pInfo );
}
category_info_container_t m_CategoryInfos;
};
AuctionCategoryResourceDB& GetAuctionCategoryResourceDB();
}*/
// } 3.1.5 검색 카테고리 수정.sonador
} // namespace auction
/// auction window main frame ----------------------------------------------------------------------
class SUIAuctionWnd : public SUIWnd
{
public:
enum CATEGORY { SEARCH, REGISTER, TENDER, DEPOSIT, MAX };
enum OFFSET { CATEGORY_X = 6, CATEGORY_Y = 57 };
SUIAuctionWnd( SGameManager* pGameManager, SUIDisplayInfo* pDisplayInfo )
: SUIWnd ( pGameManager )
, m_pDisplayInfo ( pDisplayInfo )
, m_NoticeBox ( 5000 )
, m_LazyMsgProc ( pGameManager, m_NoticeBox )
, m_pCtrlCategoryTab( 0 )
, m_pCtrlNoticeBox ( 0 )
{
}
~SUIAuctionWnd()
{
}
virtual void Process( DWORD dwTime );
virtual bool InitControls( KPoint kPos );
virtual bool InitData( bool bReload = false );
virtual void* Perform( KID id, KArg& msg );
virtual void PumpUpMessage( LPCTSTR lpszControlID, DWORD nMessage, DWORD lparam, DWORD wparam );
virtual void ProcMsgAtStatic( SGameMessage* pMsg );
virtual void OnNotifyUIWindowOpen( bool bOpen, bool bLimitWnd = true );
virtual void CheckManager();
// 2010.08.12 - prodongi
bool isSearchEditFocus() const;
private:
void _Refresh();
void _UpdateHoldMoney();
void _UpdateNoticeMessage( const char* msg );
void _SelectCategory( CATEGORY index );
SUIDisplayInfo* m_pDisplayInfo;
auction::NoticeBox m_NoticeBox;
auction::LazyMsgProc m_LazyMsgProc;
// controls
KUISimpleTabControl* m_pCtrlCategoryTab;
KUIControlStatic* m_pCtrlMoneyStatic;
KUIControlStatic* m_pCtrlNoticeBox;
auction::CategoryInterface* m_arCategoryWnd[ CATEGORY::MAX ];
};
/// search products category window ----------------------------------------------------------------
class SUIAuctionSearchWnd : public auction::CategoryInterface
{
public:
enum {
TREE_MAX = 20,
LIST_MAX = 8,
LIST_OFFSET = 37,
};
enum COLUMN {
ITEM,
SELLER,
LIMITTIME,
TENDER,
PURCHASE,
RANK,
MAX,
};
SUIAuctionSearchWnd( SGameManager* pGameManager, SUIDisplayInfo* pDisplayInfo, auction::NoticeBox& TipMgr, auction::LazyMsgProc& LazyMsgPoster )
: CategoryInterface ( pGameManager )
, m_pDisplayInfo ( pDisplayInfo )
, m_NoticeBox ( TipMgr )
, m_LazyMsgPoster ( LazyMsgPoster )
, m_pSearchEdit ( 0 )
, m_pTreeControl ( 0 )
, m_ItemList ( this, "item_list", LIST_MAX, LIST_OFFSET )
, m_SelectedItem ( this, "item_selected" , 1 )
, m_pCtrlCurrentPage( 0 )
, m_pCtrlEndPage ( 0 )
, m_pTenderButton ( 0 )
, m_pPurchaseButton ( 0 )
, m_pEditBid ( 0 )
, m_nSavedSortingState( COLUMN::ITEM )
, m_bMaintainListState( false )
{
::memset( m_bSortButtonState, 0, sizeof( m_bSortButtonState ) );
}
// 2010.04.22 auction::search::deco_list_item_l 메모리 해제 때문에 cpp로 뺐습니다. - prodongi
~SUIAuctionSearchWnd();
// {
// }
virtual void Process( DWORD dwTime );
virtual bool InitControls( KPoint kPos );
virtual bool InitData( bool bReload = false );
virtual void* Perform( KID id, KArg& msg );
virtual void PumpUpMessage( LPCTSTR lpszControlID, DWORD nMessage, DWORD lparam, DWORD wparam );
virtual void ProcMsgAtStatic( SGameMessage* pMsg );
virtual void OnNotifyUIWindowOpen( bool bOpen, bool bLimitWnd = true );
virtual DWORD OnMouseMessage( DWORD dwMessage, int x, int y );
void RefreshCategory();
// 2010.08.12 - prodongi
bool isSearchEditFocus() const { return m_pSearchEdit->HasFocus(); }
void enterSearch();
private:
struct ItemCategoryInfo
{
ItemCategoryInfo() : name( "" ), categoryID( -1 ), subCategoryID( -1 )
{
}
ItemCategoryInfo( const char* lpszName, int nGroupID = -1, int nClassID = - 1 ) : name( lpszName ), categoryID( nGroupID ), subCategoryID( nClassID )
{
}
ItemCategoryInfo( const ItemCategoryInfo& rhs ) : name( rhs.name ), categoryID( rhs.categoryID ), subCategoryID( rhs.subCategoryID )
{
}
ItemCategoryInfo& operator = ( const ItemCategoryInfo& rhs )
{
if( this == &rhs )
return *this;
name = rhs.name;
categoryID = rhs.categoryID;
subCategoryID = rhs.subCategoryID;
return *this;
}
bool operator == ( const ItemCategoryInfo& rhs ) const
{
return ( categoryID == rhs.categoryID && subCategoryID == rhs.subCategoryID ) ? true : false;
}
bool operator != ( const ItemCategoryInfo& rhs ) const
{
return !operator == ( rhs );
}
std::string name;
int categoryID;
int subCategoryID;
};
typedef sui::proxy_tree< ItemCategoryInfo > search_tree_t;
typedef sui::proxy_list item_list_t;
struct ItemImporter {
typedef TS_SC_AUCTION_SEARCH::SEARCHED_AUCTION_INFO item_t;
ItemImporter ( SUIAuctionSearchWnd* wnd, item_list_t& list ) : m_searchwnd( wnd ), m_target_list( list ) {}
void operator()( item_t& item );
item_list_t& m_target_list;
SUIAuctionSearchWnd* m_searchwnd;
};
void _PrepareControls();
void _RefreshTree();
void _RefreshKeyword();
void _UpdatePage( int nCurrent = 1, int nTotal = 1 );
void _UpdateCurrentCategory( const ItemCategoryInfo& info = ItemCategoryInfo() );
void _UpdateBidablePrice( money_t nPrice = money_t( 0 ) );
void _RequestItemList( int nCategoryID = 0, int nSubCategoryID = 0, int nPage = 1 );
void _RequestBid();
void _RequestInstantPurchase();
void _GetTemporaryListData();
void _GetTreeItemCaption( const search_tree_t::node& node, std::string& caption );
void _SortItemListByColumn( COLUMN column, bool maintain = false );
// 2010.08.25 - prodongi
int GetCheckBoxValue( const char * pControlName );
SUIDisplayInfo* m_pDisplayInfo;
auction::NoticeBox& m_NoticeBox;
auction::LazyMsgProc& m_LazyMsgPoster;
KUIControlEdit* m_pSearchEdit;
KUIControlEdit* m_pEditBid;
KUIControIStringList* m_pTreeControl;
KUIControlStatic* m_pCtrlCurrentPage;
KUIControlStatic* m_pCtrlEndPage;
KUIControlButton* m_pTenderButton;
KUIControlButton* m_pPurchaseButton;
bool m_bSortButtonState[ COLUMN::MAX ];
search_tree_t m_SearchTree;
item_list_t m_ItemList;
item_list_t m_SelectedItem;
ItemCategoryInfo m_CurrentCategory;
sui::Page m_Page;
COLUMN m_nSavedSortingState;
bool m_bMaintainListState;
// 2010.08.25 - prodongi
bool m_checkEnableEquipItemShow;
};
/// register products window -----------------------------------------------------------------------
class SUIAuctionRegisterWnd : public auction::CategoryInterface
{
public:
enum {
LIST_MAX = 9,
LIST_OFFSET = 37,
};
enum COLUMN {
ITEM,
STATE,
LIMITTIME,
TENDER,
PURCHASE,
RANK,
MAX,
};
SUIAuctionRegisterWnd( SGameManager* pGameManager, SUIDisplayInfo* pDisplayInfo, auction::NoticeBox& TipMgr, auction::LazyMsgProc& LazyMsgPoster )
: CategoryInterface ( pGameManager )
, m_pDisplayInfo ( pDisplayInfo )
, m_NoticeBox ( TipMgr )
, m_LazyMsgPoster ( LazyMsgPoster )
, m_hRegisterItemCandidate ( 0 )
, m_nCurrentDuration ( auction::rule::DUR_SHORT )
, m_pCtrlCurrentPage ( 0 )
, m_pCtrlEndPage ( 0 )
, m_pCtrlRegisterSlotFrame ( 0 )
, m_ItemList ( this, "item_list", LIST_MAX, LIST_OFFSET )
, m_SelectedItem ( this, "item_selected" , 1 )
, m_pEditBasePrice ( 0 )
, m_pEditPurchasePrice ( 0 )
, m_pStaticGuarantee ( 0 )
, m_pBtnRegister ( 0 )
, m_nSavedSortingState ( COLUMN::ITEM )
, m_bMaintainListState ( false )
{
::memset( m_bSortButtonState, 0, sizeof( m_bSortButtonState ) );
::memset( m_pCheckAvailableTime, 0, sizeof( m_pCheckAvailableTime ) );
}
~SUIAuctionRegisterWnd();
virtual bool InitControls( KPoint kPos );
virtual bool InitData( bool bReload = false );
virtual void* Perform( KID id, KArg& msg );
virtual void PumpUpMessage( LPCTSTR lpszControlID, DWORD nMessage, DWORD lparam, DWORD wparam );
virtual void ProcMsgAtStatic( SGameMessage* pMsg );
virtual void OnNotifyUIWindowOpen( bool bOpen, bool bLimitWnd = true );
virtual DWORD OnMouseMessage( DWORD dwMessage, int x, int y );
void RefreshCategory();
private:
struct CachedPrice
{
struct Key
{
Key() : nItemCode( 0 ), nItemCount( 0 ) {}
Key( int nCode, count_t nCount ) : nItemCode( nCode ), nItemCount( nCount ) {}
bool operator < ( const Key& rhs ) const
{
if( nItemCode < rhs.nItemCode )
return true;
if( nItemCode == rhs.nItemCode && nItemCount < rhs.nItemCount )
return true;
return false;
}
int nItemCode;
count_t nItemCount;
};
CachedPrice() : nBase( 0 ), nPurchase( 0 ) {}
CachedPrice( money_t base, money_t purchase ) : nBase( base ), nPurchase( purchase ) {}
money_t nBase;
money_t nPurchase;
};
typedef sui::proxy_list item_list_t;
typedef std::map< CachedPrice::Key, CachedPrice > price_cache_t;
struct ItemImporter {
typedef TS_SC_AUCTION_SELLING_LIST::REGISTERED_AUCTION_INFO item_t;
ItemImporter( item_list_t& list ) : m_target_list( list ) {}
void operator()( item_t& item );
item_list_t& m_target_list;
};
void _GetTemporaryListData();
void _SortItemListByColumn( COLUMN id, bool maintain = false );
void _RequestSellingList( int nPage = 1 );
void _RequestItemRegistration();
void _RegisterItem();
void _RequestItemDeregistration();
void _DeregisterItem();
void _RequestOpenInventory();
void _AcceptDrag( SInventorySlot* pSlot, const char* lpszDragSound );
void _PrepareControls();
void _UpdatePage( int nCurrent = 1, int nTotal = 1 );
void _UpdateRegisterSlot( SInventorySlot* pSlot = 0, count_t nCount = count_t( 0 ) );
void _UpdateRegisterPrice( SInventorySlot* pSlot = 0, count_t nCount = count_t( 0 ) );
void _UpdateRegisterDuration( auction::rule::DURATION dur );
void _UpdateRegisterButton();
void _UpdateBasePrice( money_t nPrice );
void _UpdatePurchasePrice( money_t nPrice );
bool _IsRegisterableItem( AR_HANDLE hItem ) const;
bool _IsWearableItem( int nItemCode ) const;
bool _IsCreatureCard( int nItemCode ) const;
bool _IsExistInInventory( int nItemCode ) const;
void _NormalizePrice();
TS_CS_AUCTION_REGISTER::AUCTION_DURATION_TYPE _GetDurationType( auction::rule::DURATION dur );
// rules...
money_t _GetMarketPrice( int nItemCode,int nLevel ) const;
SUIDisplayInfo* m_pDisplayInfo;
auction::NoticeBox& m_NoticeBox;
auction::LazyMsgProc& m_LazyMsgPoster;
AR_HANDLE m_hRegisterItemCandidate;
auction::rule::DURATION m_nCurrentDuration;
bool m_bSortButtonState[ COLUMN::MAX ];
KUIControlStatic* m_pCtrlCurrentPage;
KUIControlStatic* m_pCtrlEndPage;
KUIControlStatic* m_pCtrlRegisterSlotFrame;
sui::kui_updatable_window_array m_RegisterSlot;
KUIControlCheck* m_pCheckAvailableTime[ auction::rule::DUR_MAX ];
KUIControlEdit* m_pEditBasePrice;
KUIControlEdit* m_pEditPurchasePrice;
KUIControlStatic* m_pStaticGuarantee;
KUIControlButton* m_pBtnRegister;
item_list_t m_ItemList;
item_list_t m_SelectedItem;
price_cache_t m_PriceCache;
sui::Page m_Page;
COLUMN m_nSavedSortingState;
bool m_bMaintainListState;
};
/// tender window ----------------------------------------------------------------------------------
class SUIAuctionTenderWnd : public auction::CategoryInterface
{
public:
enum {
LIST_MAX = 9,
LIST_OFFSET = 37,
};
enum COLUMN {
ITEM,
LIMITTIME,
TENDER,
STATE,
PURCHASE,
MAX,
};
SUIAuctionTenderWnd( SGameManager* pGameManager, SUIDisplayInfo* pDisplayInfo, auction::NoticeBox& TipMgr, auction::LazyMsgProc& LazyMsgPoster )
: CategoryInterface ( pGameManager )
, m_pDisplayInfo ( pDisplayInfo )
, m_NoticeBox ( TipMgr )
, m_LazyMsgPoster ( LazyMsgPoster )
, m_pCtrlCurrentPage( 0 )
, m_pCtrlEndPage ( 0 )
, m_pEditBid ( 0 )
, m_pRetenderButton ( 0 )
, m_pPurchaseButton ( 0 )
, m_ItemList ( this, "item_list", LIST_MAX, LIST_OFFSET )
, m_SelectedItem ( this, "item_selected" , 1 )
, m_nSavedSortingState( COLUMN::ITEM )
, m_bMaintainListState( false )
{
::memset( m_bSortButtonState, 0, sizeof( m_bSortButtonState ) );
}
// 2010.04.22 auction::search::deco_list_item_l 메모리 해제 때문에 cpp로 뺐습니다. - prodongi
~SUIAuctionTenderWnd();
// {
// }
virtual bool InitControls( KPoint kPos );
virtual bool InitData( bool bReload = false );
virtual void* Perform( KID id, KArg& msg );
virtual void PumpUpMessage( LPCTSTR lpszControlID, DWORD nMessage, DWORD lparam, DWORD wparam );
virtual void ProcMsgAtStatic( SGameMessage* pMsg );
virtual void OnNotifyUIWindowOpen( bool bOpen, bool bLimitWnd = true );
virtual DWORD OnMouseMessage( DWORD dwMessage, int x, int y );
void RefreshCategory();
private:
typedef sui::proxy_list item_list_t;
struct ItemImporter {
typedef TS_SC_AUCTION_BIDDED_LIST::BIDDED_AUCTION_LIST item_t;
ItemImporter ( item_list_t& list ) : m_target_list( list ) {}
void operator()( item_t& item );
item_list_t& m_target_list;
};
void _UpdatePage( int nCurrent = 1, int nTotal = 1 );
void _UpdateBidablePrice( money_t nPrice = money_t( 0 ) );
void _GetTemporaryListData();
void _RequestBiddedList( int nPage = 1 );
void _RequestBid();
void _RequestInstantPurchase();
void _SortItemListByColumn( COLUMN id, bool maintain = false );
SUIDisplayInfo* m_pDisplayInfo;
auction::NoticeBox& m_NoticeBox;
auction::LazyMsgProc& m_LazyMsgPoster;
bool m_bSortButtonState[ COLUMN::MAX ];
KUIControlStatic* m_pCtrlCurrentPage;
KUIControlStatic* m_pCtrlEndPage;
KUIControlEdit* m_pEditBid;
KUIControlButton* m_pRetenderButton;
KUIControlButton* m_pPurchaseButton;
item_list_t m_ItemList;
item_list_t m_SelectedItem;
sui::Page m_Page;
COLUMN m_nSavedSortingState;
bool m_bMaintainListState;
};
/// diposit window ---------------------------------------------------------------------------------
class SUIAuctionDepositWnd : public auction::CategoryInterface
{
public:
enum {
LIST_MAX = 8,
LIST_OFFSET = 41,
};
enum COLUMN {
ITEM,
STORABLETIME,
STATE,
MAX,
};
SUIAuctionDepositWnd( SGameManager* pGameManager, SUIDisplayInfo* pDisplayInfo, auction::NoticeBox& TipMgr, auction::LazyMsgProc& LazyMsgPoster )
: CategoryInterface ( pGameManager )
, m_pDisplayInfo ( pDisplayInfo )
, m_NoticeBox ( TipMgr )
, m_LazyMsgPoster ( LazyMsgPoster )
, m_pCtrlCurrentPage( 0 )
, m_pCtrlEndPage ( 0 )
, m_ItemList ( this, "item_list", LIST_MAX, LIST_OFFSET )
, m_SelectedItem ( this, "item_selected" , 1 )
, m_nSavedSortingState( COLUMN::STORABLETIME )
, m_bMaintainListState( false )
{
::memset( m_bSortButtonState, 0, sizeof( m_bSortButtonState ) );
}
// 2010.04.22 auction::search::deco_list_item_l 메모리 해제 때문에 cpp로 뺐습니다. - prodongi
~SUIAuctionDepositWnd();
// {
// }
virtual bool InitControls( KPoint kPos );
virtual bool InitData( bool bReload = false );
virtual void* Perform( KID id, KArg& msg );
virtual void PumpUpMessage( LPCTSTR lpszControlID, DWORD nMessage, DWORD lparam, DWORD wparam );
virtual void ProcMsgAtStatic( SGameMessage* pMsg );
virtual void OnNotifyUIWindowOpen( bool bOpen, bool bLimitWnd = true );
virtual DWORD OnMouseMessage( DWORD dwMessage, int x, int y );
void RefreshCategory();
private:
typedef sui::proxy_list item_list_t;
struct ItemImporter {
typedef TS_SC_ITEM_KEEPING_LIST::TS_ITEM_KEEPING_INFO item_t;
ItemImporter ( item_list_t& list ) : m_target_list( list ) {}
void operator()( item_t& item );
item_list_t& m_target_list;
};
void _UpdatePage( int nCurrent = 1, int nTotal = 1 );
void _RequestKeepingList( int nPage = 1 );
void _RequestDrawingItem( int nKeepingID );
void _GetTemporaryListData();
void _SortItemListByColumn( COLUMN id, bool maintain = false );
SUIDisplayInfo* m_pDisplayInfo;
auction::NoticeBox& m_NoticeBox;
auction::LazyMsgProc& m_LazyMsgPoster;
bool m_bSortButtonState[ COLUMN::MAX ];
KUIControlStatic* m_pCtrlCurrentPage;
KUIControlStatic* m_pCtrlEndPage;
item_list_t m_ItemList;
item_list_t m_SelectedItem;
sui::Page m_Page;
bool m_bSelectable;
COLUMN m_nSavedSortingState;
bool m_bMaintainListState;
};