#include "stdafx.h" #include "KUIControlQJTV.h" #include "KDeviceManager.h" #include "KResource.h" #include "KPrimitiveSprite.h" #include "GameDefine.h" #include "KUIWndManager.h" #ifdef _RAC #include "SGameViewPort.h" #else #include "KViewport.h" #endif //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // KUIControlQJTV Implement //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// namespace { KUIWnd* ControlQJTVStatic() { return new KUIControlQJTV; } bool bQJTVStaticRegister = KUIFactory::GetInstance()->RegisterCreator( ControlQJTVStatic, "qjtv_static"); } KUIControlQJTV::KUIControlQJTV() : m_bXVID(false) { m_spRes = new KResSprite; } KUIControlQJTV::~KUIControlQJTV() { } void KUIControlQJTV::Create(KUIWND_CREATE_ARG& CREATE_ARG) { KUIControl::Create( CREATE_ARG); } void KUIControlQJTV::Render(KViewportObject * pViewport, bool isFront ) { if( IsShow() ) pViewport->Register( &m_prSprite ); } void KUIControlQJTV::OnPosChangeNofity(int XOffset, int YOffset) { KUIControl::OnPosChangeNofity(XOffset, YOffset); m_prSprite.SetAddPosition(XOffset, YOffset); } void KUIControlQJTV::OnAlphaChangeNotify(float fAlpha) { KUIControl::OnAlphaChangeNotify( fAlpha ); m_prSprite.SetVisibility( fAlpha ); } DWORD KUIControlQJTV::OnMouseMessage(DWORD dwMessage, int x, int y) { DWORD dwRet = KUIControl::OnMouseMessage(dwMessage,x,y); if(KMR_NO_GET & dwRet) return dwRet; if( IsDisable() ) return dwRet; return dwRet; } void KUIControlQJTV::SetRenderTarget( K3DTexture* pRenderTarget, int nWidth, int nHeight ) { m_spRenderTarget = pRenderTarget; if( m_spRenderTarget != NULL) { //Center 계산 int nHalfWidth = pRenderTarget->GetWidth()/2; int nHalfHeight = pRenderTarget->GetHeight()/2; KRect rect; rect.left = nHalfWidth - nWidth/2; rect.top = nHalfHeight - nHeight/2; rect.right = nHalfWidth + nWidth/2; rect.bottom = nHalfHeight + nHeight/2; float fUV[4]; fUV[0] = (float)rect.left/pRenderTarget->GetWidth(); fUV[1] = (float)rect.top/pRenderTarget->GetHeight(); fUV[2] = (float)rect.right/pRenderTarget->GetWidth(); fUV[3] = (float)rect.bottom/pRenderTarget->GetHeight(); m_spRes->SetTexture(m_spRenderTarget, &rect); m_rcRegion.right = m_rcRegion.left + GetRect().GetWidth(); m_rcRegion.bottom = m_rcRegion.top + GetRect().GetHeight(); m_prSprite.SetRes( m_spRes ); m_prSprite.SetVisibility( 1.0f ); K3DMatrix mat; K3DMatrixIdentity( mat ); mat.SetPosVector( K3DVertex( m_rcRegion.left, m_rcRegion.top, m_fZPos ) ); if(m_bXVID) mat._22 *= -1.0f; m_prSprite.SetTransform( mat ); m_prSprite.SetTargetSize( GetRect().GetWidth(), GetRect().GetHeight() ); m_prSprite.SetSourceUVRect( fUV[0], fUV[1], fUV[2], fUV[3] ); InvalidateWnd(); } } ////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////// namespace { KUIWnd* ControlDynamicTextureStatic() { return new KUIControlDynamicTexture; } bool bDynamicTextureStatic = KUIFactory::GetInstance()->RegisterCreator( ControlDynamicTextureStatic, "dynamictexture_static" ); } KUIControlDynamicTexture::KUIControlDynamicTexture() { m_spRes = new KResSprite; } KUIControlDynamicTexture::~KUIControlDynamicTexture() { } void KUIControlDynamicTexture::Create(KUIWND_CREATE_ARG& CREATE_ARG) { KUIControl::Create( CREATE_ARG); } void KUIControlDynamicTexture::Render(KViewportObject * pViewport, bool isFront /*= false*/ ) { if( IsShow() ) pViewport->Register( &m_prSprite ); } void KUIControlDynamicTexture::OnPosChangeNofity(int XOffset, int YOffset) { KUIControl::OnPosChangeNofity(XOffset, YOffset); m_prSprite.SetAddPosition(XOffset, YOffset); } void KUIControlDynamicTexture::OnAlphaChangeNotify(float fAlpha) { KUIControl::OnAlphaChangeNotify( fAlpha ); m_prSprite.SetVisibility( fAlpha ); } void KUIControlDynamicTexture::SetRenderTarget( K3DTexture* pTexture, int nWidth, int nHeight ) { m_spRenderTarget = pTexture; if( m_spRenderTarget != NULL) { m_spRes->SetTexture(m_spRenderTarget, NULL); float fUV[4]; fUV[0] = 0.f; fUV[1] = 0.f; fUV[2] = (float)nWidth/pTexture->GetWidth(); fUV[3] = (float)nHeight/pTexture->GetHeight(); m_rcRegion.right = m_rcRegion.left + GetRect().GetWidth(); m_rcRegion.bottom = m_rcRegion.top + GetRect().GetHeight(); m_prSprite.SetRes( m_spRes ); m_prSprite.SetVisibility( 1.0f ); K3DMatrix mat; K3DMatrixIdentity( mat ); mat.SetPosVector( K3DVertex( m_rcRegion.left, m_rcRegion.top, m_fZPos ) ); m_prSprite.SetTransform( mat ); m_prSprite.SetTargetSize( GetRect().GetWidth(), GetRect().GetHeight() ); m_prSprite.SetSourceUVRect( fUV[0], fUV[1], fUV[2], fUV[3] ); InvalidateWnd(); } }