remove confusing overlap between "requirements met" and "unlocked"

This commit is contained in:
Chris Danford
2006-05-03 21:34:05 +00:00
parent acb136102f
commit 5b756e7e31
5 changed files with 34 additions and 31 deletions
+1 -1
View File
@@ -127,7 +127,7 @@ void SaveCatalogXml( LoadingWindow *loading_window )
int iNumUnlockedCourses = 0;
FOREACH_CONST( UnlockEntry, UNLOCKMAN->m_UnlockEntries, e )
{
if( e->IsLocked() )
if( e->GetUnlockEntryStatus() == UnlockEntryStatus_Unlocked )
continue;
switch( e->m_Type )
{
+1 -1
View File
@@ -11,7 +11,7 @@ void ScreenUnlockBrowse::Init()
FOREACH_CONST( UnlockEntry, UNLOCKMAN->m_UnlockEntries, ue )
{
GameCommand gc;
if( ue->IsRequirementMet() )
if( ue->GetUnlockEntryStatus() >= UnlockEntryStatus_RequirementsMet )
gc.m_bInvalid = false;
gc.m_iIndex = ue - UNLOCKMAN->m_UnlockEntries.begin();
gc.m_iUnlockEntryID = ue->m_iEntryID;
+8 -4
View File
@@ -1,15 +1,23 @@
#include "global.h"
#include "ScreenUnlockCelebrate.h"
#include "UnlockManager.h"
#include "LuaFunctions.h"
REGISTER_SCREEN_CLASS( ScreenUnlockCelebrate );
static int g_iUnlockEntryIndexToCelebrate = 0;
LuaFunction( GetUnlockEntryIndexToCelebrate, g_iUnlockEntryIndexToCelebrate );
void ScreenUnlockCelebrate::Init()
{
// We shouldn't be called if there aren't any unlocks to celebrate
ASSERT( UNLOCKMAN->AnyUnlocksToCelebrate() );
g_iUnlockEntryIndexToCelebrate = UNLOCKMAN->GetUnlockEntryIndexToCelebrate();
UNLOCKMAN->UnlockEntryIndex( g_iUnlockEntryIndexToCelebrate );
ScreenUnlockBrowse::Init();
}
@@ -31,10 +39,6 @@ void ScreenUnlockCelebrate::MenuDown( const InputEventPlus &input )
void ScreenUnlockCelebrate::MenuStart( PlayerNumber pn )
{
// Mark this unlock as celebrated
int iUnlockIndex = UNLOCKMAN->GetUnlockEntryIndexToCelebrate();
UNLOCKMAN->UnlockEntryIndex( iUnlockIndex );
ScreenUnlockBrowse::MenuStart( pn );
}
+15 -22
View File
@@ -292,14 +292,17 @@ bool UnlockEntry::IsValid() const
}
}
bool UnlockEntry::IsRequirementMet() const
UnlockEntryStatus UnlockEntry::GetUnlockEntryStatus() const
{
if( m_iEntryID != -1 && PROFILEMAN->GetMachineProfile()->m_UnlockedEntryIDs.find(m_iEntryID) != PROFILEMAN->GetMachineProfile()->m_UnlockedEntryIDs.end() )
return UnlockEntryStatus_Unlocked;
float fScores[NUM_UnlockRequirement];
UNLOCKMAN->GetPoints( PROFILEMAN->GetMachineProfile(), fScores );
for( int i = 0; i < NUM_UnlockRequirement; ++i )
if( m_fRequirement[i] && fScores[i] >= m_fRequirement[i] )
return true;
return UnlockEntryStatus_RequirementsMet;
if( m_bRequirePassHardSteps && m_pSong )
{
@@ -311,18 +314,11 @@ bool UnlockEntry::IsRequirementMet() const
);
FOREACH_CONST( Steps*, vp, s )
if( PROFILEMAN->GetMachineProfile()->HasPassedSteps( m_pSong, *s ) )
return true;
return UnlockEntryStatus_RequirementsMet;
}
return false;
}
bool UnlockEntry::IsLocked() const
{
if( m_iEntryID != -1 && PROFILEMAN->GetMachineProfile()->m_UnlockedEntryIDs.find(m_iEntryID) != PROFILEMAN->GetMachineProfile()->m_UnlockedEntryIDs.end() )
return false;
return true;
return UnlockEntryStatus_RequrementsNotMet;
}
RString UnlockEntry::GetDescription() const
@@ -616,21 +612,22 @@ int UnlockManager::GetNumUnlocks() const
return m_UnlockEntries.size();
}
bool UnlockManager::AnyRequirementsAreMet() const
int UnlockManager::GetNumUnlocked() const
{
int count = 0;
FOREACH_CONST( UnlockEntry, m_UnlockEntries, ue )
{
if( ue->IsRequirementMet() )
return true;
if( ue->GetUnlockEntryStatus() == UnlockEntryStatus_Unlocked )
count++;
}
return false;
return count;
}
int UnlockManager::GetUnlockEntryIndexToCelebrate() const
{
FOREACH_CONST( UnlockEntry, m_UnlockEntries, ue )
{
if( ue->IsRequirementMet() && ue->IsLocked() )
if( ue->GetUnlockEntryStatus() == UnlockEntryStatus_RequirementsMet )
return ue - m_UnlockEntries.begin();
}
return -1;
@@ -683,7 +680,6 @@ public:
LunaUnlockEntry() { LUA->Register( Register ); }
static int IsLocked( T* p, lua_State *L ) { lua_pushboolean(L, p->IsLocked() ); return 1; }
static int IsRequirementMet( T* p, lua_State *L ) { lua_pushboolean(L, p->IsRequirementMet() ); 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; }
@@ -692,7 +688,6 @@ public:
static void Register(lua_State *L)
{
ADD_METHOD( IsLocked );
ADD_METHOD( IsRequirementMet );
ADD_METHOD( GetDescription );
ADD_METHOD( GetUnlockRewardType );
ADD_METHOD( GetRequirement );
@@ -714,8 +709,7 @@ public:
static int UnlockEntryIndex( T* p, lua_State *L ) { int iUnlockEntryID = IArg(1); p->UnlockEntryIndex(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 AnyRequirementsAreMet( T* p, lua_State *L ) { lua_pushboolean( L, p->AnyRequirementsAreMet() ); return 1; }
static int GetUnlockEntryIndexToCelebrate( T* p, lua_State *L ) { lua_pushnumber( L, p->GetUnlockEntryIndexToCelebrate() ); return 1; }
static int GetNumUnlocked( T* p, lua_State *L ) { lua_pushnumber( L, p->GetNumUnlocked() ); return 1; }
static int AnyUnlocksToCelebrate( T* p, lua_State *L ) { lua_pushboolean( L, p->AnyUnlocksToCelebrate() ); 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 )
@@ -744,8 +738,7 @@ public:
ADD_METHOD( UnlockEntryIndex );
ADD_METHOD( PreferUnlockEntryID );
ADD_METHOD( GetNumUnlocks );
ADD_METHOD( AnyRequirementsAreMet );
ADD_METHOD( GetUnlockEntryIndexToCelebrate );
ADD_METHOD( GetNumUnlocked );
ADD_METHOD( AnyUnlocksToCelebrate );
ADD_METHOD( GetUnlockEntry );
ADD_METHOD( GetSongsUnlockedByEntryID );
+9 -3
View File
@@ -39,6 +39,11 @@ enum UnlockRewardType {
const RString& UnlockRewardTypeToString( UnlockRewardType i );
const RString& UnlockRewardTypeToLocalizedString( UnlockRewardType i );
enum UnlockEntryStatus {
UnlockEntryStatus_RequrementsNotMet,
UnlockEntryStatus_RequirementsMet,
UnlockEntryStatus_Unlocked,
};
class UnlockEntry
{
@@ -70,8 +75,9 @@ public:
int m_iEntryID;
bool IsValid() const;
bool IsRequirementMet() const;
bool IsLocked() const;
bool IsLocked() const { return GetUnlockEntryStatus() != UnlockEntryStatus_Unlocked; }
//bool IsUnlocked() const { return !IsLocked(); }
UnlockEntryStatus GetUnlockEntryStatus() const;
RString GetModifier() const { return m_cmd.GetArg(1).s; }
RString GetDescription() const;
RString GetBannerFile() const;
@@ -104,7 +110,7 @@ public:
// Gets number of unlocks for title screen
int GetNumUnlocks() const;
bool AnyRequirementsAreMet() const;
int GetNumUnlocked() const;
int GetUnlockEntryIndexToCelebrate() const;
bool AnyUnlocksToCelebrate() const;