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

373 lines
9.1 KiB
C++

#include "stdafx.h"
#include <toolkit/XStringUtil.h>
#include <toolkit/nsl.h>
#include <toolkit/nsluni.h>
#include "XAbuseFilter.h"
#include "SStringDB.h"
#include "SGameManager.h"
#include "SGameMessage.h"
//#include "SGameMessageUI.h"
#include "SMessengerMgr.h"
#include "KUIControlEdit.h"
#include "KUIControlButton.h"
#include "KUIControlPanel.h"
#include "KUIControlStatic.h"
#include "SUIClassNamePanelWnd.h"
namespace
{
const int g_LimitText = 24;
const int g_EditFontSize = 9;
}
// ** 길드 등급 명칭 패널 **
SUIClassNamePanelWnd::SUIClassNamePanelWnd( SGameManager * pGameManager, KUIControlPanelManager * pPanelManager ):
KUIControlPanel( pGameManager, pPanelManager ),
m_pExtensionButton( NULL ) // 확장버튼.
{
for( int i=0; i<EAUTHORITY_CLASS::ACLASS_MAX; ++i )
m_arrEditClass[ i ] = NULL;
}
SUIClassNamePanelWnd::~SUIClassNamePanelWnd()
{
Release();
}
// 메모리 해제.
void SUIClassNamePanelWnd::Release()
{
}
//-----------------------------
// Override
// KUIControlPanel::
// 패널의 크기를 원본크기로 변경한다. 각 패널윈도우의 크기가 다르므로 재정의할것!!.
void SUIClassNamePanelWnd::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 SUIClassNamePanelWnd::InitControls( KPoint kPos )
{
//
// 클래스등급명 에디트 컨트롤.
for( int i=0; i<EAUTHORITY_CLASS::ACLASS_MAX; ++i )
{
KUIControlEdit * pEdit = dynamicCast< KUIControlEdit * >( GetChild( CStringUtil::StringFormat( "text_class_%d", (i+1) ).c_str() ) );
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_arrEditClass[ i ] = pEdit;
}
// ****
// 확장 여부에따라 숨김, 보임 처리가 바뀌는 Wnd 를 배열에 추가한다.
this->AddChangeVisibleWnd( GetChild( "select_list_cyan" ) );
// 확장버튼 컨트롤.
m_pExtensionButton = dynamicCast< KUIControlSimpleButton * >( GetChild( "sub_open" ) );
//const KRect & rtOutLine = GetChild( "select_list_cyan_06" )->GetRect();
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;
// 활성화시 텍스트 컬러.
KUIControlStatic* ctrl = dynamicCast< KUIControlStatic * >( GetChild( "guild_manage_menu" ) );
if (ctrl) ctrl->SetEnableColor( "<#ffffff>" );
return SUIWnd::InitControls( kPos );
}
//
void SUIClassNamePanelWnd::DataMapping()
{
// 등급명 출력.
int nClass = _PERMISSION::PERMISSION_MEMBER_MAX;
for( int i=0; i<EAUTHORITY_CLASS::ACLASS_MAX; ++i, nClass-- )
{
if( m_arrEditClass[ i ] )
{
m_arrEditClass[ i ]->SetText( m_GuildMgr.GetAuthorityClassName( nClass - 1 ) );
}
}
}
void SUIClassNamePanelWnd::OnNotifyUIWindowOpen( bool bOpen, bool bLimitWnd)
{
//// 등급명 출력.
//for( int i=0; i<EAUTHORITY_CLASS::ACLASS_MAX; ++i )
//{
// if( m_arrEditClass[ i ] )
// {
// m_arrEditClass[ i ]->SetText( m_GuildMgr.GetAuthorityClassName( i ) );
// }
//}
//m_arrEditClass[ 0 ]->SetFocus( true );
if( bOpen )
{
DataMapping();
/*if( m_arrEditClass[ 0 ] )
m_arrEditClass[ 0 ]->SetFocus( true );*/
}
else
{
KillEditFocus();
}
//SUIWnd::OnNotifyUIWindowOpen( bOpen, bLimitWnd );
}
void SUIClassNamePanelWnd::KillEditFocus()
{
// Edit의 모든 focus 제거.
for( int i=0; i<EAUTHORITY_CLASS::ACLASS_MAX; ++i )
{
if( m_arrEditClass[ i ] )
{
m_arrEditClass[ i ]->SetFocus( false );
}
}
}
void SUIClassNamePanelWnd::ProcMsgAtStatic( SGameMessage* pMsg )
{
switch( pMsg->nType )
{
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 SUIClassNamePanelWnd::PumpUpMessage( LPCSTR lpszControlID, DWORD nMessage, DWORD lparam, DWORD wparam )
{
switch( nMessage )
{
//// 등급명수정불가 테스트 TEST.
//case KUI_MESSAGE::KEDIT_CHANGE :
// {
// KUIWnd * pWnd = GetChild( lpszControlID );
// const char * pText = NULL;
// if( pWnd )
// pText = static_cast< KUIControlEdit * >( pWnd )->GetText();
// }
// break;
case KUI_MESSAGE::KBUTTON_CLICK :
{
//// Edit박스 클릭 여부.
//std::string strControlID( lpszControlID );
//std::string::size_type nSize = strControlID.find( "text_" );
//if( nSize != -1 )
//{
// GetChild( lpszControlID )->SetFocus( true );
//}
// 확대축소 토글.
if( !::_stricmp( lpszControlID, "sub_open" ) || !::_stricmp( lpszControlID, "trim_titlebar_open" ) )
{
// 토글.
this->ToggleExtend();
// 버튼 애니 변경.
PanelExtend();
}
// 길드등급명 변경 저장.
else if( !::_stricmp( lpszControlID, "button_save" ) )
{
// 클래스 등급명 변경 요청.
int nClass = EAUTHORITY_CLASS::ACLASS_MAX;
for( int i=0; i<EAUTHORITY_CLASS::ACLASS_MAX; ++i, nClass-- )
{
const char * pStr = m_arrEditClass[ i ]->GetText();
// 변경된 등급명만 전송.
if( ::_stricmp( pStr, m_GuildMgr.GetAuthorityClassName( nClass - 1 ) ) )
{
// '|' 불가.
/*
std::string strClass( pStr );
std::string::size_type nFPos = strClass.find( "|" );
if( nFPos != std::string::npos )
{
m_pGameManager->PostMsgAtDynamic( new SIMSG_REQ_OPEN_MSGBOX( SIMSG_REQ_OPEN_MSGBOX::_MSGBOXID::MSGBOX_GUILD_YES, S( 1922 ), true ) );
break;
}
*/
/// 2011.11.29 유니코드로 변환해서 체크 - prodongi
if (safeFindString(pStr, L"|"))
{
m_pGameManager->PostMsgAtDynamic( new SIMSG_REQ_OPEN_MSGBOX( SIMSG_REQ_OPEN_MSGBOX::_MSGBOXID::MSGBOX_GUILD_YES, S( 1922 ), true ) );
break;
}
// 한글2, 영문4 자 이상.
if( strlen( pStr ) < 4 )
{
m_pGameManager->PostMsgAtDynamic( new SIMSG_REQ_OPEN_MSGBOX( SIMSG_REQ_OPEN_MSGBOX::_MSGBOXID::MSGBOX_GUILD_YES, S( 1891 ), true ) );
break;
}
// 저장. //
// 금지어 필터.
std::wstring wstrText = nsl::uni::conv( pStr );
wchar_t szTemp[1024]={0,};
//AbuseFilter::Filter에 들어갈 마지막 인자의 size는 실질적인 버퍼상의 싸이즈이다. 따라서 wstr이지만 그냥 sizeof를 한다.
AbuseFilter::Filter( wstrText.c_str(), szTemp, sizeof(szTemp) );
std::string strClassName = nsl::uni::conv( szTemp );
//m_pGameManager->PostMsgAtDynamic( new SIMSG_REQ_OPEN_MSGBOX( SIMSG_REQ_OPEN_MSGBOX::_MSGBOXID::MSGBOX_GUILD_YES, pStr, true ) );
//m_pGameManager->PostMsgAtDynamic( new SMSG_GUILD_COMMAND( SMSG_GUILD_COMMAND::GUILD_AUTHORITY_CLASS_NAME, std::string( pStr ), (i + 1) ) );
m_pGameManager->PostMsgAtDynamic( new SMSG_GUILD_COMMAND( SMSG_GUILD_COMMAND::GUILD_AUTHORITY_CLASS_NAME, strClassName, nClass ) );
}
}
}
}
break;
}
SUIWnd::PumpUpMessage( lpszControlID, nMessage, lparam, wparam );
}
DWORD SUIClassNamePanelWnd::OnMouseMessage(DWORD dwMessage, int x, int y)
{
DWORD ret = SUIWnd::OnMouseMessage( dwMessage, x, y );
if( KMR_NO_GET & ret )
return ret;
switch( dwMessage )
{
case KLBUTTON_DOWN :
//case KLBUTTON_UP :
{
if( this->GetIsExtend() )
{
//bool bEditFocuse = false;
//// Edit 컨트롤 Focus.
//for( int i=0; i<EAUTHORITY_CLASS::ACLASS_MAX; ++i )
//{
// if( m_arrEditClass[ i ] )
// {
// KRect rt = m_arrEditClass[ i ]->GetRect();
// if( m_arrEditClass[ i ] && m_arrEditClass[ i ]->GetRect().IsInRect( x, y ) )
// {
// bEditFocuse = true;
// //m_arrEditClass[ i ]->SetFocus( true );
// break;
// }
// }
//}
//if( !bEditFocuse )
//{
// KillEditFocus();
//}
bool bEditFocuse = false;
// Edit 컨트롤 Focus.
for( int i=0; i<EAUTHORITY_CLASS::ACLASS_MAX; ++i )
{
if( m_arrEditClass[ i ] )
{
KRect rt = m_arrEditClass[ i ]->GetRect();
if( m_arrEditClass[ i ] &&
m_arrEditClass[ i ]->HasFocus() &&
!( m_arrEditClass[ i ]->GetRect().IsInRect( x, y ) ) )
{
m_arrEditClass[ i ]->SetFocus( false );
}
}
}
}
}
break;
}
return ret;
}
// Panel 확대,축소
void SUIClassNamePanelWnd::PanelExtend()
{
m_pExtensionButton->SetAniName( this->GetIsExtend() ? "common_button_titanium_sub_open" : "common_button_titanium_sub_close" );
}
// Open 시 필요기능정의.
void SUIClassNamePanelWnd::CustomOpen()
{
// Panel 확대,축소
PanelExtend();
}