Files
2026-06-01 12:46:52 +02:00

235 lines
6.1 KiB
C++

#include "stdafx.h"
#include "SUIDevOutputWnd.h"
//#include "Util.h"
#include "KUIControlSkillCastGauge.h"
#include "KUIControlQJTV.h"
#include "KDeviceManager.h"
#include "KRenderDevice.h"
#include "KUITextureManager.h"
#include <kfile/KFileManager.h>
#include "QJTVObj.h"
#include <mmo/ArTime.h>
extern int g_DP_Count[3];
extern int g_Poly_Count;
extern int g_TexMem;
extern int g_TexRef;
extern int g_TerrainSegments;
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
void SUIDevOutputWnd::SetFPS( DWORD dwFPS, DWORD dwFree, DWORD dwTotal )
{
// if( !IsShow() ) return;
KUIWnd* pStaticFPS = GetChild( "staticFPS" );
if( NULL != pStaticFPS ) pStaticFPS->SetCaption( CStringUtil::StringFormat( "%03d FPS : [F:%d KB] [T:%d MB]", dwFPS, dwFree/(1024), dwTotal/(1024*1024) ).c_str() );
}
void SUIDevOutputWnd::SetPosition( float fX, float fY, float fZ, float fcx, float fcy, float fcz )
{
if( !IsShow() ) return;
KUIWnd* pStaticPosition = GetChild( "staticPosition" );
if( NULL != pStaticPosition )
pStaticPosition->SetCaption(
CStringUtil::StringFormat( "DP[%d %d %d], Pos[%6.2f, %6.2f, %6.2f] ---- [%6.2f, %6.2f, %6.2f], Polygon[%d], TexMem[%0.2fM], TexRef[%d], TerrainSegments[%d]",
g_DP_Count[0], g_DP_Count[1]-g_DP_Count[0], g_DP_Count[2],
fX, fY, fZ, fcx, fcy, fcz,
g_Poly_Count,
g_TexMem / 1048576.0f, g_TexRef,
g_TerrainSegments
).c_str()
);
}
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
SUITestWnd::SUITestWnd( SGameManager* pGameManager ) : SUIWnd( pGameManager )
{
m_pQJTVObj = NULL;
m_bInitAni = false;
m_dwRefreshTime = 0;
m_nCurFrame = 0;
}
SUITestWnd::~SUITestWnd()
{
SAFE_DELETE( m_pQJTVObj );
}
void SUITestWnd::initRace()
{
KStream * pResTml = KFileManager::Instance().CreateStreamFromResource( "QJTV.tml" );
if( pResTml && pResTml->IsValid() )
{
pResTml->Seek( 0, KStream::seekSet );
m_meta.importTML( *pResTml );
}
KFileManager::Instance().DeleteStream( pResTml );
KStream * pResLogo00 = KFileManager::Instance().CreateStreamFromResource( "select_deva.jtv" );
if( !pResLogo00 || !pResLogo00->IsValid() )
return;
SAFE_DELETE( m_pQJTVObj );
//pResLogo는 m_pQJTVObj에서 삭제 된다.
m_pQJTVObj = new QJTVObj;
m_pQJTVObj->Load( &m_meta, pResLogo00 );
BYTE* pBuf(NULL);
int nW, nH;
m_pQJTVObj->GetFrame( 0, pBuf, nW, nH );
m_bInitAni = false;
m_dwRefreshTime = 0;
m_nCurFrame = 0;
if( !m_spLogoTexture )
{
KUIControlQJTV* pControlQJTV = dynamicCast<KUIControlQJTV*>(GetChild("race_ani"));
int nExpX, nExpY;
K3DRenderDevice::GetSquareSize( nW, nH, nExpX, nExpY );
if( KUITextureManager::GetHWType() == KUITextureManager::HW_SUPPORT )
{
m_spLogoTexture = KDeviceManager::GetDeviceManager()->GetRenderDevice()->CreateTexture( nExpX, nExpY, KUSAGE_DYNAMIC, K3DFMT_A8R8G8B8, D3DPOOL_DEFAULT );
}
else
{
//Intel Chip 계열에서 지원 안 되는 넘들이 있음.
m_spLogoTexture = KDeviceManager::GetDeviceManager()->GetRenderDevice()->CreateTexture( nExpX, nExpY, K3DFMT_A8R8G8B8, D3DPOOL_MANAGED );
}
if( pControlQJTV ) pControlQJTV->SetRenderTarget( m_spLogoTexture, nW, nH );
}
}
bool SUITestWnd::CreateControls( class KUIWndManager* pWndManager )
{
KRect topRect, btnRect;
topRect.left = m_rcRegion.left+10;
topRect.right = m_rcRegion.left+646;
topRect.top = m_rcRegion.top+0;
topRect.bottom = m_rcRegion.top+256;
btnRect.left = m_rcRegion.left+0;
btnRect.right = m_rcRegion.left+20;
btnRect.top = m_rcRegion.top+120;
btnRect.bottom = m_rcRegion.top+140;
KUIWND_CREATE_ARG arg;
arg.lpszAniName = "button_lobby_character_select01";
arg.lpszSprName = m_sSprName.c_str();
arg.lpszClassName = "effect_gauge";
arg.lpszID = "effect_test";
arg.dwFlag = 0;
arg.dwStyle = 0;
arg.rcRect = topRect;
arg.pParent = this;
KUIControlEffectGauge* pWnd = (KUIControlEffectGauge*)pWndManager->CreateControl(arg);
//topRect.right = topRect.left+620;
//topRect.bottom = topRect.top+230;
////JTV
//arg.lpszAniName = "";
//arg.lpszSprName = m_sSprName.c_str();
//arg.lpszClassName = "qjtv_static";
//arg.lpszID = "race_ani";
//arg.dwFlag = 0;
//arg.dwStyle = 0;
//arg.rcRect = topRect;
//arg.pParent = this;
//pWndManager->CreateControl(arg);
//테스트 버튼 추가
arg.lpszAniName = "button_skill_jlvup";
arg.lpszSprName = m_sSprName.c_str();
arg.lpszClassName = "simplebutton";
arg.lpszID = "testbtn";
arg.dwStyle = 0;
arg.rcRect = btnRect;
arg.pParent = this;
arg.dwFlag = 0;
pWndManager->CreateControl(arg);
initRace();
return true;
}
void SUITestWnd::PumpUpMessage( LPCSTR lpszControlID, DWORD nMessage, DWORD lparam, DWORD wparam )
{
switch(nMessage)
{
case KUI_MESSAGE::KBUTTON_CLICK:
{
if( ::_stricmp( "testbtn", lpszControlID ) == 0 )
{
KUIControlEffectGauge* pControl = dynamicCast<KUIControlEffectGauge*>(GetChild("effect_test"));
if( pControl )
pControl->SetWorkingTime( 1700 );
}
}
break;
case KUI_MESSAGE::KEFFECTGAUGE_CLICK:
{
if( ::_stricmp( "effect_test", lpszControlID ) == 0 )
{
KUIControlEffectGauge* pControl = dynamicCast<KUIControlEffectGauge*>(GetChild("effect_test"));
if( pControl )
pControl->SetWorkingTime( 100+rand()%1000 );
}
}
break;
}
}
extern bool _refreshTexture( K3DTexture* pTexture, BYTE* pBit, int nW, int nH );
void SUITestWnd::Process(DWORD dwTime)
{
int fixFps = 24;
float msFps = 1000.f / fixFps;
SUIWnd::Process( dwTime );
if ( (dwTime - m_dwRefreshTime) < msFps )
return;
static bool bFlag = false;
m_dwRefreshTime = dwTime;
if( m_pQJTVObj && m_spLogoTexture )
{
BYTE* pBit(NULL);
int nW, nH;
nW = nH = 0;
m_pQJTVObj->GetFrame( m_nCurFrame, pBit, nW, nH );
m_nCurFrame++;
if( m_nCurFrame >= m_pQJTVObj->GetFrameCount() )
{
m_nCurFrame = 0;
}
K3DTexture* pTexture = (K3DTexture*)m_spLogoTexture;
m_bInitAni = _refreshTexture( pTexture, pBit, nW, nH );
}
}