📄 quickstylemanager.cpp
字号:
#include "StdAfx.h"
#include ".\QuickStyleManager.h"
#include ".\SlotManager.h"
#include ".\SCQuickStyleSlot.h"
#include ".\SCQuickStyleSlotContainer.h"
#include "StyleQuickRegistInfoParser.h"
#include "SCSkillSlot.h"
#include "Player.h"
#include "SCSkillSlotContainer.h"
QuickStyleManager::QuickStyleManager(void)
{
}
QuickStyleManager::~QuickStyleManager(void)
{
}
VOID QuickStyleManager::Release()
{
}
VOID QuickStyleManager::Init( SlotManager * pMGR )
{
m_pPlayer = pMGR->m_pPlayer;
m_ppSlotContainer = pMGR->m_pSlotContainer;
m_pSlotMGR = pMGR;
}
BOOL QuickStyleManager::IsEmpty( POSTYPE pos )
{
return m_pSlotMGR->IsEmpty( SI_STYLE, pos );
}
SCQuickStyleSlotContainer * QuickStyleManager::GetQuickStyleSlotContainer()
{
return (SCQuickStyleSlotContainer *)m_pSlotMGR->GetSlotContainer(SI_STYLE);
}
BOOL QuickStyleManager::ValidPos( SLOTIDX atIndex, POSTYPE atPos, BOOL bEmptyCheck )
{
return m_pSlotMGR->ValidPos(atIndex, atPos, bEmptyCheck);
}
BOOL QuickStyleManager::ValidState()
{
return m_pSlotMGR->ValidState();
}
VOID QuickStyleManager::SerializeStyleStream( POSTYPE pos, STYLESTREAM * IN pStream, eSERIALIZE eType )
{
if( eType == SERIALIZE_LOAD )
{
SCQuickStyleSlot & rSlot = static_cast<SCQuickStyleSlot &>(GetQuickStyleSlotContainer()->GetSlot(pos));
rSlot.CopyOut(*pStream);
}
else if( eType == SERIALIZE_STORE )
((SCQuickStyleSlotContainer*)GetQuickStyleSlotContainer())->InsertSlot( pos, *pStream );
}
RC::eSTYLE_RESULT QuickStyleManager::Link( SLOTCODE code, POSTYPE toPos )
{
if( !ValidState() )
return RC::RC_STYLE_INVALIDSTATE;
if( !ValidPos( SI_STYLE, toPos, FALSE ) )
return RC::RC_STYLE_INVALIDPOS;
SCSlotContainer * pContainer = GetQuickStyleSlotContainer();
if( !pContainer->IsEmpty(toPos) )
return RC::RC_STYLE_INVALIDPOS;
// 绢恫 巴阑 棵副 荐 乐绰瘤俊 措茄 眉农 鞘夸!
SCQuickStyleSlot slot;
slot.SetOrgCode(code);
pContainer->InsertSlot(toPos, slot);
return RC::RC_STYLE_SUCCESS;
}
RC::eSTYLE_RESULT QuickStyleManager::Unlink( POSTYPE atPos )
{
if( !ValidState() )
return RC::RC_STYLE_INVALIDSTATE;
if( !ValidPos( SI_STYLE, atPos ) )
return RC::RC_STYLE_INVALIDPOS;
SCSlotContainer * pContainer = GetQuickStyleSlotContainer();
pContainer->DeleteSlot( atPos, NULL );
return RC::RC_STYLE_SUCCESS;
}
RC::eSTYLE_RESULT QuickStyleManager::Move( POSTYPE fromPos, POSTYPE toPos )
{
if( !ValidState() )
return RC::RC_STYLE_INVALIDSTATE;
if( !ValidPos( SI_STYLE, fromPos ) )
return RC::RC_STYLE_INVALIDPOS;
if( !ValidPos( SI_STYLE, toPos, FALSE ) )
return RC::RC_STYLE_INVALIDPOS;
SCSlotContainer *pContainer = GetQuickStyleSlotContainer();
SCQuickStyleSlot FromSlot;
pContainer->DeleteSlot( fromPos, &FromSlot );
if( TRUE == pContainer->IsEmpty( toPos ) )
{
// 茄 规氢 捞悼
if( !pContainer->InsertSlot( toPos, FromSlot ) )
{
pContainer->InsertSlot( fromPos, FromSlot );
return RC::RC_STYLE_UNKNOWNERROR;
}
}
else
{
// 背券
SCQuickStyleSlot ToSlot;
pContainer->DeleteSlot( toPos, &ToSlot );
if( !pContainer->InsertSlot( fromPos, ToSlot ) )
{
//rollback
pContainer->InsertSlot( fromPos, FromSlot );
pContainer->InsertSlot( toPos, ToSlot );
return RC::RC_STYLE_UNKNOWNERROR;
}
if( !pContainer->InsertSlot( toPos, FromSlot ) )
{
//rollback
pContainer->DeleteSlot( fromPos, NULL );
pContainer->InsertSlot( fromPos, FromSlot );
pContainer->InsertSlot( toPos, ToSlot );
return RC::RC_STYLE_UNKNOWNERROR;
}
}
return RC::RC_STYLE_SUCCESS;
}
class QuickStyleUpdate
{
QuickStyleManager* m_pStyleManager;
BASE_StyleQuickRegistInfo* m_pStyleQuickInfo;
public:
QuickStyleUpdate( QuickStyleManager *pStyleManager, BASE_StyleQuickRegistInfo *pStyleQuickInfo ) :
m_pStyleManager(pStyleManager), m_pStyleQuickInfo(pStyleQuickInfo) {}
VOID operator () ( SCSlot* pSlot )
{
SCSkillSlot *pSkillSlot = (SCSkillSlot*)pSlot;
if( pSkillSlot->IsSKill() ) return;
BASE_STYLEINFO *pBaseStyleInfo = pSkillSlot->GetStyleInfo();
for( BYTE i = 0; i < MAX_STYLE_REGIST_COUNT; i++ )
{
if( m_pStyleQuickInfo->m_wStyleClassCode[i] != pBaseStyleInfo->m_SkillClassCode ) continue;
// 胶鸥老阑 狞 胶鸥老 浇吩俊 殿废茄促.
RC::eSTYLE_RESULT rt = m_pStyleManager->Link( pSkillSlot->GetCode(), i );
break;
}
}
};
VOID QuickStyleManager::UpdateStyleSlot()
{
BASE_StyleQuickRegistInfo *pStyleQuickInfo = StyleQuickRegistInfoParser::Instance()->GetStyleQuickRegistInfo( m_pPlayer->GetCharType(), m_pPlayer->GetWeaponKind() );
SCSkillSlotContainer *pSkillSlotContainer = (SCSkillSlotContainer *)m_pSlotMGR->GetSlotContainer(SI_SKILL);
// 胶鸥老 狞 檬扁拳
GetQuickStyleSlotContainer()->ClearAll();
// 嚼垫茄 胶鸥老甸 吝俊辑 pStyleQuickInfo俊 沥焊啊 乐绰 巴父 殿废
if( pStyleQuickInfo )
{
QuickStyleUpdate Opr( this, pStyleQuickInfo );
pSkillSlotContainer->ForEachSlot( Opr );
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -