#include "StdAfx.h" #include "UIRootNode.h" #include "UIWindow.h" #include "UIManager.h" #include "UIMsgboxEvent.h" /// ÁÖÀÇ»çÇ× : cUIRootNode::cUIRootNode( eUINodeType type ) : cUIContainer( type ) , mFontItemKeeper( 0 ) , mTipWindow( 0 ) { mpParent = 0; mID = 0; mpImage = 0; mRelativeRect.Set( 0, 0, GetScreenWidth(), GetScreenHeight() ); mAbsoluteRect.Set( 0, 0, GetScreenWidth(), GetScreenHeight() ); mVisible = true; mEnabled = true; mFontItemKeeper = new cUIFontItemKeeper; } /// ÁÖÀÇ»çÇ× : cUIRootNode::~cUIRootNode() { SAFE_DELETE(mFontItemKeeper); mProcessList.Clear(); mChildVisArray.Clear(); mFindChildMap.Clear(); } void cUIRootNode::HideAllChild( cUIWindow* except ) { /// °¡½Ã ¿©ºÎ¸¦ ¹é¾÷ mChildVisArray.Clear(); cChildList::cIterator i = mChildList.Begin(); cChildList::cIterator iend = mChildList.End(); for( ; i != iend; ++i ) { cUINode* n = (cUINode*)(*i); if( n && n->IsKindof( eUINODE_WINDOW ) ) { cUIWindow* w = (cUIWindow*)n; if( w->GetModalType() != eMSGBOX_NONE ) continue; /// visible À» ¹é¾÷Çϰí, visible »óŸé ÀúÀå if( w != except && w->IsBackupVisible() && w->IsVisible() ) { mChildVisArray.PushBack( w ); } } } /// Àüü UI ¼û±è ( except Á¦¿Ü ) cChildList::cIterator b = mChildList.Begin(); cChildList::cIterator bend = mChildList.End(); for( ; b != bend; ++b ) { cUINode* n = (cUINode*)(*b); if( n && n->IsKindof( eUINODE_WINDOW ) ) { cUIWindow* w = (cUIWindow*)n; if( w->GetModalType() != eMSGBOX_NONE ) continue; if( n != except && w->IsVisible() ) w->Hide( false ); } else { assert(0); } } } void cUIRootNode::ShowAllChild() { /// °¡½Ã ¿©ºÎ¸¦ º¹±¸ for( unsigned int i = 0; i < mChildVisArray.GetSize(); ++i ) { cUIWindow* w = (cUIWindow*)mChildVisArray[i]; if( w ) w->Show( false ); else assert(0); } mChildVisArray.Clear(); /// Ưº° À©µµ¿ìµé º¹±¸ UIMAN->RestoreShow(); } /// ÁÖÀÇ»çÇ× : bool cUIRootNode::Create( const cString&, cUIContainer*, unsigned int, bool ) { assert( 0 ); return true; } /// ÁÖÀÇ»çÇ× : void cUIRootNode::UpdateRect() { assert( 0 ); } void cUIRootNode::UpdateSkin() { /// ÇØ»óµµ º¯È­¿¡µû¸¥ ·çÆ®³ëµåÀÇ »çÀÌÁîµµ º¯°æ cUIRect rc( 0, 0, GetScreenWidth(), GetScreenHeight() ); mAbsoluteRect = rc; mRelativeRect = rc; /// ÀڽĿ¡ ½ºÅ² Àû¿ë cChildList::cIterator i = mChildList.Begin(); cChildList::cIterator end = mChildList.End(); cUINode* n = 0; for( ; i != end; ++i ) { n = (cUINode*)(*i); if( n ) n->UpdateSkin(); } } /// ÁÖÀÇ»çÇ× : bool cUIRootNode::SetSkin( const cUINodeSkin* ) { return true; } /// ÁÖÀÇ»çÇ× : bool cUIRootNode::IsValid() const { return true; } /// ÁÖÀÇ»çÇ× : bool cUIRootNode::HandleEvent( const cUIEvent& ) { return true; } void cUIRootNode::OnPreRender() { if( mVisible == false ) return; cChildList::cIterator i = mChildList.Begin(); cChildList::cIterator end = mChildList.End(); for( ; i != end; ++i ) { cUINode* n = (cUINode*)(*i); if( n && n->IsVisible() == true ) n->OnPreRender(); } } /// ÁÖÀÇ»çÇ× : void cUIRootNode::OnRender( cUIFontItemKeeper* ) { if( mVisible ) { /// ÀÚ½Ä ·»´õ¸µ cChildList::cIterator i = mChildList.Begin(); cChildList::cIterator end = mChildList.End(); for( ; i != end; ++i ) { cUINode* n = (cUINode*)(*i); if( n == mTipWindow ) continue; if( n && n->IsVisible() == true ) n->OnRender( mFontItemKeeper ); } mFontItemKeeper->DrawAll(); } } // ÆÁ ±×¸®±â void cUIRootNode::OnRenderTip() { if( mVisible == false ) return; /// ÆÁ ·»´õ¸µ if( mTipWindow ) { mTipWindow->OnRender( mFontItemKeeper ); mFontItemKeeper->DrawAll(); } } /// ÁÖÀÇ»çÇ× : void cUIRootNode::OnProcess( unsigned long deltaTime, unsigned long accumTime ) { if( mVisible ) { cProcessChildList::cIterator i = mProcessList.Begin(); cProcessChildList::cIterator end = mProcessList.End(); for( ; i != end; ++i ) { cUINode* node = ( cUINode* )( *i ); if( node ) { node->OnProcess( deltaTime, accumTime ); } else { assert(0); } } } } cUIContainer* cUIRootNode::GetContainer( const cUIPos& pos ) const { /// È­¸é»ó ¸Ç ¾Õ¿¡¼­ µÚ·Î °Ë»ç cChildList::cConstIterator i = (--mChildList.End()); cChildList::cConstIterator end = (--mChildList.Begin()); for( ; i != end; --i ) { cUINode* n = (cUINode*)(*i); if( !n ) { assert(0); return 0; } if( n->IsVisible() == false ) { continue; } if( n->IsKindof(eUINODE_CONTAINER) ) { if( n->ContainPoint( pos ) ) { return (cUIContainer*)n; } } } return 0; } void cUIRootNode::Open() { if( mChildList.GetSize() > 0 ) { cChildList::cIterator i = mChildList.Begin(); cChildList::cIterator end = mChildList.End(); for( ; i != end; i++ ) { cUINode* n = (cUINode*)(*i); if( n && n->IsKindof( eUINODE_WINDOW ) ) { cUIWindow* con = (cUIWindow*)n; if( con ) con->Open(); } } } } void cUIRootNode::Close() { if( mChildList.GetSize() > 0 ) { /// È­¸é»ó ¾Õ¿¡¼­ µÚ·Î °Ë»ç cChildList::cConstIterator i = (--mChildList.End()); cChildList::cConstIterator end = (--mChildList.Begin()); for( ; i != end; --i ) { cUINode* n = (cUINode*)(*i); if( n && n->IsKindof( eUINODE_WINDOW ) ) { cUIWindow* con = (cUIWindow*)n; if( con ) con->Close(); } } } } /// À©µµ¿ì¸¦ ´Ý´Â´Ù. bool cUIRootNode::HideESC() { /// Àڽݹ¼ö°¡ Çϳª¶óµµ ÀÖ¾î¾ßÇÑ´Ù. if( mChildList.GetSize() > 0 ) { /// È­¸é»ó ¾Õ¿¡¼­ µÚ·Î °Ë»ç cChildList::cConstIterator i = (--mChildList.End()); cChildList::cConstIterator end = (--mChildList.Begin()); for( ; i != end; --i ) { ////// nodeÀε¥ ÀÚ½ÄÀÎ°Íµé µû·Î Ã¼Å©ÇØº¸±â cUINode* n = (cUINode*)(*i); /// root ÀÇ ÀÚ½ÄÀº ¹Ýµå½Ã ÄÁÅ×À̳ʿ©¾ß ÇÑ´Ù. if( n && n->IsKindof( eUINODE_WINDOW ) ) { cUIWindow* con = (cUIWindow*)n; /// ¹Ýµå½Ã º¸¿©¾ßÇÏ´Â À©µµ¿ìµé¸¸ »©°í ó¸®ÇÑ´Ù if( con && con->IsVisible() && con->IsHoldView() == false ) { con->HideESC( true ); return true; } } } } return false; } void cUIRootNode::NetUnLockAllUI() { /// Àڽݹ¼ö°¡ Çϳª¶óµµ ÀÖ¾î¾ßÇÑ´Ù. if( mChildList.GetSize() > 0 ) { /// È­¸é»ó ¾Õ¿¡¼­ µÚ·Î °Ë»ç cChildList::cConstIterator i = (--mChildList.End()); cChildList::cConstIterator end = (--mChildList.Begin()); for( ; i != end; --i ) { ////// nodeÀε¥ ÀÚ½ÄÀÎ°Íµé µû·Î Ã¼Å©ÇØº¸±â cUINode* n = (cUINode*)(*i); /// root ÀÇ ÀÚ½ÄÀº ¹Ýµå½Ã ÄÁÅ×À̳ʿ©¾ß ÇÑ´Ù. if( n && n->IsKindof( eUINODE_WINDOW ) ) { cUIWindow* con = (cUIWindow*)n; if( con ) con->NetUnLockAllUI(); } } } } void cUIRootNode::AddProcessChild( cUINode* n ) { if( n->IsEnableProcess() ) mProcessList.PushFront( n ); if( n->IsKindof( eUINODE_CONTAINER ) == true ) { cUIContainer* con = (cUIContainer*)n; tPointerList* plist = con->GetChildList(); if( plist->IsEmpty() ) return; tPointerList::cIterator i = plist->Begin(); tPointerList::cIterator iend = plist->End(); for( ; i != iend; ++i ) { AddProcessChild( (cUINode*)(*i) ); } } } void cUIRootNode::RemoveProcessChild( cUINode* n ) { if( n->IsEnableProcess() ) mProcessList.Remove( n ); if( n->IsKindof( eUINODE_CONTAINER ) == true ) { cUIContainer* con = (cUIContainer*)n; tPointerList* plist = con->GetChildList(); if( plist->IsEmpty() ) return; tPointerList::cIterator i = plist->Begin(); tPointerList::cIterator iend = plist->End(); for( ; i != iend; ++i ) { cUINode* p = (cUINode*)(*i); RemoveProcessChild( p ); } } } // ¸Þ¼¼Áö¹Ú½º´Â Á¦¿Ü void cUIRootNode::AddSearchChild( cUINode* n ) { if( n ) { if( n->GetID() > eUIID_ID_BEGIN ) { if( mFindChildMap.Insert( n->GetID(), n ) == false ) { assert(0); return; } } } else assert(0); } void cUIRootNode::RemoveSearchChild( unsigned long id ) { if( mFindChildMap.IsEmpty() == false ) mFindChildMap.Erase( id ); } cUINode* cUIRootNode::FindNodeByID( unsigned long id ) { return (cUINode*)mFindChildMap.GetAt( id ); }