set the loading screen, so actors can use it as an input variable

This commit is contained in:
Glenn Maynard
2005-10-28 22:47:11 +00:00
parent 102f39d7c5
commit fde59d8464
3 changed files with 36 additions and 3 deletions
+7 -2
View File
@@ -196,9 +196,14 @@ void Actor::LoadFromNode( const CString& sDir, const XNode* pNode )
{
if( pChild->m_sName == "Input" )
{
/* Parameters are set as globals by ActorUtil::LoadFromNode.
/*
* Parameters are set as globals by ActorUtil::LoadFromNode and
* Screen::InitScreen.
* If parameters are specified here, save them to the actor. Accessing
* parameters as globals directly is deprecated. */
* parameters as globals directly is deprecated. (However, it's still
* the only way to access them when self isn't available, such as from
* RunAtExpressionS.)
*/
CString sName;
if( !pChild->GetAttrValue( "Name", sName ) )
RageException::Throw( ssprintf("Input node in '%s' is missing the attribute 'Name'", sDir.c_str()) );
+26
View File
@@ -17,6 +17,32 @@
#define PERSIST_SCREENS THEME->GetMetric (m_sName,"PersistScreens")
#define GROUPED_SCREENS THEME->GetMetric (m_sName,"GroupedScreens")
void Screen::InitScreen( Screen *pScreen )
{
/* Set the name of the loading screen, so Actor::LoadFromNode can
* access it. */
LuaReference Old;
{
Lua *L = LUA->Get();
lua_getglobal( L, "LoadingScreen" );
Old.SetFromStack( L );
LuaHelpers::Push( pScreen->GetName(), L );
lua_setglobal( L, "LoadingScreen" );
LUA->Release( L );
}
pScreen->Init();
/* Restore the old value. */
{
Lua *L = LUA->Get();
Old.PushSelf( L );
lua_setglobal( L, "LoadingScreen" );
LUA->Release( L );
}
}
Screen::Screen( CString sName )
{
SetName( sName );
+3 -1
View File
@@ -17,7 +17,7 @@ void RegisterScreenClass( const CString& sClassName, CreateScreenFn pfn );
// Each Screen class should have a REGISTER_SCREEN_CLASS in its CPP file.
#define REGISTER_SCREEN_CLASS( className ) \
static Screen* Create##className( const CString &sName ) { Screen *pRet = new className( sName ); pRet->Init(); return pRet; } \
static Screen* Create##className( const CString &sName ) { Screen *pRet = new className( sName ); Screen::InitScreen( pRet ); return pRet; } \
struct Register##className { \
Register##className() { RegisterScreenClass( #className,Create##className); } \
}; \
@@ -34,6 +34,8 @@ enum ScreenType
class Screen : public ActorFrame
{
public:
static void InitScreen( Screen *pScreen );
Screen( CString sName ); // enforce that all screens have m_sName filled in
virtual ~Screen();