From e99daa073afdd54fb798c50ab35999d951e5be46 Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Mon, 30 Jan 2006 08:13:16 +0000 Subject: [PATCH] add simple unlock screens --- stepmania/src/Makefile.am | 2 + stepmania/src/ScreenUnlockBrowse.cpp | 55 +++++++++++++++++++++ stepmania/src/ScreenUnlockBrowse.h | 39 +++++++++++++++ stepmania/src/ScreenUnlockCelebrate.cpp | 65 +++++++++++++++++++++++++ stepmania/src/ScreenUnlockCelebrate.h | 43 ++++++++++++++++ stepmania/src/StepMania-net2003.vcproj | 12 +++++ stepmania/src/StepMania.dsp | 28 +++++++---- stepmania/src/UnlockManager.cpp | 45 +++++++++++++++-- stepmania/src/UnlockManager.h | 5 ++ 9 files changed, 279 insertions(+), 15 deletions(-) create mode 100644 stepmania/src/ScreenUnlockBrowse.cpp create mode 100644 stepmania/src/ScreenUnlockBrowse.h create mode 100644 stepmania/src/ScreenUnlockCelebrate.cpp create mode 100644 stepmania/src/ScreenUnlockCelebrate.h diff --git a/stepmania/src/Makefile.am b/stepmania/src/Makefile.am index f57ae521f1..080f07e8ce 100644 --- a/stepmania/src/Makefile.am +++ b/stepmania/src/Makefile.am @@ -76,6 +76,8 @@ ScreenStage.cpp ScreenStage.h \ ScreenTest.cpp ScreenTest.h ScreenTestFonts.cpp ScreenTestFonts.h ScreenTestInput.cpp ScreenTestInput.h \ ScreenTestLights.cpp ScreenTestLights.h ScreenTestSound.cpp ScreenTestSound.h ScreenTextEntry.cpp ScreenTextEntry.h \ ScreenTitleMenu.cpp ScreenTitleMenu.h \ +ScreenUnlockBrowse.cpp ScreenUnlockBrowse.h \ +ScreenUnlockCelebrate.cpp ScreenUnlockCelebrate.h \ ScreenUnlockStatus.cpp ScreenUnlockStatus.h \ ScreenWithMenuElements.cpp ScreenWithMenuElements.h diff --git a/stepmania/src/ScreenUnlockBrowse.cpp b/stepmania/src/ScreenUnlockBrowse.cpp new file mode 100644 index 0000000000..071fd4c1ec --- /dev/null +++ b/stepmania/src/ScreenUnlockBrowse.cpp @@ -0,0 +1,55 @@ +#include "global.h" +#include "ScreenUnlockBrowse.h" +#include "UnlockManager.h" + + +REGISTER_SCREEN_CLASS( ScreenUnlockBrowse ); + +void ScreenUnlockBrowse::Init() +{ + // fill m_aGameCommands before calling Init() + FOREACH_CONST( UnlockEntry, UNLOCKMAN->m_UnlockEntries, ue ) + { + GameCommand gc; + if( !ue->IsLocked() ) + gc.m_bInvalid = false; + gc.m_iIndex = ue - UNLOCKMAN->m_UnlockEntries.begin(); + gc.m_iUnlockEntryID = ue->m_iEntryID; + gc.m_sName = ssprintf("%d",ue->m_iEntryID); + + m_aGameCommands.push_back( gc ); + } + + ScreenSelectMaster::Init(); +} + +void ScreenUnlockBrowse::MenuStart( PlayerNumber pn ) +{ + this->PostScreenMessage( SM_BeginFadingOut, 0 ); +} + + +/* + * (c) 2006 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/ScreenUnlockBrowse.h b/stepmania/src/ScreenUnlockBrowse.h new file mode 100644 index 0000000000..073f583bbc --- /dev/null +++ b/stepmania/src/ScreenUnlockBrowse.h @@ -0,0 +1,39 @@ +#ifndef ScreenUnlockBrowse_H +#define ScreenUnlockBrowse_H + +#include "ScreenSelectMaster.h" + +class ScreenUnlockBrowse : public ScreenSelectMaster +{ +public: + virtual void Init(); + virtual void MenuStart( PlayerNumber pn ); +protected: +}; + +#endif + +/* + * (c) 2006 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/ScreenUnlockCelebrate.cpp b/stepmania/src/ScreenUnlockCelebrate.cpp new file mode 100644 index 0000000000..6ebf124a83 --- /dev/null +++ b/stepmania/src/ScreenUnlockCelebrate.cpp @@ -0,0 +1,65 @@ +#include "global.h" +#include "ScreenUnlockCelebrate.h" +#include "UnlockManager.h" + + +REGISTER_SCREEN_CLASS( ScreenUnlockCelebrate ); + +void ScreenUnlockCelebrate::Init() +{ + // We shouldn't be called if there aren't any unlocks to celebrate + ASSERT( UNLOCKMAN->AnyUnlocksToCelebrate() ); + + ScreenUnlockBrowse::Init(); + + // Mark this unlock as celebrated + int iIndex = UNLOCKMAN->GetUnlockIndexToCelebrate(); + UNLOCKMAN->m_UnlockEntries[iIndex].m_bCelebrated = true; +} + +void ScreenUnlockCelebrate::MenuLeft( const InputEventPlus &input ) +{ +} + +void ScreenUnlockCelebrate::MenuRight( const InputEventPlus &input ) +{ +} + +void ScreenUnlockCelebrate::MenuUp( const InputEventPlus &input ) +{ +} + +void ScreenUnlockCelebrate::MenuDown( const InputEventPlus &input ) +{ +} + +void ScreenUnlockCelebrate::MenuBack( PlayerNumber pn ) +{ + this->MenuStart(pn); +} + + +/* + * (c) 2006 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/ScreenUnlockCelebrate.h b/stepmania/src/ScreenUnlockCelebrate.h new file mode 100644 index 0000000000..82232eb496 --- /dev/null +++ b/stepmania/src/ScreenUnlockCelebrate.h @@ -0,0 +1,43 @@ +#ifndef ScreenUnlockCelebrate_H +#define ScreenUnlockCelebrate_H + +#include "ScreenUnlockBrowse.h" + +class ScreenUnlockCelebrate : public ScreenUnlockBrowse +{ +public: + virtual void Init(); + virtual void MenuLeft( const InputEventPlus &input ); + virtual void MenuRight( const InputEventPlus &input ); + virtual void MenuUp( const InputEventPlus &input ); + virtual void MenuDown( const InputEventPlus &input ); + virtual void MenuBack( PlayerNumber pn ); +protected: +}; + +#endif + +/* + * (c) 2006 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 3e7ea4ff3c..21a958d3e2 100644 --- a/stepmania/src/StepMania-net2003.vcproj +++ b/stepmania/src/StepMania-net2003.vcproj @@ -709,6 +709,18 @@ cl /Zl /nologo /c verstub.cpp /Fo"$(IntDir)"\ + + + + + + + + diff --git a/stepmania/src/StepMania.dsp b/stepmania/src/StepMania.dsp index c3af68b2c5..61aa1cbb80 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 @@ -448,14 +448,6 @@ SOURCE=.\RageSoundReader_WAV.h # End Source File # Begin Source File -SOURCE=.\RageSoundResampler.cpp -# End Source File -# Begin Source File - -SOURCE=.\RageSoundResampler.h -# End Source File -# Begin Source File - SOURCE=.\RageSoundUtil.cpp # End Source File # Begin Source File @@ -3244,6 +3236,22 @@ SOURCE=.\ScreenTitleMenu.h # End Source File # Begin Source File +SOURCE=.\ScreenUnlockBrowse.cpp +# End Source File +# Begin Source File + +SOURCE=.\ScreenUnlockBrowse.h +# End Source File +# Begin Source File + +SOURCE=.\ScreenUnlockCelebrate.cpp +# End Source File +# Begin Source File + +SOURCE=.\ScreenUnlockCelebrate.h +# End Source File +# Begin Source File + SOURCE=.\ScreenUnlockStatus.cpp # End Source File # Begin Source File diff --git a/stepmania/src/UnlockManager.cpp b/stepmania/src/UnlockManager.cpp index 8ade4539f1..9ca0fc20d0 100644 --- a/stepmania/src/UnlockManager.cpp +++ b/stepmania/src/UnlockManager.cpp @@ -427,6 +427,10 @@ void UnlockManager::Load() if( bRoulette ) m_RouletteCodes.insert( current.m_iEntryID ); + // TODO: Persist celebrated info? + if( !current.IsLocked() ) + current.m_bCelebrated = false; + m_UnlockEntries.push_back( current ); } @@ -540,6 +544,31 @@ int UnlockManager::GetNumUnlocks() const return m_UnlockEntries.size(); } +bool UnlockManager::AllAreLocked() const +{ + FOREACH_CONST( UnlockEntry, m_UnlockEntries, ue ) + { + if( !ue->IsLocked() ) + return false; + } + return true; +} + +int UnlockManager::GetUnlockIndexToCelebrate() const +{ + FOREACH_CONST( UnlockEntry, m_UnlockEntries, ue ) + { + if( !ue->IsLocked() && !ue->m_bCelebrated ) + return ue - m_UnlockEntries.begin(); + } + return -1; +} + +bool UnlockManager::AnyUnlocksToCelebrate() const +{ + return GetUnlockIndexToCelebrate() != -1; +} + void UnlockManager::GetUnlocksByType( UnlockRewardType t, vector &apEntries ) { for( unsigned i = 0; i < m_UnlockEntries.size(); ++i ) @@ -604,11 +633,14 @@ class LunaUnlockManager: public Luna public: LunaUnlockManager() { LUA->Register( Register ); } - static int FindEntryID( T* p, lua_State *L ) { RString sName = SArg(1); int i = p->FindEntryID(sName); if( i == -1 ) lua_pushnil(L); else lua_pushnumber(L, i); return 1; } - static int UnlockEntryID( T* p, lua_State *L ) { int iUnlockEntryID = IArg(1); p->UnlockEntryID(iUnlockEntryID); return 0; } - static int PreferUnlockEntryID( T* p, lua_State *L ) { int iUnlockEntryID = IArg(1); p->PreferUnlockEntryID(iUnlockEntryID); return 0; } - static int GetNumUnlocks( T* p, lua_State *L ) { lua_pushnumber( L, p->GetNumUnlocks() ); return 1; } - static int GetUnlockEntry( T* p, lua_State *L ) { int iIndex = IArg(1); p->m_UnlockEntries[iIndex].PushSelf(L); return 1; } + static int FindEntryID( T* p, lua_State *L ) { RString sName = SArg(1); int i = p->FindEntryID(sName); if( i == -1 ) lua_pushnil(L); else lua_pushnumber(L, i); return 1; } + static int UnlockEntryID( T* p, lua_State *L ) { int iUnlockEntryID = IArg(1); p->UnlockEntryID(iUnlockEntryID); return 0; } + static int PreferUnlockEntryID( T* p, lua_State *L ) { int iUnlockEntryID = IArg(1); p->PreferUnlockEntryID(iUnlockEntryID); return 0; } + static int GetNumUnlocks( T* p, lua_State *L ) { lua_pushnumber( L, p->GetNumUnlocks() ); return 1; } + static int AllAreLocked( T* p, lua_State *L ) { lua_pushboolean( L, p->AllAreLocked() ); return 1; } + static int GetUnlockIndexToCelebrate( T* p, lua_State *L ) { lua_pushnumber( L, p->GetUnlockIndexToCelebrate() ); return 1; } + static int AnyUnlocksToCelebrate( T* p, lua_State *L ) { lua_pushboolean( L, p->AnyUnlocksToCelebrate() ); return 1; } + static int GetUnlockEntry( T* p, lua_State *L ) { int iIndex = IArg(1); p->m_UnlockEntries[iIndex].PushSelf(L); return 1; } static int GetSongsUnlockedByEntryID( T* p, lua_State *L ) { vector apSongs; @@ -634,6 +666,9 @@ public: ADD_METHOD( UnlockEntryID ); ADD_METHOD( PreferUnlockEntryID ); ADD_METHOD( GetNumUnlocks ); + ADD_METHOD( AllAreLocked ); + ADD_METHOD( GetUnlockIndexToCelebrate ); + ADD_METHOD( AnyUnlocksToCelebrate ); ADD_METHOD( GetUnlockEntry ); ADD_METHOD( GetSongsUnlockedByEntryID ); ADD_METHOD( GetStepsUnlockedByEntryID ); diff --git a/stepmania/src/UnlockManager.h b/stepmania/src/UnlockManager.h index 3f8495dcaa..48c90fd92e 100644 --- a/stepmania/src/UnlockManager.h +++ b/stepmania/src/UnlockManager.h @@ -53,6 +53,7 @@ public: ZERO( m_fRequirement ); m_iEntryID = -1; + m_bCelebrated = false; } UnlockRewardType m_Type; @@ -66,6 +67,7 @@ public: float m_fRequirement[NUM_UnlockRequirement]; int m_iEntryID; + bool m_bCelebrated; bool IsValid() const; bool IsLocked() const; @@ -100,6 +102,9 @@ public: // Gets number of unlocks for title screen int GetNumUnlocks() const; + bool AllAreLocked() const; + int GetUnlockIndexToCelebrate() const; + bool AnyUnlocksToCelebrate() const; void GetPoints( const Profile *pProfile, float fScores[NUM_UnlockRequirement] ) const;