In ScreenEdit, figure out whether a song is dirty or not by keeping track
of a m_bDirty bit, not by reusing the m_bHasUndo bit. This fixes two bugs: 1) Save & revert wouldn't clear the dirty bit before 2) Some operations such as tempo and stop changes wouldn't make the song dirty R=Steve Chekoway
This commit is contained in:
@@ -717,6 +717,8 @@ void ScreenEdit::Init()
|
|||||||
m_bHasUndo = false;
|
m_bHasUndo = false;
|
||||||
m_Undo.SetNumTracks( m_NoteDataEdit.GetNumTracks() );
|
m_Undo.SetNumTracks( m_NoteDataEdit.GetNumTracks() );
|
||||||
|
|
||||||
|
m_bDirty = false;
|
||||||
|
|
||||||
|
|
||||||
m_Player->Init( "Player", GAMESTATE->m_pPlayerState[PLAYER_1], NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL );
|
m_Player->Init( "Player", GAMESTATE->m_pPlayerState[PLAYER_1], NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL );
|
||||||
m_Player->CacheAllUsedNoteSkins();
|
m_Player->CacheAllUsedNoteSkins();
|
||||||
@@ -1177,6 +1179,7 @@ void ScreenEdit::InputEdit( const InputEventPlus &input, EditButton EditB )
|
|||||||
if( m_NoteDataEdit.IsHoldNoteAtRow( iCol, iSongIndex, &iHeadRow ) )
|
if( m_NoteDataEdit.IsHoldNoteAtRow( iCol, iSongIndex, &iHeadRow ) )
|
||||||
{
|
{
|
||||||
m_soundRemoveNote.Play();
|
m_soundRemoveNote.Play();
|
||||||
|
SetDirty( true );
|
||||||
SaveUndo();
|
SaveUndo();
|
||||||
m_NoteDataEdit.SetTapNote( iCol, iHeadRow, TAP_EMPTY );
|
m_NoteDataEdit.SetTapNote( iCol, iHeadRow, TAP_EMPTY );
|
||||||
// Don't CheckNumberOfNotesAndUndo. We don't want to revert any change that removes notes.
|
// Don't CheckNumberOfNotesAndUndo. We don't want to revert any change that removes notes.
|
||||||
@@ -1184,6 +1187,7 @@ void ScreenEdit::InputEdit( const InputEventPlus &input, EditButton EditB )
|
|||||||
else if( m_NoteDataEdit.GetTapNote(iCol, iSongIndex).type != TapNote::empty )
|
else if( m_NoteDataEdit.GetTapNote(iCol, iSongIndex).type != TapNote::empty )
|
||||||
{
|
{
|
||||||
m_soundRemoveNote.Play();
|
m_soundRemoveNote.Play();
|
||||||
|
SetDirty( true );
|
||||||
SaveUndo();
|
SaveUndo();
|
||||||
m_NoteDataEdit.SetTapNote( iCol, iSongIndex, TAP_EMPTY );
|
m_NoteDataEdit.SetTapNote( iCol, iSongIndex, TAP_EMPTY );
|
||||||
// Don't CheckNumberOfNotesAndUndo. We don't want to revert any change that removes notes.
|
// Don't CheckNumberOfNotesAndUndo. We don't want to revert any change that removes notes.
|
||||||
@@ -1191,6 +1195,7 @@ void ScreenEdit::InputEdit( const InputEventPlus &input, EditButton EditB )
|
|||||||
else if( EditIsBeingPressed(EDIT_BUTTON_LAY_MINE_OR_ROLL) )
|
else if( EditIsBeingPressed(EDIT_BUTTON_LAY_MINE_OR_ROLL) )
|
||||||
{
|
{
|
||||||
m_soundAddNote.Play();
|
m_soundAddNote.Play();
|
||||||
|
SetDirty( true );
|
||||||
SaveUndo();
|
SaveUndo();
|
||||||
TapNote tn = TAP_ORIGINAL_MINE;
|
TapNote tn = TAP_ORIGINAL_MINE;
|
||||||
tn.pn = m_InputPlayerNumber;
|
tn.pn = m_InputPlayerNumber;
|
||||||
@@ -1205,6 +1210,7 @@ void ScreenEdit::InputEdit( const InputEventPlus &input, EditButton EditB )
|
|||||||
else if( EditIsBeingPressed(EDIT_BUTTON_LAY_LIFT) )
|
else if( EditIsBeingPressed(EDIT_BUTTON_LAY_LIFT) )
|
||||||
{
|
{
|
||||||
m_soundAddNote.Play();
|
m_soundAddNote.Play();
|
||||||
|
SetDirty( true );
|
||||||
SaveUndo();
|
SaveUndo();
|
||||||
TapNote tn = TAP_ORIGINAL_LIFT;
|
TapNote tn = TAP_ORIGINAL_LIFT;
|
||||||
tn.pn = m_InputPlayerNumber;
|
tn.pn = m_InputPlayerNumber;
|
||||||
@@ -1214,6 +1220,7 @@ void ScreenEdit::InputEdit( const InputEventPlus &input, EditButton EditB )
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_soundAddNote.Play();
|
m_soundAddNote.Play();
|
||||||
|
SetDirty( true );
|
||||||
SaveUndo();
|
SaveUndo();
|
||||||
TapNote tn = TAP_ORIGINAL_TAP;
|
TapNote tn = TAP_ORIGINAL_TAP;
|
||||||
tn.pn = m_InputPlayerNumber;
|
tn.pn = m_InputPlayerNumber;
|
||||||
@@ -1471,6 +1478,7 @@ void ScreenEdit::InputEdit( const InputEventPlus &input, EditButton EditB )
|
|||||||
float fNewBPM = fBPM + fDelta;
|
float fNewBPM = fBPM + fDelta;
|
||||||
m_pSong->SetBPMAtBeat( GAMESTATE->m_fSongBeat, fNewBPM );
|
m_pSong->SetBPMAtBeat( GAMESTATE->m_fSongBeat, fNewBPM );
|
||||||
(fDelta>0 ? m_soundValueIncrease : m_soundValueDecrease).Play();
|
(fDelta>0 ? m_soundValueIncrease : m_soundValueDecrease).Play();
|
||||||
|
SetDirty( true );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case EDIT_BUTTON_STOP_UP:
|
case EDIT_BUTTON_STOP_UP:
|
||||||
@@ -1515,6 +1523,7 @@ void ScreenEdit::InputEdit( const InputEventPlus &input, EditButton EditB )
|
|||||||
m_pSong->m_Timing.m_StopSegments.begin()+i+1);
|
m_pSong->m_Timing.m_StopSegments.begin()+i+1);
|
||||||
}
|
}
|
||||||
(fDelta>0 ? m_soundValueIncrease : m_soundValueDecrease).Play();
|
(fDelta>0 ? m_soundValueIncrease : m_soundValueDecrease).Play();
|
||||||
|
SetDirty( true );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case EDIT_BUTTON_OFFSET_UP:
|
case EDIT_BUTTON_OFFSET_UP:
|
||||||
@@ -1540,6 +1549,7 @@ void ScreenEdit::InputEdit( const InputEventPlus &input, EditButton EditB )
|
|||||||
}
|
}
|
||||||
m_pSong->m_Timing.m_fBeat0OffsetInSeconds += fDelta;
|
m_pSong->m_Timing.m_fBeat0OffsetInSeconds += fDelta;
|
||||||
(fDelta>0 ? m_soundValueIncrease : m_soundValueDecrease).Play();
|
(fDelta>0 ? m_soundValueIncrease : m_soundValueDecrease).Play();
|
||||||
|
SetDirty( true );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case EDIT_BUTTON_SAMPLE_START_UP:
|
case EDIT_BUTTON_SAMPLE_START_UP:
|
||||||
@@ -1576,6 +1586,7 @@ void ScreenEdit::InputEdit( const InputEventPlus &input, EditButton EditB )
|
|||||||
m_pSong->m_fMusicSampleStartSeconds = max(m_pSong->m_fMusicSampleStartSeconds,0);
|
m_pSong->m_fMusicSampleStartSeconds = max(m_pSong->m_fMusicSampleStartSeconds,0);
|
||||||
}
|
}
|
||||||
(fDelta>0 ? m_soundValueIncrease : m_soundValueDecrease).Play();
|
(fDelta>0 ? m_soundValueIncrease : m_soundValueDecrease).Play();
|
||||||
|
SetDirty( true );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case EDIT_BUTTON_PLAY_SAMPLE_MUSIC:
|
case EDIT_BUTTON_PLAY_SAMPLE_MUSIC:
|
||||||
@@ -2128,6 +2139,7 @@ void ScreenEdit::TransitionEditState( EditState em )
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case STATE_RECORDING:
|
case STATE_RECORDING:
|
||||||
|
SetDirty( true );
|
||||||
SaveUndo();
|
SaveUndo();
|
||||||
|
|
||||||
// delete old TapNotes in the range
|
// delete old TapNotes in the range
|
||||||
@@ -2390,16 +2402,19 @@ void ScreenEdit::HandleScreenMessage( const ScreenMessage SM )
|
|||||||
float fBPM = StringToFloat( ScreenTextEntry::s_sLastAnswer );
|
float fBPM = StringToFloat( ScreenTextEntry::s_sLastAnswer );
|
||||||
if( fBPM > 0 )
|
if( fBPM > 0 )
|
||||||
m_pSong->SetBPMAtBeat( GAMESTATE->m_fSongBeat, fBPM );
|
m_pSong->SetBPMAtBeat( GAMESTATE->m_fSongBeat, fBPM );
|
||||||
|
SetDirty( true );
|
||||||
}
|
}
|
||||||
else if( SM == SM_BackFromStopChange )
|
else if( SM == SM_BackFromStopChange )
|
||||||
{
|
{
|
||||||
float fStop = StringToFloat( ScreenTextEntry::s_sLastAnswer );
|
float fStop = StringToFloat( ScreenTextEntry::s_sLastAnswer );
|
||||||
if( fStop >= 0 )
|
if( fStop >= 0 )
|
||||||
m_pSong->m_Timing.SetStopAtBeat( GAMESTATE->m_fSongBeat, fStop );
|
m_pSong->m_Timing.SetStopAtBeat( GAMESTATE->m_fSongBeat, fStop );
|
||||||
|
SetDirty( true );
|
||||||
}
|
}
|
||||||
else if( SM == SM_BackFromBGChange )
|
else if( SM == SM_BackFromBGChange )
|
||||||
{
|
{
|
||||||
HandleBGChangeChoice( (BGChangeChoice)ScreenMiniMenu::s_iLastRowCode, ScreenMiniMenu::s_viLastAnswers );
|
HandleBGChangeChoice( (BGChangeChoice)ScreenMiniMenu::s_iLastRowCode, ScreenMiniMenu::s_viLastAnswers );
|
||||||
|
SetDirty( true );
|
||||||
}
|
}
|
||||||
else if( SM == SM_BackFromCourseModeMenu )
|
else if( SM == SM_BackFromCourseModeMenu )
|
||||||
{
|
{
|
||||||
@@ -2454,6 +2469,7 @@ void ScreenEdit::HandleScreenMessage( const ScreenMessage SM )
|
|||||||
g_fLastInsertAttackDurationSeconds,
|
g_fLastInsertAttackDurationSeconds,
|
||||||
-1 );
|
-1 );
|
||||||
tn.pn = m_InputPlayerNumber;
|
tn.pn = m_InputPlayerNumber;
|
||||||
|
SetDirty( true );
|
||||||
SaveUndo();
|
SaveUndo();
|
||||||
m_NoteDataEdit.SetTapNote( g_iLastInsertTapAttackTrack, row, tn );
|
m_NoteDataEdit.SetTapNote( g_iLastInsertTapAttackTrack, row, tn );
|
||||||
CheckNumberOfNotesAndUndo();
|
CheckNumberOfNotesAndUndo();
|
||||||
@@ -2520,6 +2536,7 @@ void ScreenEdit::HandleScreenMessage( const ScreenMessage SM )
|
|||||||
SaveUndo();
|
SaveUndo();
|
||||||
CopyFromLastSave();
|
CopyFromLastSave();
|
||||||
m_pSteps->GetNoteData( m_NoteDataEdit );
|
m_pSteps->GetNoteData( m_NoteDataEdit );
|
||||||
|
SetDirty( false );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if( SM == SM_DoRevertFromDisk )
|
else if( SM == SM_DoRevertFromDisk )
|
||||||
@@ -2529,6 +2546,7 @@ void ScreenEdit::HandleScreenMessage( const ScreenMessage SM )
|
|||||||
SaveUndo();
|
SaveUndo();
|
||||||
RevertFromDisk();
|
RevertFromDisk();
|
||||||
m_pSteps->GetNoteData( m_NoteDataEdit );
|
m_pSteps->GetNoteData( m_NoteDataEdit );
|
||||||
|
SetDirty( false );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if( SM == SM_DoSaveAndExit ) // just asked "save before exiting? yes, no, cancel"
|
else if( SM == SM_DoSaveAndExit ) // just asked "save before exiting? yes, no, cancel"
|
||||||
@@ -2553,6 +2571,7 @@ void ScreenEdit::HandleScreenMessage( const ScreenMessage SM )
|
|||||||
LOG->Trace( "Save successful." );
|
LOG->Trace( "Save successful." );
|
||||||
m_pSteps->SetSavedToDisk( true );
|
m_pSteps->SetSavedToDisk( true );
|
||||||
CopyToLastSave();
|
CopyToLastSave();
|
||||||
|
SetDirty( false );
|
||||||
|
|
||||||
if( m_CurrentAction == save_on_exit )
|
if( m_CurrentAction == save_on_exit )
|
||||||
ScreenPrompt::Prompt( SM_DoExit, SAVE_SUCCESSFUL );
|
ScreenPrompt::Prompt( SM_DoExit, SAVE_SUCCESSFUL );
|
||||||
@@ -2890,7 +2909,7 @@ void ScreenEdit::HandleMainMenuChoice( MainMenuChoice c, const vector<int> &iAns
|
|||||||
DEFAULT_FAIL( EDIT_MODE.GetValue() );
|
DEFAULT_FAIL( EDIT_MODE.GetValue() );
|
||||||
case EditMode_Full:
|
case EditMode_Full:
|
||||||
case EditMode_Home:
|
case EditMode_Home:
|
||||||
if( m_bHasUndo )
|
if( IsDirty() )
|
||||||
ScreenPrompt::Prompt( SM_DoSaveAndExit, SAVE_CHANGES_BEFORE_EXITING, PROMPT_YES_NO_CANCEL, ANSWER_CANCEL );
|
ScreenPrompt::Prompt( SM_DoSaveAndExit, SAVE_CHANGES_BEFORE_EXITING, PROMPT_YES_NO_CANCEL, ANSWER_CANCEL );
|
||||||
else
|
else
|
||||||
SCREENMAN->SendMessageToTopScreen( SM_DoExit );
|
SCREENMAN->SendMessageToTopScreen( SM_DoExit );
|
||||||
@@ -2935,6 +2954,9 @@ void ScreenEdit::HandleAreaMenuChoice( AreaMenuChoice c, const vector<int> &iAns
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( bSaveUndo )
|
||||||
|
SetDirty( true );
|
||||||
|
|
||||||
// We call HandleAreaMenuChoice recursively. Only the outermost HandleAreaMenuChoice
|
// We call HandleAreaMenuChoice recursively. Only the outermost HandleAreaMenuChoice
|
||||||
// should allow Undo so that the inner calls don't also save Undo and mess up the outermost
|
// should allow Undo so that the inner calls don't also save Undo and mess up the outermost
|
||||||
if( !bAllowUndo )
|
if( !bAllowUndo )
|
||||||
@@ -3424,6 +3446,8 @@ void ScreenEdit::RevertFromDisk()
|
|||||||
m_songLastSave = *GAMESTATE->m_pCurSong;
|
m_songLastSave = *GAMESTATE->m_pCurSong;
|
||||||
if( GAMESTATE->m_pCurSteps[PLAYER_1] )
|
if( GAMESTATE->m_pCurSteps[PLAYER_1] )
|
||||||
m_stepsLastSave = *GAMESTATE->m_pCurSteps[PLAYER_1];
|
m_stepsLastSave = *GAMESTATE->m_pCurSteps[PLAYER_1];
|
||||||
|
|
||||||
|
SetDirty(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenEdit::SaveUndo()
|
void ScreenEdit::SaveUndo()
|
||||||
|
|||||||
@@ -179,6 +179,9 @@ public:
|
|||||||
void InputPlay( const InputEventPlus &input, EditButton EditB );
|
void InputPlay( const InputEventPlus &input, EditButton EditB );
|
||||||
virtual void HandleScreenMessage( const ScreenMessage SM );
|
virtual void HandleScreenMessage( const ScreenMessage SM );
|
||||||
|
|
||||||
|
void SetDirty( bool bDirty ) { m_bDirty = bDirty; }
|
||||||
|
bool IsDirty() const { return m_bDirty; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual ScreenType GetScreenType() const { return m_EditState==STATE_PLAYING ? gameplay : ScreenWithMenuElements::GetScreenType(); }
|
virtual ScreenType GetScreenType() const { return m_EditState==STATE_PLAYING ? gameplay : ScreenWithMenuElements::GetScreenType(); }
|
||||||
|
|
||||||
@@ -232,6 +235,8 @@ protected:
|
|||||||
bool m_bHasUndo;
|
bool m_bHasUndo;
|
||||||
NoteData m_Undo;
|
NoteData m_Undo;
|
||||||
|
|
||||||
|
bool m_bDirty;
|
||||||
|
|
||||||
RageSound m_soundAddNote;
|
RageSound m_soundAddNote;
|
||||||
RageSound m_soundRemoveNote;
|
RageSound m_soundRemoveNote;
|
||||||
RageSound m_soundChangeLine;
|
RageSound m_soundChangeLine;
|
||||||
|
|||||||
Reference in New Issue
Block a user