391 lines
11 KiB
C++
391 lines
11 KiB
C++
#include "stdafx.h"
|
|
#include "Arena\\ArenaJoinSituationChecker.h"
|
|
#include "ARena\\ArenaSystem.h"
|
|
#include "SUIArenaWaitingWnd.h"
|
|
//#include "SGameMessageUI.h"
|
|
#include "KUIControlStatic.h"
|
|
#include "SGameManager.h"
|
|
#include "SGameMessage.h"
|
|
#include "SBattleArenaDB.h"
|
|
#include "SGameAvatarEx.h"
|
|
#include "ArenaRankInfo.h"
|
|
#include "SGameSystem.h"
|
|
#include "CommonUtil.h"
|
|
#include "SStringDB.h"
|
|
#include "SGame.h"
|
|
|
|
extern SGameSystem * g_pCurrentGameSystem;
|
|
|
|
/// 재진입 시간, 10초
|
|
int SUIArenaWaitingWnd::RECONNECT_WAITING_TIME = 1000;
|
|
|
|
SUIArenaWaitingWnd::SUIArenaWaitingWnd(SGameManager* gameManager) : SUIWnd(gameManager)
|
|
{
|
|
}
|
|
|
|
SUIArenaWaitingWnd::~SUIArenaWaitingWnd()
|
|
{
|
|
}
|
|
|
|
bool SUIArenaWaitingWnd::InitData(bool reload)
|
|
{
|
|
initFp();
|
|
initTooltip();
|
|
getWndInfo();
|
|
|
|
return SUIWnd::InitData(reload);
|
|
}
|
|
|
|
void SUIArenaWaitingWnd::initFp()
|
|
{
|
|
m_controlFp.add("button_arena_start_01", &SUIArenaWaitingWnd::start);
|
|
|
|
m_msgFp.add(MSG_BATTLE_ARENA_BATTLE_INFO, &SUIArenaWaitingWnd::procMsgBattleInfo);
|
|
m_msgFp.add(MSG_BATTLE_ARENA_UPDATE_WAIT_USER_COUNT, &SUIArenaWaitingWnd::procMsgUpdateWaitUserCount);
|
|
m_msgFp.add(MSG_BATTLE_ARENA_JOIN_QUEUE, &SUIArenaWaitingWnd::procMsgJoinQueue);
|
|
m_msgFp.add(MSG_BATTLE_ARENA_JOIN_BATTLE, &SUIArenaWaitingWnd::procMsgJoinBattle);
|
|
m_msgFp.add(MSG_BATTLE_ARENA_LEAVE, &SUIArenaWaitingWnd::procMsgLeave);
|
|
}
|
|
|
|
void SUIArenaWaitingWnd::initTooltip()
|
|
{
|
|
SetChildTooltip("mark_arena_mode_01", S(2317));
|
|
SetChildTooltip("mark_arena_vs_01", S(2318));
|
|
SetChildTooltip("mark_arena_current_01", S(2399));
|
|
}
|
|
|
|
void SUIArenaWaitingWnd::getWndInfo()
|
|
{
|
|
m_startButton = dynamicCast<KUIControl*>(GetChild("button_arena_start_01"));
|
|
m_countStatic = GetChild("text_arena_count_01");
|
|
m_helpStatic = GetChild("text_arena_help_01");
|
|
|
|
m_emptyControlRegionChecker.add(GetChild("area_control"));
|
|
}
|
|
|
|
void SUIArenaWaitingWnd::syncPos()
|
|
{
|
|
SUIWnd* menuWnd = m_pGameManager->GetSUI(SIMSG_TOGGLE_UIWINDOW::UIWINDOW_MAINMENU);
|
|
if (menuWnd)
|
|
MovePos(menuWnd->GetRect().left, menuWnd->GetRect().top - GetRect().GetHeight());
|
|
}
|
|
|
|
void SUIArenaWaitingWnd::ProcMsgAtStatic( SGameMessage* msg )
|
|
{
|
|
m_msgFp.call(msg->nType, this, msg);
|
|
}
|
|
|
|
void SUIArenaWaitingWnd::OnNotifyUIWindowOpen(bool bOpen, bool bLimitWnd)
|
|
{
|
|
if (bOpen)
|
|
{
|
|
syncPos();
|
|
setData();
|
|
setDefaultMyTeam();
|
|
|
|
/// 알림창은 아레나 메뉴보다 위로 오게 해준다
|
|
m_pGameManager->PostMsgAtDynamic( new SIMSG_UI_LIST_MOVE_FORCE_BACK( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_NOTIFICATION ) );
|
|
}
|
|
postUpdateMainMenuButton();
|
|
}
|
|
|
|
void SUIArenaWaitingWnd::postUpdateMainMenuButton()
|
|
{
|
|
m_pGameManager->PostMsgAtDynamic( new SIMSG_UPDATE_MAIN_MENU_BUTTON());
|
|
}
|
|
|
|
void SUIArenaWaitingWnd::PumpUpMessage( LPCTSTR controlID, DWORD msg, DWORD lparam, DWORD wparam )
|
|
{
|
|
switch (msg)
|
|
{
|
|
case KUI_MESSAGE::KBUTTON_CLICK: m_controlFp.call(controlID, this); break;
|
|
}
|
|
}
|
|
|
|
DWORD SUIArenaWaitingWnd::OnMouseMessage(DWORD dwMessage, int x, int y)
|
|
{
|
|
if (KLBUTTON_DOWN == dwMessage)
|
|
{
|
|
if (m_emptyControlRegionChecker.isIn(x, y))
|
|
return KMR_GET_PASS;
|
|
}
|
|
|
|
return SUIWnd::OnMouseMessage(dwMessage, x, y);
|
|
}
|
|
|
|
void SUIArenaWaitingWnd::Process(DWORD dwTime)
|
|
{
|
|
KUIWnd::Process(dwTime);
|
|
procCount(dwTime);
|
|
checkWaiting();
|
|
}
|
|
|
|
void SUIArenaWaitingWnd::procCount(DWORD dwTime)
|
|
{
|
|
if (!m_countDirecting.isEnable())
|
|
return ;
|
|
|
|
bool isEnd;
|
|
m_countDirecting.process(dwTime, isEnd);
|
|
if (isEnd)
|
|
{
|
|
endCounting();
|
|
}
|
|
updateCount();
|
|
}
|
|
|
|
void SUIArenaWaitingWnd::updateCount()
|
|
{
|
|
SetChildCaptionFormat(m_countStatic, "%s%d", "<font:font_01><size:28><#898989><out><hcenter>", m_countDirecting.getCount());
|
|
}
|
|
|
|
void SUIArenaWaitingWnd::start()
|
|
{
|
|
/// send
|
|
TS_CS_BATTLE_ARENA_ENTER_WHILE_COUNTDOWN msg;
|
|
m_pGameManager->PendMessage(&msg);
|
|
|
|
m_pGameManager->PostMsgAtDynamic( new SIMSG_SHOW_UIWINDOW( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_ARENA_WAITING, false) );
|
|
}
|
|
|
|
void SUIArenaWaitingWnd::setEnableStartButton(bool enable)
|
|
{
|
|
if (enable)
|
|
m_startButton->Enable();
|
|
else
|
|
m_startButton->Disable();
|
|
}
|
|
|
|
void SUIArenaWaitingWnd::setMode(int mode)
|
|
{
|
|
sArenaUtility utility;
|
|
SetChildCaptionFormat(GetChild("text_select_01"), "<font:font_01><size:9><#898989><b><right>%s", utility.modeToStr(mode));
|
|
}
|
|
|
|
void SUIArenaWaitingWnd::setMemberString(int maxMember)
|
|
{
|
|
sArenaUtility utility;
|
|
SetChildCaptionFormat(GetChild("text_select_02"), "<font:font_01><size:9><#898989><b><right>%s", utility.maxMemberToMemberStr(maxMember));
|
|
}
|
|
|
|
void SUIArenaWaitingWnd::setMemberCount(int curMember)
|
|
{
|
|
int maxMember = 0;
|
|
BattleArenaBase* base = GetBattleArenaDB().getData(g_pCurrentGameSystem->getArenaId());
|
|
if (base) maxMember = base->nMaxMember;
|
|
|
|
sArenaUtility utility;
|
|
char const* curMemberColor = utility.getMinMemberCountColor(curMember, maxMember);
|
|
/// set caption
|
|
SetChildCaptionFormat(GetChild("text_current_member_01"), "<font:font_01><size:9><b><right>%s%d<#ffffff>/%d", curMemberColor, curMember, maxMember);
|
|
}
|
|
|
|
void SUIArenaWaitingWnd::updateMemberCount()
|
|
{
|
|
sArenaSystem* arenaSystem = g_pCurrentGameSystem->getArenaSystem();
|
|
|
|
int curMember = 0;
|
|
for (int i = 0; i < sArenaUtility::MAX_TEAM_NUM; ++i)
|
|
{
|
|
curMember += arenaSystem->getPlayerCount(i);
|
|
}
|
|
|
|
setMemberCount(curMember);
|
|
}
|
|
|
|
void SUIArenaWaitingWnd::setTotalCount(float count)
|
|
{
|
|
m_countDirecting.setCount(count);
|
|
}
|
|
|
|
void SUIArenaWaitingWnd::startCounting()
|
|
{
|
|
isValidArenaJoinSituationAtStartCount();
|
|
m_countDirecting.start();
|
|
updateCount();
|
|
}
|
|
|
|
void SUIArenaWaitingWnd::endCounting()
|
|
{
|
|
isValidArenaJoinSituationAtEndCount();
|
|
/// SUIArenaGameWnd에서 하고 있다
|
|
//g_pCurrentGameSystem->GetGame()->SendGameInterfaceMsg(&SIMSG_ANNOUNCE(S(2462)));
|
|
}
|
|
|
|
void SUIArenaWaitingWnd::setRank()
|
|
{
|
|
sArenaRankInfo rankInfo;
|
|
rankInfo.setRank(GetChild("mark_rookie"));
|
|
}
|
|
|
|
void SUIArenaWaitingWnd::isValidArenaJoinSituationAtStartCount()
|
|
{
|
|
sArenaJoinSituationCondition situationCondition;
|
|
/// way
|
|
situationCondition.m_notificationWays = cArenaJoinSituationChecker::WAY_NOTIFICATION_WND;
|
|
/// situation
|
|
situationCondition.add(cArenaJoinSituationChecker::SITUATION_DEATH, S(2434));
|
|
situationCondition.add(cArenaJoinSituationChecker::SITUATION_TRADE, S(2435));
|
|
situationCondition.add(cArenaJoinSituationChecker::SITUATION_INSTANCE_PLAYING, S(2431));
|
|
situationCondition.add(cArenaJoinSituationChecker::SITUATION_SIEGE_PLAYING, S(2432));
|
|
|
|
g_pCurrentGameSystem->isValidArenaJoinSituation(situationCondition);
|
|
}
|
|
|
|
void SUIArenaWaitingWnd::isValidArenaJoinSituationAtEndCount()
|
|
{
|
|
sArenaJoinSituationCondition situationCondition;
|
|
/// way
|
|
situationCondition.m_notificationWays = cArenaJoinSituationChecker::WAY_NOTIFICATION_WND;
|
|
/// situation
|
|
situationCondition.add(cArenaJoinSituationChecker::SITUATION_DEATH, S(2437));
|
|
situationCondition.add(cArenaJoinSituationChecker::SITUATION_TRADE, S(2438));
|
|
|
|
g_pCurrentGameSystem->isValidArenaJoinSituation(situationCondition);
|
|
}
|
|
|
|
void SUIArenaWaitingWnd::setData()
|
|
{
|
|
BattleArenaBase* base = GetBattleArenaDB().getData(g_pCurrentGameSystem->getArenaId());
|
|
/// 경기 타입
|
|
setMode(base->eType);
|
|
/// 인원 수
|
|
setMemberString(base->nMaxMember);
|
|
/// rank
|
|
setRank();
|
|
|
|
/// 배틀 인포 데이타를 아직 안 받았을 때, startTime으로 체크한다
|
|
sArenaSystem* arenaSystem = g_pCurrentGameSystem->getArenaSystem();
|
|
if (!arenaSystem->isRecvBattleInfo())
|
|
{
|
|
m_countDirecting.end();
|
|
|
|
std::string caption;
|
|
|
|
caption = "<font:font_01><size:9><#898989><b><top><hcenter>";
|
|
caption += SR<int>(2331, "#@least_num@#", base->nMinMember, "#@minutes@#", base->nCountDown/100);
|
|
m_helpStatic->SetCaption(caption.c_str());
|
|
|
|
XStringUtil::Format(caption, "<font:font_01><size:9><#898989><b><top><hcenter>%s", S(2433));
|
|
m_countStatic->SetCaption(caption.c_str());
|
|
}
|
|
}
|
|
|
|
void SUIArenaWaitingWnd::procMsgBattleInfo(SGameMessage* msg)
|
|
{
|
|
msg->bUse = true;
|
|
|
|
SMSG_BATTLE_ARENA_BATTLE_INFO* _msg = dynamicCast<SMSG_BATTLE_ARENA_BATTLE_INFO*>(msg);
|
|
|
|
sArenaSystem* arenaSystem = g_pCurrentGameSystem->getArenaSystem();
|
|
|
|
bool reconnect;
|
|
AR_TIME count = 0;
|
|
AR_TIME curTime = GetArTime();
|
|
if (_msg->startTime > curTime)
|
|
{
|
|
reconnect = false;
|
|
count = _msg->startTime - curTime;
|
|
}
|
|
else
|
|
{
|
|
reconnect = true;
|
|
count = RECONNECT_WAITING_TIME;
|
|
}
|
|
setTotalCount((float)count/100.0f);
|
|
/// member count
|
|
int memberCount = 0;
|
|
for (int i = 0; i < sArenaUtility::MAX_TEAM_NUM; ++i)
|
|
memberCount += _msg->playerCountPerTeam[i];
|
|
setMemberCount(memberCount);
|
|
///
|
|
setMyTeam(arenaSystem->getMyTeam());
|
|
startCounting();
|
|
setEnableStartButton(true);
|
|
setHelpText(reconnect);
|
|
|
|
/// procMsgJoinQueue에서 show를 하나, 카운트중에 참여 했을 때는 join queue가 안 날라오기 때문에 여기서 체크해준다
|
|
if (!IsShow())
|
|
m_pGameManager->PostMsgAtDynamic( new SIMSG_SHOW_UIWINDOW( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_ARENA_WAITING, true) );
|
|
}
|
|
|
|
void SUIArenaWaitingWnd::procMsgUpdateWaitUserCount(SGameMessage* msg)
|
|
{
|
|
msg->bUse = true;
|
|
|
|
sArenaSystem* arenaSystem = g_pCurrentGameSystem->getArenaSystem();
|
|
setMemberCount(arenaSystem->getWaitingUserCount());
|
|
}
|
|
|
|
void SUIArenaWaitingWnd::procMsgJoinQueue(SGameMessage* msg)
|
|
{
|
|
msg->bUse = true;
|
|
|
|
sArenaSystem* arenaSystem = g_pCurrentGameSystem->getArenaSystem();
|
|
setMemberCount(arenaSystem->getWaitingUserCount());
|
|
setEnableStartButton(false);
|
|
|
|
m_pGameManager->PostMsgAtDynamic( new SIMSG_SHOW_UIWINDOW( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_ARENA_WAITING, true) );
|
|
}
|
|
|
|
void SUIArenaWaitingWnd::procMsgJoinBattle(SGameMessage* msg)
|
|
{
|
|
msg->bUse = true;
|
|
updateMemberCount();
|
|
}
|
|
|
|
void SUIArenaWaitingWnd::procMsgLeave(SGameMessage* msg)
|
|
{
|
|
msg->bUse = true;
|
|
updateMemberCount();
|
|
}
|
|
|
|
void SUIArenaWaitingWnd::setMyTeam(int team)
|
|
{
|
|
sArenaUtility utility;
|
|
|
|
/// mark bg
|
|
KUIControlStatic* staticBgMark = dynamicCast<KUIControlStatic*>(GetChild("bg_mark_arena_alliance_01"));
|
|
staticBgMark->SetAniName(utility.getMenuRankBgAniName(team));
|
|
/// titlebar bg
|
|
KUIControlStatic* staticTitleBar = dynamicCast<KUIControlStatic*>(GetChild("bg_arena_titlebar_alliance_01"));
|
|
staticTitleBar->SetAniName(utility.getMenuTitleBgAniName(team));
|
|
}
|
|
|
|
void SUIArenaWaitingWnd::checkWaiting()
|
|
{
|
|
sArenaSystem* arenaSystem = g_pCurrentGameSystem->getArenaSystem();
|
|
if (arenaSystem->isPlaying())
|
|
{
|
|
if (IsShow())
|
|
m_pGameManager->PostMsgAtDynamic( new SIMSG_SHOW_UIWINDOW( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_ARENA_WAITING, false) );
|
|
}
|
|
}
|
|
|
|
void SUIArenaWaitingWnd::setHelpText(bool reconnect)
|
|
{
|
|
int countDown;
|
|
if (reconnect)
|
|
{
|
|
countDown = RECONNECT_WAITING_TIME;
|
|
}
|
|
else
|
|
{
|
|
BattleArenaBase* base = GetBattleArenaDB().getData(g_pCurrentGameSystem->getArenaId());
|
|
countDown = base->nCountDown;
|
|
}
|
|
std::string str = "<font:font_01><size:9><#898989><b><top><hcenter>";
|
|
str += SR<int>(2466, "#@minutes@#", countDown/100);
|
|
m_helpStatic->SetCaption(str.c_str());
|
|
}
|
|
|
|
void SUIArenaWaitingWnd::setDefaultMyTeam()
|
|
{
|
|
sArenaSystem* arenaSystem = g_pCurrentGameSystem->getArenaSystem();
|
|
/// battle info를 받았으면 이미 팀 설정을 했다는 뜻이다.
|
|
if (arenaSystem->isRecvBattleInfo())
|
|
return ;
|
|
|
|
setMyTeam(sArenaUtility::TEAM_NONE);
|
|
}
|