Files
itgmania212121/stepmania/src/UnlockManager.h
T

162 lines
4.6 KiB
C++
Raw Normal View History

2005-02-21 06:13:31 +00:00
/* UnlockManager - Unlocks handling. */
2004-06-08 01:24:17 +00:00
#ifndef UNLOCK_SYSTEM_H
#define UNLOCK_SYSTEM_H
#include "Grade.h"
2005-04-24 19:41:52 +00:00
#include "Command.h"
2004-01-25 16:24:34 +00:00
#include <set>
2006-01-28 21:37:13 +00:00
#include "Difficulty.h"
2004-01-25 16:24:34 +00:00
2003-07-09 04:46:24 +00:00
class Song;
2006-01-28 21:37:13 +00:00
class Course;
class Steps;
class Profile;
2005-02-21 06:51:04 +00:00
struct lua_State;
2003-07-09 04:46:24 +00:00
2006-01-28 21:37:13 +00:00
enum UnlockTrigger
2004-01-24 23:40:40 +00:00
{
2006-01-28 21:37:13 +00:00
UnlockTrigger_ArcadePoints,
UnlockTrigger_DancePoints,
UnlockTrigger_SongPoints,
UnlockTrigger_ExtraCleared,
UnlockTrigger_ExtraFailed,
UnlockTrigger_Toasties,
UnlockTrigger_StagesCleared,
NUM_UnlockTrigger,
UnlockTrigger_INVALID,
2004-01-24 23:40:40 +00:00
};
2006-01-28 21:37:13 +00:00
2004-01-24 23:40:40 +00:00
2003-08-11 20:57:57 +00:00
struct UnlockEntry
{
2005-04-24 19:41:52 +00:00
UnlockEntry()
{
m_Type = TYPE_INVALID;
2005-04-24 19:41:52 +00:00
m_pSong = NULL;
m_dc = DIFFICULTY_INVALID;
m_pCourse = NULL;
ZERO( m_fRequired );
m_iCode = -1;
}
2006-01-28 21:37:13 +00:00
enum Type {
TYPE_SONG,
TYPE_STEPS,
TYPE_COURSE,
TYPE_MODIFIER,
NUM_TYPES,
TYPE_INVALID
};
2005-03-29 01:44:36 +00:00
Type m_Type;
2005-04-24 19:41:52 +00:00
Command m_cmd;
2005-03-29 01:44:36 +00:00
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;
2005-04-24 19:41:52 +00:00
Difficulty m_dc;
2003-07-18 06:38:05 +00:00
Course *m_pCourse;
2003-07-16 12:58:02 +00:00
2006-01-28 21:37:13 +00:00
float m_fRequired[NUM_UnlockTrigger];
int m_iCode;
bool IsValid() const;
2004-01-25 16:24:34 +00:00
bool IsLocked() const;
};
2005-02-21 06:13:31 +00:00
class UnlockManager
{
friend struct UnlockEntry;
public:
2005-02-21 06:13:31 +00:00
UnlockManager();
2004-01-24 22:55:59 +00:00
// returns # of points till next unlock - used for ScreenUnlock
2006-01-28 21:37:13 +00:00
float PointsUntilNextUnlock( UnlockTrigger t ) const;
float ArcadePointsUntilNextUnlock() const { return PointsUntilNextUnlock(UnlockTrigger_ArcadePoints); }
float DancePointsUntilNextUnlock() const { return PointsUntilNextUnlock(UnlockTrigger_DancePoints); }
float SongPointsUntilNextUnlock() const { return PointsUntilNextUnlock(UnlockTrigger_SongPoints); }
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;
2005-04-24 19:41:52 +00:00
bool StepsIsLocked( const Song *pSong, const Steps *pSteps ) const;
2004-02-22 21:25:22 +00:00
bool CourseIsLocked( const Course *course ) const;
2006-01-22 01:00:06 +00:00
bool ModifierIsLocked( const RString &sOneMod ) const;
// Gets number of unlocks for title screen
int GetNumUnlocks() const;
2006-01-28 21:37:13 +00:00
void GetPoints( const Profile *pProfile, float fScores[NUM_UnlockTrigger] ) const;
2004-01-24 23:40:40 +00:00
2005-02-21 06:51:04 +00:00
// Unlock an entry by code.
2004-01-25 16:24:34 +00:00
void UnlockCode( int num );
2005-02-24 22:34:54 +00:00
/*
* If a code is associated with at least one song or course, set the preferred song
* and/or course in GAMESTATE to them.
*/
void PreferUnlockCode( int iCode );
2005-02-21 06:51:04 +00:00
// Unlocks a song.
2004-01-25 16:24:34 +00:00
void UnlockSong( const Song *song );
2003-07-15 08:00:59 +00:00
2005-04-24 00:07:12 +00:00
// Return the associated code.
2006-01-22 01:00:06 +00:00
int FindCode( const RString &sName ) const;
2005-04-24 00:07:12 +00:00
2004-01-24 22:55:59 +00:00
// All locked songs are stored here
2005-03-29 01:44:36 +00:00
vector<UnlockEntry> m_UnlockEntries;
2004-01-24 22:55:59 +00:00
2004-02-22 21:25:22 +00:00
// If global song or course points change, call to update
2005-04-24 19:41:52 +00:00
void UpdateCachedPointers();
void GetUnlocksByType( UnlockEntry::Type t, vector<UnlockEntry *> &apEntries );
void GetSongsUnlockedByCode( vector<Song *> &apSongsOut, int iCode );
void GetStepsUnlockedByCode( vector<Song *> &apSongsOut, vector<Difficulty> &apStepsOut, int iCode );
2005-02-21 06:51:04 +00:00
// Lua
void PushSelf( lua_State *L );
private:
// read unlocks
void Load();
2004-01-25 16:24:34 +00:00
2004-02-22 21:25:22 +00:00
const UnlockEntry *FindSong( const Song *pSong ) const;
2005-04-24 19:41:52 +00:00
const UnlockEntry *FindSteps( const Song *pSong, const Steps *pSteps ) const;
2004-02-22 21:25:22 +00:00
const UnlockEntry *FindCourse( const Course *pCourse ) const;
2006-01-22 01:00:06 +00:00
const UnlockEntry *FindModifier( const RString &sOneMod ) 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
};
2005-02-21 06:13:31 +00:00
extern UnlockManager* 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.
*/