#include "stdafx.h" //#include "SUIWnd.h" #include "SGameManager.h" //#include "SGameMessageUI.h" #include "KResourceManager.h" #include //#include "KUIControl.h" #include "SInventoryMgr.h" #include "SSKillSlot.h" #include "SSummonSlotMgr.h" #include "SMessengerMgr.h" #include "STradeMgr.h" #include "SStorageMgr.h" #include "SMotionMgr.h" #include "STargetMgr.h" #include "SPlayerInfoMgr.h" #include "SStoreMgr.h" #include "SPetMgr.h" // sonador #2.1.2.4.3 팻 조작 UI 연동 #include "SPetSkillMgr.h" // sonador #2.1.2.4.3 팻 조작 UI 연동 #include "STitleMgr.h" #include "GameDefine.h" #include "SDebug_Util.h" SUIWnd::SUIWnd( SGameManager* pGameManager ) : m_RaidMgr ( *static_cast(GameUIMgrInstance.GetUIMgr( SGameUIInstance::RAID_MGR ) ) ) , m_PartyMgr ( *static_cast(GameUIMgrInstance.GetUIMgr( SGameUIInstance::PARTY_MGR )) ) // 2011.10.18 : servantes : SPartyMgr 관리 클래스 , m_GuildMgr ( *static_cast(GameUIMgrInstance.GetUIMgr( SGameUIInstance::GUILD_MGR )) ) , m_FriendMgr ( *static_cast(GameUIMgrInstance.GetUIMgr( SGameUIInstance::FRIEND_MGR )) ) , m_CutMgr ( *static_cast(GameUIMgrInstance.GetUIMgr( SGameUIInstance::CUT_MGR )) ) , m_TradeMgr ( *static_cast(GameUIMgrInstance.GetUIMgr( SGameUIInstance::TRADE_MGR )) ) , m_StorageMgr ( *static_cast(GameUIMgrInstance.GetUIMgr( SGameUIInstance::STORAGE_MGR )) ) , m_MotionMgr ( *static_cast(GameUIMgrInstance.GetUIMgr( SGameUIInstance::MOTION_MGR )) ) , m_PlayerInfoMgr ( *static_cast(GameUIMgrInstance.GetUIMgr( SGameUIInstance::PLAYERINFO_MGR )) ) , m_InventoryMgr ( *static_cast(GameUIMgrInstance.GetUIMgr( SGameUIInstance::INVENTORY_MGR )) ) , m_CreatureSlotMgr ( *static_cast(GameUIMgrInstance.GetUIMgr( SGameUIInstance::CREATURESLOT_MGR )) ) , m_SkillSlotMgr ( *static_cast(GameUIMgrInstance.GetUIMgr( SGameUIInstance::SKILLSLOT_MGR )) ) , m_CreatureSkillSlotMgr( *static_cast(GameUIMgrInstance.GetUIMgr( SGameUIInstance::CREATURESKILLSLOT_MGR )) ) , m_GuildDataMgr ( *static_cast(GameUIMgrInstance.GetUIMgr( SGameUIInstance::GUILDDATA_MGR )) ) , m_PetMgr ( *static_cast(GameUIMgrInstance.GetUIMgr( SGameUIInstance::PET_MGR )) ) // sonador #2.1.2.4.3 팻 조작 UI 연동 , m_PetSkillMgr ( *static_cast(GameUIMgrInstance.GetUIMgr( SGameUIInstance::PETSKILL_MGR )) ) // sonador #2.1.2.4.3 팻 조작 UI 연동 , m_TitleMgr ( *static_cast(GameUIMgrInstance.GetUIMgr( SGameUIInstance::TITLE_MGR )) ) // 2012. 4. 30 - marine , m_bShiftKey ( false ) //servantes 2010.10.15 , m_bControlKey ( false ) //servantes 2010.10.15 , m_bAltKey ( false ) { m_pGameManager = pGameManager; m_nDynamicWndID = -1; m_bCutCaption = false; } SUIWnd::~SUIWnd() { iter_AddonWndList it = m_listChildAddonWnd.begin(); while( it != m_listChildAddonWnd.end() ) { SAFE_DELETE( (*it) ); it = m_listChildAddonWnd.erase( it ); } } SUIWnd* SUIWnd::CreateWnd( const char* szNUIFileName, KUIWndManager* pWndManager, KPoint kPos, int nWindowID ) { KStream* pStream = KFileManager::Instance().CreateStreamFromResource( szNUIFileName ); if( pStream ) { m_nWindowID = nWindowID; Create( *pStream, pWndManager ); InitControls( kPos ); } KFileManager::Instance().DeleteStream( pStream ); return this; } bool SUIWnd::InitControls( KPoint kPos ) { KUIWnd::setBoundingControl(); /// 2011.02.16 - prodongi MovePos( kPos.x, kPos.y ); InitData(); return true; } bool SUIWnd::InitData( bool bReload ) { // Crop caption text if( m_bCutCaption ) CutCaptionNTooltip(); return true; } void SUIWnd::LimitMoveWnd( int nLeft, int nTop, int nRight, int nBottom ) { const KSize& rResolution = KUIWndManager::GetResolution(); const KRect &rWndRect = GetRect(); KRect rcLimit( nLeft, nTop, (rResolution.cx + nRight), (rResolution.cy + nBottom) ); KSize sizMoveOffset( 0, 0 ); if( rWndRect.left < rcLimit.left ) sizMoveOffset.cx += (rcLimit.left - rWndRect.left ); if( rWndRect.top < rcLimit.top ) sizMoveOffset.cy += (rcLimit.top - rWndRect.top ); if( rWndRect.right > rcLimit.right ) sizMoveOffset.cx += (rcLimit.right - rWndRect.right ); if( rWndRect.bottom > rcLimit.bottom ) sizMoveOffset.cy += (rcLimit.bottom - rWndRect.bottom); if( 0 != sizMoveOffset.cx || 0 != sizMoveOffset.cy ) MovePosOffset( sizMoveOffset.cx, sizMoveOffset.cy ); } void SUIWnd::SetDynamicID( int nDynamicWndID ) { m_nDynamicWndID = nDynamicWndID; } void SUIWnd::OnNotifyUIWindowOpen( bool bOpen, bool bLimitWnd ) { if( bLimitWnd ) LimitMoveWnd(); #ifdef _KUI_INVALIDATION // { [sonador] if( this->IsShow() != bOpen ) { InvalidateWnd(); } // } #endif if( bOpen == false && m_pGameManager != NULL ) { iter_AddonWndList it = m_listChildAddonWnd.begin(); for( ; it != m_listChildAddonWnd.end(); ++it ) { if( (*it)->addonwnd && (*it)->addonwnd->IsShow()) m_pGameManager->PostMsgAtDynamic( new SIMSG_SHOW_UIWINDOW( (SIMSG_TOGGLE_UIWINDOW::_UIWINDOW_TYPE)(*it)->window_id, false ) ); } } } void SUIWnd::PumpUpMessage( LPCSTR lpszControlID, DWORD nMessage, DWORD lparam, DWORD wparam ) { if( nMessage == KUI_MESSAGE::KBUTTON_CLICK && m_pGameManager != NULL ) m_pGameManager->StartSound( "ui_button_click.wav" ); KUIGenWnd::PumpUpMessage( lpszControlID, nMessage, lparam, wparam ); } DWORD SUIWnd::OnMouseMessage( DWORD dwMessage, int x, int y ) { switch( dwMessage ) { case KLBUTTON_UP: case KLBUTTON_DOWN: case KRBUTTON_UP: case KRBUTTON_DOWN: case KWHEEL_UP: case KWHEEL_DOWN: case KLBUTTON_DBLCLK: case KRBUTTON_DBLCLK: { if(KLBUTTON_UP == dwMessage) int k=0; // 2011.10.29 : servantes : test code if( m_pGameManager == NULL ) return KUIGenWnd::OnMouseMessage( dwMessage, x, y ); iter_AddonWndList it = m_listChildAddonWnd.begin(); for( ; it != m_listChildAddonWnd.end(); ++it ) { if( (*it)->addonwnd == NULL ) continue; if( dwMessage == (*it)->click_mode ) { if( (*it)->vControl_list.empty() ) { if( !(*it)->addonwnd->IsShow() ) { SetAddOnWindowPosition( (*it), this, x, y ); } m_pGameManager->PostMsgAtDynamic( new SIMSG_SHOW_UIWINDOW( (SIMSG_TOGGLE_UIWINDOW::_UIWINDOW_TYPE)(*it)->window_id, !(*it)->addonwnd->IsShow() ) ); break; } else { std::vector< std::string >::iterator it_string = (*it)->vControl_list.begin(); for( ; it_string != (*it)->vControl_list.end(); ++it_string ) { KUIWnd* pControl = GetChild( (*it_string).c_str() ); if( pControl == NULL ) continue; if( pControl->IsInRect( x, y ) == false ) continue; if( !(*it)->addonwnd->IsShow() ) { SetAddOnWindowPosition( (*it), pControl, x, y ); } m_pGameManager->PostMsgAtDynamic( new SIMSG_SHOW_UIWINDOW( (SIMSG_TOGGLE_UIWINDOW::_UIWINDOW_TYPE)(*it)->window_id, !(*it)->addonwnd->IsShow() ) ); return KUIGenWnd::OnMouseMessage( dwMessage, x, y ); } } } else { if( (*it)->addonwnd->IsShow() ) { bool bCloseWnd = true; switch( (*it)->click_mode ) { case KLBUTTON_DOWN: if( dwMessage == KLBUTTON_UP ) bCloseWnd = false; break; case KRBUTTON_DOWN: if( dwMessage == KRBUTTON_UP ) bCloseWnd = false; break; case KWHEEL_DOWN: if( dwMessage == KWHEEL_UP )bCloseWnd = false; break; } if( bCloseWnd ) m_pGameManager->PostMsgAtDynamic( new SIMSG_SHOW_UIWINDOW( (SIMSG_TOGGLE_UIWINDOW::_UIWINDOW_TYPE)(*it)->window_id, false ) ); } } } } break; } return KUIGenWnd::OnMouseMessage( dwMessage, x, y ); } void SUIWnd::AddChildAddonWnd( int window_id, KUIWnd *wnd, int click_mode, std::vector< std::string >& control_list, int addon_posx_type, int addon_posy_type, int pos_x, int pos_y ) { if( GetAddOnWnd( window_id ) != NULL ) { SAFE_DELETE( wnd ); assert( false && "동일한 애드온 윈도우가 발견됨" ); return; } m_listChildAddonWnd.push_back( new AddOnWndOpenClose( window_id, wnd, click_mode, control_list, addon_posx_type, addon_posy_type, pos_x, pos_y ) ); } bool SUIWnd::RemoveChildAddonWnd( int window_id, KUIWnd *wnd ) { iter_AddonWndList it = m_listChildAddonWnd.begin(); for( ; it != m_listChildAddonWnd.end(); ++it ) { AddOnWndOpenClose* pAddonWnd = (*it); if( (*pAddonWnd) == window_id ) { SAFE_DELETE( (*it) ); m_listChildAddonWnd.erase( it ); return true; } } return false; } AddOnWndOpenClose* SUIWnd::GetAddOnWnd( int window_id ) { iter_AddonWndList it = m_listChildAddonWnd.begin(); while( it != m_listChildAddonWnd.end() ) { AddOnWndOpenClose* pAddonWnd = (*it); if( (*pAddonWnd) == window_id ) return pAddonWnd; ++it; } return NULL; } bool SUIWnd::SetAddOnWindowPosition( AddOnWndOpenClose* pInfo, KUIWnd* pMainWnd, int mouse_posx, int mouse_posy ) { if( m_pGameManager == NULL ) return false; if( pInfo == NULL || pMainWnd == NULL ) return false; if( pInfo->addonwnd == NULL ) return false; KPoint point( 0, 0 ); if( pInfo->addon_posx_type == MOUSE_POSITION ) point.x = mouse_posx; else if( pInfo->addon_posx_type == USER_INPUT_POSTION ) point.x = pMainWnd->GetRect().left + pInfo->pos_x; else { SIMSG_GET_ADDON_POSITION msg( pInfo->addon_posx_type, pMainWnd->GetRect(), pInfo->addonwnd->GetRect() ); m_pGameManager->InterfaceMsg( &msg ); point.x = msg.val; } if( pInfo->addon_posy_type == MOUSE_POSITION ) point.y = mouse_posy; else if( pInfo->addon_posy_type == USER_INPUT_POSTION ) point.y = pMainWnd->GetRect().top + pInfo->pos_y; else { SIMSG_GET_ADDON_POSITION msg( pInfo->addon_posy_type, pMainWnd->GetRect(), pInfo->addonwnd->GetRect() ); m_pGameManager->InterfaceMsg( &msg ); point.y = msg.val; } pInfo->addonwnd->MovePos( point.x, point.y ); return true; } // bintitle. 2010.04.30 // If a child control's caption text exceeds the control's size, // trim the caption text to fit the control (add "..." at the end) // and show the original text as a tooltip. void SUIWnd::CutCaptionNTooltip() { for( std::list< KUIWnd* >::iterator it = m_listChild.begin(); it!=m_listChild.end(); ++it) { static_cast< KUIControl* >( (*it) )->CutCaptionNTooltip(); } }