From 264dd13b45e3a866d525eb36f674a644c885f460 Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Tue, 8 Mar 2005 07:57:14 +0000 Subject: [PATCH] eliminate Save on ScreenEditMenu when creating new steps --- stepmania/Themes/default/metrics.ini | 5 +++ stepmania/src/NotesLoaderSM.cpp | 2 ++ stepmania/src/ScreenEdit.cpp | 25 ++++++++++++- stepmania/src/ScreenEditMenu.cpp | 52 ++++++++++++++++++++-------- stepmania/src/ScreenEditMenu.h | 4 +-- stepmania/src/ScreenSplash.cpp | 9 +++-- stepmania/src/ScreenSplash.h | 1 + stepmania/src/Song.cpp | 6 ++-- stepmania/src/Steps.cpp | 1 + stepmania/src/Steps.h | 3 ++ 10 files changed, 86 insertions(+), 22 deletions(-) diff --git a/stepmania/Themes/default/metrics.ini b/stepmania/Themes/default/metrics.ini index 95e7c585d2..868cb6f997 100644 --- a/stepmania/Themes/default/metrics.ini +++ b/stepmania/Themes/default/metrics.ini @@ -949,6 +949,7 @@ Class=ScreenSplash Fallback=ScreenWithMenuElements MinimumLoadDelaySeconds=2 AllowStartToSkip=0 +PrepareScreen=0 [ScreenStage] Class=ScreenStage @@ -4238,3 +4239,7 @@ ItemUseRateSeconds=0 [OptionRowHandler] StepsTypesToHide= + +[ScreenMemcardSaveEditsAfterDeleteSteps] + +[ScreenMemcardSaveEditsInEditor] diff --git a/stepmania/src/NotesLoaderSM.cpp b/stepmania/src/NotesLoaderSM.cpp index 48619603db..8685662468 100644 --- a/stepmania/src/NotesLoaderSM.cpp +++ b/stepmania/src/NotesLoaderSM.cpp @@ -21,6 +21,8 @@ void SMLoader::LoadFromSMTokens( Steps &out ) { + out.SetSavedToDisk( true ); // we're loading from disk, so this is by definintion already saved + TrimLeft(sStepsType); TrimRight(sStepsType); TrimLeft(sDescription); TrimRight(sDescription); TrimLeft(sDifficulty); TrimRight(sDifficulty); diff --git a/stepmania/src/ScreenEdit.cpp b/stepmania/src/ScreenEdit.cpp index 42e267e921..edcf4f7f57 100644 --- a/stepmania/src/ScreenEdit.cpp +++ b/stepmania/src/ScreenEdit.cpp @@ -30,6 +30,7 @@ #include "Style.h" #include "ActorUtil.h" #include "ScreenPrompt.h" +#include "CommonMetrics.h" const float RECORD_HOLD_SECONDS = 0.3f; @@ -1643,7 +1644,19 @@ void ScreenEdit::HandleScreenMessage( const ScreenMessage SM ) case SM_DoExit: if( ScreenPrompt::s_LastAnswer != ANSWER_CANCEL ) + { + // If these steps have never been saved, then we should delete them. + // If the user created them in the edit menu and never bothered + // to save them, then they aren't wanted. + Steps* pSteps = GAMESTATE->m_pCurSteps[PLAYER_1]; + if( !pSteps->GetSavedToDisk() ) + { + Song* pSong = GAMESTATE->m_pCurSong; + pSong->RemoveSteps( pSteps ); + } + m_Out.StartTransitioning( SM_GoToNextScreen ); + } break; case SM_GainFocus: @@ -1782,7 +1795,17 @@ void ScreenEdit::HandleMainMenuChoice( MainMenuChoice c, int* iAnswers ) ASSERT( pSteps ); pSteps->SetNoteData( m_NoteDataEdit ); - GAMESTATE->m_pCurSong->Save(); + pSteps->SetSavedToDisk( true ); + + if( HOME_EDIT_MODE ) + { + SCREENMAN->AddNewScreenToTop( "ScreenMemcardSaveEditsInEditor", SM_None ); + } + else + { + GAMESTATE->m_pCurSong->Save(); + SCREENMAN->ZeroNextUpdate(); + } // we shouldn't say we're saving a DWI if we're on any game besides // dance, it just looks tacky and people may be wondering where the diff --git a/stepmania/src/ScreenEditMenu.cpp b/stepmania/src/ScreenEditMenu.cpp index 48e715dc80..8791bf988f 100644 --- a/stepmania/src/ScreenEditMenu.cpp +++ b/stepmania/src/ScreenEditMenu.cpp @@ -105,6 +105,7 @@ void ScreenEditMenu::MenuRight( PlayerNumber pn, const InputEventType type ) } } +ScreenEditMenu *g_pScreenEditMenu = NULL; // helpers for MenuStart() below void DeleteCurSteps( void* pThrowAway ) @@ -112,7 +113,16 @@ void DeleteCurSteps( void* pThrowAway ) Song* pSong = GAMESTATE->m_pCurSong; Steps* pStepsToDelete = GAMESTATE->m_pCurSteps[PLAYER_1]; pSong->RemoveSteps( pStepsToDelete ); - pSong->Save(); + if( HOME_EDIT_MODE ) + { + SCREENMAN->AddNewScreenToTop( "ScreenMemcardSaveEditsAfterDeleteSteps", SM_None ); + } + else + { + pSong->Save(); + SCREENMAN->ZeroNextUpdate(); + } + g_pScreenEditMenu->m_Selector.RefreshAll(); } @@ -157,24 +167,19 @@ void ScreenEditMenu::MenuStart( PlayerNumber pn ) if( !pSong->HasMusic() ) { - SCREENMAN->Prompt( SM_None, "This song is missing a music file\nand cannot be edited" ); + SCREENMAN->Prompt( SM_None, "This song is missing a music file and cannot be edited" ); return; } switch( action ) { case EDIT_MENU_ACTION_EDIT: - // Prepare prepare for ScreenEdit - ASSERT( pSteps ); - SOUND->StopMusic(); - SCREENMAN->PlayStartSound(); - StartTransitioning( SM_GoToNextScreen ); break; case EDIT_MENU_ACTION_DELETE: ASSERT( pSteps ); SCREENMAN->Prompt( SM_RefreshSelector, "These steps will be lost permanently.\n\nContinue with delete?", PROMPT_YES_NO, ANSWER_NO, DeleteCurSteps ); - m_Selector.RefreshAll(); - return; + g_pScreenEditMenu = this; + break; case EDIT_MENU_ACTION_COPY: case EDIT_MENU_ACTION_AUTOGEN: ASSERT( !pSteps ); @@ -203,14 +208,13 @@ void ScreenEditMenu::MenuStart( PlayerNumber pn ) SCREENMAN->SystemMessage( "Steps created from AutoGen." ); SOUND->PlayOnce( THEME->GetPathS(m_sName,"create") ); - pSong->Save(); GAMESTATE->m_pCurSong.Set( pSong ); GAMESTATE->m_pCurSteps[0].Set( pNewSteps ); m_Selector.RefreshAll(); } - return; + break; case EDIT_MENU_ACTION_BLANK: ASSERT( !pSteps ); { @@ -228,14 +232,34 @@ void ScreenEditMenu::MenuStart( PlayerNumber pn ) SCREENMAN->SystemMessage( "Blank Steps created." ); SOUND->PlayOnce( THEME->GetPathS(m_sName,"create") ); m_Selector.RefreshAll(); - pSong->Save(); GAMESTATE->m_pCurSong.Set( pSong ); GAMESTATE->m_pCurSteps[0].Set( pNewSteps ); m_Selector.RefreshAll(); } - return; + break; + default: + ASSERT(0); + } + + + pSteps = m_Selector.GetSelectedSteps(); + + switch( action ) + { + case EDIT_MENU_ACTION_EDIT: + case EDIT_MENU_ACTION_COPY: + case EDIT_MENU_ACTION_AUTOGEN: + case EDIT_MENU_ACTION_BLANK: + // Prepare prepare for ScreenEdit + ASSERT( pSteps ); + SOUND->StopMusic(); + SCREENMAN->PlayStartSound(); + StartTransitioning( SM_GoToNextScreen ); + break; + case EDIT_MENU_ACTION_DELETE: + break; default: ASSERT(0); } @@ -257,7 +281,7 @@ void ScreenEditMenu::RefreshExplanationText() void ScreenEditMenu::RefreshNumStepsLoadedFromProfile() { - CString s = ssprintf( "edits loaded: %d", SONGMAN->GetNumStepsLoadedFromProfile() ); + CString s = ssprintf( "edits used: %d", SONGMAN->GetNumStepsLoadedFromProfile() ); int iMaxStepsLoadedFromProfile = MAX_STEPS_LOADED_FROM_PROFILE; if( iMaxStepsLoadedFromProfile != -1 ) s += ssprintf( " / %d", iMaxStepsLoadedFromProfile ); diff --git a/stepmania/src/ScreenEditMenu.h b/stepmania/src/ScreenEditMenu.h index 7ff7345a9c..7dea7318f5 100644 --- a/stepmania/src/ScreenEditMenu.h +++ b/stepmania/src/ScreenEditMenu.h @@ -24,9 +24,9 @@ private: void RefreshExplanationText(); void RefreshNumStepsLoadedFromProfile(); - +public: EditMenu m_Selector; - +private: BitmapText m_textExplanation; BitmapText m_textNumStepsLoadedFromProfile; }; diff --git a/stepmania/src/ScreenSplash.cpp b/stepmania/src/ScreenSplash.cpp index 2c6e3df114..fd08ce8b44 100644 --- a/stepmania/src/ScreenSplash.cpp +++ b/stepmania/src/ScreenSplash.cpp @@ -8,6 +8,7 @@ const ScreenMessage SM_PrepScreen = (ScreenMessage)(SM_User+0); REGISTER_SCREEN_CLASS( ScreenSplash ); ScreenSplash::ScreenSplash( CString sClassName ) : ScreenWithMenuElements( sClassName ), + PREPARE_SCREEN (m_sName,"PrepareScreen"), ALLOW_START_TO_SKIP (m_sName,"AllowStartToSkip"), NEXT_SCREEN (m_sName,"NextScreen"), PREV_SCREEN (m_sName,"PrevScreen"), @@ -30,7 +31,8 @@ void ScreenSplash::HandleScreenMessage( const ScreenMessage SM ) case SM_PrepScreen: { RageTimer length; - SCREENMAN->PrepareScreen( NEXT_SCREEN ); + if( PREPARE_SCREEN ) + SCREENMAN->PrepareScreen( NEXT_SCREEN ); float fScreenLoadSeconds = length.GetDeltaTime(); /* The screen load took fScreenLoadSeconds. Move on to the next screen after @@ -42,7 +44,10 @@ void ScreenSplash::HandleScreenMessage( const ScreenMessage SM ) StartTransitioning( SM_GoToNextScreen ); break; case SM_GoToNextScreen: - SCREENMAN->SetNewScreen( NEXT_SCREEN ); + if( SCREENMAN->IsStackedScreen(SCREENMAN->GetTopScreen()) ) + SCREENMAN->PopTopScreen(); + else + SCREENMAN->SetNewScreen( NEXT_SCREEN ); break; case SM_GoToPrevScreen: SCREENMAN->DeletePreparedScreens(); diff --git a/stepmania/src/ScreenSplash.h b/stepmania/src/ScreenSplash.h index 3ed168b568..84fd1e6851 100644 --- a/stepmania/src/ScreenSplash.h +++ b/stepmania/src/ScreenSplash.h @@ -21,6 +21,7 @@ protected: ThemeMetric NEXT_SCREEN; ThemeMetric PREV_SCREEN; ThemeMetric MINIMUM_LOAD_DELAY_SECONDS; + ThemeMetric PREPARE_SCREEN; }; #endif diff --git a/stepmania/src/Song.cpp b/stepmania/src/Song.cpp index e9d49632b8..f5dc50fc3d 100644 --- a/stepmania/src/Song.cpp +++ b/stepmania/src/Song.cpp @@ -265,13 +265,13 @@ bool Song::LoadFromSongDir( CString sDir ) - for( unsigned i=0; iSetFile( GetCacheFilePath() ); + (*s)->SetFile( GetCacheFilePath() ); /* Compress all Steps. During initial caching, this will remove cached NoteData; * during cached loads, this will just remove cached SMData. */ - m_vpSteps[i]->Compress(); + (*s)->Compress(); } /* Load the cached banners, if it's not loaded already. */ diff --git a/stepmania/src/Steps.cpp b/stepmania/src/Steps.cpp index 483d000ea5..5b0d42a816 100644 --- a/stepmania/src/Steps.cpp +++ b/stepmania/src/Steps.cpp @@ -33,6 +33,7 @@ Steps::Steps() { + m_bSavedToDisk = false; m_StepsType = STEPS_TYPE_INVALID; m_LoadedFromProfile = PROFILE_SLOT_INVALID; m_uHash = 0; diff --git a/stepmania/src/Steps.h b/stepmania/src/Steps.h index 484b746e51..316307fe79 100644 --- a/stepmania/src/Steps.h +++ b/stepmania/src/Steps.h @@ -41,6 +41,8 @@ public: const RadarValues& GetRadarValues() const { return Real()->m_RadarValues; } void SetFile( CString fn ); + void SetSavedToDisk( bool b ) { m_bSavedToDisk = b; } + bool GetSavedToDisk() { return m_bSavedToDisk; } void SetDescription(CString desc); static bool MakeValidDescription( CString &sPreferredDescription ); // return true if was modified @@ -77,6 +79,7 @@ protected: const Steps *Real() const; CString m_sFilename; + bool m_bSavedToDisk; // true if this was loaded from disk or has been saved to disk. /* These values are pulled from the autogen source first, if there is one. */ ProfileSlot m_LoadedFromProfile; // PROFILE_SLOT_INVALID if wasn't loaded from a profile