#include "stdafx.h" #include #include "SGameManager.h" #include "SGameMessage.h" //#include "SGameMessageUI.h" #include "SMessengerMgr.h" //#include "KUIControl.h" #include "KUIListControl.h" #include "KUIControlEdit.h" #include "KUIControlScroll.h" #include "SUIMemoViewWnd.h" #define SHOW_SCROLLBAR 4 // // * 길드메모 팝업 윈도우 // namespace { const int g_TextLineCount = 4; // 길드공지 텍스트 리스트 기본 개수. const int g_ListSizeMAX = 6; //std::string g_arrAllianceGuild[] = { "연합1", "연합2","연합3","연합4","연합5",}; const char g_strPictogram[][20] = { "#@guild_notice@#", "#@guild_memo@#" }; } SUIMemoViewWnd::SUIMemoViewWnd( SGameManager * pGameManager ) : SUIWnd( pGameManager ), m_pTextControl( NULL ), m_pListMemo( NULL ), m_pScrollBar( NULL ), m_nScrollPos( 0 ), m_fAlphaValue( 0.0f ), m_dwAlphaTime( 0.0f ), m_dwTime( 0.0f ), m_bAlphaShow( false ), m_nTextPictogram( 0 ), m_strRegion( "" ) { } SUIMemoViewWnd::~SUIMemoViewWnd() { Release(); } void SUIMemoViewWnd::Release() { SAFE_DELETE( m_pListMemo ); } SUIWnd* SUIMemoViewWnd::CreateWnd( const char* szFile, KUIWndManager* pWndManager, KPoint kPos, int nWindowID ) { SUIWnd::CreateWnd( szFile, pWndManager, kPos, nWindowID ); return this; } bool SUIMemoViewWnd::InitControls( KPoint kPos ) { m_bAlphaShow = false; m_fAlphaValue = 0.0f; m_dwAlphaTime = 0.0f; // 텍스트 출력용 컨트롤. m_pTextControl = dynamicCast< KUIControl * >( GetChild( "guild_notice_text_01" ) ); // 텍스트 데코레이션 뽑아내기. string strOrg( m_pTextControl->GetCaption() ); std::string::size_type sizeEnd = strOrg.find_last_of( ">" ); m_TextDecoration = strOrg.substr( 0, ++sizeEnd ); //m_TextDecoration.append( "#@1R@#" ); //------------------------------------ // ListControl 생성. m_pListMemo = new KUIListControl( this, "listcontrol_01", "", "listitem_01", g_TextLineCount ); // Item column m_pListMemo->AddStringItemColumn( "guild_notice_text_01" ); // Create m_pListMemo->Create(); //------------------------------------- // 스크롤바. m_pScrollBar = dynamicCast< KUIControlVScrollSmallEx* >(GetChild( "scrollbar_memo" )); m_pScrollBar->SetShow( false ); return SUIWnd::InitControls( kPos ); } void SUIMemoViewWnd::OnNotifyUIWindowOpen( bool bOpen, bool bLimitWnd) { if( bOpen ) { //m_fAlphaValue = 0.1f; //m_bAlphaShow = true; //this->SetShow( true ); // //// 기존 포커스 제거. //this->m_pManager->RemoveWnd( this ); //// wnd 출력 리스트의 최하단에 추가. ( wnd 들중 가장 상위에 뜨게 된다. ) //this->m_pManager->AddWnd( this ); //// 가장위에 뜨도록 한다. this->m_pManager->SetFocus( this ); // 리스트의 각 아이템의 상태정보. if( m_pListMemo ) { m_nScrollPos = 0; m_pListMemo->RefreshItemState( g_ListSizeMAX ); // List 설정. RefreshList( m_nScrollPos ); // Scroll bar RefreshScrollbar(); } } } void SUIMemoViewWnd::Process(DWORD dwTime) { //// if( IsShow() ) //// { // m_dwAlphaTime = dwTime; // // SUIWnd::Process( dwTime ); // // // Fade In. // if( m_bAlphaShow ) // { // if( m_fAlphaValue < 1.0f && m_dwTime != 0.0f ) // { // m_fAlphaValue += 0.001f * ( dwTime - m_dwTime ); // this->ChangeAlpha( m_fAlphaValue ); // } // } // // Fade Out. // else // { // m_dwTime = 0.0f; // m_fAlphaValue = 0.0f; // m_bAlphaShow = false; // //this->ChangeAlpha( 0.0f ); // m_pGameManager->PostMsgAtDynamic( new SIMSG_SHOW_UIWINDOW( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_MEMOWND, false ) ); // 닫기. // } // // m_dwTime = dwTime; //// } } void SUIMemoViewWnd::ProcMsgAtStatic( SGameMessage* pMsg ) { switch( pMsg->nType ) { case IMSG_MOUSEMOVE : { //static DWORD dwTime = 0; //if(GetSafeTickCount() - dwTime > 300) //{ // // // pMsg->bUse = true; // //if( this->IsShow() ) // //{ // SIMSG_MOUSEMOVE * pData = static_cast< SIMSG_MOUSEMOVE * >( pMsg ); // // Fade IN. // KRect rt = this->GetRect(); // rt.left -= 4; rt.right += 4; // rt.top -=4; rt.bottom += 4; // //if( ( this->GetRect().IsInRect( LOWORD( pData->lParam ), HIWORD( pData->lParam ) ) ) ) // if( ( rt.IsInRect( LOWORD( pData->lParam ), HIWORD( pData->lParam ) ) ) ) // { // if( !m_bAlphaShow ) // { // m_fAlphaValue = 0.0f; // this->ChangeAlpha( m_fAlphaValue ); // m_bAlphaShow = true; // //------------------------------------------------------------------- // //this->SetShow( true ); // // //// 기존 포커스 제거. // //this->m_pManager->RemoveWnd( this ); // //// wnd 출력 리스트의 최하단에 추가. ( wnd 들중 가장 상위에 뜨게 된다. ) // //this->m_pManager->AddWnd( this ); // //// 가장위에 뜨도록 한다. // this->m_pManager->SetFocus( this ); // // // 리스트의 각 아이템의 상태정보. // if( m_pListMemo ) // { // m_nScrollPos = 0; // m_pListMemo->RefreshItemState( g_ListSizeMAX ); // // // List 설정. // RefreshList( m_nScrollPos ); // // Scroll bar // RefreshScrollbar(); // } // //------------------------------------------------------------------- // } // } // // Fade Out. // else // if( !( this->GetRect().IsInRect( LOWORD( pData->lParam ), HIWORD( pData->lParam ) ) ) ) // { // if( m_bAlphaShow && IsShow() ) // m_bAlphaShow = false; // } // dwTime = GetSafeTickCount(); //} pMsg->bUse = true; SIMSG_MOUSEMOVE * pData = dynamicCast< SIMSG_MOUSEMOVE * >( pMsg ); if( !( this->GetRect().IsInRect( LOWORD( pData->lParam ), HIWORD( pData->lParam ) ) ) ) { m_pGameManager->PostMsgAtDynamic( new SIMSG_SHOW_UIWINDOW( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_MEMOWND, false ) ); // 닫기. } } break; case IMSG_UI_SEND_DATA : { SIMSG_UI_SEND_DATA *pData = (SIMSG_UI_SEND_DATA *)pMsg; if( pData->m_strString == "guild_memo" ) // 길드메모. { m_ReceiveText = pData->m_strText; m_nTextPictogram = pData->m_dwData; // 메모뷰 Refresh. RefreshList( m_nScrollPos ); // Scroll bar RefreshScrollbar(); pData->bUse = true; } } break; case IMSG_UI_SETUP_REGION : { // string 에 해당하는 영역(크기)지정용 컨트롤을 읽어온다. SIMSG_UI_SETUP_REGION * pData = (SIMSG_UI_SETUP_REGION *)pMsg; //// 크기변경. //if( m_strRegion == "" || m_strRegion != pData->m_strRegion ) //{ m_strRegion = pData->m_strRegion; KUIWnd * pRegionWnd = GetChild( pData->m_strRegion.c_str() ); if( pRegionWnd ) { KRect rt = this->GetRect(); rt.right = rt.left + pRegionWnd->GetRect().GetWidth(); rt.bottom = rt.top + pRegionWnd->GetRect().GetHeight(); ResizeWnd( rt, pData->m_nX, pData->m_nY ); } MovePos( pData->m_nX, pData->m_nY ); // 위치이동. //// 스크롤. KRect rtScroll = m_pScrollBar->GetRect(); m_pScrollBar->MovePos( this->GetRect().right - rtScroll.GetWidth() - 3, pData->m_nY + 11 ); // y + 13 ); m_pScrollBar->ScrollRefresh(); //} pData->bUse = true; } break; //// 길드등급명 반환. //case IMSG_UI_GUILD_CLASSNAME : // { // // Edit 의 데코에 맞게 텍스트 변형 // std::string strOrg( static_cast< SIMSG_UI_GUILD_WNDMSG * >( pMsg )->strData.c_str() ); // ModifyText( strOrg ); // // 길드등급명 적용. // m_pClassName->SetCaption( strOrg.c_str() ); // } // break; /*case IMSG_UI_MOVE: { SIMSG_UI_MOVE* pMoveMsg = ( SIMSG_UI_MOVE* )pMsg; MovePos( pMoveMsg->m_nX, pMoveMsg->m_nY ); pMsg->bUse = true; } break; */ } } void SUIMemoViewWnd::PumpUpMessage( LPCSTR lpszControlID, DWORD nMessage, DWORD lparam, DWORD wparam ) { switch( nMessage ) { /*case KUI_MESSAGE::KBUTTON_CLICK : break;*/ //--------------------------------- // Scroll case KUI_MESSAGE::KSCROLL_SELECT : { m_nScrollPos = max( (int)lparam, 0 ); // 길드메모 재설정. RefreshList( m_nScrollPos ); // 스크롤바 조절. RefreshScrollbar(); } break; // 윈도우 이동 case KUI_MESSAGE::KGENWND_MOVE: LimitMoveWnd(); // 게임 외부로 나가지 못하게 제한 break; } SUIWnd::PumpUpMessage( lpszControlID, nMessage, lparam, wparam ); } DWORD SUIMemoViewWnd::OnMouseMessage(DWORD dwMessage, int x, int y) { /*switch( dwMessage ) { case KLBUTTON_DOWN : break; }*/ return SUIWnd::OnMouseMessage(dwMessage, x, y); } // Edit 의 데코에 맞게 텍스트 변형 void SUIMemoViewWnd::ModifyText( std::string & strOrg ) { // 데코 제외 순수 텍스트만 뽑아내기. std::string::size_type size = strOrg.find_last_of( ">" ); // Edit 의 데코에 맞게 텍스트 변형 strOrg = m_TextDecoration + strOrg.substr( ++size ); } void SUIMemoViewWnd::ResizeWnd( const KRect & rect, int x, int y ) { // 뒷배경. KUIWnd * pMemo = GetChild( "backline_12" ); KRect rt = pMemo->GetRect(); rt.right = rt.left + rect.GetWidth(); rt.bottom = rt.top + rect.GetHeight(); pMemo->Resize( rt ); ////// 스크롤. //KRect rtScroll = m_pScrollBar->GetRect(); //m_pScrollBar->MovePos( x + rect.GetWidth() - rtScroll.GetWidth() - 1, rt.top + 11 ); // y + 13 ); //m_pScrollBar->ScrollRefresh(); // 텍스트 컨트롤. rt = m_pTextControl->GetRect(); rt.right = rect.right - m_pScrollBar->GetRect().GetWidth() - 4; m_pTextControl->Resize( rt ); // 2010.07.20 - prodongi KUIControl * pControl = NULL; int maxSize = m_pListMemo->GetListConutMAX(); // 리스트 최대개수. int textIndex = 0; for( int i=0; iGetItem( i ); if( pItem ) { pItem->GetControl( pControl, "guild_notice_text_01" ); if (pControl) { rt = pControl->GetRect(); // 2010.07.21 첫 줄은 이모티콘 때문에 여유 길이 100을 더해준다 // 정상적으로는 int KTextParser::AddString을 수정해야 되는데, 오래 걸릴거 같아 임시로 offset을 준다,,, #ifdef _COUNTRY_TL_ int offset = 0; if (0 == i) offset = 100; rt.right = rect.right - m_pScrollBar->GetRect().GetWidth() - 4 + offset; #else rt.right = rect.right - m_pScrollBar->GetRect().GetWidth() - 4; #endif pControl->Resize(rt); } } }// for // 윈도우 크기변경. KUIWnd::OnSizeChangeNofity( rect ); } // 스크롤바 설정. void SUIMemoViewWnd::RefreshScrollbar() { if( m_pScrollBar && m_pListMemo ) { m_pScrollBar->SetScrollRange( m_pListMemo->GetListConutMAX(), m_lineList.size() ); } } // 스크롤바 설정. void SUIMemoViewWnd::RefreshList( int nScroll ) { if( m_pListMemo == NULL ) return; std::string StrMemo("____"); StrMemo += m_ReceiveText; // 맨 앞 네칸에는 '픽토그램' 이 들어갈자리. // 텍스트가 들어갈 영역만큼 텍스트를 분할하여 리스트로 관리. m_lineList.clear(); //m_pTextControl->SplitLine(m_lineList, StrMemo, "font_02", 9, false, true, true ); m_pTextControl->SplitLine(m_lineList, StrMemo, "font_02", 9, false, true ); int listMAX = m_lineList.size(); std::string::size_type nSize; if( ( nSize = m_lineList[ 0 ].find( "____" ) ) != std::string::npos ) { m_lineList[ 0 ].replace( nSize, 4, g_strPictogram[ m_nTextPictogram ] ); } if( listMAX > SHOW_SCROLLBAR ) m_pScrollBar->SetShow( true ); else m_pScrollBar->SetShow( false ); KUIControl * pControl = NULL; int maxSize = m_pListMemo->GetListConutMAX(); // 리스트 최대개수. int textIndex = 0; for( int i=0; iGetItem( i ); if( pItem ) { // index가 권한목록 최대개수 이하인동안 Refresh. if( i + nScroll < listMAX ) { textIndex = i + nScroll; // 컨트롤에 텍스트 맵핑. pItem->GetControl( pControl, "guild_notice_text_01" ); pControl->SetCaption( ( m_TextDecoration + m_lineList[ textIndex ] ).c_str() ); ////------------------------------- //// ** 해당 아이템을 확장 or 축소(원본크기) 한다. m_pListMemo->SetResize( i, textIndex, 1 ); } } }// for ////------------------------------- //// ** 리스트정보 최종 업데이트. m_pListMemo->RefreshList( m_nScrollPos ); }