enum name cleanup
add Lua bindings
This commit is contained in:
@@ -102,7 +102,7 @@ void ScreenUnlockStatus::Init()
|
|||||||
|
|
||||||
switch( entry.m_Type )
|
switch( entry.m_Type )
|
||||||
{
|
{
|
||||||
case UnlockEntry::TYPE_SONG:
|
case UnlockRewardType_Song:
|
||||||
{
|
{
|
||||||
const Song *pSong = entry.m_pSong;
|
const Song *pSong = entry.m_pSong;
|
||||||
ASSERT( pSong );
|
ASSERT( pSong );
|
||||||
@@ -115,7 +115,7 @@ void ScreenUnlockStatus::Init()
|
|||||||
text->SetText( title );
|
text->SetText( title );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case UnlockEntry::TYPE_COURSE:
|
case UnlockRewardType_Course:
|
||||||
{
|
{
|
||||||
const Course *pCourse = entry.m_pCourse;
|
const Course *pCourse = entry.m_pCourse;
|
||||||
ASSERT( pCourse );
|
ASSERT( pCourse );
|
||||||
|
|||||||
+134
-37
@@ -13,13 +13,15 @@
|
|||||||
#include "Foreach.h"
|
#include "Foreach.h"
|
||||||
#include "Steps.h"
|
#include "Steps.h"
|
||||||
#include <float.h>
|
#include <float.h>
|
||||||
|
#include "CommonMetrics.h"
|
||||||
|
#include "LuaFunctions.h"
|
||||||
|
|
||||||
UnlockManager* UNLOCKMAN = NULL; // global and accessable from anywhere in our program
|
UnlockManager* UNLOCKMAN = NULL; // global and accessable from anywhere in our program
|
||||||
|
|
||||||
#define UNLOCK_NAMES THEME->GetMetric ("Unlocks","UnlockNames")
|
#define UNLOCK_NAMES THEME->GetMetric ("Unlocks","UnlockNames")
|
||||||
#define UNLOCK(sLineName) THEME->GetMetric ("Unlocks",ssprintf("Unlock%s",sLineName.c_str()))
|
#define UNLOCK(sLineName) THEME->GetMetric ("Unlocks",ssprintf("Unlock%s",sLineName.c_str()))
|
||||||
|
|
||||||
static const char *UnlockTriggerNames[] =
|
static const char *UnlockRequirementNames[] =
|
||||||
{
|
{
|
||||||
"ArcadePoints",
|
"ArcadePoints",
|
||||||
"DancePoints",
|
"DancePoints",
|
||||||
@@ -29,8 +31,20 @@ static const char *UnlockTriggerNames[] =
|
|||||||
"Toasties",
|
"Toasties",
|
||||||
"StagesCleared"
|
"StagesCleared"
|
||||||
};
|
};
|
||||||
XToString( UnlockTrigger, NUM_UnlockTrigger );
|
XToString( UnlockRequirement, NUM_UnlockRequirement );
|
||||||
StringToX( UnlockTrigger );
|
StringToX( UnlockRequirement );
|
||||||
|
LuaXType( UnlockRequirement, NUM_UnlockRequirement, "UnlockRequirement_", false )
|
||||||
|
|
||||||
|
static const char *UnlockRewardTypeNames[] =
|
||||||
|
{
|
||||||
|
"Song",
|
||||||
|
"Steps",
|
||||||
|
"Course",
|
||||||
|
"Modifier",
|
||||||
|
};
|
||||||
|
XToString( UnlockRewardType, NUM_UnlockRewardType );
|
||||||
|
XToLocalizedString( UnlockRewardType );
|
||||||
|
LuaFunction( UnlockRewardTypeToLocalizedString, UnlockRewardTypeToLocalizedString((UnlockRewardType) IArg(1)) );
|
||||||
|
|
||||||
UnlockManager::UnlockManager()
|
UnlockManager::UnlockManager()
|
||||||
{
|
{
|
||||||
@@ -167,7 +181,7 @@ const UnlockEntry *UnlockManager::FindCourse( const Course *pCourse ) const
|
|||||||
const UnlockEntry *UnlockManager::FindModifier( const RString &sOneMod ) const
|
const UnlockEntry *UnlockManager::FindModifier( const RString &sOneMod ) const
|
||||||
{
|
{
|
||||||
FOREACH_CONST( UnlockEntry, m_UnlockEntries, e )
|
FOREACH_CONST( UnlockEntry, m_UnlockEntries, e )
|
||||||
if( e->m_cmd.GetArg(1).s.CompareNoCase(sOneMod) == 0 )
|
if( e->GetModifier() == 0 )
|
||||||
return &(*e);
|
return &(*e);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -245,12 +259,12 @@ static float GetSongPoints( const Profile *pProfile )
|
|||||||
return fSP;
|
return fSP;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UnlockManager::GetPoints( const Profile *pProfile, float fScores[NUM_UnlockTrigger] ) const
|
void UnlockManager::GetPoints( const Profile *pProfile, float fScores[NUM_UnlockRequirement] ) const
|
||||||
{
|
{
|
||||||
fScores[UnlockTrigger_ArcadePoints] = GetArcadePoints( pProfile );
|
fScores[UnlockRequirement_ArcadePoints] = GetArcadePoints( pProfile );
|
||||||
fScores[UnlockTrigger_SongPoints] = GetSongPoints( pProfile );
|
fScores[UnlockRequirement_SongPoints] = GetSongPoints( pProfile );
|
||||||
fScores[UnlockTrigger_DancePoints] = (float) pProfile->m_iTotalDancePoints;
|
fScores[UnlockRequirement_DancePoints] = (float) pProfile->m_iTotalDancePoints;
|
||||||
fScores[UnlockTrigger_StagesCleared] = (float) pProfile->GetTotalNumSongsPassed();
|
fScores[UnlockRequirement_StagesCleared] = (float) pProfile->GetTotalNumSongsPassed();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return true if all songs and/or courses referenced by an unlock are available. */
|
/* Return true if all songs and/or courses referenced by an unlock are available. */
|
||||||
@@ -258,16 +272,16 @@ bool UnlockEntry::IsValid() const
|
|||||||
{
|
{
|
||||||
switch( m_Type )
|
switch( m_Type )
|
||||||
{
|
{
|
||||||
case TYPE_SONG:
|
case UnlockRewardType_Song:
|
||||||
return m_pSong != NULL;
|
return m_pSong != NULL;
|
||||||
|
|
||||||
case TYPE_STEPS:
|
case UnlockRewardType_Steps:
|
||||||
return m_pSong != NULL && m_dc != DIFFICULTY_INVALID;
|
return m_pSong != NULL && m_dc != DIFFICULTY_INVALID;
|
||||||
|
|
||||||
case TYPE_COURSE:
|
case UnlockRewardType_Course:
|
||||||
return m_pCourse != NULL;
|
return m_pCourse != NULL;
|
||||||
|
|
||||||
case TYPE_MODIFIER:
|
case UnlockRewardType_Modifier:
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -278,11 +292,11 @@ bool UnlockEntry::IsValid() const
|
|||||||
|
|
||||||
bool UnlockEntry::IsLocked() const
|
bool UnlockEntry::IsLocked() const
|
||||||
{
|
{
|
||||||
float fScores[NUM_UnlockTrigger];
|
float fScores[NUM_UnlockRequirement];
|
||||||
UNLOCKMAN->GetPoints( PROFILEMAN->GetMachineProfile(), fScores );
|
UNLOCKMAN->GetPoints( PROFILEMAN->GetMachineProfile(), fScores );
|
||||||
|
|
||||||
for( int i = 0; i < NUM_UnlockTrigger; ++i )
|
for( int i = 0; i < NUM_UnlockRequirement; ++i )
|
||||||
if( m_fRequired[i] && fScores[i] >= m_fRequired[i] )
|
if( m_fRequirement[i] && fScores[i] >= m_fRequirement[i] )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if( m_iEntryID != -1 && PROFILEMAN->GetMachineProfile()->m_UnlockedEntryIDs.find(m_iEntryID) != PROFILEMAN->GetMachineProfile()->m_UnlockedEntryIDs.end() )
|
if( m_iEntryID != -1 && PROFILEMAN->GetMachineProfile()->m_UnlockedEntryIDs.find(m_iEntryID) != PROFILEMAN->GetMachineProfile()->m_UnlockedEntryIDs.end() )
|
||||||
@@ -291,6 +305,61 @@ bool UnlockEntry::IsLocked() const
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RString UnlockEntry::GetDescription() const
|
||||||
|
{
|
||||||
|
switch( m_Type )
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
ASSERT(0);
|
||||||
|
return "";
|
||||||
|
case UnlockRewardType_Song:
|
||||||
|
return m_pSong ? m_pSong->GetDisplayFullTitle() : "";
|
||||||
|
case UnlockRewardType_Steps:
|
||||||
|
return DifficultyToLocalizedString( m_dc );
|
||||||
|
case UnlockRewardType_Course:
|
||||||
|
return m_pCourse ? m_pCourse->GetDisplayFullTitle() : "";
|
||||||
|
case UnlockRewardType_Modifier:
|
||||||
|
return CommonMetrics::LocalizeOptionItem( GetModifier(), false );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
RString UnlockEntry::GetBannerFile() const
|
||||||
|
{
|
||||||
|
switch( m_Type )
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
ASSERT(0);
|
||||||
|
return "";
|
||||||
|
case UnlockRewardType_Song:
|
||||||
|
return m_pSong ? m_pSong->GetBannerPath() : "";
|
||||||
|
case UnlockRewardType_Steps:
|
||||||
|
return "";
|
||||||
|
case UnlockRewardType_Course:
|
||||||
|
return m_pCourse ? m_pCourse->m_sBannerPath : "";
|
||||||
|
case UnlockRewardType_Modifier:
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
RString UnlockEntry::GetBackgroundFile() const
|
||||||
|
{
|
||||||
|
switch( m_Type )
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
ASSERT(0);
|
||||||
|
return "";
|
||||||
|
case UnlockRewardType_Song:
|
||||||
|
case UnlockRewardType_Steps:
|
||||||
|
return m_pSong ? m_pSong->GetBackgroundPath() : "";
|
||||||
|
case UnlockRewardType_Course:
|
||||||
|
return "";
|
||||||
|
case UnlockRewardType_Modifier:
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void UnlockManager::Load()
|
void UnlockManager::Load()
|
||||||
{
|
{
|
||||||
LOG->Trace( "UnlockManager::Load()" );
|
LOG->Trace( "UnlockManager::Load()" );
|
||||||
@@ -318,22 +387,22 @@ void UnlockManager::Load()
|
|||||||
|
|
||||||
if( sName == "song" )
|
if( sName == "song" )
|
||||||
{
|
{
|
||||||
current.m_Type = UnlockEntry::TYPE_SONG;
|
current.m_Type = UnlockRewardType_Song;
|
||||||
current.m_cmd = cmd;
|
current.m_cmd = cmd;
|
||||||
}
|
}
|
||||||
if( sName == "steps" )
|
if( sName == "steps" )
|
||||||
{
|
{
|
||||||
current.m_Type = UnlockEntry::TYPE_STEPS;
|
current.m_Type = UnlockRewardType_Steps;
|
||||||
current.m_cmd = cmd;
|
current.m_cmd = cmd;
|
||||||
}
|
}
|
||||||
if( sName == "course" )
|
if( sName == "course" )
|
||||||
{
|
{
|
||||||
current.m_Type = UnlockEntry::TYPE_COURSE;
|
current.m_Type = UnlockRewardType_Course;
|
||||||
current.m_cmd = cmd;
|
current.m_cmd = cmd;
|
||||||
}
|
}
|
||||||
if( sName == "mod" )
|
if( sName == "mod" )
|
||||||
{
|
{
|
||||||
current.m_Type = UnlockEntry::TYPE_MODIFIER;
|
current.m_Type = UnlockRewardType_Modifier;
|
||||||
current.m_cmd = cmd;
|
current.m_cmd = cmd;
|
||||||
}
|
}
|
||||||
else if( sName == "code" )
|
else if( sName == "code" )
|
||||||
@@ -349,9 +418,9 @@ void UnlockManager::Load()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const UnlockTrigger ut = StringToUnlockTrigger( cmd.GetName() );
|
const UnlockRequirement ut = StringToUnlockRequirement( cmd.GetName() );
|
||||||
if( ut != UnlockTrigger_INVALID )
|
if( ut != UnlockRequirement_INVALID )
|
||||||
current.m_fRequired[ut] = cmd.GetArg(1);
|
current.m_fRequirement[ut] = cmd.GetArg(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -366,9 +435,9 @@ void UnlockManager::Load()
|
|||||||
FOREACH_CONST( UnlockEntry, m_UnlockEntries, e )
|
FOREACH_CONST( UnlockEntry, m_UnlockEntries, e )
|
||||||
{
|
{
|
||||||
RString str = ssprintf( "Unlock: %s; ", join("\n",e->m_cmd.m_vsArgs).c_str() );
|
RString str = ssprintf( "Unlock: %s; ", join("\n",e->m_cmd.m_vsArgs).c_str() );
|
||||||
FOREACH_ENUM2( UnlockTrigger, j )
|
FOREACH_ENUM2( UnlockRequirement, j )
|
||||||
if( e->m_fRequired[j] )
|
if( e->m_fRequirement[j] )
|
||||||
str += ssprintf( "%s = %f; ", UnlockTriggerToString(j).c_str(), e->m_fRequired[j] );
|
str += ssprintf( "%s = %f; ", UnlockRequirementToString(j).c_str(), e->m_fRequirement[j] );
|
||||||
|
|
||||||
str += ssprintf( "entryID = %i ", e->m_iEntryID );
|
str += ssprintf( "entryID = %i ", e->m_iEntryID );
|
||||||
str += e->IsLocked()? "locked":"unlocked";
|
str += e->IsLocked()? "locked":"unlocked";
|
||||||
@@ -382,15 +451,15 @@ void UnlockManager::Load()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
float UnlockManager::PointsUntilNextUnlock( UnlockTrigger t ) const
|
float UnlockManager::PointsUntilNextUnlock( UnlockRequirement t ) const
|
||||||
{
|
{
|
||||||
float fScores[NUM_UnlockTrigger];
|
float fScores[NUM_UnlockRequirement];
|
||||||
UNLOCKMAN->GetPoints( PROFILEMAN->GetMachineProfile(), fScores );
|
UNLOCKMAN->GetPoints( PROFILEMAN->GetMachineProfile(), fScores );
|
||||||
|
|
||||||
float fSmallestPoints = FLT_MAX; // or an arbitrarily large value
|
float fSmallestPoints = FLT_MAX; // or an arbitrarily large value
|
||||||
for( unsigned a=0; a<m_UnlockEntries.size(); a++ )
|
for( unsigned a=0; a<m_UnlockEntries.size(); a++ )
|
||||||
if( m_UnlockEntries[a].m_fRequired[t] > fScores[t] )
|
if( m_UnlockEntries[a].m_fRequirement[t] > fScores[t] )
|
||||||
fSmallestPoints = min( fSmallestPoints, m_UnlockEntries[a].m_fRequired[t] );
|
fSmallestPoints = min( fSmallestPoints, m_UnlockEntries[a].m_fRequirement[t] );
|
||||||
|
|
||||||
if( fSmallestPoints == FLT_MAX )
|
if( fSmallestPoints == FLT_MAX )
|
||||||
return 0; // no match found
|
return 0; // no match found
|
||||||
@@ -405,12 +474,12 @@ void UnlockManager::UpdateCachedPointers()
|
|||||||
{
|
{
|
||||||
switch( e->m_Type )
|
switch( e->m_Type )
|
||||||
{
|
{
|
||||||
case UnlockEntry::TYPE_SONG:
|
case UnlockRewardType_Song:
|
||||||
e->m_pSong = SONGMAN->FindSong( e->m_cmd.GetArg(1) );
|
e->m_pSong = SONGMAN->FindSong( e->m_cmd.GetArg(1) );
|
||||||
if( e->m_pSong == NULL )
|
if( e->m_pSong == NULL )
|
||||||
LOG->Warn( "Unlock: Cannot find song matching \"%s\"", e->m_cmd.GetArg(1).s.c_str() );
|
LOG->Warn( "Unlock: Cannot find song matching \"%s\"", e->m_cmd.GetArg(1).s.c_str() );
|
||||||
break;
|
break;
|
||||||
case UnlockEntry::TYPE_STEPS:
|
case UnlockRewardType_Steps:
|
||||||
e->m_pSong = SONGMAN->FindSong( e->m_cmd.GetArg(1) );
|
e->m_pSong = SONGMAN->FindSong( e->m_cmd.GetArg(1) );
|
||||||
if( e->m_pSong == NULL )
|
if( e->m_pSong == NULL )
|
||||||
{
|
{
|
||||||
@@ -426,12 +495,12 @@ void UnlockManager::UpdateCachedPointers()
|
|||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case UnlockEntry::TYPE_COURSE:
|
case UnlockRewardType_Course:
|
||||||
e->m_pCourse = SONGMAN->FindCourse( e->m_cmd.GetArg(1) );
|
e->m_pCourse = SONGMAN->FindCourse( e->m_cmd.GetArg(1) );
|
||||||
if( e->m_pCourse == NULL )
|
if( e->m_pCourse == NULL )
|
||||||
LOG->Warn( "Unlock: Cannot find course matching \"%s\"", e->m_cmd.GetArg(1).s.c_str() );
|
LOG->Warn( "Unlock: Cannot find course matching \"%s\"", e->m_cmd.GetArg(1).s.c_str() );
|
||||||
break;
|
break;
|
||||||
case UnlockEntry::TYPE_MODIFIER:
|
case UnlockRewardType_Modifier:
|
||||||
// nothing to cache
|
// nothing to cache
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -471,7 +540,7 @@ int UnlockManager::GetNumUnlocks() const
|
|||||||
return m_UnlockEntries.size();
|
return m_UnlockEntries.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
void UnlockManager::GetUnlocksByType( UnlockEntry::Type t, vector<UnlockEntry *> &apEntries )
|
void UnlockManager::GetUnlocksByType( UnlockRewardType t, vector<UnlockEntry *> &apEntries )
|
||||||
{
|
{
|
||||||
for( unsigned i = 0; i < m_UnlockEntries.size(); ++i )
|
for( unsigned i = 0; i < m_UnlockEntries.size(); ++i )
|
||||||
if( m_UnlockEntries[i].IsValid() && m_UnlockEntries[i].m_Type == t )
|
if( m_UnlockEntries[i].IsValid() && m_UnlockEntries[i].m_Type == t )
|
||||||
@@ -481,7 +550,7 @@ void UnlockManager::GetUnlocksByType( UnlockEntry::Type t, vector<UnlockEntry *>
|
|||||||
void UnlockManager::GetSongsUnlockedByEntryID( vector<Song *> &apSongsOut, int iUnlockEntryID )
|
void UnlockManager::GetSongsUnlockedByEntryID( vector<Song *> &apSongsOut, int iUnlockEntryID )
|
||||||
{
|
{
|
||||||
vector<UnlockEntry *> apEntries;
|
vector<UnlockEntry *> apEntries;
|
||||||
GetUnlocksByType( UnlockEntry::TYPE_SONG, apEntries );
|
GetUnlocksByType( UnlockRewardType_Song, apEntries );
|
||||||
|
|
||||||
for( unsigned i = 0; i < apEntries.size(); ++i )
|
for( unsigned i = 0; i < apEntries.size(); ++i )
|
||||||
if( apEntries[i]->m_iEntryID == iUnlockEntryID )
|
if( apEntries[i]->m_iEntryID == iUnlockEntryID )
|
||||||
@@ -491,7 +560,7 @@ void UnlockManager::GetSongsUnlockedByEntryID( vector<Song *> &apSongsOut, int i
|
|||||||
void UnlockManager::GetStepsUnlockedByEntryID( vector<Song *> &apSongsOut, vector<Difficulty> &apDifficultyOut, int iUnlockEntryID )
|
void UnlockManager::GetStepsUnlockedByEntryID( vector<Song *> &apSongsOut, vector<Difficulty> &apDifficultyOut, int iUnlockEntryID )
|
||||||
{
|
{
|
||||||
vector<UnlockEntry *> apEntries;
|
vector<UnlockEntry *> apEntries;
|
||||||
GetUnlocksByType( UnlockEntry::TYPE_STEPS, apEntries );
|
GetUnlocksByType( UnlockRewardType_Steps, apEntries );
|
||||||
|
|
||||||
for( unsigned i = 0; i < apEntries.size(); ++i )
|
for( unsigned i = 0; i < apEntries.size(); ++i )
|
||||||
{
|
{
|
||||||
@@ -503,8 +572,33 @@ void UnlockManager::GetStepsUnlockedByEntryID( vector<Song *> &apSongsOut, vecto
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// lua start
|
||||||
#include "LuaBinding.h"
|
#include "LuaBinding.h"
|
||||||
|
|
||||||
|
class LunaUnlockEntry: public Luna<UnlockEntry>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
LunaUnlockEntry() { LUA->Register( Register ); }
|
||||||
|
|
||||||
|
static int IsLocked( T* p, lua_State *L ) { lua_pushboolean(L, p->IsLocked() ); return 1; }
|
||||||
|
static int GetDescription( T* p, lua_State *L ) { lua_pushstring(L, p->GetDescription() ); return 1; }
|
||||||
|
static int GetUnlockRewardType( T* p, lua_State *L ) { lua_pushnumber(L, p->m_Type ); return 1; }
|
||||||
|
static int GetRequirement( T* p, lua_State *L ) { UnlockRequirement i = (UnlockRequirement)IArg(1); lua_pushnumber(L, p->m_fRequirement[i] ); return 1; }
|
||||||
|
|
||||||
|
static void Register(lua_State *L)
|
||||||
|
{
|
||||||
|
ADD_METHOD( IsLocked );
|
||||||
|
ADD_METHOD( GetDescription );
|
||||||
|
ADD_METHOD( GetUnlockRewardType );
|
||||||
|
ADD_METHOD( GetRequirement );
|
||||||
|
|
||||||
|
Luna<T>::Register( L );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
LUA_REGISTER_CLASS( UnlockEntry )
|
||||||
|
|
||||||
class LunaUnlockManager: public Luna<UnlockManager>
|
class LunaUnlockManager: public Luna<UnlockManager>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -514,6 +608,7 @@ public:
|
|||||||
static int UnlockEntryID( T* p, lua_State *L ) { int iUnlockEntryID = IArg(1); p->UnlockEntryID(iUnlockEntryID); return 0; }
|
static int UnlockEntryID( T* p, lua_State *L ) { int iUnlockEntryID = IArg(1); p->UnlockEntryID(iUnlockEntryID); return 0; }
|
||||||
static int PreferUnlockEntryID( T* p, lua_State *L ) { int iUnlockEntryID = IArg(1); p->PreferUnlockEntryID(iUnlockEntryID); return 0; }
|
static int PreferUnlockEntryID( T* p, lua_State *L ) { int iUnlockEntryID = IArg(1); p->PreferUnlockEntryID(iUnlockEntryID); return 0; }
|
||||||
static int GetNumUnlocks( T* p, lua_State *L ) { lua_pushnumber( L, p->GetNumUnlocks() ); return 1; }
|
static int GetNumUnlocks( T* p, lua_State *L ) { lua_pushnumber( L, p->GetNumUnlocks() ); return 1; }
|
||||||
|
static int GetUnlockEntry( T* p, lua_State *L ) { int iIndex = IArg(1); p->m_UnlockEntries[iIndex].PushSelf(L); return 1; }
|
||||||
static int GetSongsUnlockedByEntryID( T* p, lua_State *L )
|
static int GetSongsUnlockedByEntryID( T* p, lua_State *L )
|
||||||
{
|
{
|
||||||
vector<Song *> apSongs;
|
vector<Song *> apSongs;
|
||||||
@@ -539,6 +634,7 @@ public:
|
|||||||
ADD_METHOD( UnlockEntryID );
|
ADD_METHOD( UnlockEntryID );
|
||||||
ADD_METHOD( PreferUnlockEntryID );
|
ADD_METHOD( PreferUnlockEntryID );
|
||||||
ADD_METHOD( GetNumUnlocks );
|
ADD_METHOD( GetNumUnlocks );
|
||||||
|
ADD_METHOD( GetUnlockEntry );
|
||||||
ADD_METHOD( GetSongsUnlockedByEntryID );
|
ADD_METHOD( GetSongsUnlockedByEntryID );
|
||||||
ADD_METHOD( GetStepsUnlockedByEntryID );
|
ADD_METHOD( GetStepsUnlockedByEntryID );
|
||||||
|
|
||||||
@@ -557,6 +653,7 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
LUA_REGISTER_CLASS( UnlockManager )
|
LUA_REGISTER_CLASS( UnlockManager )
|
||||||
|
// lua end
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (c) 2001-2004 Kevin Slaughter, Andrew Wong, Glenn Maynard
|
* (c) 2001-2004 Kevin Slaughter, Andrew Wong, Glenn Maynard
|
||||||
|
|||||||
@@ -14,43 +14,48 @@ class Steps;
|
|||||||
class Profile;
|
class Profile;
|
||||||
struct lua_State;
|
struct lua_State;
|
||||||
|
|
||||||
enum UnlockTrigger
|
enum UnlockRequirement
|
||||||
{
|
{
|
||||||
UnlockTrigger_ArcadePoints,
|
UnlockRequirement_ArcadePoints,
|
||||||
UnlockTrigger_DancePoints,
|
UnlockRequirement_DancePoints,
|
||||||
UnlockTrigger_SongPoints,
|
UnlockRequirement_SongPoints,
|
||||||
UnlockTrigger_ExtraCleared,
|
UnlockRequirement_ExtraCleared,
|
||||||
UnlockTrigger_ExtraFailed,
|
UnlockRequirement_ExtraFailed,
|
||||||
UnlockTrigger_Toasties,
|
UnlockRequirement_Toasties,
|
||||||
UnlockTrigger_StagesCleared,
|
UnlockRequirement_StagesCleared,
|
||||||
NUM_UnlockTrigger,
|
NUM_UnlockRequirement,
|
||||||
UnlockTrigger_INVALID,
|
UnlockRequirement_INVALID,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
struct UnlockEntry
|
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
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
UnlockEntry()
|
UnlockEntry()
|
||||||
{
|
{
|
||||||
m_Type = TYPE_INVALID;
|
m_Type = UnlockRewardType_INVALID;
|
||||||
|
|
||||||
m_pSong = NULL;
|
m_pSong = NULL;
|
||||||
m_dc = DIFFICULTY_INVALID;
|
m_dc = DIFFICULTY_INVALID;
|
||||||
m_pCourse = NULL;
|
m_pCourse = NULL;
|
||||||
|
|
||||||
ZERO( m_fRequired );
|
ZERO( m_fRequirement );
|
||||||
m_iEntryID = -1;
|
m_iEntryID = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
enum Type {
|
UnlockRewardType m_Type;
|
||||||
TYPE_SONG,
|
|
||||||
TYPE_STEPS,
|
|
||||||
TYPE_COURSE,
|
|
||||||
TYPE_MODIFIER,
|
|
||||||
NUM_TYPES,
|
|
||||||
TYPE_INVALID
|
|
||||||
};
|
|
||||||
Type m_Type;
|
|
||||||
Command m_cmd;
|
Command m_cmd;
|
||||||
|
|
||||||
/* A cached pointer to the song or course this entry refers to. Only one of
|
/* A cached pointer to the song or course this entry refers to. Only one of
|
||||||
@@ -59,25 +64,32 @@ struct UnlockEntry
|
|||||||
Difficulty m_dc;
|
Difficulty m_dc;
|
||||||
Course *m_pCourse;
|
Course *m_pCourse;
|
||||||
|
|
||||||
float m_fRequired[NUM_UnlockTrigger];
|
float m_fRequirement[NUM_UnlockRequirement];
|
||||||
int m_iEntryID;
|
int m_iEntryID;
|
||||||
|
|
||||||
bool IsValid() const;
|
bool IsValid() const;
|
||||||
bool IsLocked() const;
|
bool IsLocked() const;
|
||||||
|
RString GetModifier() const { return m_cmd.GetArg(1).s; }
|
||||||
|
RString GetDescription() const;
|
||||||
|
RString GetBannerFile() const;
|
||||||
|
RString GetBackgroundFile() const;
|
||||||
|
|
||||||
|
// Lua
|
||||||
|
void PushSelf( lua_State *L );
|
||||||
};
|
};
|
||||||
|
|
||||||
class UnlockManager
|
class UnlockManager
|
||||||
{
|
{
|
||||||
friend struct UnlockEntry;
|
friend class UnlockEntry;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
UnlockManager();
|
UnlockManager();
|
||||||
|
|
||||||
// returns # of points till next unlock - used for ScreenUnlock
|
// returns # of points till next unlock - used for ScreenUnlock
|
||||||
float PointsUntilNextUnlock( UnlockTrigger t ) const;
|
float PointsUntilNextUnlock( UnlockRequirement t ) const;
|
||||||
float ArcadePointsUntilNextUnlock() const { return PointsUntilNextUnlock(UnlockTrigger_ArcadePoints); }
|
float ArcadePointsUntilNextUnlock() const { return PointsUntilNextUnlock(UnlockRequirement_ArcadePoints); }
|
||||||
float DancePointsUntilNextUnlock() const { return PointsUntilNextUnlock(UnlockTrigger_DancePoints); }
|
float DancePointsUntilNextUnlock() const { return PointsUntilNextUnlock(UnlockRequirement_DancePoints); }
|
||||||
float SongPointsUntilNextUnlock() const { return PointsUntilNextUnlock(UnlockTrigger_SongPoints); }
|
float SongPointsUntilNextUnlock() const { return PointsUntilNextUnlock(UnlockRequirement_SongPoints); }
|
||||||
|
|
||||||
// Used on select screens:
|
// Used on select screens:
|
||||||
bool SongIsLocked( const Song *song ) const;
|
bool SongIsLocked( const Song *song ) const;
|
||||||
@@ -89,7 +101,7 @@ public:
|
|||||||
// Gets number of unlocks for title screen
|
// Gets number of unlocks for title screen
|
||||||
int GetNumUnlocks() const;
|
int GetNumUnlocks() const;
|
||||||
|
|
||||||
void GetPoints( const Profile *pProfile, float fScores[NUM_UnlockTrigger] ) const;
|
void GetPoints( const Profile *pProfile, float fScores[NUM_UnlockRequirement] ) const;
|
||||||
|
|
||||||
// Unlock an entry by code.
|
// Unlock an entry by code.
|
||||||
void UnlockEntryID( int iEntryID );
|
void UnlockEntryID( int iEntryID );
|
||||||
@@ -112,7 +124,7 @@ public:
|
|||||||
// If global song or course points change, call to update
|
// If global song or course points change, call to update
|
||||||
void UpdateCachedPointers();
|
void UpdateCachedPointers();
|
||||||
|
|
||||||
void GetUnlocksByType( UnlockEntry::Type t, vector<UnlockEntry *> &apEntries );
|
void GetUnlocksByType( UnlockRewardType t, vector<UnlockEntry *> &apEntries );
|
||||||
void GetSongsUnlockedByEntryID( vector<Song *> &apSongsOut, int iEntryID );
|
void GetSongsUnlockedByEntryID( vector<Song *> &apSongsOut, int iEntryID );
|
||||||
void GetStepsUnlockedByEntryID( vector<Song *> &apSongsOut, vector<Difficulty> &apStepsOut, int iEntryID );
|
void GetStepsUnlockedByEntryID( vector<Song *> &apSongsOut, vector<Difficulty> &apStepsOut, int iEntryID );
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user