Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members

UnlockSystem.h

Go to the documentation of this file.
00001 /* UnlockSystem - Unlocks handling. */ 00002 00003 #ifndef UNLOCK_SYSTEM_H 00004 #define UNLOCK_SYSTEM_H 00005 00006 #include "Grade.h" 00007 #include <set> 00008 00009 class Song; 00010 class Profile; 00011 00012 enum UnlockType 00013 { 00014 UNLOCK_ARCADE_POINTS, 00015 UNLOCK_DANCE_POINTS, 00016 UNLOCK_SONG_POINTS, 00017 UNLOCK_EXTRA_CLEARED, 00018 UNLOCK_EXTRA_FAILED, 00019 UNLOCK_TOASTY, 00020 UNLOCK_CLEARED, 00021 NUM_UNLOCK_TYPES, 00022 UNLOCK_INVALID, 00023 }; 00024 00025 struct UnlockEntry 00026 { 00027 UnlockEntry(); 00028 00029 CString m_sSongName; 00030 00031 /* A cached pointer to the song or course this entry refers to. Only one of 00032 * these will be non-NULL. */ 00033 Song *m_pSong; 00034 Course *m_pCourse; 00035 00036 float m_fRequired[NUM_UNLOCK_TYPES]; 00037 int m_iCode; 00038 00039 bool IsCourse() const { return m_pCourse != NULL; } 00040 00041 bool IsLocked() const; 00042 }; 00043 00044 class UnlockSystem 00045 { 00046 friend struct UnlockEntry; 00047 00048 public: 00049 UnlockSystem(); 00050 00051 // returns # of points till next unlock - used for ScreenUnlock 00052 float PointsUntilNextUnlock( UnlockType t ) const; 00053 float ArcadePointsUntilNextUnlock() const { return PointsUntilNextUnlock(UNLOCK_ARCADE_POINTS); } 00054 float DancePointsUntilNextUnlock() const { return PointsUntilNextUnlock(UNLOCK_DANCE_POINTS); } 00055 float SongPointsUntilNextUnlock() const { return PointsUntilNextUnlock(UNLOCK_SONG_POINTS); } 00056 00057 // Used on select screens: 00058 bool SongIsLocked( const Song *song ) const; 00059 bool SongIsRouletteOnly( const Song *song ) const; 00060 bool CourseIsLocked( const Course *course ) const; 00061 00062 // Gets number of unlocks for title screen 00063 int GetNumUnlocks() const; 00064 00065 const UnlockEntry *FindLockEntry( CString lockname ) const; 00066 00067 void GetPoints( const Profile *pProfile, float fScores[NUM_UNLOCK_TYPES] ) const; 00068 00069 void UnlockCode( int num ); 00070 00071 // unlocks the song's code 00072 void UnlockSong( const Song *song ); 00073 00074 // All locked songs are stored here 00075 vector<UnlockEntry> m_SongEntries; 00076 00077 // If global song or course points change, call to update 00078 void UpdateSongs(); 00079 00080 private: 00081 // read unlocks 00082 bool Load(); 00083 00084 const UnlockEntry *FindSong( const Song *pSong ) const; 00085 const UnlockEntry *FindCourse( const Course *pCourse ) const; 00086 00087 set<int> m_RouletteCodes; // "codes" which are available in roulette and which unlock if rouletted 00088 }; 00089 00090 extern UnlockSystem* UNLOCKMAN; // global and accessable from anywhere in program 00091 00092 #endif 00093 00094 /* 00095 * (c) 2001-2004 Kevin Slaughter, Andrew Wong, Glenn Maynard 00096 * All rights reserved. 00097 * 00098 * Permission is hereby granted, free of charge, to any person obtaining a 00099 * copy of this software and associated documentation files (the 00100 * "Software"), to deal in the Software without restriction, including 00101 * without limitation the rights to use, copy, modify, merge, publish, 00102 * distribute, and/or sell copies of the Software, and to permit persons to 00103 * whom the Software is furnished to do so, provided that the above 00104 * copyright notice(s) and this permission notice appear in all copies of 00105 * the Software and that both the above copyright notice(s) and this 00106 * permission notice appear in supporting documentation. 00107 * 00108 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 00109 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00110 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF 00111 * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS 00112 * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT 00113 * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 00114 * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR 00115 * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 00116 * PERFORMANCE OF THIS SOFTWARE. 00117 */

Generated on Thu Jan 27 20:57:34 2005 for StepMania by doxygen 1.3.7