added GetStylesForGame method

This commit is contained in:
sigatrev
2014-08-02 18:09:52 -05:00
parent f0d6bce62a
commit 3478bc7650
3 changed files with 24 additions and 1 deletions
+1
View File
@@ -726,6 +726,7 @@
<Function name='StepsTypeToLocalizedString'/>
<Function name='SetGame'/>
<Function name='GetEnabledGames'/>
<Function name='GetStylesForGame'/>
</Class>
<Class name='GameSoundManager'>
<Function name='DimMusic'/>
+3
View File
@@ -2189,6 +2189,9 @@ save yourself some time, copy this for undocumented things:
<Function name='GetEnabledGames' return='{string}'>
Returns a table of all selectable games.
</Function>
<Function name='GetStylesForGame' return='{style}' arguments='string game'>
Returns a table of all the styles for the that exist for <code>game</code>.
</Function>
<Function name='SetGame' return='void' arguments='string Game, string Theme' >
Sets the current game to <code>Game</code>. The second argument is optional, and if provided will determine which theme is loaded when the game changes. If the second argument is not provided, the default theme from the preferences for the new game type will be loaded.<br />
If only the game changes, the screen specified by the Common::AfterGameChangeScreen metric will be loaded.<br />
+20 -1
View File
@@ -3160,10 +3160,28 @@ public:
return 1;
}
static int GetStylesForGame( T* p, lua_State *L )
{
RString game_name= SArg(1);
const Game *pGame = p->StringToGame(game_name);
if(!pGame)
{
luaL_error(L, "GetStylesForGame: Invalid Game: '%s'", game_name.c_str());
}
vector<Style*> aStyles;
for( int s=0; pGame->m_apStyles[s]; ++s )
{
Style *pStyle = const_cast<Style *>( pGame->m_apStyles[s] );
aStyles.push_back( pStyle );
}
LuaHelpers::CreateTableFromArray<Style*>( aStyles, L );
return 1;
}
static int GetEnabledGames( T* p, lua_State *L )
{
vector<const Game*> aGames;
GAMEMAN->GetEnabledGames( aGames );
p->GetEnabledGames( aGames );
vector<RString> vsGames;
FOREACH( const Game*, aGames, g )
@@ -3201,6 +3219,7 @@ public:
ADD_METHOD( StepsTypeToLocalizedString );
ADD_METHOD( GetFirstStepsTypeForGame );
ADD_METHOD( IsGameEnabled );
ADD_METHOD( GetStylesForGame );
ADD_METHOD( GetEnabledGames );
ADD_METHOD( SetGame );
};