From b2c7e5e829859b05f16a6ed650bc02a11de9f2ed Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Fri, 22 Jul 2005 00:55:36 +0000 Subject: [PATCH] add "jump to next note", "jump to previous note" --- stepmania/src/NoteDataUtil.cpp | 65 ++++++++++++++++++++++++++++++++++ stepmania/src/NoteDataUtil.h | 3 ++ stepmania/src/ScreenEdit.cpp | 16 +++++++++ stepmania/src/ScreenEdit.h | 2 ++ 4 files changed, 86 insertions(+) diff --git a/stepmania/src/NoteDataUtil.cpp b/stepmania/src/NoteDataUtil.cpp index 58fd0efe02..653031c1dd 100644 --- a/stepmania/src/NoteDataUtil.cpp +++ b/stepmania/src/NoteDataUtil.cpp @@ -1975,6 +1975,71 @@ bool NoteDataUtil::AnyTapsAndHoldsInTrackRange( const NoteData& in, int iTrack, return false; } +/* Find the next row that either starts a TapNote, or ends a previous one. */ +bool NoteDataUtil::GetNextEditorPosition( const NoteData& in, int &rowInOut ) +{ + int iOriginalRow = rowInOut; + bool bAnyHaveNextNote = in.GetNextTapNoteRowForAllTracks( rowInOut ); + + int iClosestNextRow = rowInOut; + if( !bAnyHaveNextNote ) + iClosestNextRow = MAX_NOTE_ROW; + + for( int t=0; t= iOriginalRow ) + continue; + + bAnyHavePrevNote = true; + ASSERT( iEndRow < MAX_NOTE_ROW ); + iClosestPrevRow = max( iClosestPrevRow, iEndRow ); + } + + if( !bAnyHavePrevNote ) + return false; + + rowInOut = iClosestPrevRow; + return true; +} + /* * (c) 2001-2004 Chris Danford, Glenn Maynard diff --git a/stepmania/src/NoteDataUtil.h b/stepmania/src/NoteDataUtil.h index 2d1aa4de4d..4debe500a5 100644 --- a/stepmania/src/NoteDataUtil.h +++ b/stepmania/src/NoteDataUtil.h @@ -108,6 +108,9 @@ namespace NoteDataUtil int GetNumUsedTracks( const NoteData& in ); bool AnyTapsAndHoldsInTrackRange( const NoteData& in, int iTrack, int iStart, int iEnd ); + + bool GetNextEditorPosition( const NoteData& in, int &rowInOut ); + bool GetPrevEditorPosition( const NoteData& in, int &rowInOut ); }; #endif diff --git a/stepmania/src/ScreenEdit.cpp b/stepmania/src/ScreenEdit.cpp index ced3d98f0a..a944c63f19 100644 --- a/stepmania/src/ScreenEdit.cpp +++ b/stepmania/src/ScreenEdit.cpp @@ -122,6 +122,8 @@ void ScreenEdit::InitEditMappings() m_EditMappings.button[EDIT_BUTTON_SCROLL_DOWN_PAGE][0] = DeviceInput(DEVICE_KEYBOARD, KEY_PGDN); m_EditMappings.button[EDIT_BUTTON_SCROLL_HOME][0] = DeviceInput(DEVICE_KEYBOARD, KEY_HOME); m_EditMappings.button[EDIT_BUTTON_SCROLL_END][0] = DeviceInput(DEVICE_KEYBOARD, KEY_END); + m_EditMappings.button[EDIT_BUTTON_SCROLL_NEXT][0] = DeviceInput(DEVICE_KEYBOARD, KEY_PERIOD); + m_EditMappings.button[EDIT_BUTTON_SCROLL_PREV][0] = DeviceInput(DEVICE_KEYBOARD, KEY_COMMA); m_EditMappings.button [EDIT_BUTTON_SCROLL_SPEED_UP][0] = DeviceInput(DEVICE_KEYBOARD, KEY_UP); m_EditMappings.hold[EDIT_BUTTON_SCROLL_SPEED_UP][0] = DeviceInput(DEVICE_KEYBOARD, KEY_LCTRL); @@ -1154,6 +1156,20 @@ void ScreenEdit::InputEdit( const DeviceInput& DeviceI, const InputEventType typ ScrollTo( fDestinationBeat ); } break; + case EDIT_BUTTON_SCROLL_NEXT: + { + int iRow = BeatToNoteRow( GAMESTATE->m_fSongBeat ); + NoteDataUtil::GetNextEditorPosition( m_NoteDataEdit, iRow ); + ScrollTo( NoteRowToBeat(iRow) ); + } + break; + case EDIT_BUTTON_SCROLL_PREV: + { + int iRow = BeatToNoteRow( GAMESTATE->m_fSongBeat ); + NoteDataUtil::GetPrevEditorPosition( m_NoteDataEdit, iRow ); + ScrollTo( NoteRowToBeat(iRow) ); + } + break; case EDIT_BUTTON_SNAP_NEXT: if( m_SnapDisplay.PrevSnapMode() ) OnSnapModeChange(); diff --git a/stepmania/src/ScreenEdit.h b/stepmania/src/ScreenEdit.h index 78bf27e611..205883e24c 100644 --- a/stepmania/src/ScreenEdit.h +++ b/stepmania/src/ScreenEdit.h @@ -46,6 +46,8 @@ enum EditButton EDIT_BUTTON_SCROLL_DOWN_PAGE, EDIT_BUTTON_SCROLL_HOME, EDIT_BUTTON_SCROLL_END, + EDIT_BUTTON_SCROLL_NEXT, + EDIT_BUTTON_SCROLL_PREV, /* These are modifiers to EDIT_BUTTON_SCROLL_*. */ EDIT_BUTTON_SCROLL_SELECT,