From 49ac1c362dde0f122118624b633cb5e8d4106dc1 Mon Sep 17 00:00:00 2001 From: Jason Felds Date: Wed, 15 Jun 2011 16:56:01 -0400 Subject: [PATCH] Add many TimingData bindings. See changelog. --- Docs/Changelog_sm5.txt | 6 ++ Docs/Luadoc/Lua.xml | 7 +++ Docs/Luadoc/LuaDocumentation.xml | 21 +++++++ src/TimingData.cpp | 94 ++++++++++++++++++++++++++++++++ 4 files changed, 128 insertions(+) diff --git a/Docs/Changelog_sm5.txt b/Docs/Changelog_sm5.txt index 874e230a6e..a5370c4746 100644 --- a/Docs/Changelog_sm5.txt +++ b/Docs/Changelog_sm5.txt @@ -8,6 +8,12 @@ ________________________________________________________________________________ StepMania 5.0 Preview 2 | 20110??? -------------------------------------------------------------------------------- +2011/06/15 +---------- +* [TimingData] Added many lua bindings for the other timing segments. GetWarps, + GetCombos, GetTimeSignatures, GetTickcounts, GetFakes, GetScrolls, GetSpeeds. + This should cover all of them now. [Wolfman2000] + 2011/06/13 ---------- * [InputHandler_DirectInput] Fixed MouseWheel input not resetting. [AJ] diff --git a/Docs/Luadoc/Lua.xml b/Docs/Luadoc/Lua.xml index f88325bed1..521b2c5e68 100644 --- a/Docs/Luadoc/Lua.xml +++ b/Docs/Luadoc/Lua.xml @@ -1430,10 +1430,17 @@ + + + + + + + diff --git a/Docs/Luadoc/LuaDocumentation.xml b/Docs/Luadoc/LuaDocumentation.xml index 30e4ff0436..659e951332 100644 --- a/Docs/Luadoc/LuaDocumentation.xml +++ b/Docs/Luadoc/LuaDocumentation.xml @@ -3611,6 +3611,27 @@ Returns a table of the Labels and the times they happen as strings with the format "beat=label name." + + Returns a table of the Warps and the times they happen as strings with the format "beat=number of beats warped over." + + + Returns a table of the Combos and the times they happen as strings with the format "beat=combo value." + + + Returns a table of the Time Signatures and the times they happen as strings with the format "beat=beats per measure (numerator)=denominator." + + + Returns a table of the Tickcountss and the times they happen as strings with the format "beat=number of ticks per beat." + + + Returns a table of the Fakes and the times they happen as strings with the format "beat=number of beats to not judge." + + + Returns a table of the Scrolls and the times they happen as strings with the format "beat=scroll rate ratio." + + + Returns a table of the Speeds and the times they happen as strings with the format "beat=scroll rate ratio=length of time to fully activate=unit of activation (0 for beats, 1 for seconds)." + Returns true if the TimingData contains BPM changes. diff --git a/src/TimingData.cpp b/src/TimingData.cpp index 660b5e50c0..579d11c635 100644 --- a/src/TimingData.cpp +++ b/src/TimingData.cpp @@ -1670,6 +1670,93 @@ public: static int HasFakes( T* p, lua_State *L ) { lua_pushboolean(L, p->HasFakes()); return 1; } static int HasSpeedChanges( T* p, lua_State *L ) { lua_pushboolean(L, p->HasSpeedChanges()); return 1; } static int HasScrollChanges( T* p, lua_State *L ) { lua_pushboolean(L, p->HasScrollChanges()); return 1; } + static int GetWarps( T* p, lua_State *L ) + { + vector vWarps; + FOREACH_CONST( WarpSegment, p->m_WarpSegments, seg ) + { + const float length = seg->GetLength(); + const float beat = seg->GetBeat(); + vWarps.push_back( ssprintf("%f=%f", beat, length) ); + } + LuaHelpers::CreateTableFromArray(vWarps, L); + return 1; + } + static int GetFakes( T* p, lua_State *L ) + { + vector vFakes; + FOREACH_CONST( FakeSegment, p->m_FakeSegments, seg ) + { + const float length = seg->GetLength(); + const float beat = seg->GetBeat(); + vFakes.push_back( ssprintf("%f=%f", beat, length) ); + } + LuaHelpers::CreateTableFromArray(vFakes, L); + return 1; + } + static int GetScrolls( T* p, lua_State *L ) + { + vector vScrolls; + FOREACH_CONST( ScrollSegment, p->m_ScrollSegments, seg ) + { + const float ratio = seg->GetRatio(); + const float beat = seg->GetBeat(); + vScrolls.push_back( ssprintf("%f=%f", beat, ratio) ); + } + LuaHelpers::CreateTableFromArray(vScrolls, L); + return 1; + } + static int GetSpeeds( T* p, lua_State *L ) + { + vector vSpeeds; + FOREACH_CONST( SpeedSegment, p->m_SpeedSegments, seg ) + { + const float length = seg->GetLength(); + const float ratio = seg->GetRatio(); + const unsigned short unit = seg->GetUnit(); + const float beat = seg->GetBeat(); + vSpeeds.push_back( ssprintf("%f=%f=%f=%uh", beat, ratio, length, unit) ); + } + LuaHelpers::CreateTableFromArray(vSpeeds, L); + return 1; + } + static int GetTimeSignatures( T* p, lua_State *L ) + { + vector vTimes; + FOREACH_CONST( TimeSignatureSegment, p->m_vTimeSignatureSegments, seg ) + { + const int numerator = seg->GetNum(); + const int denominator = seg->GetDen(); + const float beat = seg->GetBeat(); + vTimes.push_back( ssprintf("%f=%d=%d", beat, numerator, denominator) ); + } + LuaHelpers::CreateTableFromArray(vTimes, L); + return 1; + } + static int GetCombos( T* p, lua_State *L ) + { + vector vCombos; + FOREACH_CONST( ComboSegment, p->m_ComboSegments, seg ) + { + const int combo = seg->GetCombo(); + const float beat = seg->GetBeat(); + vCombos.push_back( ssprintf("%f=%d", beat, combo) ); + } + LuaHelpers::CreateTableFromArray(vCombos, L); + return 1; + } + static int GetTickcounts( T* p, lua_State *L ) + { + vector vTicks; + FOREACH_CONST( TickcountSegment, p->m_TickcountSegments, seg ) + { + const int ticks = seg->GetTicks(); + const float beat = seg->GetBeat(); + vTicks.push_back( ssprintf("%f=%d", beat, ticks) ); + } + LuaHelpers::CreateTableFromArray(vTicks, L); + return 1; + } static int GetStops( T* p, lua_State *L ) { vector vStops; @@ -1763,6 +1850,13 @@ public: ADD_METHOD( GetStops ); ADD_METHOD( GetDelays ); ADD_METHOD( GetBPMs ); + ADD_METHOD( GetWarps ); + ADD_METHOD( GetFakes ); + ADD_METHOD( GetTimeSignatures ); + ADD_METHOD( GetTickcounts ); + ADD_METHOD( GetSpeeds ); + ADD_METHOD( GetScrolls ); + ADD_METHOD( GetCombos ); ADD_METHOD( GetLabels ); ADD_METHOD( GetBPMsAndTimes ); ADD_METHOD( GetActualBPM );