#include "stdafx.h" #include "Arena\\ArenaJoinSituationChecker.h" #include "SGameWorldKeymapping.h" #include "Arena\\ArenaSystem.h" #include "SUIArenaGameWnd.h" //#include "SGameMessageUI.h" #include "KUIControlButton.h" #include "SGameManager.h" #include "SBattleArenaDB.h" #include "SGameAvatarEx.h" #include "ArenaRankInfo.h" #include "SGameSystem.h" #include "CommonUtil.h" #include "SStringDB.h" #include "SUIDefine.h" extern SGameSystem* g_pCurrentGameSystem; void sOpacityInfo::addHideControl(KUIWnd* wnd) { m_hideList.push_back(wnd); } void sOpacityInfo::toggleOpacity() { setOpacity(!m_isOpacity); } void sOpacityInfo::initialize(SUIWnd* parent) { m_opacityButton = dynamicCast(parent->GetChild("button_window_opacity_01")); m_statusButton = dynamicCast(parent->GetChild("button_status_01")); m_inviteButton = dynamicCast(parent->GetChild("button_member_invite_witch_01")); m_titleOpacity = parent->GetChild("titlebar_opacity_01"); m_timeOpacity = parent->GetChild("layout_time_opacity_01"); addHideControl(parent->GetChild("titlebar")); addHideControl(parent->GetChild("mark_rookie")); addHideControl(parent->GetChild("bg_mark_arena_alliance_01")); addHideControl(parent->GetChild("text_01")); addHideControl(parent->GetChild("layout_bg_01")); addHideControl(parent->GetChild("outframe")); addHideControl(parent->GetChild("text_02")); addHideControl(parent->GetChild("text_03")); addHideControl(parent->GetChild("inframe01")); addHideControl(parent->GetChild("text_04")); addHideControl(parent->GetChild("text_05")); addHideControl(parent->GetChild("mark_dive_01")); addHideControl(parent->GetChild("mark_score_100_01")); addHideControl(parent->GetChild("mark_score_100_02")); } bool sOpacityInfo::checkIsInButton(int x, int y) { if (isOpacity()) return true; if (m_opacityButton->IsInRect(x, y)) return true; else m_opacityButton->SetButtonState(KUIControlSimpleButton::KBUTTON_NORMAL); if (m_statusButton->IsInRect(x, y)) return true; else m_statusButton->SetButtonState(KUIControlSimpleButton::KBUTTON_NORMAL); if (m_inviteButton) { if (m_inviteButton->IsInRect(x, y)) return true; else m_inviteButton->SetButtonState(KUIControlSimpleButton::KBUTTON_NORMAL); } return false; } void sOpacityInfo::setOpacity(bool opacity) { m_isOpacity = opacity; m_opacityButton->SetAniName(opacity ? "common_button_titanium_unlock" : "common_button_titanium_lock"); setShowHideList(opacity ? true : false); m_titleOpacity->SetShow(opacity ? false : true); m_timeOpacity->SetShow(opacity ? false : true); } void sOpacityInfo::setShowHideList(bool show) { std::list::iterator it = m_hideList.begin(); for (; it != m_hideList.end(); ++it) { (*it)->SetShow(show); } } SUIArenaGameWnd::SUIArenaGameWnd(SGameManager* gameManager) : SUIWnd(gameManager), m_isPlaying(false), m_isEnd(false) { } SUIArenaGameWnd::~SUIArenaGameWnd() { } bool SUIArenaGameWnd::InitControls(KPoint kPos) { bool ret = SUIWnd::InitControls(kPos); KUIWnd* wnd = GetChild("titlebar"); if (wnd) { SetCustomMovingRect(KRect(0, 0, wnd->GetRect().GetWidth(), wnd->GetRect().GetHeight())); } return ret; } bool SUIArenaGameWnd::InitData(bool reload) { initFp(); getWndInfo(); initOpacityInfo(); return SUIWnd::InitData(reload); } void SUIArenaGameWnd::Process(DWORD dwTime) { SUIWnd::Process(dwTime); checkGameStart(); procRemainTime(); procCenterCount(); } void SUIArenaGameWnd::ProcMsgAtStatic(SGameMessage* msg) { m_msgFp.call(msg->nType, this, msg); } void SUIArenaGameWnd::procMsgBattleInfo(SGameMessage* msg) { msg->bUse = true; resetData(); SMSG_BATTLE_ARENA_BATTLE_INFO* _msg = dynamicCast(msg); sArenaSystem* arenaSystem = g_pCurrentGameSystem->getArenaSystem(); checkGameStart(); /// set team updateMyTeam(); /// member count updateMemberCount(); /// set remainTime, checkGameStart()가 먼저 호출 되어야 한다 int remainTime = 0; if (m_isPlaying) { if (arenaSystem->getEndTime() > GetArTime()) remainTime = (arenaSystem->getEndTime() - GetArTime())/100; } else { BattleArenaBase* base = GetBattleArenaDB().getData(_msg->arenaId); if (base) remainTime = base->nBattleDuration/100; } setRemainTime(remainTime); setPartyTitleBarArenaInfo(); m_isEnd = false; if (!IsShow()) setShow(true); } void SUIArenaGameWnd::procMsgBattleScore(SGameMessage* msg) { msg->bUse = true; updateScore(); } void SUIArenaGameWnd::procMsgJoinBattle(SGameMessage* msg) { msg->bUse = true; updateMemberCount(); } void SUIArenaGameWnd::procMsgReconnectBattle(SGameMessage* msg) { msg->bUse = true; } void SUIArenaGameWnd::procMsgLeave(SGameMessage* msg) { msg->bUse = true; updateMemberCount(); /// leave가 자신일 경우에는 end = true로 해준다(아레나에서 워프를 했을 때, result는 안 날라오고, leave만 날라오는데 /// leave를 받을 때, hideAll을 해주는데, 워프가 끝나고 다시 게임창이 show가 되기 때문에, 그때 체크하기 위해서이다. SMSG_BATTLE_ARENA_LEAVE* _msg = dynamicCast(msg); SGameAvatarEx* localPlayer = g_pCurrentGameSystem->GetLocalPlayer(); if (!localPlayer) return ; if (stricmp(localPlayer->GetName(), _msg->name) == 0) m_isEnd = true; } void SUIArenaGameWnd::procMsgResult(SGameMessage* msg) { msg->bUse = true; m_isEnd = true; } void SUIArenaGameWnd::procMsgHotKeyEx(SGameMessage* msg) { if (!IsShow()) return ; if(GetGameKeymapping().GetHotKeyState(HOTKEYCODE::ARENASCORE) == KEYSTATE::DOWN) { /// 경기 결과를 받은 경우에는 토글을 시키지 않는다 if (!m_isEnd) toggleResult(); } } void SUIArenaGameWnd::procMsgLogin(SGameMessage* msg) { sArenaSystem* arenaSystem = g_pCurrentGameSystem->getArenaSystem(); if (!arenaSystem->isRecvBattleInfo()) return ; updateScore(); } void SUIArenaGameWnd::updateMemberCount() { sArenaSystem* arenaSystem = g_pCurrentGameSystem->getArenaSystem(); int myTeam = arenaSystem->getMyTeam(); int opponentTeam = arenaSystem->getOpponentTeam(); setMyTeamMemberCount(arenaSystem->getPlayerCount(myTeam)); setOpponentTeamMemberCount(arenaSystem->getPlayerCount(opponentTeam)); } void SUIArenaGameWnd::procRemainTime() { if (!m_isPlaying) return ; sArenaSystem* arenaSystem = g_pCurrentGameSystem->getArenaSystem(); int remainTime = 0; if (arenaSystem->getEndTime() > GetArTime()) remainTime = (arenaSystem->getEndTime() - GetArTime())/100; setRemainTime(remainTime); } void SUIArenaGameWnd::initFp() { /// control fp m_controlFp.add("button_window_opacity_01", &SUIArenaGameWnd::toggleOpacity); m_controlFp.add("button_member_invite_witch_01", &SUIArenaGameWnd::inviteTeam); m_controlFp.add("button_status_01", &SUIArenaGameWnd::toggleResult); /// msg fp m_msgFp.add(IMSG_UI_INPUTTEXT, &SUIArenaGameWnd::procMsgInviteTeam); m_msgFp.add(MSG_BATTLE_ARENA_BATTLE_INFO, &SUIArenaGameWnd::procMsgBattleInfo); m_msgFp.add(MSG_BATTLE_ARENA_BATTLE_STATUS, &SUIArenaGameWnd::procMsgBattleStatus); m_msgFp.add(MSG_BATTLE_ARENA_BATTLE_SCORE, &SUIArenaGameWnd::procMsgBattleScore); m_msgFp.add(MSG_BATTLE_ARENA_JOIN_BATTLE, &SUIArenaGameWnd::procMsgJoinBattle); m_msgFp.add(MSG_BATTLE_ARENA_RECONNECT_BATTLE, &SUIArenaGameWnd::procMsgReconnectBattle); m_msgFp.add(MSG_BATTLE_ARENA_LEAVE, &SUIArenaGameWnd::procMsgLeave); m_msgFp.add(MSG_BATTLE_ARENA_PROMOTE, &SUIArenaGameWnd::procMsgPromote); m_msgFp.add(MSG_BATTLE_ARENA_RESULT, &SUIArenaGameWnd::procMsgResult); m_msgFp.add(IMSG_HOTKEY_EX, &SUIArenaGameWnd::procMsgHotKeyEx); m_msgFp.add(MSG_LOGIN, &SUIArenaGameWnd::procMsgLogin); } void SUIArenaGameWnd::getWndInfo() { m_wndMyKillCount = GetChild("text_kill_01"); m_wndMyDeathCount = GetChild("text_death_01"); m_wndMyTeamScore = GetChild("text_score_alliance_01"); m_wndOpponentTeamScore = GetChild("text_score_witch_01"); m_wndTime = dynamicCast(GetChild("text_time_01")); m_wndMyTeamGaugeScoreNumber = GetChild("text_gauge_score_alliance_01"); m_wndOpponentTeamGaugeScoreNumber = GetChild("text_gauge_score_witch_01"); m_gaugeMyTeamScore = dynamicCast(GetChild("gauge_score_alliance_01")); m_gaugeOpponentTeamScore = dynamicCast(GetChild("gauge_score_witch_01")); if( m_gaugeMyTeamScore ) m_gaugeMyTeamScore->SetMax( MAX_GAUGE_SCORE ); if( m_gaugeOpponentTeamScore ) m_gaugeOpponentTeamScore->SetMax( MAX_GAUGE_SCORE ); } void SUIArenaGameWnd::initOpacityInfo() { m_opacityInfo.initialize(this); } void SUIArenaGameWnd::moveWnd() { LimitMoveWnd(); } void SUIArenaGameWnd::PumpUpMessage( LPCTSTR controlID, DWORD msg, DWORD lparam, DWORD wparam ) { switch (msg) { case KUI_MESSAGE::KGENWND_MOVE: moveWnd(); break; case KUI_MESSAGE::KBUTTON_CLICK: m_controlFp.call(controlID, this); break; } } void SUIArenaGameWnd::OnNotifyUIWindowOpen( bool bOpen, bool bLimitWnd ) { if (bOpen) { m_oldCount = -1; syncPos(); setRank(); setTooltip(); setOpacity(true); /// 경기가 끝났는데 show상태명 hide 시켜 준다(로딩중에 경기 결과가 날라왔을 때에 해당 된다.) if (m_isEnd) setShow(false); } postUpdateMainMenuButton(); } void SUIArenaGameWnd::postUpdateMainMenuButton() { m_pGameManager->PostMsgAtDynamic( new SIMSG_UPDATE_MAIN_MENU_BUTTON()); } void SUIArenaGameWnd::procCenterCount() { sArenaSystem* arenaSystem = g_pCurrentGameSystem->getArenaSystem(); AR_TIME curTime = GetArTime(); if (curTime > arenaSystem->getStartTime()) return ; int count = (arenaSystem->getStartTime() - curTime)/100; if (15 < count) return ; if (m_oldCount == count) return ; m_oldCount = count; sArenaJoinSituationCondition situationCondition; /// way situationCondition.m_notificationWays = cArenaJoinSituationChecker::WAY_CENTER_NOTICE; if (15 == count) { situationCondition.addNone(S(2461)); } else if (0 == count) { situationCondition.addNone(S(2462)); } else if (10 >= count) { std::string str; XStringUtil::Format(str, "<#898989>%d", count); situationCondition.addNone(str.c_str()); } else { return ; } g_pCurrentGameSystem->isValidArenaJoinSituation(situationCondition); } DWORD SUIArenaGameWnd::OnMouseMessage(DWORD dwMessage, int x, int y) { if (m_opacityInfo.checkIsInButton(x, y)) { return SUIWnd::OnMouseMessage(dwMessage, x, y); } else { OffToolTipWnd(); return 0; } } void SUIArenaGameWnd::setTooltip() { std::string caption; XStringUtil::Format(caption, "<#898989>%s
%s", S(2339), GetGameKeymapping().GetHotKeyStringInfo(HOTKEYCODE::ARENASCORE).c_str()); SetChildTooltip("button_status_01", caption.c_str()); SetChildTooltip("mark_dive_01", S(2387)); } void SUIArenaGameWnd::setTitle() { } void SUIArenaGameWnd::syncPos() { SUIWnd* miniWnd = m_pGameManager->GetSUI(SIMSG_TOGGLE_UIWINDOW::UIWINDOW_MINIMAP); if (miniWnd) MovePos(KUIWndManager::GetResolution().width - GetRect().GetWidth(), miniWnd->GetRect().bottom); } void SUIArenaGameWnd::setRank() { sArenaRankInfo rankInfo; rankInfo.setRank(GetChild("mark_rookie")); } void SUIArenaGameWnd::setMyKillCount(int count) { SetChildCaptionFormat(m_wndMyKillCount, "<#18b222>%d", count); } void SUIArenaGameWnd::setMyDeathCount(int count) { SetChildCaptionFormat(m_wndMyDeathCount, "<#9e0b0f>%d", count); } void SUIArenaGameWnd::setRemainTime(int second) { if (0 > second) second = 0; int m = second/60; int s = second%60; std::string color; int tooltipStringId; getRemainTimeColorAndTooltip(second, color, tooltipStringId); std::string caption; XStringUtil::Format(caption, "%s%02d:%02d", color.c_str(), m, s); m_wndTime->SetCaption(caption.c_str()); m_wndTime->SetTooltip(S(tooltipStringId)); } void SUIArenaGameWnd::setMyTeamMemberCount(int count) { SetChildCaptionFormat(GetChild("text_member_alliance_01"), "<#FFFFFF>%d", count); } void SUIArenaGameWnd::setMyTeamScore(int score) { sArenaSystem* arenaSystem = g_pCurrentGameSystem->getArenaSystem(); int myTeam = arenaSystem->getMyTeam(); char const* color; if (sArenaUtility::TEAM_ALLIANCE == myTeam) color = "<#1e9cde>"; else if (sArenaUtility::TEAM_WITCH == myTeam) color = "<#ea5c11>"; else color = "<#ffffff>"; SetChildCaptionFormat(m_wndMyTeamScore, "%s%d", color, score); } void SUIArenaGameWnd::setMyTeamScoreGauge(int score) { if( m_gaugeMyTeamScore ) m_gaugeMyTeamScore->SetGauge(score, 0); if( NULL == g_pCurrentGameSystem ) { if( m_gaugeMyTeamScore ) m_gaugeMyTeamScore->SetMax( MAX_GAUGE_SCORE ); SetChildCaptionFormat(m_wndMyTeamGaugeScoreNumber, "<#FFFFFF>%d/%d", score, MAX_GAUGE_SCORE ); return ; } BattleArenaBase* pBattleArenaBase( GetBattleArenaDB().getData( g_pCurrentGameSystem->getArenaId() ) ); if( pBattleArenaBase ) { int nObjectivePoint( pBattleArenaBase->nObjectivePoint ); if( m_gaugeMyTeamScore ) m_gaugeMyTeamScore->SetMax( nObjectivePoint ); SetChildCaptionFormat(m_wndMyTeamGaugeScoreNumber, "<#FFFFFF>%d/%d", score, nObjectivePoint ); } else { if( m_gaugeMyTeamScore ) m_gaugeMyTeamScore->SetMax( MAX_GAUGE_SCORE ); SetChildCaptionFormat(m_wndMyTeamGaugeScoreNumber, "<#FFFFFF>%d/%d", score, MAX_GAUGE_SCORE ); } } void SUIArenaGameWnd::setOpponentTeamMemberCount(int count) { SetChildCaptionFormat(GetChild("text_member_witch_01"), "<#FFFFFF>%d", count); } void SUIArenaGameWnd::setOpponentTeamScore(int score) { sArenaSystem* arenaSystem = g_pCurrentGameSystem->getArenaSystem(); int myTeam = arenaSystem->getMyTeam(); if (sArenaUtility::TEAM_NONE == myTeam) return ; char const* color[] = { "<#ea5c11>", "<#1e9cde>" }; SetChildCaptionFormat(m_wndOpponentTeamScore, "%s%d", color[myTeam], score); } void SUIArenaGameWnd::setOpponentTeamScoreGauge(int score) { if( m_gaugeOpponentTeamScore ) m_gaugeOpponentTeamScore->SetGauge(score, 0); if( NULL == g_pCurrentGameSystem ) { if( m_gaugeOpponentTeamScore ) m_gaugeOpponentTeamScore->SetMax( MAX_GAUGE_SCORE ); SetChildCaptionFormat(m_wndOpponentTeamGaugeScoreNumber, "<#FFFFFF>%d/%d", score, MAX_GAUGE_SCORE ); return ; } BattleArenaBase* pBattleArenaBase( GetBattleArenaDB().getData( g_pCurrentGameSystem->getArenaId() ) ); if( pBattleArenaBase ) { int nObjectivePoint( pBattleArenaBase->nObjectivePoint ); if( m_gaugeOpponentTeamScore ) m_gaugeOpponentTeamScore->SetMax( nObjectivePoint ); SetChildCaptionFormat(m_wndOpponentTeamGaugeScoreNumber, "<#FFFFFF>%d/%d", score, nObjectivePoint ); } else { if( m_gaugeOpponentTeamScore ) m_gaugeOpponentTeamScore->SetMax( MAX_GAUGE_SCORE ); SetChildCaptionFormat(m_wndOpponentTeamGaugeScoreNumber, "<#FFFFFF>%d/%d", score, MAX_GAUGE_SCORE ); } } void SUIArenaGameWnd::toggleOpacity() { setOpacity(!m_opacityInfo.isOpacity()); } void SUIArenaGameWnd::setOpacity(bool opacity) { m_opacityInfo.setOpacity(opacity); } void SUIArenaGameWnd::toggleResult() { if (m_pGameManager->IsShow(SIMSG_TOGGLE_UIWINDOW::UIWINDOW_ARENA_RESULT)) m_pGameManager->PostMsgAtDynamic(new SIMSG_SHOW_UIWINDOW( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_ARENA_RESULT, false)); else m_pGameManager->PostMsgAtDynamic(new SIMSG_UI_SEND_DATA(SIMSG_TOGGLE_UIWINDOW::UIWINDOW_ARENA_RESULT, "openResult")); } void SUIArenaGameWnd::updateMyTeam() { sArenaSystem* arenaSystem = g_pCurrentGameSystem->getArenaSystem(); int myTeam = arenaSystem->getMyTeam(); int opponentTeam = arenaSystem->getOpponentTeam(); if (sArenaUtility::TEAM_NONE == myTeam) return ; char const* titleTeamName[] = {"game_panel_gold_arena_game_alliance", "game_panel_gold_arena_game_witch"}; char const* markName[] = {"game_mark_arena_game_alliance_team", "game_mark_arena_game_witch_team"}; char const* memberBgName[] = {"game_panel_titanium_arena_game_alliance", "game_panel_titanium_arena_game_witch"}; int tooltipId[] = { 2382, 2383 }; /// my team SetChildAniName("bg_mark_arena_alliance_01", titleTeamName[myTeam]); SetChildAniName("mark_alliance_01", markName[myTeam]); SetChildAniName("bg_member_alliance_01", memberBgName[myTeam]); SetChildTooltip("bg_member_alliance_01", S(tooltipId[myTeam])); /// opponent team SetChildAniName("mark_alliance_02", markName[opponentTeam]); SetChildAniName("bg_member_witch_01", memberBgName[opponentTeam]); SetChildTooltip("bg_member_witch_01", S(tooltipId[opponentTeam])); } void SUIArenaGameWnd::resetData() { setMyKillCount(0); setMyDeathCount(0); setRemainTime(0); setMyTeamMemberCount(0); setMyTeamScore(0); setOpponentTeamMemberCount(0); setOpponentTeamScore(0); setMyTeamScoreGauge(0); setOpponentTeamScoreGauge(0); } void SUIArenaGameWnd::checkGameStart() { sArenaSystem* arenaSystem = g_pCurrentGameSystem->getArenaSystem(); AR_TIME curTime = GetArTime(); if (arenaSystem->getForceEnterTime() > curTime) { m_isPlaying = false; } else if (arenaSystem->getEndTime() > curTime) { if (!m_isPlaying) { m_isPlaying = true; int remainTime = (arenaSystem->getEndTime() - GetArTime())/100; setRemainTime(remainTime); } } } void SUIArenaGameWnd::setPartyTitleBarArenaInfo() { sArenaSystem* arenaSystem = g_pCurrentGameSystem->getArenaSystem(); int myTeam = arenaSystem->getMyTeam(); m_pGameManager->ProcMsgAtStatic( &SIMSG_UI_SEND_DATA( SIMSG_TOGGLE_UIWINDOW::_UIWINDOW_TYPE::UIWINDOW_PARTY, "set_arena_titlebar_arena_info", myTeam)); } void SUIArenaGameWnd::getRemainTimeColorAndTooltip(int second, std::string& color, int& tooltipStringId) { BattleArenaBase* base = GetBattleArenaDB().getData(g_pCurrentGameSystem->getArenaId()); if (!base) return ; sArenaUtility utility; color = "<#ffffff>"; tooltipStringId = 2385; if (180 > second) { color = "<#ff0000>"; tooltipStringId = 2386; } else { sArenaSystem* arenaSystem = g_pCurrentGameSystem->getArenaSystem(); AR_TIME playTime = GetArTime() - arenaSystem->getStartTime(); /// 최소 플레이 시간 보다 작은 경우 if (playTime < utility.getMinimumPlayTime(base->nMaxMember)) { color = "<#ff0000>"; tooltipStringId = 2384; } /// 한쪽 진영의 유저 수가 50%미만인 경우 else if (!arenaSystem->isEnoughHalfPlayerCount(base->nMaxMember)) { color = "<#ff0000>"; tooltipStringId = 2384; } } } void SUIArenaGameWnd::updateScore() { sArenaSystem* arenaSystem = g_pCurrentGameSystem->getArenaSystem(); /// sArenaSystem::sPlayerScore* myScore = arenaSystem->getMyPlayerScore(); if (myScore) { setMyKillCount(myScore->killCount); setMyDeathCount(myScore->deathCount); } int myTeam = arenaSystem->getMyTeam(); sArenaSystem::sTeamScore* myTeamScore = arenaSystem->getTeamScore(myTeam); if (myTeamScore) { setMyTeamMemberCount(arenaSystem->getPlayerCount(myTeam)); setMyTeamScore(myTeamScore->score); setMyTeamScoreGauge(myTeamScore->score); } int opponentTeam = arenaSystem->getOpponentTeam(); sArenaSystem::sTeamScore* opponentTeamScore = arenaSystem->getTeamScore(opponentTeam); if (opponentTeamScore) { setOpponentTeamMemberCount(arenaSystem->getPlayerCount(opponentTeam)); setOpponentTeamScore(opponentTeamScore->score); setOpponentTeamScoreGauge(opponentTeamScore->score); } }