From cc1d203afe581232ed6b6b9483415ac196e5bca9 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Wed, 20 Jul 2005 05:26:27 +0000 Subject: [PATCH] Give time-based lead-in for record, like play, not a whole measure (and merge code). Only pad the end position by a measure when playing the whole song, not when playing a selection. Don't pad when recording. It'll jump to the end position, anyway. Don't mess up the user's selection range when using play from start/play from cursor. --- stepmania/src/ScreenEdit.cpp | 42 +++++++++++++++++++++++------------- stepmania/src/ScreenEdit.h | 1 + 2 files changed, 28 insertions(+), 15 deletions(-) diff --git a/stepmania/src/ScreenEdit.cpp b/stepmania/src/ScreenEdit.cpp index ac5d655671..e5300fd4b6 100644 --- a/stepmania/src/ScreenEdit.cpp +++ b/stepmania/src/ScreenEdit.cpp @@ -582,6 +582,8 @@ void ScreenEdit::Init() GAMESTATE->StoreSelectedOptions(); m_iShiftAnchor = -1; + m_iStartPlayingAt = -1; + m_iStopPlayingAt = -1; m_EditState = STATE_INVALID; TransitionEditState( STATE_EDITING ); @@ -815,7 +817,7 @@ void ScreenEdit::Update( float fDeltaTime ) { // check for end of playback/record - if( GAMESTATE->m_fSongBeat > NoteRowToBeat(m_NoteFieldEdit.m_iEndMarker) + 4 ) // give a one measure lead out + if( GAMESTATE->m_fSongBeat > NoteRowToBeat(m_iStopPlayingAt) ) { TransitionEditState( STATE_EDITING ); GAMESTATE->m_fSongBeat = NoteRowToBeat( m_NoteFieldEdit.m_iEndMarker ); @@ -1796,6 +1798,16 @@ void ScreenEdit::TransitionEditState( EditState em ) m_Player.SetHidden( em != STATE_PLAYING ); m_Foreground.SetHidden( !PREFSMAN->m_bEditorShowBGChangesPlay || em == STATE_EDITING ); + switch( em ) + { + case STATE_PLAYING: + case STATE_RECORDING: + /* Give a 1 secord lead-in. If we're loading Player, this must be done first. */ + float fSeconds = m_pSong->m_Timing.GetElapsedTimeFromBeat( NoteRowToBeat(m_iStartPlayingAt) ) - 1; + GAMESTATE->UpdateSongPosition( fSeconds, m_pSong->m_Timing ); + break; + } + switch( em ) { case STATE_PLAYING: @@ -1807,12 +1819,6 @@ void ScreenEdit::TransitionEditState( EditState em ) /* Reset the note skin, in case preferences have changed. */ GAMESTATE->ResetNoteSkins(); - - /* Give a 1 secord lead-in. Set this before loading Player, so it knows - * where we're starting. */ - float fSeconds = m_pSong->m_Timing.GetElapsedTimeFromBeat( NoteRowToBeat(m_NoteFieldEdit.m_iBeginMarker) ) - 1; - GAMESTATE->UpdateSongPosition( fSeconds, m_pSong->m_Timing ); - /* If we're in course display mode, set that up. */ SetupCourseAttacks(); @@ -1849,8 +1855,6 @@ void ScreenEdit::TransitionEditState( EditState em ) // initialize m_NoteFieldRecord m_NoteDataRecord.CopyAll( m_NoteDataEdit ); - GAMESTATE->m_fSongBeat = NoteRowToBeat(m_NoteFieldEdit.m_iBeginMarker - ROWS_PER_MEASURE ); // give a 1 measure lead-in - break; } } @@ -2161,16 +2165,20 @@ void ScreenEdit::HandleMainMenuChoice( MainMenuChoice c, const vector &iAns break; case play_whole_song: { - m_NoteFieldEdit.m_iBeginMarker = 0; - m_NoteFieldEdit.m_iEndMarker = m_NoteDataEdit.GetLastRow(); - HandleAreaMenuChoice( play ); + m_iStartPlayingAt = 0; + m_iStopPlayingAt = m_NoteDataEdit.GetLastRow(); + m_iStopPlayingAt += BeatToNoteRow(4); // give a one measure lead out + + TransitionEditState( STATE_PLAYING ); } break; case play_current_beat_to_end: { - m_NoteFieldEdit.m_iBeginMarker = BeatToNoteRow(GAMESTATE->m_fSongBeat); - m_NoteFieldEdit.m_iEndMarker = m_NoteDataEdit.GetLastRow(); - HandleAreaMenuChoice( play ); + m_iStartPlayingAt = BeatToNoteRow(GAMESTATE->m_fSongBeat); + m_iStopPlayingAt = m_NoteDataEdit.GetLastRow(); + m_iStopPlayingAt += BeatToNoteRow(4); // give a one measure lead out + + TransitionEditState( STATE_PLAYING ); } break; case save: @@ -2562,10 +2570,14 @@ void ScreenEdit::HandleAreaMenuChoice( AreaMenuChoice c, const vector &iAns break; case play: ASSERT( m_NoteFieldEdit.m_iBeginMarker!=-1 && m_NoteFieldEdit.m_iEndMarker!=-1 ); + m_iStartPlayingAt = m_NoteFieldEdit.m_iBeginMarker; + m_iStopPlayingAt = m_NoteFieldEdit.m_iEndMarker; TransitionEditState( STATE_PLAYING ); break; case record: ASSERT( m_NoteFieldEdit.m_iBeginMarker!=-1 && m_NoteFieldEdit.m_iEndMarker!=-1 ); + m_iStartPlayingAt = m_NoteFieldEdit.m_iBeginMarker; + m_iStopPlayingAt = m_NoteFieldEdit.m_iEndMarker; TransitionEditState( STATE_RECORDING ); break; case insert_and_shift: diff --git a/stepmania/src/ScreenEdit.h b/stepmania/src/ScreenEdit.h index 2bdea5d3a1..7a183e67bb 100644 --- a/stepmania/src/ScreenEdit.h +++ b/stepmania/src/ScreenEdit.h @@ -225,6 +225,7 @@ protected: Course *m_pAttacksFromCourse; // for MODE_RECORD and MODE_PLAY + int m_iStartPlayingAt, m_iStopPlayingAt; RageSound m_soundMusic;