Originally, the AdjustSync class always saved to disk, even in edit mode.

In edit mode, though, AdjustSync should only save to memory, giving the
user a chance to save later.  This change adds a SongChanged message
to the MessageManager.  Making the ScreenEdit class listen to this
message allows the AdjustSync class to mark a song as dirty rather than
saving it to disk when in edit mode.

R=steve chekoway
This commit is contained in:
John Bauer
2006-11-02 05:30:02 +00:00
parent db38f88c39
commit 592c27996d
5 changed files with 27 additions and 5 deletions
+13 -5
View File
@@ -34,11 +34,11 @@
*/ */
#include "global.h" #include "global.h"
#include "song.h"
#include "AdjustSync.h" #include "AdjustSync.h"
#include "GameState.h" #include "GameState.h"
#include "song.h"
#include "PrefsManager.h"
#include "LocalizedString.h" #include "LocalizedString.h"
#include "PrefsManager.h"
#include "ScreenManager.h" #include "ScreenManager.h"
TimingData *AdjustSync::s_pTimingDataOriginal = NULL; TimingData *AdjustSync::s_pTimingDataOriginal = NULL;
@@ -51,7 +51,6 @@ float AdjustSync::s_fAverageError = 0.0f;
const float AdjustSync::ERROR_TOO_HIGH = 0.025f; const float AdjustSync::ERROR_TOO_HIGH = 0.025f;
int AdjustSync::s_iStepsFiltered = 0; int AdjustSync::s_iStepsFiltered = 0;
void AdjustSync::ResetOriginalSyncData() void AdjustSync::ResetOriginalSyncData()
{ {
if( s_pTimingDataOriginal == NULL ) if( s_pTimingDataOriginal == NULL )
@@ -87,8 +86,17 @@ void AdjustSync::SaveSyncChanges()
{ {
if( GAMESTATE->IsCourseMode() ) if( GAMESTATE->IsCourseMode() )
return; return;
if( GAMESTATE->m_pCurSong && *s_pTimingDataOriginal != GAMESTATE->m_pCurSong->m_Timing ) if( GAMESTATE->m_pCurSong && *s_pTimingDataOriginal != GAMESTATE->m_pCurSong->m_Timing )
GAMESTATE->m_pCurSong->Save(); {
if( GAMESTATE->IsEditing() )
{
MESSAGEMAN->Broadcast( Message_SongChanged );
}
else
{
GAMESTATE->m_pCurSong->Save();
}
}
if( s_fGlobalOffsetSecondsOriginal != PREFSMAN->m_fGlobalOffsetSeconds ) if( s_fGlobalOffsetSecondsOriginal != PREFSMAN->m_fGlobalOffsetSeconds )
PREFSMAN->SavePrefsToDisk(); PREFSMAN->SavePrefsToDisk();
ResetOriginalSyncData(); ResetOriginalSyncData();
+1
View File
@@ -132,6 +132,7 @@ static const char *MessageNames[] = {
"ShowHoldJudgmentMuliPlayerP30", "ShowHoldJudgmentMuliPlayerP30",
"ShowHoldJudgmentMuliPlayerP31", "ShowHoldJudgmentMuliPlayerP31",
"ShowHoldJudgmentMuliPlayerP32", "ShowHoldJudgmentMuliPlayerP32",
"MessageSongChanged",
}; };
XToString( Message ); XToString( Message );
+1
View File
@@ -127,6 +127,7 @@ enum Message
Message_ShowHoldJudgmentMuliPlayerP30, Message_ShowHoldJudgmentMuliPlayerP30,
Message_ShowHoldJudgmentMuliPlayerP31, Message_ShowHoldJudgmentMuliPlayerP31,
Message_ShowHoldJudgmentMuliPlayerP32, Message_ShowHoldJudgmentMuliPlayerP32,
Message_SongChanged,
NUM_Message, // leave this at the end NUM_Message, // leave this at the end
Message_Invalid Message_Invalid
}; };
+11
View File
@@ -763,6 +763,8 @@ void ScreenEdit::Init()
this->HandleScreenMessage( SM_UpdateTextInfo ); this->HandleScreenMessage( SM_UpdateTextInfo );
m_bTextInfoNeedsUpdate = true; m_bTextInfoNeedsUpdate = true;
SubscribeToMessage( Message_SongChanged );
} }
ScreenEdit::~ScreenEdit() ScreenEdit::~ScreenEdit()
@@ -2365,6 +2367,15 @@ void ScreenEdit::ScrollTo( float fDestinationBeat )
m_soundChangeLine.Play(); m_soundChangeLine.Play();
} }
void ScreenEdit::HandleMessage( const RString &sMessage )
{
if( sMessage == MessageToString( Message_SongChanged ) )
{
SetDirty( true );
}
Screen::HandleMessage( sMessage );
}
static LocalizedString SAVE_SUCCESSFUL ( "ScreenEdit", "Save successful." ); static LocalizedString SAVE_SUCCESSFUL ( "ScreenEdit", "Save successful." );
void ScreenEdit::HandleScreenMessage( const ScreenMessage SM ) void ScreenEdit::HandleScreenMessage( const ScreenMessage SM )
+1
View File
@@ -177,6 +177,7 @@ public:
void InputRecord( const InputEventPlus &input, EditButton EditB ); void InputRecord( const InputEventPlus &input, EditButton EditB );
void InputRecordPaused( const InputEventPlus &input, EditButton EditB ); void InputRecordPaused( const InputEventPlus &input, EditButton EditB );
void InputPlay( const InputEventPlus &input, EditButton EditB ); void InputPlay( const InputEventPlus &input, EditButton EditB );
virtual void HandleMessage( const RString& sMessage );
virtual void HandleScreenMessage( const ScreenMessage SM ); virtual void HandleScreenMessage( const ScreenMessage SM );
void SetDirty( bool bDirty ) { m_bDirty = bDirty; } void SetDirty( bool bDirty ) { m_bDirty = bDirty; }