From 2f6b0614e9c5fa95b87fdd4d03e8c6a1563ff719 Mon Sep 17 00:00:00 2001 From: Jason Felds Date: Thu, 3 Mar 2011 01:30:57 -0500 Subject: [PATCH] combos branch: implement some header functions. --- src/TimingData.cpp | 90 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) diff --git a/src/TimingData.cpp b/src/TimingData.cpp index 7fb9f60786..7640cc94ad 100644 --- a/src/TimingData.cpp +++ b/src/TimingData.cpp @@ -52,6 +52,11 @@ void TimingData::AddTickcountSegment( const TickcountSegment &seg ) m_TickcountSegments.insert( upper_bound(m_TickcountSegments.begin(), m_TickcountSegments.end(), seg), seg ); } +void TimingData::AddComboSegment( const ComboSegment &seg ) +{ + m_ComboSegments.insert( upper_bound(m_ComboSegments.begin(), m_ComboSegments.end(), seg), seg ); +} + /* Change an existing BPM segment, merge identical segments together or insert a new one. */ void TimingData::SetBPMAtRow( int iNoteRow, float fBPM ) { @@ -176,6 +181,27 @@ void TimingData::SetTickcountAtRow( int iRow, int iTicks ) } } +void TimingData::SetComboAtRow( int iRow, int iCombo ) +{ + unsigned i; + for( i=0; i= iRow ) + break; + + if( i == m_ComboSegments.size() || m_ComboSegments[i].m_iStartRow != iRow ) + { + if( i == 0 || m_ComboSegments[i-1].m_iCombo != iCombo ) + AddComboSegment( ComboSegment(iRow, iCombo ) ); + } + else + { + if( i > 0 && m_ComboSegments[i-1].m_iCombo == iCombo ) + m_ComboSegments.erase( m_ComboSegments.begin()+i, m_ComboSegments.begin()+i+1 ); + else + m_ComboSegments[i].m_iCombo = iCombo; + } +} + float TimingData::GetStopAtRow( int iNoteRow, bool bDelay ) const { for( unsigned i=0; i iRow ) + break; + } + return (int)i; +} + BPMSegment& TimingData::GetBPMSegmentAtRow( int iNoteRow ) { static BPMSegment empty; @@ -319,6 +369,15 @@ BPMSegment& TimingData::GetBPMSegmentAtRow( int iNoteRow ) return m_BPMSegments[i]; } +ComboSegment& TimingData::GetComboSegmentAtRow( int iRow ) +{ + unsigned i; + for( i=0; i iRow ) + break; + return m_ComboSegments[i]; +} + StopSegment& TimingData::GetStopSegmentAtRow( int iNoteRow, bool bDelay ) { static StopSegment empty; @@ -487,16 +546,19 @@ void TimingData::GetBeatAndBPSFromElapsedTimeNoOffset( float fElapsedTime, float vector vWS = m_WarpSegments; vector vTSS = m_vTimeSignatureSegments; vector vTS = m_TickcountSegments; + vector vCS = m_ComboSegments; sort( vBPMS.begin(), vBPMS.end() ); sort( vSS.begin(), vSS.end() ); sort( vWS.begin(), vWS.end() ); sort( vTSS.begin(), vTSS.end() ); sort( vTS.begin(), vTS.end() ); + sort( vCS.begin(), vCS.end() ); ASSERT_M( vBPMS == m_BPMSegments, "The BPM segments were not sorted!" ); ASSERT_M( vSS == m_StopSegments, "The Stop segments were not sorted!" ); ASSERT_M( vWS == m_WarpSegments, "The Warp segments were not sorted!" ); ASSERT_M( vTSS == m_vTimeSignatureSegments, "The Time Signature segments were not sorted!" ); ASSERT_M( vTS == m_TickcountSegments, "The Tickcount segments were not sorted!" ); + ASSERT_M( vCS == m_ComboSegments, "The Combo segments were not sorted!" ); FAIL_M( ssprintf("Failed to find the appropriate segment for elapsed time %f.", fTime) ); } @@ -619,6 +681,14 @@ void TimingData::InsertRows( int iStartRow, int iRowsToAdd ) continue; tick.m_iStartRow += iRowsToAdd; } + + for( unsigned i = 0; i < m_ComboSegments.size(); i++ ) + { + ComboSegment &comb = m_ComboSegments[i]; + if( comb.m_iStartRow < iStartRow ) + continue; + comb.m_iStartRow += iRowsToAdd; + } if( iStartRow == 0 ) { @@ -720,6 +790,26 @@ void TimingData::DeleteRows( int iStartRow, int iRowsToDelete ) // After deleted region: tick.m_iStartRow -= iRowsToDelete; } + + for( unsigned i = 0; i < m_ComboSegments.size(); i++ ) + { + ComboSegment &comb = m_ComboSegments[i]; + + // Before deleted region: + if( comb.m_iStartRow < iStartRow ) + continue; + + // Inside deleted region: + if( comb.m_iStartRow < iStartRow+iRowsToDelete ) + { + m_ComboSegments.erase( m_ComboSegments.begin()+i, m_ComboSegments.begin()+i+1 ); + --i; + continue; + } + + // After deleted region: + comb.m_iStartRow -= iRowsToDelete; + } this->SetBPMAtRow( iStartRow, fNewBPM ); }