Files
2026-06-01 12:46:52 +02:00

438 lines
14 KiB
C++

#include "stdafx.h"
#include "SUIMainMenuWnd.h"
#include "KUIControlButton.h"
#include "SGameManager.h"
#include "SGameMessage.h"
//#include "SGameMessageUI.h"
#include "SStringDB.h"
#include "Arena\\ArenaJoinSituationChecker.h"
#include "SGameWorldKeymapping.h"
#include "Arena\\ArenaRanKInfo.h"
#include "Arena\\ArenaSystem.h"
#include "SContentsManager.h"
#include "SHuntaHolicSystem.h"
#include "SGameLocalPlayer.h"
#include "KUIControlStatic.h"
#include "SGameInterface.h"
#include "SGameSystem.h"
#include <toolkit/XStringUtil.h>
extern SGameSystem * g_pCurrentGameSystem;
namespace
{
//const int c_nButtonClickArea = 14;
//const char* c_szStaticMenu = "button_mainmenu";
//const char* c_szStatciMoney = "static_money";
std::string c_szAniFile = "";
};
bool SUIMainMenuWnd::InitControls( KPoint kPos )
{
/// 2012.05.16 - prodongi
initMenuButtonStatus();
// 버튼 클릭 영역 지정
//SetValidRect( "mainmenu_item" , KRect(0,0,-c_nButtonClickArea,0) );
//SetValidRect( "mainmenu_character", KRect(c_nButtonClickArea,0,-c_nButtonClickArea,0) );
//SetValidRect( "mainmenu_summon" , KRect(c_nButtonClickArea,0,-c_nButtonClickArea,0) );
//SetValidRect( "mainmenu_chat" , KRect(c_nButtonClickArea,0,-c_nButtonClickArea,0) );
//SetValidRect( "mainmenu_skill" , KRect(c_nButtonClickArea,0,-c_nButtonClickArea,0) );
//SetValidRect( "mainmenu_messanger", KRect(c_nButtonClickArea,0,-c_nButtonClickArea,0) );
//SetValidRect( "mainmenu_system" , KRect(c_nButtonClickArea,0,-c_nButtonClickArea,0) );
//SetChildCaption( c_szStaticMenu, GetStringDB().GetString( STRING_MENU ) );
//SetChildCaption( c_szStatciMoney, GetStringDB().GetString( STRING_UI_MENU_TEXT ) ); // #2.1.11
//GetChild("button_mainmenu")->
return SUIWnd::InitControls(kPos);
}
void SUIMainMenuWnd::initMenuButtonStatus()
{
/// 2012.05.16 - prodongi
m_arenaButton = dynamicCast<KUIControl*>(GetChild("button_arena_entrance_01"));
m_arenaText = dynamicCast<KUIControlStatic*>(GetChild("text_button_arena_entrance_01"));
m_instanceButton = dynamicCast<KUIControl*>(GetChild("button_instance_entrance_01"));
m_exitButton = dynamicCast<KUIControl*>(GetChild("button_arena_end_01"));
m_exitText = dynamicCast<KUIControlStatic*>(GetChild("text_button_arena_end_01"));
m_arenaText->SetEnableColor( "<#ffffff>" );
m_arenaText->SetDisableColor( "<#a0a0a0>" );
m_arenaText->SetEnableOption(true);
m_exitText->SetEnableColor( "<#ffffff>" );
m_exitText->SetDisableColor( "<#a0a0a0>" );
m_exitText->SetEnableOption(true);
setInstanceArenaButtonStatus(SGameLocalPlayer::IAS_NORMAL);
}
void SUIMainMenuWnd::setTooltip()
{
m_instanceButton->SetTooltip(S(2364));
std::string caption;
XStringUtil::Format(caption, "<hcenter><#898989>%s<br>%s", S(6687), GetGameKeymapping().GetHotKeyStringInfo(HOTKEYCODE::SYSTEM).c_str());
SetChildTooltip("button_option_01", caption.c_str());
XStringUtil::Format(caption, "<hcenter><#898989>%s<br>%s", S(6686), GetGameKeymapping().GetHotKeyStringInfo(HOTKEYCODE::HELP).c_str());
SetChildTooltip("button_move_01", caption.c_str());
}
void SUIMainMenuWnd::PumpUpMessage( LPCSTR lpszControlID, DWORD nMessage, DWORD lparam, DWORD wparam )
{
switch(nMessage)
{
case KUI_MESSAGE::KBUTTON_CLICK:
{
m_pGameManager->StartSound( "ui_click_menu01.wav" );
if( 0 == ::_stricmp( "button_mainmenu", lpszControlID ) )
m_pGameManager->PostMsgAtDynamic( new SIMSG_TOGGLE_UIWINDOW( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_MAINMENU_SUB ) );
else if (0 == ::_stricmp("button_arena_entrance_01", lpszControlID))
{
if (g_pCurrentGameSystem->isInArena())
break;
if (checkValidArenaJoinSituationAtEntrance())
{
if (m_pGameManager->IsShow(SIMSG_TOGGLE_UIWINDOW::UIWINDOW_ARENA_MENU))
{
showMenu(SIMSG_TOGGLE_UIWINDOW::UIWINDOW_ARENA_MENU, false);
}
else
{
showMenu(SIMSG_TOGGLE_UIWINDOW::UIWINDOW_ARENA_MENU, true);
showMenu(SIMSG_TOGGLE_UIWINDOW::UIWINDOW_INSTANCE_TASKBAR_ENTRANCE, false);
}
}
}
else if (0 == ::_stricmp("button_instance_entrance_01", lpszControlID))
{
if (g_pCurrentGameSystem->isInArena())
break;
if (m_pGameManager->IsShow(SIMSG_TOGGLE_UIWINDOW::UIWINDOW_INSTANCE_TASKBAR_ENTRANCE))
{
showMenu(SIMSG_TOGGLE_UIWINDOW::UIWINDOW_INSTANCE_TASKBAR_ENTRANCE, false);
}
else
{
showMenu(SIMSG_TOGGLE_UIWINDOW::UIWINDOW_ARENA_MENU, false);
showMenu(SIMSG_TOGGLE_UIWINDOW::UIWINDOW_ARENA_SELECTION_READY, false);
showMenu(SIMSG_TOGGLE_UIWINDOW::UIWINDOW_ARENA_PRACTICE_READY, false);
showMenu(SIMSG_TOGGLE_UIWINDOW::UIWINDOW_INSTANCE_TASKBAR_ENTRANCE, true);
}
}
else if (0 == ::_stricmp("button_arena_end_01", lpszControlID))
{
clickExitButton();
}
else if (0 == ::_stricmp("button_option_01", lpszControlID))
{
m_pGameManager->PostMsgAtDynamic( new SIMSG_TOGGLE_UIWINDOW( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_SYSTEM_MAIN));
}
else if (0 == ::_stricmp("button_move_01", lpszControlID))
{
m_pGameManager->PostMsgAtDynamic( new SMSG_SEND_DATA( "toggle_help" ) );
}
}
break;
}
SUIWnd::PumpUpMessage( lpszControlID, nMessage, lparam, wparam );
}
void SUIMainMenuWnd::OnPosChangeNofity(int XOffset, int YOffset)
{
SUIWnd::OnPosChangeNofity(XOffset,YOffset);
}
DWORD SUIMainMenuWnd::OnMouseMessage(DWORD dwMessage, int x, int y)
{
DWORD dwRet = SUIWnd::OnMouseMessage(dwMessage,x,y);
return dwRet;
}
void SUIMainMenuWnd::ProcMsgAtStatic( SGameMessage* pMsg )
{
switch(pMsg->nType)
{
case IMSG_MOUSEMOVE:
{
SIMSG_MOUSEMOVE* pMouseMove = (SIMSG_MOUSEMOVE* )pMsg;
int x = ((int)(short)LOWORD(pMouseMove->lParam));
int y = ((int)(short)HIWORD(pMouseMove->lParam));
OnMouseMessage(KMOUSE_MOVE,x,y);
}
break;
case IMSG_UI_SEND_DATA:
{
SIMSG_UI_SEND_DATA *pData = (SIMSG_UI_SEND_DATA *)pMsg;
// _oprint( "GOLD UPDATED:%d\n", pData->m_nNumber );
if( pData->m_strString == "gold" )
{
std::string strGold = "<size:8><right><vcenter>";
strGold += S(6425);
strGold += CStringUtil::GetCommaNumberString( ((SIMSG_UI_SEND_DATA*)pMsg)->m_nNumber.getAmount() );
SetChildCaption( "static_money_value", strGold.c_str() );
}
else if (pData->m_strString == "enable_exit")
{
enableExitButton(pData->m_dwData == 0 ? false : true);
}
}
break;
case IMSG_UI_SYSMENU_HOTKEY:
{
switch( ((SIMSG_UI_SYSMENU_HOTKEY*)pMsg)->m_nType )
{
case SIMSG_TOGGLE_UIWINDOW::UIWINDOW_MAINMENU_SUB:
{
// m_pGameManager->PostMsgAtDynamic( new SIMSG_UI_SYSMENU( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_SKILL, bShow) );
}
break;
}
pMsg->bUse = true;
}
break;
case IMSG_SET_KEYMAPPING:
{
setTooltip();
}
break;
case IMSG_UPDATE_MAIN_MENU_BUTTON:
{
updateInstanceArenaStatus();
}
break;
}
}
void SUIMainMenuWnd::showMenu(int wndId, bool show)
{
SUIWnd* wnd = m_pGameManager->GetSUI(wndId);
if (wnd && wnd->IsShow() != show)
m_pGameManager->PostMsgAtDynamic( new SIMSG_SHOW_UIWINDOW( (SIMSG_TOGGLE_UIWINDOW::_UIWINDOW_TYPE)wndId, show));
}
void SUIMainMenuWnd::enableExitButton(bool enable)
{
if (enable)
{
m_exitButton->Enable();
m_exitText->Enable();
}
else
{
m_exitButton->Disable();
m_exitText->Disable();
}
}
void SUIMainMenuWnd::showArenaButton(bool show)
{
m_arenaButton->SetShow(show);
m_arenaText->SetShow(show);
}
void SUIMainMenuWnd::showInstanceButton(bool show)
{
m_instanceButton->SetShow(show);
}
void SUIMainMenuWnd::showExitButton(bool show)
{
m_exitButton->SetShow(show);
m_exitText->SetShow(show);
}
bool SUIMainMenuWnd::checkValidArenaJoinSituationAtEntrance()
{
sArenaRankInfo rankInfo;
int rank = rankInfo.getRank();
if (sArenaUtility::RANK_NONE == rank)
{
sArenaJoinSituationCondition situationCondition;
situationCondition.m_notificationWays = cArenaJoinSituationChecker::WAY_NOTIFICATION_WND;
situationCondition.addNone(S(2467));
g_pCurrentGameSystem->isValidArenaJoinSituation(situationCondition);
return false;
}
return true;
}
int SUIMainMenuWnd::calcInstanceArenaStatus()
{
SGameLocalPlayer* localPlayer = dynamicCast<SGameLocalPlayer*>(g_pCurrentGameSystem->GetLocalPlayer());
if (!localPlayer)
return SGameLocalPlayer::IAS_NORMAL;
int iasStatus = SGameLocalPlayer::IAS_NORMAL;
if(localPlayer->IsInBearroad())
{
iasStatus = SGameLocalPlayer::IAS_BEARLOAD;
}
else if(localPlayer->IsInBearroadLobby())
{
iasStatus = SGameLocalPlayer::IAS_BEARLOADLOBBY;
}
else if(localPlayer->IsInDeathMatch())
{
iasStatus = SGameLocalPlayer::IAS_DEATHMATCH;
}
else
{
/// 윈도우의 상태를 체크해야 되서 이렇게 했는데, 보기에는 복잡하지만 자주 호출 되는게 아니라서 큰 무리는 없을 것 같음,,
/// 좋은 생각이 안남;;
SUIWnd* arenaMenuWnd = m_pGameManager->GetSUI(SIMSG_TOGGLE_UIWINDOW::UIWINDOW_ARENA_MENU);
SUIWnd* selectReadyWnd = m_pGameManager->GetSUI(SIMSG_TOGGLE_UIWINDOW::UIWINDOW_ARENA_SELECTION_READY);
SUIWnd* practiceReadyWnd = m_pGameManager->GetSUI(SIMSG_TOGGLE_UIWINDOW::UIWINDOW_ARENA_PRACTICE_READY);
SUIWnd* waitingWnd = m_pGameManager->GetSUI(SIMSG_TOGGLE_UIWINDOW::UIWINDOW_ARENA_WAITING);
SUIWnd* practiceWaitingWnd = m_pGameManager->GetSUI(SIMSG_TOGGLE_UIWINDOW::UIWINDOW_ARENA_PRACTICE_WAITING);
SUIWnd* classicWnd = m_pGameManager->GetSUI(SIMSG_TOGGLE_UIWINDOW::UIWINDOW_ARENA_GAME_CLASSIC);
SUIWnd* slaughterWnd = m_pGameManager->GetSUI(SIMSG_TOGGLE_UIWINDOW::UIWINDOW_ARENA_GAME_SLAUGHTER);
SUIWnd* bingoWnd = m_pGameManager->GetSUI(SIMSG_TOGGLE_UIWINDOW::UIWINDOW_ARENA_GAME_BINGO);
SUIWnd* slaughterPracticeWnd = m_pGameManager->GetSUI(SIMSG_TOGGLE_UIWINDOW::UIWINDOW_ARENA_GAME_SLAUGHTER_PRACTICE);
SUIWnd* instanceWnd = m_pGameManager->GetSUI(SIMSG_TOGGLE_UIWINDOW::UIWINDOW_INSTANCE_TASKBAR_ENTRANCE);
/// 동시에 여러 윈도우가 보여질 수 있기 때문에 우선순위를 둬서 체크한다
if ( instanceWnd && instanceWnd->IsShow())
{
iasStatus = SGameLocalPlayer::IAS_INSTANCE_MENU;
}
else if ( practiceWaitingWnd && practiceWaitingWnd->IsShow())
{
iasStatus = SGameLocalPlayer::IAS_ARENA_PRACTICE_WAITING;
}
else if ( waitingWnd && waitingWnd->IsShow())
{
iasStatus = SGameLocalPlayer::IAS_ARENA_WAITING;
}
else if ( slaughterPracticeWnd && slaughterPracticeWnd->IsShow())
{
iasStatus = SGameLocalPlayer::IAS_ARENA_PRACTICE;
}
else if ( (classicWnd&&classicWnd->IsShow()) || (slaughterWnd&&slaughterWnd->IsShow()) || (bingoWnd&&bingoWnd->IsShow()) )
{
iasStatus = SGameLocalPlayer::IAS_ARENA_GAME;
}
else if ( (arenaMenuWnd&&arenaMenuWnd->IsShow()) || (selectReadyWnd&&selectReadyWnd->IsShow()) || (practiceReadyWnd&&practiceReadyWnd->IsShow()) )
{
iasStatus = SGameLocalPlayer::IAS_ARENA_MENU;
}
}
return iasStatus;
}
void SUIMainMenuWnd::setInstanceArenaStatus(int iasStatus)
{
SGameLocalPlayer* localPlayer = dynamicCast<SGameLocalPlayer*>(g_pCurrentGameSystem->GetLocalPlayer());
if (!localPlayer)
return ;
int curIasStatus = localPlayer->getInstanceArenaStatus();
if (curIasStatus == iasStatus)
return ;
localPlayer->setInstanceArenaStatus(iasStatus);
setInstanceArenaButtonStatus(iasStatus);
}
void SUIMainMenuWnd::setInstanceArenaButtonStatus(int iasStatus)
{
if (SGameLocalPlayer::IAS_NORMAL == iasStatus)
{
showArenaButton(true);
showInstanceButton(false); //true
showExitButton(false);
}
else if (SGameLocalPlayer::IAS_ARENA_MENU == iasStatus)
{
showArenaButton(true);
showInstanceButton(false); //true
showExitButton(false);
}
else if (SGameLocalPlayer::IAS_ARENA_WAITING == iasStatus ||
SGameLocalPlayer::IAS_ARENA_PRACTICE_WAITING == iasStatus ||
SGameLocalPlayer::IAS_ARENA_PRACTICE == iasStatus ||
SGameLocalPlayer::IAS_ARENA_GAME == iasStatus ||
SGameLocalPlayer::IAS_DEATHMATCH == iasStatus ||
SGameLocalPlayer::IAS_BEARLOAD == iasStatus ||
SGameLocalPlayer::IAS_BEARLOADLOBBY == iasStatus)
{
showArenaButton(false);
showInstanceButton(false);
showExitButton(true);
}
enableExitButton(true);
}
void SUIMainMenuWnd::clickExitButton()
{
SGameLocalPlayer* localPlayer = dynamicCast<SGameLocalPlayer*>(g_pCurrentGameSystem->GetLocalPlayer());
if (!localPlayer)
return ;
int curIasStatus = localPlayer->getInstanceArenaStatus();
sArenaSystem* arenaSystem = g_pCurrentGameSystem->getArenaSystem();
if (SGameLocalPlayer::IAS_ARENA_WAITING == curIasStatus)
{
int stringId;
if (arenaSystem->isRecvBattleInfo()) stringId = 2486;
else stringId = 2485;
m_pGameManager->GetGameInterface()->OpenMessageBox(SIMSG_REQ_OPEN_MSGBOX::MSGBOX_OKCANCEL, SIMSG_REQ_OPEN_MSGBOX::MSGBOX_ARENA_WAITING_EXIT, false, stringId, "", 0, false);
}
else if (SGameLocalPlayer::IAS_ARENA_PRACTICE_WAITING == curIasStatus)
{
m_pGameManager->GetGameInterface()->OpenMessageBox(SIMSG_REQ_OPEN_MSGBOX::MSGBOX_OKCANCEL, SIMSG_REQ_OPEN_MSGBOX::MSGBOX_ARENA_PRACTICE_WAITING_EXIT, true, 2485, "", 0, false);
}
else if (SGameLocalPlayer::IAS_ARENA_PRACTICE == curIasStatus)
{
m_pGameManager->GetGameInterface()->OpenMessageBox(SIMSG_REQ_OPEN_MSGBOX::MSGBOX_OKCANCEL, SIMSG_REQ_OPEN_MSGBOX::MSGBOX_ARENA_PRACTICE_EXIT, false, 2422, "", 0, false);
}
else if (SGameLocalPlayer::IAS_ARENA_GAME == curIasStatus)
{
m_pGameManager->GetGameInterface()->OpenMessageBox(SIMSG_REQ_OPEN_MSGBOX::MSGBOX_OKCANCEL, SIMSG_REQ_OPEN_MSGBOX::MSGBOX_ARENA_GAME_EXIT, false, 2486, "", 0, false);
}
else if (SGameLocalPlayer::IAS_DEATHMATCH == curIasStatus)
{
//게임밖으로.. 나갈지 묻는다.
m_pGameManager->PostMsgAtDynamic( new SIMSG_REQ_OPEN_MSGBOX(SIMSG_REQ_OPEN_MSGBOX::MSGBOX_DEATHMATCH_EXIT, S( 9206 ), "deathmatchexit" ) );
}
else if (SGameLocalPlayer::IAS_BEARLOAD == curIasStatus)
{
//베어로드 로비로 나올것
if( g_pCurrentGameSystem->GetContentsMgr().acquire< SHuntaHolicSystem >( "huntaholic" )->isHunting() )
{
if( g_pCurrentGameSystem->GetContentsMgr().acquire< SHuntaHolicSystem >( "huntaholic" )->isObjCompleted() )
{
m_pGameManager->PostMsgAtDynamic(new SIMSG_REQ_OPEN_MSGBOX(SIMSG_REQ_OPEN_MSGBOX::MSGBOX_HUNTAHOLIC_SCOREBOARD, S( 6671 ), "huntaholic_scoreboard" ) );
}
else
{
m_pGameManager->PostMsgAtDynamic(new SIMSG_REQ_OPEN_MSGBOX(SIMSG_REQ_OPEN_MSGBOX::MSGBOX_HUNTAHOLIC_SCOREBOARD, S( 6670 ), "huntaholic_scoreboard" ) );
}
}
}
else if (SGameLocalPlayer::IAS_BEARLOADLOBBY == curIasStatus)
{
//베어로드 로비에서 게임으로..
SMSG_INSTANCE_GAME_EXIT *pMsg = new SMSG_INSTANCE_GAME_EXIT();
m_pGameManager->PostMsgAtDynamic( pMsg );
}
}
void SUIMainMenuWnd::updateInstanceArenaStatus()
{
int iasStatus = calcInstanceArenaStatus();
setInstanceArenaStatus(iasStatus);
}