269 lines
6.9 KiB
C++
269 lines
6.9 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 "SUIHuntaHolicInstanceWnd.h"
|
|
#include <toolkit/nsl.h>
|
|
#include "SMessengerMgr.h"
|
|
#include "SChatType.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_roomNumber = "number_box01";
|
|
const char* ctrl_roomTitle = "room_title01";
|
|
const char* ctrl_roomSetup = "room_setup01";
|
|
const char* ctrl_roomVisitor = "person_box01";
|
|
const char* ctrl_enterRoom = "button_entrance_01";
|
|
const char* ctrl_leaveRoom = "button_entrance_02";
|
|
|
|
DWORD readycounttime = 0;
|
|
|
|
}
|
|
|
|
SUIHuntaHolicInstanceWnd::SUIHuntaHolicInstanceWnd( SGameManager* pGameManager )
|
|
: SUIWnd( pGameManager )
|
|
, m_StartHuntaHolicTime(0)
|
|
, m_StartHuntaHolicTime2(0)
|
|
, m_Begine_Countdown(false)
|
|
{
|
|
}
|
|
|
|
SUIHuntaHolicInstanceWnd::~SUIHuntaHolicInstanceWnd()
|
|
{
|
|
}
|
|
|
|
void SUIHuntaHolicInstanceWnd::Process( DWORD time )
|
|
{
|
|
SUIWnd::Process( time );
|
|
|
|
if(m_Begine_Countdown == true)
|
|
{
|
|
if(m_StartHuntaHolicTime == 0)
|
|
{
|
|
m_StartHuntaHolicTime = time;
|
|
m_StartHuntaHolicTime2 = time;
|
|
}
|
|
|
|
if(m_StartHuntaHolicTime >0 )
|
|
{
|
|
if(time - m_StartHuntaHolicTime2> 1000)
|
|
{
|
|
m_StartHuntaHolicTime2 += 1000;
|
|
|
|
std::string strRemain = GetStringDB().GetString( 9236 );
|
|
XStringUtil::Replace( strRemain, "#@time@#", CStringUtil::StringFormat( "%d", 11 - (DWORD)((m_StartHuntaHolicTime2 - m_StartHuntaHolicTime)/1000)) );
|
|
|
|
SMSG_CHATTING * chatmsg = new SMSG_CHATTING;
|
|
chatmsg->handle = 0;
|
|
chatmsg->nChatType = CHAT_NOTICE;
|
|
chatmsg->szSender = "@NOTICE";//"notice";
|
|
chatmsg->strText = strRemain;
|
|
chatmsg->nNoticeOnly = 0;
|
|
m_pGameManager->PostMsgAtDynamic( chatmsg );
|
|
|
|
//_oprint("[%d] %d - %d - %d\n", 9 - (DWORD)((m_StartHuntaHolicTime2 - m_StartHuntaHolicTime)/1000), time, m_StartHuntaHolicTime, m_StartHuntaHolicTime2 );
|
|
|
|
if( (DWORD)((m_StartHuntaHolicTime2 - m_StartHuntaHolicTime)/1000) > 5)
|
|
{
|
|
if( GetChild(ctrl_leaveRoom) )
|
|
dynamicCast<KUIControl*>(GetChild(ctrl_leaveRoom))->Disable();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
bool SUIHuntaHolicInstanceWnd::InitControls( KPoint pos )
|
|
{
|
|
cleanUp();
|
|
|
|
mInstance.add( sui::MakeUpdatableWindow( "room_number" , sui::SCaptionUpdator( "<size:10><hcenter>%s" ) , GetChild( ctrl_roomNumber ) ) );
|
|
mInstance.add( sui::MakeUpdatableWindow( "room_title" , sui::SCaptionUpdator( "<size:10><hcenter>%s" ) , GetChild( ctrl_roomTitle ) ) );
|
|
mInstance.add( sui::MakeUpdatableWindow( "room_setup" , sui::SCaptionUpdator( "<size:10><hcenter>%s" ) , GetChild( ctrl_roomSetup ) ) );
|
|
mInstance.add( sui::MakeUpdatableWindow( "room_visitor" , sui::SCaptionUpdator( "<size:10><hcenter><#ffffff>%s" ) , GetChild( ctrl_roomVisitor ) ) );
|
|
|
|
return SUIWnd::InitControls( pos );
|
|
}
|
|
|
|
bool SUIHuntaHolicInstanceWnd::InitData( bool reload )
|
|
{
|
|
return SUIWnd::InitData( reload );
|
|
}
|
|
|
|
void* SUIHuntaHolicInstanceWnd::Perform( KID id, KArg& msg )
|
|
{
|
|
if( id == hhi::id_updateMyInstance )
|
|
{
|
|
refreshInstance();
|
|
}
|
|
|
|
return SUIWnd::Perform( id, msg );
|
|
}
|
|
|
|
void SUIHuntaHolicInstanceWnd::PumpUpMessage( LPCTSTR controlID, DWORD msg, DWORD lparam, DWORD wparam )
|
|
{
|
|
switch( msg )
|
|
{
|
|
case KUI_MESSAGE::KBUTTON_CLICK:
|
|
{
|
|
if( !::stricmp( controlID, ctrl_leaveRoom ) )
|
|
{
|
|
HUNTAHOLICSYSTEM->reqLeaveInstance();
|
|
|
|
m_Begine_Countdown = false;
|
|
m_StartHuntaHolicTime2 = 0;
|
|
m_StartHuntaHolicTime = 0;
|
|
}
|
|
else if( !::stricmp( controlID, ctrl_enterRoom ) )
|
|
{
|
|
HUNTAHOLICSYSTEM->reqBeginHuntaHolic();
|
|
if( GetChild(ctrl_enterRoom) )
|
|
dynamicCast<KUIControl*>(GetChild(ctrl_enterRoom))->Disable();
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
|
|
SUIWnd::PumpUpMessage( controlID, msg, lparam, wparam );
|
|
}
|
|
|
|
void SUIHuntaHolicInstanceWnd::ProcMsgAtStatic( SGameMessage* msg )
|
|
{
|
|
switch( msg->nType )
|
|
{
|
|
case MSG_HUNTAHOLIC_BEGIN_COUNTDOWN:
|
|
{
|
|
|
|
// -1이 허용되지 않는다. 고쳐야할듯.
|
|
m_Begine_Countdown = true;
|
|
m_StartHuntaHolicTime2 = 0;
|
|
m_StartHuntaHolicTime = 0;
|
|
}
|
|
break;
|
|
case IMSG_INSTANCE_GAME_EXIT:
|
|
case MSG_HUNTAHOLIC_BEGIN_HUNTING:
|
|
{
|
|
m_Begine_Countdown = false;
|
|
m_StartHuntaHolicTime2 = 0;
|
|
m_StartHuntaHolicTime = 0;
|
|
}
|
|
break;
|
|
|
|
case MSG_CHATTING:
|
|
{
|
|
SMSG_CHATTING* pChatMsg = ( SMSG_CHATTING* )msg;
|
|
|
|
if( pChatMsg->nChatType == CHAT_PARTY_SYSTEM )
|
|
{
|
|
if( m_PartyMgr.IsExist() && m_PartyMgr.GetMemberCount() > 0 )
|
|
{
|
|
if( GetChild(ctrl_enterRoom) )
|
|
dynamicCast<KUIControl*>(GetChild(ctrl_enterRoom))->Disable();
|
|
|
|
//파티장인지 확인하고 맞으면 enable
|
|
if( m_PartyMgr.IsLeader() )
|
|
{
|
|
if( GetChild(ctrl_enterRoom) )
|
|
dynamicCast<KUIControl*>(GetChild(ctrl_enterRoom))->Enable();
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
|
|
void SUIHuntaHolicInstanceWnd::OnNotifyUIWindowOpen( bool open, bool limitWnd )
|
|
{
|
|
if( open )
|
|
{
|
|
cleanUpInstance();
|
|
}
|
|
}
|
|
|
|
DWORD SUIHuntaHolicInstanceWnd::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 SUIHuntaHolicInstanceWnd::cleanUp()
|
|
{
|
|
}
|
|
|
|
void SUIHuntaHolicInstanceWnd::refreshInstance()
|
|
{
|
|
const HuntaHolicInstance& instance = HUNTAHOLICSYSTEM->getMyInstance();
|
|
|
|
char buffer[ 256 ];
|
|
::sprintf_s( buffer, "%.3d", instance.instance_no );
|
|
|
|
mInstance[ "room_number" ].set_data( buffer );
|
|
mInstance[ "room_title" ].set_data( instance.name );
|
|
|
|
if( instance.require_password )
|
|
mInstance[ "room_setup" ].set_data( GetStringDB().GetString( 6635 ) );
|
|
else
|
|
mInstance[ "room_setup" ].set_data( GetStringDB().GetString( 6634 ) );
|
|
|
|
std::string visitor;
|
|
nsl::sprintf_str( visitor, "%d / %d", instance.current_member_count, instance.max_member_count );
|
|
|
|
mInstance[ "room_visitor" ].set_data( visitor.c_str() );
|
|
|
|
mInstance.update();
|
|
}
|
|
|
|
void SUIHuntaHolicInstanceWnd::cleanUpInstance()
|
|
{
|
|
mInstance[ "room_number" ].set_data( "" );
|
|
mInstance[ "room_title" ].set_data( "" );
|
|
mInstance[ "room_setup" ].set_data( "" );
|
|
mInstance[ "room_visitor" ].set_data( "" );
|
|
|
|
mInstance.update();
|
|
|
|
|
|
if( GetChild(ctrl_enterRoom) )
|
|
dynamicCast<KUIControl*>(GetChild(ctrl_enterRoom))->Disable();
|
|
|
|
if( GetChild(ctrl_leaveRoom) )
|
|
dynamicCast<KUIControl*>(GetChild(ctrl_leaveRoom))->Enable();
|
|
|
|
//파티장인지 확인하고 맞으면 enable
|
|
if( m_PartyMgr.IsLeader() )
|
|
{
|
|
if( GetChild(ctrl_enterRoom) )
|
|
dynamicCast<KUIControl*>(GetChild(ctrl_enterRoom))->Enable();
|
|
}
|
|
} |