#include "StdAfx.h" #include "SkillWindow.h" #include "TabButton.h" #include "Label.h" #include "CheckBox.h" #include "UIRootNode.h" #include "Skillscript.h" #include "GameResourceManager.h" #include "SkillManager.h" #include "SkillStepListWindow.h" #include "DragWindow.h" #include "QuickManager.h" #include "ObjectManager.h" #include "Hero.h" #include "skillicon.h" #include "TipWindow.h" #include "SkillSheetWindow.h" cSkillWindow::cSkillWindow() : mpSkillPoint(0) , mpSkillUsePoint(0) , mBackupPos(0, 0) , mpSkillStepListWindow(0) , mImageSize(0, 0) , mpVisibleStepWinCheckBtn(0) { mpCommuButton = 0; mpCommuSheetWindow = 0; mJobTabCount = 0; mIsBackup = false; mCommuBtnBaseRect.Set(0, 0, 0, 0); ::ZeroMemory( mpSkillPointImg, sizeof(mpSkillPointImg) ); } cSkillWindow::~cSkillWindow() { if( mpSkillPointImg ) ::ZeroMemory( mpSkillPointImg, sizeof(mpSkillPointImg) ); } void cSkillWindow::Clear() { for( unsigned int i=0; iClear(); RemoveChildComplete( p ); } mTabSheetArray.Clear(); for( unsigned int i=0; iClear(); } void cSkillWindow::Open() { } void cSkillWindow::Close() { cTabWindow::Close(); Clear(); UIMAN->HideTip(); UIMAN->HideDrag( this ); /// npc »óÁ¡Ã¢ÀÌ ¿­·ÁÀÖÀ¸¸é ´Ý±â if( HERO->IsOpenNpcTalk() == true ) HERO->CloseNpcTalk( false ); ApplyBackupPos(); } void cSkillWindow::OnShow() { cTabWindow::OnShow(); int size = mTabButtonArray.GetSize(); if( size > 0) SetCurrent( size-1 ); ShowSkillUpButton(); } void cSkillWindow::OnHide() { cTabWindow::OnHide(); if( mpSkillStepListWindow ) mpSkillStepListWindow->Hide(); UIMAN->HideTip(); UIMAN->HideDrag( this ); /// npc »óÁ¡Ã¢ÀÌ ¿­·ÁÀÖÀ¸¸é ´Ý±â if( HERO->IsOpenNpcTalk() == true ) HERO->CloseNpcTalk(); ApplyBackupPos(); } void cSkillWindow::InitSkillData() { for( unsigned int i=0; iInitSkillData(); } // ½ºÅ³ ÃʱâÈ­½Ã ½ºÅ³ ´Ü°èº° ¸®½ºÆ®ÀÇ ¸ðµç ¿ø¼Ò´Â Á¦°Å ½ÃŲ´Ù. if( mpSkillStepListWindow ) mpSkillStepListWindow->Clear(); UpdateSkillPoint(); UpdateSkillUsePoint(); } void cSkillWindow::UpdateSkin() { cTabWindow::UpdateSkin(); if( mpSkillStepListWindow ) { const cUIRect& rect = mpSkillStepListWindow->GetRelativeRect(); mpSkillStepListWindow->SetRelativePos( cUIPos(rect.mLeft, mRelativeRect.GetHeight()-rect.GetHeight()) ); } int size = mTabButtonArray.GetSize(); if( size > 0) SetCurrent( size-1 ); } unsigned int cSkillWindow::AddJobTab( unsigned long jobIdx ) { cString str = "JobTabbutton"; cTabButton* btn = new cTabButton; if( btn->CreateBySkinName( str, this, 1 ) == false ) { assert(0); return 0; } /// mCommuBtnBaseRect = btn->GetRelativeRect(); btn->SetRelativePos( cUIPos( mCommuBtnBaseRect.mLeft + mCommuBtnBaseRect.GetWidth() * mJobTabCount, mCommuBtnBaseRect.mTop) ); btn->SetText( GAMERESOURCEMAN->GetJobName( jobIdx ) ); AddTab( btn ); UIMAN->GetRootNode()->AddProcessChild( btn ); mJobTabCount++; UpdateCommuButtonPos(); /// cSkillSheetWindow* sheet = new cSkillSheetWindow; if( sheet->CreateBySkinName( "skillSheet", this, (unsigned int)jobIdx ) == false ) { assert(0); return 0; } cSkillTree* pTree = SKILLSCRIPT->GetSkillTree( jobIdx ); assert(pTree); if( pTree ) { sheet->InitSkillSheetInfo( jobIdx, pTree ); // ½ºÅ³ ´Ü°èº° Ç¥½Ã ¸®½ºÆ® À©µµ¿ì »ý¼º ¹× Data ÃʱâÈ­ if( mpSkillStepListWindow ) mpSkillStepListWindow->ResetSkillInfo(); } AddSheet( sheet ); UIMAN->GetRootNode()->AddProcessChild( sheet ); SetCurrent( mJobTabCount ); return mTabButtonArray.GetSize(); } /// ÁÖÀÇ»çÇ× : bool cSkillWindow::OnCreate( cUINodeProperty* pproperty ) { if( cTabWindow::OnCreate( pproperty ) == false ) return false; mpSkillPoint = (cLabel*)GetChild( eUIID_GAME_SKILL_POINT ); mpSkillUsePoint = (cLabel*)GetChild( eUIID_GAME_SKILL_USEPOINT ); mpSkillStepListWindow = (cSkillStepListWindow*)GetChild( eUIID_GAME_SKILL_STEPWINDOW ); mpVisibleStepWinCheckBtn = (cCheckBox*)GetChild( eUIID_GAME_SKILL_CHECKBOX ); mpSkillPointImg[eSKILL_USE_IMG] = (cUINode*)GetChild( eUIID_GAME_SKILL_USEPOINTIMG ); mpSkillPointImg[eSKILL_REST_IMG] = (cUINode*)GetChild( eUIID_GAME_SKILL_POINTIMG ); if( mpVisibleStepWinCheckBtn ) { mpVisibleStepWinCheckBtn->SetPress( true ); } if( mpSkillStepListWindow ) { const cUIRect& rect = mpSkillStepListWindow->GetRelativeRect(); mpSkillStepListWindow->SetRelativePos( cUIPos(rect.mLeft, mRelativeRect.GetHeight()-rect.GetHeight()) ); } // ½ºÅ³ »ç¿ë, ³²Àº SP Ãâ·ÂºÎºÐ À̹ÌÁö for( unsigned char i = 0; i < eSKILL_IMG_MAX; i++ ) { if( mpSkillPointImg[ i ] ) { mpSkillPointImg[ i ]->Hide(); } } cString str = "JobTabbutton"; mpCommuButton = new cTabButton; if( mpCommuButton->CreateBySkinName( str, this, 1 ) == false ) { assert(0); return false; } mpCommuButton->SetText( UIMAN->GetUIText(24) ); UpdateCommuButtonPos(); AddTab(mpCommuButton); mpCommuSheetWindow = new cCommuSheetWindow; if( mpCommuSheetWindow->CreateBySkinName( "communitySheet", this, 2 ) == false ) { assert(0); return false; } AddSheet( mpCommuSheetWindow ); // Ãʱâ À̹ÌÁö »çÀÌÁî ¼ÂÆÃ mImageSize.mWidth = mRelativeRect.GetWidth(); mImageSize.mHeight = mRelativeRect.GetHeight(); if( mpImage ) { cUIRect imageRect; imageRect.mLeft = mAbsoluteRect.mLeft; imageRect.mTop = mAbsoluteRect.mTop; imageRect.mRight = imageRect.mLeft + mImageSize.mWidth; imageRect.mBottom = imageRect.mTop + mImageSize.mHeight; mpImage->SetScreenRect( imageRect ); } return true; } void cSkillWindow::UpdateRect() { cUIWindow::UpdateRect(); if( mpImage ) { cUIRect imageRect; imageRect.mLeft = mAbsoluteRect.mLeft; imageRect.mTop = mAbsoluteRect.mTop; imageRect.mRight = imageRect.mLeft + mImageSize.mWidth; imageRect.mBottom = imageRect.mTop + mImageSize.mHeight; mpImage->SetScreenRect( imageRect ); } } /// ÁÖÀÇ»çÇ× : void cSkillWindow::OnCommand( cUINode*, unsigned int id ) { /// Ŭ·ÎÁî¹öư´©¸£¸é ¾Èº¸ÀÓ. if( id == eUIID_GAME_SKILL_CLOSE_BUTTON ) { Hide(); } } void cSkillWindow::OnIconDragged( cUINode* caller, unsigned int /*id*/, const cUIPos& pos, bool shift ) { cIcon* icon = (cIcon*)caller; if( icon == 0 ) return; if( icon->GetIconType() == eICON_SKILL ) { UIMAN->ShowDrag( this, DRAG_FROM_SKILLWINDOW, icon, pos, shift ); } else if( icon->GetIconType() == eICON_COMMUNITY ) { UIMAN->ShowDrag( this, DRAG_FROM_COMMUNITYWINDOW, icon, pos, shift ); } else { assert(0); } } void cSkillWindow::OnCheckBoxChanged( cUINode* caller, unsigned int id ) { cCheckBox* checkbox = (cCheckBox*)caller; if( !checkbox ) return; switch( id ) { case eUIID_GAME_SKILL_CHECKBOX: { if( checkbox->IsPress() ) { if( mpSkillStepListWindow && mpCommuSheetWindow != GetCurrentSheet() ) { SetRelativeSize( cUISize( mImageSize.mWidth+mpSkillStepListWindow->GetAbsoluteRect().GetWidth(), mRelativeRect.GetHeight())); mpSkillStepListWindow->Show(); } } else { SetRelativeSize( mImageSize ); if( mpSkillStepListWindow ) mpSkillStepListWindow->Hide(); } } break; } } void cSkillWindow::UpdateSkillStep( unsigned long idx, unsigned char step ) { for( unsigned int i=0; iGetSkillIcon( idx ); if( icon == 0 ) continue; assert( icon->GetSkillIdx() == idx ); icon->SetSkillInfo( idx, step, p->GetJobIdx(), eTIP_SKILL ); icon->SetUsedFlag( true ); icon->SetColor( NiColorA::WHITE ); } } /// ¿À¶ó½ºÅ³ ¼¼ÆÃ¿ë void cSkillWindow::SetOnAura( unsigned long skillIdx, unsigned long AuraUniqueIdx, bool on ) { for( unsigned int i=0; iGetSkillIcon( skillIdx ); if( icon == 0 ) continue; /// ¿À¶ó½ºÅ³ ¼¼ÆÃ icon->SetAuraUniqueIdx( AuraUniqueIdx ); icon->SetAuraOn( on ); QUICKMAN->SetSkillAniAura( skillIdx, icon->GetAniParam() ); } } unsigned long cSkillWindow::GetAuraUniqueIdx( unsigned long idx ) { for( unsigned int i=0; iGetSkillIcon( idx ); if( icon == 0 ) continue; if( icon->IsAuraOn() == false ) return 0; return icon->GetAuraUniqueIdx(); } return 0; } void cSkillWindow::ClearCoolTime( unsigned long exceptSkillIdx ) { for( unsigned int i=0; iClearSkillCoolTime( exceptSkillIdx ); } QUICKMAN->ClearCoolTime( exceptSkillIdx ); if( mpSkillStepListWindow ) mpSkillStepListWindow->UpdateIConListInfo(); } void cSkillWindow::UpdateSkillPoint() { if( mpSkillPoint ) mpSkillPoint->SetValue( HERO->GetSkillPointRemain() ); } void cSkillWindow::UpdateSkillUsePoint() { if( mpSkillUsePoint ) { if( mCurrentSheet == 0 ) return; if( mCurrentSheet == mpCommuSheetWindow ) { mpSkillUsePoint->Clear(); return; } unsigned long totalUsSP = 0; unsigned long jobIdx = ((cSkillSheetWindow*)mCurrentSheet)->GetJobIdx(); unsigned int jobStep = GAMERESOURCEMAN->GetJobStep( jobIdx ); /// Á÷¾÷ º¯È¯½Ã »ç¿ë ½ºÅ³Æ÷ÀÎÆ® Àç°è»ê.. tPointerHashMap* keepSkillMap = SKILLMAN->GetKeepSkillMap(); if( keepSkillMap ) { tPointerHashMap::cIterator iter = keepSkillMap->Begin(); while( iter != keepSkillMap->End() ) { unsigned long skillIdx = (*iter).mFirst; sKeepSkill* pKeepSkill = (sKeepSkill*)((*iter).mSecond); if( pKeepSkill == 0 ) { assert(0); return; } ++iter; sPlayerSkillBaseInfo* pSkillInfo = SKILLSCRIPT->GetPlayerSkillInfo( skillIdx ); if( pSkillInfo == 0 ) continue; if( pSkillInfo->mJobStep != jobStep ) continue; if( pSkillInfo->mStepCount <= pKeepSkill->mStep ) { assert(0); continue; } for( unsigned int i=0;i<=pKeepSkill->mStep;i++ ) { sPlayerSkillStepInfo* pSkillStep = &pSkillInfo->mpSetpInfoArray[i]; if( pSkillStep->mPlayerLevel != 0 ) totalUsSP += pSkillStep->mRequireSP; } } } mpSkillUsePoint->SetValue( totalUsSP ); } } void cSkillWindow::UpdateCommuButtonPos() { if( mpCommuButton == 0 ) return; mpCommuButton->SetRelativePos( cUIPos( mCommuBtnBaseRect.mLeft + mCommuBtnBaseRect.GetWidth() * mJobTabCount, mCommuBtnBaseRect.mTop) ); } void cSkillWindow::RequestCommuSkill( unsigned long skillIndex ) { if( mpCommuSheetWindow ) mpCommuSheetWindow->RequestCommuSkill( skillIndex ); } void cSkillWindow::RequestLifeCommand( unsigned long comIdx, LPCTSTR value1, LPCSTR value2 ) { if( mpCommuSheetWindow ) mpCommuSheetWindow->RequestLifeCommand( comIdx, value1, value2 ); } void cSkillWindow::NetUnLockCommu() { if( mpCommuSheetWindow ) mpCommuSheetWindow->NetUnLock(); } void cSkillWindow::SetCurrent( unsigned int index ) { if( !mVisible ) return; cTabWindow::SetCurrent( index ); UpdateSkillUsePoint(); if( mpSkillStepListWindow ) { // ½ºÅ³ Á÷¾÷ °ü·Ã ÅÇ if( mpCommuSheetWindow != GetCurrentSheet() ) { if( index <= 0 ) { assert(0); return; } mpSkillStepListWindow->SetCurrentJobStep( (unsigned char)(index - 1) ); mpSkillStepListWindow->ResetSkillInfo(); if( mpVisibleStepWinCheckBtn && mpVisibleStepWinCheckBtn->IsPress() ) { SetRelativeSize( cUISize( mImageSize.mWidth+mpSkillStepListWindow->GetAbsoluteRect().GetWidth(), mRelativeRect.GetHeight())); mpSkillStepListWindow->Show(); } // »ç¿ë, ³²Àº SP ºÎºÐ À̹ÌÁö Show for( unsigned char i = 0; i < eSKILL_IMG_MAX; i++ ) { if( mpSkillPointImg[ i ] ) { mpSkillPointImg[ i ]->Show(); } } // ³²Àº SP if( mpSkillPoint ) mpSkillPoint->Show(); // »ç¿ë SP if( mpSkillUsePoint ) mpSkillUsePoint->Show(); } // Ä¿¹Â´ÏƼ ÅÇ else { if( mpSkillStepListWindow->IsVisible() ) { SetRelativeSize( mImageSize ); mpSkillStepListWindow->Hide(); } // »ç¿ë, ³²Àº SP ºÎºÐ À̹ÌÁö Hide for( unsigned char i = 0; i < eSKILL_IMG_MAX; i++ ) { if( mpSkillPointImg[ i ] ) { mpSkillPointImg[ i ]->Hide(); } } // ³²Àº SP if( mpSkillPoint ) mpSkillPoint->Hide(); // »ç¿ë SP if( mpSkillUsePoint ) mpSkillUsePoint->Hide(); } } } void cSkillWindow::BackupWindowPos() { cUIRect rt; mIsBackup = true; rt = GetAbsoluteRect(); mBackupPos.mX = rt.mLeft; mBackupPos.mY = rt.mTop; } void cSkillWindow::ApplyBackupPos() { if( mIsBackup == false ) return; /// SetRelativePos( mBackupPos ); mIsBackup = false; } void cSkillWindow::ShowSkillUpButton() { for( unsigned int i=0; iShowSkillUpButton(); } } void cSkillWindow::SetPressStepListView( bool bView ) { if( mpVisibleStepWinCheckBtn ) { mpVisibleStepWinCheckBtn->SetPress( bView ); } else { assert(0); } } bool cSkillWindow::IsShowStepListWin() { if( !mpVisibleStepWinCheckBtn ) { assert(0); return false; } return mpVisibleStepWinCheckBtn->IsPress(); } void cSkillWindow::OnNetLock( int lockTry ) { for( unsigned int i=0; iSetEnabled( false ); } if( mpVisibleStepWinCheckBtn ) mpVisibleStepWinCheckBtn->NetLock( lockTry ); } void cSkillWindow::OnNetUnLock( int lockTry ) { for( unsigned int i=0; iSetEnabled( true ); } if( mpVisibleStepWinCheckBtn ) mpVisibleStepWinCheckBtn->NetUnLock( lockTry ); } void cSkillWindow::StartCoolTime( unsigned long idx, unsigned long restTime, unsigned long totalTime ) { for( unsigned int i=0; iGetSkillIcon( idx ); if( icon == 0 ) continue; if( restTime == 0 || totalTime == 0 ) continue; icon->StartDelay( totalTime ); if( totalTime < restTime ) icon->SetElapsedTime( 0 ); else icon->SetElapsedTime( totalTime - restTime ); if( restTime == totalTime ) QUICKMAN->StartSkillCoolTime( idx, totalTime ); } if( mpSkillStepListWindow ) mpSkillStepListWindow->UpdateIConListInfo(); }