From b6264bd96faa5f8f16054b7096159c5109b4f2bf Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Sun, 18 Dec 2005 07:16:47 +0000 Subject: [PATCH] the +1 in the DeleteRows call means "keep the row at the start, not the end"; it's wrong in the m_Timing.ShiftRows call use m_Timing.SetStopAtBeat this is still not quite right: it will create multiple StopSegments in the same place in some cases --- stepmania/src/ScreenEdit.cpp | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/stepmania/src/ScreenEdit.cpp b/stepmania/src/ScreenEdit.cpp index 4ded0b716a..bab98c12b5 100644 --- a/stepmania/src/ScreenEdit.cpp +++ b/stepmania/src/ScreenEdit.cpp @@ -2979,33 +2979,24 @@ void ScreenEdit::HandleAreaMenuChoice( AreaMenuChoice c, const vector &iAns ASSERT( m_NoteFieldEdit.m_iBeginMarker!=-1 && m_NoteFieldEdit.m_iEndMarker!=-1 ); float fMarkerStart = m_pSong->m_Timing.GetElapsedTimeFromBeat( NoteRowToBeat(m_NoteFieldEdit.m_iBeginMarker) ); float fMarkerEnd = m_pSong->m_Timing.GetElapsedTimeFromBeat( NoteRowToBeat(m_NoteFieldEdit.m_iEndMarker) ); + + // The length of the stop segment we're going to create. This includes time spent in any + // stops in the selection, which will be deleted and subsumed into the new stop. float fStopLength = fMarkerEnd - fMarkerStart; + // be sure not to clobber the row at the start - a row at the end // can be dropped safely, though NoteDataUtil::DeleteRows( m_NoteDataEdit, m_NoteFieldEdit.m_iBeginMarker + 1, m_NoteFieldEdit.m_iEndMarker-m_NoteFieldEdit.m_iBeginMarker ); - m_pSong->m_Timing.ShiftRows( m_NoteFieldEdit.m_iBeginMarker + 1, + // XXX: this will push any stops inside the region to the top of it; that's weird, but + // will be overwritten below anyway + // delete all stops in the region first + m_pSong->m_Timing.ShiftRows( m_NoteFieldEdit.m_iBeginMarker, -m_NoteFieldEdit.m_iEndMarker+m_NoteFieldEdit.m_iBeginMarker ); - unsigned i; - for( i=0; im_Timing.m_StopSegments.size(); i++ ) - { - float fStart = m_pSong->m_Timing.GetElapsedTimeFromBeat(NoteRowToBeat(m_pSong->m_Timing.m_StopSegments[i].m_iStartRow)); - float fEnd = fStart + m_pSong->m_Timing.m_StopSegments[i].m_fStopSeconds; - if( fStart > fMarkerEnd || fEnd < fMarkerStart ) - continue; - else { - if( fStart > fMarkerStart ) - m_pSong->m_Timing.m_StopSegments[i].m_iStartRow = m_NoteFieldEdit.m_iBeginMarker; - m_pSong->m_Timing.m_StopSegments[i].m_fStopSeconds = fStopLength; - break; - } - } - - if( i == m_pSong->m_Timing.m_StopSegments.size() ) // there is no BPMSegment at the current beat - m_pSong->AddStopSegment( StopSegment(m_NoteFieldEdit.m_iBeginMarker, fStopLength) ); + m_pSong->m_Timing.SetStopAtBeat( NoteRowToBeat(m_NoteFieldEdit.m_iBeginMarker), fStopLength ); m_NoteFieldEdit.m_iBeginMarker = -1; m_NoteFieldEdit.m_iEndMarker = -1; break;