Files
itgmania212121/stepmania/src/UnlockManager.h
T

179 lines
5.3 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-29 22:17:43 +00:00
enum UnlockRequirement
2004-01-24 23:40:40 +00:00
{
2006-01-29 22:17:43 +00:00
UnlockRequirement_ArcadePoints,
UnlockRequirement_DancePoints,
UnlockRequirement_SongPoints,
UnlockRequirement_ExtraCleared,
UnlockRequirement_ExtraFailed,
UnlockRequirement_Toasties,
UnlockRequirement_StagesCleared,
NUM_UnlockRequirement,
UnlockRequirement_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
2006-01-29 22:17:43 +00:00
enum UnlockRewardType {
UnlockRewardType_Song,
UnlockRewardType_Steps,
UnlockRewardType_Course,
UnlockRewardType_Modifier,
NUM_UnlockRewardType,
UnlockRewardType_INVALID
};
const RString& UnlockRewardTypeToString( UnlockRewardType i );
const RString& UnlockRewardTypeToLocalizedString( UnlockRewardType i );
class UnlockEntry
{
2006-01-29 22:17:43 +00:00
public:
2005-04-24 19:41:52 +00:00
UnlockEntry()
{
2006-01-29 22:17:43 +00:00
m_Type = UnlockRewardType_INVALID;
2005-04-24 19:41:52 +00:00
m_pSong = NULL;
m_dc = DIFFICULTY_INVALID;
m_pCourse = NULL;
2006-01-29 22:17:43 +00:00
ZERO( m_fRequirement );
2006-01-28 22:08:16 +00:00
m_iEntryID = -1;
2006-01-30 08:13:16 +00:00
m_bCelebrated = false;
2005-04-24 19:41:52 +00:00
}
2006-01-29 22:17:43 +00:00
UnlockRewardType 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-29 22:17:43 +00:00
float m_fRequirement[NUM_UnlockRequirement];
2006-01-28 22:08:16 +00:00
int m_iEntryID;
2006-01-30 08:13:16 +00:00
bool m_bCelebrated;
bool IsValid() const;
2004-01-25 16:24:34 +00:00
bool IsLocked() const;
2006-01-29 22:17:43 +00:00
RString GetModifier() const { return m_cmd.GetArg(1).s; }
RString GetDescription() const;
RString GetBannerFile() const;
RString GetBackgroundFile() const;
// Lua
void PushSelf( lua_State *L );
};
2005-02-21 06:13:31 +00:00
class UnlockManager
{
2006-01-29 22:17:43 +00:00
friend class 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-29 22:17:43 +00:00
float PointsUntilNextUnlock( UnlockRequirement t ) const;
float ArcadePointsUntilNextUnlock() const { return PointsUntilNextUnlock(UnlockRequirement_ArcadePoints); }
float DancePointsUntilNextUnlock() const { return PointsUntilNextUnlock(UnlockRequirement_DancePoints); }
float SongPointsUntilNextUnlock() const { return PointsUntilNextUnlock(UnlockRequirement_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-30 08:13:16 +00:00
bool AllAreLocked() const;
int GetUnlockIndexToCelebrate() const;
bool AnyUnlocksToCelebrate() const;
2006-01-29 22:17:43 +00:00
void GetPoints( const Profile *pProfile, float fScores[NUM_UnlockRequirement] ) const;
2004-01-24 23:40:40 +00:00
2005-02-21 06:51:04 +00:00
// Unlock an entry by code.
2006-01-28 22:08:16 +00:00
void UnlockEntryID( int iEntryID );
2004-01-25 16:24:34 +00:00
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.
*/
2006-01-28 22:08:16 +00:00
void PreferUnlockEntryID( int iEntryID );
2005-02-24 22:34:54 +00:00
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
2006-01-28 22:08:16 +00:00
// Return the associated EntryID.
int FindEntryID( 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();
2006-01-29 22:17:43 +00:00
void GetUnlocksByType( UnlockRewardType t, vector<UnlockEntry *> &apEntries );
2006-01-28 22:08:16 +00:00
void GetSongsUnlockedByEntryID( vector<Song *> &apSongsOut, int iEntryID );
void GetStepsUnlockedByEntryID( vector<Song *> &apSongsOut, vector<Difficulty> &apStepsOut, int iEntryID );
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.
*/