[GrooveRadar] Added SetFromValues(pn,{f1,f2,f3,f4,f5}) Lua binding.

This commit is contained in:
AJ Kelly
2012-06-05 13:00:37 -05:00
parent ebf1bf6028
commit c5fdfca65d
3 changed files with 43 additions and 0 deletions
+4
View File
@@ -8,6 +8,10 @@ ________________________________________________________________________________
StepMania 5.0 ???? ?? | 20120???
--------------------------------------------------------------------------------
2012/06/05
----------
* [GrooveRadar] Added SetFromValues(pn,{f1,f2,f3,f4,f5}) Lua binding. [AJ]
2012/06/02
----------
* [PrefsManager] Added StretchBackgrounds preference. [AJ]
+37
View File
@@ -78,6 +78,11 @@ void GrooveRadar::SetFromSteps( PlayerNumber pn, Steps* pSteps ) // NULL means n
m_GrooveRadarValueMap[pn].SetFromSteps( rv );
}
void GrooveRadar::SetFromValues( PlayerNumber pn, vector<float> vals )
{
m_GrooveRadarValueMap[pn].SetFromValues(vals);
}
GrooveRadar::GrooveRadarValueMap::GrooveRadarValueMap()
{
m_bValuesVisible = false;
@@ -111,6 +116,22 @@ void GrooveRadar::GrooveRadarValueMap::SetFromSteps( const RadarValues &rv )
m_PercentTowardNew = 0;
}
void GrooveRadar::GrooveRadarValueMap::SetFromValues( vector<float> vals )
{
m_bValuesVisible = true;
for( int c=0; c<NUM_SHOWN_RADAR_CATEGORIES; c++ )
{
const float fValueCurrent = m_fValuesOld[c] * (1-m_PercentTowardNew) + m_fValuesNew[c] * m_PercentTowardNew;
m_fValuesOld[c] = fValueCurrent;
m_fValuesNew[c] = vals[c];
}
if( !m_bValuesVisible ) // the values WERE invisible
m_PercentTowardNew = 1;
else
m_PercentTowardNew = 0;
}
void GrooveRadar::GrooveRadarValueMap::Update( float fDeltaTime )
{
ActorFrame::Update( fDeltaTime );
@@ -205,11 +226,27 @@ public:
}
return 0;
}
static int SetFromValues( T* p, lua_State *L )
{
PlayerNumber pn = Enum::Check<PlayerNumber>(L, 1);
if( !lua_istable(L, 2) || lua_isnil(L,2) )
{
p->SetEmpty( pn );
}
else
{
vector<float> vals;
LuaHelpers::ReadArrayFromTable( vals, L );
p->SetFromValues(pn, vals);
}
return 0;
}
static int SetEmpty( T* p, lua_State *L ) { p->SetEmpty( Enum::Check<PlayerNumber>(L, 1) ); return 0; }
LunaGrooveRadar()
{
ADD_METHOD( SetFromRadarValues );
ADD_METHOD( SetFromValues );
ADD_METHOD( SetEmpty );
}
};
+2
View File
@@ -26,6 +26,7 @@ public:
* @param pn the Player to give a GrooveRadar.
* @param pSteps the Steps to use to make the radar. If NULL, there are no Steps. */
void SetFromSteps( PlayerNumber pn, Steps* pSteps );
void SetFromValues( PlayerNumber pn, vector<float> vals );
// Lua
void PushSelf( lua_State *L );
@@ -45,6 +46,7 @@ protected:
void SetEmpty();
void SetFromSteps( const RadarValues &rv );
void SetFromValues( vector<float> vals );
void SetRadius( float f ) { m_size.x = f; m_size.y = f; }