diff --git a/stepmania/src/Actor.cpp b/stepmania/src/Actor.cpp index 27c638ad5b..469de4bdcf 100644 --- a/stepmania/src/Actor.cpp +++ b/stepmania/src/Actor.cpp @@ -15,6 +15,7 @@ #include "ThemeManager.h" #include "LuaReference.h" #include "MessageManager.h" +#include "LightsManager.h" // for NUM_CABINET_LIGHTS // lua start @@ -171,6 +172,19 @@ void Actor::BeginDraw() // set the world matrix and calculate actor properties { m_pTempState = &m_current; } + else if( m_Effect == effect_lua ) + { + /* Allow a Lua function to set the frame's draw state. This may be expensive + * and has not been well-benchmarked yet; use wisely. This allows arbitrary + * effects, instead of the mess of parameters below. (In fact, all this does + * is run a command, but to avoid calling RunCommand() all the time, and due + * to the fact that this is the only place where the TempState is meaningful, + * we treat this as an effect.) */ + m_pTempState = &m_tempState; + m_tempState = m_current; + + PlayCommand( m_sEffectCommand ); + } else { m_pTempState = &m_tempState; @@ -348,6 +362,7 @@ void Actor::SetTextureRenderStates() void Actor::EndDraw() { DISPLAY->PopMatrix(); + m_pTempState = NULL; } void Actor::UpdateTweening( float fDeltaTime ) @@ -621,6 +636,12 @@ void Actor::StretchTo( const RectF &r ) // effect "macros" +void Actor::SetEffectLua( const CString &sCommand ) +{ + m_Effect = effect_lua; + m_sEffectCommand = sCommand; +} + void Actor::SetEffectDiffuseBlink( float fEffectPeriodSeconds, RageColor c1, RageColor c2 ) { if( m_Effect != diffuse_blink ) diff --git a/stepmania/src/Actor.h b/stepmania/src/Actor.h index ed6ffcfd61..72eb3cb628 100644 --- a/stepmania/src/Actor.h +++ b/stepmania/src/Actor.h @@ -41,7 +41,7 @@ public: TWEEN_BOUNCE_END, TWEEN_SPRING, }; - enum Effect { no_effect, + enum Effect { no_effect, effect_lua, diffuse_blink, diffuse_shift, diffuse_ramp, glow_blink, glow_shift, rainbow, @@ -205,7 +205,9 @@ public: virtual float GetTweenTimeLeft() const; // Amount of time until all tweens have stopped TweenState& DestTweenState() // where Actor will end when its tween finish { - if( m_Tweens.empty() ) // not tweening + if( m_pTempState != NULL ) // effect_lua running + return *m_pTempState; + else if( m_Tweens.empty() ) // not tweening return m_current; else return LatestTween(); @@ -249,6 +251,7 @@ public: void SetEffectMagnitude( RageVector3 vec ) { m_vEffectMagnitude = vec; } + void SetEffectLua( const CString &sCommand ); void SetEffectDiffuseBlink( float fEffectPeriodSeconds = 1.0f, RageColor c1 = RageColor(0.5f,0.5f,0.5f,1), @@ -402,6 +405,7 @@ protected: // Stuff for effects // Effect m_Effect; + CString m_sEffectCommand; // effect_lua float m_fSecsIntoEffect, m_fEffectDelta; float m_fEffectPeriodSeconds; float m_fEffectDelay; @@ -507,6 +511,7 @@ public: static int shadowlength( T* p, lua_State *L ) { p->SetShadowLength(FArg(1)); return 0; } static int horizalign( T* p, lua_State *L ) { p->SetHorizAlignString(SArg(1)); return 0; } static int vertalign( T* p, lua_State *L ) { p->SetVertAlignString(SArg(1)); return 0; } + static int luaeffect( T* p, lua_State *L ) { p->SetEffectLua(SArg(1)); return 0; } static int diffuseblink( T* p, lua_State *L ) { p->SetEffectDiffuseBlink(); return 0; } static int diffuseshift( T* p, lua_State *L ) { p->SetEffectDiffuseShift(); return 0; } static int diffuseramp( T* p, lua_State *L ) { p->SetEffectDiffuseRamp(); return 0; } @@ -612,6 +617,7 @@ public: ADD_METHOD( shadowlength ) ADD_METHOD( horizalign ) ADD_METHOD( vertalign ) + ADD_METHOD( luaeffect ) ADD_METHOD( diffuseblink ) ADD_METHOD( diffuseshift ) ADD_METHOD( diffuseramp )