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