#include "stdafx.h" // messages... #include "SGameMessage.h" //#include "SGameMessageUI.h" #include "ErrorCode/ErrorCode.h" // managers... #include "SGameManager.h" #include "KUIWndManager.h" #include "SInventoryMgr.h" #include "SPlayerInfoMgr.h" // DBs... #include "SItemDB.h" #include "SStringDB.h" #include "SAuctionCategoryResourceDB.h" // Utils... #include // 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" // 2010.04.22 - prodongi #include "KTypes.h" namespace auction { namespace search { // tree... const char* searching = "search_edit"; const char* search_start = "button_search"; const char* tree_folder = "inframe_01"; // column button... const char* column_item = "button_01"; const char* column_seller = "button_02"; const char* column_limittime = "button_03"; const char* column_tender = "button_04"; const char* column_purchase = "button_06"; const char* column_rank = "button_020"; // list... const char* list_back = "selectbar_back_%.2d"; const char* list_select = "selectbar_on"; 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_rank = "static_rank_%.2d"; const char* list_seller = "static_itemtext02_%.2d"; const char* list_limittime = "static_itemtext03_%.2d"; const char* list_tender = "static_itemtext04_%.2d"; const char* list_purchase = "static_itemtext05_%.2d"; const char* list_tender_rac = "static_itemtextr04_%.2d"; const char* list_purchase_rac = "static_itemtextr05_%.2d"; // selected... const char* selected_item_back = "static_selected_back_%.2d"; const char* selected_item_icon = "icon_selected_itemslot_%.2d"; const char* selected_item_count = "icon_selected_itemslot_count_%.2d"; const char* selected_item_item_s = "static_selected_itemtexts01_%.2d"; const char* selected_item_item_n = "static_selected_itemtextn01_%.2d"; const char* selected_item_item_l = "static_selected_itemtextl01_%.2d"; const char* selected_item_rank = "static_selected_rank_%.2d"; const char* selected_item_seller = "static_selected_itemtext02_%.2d"; const char* selected_item_limittime = "static_selected_itemtext03_%.2d"; const char* selected_item_tender = "static_selected_itemtext04_%.2d"; const char* selected_item_purchase = "static_selected_itemtext05_%.2d"; const char* selected_item_tender_rac = "static_selected_itemtextr04_%.2d"; const char* selected_item_purchase_rac = "static_selected_itemtextr05_%.2d"; // etc... const char* list_scrollbar = "static_scrollbar"; const char* bid_edit = "edit_bid"; const char* bid_rupy = "static_cash_02"; const char* page_now = "static_page_01"; const char* page_max = "static_page_02"; const char* tender = "button_common01_01"; const char* purchase = "button_common01_02"; const char* page_left = "button_page_left"; const char* page_right = "button_page_right"; // decorator const char* deco_top_div = "<#ffeab1>"; const char* deco_low_div = "<#ffffff>"; const char* deco_folded = "+ "; const char* deco_unfolded = "- "; const char* deco_indent = " "; const char* deco_list_item_count = "%s"; const char* deco_list_item_s = "<#ffeab1>+%s"; const char* deco_list_item_n = "<#ffeab1>%s"; //'Lv'을 String DB 9501로 참조하도록 한다 2009.09.25. sfreer //const char* deco_list_item_l = "<#ffeab1>#@LVTEXT@#%s"; char* deco_list_item_l = NULL;//"<#ffeab1>Lc%s"; const char* deco_list_rank = "%s"; const char* deco_list_seller = "%s"; const char* deco_list_seller_in_bidding = ""; const char* deco_list_limittime = "%s"; const char* deco_money = "%s"; const char* deco_rupy = "<#fec530>%s"; const char* deco_page_now = "%d /"; const char* deco_page_max = "%d"; } typedef AuctionCategoryDB::category_info_t category_info_t; typedef AuctionCategoryDB::category_info_container_t category_info_container_t; typedef AuctionCategoryDB::category_info_container_t::iterator category_info_iterator_t; } // 2010.04.22 - prodongi SUIAuctionSearchWnd::~SUIAuctionSearchWnd() { SAFE_DELETE_ARRAY(auction::search::deco_list_item_l); } // search products category window ---------------------------------------------------------------- void SUIAuctionSearchWnd::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.auction_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< money_t::value_t >( item.item_info.count ) ); 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 ) ); } int nIsMine = ( ::strcmp( m_searchwnd->m_PlayerInfoMgr.GetPlayerInfo().GetName(), item.seller_name ) == 0 ) ? 1 : 0; int nIsHighestBidder = ( item.flag & ( 1 << 0 ) ) ? 1 : 0; int nIsFirstBidder = ( item.flag & ( 1 << 1 ) ) ? 1 : 0; std::string strSeller; if( nIsHighestBidder ) // if it's in my bidding and i'm the highest bidder strSeller = S( 9101 ); // <#ff0000>본인 입찰 else if( nIsMine ) strSeller = S( 994 ); // <#4CFF00>본인 등록 else strSeller = item.seller_name; std::string rank; if (itemBaseInfo->nRank >= 1) XStringUtil::Format(rank, "%d", itemBaseInfo->nRank); else rank = GetStringDB().GetString( 6370 ); // "일반" element->add( &( new sui::property( "rank" ) )->set_value( rank.c_str() ) ); element->add( &( new sui::property( "is_mine" ) )->set_value( nIsMine ) ); element->add( &( new sui::property( "seller" ) )->set_value( strSeller.c_str() ) ); element->add( &( new sui::property( "limittime" ) )->set_value( (int)item.duration_type ) ); element->add( &( new sui::property( "tender_rac" ) )->set_value( S( 6618 ) ) ); if( item.instant_purchase_price > 0 ) element->add( &( new sui::property( "purchase_rac" ) )->set_value( S( 6618 ) ) ); element->add( &( new sui::property( "tender" ) )->set_value< money_t::value_t >( item.bidded_price ) ); element->add( &( new sui::property( "purchase" ) )->set_value< money_t::value_t >( item.instant_purchase_price ) ); element->add( &( new sui::property( "is_highest_bidder" ) )->set_value( nIsHighestBidder ) ); element->add( &( new sui::property( "is_first_bidder" ) )->set_value( nIsFirstBidder ) ); m_target_list.add( element ); } void SUIAuctionSearchWnd::Process( DWORD dwTime ) { SUIWnd::Process( dwTime ); } bool SUIAuctionSearchWnd::InitControls( KPoint kPos ) { // todo: init controls here... // search edit control m_pSearchEdit = dynamicCast(GetChild( auction::search::searching )); if( m_pSearchEdit ) { m_pSearchEdit->SetLineChange( false ); } // bid edit control m_pEditBid = dynamicCast< KUIControlEdit* >( GetChild( auction::search::bid_edit ) ); if( m_pEditBid ) { m_pEditBid->SetOnlyNumber( true ); m_pEditBid->SetLimitation( auction::rule::INPUT_NUMBER_LIMIT ); m_pEditBid->SetFont( "Default" ); m_pEditBid->SetFontSize( 9 ); m_pEditBid->SetText( "" ); m_pEditBid->SetCaptionAlign( KTextRender::KTALIGN_VCENTER | KTextRender::KTALIGN_RIGHT ); } // item category view m_pTreeControl = dynamicCast< KUIControIStringList* >( GetChild( auction::search::tree_folder ) ); if( m_pTreeControl ) { m_pTreeControl->SetItemShowCnt( TREE_MAX ); m_pTreeControl->SetScroll( true ); m_pTreeControl->ShowOutLine( false ); } // { sonador 3.1.5 검색 카테고리 수정 // make category tree { // "overall" m_SearchTree->add( ( new search_tree_t::node( ItemCategoryInfo( S( 6308 ), -1, -1 ) ) ) ); // load from auction category resource table auction::category_info_container_t vecCategoryInfo; GetAuctionCategoryDB().GetCategoryInfo( vecCategoryInfo, 0 ); auction::category_info_iterator_t it = vecCategoryInfo.begin(), end = vecCategoryInfo.end(); for( ; it != end; ++it ) { auction::category_info_t& info = *(*it); ItemCategoryInfo treeItem( S( info.name_id ), info.category_id, info.sub_category_id ); search_tree_t::node* pFoundNode = m_SearchTree->find( treeItem ); if( pFoundNode ) continue; search_tree_t::node* pTargetNode = 0; if( info.sub_category_id == -1 ) { pTargetNode = m_SearchTree.root(); } else { // find main category ItemCategoryInfo mainInfo; mainInfo.categoryID = info.category_id; pTargetNode = m_SearchTree->find( mainInfo ); } assert( pTargetNode && "SUIAuctionSearchWnd:Invalid category id!!!" ); if( pTargetNode ) pTargetNode->add( new search_tree_t::node( treeItem ) ); } // "etc..." m_SearchTree->add( ( new search_tree_t::node( ItemCategoryInfo( S( 6718 ), -1, 0 ) ) ) ); } // } sonador 3.1.5 검색 카테고리 수정 // copy controls and paste them _PrepareControls(); //'Lv'을 String DB 9501로 참조하도록 한다 2009.09.25. sfreer if(auction::search::deco_list_item_l == NULL) { std::string str_deco_list_item_l = "<#ffeab1>"; str_deco_list_item_l += GetStringDB().GetString( 9501 ); str_deco_list_item_l += "%s"; auction::search::deco_list_item_l = new char[str_deco_list_item_l.length()+1]; memset(auction::search::deco_list_item_l,0,str_deco_list_item_l.length()+1); strcpy(auction::search::deco_list_item_l,str_deco_list_item_l.c_str()); } // item list view m_ItemList.initialize( auction::search::list_back, auction::search::list_select, auction::search::list_scrollbar ); m_ItemList.add_column( auction::search::list_icon , new auction::kui_window_item_icon_property( "icon", m_pDisplayInfo, this, m_InventoryMgr ) ); m_ItemList.add_column( auction::search::list_item_count , new sui::kui_window_caption_property( "item_count", auction::search::deco_list_item_count ) ); m_ItemList.add_column( auction::search::list_item_s , new sui::kui_window_caption_property( "item_s", auction::search::deco_list_item_s ) ); m_ItemList.add_column( auction::search::list_item_n , new sui::kui_window_caption_property( "item_n", auction::search::deco_list_item_n ) ); m_ItemList.add_column( auction::search::list_item_l , new sui::kui_window_caption_property( "item_l", auction::search::deco_list_item_l ) );//str_deco_list_item_l.c_str() ) ); m_ItemList.add_column( auction::search::list_rank , new sui::kui_window_caption_property( "rank", auction::search::deco_list_rank ) ); m_ItemList.add_column( auction::search::list_seller , new sui::kui_window_caption_property( "seller", auction::search::deco_list_seller ) ); m_ItemList.add_column( auction::search::list_limittime , new auction::kui_window_limittime_caption_property( "limittime", auction::search::deco_list_limittime ) ); m_ItemList.add_column( auction::search::list_tender_rac , new sui::kui_window_caption_property( "tender_rac", auction::search::deco_rupy ) ); m_ItemList.add_column( auction::search::list_purchase_rac , new sui::kui_window_caption_property( "purchase_rac", auction::search::deco_rupy ) ); m_ItemList.add_column( auction::search::list_tender , new sui::kui_window_numeric_caption_property( "tender", auction::search::deco_money ) ); m_ItemList.add_column( auction::search::list_purchase , new auction::kui_window_purchase_price_caption_property( "purchase", auction::search::deco_money, S( 993 ) ) ); // selected item view m_SelectedItem.initialize( auction::search::selected_item_back, 0, 0 ); m_SelectedItem.add_column( auction::search::selected_item_icon , new auction::kui_window_item_icon_property( "icon", m_pDisplayInfo, this, m_InventoryMgr ) ); m_SelectedItem.add_column( auction::search::selected_item_count , new sui::kui_window_caption_property( "item_count", auction::search::deco_list_item_count ) ); m_SelectedItem.add_column( auction::search::selected_item_item_s , new sui::kui_window_caption_property( "item_s", auction::search::deco_list_item_s ) ); m_SelectedItem.add_column( auction::search::selected_item_item_n , new sui::kui_window_caption_property( "item_n", auction::search::deco_list_item_n ) ); m_SelectedItem.add_column( auction::search::selected_item_item_l , new sui::kui_window_caption_property( "item_l", auction::search::deco_list_item_l ) );//str_deco_list_item_l.c_str() ) ); m_SelectedItem.add_column( auction::search::selected_item_rank , new sui::kui_window_caption_property( "rank", auction::search::deco_list_rank ) ); m_SelectedItem.add_column( auction::search::selected_item_seller , new sui::kui_window_caption_property( "seller", auction::search::deco_list_seller ) ); m_SelectedItem.add_column( auction::search::selected_item_limittime , new auction::kui_window_limittime_caption_property( "limittime", auction::search::deco_list_limittime ) ); m_SelectedItem.add_column( auction::search::selected_item_tender_rac , new sui::kui_window_caption_property( "tender_rac", auction::search::deco_rupy ) ); m_SelectedItem.add_column( auction::search::selected_item_purchase_rac , new sui::kui_window_caption_property( "purchase_rac", auction::search::deco_rupy ) ); m_SelectedItem.add_column( auction::search::selected_item_tender , new sui::kui_window_numeric_caption_property( "tender", auction::search::deco_money ) ); m_SelectedItem.add_column( auction::search::selected_item_purchase , new auction::kui_window_purchase_price_caption_property( "purchase", auction::search::deco_money, S( 993 ) ) ); // pages.. m_pCtrlCurrentPage = dynamicCast< KUIControlStatic* >( GetChild( auction::search::page_now ) ); m_pCtrlEndPage = dynamicCast< KUIControlStatic* >( GetChild( auction::search::page_max ) ); // buttons KUIControlButton* pSearchButton = dynamicCast< KUIControlButton* >( GetChild( auction::search::search_start ) ); KUIControlSimpleButton* pPrevButton = dynamicCast< KUIControlSimpleButton* >( GetChild( auction::search::page_left ) ); // 2011.11.24 - servantes : KUIControlButton -> KUIControlSimpleButton 으로 변경 KUIControlSimpleButton* pNextButton = dynamicCast< KUIControlSimpleButton* >( GetChild( auction::search::page_right ) ); // 2011.11.24 - servantes : KUIControlButton -> KUIControlSimpleButton 으로 변경 m_Page.SetButton( pPrevButton, pNextButton ); m_pTenderButton = dynamicCast< KUIControlButton* >( GetChild( auction::search::tender ) ); m_pPurchaseButton = dynamicCast< KUIControlButton* >( GetChild( auction::search::purchase ) ); // append ticking actions... m_LazyMsgPoster.AppendAction( new sui::ActionBinder( new sui::ActionDisableControl( pSearchButton ), new sui::ActionEnableControl( pSearchButton ), 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 sui::ActionDisableControl( m_pTenderButton ), new sui::ActionEnableControl( m_pTenderButton ), 0 ) ); m_LazyMsgPoster.AppendAction( new sui::ActionBinder( new sui::ActionDisableControl( m_pPurchaseButton ), new sui::ActionEnableControl( m_pPurchaseButton ), 0 ) ); std::string caption; XStringUtil::Format( caption, auction::search::deco_rupy, S( 6618 ) ); KUIControlStatic* pRupy = dynamicCast< KUIControlStatic* >( GetChild( auction::search::bid_rupy ) ); if( pRupy ) pRupy->SetCaption( caption.c_str() ); // 2010.08.25 - prodongi m_checkEnableEquipItemShow = GetCheckBoxValue("common_checkbox_deco"); RefreshCategory(); return SUIWnd::InitControls( kPos ); } bool SUIAuctionSearchWnd::InitData( bool bReload ) { // init data here... return SUIWnd::InitData( bReload ); } void* SUIAuctionSearchWnd::Perform( KID id, KArg& msg ) { // process perform message here... return SUIWnd::Perform( id, msg ); } void SUIAuctionSearchWnd::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 ) if( ::stricmp( lpszControlID, auction::search::search_start ) == 0 ) { // request search message... _RequestItemList( m_CurrentCategory.categoryID, m_CurrentCategory.subCategoryID ); } else if( ::stricmp( lpszControlID, auction::search::column_item ) == 0 ) { _SortItemListByColumn( COLUMN::ITEM ); m_ItemList.update_data(); m_SelectedItem.clear(); m_SelectedItem.update_data(); } else if( ::stricmp( lpszControlID, auction::search::column_seller ) == 0 ) { _SortItemListByColumn( COLUMN::SELLER ); m_ItemList.update_data(); m_SelectedItem.clear(); m_SelectedItem.update_data(); } else if( ::stricmp( lpszControlID, auction::search::column_limittime ) == 0 ) { _SortItemListByColumn( COLUMN::LIMITTIME ); m_ItemList.update_data(); m_SelectedItem.clear(); m_SelectedItem.update_data(); } else if( ::stricmp( lpszControlID, auction::search::column_tender ) == 0 ) { _SortItemListByColumn( COLUMN::TENDER ); m_ItemList.update_data(); m_SelectedItem.clear(); m_SelectedItem.update_data(); } else if( ::stricmp( lpszControlID, auction::search::column_purchase ) == 0 ) { _SortItemListByColumn( COLUMN::PURCHASE ); m_ItemList.update_data(); m_SelectedItem.clear(); m_SelectedItem.update_data(); } else if( ::stricmp( lpszControlID, auction::search::column_rank ) == 0 ) { _SortItemListByColumn( COLUMN::RANK ); m_ItemList.update_data(); m_SelectedItem.clear(); m_SelectedItem.update_data(); } else if( ::stricmp( lpszControlID, auction::search::page_left ) == 0 ) { _RequestItemList( m_CurrentCategory.categoryID, m_CurrentCategory.subCategoryID, m_Page.Prev() ); m_bMaintainListState = false; } else if( ::stricmp( lpszControlID, auction::search::page_right ) == 0 ) { _RequestItemList( m_CurrentCategory.categoryID, m_CurrentCategory.subCategoryID, m_Page.Next() ); m_bMaintainListState = false; } else if( ::stricmp( lpszControlID, auction::search::tender ) == 0 ) { _RequestBid(); } else if( ::stricmp( lpszControlID, auction::search::purchase ) == 0 ) { _RequestInstantPurchase(); } } break; case KUI_MESSAGE::KICON_CLICK: { if( ::stricmp( lpszControlID, auction::search::searching ) == 0 ) { m_pSearchEdit->SetFocus( true ); break; } } break; // 2010.08.13 - prodongi case KUI_MESSAGE::KLIST_ITEM_DBSELECT: { if( ::stricmp( lpszControlID, auction::search::tree_folder ) == 0 ) { int real_index = static_cast< int >( lparam ); search_tree_t::node* selected_node = m_SearchTree->next_visible_index( real_index ); KUIControlStringItem::StrItem* selected_item = (KUIControlStringItem::StrItem*)m_pTreeControl->GetListItem( real_index ); if( selected_node && selected_item ) { if( selected_node->empty() ) { _RequestItemList( m_CurrentCategory.categoryID, m_CurrentCategory.subCategoryID ); } } } } break; case KUI_MESSAGE::KLIST_ITEM_SELECT: { // message from tree... if( ::stricmp( lpszControlID, auction::search::tree_folder ) == 0 ) { int real_index = static_cast< int >( lparam ); search_tree_t::node* selected_node = m_SearchTree->next_visible_index( real_index ); KUIControlStringItem::StrItem* selected_item = (KUIControlStringItem::StrItem*)m_pTreeControl->GetListItem( real_index ); if( selected_node && selected_item ) { _UpdateCurrentCategory( selected_node->get_element() ); //if( ) //{ // // select leaf node // _RequestItemList( m_CurrentCategory.categoryID, m_CurrentCategory.subCategoryID ); //} if( !selected_node->empty() ) { // fold or unfold tree node... if( selected_node->folded() ) { XStringUtil::Replace( selected_item->strCaption, auction::search::deco_folded, auction::search::deco_unfolded ); search_tree_t::node::nodes_t::iterator i = selected_node->begin(), e = selected_node->end(); for( int index = 0; i != e; ++i, ++index ) { std::string caption; search_tree_t::node* dest_node = (*i); _GetTreeItemCaption( *dest_node, caption ); KUIControlStringItem::StrItem* pStrItem = _STRITEM( caption.c_str() ); if( m_pTreeControl->InsertItem( pStrItem, real_index + index + 1 ) == -1 ) SAFE_DELETE( pStrItem ); } } else { XStringUtil::Replace( selected_item->strCaption, auction::search::deco_unfolded, auction::search::deco_folded ); int children_size = selected_node->size_children(); for( int n = 0; n < children_size; ++n ) { m_pTreeControl->DeleteItem( real_index + 1 ); } } selected_node->toggle(); } } m_pTreeControl->UpdateListControl(); } // message from item list... else 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(); // sonador 7.0.24 경매장 입찰금 자동 입력 오류 수정 money_t nBidablePrice = (*item)[ "is_first_bidder" ].get_int_value() ? money_t( (*item)[ "tender" ].get_int64_value() ) : auction::rule::GetBiddablePrice( money_t( (*item)[ "tender" ].get_int64_value() ) ); _UpdateBidablePrice( nBidablePrice ); } } } break; //case KUI_MESSAGE::KLIST_ITEM_LDBLCLK: // if( ::stricmp( lpszControlID, auction::search::tree_folder ) == 0 ) // { // int real_index = static_cast< int >( lparam ); // search_tree_t::node* selected_node = m_SearchTree->next_visible_index( real_index ); // KUIControlStringItem::StrItem* selected_item = (KUIControlStringItem::StrItem*)m_pTreeControl->GetListItem( real_index ); // if( selected_node && selected_item ) // { // _UpdateCurrentCategory( selected_node->get_element() ); // _RequestItemList( m_CurrentCategory.categoryID, m_CurrentCategory.subCategoryID ); // } // m_pTreeControl->UpdateListControl(); // } // break; case KUI_MESSAGE::KEDIT_CHANGE: { if( ::_stricmp( lpszControlID, auction::search::bid_edit ) == 0 ) { _UpdateBidablePrice( auction::rule::GetPriceFrom( m_pEditBid ) ); } else if( ::_stricmp( lpszControlID, auction::search::searching ) == 0 ) { m_bMaintainListState = false; } } break; // 2010.08.25 - prodongi case KUI_MESSAGE::KCHECK_CHANGE: { m_pGameManager->StartSound( "ui_button_click.wav" ); if( ::_stricmp( "common_checkbox_deco", lpszControlID ) == 0 ) { m_checkEnableEquipItemShow = GetCheckBoxValue( lpszControlID ); } } break; /// 2011.05.12 - 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 SUIAuctionSearchWnd::ProcMsgAtStatic( SGameMessage* pMsg ) { // process game message here... switch( pMsg->nType ) { case IMSG_RES_AUCTION_SEARCH: { SIMSG_RES_AUCTION_SEARCH* msg = dynamicCast< SIMSG_RES_AUCTION_SEARCH* >( 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->auction_info_count > 0 ) { std::for_each( msg->auction_info, msg->auction_info + msg->auction_info_count, ItemImporter( this, 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(); _UpdateBidablePrice(); } break; case MSG_RESULT: { SMSG_RESULT* msg = dynamicCast< SMSG_RESULT* >( pMsg ); switch( msg->request_msg_id ) { case TM_CS_AUCTION_SEARCH: if( msg->result == RESULT_NOT_EXIST ) { _UpdatePage(); m_ItemList.clear(); m_ItemList.update_data(); m_SelectedItem.clear(); m_SelectedItem.update_data(); _UpdateBidablePrice( money_t( 0 ) ); } break; #ifdef _DEBUG case TM_CS_AUCTION_BID: if( msg->result == RESULT_SUCCESS ) m_NoticeBox.AppendUrgent( "입찰 성공" ); break; case TM_CS_AUCTION_INSTANT_PURCHASE: if( msg->result == RESULT_SUCCESS ) m_NoticeBox.AppendUrgent( "즉구 성공" ); break; #endif } } break; case IMSG_HOTKEY_EX: { SIMSG_HOTKEY_EX* pHotKey = dynamicCast(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 SUIAuctionSearchWnd::OnNotifyUIWindowOpen( bool bOpen, bool bLimitWnd ) { SUIWnd::OnNotifyUIWindowOpen( bOpen, bLimitWnd ); if( bOpen ) { m_LazyMsgPoster.CancelLazyMessage(); } else { m_SelectedItem.clear(); } } DWORD SUIAuctionSearchWnd::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 SUIAuctionSearchWnd::_PrepareControls() { } // 2010.08.12 - prodongi void SUIAuctionSearchWnd::enterSearch() { if (!m_pSearchEdit->isEndComposing()) { _RequestItemList( m_CurrentCategory.categoryID, m_CurrentCategory.subCategoryID ); m_pSearchEdit->SetFocus(false); } } void SUIAuctionSearchWnd::RefreshCategory() { _RefreshKeyword(); _RefreshTree(); _UpdatePage(); m_ItemList.clear(); m_ItemList.update_data(); m_SelectedItem.clear(); m_SelectedItem.update_data(); _UpdateCurrentCategory(); _UpdateBidablePrice( money_t( 0 ) ); m_bMaintainListState = false; } void SUIAuctionSearchWnd::_RefreshTree() { m_pTreeControl->ClearItem(); search_tree_t::node* node = m_SearchTree->next_visible(); while( node ) { std::string caption; _GetTreeItemCaption( *node, caption ); KUIControlStringItem::StrItem* pStrItem = _STRITEM( caption.c_str() ); /// 2010.12.23 - prodongi pStrItem->uiFlag = KFLAG_NO_GET_MESSAGE | KFLAG_SINGLE_LINE; if( m_pTreeControl->AddItem( pStrItem ) == -1 ) SAFE_DELETE( pStrItem ); node = node->next_visible(); } m_pTreeControl->SetCrrIndex( 0 ); // default selection : "search all" } void SUIAuctionSearchWnd::_RefreshKeyword() { if( m_pSearchEdit ) m_pSearchEdit->SetText( "" ); } void SUIAuctionSearchWnd::_UpdatePage( int nCurrent, int nTotal ) { std::string strCurrentPage, strEndPage; m_Page.Update( nCurrent, nTotal ); XStringUtil::Format( strCurrentPage, auction::search::deco_page_now, m_Page.Current() ); XStringUtil::Format( strEndPage, auction::search::deco_page_max, m_Page.End() ); m_pCtrlCurrentPage->SetCaption( strCurrentPage.c_str() ); m_pCtrlEndPage->SetCaption( strEndPage.c_str() ); } void SUIAuctionSearchWnd::_UpdateCurrentCategory( const ItemCategoryInfo& info ) { if( m_CurrentCategory != info ) { m_CurrentCategory = info; // refresh search keyword... _RefreshKeyword(); m_bMaintainListState = false; } } void SUIAuctionSearchWnd::_UpdateBidablePrice( money_t nPrice ) { if( m_pEditBid == 0 ) return; if( m_SelectedItem.empty() || !m_SelectedItem[ 0 ] ) { auction::rule::SetPriceTo( m_pEditBid, money_t( 0 ) ); return; } item_list_t::item_t& item = *m_SelectedItem[ 0 ]; // normalize the price... auction::rule::NormalizeBasePrice( nPrice ); auction::rule::SetPriceTo( m_pEditBid, nPrice ); money_t nBidablePrice( 0 ); money_t nPurchasePrice( item[ "purchase" ].get_int64_value() ); if( item[ "is_first_bidder" ].get_int_value() ) nBidablePrice = money_t( item[ "tender" ].get_int64_value() ); else nBidablePrice = auction::rule::GetBiddablePrice( money_t( item[ "tender" ].get_int64_value() ) ); bool bEditBid = true; bool bTender = true; bool bPurchase = true; if( nBidablePrice >= nPurchasePrice && nPurchasePrice > 0 ) { //m_NoticeBox.AppendUrgent( S( -543 ) ); // 최소 입찰 가능 가격이 즉시 구매 가격보다 높아 즉시 구매만 가능합니다. bEditBid = false; bTender = false; } if( nPrice < nBidablePrice ) { m_NoticeBox.AppendUrgent( S( 984 ) ); // "기존 입찰 가격보다 1% 이상 높은 가격으로만 입찰 할 수 있습니다." bTender = false; } if( nPrice >= nPurchasePrice && nPurchasePrice > 0 ) { m_NoticeBox.AppendUrgent( S( 985 ) ); // 즉시 구매 가격보다 낮은 가격으로만 입찰 할 수 있습니다. bTender = false; } if( item[ "is_mine" ].get_int_value() ) { bEditBid = false; bTender = false; bPurchase = false; } if( item[ "is_highest_bidder" ].get_int_value() ) bTender = false; if( nPurchasePrice <= 0 ) bPurchase = false; m_pEditBid->SetShow( bEditBid ); m_pTenderButton->SetShow( bTender ); m_pPurchaseButton->SetShow( bPurchase ); } void SUIAuctionSearchWnd::_GetTemporaryListData() { } void SUIAuctionSearchWnd::_RequestItemList( int nCategoryID, int nSubCategoryID, int nPage ) { std::string strKeyword; if( m_pSearchEdit ) { strKeyword = m_pSearchEdit->GetText(); } SIMSG_REQ_AUCTION_SEARCH* pMsg = new SIMSG_REQ_AUCTION_SEARCH( nCategoryID, nSubCategoryID, strKeyword.c_str(), nPage, m_checkEnableEquipItemShow ); m_LazyMsgPoster.PostMsgAtDynamic( pMsg, auction::rule::SEARCH_REQ_DELAY ); } void SUIAuctionSearchWnd::_RequestBid() { if( !m_SelectedItem.empty() && m_SelectedItem[ 0 ] ) { item_list_t::item_t& prop = *m_SelectedItem[ 0 ]; money_t nBiddingPrice = auction::rule::GetPriceFrom( m_pEditBid ); auction::rule::NormalizeBasePrice( nBiddingPrice ); SIMSG_REQ_AUCTION_BID* pMsg = new SIMSG_REQ_AUCTION_BID(); pMsg->auction_uid = prop[ "id" ].get_int_value(); pMsg->bidding_price = nBiddingPrice; m_pGameManager->PostMsgAtDynamic( pMsg ); // request updated list _RequestItemList( m_CurrentCategory.categoryID, m_CurrentCategory.subCategoryID, m_Page.Current() ); } } void SUIAuctionSearchWnd::_RequestInstantPurchase() { if( !m_SelectedItem.empty() && m_SelectedItem[ 0 ] ) { // request bid SIMSG_REQ_AUCTION_INSTANT_PURCHASE* pMsg = new SIMSG_REQ_AUCTION_INSTANT_PURCHASE(); item_list_t::item_t& prop = *m_SelectedItem[ 0 ]; pMsg->auction_uid = prop[ "id" ].get_int_value(); m_pGameManager->PostMsgAtDynamic( pMsg ); // request updated list int nReqPage = m_Page.Current(); if( m_ItemList.size() == 1 && nReqPage == m_Page.End() ) nReqPage = m_Page.Prev(); _RequestItemList( m_CurrentCategory.categoryID, m_CurrentCategory.subCategoryID, nReqPage ); } } void SUIAuctionSearchWnd::_GetTreeItemCaption( const search_tree_t::node& node, std::string& caption ) { // division if( node.depth() == 1 ) { // top division caption = auction::search::deco_top_div; } else { // lower division caption = auction::search::deco_low_div; } // indentation int indent = node.depth() - 1; for( int i = 0; i < indent; ++i ) { caption += auction::search::deco_indent; } // identification of folder state if( node.folded() ) { caption += auction::search::deco_folded; } else { caption += auction::search::deco_unfolded; } // title caption += node.get_element().name; } void SUIAuctionSearchWnd::_SortItemListByColumn( COLUMN id, bool maintain ) { 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::SELLER: if( m_bSortButtonState[ id ] == 0 ) m_ItemList.stable_sort< std::string >( "seller", auction::ColumnCompareLessThen< std::string >() ); else m_ItemList.stable_sort< std::string >( "seller", auction::ColumnCompareMoreThen< std::string >() ); break; case COLUMN::LIMITTIME: if( m_bSortButtonState[ id ] == 0 ) m_ItemList.stable_sort< int >( "limittime", auction::ColumnCompareLessThen< int >() ); else m_ItemList.stable_sort< int >( "limittime", auction::ColumnCompareMoreThen< int >() ); break; case COLUMN::TENDER: if( m_bSortButtonState[ id ] == 0 ) m_ItemList.stable_sort< money_t::value_t >( "tender", auction::ColumnCompareLessThen< money_t::value_t >() ); else m_ItemList.stable_sort< money_t::value_t >( "tender", auction::ColumnCompareMoreThen< money_t::value_t >() ); break; case COLUMN::PURCHASE: if( m_bSortButtonState[ id ] == 0 ) m_ItemList.stable_sort< money_t::value_t >( "purchase", auction::ColumnCompareLessThen< money_t::value_t >() ); else m_ItemList.stable_sort< money_t::value_t >( "purchase", auction::ColumnCompareMoreThen< money_t::value_t >() ); break; case COLUMN::RANK: if( m_bSortButtonState[ id ] == 0 ) m_ItemList.stable_sort< std::string >( "rank", auction::RankCompareLessThen() ); else m_ItemList.stable_sort< std::string >( "rank", auction::RankCompareMoreThen() ); break; default: return; } m_nSavedSortingState = id; } // 2010.08.25 - prodongi int SUIAuctionSearchWnd::GetCheckBoxValue( const char * pControlName ) { KUIControlCheck* pCheck = dynamicCast( GetChild(pControlName) ); if( pCheck ) { bool bFlag = pCheck->GetCheck(); return bFlag ? 1 : 0; } return 0; }