diff --git a/stepmania/src/Actor.cpp b/stepmania/src/Actor.cpp index cb285cc262..ade468f2fd 100644 --- a/stepmania/src/Actor.cpp +++ b/stepmania/src/Actor.cpp @@ -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()) ); diff --git a/stepmania/src/Screen.cpp b/stepmania/src/Screen.cpp index f02a729a86..b3eda02b28 100644 --- a/stepmania/src/Screen.cpp +++ b/stepmania/src/Screen.cpp @@ -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 ); diff --git a/stepmania/src/Screen.h b/stepmania/src/Screen.h index 07a8adae75..158fda1d9e 100644 --- a/stepmania/src/Screen.h +++ b/stepmania/src/Screen.h @@ -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();