Files
Leviathan/Client/Game/game/Interface/Lobby/SUICharNameListWnd.cpp
T
2026-06-01 12:46:52 +02:00

332 lines
10 KiB
C++

#include "stdafx.h"
//#include "KUIControlNumber.h"
#include "SGameManager.h"
#include "SUICharNameListWnd.h"
#include "SGameMessage.h"
//#include "SGameMessageUI.h"
#include "SJobDB.h"
//#include "Util.h"
//#include "KUIControl.h"
#include "SDebug_Util.h"
namespace
{
const char* c_szViewNameBar = "select_name_text";
const char* c_szJobNameText = "select_jobname_text";
const char* c_szJobIcon = "static_job_icon";
const char* c_szLevelNumber = "select_lv_number";
const char* c_szJobLevelNumber = "select_jlv_number";
const char* c_szLevelFont = "select_lv_font";
const char* c_szJobLevelFont = "select_jlv_font";
const char* c_szLevelBG = "select_lv_bg";
const char* c_szCharacterSelect = "character_select_";
//const char* c_szSelectionBox = "select_selectline";
//const char* c_szSelectionBG = "select_selectback";
// const int c_nSelectionBoxGapWidth = (-5);
// const int c_nSelectionBoxGapHeight = (-5);
};
bool SUICharNameListWnd::InitControls( KPoint kPos )
{
for( int nIndex( 0 ); nIndex < GameRule::nMaxCharactersPerAccount; ++nIndex )
{
KUIWnd* pStaticLevelBG = GetChild( GetNumberedControlName( c_szLevelBG, nIndex ).c_str() );
SetChildShow( GetNumberedControlName( c_szViewNameBar , nIndex ).c_str(), false );
SetChildShow( GetNumberedControlName( c_szJobNameText , nIndex ).c_str(), false );
SetChildShow( GetNumberedControlName( c_szJobIcon , nIndex ).c_str(), false );
SetChildShow( GetNumberedControlName( c_szLevelNumber , nIndex ).c_str(), false );
SetChildShow( GetNumberedControlName( c_szJobLevelNumber, nIndex ).c_str(), false );
SetChildShow( GetNumberedControlName( c_szLevelFont , nIndex ).c_str(), false );
SetChildShow( GetNumberedControlName( c_szJobLevelFont , nIndex ).c_str(), false );
SetChildShow( GetNumberedControlName( c_szCharacterSelect, nIndex ).c_str(), false );
if( pStaticLevelBG )
{
m_rcCharSelect[ nIndex ] = KRect
( pStaticLevelBG->GetRect().left
, pStaticLevelBG->GetRect().top
, pStaticLevelBG->GetRect().right
, pStaticLevelBG->GetRect().bottom );
}
}
return SUIWnd::InitControls(kPos);
}
bool SUICharNameListWnd::InitData( bool bReload )
{
m_nSelectedIndex = -1;
//SetChildShow( c_szSelectionBox, false );
//SetChildShow( c_szSelectionBG , false );
return SUIWnd::InitData(bReload);
}
void SUICharNameListWnd::OnNotifyUIWindowOpen( bool bOpen, bool bLimitWnd /* = true*/ )
{
if( bOpen )
{
}
else
{
// 2008. 6. 17 floyd #2.3.1.24
// http://bug.nflavor.com/view.php?id=3403 관련 수정
// 로비에서 Ctrl-H키를 눌러 인터페이스를 숨겼다가 다시 열었을때 캐릭터 선택이 제대로 안되는 문제 수정
// m_nCrrMaxIndex = -1;
}
SUIWnd::OnNotifyUIWindowOpen( bOpen, bLimitWnd );
}
void SUICharNameListWnd::PumpUpMessage( LPCSTR lpszControlID, DWORD nMessage, DWORD lparam, DWORD wparam )
{
switch( nMessage )
{
case KUI_MESSAGE::KBUTTON_CLICK:
{
if( strcmp( lpszControlID, "entergamebtn" ) == 0 )
{
//m_pGameManager->StartSound( "ui_click_login02.wav" );
// m_pGameManager->StartSound( "ui_click_select01.wav" );
m_pGameManager->StartSound( "ui_bgm_antechamber01.wav" );
}
else if( strcmp( lpszControlID, "selectserverbtn" ) == 0 )
{
m_pGameManager->StartSound( "ui_bgm_antechamber01.wav" );
}
m_pGameManager->ProcMsgAtStatic( &SIMSG_UIWND_NOTIFY_TO_LOBBY( lpszControlID ) );
}
break;
case KUI_MESSAGE::KFOCUS_ACTIVATED:
{
for( int nIndex( 0 ); nIndex < GameRule::nMaxCharactersPerAccount; ++nIndex )
{
if( m_rcCharSelect[ nIndex ].IsInRect( int(lparam) - GetRect().left, int(wparam) - GetRect().top ) )
{
if( m_nCrrMaxIndex >= nIndex )
{
m_pGameManager->ProcMsgAtStatic( &SIMSG_UIWND_NOTIFY_TO_LOBBY( GetNumberedControlName( "avatarSelect", nIndex ).c_str() ) );
break;
}
}
}
}
break;
}
SUIWnd::PumpUpMessage( lpszControlID, nMessage, lparam, wparam );
}
void SUICharNameListWnd::ProcMsgAtStatic( SGameMessage* pMsg )
{
switch( pMsg->nType )
{
case IMSG_UI_SEND_DATA:
{
SIMSG_UI_SEND_DATA* pData = (SIMSG_UI_SEND_DATA*)pMsg;
if( pData->m_strString == "set_focus_charnamelist_wnd" )
{
m_pManager->SetFocus(this);
}
}
}
}
void SUICharNameListWnd::SetSelectedCharInfo( int nIndex, int nLevel/* = 0*/, int nJobLevel/* = 0*/, int nJobID/* = (-1)*/, const char* szName/* = ""*/, bool bSelected/* = false*/ )
{
// if( 0 <= nIndex && nIndex < c_nCharNameCount )
{
// 선택 박스 처리
//KUIWnd* pStaticSelectionBox = GetChild( c_szSelectionBox );
//KUIWnd* pStaticSelectionBg = GetChild( c_szSelectionBG );
// if( NULL != pStaticSelectionBox && NULL != pStaticSelectionBg )
//for( int i( 0 ); i < c_nCharNameCount; ++i )
//SetChildShow( GetNumberedControlName( c_szCharacterSelect, i ).c_str(), false );
{
if( bSelected )
{
for( int i( 0 ); i < GameRule::nMaxCharactersPerAccount; ++i )
SetChildShow( GetNumberedControlName( c_szCharacterSelect, i ).c_str(), false );
m_nSelectedIndex = nIndex;
/*pStaticSelectionBox->MovePos
( GetRect().left + m_rcCharSelect[ nIndex ].left + c_nSelectionBoxGapWidth
, GetRect().top + m_rcCharSelect[ nIndex ].top );
pStaticSelectionBg->MovePos
( GetRect().left + m_rcCharSelect[ nIndex ].left + c_nSelectionBoxGapWidth
, GetRect().top + m_rcCharSelect[ nIndex ].top );*/
//pStaticSelectionBox->SetShow( true );
//pStaticSelectionBg->SetShow( true );
SetChildShow( GetNumberedControlName( c_szCharacterSelect, m_nSelectedIndex ).c_str(), true );
}
else
{
if( m_nSelectedIndex == nIndex )
{
m_nSelectedIndex = (-1);
//pStaticSelectionBox->SetShow( false );
//pStaticSelectionBg->SetShow( false );
}
}
}
// 이름
std::string strName = "<#fbe6b1><size:12><hcenter>";
strName += szName;
if( ::strlen(szName) )
m_nCrrMaxIndex = ::max(m_nCrrMaxIndex, nIndex);
std::string strNameBar = GetNumberedControlName( c_szViewNameBar, nIndex ).c_str();
SetChildCaption( strNameBar.c_str(), strName.c_str() );
SetChildShow ( strNameBar.c_str(), true );
// 직업 이름
const char* szJobName = ((-1) != nJobID) ? GetJobDB().GetJobName( nJobID ) : NULL;
std::string strJobName = "<hcenter><size:10>";
strJobName += (NULL != szJobName) ? szJobName : "";
std::string strJobNameText = GetNumberedControlName( c_szJobNameText, nIndex ).c_str();
SetChildShow ( strJobNameText.c_str(), true );
SetChildCaption( strJobNameText.c_str(), strJobName.c_str() );
//직업 아이콘
const char* szJobIconName = ((-1) != nJobID) ? GetJobDB().GetJobIconName( nJobID ) : NULL;
if( szJobIconName && nJobID != 0)
{
SetChildAniName( GetNumberedControlName( c_szJobIcon, nIndex ).c_str(), szJobIconName);
SetChildShow ( GetNumberedControlName( c_szJobIcon, nIndex ).c_str(), true );
}
else
{
SetChildShow ( GetNumberedControlName( c_szJobIcon, nIndex ).c_str(), false );
}
char szNum[10];
itoa( nLevel, szNum, 10 );
// 레벨
std::string strLevelNumber = GetNumberedControlName( c_szLevelNumber, nIndex ).c_str();
SetChildShow ( strLevelNumber.c_str(), (nLevel > 0) );
if( (nLevel > 0) )
SetChildCaption( strLevelNumber.c_str(), szNum );
// 직업 레벨
itoa( nJobLevel, szNum, 10 );
std::string strJobLevelNumber = GetNumberedControlName( c_szJobLevelNumber, nIndex ).c_str();
SetChildShow ( strJobLevelNumber.c_str(), (nJobLevel > 0) );
if( (nLevel > 0) )
SetChildCaption( strJobLevelNumber.c_str(), szNum );
// "Lv" 폰트
SetChildShow( GetNumberedControlName( c_szLevelFont, nIndex ).c_str(), (nLevel > 0) );
// "JLv" 폰트
SetChildShow( GetNumberedControlName( c_szJobLevelFont, nIndex ).c_str(), (nJobLevel > 0) );
}
}
std::string SUICharNameListWnd::GetNumberedControlName( const char* szControlName, int nNum )
{
return CStringUtil::StringFormat( "%s%02d", szControlName, nNum );
}
int SUICharNameListWnd::GetControlIndex( int x, int y )
{
KUIWnd* pWnd(NULL);
for( int i(0); i<GameRule::nMaxCharactersPerAccount; ++i )
{
pWnd = GetChild( CStringUtil::StringFormat( "%s%02d", "select_lv_bg", i ).c_str() );
if( !pWnd ) continue;
if( pWnd->IsInRect(x,y) )
return i;
}
return -1;
}
DWORD SUICharNameListWnd::OnMouseMessage(DWORD dwMessage, int x, int y)
{
if( dwMessage == KLBUTTON_DBLCLK )
{
int nIndex = GetControlIndex( x, y );
if( nIndex != -1 )
{
m_pGameManager->StartSound( "ui_bgm_antechamber01.wav" );
m_pGameManager->PostMsgAtDynamic( new SMSG_SEND_DATA( nIndex, "dclick_login_char" ) );
}
}
return SUIWnd::OnMouseMessage(dwMessage, x, y);
}
DWORD SUICharNameListWnd::OnKeyMessage(DWORD dwMessage, DWORD dwKeyCode)
{
if( IsShow() )
{
if( dwKeyCode == VK_DOWN )
m_pGameManager->PostMsgAtDynamic( new SMSG_SEND_DATA( "char_select_down" ) );
if( dwKeyCode == VK_UP )
{
m_pGameManager->PostMsgAtDynamic( new SMSG_SEND_DATA( "char_select_up" ) );
}
else if( dwKeyCode == VK_RETURN )
{
m_pGameManager->StartSound( "ui_bgm_antechamber01.wav" );
m_pGameManager->PostMsgAtDynamic( new SMSG_SEND_DATA( m_nSelectedIndex, "login_char" ) );
}
}
return KUIWnd::OnKeyMessage(dwMessage, dwKeyCode);
}
void SUISelectCharInfoWnd::SetAvatarData( int nLv, int nJobLv, int nJobID, const char* lpName )
{
if( lpName )
SetChildCaption( "select_name_text00", CStringUtil::StringFormat( "<#fbe6b1><size:12><hcenter><vcenter>%s", lpName ).c_str() );
else SetChildCaption( "select_name_text00", "" );
const char* szJobName = ((-1) != nJobID) ? GetJobDB().GetJobName( nJobID ) : NULL;
if( szJobName )
SetChildCaption( "select_jobname_text00", CStringUtil::StringFormat( "<#fbe6b1><size:12><hcenter><vcenter>%s", szJobName ).c_str() );
else SetChildCaption( "select_jobname_text00", "" );
SetChildCaption( "select_lv_number00", CStringUtil::StringFormat( "%d", nLv ).c_str() );
SetChildCaption( "select_Jlv_number00", CStringUtil::StringFormat( "%d", nJobLv ).c_str() );
//직업 아이콘
const char* szJobIconName = ((-1) != nJobID) ? GetJobDB().GetJobIconName( nJobID ) : NULL;
if( szJobIconName && nJobID != 0)
{
SetChildAniName( "static_job_icon00", szJobIconName);
SetChildShow ( "static_job_icon00", true );
}
else
{
SetChildShow ( "static_job_icon00", false );
}
}