#include "stdafx.h" #include "NpcDisjointWindow.h" #include "ItemManager.h" #include "Gauge.h" #include "Label.h" #include "NumberEditBox.h" #include "Button.h" #include "ItemIcon.h" #include "GameResourceManager.h" #include "ChatManager.h" #include "ObjectManager.h" #include "Hero.h" cNpcDisjointWindow::cNpcDisjointWindow() : mpGaugeBar(0) , mpPrice(0) , mpDisjointButton(0) , mItemIcon(0) { for( int i = 0; i < DISJOINT_COUNT; ++i ) mResultIcon[i] = 0; } cNpcDisjointWindow::~cNpcDisjointWindow() { } /// ÃʱâÈ­ void cNpcDisjointWindow::Clear() { /// ¾ÆÀÌÅÛ ¶ô ÃʱâÈ­ unsigned short slotIndex = mItemIcon->GetSlotIndex(); if( slotIndex <= MAX_INVENTORY ) { cItem* oldItem = ITEMMAN->GetItem( slotIndex ); if( oldItem ) { oldItem->SetLock( false ); } mItemIcon->SetSlotIndex( USHRT_MAX ); } /// ¾ÆÀÌÄÜ ÃʱâÈ­ mItemIcon->ChangeImage( 0 ); for( unsigned int i = 0; i < DISJOINT_COUNT; ++i ) { mResultIcon[i]->ChangeImage( 0 ); mResultIcon[i]->SetItemIndex( 0 ); mResultIcon[i]->ShowNumber( false ); mResultIcon[i]->SetNumber( 0 ); } if( mpGaugeBar ) mpGaugeBar->ClearFront(); SetPrice( 0 ); /// NetUnLock(); if( mpDisjointButton ) mpDisjointButton->SetEnabled( false ); /// ¾ÆÀÌÅÛ ºÐÇØ »ç¿îµå Àç»ý Ãë¼ÒÇϱâ. HERO->ClearItemDisjointSound(); } void cNpcDisjointWindow::Open() { } void cNpcDisjointWindow::Close() { cUIWindow::Close(); HERO->CloseNpcTalk( false ); Clear(); } void cNpcDisjointWindow::OnHide() { cUIWindow::OnHide(); HERO->CloseNpcTalk(); Clear(); } bool cNpcDisjointWindow::OnCreate( cUINodeProperty* property ) { if( cUIWindow::OnCreate( property ) == false ) return false; mpGaugeBar = (cGauge*)GetChild( eUIID_GAME_NPCDISJOINT_GAUGEBAR ); mpPrice = (cLabel*)GetChild( eUIID_GAME_NPCDISJOINT_PRICE ); mpDisjointButton = (cButton*)GetChild( eUIID_GAME_NPCDISJOINT_DISJOINT ); if( mpDisjointButton ) mpDisjointButton->SetEnabled( false ); if( mpGaugeBar ) mpGaugeBar->SetMaxValue( 100 ); /// ºÐÇØ °á°ú ¾ÆÀÌÄÜ »ý¼º cString str; for( unsigned int i = 0; i < DISJOINT_COUNT; ++i ) { str.Format( "Disjoint_Result%02d", i ); cItemIcon* icon = new cItemIcon; if( icon->CreateBySkinName( str, this, i+1 ) == false ) return false; icon->SetUsedFlag( false, false ); mResultIcon[i] = icon; } /// ºÐÇØÇÒ ¾ÆÀÌÅÛ ¾ÆÀÌÄÜ »ý¼º mItemIcon = new cItemIcon; if( mItemIcon->CreateBySkinName( "Disjoint_Item", this, 100 ) == false ) return false; /// hover À̺¥Æ®´Â ó¸®ÇÏÁö¸¸ À̵¿ ºÒ°¡ mItemIcon->SetUsedFlag( false, false ); // SetPrice(0); return true; } void cNpcDisjointWindow::OnCommand( cUINode*, unsigned int id ) { switch( id ) { case eUIID_GAME_NPCDISJOINT_CLOSE: { Hide(); /// ¾ÆÀÌÅÛ ºÐÇØ »ç¿îµå Àç»ý Ãë¼ÒÇϱâ. HERO->ClearItemDisjointSound(); } break; case eUIID_GAME_NPCDISJOINT_CANCEL: if( mpGaugeBar && mpGaugeBar->IsProgress() == true ) { if( mpGaugeBar ) mpGaugeBar->ClearFront(); if( mpDisjointButton ) mpDisjointButton->SetEnabled( true ); HERO->ClearItemDisjointSound(); } else { Hide(); } break; case eUIID_GAME_NPCDISJOINT_DISJOINT: if( mItemIcon->GetSlotIndex() <= MAX_INVENTORY ) { unsigned long state = HERO->GetState(); eSTOPFLAG stopFlag = HERO->GetStopFlag(); if( !(state == eOBJECT_STATE_STOP && stopFlag == eSTOP_NPCSPEECH ) ) { CHATMANAGER->AddSystemMsg( eSYSTEM_NORMAL, GAMERESOURCEMAN->GetGameText( 235 ) ); return; } /// ºÐÇØ Á¶°Ç°Ë»ç if( ITEMMAN->CheckDisjoint( mItemIcon->GetSlotIndex() ) == false ) return; if( mpGaugeBar ) { float speed = 100.0f / ((float)DISJOINT_DELAYTIME*0.001f); mpGaugeBar->SetGaugeSpeed( speed ); mpGaugeBar->SetGaugeAni( 100.0f ); } /// ¾ÆÀÌÅÛ ºÐÇØ »ç¿îµå Àç»ý HERO->SetItemDisjointSound(); if( mpDisjointButton ) mpDisjointButton->SetEnabled( false ); /// ¶ô °É±â NetLock(); } break; } } void cNpcDisjointWindow::OnGaugeEnd( cUINode* n , unsigned int ) { if( mpGaugeBar && n == mpGaugeBar ) { /// ºÐÇØ½ÃÀÛ¹öư if( ITEMMAN->TryToDisjoint( mItemIcon->GetSlotIndex() ) == false ) { NetUnLock(); UIMAN->CreateMsgBox( eStage_Game, eMSGBOX_MODAL, eMBEVENT_NONE, eSKIN_OK, GAMERESOURCEMAN->GetGameText( 261 ), GAMERESOURCEMAN->GetGameText( 301 ) ); if( mpGaugeBar ) mpGaugeBar->ClearFront(); } UIMAN->HideTip(); } } /// ºÐÇØ ¾ÆÀÌÅÛ µî·Ï bool cNpcDisjointWindow::AddItem( unsigned short slotIndex ) { /// ÀÌ¹Ì ºÐÇØÁßÀÌ¸é ¸®ÅÏ if( mpDisjointButton->IsNetLock() == true ) return false; if( slotIndex > MAX_INVENTORY ) return false; /// Á¦ÇÑ ½½·Ô üũ unsigned short bagEnd = HERO->GetBagEndSlot(); if ( slotIndex > bagEnd ) { assert( 0 && "Bad slot index" ); CHATMANAGER->AddSystemMsg( eSYSTEM_NORMAL, GAMERESOURCEMAN->GetGameText( 3101 ) ); return false; } cItem* item = ITEMMAN->GetItem( slotIndex ); if( !item ) { assert(0); return false; } cItemDefine* define = item->GetDefine(); if( !define ) { assert(0); return false; } sItemDisjoint* data = define->GetDisjoint(); if( !data ) { UIMAN->CreateMsgBox(eStage_Game, eMSGBOX_MODAL, eMBEVENT_NONE, eSKIN_OK, GAMERESOURCEMAN->GetGameText( 299 ), GAMERESOURCEMAN->GetGameText( 301 ) ); return false; } /// ¹ÌÀÎÁõµÈ ¾ÆÀÌÅÛÀÌ¸é °­È­ ºÒ°¡´É if( item->IsSeal() == true ) { UIMAN->CreateMsgBox(eStage_Game, eMSGBOX_MODAL, eMBEVENT_NONE, eSKIN_OK, GAMERESOURCEMAN->GetGameText( 293 ), GAMERESOURCEMAN->GetGameText( 301 ) ); return false; } /// °á°ú Á¤º¸ ÃʱâÈ­ for( unsigned int i = 0; i < DISJOINT_COUNT; ++i ) { mResultIcon[i]->ChangeImage( 0 ); mResultIcon[i]->SetTipType( eTOOLTIP_NONE ); mResultIcon[i]->SetNumber( 0 ); mResultIcon[i]->SetItemIndex( 0 ); mResultIcon[i]->ShowNumber( false ); } /// ±âÁ¸ µî·Ï ¾ÆÀÌÅÛ »èÁ¦ unsigned short itemSlotIndex = mItemIcon->GetSlotIndex(); if( itemSlotIndex <= MAX_INVENTORY && itemSlotIndex != slotIndex ) { cItem* oldItem = ITEMMAN->GetItem( itemSlotIndex ); if( oldItem ) { oldItem->SetLock( false ); } } /// ÂüÁ¶ ½½·Ô À妽º mItemIcon->SetSlotIndex( slotIndex ); item->SetLock( true ); /// ¾ÆÀÌÅÛ À̹ÌÁö üÀÎÁö mItemIcon->SetItemIndex( item->GetIndex() ); mItemIcon->ChangeImage( define->GetIconParam() ); mItemIcon->SetTipType( define->GetTipType() ); /// ºÐÇØ °á°ú ¾ÆÀÌÅÛ Á¤º¸ µî·Ï int result = 0; for( int i = 0 ; i < MAX_DISJOINT; ++i, ++result ) { if( data->mDisjoint[i].itemIndex == 0 ) break; cItemDefine* resultDefine = ITEMMAN->GetItemDefine( data->mDisjoint[i].itemIndex ); if( !resultDefine ) { assert(0); return false; } /// Á¤º¸ ¼¼ÆÃ mResultIcon[result]->SetItemIndex( data->mDisjoint[i].itemIndex ); mResultIcon[result]->ChangeImage( resultDefine->GetIconParam() ); mResultIcon[result]->SetNumber( data->mDisjoint[i].count ); mResultIcon[result]->SetTipType( resultDefine->GetTipType() ); bool show = ( resultDefine->GetCapacity() > 1 ) ? true : false; mResultIcon[result]->ShowNumber( show ); } SetPrice( data->mPrice ); /// ¾ÆÀÌÅÛ µî·Ï ½Ã »ç¿îµå Àç»ý ITEMMAN->PlayIconSettingSound( slotIndex ); if( mpDisjointButton ) mpDisjointButton->SetEnabled( true ); return true; } void cNpcDisjointWindow::SetPrice( unsigned int price ) { if( mpPrice ) { LPCTSTR value = cNumberEditBox::FormatNumber( price ); mpPrice->SetText( value ); } } /// void cNpcDisjointWindow::OnNetLock( int lockTry ) { if( mpDisjointButton ) mpDisjointButton->NetLock( lockTry ); } void cNpcDisjointWindow::OnNetUnLock( int lockTry ) { if( mpDisjointButton ) mpDisjointButton->NetUnLock( lockTry ); } unsigned short cNpcDisjointWindow::GetSlotIndex() { return ( mItemIcon ) ? mItemIcon->GetSlotIndex() : USHRT_MAX; }