When editing an edit, don't allow navigating far past the end of the song.

This commit is contained in:
Chris Danford
2005-03-26 19:11:22 +00:00
parent 89a1c9f42a
commit 40b6c0c350
2 changed files with 44 additions and 14 deletions
+40 -14
View File
@@ -32,6 +32,7 @@
#include "CommonMetrics.h" #include "CommonMetrics.h"
#include "ScreenPlayerOptions.h" // for SM_BackFromPlayerOptions #include "ScreenPlayerOptions.h" // for SM_BackFromPlayerOptions
#include "ScreenSongOptions.h" // for SM_BackFromSongOptions #include "ScreenSongOptions.h" // for SM_BackFromSongOptions
#include <float.h>
// //
// Defines specific to ScreenEdit // Defines specific to ScreenEdit
@@ -951,13 +952,15 @@ void ScreenEdit::InputEdit( const DeviceInput& DeviceI, const InputEventType typ
break; break;
} }
const float fStartBeat = GAMESTATE->m_fSongBeat; const float fOriginalBeat = GAMESTATE->m_fSongBeat;
float fEndBeat = max( GAMESTATE->m_fSongBeat + fBeatsToMove, 0 ); float fDestinationBeat = GAMESTATE->m_fSongBeat + fBeatsToMove;
fEndBeat = Quantize( fEndBeat , NoteTypeToBeat(m_SnapDisplay.GetNoteType()) ); fDestinationBeat = Quantize( fDestinationBeat, NoteTypeToBeat(m_SnapDisplay.GetNoteType()) );
GAMESTATE->m_fSongBeat = fEndBeat; CLAMP( fDestinationBeat, 0, GetMaximumBeat() );
GAMESTATE->m_fSongBeat = fDestinationBeat;
// check to see if they're holding a button // 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<NUM_EDIT_BUTTON_COLUMNS; n++ )
{ {
int iCol = n; int iCol = n;
@@ -973,16 +976,16 @@ void ScreenEdit::InputEdit( const DeviceInput& DeviceI, const InputEventType typ
continue; continue;
// create a new hold note // create a new hold note
int iStartRow = BeatToNoteRow( min(fStartBeat, fEndBeat) ); int iOriginalRow = BeatToNoteRow( min(fOriginalBeat, fDestinationBeat) );
int iEndRow = BeatToNoteRow( max(fStartBeat, fEndBeat) ); int iDestinationRow = BeatToNoteRow( max(fOriginalBeat, fDestinationBeat) );
iStartRow = max( iStartRow, 0 ); iOriginalRow = max( iOriginalRow, 0 );
iEndRow = max( iEndRow, 0 ); iDestinationRow = max( iDestinationRow, 0 );
// Don't SaveUndo. We want to undo the whole hold, not just the last segment // 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 // 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. // other taps, so dragging won't cause us to exceed the note limit.
m_NoteDataEdit.AddHoldNote( iCol, iStartRow, iEndRow, TAP_ORIGINAL_HOLD_HEAD ); m_NoteDataEdit.AddHoldNote( iCol, iOriginalRow, iDestinationRow, TAP_ORIGINAL_HOLD_HEAD );
} }
if( EditIsBeingPressed(EDIT_BUTTON_SCROLL_SELECT) ) if( EditIsBeingPressed(EDIT_BUTTON_SCROLL_SELECT) )
@@ -991,11 +994,11 @@ void ScreenEdit::InputEdit( const DeviceInput& DeviceI, const InputEventType typ
* *
* If this is the first time we've moved since shift was depressed, * If this is the first time we've moved since shift was depressed,
* the old position (before this move) becomes the start pos: */ * the old position (before this move) becomes the start pos: */
int iEndBeat = BeatToNoteRow( fEndBeat ); int iDestinationRow = BeatToNoteRow( fDestinationBeat );
if( g_iShiftAnchor == -1 ) if( g_iShiftAnchor == -1 )
g_iShiftAnchor = BeatToNoteRow(fStartBeat); g_iShiftAnchor = BeatToNoteRow(fOriginalBeat);
if( iEndBeat == g_iShiftAnchor ) if( iDestinationRow == g_iShiftAnchor )
{ {
/* We're back at the anchor, so we have nothing selected. */ /* We're back at the anchor, so we have nothing selected. */
m_NoteFieldEdit.m_iBeginMarker = m_NoteFieldEdit.m_iEndMarker = -1; m_NoteFieldEdit.m_iBeginMarker = m_NoteFieldEdit.m_iEndMarker = -1;
@@ -1003,7 +1006,7 @@ void ScreenEdit::InputEdit( const DeviceInput& DeviceI, const InputEventType typ
else else
{ {
m_NoteFieldEdit.m_iBeginMarker = g_iShiftAnchor; m_NoteFieldEdit.m_iBeginMarker = g_iShiftAnchor;
m_NoteFieldEdit.m_iEndMarker = iEndBeat; m_NoteFieldEdit.m_iEndMarker = iDestinationRow;
if( m_NoteFieldEdit.m_iBeginMarker > m_NoteFieldEdit.m_iEndMarker ) if( m_NoteFieldEdit.m_iBeginMarker > m_NoteFieldEdit.m_iEndMarker )
swap( m_NoteFieldEdit.m_iBeginMarker, 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 * (c) 2001-2004 Chris Danford
* All rights reserved. * All rights reserved.
+4
View File
@@ -18,6 +18,8 @@
#include "Steps.h" #include "Steps.h"
#include "ThemeMetric.h" #include "ThemeMetric.h"
const int NUM_EDIT_BUTTON_COLUMNS = 10;
enum EditButton enum EditButton
{ {
EDIT_BUTTON_COLUMN_0, EDIT_BUTTON_COLUMN_0,
@@ -154,6 +156,8 @@ protected:
void MenuItemGainFocus( BitmapText* menuitem ); void MenuItemGainFocus( BitmapText* menuitem );
void MenuItemLoseFocus( BitmapText* menuitem ); void MenuItemLoseFocus( BitmapText* menuitem );
float GetMaximumBeat() const; // don't allow Down key to go past this beat.
EditMode m_EditMode; EditMode m_EditMode;