227 lines
5.7 KiB
C++
227 lines
5.7 KiB
C++
#include "stdafx.h"
|
|
#include "SUIInGameLogoutWnd.h"
|
|
#include "SGameManager.h"
|
|
//#include "SGameMessageUI.h"
|
|
#include "SGameMessage.h"
|
|
|
|
#include "SStringDB.h"
|
|
#include "SUISysMsgDefine.h"
|
|
|
|
#include "KUIControlStatic.h"
|
|
#include "KUIControlButton.h"
|
|
|
|
#include <toolkit/XStringUtil.h>
|
|
|
|
namespace
|
|
{
|
|
const char* c_szStatic_msg = "static_msg";
|
|
const char* c_szButton_logout = "button_logout";
|
|
const char* c_szButton_cancel = "button_cancel";
|
|
};
|
|
|
|
SUIInGameLogoutWnd::SUIInGameLogoutWnd( SGameManager* pGameManager )
|
|
: SUIWnd( pGameManager )
|
|
, m_dwStartTime( 0 )
|
|
, m_dwEndTime( 20000 )
|
|
, m_bStart( false )
|
|
, m_pStaticCtrl( NULL )
|
|
, m_pLogOutButtonCtrl( NULL )
|
|
, m_pCancelButtonCtrl( NULL )
|
|
, m_Type( GAME_LOGOUT )
|
|
|
|
{
|
|
}
|
|
|
|
SUIInGameLogoutWnd::~SUIInGameLogoutWnd()
|
|
{
|
|
m_pStaticCtrl = NULL;
|
|
}
|
|
|
|
bool SUIInGameLogoutWnd::InitControls( KPoint kPos )
|
|
{
|
|
m_pStaticCtrl = dynamicCast<KUIControlStatic*>(GetChild( c_szStatic_msg ));
|
|
m_pLogOutButtonCtrl = dynamicCast<KUIControlButton*>(GetChild( c_szButton_logout ));
|
|
|
|
if( m_pStaticCtrl )
|
|
{
|
|
m_strDeco = m_pStaticCtrl->GetCaption();
|
|
std::string::size_type nFPos = m_strDeco.find( "<$" );
|
|
if( nFPos != std::string::npos )
|
|
{
|
|
m_strDeco = m_strDeco.substr( 0, nFPos );
|
|
}
|
|
}
|
|
|
|
|
|
std::string strDeco;
|
|
|
|
if( m_pLogOutButtonCtrl )
|
|
{
|
|
m_pLogOutButtonCtrl->SetEnableColor( "<#ffffff>" );
|
|
strDeco = m_pLogOutButtonCtrl->GetCaption();
|
|
std::string::size_type nFPos = strDeco.find( "<$" );
|
|
if( nFPos != std::string::npos )
|
|
{
|
|
strDeco = strDeco.substr( 0, nFPos );
|
|
}
|
|
|
|
m_pLogOutButtonCtrl->SetCaption( CStringUtil::StringFormat( "%s%s", strDeco.c_str(), GetStringDB().GetString( SYS_MSG_CONFIRM_BTN ) ).c_str() );
|
|
}
|
|
|
|
m_pCancelButtonCtrl = dynamicCast<KUIControlButton*>(GetChild( c_szButton_cancel ));
|
|
if( m_pCancelButtonCtrl )
|
|
{
|
|
m_pCancelButtonCtrl->SetEnableColor( "<#ffffff>" );
|
|
m_pCancelButtonCtrl->SetCaption( CStringUtil::StringFormat( "%s%s", strDeco.c_str(), GetStringDB().GetString( SYS_MSG_CANCEL_BTN ) ).c_str() );
|
|
}
|
|
|
|
return SUIWnd::InitControls( kPos );
|
|
}
|
|
|
|
bool SUIInGameLogoutWnd::InitData( bool bReload )
|
|
{
|
|
return SUIWnd::InitData( bReload );
|
|
}
|
|
|
|
void SUIInGameLogoutWnd::OnNotifyUIWindowOpen( bool bOpen, bool bLimitWnd )
|
|
{
|
|
m_bStart = bOpen;
|
|
m_dwStartTime = 0;
|
|
|
|
SUIWnd::OnNotifyUIWindowOpen( bOpen, bLimitWnd );
|
|
}
|
|
|
|
void SUIInGameLogoutWnd::ProcMsgAtStatic( SGameMessage* pMsg )
|
|
{
|
|
SUIWnd::ProcMsgAtStatic( pMsg );
|
|
}
|
|
|
|
void SUIInGameLogoutWnd::PumpUpMessage( LPCSTR lpszControlID, DWORD nMessage, DWORD lparam, DWORD wparam )
|
|
{
|
|
switch( nMessage )
|
|
{
|
|
case KUI_MESSAGE::KBUTTON_CLICK:
|
|
{
|
|
if( strcmp( lpszControlID, c_szButton_logout ) == 0 ||
|
|
::_stricmp( lpszControlID, "IDOK" ) == 0 )
|
|
{
|
|
CloseWnd();
|
|
|
|
if( GetOutType() == GAME_LOGOUT_INT_TOWN )
|
|
m_pGameManager->PostMsgAtDynamic( new SIMSG_UI_REQ_RETURN_LOBBY( true ) );
|
|
else if( GetOutType() == GAME_EXIT_IN_TOWN )
|
|
m_pGameManager->PostMsgAtDynamic( new STMSG_REQ_CLOSE_EX );
|
|
}
|
|
else if( strcmp( lpszControlID, c_szButton_cancel ) == 0 ||
|
|
::_stricmp( lpszControlID, "IDCANCEL" ) == 0 )
|
|
{
|
|
m_pGameManager->PostMsgAtDynamic( new SIMSG_SHOW_UIWINDOW( (SIMSG_TOGGLE_UIWINDOW::_UIWINDOW_TYPE)m_nWindowID, false, true ) );
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
|
|
SUIWnd::PumpUpMessage( lpszControlID, nMessage, lparam, wparam );
|
|
}
|
|
|
|
void SUIInGameLogoutWnd::CloseWnd()
|
|
{
|
|
m_bStart = false;
|
|
m_dwStartTime = 0;
|
|
|
|
m_pGameManager->PostMsgAtDynamic( new SIMSG_SHOW_UIWINDOW( (SIMSG_TOGGLE_UIWINDOW::_UIWINDOW_TYPE)m_nWindowID, false, true ) );
|
|
}
|
|
|
|
void SUIInGameLogoutWnd::SetOutType( OUT_TYPE type, int cooltime )
|
|
{
|
|
if( type == GAME_LOGOUT_INT_TOWN )
|
|
{
|
|
if( m_pStaticCtrl )
|
|
m_pStaticCtrl->SetCaption( CStringUtil::StringFormat( "%s%s", m_strDeco.c_str(), GetStringDB().GetString( SYS_MSG_LOGOUT_TOWN02 ) ).c_str() );
|
|
|
|
if( m_pLogOutButtonCtrl )
|
|
m_pLogOutButtonCtrl->Enable();
|
|
}
|
|
else if( type == GAME_EXIT_IN_TOWN )
|
|
{
|
|
if( m_pStaticCtrl )
|
|
m_pStaticCtrl->SetCaption( CStringUtil::StringFormat( "%s%s", m_strDeco.c_str(), GetStringDB().GetString( SYS_MSG_LOGOUT_TOWN01 ) ).c_str() );
|
|
|
|
if( m_pLogOutButtonCtrl )
|
|
m_pLogOutButtonCtrl->Enable();
|
|
}
|
|
else
|
|
{
|
|
if( m_pLogOutButtonCtrl ) m_pLogOutButtonCtrl->Disable();
|
|
}
|
|
|
|
m_dwEndTime = (DWORD)cooltime*1000;
|
|
|
|
m_Type = type;
|
|
}
|
|
|
|
void SUIInGameLogoutWnd::Process( DWORD dwTime )
|
|
{
|
|
if( m_bStart == false ) return;
|
|
|
|
if( GetOutType() != GAME_LOGOUT &&
|
|
GetOutType() != GAME_EXIT )
|
|
{
|
|
return;
|
|
}
|
|
|
|
if( m_dwStartTime == 0 )
|
|
m_dwStartTime = dwTime;
|
|
|
|
std::string str;
|
|
|
|
DWORD time = (dwTime - m_dwStartTime);
|
|
if( time < m_dwEndTime )
|
|
{
|
|
if( m_pStaticCtrl )
|
|
{
|
|
int left_time = (int)((m_dwEndTime/1000) - (time / 1000));
|
|
|
|
if( GetOutType() == GAME_LOGOUT )
|
|
str = GetStringDB().GetString( SYS_MSG_LOGOUT_TIMER_02 );
|
|
else
|
|
str = GetStringDB().GetString( SYS_MSG_LOGOUT_TIMER_01 );
|
|
|
|
str += SR( SYS_MSG_LOGOUT_COUNTER, "#@counter@#", left_time );
|
|
//m_pStaticCtrl->SetCaption( str.c_str() );
|
|
m_pStaticCtrl->SetCaption( ( m_strDeco + str ).c_str() ); // 수정. bintitle. 2010.06.21.
|
|
|
|
}
|
|
}
|
|
else
|
|
{
|
|
CloseWnd();
|
|
|
|
if( GetOutType() == GAME_LOGOUT )
|
|
{
|
|
if( m_pStaticCtrl )
|
|
{
|
|
str = GetStringDB().GetString( SYS_MSG_LOGOUT_TIMER_02 );
|
|
str += SR( SYS_MSG_LOGOUT_COUNTER, "#@counter@#", 0 );
|
|
|
|
//m_pStaticCtrl->SetCaption( str.c_str() );
|
|
m_pStaticCtrl->SetCaption( ( m_strDeco + str ).c_str() ); // 수정. bintitle. 2010.06.21.
|
|
}
|
|
|
|
m_pGameManager->PostMsgAtDynamic( new SIMSG_UI_REQ_RETURN_LOBBY( true ) );
|
|
}
|
|
else
|
|
{
|
|
if( m_pStaticCtrl )
|
|
{
|
|
str = GetStringDB().GetString( SYS_MSG_LOGOUT_TIMER_01 );
|
|
str += SR( SYS_MSG_LOGOUT_COUNTER, "#@counter@#", 0 );
|
|
|
|
//m_pStaticCtrl->SetCaption( str.c_str() );
|
|
m_pStaticCtrl->SetCaption( ( m_strDeco + str ).c_str() ); // 수정. bintitle. 2010.06.21.
|
|
}
|
|
|
|
m_pGameManager->PostMsgAtDynamic( new STMSG_REQ_CLOSE_EX );
|
|
}
|
|
}
|
|
} |