331 lines
9.0 KiB
C++
331 lines
9.0 KiB
C++
|
|
/// 2011.10.12 - prodongi
|
|
|
|
#include "stdafx.h"
|
|
#include "SUIRaidSiegeStatusWnd.h"
|
|
#include "SUIRaidSiegeProgressRaidWnd.h"
|
|
#include "SUIRaidSiegeProgressSiegeWnd.h"
|
|
#include "SUIRaidSiegeResultRaidWnd.h"
|
|
#include "SUIRaidSiegeResultSiegeWnd.h"
|
|
#include "SUIRaidSiegeRotationSiegeWnd.h"
|
|
#include "SGameManager.h"
|
|
//#include "SGameMessageUI.h"
|
|
#include "GameDefine.h"
|
|
#include "SGameOption.h"
|
|
#include <mmo/ArTime.h>
|
|
|
|
SUIRaidSiegeStatusWnd::SUIRaidSiegeStatusWnd(SGameManager* pGameManager) : SUIWnd(pGameManager),
|
|
m_readyType(-1),
|
|
m_wndProgress(NULL),
|
|
m_wndResult(NULL),
|
|
m_wndRotationSiege(NULL),
|
|
m_progressTime(0),
|
|
m_recvProgressTime(0),
|
|
m_defenseHp(0),
|
|
m_offenseHp(0),
|
|
m_curLocation(-1),
|
|
m_prevLocation(-1)
|
|
{
|
|
}
|
|
|
|
SUIRaidSiegeStatusWnd::~SUIRaidSiegeStatusWnd()
|
|
{
|
|
}
|
|
|
|
void SUIRaidSiegeStatusWnd::Process(DWORD dwTime)
|
|
{
|
|
if (m_wndProgress)
|
|
m_wndProgress->Process(dwTime);
|
|
if (m_wndResult)
|
|
m_wndResult->Process(dwTime);
|
|
updateRotationSiege(dwTime);
|
|
|
|
checkReadyType();
|
|
}
|
|
|
|
void SUIRaidSiegeStatusWnd::removeReadyTypes()
|
|
{
|
|
if (m_wndProgress)
|
|
{
|
|
RemoveChild(m_wndProgress);
|
|
m_wndProgress = NULL;
|
|
}
|
|
if (m_wndResult)
|
|
{
|
|
RemoveChild(m_wndResult);
|
|
m_wndResult = NULL;
|
|
}
|
|
}
|
|
|
|
void SUIRaidSiegeStatusWnd::checkReadyType()
|
|
{
|
|
if (-1 == m_readyType)
|
|
return ;
|
|
|
|
removeReadyTypes();
|
|
|
|
m_wndResult = createResult(m_readyType);
|
|
m_wndProgress = createProgress(m_readyType);
|
|
m_readyType = -1;
|
|
}
|
|
|
|
SUIRaidSiegeProgressBaseWnd* SUIRaidSiegeStatusWnd::createProgress(int type)
|
|
{
|
|
char const* nuiName;
|
|
SUIRaidSiegeProgressBaseWnd* wnd = NULL;
|
|
switch (type)
|
|
{
|
|
case RAID: wnd = new SUIRaidSiegeProgressRaidWnd(m_pGameManager);
|
|
nuiName = "window_dungeon_raid_time_state.nui";
|
|
break;
|
|
case SIEGE: wnd = new SUIRaidSiegeProgressSiegeWnd(m_pGameManager);
|
|
nuiName = "window_dungeon_siege_state.nui";
|
|
break;
|
|
default: return NULL;
|
|
}
|
|
|
|
wnd->CreateWnd(nuiName, m_pManager, KPoint(0, 0));
|
|
wnd->SetParent(this);
|
|
AddChild(wnd);
|
|
wnd->MovePos(GetGameOption().GetResolution_Width()-wnd->GetRect().GetWidth(),
|
|
GetGameOption().GetResolution_Height()-250 - wnd->GetRect().GetHeight());
|
|
wnd->initialize();
|
|
wnd->start(m_progressTime + GetSafeTickCount() - m_recvProgressTime);
|
|
wnd->start(m_defenseHp, m_offenseHp, m_ownerType);
|
|
wnd->setOpponentName(m_opponentName.c_str());
|
|
wnd->SetShow(true);
|
|
wnd->setType(type);
|
|
SetChildAsTop(wnd->GetID());
|
|
return wnd;
|
|
}
|
|
|
|
SUIRaidSiegeResultBaseWnd* SUIRaidSiegeStatusWnd::createResult(int type)
|
|
{
|
|
char const* nuiName;
|
|
SUIRaidSiegeResultBaseWnd* wnd = NULL;
|
|
switch (type)
|
|
{
|
|
case RAID: wnd = new SUIRaidSiegeResultRaidWnd(m_pGameManager);
|
|
nuiName = "window_dungeon_raid_result.nui";
|
|
break;
|
|
case SIEGE: wnd = new SUIRaidSiegeResultSiegeWnd(m_pGameManager);
|
|
nuiName = "window_dungeon_siege_result.nui";
|
|
break;
|
|
default: return NULL;
|
|
}
|
|
|
|
wnd->CreateWnd(nuiName, m_pManager, KPoint(0, 0));
|
|
wnd->SetParent(this);
|
|
AddChild(wnd);
|
|
wnd->MovePos((GetGameOption().GetResolution_Width() - wnd->GetRect().GetWidth()) >> 1,
|
|
(GetGameOption().GetResolution_Height() - wnd->GetRect().GetHeight()) >> 1);
|
|
wnd->SetShow(false);
|
|
wnd->setType(type);
|
|
SetChildAsTop(wnd->GetID());
|
|
return wnd;
|
|
}
|
|
|
|
void SUIRaidSiegeStatusWnd::setReadyType(int type)
|
|
{
|
|
m_readyType = type;
|
|
}
|
|
|
|
void SUIRaidSiegeStatusWnd::PumpUpMessage( LPCSTR lpszControlID, DWORD nMessage, DWORD lparam, DWORD wparam )
|
|
{
|
|
SUIWnd::PumpUpMessage(lpszControlID, nMessage, lparam, wparam);
|
|
}
|
|
|
|
void SUIRaidSiegeStatusWnd::ProcMsgAtStatic( SGameMessage* pMsg )
|
|
{
|
|
switch (pMsg->nType)
|
|
{
|
|
case IMSG_UI_SEND_DATA:
|
|
{
|
|
pMsg->bUse = true;
|
|
SIMSG_UI_SEND_DATA* data = dynamicCast<SIMSG_UI_SEND_DATA*>(pMsg);
|
|
if (!data)
|
|
return ;
|
|
if (data->m_strString == "RAID_ENTER")
|
|
{
|
|
if ("-1" != data->m_strText)
|
|
{
|
|
setReadyType(RAID);
|
|
setProgressTime(data->m_strText);
|
|
m_recvProgressTime = GetSafeTickCount();
|
|
if (m_wndResult && m_wndResult->IsShow())
|
|
m_wndResult->SetShow(false);
|
|
if (!IsShow())
|
|
m_pGameManager->PostMsgAtDynamic( new SIMSG_SHOW_UIWINDOW( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_RAID_SIEGE_STATUS, true ) );
|
|
}
|
|
}
|
|
else if (data->m_strString == "RAID_RESULT")
|
|
{
|
|
if (m_wndResult)
|
|
{
|
|
m_wndResult->setResult(data->m_strText.c_str(), data->m_nNumber.getAmount(), data->m_nNumber2.getAmount(), data->m_nNumber3.getAmount());
|
|
m_wndResult->SetShow(true);
|
|
}
|
|
if (m_wndProgress)
|
|
{
|
|
m_wndProgress->end();
|
|
m_wndProgress->SetShow(false);
|
|
}
|
|
}
|
|
else if (data->m_strString == "SIEGE_STATUS")
|
|
{
|
|
int offenseHp = data->m_nNumber.getAmount(); /// 결계석
|
|
int defenseHp = data->m_nNumber2.getAmount(); /// 코어
|
|
int ownerType = data->m_nNumber3.getAmount(); /// 소유자
|
|
if (!m_wndProgress || SIEGE != m_wndProgress->getType())
|
|
{
|
|
setReadyType(SIEGE);
|
|
setProgressHp(defenseHp, offenseHp, ownerType);
|
|
/// 레이드를 뛰고 바로 시즈를 뛸 때, 남아 있을 수 있다.
|
|
if (m_wndResult && m_wndResult->IsShow())
|
|
m_wndResult->SetShow(false);
|
|
}
|
|
else
|
|
{
|
|
if (!m_wndProgress->IsShow())
|
|
m_wndProgress->SetShow(true);
|
|
m_wndProgress->start(defenseHp, offenseHp, ownerType);
|
|
}
|
|
|
|
if (!IsShow())
|
|
m_pGameManager->PostMsgAtDynamic( new SIMSG_SHOW_UIWINDOW( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_RAID_SIEGE_STATUS, true ) );
|
|
}
|
|
else if (data->m_strString == "SIEGE_OPPONENT")
|
|
{
|
|
m_opponentName = data->m_strText;
|
|
if (m_wndProgress)
|
|
m_wndProgress->setOpponentName(data->m_strText.c_str());
|
|
}
|
|
else if (data->m_strString == "SIEGE_RESULT")
|
|
{
|
|
removeRotationSiege();
|
|
|
|
if (m_wndResult)
|
|
{
|
|
m_wndResult->setResult(data->m_strText.c_str());
|
|
m_wndResult->SetShow(true);
|
|
}
|
|
if (m_wndProgress)
|
|
{
|
|
m_wndProgress->SetShow(false);
|
|
}
|
|
}
|
|
else if (data->m_strString == "RAID_END" || data->m_strString == "SIEGE_END")
|
|
{
|
|
removeReadyTypes();
|
|
m_pGameManager->PostMsgAtDynamic( new SIMSG_SHOW_UIWINDOW( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_RAID_SIEGE_STATUS, false ) );
|
|
}
|
|
}
|
|
break;
|
|
case IMSG_UI_CHANGE_RESOLUTION:
|
|
{
|
|
pMsg->bUse = true;
|
|
SetRect(KRect(0, 0, GetGameOption().GetResolution_Width(), GetGameOption().GetResolution_Height()));
|
|
}
|
|
break;
|
|
case IMSG_UI_DISPLAY_LOCAL_NAME:
|
|
{
|
|
pMsg->bUse = true;
|
|
SIMSG_UI_DISPLAY_LOCAL_NAME* pLocalNameMsg = (SIMSG_UI_DISPLAY_LOCAL_NAME*)pMsg;
|
|
|
|
m_prevLocation = m_curLocation;
|
|
m_curLocation = pLocalNameMsg->nCurrentLocation;
|
|
}
|
|
break;
|
|
case IMSG_MOUSEMOVE:
|
|
{
|
|
SIMSG_MOUSEMOVE* pMouseMove = (SIMSG_MOUSEMOVE* )pMsg;
|
|
int mouseX = ((int)(short)LOWORD(pMouseMove->lParam));
|
|
int mouseY = ((int)(short)HIWORD(pMouseMove->lParam));
|
|
if (m_wndProgress)
|
|
m_wndProgress->setMousePos(mouseX, mouseY);
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
|
|
void SUIRaidSiegeStatusWnd::OnNotifyUIWindowOpen( bool bOpen, bool bLimitWnd )
|
|
{
|
|
if (bOpen)
|
|
{
|
|
/// 워프할 때, SGameInterface::WarpInterface();에서 show를 하기 때문에 여기에서 조건 체크해서 hide를 시킨다
|
|
/// 레이드(시즈) 결과 화면에서 워프 할 때, hide 시킴
|
|
if (PLAYER_IN_DUNGEON_SIEGE == m_prevLocation || PLAYER_IN_DUNGEON_RAID == m_prevLocation)
|
|
{
|
|
if (PLAYER_IN_DUNGEON_SIEGE != m_curLocation && PLAYER_IN_DUNGEON_RAID != m_curLocation)
|
|
{
|
|
if (m_wndResult && m_wndResult->IsShow())
|
|
{
|
|
m_pGameManager->PostMsgAtDynamic( new SIMSG_SHOW_UIWINDOW( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_RAID_SIEGE_STATUS, false ) );
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
bool SUIRaidSiegeStatusWnd::InitControls( KPoint kPos )
|
|
{
|
|
return true;
|
|
}
|
|
|
|
void SUIRaidSiegeStatusWnd::setProgressTime(std::string const& progressTime)
|
|
{
|
|
int t = atoi(progressTime.c_str());
|
|
if (-1 == t)
|
|
{
|
|
m_progressTime = 0;
|
|
}
|
|
else
|
|
{
|
|
/// ar_time 은 1/100초이기 때문에 1/1000으로 바꿔준다
|
|
m_progressTime = (AR_TIME)t * 10;
|
|
}
|
|
}
|
|
|
|
void SUIRaidSiegeStatusWnd::setProgressHp(int defenseHp, int offenseHp, int ownerType)
|
|
{
|
|
m_defenseHp = defenseHp;
|
|
m_offenseHp = offenseHp;
|
|
m_ownerType = ownerType;
|
|
}
|
|
|
|
void SUIRaidSiegeStatusWnd::changeSiegeOwner(int newOwnerType)
|
|
{
|
|
if (m_wndRotationSiege)
|
|
return ;
|
|
|
|
m_wndRotationSiege = new SUIRaidSiegeRotationSiegeWnd(m_pGameManager);
|
|
m_wndRotationSiege->CreateWnd("window_dungeon_siege_rotation.nui", m_pManager, KPoint(0, 0));
|
|
m_wndRotationSiege->SetParent(this);
|
|
AddChild(m_wndRotationSiege);
|
|
m_wndRotationSiege->MovePos((GetGameOption().GetResolution_Width() - m_wndRotationSiege->GetRect().GetWidth()) >> 1,
|
|
(GetGameOption().GetResolution_Height() - m_wndRotationSiege->GetRect().GetHeight()) >> 1);
|
|
m_wndRotationSiege->setOwnerType(newOwnerType);
|
|
m_wndRotationSiege->SetShow(true);
|
|
SetChildAsTop(m_wndRotationSiege->GetID());
|
|
}
|
|
|
|
void SUIRaidSiegeStatusWnd::updateRotationSiege(DWORD time)
|
|
{
|
|
if (!m_wndRotationSiege)
|
|
return ;
|
|
|
|
m_wndRotationSiege->Process(time);
|
|
if (m_wndRotationSiege->isEnd())
|
|
{
|
|
removeRotationSiege();
|
|
}
|
|
}
|
|
|
|
void SUIRaidSiegeStatusWnd::removeRotationSiege()
|
|
{
|
|
if (!m_wndRotationSiege)
|
|
return ;
|
|
RemoveChild(m_wndRotationSiege);
|
|
m_wndRotationSiege = NULL;
|
|
}
|