diff --git a/stepmania/src/ScreenEdit.cpp b/stepmania/src/ScreenEdit.cpp index bdad8a187a..3e1f0aa0fd 100644 --- a/stepmania/src/ScreenEdit.cpp +++ b/stepmania/src/ScreenEdit.cpp @@ -32,6 +32,7 @@ #include "CommonMetrics.h" #include "ScreenPlayerOptions.h" // for SM_BackFromPlayerOptions #include "ScreenSongOptions.h" // for SM_BackFromSongOptions +#include // // Defines specific to ScreenEdit @@ -951,13 +952,15 @@ void ScreenEdit::InputEdit( const DeviceInput& DeviceI, const InputEventType typ break; } - const float fStartBeat = GAMESTATE->m_fSongBeat; - float fEndBeat = max( GAMESTATE->m_fSongBeat + fBeatsToMove, 0 ); - fEndBeat = Quantize( fEndBeat , NoteTypeToBeat(m_SnapDisplay.GetNoteType()) ); - GAMESTATE->m_fSongBeat = fEndBeat; + const float fOriginalBeat = GAMESTATE->m_fSongBeat; + float fDestinationBeat = GAMESTATE->m_fSongBeat + fBeatsToMove; + fDestinationBeat = Quantize( fDestinationBeat, NoteTypeToBeat(m_SnapDisplay.GetNoteType()) ); + CLAMP( fDestinationBeat, 0, GetMaximumBeat() ); + + GAMESTATE->m_fSongBeat = fDestinationBeat; // check to see if they're holding a button - for( int n=0; n<=9; n++ ) // for each number key + for( int n=0; n m_NoteFieldEdit.m_iEndMarker ) swap( m_NoteFieldEdit.m_iBeginMarker, m_NoteFieldEdit.m_iEndMarker ); } @@ -2576,6 +2579,29 @@ void ScreenEdit::CheckNumberOfNotesAndUndo() } } +float ScreenEdit::GetMaximumBeat() const +{ + if( GAMESTATE->m_pCurSteps[0]->IsAnEdit() ) + { + // Jump to GetLastBeat even if it's past m_pCurSong->m_fLastBeat + // so that users can delete garbage steps past then end that they have + // have inserted in a text editor. Once they delete all steps on + // GetLastBeat() and move off of that beat, they won't be able to return. + float fEndBeat = max( m_NoteDataEdit.GetLastBeat(), GAMESTATE->m_pCurSong->m_fLastBeat ); + + // Round up to the next measure end. Some songs end on weird beats + // mid-measure, and it's odd to have movement capped to these weird + // beats. + fEndBeat += BEATS_PER_MEASURE; + fEndBeat = ftruncf( fEndBeat, (float)BEATS_PER_MEASURE ); + return fEndBeat; + } + else + { + return FLT_MAX; + } +} + /* * (c) 2001-2004 Chris Danford * All rights reserved. diff --git a/stepmania/src/ScreenEdit.h b/stepmania/src/ScreenEdit.h index bfc15a63f9..19b5e2fe50 100644 --- a/stepmania/src/ScreenEdit.h +++ b/stepmania/src/ScreenEdit.h @@ -18,6 +18,8 @@ #include "Steps.h" #include "ThemeMetric.h" +const int NUM_EDIT_BUTTON_COLUMNS = 10; + enum EditButton { EDIT_BUTTON_COLUMN_0, @@ -154,6 +156,8 @@ protected: void MenuItemGainFocus( BitmapText* menuitem ); void MenuItemLoseFocus( BitmapText* menuitem ); + float GetMaximumBeat() const; // don't allow Down key to go past this beat. + EditMode m_EditMode;