#include "stdafx.h" #include "Arena\\ArenaJoinSituationChecker.h" #include "Arena\\ArenaSystem.h" #include "SUIArenaResultWnd.h" #include "SUIArenaGameWnd.h" //#include "SGameMessageUI.h" #include "KUIControlStatic.h" #include "SGameManager.h" #include "SBattleArenaDB.h" #include "SGameMessage.h" #include "SGameAvatarEx.h" #include "SGameSystem.h" #include "CommonUtil.h" #include #include "SStringDB.h" #include "SJobDB.h" //#include "Util.h" extern SGameSystem* g_pCurrentGameSystem; /// exceptionBg : 백그라운드 제외 void SUIArenaResultWnd::sRowControls::setShow(bool show, int beginColumn) { int c_num = beginColumn; for (; c_num < MAX_COLUMN; ++c_num) { m_control[c_num]->SetShow(show); } } SUIArenaResultWnd::SUIArenaResultWnd(SGameManager* gameManager) : SUIWnd(gameManager), m_rowNum(-1), m_myRowIndex(0) { } SUIArenaResultWnd::~SUIArenaResultWnd() { m_needResizeControl.clear(); } bool SUIArenaResultWnd::InitData(bool reload) { initFp(); initTooltip(); createRowControls(); initNeedResizeControls(); m_oriWndHeight = GetRect().GetHeight(); m_buttonClose = dynamicCast(GetChild("button_arena_end_01")); m_buttonClose->SetEnableColor("<#ffffff>"); m_buttonClose->SetDisableColor("<#a0a0a0>"); m_oriCloseButtonOffsetY = m_buttonClose->GetRect().top - GetRect().top; return SUIWnd::InitData(reload); } void SUIArenaResultWnd::initFp() { m_controlFp.add("button_close", &SUIArenaResultWnd::close); m_controlFp.add("button_arena_end_01", &SUIArenaResultWnd::end); m_msgFp.add(IMSG_UI_SEND_DATA, &SUIArenaResultWnd::procMsgData); m_msgFp.add(MSG_BATTLE_ARENA_BATTLE_INFO, &SUIArenaResultWnd::procMsgBattleInfo); m_msgFp.add(MSG_BATTLE_ARENA_BATTLE_SCORE, &SUIArenaResultWnd::procMsgBattleScore); m_msgFp.add(MSG_BATTLE_ARENA_JOIN_BATTLE, &SUIArenaResultWnd::procMsgJoinBattle); m_msgFp.add(MSG_BATTLE_ARENA_RECONNECT_BATTLE, &SUIArenaResultWnd::procMsgReconnectBattle); m_msgFp.add(MSG_BATTLE_ARENA_RESULT, &SUIArenaResultWnd::procMsgResult); m_msgFp.add(MSG_BATTLE_ARENA_LEAVE, &SUIArenaResultWnd::procMsgLeave); } void SUIArenaResultWnd::initTooltip() { SetChildTooltip("bg_member_alliance_01", S(2391)); SetChildTooltip("ally_category_job_01", S(2392)); SetChildTooltip("ally_category_kill_01", S(2393)); SetChildTooltip("ally_category_death_01", S(2394)); SetChildTooltip("ally_category_prop_01", S(2395)); SetChildTooltip("ally_text_category_ap_01", S(2396)); SetChildTooltip("bg_member_witch_01", S(2398)); SetChildTooltip("enemy_category_job_02", S(2392)); SetChildTooltip("enemy_category_kill_01", S(2393)); SetChildTooltip("enemy_category_death_01", S(2394)); SetChildTooltip("enemy_category_prop_01", S(2395)); SetChildTooltip("enemy_text_category_ap_01", S(2396)); } void SUIArenaResultWnd::createRowControls() { copyRowControl(MY_PANEL); copyRowControl(OPPONENT_PANEL); } void SUIArenaResultWnd::copyRowControl(int panel) { char const* className = (MY_PANEL == panel) ? "ally" : "enemy"; char const* id[] = { "line", "text_number", "job_icon", "text_id", "text_kill", "text_death", "text_prop", "text_point" }; /// get first/second child for (int c_num = 0; c_num < MAX_COLUMN; ++c_num) { m_rowControl[panel][0].m_control[c_num] = dynamicCast(GetChild(CStringUtil::StringFormat("%s_%s_00", className, id[c_num]).c_str())); m_rowControl[panel][1].m_control[c_num] = dynamicCast(GetChild(CStringUtil::StringFormat("%s_%s_01", className, id[c_num]).c_str())); } /// copy control RECT offset; offset.left = 0; offset.top = ROW_HEIGHT; offset.right = 0; offset.bottom = ROW_HEIGHT; for (int t_num = 2; t_num < MAX_ROW; ++t_num) { for (int c_num = 0; c_num < MAX_COLUMN; ++c_num) { std::string srcId = CStringUtil::StringFormat("%s_%s_%02d", className, id[c_num], t_num-1); std::string destId = CStringUtil::StringFormat("%s_%s_%02d", className, id[c_num], t_num); m_rowControl[panel][t_num].m_control[c_num] = dynamicCast(CopyControl(srcId.c_str(), destId.c_str(), offset)); } } } void SUIArenaResultWnd::initNeedResizeControls() { addNeedResizeControl("win_display_panel_01"); addNeedResizeControl("my_display_panel_01"); addNeedResizeControl("ally_inframe_01"); addNeedResizeControl("win_display_panel_02"); addNeedResizeControl("enemy_inframe_01"); addNeedResizeControl("outframe"); } void SUIArenaResultWnd::addNeedResizeControl(char const* id) { KUIWnd* wnd = GetChild(id); assert(!wnd && "failed addNeedResize, wnd is null"); m_needResizeControl.push_back(sNeedResizeControl(wnd->GetRect().GetHeight(), wnd)); } void SUIArenaResultWnd::OnNotifyUIWindowOpen(bool bOpen, bool bLimitWnd) { if (bOpen) { syncPos(); } } void SUIArenaResultWnd::ProcMsgAtStatic(SGameMessage* pMsg) { m_msgFp.call(pMsg->nType, this, pMsg); }; void SUIArenaResultWnd::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 SUIArenaResultWnd::close() { m_pGameManager->PostMsgAtDynamic( new SIMSG_SHOW_UIWINDOW( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_ARENA_RESULT, false) ); } void SUIArenaResultWnd::end() { if (m_isEnd) { TS_CS_BATTLE_ARENA_LEAVE msgLeave; m_pGameManager->PendMessage(&msgLeave); } else { close(); } } void SUIArenaResultWnd::setWinTeam(int winTeam) { char const* idFlower[] = { "win_display_mark_01", "win_display_mark_02" }; char const* idOutLine[] = { "win_display_panel_01", "win_display_panel_02" }; /// 무승부 if (sArenaUtility::TEAM_NONE == winTeam) { SetChildShow(idFlower[0], false); SetChildShow(idFlower[1], false); SetChildShow(idOutLine[0], false); SetChildShow(idOutLine[1], false); } else { sArenaSystem* arenaSystem = g_pCurrentGameSystem->getArenaSystem(); int winPanel; if (arenaSystem->getMyTeam() == winTeam) winPanel = 0; /// 왼쪽(자신은 항상 왼쪽이다) else winPanel = 1; /// 오른쪽 int losePanel = !winPanel; SetChildShow(idFlower[winPanel], true); SetChildShow(idOutLine[winPanel], true); SetChildShow(idFlower[losePanel], false); SetChildShow(idOutLine[losePanel], false); } } void SUIArenaResultWnd::setRowNum() { BattleArenaBase* data = GetBattleArenaDB().getData(g_pCurrentGameSystem->getArenaId()); if (!data) return ; int rowNum = data->nMaxMember >> 1; if (m_rowNum == rowNum) return ; m_rowNum = rowNum; updateRow(m_rowNum); } void SUIArenaResultWnd::updateRow(int rowNum) { showRow(rowNum); resizeWnd(rowNum); } void SUIArenaResultWnd::updateTotalPlayerCount() { sArenaSystem* arenaSystem = g_pCurrentGameSystem->getArenaSystem(); std::string strNum; int myTeam = arenaSystem->getMyTeam(); strNum = CStringUtil::StringFormat("<#FFFFFF>%d", arenaSystem->getPlayerCount(myTeam)); SetChildCaption("text_member_alliance_01", strNum.c_str()); int opponentTeam = arenaSystem->getOpponentTeam(); strNum = CStringUtil::StringFormat("<#FFFFFF>%d", arenaSystem->getPlayerCount(opponentTeam)); SetChildCaption("text_member_witch_01", strNum.c_str()); } void SUIArenaResultWnd::showRow(int rowNum) { int t_num; for (int panel = 0; panel < MAX_PANEL; ++panel) { for (t_num = 0; t_num < rowNum; ++t_num) { m_rowControl[panel][t_num].setShow(true); m_rowControl[panel][t_num].m_control[COLUMN_NUMBER]->SetTooltip(""); } for (; t_num < MAX_ROW; ++t_num) { m_rowControl[panel][t_num].setShow(false); } } } void SUIArenaResultWnd::resizeWnd(int rowNum) { /// 줄어드는 사이즈 int maxRowHeight = MAX_ROW * ROW_HEIGHT; int curRowHeight = rowNum * ROW_HEIGHT; int reduceHeight = maxRowHeight - curRowHeight; int height; KRect r; /// control resize std::list::iterator it_n = m_needResizeControl.begin(); for (; it_n != m_needResizeControl.end(); ++it_n) { height = it_n->m_oriHeight - reduceHeight; r = it_n->m_control->GetRect(); r.bottom = r.top + height; it_n->m_control->Resize(r); } /// wnd resize height = m_oriWndHeight - reduceHeight; r = GetRect(); r.bottom = r.top + height; Resize(r); /// close button int x = m_buttonClose->GetRect().left; int y = GetRect().top + m_oriCloseButtonOffsetY - reduceHeight; m_buttonClose->MovePos(x, y); } void SUIArenaResultWnd::syncPos() { int centerx = KUIWndManager::GetResolution().width >> 1; int centery = KUIWndManager::GetResolution().height >> 1; int wndhx = GetRect().GetWidth() >> 1; int wndhy = GetRect().GetHeight() >> 1; MovePos(centerx - wndhx, centery - wndhy); } void SUIArenaResultWnd::setGameMode() { int gameMode = -1; BattleArenaBase* data = GetBattleArenaDB().getData(g_pCurrentGameSystem->getArenaId()); if (data) gameMode = data->eType; /// set ani name char const* aniName; int tooltipId; switch (gameMode) { case sArenaUtility::MODE_CLASSIC: aniName = "game_panel_arena_mode_classic_default"; tooltipId = 2314; break; case sArenaUtility::MODE_BINGO: aniName = "game_panel_arena_mode_bingo_default"; tooltipId = 2316; break; case sArenaUtility::MODE_SLAUGHTER: aniName = "game_panel_arena_mode_slaughter_default"; tooltipId = 2315; break; default: aniName = ""; tooltipId = 0; break; } KUIControl* control = dynamicCast(GetChild("panel_status_default_01")); control->SetAniName(aniName); control->SetTooltip(S(tooltipId)); } void SUIArenaResultWnd::setMyTeam(int teamType) { if (sArenaUtility::TEAM_ALLIANCE == teamType) { /// my(동맹군) SetChildAniName("mark_alliance_01", "game_mark_arena_game_alliance_team"); SetChildAniName("bg_member_alliance_01", "game_panel_titanium_arena_game_alliance"); /// opponent(마녀군) SetChildAniName("mark_witch_right_01", "game_mark_arena_game_witch_team_right"); SetChildAniName("bg_member_witch_01", "game_panel_titanium_arena_game_witch"); } else if (sArenaUtility::TEAM_WITCH == teamType) { /// my(마녀군) SetChildAniName("mark_alliance_01", "game_mark_arena_game_witch_team"); SetChildAniName("bg_member_alliance_01", "game_panel_titanium_arena_game_witch"); /// opponent(동맹군) SetChildAniName("mark_witch_right_01", "game_mark_arena_game_alliance_team_right"); SetChildAniName("bg_member_witch_01", "game_panel_titanium_arena_game_alliance"); } else { /// my(마녀군) SetChildAniName("mark_alliance_01", ""); SetChildAniName("bg_member_alliance_01", ""); /// opponent(동맹군) SetChildAniName("mark_witch_right_01", ""); SetChildAniName("bg_member_witch_01", ""); } } void SUIArenaResultWnd::setScore(int team, int score, char const* controlId) { sArenaUtility utility; if (!utility.isValidTeam(team)) return ; char const* color[] = { "<#1e9cde>", "<#ea5c11>" }; SetChildCaption(controlId, CStringUtil::StringFormat("%s%d", color[team], score).c_str()); } void SUIArenaResultWnd::setMyScore(int score) { sArenaSystem* arenaSystem = g_pCurrentGameSystem->getArenaSystem(); setScore(arenaSystem->getMyTeam(), score, "text_score_alliance_01"); } void SUIArenaResultWnd::setOpponentScore(int score) { sArenaSystem* arenaSystem = g_pCurrentGameSystem->getArenaSystem(); setScore(arenaSystem->getOpponentTeam(), score, "text_score_witch_01"); } void SUIArenaResultWnd::setRowBackground() { char const* myBackground; char const* opponentBackground; for (int i = 0; i < m_rowNum; ++i) { if (0 == i%2) { myBackground = "game_panel_titanium_arena_status_line_blue"; opponentBackground = "game_panel_titanium_arena_status_line_blue"; } else { myBackground = "game_panel_titanium_arena_status_line_black"; opponentBackground = "game_panel_titanium_arena_status_line_gray_a"; } m_rowControl[MY_PANEL][i].m_control[COLUMN_BACKGROUND]->SetAniName(myBackground); m_rowControl[OPPONENT_PANEL][i].m_control[COLUMN_BACKGROUND]->SetAniName(opponentBackground); } /// my m_rowControl[MY_PANEL][m_myRowIndex].m_control[COLUMN_BACKGROUND]->SetAniName("game_panel_titanium_arena_status_line_my"); } void SUIArenaResultWnd::setEndGame(bool end) { m_isEnd = end; /// 연관된 스트링 id 설정 int stringId; if (m_isEnd) stringId = 2341; else stringId = 9226; std::string str; XStringUtil::Format(str, "<#ffffff>%s", S(stringId)); m_buttonClose->SetCaption(str.c_str()); /// x 버튼 SetChildShow("button_close", end ? false : true); } void SUIArenaResultWnd::procMsgData(SGameMessage* msg) { msg->bUse = true; SIMSG_UI_SEND_DATA* msgData = dynamicCast(msg); if ("openResult" == msgData->m_strString) { if (!IsShow()) { updateData(); m_pGameManager->PostMsgAtDynamic( new SIMSG_SHOW_UIWINDOW( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_ARENA_RESULT, true)); } } } void SUIArenaResultWnd::procMsgBattleInfo(SGameMessage* msg) { msg->bUse = true; sArenaSystem* arenaSystem = g_pCurrentGameSystem->getArenaSystem(); initNumber(); setMyTeam(arenaSystem->getMyTeam()); updateRow(); setMyScore(0); setOpponentScore(0); setWinTeam(sArenaUtility::TEAM_NONE); setEndGame(false); } void SUIArenaResultWnd::procMsgBattleScore(SGameMessage* msg) { msg->bUse = true; if (IsShow()) updateData(); } void SUIArenaResultWnd::procMsgJoinBattle(SGameMessage* msg) { msg->bUse = true; updateRow(); if (IsShow()) updateData(); } void SUIArenaResultWnd::procMsgReconnectBattle(SGameMessage* msg) { msg->bUse = true; } void SUIArenaResultWnd::procMsgResult(SGameMessage* msg) { msg->bUse = true; SMSG_BATTLE_ARENA_RESULT* _msg = dynamicCast(msg); setEndGame(true); setWinTeam(_msg->winnerTeamNo); updateData(_msg->mvpCount, _msg->mvp); m_pGameManager->PostMsgAtDynamic( new SIMSG_SHOW_UIWINDOW( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_ARENA_RESULT, true)); isValidArenaJoinSituationAtResult(msg); } void SUIArenaResultWnd::procMsgLeave(SGameMessage* msg) { msg->bUse = true; updateRow(); if (IsShow()) updateData(); } void SUIArenaResultWnd::updateRow() { setRowNum(); updateTotalPlayerCount(); findMyRowIndex(); setRowBackground(); } void SUIArenaResultWnd::updateData(int mvpCount, sMvp const* mvp) { sArenaSystem* arenaSystem = g_pCurrentGameSystem->getArenaSystem(); // game mode setGameMode(); /// my socre int myTeam = arenaSystem->getMyTeam(); sArenaSystem::sTeamScore* myScore = arenaSystem->getTeamScore(myTeam); if (myScore) setMyScore(myScore->score); /// opponent score int opponentTeam = arenaSystem->getOpponentTeam(); sArenaSystem::sTeamScore* opponentScore = arenaSystem->getTeamScore(opponentTeam); if (opponentScore) setOpponentScore(opponentScore->score); setPanelData(myTeam, MY_PANEL, mvpCount, mvp); setPanelData(opponentTeam, OPPONENT_PANEL, mvpCount, mvp); } void SUIArenaResultWnd::setPanelData(int team, int panel, int mvpCount, sMvp const* mvp) { sArenaSystem* arenaSystem = g_pCurrentGameSystem->getArenaSystem(); sArenaSystem::sPlayerInfo* info; /// 중간에 빈건 채워주면서 보여줘야 된다 int row = 0; for (int pn = 0; pn < sArenaUtility::MAX_MEMBER_ONE_TEAM; ++pn) { info = arenaSystem->getPlayerInfo(team, pn); if (!info || 0 == info->handle) continue; setRowData(info, panel, row, mvpCount, mvp); ++row; } for (; row < m_rowNum; ++row) { m_rowControl[panel][row].setShow(false, COLUMN_JOB); } } bool SUIArenaResultWnd::setRowData(sArenaSystem::sPlayerInfo* info, int panel, int row, int mvpCount, sMvp const* mvp) { sArenaSystem* arenaSystem = g_pCurrentGameSystem->getArenaSystem(); m_rowControl[panel][row].setShow(true, COLUMN_JOB); sArenaSystem::sPlayerScore emptyScore; ZeroMemory(&emptyScore, sizeof (emptyScore)); /// 스코어 데이타가 없으면 빈 데이타를 넣어준다 sArenaSystem::sPlayerScore* _score = arenaSystem->findPlayerScore(info->name); sArenaSystem::sPlayerScore* score = (_score) ? _score : &emptyScore; char const* color; KUIControl* control; std::string caption; /// mvp if (isMvp(info->name, mvpCount, mvp)) { control = m_rowControl[panel][row].m_control[COLUMN_NUMBER]; control->SetAniName("game_mark_titanium_arena_mvp"); control->SetCaption(""); control->SetTooltip(S(2397)); } /// COLUMN_JOB control = m_rowControl[panel][row].m_control[COLUMN_JOB]; control->SetAniName(GetJobDB().GetJobIconName(info->jobID)); /// COLUMN_ID control = m_rowControl[panel][row].m_control[COLUMN_ID]; color = (row == 0) ? "<#f5989d>" : "<#ffffff>"; XStringUtil::Format(caption, "%s%s",color, info->name); control->SetCaption(caption.c_str()); /// COLUMN_KILLCOUNT control = m_rowControl[panel][row].m_control[COLUMN_KILLCOUNT]; color = (row == 0) ? "<#f5989d>" : "<#898989>"; XStringUtil::Format(caption, "%s%d",color, score->killCount); control->SetCaption(caption.c_str()); /// COLUMN_DEATHCOUNT control = m_rowControl[panel][row].m_control[COLUMN_DEATHCOUNT]; XStringUtil::Format(caption, "<#40322b>%d", score->deathCount); control->SetCaption(caption.c_str()); /// COLUMN_PROPPOINT control = m_rowControl[panel][row].m_control[COLUMN_PROPPOINT]; color = (row == 0) ? "<#f5989d>" : "<#898989>"; XStringUtil::Format(caption, "%s%d",color, score->propActivateCount); control->SetCaption(caption.c_str()); /// COLUMN_AP control = m_rowControl[panel][row].m_control[COLUMN_AP]; color = (row == 0) ? "<#f5989d>" : "<#898989>"; XStringUtil::Format(caption, "%s%d",color, score->totalGainAP); control->SetCaption(caption.c_str()); return true; } void SUIArenaResultWnd::initNumber() { std::string caption; KUIWnd* control; for (int team = 0; team < sArenaUtility::MAX_TEAM_NUM; ++team) { for (int rowIndex = 0; rowIndex < sArenaUtility::MAX_MEMBER_ONE_TEAM; ++rowIndex) { control = m_rowControl[team][rowIndex].m_control[COLUMN_NUMBER]; control->SetAniName(""); XStringUtil::Format(caption, "<#898989>%d", rowIndex+1); control->SetCaption(caption.c_str()); } } } bool SUIArenaResultWnd::findRowIndex(char const* playerName, int& team, int& rowIndex) { sArenaSystem* arenaSystem = g_pCurrentGameSystem->getArenaSystem(); int maxTeam = sArenaUtility::MAX_TEAM_NUM; for (int tn = 0; tn < maxTeam; ++tn) { int playerCount = arenaSystem->getPlayerCount(tn); for (int pn = 0; pn < playerCount; ++pn) { sArenaSystem::sPlayerInfo* playerInfo = arenaSystem->getPlayerInfo(tn, pn); if (!playerInfo) continue; if (strcmp(playerInfo->name, playerName) == 0) { team = tn; rowIndex = pn; return true; } } } team = sArenaUtility::TEAM_NONE; rowIndex = 0; return false; } void SUIArenaResultWnd::findMyRowIndex() { sArenaSystem* arenaSystem = g_pCurrentGameSystem->getArenaSystem(); int myTeam = arenaSystem->getMyTeam(); char const* playerName = arenaSystem->getPlayerName(&m_PlayerInfoMgr); findRowIndex(playerName, myTeam, m_myRowIndex); } void SUIArenaResultWnd::isValidArenaJoinSituationAtResult(SGameMessage* msg) { SMSG_BATTLE_ARENA_RESULT* _msg = dynamicCast(msg); sArenaSystem* arenaSystem = g_pCurrentGameSystem->getArenaSystem(); sArenaJoinSituationCondition situationCondition; situationCondition.m_notificationWays = cArenaJoinSituationChecker::WAY_CENTER_NOTICE; int stringId; /// 종료 situationCondition.addNone(S(2449)); /// switch (_msg->rewardType) { case _ARENA_REWARD_TYPE::ART_HALF_REWARD_BY_FEW_MEMBER: stringId = 2453; break; case _ARENA_REWARD_TYPE::ART_NO_REWARD_BY_NO_MEMBER: stringId = 2473; break; case _ARENA_REWARD_TYPE::ART_NO_REWARD_BY_MIN_TIME: stringId = 2474; break; case _ARENA_REWARD_TYPE::ART_NO_REWARD_BY_EXERCISE: stringId = 2475; break; default: stringId = 0; break; } if (0 < stringId) situationCondition.addNone(S(stringId)); /// 승부 if (sArenaUtility::TEAM_ALLIANCE == _msg->winnerTeamNo) stringId = 2450; else if (sArenaUtility::TEAM_WITCH == _msg->winnerTeamNo) stringId = 2451; else { if (_ARENA_END_TYPE::AET_TIME_OVER == _msg->endType && arenaSystem->isEqualScore()) stringId = 2452; else if (_ARENA_END_TYPE::AET_ONE_TEAM_NO_MEMBER == _msg->endType) stringId = 0; else stringId = 0; } if (0 < stringId) situationCondition.addNone(S(stringId)); g_pCurrentGameSystem->isValidArenaJoinSituation(situationCondition); } void SUIArenaResultWnd::moveWnd() { LimitMoveWnd(); } bool SUIArenaResultWnd::isMvp(char const* name, int mvpCount, sMvp const* mvp) const { if (!mvp) return false; for (int i = 0; i < mvpCount; ++i) { if (::stricmp(name, mvp[i].name) == 0) return true; } return false; }