[default -> scroll] merge

This commit is contained in:
Thai Pangsakulyanont
2011-05-25 22:56:26 +07:00
9 changed files with 83 additions and 54 deletions
+45
View File
@@ -553,6 +553,7 @@ bool TimingData::IsWarpAtRow( int iNoteRow ) const
const WarpSegment& s = m_WarpSegments[i];
if( s.m_iStartRow <= iNoteRow && iNoteRow < (s.m_iStartRow + BeatToNoteRow(s.m_fLengthBeats) ) )
{
// Allow stops inside warps to allow things like stop, warp, stop, warp, stop, and so on.
if( m_StopSegments.empty() )
{
return true;
@@ -1408,6 +1409,50 @@ void TimingData::DeleteRows( int iStartRow, int iRowsToDelete )
this->SetBPMAtRow( iStartRow, fNewBPM );
}
float TimingData::GetDisplayedSpeedPercent( float fSongBeat, float fMusicSeconds ) const
{
if( m_SpeedSegments.size() == 0 )
return 1.0;
const int index = GetSpeedSegmentIndexAtBeat( fSongBeat );
const SpeedSegment &seg = m_SpeedSegments[index];
float fStartBeat = NoteRowToBeat(seg.m_iStartRow);
float fStartTime = GetElapsedTimeFromBeat( fStartBeat ) - GetDelayAtBeat( fStartBeat );
float fEndTime;
float fCurTime = fMusicSeconds;
if( seg.m_usMode == 1 ) // seconds
{
fEndTime = fStartTime + seg.m_fWait;
}
else
{
fEndTime = GetElapsedTimeFromBeat( fStartBeat + seg.m_fWait ) - GetDelayAtBeat( fStartBeat + seg.m_fWait );
}
if( ( index == 0 && m_SpeedSegments[0].m_fWait > 0.0 ) && fCurTime < fStartTime )
{
return 1.0;
}
else if( fEndTime >= fCurTime && ( index > 0 || m_SpeedSegments[0].m_fWait > 0.0 ) )
{
const float fPriorSpeed = ( index == 0 ? 1 : m_SpeedSegments[index - 1].m_fPercent );
float fTimeUsed = fCurTime - fStartTime;
float fDuration = fEndTime - fStartTime;
float fRatioUsed = fDuration == 0.0 ? 1 : fTimeUsed / fDuration;
float fDistance = fPriorSpeed - seg.m_fPercent;
float fRatioNeed = fRatioUsed * -fDistance;
return (fPriorSpeed + fRatioNeed);
}
else
{
return seg.m_fPercent;
}
}
void TimingData::TidyUpData()
{
// If there are no BPM segments, provide a default.