Files
Leviathan/Client/Game/game/Interface/Party/SUIPartyStateWnd.cpp
T
2026-06-01 12:46:52 +02:00

1852 lines
49 KiB
C++

#include "stdafx.h"
#include "KUIControlStatic.h"
#include "KUIControlGauge.h"
#include "KUIControlEdit.h"
#include "KUIControlButton.h"
#include "SGameManager.h"
#include "SGameMessage.h"
//#include "SGameMessageUI.h"
#include "SUIPartyWndDual.h" // 2011.11.14 - servantes
#include "SUIPartyTypes.h" // 2011.11.14 - servantes
#include "SUIPartyStateWnd.h"
#include "SUIDisplayInfo.h"
#include "SUISysMsgDefine.h"
#include <toolkit/XStringUtil.h>
#include "SStringDB.h"
#include "SJobDB.h"
#include "SItemDB.h"
#include "SGameOption.h"
#include "SPlayerInfoMgr.h"
#include "SMessengerMgr.h"
#include "SUIPartyWndMgr.h"
//#include "Util.h"
#include "SChatType.h"
#include "SGameAvatarEx.h"
#include "SGame.h"
#include "SCreatureDB.h"
#include "ErrorCode/ErrorCode.h" // sonador 3.5.1 던전 시즈 레벨 제한
#include <kfile/KFileManager.h>
#include "SUIPartyStateSetWnd.h"
#include "IHuntaHolicSystem.h" // #2.1.2.11.1
// 2010.08.31 - prodongi
#include "SSummonSlotMgr.h"
//#include "SUIUtil.h"
#include "SGameCreature.h"
#include "SGameSystem.h"
extern SGameSystem* g_pCurrentGameSystem;
extern void MsgSplit( const char* szMsg, STR_LIST& vecText, const wchar_t* lpDelimiter, bool bProcSpecialCharacter=false );
namespace
{
const int c_nStateDelta = 32; //지속효과 리사이즈 단위
const int c_nStateDeltaSmall= 20; //지속효과 리사이즈 단위
const int c_nMaxLine = 8; // 보여주는 최대 라인수
const int c_nPartyWndWidthSize = 138;
const int c_nDelta = 32; //32; // 리사이즈 단위
const int c_nDeltaSmall = 26; //22; // 리사이즈 단위
const int c_nCreatureDelta = 24; //24; // 소환수 Max Height Size
const int c_nCreatureDeltaSmall = 16; //14; // 소환수 Max Height Size
const char* c_lpStateSetID = "state_set%02d";
const char* c_lpCreatureStateSetID = "Creature_state_set%02d";
}
SUIPartyStateWnd::SUIPartyStateWnd( SGameManager* pGameManager, SUIDisplayInfo* pDisplayInfo )
: SUIWnd( pGameManager )
, m_pDisplayInfo( pDisplayInfo )
, m_bLeftRender(true), m_bStateRender(true)
{
m_pLinkPartyUI = NULL; // 2011.11.14 - servantes : 연결된 파티창 포인터
m_bSizeBig = true; // 2011.11.14 - servantes : 버프 크기 변환플래그
for( int i(0); i<SLOT_MAXLINE; ++i )
{
/// 2011.12.21 기본 값을 false로 한다 - prodongi
//m_MemberStateRender[i] = false;
//m_CreatureStateRender[i] = false;
m_vecCreatureList[i].hCreature1st = NULL;
m_vecCreatureList[i].hCreature2nd = NULL;
m_vecCreatureList[i].hMaster = NULL;
}
}
void SUIPartyStateWnd::ClearCtr()
{
}
bool SUIPartyStateWnd::InitControls( KPoint kPos )
{
std::string strID, strID2;
KRect rt(0,0,100,30);
SUIPartyStateSetWnd* pStateSetWnd(NULL);
for( int i(0); i<c_nMaxLine; ++i )
{
strID = CStringUtil::StringFormat(c_lpStateSetID, i);
strID2 = CStringUtil::StringFormat(c_lpCreatureStateSetID, i);
pStateSetWnd = new SUIPartyStateSetWnd(m_pGameManager, m_pDisplayInfo, this, m_pManager, strID.c_str(), rt );
AddChild(pStateSetWnd);
pStateSetWnd = new SUIPartyStateSetWnd(m_pGameManager, m_pDisplayInfo, this, m_pManager, strID2.c_str(), KRect(rt.left, rt.top+c_nStateDelta, rt.right, rt.bottom+c_nStateDelta) );
pStateSetWnd->SetNegativeStateCnt( 10 );
AddChild(pStateSetWnd);
rt.top += c_nStateDelta;
rt.bottom += c_nStateDelta;
}
SetCorrectionRect(KRect(0,0,0,0)); // 2011.11.17 - servantes : 보정영역이라는데 필요 없는것 같아 값을 0으로 설정
return SUIWnd::InitControls(kPos);
}
bool SUIPartyStateWnd::InitData( bool bReload )
{
return SUIWnd::InitData(bReload);
}
void SUIPartyStateWnd::OnNotifyUIWindowOpen( bool bOpen, bool bLimitWnd )
{
SUIWnd::OnNotifyUIWindowOpen(bOpen);
if( bOpen )
{
RefreshSlots();
}
}
void SUIPartyStateWnd::ProcMsgAtStatic( SGameMessage* pMsg )
{
switch( pMsg->nType )
{
case IMSG_UI_SEND_DATA:
{
SIMSG_UI_SEND_DATA *pData = (SIMSG_UI_SEND_DATA *)pMsg;
if( pData->m_strString == "party_update" )
{
//RefreshSlots();
}
else if( pData->m_strString == "add_creature" )
{
pMsg->bUse = true;
AddCreature( pData->m_dwData );
RefreshSlots();
}
else if( pData->m_strString == "add_creature_index" )
{
// 2010.08.30 - prodongi
//AddCreature( (int)pData->m_nNumber.getAmount() );
RefreshSlots();
//setRenderCreatureUI((int)pData->m_nNumber.getAmount(), true);
}
else if( pData->m_strString == "remove_creature" )
{
RemoveCreature( pData->m_dwData );
RefreshSlots();
}
else if( pData->m_strString == "remove_creature_index" )
{
// 2010.08.30 - prodongi
//RemoveCreature( (int)pData->m_nNumber.getAmount() );
//setRenderCreatureUI((int)pData->m_nNumber.getAmount(), false);
RefreshSlots();
}
else if (pData->m_strString == "show_wnd")
{
SetShow(true);
}
else if (pData->m_strString == "hide_wnd")
{
SetShow(false);
}
else if (pData->m_strString == "refresh")
{
SetShow(true);
_RefreshSlots();
Move((int)pData->m_nNumber.getAmount(), (int)pData->m_nNumber2.getAmount()); // 2011.12.20 - servantes : 버프위치 조정
}
else if( pData->m_strString == "state_all_on" )
{
if(m_bSizeBig != (bool)pData->m_dwData) // 2011.12.20 - servantes : 창의 크기에 따라 버프 크기 변경
{
if(pData->m_dwData == PARTY_UI_SIZE_SMALL)
ChangeSizeStateWnd(false);
else
ChangeSizeStateWnd(true);
}
setShowParent(true);
SetShow(true);
//setRenderAllState(true);
m_bStateRender = true;
RefreshSlots();
Move((int)pData->m_nNumber.getAmount(), (int)pData->m_nNumber2.getAmount()); // 2011.12.20 - servantes : 버프위치 조정
}
else if( pData->m_strString == "state_all_off" )
{
setShowParent(false);
SetShow(false);
//setRenderAllState(false);
m_bStateRender = false;
DisableAllSlots();
}
else if( pData->m_strString == "one_state_on" )
{
if( pData->m_nNumber2>=0 && pData->m_nNumber2<SLOT_MAXLINE )
{
//setRenderState(true, pData->m_nNumber.getAmount(), pData->m_nNumber2.getAmount());
setShowParent(true);
SetShow(true);
m_bStateRender = true;
RefreshSlot( pData->m_nNumber2.getAmount() );
// RefreshSlots();
// Move((int)pData->m_nNumber.getAmount(), (int)pData->m_nNumber2.getAmount()); // 2011.12.20 - servantes : 버프위치 조정
}
}
else if( pData->m_strString == "one_state_off" )
{
if( pData->m_nNumber2>=0 && pData->m_nNumber2<SLOT_MAXLINE )
{
//setRenderState(false, pData->m_nNumber.getAmount(), pData->m_nNumber2.getAmount());
RefreshSlots();
}
}
else if( pData->m_strString == "position" ) // 2011.12.20 - servantes : 창의 크기에 따라 버프 크기 변경 및 위치 조정
{
if(m_bSizeBig != (bool)pData->m_dwData) // 창의 크기에 따라 버프 크기 변경
{
if(pData->m_dwData == PARTY_UI_SIZE_SMALL)
ChangeSizeStateWnd(false);
else
ChangeSizeStateWnd(true);
}
_RefreshSlots();
Move((int)pData->m_nNumber.getAmount(), (int)pData->m_nNumber2.getAmount()); // 버프위치 조정
}
pMsg->bUse = true;
/// 2011.11.17 - prodongi
/*
else if( pData->m_strString == "open_private_menu" )
{
if( pData->m_dwData < 0 || pData->m_dwData >= SLOT_MAXLINE )
break;
SIMSG_UI_OPEN_PRIVATE_MENU Msg;
if( pData->m_strText == "player" )
{
Msg.m_bPlayer = true;
Msg.m_bRender = m_MemberStateRender[pData->m_dwData];
}
else if( pData->m_strText == "creature" )
{
Msg.m_bPlayer = false;
Msg.m_bRender = m_CreatureStateRender[pData->m_dwData];
}
Msg.m_nIndex = pData->m_dwData;
Msg.m_nX = pData->m_nNumber.getAmount();
Msg.m_nY = pData->m_nNumber2.getAmount();
m_pGameManager->ProcMsgAtStatic( &Msg );
}
*/
}
break;
case MSG_CHATTING:
{
SMSG_CHATTING* pChatMsg = ( SMSG_CHATTING* )pMsg;
if( pChatMsg->nChatType == CHAT_PARTY_SYSTEM )
{
/*
if( m_PartyMgr.IsExist() && m_PartyMgr.GetMemberCount() > 0 )
{
RefreshSlots();
}
else
{
ClearCreatureList();
DisableAllSlots();
}*/
}
pMsg->bUse = true;
}
break;
case IMSG_UI_MOVE:
{
SIMSG_UI_MOVE* pMoveMsg = ( SIMSG_UI_MOVE* )pMsg;
// Move( pMoveMsg->m_nX, pMoveMsg->m_nY+2 ); // 2011.11.11 - servantes : 위치 보정을 위해서 2을 더하지 않는다
Move( pMoveMsg->m_nX, pMoveMsg->m_nY );
pMsg->bUse = true;
}
break;
case IMSG_UI_STATE_UPDATE:
{
SIMSG_UI_STATE_UPDATE* pStateUpdate = ( SIMSG_UI_STATE_UPDATE* )pMsg;
SUIPartyStateSetWnd* pWnd = GetChildWnd( pStateUpdate->m_hPlayer );
if( pWnd )
pWnd->StateUpdate(pMsg);
pMsg->bUse = true;
}
break;
case IMSG_UI_STATE_LIST_UPDATE:
{
SIMSG_UI_STATE_LIST_UPDATE* pStateListUpdate = ( SIMSG_UI_STATE_LIST_UPDATE* )pMsg;
SUIPartyStateSetWnd* pWnd = GetChildWnd( pStateListUpdate->hPlayer );
if( pWnd )
pWnd->StateListUpdate(pMsg);
pMsg->bUse = true;
}
break;
case MSG_ENTER:
{
SMSG_ENTER* pEnter = (SMSG_ENTER*)pMsg;
if( pEnter->ObjType == TS_ENTER::GAME_SUMMON )
if( ChangeCreature( pEnter->handle ) )
RefreshSlots();
else if( pEnter->ObjType == TS_ENTER::GAME_PLAYER )
if( ChangeMasterCreature( pEnter->handle ) )
RefreshSlots();
pMsg->bUse = true;
}
break;
case MSG_LEAVE:
{
SMSG_LEAVE* pLeave = (SMSG_LEAVE*)pMsg;
if( LeaveCreature( pLeave->handle ) == -1 )
LeaveMaster( pLeave->handle );
pMsg->bUse = true;
}
break;
}
}
bool SUIPartyStateWnd::ChangeCreature( AR_HANDLE handle )
{
AR_HANDLE hMaster = GetMaster( handle );
int nIndex = m_PartyMgr.GetMemberIndex( hMaster );
if( hMaster && nIndex >= 0 && nIndex < c_nMaxLine )
{
if( m_vecCreatureList[nIndex].hMaster == hMaster )
{
m_vecCreatureList[nIndex].hCreature1st = handle;
//m_vecCreatureList[nIndex].bRender = true;
//m_vecCreatureList[nIndex].bRenderUI = true; // 2010.08.30 - prodongi
return true;
}
}
for( int i(0); i<c_nMaxLine; ++i )
{
if( m_vecCreatureList[i].hMaster == hMaster )
{
m_vecCreatureList[i].hCreature1st = handle;
//m_vecCreatureList[i].bRender = true;
//m_vecCreatureList[i].bRenderUI = true; // 2010.08.30 - prodongi
return true;
}
}
return false;
}
AR_HANDLE SUIPartyStateWnd::getMainCreature(SGameAvatarEx* master)
{
if (!master)
return 0;
//AR_HANDLE hCreature;
SPlayerSlot* slot = m_PartyMgr.FindMember(master->GetArID(), GetPartyName());
if (slot)
return slot->GetMainCreatureHandle();
return master->GetCreature();
}
AR_HANDLE SUIPartyStateWnd::getMainCreature(AR_HANDLE hMaster)
{
return getMainCreature(GetObject( hMaster ));
}
bool SUIPartyStateWnd::ChangeMasterCreature( AR_HANDLE hMaster )
{
int nIndex = m_PartyMgr.GetMemberIndex( hMaster );
if( hMaster && nIndex >= 0 && nIndex < c_nMaxLine )
{
SGameAvatarEx* pMaster = GetObject( hMaster );
if( pMaster )
{
m_vecCreatureList[nIndex].hMaster = hMaster;
m_vecCreatureList[nIndex].hCreature1st = getMainCreature(pMaster);
//m_vecCreatureList[nIndex].bRender = true;
//m_vecCreatureList[nIndex].bRenderUI = true; // 2010.08.30 - prodongi
return true;
}
}
return false;
}
void SUIPartyStateWnd::InitBuffFlag()
{
/*
for(int i=0; i<SLOT_MAXLINE; i++)
{
m_MemberStateRender [ i ] = false;
m_CreatureStateRender[ i ] = false;
}
*/
std::vector<SPlayerSlot*>& vecMemberList = m_PartyMgr.GetMemberList(&m_strPartyName);
int nIndex(0);
/*
size_t nMemberSize = vecMemberList.size();
for( int i(0); i<nMemberSize; ++i )
{
m_vecCreatureList[ i ].bRender = false;
m_vecCreatureList[ i ].bRenderUI = false;
}
*/
}
void SUIPartyStateWnd::SetCreatureMaster( int nPos, AR_HANDLE hMaster )
{
if( nPos < 0 || nPos >= c_nMaxLine ) return;
m_vecCreatureList[nPos].hMaster = hMaster;
SGameAvatarEx* pMaster = GetObject( hMaster );
if( pMaster )
{
AR_HANDLE hCreature = getMainCreature(pMaster);
SGameAvatarEx* pCreature = GetObject( hCreature );
if( pCreature && pCreature->IsActivated() )
{
// 2010.08.30 - prodongi
//if (!m_vecCreatureList[nPos].bRender && !m_vecCreatureList[nPos].bRenderUI)
// m_vecCreatureList[nPos].bRenderUI = true;
m_vecCreatureList[nPos].hCreature1st = hCreature;
// 2010.08.12 - prodongi
//m_vecCreatureList[nPos].bRender = true;
}
else
{
m_vecCreatureList[nPos].hCreature1st = NULL;
m_vecCreatureList[nPos].hCreature2nd = NULL; // 2011.11.12 - servantes : NULL 처리
}
}
/*
if( m_vecCreatureList[nPos].hCreature1st == NULL )
{
m_vecCreatureList[nPos].bRender = false;
m_vecCreatureList[nPos].bRenderUI = false; // 2010.08.30 - prodongi
}
*/
}
int SUIPartyStateWnd::AddCreature( AR_HANDLE handle )
{
AR_HANDLE hMaster = GetMaster( handle );
int nIndex = m_PartyMgr.GetMemberIndex( hMaster );
if( hMaster && nIndex >= 0 && nIndex < c_nMaxLine )
{
m_vecCreatureList[nIndex].hMaster = hMaster;
m_vecCreatureList[nIndex].hCreature1st = handle;
return nIndex;
}
else
{
return -1;
}
return -1;
}
SGameAvatarEx* SUIPartyStateWnd::GetPlayerPtr( int nIndex )
{
if( nIndex < 0 || nIndex >= m_PartyMgr.GetMemberCount() )
return NULL;
//순차분배 수정: 파티장이 0번 슬롯에 나오던 부분을 자기 위치에 나오도록 수정
//2009-02-23: hunee
std::vector<SPlayerSlot*> vecMemberList;
vecMemberList = m_PartyMgr.GetMemberList();
if( vecMemberList[nIndex] )
{
return GetObject( vecMemberList[nIndex]->GetHandle() );
}
return NULL;
}
void SUIPartyStateWnd::LeaveMaster( AR_HANDLE hMaster )
{
int nIndex = m_PartyMgr.GetMemberIndex( hMaster );
if( hMaster && nIndex >= 0 && nIndex < c_nMaxLine )
{
if( m_vecCreatureList[nIndex].hMaster == hMaster )
{
m_vecCreatureList[nIndex].hMaster = NULL;
m_vecCreatureList[nIndex].hCreature1st = NULL;
//m_vecCreatureList[nIndex].bRender = false;
//m_vecCreatureList[nIndex].bRenderUI = false; // 2010.08.30 - prodongi
}
}
}
int SUIPartyStateWnd::LeaveCreature( AR_HANDLE handle )
{
for( int i(0); i<c_nMaxLine; ++i )
{
if( m_vecCreatureList[i].hCreature1st == handle )
{
m_vecCreatureList[i].hCreature1st = NULL;
//m_vecCreatureList[i].bRender = false;
//m_vecCreatureList[i].bRenderUI = false; // 2010.08.30 - prodongi
return i;
}
}
return -1;
}
int SUIPartyStateWnd::RemoveCreature( AR_HANDLE handle )
{
for( int i(0); i<c_nMaxLine; ++i )
{
if( m_vecCreatureList[i].hCreature1st == handle )
{
m_vecCreatureList[i].hCreature1st = NULL; // 2011.11.12 - servantes : NULL 처리
m_vecCreatureList[i].hCreature2nd = NULL; // 2011.11.12 - servantes : NULL 처리
//m_vecCreatureList[i].bRender = false;
//m_vecCreatureList[i].bRenderUI = false; // 2010.08.30 - prodongi
return i;
}
}
return -1;
}
/*
// 2010.08.30 - prodongi
void SUIPartyStateWnd::setRenderCreatureUI(int index, bool render)
{
if( index < 0 || index >= c_nMaxLine )
return;
m_vecCreatureList[index].bRenderUI = render;
}
*/
void SUIPartyStateWnd::PumpUpMessage( LPCSTR lpszControlID, DWORD nMessage, DWORD lparam, DWORD wparam )
{
switch(nMessage)
{
case KUI_MESSAGE::KBUTTON_CLICK:
{
}
break;
}
SUIWnd::PumpUpMessage( lpszControlID, nMessage, lparam, wparam );
}
void SUIPartyStateWnd::ClearCreatureList()
{
for( int i(0); i<c_nMaxLine; ++i )
{
m_vecCreatureList[i].hCreature1st = NULL;
m_vecCreatureList[i].hCreature2nd = NULL; // 2011.11.12 - servantes : NULL 처리
m_vecCreatureList[i].hMaster = NULL;
//m_vecCreatureList[i].bRender = false;
//m_vecCreatureList[i].bRenderUI = false; // 2010.08.30 - prodongi
}
}
AR_HANDLE SUIPartyStateWnd::GetMaster( AR_HANDLE handle )
{
SGameAvatarEx* pCreature = GetObject( handle );
if( pCreature && pCreature->GetObjType() == TS_ENTER::GAME_SUMMON )
return pCreature->GetMaster();
return 0;
}
SGameAvatarEx* SUIPartyStateWnd::GetMasterPtr( AR_HANDLE handle )
{
SGameAvatarEx* pCreature = GetObject( handle );
if( pCreature && pCreature->GetObjType() == TS_ENTER::GAME_SUMMON )
return GetObject( pCreature->GetMaster() );
return NULL;
}
SGameAvatarEx* SUIPartyStateWnd::GetObject( AR_HANDLE handle )
{
SGame* pGame = m_pGameManager->GetActiveGame();
if( !pGame || pGame->GetGameType() != GAME_TYPE_WORLD )
return NULL;
return (SGameAvatarEx*)(pGame->GetGameObject(handle));
}
void SUIPartyStateWnd::Move( int nX, int nY )
{
int nResolution_Width = GetGameOption().GetResolution_Width();
int nTempX( nX );
int nWidth( GetRect().GetWidth() );
bool bMoveRight( !IsRenderStateLeft(nTempX+nWidth) );
if( bMoveRight )
{
int nAddWidth=0;
if(m_pLinkPartyUI)
{
if(m_pLinkPartyUI->GetUISizeState() == PARTY_UI_SIZE_SMALL)
nAddWidth = 97;
else
nAddWidth = 138;
}
// nTempX = nTempX - (nWidth+c_nPartyWndWidthSize);
nTempX = nTempX - (nWidth + nAddWidth);
if( m_bLeftRender )
{
SUIPartyStateSetWnd* pStateSetWnd(NULL);
for( int i(0); i<c_nMaxLine; ++i )
{
pStateSetWnd = dynamicCast<SUIPartyStateSetWnd*>(GetChild( CStringUtil::StringFormat( c_lpStateSetID, i ).c_str() ));
if( pStateSetWnd )
pStateSetWnd->SwapPos(false);
pStateSetWnd = dynamicCast<SUIPartyStateSetWnd*>(GetChild( CStringUtil::StringFormat( c_lpCreatureStateSetID, i ).c_str() ));
if( pStateSetWnd )
pStateSetWnd->SwapPos(false);
}
m_bLeftRender = false;
}
}
else if( !m_bLeftRender )
{
SUIPartyStateSetWnd* pStateSetWnd(NULL);
for( int i(0); i<c_nMaxLine; ++i )
{
pStateSetWnd = dynamicCast<SUIPartyStateSetWnd*>(GetChild( CStringUtil::StringFormat( c_lpStateSetID, i ).c_str() ));
if( pStateSetWnd )
pStateSetWnd->SwapPos(true);
pStateSetWnd = dynamicCast<SUIPartyStateSetWnd*>(GetChild( CStringUtil::StringFormat( c_lpCreatureStateSetID, i ).c_str() ));
if( pStateSetWnd )
pStateSetWnd->SwapPos(true);
}
m_bLeftRender = true;
}
MovePos( nTempX, nY );
// m_pGameManager->PostMsgAtDynamic( new SIMSG_UI_SEND_DATA( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_PARTY, "position", number_t(nTempX), number_t(nY) ) );
}
bool SUIPartyStateWnd::IsRenderStateLeft( int nRight/*=-1*/ )
{
int nResolution_Width = GetGameOption().GetResolution_Width();
if( nRight == -1 ) nRight = GetRect().right;
return nRight < nResolution_Width;
}
void SUIPartyStateWnd::RefreshSlot(int id)
{
if( !m_bStateRender )
return;
bool bExist = m_PartyMgr.IsExist(&m_strPartyName);
int nCount( m_PartyMgr.GetMemberCount(&m_strPartyName) );
if( !bExist || nCount <= 0 )
return;
RefreshEnableSlot(id);
nCount = min( c_nMaxLine, nCount );
ChangeSize( nCount );
}
void SUIPartyStateWnd::RefreshSlots()
{
DisableAllSlots();
/// 2011.12.21 코드 재사용을 위해 함수로 뺌 - prodongi
_RefreshSlots();
/*
if( !m_bStateRender )
return;
bool bExist = m_PartyMgr.IsExist(&m_strPartyName);
int nCount( m_PartyMgr.GetMemberCount(&m_strPartyName) );
if( !bExist || nCount <= 0 )
return;
RefreshEnableSlots();
nCount = min( c_nMaxLine, nCount );
ChangeSize( nCount );
*/
}
void SUIPartyStateWnd::_RefreshSlots()
{
if( !m_bStateRender )
return;
bool bExist = m_PartyMgr.IsExist(&m_strPartyName);
int nCount( m_PartyMgr.GetMemberCount(&m_strPartyName) );
if( !bExist || nCount <= 0 )
return;
RefreshEnableSlots();
nCount = min( c_nMaxLine, nCount );
ChangeSize( nCount );
}
void SUIPartyStateWnd::RefreshEnableSlots()
{
std::vector<SPlayerSlot*>& vecMemberList = m_PartyMgr.GetMemberList(&m_strPartyName);
std::vector<SPlayerSlot*>::const_iterator it = vecMemberList.begin();
int nCount = static_cast<int>( vecMemberList.size() );
nCount = min( c_nMaxLine, nCount );
int nIndex(0);
size_t nMemberSize = vecMemberList.size();
for( int i(0); i<nMemberSize; ++i )
{
//if( vecMemberList[i]->IsLeader() ) continue;
SetSlotData_N_Enable( nIndex, vecMemberList[i], false );
SetCreatureMaster( nIndex, vecMemberList[i]->GetHandle() );
// 2010.08.30 - prodongi
//if( m_vecCreatureList[nIndex].bRender )
//if (m_vecCreatureList[nIndex].bRender && m_vecCreatureList[nIndex].bRenderUI)
if (m_pLinkPartyUI && m_pLinkPartyUI->isShowCreature(nIndex) && m_pLinkPartyUI->isShowCreatureBuff(nIndex))
SetSlotData_N_Enable( nIndex, m_vecCreatureList[nIndex].hCreature1st, true );
else if (0 == m_vecCreatureList[nIndex].hCreature1st) /// 2011.12.21 핸들이 없으면 안보이게 해야 된다 - prodongi
SetSlotData_N_Enable( nIndex, m_vecCreatureList[nIndex].hCreature1st, true );
nIndex++;
}
}
void SUIPartyStateWnd::RefreshEnableSlot(int id)
{
if(id < 0 || id >= c_nMaxLine)
return ;
std::vector<SPlayerSlot*>& vecMemberList = m_PartyMgr.GetMemberList(&m_strPartyName);
std::vector<SPlayerSlot*>::const_iterator it = vecMemberList.begin();
int nCount = static_cast<int>( vecMemberList.size() );
nCount = min( c_nMaxLine, nCount );
if(id >= nCount)
return ;
SetSlotData_N_Enable( id, vecMemberList[ id ], false );
SetCreatureMaster ( id, vecMemberList[ id ]->GetHandle() );
SetSlotData_N_Enable( id, m_vecCreatureList[ id ].hCreature1st, true );
/*
//if (m_vecCreatureList[ id ].bRender && m_vecCreatureList[ id ].bRenderUI)
if (m_pLinkPartyUI->isShowCreature(id) && m_pLinkPartyUI->isShowCreatureBuff(id))
SetSlotData_N_Enable( id, m_vecCreatureList[ id ].hCreature1st, true );
else if (0 == m_vecCreatureList[ id ].hCreature1st) /// 2011.12.21 핸들이 없으면 안보이게 해야 된다 - prodongi
SetSlotData_N_Enable( id, m_vecCreatureList[ id ].hCreature1st, true );
*/
}
void SUIPartyStateWnd::RefreshCreatureSlots()
{
int nIndex(-1);
for( int i(0); i<c_nMaxLine; ++i )
{
if( m_vecCreatureList[i].hMaster )
{
nIndex = m_PartyMgr.GetMemberIndex( m_vecCreatureList[i].hMaster, &m_strPartyName );
if( nIndex>=0 && nIndex != i && nIndex < c_nMaxLine )
{
m_vecCreatureList[nIndex].hCreature1st = m_vecCreatureList[i].hCreature1st;
m_vecCreatureList[nIndex].hMaster = m_vecCreatureList[i].hMaster;
}
}
}
}
void SUIPartyStateWnd::RefreshCreatureSlot(int id)
{
if( m_vecCreatureList[ id ].hMaster == NULL )
return ;
int nIndex = m_PartyMgr.GetMemberIndex( m_vecCreatureList[ id ].hMaster, &m_strPartyName );
if( nIndex>=0 && nIndex != id && nIndex < c_nMaxLine )
{
m_vecCreatureList[ nIndex ].hCreature1st = m_vecCreatureList[ id ].hCreature1st;
m_vecCreatureList[ nIndex ].hMaster = m_vecCreatureList[ id ].hMaster;
}
}
void SUIPartyStateWnd::DisableAllSlots()
{
AR_HANDLE hNULL(NULL);
for( int i = 0; i < c_nMaxLine; i++ )
{
SetSlotData_N_Enable(i, hNULL, true);
SetSlotData_N_Enable(i, hNULL, false);
}
}
void SUIPartyStateWnd::SetSlotData_N_Enable( int nIndex, SPlayerSlot* pSlot, bool bCreature )
{
if( nIndex<0 || nIndex>=c_nMaxLine ) return;
if( pSlot )
SetSlotData_N_Enable( nIndex, pSlot->GetHandle(), bCreature );
}
void SUIPartyStateWnd::SetSlotData_N_Enable( int nIndex, AR_HANDLE handle, bool bCreature )
{
if( nIndex<0 || nIndex>=c_nMaxLine ) return;
SUIPartyStateSetWnd* pStateSetWnd(NULL);
if( bCreature )
pStateSetWnd = dynamicCast<SUIPartyStateSetWnd*>(GetChild( CStringUtil::StringFormat( c_lpCreatureStateSetID, nIndex ).c_str() ));
else
pStateSetWnd = dynamicCast<SUIPartyStateSetWnd*>(GetChild( CStringUtil::StringFormat( c_lpStateSetID, nIndex ).c_str() ));
if( pStateSetWnd )
{
if (!handle)
{
pStateSetWnd->SetShow(false);
return ;
}
pStateSetWnd->SetPlayer( handle );
/*
bool bShow( pStateSetWnd->IsLogin() );
if( bCreature )
bShow = (m_CreatureStateRender[nIndex] && bShow);
else
bShow = (m_MemberStateRender[nIndex] && bShow);
*/
bool bShow = false;
if (pStateSetWnd->IsLogin() && m_pLinkPartyUI)
{
if (bCreature)
{
if (m_pLinkPartyUI->isShowCreature(nIndex) && m_pLinkPartyUI->isShowCreatureBuff(nIndex))
bShow = true;
}
else
{
if (m_pLinkPartyUI->isShowPlayerBuff(nIndex))
bShow = true;
}
}
pStateSetWnd->SetShow( bShow );
if( bShow )
pStateSetWnd->RefreshAllStateSlot();
}
}
void SUIPartyStateWnd::ChangeSize( int nCount )
{
//SPlayerSlot* pSlot = m_PartyMgr.GetLeaderInfo();
int nPos_Y( GetRect().top + 1 );
//파티장 맨위로 가는부분 수정시 크리쳐 슬롯 위치 지대로 못 잡는 부분 수정
//2009-05-27: hunee
std::vector<SPlayerSlot*>& vecMemberList = m_PartyMgr.GetMemberList(&m_strPartyName);
size_t nMemberSize = vecMemberList.size();
if(m_bSizeBig) // 2011.11.14 - servantes : 버프 크기 변환플래그
{
for( int i(0); i<nMemberSize; ++i )
{
MoveStateWindow(i, nPos_Y, false);
nPos_Y += c_nDelta;
//if( m_vecCreatureList[i].bRender )
if (m_pLinkPartyUI && m_pLinkPartyUI->isShowCreature(i))
{
MoveStateWindow(i, nPos_Y, true);
nPos_Y += c_nCreatureDelta;
}
}
}
else
{
for( int i(0); i<nMemberSize; ++i )
{
MoveStateWindow(i, nPos_Y, false);
nPos_Y += c_nDeltaSmall;
//if( m_vecCreatureList[i].bRender )
if (m_pLinkPartyUI && m_pLinkPartyUI->isShowCreature(i))
{
MoveStateWindow(i, nPos_Y, true);
nPos_Y += c_nCreatureDeltaSmall;
}
}
}
KRect rcNew = GetRect();
rcNew.bottom = nPos_Y + 5;
Resize( rcNew );
// SetCorrectionRect( rcNew, false );
}
bool SUIPartyStateWnd::IsAddCreature( AR_HANDLE handle, bool bMaster/*=false*/ )
{
if( handle == NULL ) return false;
for( int i(0); i<c_nMaxLine; ++i )
{
if( bMaster && m_vecCreatureList[i].hMaster == handle )
if( m_vecCreatureList[i].hCreature1st != NULL )
return true;
if( !bMaster && m_vecCreatureList[i].hCreature1st == handle )
if( m_vecCreatureList[i].hMaster != NULL )
return true;
}
return false;
}
void SUIPartyStateWnd::MoveStateWindow( int nIndex, int nY, bool Creature )
{
SUIPartyStateSetWnd* pStateSetWnd(NULL);
if( Creature )
{
pStateSetWnd = dynamicCast<SUIPartyStateSetWnd*>(GetChild( CStringUtil::StringFormat( c_lpCreatureStateSetID, nIndex ).c_str() ));
if( pStateSetWnd )
pStateSetWnd->MovePos( pStateSetWnd->GetRect().left, nY );
}
else
{
pStateSetWnd = dynamicCast<SUIPartyStateSetWnd*>(GetChild( CStringUtil::StringFormat( c_lpStateSetID, nIndex ).c_str() ));
if( pStateSetWnd )
pStateSetWnd->MovePos( pStateSetWnd->GetRect().left, nY );
}
}
SUIPartyStateSetWnd* SUIPartyStateWnd::GetChildWnd( AR_HANDLE handle )
{
SUIPartyStateSetWnd* pStateSetWnd(NULL);
for( int i(0); i<c_nMaxLine; ++i )
{
pStateSetWnd = dynamicCast<SUIPartyStateSetWnd*>(GetChild( CStringUtil::StringFormat( c_lpStateSetID, i ).c_str() ));
if( pStateSetWnd && pStateSetWnd->IsEqualPlayer(handle) )
return pStateSetWnd;
}
for( int i(0); i<c_nMaxLine; ++i )
{
pStateSetWnd = dynamicCast<SUIPartyStateSetWnd*>(GetChild( CStringUtil::StringFormat( c_lpCreatureStateSetID, i ).c_str() ));
if( pStateSetWnd && pStateSetWnd->IsEqualPlayer(handle) )
return pStateSetWnd;
}
return NULL;
}
DWORD SUIPartyStateWnd::OnMouseMessage(DWORD dwMessage, int x, int y)
{
return SUIWnd::OnMouseMessage( dwMessage, x, y );
}
void SUIPartyStateWnd::ChangeSizeStateWnd(bool bBig)
{
m_bSizeBig = bBig;
SUIPartyStateSetWnd* pStateSetWnd;
KRect rt = GetRect();
if(bBig)
rt.top += 1;
for( int i(0); i<c_nMaxLine; ++i )
{
pStateSetWnd = dynamicCast<SUIPartyStateSetWnd*>(GetChild( CStringUtil::StringFormat( c_lpCreatureStateSetID, i ).c_str() ));
if( pStateSetWnd )
{
// pStateSetWnd->Resize(rt);
pStateSetWnd->MovePos(rt.left, rt.top);
if(bBig)
pStateSetWnd->ChangeSizeStateWnd(true);
else
pStateSetWnd->ChangeSizeStateWnd(false);
}
pStateSetWnd = dynamicCast<SUIPartyStateSetWnd*>(GetChild( CStringUtil::StringFormat( c_lpStateSetID, i ).c_str() ));
if( pStateSetWnd )
{
// pStateSetWnd->Resize(rt);
pStateSetWnd->MovePos(rt.left, rt.top);
if(bBig)
pStateSetWnd->ChangeSizeStateWnd(true);
else
pStateSetWnd->ChangeSizeStateWnd(false);
}
if(bBig)
{
rt.top += c_nStateDelta;
rt.bottom += c_nStateDelta;
}
else
{
rt.top += c_nStateDeltaSmall;
rt.bottom += c_nStateDeltaSmall;
}
}
}
/*
void SUIPartyStateWnd::setRenderAllState(bool render)
{
for( int i(0); i<SLOT_MAXLINE; ++i )
{
m_MemberStateRender[i] = render;
m_CreatureStateRender[i] = render;
}
}
*/
/*
void SUIPartyStateWnd::setRenderState(bool render, int objType, int index)
{
if( objType == TS_ENTER::GAME_PLAYER )
{
m_MemberStateRender[index] = render;
}
else if( objType == TS_ENTER::GAME_SUMMON )
{
m_CreatureStateRender[index] = render;
}
}
*/
void SUIPartyStateWnd::setShowParent(bool show)
{
SUIPartyStateWndMgr* parent = dynamicCast<SUIPartyStateWndMgr*>(GetParent());
if (!parent)
return ;
parent->SetShow(show);
}
void SUIPartyStateWnd::setCreatureListHandle(int index, AR_HANDLE masterHandle, AR_HANDLE firstCreatureHandle)
{
if (0 > index || index >= SLOT_MAXLINE)
return ;
PartyCreatureInfo* info = m_vecCreatureList + index;
info->hMaster = masterHandle;
info->hCreature1st = firstCreatureHandle;
info->hCreature2nd = 0;
//info->bRender = true;
//info->bRenderUI = true;
}
//============================================================================================================================================
// SUIPartyStateWndMgr
//============================================================================================================================================
std::string g_strToProcessPartyName = ""; // 2011.11.09 - servantes : 메세지 처리할 파티 이름
SUIPartyStateWndMgr::SUIPartyStateWndMgr( SGameManager* pGameManager, SUIDisplayInfo* pDisplayInfo )
: SUIWnd( pGameManager ), m_pDisplayInfo ( pDisplayInfo )
{
}
SUIPartyStateWndMgr::~SUIPartyStateWndMgr()
{
ClearWnd();
}
SUIWnd* SUIPartyStateWndMgr::CreateWnd( const char* szFile, KUIWndManager* pWndManager, KPoint kPos, int nWindowID )
{
SUIWnd::CreateWnd( szFile, pWndManager, kPos, nWindowID );
m_pManager = pWndManager;
// 2011.11.12 - servantes : 포커스 받지 않도록 플래그 추가
DWORD dwFlag = GetFlag();
SetFlag(dwFlag | KFLAG_NO_GET_FOCUS);
InitWnd();
SetShow(true);
KRect rt;
rt.left = 0;
rt.right = GetGameOption().GetResolution_Width();
rt.top = 0;
rt.bottom = GetGameOption().GetResolution_Height();
this->Resize(rt);
return this;
}
void SUIPartyStateWndMgr::InitWnd()
{
char buf[64];
int h = GetGameOption().GetResolution_Height();
for(int x=0; x<8; x++)
{
sprintf(buf, "temp_buff_party_%d", x);
SUIPartyStateWnd* pWnd = new SUIPartyStateWnd(m_pGameManager, m_pDisplayInfo);
pWnd->CreateWnd("window_main_party_state.nui", m_pManager, KPoint(0, 0), x);
pWnd->SetParent(this);
pWnd->MovePos(0, 0);
pWnd->SetShow(false);
pWnd->OnNotifyUIWindowOpen(false);
pWnd->SetPartyName(buf);
AddWnd(pWnd);
AddChild(pWnd);
}
}
bool SUIPartyStateWndMgr::InitControls( KPoint kPos )
{
return SUIWnd::InitControls( kPos );
}
void SUIPartyStateWndMgr::PumpUpMessage( LPCSTR lpszControlID, DWORD nMessage, DWORD lparam, DWORD wparam )
{
int k=0;
k=0;
SUIWnd::PumpUpMessage( lpszControlID, nMessage, lparam, wparam );
}
int SUIPartyStateWndMgr::AddCreature( SGameMessage* pMsg )
{
SIMSG_UI_SEND_DATA* pData = (SIMSG_UI_SEND_DATA *)pMsg;
std::map<std::string, SUIPartyStateWnd*>::iterator itE = m_mapWnd.end();
std::map<std::string, SUIPartyStateWnd*>::iterator itS = m_mapWnd.begin();
for(; itS != itE; itS++)
{
SUIPartyStateWnd* pStateWnd = itS->second;
int id = pStateWnd->AddCreature( pData->m_dwData );
if( id > -1 )
{
pStateWnd->RefreshSlots();
return id;
}
}
return -1;
}
int SUIPartyStateWndMgr::RemoveCreature( SGameMessage* pMsg )
{
SIMSG_UI_SEND_DATA* pData = (SIMSG_UI_SEND_DATA *)pMsg;
std::map<std::string, SUIPartyStateWnd*>::iterator itE = m_mapWnd.end();
std::map<std::string, SUIPartyStateWnd*>::iterator itS = m_mapWnd.begin();
for(; itS != itE; itS++)
{
SUIPartyStateWnd* pStateWnd = itS->second;
int id = pStateWnd->RemoveCreature( pData->m_dwData );
if( id > -1 )
{
pStateWnd->RefreshSlots();
return id;
}
}
return -1;
}
void SUIPartyStateWndMgr::RemoveMaster( SGameMessage* pMsg )
{
SIMSG_UI_SEND_DATA* pData = (SIMSG_UI_SEND_DATA *)pMsg;
std::map<std::string, SUIPartyStateWnd*>::iterator itE = m_mapWnd.end();
std::map<std::string, SUIPartyStateWnd*>::iterator itS = m_mapWnd.begin();
for(; itS != itE; itS++)
{
SUIPartyStateWnd* pStateWnd = itS->second;
pStateWnd->LeaveMaster( pData->m_dwData);
pStateWnd->RefreshSlots();
}
}
void SUIPartyStateWndMgr::ProcMsgAtStatic( SGameMessage* pMsg )
{
switch(pMsg->nType)
{
case IMSG_UI_SEND_DATA:
{
SIMSG_UI_SEND_DATA* pData = (SIMSG_UI_SEND_DATA *)pMsg;
if( pData->m_strString == "set_party_name" ) // 2011.11.09 - servantes : 파티 이름 설정
{
g_strToProcessPartyName = pData->m_strText;
pMsg->bUse = true;
}
else if( pData->m_strString == "buff_size_force")
{
SUIPartyStateWnd* p = FindWnd(pData->m_strText.c_str());
if(p)
{
p->ChangeSizeStateWnd((bool)pData->m_dwData);
}
pMsg->bUse = true;
}
else if( pData->m_strString == "buff_size")
{
SUIPartyStateWnd* p = FindWnd(pData->m_strText.c_str());
if(p)
{
bool bSizeBigFlag = (bool)pData->m_dwData;
if(p->GetBuffSizeBigFalg() != bSizeBigFlag)
ChangeSizeStateWnd(pData->m_strText.c_str(), bSizeBigFlag);
}
pMsg->bUse = true;
}
else if( pData->m_strString == "small_buff" )
{
ChangeSizeStateWnd(pData->m_strText.c_str(), false);
pMsg->bUse = true;
}
else if( pData->m_strString == "big_buff" )
{
ChangeSizeStateWnd(pData->m_strText.c_str(), true);
pMsg->bUse = true;
}
else if( pData->m_strString == "show_buff" )
{
SetShow(true);
int id = m_PartyMgr.FindPartyID( &pData->m_strText );
if(id < 0)
return ; // 해당 파티가 없다는 뜻
SUIPartyStateWnd* pStateWnd = FindWnd( id );
if(pStateWnd)
{
pStateWnd->SetPartyName(pData->m_strText.c_str());
if( pStateWnd->GetLinkPartyUIPtr() == NULL )
{
SUIPartyWndMgr* pPartyWndMgr = (SUIPartyWndMgr*)this->m_pGameManager->GetSUI(SIMSG_TOGGLE_UIWINDOW::UIWINDOW_PARTY);
if(pPartyWndMgr)
{
int id;
SUIPartyDualWnd* pWnd = pPartyWndMgr->FindWnd( pData->m_strText.c_str(), id );
if(pWnd)
pStateWnd->SetLinkPartyUIPtr( pWnd ); // 파티창 UI 포인터
}
}
pStateWnd->SetShow(true);
pStateWnd->OnNotifyUIWindowOpen(true);
pStateWnd->Move((int)pData->m_nNumber.getAmount(), (int)pData->m_nNumber2.getAmount());
}
/*
SUIPartyStateWnd* pStateWnd = FindWnd(pData->m_strText.c_str());
if(pStateWnd)
{
SUIPartyWndMgr* pUIPartyMgr = dynamicCast< SUIPartyWndMgr * >(m_pGameManager->GetSUI(SIMSG_TOGGLE_UIWINDOW::_UIWINDOW_TYPE::UIWINDOW_PARTY));
if(pUIPartyMgr == NULL)
{
pMsg->bUse = true;
break;
}
int _temp;
SUIPartyDualWnd* pWnd = pUIPartyMgr->FindWnd(pData->m_strText.c_str(), _temp);
if(pWnd)
{
POINT pt = pWnd->GetBuffRenderPos();
pStateWnd->SetShow(true);
pStateWnd->OnNotifyUIWindowOpen(true);
pStateWnd->Move((int)pt.x, (int)pt.y);
}
}
*/
pMsg->bUse = true;
}
else if( pData->m_strString == "hide_buff" || pData->m_strString == "hide_wnd" )
{
int id = m_PartyMgr.FindPartyID( &pData->m_strText );
if(id < 0)
return ; // 해당 파티가 없다는 뜻
SUIPartyStateWnd* pStateWnd = FindWnd( id );
if(pStateWnd)
{
pStateWnd->SetPartyName(pData->m_strText.c_str());
if( pStateWnd->GetLinkPartyUIPtr() == NULL )
{
SUIPartyWndMgr* pPartyWndMgr = (SUIPartyWndMgr*)this->m_pGameManager->GetSUI(SIMSG_TOGGLE_UIWINDOW::UIWINDOW_PARTY);
if(pPartyWndMgr)
{
int id;
SUIPartyDualWnd* pWnd = pPartyWndMgr->FindWnd( pData->m_strText.c_str(), id );
if(pWnd)
pStateWnd->SetLinkPartyUIPtr( pWnd ); // 파티창 UI 포인터
}
}
pStateWnd->SetShow(false);
pStateWnd->OnNotifyUIWindowOpen(false);
}
pMsg->bUse = true;
}
else if( pData->m_strString == "hide_all_buff" )
{
std::map<std::string, SUIPartyStateWnd*>::iterator itE = m_mapWnd.end();
std::map<std::string, SUIPartyStateWnd*>::iterator itS = m_mapWnd.begin();
for(; itS != itE; itS++)
{
SUIPartyStateWnd* p = itS->second;
p->SetShow(false);
p->OnNotifyUIWindowOpen(false);
}
pMsg->bUse = true;
}
else if( pData->m_strString == "sync_party_delete" )
{
SUIPartyStateWnd* pStateWnd = FindWnd(pData->m_strText.c_str());
if(pStateWnd)
{
pStateWnd->ClearCreatureList();
pStateWnd->DisableAllSlots();
pStateWnd->SetShow(false);
pStateWnd->OnNotifyUIWindowOpen(false);
pStateWnd->SetLinkPartyUIPtr( NULL );
}
pMsg->bUse = true;
}
//else if( pData->m_strString == "sync_party_name" )
//{
// SUIPartyStateWnd* pStateWnd = FindWnd( (int)pData->m_dwData );
// if(pStateWnd)
// {
// pStateWnd->SetShow(true);
// pStateWnd->SetPartyName(pData->m_strText.c_str());
//
// if(pData->m_strText.size())
// {
// SUIPartyWndMgr* pPartyWndMgr = (SUIPartyWndMgr*)this->m_pGameManager->GetSUI(SIMSG_TOGGLE_UIWINDOW::UIWINDOW_PARTY);
// if(pPartyWndMgr)
// {
// int id;
// SUIPartyDualWnd* pWnd = pPartyWndMgr->FindWnd( pData->m_strText.c_str(), id );
// if(pWnd == NULL)
// return ;
// pStateWnd->SetLinkPartyUIPtr( pWnd ); // 파티창 UI 포인터
// if(pWnd->GetUISizeState() == PARTY_UI_SIZE_SMALL)
// pStateWnd->ChangeSizeStateWnd(true);
// else
// pStateWnd->ChangeSizeStateWnd(false);
// pStateWnd->RefreshEnableSlots();
// }
// }
// }
// pMsg->bUse = true;
//}
else if( pData->m_strString == "add_creature" )
{
AddCreature( pMsg ); //pData->m_dwData );
g_strToProcessPartyName = ""; // 2011.11.10 - servantes : 파티 이름 초기화
pMsg->bUse = true;
}
else if( pData->m_strString == "remove_creature" )
{
RemoveCreature( pMsg ); //pData->m_dwData );
g_strToProcessPartyName = ""; // 2011.11.10 - servantes : 파티 이름 초기화
pMsg->bUse = true;
}
else if( pData->m_strString == "remove_player" )
{
RemoveMaster( pMsg );
g_strToProcessPartyName = ""; // 2011.11.10 - servantes : 파티 이름 초기화
pMsg->bUse = true;
}
else if (pData->m_strString == "member_creature_info")
{
std::vector<std::string> textList;
MsgSplit(pData->m_strText.c_str(), textList, L"|");
setMemberCreatureInfo(textList);
textList.clear();
}
/// 2011.11.17 - prodongi
else
{
SUIPartyStateWnd* p = FindWnd(pData->m_strText.c_str());
if(p)
{
p->ProcMsgAtStatic( pMsg );
g_strToProcessPartyName = ""; // 2011.11.10 - servantes : 파티 이름 초기화
pMsg->bUse = true;
}
}
pMsg->bUse = true;
break;
}
case MSG_CHATTING:
{
SMSG_CHATTING* pChatMsg = ( SMSG_CHATTING* )pMsg;
if( pChatMsg->nChatType == CHAT_PARTY_SYSTEM )
{
STR_LIST vecText;
MsgSplit( pChatMsg->strText.c_str(), vecText, L"|" );
if ("DESTROY" == vecText[0])
{
HideAndClearWnd(vecText[1].c_str());
}
else if ("CREATE" == vecText[0])
{
SetShow(true);
SetShowStateWndFlag( &vecText[1], false );
InitStateWndBuffFlag( &vecText[1] );
}
else if ("JOIN" == vecText[0])
{
/// 2012.06.08 2021.06.08 " // JOIN|파티명|캐릭터명" 공대 파티와 일반 파티와 통일됨 - prodongi
const char* pMyName = g_pCurrentGameSystem->GetLocalPlayer()->GetName();
if( vecText[2].compare( pMyName ) == 0 )
{
SetShow( true );
InitStateWndBuffFlag( &vecText[1] );
}
}
else if ("KICK" == vecText[0])
{
if(g_pCurrentGameSystem)
{
const char* pMyName = g_pCurrentGameSystem->GetLocalPlayer()->GetName();
if( vecText[2].compare( pMyName ) == 0 )
SetShow( false );
}
}
else if ("LEAVE" == vecText[0])
{
if(g_pCurrentGameSystem)
{
const char* pMyName = g_pCurrentGameSystem->GetLocalPlayer()->GetName();
if( vecText[1].compare( pMyName ) == 0 )
SetShow( false );
}
}
else if ("PROMOTE" == vecText[0])
{
RefreshStateWnd();
}
vecText.clear();
/*
if( m_PartyMgr.IsExist() && m_PartyMgr.GetMemberCount() > 0 )
{
void SUIPartyStateWndMgr::RefreshStateWnd()
{
std::map<std::string, SUIPartyStateWnd*>::iterator itE = m_mapWnd.end();
std::map<std::string, SUIPartyStateWnd*>::iterator itS = m_mapWnd.begin();
for(; itS != itE; itS++)
{
SUIPartyStateWnd* p = itS->second;
p->RefreshSlots();
}
}
else
{
std::map<std::string, SUIPartyStateWnd*>::iterator itE = m_mapWnd.end();
std::map<std::string, SUIPartyStateWnd*>::iterator itS = m_mapWnd.begin();
for(; itS != itE; itS++)
{
SUIPartyStateWnd* p = itS->second;
p->ClearCreatureList();
p->DisableAllSlots();
}
}*/
}
pMsg->bUse = true;
}
break;
case IMSG_UI_MOVE:
{
SIMSG_UI_MOVE* pMoveMsg = ( SIMSG_UI_MOVE* )pMsg;
SUIPartyStateWnd* p = FindWnd(g_strToProcessPartyName.c_str());
if(p)
{
p->ProcMsgAtStatic( pMsg );
g_strToProcessPartyName = ""; // 2011.11.10 - servantes : 파티 이름 초기화
pMsg->bUse = true;
}
}
break;
case IMSG_UI_STATE_UPDATE:
{
SIMSG_UI_STATE_UPDATE* pStateUpdate = ( SIMSG_UI_STATE_UPDATE* )pMsg;
std::map<std::string, SUIPartyStateWnd*>::iterator itE = m_mapWnd.end();
std::map<std::string, SUIPartyStateWnd*>::iterator itS = m_mapWnd.begin();
for(; itS != itE; itS++)
{
SUIPartyStateWnd* p = itS->second;
SUIPartyStateSetWnd* pWnd = p->GetChildWnd( pStateUpdate->m_hPlayer );
if( pWnd )
{
if( pWnd->StateUpdate(pMsg) == true )
break;
}
}
g_strToProcessPartyName = ""; // 2011.11.10 - servantes : 파티 이름 초기화
pMsg->bUse = true;
}
break;
case IMSG_UI_STATE_LIST_UPDATE:
{
SIMSG_UI_STATE_LIST_UPDATE* pStateListUpdate = ( SIMSG_UI_STATE_LIST_UPDATE* )pMsg;
std::map<std::string, SUIPartyStateWnd*>::iterator itE = m_mapWnd.end();
std::map<std::string, SUIPartyStateWnd*>::iterator itS = m_mapWnd.begin();
for(; itS != itE; itS++)
{
SUIPartyStateWnd* p = itS->second;
SUIPartyStateSetWnd* pWnd = p->GetChildWnd( pStateListUpdate->hPlayer );
if( pWnd )
{
if( pWnd->StateListUpdate(pMsg) == true )
break;
}
}
g_strToProcessPartyName = ""; // 2011.11.10 - servantes : 파티 이름 초기화
pMsg->bUse = true;
}
break;
case MSG_ENTER:
{
SMSG_ENTER* pEnter = (SMSG_ENTER*)pMsg;
/// 2012.01.11 크리처는 setMemberCreatureInfo 에서 설정해 준다- prodongi
if( pEnter->ObjType == TS_ENTER::GAME_SUMMON )
{
std::string partyName;
SPlayerSlot* slot = m_PartyMgr.FindMemberByCreature(pEnter->handle, partyName);
if (slot)
{
setMemberCreatureInfo(slot->GetHandle(), slot->GetMainCreatureHandle(), partyName.c_str());
}
/*
std::map<std::string, SUIPartyStateWnd*>::iterator itE = m_mapWnd.end();
std::map<std::string, SUIPartyStateWnd*>::iterator itS = m_mapWnd.begin();
for(; itS != itE; itS++)
{
SUIPartyStateWnd* pWnd = itS->second;
if( pWnd->ChangeCreature( pEnter->handle ) )
{
pWnd->RefreshSlots();
break;
}
}
*/
}
else if( pEnter->ObjType == TS_ENTER::GAME_PLAYER )
{
std::map<std::string, SUIPartyStateWnd*>::iterator itE = m_mapWnd.end();
std::map<std::string, SUIPartyStateWnd*>::iterator itS = m_mapWnd.begin();
for(; itS != itE; itS++)
{
SUIPartyStateWnd* pWnd = itS->second;
if( pWnd->ChangeMasterCreature( pEnter->handle ) )
{
pWnd->RefreshSlots();
break;
}
}
}
pMsg->bUse = true;
}
break;
case MSG_LEAVE:
{
SMSG_LEAVE* pLeave = (SMSG_LEAVE*)pMsg;
std::map<std::string, SUIPartyStateWnd*>::iterator itE = m_mapWnd.end();
std::map<std::string, SUIPartyStateWnd*>::iterator itS = m_mapWnd.begin();
for(; itS != itE; itS++)
{
SUIPartyStateWnd* pWnd = itS->second;
if( pWnd->LeaveCreature( pLeave->handle ) == -1 )
{
pWnd->LeaveMaster( pLeave->handle );
break;
}
}
pMsg->bUse = true;
}
break;
}
}
void SUIPartyStateWndMgr::SetShowStateWndFlag(std::string* pPartyName, bool bShow)
{
if(pPartyName == NULL)
return ;
int id = m_PartyMgr.FindPartyID( pPartyName );
if(id < 0)
return ; // 해당 파티가 없다는 뜻
SUIPartyWndMgr* pPartyWndMgr = (SUIPartyWndMgr*)this->m_pGameManager->GetSUI(SIMSG_TOGGLE_UIWINDOW::UIWINDOW_PARTY);
if(pPartyWndMgr)
{
SUIPartyStateWnd* p = FindWnd( id );
if(p)
{
p->SetShow(bShow);
}
}
}
void SUIPartyStateWndMgr::InitStateWndBuffFlag(std::string* pPartyName)
{
if(pPartyName == NULL)
return ;
int id = m_PartyMgr.FindPartyID( pPartyName );
if(id < 0)
return ; // 해당 파티가 없다는 뜻
SUIPartyWndMgr* pPartyWndMgr = (SUIPartyWndMgr*)this->m_pGameManager->GetSUI(SIMSG_TOGGLE_UIWINDOW::UIWINDOW_PARTY);
if(pPartyWndMgr)
{
SUIPartyStateWnd* p = FindWnd( id );
if(p)
{
p->InitBuffFlag();
}
}
}
void SUIPartyStateWndMgr::HideAndClearWnd(char const* partyName)
{
std::string localPlayerName = g_pCurrentGameSystem->getLocalPlayerName();
SPartyMgr* localParty = m_PartyMgr.FindPartyByPlayerName(&localPlayerName);
if (!localParty || strcmp(localParty->GetPartyName(), partyName) == 0)
{
std::map<std::string, SUIPartyStateWnd*>::iterator itE = m_mapWnd.end();
std::map<std::string, SUIPartyStateWnd*>::iterator itS = m_mapWnd.begin();
for(; itS != itE; itS++)
{
SUIPartyStateWnd* pStateWnd = itS->second;
pStateWnd->ClearCreatureList();
pStateWnd->DisableAllSlots();
pStateWnd->SetShow(false);
pStateWnd->OnNotifyUIWindowOpen(false);
pStateWnd->SetLinkPartyUIPtr( NULL );
}
SetShow(false);
}
}
void SUIPartyStateWndMgr::OnNotifyUIWindowOpen( bool bOpen, bool bLimitWnd )
{
SUIWnd::OnNotifyUIWindowOpen(bOpen);
}
DWORD SUIPartyStateWndMgr::OnMouseMessage(DWORD dwMessage, int x, int y)
{
if( dwMessage == KLBUTTON_DOWN )
return KMR_GET_PASS;
return SUIWnd::OnMouseMessage( dwMessage, x, y );
}
void SUIPartyStateWndMgr::RemoveParty(const char* pstrPartyName)
{
if(pstrPartyName == NULL)
return ;
std::string str = pstrPartyName;
std::map<std::string, SUIPartyStateWnd*>::iterator itE = m_mapWnd.end();
std::map<std::string, SUIPartyStateWnd*>::iterator itS = m_mapWnd.begin();
for(; itS != itE; itS++)
{
SUIPartyStateWnd* pWnd = itS->second;
if( *pWnd->GetPartyName() == str )
{
RemoveChild((KUIWnd*)pWnd);
m_mapWnd.erase(itS); // 지운다
break;
}
}
}
void SUIPartyStateWndMgr::AddWnd(SUIPartyStateWnd* pWnd)
{
if(pWnd)
m_mapWnd.insert(std::make_pair(*pWnd->GetPartyName(), pWnd));
}
/*
int SUIPartyStateWndMgr::GetBuffVisible(const char* strPartName, bool bChar, int id_slot, bool& bShow)
{
SUIPartyStateWnd* pWnd = FindWnd(strPartName);
if(pWnd == NULL)
return -1;
if(bChar == true)
bShow = pWnd->GetCharacterBuffFlag(id_slot);
else
bShow = pWnd->GetCreatureBuffFlag(id_slot);
return 1;
}
*/
SUIPartyStateWnd* SUIPartyStateWndMgr::FindWnd(const char* pstrName)
{
if(pstrName == NULL)
return NULL;
std::map<std::string, SUIPartyStateWnd*>::iterator itE = m_mapWnd.end();
std::map<std::string, SUIPartyStateWnd*>::iterator itS = m_mapWnd.begin();
for(; itS != itE; itS++)
{
SUIPartyStateWnd* p = itS->second;
std::string pstr = *p->GetPartyName();
if( pstr.compare( pstrName ) == 0 )
return p;
}
return NULL;
}
SUIPartyStateWnd* SUIPartyStateWndMgr::FindWnd(int id)
{
if(id < 0)
return NULL;
int k=0;
std::map<std::string, SUIPartyStateWnd*>::iterator itE = m_mapWnd.end();
std::map<std::string, SUIPartyStateWnd*>::iterator itS = m_mapWnd.begin();
for(; itS != itE; itS++, k++)
{
if(k == id)
{
SUIPartyStateWnd* p = itS->second;
return p;
}
}
return NULL;
}
void SUIPartyStateWndMgr::ClearWnd()
{
std::map<std::string, SUIPartyStateWnd*>::iterator itE = m_mapWnd.end();
std::map<std::string, SUIPartyStateWnd*>::iterator itS = m_mapWnd.begin();
for(; itS != itE; itS++)
{
SUIPartyStateWnd* p = itS->second;
}
m_mapWnd.clear();
}
void SUIPartyStateWndMgr::ChangeSizeStateWnd(const char* pPartyName, bool bBig)
{
SUIPartyStateWnd* pWnd = FindWnd(pPartyName);
if(pWnd == NULL)
return ;
KRect rt = pWnd->GetRect();
POINT pt = {rt.left, rt.top};
if( pWnd->GetLinkPartyUIPtr() )
pt = pWnd->GetLinkPartyUIPtr()->GetBuffRenderPos();
if(bBig)
{
rt.right = rt.left + (10 * 10); // 10(버프 개수) X 10(버프 크기)
rt.bottom = rt.top + (3 * 10); // 3(버프 나오는 줄 개수) X 10(버프 크기)
pWnd->Resize(rt);
pWnd->ChangeSizeStateWnd(true);
pWnd->MovePos(pt.x, pt.y);
}
else
{
rt.right = rt.left + (10 * 7); // 10(버프 개수) X 7(버프 크기)
rt.bottom = rt.top + (3 * 7); // 3(버프 나오는 줄 개수) X 7(버프 크기)
pWnd->Resize(rt);
pWnd->ChangeSizeStateWnd(false);
pWnd->MovePos(pt.x, pt.y);
}
}
void SUIPartyStateWndMgr::RefreshStateWnd()
{
std::map<std::string, SUIPartyStateWnd*>::iterator itE = m_mapWnd.end();
std::map<std::string, SUIPartyStateWnd*>::iterator itS = m_mapWnd.begin();
for(; itS != itE; itS++)
{
SUIPartyStateWnd* p = itS->second;
p->RefreshSlots();
}
}
void SUIPartyStateWndMgr::setMemberCreatureInfo(std::vector<std::string> const& textList)
{
char* endPtr;
AR_HANDLE hMainCreature = ::strtoul( textList[ 2 ].c_str(), &endPtr, 10 );
AR_HANDLE hMaster = ::strtoul(textList[1].c_str(), &endPtr, 10);
setMemberCreatureInfo(hMaster, hMainCreature, textList[0].c_str());
}
void SUIPartyStateWndMgr::setMemberCreatureInfo(AR_HANDLE hMaster, AR_HANDLE hMainCreature, char const* partyName)
{
std::string _partyName = partyName;
std::map<std::string, SUIPartyStateWnd*>::iterator itE = m_mapWnd.end();
std::map<std::string, SUIPartyStateWnd*>::iterator itS = m_mapWnd.begin();
for(; itS != itE; itS++)
{
SUIPartyStateWnd* pWnd = itS->second;
if (0 == pWnd->GetPartyName()->compare(_partyName))
{
int index = m_PartyMgr.GetMemberIndex( hMaster, &_partyName);
if( index >= 0 && index < c_nMaxLine )
{
pWnd->setCreatureListHandle(index, hMaster, hMainCreature);
pWnd->RefreshSlot(index);
break;
}
}
}
}