#include "stdafx.h" #include "Arena\\ArenaJoinSituationChecker.h" #include "SUIArenaPracticeWaitingWnd.h" #include "Arena\\ArenaSystem.h" #include "SUIArenaGuideTooltipWnd.h" //#include "SGameMessageUI.h" #include "KUIControlButton.h" #include "SMessengerMgr.h" #include "KUIControlStatic.h" #include "SGameManager.h" #include "SGameInterface.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; SUIArenaPracticeWaitingWnd::SUIArenaPracticeWaitingWnd(SGameManager* gameManager) : SUIWnd(gameManager) { } SUIArenaPracticeWaitingWnd::~SUIArenaPracticeWaitingWnd() { } bool SUIArenaPracticeWaitingWnd::InitData(bool reload) { initFp(); getWndInfo(); initTooltip(); return SUIWnd::InitData(reload); } void SUIArenaPracticeWaitingWnd::initFp() { m_controlFp.add("button_arena_ready_01", &SUIArenaPracticeWaitingWnd::prepareComplete); m_controlFp.add("button_arena_start_01", &SUIArenaPracticeWaitingWnd::start); m_msgFp.add(MSG_BATTLE_ARENA_BATTLE_INFO, &SUIArenaPracticeWaitingWnd::procMsgBattleInfo); m_msgFp.add(MSG_BATTLE_ARENA_UPDATE_WAIT_USER_COUNT, &SUIArenaPracticeWaitingWnd::procMsgUpdateWaitUserCount); m_msgFp.add(MSG_BATTLE_ARENA_EXERCISE_READY_STATUS, &SUIArenaPracticeWaitingWnd::procMsgExerciseReadyStatus); m_msgFp.add(MSG_BATTLE_ARENA_LEAVE, &SUIArenaPracticeWaitingWnd::procMsgLeave); m_msgFp.add(MSG_BATTLE_ARENA_JOIN_BATTLE, &SUIArenaPracticeWaitingWnd::procMsgJoinBattle); m_msgFp.add(MSG_BATTLE_ARENA_PROMOTE, &SUIArenaPracticeWaitingWnd::procMsgPromote); } void SUIArenaPracticeWaitingWnd::initTooltip() { SetChildTooltip("mark_arena_mode_01", S(2317)); SetChildTooltip("mark_arena_vs_01", S(2318)); SetChildTooltip("mark_arena_current_01", S(2399)); SetChildTooltip("mark_arena_map_01", S(2319)); SetChildTooltip("mark_arena_time_01", S(2320)); } void SUIArenaPracticeWaitingWnd::getWndInfo() { m_emptyControlRegionChecker.add(GetChild("area_control")); m_buttonComplete = dynamicCast(GetChild("button_arena_ready_01")); m_buttonStart = dynamicCast(GetChild("button_arena_start_01")); m_staticComplete = dynamicCast(GetChild("text_button_ready_01")); m_staticStart = dynamicCast(GetChild("text_button_start_01")); m_staticComplete->SetDisableColor("<#a0a0a0>"); m_staticComplete->SetEnableColor("<#ffffff>"); m_staticComplete->SetEnableOption(true); m_staticStart->SetDisableColor("<#a0a0a0>"); m_staticStart->SetEnableColor("<#ffffff>"); m_staticStart->SetEnableOption(true); } void SUIArenaPracticeWaitingWnd::setRank() { sArenaRankInfo rankInfo; rankInfo.setRank(GetChild("mark_rookie")); } void SUIArenaPracticeWaitingWnd::syncPos() { SUIWnd* menuWnd = m_pGameManager->GetSUI(SIMSG_TOGGLE_UIWINDOW::UIWINDOW_MAINMENU); if (menuWnd) MovePos(menuWnd->GetRect().left, menuWnd->GetRect().top - GetRect().GetHeight()); } void SUIArenaPracticeWaitingWnd::OnNotifyUIWindowOpen(bool bOpen, bool bLimitWnd) { if (bOpen) { syncPos(); setRank(); /// 알림창은 아레나 메뉴보다 위로 오게 해준다 m_pGameManager->PostMsgAtDynamic( new SIMSG_UI_LIST_MOVE_FORCE_BACK( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_NOTIFICATION ) ); } else { m_pGameManager->PostMsgAtDynamic( new SIMSG_SHOW_UIWINDOW( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_ARENA_GUIDE_TOOLTIP, false) ); } postUpdateMainMenuButton(); } void SUIArenaPracticeWaitingWnd::Process(DWORD dwTime) { SUIWnd::Process(dwTime); checkWaiting(); procGuideTooltip(); } void SUIArenaPracticeWaitingWnd::postUpdateMainMenuButton() { m_pGameManager->PostMsgAtDynamic( new SIMSG_UPDATE_MAIN_MENU_BUTTON()); } void SUIArenaPracticeWaitingWnd::ProcMsgAtStatic( SGameMessage* msg ) { m_msgFp.call(msg->nType, this, msg); } void SUIArenaPracticeWaitingWnd::PumpUpMessage( LPCTSTR controlID, DWORD msg, DWORD lparam, DWORD wparam ) { switch (msg) { case KUI_MESSAGE::KBUTTON_CLICK: m_controlFp.call(controlID, this); break; } } DWORD SUIArenaPracticeWaitingWnd::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 SUIArenaPracticeWaitingWnd::setRule(int type) { SetChildCaptionFormat(GetChild("text_select_01"), "<#898989>%d", type); } void SUIArenaPracticeWaitingWnd::setTeam(int type) { SetChildCaptionFormat(GetChild("text_select_02"), "<#898989>%d", type); } void SUIArenaPracticeWaitingWnd::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 SUIArenaPracticeWaitingWnd::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); SetChildCaptionFormat(GetChild("text_current_member_01"), "%s%d<#ffffff>/%d", curMemberColor, curMember, maxMember); } void SUIArenaPracticeWaitingWnd::setStadium() { /// 현재 연습 경기장이 한개라서 정보가 따로 없다, 우선 한개로 설정함 SetChildCaptionFormat(GetChild("text_select_03"), "<#898989>%s", S(2476)); } void SUIArenaPracticeWaitingWnd::setTime(int type) { SetChildCaptionFormat(GetChild("text_select_04"), "<#898989>%d", type); } void SUIArenaPracticeWaitingWnd::prepareComplete() { sArenaSystem* arenaSystem = g_pCurrentGameSystem->getArenaSystem(); int myTeam = arenaSystem->getMyTeam(); TS_CS_BATTLE_ARENA_EXERCISE_READY msg; msg.bReady = !arenaSystem->isReady(myTeam); m_pGameManager->PendMessage(&msg); } void SUIArenaPracticeWaitingWnd::start() { if (!isValidArenaJoinSituation()) return ; TS_CS_BATTLE_ARENA_EXERCISE_START msg; m_pGameManager->PendMessage(&msg); } bool SUIArenaPracticeWaitingWnd::isValidArenaJoinSituation() { sArenaJoinSituationCondition situationCondition; /// way situationCondition.m_notificationWays = cArenaJoinSituationChecker::WAY_CENTER_NOTICE; /// situation situationCondition.add(cArenaJoinSituationChecker::SITUATION_DEATH, S(2458)); situationCondition.add(cArenaJoinSituationChecker::SITUATION_TRADE, S(2459)); return g_pCurrentGameSystem->isValidArenaJoinSituation(situationCondition); } void SUIArenaPracticeWaitingWnd::procMsgBattleInfo(SGameMessage* msg) { msg->bUse = true; sArenaSystem* arenaSystem = g_pCurrentGameSystem->getArenaSystem(); setMyTeam(arenaSystem->getMyTeam()); /// member count updateMemberCount(); setStadium(); /// updateStartButtonStatus(); m_pGameManager->PostMsgAtDynamic( new SIMSG_SHOW_UIWINDOW( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_ARENA_PRACTICE_WAITING, true) ); } void SUIArenaPracticeWaitingWnd::procMsgUpdateWaitUserCount(SGameMessage* msg) { msg->bUse = true; SMSG_BATTLE_ARENA_UPDATE_WAIT_USER_COUNT* _msg = dynamicCast(msg); setMemberCount(_msg->waitUserCount); } void SUIArenaPracticeWaitingWnd::procMsgExerciseReadyStatus(SGameMessage* msg) { msg->bUse = true; updateStartButtonStatus();; } void SUIArenaPracticeWaitingWnd::procMsgJoinBattle(SGameMessage* msg) { msg->bUse = true; updateMemberCount(); } void SUIArenaPracticeWaitingWnd::procMsgLeave(SGameMessage* msg) { msg->bUse = true; updateStartButtonStatus(); updateMemberCount(); } void SUIArenaPracticeWaitingWnd::procMsgPromote(SGameMessage* msg) { msg->bUse = true; updateStartButtonStatus(); } void SUIArenaPracticeWaitingWnd::setMyTeam(int team) { if (sArenaUtility::TEAM_NONE > team) return ; sArenaUtility utility; /// mark bg KUIControlStatic* staticBgMark = dynamicCast(GetChild("bg_mark_arena_alliance_01")); staticBgMark->SetAniName(utility.getMenuRankBgAniName(team)); /// titlebar bg KUIControlStatic* staticTitleBar = dynamicCast(GetChild("bg_arena_titlebar_alliance_01")); staticTitleBar->SetAniName(utility.getMenuTitleBgAniName(team)); } void SUIArenaPracticeWaitingWnd::updateStartButtonStatus() { sArenaSystem* arenaSystem = g_pCurrentGameSystem->getArenaSystem(); int myTeam = arenaSystem->getMyTeam(); bool isUnitLeader = m_PartyMgr.IsPartyLeader(); bool _isMyReady = arenaSystem->isReady(myTeam); bool _isAllReady = isAllReady(); bool enableCompleteButton = false; bool enableStart = false; bool enableEnd = true; bool pushComplete = false; std::string strComplete = S(2321); ///준비완료 std::string strStart = S(2322); ///시작 int myPlayerCount = arenaSystem->getPlayerCount(myTeam); /// 원래는 0이 아니고 1이어야 한다 if (MIN_ENABLE_COMPLETE_PLAYER_NUM <= myPlayerCount) { /// 연합군 if (sArenaUtility::TEAM_ALLIANCE == myTeam) { /// 방장 if (isUnitLeader) { enableCompleteButton = true; if (_isMyReady) { strComplete = S(2477); enableEnd = false; } if (_isAllReady) { enableStart = true; } } else { strComplete = S(2324); ///준비중 pushComplete = true; if (_isMyReady) { enableEnd = false; } if (_isAllReady) { strComplete = S(2321); /// 준비완료 strStart = S(2325); /// 시작예정 } } } /// 마녀군 else if (sArenaUtility::TEAM_WITCH == myTeam) { /// 파티장 if (isUnitLeader) { enableCompleteButton = true; if (_isMyReady) { strComplete = S(2477); enableEnd = false; } if (_isAllReady) { strStart = S(2325); ///시작예정 } } else { strComplete = S(2324); ///준비중 pushComplete = true; if (_isMyReady) { enableEnd = false; } if (_isAllReady) { strComplete = S(2321); ///준비완료 strStart = S(2325); ///시작예정 } } } } std::string caption; /// static complete XStringUtil::Format(caption, "<#cccccc><@252525>%s", strComplete.c_str()); m_staticComplete->SetCaption(caption.c_str()); /// static start XStringUtil::Format(caption, "<#cccccc><@252525>%s", strStart.c_str()); m_staticStart->SetCaption(caption.c_str()); if (enableCompleteButton) { if (pushComplete) m_buttonComplete->DisableAndButtonState(KUIControlSimpleButton::KBUTTON_DOWN); else m_buttonComplete->Enable(); m_staticComplete->Enable(); } else { if (pushComplete) m_buttonComplete->DisableAndButtonState(KUIControlSimpleButton::KBUTTON_DOWN); else m_buttonComplete->Disable(); m_staticComplete->Disable(); } if (enableStart) { m_buttonStart->Enable(); m_staticStart->Enable(); } else { m_buttonStart->Disable(); m_staticStart->Disable(); } /// exit button m_pGameManager->PostMsgAtDynamic( new SIMSG_UI_SEND_DATA(SIMSG_TOGGLE_UIWINDOW::UIWINDOW_MAINMENU, "enable_exit", enableEnd ? 1 : 0) ); } bool SUIArenaPracticeWaitingWnd::isAllReady() { sArenaSystem* arenaSystem = g_pCurrentGameSystem->getArenaSystem(); int myTeam = arenaSystem->getMyTeam(); int opponentTeam = arenaSystem->getOpponentTeam(); if (!arenaSystem->isReady(myTeam)) return false; if (!arenaSystem->isReady(opponentTeam)) return false; return true; } void SUIArenaPracticeWaitingWnd::checkWaiting() { sArenaSystem* arenaSystem = g_pCurrentGameSystem->getArenaSystem(); if (arenaSystem->isPlaying()) { if (IsShow()) m_pGameManager->PostMsgAtDynamic( new SIMSG_SHOW_UIWINDOW( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_ARENA_PRACTICE_WAITING, false)); } } /// 가이드 툴팁이 HIDE 상태라서 process가 호출 되지 않는다. 그래서 void SUIArenaPracticeWaitingWnd::procGuideTooltip() { int wndId = SIMSG_TOGGLE_UIWINDOW::UIWINDOW_ARENA_GUIDE_TOOLTIP; SUIArenaGuideTooltipWnd* guideTooltip = dynamicCast(m_pGameManager->GetSUI(wndId)); if (!guideTooltip) return ; guideTooltip->procCheckGuideType(); }