diff --git a/stepmania/src/ScreenGameplay.cpp b/stepmania/src/ScreenGameplay.cpp index f99b5b4520..c41ebced98 100644 --- a/stepmania/src/ScreenGameplay.cpp +++ b/stepmania/src/ScreenGameplay.cpp @@ -2197,12 +2197,7 @@ void ScreenGameplay::HandleScreenMessage( const ScreenMessage SM ) int iPlaySongIndex = GAMESTATE->GetCourseSongIndex()+1; iPlaySongIndex %= m_apSongsQueue.size(); - Lua *L = LUA->Get(); - m_apSongsQueue[iPlaySongIndex]->PushSelf( L ); - GAMESTATE->m_Environment->Set( L, "NextSong" ); MESSAGEMAN->Broadcast( "NextCourseSong" ); - GAMESTATE->m_Environment->Unset( L, "NextSong" ); - LUA->Release( L ); m_NextSong.PlayCommand( "Start" ); m_NextSong.Reset(); m_NextSong.StartTransitioning( SM_LoadNextSong ); @@ -2414,6 +2409,34 @@ void ScreenGameplay::ShowOniGameOver( PlayerNumber pn ) m_sprOniGameOver[pn].PlayCommand( "Die" ); } +Song *ScreenGameplay::GetNextCourseSong() const +{ + ASSERT( GAMESTATE->IsCourseMode() ); + + int iPlaySongIndex = GAMESTATE->GetCourseSongIndex()+1; + iPlaySongIndex %= m_apSongsQueue.size(); + + return m_apSongsQueue[iPlaySongIndex]; +} + +// lua start +#include "LuaBinding.h" + +class LunaScreenGameplay: public Luna +{ +public: + LunaScreenGameplay() { LUA->Register( Register ); } + + static int GetNextCourseSong( T* p, lua_State *L ) { p->GetNextCourseSong()->PushSelf(L); return 1; } + static void Register( Lua *L ) + { + ADD_METHOD( GetNextCourseSong ) + Luna::Register( L ); + } +}; + +LUA_REGISTER_DERIVED_CLASS( ScreenGameplay, ScreenWithMenuElements ) +// lua end /* * (c) 2001-2004 Chris Danford, Glenn Maynard diff --git a/stepmania/src/ScreenGameplay.h b/stepmania/src/ScreenGameplay.h index 62dd02ef53..c207ed9f89 100644 --- a/stepmania/src/ScreenGameplay.h +++ b/stepmania/src/ScreenGameplay.h @@ -44,6 +44,12 @@ public: virtual bool UsesBackground() const { return false; } virtual ScreenType GetScreenType() const { return gameplay; } + // + // Lua + // + virtual void PushSelf( lua_State *L ); + Song *GetNextCourseSong() const; + protected: ThemeMetric PLAYER_TYPE; ThemeMetric GIVE_UP_TEXT;