275 lines
7.5 KiB
C++
275 lines
7.5 KiB
C++
#include "stdafx.h"
|
|
|
|
#include <mmo/ArType.h>
|
|
#include "SUIDefine.h"
|
|
#include "SGameManager.h"
|
|
#include "SGameSystem.h"
|
|
//#include "SGameMessageUI.h"
|
|
#include "SNetMessage.h"
|
|
#include "SGameMessage.h"
|
|
#include "ErrorCode/ErrorCode.h"
|
|
|
|
#include "KUIWndManager.h"
|
|
|
|
#include "SUIDisplayInfo.h"
|
|
#include "KUITabControl.h"
|
|
#include "KUIControlStatic.h"
|
|
#include "KUIControlButton.h"
|
|
|
|
#include "SPetDB.h"
|
|
#include "SStringDB.h"
|
|
#include "SSkillDB.h"
|
|
|
|
#include "SPetMgr.h"
|
|
#include "SPetSkillMgr.h"
|
|
|
|
#include "SUIPetCommandWnd.h"
|
|
#include "SGameLocalPet.h"
|
|
|
|
|
|
namespace petcmd {
|
|
|
|
namespace ctrl {
|
|
|
|
const char* PetIcon = "creature_faceicon";
|
|
const char* PetGradeIcon = "static_grade_00";
|
|
const char* PetName = "creature_customname_text";
|
|
const char* PetType = "creature_name_text";
|
|
const char* SelectBack = "creature02_selectbar_back";
|
|
const char* SelectBar = "creature02_selectbar";
|
|
const char* SelectIcon = "creature02_skillicon_select";
|
|
const char* SkillIcon = "creature02_skillicon%.2d";
|
|
const char* SkillEffect = "creature02_skillicon_effect%.2d";
|
|
const char* SkillName = "creature02_skillname_text%.2d";
|
|
const char* Close = "button_add";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
using namespace petcmd;
|
|
|
|
extern SGameSystem* g_pCurrentGameSystem;
|
|
|
|
void SUIPetCommandWnd::SSkillSlotImporter::operator () ( SSkillSlot* slot )
|
|
{
|
|
sui::proxy_list::item_t* ListItem = new sui::proxy_list::item_t();
|
|
|
|
ListItem->add( &( new sui::property( "skill_icon" ) )->set_value( slot ) );
|
|
|
|
SPetMgr* petMgr = static_cast< SPetMgr* >( GameUIMgrInstance.GetUIMgr( SGameUIInstance::PET_MGR ) );
|
|
if( petMgr && petMgr->GetSummonPetData().pet_avatar )
|
|
{
|
|
const DATA_PET& petData = petMgr->GetSummonPetData();
|
|
SGameLocalPet* petAvatar = static_cast< SGameLocalPet* >( petData.pet_avatar );
|
|
ListItem->add( &( new sui::property( "skill_effect" ) )->set_value< unsigned int >( petAvatar->IsAutoPickItemMode() ? QUICK_SKILL::STATE_TOGGLE_ON : QUICK_SKILL::STATE_TOGGLE_OFF ) );
|
|
}
|
|
else
|
|
{
|
|
ListItem->add( &( new sui::property( "skill_effect" ) )->set_value< unsigned int >( QUICK_SKILL::STATE_NONE ) );
|
|
}
|
|
|
|
SkillBaseEx* SkillData = GetSkillDB().GetSkillData( slot->GetSkillID() );
|
|
if( SkillData )
|
|
ListItem->add( &( new sui::property( "skill_name" ) )->set_value( GetStringDB().GetString( SkillData->GetNameID() ) ) );
|
|
|
|
mSkillList.add( ListItem );
|
|
}
|
|
|
|
SUIPetCommandWnd::SUIPetCommandWnd( SGameManager* pGameManager, SUIDisplayInfo* pDisplayInfo )
|
|
: SUIWnd ( pGameManager )
|
|
, m_pDisplayInfo( pDisplayInfo )
|
|
, m_SkillList ( this, "skill_list", 1 )
|
|
, m_nPetID ( 0 )
|
|
{
|
|
}
|
|
|
|
SUIPetCommandWnd::~SUIPetCommandWnd()
|
|
{
|
|
}
|
|
|
|
void SUIPetCommandWnd::Process( DWORD time )
|
|
{
|
|
SUIWnd::Process( time );
|
|
}
|
|
|
|
bool SUIPetCommandWnd::InitControls( KPoint pos )
|
|
{
|
|
SetCustomMovingRect( KRect( 0, 0, 220, 20 ) );
|
|
|
|
m_InfoSlot.add( sui::MakeUpdatableWindow( "icon" , sui::SItemSlotIconUpdator( m_pDisplayInfo, this, m_InventoryMgr ) , GetChild( ctrl::PetIcon ) ) );
|
|
m_InfoSlot.add( sui::MakeUpdatableWindow( "grade" , sui::SPetGradeIconUpdator() , GetChild( ctrl::PetGradeIcon ) ) );
|
|
m_InfoSlot.add( sui::MakeUpdatableWindow( "name" , sui::SCaptionUpdator( "<size:12><vcenter><left>%s" ) , GetChild( ctrl::PetName ) ) );
|
|
m_InfoSlot.add( sui::MakeUpdatableWindow( "type" , sui::SCaptionUpdator( "<#fec530><size:10><vcenter>%s" ) , GetChild( ctrl::PetType ) ) );
|
|
|
|
m_SkillList.initialize( ctrl::SelectBack, ctrl::SelectBar );
|
|
m_SkillList.add_column( ctrl::SkillIcon, sui::MakeUpdator( "skill_icon" , sui::SSkillSlotIconUpdator( m_pDisplayInfo ) ) );
|
|
m_SkillList.add_column( ctrl::SkillEffect, sui::MakeUpdator( "skill_effect", sui::SSkillSlotFxUpdator() ) );
|
|
m_SkillList.add_column( ctrl::SkillName, sui::MakeUpdator( "skill_name" , sui::SCaptionUpdator( "<size:10><#fde7ad><left>%s" ) ) );
|
|
|
|
return SUIWnd::InitControls( pos );
|
|
}
|
|
|
|
bool SUIPetCommandWnd::InitData( bool reload )
|
|
{
|
|
return SUIWnd::InitData( reload );
|
|
}
|
|
|
|
void* SUIPetCommandWnd::Perform( KID id, KArg& msg )
|
|
{
|
|
return SUIWnd::Perform( id, msg );
|
|
}
|
|
|
|
void SUIPetCommandWnd::PumpUpMessage( LPCTSTR controlID, DWORD msg, DWORD lparam, DWORD wparam )
|
|
{
|
|
m_SkillList.proc_pumpup( controlID, msg, lparam, wparam );
|
|
|
|
switch( msg )
|
|
{
|
|
case KUI_MESSAGE::KBUTTON_CLICK:
|
|
{
|
|
if( ::_stricmp( controlID, "button_close" ) == 0 || ::_stricmp( controlID, "button_add" ) == 0 )
|
|
m_pGameManager->PostMsgAtDynamic( new SIMSG_SHOW_UIWINDOW( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_PET_COMMAND, false) );
|
|
}
|
|
break;
|
|
case KUI_MESSAGE::KICON_CLICK:
|
|
case KUI_MESSAGE::KICON_RCLICK:
|
|
{
|
|
for( int i = 0; i < m_SkillList.size(); ++i )
|
|
{
|
|
if( ::_stricmp( controlID, sui::helper::indexed_id( ctrl::SkillIcon, i ).c_str() ) == 0 )
|
|
{
|
|
_UseSkill( i );
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
case KUI_MESSAGE::KGENWND_MOVE:
|
|
{
|
|
LimitMoveWnd();
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
|
|
void SUIPetCommandWnd::ProcMsgAtStatic( SGameMessage* msg )
|
|
{
|
|
switch( msg->nType )
|
|
{
|
|
case MSG_SKILL_LIST:
|
|
{
|
|
_UpdatePet( m_PetMgr.GetSummonPetData().code );
|
|
}
|
|
break;
|
|
/// 2011.10.24 - prodongi
|
|
case IMSG_UI_SEND_DATA:
|
|
{
|
|
msg->bUse = true;
|
|
SIMSG_UI_SEND_DATA* data = dynamicCast<SIMSG_UI_SEND_DATA*>(msg);
|
|
if (!data)
|
|
return ;
|
|
|
|
if ("useAutoPickSkill" == data->m_strString)
|
|
{
|
|
_UseSkill(0);
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
|
|
void SUIPetCommandWnd::OnNotifyUIWindowOpen( bool open, bool limitWnd )
|
|
{
|
|
if( open )
|
|
{
|
|
if( m_PetMgr.GetSummonPetData().pet_handle == 0 )
|
|
m_pGameManager->ProcMsgAtStatic( &SIMSG_SHOW_UIWINDOW( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_PET_COMMAND, false ) );
|
|
else
|
|
m_pGameManager->StartSound( "ui_popup_window01.wav" );
|
|
}
|
|
}
|
|
|
|
DWORD SUIPetCommandWnd::OnMouseMessage( DWORD msg, int x, int y )
|
|
{
|
|
DWORD ret = SUIWnd::OnMouseMessage( msg, x, y );
|
|
if( KMR_NO_GET & ret )
|
|
return ret;
|
|
|
|
m_SkillList.proc_mouse( msg, x, y );
|
|
|
|
return ret;
|
|
}
|
|
|
|
void SUIPetCommandWnd::_UpdatePet( int petID )
|
|
{
|
|
m_nPetID = petID;
|
|
|
|
_UpdateInfoSlot();
|
|
_UpdateSkillList();
|
|
}
|
|
|
|
void SUIPetCommandWnd::_UpdateInfoSlot()
|
|
{
|
|
if( m_InfoSlot.empty() )
|
|
return;
|
|
|
|
const DATA_PET& data = m_PetMgr.GetSummonPetData();
|
|
SPetInfoEx dbInfo = GetPetDB().Find( m_nPetID );
|
|
|
|
m_InfoSlot[ "icon" ].set_data( data.cage_handle );
|
|
m_InfoSlot[ "grade" ].set_data( (char)dbInfo.getAttributeFlag() );
|
|
m_InfoSlot[ "name" ].set_data( data.name );
|
|
m_InfoSlot[ "type" ].set_data( GetStringDB().GetString( dbInfo.getNameID() ) );
|
|
|
|
m_InfoSlot.update();
|
|
}
|
|
|
|
void SUIPetCommandWnd::_UpdateSkillList()
|
|
{
|
|
const SKILL_VECTOR& SkillSlotList = m_PetSkillMgr.GetSkillList();
|
|
|
|
m_SkillList.clear();
|
|
|
|
std::for_each( SkillSlotList.begin(), SkillSlotList.end(), SSkillSlotImporter( m_SkillList ) );
|
|
|
|
m_SkillList.update_data();
|
|
}
|
|
|
|
void SUIPetCommandWnd::_UseSkill( int slotIndex )
|
|
{
|
|
//
|
|
// sonador
|
|
// 현재 아이템 줍기 스킬만 구현된 상태이기 때문에 다음처럼 우선 구현한다.
|
|
//
|
|
|
|
int skillIndex = m_SkillList.get_offset() + slotIndex;
|
|
|
|
const DATA_PET& data = m_PetMgr.GetSummonPetData();
|
|
|
|
if( !data.pet_handle || !data.pet_avatar )
|
|
return;
|
|
|
|
if (m_PetSkillMgr.GetSkillList().empty())
|
|
return ;
|
|
SSkillSlot* skillSlot = m_PetSkillMgr.GetSkillList().at( skillIndex );
|
|
|
|
if( !skillSlot )
|
|
return;
|
|
|
|
SkillBaseEx* skillData = GetSkillDB().GetSkillData( skillSlot->GetSkillID() );
|
|
|
|
if( !skillData )
|
|
return;
|
|
|
|
float pickupRange = skillData->var[ 0 ];
|
|
|
|
SGameLocalPet* localPetAvatar = static_cast< SGameLocalPet* >( data.pet_avatar );
|
|
|
|
localPetAvatar->SetAutoPickItemMode( !localPetAvatar->IsAutoPickItemMode() );
|
|
localPetAvatar->SetAutoPickItemDistanceByMeter( pickupRange );
|
|
|
|
( *m_SkillList[ slotIndex ] )[ "skill_effect" ].set_value< unsigned int >( localPetAvatar->IsAutoPickItemMode() ? QUICK_SKILL::STATE_TOGGLE_ON : QUICK_SKILL::STATE_TOGGLE_OFF );
|
|
|
|
m_SkillList.update_data();
|
|
} |