#include "NetCli_TalkChild.h"
#include "../../mainproc/GameMain.h"
#include "../../Interface/WorldFrames/ChatFrame.h"

//-----------------------------------------------------------------------------
bool NetCli_TalkChild::_Init()
{
	if (This)
		return false;
	This = new NetCli_TalkChild;
	return NetCli_Talk::_Init();
}

//-----------------------------------------------------------------------------
bool NetCli_TalkChild::_Release()
{
	NetCli_Talk::_Release();
	if (This)
	{
		delete This;
		This = NULL;
	}
	return true;
}

//-----------------------------------------------------------------------------
void NetCli_TalkChild::Rev_TalkTo( const char* SenderName , const char* TargetName, int ContentSize , const char* Content )
{	
	if ( strcmp(SenderName, g_pGameMain->GetPlayerName()) == 0 )
		g_pChatFrame->SendMsgEvent(CHAT_MSG_WHISPER_INFORM, Content, TargetName);
	else
		g_pChatFrame->SendMsgEvent(CHAT_MSG_WHISPER, Content, SenderName);
}

//-----------------------------------------------------------------------------
void NetCli_TalkChild::Rev_Range( int Sayer , const char* Name , int ContentSize , const char* Content )
{
	g_pChatFrame->SendMsgEvent(CHAT_MSG_SAY, Content, Name);
}

//-----------------------------------------------------------------------------
/*
void NetCli_TalkChild::Rev_Zone( int Sayer , const char* Name , int ContentSize , const char* Content )
{
	char tmp[512];
	sprintf( tmp, "[%s]:%s", Name, Content );
	g_pChatFrame->AddMessage(eMessage_Channel_Zone, tmp);
}
*/
//-----------------------------------------------------------------------------
void NetCli_TalkChild::Rev_SystemMsg( int ContentSize , const char* Content )
{
	g_pChatFrame->SendMsgEvent(CHAT_MSG_SYSTEM, Content, "");
}

//-----------------------------------------------------------------------------
void NetCli_TalkChild::Rev_GmMsg( const char* Msg )
{
	g_pChatFrame->SendMsgEvent(CHAT_MSG_SYSTEM, Msg, "");
}
//-----------------------------------------------------------------------------
void NetCli_TalkChild::Rev_Channel	( GroupObjectTypeEnum Type , int ChannelID , TalkChannelTypeENUM MsgType , char* Name , char* Content )
{
	char tmp[512];

	switch( Type )
	{
	case EM_GroupObjectType_SysChannel:
		sprintf( tmp, "[系統頻道 %d][%s]:%s", ChannelID ,  Name, Content );
		g_pChatFrame->AddMessage(0, tmp);
		break;
	case EM_GroupObjectType_SysZoneChannel:
		sprintf( tmp, "[區域頻道 %d][%s]:%s", ChannelID ,  Name, Content );
		g_pChatFrame->AddMessage(0, tmp);
		break;

	case EM_GroupObjectType_PlayerChannel:
		sprintf( tmp, "[頻道 %d][%s]:%s", ChannelID ,  Name, Content );
		g_pChatFrame->AddMessage(0, tmp);
		break;
	case EM_GroupObjectType_Party:
		g_pChatFrame->SendMsgEvent(CHAT_MSG_PARTY, Content, Name);
		//sprintf( tmp, "[隊伍 %d][%s]:%s", ChannelID ,  Name, Content );
		//g_pChatFrame->AddMessage(0, tmp);
		break;
	case EM_GroupObjectType_Guild:
		sprintf( tmp, "[工會 %d][%s]:%s", ChannelID ,  Name, Content );
		g_pChatFrame->AddMessage(0, tmp);
		break;
	}
}
//-----------------------------------------------------------------------------