Files
itgmania212121/stepmania/src/UnlockManager.h
T

195 lines
5.8 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
2007-08-16 01:14:14 +00:00
#ifndef UNLOCK_MANAGER_H
#define UNLOCK_MANAGER_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"
2007-08-15 20:56:44 +00:00
#include "SongUtil.h"
2007-08-15 21:01:23 +00:00
#include "CourseUtil.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,
2006-10-07 03:32:16 +00:00
UnlockRequirement_Invalid,
2004-01-24 23:40:40 +00:00
};
LuaDeclareType( UnlockRequirement );
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,
2006-10-07 03:32:16 +00:00
UnlockRewardType_Invalid
2006-01-29 22:17:43 +00:00
};
const RString& UnlockRewardTypeToString( UnlockRewardType i );
const RString& UnlockRewardTypeToLocalizedString( UnlockRewardType i );
2006-09-27 06:25:18 +00:00
LuaDeclareType( UnlockRewardType );
2006-01-29 22:17:43 +00:00
enum UnlockEntryStatus {
UnlockEntryStatus_RequrementsNotMet,
UnlockEntryStatus_RequirementsMet,
UnlockEntryStatus_Unlocked,
};
2006-01-29 22:17:43 +00:00
class UnlockEntry
{
2006-01-29 22:17:43 +00:00
public:
2005-04-24 19:41:52 +00:00
UnlockEntry()
{
2006-10-07 03:32:16 +00:00
m_Type = UnlockRewardType_Invalid;
2006-10-07 04:39:48 +00:00
m_dc = Difficulty_Invalid;
2005-04-24 19:41:52 +00:00
2006-01-29 22:17:43 +00:00
ZERO( m_fRequirement );
2006-03-24 18:32:31 +00:00
m_bRequirePassHardSteps = false;
m_bRoulette = false;
m_sEntryID = ""; // "" means not yet filled. This will be filled in automatically if not specified.
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. */
2007-08-15 20:56:44 +00:00
SongID m_Song;
2005-04-24 19:41:52 +00:00
Difficulty m_dc;
2007-08-15 21:01:23 +00:00
CourseID m_Course;
2003-07-16 12:58:02 +00:00
2006-03-20 22:41:41 +00:00
float m_fRequirement[NUM_UnlockRequirement]; // unlocked if any of of these are met
2006-03-24 18:32:31 +00:00
bool m_bRequirePassHardSteps;
bool m_bRoulette;
RString m_sEntryID;
bool IsValid() const;
bool IsLocked() const { return GetUnlockEntryStatus() != UnlockEntryStatus_Unlocked; }
UnlockEntryStatus GetUnlockEntryStatus() 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 );
};
// Option is locked due to an unsatisfied unlock entry.
#define LOCKED_LOCK 0x1
// Option is only available in random selections.
#define LOCKED_ROULETTE 0x2
// Option is locked due to a #SELECTABLE tag.
#define LOCKED_SELECTABLE 0x4
// Option is disabled by the operator. (For courses, this means that a song in the
// course is disabled.)
#define LOCKED_DISABLED 0x8
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();
2006-09-21 04:27:45 +00:00
~UnlockManager();
2006-05-02 22:02:18 +00:00
void Reload();
2006-01-29 22:17:43 +00:00
float PointsUntilNextUnlock( UnlockRequirement t ) const;
int SongIsLocked( const Song *pSong ) const;
2005-04-24 19:41:52 +00:00
bool StepsIsLocked( const Song *pSong, const Steps *pSteps ) const;
2007-08-15 20:31:47 +00:00
int 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;
int GetNumUnlocked() const;
int GetUnlockEntryIndexToCelebrate() const;
2006-01-30 08:13:16 +00:00
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.
void UnlockEntryID( RString sEntryID );
2006-03-20 22:41:41 +00:00
void UnlockEntryIndex( int iEntryIndex );
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.
*/
void PreferUnlockEntryID( RString sEntryID );
2005-02-24 22:34:54 +00:00
2005-02-21 06:51:04 +00:00
// Unlocks a song.
void UnlockSong( const Song *pSong );
2003-07-15 08:00:59 +00:00
2006-01-28 22:08:16 +00:00
// Return the associated EntryID.
RString 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
2006-01-29 22:17:43 +00:00
void GetUnlocksByType( UnlockRewardType t, vector<UnlockEntry *> &apEntries );
void GetSongsUnlockedByEntryID( vector<Song *> &apSongsOut, RString sEntryID );
void GetStepsUnlockedByEntryID( vector<Song *> &apSongsOut, vector<Difficulty> &apStepsOut, RString sEntryID );
const UnlockEntry *FindSong( const Song *pSong ) const;
const UnlockEntry *FindSteps( const Song *pSong, const Steps *pSteps ) const;
const UnlockEntry *FindCourse( const Course *pCourse ) const;
const UnlockEntry *FindModifier( const RString &sOneMod ) const;
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
set<RString> 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.
*/