218 lines
5.8 KiB
C++
218 lines
5.8 KiB
C++
|
|
#include "stdafx.h"
|
|
#include "KUITabControl.h"
|
|
#include "SGameManager.h"
|
|
#include "SUICommunityFriend.h"
|
|
//#include "SGameMessageUI.h"
|
|
#include "SGameMessage.h"
|
|
#include "KUIControlList.h"
|
|
#include "SMessengerMgr.h"
|
|
#include "SJobDB.h"
|
|
#include "SUIDisplayInfo.h"
|
|
#include "SStringDB.h"
|
|
#include "GameDefine.h"
|
|
#include "SPlayerInfoMgr.h"
|
|
#include "SGame.h"
|
|
#include "SGameAvatarEx.h"
|
|
|
|
SUICommunityFriend::~SUICommunityFriend()
|
|
{
|
|
m_vacFriendName.clear();
|
|
}
|
|
|
|
bool SUICommunityFriend::InitControls( KPoint kPos )
|
|
{
|
|
// 커스텀 윈도우 move 영역 설정
|
|
KUIControIIconStringList* pList = dynamicCast<KUIControIIconStringList*>(GetChild("list"));
|
|
if( pList )
|
|
{
|
|
pList->SetItemGap(26);
|
|
pList->SetScroll(true);
|
|
pList->ShowOutLine(false);
|
|
}
|
|
|
|
return SUIWnd::InitControls( kPos );
|
|
}
|
|
|
|
bool SUICommunityFriend::InitData( bool bReload /*= false*/ )
|
|
{
|
|
return SUIWnd::InitData( bReload );
|
|
}
|
|
|
|
void SUICommunityFriend::PumpUpMessage( LPCSTR lpszControlID, DWORD nMessage, DWORD lparam, DWORD wparam )
|
|
{
|
|
switch( nMessage )
|
|
{
|
|
case KUI_MESSAGE::KBUTTON_CLICK:
|
|
{
|
|
if( ::_stricmp( lpszControlID, "button_close" ) == 0 )
|
|
{
|
|
}
|
|
else if( ::_stricmp( lpszControlID, "button_add_friend" ) == 0 )
|
|
{
|
|
CheckAddFriendName();
|
|
}
|
|
else if( ::_stricmp( lpszControlID, "button_del_friend" ) == 0 )
|
|
{
|
|
ReqDelFriend();
|
|
}
|
|
else if( ::_stricmp( lpszControlID, "button_whisper" ) == 0 )
|
|
{
|
|
ReqWhisper();
|
|
}
|
|
else if( ::_stricmp( lpszControlID, "button_party" ) == 0 )
|
|
{
|
|
ReqParty();
|
|
}
|
|
}
|
|
break;
|
|
case KUI_MESSAGE::KGENWND_MOVE:
|
|
{
|
|
LimitMoveWnd();
|
|
}
|
|
break;
|
|
}
|
|
|
|
SUIWnd::PumpUpMessage( lpszControlID, nMessage, lparam, wparam );
|
|
}
|
|
|
|
void SUICommunityFriend::ProcMsgAtStatic( SGameMessage* pMsg )
|
|
{
|
|
switch( pMsg->nType )
|
|
{
|
|
case IMSG_UI_FRIEND_UPDATE:
|
|
{
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
|
|
void SUICommunityFriend::FriendUpdate()
|
|
{
|
|
KUIControIIconStringList* pList = dynamicCast<KUIControIIconStringList*>(GetChild("list"));
|
|
if( !pList ) return;
|
|
pList->ClearItem();
|
|
m_vacFriendName.clear();
|
|
|
|
bool bLogin(false);
|
|
const char* lpLoginIcon(NULL);
|
|
std::vector<SPlayerSlot*>& MemberList = m_FriendMgr.GetMemberList();
|
|
for( int i(0); i<MemberList.size() && MemberList[i]; ++i )
|
|
{
|
|
bLogin = MemberList[i]->IsLogin();
|
|
lpLoginIcon = bLogin ? "static_messenger_online" : "static_messenger_offline";
|
|
|
|
std::string strName = CStringUtil::StringFormat( "<#fbe8ad><hcenter><vcenter>%s", MemberList[i]->GetName() ).c_str();
|
|
int nItemCnt = pList->AddItem( _ICONSTRITEM( lpLoginIcon, strName.c_str() ) );
|
|
|
|
if( !bLogin ) pList->SetAbleItem(nItemCnt-1, false);
|
|
else pList->SetAbleItem(nItemCnt-1, true);
|
|
|
|
m_vacFriendName.push_back(MemberList[i]->GetName());
|
|
}
|
|
|
|
pList->UpdateListControl();
|
|
}
|
|
|
|
void SUICommunityFriend::FriendStatusChange( const char* lpName )
|
|
{
|
|
KUIControIIconStringList* pList = dynamicCast<KUIControIIconStringList*>(GetChild("list"));
|
|
if( !pList ) return;
|
|
|
|
SPlayerSlot* pPlayer = m_FriendMgr.FindMember(lpName);
|
|
if( pPlayer )
|
|
{
|
|
bool bLogin( pPlayer->IsLogin() );
|
|
const char* lpLoginIcon = bLogin ? "static_messenger_online" : "static_messenger_offline";
|
|
|
|
int nIndex = GetFriendIndex(lpName);
|
|
if( nIndex != -1 )
|
|
{
|
|
std::string strName = CStringUtil::StringFormat( "<#fbe8ad><hcenter><vcenter>%s", pPlayer->GetName() ).c_str();
|
|
pList->ResetItem(_ICONSTRITEM( lpLoginIcon, strName.c_str() ), nIndex);
|
|
pList->SetAbleItem(nIndex, bLogin);
|
|
}
|
|
}
|
|
}
|
|
|
|
void SUICommunityFriend::CheckAddFriendName()
|
|
{
|
|
if( !m_pGameManager ) return;
|
|
|
|
SGame* pGame( m_pGameManager->GetActiveGame() );
|
|
if( !pGame || pGame->GetGameType() != GAME_TYPE_WORLD ) return;
|
|
|
|
AR_HANDLE handle( m_PlayerInfoMgr.GetTarget() );
|
|
SGameAvatarEx* pAvatar( (SGameAvatarEx*)pGame->GetGameObject(handle) );
|
|
if( pAvatar )
|
|
{
|
|
unsigned char Type = pAvatar->GetObjType();
|
|
if( Type == TS_ENTER::GAME_PLAYER )
|
|
{
|
|
const char* lpName = m_PlayerInfoMgr.GetTargetName();
|
|
bool bLocal = m_PlayerInfoMgr.IsLocalPlayer( m_PlayerInfoMgr.GetTarget() );
|
|
if( !bLocal && lpName && ::strlen(lpName) > 0 )
|
|
{
|
|
ReqAddFriend(true, lpName);
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
|
|
//타겟 없음 /*"이름 입력해 주세요"*/
|
|
m_pGameManager->PostMsgAtDynamic( new SIMSG_UI_REQ_INPUTTEXT( SIMSG_UI_REQ_INPUTTEXT::USAGE_ADD_FRIEND, SIMSG_TOGGLE_UIWINDOW::UIWINDOW_COMMUNITY, S(6793), 1878, -1, 20, SIMSG_TOGGLE_UIWINDOW::UIWINDOW_FRIEND ) ); // [sonador][7.0.6] Mantis 0002624
|
|
}
|
|
|
|
void SUICommunityFriend::ReqAddFriend( bool bLogin, const char* lpName )
|
|
{
|
|
SMSG_FRIEND_COMMAND* pMsg = new SMSG_FRIEND_COMMAND(SMSG_FRIEND_COMMAND::FRIEND_ADD, lpName);
|
|
m_pGameManager->PostMsgAtDynamic( pMsg );
|
|
}
|
|
|
|
void SUICommunityFriend::ReqDelFriend()
|
|
{
|
|
std::string SelectUserName;
|
|
GetSelectPlayerName( SelectUserName );
|
|
|
|
SMSG_FRIEND_COMMAND* pMsg = new SMSG_FRIEND_COMMAND(SMSG_FRIEND_COMMAND::FRIEND_DELETE, SelectUserName.c_str());
|
|
m_pGameManager->PostMsgAtDynamic( pMsg );
|
|
}
|
|
|
|
void SUICommunityFriend::ReqWhisper()
|
|
{
|
|
std::string SelectUserName;
|
|
GetSelectPlayerName( SelectUserName );
|
|
m_pGameManager->PostMsgAtDynamic( new SIMSG_UI_WHISPER( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_CHATTING, SelectUserName.c_str() ) );
|
|
}
|
|
|
|
void SUICommunityFriend::ReqParty()
|
|
{
|
|
std::string SelectUserName;
|
|
GetSelectPlayerName( SelectUserName );
|
|
|
|
SMSG_PARTY_COMMAND* pMsg = new SMSG_PARTY_COMMAND;
|
|
pMsg->mode = SMSG_PARTY_COMMAND::PARTY_INVITE;
|
|
pMsg->strName = SelectUserName.c_str();
|
|
m_pGameManager->PostMsgAtDynamic( pMsg );
|
|
}
|
|
|
|
void SUICommunityFriend::GetSelectPlayerName( std::string& rPlayerName )
|
|
{
|
|
KUIControIIconStringList* pList = dynamicCast<KUIControIIconStringList*>(GetChild("list"));
|
|
if( !pList ) return;
|
|
int nIndex( pList->GetIndex() );
|
|
|
|
if( nIndex>=0 && m_vacFriendName.size() > nIndex )
|
|
rPlayerName = m_vacFriendName[nIndex];
|
|
}
|
|
|
|
int SUICommunityFriend::GetFriendIndex( const char* lpName )
|
|
{
|
|
for( int i(0); i<m_vacFriendName.size(); ++i )
|
|
{
|
|
if( m_vacFriendName[i] == lpName )
|
|
return i;
|
|
}
|
|
return -1;
|
|
}
|