197 lines
4.7 KiB
C++
197 lines
4.7 KiB
C++
#include "stdafx.h"
|
|
|
|
#include <mmo/ArType.h>
|
|
#include "SUIDefine.h"
|
|
#include "SGameManager.h"
|
|
#include "SGameSystem.h"
|
|
//#include "SGameMessageUI.h"
|
|
#include "SNetMessage.h"
|
|
#include "SGameMessage.h"
|
|
#include "ErrorCode/ErrorCode.h"
|
|
#include "KUIWndManager.h"
|
|
#include "KUIControlStatic.h"
|
|
#include "KUIControlButton.h"
|
|
#include "SStringDB.h"
|
|
#include "SHuntaHolicResourceDB.h"
|
|
#include "TemplateUtil.h"
|
|
|
|
#include "SHuntaHolicSystem.h"
|
|
#include "SGameSystem.h"
|
|
#include "SUIHuntaHolicCreateInstanceWnd.h"
|
|
|
|
#include "SDebug_Util.h"
|
|
|
|
extern SGameSystem* g_pCurrentGameSystem;
|
|
|
|
#define HUNTAHOLICSYSTEM g_pCurrentGameSystem->GetContentsMgr().acquire< SHuntaHolicSystem >( "huntaholic" )
|
|
|
|
namespace hhi = huntaholic_interface;
|
|
|
|
namespace {
|
|
|
|
const char* ctrl_title = "static_room_make_title";
|
|
const char* ctrl_name = "room_name_box";
|
|
const char* ctrl_password = "room_secret_number_box";
|
|
const char* ctrl_forces[ 3 ] = { "button_check", "button_check2", "button_check3" };
|
|
const char forcesNum[ 3 ] = { 4, 6, 8 };
|
|
const char* ctrl_confirm = "button_ok"; // servantes 2010.10.13
|
|
const char* ctrl_cancel = "button_cancel"; // servantes 2012.01.26
|
|
}
|
|
|
|
SUIHuntaHolicCreateInstanceWnd::SUIHuntaHolicCreateInstanceWnd( SGameManager* pGameManager )
|
|
: SUIWnd( pGameManager )
|
|
, mCallBack( 0 )
|
|
, mTitle( 0 )
|
|
, mName( 0 )
|
|
, mPW( 0 )
|
|
{
|
|
::memset( mForces, 0, sizeof( mForces ) );
|
|
}
|
|
|
|
SUIHuntaHolicCreateInstanceWnd::~SUIHuntaHolicCreateInstanceWnd()
|
|
{
|
|
}
|
|
|
|
void SUIHuntaHolicCreateInstanceWnd::Process( DWORD time )
|
|
{
|
|
SUIWnd::Process( time );
|
|
}
|
|
|
|
bool SUIHuntaHolicCreateInstanceWnd::InitControls( KPoint pos )
|
|
{
|
|
mName = dynamicCast<KUIControlEdit*>(GetChild( ctrl_name ));
|
|
if( mName )
|
|
{
|
|
mName->SetOnlyNumber( false );
|
|
mName->SetLimitation( GameRule::HUNTAHOLIC_MAX_INSTANCE_NAME_LENGTH / 2 );
|
|
}
|
|
|
|
mPW = dynamicCast<KUIControlEdit*>(GetChild( ctrl_password ));
|
|
if( mPW )
|
|
{
|
|
mPW->SetOnlyNumber( false );
|
|
mPW->SetLimitation( GameRule::HUNTAHOLIC_MAX_INSTANCE_PASSWORD_LENGTH );
|
|
mPW->SetPassword( true );
|
|
}
|
|
|
|
for( int i = 0; i < 3; ++i )
|
|
mForces[ i ] = dynamicCast<KUIControlCheck*>(GetChild( ctrl_forces[ i ] ));
|
|
|
|
return SUIWnd::InitControls( pos );
|
|
}
|
|
|
|
bool SUIHuntaHolicCreateInstanceWnd::InitData( bool reload )
|
|
{
|
|
return SUIWnd::InitData( reload );
|
|
}
|
|
|
|
void* SUIHuntaHolicCreateInstanceWnd::Perform( KID id, KArg& msg )
|
|
{
|
|
if( id == hhi::id_setCallBack )
|
|
{
|
|
hhi::setCallBack* real = static_cast< hhi::setCallBack* >( &msg );
|
|
mCallBack = real->callback;
|
|
}
|
|
|
|
return SUIWnd::Perform( id, msg );
|
|
}
|
|
|
|
void SUIHuntaHolicCreateInstanceWnd::PumpUpMessage( LPCTSTR controlID, DWORD msg, DWORD lparam, DWORD wparam )
|
|
{
|
|
switch( msg )
|
|
{
|
|
case KUI_MESSAGE::KBUTTON_CLICK:
|
|
{
|
|
if( !::stricmp( controlID, ctrl_cancel ) || !::stricmp( controlID, "idcancel" ) )
|
|
{
|
|
m_pGameManager->PostMsgAtDynamic( new SIMSG_SHOW_UIWINDOW( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_HUNTAHOLIC_CREATE_INSTANCE, false, true ) );
|
|
}
|
|
else if( !::stricmp( controlID, ctrl_confirm ) || !::stricmp( controlID, "idok" ) )
|
|
{
|
|
if( mCallBack )
|
|
{
|
|
std::string name, password;
|
|
int forcesIndex = 0;
|
|
|
|
if( mName ) name = mName->GetText();
|
|
if( mPW ) password = mPW->GetText();
|
|
|
|
for( int i = 0; i < 3; ++i )
|
|
if( mForces[ i ]->GetCheck() )
|
|
forcesIndex = i;
|
|
|
|
if( name.empty() )
|
|
return;
|
|
|
|
TS_CS_HUNTAHOLIC_CREATE_INSTANCE createArg;
|
|
|
|
::strcpy_s( createArg.name, name.c_str() );
|
|
createArg.max_member_count = forcesNum[ forcesIndex ];
|
|
if( !password.empty() ) ::strcpy_s( createArg.password, password.c_str() );
|
|
|
|
mCallBack->Perform( hhi::id_onCreateInstance, hhi::onCreateInstance( createArg ) );
|
|
}
|
|
m_pGameManager->PostMsgAtDynamic( new SIMSG_SHOW_UIWINDOW( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_HUNTAHOLIC_CREATE_INSTANCE, false, true ) );
|
|
}
|
|
}
|
|
break;
|
|
case KUI_MESSAGE::KCHECK_CHANGE:
|
|
{
|
|
for( int i = 0; i < 3; ++i )
|
|
if( !::stricmp( controlID, ctrl_forces[ i ] ) )
|
|
{
|
|
updateForces( i );
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
|
|
SUIWnd::PumpUpMessage( controlID, msg, lparam, wparam );
|
|
}
|
|
|
|
void SUIHuntaHolicCreateInstanceWnd::ProcMsgAtStatic( SGameMessage* msg )
|
|
{
|
|
}
|
|
|
|
void SUIHuntaHolicCreateInstanceWnd::OnNotifyUIWindowOpen( bool open, bool limitWnd )
|
|
{
|
|
if( open )
|
|
{
|
|
SetFocus( true );
|
|
|
|
mName->SetText( "" );
|
|
mPW->SetText( "" );
|
|
updateForces( 0 );
|
|
}
|
|
else
|
|
{
|
|
SetFocus( false );
|
|
}
|
|
}
|
|
|
|
DWORD SUIHuntaHolicCreateInstanceWnd::OnMouseMessage( DWORD msg, int x, int y )
|
|
{
|
|
DWORD ret = SUIWnd::OnMouseMessage( msg, x, y );
|
|
|
|
if( KMR_NO_GET & ret )
|
|
return ret;
|
|
|
|
// do something ...
|
|
|
|
return ret;
|
|
}
|
|
|
|
void SUIHuntaHolicCreateInstanceWnd::OnFocusNotify()
|
|
{
|
|
}
|
|
|
|
void SUIHuntaHolicCreateInstanceWnd::updateForces( int index )
|
|
{
|
|
for( int i = 0; i < 3; ++i )
|
|
{
|
|
if( i != index )
|
|
mForces[ i ]->SetCheck( false );
|
|
else
|
|
mForces[ i ]->SetCheck( true );
|
|
}
|
|
} |