Files
2026-06-01 12:46:52 +02:00

303 lines
7.3 KiB
C++

#include "stdafx.h"
#include "SStringDB.h"
#include <toolkit/nsluni.h>
#include "XAbuseFilter.h"
#include "SGameManager.h"
#include "SGameMessage.h"
//#include "SGameMessageUI.h"
#include "SMessengerMgr.h"
#include "SPlayerInfoMgr.h"
#include "SChatType.h"
#include "KUIWndManager.h"
#include "KUIControlButton.h"
#include "KUIControlEdit.h"
#include "KUIControlPanel.h"
#include "KUIControlStatic.h"
#include "SUIOneselfPanelWnd.h"
namespace
{
const int g_LimitText = 112; //56; // Edit 컨트롤 최대 텍스트.
const int g_EditFontSize = 9;
}
SUIOneselfPanelWnd::SUIOneselfPanelWnd( SGameManager * pGameManager, KUIControlPanelManager * pPanelManager ):
KUIControlPanel( pGameManager, pPanelManager ),
m_pExtensionButton( NULL ), // 확장버튼.
m_EditMemo( NULL ), // 메모 에디트.
m_pMemoSaveBtn( NULL )
{
}
SUIOneselfPanelWnd::~SUIOneselfPanelWnd()
{
Release();
}
// 메모리 해제.
void SUIOneselfPanelWnd::Release()
{
}
//-----------------------------
// Override
// KUIControlPanel::
// 패널의 크기를 원본크기로 변경한다. 각 패널윈도우의 크기가 다르므로 재정의할것!!.
void SUIOneselfPanelWnd::ResizeOriginal()
{
KRect rtWnd = this->GetRect();
const KRect & rtTitlebar = GetChild( "trim_titlebar_open" )->GetRect();
rtWnd.bottom = rtWnd.top + rtTitlebar.GetHeight() - 1;
// 윈도우 크기변경.
KUIWnd::OnSizeChangeNofity( rtWnd );
// Panel 의 함수.
KUIControlPanel::ResizeOriginal();
// 버튼 애니 변경.
PanelExtend();
}
bool SUIOneselfPanelWnd::InitControls( KPoint kPos )
{
m_pMemoSaveBtn = dynamicCast< KUIControlButton * >( GetChild( "button_save_01" ) );
m_pMemoSaveBtn->SetEnableColor( "<#ffffff>" );
m_pMemoSaveBtn->SetDisableColor( "<#a0a0a0>" );
// 메모 에디트 박스.
KUIControlEdit * pEdit = dynamicCast< KUIControlEdit * >( GetChild( "guild_memo_text_01" ) );
if( pEdit )
{
pEdit->SetLimitation( g_LimitText );
pEdit->SetLineChange( true );
pEdit->SetText("");
pEdit->SetCaption("");
pEdit->UseEmoticonFilter( false );
pEdit->SetFont( "font_02" );
pEdit->SetFontSize( g_EditFontSize );
pEdit->setEditBoxScroll(true);
}
m_EditMemo = pEdit;
// ****
// 확장 여부에따라 숨김, 보임 처리가 바뀌는 Wnd 를 배열에 추가한다.
this->AddChangeVisibleWnd( GetChild( "select_list_cyan" ) );
// 확장버튼 컨트롤.
m_pExtensionButton = dynamicCast< KUIControlSimpleButton * >( GetChild( "sub_open" ) );
const KRect & rtTitlebar = GetChild( "trim_titlebar_open" )->GetRect();
KRect rtOriginal = this->GetRect(); // window의 크기.
rtOriginal.bottom = rtOriginal.top + rtTitlebar.GetHeight();
// 초기설정.( 확대, 축소 크기지정 )
this->Initialize( rtOriginal, this->GetRect() );
kPos.x = rtOriginal.left;
kPos.y = rtOriginal.top;
// 활성화시 텍스트 컬러.
dynamicCast< KUIControlStatic * >( GetChild( "guild_manage_menu" ) )->SetEnableColor( "<#ffffff>" );
return SUIWnd::InitControls( kPos );
}
void SUIOneselfPanelWnd::DataMapping()
{
SPlayerSlot * pPlayer = m_GuildMgr.FindMember( m_PlayerInfoMgr.GetPlayerInfo().GetName() );
if( pPlayer == NULL ) // 2010.12.07. bintitle.
return;
if( m_EditMemo )
{
if( pPlayer )
m_EditMemo->SetText( pPlayer->GetGuildMemo().c_str() );
//m_EditMemo->SetFocus( true );
}
// 권한처리.
if( m_pMemoSaveBtn )
{
int nClass = pPlayer->GetAuthority();
int nBitSet = m_GuildMgr.GetAuthorityClassBitSet( nClass - 1 ); // 권한 비트셋.
if( nClass == _PERMISSION::PERMISSION_LEADER || ( nBitSet & _PERMIT_REQUIRED_ACTION::PRA_MEMBER_MEMO ) )
{
m_pMemoSaveBtn->Enable();
}
else
{
m_pMemoSaveBtn->Disable();
}
}
}
void SUIOneselfPanelWnd::OnNotifyUIWindowOpen( bool bOpen, bool bLimitWnd)
{
if( bOpen )
{
DataMapping();
/*if( m_EditMemo )
m_EditMemo->SetFocus( true );*/
}
else
{
m_EditMemo->SetFocus( false );
}
}
void SUIOneselfPanelWnd::ProcMsgAtStatic( SGameMessage* pMsg )
{
switch( pMsg->nType )
{
// 길드 탈퇴 결심 메세지박스 결과.
case IMSG_UI_GUILD_SECESSION:
{
//this->m_pGameManager->GetWndManager()
//m_pGameManager->ProcMsgAtStatic( new SIMSG_REQ_OPEN_MSGBOX( SIMSG_REQ_OPEN_MSGBOX::_MSGBOXID::MSGBOX_ITEMDROPCHECK, "탈퇴결심" ) );
// 길드탈퇴 메세지 전송.
SMSG_CHATTING_REQUEST msg;
msg.type = CHAT_TYPE::CHAT_NORMAL;
msg.strText = "/gleave";
m_pGameManager->ProcMsgAtStatic( &msg );
pMsg->bUse = true;
}
break;
case IMSG_UI_SEND_DATA:
{
if( IsShow() )
{
SIMSG_UI_SEND_DATA *pData = (SIMSG_UI_SEND_DATA *)pMsg;
if( pData->m_strString == "guild_update" )
{
DataMapping();
}
}
}
break;
}
}
void SUIOneselfPanelWnd::PumpUpMessage( LPCSTR lpszControlID, DWORD nMessage, DWORD lparam, DWORD wparam )
{
switch( nMessage )
{
case KUI_MESSAGE::KBUTTON_CLICK :
{
// 확대축소 토글.
if( !::_stricmp( lpszControlID, "sub_open" ) || !::_stricmp( lpszControlID, "trim_titlebar_open" ) )
{
// 토글.
this->ToggleExtend();
// 버튼 애니 변경.
PanelExtend();
}
// 메모 저장.
else if( !::_stricmp( lpszControlID, "button_save_01" ) )
{
/// 2010.12.14 - prodongi
if (!isEqualMemo(m_EditMemo->GetText()))
{
// 금지어 필터.
std::wstring wstrText = nsl::uni::conv( m_EditMemo->GetText());
wchar_t szTemp[1024]={0,};
//AbuseFilter::Filter에 들어갈 마지막 인자의 size는 실질적인 버퍼상의 싸이즈이다. 따라서 wstr이지만 그냥 sizeof를 한다.
AbuseFilter::Filter( wstrText.c_str(), szTemp, sizeof(szTemp) );
std::string strMemo = nsl::uni::conv( szTemp );
m_pGameManager->PostMsgAtDynamic( new SMSG_GUILD_COMMAND( SMSG_GUILD_COMMAND::GUILD_MEMBER_MEMO,
std::string( m_PlayerInfoMgr.GetPlayerInfo().GetName() ), strMemo ) );
}
}
// 결심.
else if( !::_stricmp( lpszControlID, "button_leave_01" ) )
{
SPlayerInfo player = m_PlayerInfoMgr.GetPlayerInfo();
SPlayerSlot * pPlayerSlot = this->m_GuildMgr.FindMember( player.GetName() );
if( pPlayerSlot->GetAuthority() == _PERMISSION::PERMISSION_LEADER ) // 길드장.
m_pGameManager->PostMsgAtDynamic( new SIMSG_REQ_OPEN_MSGBOX( SIMSG_REQ_OPEN_MSGBOX::_MSGBOXID::MSGBOX_GUILD_YES, S( 622 ), true ) );
else
m_pGameManager->PostMsgAtDynamic( new SIMSG_REQ_OPEN_MSGBOX( SIMSG_REQ_OPEN_MSGBOX::_MSGBOXID::MSGBOX_GUILD_SECESSION, S( 628 ), true ) );
}
}
break;
}
SUIWnd::PumpUpMessage( lpszControlID, nMessage, lparam, wparam );
}
DWORD SUIOneselfPanelWnd::OnMouseMessage(DWORD dwMessage, int x, int y)
{
switch( dwMessage )
{
case KLBUTTON_DOWN :
// Edit.
if( m_EditMemo && !m_EditMemo->GetRect().IsInRect( x, y ) )
{
m_EditMemo->SetFocus( false );
}
break;
}
return SUIWnd::OnMouseMessage(dwMessage, x, y);
}
// Panel 확대,축소
void SUIOneselfPanelWnd::PanelExtend()
{
m_pExtensionButton->SetAniName( this->GetIsExtend() ? "common_button_titanium_sub_open" : "common_button_titanium_sub_close" );
}
// Open 시 필요기능정의.
void SUIOneselfPanelWnd::CustomOpen()
{
// Panel 확대,축소
PanelExtend();
}
/// 2010.12.14 - prodongi
bool SUIOneselfPanelWnd::isEqualMemo(std::string const& newMemo)
{
SPlayerSlot * pPlayer = m_GuildMgr.FindMember( m_PlayerInfoMgr.GetPlayerInfo().GetName() );
if( pPlayer == NULL ) // 2010.12.07. bintitle.
return false;
return newMemo == pPlayer->GetGuildMemo();
}