add SetDrawFunction
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
#include "ActorFrame.h"
|
#include "ActorFrame.h"
|
||||||
#include "arch/Dialog/Dialog.h"
|
#include "arch/Dialog/Dialog.h"
|
||||||
#include "RageUtil.h"
|
#include "RageUtil.h"
|
||||||
|
#include "RageLog.h"
|
||||||
#include "XmlFile.h"
|
#include "XmlFile.h"
|
||||||
#include "ActorUtil.h"
|
#include "ActorUtil.h"
|
||||||
#include "LuaBinding.h"
|
#include "LuaBinding.h"
|
||||||
@@ -25,6 +26,7 @@ ActorFrame::ActorFrame()
|
|||||||
m_bPropagateCommands = false;
|
m_bPropagateCommands = false;
|
||||||
m_bDeleteChildren = false;
|
m_bDeleteChildren = false;
|
||||||
m_bDrawByZPosition = false;
|
m_bDrawByZPosition = false;
|
||||||
|
m_DrawFunction.SetFromNil();
|
||||||
m_fUpdateRate = 1;
|
m_fUpdateRate = 1;
|
||||||
m_fFOV = -1;
|
m_fFOV = -1;
|
||||||
m_fVanishX = SCREEN_CENTER_X;
|
m_fVanishX = SCREEN_CENTER_X;
|
||||||
@@ -46,6 +48,7 @@ ActorFrame::ActorFrame( const ActorFrame &cpy ):
|
|||||||
CPY( m_bPropagateCommands );
|
CPY( m_bPropagateCommands );
|
||||||
CPY( m_bDeleteChildren );
|
CPY( m_bDeleteChildren );
|
||||||
CPY( m_bDrawByZPosition );
|
CPY( m_bDrawByZPosition );
|
||||||
|
CPY( m_DrawFunction );
|
||||||
CPY( m_fUpdateRate );
|
CPY( m_fUpdateRate );
|
||||||
CPY( m_fFOV );
|
CPY( m_fFOV );
|
||||||
CPY( m_fVanishX );
|
CPY( m_fVanishX );
|
||||||
@@ -204,6 +207,19 @@ void ActorFrame::DrawPrimitives()
|
|||||||
// any geometry that belongs to this object.
|
// any geometry that belongs to this object.
|
||||||
// Actor::DrawPrimitives();
|
// Actor::DrawPrimitives();
|
||||||
|
|
||||||
|
if( unlikely(!m_DrawFunction.IsNil()) )
|
||||||
|
{
|
||||||
|
Lua *L = LUA->Get();
|
||||||
|
m_DrawFunction.PushSelf( L );
|
||||||
|
ASSERT( !lua_isnil(L, -1) );
|
||||||
|
this->PushSelf( L );
|
||||||
|
RString sError;
|
||||||
|
if( !LuaHelpers::RunScriptOnStack(L, sError, 1, 0) ) // 1 arg, 0 results
|
||||||
|
LOG->Warn( "Error running DrawFunction: %s", sError.c_str() );
|
||||||
|
LUA->Release(L);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// draw all sub-ActorFrames while we're in the ActorFrame's local coordinate space
|
// draw all sub-ActorFrames while we're in the ActorFrame's local coordinate space
|
||||||
if( m_bDrawByZPosition )
|
if( m_bDrawByZPosition )
|
||||||
{
|
{
|
||||||
@@ -423,6 +439,21 @@ public:
|
|||||||
}
|
}
|
||||||
static int GetNumChildren( T* p, lua_State *L ) { lua_pushnumber( L, p->GetNumChildren() ); return 1; }
|
static int GetNumChildren( T* p, lua_State *L ) { lua_pushnumber( L, p->GetNumChildren() ); return 1; }
|
||||||
static int SetDrawByZPosition( T* p, lua_State *L ) { p->SetDrawByZPosition( BArg(1) ); return 1; }
|
static int SetDrawByZPosition( T* p, lua_State *L ) { p->SetDrawByZPosition( BArg(1) ); return 1; }
|
||||||
|
static int SetDrawFunction( T* p, lua_State *L )
|
||||||
|
{
|
||||||
|
luaL_checktype( L, 1, LUA_TFUNCTION );
|
||||||
|
|
||||||
|
LuaReference ref;
|
||||||
|
lua_pushvalue( L, 1 );
|
||||||
|
ref.SetFromStack( L );
|
||||||
|
p->SetDrawFunction( ref );
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
static int GetDrawFunction( T* p, lua_State *L )
|
||||||
|
{
|
||||||
|
p->GetDrawFunction().PushSelf(L);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
LunaActorFrame()
|
LunaActorFrame()
|
||||||
{
|
{
|
||||||
@@ -438,6 +469,8 @@ public:
|
|||||||
ADD_METHOD( GetChildren );
|
ADD_METHOD( GetChildren );
|
||||||
ADD_METHOD( GetNumChildren );
|
ADD_METHOD( GetNumChildren );
|
||||||
ADD_METHOD( SetDrawByZPosition );
|
ADD_METHOD( SetDrawByZPosition );
|
||||||
|
ADD_METHOD( SetDrawFunction );
|
||||||
|
ADD_METHOD( GetDrawFunction );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -27,6 +27,8 @@ public:
|
|||||||
void SortByDrawOrder();
|
void SortByDrawOrder();
|
||||||
void SetDrawByZPosition( bool b );
|
void SetDrawByZPosition( bool b );
|
||||||
|
|
||||||
|
void SetDrawFunction( const LuaReference &DrawFunction ) { m_DrawFunction = DrawFunction; }
|
||||||
|
LuaReference GetDrawFunction() const { return m_DrawFunction; }
|
||||||
virtual bool AutoLoadChildren() const { return false; } // derived classes override to automatically LoadChildrenFromNode
|
virtual bool AutoLoadChildren() const { return false; } // derived classes override to automatically LoadChildrenFromNode
|
||||||
void DeleteChildrenWhenDone( bool bDelete=true ) { m_bDeleteChildren = bDelete; }
|
void DeleteChildrenWhenDone( bool bDelete=true ) { m_bDeleteChildren = bDelete; }
|
||||||
void DeleteAllChildren();
|
void DeleteAllChildren();
|
||||||
@@ -76,6 +78,7 @@ protected:
|
|||||||
bool m_bPropagateCommands;
|
bool m_bPropagateCommands;
|
||||||
bool m_bDeleteChildren;
|
bool m_bDeleteChildren;
|
||||||
bool m_bDrawByZPosition;
|
bool m_bDrawByZPosition;
|
||||||
|
LuaReference m_DrawFunction;
|
||||||
|
|
||||||
// state effects
|
// state effects
|
||||||
float m_fUpdateRate;
|
float m_fUpdateRate;
|
||||||
|
|||||||
Reference in New Issue
Block a user