add GetChild

This commit is contained in:
Chris Danford
2005-03-01 21:55:47 +00:00
parent cb02171492
commit 1fd957fe9c
2 changed files with 23 additions and 0 deletions
+11
View File
@@ -8,6 +8,7 @@
#include "ActorCommands.h"
#include "RageDisplay.h"
#include "ScreenDimensions.h"
#include "Foreach.h"
// lua start
LUA_REGISTER_CLASS( ActorFrame )
@@ -89,6 +90,16 @@ void ActorFrame::RemoveChild( Actor* pActor )
m_SubActors.erase( iter );
}
Actor* ActorFrame::GetChild( const CString &sName )
{
FOREACH( Actor*, m_SubActors, a )
{
if( (*a)->GetName() == sName )
return *a;
}
return NULL;
}
void ActorFrame::RemoveAllChildren()
{
m_SubActors.clear();
+12
View File
@@ -12,10 +12,20 @@ public:
LunaActorFrame() { LUA->Register( Register ); }
static int propagate( T* p, lua_State *L ) { p->SetPropagateCommands( !!IArg(1) ); return 0; }
static int GetChild( T* p, lua_State *L )
{
Actor *pChild = p->GetChild( SArg(1) );
if( pChild )
pChild->PushSelf( L );
else
lua_pushnil( L );
return 1;
}
static void Register(lua_State *L)
{
ADD_METHOD( propagate )
ADD_METHOD( GetChild )
LunaActor<T>::Register( L );
}
};
@@ -31,6 +41,8 @@ public:
virtual void AddChild( Actor* pActor );
virtual void RemoveChild( Actor* pActor );
Actor* GetChild( const CString &sName );
void RemoveAllChildren();
void MoveToTail( Actor* pActor );
void MoveToHead( Actor* pActor );