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

743 lines
24 KiB
C++

#include "stdafx.h"
#include "SUIDefine.h"
#include "SGameManager.h"
//#include "SGameMessageUI.h"
#include "SNetMessage.h"
#include "SGameMessage.h"
#include "ErrorCode/ErrorCode.h"
#include "SItemDB.h"
#include "SStringDB.h"
#include <toolkit/XStringUtil.h>
#include "SPlayerInfoMgr.h"
#include "SInventoryMgr.h"
#include "KUIWndManager.h"
#include "SUIDisplayInfo.h"
#include "KUITabControl.h"
#include "KUIControlStatic.h"
#include "KUIControlButton.h"
#include "KUIControlEdit.h"
#include "SUIAuctionWnd.h"
#include "SDebug_Util.h"
#include "SGameInterface.h" // 2012. 2. 21 - marine
#include "SUILazyTooltip.h"
#include "SGameSystem.h"
extern SGameSystem * g_pCurrentGameSystem;
namespace auction {
const int nLayer = 8;
namespace control {
// sub nui...
const char* category_search_name = "window_system_auction_sub1.nui";
const char* category_register_name = "window_system_auction_sub2.nui";
const char* category_tender_name = "window_system_auction_sub3.nui";
const char* category_deposit_name = "window_system_auction_sub4.nui";
const char* sound_on_opening = "ui_popup_window01.wav";
const char* sound_on_closing = "ui_popup_window01.wav";
const char* mainframe_tab = "tab_01";
const char* mainframe_money = "r_text01";
const char* mainframe_rupy = "r_text00";
const char* notice = "allim_box";
const char* close_button_x = "button_close"; //servantes 2010.10.28
const char* close_button = "close_button";
// deco
const char* deco_category = "<size:10><vcenter><center>";
const char* deco_money = "<size:10><vcenter><right>";
const char* deco_notice = "<hcenter><vcenter><size:10><shadow>";
const char* deco_rupy = "<#fec530><vcenter><hcenter><size:10><shadow>%s";
}
const int help_text[] = {
3521 // The auction system allows players to sell registered items to other players through competitive bidding.
, 3522 // Time-limited items cannot be auctioned.
, 3523 // Only tradable items can be auctioned.
, 3524 // If a player is already the highest bidder, they cannot place an additional bid.
, 3525 // The bid amount for an item can be freely entered.
, 3526 // The registration fee is consumed only when the auction is canceled after registration. If the auction expires without a sale, the fee is refunded.
, 3527 // The auction starting price must be set at or above the NPC shop selling price of the item.
, 3528 // Players can rebid or purchase instantly through the bid list.
, 3529 // Items in storage can be moved to the inventory by double-clicking.
, 3530 // Items obtained through auctions are first stored in the storage box, and if not claimed within 15 days, they will be deleted.
};
namespace rule {
void NormalizeBasePrice( money_t& nPrice )
{
if( (unsigned __int64)nPrice.getAmount() > (double)auction::rule::MAX_PRICE * ( 1 - auction::rule::PURCHASE_RATIO ) )
nPrice = money_t( (double)auction::rule::MAX_PRICE * ( 1 - auction::rule::PURCHASE_RATIO ) );
if( nPrice < 0 )
nPrice = money_t( 0 );
}
void NormalizePurchasePrice( money_t& nPrice )
{
if( (unsigned __int64)nPrice.getAmount() > auction::rule::MAX_PRICE )
nPrice = money_t( auction::rule::MAX_PRICE );
if( nPrice < 0 )
nPrice = money_t( 0 );
}
std::string GetColorTagByPrice( money_t nGold )
{
if( nGold >= auction::rule::PRICE_COLOR_CUT_1 ) return "<#FF0000>";
else if( nGold >= auction::rule::PRICE_COLOR_CUT_2 ) return "<#FF00F3>";
else if( nGold >= auction::rule::PRICE_COLOR_CUT_3 ) return "<#FF1493>";
else if( nGold >= auction::rule::PRICE_COLOR_CUT_4 ) return "<#00FFFC>";
else if( nGold >= auction::rule::PRICE_COLOR_CUT_5 ) return "<#FF8C00>";
else if( nGold >= auction::rule::PRICE_COLOR_CUT_6 ) return "<#FFFF00>";
else if( nGold >= auction::rule::PRICE_COLOR_CUT_7 ) return "<#4AD55D>";
return "<#FFFFFF>";
}
KColor GetColorValueByPrice( money_t nGold )
{
if( nGold >= auction::rule::PRICE_COLOR_CUT_1 ) return KColor( 0xFFEE0000 );
else if( nGold >= auction::rule::PRICE_COLOR_CUT_2 ) return KColor( 0xFF800080 );
else if( nGold >= auction::rule::PRICE_COLOR_CUT_3 ) return KColor( 0xFFFF1493 );
else if( nGold >= auction::rule::PRICE_COLOR_CUT_4 ) return KColor( 0xFF00FFFC );
else if( nGold >= auction::rule::PRICE_COLOR_CUT_5 ) return KColor( 0xFFFF8C00 );
else if( nGold >= auction::rule::PRICE_COLOR_CUT_6 ) return KColor( 0xFFFFFF00 );
else if( nGold >= auction::rule::PRICE_COLOR_CUT_7 ) return KColor( 0xFF4AD55D );
else return KColor( 0xFFFFFFFF );
}
money_t GetBiddablePrice( money_t nBasePrice )
{
return nBasePrice + money_t( (float)nBasePrice.getAmount() * auction::rule::TENDER_RATIO );
}
money_t GetPurchasePriceBasedOn( money_t nBasePrice )
{
return nBasePrice + money_t( (float)nBasePrice.getAmount() * auction::rule::PURCHASE_RATIO );
}
money_t GetGuaranteeBasedOn( DURATION dur, money_t nBasePrice )
{
assert( dur >= 0 && dur < DUR_MAX && "SUIAuctionWnd: Invalid Duration Information!!!" );
money_t nCommission( 0 );
switch( dur )
{
case DUR_SHORT:
nCommission = money_t( (float)nBasePrice.getAmount() * auction::rule::COMMISSION_SHORT_RATIO );
break;
case DUR_MIDDLE:
nCommission = money_t( (float)nBasePrice.getAmount() * auction::rule::COMMISSION_MIDDLE_RATIO );
break;
case DUR_LONG:
nCommission = money_t( (float)nBasePrice.getAmount() * auction::rule::COMMISSION_LONG_RATIO );
break;
}
return nCommission;
}
money_t GetPriceFrom( KUIControlEdit* pEdit )
{
if( pEdit == 0 )
return money_t( 0 );
const char* pText = pEdit->GetText();
if( ::strlen( pText ) == 0 )
return money_t( 0 );
return money_t( sui::helper::comma_numeric_to_int( pText ) );
}
void SetPriceTo( KUIControlEdit* pEdit, money_t nPrice )
{
if( pEdit == 0 )
return;
if( nPrice > 0 )
{
pEdit->SetFontColor( auction::rule::GetColorValueByPrice( nPrice ) );
pEdit->SetText( sui::helper::int_to_comma_numeric( nPrice.getAmount() ).c_str() );
}
else
{
pEdit->SetText( "" );
}
}
void SetPriceTo( KUIControlStatic* pStatic, money_t nPrice )
{
if( pStatic == 0 )
return;
if( nPrice > 0 )
{
std::string strCaption = auction::rule::GetColorTagByPrice( nPrice );
strCaption += "<right><vcenter><shadow>%s";
XStringUtil::Format( strCaption, strCaption.c_str(), sui::helper::int_to_comma_numeric( nPrice.getAmount() ).c_str() );
pStatic->SetCaption( strCaption.c_str() );
}
else
{
pStatic->SetCaption( "" );
}
}
} // namespace rule
const char* rupy_icon_name = "Icon_rupy";
void kui_window_item_icon_property::on_update( property& data )
{
KUIControlMultiIcon* icon = static_cast< KUIControlMultiIcon* >( get_pointer_value() );
if( icon )
{
ResetMultiIcon( icon, 0, 8 );
TS_ITEM_BASE_INFO* item_info = 0;
if( data.is_valid() )
{
assert( data.get_class() == CID_RESOURCE );
if( data.get_resource() )
item_info = reinterpret_cast< TS_ITEM_BASE_INFO* >( data.get_resource() );
}
if( data.is_valid() && item_info )
{
XFlag< int > xFlag;
xFlag.CopyFrom( &item_info->Flag );
// 코인을 출력하기 위해 예외처리( item_info->Code == 0 )
if( item_info->Code == 0 )
{
icon->SetIcon( 0, c_szDEF_SPR_NAME, auction::rupy_icon_name );
icon->SetTooltip();
}
else
{
/// 2011.08.03 - prodongi
if( !setSkillCardIcon(icon, item_info->Code) && !setSummonCardIcon( icon, item_info->Code, item_info->summon_id, item_info->enhance, item_info->Flag, item_info->ethereal_durability ) )
{
icon->SetIcon( 0, c_szDEF_SPR_NAME, GetItemDB().GetIconName( item_info->Code ) );
//gmpbigsun( 20130225 ) 빈카드 표시 제거예정
/// 2011.10.21 빈카드 표시 - prodongi
//if (isEmptyCreatureCard(item_info->Code, xFlag))
// icon->SetIcon( 2, c_szDEF_SPR_NAME, "common_mark_titanium_empty_card");
}
XFlag<int> xFlag;
xFlag.CopyFrom( &(item_info->Flag) );
EquipItemAddtionalIconSetter icon_setter( icon, item_info->Code, item_info->enhance, item_info->ethereal_durability, xFlag );
icon->SetTooltip( m_display->GetItemTooltipText( item_info, true ).c_str() );
if( m_pParent->IsAlt() )
{
m_display->SetComparableEquipItemSubTooltip( icon, item_info->Code );
}
}
if( item_info->appearance_code )
icon->SetIcon( 4, c_szDEF_SPR_NAME, g_strLookChangeIcon ); // 2012. 7. 27 - marine 아이템 형상변환 아이콘
icon->SetIcon( 1, c_szDEF_SPR_NAME, xFlag.IsOn( ItemInstance::ITEM_FLAG_CARD ) ? "static_common_useunitcardicon" : NULL );
}
else
{
icon->SetIcon( 0, c_szDEF_SPR_NAME, "static_common_itemslot" );
icon->SetTooltip();
}
}
}
sui::kui_window_property& kui_window_item_icon_property::set_value( KUIWnd* value )
{
kui_window_property::set_value( value );
KUIControlMultiIcon* icon = dynamicCast< KUIControlMultiIcon* >( get_window() );
if( icon )
icon->SetIconLayer( nLayer );
return *this;
}
void kui_window_deposit_status_caption_property::get_caption_string( property& data, std::string& caption )
{
StatusInfo* pInfo = reinterpret_cast< StatusInfo* >( data.get_resource() );
if( pInfo )
{
unsigned char status = pInfo->keeping_type;
const char* szStatus = GetAuctionDepositStatus( status );
if( szStatus )
caption += szStatus;
if( pInfo->is_exist_related_item && pInfo->related_item_code != 0 )
{
char bufferItemEnhance[ 32 ] = { 0, }, bufferItemLevel[ 32 ] = { 0, };
// enhance
if( pInfo->related_item_enhance > 0 )
::itoa( pInfo->related_item_enhance, bufferItemEnhance, 10 );
// level
::itoa( pInfo->related_item_level, bufferItemLevel, 10 );
caption = SStringDB::ParseString( caption.c_str(), "#@item_enhance@#", bufferItemEnhance, "#@item_level@#", bufferItemLevel,
"#@item_name@#", GetStringDB().GetString( GetItemDB().GetItemData( pInfo->related_item_code )->nNameId ) );
}
}
}
const char* GetAuctionDuration( int nAuctionDurationType )
{
switch( (TS_AUCTION_INFO::AUCTION_DURATION_TYPE)nAuctionDurationType )
{
case TS_AUCTION_INFO::DURATION_SHORTTERM:
return S( 9108 ); // 단기
case TS_AUCTION_INFO::DURATION_MIDTERM:
return S( 9109 ); // 중기
case TS_AUCTION_INFO::DURATION_LONGTERM:
return S( 9110 ); // 장기
}
assert( "auction : wrong duration!!" );
return 0;
}
const char* GetAuctionStatus( unsigned char ucAuctionStatus )
{
switch( (TS_SC_AUCTION_SELLING_LIST::REGISTERED_AUCTION_INFO::REGISTERED_AUCTION_STATUS)ucAuctionStatus )
{
case TS_SC_AUCTION_SELLING_LIST::REGISTERED_AUCTION_INFO::STATUS_NO_BIDDER:
return S( 9111 ); // 입찰자 없음
break;
case TS_SC_AUCTION_SELLING_LIST::REGISTERED_AUCTION_INFO::STATUS_BID_CALLING:
return S( 9112 ); // 입찰 진행중
break;
}
assert( "auction : wrong registered status!!" );
return 0;
}
const char* GetAuctionBiddedStatus( unsigned char ucAuctionBiddedStatus )
{
switch( (TS_SC_AUCTION_BIDDED_LIST::BIDDED_AUCTION_LIST::BIDDED_AUCTION_STATUS)ucAuctionBiddedStatus )
{
case TS_SC_AUCTION_BIDDED_LIST::BIDDED_AUCTION_LIST::STATUS_MINE:
return S( 9101 ); // 본인 입찰
break;
case TS_SC_AUCTION_BIDDED_LIST::BIDDED_AUCTION_LIST::STATUS_OTHERS:
return S( 9102 ); // 타인 입찰
break;
}
assert( "auction : wrong bidded status!!" );
return 0;
}
const char* GetAuctionDepositStatus( unsigned char ucAuctionKeepingType )
{
switch( (KEEPING_TYPE)ucAuctionKeepingType )
{
case KEEPING_TYPE_ITEM_BY_SUCCESSFUL_BID:
return S( 9113 );
case KEEPING_TYPE_ITEM_BY_INSTANT_PURCHASE:
return S( 9114 );
case KEEPING_TYPE_ITEM_BY_EXPIRATION:
return S( 9115 );
case KEEPING_TYPE_ITEM_BY_CANCEL:
return S( 9116 );
case KEEPING_TYPE_GOLD_BY_ITEM_SELL:
return S( 9117 );
case KEEPING_TYPE_GOLD_BY_REG_TAX:
return S( 9118 );
case KEEPING_TYPE_GOLD_BY_HIGHER_BID:
return S( 9119 );
case KEEPING_TYPE_GOLD_BY_CANCEL:
return S( 9120 );
case KEEPING_TYPE_GOLD_BY_ITEM_SOLD_OUT:
return S( 9121 );
default:
return S( 9122 );
}
assert( "auction : wrong bidded status!!" );
return 0;
}
void NoticeBox::Initialize( KUIWnd* pOutput )
{
m_nIndex = 0;
m_pOutput = pOutput;
}
void NoticeBox::Process( DWORD dwTime )
{
DWORD dwTimeDiff = dwTime - m_dwCurrentTime;
if( dwTimeDiff > m_dwFrequency )
{
// show random tip...
if( !m_strFreezeMessage.empty() )
{
Output( m_strFreezeMessage.c_str() );
}
else if( !m_ctUrgentTipsQueue.empty() )
{
Output( m_ctUrgentTipsQueue.front().c_str() );
m_ctUrgentTipsQueue.pop();
}
else if( !m_ctTips.empty() )
{
Output( m_ctTips.at( _GetNextIndex() ).c_str() );
}
// reset timer
m_dwCurrentTime = dwTime;
}
}
void NoticeBox::RandomShuffle()
{
// random shuffle
std::random_shuffle( m_ctTips.begin(), m_ctTips.end() );
}
NoticeBox& NoticeBox::Append( const char* lpszTip )
{
m_ctTips.push_back( lpszTip );
return *this;
}
NoticeBox& NoticeBox::AppendUrgent( const char* lpszTip )
{
// for outputing immediately
m_dwCurrentTime = 0;
m_ctUrgentTipsQueue.push( lpszTip );
return *this;
}
bool NoticeBox::IsFrozen() const
{
return !m_strFreezeMessage.empty();
}
void NoticeBox::Freeze( const char* lpszTip )
{
m_strFreezeMessage = lpszTip;
}
void NoticeBox::Warm()
{
m_strFreezeMessage = "";
}
void NoticeBox::Pass()
{
m_dwCurrentTime = 0;
}
void NoticeBox::Output( const char* lpszTip )
{
if( m_pOutput )
{
std::string caption( control::deco_notice );
caption += lpszTip;
m_pOutput->SetCaption( caption.c_str() );
}
}
int NoticeBox::_GetNextIndex()
{
++m_nIndex;
if( m_nIndex >= m_ctTips.size() )
m_nIndex = 0;
return m_nIndex;
}
// #2.1.2.12
bool LazyMsgProc::ResultSatisfier::IsSatisfied( SGameMessage* pMessage )
{
if( TypeSatisfier::IsSatisfied( pMessage ) )
{
SMSG_RESULT* msg = dynamicCast< SMSG_RESULT* >( pMessage );
if( msg->request_msg_id == m_nRequestMsgID )
return true;
}
return false;
}
/*namespace acr {
AuctionCategoryResourceDB& GetAuctionCategoryResourceDB()
{
static AuctionCategoryResourceDB auctionCategoryDB;
return auctionCategoryDB;
}
}*/
} // namespace auction
// auction window main frame ----------------------------------------------------------------------
void SUIAuctionWnd::Process( DWORD dwTime )
{
SUIWnd::Process( dwTime );
m_NoticeBox.Process( dwTime );
m_LazyMsgProc.Process( dwTime );
}
bool SUIAuctionWnd::InitControls( KPoint kPos )
{
// init controls here...
SetCustomMovingRect( KRect( 0, 0, 850, 20 ) );
// prepare control member variables
m_pCtrlCategoryTab = dynamicCast< KUISimpleTabControl* >( GetChild( auction::control::mainframe_tab ) );
m_pCtrlMoneyStatic = dynamicCast< KUIControlStatic* >( GetChild( auction::control::mainframe_money ) );
// initialize controls
if( m_pCtrlCategoryTab )
{
std::string strCategoryName;
m_pCtrlCategoryTab->SetTabProperty( 0, false, 4 );
strCategoryName = auction::control::deco_category;
strCategoryName += S( 9124 );
m_pCtrlCategoryTab->AddTabItem( strCategoryName.c_str(), S( 9125 ), 0, 3 );
strCategoryName = auction::control::deco_category;
strCategoryName += S( 9126 );
m_pCtrlCategoryTab->AddTabItem( strCategoryName.c_str(), S( 9127 ), 0, 3 );
strCategoryName = auction::control::deco_category;
strCategoryName += S( 9128 );
m_pCtrlCategoryTab->AddTabItem( strCategoryName.c_str(), S( 9129 ), 0, 3 );
strCategoryName = auction::control::deco_category;
strCategoryName += S( 9130 );
m_pCtrlCategoryTab->AddTabItem( strCategoryName.c_str(), S( 9131 ), 0, 3 );
}
// ticking message poster
m_LazyMsgProc.AppendSatisfier( new auction::LazyMsgProc::TypeSatisfier( IMSG_RES_AUCTION_SEARCH ) );
m_LazyMsgProc.AppendSatisfier( new auction::LazyMsgProc::TypeSatisfier( IMSG_RES_AUCTION_SELLING_LIST ) );
m_LazyMsgProc.AppendSatisfier( new auction::LazyMsgProc::TypeSatisfier( IMSG_RES_AUCTION_BIDDED_LIST ) );
m_LazyMsgProc.AppendSatisfier( new auction::LazyMsgProc::TypeSatisfier( IMSG_RES_AUCTION_ITEM_KEEPING_LIST ) );
m_LazyMsgProc.AppendSatisfier( new auction::LazyMsgProc::ResultSatisfier( TM_CS_AUCTION_SEARCH ) );
m_LazyMsgProc.AppendSatisfier( new auction::LazyMsgProc::ResultSatisfier( TM_CS_AUCTION_SELLING_LIST ) );
m_LazyMsgProc.AppendSatisfier( new auction::LazyMsgProc::ResultSatisfier( TM_CS_AUCTION_BIDDED_LIST ) );
m_LazyMsgProc.AppendSatisfier( new auction::LazyMsgProc::ResultSatisfier( TM_CS_ITEM_KEEPING_LIST ) );
m_arCategoryWnd[ CATEGORY::SEARCH ] = new SUIAuctionSearchWnd( m_pGameManager, m_pDisplayInfo, m_NoticeBox, m_LazyMsgProc );
m_arCategoryWnd[ CATEGORY::SEARCH ]->CreateWnd( auction::control::category_search_name, m_pGameManager->GetWndManager(), KPoint( 0, 0 ), SIMSG_TOGGLE_UIWINDOW::UIWINDOW_AUCTION_SEARCH );
AddChild( m_arCategoryWnd[ CATEGORY::SEARCH ] );
m_arCategoryWnd[ CATEGORY::SEARCH ]->MovePos( OFFSET::CATEGORY_X, OFFSET::CATEGORY_Y );
SetChildAsTop( auction::control::category_search_name );
m_arCategoryWnd[ CATEGORY::REGISTER ] = new SUIAuctionRegisterWnd( m_pGameManager, m_pDisplayInfo, m_NoticeBox, m_LazyMsgProc );
m_arCategoryWnd[ CATEGORY::REGISTER ]->CreateWnd( auction::control::category_register_name, m_pGameManager->GetWndManager(), KPoint( 0, 0 ), SIMSG_TOGGLE_UIWINDOW::UIWINDOW_AUCTION_REGISTER );
AddChild( m_arCategoryWnd[ CATEGORY::REGISTER ] );
m_arCategoryWnd[ CATEGORY::REGISTER ]->MovePos( OFFSET::CATEGORY_X, OFFSET::CATEGORY_Y );
SetChildAsTop( auction::control::category_register_name );
m_arCategoryWnd[ CATEGORY::TENDER ] = new SUIAuctionTenderWnd( m_pGameManager, m_pDisplayInfo, m_NoticeBox, m_LazyMsgProc );
m_arCategoryWnd[ CATEGORY::TENDER ]->CreateWnd( auction::control::category_tender_name, m_pGameManager->GetWndManager(), KPoint( 0, 0 ), SIMSG_TOGGLE_UIWINDOW::UIWINDOW_AUCTION_TENDER );
AddChild( m_arCategoryWnd[ CATEGORY::TENDER ] );
m_arCategoryWnd[ CATEGORY::TENDER ]->MovePos( OFFSET::CATEGORY_X, OFFSET::CATEGORY_Y );
SetChildAsTop( auction::control::category_tender_name );
m_arCategoryWnd[ CATEGORY::DEPOSIT ] = new SUIAuctionDepositWnd( m_pGameManager, m_pDisplayInfo, m_NoticeBox, m_LazyMsgProc );
m_arCategoryWnd[ CATEGORY::DEPOSIT ]->CreateWnd( auction::control::category_deposit_name, m_pGameManager->GetWndManager(), KPoint( 0, 0 ), SIMSG_TOGGLE_UIWINDOW::UIWINDOW_AUCTION_DEPOSIT );
AddChild( m_arCategoryWnd[ CATEGORY::DEPOSIT ] );
m_arCategoryWnd[ CATEGORY::DEPOSIT ]->MovePos( OFFSET::CATEGORY_X, OFFSET::CATEGORY_Y );
SetChildAsTop( auction::control::category_deposit_name );
// notice box
m_pCtrlNoticeBox = dynamicCast< KUIControlStatic* >( GetChild( auction::control::notice ) );
m_NoticeBox.Initialize( m_pCtrlNoticeBox );
int nHelpTextCount = sizeof( auction::help_text ) / sizeof( int );
for( int index = 0; index < nHelpTextCount; ++index )
m_NoticeBox.Append( S( auction::help_text[ index ] ) );
m_NoticeBox.RandomShuffle();
KUIControlStatic* pRupy = dynamicCast< KUIControlStatic* >( GetChild( auction::control::mainframe_rupy ) );
if( pRupy )
{
std::string caption;
XStringUtil::Format( caption, auction::control::deco_rupy, S( 6618 ) );
pRupy->SetCaption( caption.c_str() );
}
return SUIWnd::InitControls( kPos );
}
bool SUIAuctionWnd::InitData( bool bReload )
{
// init data here...
return SUIWnd::InitData( bReload );
}
void* SUIAuctionWnd::Perform( KID id, KArg& msg )
{
// process perform message here...
for( int i = 0; i < CATEGORY::MAX; ++i )
{
if( m_arCategoryWnd[ i ] && m_arCategoryWnd[ i ]->IsShow() )
{
m_arCategoryWnd[ i ]->Perform( id, msg );
}
}
return SUIWnd::Perform( id, msg );
}
void SUIAuctionWnd::PumpUpMessage( LPCTSTR lpszControlID, DWORD nMessage, DWORD lparam, DWORD wparam )
{
// process control message here...
switch( nMessage )
{
case KUI_MESSAGE::KBUTTON_CLICK:
{
if( ::stricmp( lpszControlID, auction::control::close_button_x ) == 0 || ::stricmp( lpszControlID, auction::control::close_button ) == 0 )
{
m_pGameManager->InterfaceMsg( &SIMSG_TOGGLE_UIWINDOW( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_AUCTION ) );
m_pGameManager->PostMsgAtDynamic( new SIMSG_SHOW_UIWINDOW( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_INPUTNUMBER, false ) );
}
}
break;
case KUI_MESSAGE::KTAB_SELECT: // changed category
{
int item = m_pCtrlCategoryTab->GetSelectedItem();
_SelectCategory( (CATEGORY)item );
}
break;
case KUI_MESSAGE::KGENWND_MOVE: // window move
{
LimitMoveWnd(); // don't get out of client region
//m_pGameManager->ProcMsgAtStatic( &SIMSG_UI_MOVE( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_AUCTION_SEARCH, GetRect().left, GetRect().top ) );
}
break;
}
SUIWnd::PumpUpMessage( lpszControlID, nMessage, lparam, wparam );
}
void SUIAuctionWnd::ProcMsgAtStatic( SGameMessage* pMsg )
{
// process game message here...
// if this message is a return one of the message posted by lazy message procedure, satisfy ticker
m_LazyMsgProc.ProcMsgAtStatic( pMsg );
switch( pMsg->nType )
{
case IMSG_TOGGLE_UIWINDOW:
case IMSG_SHOW_UIWINDOW:
pMsg->bUse = true;
break;
case MSG_GOLD_UPDATE:
_UpdateHoldMoney();
break;
//case IMSG_UI_SEND_DATA:
// {
// SIMSG_UI_SEND_DATA* pSendData = static_cast< SIMSG_UI_SEND_DATA* >( pMsg );
// _UpdateNoticeMessage( pSendData->m_strString.c_str() );
// pMsg->bUse = true;
// }
break;
// 2010.08.12 - prodongi
case IMSG_HOTKEY_EX:
SIMSG_HOTKEY_EX* pHotKeyMsg = (SIMSG_HOTKEY_EX*)pMsg;
/// 2012.02.16 up 상태 체크 추가,
/// enter down 상태일 때 ime의 endcompsition을 초기화 하기 위해서 추가함,
/// 일본 같은 경우에 조합완료 엔터를 치고, 다시 엔터를 처야 검색이 되도록 해야 된다.
/// 그래서 조합완료 엔터인지, 일반 엔터인지 구분을 지어야 된다. isEndComposing() 함수로 체크함 - prodongi
if (LOWORD(pHotKeyMsg->wParam ) == VK_RETURN && isSearchEditFocus() && pHotKeyMsg->bUp)
{
SUIAuctionSearchWnd* searchWnd = (SUIAuctionSearchWnd*)m_arCategoryWnd[CATEGORY::SEARCH];
searchWnd->enterSearch();
}
break;
}
// put about message to category windows...
for( int i = 0; i < CATEGORY::MAX; ++i )
m_arCategoryWnd[ i ]->ProcMsgAtStatic( pMsg );
}
void SUIAuctionWnd::OnNotifyUIWindowOpen( bool bOpen, bool bLimitWnd )
{
SUIWnd::OnNotifyUIWindowOpen( bOpen, bLimitWnd );
if( bOpen )
{
//2012. 2. 20 - marine 열린 파괴창, 수리창, 조합창, 강화창 닫기,
m_pGameManager->GetGameInterface()->CloseAgainstUi();
m_pGameManager->StartSound( auction::control::sound_on_opening );
_SelectCategory( CATEGORY::SEARCH );
_UpdateHoldMoney();
}
else
{
m_pGameManager->StartSound( auction::control::sound_on_closing );
_Refresh();
}
}
void SUIAuctionWnd::_SelectCategory( CATEGORY index )
{
if( index < 0 || index >= CATEGORY::MAX )
return;
for( int n = 0; n < CATEGORY::MAX; ++n )
{
SUIWnd* window = m_arCategoryWnd[ n ];
bool bShow = false;
if( n == index )
{
bShow = true;
m_pCtrlCategoryTab->SetSelectedItem( n );
}
window->SetShow( bShow );
window->OnNotifyUIWindowOpen( bShow );
}
}
void SUIAuctionWnd::CheckManager()
{
}
// 2010.08.12 - prodongi
bool SUIAuctionWnd::isSearchEditFocus() const
{
SUIAuctionSearchWnd* searchWnd = (SUIAuctionSearchWnd*)m_arCategoryWnd[CATEGORY::SEARCH];
return searchWnd->isSearchEditFocus();
}
void SUIAuctionWnd::_Refresh()
{
for( int i = 0; i < CATEGORY::MAX; ++i )
{
if( m_arCategoryWnd[ i ] )
m_arCategoryWnd[ i ]->RefreshCategory();
}
}
void SUIAuctionWnd::_UpdateHoldMoney()
{
if( !m_pCtrlMoneyStatic )
return;
money_t nMoney = m_PlayerInfoMgr.GetGold();
std::string strCaption( auction::control::deco_money );
strCaption += sui::helper::int_to_comma_numeric( nMoney.getAmount() ).c_str();
m_pCtrlMoneyStatic->SetCaption( strCaption.c_str() );
}
void SUIAuctionWnd::_UpdateNoticeMessage( const char* msg )
{
if( !m_pCtrlNoticeBox )
return;
std::string caption( auction::control::deco_notice );
caption += msg;
m_pCtrlNoticeBox->SetCaption( caption.c_str() );
}