302 lines
8.1 KiB
C++
302 lines
8.1 KiB
C++
#include "stdafx.h"
|
|
#include "Arena\\ArenaJoinSituationChecker.h"
|
|
#include "Arena\\ArenaSystem.h"
|
|
#include "SUIArenaMenuWnd.h"
|
|
//#include "SGameMessageUI.h"
|
|
#include "SGameManager.h"
|
|
#include "SGameMessage.h"
|
|
#include "SGameAvatarEx.h"
|
|
#include "SPlayerInfoMgr.h"
|
|
#include "ArenaRankInfo.h"
|
|
#include "SGameSystem.h"
|
|
#include "CommonUtil.h"
|
|
#include "ErrorCode/ErrorCode.h"
|
|
#include "SStringDB.h"
|
|
|
|
extern SGameSystem * g_pCurrentGameSystem;
|
|
|
|
SUIArenaMenuWnd::SUIArenaMenuWnd(SGameManager* gameManager) : SUIWnd(gameManager)
|
|
{
|
|
}
|
|
|
|
SUIArenaMenuWnd::~SUIArenaMenuWnd()
|
|
{
|
|
}
|
|
|
|
bool SUIArenaMenuWnd::InitData(bool reload)
|
|
{
|
|
initFp();
|
|
initTooltip();
|
|
getWndInfo();
|
|
m_sendChangeAlias = false;
|
|
|
|
return SUIWnd::InitData(reload);
|
|
}
|
|
|
|
void SUIArenaMenuWnd::initFp()
|
|
{
|
|
/// control fp
|
|
m_controlFp.add("button_close", &SUIArenaMenuWnd::close);
|
|
m_controlFp.add("button_arena_quick_01", &SUIArenaMenuWnd::fastEnter);
|
|
m_controlFp.add("button_arena_select_01", &SUIArenaMenuWnd::selectionEnter);
|
|
m_controlFp.add("button_arena_practice_01", &SUIArenaMenuWnd::practiceEnter);
|
|
m_controlFp.add("button_name_change", &SUIArenaMenuWnd::changeAlias);
|
|
m_controlFp.add("button_name_remove_01", &SUIArenaMenuWnd::removeAlias);
|
|
|
|
/// msg fp
|
|
m_msgFp.add(IMSG_UI_INPUTTEXT, &SUIArenaMenuWnd::procMsgChangeAlias);
|
|
m_msgFp.add(MSG_BATTLE_ARENA_JOIN_QUEUE, &SUIArenaMenuWnd::procMsgJoinQueue);
|
|
m_msgFp.add(MSG_BATTLE_ARENA_BATTLE_INFO, &SUIArenaMenuWnd::procMsgBattleInfo);
|
|
m_msgFp.add(MSG_RESULT, &SUIArenaMenuWnd::procMsgResult);
|
|
m_msgFp.add(MSG_PROPERTY, &SUIArenaMenuWnd::procMsgProperty);
|
|
}
|
|
|
|
void SUIArenaMenuWnd::initTooltip()
|
|
{
|
|
SetChildTooltip("button_name_change", S(2368));
|
|
SetChildTooltip("button_arena_quick_01", S(2369));
|
|
SetChildTooltip("button_arena_select_01", S(2370));
|
|
SetChildTooltip("button_arena_practice_01", S(2371));
|
|
}
|
|
|
|
void SUIArenaMenuWnd::getWndInfo()
|
|
{
|
|
/// add empty control
|
|
m_emptyControlRegionChecker.add(GetChild("area_control"));
|
|
}
|
|
|
|
void SUIArenaMenuWnd::ProcMsgAtStatic( SGameMessage* msg )
|
|
{
|
|
m_msgFp.call(msg->nType, this, msg);
|
|
}
|
|
|
|
void SUIArenaMenuWnd::PumpUpMessage( LPCTSTR controlID, DWORD msg, DWORD lparam, DWORD wparam )
|
|
{
|
|
switch (msg)
|
|
{
|
|
case KUI_MESSAGE::KBUTTON_CLICK: m_controlFp.call(controlID, this); break;
|
|
}
|
|
}
|
|
|
|
void SUIArenaMenuWnd::OnNotifyUIWindowOpen(bool bOpen, bool bLimitWnd)
|
|
{
|
|
if (bOpen)
|
|
{
|
|
syncPos();
|
|
setRank();
|
|
|
|
/// 알림창은 아레나 메뉴보다 위로 오게 해준다
|
|
m_pGameManager->PostMsgAtDynamic( new SIMSG_UI_LIST_MOVE_FORCE_BACK( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_NOTIFICATION ) );
|
|
}
|
|
postUpdateMainMenuButton();
|
|
}
|
|
|
|
void SUIArenaMenuWnd::postUpdateMainMenuButton()
|
|
{
|
|
m_pGameManager->PostMsgAtDynamic( new SIMSG_UPDATE_MAIN_MENU_BUTTON());
|
|
}
|
|
|
|
DWORD SUIArenaMenuWnd::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 SUIArenaMenuWnd::syncPos()
|
|
{
|
|
SUIWnd* menuWnd = m_pGameManager->GetSUI(SIMSG_TOGGLE_UIWINDOW::UIWINDOW_MAINMENU);
|
|
if (menuWnd)
|
|
MovePos(menuWnd->GetRect().left, menuWnd->GetRect().top - GetRect().GetHeight());
|
|
}
|
|
|
|
void SUIArenaMenuWnd::close()
|
|
{
|
|
m_pGameManager->PostMsgAtDynamic( new SIMSG_SHOW_UIWINDOW( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_ARENA_MENU, false) );
|
|
}
|
|
|
|
void SUIArenaMenuWnd::fastEnter()
|
|
{
|
|
if (checkEnterBlockTime())
|
|
return ;
|
|
|
|
sArenaSystem* arenaSystem = g_pCurrentGameSystem->getArenaSystem();
|
|
arenaSystem->clear();
|
|
|
|
/// pend message
|
|
TS_CS_BATTLE_ARENA_JOIN_QUEUE msg;
|
|
msg.nArenaID = 0;
|
|
m_pGameManager->PendMessage(&msg);
|
|
}
|
|
|
|
void SUIArenaMenuWnd::selectionEnter()
|
|
{
|
|
if (checkEnterBlockTime())
|
|
return ;
|
|
|
|
if (!isValidArenaJoinSituation())
|
|
return ;
|
|
|
|
close();
|
|
m_pGameManager->PostMsgAtDynamic( new SIMSG_SHOW_UIWINDOW( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_ARENA_SELECTION_READY, true) );
|
|
}
|
|
|
|
void SUIArenaMenuWnd::practiceEnter()
|
|
{
|
|
if (!isValidArenaJoinSituation())
|
|
return ;
|
|
|
|
close();
|
|
m_pGameManager->PostMsgAtDynamic( new SIMSG_SHOW_UIWINDOW( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_ARENA_PRACTICE_READY, true) );
|
|
}
|
|
|
|
void SUIArenaMenuWnd::changeAlias()
|
|
{
|
|
m_pGameManager->PostMsgAtDynamic( new SIMSG_UI_REQ_INPUTTEXT( SIMSG_UI_REQ_INPUTTEXT::USAGE_ARENA_CHANGE_PLAYER_NAME,
|
|
SIMSG_TOGGLE_UIWINDOW::UIWINDOW_ARENA_MENU,
|
|
S(2404), 2303, 11 ) );
|
|
|
|
///
|
|
sArenaJoinSituationCondition situationCondition;
|
|
situationCondition.m_notificationWays = cArenaJoinSituationChecker::WAY_NOTIFICATION_WND;
|
|
situationCondition.addNone(S(2403), false);
|
|
g_pCurrentGameSystem->isValidArenaJoinSituation(situationCondition);
|
|
}
|
|
|
|
void SUIArenaMenuWnd::removeAlias()
|
|
{
|
|
sendChangeAliasMsg("");
|
|
}
|
|
|
|
void SUIArenaMenuWnd::setAlias(char const* alias)
|
|
{
|
|
assert(!alias && "changed player name is null");
|
|
|
|
KUIWnd* wnd = GetChild("text_arena_titlebar_default_03");
|
|
assert(!wnd && "failed get changed player name static control");
|
|
wnd->SetCaption(alias);
|
|
}
|
|
|
|
void SUIArenaMenuWnd::setRank()
|
|
{
|
|
sArenaRankInfo rankInfo;
|
|
rankInfo.setRank(GetChild("mark_rookie"));
|
|
}
|
|
|
|
void SUIArenaMenuWnd::procMsgChangeAlias(SGameMessage* msg)
|
|
{
|
|
msg->bUse = true;
|
|
|
|
SIMSG_UI_INPUTTEXT* inputMsg = dynamicCast<SIMSG_UI_INPUTTEXT*>(msg);
|
|
if (inputMsg->m_strText.empty())
|
|
return ;
|
|
|
|
if (SIMSG_UI_REQ_INPUTTEXT::USAGE_ARENA_CHANGE_PLAYER_NAME == inputMsg->m_nUsage)
|
|
{
|
|
sendChangeAliasMsg(inputMsg->m_strText.c_str());
|
|
}
|
|
}
|
|
|
|
void SUIArenaMenuWnd::procMsgJoinQueue(SGameMessage* msg)
|
|
{
|
|
msg->bUse = true;
|
|
/// 빠른 입장을 고려해서 넣어둠, 선택/연습은 버튼 클릭할 때 close를 하므로 상관이 없다
|
|
close();
|
|
}
|
|
|
|
void SUIArenaMenuWnd::procMsgBattleInfo(SGameMessage* msg)
|
|
{
|
|
msg->bUse = true;
|
|
/// 빠른 입장을 고려해서 넣어둠, 선택/연습은 버튼 클릭할 때 close를 하므로 상관이 없다
|
|
close();
|
|
}
|
|
|
|
void SUIArenaMenuWnd::procMsgResult(SGameMessage* msg)
|
|
{
|
|
msg->bUse = true;
|
|
SMSG_RESULT* _msg = dynamicCast<SMSG_RESULT*>(msg);
|
|
if (TM_CS_CHANGE_ALIAS == _msg->request_msg_id)
|
|
{
|
|
m_sendChangeAlias = false;
|
|
if (RESULT_SUCCESS == _msg->result)
|
|
{
|
|
m_pGameManager->PostMsgAtDynamic( new SIMSG_SHOW_UIWINDOW( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_INPUTTEXT, false ) );
|
|
}
|
|
/// 지정된 가명이 최소 길이(4바이트) 미만일 경우
|
|
else if (RESULT_LIMIT_MIN == _msg->result)
|
|
{
|
|
m_pGameManager->PostMsgAtDynamic( new SIMSG_REQ_OPEN_MSGBOX(SIMSG_REQ_OPEN_MSGBOX::MSGBOX_GENERAL, S(2498), false) );
|
|
}
|
|
/// 지정된 가명이 최대 길이(17바이트)를 초과하는 경우
|
|
else if (RESULT_LIMIT_MAX == _msg->result)
|
|
{
|
|
m_pGameManager->PostMsgAtDynamic( new SIMSG_REQ_OPEN_MSGBOX(SIMSG_REQ_OPEN_MSGBOX::MSGBOX_GENERAL, S(128), false) );
|
|
}
|
|
else
|
|
{
|
|
m_pGameManager->PostMsgAtDynamic( new SIMSG_REQ_OPEN_MSGBOX(SIMSG_REQ_OPEN_MSGBOX::MSGBOX_GENERAL, S(128), false) );
|
|
}
|
|
}
|
|
}
|
|
|
|
void SUIArenaMenuWnd::procMsgProperty(SGameMessage* msg)
|
|
{
|
|
msg->bUse = true;
|
|
SMSG_PROPERTY* _msg = dynamicCast<SMSG_PROPERTY*>(msg);
|
|
if (SMSG_PROPERTY::PROPERTY_ALIAS == _msg->nPropertyType)
|
|
{
|
|
updateAlias();
|
|
}
|
|
}
|
|
|
|
bool SUIArenaMenuWnd::isValidArenaJoinSituation()
|
|
{
|
|
sArenaJoinSituationCondition situationCondition;
|
|
/// way
|
|
situationCondition.m_notificationWays = cArenaJoinSituationChecker::WAY_NOTIFICATION_WND;
|
|
/// situation
|
|
situationCondition.add(cArenaJoinSituationChecker::SITUATION_DEATH, S(2423));
|
|
situationCondition.add(cArenaJoinSituationChecker::SITUATION_TRADE, S(2424));
|
|
|
|
return g_pCurrentGameSystem->isValidArenaJoinSituation(situationCondition);
|
|
}
|
|
|
|
bool SUIArenaMenuWnd::checkEnterBlockTime()
|
|
{
|
|
sArenaSystem* arenaSystem = g_pCurrentGameSystem->getArenaSystem();
|
|
int blockTime = arenaSystem->getBlockTime();
|
|
if (0 < blockTime)
|
|
{
|
|
m_pGameManager->PostMsgAtDynamic(new SMSG_SEND_DATA(2420, "open_panelty_message_box", blockTime,
|
|
arenaSystem->getPenaltyCount(),
|
|
arenaSystem->getPenaltyCountTime(),
|
|
""));
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
void SUIArenaMenuWnd::sendChangeAliasMsg(char const* alias)
|
|
{
|
|
if (m_sendChangeAlias)
|
|
return ;
|
|
|
|
m_sendChangeAlias = true;
|
|
|
|
TS_CS_CHANGE_ALIAS msg;
|
|
int len = 18;
|
|
strncpy(msg.alias, alias, len);
|
|
msg.alias[len] = 0x00;
|
|
|
|
m_pGameManager->PendMessage(&msg);
|
|
}
|
|
|
|
void SUIArenaMenuWnd::updateAlias()
|
|
{
|
|
setAlias(m_PlayerInfoMgr.GetAlias());
|
|
}
|