From eaa058c521c2f442dee73de4423e55ebe3dca6af Mon Sep 17 00:00:00 2001 From: Jason Felds Date: Thu, 7 Jul 2011 15:47:29 -0400 Subject: [PATCH] More copying from Song to Steps. This includes the lua, but we're not documenting this yet. Want to be sure this works without it blowing up. ...I think some work on the editor will be needed here. --- src/Steps.cpp | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++- src/Steps.h | 2 ++ 2 files changed, 56 insertions(+), 1 deletion(-) diff --git a/src/Steps.cpp b/src/Steps.cpp index d3b42b5bcb..3ff6c97499 100644 --- a/src/Steps.cpp +++ b/src/Steps.cpp @@ -34,12 +34,29 @@ Steps::Steps(): m_StepsType(StepsType_Invalid), m_sDescription(""), m_sChartStyle(""), m_Difficulty(Difficulty_Invalid), m_iMeter(0), m_bAreCachedRadarValuesJustLoaded(false), - m_sCredit("") {} + m_sCredit(""), displayBPMType(DISPLAY_BPM_ACTUAL), + specifiedBPMMin(0), specifiedBPMMax(0) {} Steps::~Steps() { } +void Steps::GetDisplayBpms( DisplayBpms &AddTo ) const +{ + if( this->GetDisplayBPM() == DISPLAY_BPM_SPECIFIED ) + { + AddTo.Add( this->GetMinBPM() ); + AddTo.Add( this->GetMaxBPM() ); + } + else + { + float fMinBPM, fMaxBPM; + this->m_Timing.GetActualBPM( fMinBPM, fMaxBPM ); + AddTo.Add( fMinBPM ); + AddTo.Add( fMaxBPM ); + } +} + bool Steps::HasAttacks() const { return !this->m_Attacks.empty(); @@ -513,6 +530,38 @@ public: lua_pushstring(L, p->GetChartName()); return 1; } + + static int GetDisplayBpms( T* p, lua_State *L ) + { + DisplayBpms temp; + p->GetDisplayBpms(temp); + float fMin = temp.GetMin(); + float fMax = temp.GetMax(); + vector fBPMs; + fBPMs.push_back( fMin ); + fBPMs.push_back( fMax ); + LuaHelpers::CreateTableFromArray(fBPMs, L); + return 1; + } + static int IsDisplayBpmSecret( T* p, lua_State *L ) + { + DisplayBpms temp; + p->GetDisplayBpms(temp); + lua_pushboolean( L, temp.IsSecret() ); + return 1; + } + static int IsDisplayBpmConstant( T* p, lua_State *L ) + { + DisplayBpms temp; + p->GetDisplayBpms(temp); + lua_pushboolean( L, temp.BpmIsConstant() ); + return 1; + } + static int IsDisplayBpmRandom( T* p, lua_State *L ) + { + lua_pushboolean( L, p->GetDisplayBPM() == DISPLAY_BPM_RANDOM ); + return 1; + } LunaSteps() { @@ -534,6 +583,10 @@ public: ADD_METHOD( IsAutogen ); ADD_METHOD( IsAPlayerEdit ); ADD_METHOD( UsesSplitTiming ); + ADD_METHOD( GetDisplayBpms ); + ADD_METHOD( IsDisplayBpmSecret ); + ADD_METHOD( IsDisplayBpmConstant ); + ADD_METHOD( IsDisplayBpmRandom ); } }; diff --git a/src/Steps.h b/src/Steps.h index 3b2c7ce813..a6a4aded2e 100644 --- a/src/Steps.h +++ b/src/Steps.h @@ -197,6 +197,8 @@ public: { return this->specifiedBPMMax; } + + void GetDisplayBpms( DisplayBpms &addTo) const; private: inline const Steps *Real() const { return parent ? parent : this; }