Rename to rate_scaling_enable_ + Expose functions to lua

This commit is contained in:
teejusb
2025-03-02 10:34:28 -08:00
parent 9789ef9697
commit 368c257e95
5 changed files with 31 additions and 11 deletions
+11 -4
View File
@@ -170,7 +170,7 @@ Actor::Actor()
m_FakeParent = nullptr;
m_bFirstUpdate = true;
m_tween_uses_effect_delta = false;
tab_tilde_scaling_enabled_ = true;
rate_scaling_enabled_ = true;
}
Actor::~Actor()
@@ -876,7 +876,8 @@ void Actor::Update( float fDeltaTime )
// LOG->Trace( "Actor::Update( %f )", fDeltaTime );
float rate = GameLoop::GetUpdateRate();
if (rate != 1 && !tab_tilde_scaling_enabled_) {
if (rate != 1 && !rate_scaling_enabled_) {
// Prevent divide by 0 when tab + tilde are both pressed.
if (rate != 0) {
fDeltaTime *= (1 / rate);
}
@@ -2010,10 +2011,13 @@ public:
COMMON_RETURN_SELF;
}
static int SetRateScalingEnabled( T* p, lua_State *L ) { p->SetRateScalingEnabled(BArg(1)); COMMON_RETURN_SELF; }
static int GetRateScalingEnabled( T* p, lua_State *L ) { lua_pushboolean( L, p->GetRateScalingEnabled() ); return 1; }
LunaActor()
{
ADD_METHOD( name );
ADD_METHOD( sleep );
ADD_METHOD( name );
ADD_METHOD( sleep );
ADD_METHOD( linear );
ADD_METHOD( accelerate );
ADD_METHOD( decelerate );
@@ -2182,6 +2186,9 @@ public:
ADD_METHOD( GetNumWrapperStates );
ADD_METHOD( GetWrapperState );
ADD_METHOD( SetRateScalingEnabled );
ADD_METHOD( GetRateScalingEnabled );
ADD_METHOD( Draw );
}
};
+8 -6
View File
@@ -622,6 +622,10 @@ public:
virtual void SetUpdateRate( float ) {}
virtual float GetUpdateRate() { return 1.0f; }
// Use this to enable/disable scaling an actor's rate with tab or tilde.
void SetRateScalingEnabled(bool b) { rate_scaling_enabled_ = b; }
bool GetRateScalingEnabled() { return rate_scaling_enabled_; }
HiddenPtr<LuaClass> m_pLuaInstance;
protected:
@@ -714,9 +718,6 @@ protected:
* follow the effect clock. Actor::Update must be called first. */
float GetEffectDeltaTime() const { return m_fEffectDelta; }
// Use this to disable scaling an actor's rate with tab or tilde.
void DisableTabTildeScaling() { tab_tilde_scaling_enabled_ = false; }
// todo: account for SSC_FUTURES by having these be vectors too -aj
RageColor m_effectColor1;
RageColor m_effectColor2;
@@ -756,9 +757,10 @@ protected:
static std::vector<float> g_vfCurrentBGMBeatPlayerNoOffset;
private:
// Some actors shouldn't be scaled with tab or tilde. This bool does not
// guard against holding both at the same time (setting the rate to zero).
bool tab_tilde_scaling_enabled_;
// Some actors shouldn't be scaled by the engine i.e. using with tab for
// speeding up or tilde for slowing down.
// In the case both are pressed (setting rate to 0), this bool does nothing.
bool rate_scaling_enabled_;
// commands
std::map<RString, apActorCommands> m_mapNameToCommands;
+4 -1
View File
@@ -25,7 +25,10 @@ Banner::Banner()
{
m_bScrolling = false;
m_fPercentScrolling = 0;
Actor::DisableTabTildeScaling();
// By default, don't let banners scale their rate with tab/tilde.
// This helps with animated/video banners.
Actor::SetRateScalingEnabled(false);
}
// Ugly: if sIsBanner is false, we're actually loading something other than a banner.