diff --git a/Docs/Luadoc/Lua.xml b/Docs/Luadoc/Lua.xml
index 6009181605..6b2d77b790 100644
--- a/Docs/Luadoc/Lua.xml
+++ b/Docs/Luadoc/Lua.xml
@@ -723,6 +723,8 @@
+
+
diff --git a/Docs/Luadoc/LuaDocumentation.xml b/Docs/Luadoc/LuaDocumentation.xml
index cad9107811..5d4ab8bf66 100644
--- a/Docs/Luadoc/LuaDocumentation.xml
+++ b/Docs/Luadoc/LuaDocumentation.xml
@@ -2177,6 +2177,12 @@ save yourself some time, copy this for undocumented things:
Return the localized string representation of st.
+
+ Returns a table of all selectable games.
+
+
+ Sets the current game to Game. The second argument is optional, and if provided will determine which theme is loaded when the game changes. If Stepmania was run with a commandline argument setting the theme, that will override the second argument of this function.
+
diff --git a/src/GameManager.cpp b/src/GameManager.cpp
index a6c9656c4f..6999da2a21 100644
--- a/src/GameManager.cpp
+++ b/src/GameManager.cpp
@@ -1,4 +1,6 @@
#include "global.h"
+#include "Stepmania.h"
+#include "arch/Dialog/Dialog.h"
#include "GameManager.h"
#include "GameConstantsAndTypes.h"
#include "GameInput.h" // for GameButton constants
@@ -3157,11 +3159,49 @@ public:
return 1;
}
+ static int GetEnabledGames( T* p, lua_State *L )
+ {
+ vector aGames;
+ GAMEMAN->GetEnabledGames( aGames );
+
+ vector vsGames;
+ FOREACH( const Game*, aGames, g )
+ {
+ RString sGameName = (*g)->m_szName;
+ vsGames.push_back( sGameName );
+ }
+ LuaHelpers::CreateTableFromArray( vsGames, L );
+ return 1;
+ }
+
+ static int SetGame( T* p, lua_State *L )
+ {
+ const Game *pGame = p->StringToGame(SArg(1));
+ RString sTheme;
+ if( lua_gettop(L) >= 2 && !lua_isnil(L, 2) )
+ {
+ sTheme = SArg(2);
+ }
+ if( pGame )
+ {
+ StepMania::ChangeCurrentGame( pGame, sTheme );
+ THEME->ReloadMetrics();
+ }
+ else
+ {
+ LOG->Warn( "SetGame: Invalid Game, %s", pGame->m_szName );
+ Dialog::OK( "SetGame: Invalid Game, %s", pGame->m_szName );
+ }
+ return 0;
+ }
+
LunaGameManager()
{
ADD_METHOD( StepsTypeToLocalizedString );
ADD_METHOD( GetFirstStepsTypeForGame );
ADD_METHOD( IsGameEnabled );
+ ADD_METHOD( GetEnabledGames );
+ ADD_METHOD( SetGame );
};
};
diff --git a/src/StepMania.cpp b/src/StepMania.cpp
index e6de401827..be90ff990e 100644
--- a/src/StepMania.cpp
+++ b/src/StepMania.cpp
@@ -808,7 +808,7 @@ static void SwitchToLastPlayedGame()
StepMania::ChangeCurrentGame( pGame );
}
-void StepMania::ChangeCurrentGame( const Game* g )
+void StepMania::ChangeCurrentGame( const Game* g, RString Theme )
{
ASSERT( g != NULL );
ASSERT( GAMESTATE != NULL );
@@ -825,7 +825,9 @@ void StepMania::ChangeCurrentGame( const Game* g )
sAnnouncer = GAMESTATE->GetCurrentGame()->m_szName;
if( sTheme.empty() )
sTheme = GAMESTATE->GetCurrentGame()->m_szName;
-
+ if( Theme.size() )
+ sTheme = Theme;
+
// process theme and language command line arguments;
// these change the preferences in order for transparent loading -aj
RString argTheme;
diff --git a/src/StepMania.h b/src/StepMania.h
index 00da5d0048..82baed076b 100644
--- a/src/StepMania.h
+++ b/src/StepMania.h
@@ -15,7 +15,7 @@ namespace StepMania
void ResetGame();
RString GetInitialScreen();
RString GetSelectMusicScreen();
- void ChangeCurrentGame( const Game* g );
+ void ChangeCurrentGame( const Game* g, RString Theme = "" );
// If successful, return filename of screenshot in sDir, else return ""
RString SaveScreenshot( RString Dir, bool SaveCompressed, bool MakeSignature, RString NamePrefix, RString NameSuffix );