Files
itgmania212121/stepmania/src/UnlockSystem.h
T

116 lines
2.7 KiB
C++
Raw Normal View History

#ifndef UNLOCK_SYSTEM_H
#define UNLOCK_SYSTEM_H
#include "Grade.h"
2004-01-25 16:24:34 +00:00
#include <set>
/*
-----------------------------------------------------------------------------
Class: UnlockSystem
Desc: The unlock system for Stepmania.
Copyright (c) 2001-2003 by the person(s) listed below. All rights reserved.
Kevin Slaughter
Andrew Wong
-----------------------------------------------------------------------------
*/
2003-07-09 04:46:24 +00:00
class Song;
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,
NUM_UNLOCK_TYPES
};
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:
2003-07-09 04:46:24 +00:00
bool SongIsLocked( const Song *song );
2003-07-15 08:00:59 +00:00
bool SongIsRoulette( const Song *song );
bool CourseIsLocked( const Course *course );
2003-07-15 08:00:59 +00:00
// executed when program is first executed
bool LoadFromDATFile();
// Gets number of unlocks for title screen
int GetNumUnlocks() const;
2004-01-24 23:40:40 +00:00
void UpdateSongs();
// functions that add to values
2004-01-24 23:40:40 +00:00
void UnlockAddAP(Grade credit);
void UnlockAddAP(float credit);
void UnlockAddDP(float credit);
void UnlockAddSP(Grade credit);
void UnlockAddSP(float credit);
void UnlockClearExtraStage();
void UnlockFailExtraStage();
void UnlockClearStage();
void UnlockToasty();
2003-07-15 08:00:59 +00:00
2004-01-25 16:24:34 +00:00
void UnlockCode( int num );
// unlocks the song's code
void UnlockSong( const Song *song );
2003-08-11 20:57:57 +00:00
UnlockEntry *FindLockEntry( CString lockname );
2003-07-18 06:38:05 +00:00
2004-01-24 22:55:59 +00:00
// All locked songs are stored here
vector<UnlockEntry> m_SongEntries;
private:
2004-01-25 16:24:34 +00:00
// read and write unlock in values
bool ReadValues();
bool WriteValues() const;
2003-08-11 20:57:57 +00:00
UnlockEntry *FindSong( const Song *pSong );
UnlockEntry *FindCourse( const Course *pCourse );
2003-07-15 08:00:59 +00:00
// unlock values, cached
2004-01-24 23:40:40 +00:00
float m_fScores[NUM_UNLOCK_TYPES];
2004-01-25 16:24:34 +00:00
set<int> m_UnlockedCodes;
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