399 lines
13 KiB
C++
399 lines
13 KiB
C++
#include "stdafx.h"
|
|
#include "SUITargetWnd_Prop.h"
|
|
|
|
#include "SLog.h"
|
|
#include "Util.h"
|
|
#include "CommonUtil.h"
|
|
|
|
#include "SStringDB.h"
|
|
|
|
#include "KUIDefine.h"
|
|
|
|
#include "KUIControlGauge.h"
|
|
#include "KUIControlStatic.h"
|
|
|
|
#include "SGameManager.h"
|
|
#include "SPlayerInfoMgr.h"
|
|
#include "SGameAvatarEx.h"
|
|
|
|
#include "FieldPropResource.h"
|
|
|
|
namespace nsTargetUI_Prop
|
|
{
|
|
|
|
static const string PROP_PROPERTY_ICON_CONTROL_NAME( "prop_target_job" ); // 프랍 속성 아이콘 컨트롤 이름
|
|
|
|
static const string PROP_NAME_CONTROL_NAME( "prop_target_name_text_long" ); // PROP 이름 컨트롤 이름
|
|
static const string PROP_DESC_CONTROL_NAME( "prop_target_text_job_01" ); // PROP 설명 컨트롤 이름
|
|
static const string HP_GAUGE_CONTROL_NAME( "prop_target_hpbar" ); // HP 게이지 컨트롤 이름
|
|
static const string HP_GAUGE_VALUE_CONTROL_NAME( "prop_static_hp_value" ); // HP 게이지 수치 컨트롤 이름
|
|
|
|
static const string HP_GAUGE_GREEN_SPRITE_NAME( "common_gauge_titanium_player_hp100_middle" ); // HP 게이지 이미지 (녹색) 이름
|
|
static const string HP_GAUGE_RED_SPRITE_NAME( "common_gauge_titanium_monster_middle" ); // HP 게이지 이미지 (레드) 이름
|
|
|
|
static const WORD GAUGE_ANIMATION_FILLTIME( 1000 ); // 게이지 차는 애니메이션 시간
|
|
|
|
};
|
|
|
|
using namespace nsTargetUI_Prop;
|
|
|
|
//-----------------------------------------------------------------------------------------------------------------
|
|
// 생성자
|
|
//-----------------------------------------------------------------------------------------------------------------
|
|
SUITargetWnd_Prop::SUITargetWnd_Prop( SGameManager * pGameManager, SUIDisplayInfo* pDisplayInfo )
|
|
: SUIWnd( pGameManager )
|
|
, m_pDisplayInfo( pDisplayInfo )
|
|
, m_pPropertyIcon( NULL )
|
|
, m_pHpGauge( NULL )
|
|
, m_pHpGaugeValue( NULL )
|
|
, m_pPropName( NULL )
|
|
, m_pPropDesc( NULL )
|
|
, m_strPropNamePropertyTag( "" )
|
|
, m_strPropDescPropertyTag( "" )
|
|
, m_strHpGaugeValuePropertyTag( "" )
|
|
{
|
|
}
|
|
|
|
|
|
//-----------------------------------------------------------------------------------------------------------------
|
|
// 파괴자
|
|
//-----------------------------------------------------------------------------------------------------------------
|
|
SUITargetWnd_Prop::~SUITargetWnd_Prop()
|
|
{
|
|
}
|
|
|
|
|
|
//-----------------------------------------------------------------------------------------------------------------
|
|
// 윈도우 생성
|
|
//-----------------------------------------------------------------------------------------------------------------
|
|
SUIWnd* SUITargetWnd_Prop::CreateWnd( const char* szFile, KUIWndManager* pWndManager, KPoint kPos, int nWindowID )
|
|
{
|
|
SUIWnd::CreateWnd( szFile, pWndManager, kPos, nWindowID );
|
|
|
|
return this;
|
|
}
|
|
|
|
|
|
//-----------------------------------------------------------------------------------------------------------------
|
|
// 컨트롤 초기화
|
|
//-----------------------------------------------------------------------------------------------------------------
|
|
bool SUITargetWnd_Prop::InitControls( KPoint kPos )
|
|
{
|
|
return SUIWnd::InitControls( kPos );
|
|
}
|
|
|
|
|
|
//-----------------------------------------------------------------------------------------------------------------
|
|
// 데이터 초기화
|
|
// 설명 : 속성 아이콘, 설명 컨트롤은 존재는 하지만 추후를 위해서 제작해 놓은 것이다. 일단 숨긴다.
|
|
//-----------------------------------------------------------------------------------------------------------------
|
|
bool SUITargetWnd_Prop::InitData( bool bReload /*= false*/ )
|
|
{
|
|
// UI 팀과 합의 끝에 일단 적용하지 않기로 함
|
|
//m_pPropertyIcon = dynamicCast<KUIControlIconStatic*>( GetChild( PROP_PROPERTY_ICON_CONTROL_NAME.c_str() ) );
|
|
//if( NULL == m_pPropertyIcon )
|
|
//{
|
|
// SDEBUGLOG( "[타겟윈도우(PROP)] 컨트롤 정보 얻기 실패 - Name[%s]", PROP_PROPERTY_ICON_CONTROL_NAME.c_str() );
|
|
// assert( m_pPropertyIcon );
|
|
//}
|
|
//else
|
|
// m_pPropertyIcon->SetShow( false );
|
|
|
|
m_pHpGauge = dynamicCast<KUIControlGauge*>( GetChild( HP_GAUGE_CONTROL_NAME.c_str() ) );
|
|
if( NULL == m_pHpGauge )
|
|
{
|
|
SDEBUGLOG( "[타겟윈도우(PROP)] 컨트롤 정보 얻기 실패 - Name[%s]", HP_GAUGE_CONTROL_NAME.c_str() );
|
|
assert( m_pHpGauge );
|
|
}
|
|
|
|
m_pHpGaugeValue = dynamicCast<KUIControlStatic*>( GetChild( HP_GAUGE_VALUE_CONTROL_NAME.c_str() ) );
|
|
if( NULL == m_pHpGaugeValue )
|
|
{
|
|
SDEBUGLOG( "[타겟윈도우(PROP)] 컨트롤 정보 얻기 실패 - Name[%s]", HP_GAUGE_VALUE_CONTROL_NAME.c_str() );
|
|
assert( m_pHpGaugeValue );
|
|
}
|
|
else
|
|
{
|
|
string strCaption( m_pHpGaugeValue->GetCaption() );
|
|
GetTextDecoration( strCaption.c_str(), m_strHpGaugeValuePropertyTag );
|
|
|
|
m_pHpGaugeValue->SetShow( true );
|
|
}
|
|
|
|
m_pPropName = dynamicCast<KUIControlStatic*>( GetChild( PROP_NAME_CONTROL_NAME.c_str() ) );
|
|
if( NULL == m_pPropName )
|
|
{
|
|
SDEBUGLOG( "[타겟윈도우(PROP)] 컨트롤 정보 얻기 실패 - Name[%s]", PROP_NAME_CONTROL_NAME.c_str() );
|
|
assert( m_pPropName );
|
|
}
|
|
else
|
|
{
|
|
string strCaption( m_pPropName->GetCaption() );
|
|
GetTextDecoration( strCaption.c_str(), m_strPropNamePropertyTag );
|
|
}
|
|
|
|
m_pPropDesc = dynamicCast<KUIControlStatic*>( GetChild( PROP_DESC_CONTROL_NAME.c_str() ) );
|
|
if( NULL == m_pPropDesc )
|
|
{
|
|
SDEBUGLOG( "[타겟윈도우(PROP)] 컨트롤 정보 얻기 실패 - Name[%s]", PROP_DESC_CONTROL_NAME.c_str() );
|
|
assert( m_pPropDesc );
|
|
}
|
|
else
|
|
{
|
|
string strCaption( m_pPropDesc->GetCaption() );
|
|
GetTextDecoration( strCaption.c_str(), m_strPropDescPropertyTag );
|
|
m_pPropDesc->SetShow( false );
|
|
}
|
|
|
|
return SUIWnd::InitData(bReload);
|
|
}
|
|
|
|
|
|
//-----------------------------------------------------------------------------------------------------------------
|
|
// 메시지 처리
|
|
//-----------------------------------------------------------------------------------------------------------------
|
|
void SUITargetWnd_Prop::PumpUpMessage( LPCSTR lpszControlID, DWORD nMessage, DWORD lparam, DWORD wparam )
|
|
{
|
|
if( NULL == lpszControlID )
|
|
return;
|
|
|
|
string strControlID( lpszControlID );
|
|
|
|
switch( nMessage )
|
|
{
|
|
case KBUTTON_CLICK:
|
|
case KBUTTON_PRESSING:
|
|
{
|
|
if( NULL == strControlID.compare( "prop_target_off_01" ) ) // 닫기 버튼 클릭
|
|
{
|
|
m_pGameManager->PostMsgAtDynamic( new SIMSG_SHOW_UIWINDOW( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_TARGET_PROP, false ) );
|
|
|
|
// 타겟 해제, 게임 내에 NULL 타겟을 보낸다
|
|
SIMSG_UI_ACT_TARGET msg;
|
|
msg.m_nTargetHandle = NULL;
|
|
m_pGameManager->ProcMsgAtStatic(&msg);
|
|
}
|
|
}
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
SUIWnd::PumpUpMessage( lpszControlID, nMessage, lparam, wparam );
|
|
}
|
|
|
|
|
|
//-----------------------------------------------------------------------------------------------------------------
|
|
// 정적 메시지 처리 - UI 타겟 정보 ( HP 게이지 )
|
|
//-----------------------------------------------------------------------------------------------------------------
|
|
bool SUITargetWnd_Prop::ProcessMessage_UITargetInfo_Gauge( SIMSG_UI_TARGET_INFO_PROP* const pTargetMsg )
|
|
{
|
|
if( NULL == m_pDisplayInfo )
|
|
{
|
|
SDEBUGLOG( "[타겟윈도우(PROP)] 디스플레이 정보 포인터가 유효하지 않습니다." );
|
|
assert( m_pDisplayInfo );
|
|
return false;
|
|
}
|
|
|
|
BYTE byType( NULL );
|
|
bool bFriend( m_pDisplayInfo->IsFriend( pTargetMsg->handle, byType ) ? true : false );
|
|
|
|
int nMaxHP( max( pTargetMsg->nHP, pTargetMsg->nMaxHP ) );
|
|
int nCurrentHP( max( pTargetMsg->nHP, 0 ) );
|
|
|
|
if( m_pHpGaugeValue )
|
|
{
|
|
string strHpGaugeValue( m_strHpGaugeValuePropertyTag );
|
|
|
|
int nExp = 100, nRest = 0;
|
|
m_pDisplayInfo->GetPercentValue( nCurrentHP, nMaxHP, &nExp, &nRest );
|
|
strHpGaugeValue.append( StringFormat( "%d.%d", nExp, nRest ) );
|
|
strHpGaugeValue += "%";
|
|
|
|
#ifdef _DEV // HP TEXT 출력 부분 ( 개발 버젼에서만 보임 )
|
|
strHpGaugeValue.append( StringFormat( "[DEV]%u/%u", nCurrentHP, nMaxHP ) );
|
|
#endif
|
|
|
|
m_pHpGaugeValue->SetCaption( strHpGaugeValue.c_str() );
|
|
}
|
|
|
|
if( m_pHpGauge )
|
|
RefreshGauge( m_pHpGauge, nCurrentHP, nMaxHP, false, bFriend );
|
|
|
|
return true;
|
|
}
|
|
|
|
|
|
//-----------------------------------------------------------------------------------------------------------------
|
|
// 정적 메시지 처리 - UI 타겟 정보
|
|
//-----------------------------------------------------------------------------------------------------------------
|
|
bool SUITargetWnd_Prop::ProcessMessage_UITargetInfo( SIMSG_UI_TARGET_INFO_PROP* const pTargetMsg )
|
|
{
|
|
if( NULL == pTargetMsg )
|
|
{
|
|
SDEBUGLOG( "[타겟윈도우(PROP)] Msg 포인터가 유효하지 않습니다." );
|
|
assert( pTargetMsg );
|
|
return false;
|
|
}
|
|
|
|
if( NULL == pTargetMsg->handle )
|
|
{
|
|
SDEBUGLOG( "[타겟윈도우(PROP)] Msg 핸들 정보가 유효하지 않습니다." );
|
|
assert( pTargetMsg->handle );
|
|
return false;
|
|
}
|
|
|
|
if( m_pPropName )
|
|
{
|
|
string strPropName( m_strPropNamePropertyTag );
|
|
string strTempName( pTargetMsg->strName );
|
|
|
|
if( NULL == strTempName.length() )
|
|
strPropName.append( "Unknown Name" );
|
|
else
|
|
strPropName.append( strTempName );
|
|
|
|
m_pPropName->SetCaption( strPropName.c_str() );
|
|
}
|
|
|
|
ProcessMessage_UITargetInfo_Gauge( pTargetMsg );
|
|
|
|
return true;
|
|
}
|
|
|
|
|
|
//-----------------------------------------------------------------------------------------------------------------
|
|
// 정적 메시지 처리 - UI 타겟 스텟 ( HP, MP 게이지 )
|
|
//-----------------------------------------------------------------------------------------------------------------
|
|
bool SUITargetWnd_Prop::ProcessMessage_UITargetStat_Gauge( SIMSG_UI_TARGET_STAT* const pStatMsg )
|
|
{
|
|
if( NULL == m_pDisplayInfo )
|
|
{
|
|
SDEBUGLOG( "[타겟윈도우(PROP)] 디스플레이 정보 포인터가 유효하지 않습니다." );
|
|
assert( m_pDisplayInfo );
|
|
return false;
|
|
}
|
|
|
|
BYTE byType( NULL );
|
|
bool bFriend( m_pDisplayInfo->IsFriend( pStatMsg->handle, byType ) ? true : false );
|
|
|
|
int nMaxHP( max( pStatMsg->m_nVar1, pStatMsg->m_nVar3 ) );
|
|
int nCurrentHP( max( pStatMsg->m_nVar1, 0LL ) );
|
|
|
|
if( m_pHpGaugeValue )
|
|
{
|
|
string strHpGaugeValue( m_strHpGaugeValuePropertyTag );
|
|
|
|
int nExp = 100, nRest = 0;
|
|
m_pDisplayInfo->GetPercentValue( nCurrentHP, nMaxHP, &nExp, &nRest );
|
|
strHpGaugeValue.append( StringFormat( "%d.%d", nExp, nRest ) );
|
|
strHpGaugeValue += "%";
|
|
|
|
#ifdef _DEV // HP TEXT 출력 부분 ( 개발 버젼에서만 보임 )
|
|
strHpGaugeValue.append( StringFormat( "[DEV]%u/%u", nCurrentHP, nMaxHP ) );
|
|
#endif
|
|
|
|
m_pHpGaugeValue->SetCaption( strHpGaugeValue.c_str() );
|
|
}
|
|
|
|
if( m_pHpGauge )
|
|
RefreshGauge( m_pHpGauge, nCurrentHP, nMaxHP, true, bFriend );
|
|
|
|
return true;
|
|
}
|
|
|
|
|
|
//-----------------------------------------------------------------------------------------------------------------
|
|
// 정적 메시지 처리 - UI 타겟 스텟
|
|
//-----------------------------------------------------------------------------------------------------------------
|
|
bool SUITargetWnd_Prop::ProcessMessage_UITargetStat( SIMSG_UI_TARGET_STAT* const pStatMsg )
|
|
{
|
|
if( false == IsShow() )
|
|
return false;
|
|
|
|
if( NULL == pStatMsg )
|
|
{
|
|
SDEBUGLOG( "[타겟윈도우(PLAYER)] Msg 포인터가 유효하지 않습니다." );
|
|
assert( pStatMsg );
|
|
return false;
|
|
}
|
|
|
|
if( NULL == pStatMsg->handle )
|
|
{
|
|
SDEBUGLOG( "[타겟윈도우(PLAYER)] Msg 핸들 정보가 유효하지 않습니다." );
|
|
assert( pStatMsg->handle );
|
|
return false;
|
|
}
|
|
|
|
if( pStatMsg->handle != m_PlayerInfoMgr.GetTarget() )
|
|
return false;
|
|
|
|
ProcessMessage_UITargetStat_Gauge( pStatMsg );
|
|
|
|
return true;
|
|
}
|
|
|
|
|
|
//-----------------------------------------------------------------------------------------------------------------
|
|
// 정적 메시지 처리 - 게이지 갱신
|
|
//-----------------------------------------------------------------------------------------------------------------
|
|
void SUITargetWnd_Prop::RefreshGauge( KUIControlGauge* pGaugeControl, const int nCurrent, const int nMax, const bool bAnimation, const bool bFriend )
|
|
{
|
|
if( NULL == pGaugeControl )
|
|
{
|
|
SDEBUGLOG( "[타겟윈도우(PROP)] 게이지 컨트롤 포인터가 유효하지 않습니다." );
|
|
assert( pGaugeControl );
|
|
return;
|
|
}
|
|
|
|
WORD wGaugeFillTime( NULL );
|
|
|
|
if( bAnimation )
|
|
wGaugeFillTime = GAUGE_ANIMATION_FILLTIME;
|
|
|
|
BYTE byPercent( NULL );
|
|
|
|
if( nMax > 0 )
|
|
byPercent = ( static_cast<float>( nCurrent ) / static_cast<float>( nMax ) ) * 100;
|
|
|
|
pGaugeControl->SetMax( static_cast<DWORD>(nMax) );
|
|
|
|
if( HP_GAUGE_CONTROL_NAME.compare( pGaugeControl->GetID() ) == NULL )
|
|
{
|
|
if( bFriend )
|
|
setHPGaugeTexture( byPercent, pGaugeControl, 11 );
|
|
else
|
|
pGaugeControl->SetBack( c_szDEF_SPR_NAME, HP_GAUGE_RED_SPRITE_NAME.c_str() );
|
|
}
|
|
|
|
pGaugeControl->SetGauge( static_cast<DWORD>(nCurrent), wGaugeFillTime );
|
|
}
|
|
|
|
|
|
//-----------------------------------------------------------------------------------------------------------------
|
|
// 정적 메시지 처리
|
|
//-----------------------------------------------------------------------------------------------------------------
|
|
void SUITargetWnd_Prop::ProcMsgAtStatic( SGameMessage* pMsg )
|
|
{
|
|
if( NULL == pMsg )
|
|
return;
|
|
|
|
switch( pMsg->nType )
|
|
{
|
|
case IMSG_UI_TARGET_INFO:
|
|
{
|
|
SIMSG_UI_TARGET_INFO_PROP* pTargetMsg = static_cast<SIMSG_UI_TARGET_INFO_PROP*>( pMsg );
|
|
ProcessMessage_UITargetInfo( pTargetMsg );
|
|
}
|
|
break;
|
|
case IMSG_UI_TARGET_STAT:
|
|
{
|
|
SIMSG_UI_TARGET_STAT* pStatMsg = static_cast<SIMSG_UI_TARGET_STAT*>( pMsg );
|
|
ProcessMessage_UITargetStat( pStatMsg );
|
|
}
|
|
break;
|
|
}
|
|
|
|
pMsg->bUse = true;
|
|
}
|