#include "stdafx.h" #include "SGameManager.h" #include "SGameMessage.h" #include "SMessengerMgr.h" //#include "SGameMessageUI.h" #include #include "XAbuseFilter.h" #include #include "KUIControlButton.h" #include "KUIControlPanel.h" #include "KUIControlEdit.h" #include "KUIControlStatic.h" #include "SUINoticePanelWnd.h" // ** 길드공지쓰기 패널 ** namespace { const int g_LimitText = 112; // 56; // Edit 컨트롤 최대 텍스트. const int g_LimitTextURL = 128; // 56; // Edit 컨트롤 최대 텍스트 URL. const int g_EditFontSize = 9; } SUINoticePanelWnd::SUINoticePanelWnd( SGameManager * pGameManager, KUIControlPanelManager * pPanelManager ): KUIControlPanel( pGameManager, pPanelManager ), m_pExtensionButton( NULL ), // 확장버튼. m_EditMemo( NULL ), // 메모 에디트. m_EditURL( NULL ) // URL { } SUINoticePanelWnd::~SUINoticePanelWnd() { Release(); } // 메모리 해제. void SUINoticePanelWnd::Release() { } //----------------------------- // Override // KUIControlPanel:: // 패널의 크기를 원본크기로 변경한다. 각 패널윈도우의 크기가 다르므로 재정의할것!!. void SUINoticePanelWnd::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 SUINoticePanelWnd::InitControls( KPoint kPos ) { // 메모 에디트 박스. KUIControlEdit * pEdit = dynamicCast< KUIControlEdit * >( GetChild( "text_guild_notice" ) ); 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; // URL 에디트 박스. pEdit = dynamicCast< KUIControlEdit * >( GetChild( "text_guild_notice_04" ) ); if( pEdit ) { pEdit->SetLimitation( g_LimitTextURL ); pEdit->SetLineChange( true ); pEdit->SetText(""); pEdit->SetCaption(""); pEdit->UseEmoticonFilter( false ); pEdit->SetFont( "font_02" ); pEdit->SetFontSize( g_EditFontSize ); pEdit->setEditBoxScroll(true); } m_EditURL = 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; // 활성화시 텍스트 컬러. dynamicCast< KUIControlStatic * >( GetChild( "guild_manage_menu" ) )->SetEnableColor( "<#ffffff>" ); //// 2010.06.08 edit box scroll test - prodongi //KUIWnd* ctrlEdit = GetChild("text_guild_notice"); //if (ctrlEdit && ctrlEdit->GetClassNameA() == "edit") //{ // ((KUIControlEdit*)ctrlEdit)->setEditBoxScroll(true); //} return SUIWnd::InitControls( kPos ); } void SUINoticePanelWnd::OnNotifyUIWindowOpen( bool bOpen, bool bLimitWnd) { if( m_EditMemo ) { /*if( m_EditMemo ) m_EditMemo->SetFocus( true );*/ DataMapping(); } else { m_EditMemo->SetFocus( false ); m_EditURL->SetFocus( false ); } } // void SUINoticePanelWnd::DataMapping() { // 길드공지. m_EditMemo->SetText( m_GuildMgr.GetGuildNotice() ); //m_EditMemo->SetFocus( true ); // URL. std::string strURL( m_GuildMgr.GetURL() ); XStringUtil::Replace( strURL, "http://", "" ); m_EditURL->SetText( strURL.c_str() ); } void SUINoticePanelWnd::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 SUINoticePanelWnd::PumpUpMessage( LPCSTR lpszControlID, DWORD nMessage, DWORD lparam, DWORD wparam ) { switch( nMessage ) { //case KUI_MESSAGE::KEDIT_IME_CHANGE : //case KUI_MESSAGE::KEDIT_LINE_CHANGE : // { // KUIControlEdit* pEditConsole = (KUIControlEdit*)GetChild( lpszControlID ); // if( pEditConsole ) // { // int nHeight = pEditConsole->GetRect().GetHeight(); // int nOldLineCnt = static_cast(lparam); // int nNewLineCnt = static_cast(wparam); // nNewLineCnt = std::max(0, nNewLineCnt - 1); // // KRect editRect = pEditConsole->GetRect(); // editRect.bottom = editRect.top + nHeight + ((12+3)*nNewLineCnt); // //editRect.top = editRect.bottom - nHeight - ((12+3)*nNewLineCnt); // pEditConsole->SetReSize( editRect ); // } // } // break; case KUI_MESSAGE::KBUTTON_CLICK : { // 확대축소 토글. if( !::_stricmp( lpszControlID, "sub_open" )|| !::_stricmp( lpszControlID, "trim_titlebar_open" ) ) { // 토글. this->ToggleExtend(); // 버튼 애니 변경. PanelExtend(); } // 길드공지 저장. else if( !::_stricmp( lpszControlID, "button_save" ) ) { if( m_EditMemo && m_EditURL ) { /// 2010.12.14 - prodongi if (!isEqualNotice(m_EditMemo->GetText(), m_EditURL->GetText())) { std::string strURL( m_EditURL->GetText() ); std::string::size_type nSize = strURL.find( "http://" ); if( nSize == std::string::npos ) { strURL.clear(); strURL = "http://"; strURL.append( m_EditURL->GetText() ); } /// 2011.11.29 유니코드로 변환해서 체크 - prodongi /* while( ( nSize = strURL.find( "|" ) ) != std::string::npos ) { strURL.replace( nSize, 1, " " ); } */ safeReplaceString(strURL, L"|", L" "); // 금지어 필터. 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 strNotice = nsl::uni::conv( szTemp ); // URL 은 금지어필터 제거. 2010.09.27. //wstrText = nsl::uni::conv( strURL.c_str() ); //wmemset( szTemp, 0, 1024 ); ////AbuseFilter::Filter에 들어갈 마지막 인자의 size는 실질적인 버퍼상의 싸이즈이다. 따라서 wstr이지만 그냥 sizeof를 한다. //AbuseFilter::Filter( wstrText.c_str(), szTemp, sizeof(szTemp) ); //strURL = nsl::uni::conv( szTemp ); m_pGameManager->PostMsgAtDynamic( new SMSG_GUILD_COMMAND( SMSG_GUILD_COMMAND::GUILD_NOTICE, strURL, strNotice ) ); } } } } break; } SUIWnd::PumpUpMessage( lpszControlID, nMessage, lparam, wparam ); } DWORD SUINoticePanelWnd::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_UP : case KLBUTTON_DOWN : if( this->GetIsExtend() ) { // Edit. if( m_EditMemo && !m_EditMemo->GetRect().IsInRect( x, y ) ) m_EditMemo->SetFocus( false ); // URL. if( m_EditURL && !m_EditURL->GetRect().IsInRect( x, y ) ) m_EditURL->SetFocus( false ); } break; } return ret; } // Panel 확대,축소 void SUINoticePanelWnd::PanelExtend() { m_pExtensionButton->SetAniName( this->GetIsExtend() ? "common_button_titanium_sub_open" : "common_button_titanium_sub_close" ); } // Open 시 필요기능정의. void SUINoticePanelWnd::CustomOpen() { // Panel 확대,축소 PanelExtend(); } /// 2010.12.14 - prodongi bool SUINoticePanelWnd::isEqualNotice(std::string const& newNotice, std::string const& newURL) { std::string _newURL = "http://" + newURL; if (newNotice == m_GuildMgr.GetGuildNotice() && _newURL == m_GuildMgr.GetURL()) { return true; } return false; }