#include "stdafx.h" #include "SUIEndingWnd.h" //#include "KUIControl.h" #include "KUIControlEdit.h" #include "KUIControlStatic.h" #include "KUIControlScroll.h" #include "KUIControlClockBox.h" #include "KUIControlQJTV.h" #include "KDeviceManager.h" #include "KRenderDevice.h" #include "KUITextureManager.h" //#include "Util.h" #include "KCommandBuilder.h" #include #include "KResourceDX.h" #include #include #include "SGameMessage.h" //#include "SGameMessageUI.h" #include "SStringDB.h" #include "SUIDefine.h" #include "KTGA_IO.h" #include "SGameManager.h" #include #include "GameRule.h" #include "SGameOption.h" #define RP2AP(fRelativePoint, fWidth) (int)(((float)fRelativePoint * (float)fWidth) + 0.5f) ////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////// //SUILoadingWnd namespace { int nFixImgWidth = 1024; int nFixImgHeight = 768; const char *szPanelImg = "ending_type01_pane.png"; const char* pLoadImgFileName[] = { "ending_image01.jpg", "ending_image02.jpg", "ending_image03.jpg", "ending_image04.jpg", }; }; extern void SetCopy( char * pSrc, const int nSrcStride, char * pDst, const int nDstStride, const int nWidth, const int nHeight ); extern void LoadTexture(const char *filename, K3DTexture* texture); SUIEndingWnd::SUIEndingWnd(SGameManager* pGameManager) : SUIWnd(pGameManager) //, m_dwTime( 0 ) //, m_dwWarringTime( 0 ) //, m_pMessageSelector( 0 ) , m_spEndingTexture(NULL) , m_spPanelTexture(NULL) , m_pWndDowninfo(NULL) , m_pWndPublisherLogo(NULL) , m_pWndNFlaverLogo(NULL) , m_pWndText(NULL) , m_PrevTime(0) , m_ExitCounter(0) , m_wndCopyRight(NULL) // 2010.07.14 - prodongi { } SUIEndingWnd::~SUIEndingWnd() { } bool SUIEndingWnd::CreateControls( class KUIWndManager* pWndManager ) { KRect colorRect, loadRect, msgRect; colorRect.left = 0; colorRect.right = KUIWndManager::GetResolution().cx; colorRect.top = 0; colorRect.bottom = KUIWndManager::GetResolution().cy; int nWidth = KUIWndManager::GetResolution().cx; int nHeight = KUIWndManager::GetResolution().cy; float fWidth = (float)KUIWndManager::GetResolution().cx; float fHeight = (float)KUIWndManager::GetResolution().cy; loadRect.left = 0; loadRect.right = KUIWndManager::GetResolution().cy*4/3;////nFixImgWidth; loadRect.top = 0; loadRect.bottom = KUIWndManager::GetResolution().cy;//nFixImgHeight; KUIWND_CREATE_ARG arg; arg.lpszAniName = ""; arg.lpszSprName = m_sSprName.c_str(); arg.lpszClassName = "colorbox"; arg.lpszID = "color_inside"; arg.dwFlag = KFLAG_NO_GET_MESSAGE; arg.dwStyle = 0; arg.rcRect = colorRect; arg.pParent = this; arg.dwFlag = KFLAG_GET_PASS_MESSAGE; KUIControlColorBox* pWndInside = (KUIControlColorBox*)pWndManager->CreateControl(arg); pWndInside->SetWeightColor( KColor( 0,0,0,255 ) ); //Load Image arg.lpszSprName = m_sSprName.c_str(); arg.lpszClassName = "dynamictexture_static"; arg.lpszID = "load_img"; arg.rcRect = loadRect; KUIControlDynamicTexture* pWndDynamicTex = (KUIControlDynamicTexture*)pWndManager->CreateControl(arg); //Panel Image arg.lpszSprName = m_sSprName.c_str(); arg.lpszClassName = "dynamictexture_static"; arg.lpszID = "panel_img"; arg.rcRect = loadRect; KUIControlDynamicTexture* pWndPanelTex = (KUIControlDynamicTexture*)pWndManager->CreateControl(arg); //Loading msgRect.left = KUIWndManager::GetResolution().cx - KUIWndManager::GetResolution().cx/10; msgRect.right = KUIWndManager::GetResolution().cx; msgRect.top = KUIWndManager::GetResolution().cy - 100; msgRect.bottom = KUIWndManager::GetResolution().cy; int nExpX, nExpY; K3DRenderDevice::GetSquareSize( nFixImgWidth, nFixImgHeight, nExpX, nExpY ); if( KUITextureManager::GetHWType() == KUITextureManager::HW_SUPPORT ) { m_spEndingTexture = KDeviceManager::GetDeviceManager()->GetRenderDevice()->CreateTexture( nExpX, nExpY, KUSAGE_DYNAMIC, K3DFMT_A8R8G8B8, D3DPOOL_DEFAULT ); m_spPanelTexture = KDeviceManager::GetDeviceManager()->GetRenderDevice()->CreateTexture( nExpX, nExpY, KUSAGE_DYNAMIC, K3DFMT_A8R8G8B8, D3DPOOL_DEFAULT ); } else { //Intel Chip 계열에서 지원 안 되는 넘들이 있음. m_spEndingTexture = KDeviceManager::GetDeviceManager()->GetRenderDevice()->CreateTexture( nExpX, nExpY, K3DFMT_A8R8G8B8, D3DPOOL_MANAGED ); m_spPanelTexture = KDeviceManager::GetDeviceManager()->GetRenderDevice()->CreateTexture( nExpX, nExpY, K3DFMT_A8R8G8B8, D3DPOOL_MANAGED ); } if( pWndDynamicTex ) pWndDynamicTex->SetRenderTarget( m_spEndingTexture, nFixImgWidth, nFixImgHeight ); if( pWndPanelTex ) pWndPanelTex->SetRenderTarget( m_spPanelTexture, nFixImgWidth, nFixImgHeight ); int adjustwidth = KUIWndManager::GetResolution().cy*4/3; if(adjustwidth > KUIWndManager::GetResolution().cx) adjustwidth = KUIWndManager::GetResolution().cx; int adjustx = KUIWndManager::GetResolution().cx/2 - adjustwidth/2; if(adjustx < 0) adjustx = 0; /* K3DTextureSPtr m_spEndingTexture; K3DTextureSPtr m_spPanelTexture; //ILoadingMessageSelector* m_pMessageSelector; SUIWnd *m_pWndDowninfo; SUIWnd *m_pWndPublisherLogo; SUIWnd *m_pWndNFlaverLogo; SUIWnd *m_pWndText; */ //퍼블리셔로고 { if( GetLocaleOption().GetValueString("ENDING_PUBLISHER_LOGO",NULL) != NULL ) { m_pWndPublisherLogo = new SUIWnd( m_pGameManager ); m_pWndPublisherLogo->CreateWnd( GetLocaleOption().GetValueString("ENDING_PUBLISHER_LOGO", "window_lobby_pubilshed_logo.nui"), pWndManager, KPoint(0, 0) ); m_pWndPublisherLogo->SetParent(this); AddChild(m_pWndPublisherLogo); m_pWndPublisherLogo->MovePos( adjustx, KUIWndManager::GetResolution().cy - m_pWndPublisherLogo->GetRect().GetHeight() ); m_pWndPublisherLogo->SetShow(true); } else { m_pWndPublisherLogo = NULL; } } //엔플레버 로고 { if(GetLocaleOption().GetValueString("ENDING_NFLAVOR_LOGO",NULL)!=NULL) { m_pWndNFlaverLogo = new SUIWnd( m_pGameManager ); m_pWndNFlaverLogo->CreateWnd( GetLocaleOption().GetValueString("ENDING_NFLAVOR_LOGO", "window_lobby_copyright_logo.nui"), pWndManager, KPoint(0, 0) ); m_pWndNFlaverLogo->SetParent(this); AddChild(m_pWndNFlaverLogo); m_pWndNFlaverLogo->MovePos( (adjustx + adjustwidth) - m_pWndNFlaverLogo->GetRect().GetWidth(), KUIWndManager::GetResolution().cy - m_pWndNFlaverLogo->GetRect().GetHeight() ); m_pWndNFlaverLogo->SetShow(true); } else { m_pWndNFlaverLogo = NULL; } } //down tool tip { if(GetLocaleOption().GetValueString("ENDING_DOWNINFO_NUI", NULL) != NULL) { m_pWndDowninfo = new SUIWnd( m_pGameManager ); m_pWndDowninfo->CreateWnd( GetLocaleOption().GetValueString("ENDING_DOWNINFO_NUI", "window_lobby_loading_down_info.nui"), pWndManager, KPoint(0, 0) ); m_pWndDowninfo->SetParent(this); AddChild(m_pWndDowninfo); m_pWndDowninfo->MovePos( KUIWndManager::GetResolution().cx/2 - m_pWndDowninfo->GetRect().GetWidth()/2, 673*KUIWndManager::GetResolution().cy/768); m_pWndDowninfo->SetShow(true); } else { m_pWndDowninfo = NULL; } } //text { m_pWndText = new SUIWnd( m_pGameManager ); m_pWndText->CreateWnd("window_lobby_ending_text.nui", pWndManager, KPoint(0, 0) ); m_pWndText->SetParent(this); AddChild(m_pWndText); m_pWndText->MovePos( adjustx + (41*adjustwidth/1024), 627*KUIWndManager::GetResolution().cy/768); m_pWndText->SetShow(true); } // 2010.07.14 로그인 화면이 아닐때는 copyright가 엔딩 페널 뒤로 가버리기 때문에 엔딩쪽을 따로 만들어줘야됨- prodongi m_wndCopyRight = new SUIWnd( m_pGameManager ); m_wndCopyRight->CreateWnd("window_copyrights_marking01.nui", pWndManager, KPoint(0, 0) ); m_wndCopyRight->SetParent(this); AddChild(m_wndCopyRight); m_wndCopyRight->MovePos( adjustx + 730 * adjustwidth / 1024, 148*KUIWndManager::GetResolution().cy/768); m_wndCopyRight->SetShow(true); return true; } void SUIEndingWnd::Render(KViewportObject *pViewport, bool isFront) { KUIWnd::Render(pViewport, isFront); } void SUIEndingWnd::OnDeviceLost() { refreshLoadImage(); KUIControlDynamicTexture* pWndDynamicTex = dynamicCast(GetChild("load_img")); if( pWndDynamicTex ) pWndDynamicTex->SetRenderTarget( m_spEndingTexture, nFixImgWidth, nFixImgHeight ); KUIControlDynamicTexture* pWndDynamicTex2 = dynamicCast(GetChild("panel_img")); if( pWndDynamicTex2 ) pWndDynamicTex2->SetRenderTarget( m_spPanelTexture, nFixImgWidth, nFixImgHeight ); } void SUIEndingWnd::Start_ExitProcess(int time) { m_ExitCounter = time; m_PrevTime = 0; refreshLoadImage(); int nW = KUIWndManager::GetResolution().width; int nH = KUIWndManager::GetResolution().height; int nHalfWidth = nW/2; int nHalfHeight = nH/2; int ScreenPosSX = nHalfWidth - nH*4/3/2; int ScreenPosEX = nHalfWidth + nH*4/3/2; if(ScreenPosSX<0) ScreenPosSX = 0; if(ScreenPosEX>nW) ScreenPosEX = nW; KRect rect; rect.left = ScreenPosSX; rect.top = 0; rect.right = ScreenPosEX; rect.bottom = nH; KUIControlDynamicTexture* pWndDynamicTex = dynamicCast(GetChild("load_img")); if( pWndDynamicTex ) { pWndDynamicTex->MovePos( nHalfWidth - nH*4/3/2 , nHalfHeight - nH/2 ); pWndDynamicTex->Resize( rect ); pWndDynamicTex->SetRenderTarget( m_spEndingTexture, nFixImgWidth, nFixImgHeight ); } KUIControlDynamicTexture* pWndDynamicTex2 = dynamicCast(GetChild("panel_img")); if( pWndDynamicTex2 ) { pWndDynamicTex2->MovePos( nHalfWidth - nH*4/3/2 , nHalfHeight - nH/2 ); pWndDynamicTex2->Resize( rect ); pWndDynamicTex2->SetRenderTarget( m_spPanelTexture, nFixImgWidth, nFixImgHeight ); } int adjustwidth = KUIWndManager::GetResolution().cy*4/3; if(adjustwidth > KUIWndManager::GetResolution().cx) adjustwidth = KUIWndManager::GetResolution().cx; int adjustx = KUIWndManager::GetResolution().cx/2 - adjustwidth/2; if(adjustx < 0) adjustx = 0; if(m_pWndPublisherLogo) m_pWndPublisherLogo->MovePos( adjustx, KUIWndManager::GetResolution().cy - m_pWndPublisherLogo->GetRect().GetHeight() ); if(m_pWndNFlaverLogo) m_pWndNFlaverLogo->MovePos( (adjustx + adjustwidth) - m_pWndNFlaverLogo->GetRect().GetWidth(), KUIWndManager::GetResolution().cy - m_pWndNFlaverLogo->GetRect().GetHeight() ); if(m_pWndText) m_pWndText->MovePos( adjustx + (41*adjustwidth/1024), 627*KUIWndManager::GetResolution().cy/768); if(m_pWndDowninfo) m_pWndDowninfo->MovePos( KUIWndManager::GetResolution().cx/2 - m_pWndDowninfo->GetRect().GetWidth()/2, 673*KUIWndManager::GetResolution().cy/768); // 2010.07.14 - prodongi if (m_wndCopyRight) m_wndCopyRight->MovePos( adjustx + 730 * adjustwidth / 1024, 148*KUIWndManager::GetResolution().cy/768); } void SUIEndingWnd::refreshLoadImage() { //m_nCount = 0; /*POINT point; point.x = 0; point.y = 0; RECT rect; rect.left = 0; rect.top = 0; */ { KUIControlColorBox* pColorBox = dynamicCast(GetChild( "color_inside" )); if( pColorBox ) pColorBox->SetWeightColor( KColor( 0,0,0,255 ) ); KUIWnd* pLoadImg = dynamicCast(GetChild( "load_img" )); if( pLoadImg ) pLoadImg->SetShow( true ); KUIWnd* pPanelImg = dynamicCast(GetChild( "panel_img" )); if( pPanelImg ) pPanelImg->SetShow( true ); if(m_pWndPublisherLogo) m_pWndPublisherLogo->SetShow(true); if(m_pWndNFlaverLogo) m_pWndNFlaverLogo->SetShow(true); } LoadTexture( pLoadImgFileName[rand()%_countof(pLoadImgFileName)], m_spEndingTexture ); LoadTexture( szPanelImg, m_spPanelTexture ); } void SUIEndingWnd::ProcMsgAtStatic( SGameMessage* pMsg ) {//화면 크기에 맞게 리사이즈 if( pMsg->nType == IMSG_UI_CHANGE_RESOLUTION ) { pMsg->bUse = true; SIMSG_UI_CHANGE_RESOLUTION* pChangeResolution = dynamicCast(pMsg); int nW = pChangeResolution->m_nWidth; int nH = pChangeResolution->m_nHeight; #ifdef _KUI_INVALIDATION // { [sonador] // resize this SetResizeUnit( 1, 1, KSize( m_minSize.cx, m_minSize.cy ), KSize( nW, nH ) ); Resize( KRect( 0, 0, nW, nH ) ); // } #endif int nHalfWidth = nW/2; int nHalfHeight = nH/2; int ScreenPosSX = nHalfWidth - nH*4/3/2; int ScreenPosEX = nHalfWidth + nH*4/3/2; if(ScreenPosSX<0) ScreenPosSX = 0; if(ScreenPosEX>nW) ScreenPosEX = nW; KRect rect; rect.left = ScreenPosSX; rect.top = 0; rect.right = ScreenPosEX; rect.bottom = nH; KUIWnd* pColorBox = GetChild( "color_inside" ); if( pColorBox ) { pColorBox->Resize( KRect( 0,0, nW, nH ) ); pColorBox->MovePos( 0, 0 ); } KUIControlDynamicTexture* pWndDynamicTex = dynamicCast(GetChild("load_img")); if( pWndDynamicTex ) { pWndDynamicTex->MovePos( nHalfWidth - nH*4/3/2 , nHalfHeight - nH/2 ); pWndDynamicTex->Resize( rect ); pWndDynamicTex->SetRenderTarget( m_spEndingTexture, nFixImgWidth, nFixImgHeight ); } KUIControlDynamicTexture* pWndDynamicTex2 = dynamicCast(GetChild("panel_img")); if( pWndDynamicTex2 ) { pWndDynamicTex2->MovePos( nHalfWidth - nH*4/3/2 , nHalfHeight - nH/2 ); pWndDynamicTex2->Resize( rect ); pWndDynamicTex2->SetRenderTarget( m_spPanelTexture, nFixImgWidth, nFixImgHeight ); } int adjustwidth = KUIWndManager::GetResolution().cy*4/3; if(adjustwidth > KUIWndManager::GetResolution().cx) adjustwidth = KUIWndManager::GetResolution().cx; int adjustx = KUIWndManager::GetResolution().cx/2 - adjustwidth/2; if(adjustx < 0) adjustx = 0; if(m_pWndPublisherLogo) m_pWndPublisherLogo->MovePos( adjustx, KUIWndManager::GetResolution().cy - m_pWndPublisherLogo->GetRect().GetHeight() ); if(m_pWndNFlaverLogo) m_pWndNFlaverLogo->MovePos( (adjustx + adjustwidth) - m_pWndNFlaverLogo->GetRect().GetWidth(), KUIWndManager::GetResolution().cy - m_pWndNFlaverLogo->GetRect().GetHeight() ); if(m_pWndText) m_pWndText->MovePos( adjustx + (41*adjustwidth/1024), 627*KUIWndManager::GetResolution().cy/768); if(m_pWndDowninfo) m_pWndDowninfo->MovePos( KUIWndManager::GetResolution().cx/2 - m_pWndDowninfo->GetRect().GetWidth()/2, 673*KUIWndManager::GetResolution().cy/768); // 2010.07.14 - prodongi if (m_wndCopyRight) m_wndCopyRight->MovePos( adjustx + 730 * adjustwidth / 1024, 148*KUIWndManager::GetResolution().cy/768); } } void SUIEndingWnd::Process(DWORD dwTime) { if( !IsShow() ) return; KUIWnd::Process(dwTime); if(m_PrevTime==0) m_PrevTime = dwTime; m_ExitCounter = m_ExitCounter - (dwTime-m_PrevTime); m_PrevTime = dwTime; _oprint("m_ExitCounter - %d\n",m_ExitCounter); if(m_ExitCounter<=0) { m_pGameManager->GameExit(); } /* if( m_dwTime == 0 ) m_dwTime = dwTime; if( dwTime-m_dwTime > 150 ) { m_dwTime = dwTime; m_nCount++; if( m_nCount > 5 ) m_nCount = 0; if(m_pWndNowLoading) { KUIWnd *aniwnd = m_pWndNowLoading->GetChild( "key_info_point_ani" ); if(aniwnd) { std::string strLoad2 = "<#392f29>"; for( int i(0); m_nCount>i; i++ ) strLoad2 += "."; aniwnd->SetCaption( strLoad2.c_str() ); } } } if (m_pkWndLoadingProgress) m_pkWndLoadingProgress->Process(dwTime); */ } #undef RP2AP