From 788f6e8126892a79ef31529a5472be53d72826a0 Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Thu, 8 Sep 2005 22:47:16 +0000 Subject: [PATCH] working on lesson mode --- stepmania/src/Makefile.am | 1 + stepmania/src/ScreenGameplayLesson.cpp | 161 +++++++++++++++++++++++++ stepmania/src/ScreenGameplayLesson.h | 53 ++++++++ stepmania/src/StepMania-net2003.vcproj | 6 + stepmania/src/StepMania.dsp | 12 +- stepmania/src/StepMania.vcproj | 6 + 6 files changed, 237 insertions(+), 2 deletions(-) create mode 100644 stepmania/src/ScreenGameplayLesson.cpp create mode 100644 stepmania/src/ScreenGameplayLesson.h diff --git a/stepmania/src/Makefile.am b/stepmania/src/Makefile.am index 5f7012936a..de94189100 100644 --- a/stepmania/src/Makefile.am +++ b/stepmania/src/Makefile.am @@ -36,6 +36,7 @@ ScreenExit.cpp ScreenExit.h ScreenNetEvaluation.cpp ScreenNetEvaluation.h \ ScreenNetSelectMusic.cpp ScreenNetSelectMusic.h ScreenNetSelectBase.cpp ScreenNetSelectBase.h ScreenNetRoom.cpp ScreenNetRoom.h \ ScreenEz2SelectMusic.cpp ScreenEz2SelectMusic.h ScreenEz2SelectPlayer.cpp ScreenEz2SelectPlayer.h \ ScreenGameplay.cpp ScreenGameplay.h \ +ScreenGameplayLesson.cpp ScreenGameplayLesson.h \ ScreenGameplayMultiplayer.cpp ScreenGameplayMultiplayer.h \ ScreenGameplayNormal.cpp ScreenGameplayNormal.h \ ScreenHowToPlay.cpp ScreenHowToPlay.h \ diff --git a/stepmania/src/ScreenGameplayLesson.cpp b/stepmania/src/ScreenGameplayLesson.cpp new file mode 100644 index 0000000000..73c0cb1135 --- /dev/null +++ b/stepmania/src/ScreenGameplayLesson.cpp @@ -0,0 +1,161 @@ +#include "global.h" +#include "ScreenGameplayLesson.h" +#include "RageLog.h" +#include "GameState.h" +#include "PrefsManager.h" + +REGISTER_SCREEN_CLASS( ScreenGameplayLesson ); +ScreenGameplayLesson::ScreenGameplayLesson( CString sName ) : ScreenGameplayNormal( sName ) +{ + LOG->Trace( "ScreenGameplayLesson::ScreenGameplayLesson()" ); + + m_iCurrentLessonPageIndex = 0; +} + +void ScreenGameplayLesson::Init() +{ + ASSERT( GAMESTATE->m_pCurStyle ); + ASSERT( GAMESTATE->m_pCurSong ); + + /* Now that we've set up, init the base class. */ + ScreenGameplay::Init(); + + ClearMessageQueue(); // remove all of the messages set in ScreenGameplay that animate "ready", "here we go", etc. + + GAMESTATE->m_bPastHereWeGo = true; + + m_DancingState = STATE_DANCING; + + + // Load lessons + Song *pSong = GAMESTATE->m_pCurSong; + CString sDir = pSong->GetSongDir(); + vector vs; + GetDirListing( sDir+"Page*", vs, true, true ); + m_vLessonPages.resize( vs.size() ); + FOREACH( CString, vs, s ) + { + int i = s - vs.begin(); + AutoActor &aa = m_vLessonPages[i]; + + + LUA->SetGlobal( "PageIndex", i ); + LUA->SetGlobal( "NumPages", (int)vs.size() ); + aa.Load( *s ); + LUA->UnsetGlobal( "PageIndex" ); + LUA->UnsetGlobal( "NumPages" ); + + + aa->SetDrawOrder( DRAW_ORDER_OVERLAY ); + this->AddChild( aa ); + } + + this->SortByDrawOrder(); + + // Show the first lesson page + if( !m_vLessonPages.empty() ) + { + AutoActor &aa = m_vLessonPages[0]; + aa->PlayCommand( "Show" ); + } + + FOREACH( AutoActor, m_vLessonPages, aa ) + (*aa)->PlayCommand( "On" ); +} + +void ScreenGameplayLesson::Input( const InputEventPlus &input ) +{ + //LOG->Trace( "ScreenGameplayLesson::Input()" ); + + if( m_iCurrentLessonPageIndex != -1 ) + { + // show a lesson page + Screen::Input( input ); + } + else + { + // in the "your turn" section" + ScreenGameplay::Input( input ); + } +} + +void ScreenGameplayLesson::HandleScreenMessage( const ScreenMessage SM ) +{ + if( SM == SM_NotesEnded ) + { + bool bShowingAPage = m_iCurrentLessonPageIndex != -1; + + if( bShowingAPage ) + { + // reload and loop + } + else + { + // show finish message if passed, loop if failed + } + } + + ScreenGameplay::HandleScreenMessage( SM ); +} + +void ScreenGameplayLesson::MenuStart( PlayerNumber pn ) +{ + if( m_iCurrentLessonPageIndex == -1 ) + return; + ChangeLessonPage( +1 ); +} + +void ScreenGameplayLesson::MenuBack( PlayerNumber pn ) +{ + if( m_iCurrentLessonPageIndex == -1 ) + return; + ChangeLessonPage( -1 ); +} + +void ScreenGameplayLesson::ChangeLessonPage( int iDir ) +{ + if( m_iCurrentLessonPageIndex + iDir < 0 ) + { + // don't change + return; + } + else if( m_iCurrentLessonPageIndex + iDir >= m_vLessonPages.size() ) + { + // dismissed the last page. Proceed to the "your turn" portion. + FOREACH( AutoActor, m_vLessonPages, aa ) + (*aa)->PlayCommand( "Off" ); + + m_iCurrentLessonPageIndex = -1; + } + else + { + m_vLessonPages[m_iCurrentLessonPageIndex]->PlayCommand( "Hide" ); + m_iCurrentLessonPageIndex += iDir; + m_vLessonPages[m_iCurrentLessonPageIndex]->PlayCommand( "Show" ); + } +} + +/* + * (c) 2003-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/ScreenGameplayLesson.h b/stepmania/src/ScreenGameplayLesson.h new file mode 100644 index 0000000000..0421fcf398 --- /dev/null +++ b/stepmania/src/ScreenGameplayLesson.h @@ -0,0 +1,53 @@ +/* ScreenGameplayLesson - Plays whole songs continuously. */ + +#ifndef ScreenGameplayLesson_H +#define ScreenGameplayLesson_H + +#include "ScreenGameplayNormal.h" +class CourseEntry; + +class ScreenGameplayLesson : public ScreenGameplayNormal +{ +public: + ScreenGameplayLesson( CString sName ); + virtual void Init(); + + virtual void Input( const InputEventPlus &input ); + virtual void HandleScreenMessage( const ScreenMessage SM ); + + virtual void MenuStart( PlayerNumber pn ); + virtual void MenuBack( PlayerNumber pn ); + +protected: + void ChangeLessonPage( int iDir ); + + vector m_vLessonPages; + int m_iCurrentLessonPageIndex; +}; + +#endif + +/* + * (c) 2003-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/StepMania-net2003.vcproj b/stepmania/src/StepMania-net2003.vcproj index f36ff1adce..b7786bb3ae 100644 --- a/stepmania/src/StepMania-net2003.vcproj +++ b/stepmania/src/StepMania-net2003.vcproj @@ -357,6 +357,12 @@ cl /Zl /nologo /c verstub.cpp /Fo"$(IntDir)"\ + + + + diff --git a/stepmania/src/StepMania.dsp b/stepmania/src/StepMania.dsp index 191a0fad2f..58c601c925 100644 --- a/stepmania/src/StepMania.dsp +++ b/stepmania/src/StepMania.dsp @@ -62,7 +62,7 @@ IntDir=.\../Debug6 TargetDir=\cvs\stepmania\Program TargetName=StepMania-debug SOURCE="$(InputPath)" -PreLink_Cmds=archutils\Win32\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\ +PreLink_Cmds=archutils\Win32\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\ PostBuild_Cmds=archutils\Win32\mapconv $(IntDir)\$(TargetName).map $(TargetDir)\StepMania.vdi # End Special Build Tool @@ -99,7 +99,7 @@ IntDir=.\../Release6 TargetDir=\cvs\stepmania\Program TargetName=StepMania SOURCE="$(InputPath)" -PreLink_Cmds=archutils\Win32\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\ +PreLink_Cmds=archutils\Win32\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\ PostBuild_Cmds=archutils\Win32\mapconv $(IntDir)\$(TargetName).map $(TargetDir)\StepMania.vdi # End Special Build Tool @@ -2668,6 +2668,14 @@ SOURCE=.\ScreenGameplay.h # End Source File # Begin Source File +SOURCE=.\ScreenGameplayLesson.cpp +# End Source File +# Begin Source File + +SOURCE=.\ScreenGameplayLesson.h +# End Source File +# Begin Source File + SOURCE=.\ScreenGameplayMultiplayer.cpp # End Source File # Begin Source File diff --git a/stepmania/src/StepMania.vcproj b/stepmania/src/StepMania.vcproj index a4ba707c78..92a99ebafd 100644 --- a/stepmania/src/StepMania.vcproj +++ b/stepmania/src/StepMania.vcproj @@ -1147,6 +1147,12 @@ cl /Zl /nologo /c verstub.cpp /Fo"$(IntDir)"\ + + + +