Merge pull request #277 from kyzentun/WheelItemIsLoaded

WheelItemBase:IsLoaded
This commit is contained in:
Colby Klein
2014-08-31 18:16:10 -07:00
4 changed files with 43 additions and 11 deletions
+3 -2
View File
@@ -725,8 +725,8 @@
<Function name='IsGameEnabled'/>
<Function name='StepsTypeToLocalizedString'/>
<Function name='SetGame'/>
<Function name='GetEnabledGames'/>
<Function name='GetStylesForGame'/>
<Function name='GetEnabledGames'/>
<Function name='GetStylesForGame'/>
</Class>
<Class name='GameSoundManager'>
<Function name='DimMusic'/>
@@ -1770,6 +1770,7 @@
<Function name='GetColor'/>
<Function name='GetText'/>
<Function name='GetType'/>
<Function name='IsLoaded'/>
</Class>
<Class base='ActorFrame' name='WorkoutGraph'>
<Function name='SetFromCurrentWorkout'/>
+6 -2
View File
@@ -2188,10 +2188,10 @@ save yourself some time, copy this for undocumented things:
</Function>
<Function name='GetEnabledGames' return='{string}'>
Returns a table of all selectable games.
</Function>
</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>
<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 />
@@ -4995,6 +4995,10 @@ save yourself some time, copy this for undocumented things:
<Function name='GetType' return='WheelItemDataType' arguments=''>
Returns the type of this wheel item.
</Function>
<Function name='IsLoaded' return='bool' arguments=''>
Returns whether the wheel item has been loaded yet. If this function returns false, calling any other WheelItemBase function will result in an error. <br />
A specific case where this is known to happen is commands that trigger on CurrentSongChanged because the music wheel clears the current song before it finishes loading if the current song is longer than the number of stages remaining.
</Function>
</Class>
<Class name='WorkoutGraph'>
<Function name='SetFromCurrentWorkout' return='void' arguments=''>
+30 -4
View File
@@ -87,11 +87,36 @@ void WheelItemBase::DrawPrimitives()
class LunaWheelItemBase: public Luna<WheelItemBase>
{
public:
DEFINE_METHOD( GetColor, GetColor() )
DEFINE_METHOD( GetText, GetText() )
#define IS_LOADED_CHECK \
if(!p->IsLoaded()) \
{ \
luaL_error(L, "Wheel item is not loaded yet. Use WheelItem:IsLoaded() to check."); \
}
static int GetColor(T* p, lua_State *L)
{
IS_LOADED_CHECK;
LuaHelpers::Push(L, p->GetColor());
return 1;
}
static int GetText(T* p, lua_State *L)
{
IS_LOADED_CHECK;
LuaHelpers::Push(L, p->GetText());
return 1;
}
static int GetType( T* p, lua_State *L ) {
lua_pushnumber( L, p->GetType() );
static int GetType(T* p, lua_State *L)
{
IS_LOADED_CHECK;
lua_pushnumber(L, p->GetType());
return 1;
}
static int IsLoaded(T* p, lua_State *L)
{
lua_pushboolean(L, p->IsLoaded());
return 1;
}
@@ -100,6 +125,7 @@ public:
ADD_METHOD( GetColor );
ADD_METHOD( GetText );
ADD_METHOD( GetType );
ADD_METHOD( IsLoaded );
}
};
LUA_REGISTER_DERIVED_CLASS( WheelItemBase, ActorFrame )
+4 -3
View File
@@ -51,9 +51,10 @@ public:
RageColor m_colorLocked;
const RString GetText(){ return m_pData->m_sText; }
const RageColor GetColor(){ return m_pData->m_color; }
WheelItemDataType GetType(){ return m_pData->m_Type; }
const RString GetText(){ ASSERT(m_pData != NULL); return m_pData->m_sText; }
const RageColor GetColor(){ ASSERT(m_pData != NULL); return m_pData->m_color; }
WheelItemDataType GetType(){ ASSERT(m_pData != NULL); return m_pData->m_Type; }
bool IsLoaded(){ return m_pData != NULL; }
// Lua
void PushSelf( lua_State *L );