2003-07-09 03:10:01 +00:00
|
|
|
#include "global.h"
|
2006-01-28 21:37:13 +00:00
|
|
|
#include "UnlockManager.h"
|
2003-07-09 03:10:01 +00:00
|
|
|
#include "PrefsManager.h"
|
|
|
|
|
#include "RageLog.h"
|
2003-07-09 05:57:09 +00:00
|
|
|
#include "song.h"
|
2003-07-11 18:08:57 +00:00
|
|
|
#include "Course.h"
|
2003-07-09 03:10:01 +00:00
|
|
|
#include "RageUtil.h"
|
2003-07-09 05:01:37 +00:00
|
|
|
#include "SongManager.h"
|
2003-07-11 18:08:57 +00:00
|
|
|
#include "GameState.h"
|
2004-02-22 08:16:49 +00:00
|
|
|
#include "ProfileManager.h"
|
2005-07-01 05:07:22 +00:00
|
|
|
#include "Profile.h"
|
2005-02-25 01:28:45 +00:00
|
|
|
#include "ThemeManager.h"
|
2005-03-29 00:31:57 +00:00
|
|
|
#include "Foreach.h"
|
2005-04-24 19:41:52 +00:00
|
|
|
#include "Steps.h"
|
2005-03-29 19:10:42 +00:00
|
|
|
#include <float.h>
|
2006-01-29 22:17:43 +00:00
|
|
|
#include "CommonMetrics.h"
|
|
|
|
|
#include "LuaFunctions.h"
|
2003-07-09 03:10:01 +00:00
|
|
|
|
2005-02-21 06:13:31 +00:00
|
|
|
UnlockManager* UNLOCKMAN = NULL; // global and accessable from anywhere in our program
|
2003-09-19 07:02:53 +00:00
|
|
|
|
2006-01-28 21:37:13 +00:00
|
|
|
#define UNLOCK_NAMES THEME->GetMetric ("Unlocks","UnlockNames")
|
|
|
|
|
#define UNLOCK(sLineName) THEME->GetMetric ("Unlocks",ssprintf("Unlock%s",sLineName.c_str()))
|
2003-12-10 09:26:05 +00:00
|
|
|
|
2006-01-29 22:17:43 +00:00
|
|
|
static const char *UnlockRequirementNames[] =
|
2003-07-09 03:10:01 +00:00
|
|
|
{
|
2005-02-25 01:28:45 +00:00
|
|
|
"ArcadePoints",
|
|
|
|
|
"DancePoints",
|
|
|
|
|
"SongPoints",
|
|
|
|
|
"ExtraCleared",
|
|
|
|
|
"ExtraFailed",
|
|
|
|
|
"Toasties",
|
|
|
|
|
"StagesCleared"
|
2004-01-24 23:40:40 +00:00
|
|
|
};
|
2006-01-29 22:17:43 +00:00
|
|
|
XToString( UnlockRequirement, NUM_UnlockRequirement );
|
|
|
|
|
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)) );
|
2003-09-19 07:02:53 +00:00
|
|
|
|
2005-02-21 06:13:31 +00:00
|
|
|
UnlockManager::UnlockManager()
|
2004-01-24 23:40:40 +00:00
|
|
|
{
|
2004-02-21 01:06:35 +00:00
|
|
|
UNLOCKMAN = this;
|
2004-01-25 16:24:34 +00:00
|
|
|
|
2004-02-22 05:16:12 +00:00
|
|
|
Load();
|
2003-07-09 03:10:01 +00:00
|
|
|
}
|
|
|
|
|
|
2005-02-21 06:13:31 +00:00
|
|
|
void UnlockManager::UnlockSong( const Song *song )
|
2003-07-09 11:38:50 +00:00
|
|
|
{
|
2004-01-25 16:24:34 +00:00
|
|
|
const UnlockEntry *p = FindSong( song );
|
2004-01-24 19:39:18 +00:00
|
|
|
if( !p )
|
2003-07-18 08:04:47 +00:00
|
|
|
return; // does not exist
|
2006-01-28 22:08:16 +00:00
|
|
|
if( p->m_iEntryID == -1 )
|
2004-01-25 16:24:34 +00:00
|
|
|
return;
|
2003-07-09 11:38:50 +00:00
|
|
|
|
2006-01-28 22:08:16 +00:00
|
|
|
UnlockEntryID( p->m_iEntryID );
|
2003-07-09 11:38:50 +00:00
|
|
|
}
|
|
|
|
|
|
2006-01-28 22:08:16 +00:00
|
|
|
int UnlockManager::FindEntryID( const RString &sName ) const
|
2005-04-24 00:07:12 +00:00
|
|
|
{
|
|
|
|
|
const UnlockEntry *pEntry = NULL;
|
|
|
|
|
|
|
|
|
|
const Song *pSong = SONGMAN->FindSong( sName );
|
|
|
|
|
if( pSong != NULL )
|
|
|
|
|
pEntry = FindSong( pSong );
|
|
|
|
|
|
|
|
|
|
const Course *pCourse = SONGMAN->FindCourse( sName );
|
|
|
|
|
if( pCourse != NULL )
|
|
|
|
|
pEntry = FindCourse( pCourse );
|
|
|
|
|
|
|
|
|
|
if( pEntry == NULL )
|
|
|
|
|
pEntry = FindModifier( sName );
|
|
|
|
|
|
|
|
|
|
if( pEntry == NULL )
|
|
|
|
|
{
|
|
|
|
|
LOG->Warn( "Couldn't find locked entry \"%s\"", sName.c_str() );
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
2006-01-28 22:08:16 +00:00
|
|
|
return pEntry->m_iEntryID;
|
2005-04-24 00:07:12 +00:00
|
|
|
}
|
|
|
|
|
|
2005-02-21 06:13:31 +00:00
|
|
|
bool UnlockManager::CourseIsLocked( const Course *course ) const
|
2003-07-10 11:24:16 +00:00
|
|
|
{
|
2003-07-18 08:04:47 +00:00
|
|
|
if( !PREFSMAN->m_bUseUnlockSystem )
|
|
|
|
|
return false;
|
|
|
|
|
|
2004-02-22 21:25:22 +00:00
|
|
|
const UnlockEntry *p = FindCourse( course );
|
2004-01-24 19:39:18 +00:00
|
|
|
if( p == NULL )
|
|
|
|
|
return false;
|
2003-07-10 11:24:16 +00:00
|
|
|
|
2004-01-25 16:24:34 +00:00
|
|
|
return p->IsLocked();
|
2003-07-10 11:24:16 +00:00
|
|
|
}
|
2003-07-09 03:10:01 +00:00
|
|
|
|
2005-02-21 06:13:31 +00:00
|
|
|
bool UnlockManager::SongIsLocked( const Song *song ) const
|
2003-07-09 04:46:24 +00:00
|
|
|
{
|
2003-07-18 08:04:47 +00:00
|
|
|
if( !PREFSMAN->m_bUseUnlockSystem )
|
|
|
|
|
return false;
|
|
|
|
|
|
2004-02-22 21:25:22 +00:00
|
|
|
const UnlockEntry *p = FindSong( song );
|
2003-07-12 20:16:07 +00:00
|
|
|
if( p == NULL )
|
|
|
|
|
return false;
|
2003-07-09 11:38:50 +00:00
|
|
|
|
2004-01-25 16:24:34 +00:00
|
|
|
return p->IsLocked();
|
2003-07-09 04:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
2004-02-26 20:35:46 +00:00
|
|
|
/* Return true if the song is *only* available in roulette. */
|
2005-02-21 06:13:31 +00:00
|
|
|
bool UnlockManager::SongIsRouletteOnly( const Song *song ) const
|
2003-07-09 04:46:24 +00:00
|
|
|
{
|
2004-01-24 22:55:59 +00:00
|
|
|
if( !PREFSMAN->m_bUseUnlockSystem )
|
|
|
|
|
return false;
|
|
|
|
|
|
2004-01-24 19:39:18 +00:00
|
|
|
const UnlockEntry *p = FindSong( song );
|
2005-04-24 19:41:52 +00:00
|
|
|
if( p == NULL )
|
2004-01-25 16:24:34 +00:00
|
|
|
return false;
|
2003-07-09 11:38:50 +00:00
|
|
|
|
2004-01-25 16:24:34 +00:00
|
|
|
/* If the song is locked by a code, and it's a roulette code, honor IsLocked. */
|
2006-01-28 22:08:16 +00:00
|
|
|
if( p->m_iEntryID == -1 || m_RouletteCodes.find( p->m_iEntryID ) == m_RouletteCodes.end() )
|
2004-02-26 20:35:46 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
return p->IsLocked();
|
2003-07-09 04:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
2005-04-24 19:41:52 +00:00
|
|
|
bool UnlockManager::StepsIsLocked( const Song *pSong, const Steps *pSteps ) const
|
|
|
|
|
{
|
|
|
|
|
if( !PREFSMAN->m_bUseUnlockSystem )
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
const UnlockEntry *p = FindSteps( pSong, pSteps );
|
|
|
|
|
if( p == NULL )
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
return p->IsLocked();
|
|
|
|
|
}
|
|
|
|
|
|
2006-01-22 01:00:06 +00:00
|
|
|
bool UnlockManager::ModifierIsLocked( const RString &sOneMod ) const
|
2003-07-10 14:44:13 +00:00
|
|
|
{
|
2005-03-29 01:44:36 +00:00
|
|
|
if( !PREFSMAN->m_bUseUnlockSystem )
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
const UnlockEntry *p = FindModifier( sOneMod );
|
|
|
|
|
if( p == NULL )
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
return p->IsLocked();
|
|
|
|
|
}
|
2003-07-10 14:44:13 +00:00
|
|
|
|
2005-04-24 19:41:52 +00:00
|
|
|
const UnlockEntry *UnlockManager::FindSong( const Song *pSong ) const
|
2005-03-29 01:44:36 +00:00
|
|
|
{
|
|
|
|
|
FOREACH_CONST( UnlockEntry, m_UnlockEntries, e )
|
2005-04-24 19:41:52 +00:00
|
|
|
if( e->m_pSong == pSong && e->m_dc == DIFFICULTY_INVALID )
|
2005-03-29 01:44:36 +00:00
|
|
|
return &(*e);
|
2003-07-10 14:44:13 +00:00
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2005-04-24 19:41:52 +00:00
|
|
|
const UnlockEntry *UnlockManager::FindSteps( const Song *pSong, const Steps *pSteps ) const
|
2003-07-10 11:24:16 +00:00
|
|
|
{
|
2005-05-26 08:07:42 +00:00
|
|
|
ASSERT( pSong && pSteps );
|
2005-03-29 01:44:36 +00:00
|
|
|
FOREACH_CONST( UnlockEntry, m_UnlockEntries, e )
|
2005-04-24 19:41:52 +00:00
|
|
|
if( e->m_pSong == pSong && e->m_dc == pSteps->GetDifficulty() )
|
2005-03-29 01:44:36 +00:00
|
|
|
return &(*e);
|
2003-07-10 11:24:16 +00:00
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2005-02-21 06:13:31 +00:00
|
|
|
const UnlockEntry *UnlockManager::FindCourse( const Course *pCourse ) const
|
2003-07-09 03:10:01 +00:00
|
|
|
{
|
2005-03-29 01:44:36 +00:00
|
|
|
FOREACH_CONST( UnlockEntry, m_UnlockEntries, e )
|
|
|
|
|
if( e->m_pCourse == pCourse )
|
|
|
|
|
return &(*e);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2003-07-09 13:54:23 +00:00
|
|
|
|
2006-01-22 01:00:06 +00:00
|
|
|
const UnlockEntry *UnlockManager::FindModifier( const RString &sOneMod ) const
|
2005-03-29 01:44:36 +00:00
|
|
|
{
|
|
|
|
|
FOREACH_CONST( UnlockEntry, m_UnlockEntries, e )
|
2006-01-29 22:17:43 +00:00
|
|
|
if( e->GetModifier() == 0 )
|
2005-03-29 01:44:36 +00:00
|
|
|
return &(*e);
|
2003-07-09 05:01:37 +00:00
|
|
|
return NULL;
|
2003-07-09 03:10:01 +00:00
|
|
|
}
|
|
|
|
|
|
2004-02-22 08:16:49 +00:00
|
|
|
static float GetArcadePoints( const Profile *pProfile )
|
|
|
|
|
{
|
|
|
|
|
float fAP = 0;
|
|
|
|
|
|
|
|
|
|
FOREACH_Grade(g)
|
|
|
|
|
{
|
|
|
|
|
switch(g)
|
|
|
|
|
{
|
2005-08-14 11:38:31 +00:00
|
|
|
case Grade_Tier01:
|
|
|
|
|
case Grade_Tier02: fAP += 9 * pProfile->m_iNumStagesPassedByGrade[g]; break;
|
2004-08-30 06:07:14 +00:00
|
|
|
default: fAP += 1 * pProfile->m_iNumStagesPassedByGrade[g]; break;
|
2004-02-22 08:16:49 +00:00
|
|
|
|
2005-08-14 11:38:31 +00:00
|
|
|
case Grade_Failed:
|
|
|
|
|
case Grade_NoData:
|
2004-02-22 08:16:49 +00:00
|
|
|
; // no points
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FOREACH_PlayMode(pm)
|
|
|
|
|
{
|
|
|
|
|
switch(pm)
|
|
|
|
|
{
|
|
|
|
|
case PLAY_MODE_NONSTOP:
|
|
|
|
|
case PLAY_MODE_ONI:
|
|
|
|
|
case PLAY_MODE_ENDLESS:
|
|
|
|
|
fAP += pProfile->m_iNumSongsPlayedByPlayMode[pm];
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return fAP;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static float GetSongPoints( const Profile *pProfile )
|
|
|
|
|
{
|
|
|
|
|
float fSP = 0;
|
|
|
|
|
|
|
|
|
|
FOREACH_Grade(g)
|
|
|
|
|
{
|
|
|
|
|
switch( g )
|
|
|
|
|
{
|
2005-08-14 11:38:31 +00:00
|
|
|
case Grade_Tier01:/*AAAA*/ fSP += 20 * pProfile->m_iNumStagesPassedByGrade[g]; break;
|
|
|
|
|
case Grade_Tier02:/*AAA*/ fSP += 10* pProfile->m_iNumStagesPassedByGrade[g]; break;
|
|
|
|
|
case Grade_Tier03:/*AA*/ fSP += 5* pProfile->m_iNumStagesPassedByGrade[g]; break;
|
|
|
|
|
case Grade_Tier04:/*A*/ fSP += 4* pProfile->m_iNumStagesPassedByGrade[g]; break;
|
|
|
|
|
case Grade_Tier05:/*B*/ fSP += 3* pProfile->m_iNumStagesPassedByGrade[g]; break;
|
|
|
|
|
case Grade_Tier06:/*C*/ fSP += 2* pProfile->m_iNumStagesPassedByGrade[g]; break;
|
|
|
|
|
case Grade_Tier07:/*D*/ fSP += 1* pProfile->m_iNumStagesPassedByGrade[g]; break;
|
|
|
|
|
case Grade_Failed:
|
|
|
|
|
case Grade_NoData:
|
2004-02-22 08:16:49 +00:00
|
|
|
; // no points
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FOREACH_PlayMode(pm)
|
|
|
|
|
{
|
|
|
|
|
switch(pm)
|
|
|
|
|
{
|
|
|
|
|
case PLAY_MODE_NONSTOP:
|
|
|
|
|
case PLAY_MODE_ONI:
|
|
|
|
|
case PLAY_MODE_ENDLESS:
|
|
|
|
|
fSP += pProfile->m_iNumSongsPlayedByPlayMode[pm];
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return fSP;
|
|
|
|
|
}
|
|
|
|
|
|
2006-01-29 22:17:43 +00:00
|
|
|
void UnlockManager::GetPoints( const Profile *pProfile, float fScores[NUM_UnlockRequirement] ) const
|
2004-02-22 08:16:49 +00:00
|
|
|
{
|
2006-01-29 22:17:43 +00:00
|
|
|
fScores[UnlockRequirement_ArcadePoints] = GetArcadePoints( pProfile );
|
|
|
|
|
fScores[UnlockRequirement_SongPoints] = GetSongPoints( pProfile );
|
|
|
|
|
fScores[UnlockRequirement_DancePoints] = (float) pProfile->m_iTotalDancePoints;
|
|
|
|
|
fScores[UnlockRequirement_StagesCleared] = (float) pProfile->GetTotalNumSongsPassed();
|
2004-02-22 08:16:49 +00:00
|
|
|
}
|
2003-07-09 03:10:01 +00:00
|
|
|
|
2005-04-30 04:11:55 +00:00
|
|
|
/* Return true if all songs and/or courses referenced by an unlock are available. */
|
|
|
|
|
bool UnlockEntry::IsValid() const
|
|
|
|
|
{
|
|
|
|
|
switch( m_Type )
|
|
|
|
|
{
|
2006-01-29 22:17:43 +00:00
|
|
|
case UnlockRewardType_Song:
|
2005-04-30 04:11:55 +00:00
|
|
|
return m_pSong != NULL;
|
|
|
|
|
|
2006-01-29 22:17:43 +00:00
|
|
|
case UnlockRewardType_Steps:
|
2005-04-30 04:11:55 +00:00
|
|
|
return m_pSong != NULL && m_dc != DIFFICULTY_INVALID;
|
|
|
|
|
|
2006-01-29 22:17:43 +00:00
|
|
|
case UnlockRewardType_Course:
|
2005-04-30 04:11:55 +00:00
|
|
|
return m_pCourse != NULL;
|
|
|
|
|
|
2006-01-29 22:17:43 +00:00
|
|
|
case UnlockRewardType_Modifier:
|
2005-04-30 04:11:55 +00:00
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
WARN( ssprintf("%i", m_Type) );
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2004-01-25 16:24:34 +00:00
|
|
|
bool UnlockEntry::IsLocked() const
|
2003-07-09 03:10:01 +00:00
|
|
|
{
|
2006-01-29 22:17:43 +00:00
|
|
|
float fScores[NUM_UnlockRequirement];
|
2004-02-22 08:16:49 +00:00
|
|
|
UNLOCKMAN->GetPoints( PROFILEMAN->GetMachineProfile(), fScores );
|
|
|
|
|
|
2006-01-29 22:17:43 +00:00
|
|
|
for( int i = 0; i < NUM_UnlockRequirement; ++i )
|
|
|
|
|
if( m_fRequirement[i] && fScores[i] >= m_fRequirement[i] )
|
2004-01-25 16:24:34 +00:00
|
|
|
return false;
|
2003-07-09 03:10:01 +00:00
|
|
|
|
2006-01-28 22:08:16 +00:00
|
|
|
if( m_iEntryID != -1 && PROFILEMAN->GetMachineProfile()->m_UnlockedEntryIDs.find(m_iEntryID) != PROFILEMAN->GetMachineProfile()->m_UnlockedEntryIDs.end() )
|
2004-01-25 16:24:34 +00:00
|
|
|
return false;
|
2003-07-09 11:38:50 +00:00
|
|
|
|
2004-01-25 16:24:34 +00:00
|
|
|
return true;
|
2003-07-09 03:10:01 +00:00
|
|
|
}
|
|
|
|
|
|
2006-01-29 22:17:43 +00:00
|
|
|
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 "";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////
|
|
|
|
|
|
2005-02-25 01:28:45 +00:00
|
|
|
void UnlockManager::Load()
|
2004-02-22 05:16:12 +00:00
|
|
|
{
|
2005-02-21 06:13:31 +00:00
|
|
|
LOG->Trace( "UnlockManager::Load()" );
|
2004-02-22 05:16:12 +00:00
|
|
|
|
2006-01-22 01:00:06 +00:00
|
|
|
vector<RString> asUnlockNames;
|
2005-02-25 01:28:45 +00:00
|
|
|
split( UNLOCK_NAMES, ",", asUnlockNames );
|
|
|
|
|
if( asUnlockNames.empty() )
|
|
|
|
|
return;
|
2003-07-09 03:10:01 +00:00
|
|
|
|
2005-02-25 01:28:45 +00:00
|
|
|
for( unsigned i = 0; i < asUnlockNames.size(); ++i )
|
2003-07-09 03:10:01 +00:00
|
|
|
{
|
2006-01-22 01:00:06 +00:00
|
|
|
const RString &sUnlockName = asUnlockNames[i];
|
|
|
|
|
RString sUnlock = UNLOCK(sUnlockName);
|
2003-07-14 06:36:29 +00:00
|
|
|
|
2005-02-25 01:28:45 +00:00
|
|
|
Commands vCommands;
|
|
|
|
|
ParseCommands( sUnlock, vCommands );
|
2003-07-09 03:10:01 +00:00
|
|
|
|
2003-08-11 20:57:57 +00:00
|
|
|
UnlockEntry current;
|
2005-02-25 01:28:45 +00:00
|
|
|
bool bRoulette = false;
|
2003-07-09 03:10:01 +00:00
|
|
|
|
2005-02-25 01:28:45 +00:00
|
|
|
for( unsigned j = 0; j < vCommands.v.size(); ++j )
|
2003-07-09 03:10:01 +00:00
|
|
|
{
|
2005-02-25 01:28:45 +00:00
|
|
|
const Command &cmd = vCommands.v[j];
|
2006-01-22 01:00:06 +00:00
|
|
|
RString sName = cmd.GetName();
|
2005-03-29 01:44:36 +00:00
|
|
|
|
|
|
|
|
if( sName == "song" )
|
|
|
|
|
{
|
2006-01-29 22:17:43 +00:00
|
|
|
current.m_Type = UnlockRewardType_Song;
|
2005-04-24 19:41:52 +00:00
|
|
|
current.m_cmd = cmd;
|
|
|
|
|
}
|
|
|
|
|
if( sName == "steps" )
|
|
|
|
|
{
|
2006-01-29 22:17:43 +00:00
|
|
|
current.m_Type = UnlockRewardType_Steps;
|
2005-04-24 19:41:52 +00:00
|
|
|
current.m_cmd = cmd;
|
2005-03-29 01:44:36 +00:00
|
|
|
}
|
|
|
|
|
if( sName == "course" )
|
|
|
|
|
{
|
2006-01-29 22:17:43 +00:00
|
|
|
current.m_Type = UnlockRewardType_Course;
|
2005-04-24 19:41:52 +00:00
|
|
|
current.m_cmd = cmd;
|
2005-03-29 01:44:36 +00:00
|
|
|
}
|
2005-03-29 02:02:11 +00:00
|
|
|
if( sName == "mod" )
|
2005-03-29 01:44:36 +00:00
|
|
|
{
|
2006-01-29 22:17:43 +00:00
|
|
|
current.m_Type = UnlockRewardType_Modifier;
|
2005-04-24 19:41:52 +00:00
|
|
|
current.m_cmd = cmd;
|
2005-03-29 01:44:36 +00:00
|
|
|
}
|
|
|
|
|
else if( sName == "code" )
|
2005-02-25 01:46:10 +00:00
|
|
|
{
|
|
|
|
|
// Hack: Lua only has a floating point type, and codes may be big enough
|
|
|
|
|
// that converting them from string to float to int introduces rounding
|
|
|
|
|
// error. Convert directly to int.
|
2006-01-28 22:08:16 +00:00
|
|
|
current.m_iEntryID = atoi( (RString) cmd.GetArg(1) );
|
2005-02-25 01:46:10 +00:00
|
|
|
}
|
2005-03-29 01:44:36 +00:00
|
|
|
else if( sName == "roulette" )
|
|
|
|
|
{
|
2005-02-25 01:28:45 +00:00
|
|
|
bRoulette = true;
|
2005-03-29 01:44:36 +00:00
|
|
|
}
|
2005-02-25 01:28:45 +00:00
|
|
|
else
|
2003-07-14 06:36:29 +00:00
|
|
|
{
|
2006-01-29 22:17:43 +00:00
|
|
|
const UnlockRequirement ut = StringToUnlockRequirement( cmd.GetName() );
|
|
|
|
|
if( ut != UnlockRequirement_INVALID )
|
|
|
|
|
current.m_fRequirement[ut] = cmd.GetArg(1);
|
2003-07-14 06:36:29 +00:00
|
|
|
}
|
2003-07-09 14:16:21 +00:00
|
|
|
}
|
2003-07-16 12:58:02 +00:00
|
|
|
|
2005-02-25 01:28:45 +00:00
|
|
|
if( bRoulette )
|
2006-01-28 22:08:16 +00:00
|
|
|
m_RouletteCodes.insert( current.m_iEntryID );
|
2005-02-25 01:28:45 +00:00
|
|
|
|
2006-01-30 08:13:16 +00:00
|
|
|
// TODO: Persist celebrated info?
|
|
|
|
|
if( !current.IsLocked() )
|
|
|
|
|
current.m_bCelebrated = false;
|
|
|
|
|
|
2006-02-01 07:34:12 +00:00
|
|
|
// Make sure that we don't have duplicate unlock IDs. This can cause problems
|
|
|
|
|
// with UnlockCelebrate and with codes.
|
|
|
|
|
FOREACH_CONST( UnlockEntry, m_UnlockEntries, ue )
|
|
|
|
|
ASSERT( ue->m_iEntryID != current.m_iEntryID );
|
|
|
|
|
|
2005-03-29 01:44:36 +00:00
|
|
|
m_UnlockEntries.push_back( current );
|
2003-07-09 03:10:01 +00:00
|
|
|
}
|
2003-07-15 00:52:01 +00:00
|
|
|
|
2005-04-24 19:41:52 +00:00
|
|
|
UpdateCachedPointers();
|
2004-02-22 05:16:12 +00:00
|
|
|
|
2005-03-29 01:44:36 +00:00
|
|
|
FOREACH_CONST( UnlockEntry, m_UnlockEntries, e )
|
2003-07-09 11:38:50 +00:00
|
|
|
{
|
2006-01-22 01:00:06 +00:00
|
|
|
RString str = ssprintf( "Unlock: %s; ", join("\n",e->m_cmd.m_vsArgs).c_str() );
|
2006-01-29 22:17:43 +00:00
|
|
|
FOREACH_ENUM2( UnlockRequirement, j )
|
|
|
|
|
if( e->m_fRequirement[j] )
|
|
|
|
|
str += ssprintf( "%s = %f; ", UnlockRequirementToString(j).c_str(), e->m_fRequirement[j] );
|
2004-02-22 05:16:12 +00:00
|
|
|
|
2006-01-28 22:08:16 +00:00
|
|
|
str += ssprintf( "entryID = %i ", e->m_iEntryID );
|
2005-03-29 01:44:36 +00:00
|
|
|
str += e->IsLocked()? "locked":"unlocked";
|
|
|
|
|
if( e->m_pSong )
|
2004-08-05 20:15:54 +00:00
|
|
|
str += ( " (found song)" );
|
2005-03-29 01:44:36 +00:00
|
|
|
if( e->m_pCourse )
|
2004-08-05 20:15:54 +00:00
|
|
|
str += ( " (found course)" );
|
2004-08-05 17:50:30 +00:00
|
|
|
LOG->Trace( "%s", str.c_str() );
|
2003-07-09 11:38:50 +00:00
|
|
|
}
|
2003-07-09 03:10:01 +00:00
|
|
|
|
2005-02-25 01:28:45 +00:00
|
|
|
return;
|
2003-07-09 03:10:01 +00:00
|
|
|
}
|
|
|
|
|
|
2006-01-29 22:17:43 +00:00
|
|
|
float UnlockManager::PointsUntilNextUnlock( UnlockRequirement t ) const
|
2003-07-09 06:05:43 +00:00
|
|
|
{
|
2006-01-29 22:17:43 +00:00
|
|
|
float fScores[NUM_UnlockRequirement];
|
2004-02-22 08:16:49 +00:00
|
|
|
UNLOCKMAN->GetPoints( PROFILEMAN->GetMachineProfile(), fScores );
|
|
|
|
|
|
2005-03-29 19:10:42 +00:00
|
|
|
float fSmallestPoints = FLT_MAX; // or an arbitrarily large value
|
2005-03-29 01:44:36 +00:00
|
|
|
for( unsigned a=0; a<m_UnlockEntries.size(); a++ )
|
2006-01-29 22:17:43 +00:00
|
|
|
if( m_UnlockEntries[a].m_fRequirement[t] > fScores[t] )
|
|
|
|
|
fSmallestPoints = min( fSmallestPoints, m_UnlockEntries[a].m_fRequirement[t] );
|
2003-07-09 06:05:43 +00:00
|
|
|
|
2005-03-29 19:10:42 +00:00
|
|
|
if( fSmallestPoints == FLT_MAX )
|
2004-01-24 19:39:18 +00:00
|
|
|
return 0; // no match found
|
2004-02-22 08:16:49 +00:00
|
|
|
return fSmallestPoints - fScores[t];
|
2003-07-09 06:05:43 +00:00
|
|
|
}
|
|
|
|
|
|
2005-03-29 01:44:36 +00:00
|
|
|
/* Update the cached pointers. Only call this when it's likely to have changed,
|
2003-07-18 06:38:05 +00:00
|
|
|
* such as on load, or when a song title changes in the editor. */
|
2005-04-24 19:41:52 +00:00
|
|
|
void UnlockManager::UpdateCachedPointers()
|
2003-07-09 05:01:37 +00:00
|
|
|
{
|
2005-03-29 01:44:36 +00:00
|
|
|
FOREACH( UnlockEntry, m_UnlockEntries, e )
|
2003-07-18 06:38:05 +00:00
|
|
|
{
|
2005-03-29 01:44:36 +00:00
|
|
|
switch( e->m_Type )
|
2003-08-11 22:37:46 +00:00
|
|
|
{
|
2006-01-29 22:17:43 +00:00
|
|
|
case UnlockRewardType_Song:
|
2005-04-24 19:41:52 +00:00
|
|
|
e->m_pSong = SONGMAN->FindSong( e->m_cmd.GetArg(1) );
|
2005-03-29 01:44:36 +00:00
|
|
|
if( e->m_pSong == NULL )
|
2005-04-24 19:41:52 +00:00
|
|
|
LOG->Warn( "Unlock: Cannot find song matching \"%s\"", e->m_cmd.GetArg(1).s.c_str() );
|
|
|
|
|
break;
|
2006-01-29 22:17:43 +00:00
|
|
|
case UnlockRewardType_Steps:
|
2005-04-24 19:41:52 +00:00
|
|
|
e->m_pSong = SONGMAN->FindSong( e->m_cmd.GetArg(1) );
|
|
|
|
|
if( e->m_pSong == NULL )
|
|
|
|
|
{
|
|
|
|
|
LOG->Warn( "Unlock: Cannot find song matching \"%s\"", e->m_cmd.GetArg(1).s.c_str() );
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
e->m_dc = StringToDifficulty( e->m_cmd.GetArg(2) );
|
|
|
|
|
if( e->m_dc == DIFFICULTY_INVALID )
|
|
|
|
|
{
|
|
|
|
|
LOG->Warn( "Unlock: Invalid difficulty \"%s\"", e->m_cmd.GetArg(2).s.c_str() );
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2005-03-29 01:44:36 +00:00
|
|
|
break;
|
2006-01-29 22:17:43 +00:00
|
|
|
case UnlockRewardType_Course:
|
2005-04-24 19:41:52 +00:00
|
|
|
e->m_pCourse = SONGMAN->FindCourse( e->m_cmd.GetArg(1) );
|
2005-03-29 01:44:36 +00:00
|
|
|
if( e->m_pCourse == NULL )
|
2005-04-24 19:41:52 +00:00
|
|
|
LOG->Warn( "Unlock: Cannot find course matching \"%s\"", e->m_cmd.GetArg(1).s.c_str() );
|
2005-03-29 01:44:36 +00:00
|
|
|
break;
|
2006-01-29 22:17:43 +00:00
|
|
|
case UnlockRewardType_Modifier:
|
2005-03-29 01:44:36 +00:00
|
|
|
// nothing to cache
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
ASSERT(0);
|
2003-08-11 22:37:46 +00:00
|
|
|
}
|
2003-07-18 06:38:05 +00:00
|
|
|
}
|
2003-07-09 05:01:37 +00:00
|
|
|
}
|
2003-07-09 13:54:23 +00:00
|
|
|
|
2003-07-11 09:35:28 +00:00
|
|
|
|
2004-01-25 16:24:34 +00:00
|
|
|
|
2006-01-28 22:08:16 +00:00
|
|
|
void UnlockManager::UnlockEntryID( int iEntryID )
|
2004-01-25 16:24:34 +00:00
|
|
|
{
|
2004-02-22 08:16:49 +00:00
|
|
|
FOREACH_PlayerNumber( pn )
|
2005-05-09 08:44:01 +00:00
|
|
|
if( PROFILEMAN->IsPersistentProfile(pn) )
|
2006-01-28 22:08:16 +00:00
|
|
|
PROFILEMAN->GetProfile(pn)->m_UnlockedEntryIDs.insert( iEntryID );
|
2004-02-22 08:16:49 +00:00
|
|
|
|
2006-01-28 22:08:16 +00:00
|
|
|
PROFILEMAN->GetMachineProfile()->m_UnlockedEntryIDs.insert( iEntryID );
|
2003-07-11 18:08:57 +00:00
|
|
|
}
|
2003-07-25 00:03:05 +00:00
|
|
|
|
2006-01-28 22:08:16 +00:00
|
|
|
void UnlockManager::PreferUnlockEntryID( int iUnlockEntryID )
|
2005-02-24 22:34:54 +00:00
|
|
|
{
|
2005-03-29 01:44:36 +00:00
|
|
|
for( unsigned i = 0; i < m_UnlockEntries.size(); ++i )
|
2005-02-24 22:34:54 +00:00
|
|
|
{
|
2005-03-29 01:44:36 +00:00
|
|
|
UnlockEntry &pEntry = m_UnlockEntries[i];
|
2006-01-28 22:08:16 +00:00
|
|
|
if( pEntry.m_iEntryID != iUnlockEntryID )
|
2005-02-24 22:34:54 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
if( pEntry.m_pSong != NULL )
|
|
|
|
|
GAMESTATE->m_pPreferredSong = pEntry.m_pSong;
|
|
|
|
|
if( pEntry.m_pCourse != NULL )
|
|
|
|
|
GAMESTATE->m_pPreferredCourse = pEntry.m_pCourse;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2005-02-21 06:13:31 +00:00
|
|
|
int UnlockManager::GetNumUnlocks() const
|
2003-07-25 00:03:05 +00:00
|
|
|
{
|
2005-03-29 01:44:36 +00:00
|
|
|
return m_UnlockEntries.size();
|
2003-08-10 03:23:17 +00:00
|
|
|
}
|
2004-06-08 01:24:17 +00:00
|
|
|
|
2006-01-30 08:13:16 +00:00
|
|
|
bool UnlockManager::AllAreLocked() const
|
|
|
|
|
{
|
|
|
|
|
FOREACH_CONST( UnlockEntry, m_UnlockEntries, ue )
|
|
|
|
|
{
|
|
|
|
|
if( !ue->IsLocked() )
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int UnlockManager::GetUnlockIndexToCelebrate() const
|
|
|
|
|
{
|
|
|
|
|
FOREACH_CONST( UnlockEntry, m_UnlockEntries, ue )
|
|
|
|
|
{
|
|
|
|
|
if( !ue->IsLocked() && !ue->m_bCelebrated )
|
|
|
|
|
return ue - m_UnlockEntries.begin();
|
|
|
|
|
}
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool UnlockManager::AnyUnlocksToCelebrate() const
|
|
|
|
|
{
|
|
|
|
|
return GetUnlockIndexToCelebrate() != -1;
|
|
|
|
|
}
|
|
|
|
|
|
2006-01-29 22:17:43 +00:00
|
|
|
void UnlockManager::GetUnlocksByType( UnlockRewardType t, vector<UnlockEntry *> &apEntries )
|
2005-04-30 04:11:55 +00:00
|
|
|
{
|
|
|
|
|
for( unsigned i = 0; i < m_UnlockEntries.size(); ++i )
|
|
|
|
|
if( m_UnlockEntries[i].IsValid() && m_UnlockEntries[i].m_Type == t )
|
|
|
|
|
apEntries.push_back( &m_UnlockEntries[i] );
|
|
|
|
|
}
|
|
|
|
|
|
2006-01-28 22:08:16 +00:00
|
|
|
void UnlockManager::GetSongsUnlockedByEntryID( vector<Song *> &apSongsOut, int iUnlockEntryID )
|
2005-04-30 04:11:55 +00:00
|
|
|
{
|
|
|
|
|
vector<UnlockEntry *> apEntries;
|
2006-01-29 22:17:43 +00:00
|
|
|
GetUnlocksByType( UnlockRewardType_Song, apEntries );
|
2005-04-30 04:11:55 +00:00
|
|
|
|
|
|
|
|
for( unsigned i = 0; i < apEntries.size(); ++i )
|
2006-01-28 22:08:16 +00:00
|
|
|
if( apEntries[i]->m_iEntryID == iUnlockEntryID )
|
2005-04-30 04:11:55 +00:00
|
|
|
apSongsOut.push_back( apEntries[i]->m_pSong );
|
|
|
|
|
}
|
|
|
|
|
|
2006-01-28 22:08:16 +00:00
|
|
|
void UnlockManager::GetStepsUnlockedByEntryID( vector<Song *> &apSongsOut, vector<Difficulty> &apDifficultyOut, int iUnlockEntryID )
|
2005-04-30 04:11:55 +00:00
|
|
|
{
|
|
|
|
|
vector<UnlockEntry *> apEntries;
|
2006-01-29 22:17:43 +00:00
|
|
|
GetUnlocksByType( UnlockRewardType_Steps, apEntries );
|
2005-04-30 04:11:55 +00:00
|
|
|
|
|
|
|
|
for( unsigned i = 0; i < apEntries.size(); ++i )
|
|
|
|
|
{
|
2006-01-28 22:08:16 +00:00
|
|
|
if( apEntries[i]->m_iEntryID == iUnlockEntryID )
|
2005-04-30 04:11:55 +00:00
|
|
|
{
|
|
|
|
|
apSongsOut.push_back( apEntries[i]->m_pSong );
|
|
|
|
|
apDifficultyOut.push_back( apEntries[i]->m_dc );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2006-01-29 22:17:43 +00:00
|
|
|
|
|
|
|
|
// lua start
|
2005-02-21 06:51:04 +00:00
|
|
|
#include "LuaBinding.h"
|
|
|
|
|
|
2006-01-29 22:17:43 +00:00
|
|
|
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 )
|
|
|
|
|
|
2005-06-20 05:02:03 +00:00
|
|
|
class LunaUnlockManager: public Luna<UnlockManager>
|
2005-02-21 06:51:04 +00:00
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
LunaUnlockManager() { LUA->Register( Register ); }
|
|
|
|
|
|
2006-01-30 08:13:16 +00:00
|
|
|
static int FindEntryID( T* p, lua_State *L ) { RString sName = SArg(1); int i = p->FindEntryID(sName); if( i == -1 ) lua_pushnil(L); else lua_pushnumber(L, i); return 1; }
|
|
|
|
|
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 GetNumUnlocks( T* p, lua_State *L ) { lua_pushnumber( L, p->GetNumUnlocks() ); return 1; }
|
|
|
|
|
static int AllAreLocked( T* p, lua_State *L ) { lua_pushboolean( L, p->AllAreLocked() ); return 1; }
|
|
|
|
|
static int GetUnlockIndexToCelebrate( T* p, lua_State *L ) { lua_pushnumber( L, p->GetUnlockIndexToCelebrate() ); 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; }
|
2006-01-28 22:08:16 +00:00
|
|
|
static int GetSongsUnlockedByEntryID( T* p, lua_State *L )
|
2005-04-30 04:11:55 +00:00
|
|
|
{
|
|
|
|
|
vector<Song *> apSongs;
|
2006-01-28 22:08:16 +00:00
|
|
|
UNLOCKMAN->GetSongsUnlockedByEntryID( apSongs, IArg(1) );
|
2005-04-30 04:11:55 +00:00
|
|
|
LuaHelpers::CreateTableFromArray( apSongs, L );
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2006-01-28 22:08:16 +00:00
|
|
|
static int GetStepsUnlockedByEntryID( T* p, lua_State *L )
|
2005-04-30 04:11:55 +00:00
|
|
|
{
|
|
|
|
|
// Return the song each steps are associated with, too.
|
|
|
|
|
vector<Song *> apSongs;
|
|
|
|
|
vector<Difficulty> apDifficulty;
|
2006-01-28 22:08:16 +00:00
|
|
|
UNLOCKMAN->GetStepsUnlockedByEntryID( apSongs, apDifficulty, IArg(1) );
|
2005-04-30 04:11:55 +00:00
|
|
|
LuaHelpers::CreateTableFromArray( apSongs, L );
|
|
|
|
|
LuaHelpers::CreateTableFromArray( apDifficulty, L );
|
|
|
|
|
return 2;
|
|
|
|
|
}
|
2005-02-21 06:51:04 +00:00
|
|
|
|
|
|
|
|
static void Register(lua_State *L)
|
|
|
|
|
{
|
2006-01-28 22:08:16 +00:00
|
|
|
ADD_METHOD( FindEntryID );
|
|
|
|
|
ADD_METHOD( UnlockEntryID );
|
|
|
|
|
ADD_METHOD( PreferUnlockEntryID );
|
2005-09-10 02:47:04 +00:00
|
|
|
ADD_METHOD( GetNumUnlocks );
|
2006-01-30 08:13:16 +00:00
|
|
|
ADD_METHOD( AllAreLocked );
|
|
|
|
|
ADD_METHOD( GetUnlockIndexToCelebrate );
|
|
|
|
|
ADD_METHOD( AnyUnlocksToCelebrate );
|
2006-01-29 22:17:43 +00:00
|
|
|
ADD_METHOD( GetUnlockEntry );
|
2006-01-28 22:08:16 +00:00
|
|
|
ADD_METHOD( GetSongsUnlockedByEntryID );
|
|
|
|
|
ADD_METHOD( GetStepsUnlockedByEntryID );
|
2005-09-10 02:47:04 +00:00
|
|
|
|
2005-02-21 06:51:04 +00:00
|
|
|
Luna<T>::Register( L );
|
|
|
|
|
|
|
|
|
|
// Add global singleton if constructed already. If it's not constructed yet,
|
|
|
|
|
// then we'll register it later when we reinit Lua just before
|
|
|
|
|
// initializing the display.
|
|
|
|
|
if( UNLOCKMAN )
|
|
|
|
|
{
|
|
|
|
|
lua_pushstring(L, "UNLOCKMAN");
|
2005-06-15 02:21:24 +00:00
|
|
|
UNLOCKMAN->PushSelf( L );
|
2005-02-21 06:51:04 +00:00
|
|
|
lua_settable(L, LUA_GLOBALSINDEX);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
LUA_REGISTER_CLASS( UnlockManager )
|
2006-01-29 22:17:43 +00:00
|
|
|
// lua end
|
2005-02-21 06:51:04 +00:00
|
|
|
|
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.
|
|
|
|
|
*/
|