From 9bf28a134c6a9331f88642f09338689ee09acd30 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Sat, 15 Oct 2005 04:44:31 +0000 Subject: [PATCH] move to GameState --- stepmania/src/GameState.cpp | 37 +++++++++++++++++++++++++++++ stepmania/src/SongManager.cpp | 44 ----------------------------------- 2 files changed, 37 insertions(+), 44 deletions(-) diff --git a/stepmania/src/GameState.cpp b/stepmania/src/GameState.cpp index 80d650d3bc..823757a836 100644 --- a/stepmania/src/GameState.cpp +++ b/stepmania/src/GameState.cpp @@ -2048,6 +2048,42 @@ public: return 1; } + static int GetCurrentStepsCredits( T* p, lua_State *L ) + { + const Song* pSong = p->m_pCurSong; + if( pSong == NULL ) + return 0; + + // use a vector and not a set so that ordering is maintained + vector vpStepsToShow; + FOREACH_HumanPlayer( p ) + { + Steps* pSteps = GAMESTATE->m_pCurSteps[p]; + bool bAlreadyAdded = find( vpStepsToShow.begin(), vpStepsToShow.end(), pSteps ) != vpStepsToShow.end(); + if( !bAlreadyAdded ) + vpStepsToShow.push_back( pSteps ); + } + + CString s; + for( unsigned i=0; iGetDifficulty() ); + + // HACK: reset capitalization + sDifficulty.MakeLower(); + sDifficulty = Capitalize( sDifficulty ); + + if( i ) + s += "\n"; + s += sDifficulty + " steps: " + pSteps->GetDescription(); + } + + lua_pushstring( L, s ); + return 1; + } + + static void Register(lua_State *L) { ADD_METHOD( IsPlayerEnabled ); @@ -2109,6 +2145,7 @@ public: ADD_METHOD( GetEditCourseEntryIndex ); ADD_METHOD( GetEditLocalProfileID ); ADD_METHOD( GetEditLocalProfile ); + ADD_METHOD( GetCurrentStepsCredits ); Luna::Register( L ); diff --git a/stepmania/src/SongManager.cpp b/stepmania/src/SongManager.cpp index ab7caa002b..d74577327a 100644 --- a/stepmania/src/SongManager.cpp +++ b/stepmania/src/SongManager.cpp @@ -1429,50 +1429,6 @@ public: LUA_REGISTER_CLASS( SongManager ) // lua end - - - - -#include "LuaFunctions.h" - -CString GetCurrentStepsCredits() -{ - const Song* pSong = GAMESTATE->m_pCurSong; - if( pSong == NULL ) - return CString(); - - CString s; - - // use a vector and not a set so that ordering is maintained - vector vpStepsToShow; - FOREACH_PlayerNumber( p ) - { - if( !GAMESTATE->IsHumanPlayer(p) ) - continue; // skip - - Steps* pSteps = GAMESTATE->m_pCurSteps[p]; - bool bAlreadyAdded = find( vpStepsToShow.begin(), vpStepsToShow.end(), pSteps ) != vpStepsToShow.end(); - if( !bAlreadyAdded ) - vpStepsToShow.push_back( pSteps ); - } - for( unsigned i=0; iGetDifficulty() ); - - // HACK: reset capitalization - sDifficulty.MakeLower(); - sDifficulty = Capitalize( sDifficulty ); - - s += sDifficulty + " steps: " + pSteps->GetDescription(); - s += "\n"; - } - - // erase the last newline - s.erase( s.end()-1 ); - return s; -} - /* * (c) 2001-2004 Chris Danford, Glenn Maynard * All rights reserved.