From ae1bf0dcd88473541dccc106b53319106b984169 Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Sat, 4 Feb 2006 18:39:37 +0000 Subject: [PATCH] add ScreenGameplaySyncMachine --- stepmania/src/Makefile.am | 1 + stepmania/src/ScreenGameplaySyncMachine.cpp | 87 +++++++++++++++++++ stepmania/src/ScreenGameplaySyncMachine.h | 45 ++++++++++ stepmania/src/ScreenSaveSync.cpp | 94 +++++++++++---------- stepmania/src/StepMania-net2003.vcproj | 6 ++ stepmania/src/StepMania.dsp | 8 ++ stepmania/src/ThemeManager.cpp | 1 - stepmania/src/song.h | 5 +- 8 files changed, 198 insertions(+), 49 deletions(-) create mode 100644 stepmania/src/ScreenGameplaySyncMachine.cpp create mode 100644 stepmania/src/ScreenGameplaySyncMachine.h diff --git a/stepmania/src/Makefile.am b/stepmania/src/Makefile.am index fe1e914fb7..ab1ecf1f20 100644 --- a/stepmania/src/Makefile.am +++ b/stepmania/src/Makefile.am @@ -39,6 +39,7 @@ ScreenGameplay.cpp ScreenGameplay.h \ ScreenGameplayLesson.cpp ScreenGameplayLesson.h \ ScreenGameplayMultiplayer.cpp ScreenGameplayMultiplayer.h \ ScreenGameplayNormal.cpp ScreenGameplayNormal.h \ +ScreenGameplaySyncMachine.cpp ScreenGameplaySyncMachine.h \ ScreenHowToPlay.cpp ScreenHowToPlay.h \ ScreenInstructions.cpp ScreenInstructions.h \ ScreenJoinMultiplayer.cpp ScreenJoinMultiplayer.h \ diff --git a/stepmania/src/ScreenGameplaySyncMachine.cpp b/stepmania/src/ScreenGameplaySyncMachine.cpp new file mode 100644 index 0000000000..2d8b9040c0 --- /dev/null +++ b/stepmania/src/ScreenGameplaySyncMachine.cpp @@ -0,0 +1,87 @@ +#include "global.h" +#include "ScreenGameplaySyncMachine.h" +#include "NotesLoaderSM.h" +#include "GameState.h" +#include "GameManager.h" +#include "PrefsManager.h" + +REGISTER_SCREEN_CLASS( ScreenGameplaySyncMachine ); + +void ScreenGameplaySyncMachine::Init() +{ + GAMESTATE->m_PlayMode.Set( PLAY_MODE_REGULAR ); + GAMESTATE->m_pCurStyle.Set( GAMEMAN->GetHowToPlayStyleForGame(GAMESTATE->m_pCurGame) ); + + SMLoader ld; + RString sFile = THEME->GetPathO("ScreenGameplaySyncMachine","music.sm"); + ld.LoadFromSMFile( sFile, m_Song ); + m_Song.SetSongDir( Dirname(sFile) ); + m_Song.TidyUpData(); + + GAMESTATE->m_pCurSong.Set( &m_Song ); + Steps *pSteps = m_Song.GetOneSteps(); + ASSERT( pSteps ); + GAMESTATE->m_pCurSteps[0].Set( pSteps ); + + GAMESTATE->m_SongOptions.m_AutosyncType = SongOptions::AUTOSYNC_MACHINE; + PREFSMAN->m_AutoPlay.Set( PC_HUMAN ); + + ScreenGameplayNormal::Init( false ); + + ClearMessageQueue(); // remove all of the messages set in ScreenGameplay that animate "ready", "here we go", etc. + + GAMESTATE->m_bGameplayLeadIn.Set( false ); + + m_DancingState = STATE_DANCING; +} + +void ScreenGameplaySyncMachine::HandleScreenMessage( const ScreenMessage SM ) +{ + if( SM == SM_NotesEnded ) + { + ResetAndRestartCurrentSong(); + return; // handled + } + else if( SM == SM_GoToPrevScreen ) + { + GAMESTATE->m_pCurSong.Set( NULL ); + } + else if( SM == SM_GoToNextScreen ) + { + GAMESTATE->m_pCurSong.Set( NULL ); + } + + ScreenGameplayNormal::HandleScreenMessage( SM ); +} + +void ScreenGameplaySyncMachine::ResetAndRestartCurrentSong() +{ + m_pSoundMusic->Stop(); + ReloadCurrentSong(); + StartPlayingSong( 4, 0 ); +} + +/* + * (c) 2001-2004 Chris Danford + * All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, and/or sell copies of the Software, and to permit persons to + * whom the Software is furnished to do so, provided that the above + * copyright notice(s) and this permission notice appear in all copies of + * the Software and that both the above copyright notice(s) and this + * permission notice appear in supporting documentation. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT + * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS + * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ diff --git a/stepmania/src/ScreenGameplaySyncMachine.h b/stepmania/src/ScreenGameplaySyncMachine.h new file mode 100644 index 0000000000..69049e6a86 --- /dev/null +++ b/stepmania/src/ScreenGameplaySyncMachine.h @@ -0,0 +1,45 @@ +/* ScreenGameplaySyncMachine - */ + +#ifndef ScreenGameplaySyncMachine_H +#define ScreenGameplaySyncMachine_H + +#include "ScreenGameplayNormal.h" + +class ScreenGameplaySyncMachine : public ScreenGameplayNormal +{ +public: + virtual void Init(); + + void HandleScreenMessage( const ScreenMessage SM ); + void ResetAndRestartCurrentSong(); +protected: + Song m_Song; + const Steps *m_pSteps; +}; + +#endif + +/* + * (c) 2001-2004 Chris Danford + * All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, and/or sell copies of the Software, and to permit persons to + * whom the Software is furnished to do so, provided that the above + * copyright notice(s) and this permission notice appear in all copies of + * the Software and that both the above copyright notice(s) and this + * permission notice appear in supporting documentation. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT + * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS + * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ diff --git a/stepmania/src/ScreenSaveSync.cpp b/stepmania/src/ScreenSaveSync.cpp index 94d138801c..f9ae675753 100644 --- a/stepmania/src/ScreenSaveSync.cpp +++ b/stepmania/src/ScreenSaveSync.cpp @@ -37,57 +37,59 @@ static RString GetPromptText() vector vsSongChanges; + if( GAMESTATE->m_pCurSong.Get() ) { - float fOld = GAMESTATE->m_pTimingDataOriginal->m_fBeat0OffsetInSeconds; - float fNew = GAMESTATE->m_pCurSong->m_Timing.m_fBeat0OffsetInSeconds; - float fDelta = fNew - fOld; - - if( fabs(fDelta) > 0.00001 ) { - vsSongChanges.push_back( ssprintf( - CHANGED_SONG_OFFSET.GetValue()+"\n\n", - fOld, - fNew, - fDelta, - (fDelta > 0 ? EARLIER:LATER).GetValue().c_str() ) ); + float fOld = GAMESTATE->m_pTimingDataOriginal->m_fBeat0OffsetInSeconds; + float fNew = GAMESTATE->m_pCurSong->m_Timing.m_fBeat0OffsetInSeconds; + float fDelta = fNew - fOld; + + if( fabs(fDelta) > 0.00001 ) + { + vsSongChanges.push_back( ssprintf( + CHANGED_SONG_OFFSET.GetValue()+"\n\n", + fOld, + fNew, + fDelta, + (fDelta > 0 ? EARLIER:LATER).GetValue().c_str() ) ); + } + } + + for( unsigned i=0; im_pCurSong->m_Timing.m_BPMSegments.size(); i++ ) + { + float fOld = GAMESTATE->m_pTimingDataOriginal->m_BPMSegments[i].m_fBPS; + float fNew = GAMESTATE->m_pCurSong->m_Timing.m_BPMSegments[i].m_fBPS; + float fDelta = fNew - fOld; + + if( fabs(fDelta) > 0.00001 ) + { + vsSongChanges.push_back( ssprintf( + CHANGED_BPM.GetValue()+"\n\n", + i+1, + fOld, + fNew, + fDelta ) ); + } + } + + for( unsigned i=0; im_pCurSong->m_Timing.m_StopSegments.size(); i++ ) + { + float fOld = GAMESTATE->m_pTimingDataOriginal->m_StopSegments[i].m_fStopSeconds; + float fNew = GAMESTATE->m_pCurSong->m_Timing.m_StopSegments[i].m_fStopSeconds; + float fDelta = fNew - fOld; + + if( fabs(fDelta) > 0.00001 ) + { + vsSongChanges.push_back( ssprintf( + CHANGED_STOP.GetValue()+"\n\n", + i+1, + fOld, + fNew, + fDelta ) ); + } } } - for( unsigned i=0; im_pCurSong->m_Timing.m_BPMSegments.size(); i++ ) - { - float fOld = GAMESTATE->m_pTimingDataOriginal->m_BPMSegments[i].m_fBPS; - float fNew = GAMESTATE->m_pCurSong->m_Timing.m_BPMSegments[i].m_fBPS; - float fDelta = fNew - fOld; - - if( fabs(fDelta) > 0.00001 ) - { - vsSongChanges.push_back( ssprintf( - CHANGED_BPM.GetValue()+"\n\n", - i+1, - fOld, - fNew, - fDelta ) ); - } - } - - for( unsigned i=0; im_pCurSong->m_Timing.m_StopSegments.size(); i++ ) - { - float fOld = GAMESTATE->m_pTimingDataOriginal->m_StopSegments[i].m_fStopSeconds; - float fNew = GAMESTATE->m_pCurSong->m_Timing.m_StopSegments[i].m_fStopSeconds; - float fDelta = fNew - fOld; - - if( fabs(fDelta) > 0.00001 ) - { - vsSongChanges.push_back( ssprintf( - CHANGED_STOP.GetValue()+"\n\n", - i+1, - fOld, - fNew, - fDelta ) ); - } - } - - if( !vsSongChanges.empty() ) { s += ssprintf( diff --git a/stepmania/src/StepMania-net2003.vcproj b/stepmania/src/StepMania-net2003.vcproj index 9bab08082b..fc78c9e390 100644 --- a/stepmania/src/StepMania-net2003.vcproj +++ b/stepmania/src/StepMania-net2003.vcproj @@ -373,6 +373,12 @@ cl /Zl /nologo /c verstub.cpp /Fo"$(IntDir)"\ + + + + diff --git a/stepmania/src/StepMania.dsp b/stepmania/src/StepMania.dsp index 0d1f40251f..65b9b65aed 100644 --- a/stepmania/src/StepMania.dsp +++ b/stepmania/src/StepMania.dsp @@ -2788,6 +2788,14 @@ SOURCE=.\ScreenGameplayNormal.h # End Source File # Begin Source File +SOURCE=.\ScreenGameplaySyncMachine.cpp +# End Source File +# Begin Source File + +SOURCE=.\ScreenGameplaySyncMachine.h +# End Source File +# Begin Source File + SOURCE=.\ScreenHowToPlay.cpp # End Source File # Begin Source File diff --git a/stepmania/src/ThemeManager.cpp b/stepmania/src/ThemeManager.cpp index 9fd1fb9065..7809c4c264 100644 --- a/stepmania/src/ThemeManager.cpp +++ b/stepmania/src/ThemeManager.cpp @@ -23,7 +23,6 @@ #include "SpecialFiles.h" #include "EnumHelper.h" - ThemeManager* THEME = NULL; // global object accessable from anywhere in the program static const char *ElementCategoryNames[] = { diff --git a/stepmania/src/song.h b/stepmania/src/song.h index c67458500f..f50d5a0db2 100644 --- a/stepmania/src/song.h +++ b/stepmania/src/song.h @@ -19,7 +19,7 @@ struct lua_State; struct BackgroundChange; const int MAX_EDITS_PER_SONG_PER_PROFILE = 5; -const int MAX_EDITS_PER_SONG = 5*NUM_ProfileSlot; +const int MAX_EDITS_PER_SONG = 5*NUM_ProfileSlot; extern const int FILE_CACHE_VERSION; @@ -42,8 +42,9 @@ struct LyricSegment class Song { RString m_sSongDir; - public: + void SetSongDir( const RString sDir ) { m_sSongDir = sDir; } + /* Set when this song should be displayed in the music wheel: */ enum SelectionDisplay {