Files
itgmania212121/stepmania/src/UnlockSystem.h
T

118 lines
3.5 KiB
C++
Raw Normal View History

2004-06-08 01:24:17 +00:00
/* UnlockSystem - Unlocks handling. */
#ifndef UNLOCK_SYSTEM_H
#define UNLOCK_SYSTEM_H
#include "Grade.h"
2004-01-25 16:24:34 +00:00
#include <set>
2003-07-09 04:46:24 +00:00
class Song;
class Profile;
2003-07-09 04:46:24 +00:00
2004-01-24 23:40:40 +00:00
enum UnlockType
{
UNLOCK_ARCADE_POINTS,
UNLOCK_DANCE_POINTS,
UNLOCK_SONG_POINTS,
UNLOCK_EXTRA_CLEARED,
UNLOCK_EXTRA_FAILED,
UNLOCK_TOASTY,
UNLOCK_CLEARED,
2004-02-22 05:16:12 +00:00
NUM_UNLOCK_TYPES,
UNLOCK_INVALID,
2004-01-24 23:40:40 +00:00
};
2003-08-11 20:57:57 +00:00
struct UnlockEntry
{
2003-08-11 20:57:57 +00:00
UnlockEntry();
2003-07-18 06:38:05 +00:00
CString m_sSongName;
2003-07-18 06:38:05 +00:00
/* A cached pointer to the song or course this entry refers to. Only one of
* these will be non-NULL. */
Song *m_pSong;
Course *m_pCourse;
2003-07-16 12:58:02 +00:00
2004-01-24 23:40:40 +00:00
float m_fRequired[NUM_UNLOCK_TYPES];
2004-01-25 16:24:34 +00:00
int m_iCode;
2003-07-18 06:38:05 +00:00
bool IsCourse() const { return m_pCourse != NULL; }
2004-01-25 16:24:34 +00:00
bool IsLocked() const;
};
class UnlockSystem
{
friend struct UnlockEntry;
public:
UnlockSystem();
2004-01-24 22:55:59 +00:00
// returns # of points till next unlock - used for ScreenUnlock
2004-01-24 23:40:40 +00:00
float PointsUntilNextUnlock( UnlockType t ) const;
float ArcadePointsUntilNextUnlock() const { return PointsUntilNextUnlock(UNLOCK_ARCADE_POINTS); }
float DancePointsUntilNextUnlock() const { return PointsUntilNextUnlock(UNLOCK_DANCE_POINTS); }
float SongPointsUntilNextUnlock() const { return PointsUntilNextUnlock(UNLOCK_SONG_POINTS); }
2003-07-18 06:38:05 +00:00
// Used on select screens:
2004-02-22 21:25:22 +00:00
bool SongIsLocked( const Song *song ) const;
2004-02-26 20:35:46 +00:00
bool SongIsRouletteOnly( const Song *song ) const;
2004-02-22 21:25:22 +00:00
bool CourseIsLocked( const Course *course ) const;
// Gets number of unlocks for title screen
int GetNumUnlocks() const;
2004-02-22 21:25:22 +00:00
const UnlockEntry *FindLockEntry( CString lockname ) const;
void GetPoints( const Profile *pProfile, float fScores[NUM_UNLOCK_TYPES] ) const;
2004-01-24 23:40:40 +00:00
2004-01-25 16:24:34 +00:00
void UnlockCode( int num );
// unlocks the song's code
void UnlockSong( const Song *song );
2004-01-24 22:55:59 +00:00
// All locked songs are stored here
vector<UnlockEntry> m_SongEntries;
2004-02-22 21:25:22 +00:00
// If global song or course points change, call to update
void UpdateSongs();
private:
// read unlocks
2004-02-22 05:16:12 +00:00
bool Load();
2004-01-25 16:24:34 +00:00
2004-02-22 21:25:22 +00:00
const UnlockEntry *FindSong( const Song *pSong ) const;
const UnlockEntry *FindCourse( const Course *pCourse ) const;
2003-07-15 08:00:59 +00:00
2004-01-25 16:24:34 +00:00
set<int> m_RouletteCodes; // "codes" which are available in roulette and which unlock if rouletted
};
2004-02-21 01:06:35 +00:00
extern UnlockSystem* UNLOCKMAN; // global and accessable from anywhere in program
#endif
2004-06-08 01:24:17 +00:00
/*
* (c) 2001-2004 Kevin Slaughter, Andrew Wong, Glenn Maynard
* 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.
*/