From 0eb33aa8060d58c52a23caea35b1007d187c0c90 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Sat, 25 Jun 2005 05:03:35 +0000 Subject: [PATCH] instead of a hard-coded special case, bind the screen to Lua and move the special case there. this reduces cross-dependencies between screens, which should be kept to a minimum --- stepmania/src/ScreenPlayerOptions.cpp | 52 ++++++++++----------------- stepmania/src/ScreenPlayerOptions.h | 10 ++++-- 2 files changed, 26 insertions(+), 36 deletions(-) diff --git a/stepmania/src/ScreenPlayerOptions.cpp b/stepmania/src/ScreenPlayerOptions.cpp index 3fc00637e6..f23e2ab4f8 100644 --- a/stepmania/src/ScreenPlayerOptions.cpp +++ b/stepmania/src/ScreenPlayerOptions.cpp @@ -14,9 +14,6 @@ #include "PlayerState.h" #include "Foreach.h" -#define PREV_SCREEN THEME->GetMetric ("ScreenPlayerOptions","PrevScreen") -#define NEXT_SCREEN THEME->GetMetric ("ScreenPlayerOptions","NextScreen") - REGISTER_SCREEN_CLASS( ScreenPlayerOptions ); ScreenPlayerOptions::ScreenPlayerOptions( CString sClassName ) : ScreenOptionsMaster( sClassName ) @@ -73,36 +70,6 @@ void ScreenPlayerOptions::Init() } } - -void ScreenPlayerOptions::GoToPrevScreen() -{ - if( SCREENMAN->IsStackedScreen(this) ) - { - SCREENMAN->PopTopScreen( SM_BackFromPlayerOptions ); - } - else - { - SCREENMAN->DeletePreparedScreens(); - SCREENMAN->SetNewScreen( PREV_SCREEN ); - } -} - -void ScreenPlayerOptions::GoToNextScreen() -{ - if( SCREENMAN->IsStackedScreen(this) ) - { - SCREENMAN->PopTopScreen( SM_BackFromPlayerOptions ); - } - else - { - if( m_bGoToOptions ) - SCREENMAN->SetNewScreen( NEXT_SCREEN ); - else - SCREENMAN->SetNewScreen( ScreenSongOptions::GetNextScreen() ); - } -} - - void ScreenPlayerOptions::Update( float fDelta ) { ScreenOptionsMaster::Update( fDelta ); @@ -227,6 +194,25 @@ void ScreenPlayerOptions::UpdateDisqualified( int row, PlayerNumber pn ) GAMESTATE->m_pPlayerState[pn]->m_PlayerOptions = poOrig; } +// lua start +#include "LuaBinding.h" + +class LunaScreenPlayerOptions: public Luna +{ +public: + LunaScreenPlayerOptions() { LUA->Register( Register ); } + + static int GetGoToOptions( T* p, lua_State *L ) { lua_pushboolean( L, p->GetGoToOptions() ); return 1; } + static void Register( Lua *L ) + { + ADD_METHOD( GetGoToOptions ) + Luna::Register( L ); + } +}; + +LUA_REGISTER_DERIVED_CLASS( ScreenPlayerOptions, ActorFrame ) +// lua end + /* * (c) 2001-2004 Chris Danford * All rights reserved. diff --git a/stepmania/src/ScreenPlayerOptions.h b/stepmania/src/ScreenPlayerOptions.h index 957c991efb..e71599f4fd 100644 --- a/stepmania/src/ScreenPlayerOptions.h +++ b/stepmania/src/ScreenPlayerOptions.h @@ -2,6 +2,7 @@ #define SCREENPLAYEROPTIONS_H #include "ScreenOptionsMaster.h" +struct lua_State; AutoScreenMessage( SM_BackFromPlayerOptions ) @@ -15,11 +16,14 @@ public: virtual void DrawPrimitives(); virtual void Input( const DeviceInput& DeviceI, const InputEventType type, const GameInput &GameI, const MenuInput &MenuI, const StyleInput &StyleI ); virtual void HandleScreenMessage( const ScreenMessage SM ); + bool GetGoToOptions() const { return m_bGoToOptions; } + + // + // Lua + // + virtual void PushSelf( lua_State *L ); private: - void GoToNextScreen(); - void GoToPrevScreen(); - vector m_bRowCausesDisqualified[NUM_PLAYERS]; void UpdateDisqualified( int row, PlayerNumber pn );