UnlockType -> UnlockTrigger
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
#include "global.h"
|
||||
#include "UnlockManager.h"
|
||||
#include "PrefsManager.h"
|
||||
#include "RageLog.h"
|
||||
#include "song.h"
|
||||
#include "Course.h"
|
||||
#include "RageUtil.h"
|
||||
#include "UnlockManager.h"
|
||||
#include "SongManager.h"
|
||||
#include "GameState.h"
|
||||
#include "ProfileManager.h"
|
||||
@@ -16,10 +16,10 @@
|
||||
|
||||
UnlockManager* UNLOCKMAN = NULL; // global and accessable from anywhere in our program
|
||||
|
||||
#define UNLOCK_NAMES THEME->GetMetric ("Unlocks","UnlockNames")
|
||||
#define UNLOCK(sLineName) THEME->GetMetric ("Unlocks",ssprintf("Unlock%s",sLineName.c_str()))
|
||||
#define UNLOCK_NAMES THEME->GetMetric ("Unlocks","UnlockNames")
|
||||
#define UNLOCK(sLineName) THEME->GetMetric ("Unlocks",ssprintf("Unlock%s",sLineName.c_str()))
|
||||
|
||||
static const char *UnlockTypeNames[] =
|
||||
static const char *UnlockTriggerNames[] =
|
||||
{
|
||||
"ArcadePoints",
|
||||
"DancePoints",
|
||||
@@ -29,8 +29,8 @@ static const char *UnlockTypeNames[] =
|
||||
"Toasties",
|
||||
"StagesCleared"
|
||||
};
|
||||
XToString( UnlockType, NUM_UNLOCK_TYPES );
|
||||
StringToX( UnlockType );
|
||||
XToString( UnlockTrigger, NUM_UnlockTrigger );
|
||||
StringToX( UnlockTrigger );
|
||||
|
||||
UnlockManager::UnlockManager()
|
||||
{
|
||||
@@ -245,12 +245,12 @@ static float GetSongPoints( const Profile *pProfile )
|
||||
return fSP;
|
||||
}
|
||||
|
||||
void UnlockManager::GetPoints( const Profile *pProfile, float fScores[NUM_UNLOCK_TYPES] ) const
|
||||
void UnlockManager::GetPoints( const Profile *pProfile, float fScores[NUM_UnlockTrigger] ) const
|
||||
{
|
||||
fScores[UNLOCK_ARCADE_POINTS] = GetArcadePoints( pProfile );
|
||||
fScores[UNLOCK_SONG_POINTS] = GetSongPoints( pProfile );
|
||||
fScores[UNLOCK_DANCE_POINTS] = (float) pProfile->m_iTotalDancePoints;
|
||||
fScores[UNLOCK_CLEARED] = (float) pProfile->GetTotalNumSongsPassed();
|
||||
fScores[UnlockTrigger_ArcadePoints] = GetArcadePoints( pProfile );
|
||||
fScores[UnlockTrigger_SongPoints] = GetSongPoints( pProfile );
|
||||
fScores[UnlockTrigger_DancePoints] = (float) pProfile->m_iTotalDancePoints;
|
||||
fScores[UnlockTrigger_StagesCleared] = (float) pProfile->GetTotalNumSongsPassed();
|
||||
}
|
||||
|
||||
/* Return true if all songs and/or courses referenced by an unlock are available. */
|
||||
@@ -278,10 +278,10 @@ bool UnlockEntry::IsValid() const
|
||||
|
||||
bool UnlockEntry::IsLocked() const
|
||||
{
|
||||
float fScores[NUM_UNLOCK_TYPES];
|
||||
float fScores[NUM_UnlockTrigger];
|
||||
UNLOCKMAN->GetPoints( PROFILEMAN->GetMachineProfile(), fScores );
|
||||
|
||||
for( int i = 0; i < NUM_UNLOCK_TYPES; ++i )
|
||||
for( int i = 0; i < NUM_UnlockTrigger; ++i )
|
||||
if( m_fRequired[i] && fScores[i] >= m_fRequired[i] )
|
||||
return false;
|
||||
|
||||
@@ -349,8 +349,8 @@ void UnlockManager::Load()
|
||||
}
|
||||
else
|
||||
{
|
||||
const UnlockType ut = StringToUnlockType( cmd.GetName() );
|
||||
if( ut != UNLOCK_INVALID )
|
||||
const UnlockTrigger ut = StringToUnlockTrigger( cmd.GetName() );
|
||||
if( ut != UnlockTrigger_INVALID )
|
||||
current.m_fRequired[ut] = cmd.GetArg(1);
|
||||
}
|
||||
}
|
||||
@@ -366,9 +366,9 @@ void UnlockManager::Load()
|
||||
FOREACH_CONST( UnlockEntry, m_UnlockEntries, e )
|
||||
{
|
||||
RString str = ssprintf( "Unlock: %s; ", join("\n",e->m_cmd.m_vsArgs).c_str() );
|
||||
FOREACH_UnlockType(j)
|
||||
FOREACH_ENUM2( UnlockTrigger, j )
|
||||
if( e->m_fRequired[j] )
|
||||
str += ssprintf( "%s = %f; ", UnlockTypeToString(j).c_str(), e->m_fRequired[j] );
|
||||
str += ssprintf( "%s = %f; ", UnlockTriggerToString(j).c_str(), e->m_fRequired[j] );
|
||||
|
||||
str += ssprintf( "code = %i ", e->m_iCode );
|
||||
str += e->IsLocked()? "locked":"unlocked";
|
||||
@@ -382,9 +382,9 @@ void UnlockManager::Load()
|
||||
return;
|
||||
}
|
||||
|
||||
float UnlockManager::PointsUntilNextUnlock( UnlockType t ) const
|
||||
float UnlockManager::PointsUntilNextUnlock( UnlockTrigger t ) const
|
||||
{
|
||||
float fScores[NUM_UNLOCK_TYPES];
|
||||
float fScores[NUM_UnlockTrigger];
|
||||
UNLOCKMAN->GetPoints( PROFILEMAN->GetMachineProfile(), fScores );
|
||||
|
||||
float fSmallestPoints = FLT_MAX; // or an arbitrarily large value
|
||||
@@ -510,8 +510,8 @@ class LunaUnlockManager: public Luna<UnlockManager>
|
||||
public:
|
||||
LunaUnlockManager() { LUA->Register( Register ); }
|
||||
|
||||
static int FindCode( T* p, lua_State *L ) { RString sName = SArg(1); int i = p->FindCode(sName); if( i == -1 ) lua_pushnil(L); else lua_pushnumber(L, i); return 1; }
|
||||
static int UnlockCode( T* p, lua_State *L ) { int iCode = IArg(1); p->UnlockCode(iCode); return 0; }
|
||||
static int FindCode( T* p, lua_State *L ) { RString sName = SArg(1); int i = p->FindCode(sName); if( i == -1 ) lua_pushnil(L); else lua_pushnumber(L, i); return 1; }
|
||||
static int UnlockCode( T* p, lua_State *L ) { int iCode = IArg(1); p->UnlockCode(iCode); return 0; }
|
||||
static int PreferUnlockCode( T* p, lua_State *L ) { int iCode = IArg(1); p->PreferUnlockCode(iCode); return 0; }
|
||||
static int GetNumUnlocks( T* p, lua_State *L ) { lua_pushnumber( L, p->GetNumUnlocks() ); return 1; }
|
||||
static int GetSongsUnlockedByCode( T* p, lua_State *L )
|
||||
|
||||
@@ -6,24 +6,27 @@
|
||||
#include "Grade.h"
|
||||
#include "Command.h"
|
||||
#include <set>
|
||||
#include "Difficulty.h"
|
||||
|
||||
class Song;
|
||||
class Course;
|
||||
class Steps;
|
||||
class Profile;
|
||||
struct lua_State;
|
||||
|
||||
enum UnlockType
|
||||
enum UnlockTrigger
|
||||
{
|
||||
UNLOCK_ARCADE_POINTS,
|
||||
UNLOCK_DANCE_POINTS,
|
||||
UNLOCK_SONG_POINTS,
|
||||
UNLOCK_EXTRA_CLEARED,
|
||||
UNLOCK_EXTRA_FAILED,
|
||||
UNLOCK_TOASTY,
|
||||
UNLOCK_CLEARED,
|
||||
NUM_UNLOCK_TYPES,
|
||||
UNLOCK_INVALID,
|
||||
UnlockTrigger_ArcadePoints,
|
||||
UnlockTrigger_DancePoints,
|
||||
UnlockTrigger_SongPoints,
|
||||
UnlockTrigger_ExtraCleared,
|
||||
UnlockTrigger_ExtraFailed,
|
||||
UnlockTrigger_Toasties,
|
||||
UnlockTrigger_StagesCleared,
|
||||
NUM_UnlockTrigger,
|
||||
UnlockTrigger_INVALID,
|
||||
};
|
||||
#define FOREACH_UnlockType( u ) FOREACH_ENUM( UnlockType, NUM_UNLOCK_TYPES, u )
|
||||
|
||||
|
||||
struct UnlockEntry
|
||||
{
|
||||
@@ -39,7 +42,14 @@ struct UnlockEntry
|
||||
m_iCode = -1;
|
||||
}
|
||||
|
||||
enum Type { TYPE_SONG, TYPE_STEPS, TYPE_COURSE, TYPE_MODIFIER, NUM_TYPES, TYPE_INVALID };
|
||||
enum Type {
|
||||
TYPE_SONG,
|
||||
TYPE_STEPS,
|
||||
TYPE_COURSE,
|
||||
TYPE_MODIFIER,
|
||||
NUM_TYPES,
|
||||
TYPE_INVALID
|
||||
};
|
||||
Type m_Type;
|
||||
Command m_cmd;
|
||||
|
||||
@@ -49,8 +59,8 @@ struct UnlockEntry
|
||||
Difficulty m_dc;
|
||||
Course *m_pCourse;
|
||||
|
||||
float m_fRequired[NUM_UNLOCK_TYPES];
|
||||
int m_iCode;
|
||||
float m_fRequired[NUM_UnlockTrigger];
|
||||
int m_iCode;
|
||||
|
||||
bool IsValid() const;
|
||||
bool IsLocked() const;
|
||||
@@ -64,10 +74,10 @@ public:
|
||||
UnlockManager();
|
||||
|
||||
// returns # of points till next unlock - used for ScreenUnlock
|
||||
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); }
|
||||
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); }
|
||||
|
||||
// Used on select screens:
|
||||
bool SongIsLocked( const Song *song ) const;
|
||||
@@ -79,7 +89,7 @@ public:
|
||||
// Gets number of unlocks for title screen
|
||||
int GetNumUnlocks() const;
|
||||
|
||||
void GetPoints( const Profile *pProfile, float fScores[NUM_UNLOCK_TYPES] ) const;
|
||||
void GetPoints( const Profile *pProfile, float fScores[NUM_UnlockTrigger] ) const;
|
||||
|
||||
// Unlock an entry by code.
|
||||
void UnlockCode( int num );
|
||||
|
||||
Reference in New Issue
Block a user