From 818ea049c254216612eeb045dc9d926dd8bdf351 Mon Sep 17 00:00:00 2001 From: AJ Kelly Date: Fri, 19 Aug 2011 14:36:25 -0500 Subject: [PATCH] [Steps] Add PredictMeter() and GetDisplayBPMType() Lua bindings. --- Docs/Changelog_sm5.txt | 4 +++ src/Steps.cpp | 20 +++++++------ src/Steps.h | 68 ++++++++++++------------------------------ 3 files changed, 34 insertions(+), 58 deletions(-) diff --git a/Docs/Changelog_sm5.txt b/Docs/Changelog_sm5.txt index 8fae8f6502..2558d817df 100644 --- a/Docs/Changelog_sm5.txt +++ b/Docs/Changelog_sm5.txt @@ -8,6 +8,10 @@ ________________________________________________________________________________ StepMania 5.0 Preview 3 | 2011081? -------------------------------------------------------------------------------- +2011/08/19 +---------- +* [Steps] Add PredictMeter() and GetDisplayBPMType() Lua bindings. [AJ] + 2011/08/18 ---------- * [RageInput] Added "No input devices were loaded." string to languages. [AJ] diff --git a/src/Steps.cpp b/src/Steps.cpp index a1c3999701..c7c888c30a 100644 --- a/src/Steps.cpp +++ b/src/Steps.cpp @@ -41,8 +41,8 @@ static const char *DisplayBPMNames[] = "Specified", "Random", }; - XToString( DisplayBPM ); +LuaXType( DisplayBPM ); Steps::Steps(): m_StepsType(StepsType_Invalid), parent(NULL), m_pNoteData(new NoteData), m_bNoteDataIsFilled(false), @@ -548,14 +548,11 @@ public: lua_pushboolean(L, p->HasSignificantTimingChanges()); return 1; } - static int HasAttacks( T* p, lua_State *L ) { lua_pushboolean(L, p->HasAttacks()); return 1; } - - static int GetRadarValues( T* p, lua_State *L ) { PlayerNumber pn = Enum::Check(L, 1); @@ -563,16 +560,14 @@ public: rv.PushSelf(L); return 1; } - static int GetTimingData( T* p, lua_State *L ) { p->m_Timing.PushSelf(L); return 1; } - static int GetHash( T* p, lua_State *L ) { lua_pushnumber( L, p->GetHash() ); return 1; } - // untested + /* static int GetSMNoteData( T* p, lua_State *L ) { RString out; @@ -580,13 +575,12 @@ public: lua_pushstring( L, out ); return 1; } - + */ static int GetChartName(T *p, lua_State *L) { lua_pushstring(L, p->GetChartName()); return 1; } - static int GetDisplayBpms( T* p, lua_State *L ) { DisplayBpms temp; @@ -618,6 +612,12 @@ public: lua_pushboolean( L, p->GetDisplayBPM() == DISPLAY_BPM_RANDOM ); return 1; } + DEFINE_METHOD( PredictMeter, PredictMeter() ) + static int GetDisplayBPMType( T* p, lua_State *L ) + { + LuaHelpers::Push( L, p->GetDisplayBPM() ); + return 1; + } LunaSteps() { @@ -643,6 +643,8 @@ public: ADD_METHOD( IsDisplayBpmSecret ); ADD_METHOD( IsDisplayBpmConstant ); ADD_METHOD( IsDisplayBpmRandom ); + ADD_METHOD( PredictMeter ); + ADD_METHOD( GetDisplayBPMType ); } }; diff --git a/src/Steps.h b/src/Steps.h index 05237a6b42..24ea973410 100644 --- a/src/Steps.h +++ b/src/Steps.h @@ -28,8 +28,11 @@ enum DisplayBPM DISPLAY_BPM_ACTUAL, /**< Display the song's actual BPM. */ DISPLAY_BPM_SPECIFIED, /**< Display a specified value or values. */ DISPLAY_BPM_RANDOM, /**< Display a random selection of BPMs. */ - NUM_DisplayBPM + NUM_DisplayBPM, + DisplayBPM_Invalid }; +const RString& DisplayBPMToString( DisplayBPM dbpm ); +LuaDeclareType( DisplayBPM ); /** * @brief Holds note information for a Song. @@ -107,17 +110,9 @@ public: AttackArray m_Attacks; /** @brief The stringified list of attacks. */ vector m_sAttackString; - - RString GetChartName() const - { - return parent ? Real()->GetChartName() : this->chartName; - } - - void SetChartName(const RString name) - { - this->chartName = name; - } - + + RString GetChartName() const { return parent ? Real()->GetChartName() : this->chartName; } + void SetChartName(const RString name) { this->chartName = name; } void SetFilename( RString fn ) { m_sFilename = fn; } RString GetFilename() const { return m_sFilename; } void SetSavedToDisk( bool b ) { DeAutogen(); m_bSavedToDisk = b; } @@ -140,12 +135,12 @@ public: void SetNoteData( const NoteData& noteDataNew ); void SetSMNoteData( const RString ¬es_comp ); void GetSMNoteData( RString ¬es_comp_out ) const; - + /** * @brief Retrieve the NoteData from the original source. * @return true if successful, false for failure. */ bool GetNoteDataFromSimfile(); - + /** * @brief Determine if we are missing any note data. * @@ -161,12 +156,12 @@ public: * * This is required to allow Split Timing. */ TimingData m_Timing; - + /** * @brief Determine if the Steps have any major timing changes during gameplay. * @return true if it does, or false otherwise. */ bool HasSignificantTimingChanges() const; - + /** * @brief Determine if the Steps have any attacks. * @return true if it does, or false otherwise. */ @@ -178,40 +173,18 @@ public: StepsType m_StepsType; CachedObject m_CachedObject; - + /** * @brief Determine if the Steps use Split Timing by comparing the Song it's in. * @return true if the Step and Song use different timings, false otherwise. */ bool UsesSplitTiming() const; - - void SetDisplayBPM(const DisplayBPM type) - { - this->displayBPMType = type; - } - - DisplayBPM GetDisplayBPM() const - { - return this->displayBPMType; - } - - void SetMinBPM(const float f) - { - this->specifiedBPMMin = f; - } - float GetMinBPM() const - { - return this->specifiedBPMMin; - } - - void SetMaxBPM(const float f) - { - this->specifiedBPMMax = f; - } - float GetMaxBPM() const - { - return this->specifiedBPMMax; - } - + + void SetDisplayBPM(const DisplayBPM type) { this->displayBPMType = type; } + DisplayBPM GetDisplayBPM() const { return this->displayBPMType; } + void SetMinBPM(const float f) { this->specifiedBPMMin = f; } + float GetMinBPM() const { return this->specifiedBPMMin; } + void SetMaxBPM(const float f) { this->specifiedBPMMax = f; } + float GetMaxBPM() const { return this->specifiedBPMMax; } void GetDisplayBpms( DisplayBpms &addTo) const; RString GetAttackString() const @@ -261,17 +234,14 @@ private: bool m_bAreCachedRadarValuesJustLoaded; /** @brief The name of the person who created the Steps. */ RString m_sCredit; - /** @brief The name of the chart. */ RString chartName; - /** @brief How is the BPM displayed for this chart? */ DisplayBPM displayBPMType; /** @brief What is the minimum specified BPM? */ float specifiedBPMMin; /** * @brief What is the maximum specified BPM? - * * If this is a range, then min should not be equal to max. */ float specifiedBPMMax; };