From ea8705fa9dfecd89a608f444b7cb191b1b543efb Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Thu, 21 Jul 2005 22:31:09 +0000 Subject: [PATCH] spit out ScreenEdit::ScrollTo --- stepmania/src/ScreenEdit.cpp | 127 ++++++++++++++++++----------------- stepmania/src/ScreenEdit.h | 1 + 2 files changed, 67 insertions(+), 61 deletions(-) diff --git a/stepmania/src/ScreenEdit.cpp b/stepmania/src/ScreenEdit.cpp index 5ed41c410b..650b66eb72 100644 --- a/stepmania/src/ScreenEdit.cpp +++ b/stepmania/src/ScreenEdit.cpp @@ -1147,71 +1147,11 @@ void ScreenEdit::InputEdit( const DeviceInput& DeviceI, const InputEventType typ break; } - const float fOriginalBeat = GAMESTATE->m_fSongBeat; float fDestinationBeat = GAMESTATE->m_fSongBeat + fBeatsToMove; fDestinationBeat = Quantize( fDestinationBeat, NoteTypeToBeat(m_SnapDisplay.GetNoteType()) ); CLAMP( fDestinationBeat, 0, GetMaximumBeatForMoving() ); - // Don't play the sound and do the hold note logic below if our position didn't change. - if( fOriginalBeat == fDestinationBeat ) - return; - - GAMESTATE->m_fSongBeat = fDestinationBeat; - - // check to see if they're holding a button - for( int n=0; n= m_NoteDataEdit.GetNumTracks() ) - continue; // skip - - EditButton b = EditButton(EDIT_BUTTON_COLUMN_0+n); - if( !EditIsBeingPressed(b) ) - continue; - - // create a new hold note - int iStartRow = BeatToNoteRow( min(fOriginalBeat, fDestinationBeat) ); - int iEndRow = BeatToNoteRow( max(fOriginalBeat, fDestinationBeat) ); - - // Don't SaveUndo. We want to undo the whole hold, not just the last segment - // that the user made. Dragging the hold bigger can only absorb and remove - // other taps, so dragging won't cause us to exceed the note limit. - if( EditIsBeingPressed(EDIT_BUTTON_LAY_MINE_OR_ROLL) ) - m_NoteDataEdit.AddHoldNote( iCol, iStartRow, iEndRow, TAP_ORIGINAL_ROLL_HEAD ); - else - m_NoteDataEdit.AddHoldNote( iCol, iStartRow, iEndRow, TAP_ORIGINAL_HOLD_HEAD ); - } - - if( EditIsBeingPressed(EDIT_BUTTON_SCROLL_SELECT) ) - { - /* Shift is being held. - * - * If this is the first time we've moved since shift was depressed, - * the old position (before this move) becomes the start pos: */ - int iDestinationRow = BeatToNoteRow( fDestinationBeat ); - if( m_iShiftAnchor == -1 ) - m_iShiftAnchor = BeatToNoteRow(fOriginalBeat); - - if( iDestinationRow == m_iShiftAnchor ) - { - /* We're back at the anchor, so we have nothing selected. */ - m_NoteFieldEdit.m_iBeginMarker = m_NoteFieldEdit.m_iEndMarker = -1; - } - else - { - m_NoteFieldEdit.m_iBeginMarker = m_iShiftAnchor; - m_NoteFieldEdit.m_iEndMarker = iDestinationRow; - if( m_NoteFieldEdit.m_iBeginMarker > m_NoteFieldEdit.m_iEndMarker ) - swap( m_NoteFieldEdit.m_iBeginMarker, m_NoteFieldEdit.m_iEndMarker ); - } - } - - m_soundChangeLine.Play(); + ScrollTo( fDestinationBeat ); } break; case EDIT_BUTTON_SNAP_NEXT: @@ -2029,6 +1969,71 @@ void ScreenEdit::TransitionEditState( EditState em ) m_EditState = em; } +void ScreenEdit::ScrollTo( float fDestinationBeat ) +{ + // Don't play the sound and do the hold note logic below if our position didn't change. + const float fOriginalBeat = GAMESTATE->m_fSongBeat; + if( fOriginalBeat == fDestinationBeat ) + return; + + GAMESTATE->m_fSongBeat = fDestinationBeat; + + // check to see if they're holding a button + for( int n=0; n= m_NoteDataEdit.GetNumTracks() ) + continue; // skip + + EditButton b = EditButton(EDIT_BUTTON_COLUMN_0+n); + if( !EditIsBeingPressed(b) ) + continue; + + // create a new hold note + int iStartRow = BeatToNoteRow( min(fOriginalBeat, fDestinationBeat) ); + int iEndRow = BeatToNoteRow( max(fOriginalBeat, fDestinationBeat) ); + + // Don't SaveUndo. We want to undo the whole hold, not just the last segment + // that the user made. Dragging the hold bigger can only absorb and remove + // other taps, so dragging won't cause us to exceed the note limit. + if( EditIsBeingPressed(EDIT_BUTTON_LAY_MINE_OR_ROLL) ) + m_NoteDataEdit.AddHoldNote( iCol, iStartRow, iEndRow, TAP_ORIGINAL_ROLL_HEAD ); + else + m_NoteDataEdit.AddHoldNote( iCol, iStartRow, iEndRow, TAP_ORIGINAL_HOLD_HEAD ); + } + + if( EditIsBeingPressed(EDIT_BUTTON_SCROLL_SELECT) ) + { + /* Shift is being held. + * + * If this is the first time we've moved since shift was depressed, + * the old position (before this move) becomes the start pos: */ + int iDestinationRow = BeatToNoteRow( fDestinationBeat ); + if( m_iShiftAnchor == -1 ) + m_iShiftAnchor = BeatToNoteRow(fOriginalBeat); + + if( iDestinationRow == m_iShiftAnchor ) + { + /* We're back at the anchor, so we have nothing selected. */ + m_NoteFieldEdit.m_iBeginMarker = m_NoteFieldEdit.m_iEndMarker = -1; + } + else + { + m_NoteFieldEdit.m_iBeginMarker = m_iShiftAnchor; + m_NoteFieldEdit.m_iEndMarker = iDestinationRow; + if( m_NoteFieldEdit.m_iBeginMarker > m_NoteFieldEdit.m_iEndMarker ) + swap( m_NoteFieldEdit.m_iBeginMarker, m_NoteFieldEdit.m_iEndMarker ); + } + } + + m_soundChangeLine.Play(); +} + void ScreenEdit::HandleScreenMessage( const ScreenMessage SM ) { if( SM != SM_UpdateTextInfo ) diff --git a/stepmania/src/ScreenEdit.h b/stepmania/src/ScreenEdit.h index 71d8ae3566..78bf27e611 100644 --- a/stepmania/src/ScreenEdit.h +++ b/stepmania/src/ScreenEdit.h @@ -157,6 +157,7 @@ protected: STATE_INVALID }; void TransitionEditState( EditState em ); + void ScrollTo( float fDestinationBeat ); void PlayTicks(); void PlayPreviewMusic();