[UnlockEntry] Added GetCourse, GetCode Lua bindings.

[UnlockManager] Added UnlockRequirement_NumUnlocked enum.
This commit is contained in:
AJ Kelly
2011-04-30 18:41:14 -05:00
parent f5976bd860
commit b053e931c2
4 changed files with 50 additions and 8 deletions
+2
View File
@@ -19,6 +19,8 @@ sm-ssc v1.2.5 | 20110???
LineHighlight P#", making it load per-player. [AJ]
* [OptionRow] Added Text param to RefreshMessageCommand. [AJ]
* [ScreenOptions] Added SelectMultipleMessageCommand, ChangeValueMessageCommand. [AJ]
* [UnlockEntry] Added GetCourse, GetCode Lua bindings. [AJ]
* [UnlockManager] Added UnlockRequirement_NumUnlocked enum. [AJ]
20110428
--------
+28 -2
View File
@@ -123,11 +123,37 @@ UnlockColor=color("1,0.5,0,1")
ExtraColor=color("#ff0000") -- red
[UnlockManager]
# Unlock specific things. we'll go in-depth with this one day, but it really
# isnt what sm-ssc was designed for.
# Unlock specific things.
AutoLockChallengeSteps=false
UnlockNames=""
# useful commands:
# require,(UnlockRequirement),(value);
# where (UnlockRequirement) is one of the UnlockRequirement enums.
# song,(Song Name);
# sets a Song to be unlocked
# course,(Course Name);
# sets a Course to be unlocked
# roulette;
# Song shows up in roulette (useful with Song only)
# mod,(modifier);
# sets a modifier to be unlocked.
# code,(code);
# assigns a code to the unlock
# examples:
# 1) The song "Pledge" requires 500 AP.
# Unlock1Command=song,"Pledge";require,"UnlockRequirement_ArcadePoints",500
# 2) The song "ABC" can be unlocked via roulette; pick an arbitrary code
# to use to store the unlock.
# Unlock2Command=song,"ABC";code,"59183751";roulette
# 03 #
[ArrowEffects]
+18 -5
View File
@@ -33,7 +33,8 @@ static const char *UnlockRequirementNames[] =
"ExtraCleared",
"ExtraFailed",
"Toasties",
"StagesCleared"
"StagesCleared",
"NumberUnlocked"
};
XToString( UnlockRequirement );
StringToX( UnlockRequirement );
@@ -294,6 +295,7 @@ void UnlockManager::GetPoints( const Profile *pProfile, float fScores[NUM_Unlock
fScores[UnlockRequirement_SongPoints] = GetSongPoints( pProfile );
fScores[UnlockRequirement_DancePoints] = (float) pProfile->m_iTotalDancePoints;
fScores[UnlockRequirement_StagesCleared] = (float) pProfile->GetTotalNumSongsPassed();
fScores[UnlockRequirement_NumUnlocked] = (float) GetNumUnlocked();
}
/* Return true if all songs and/or courses referenced by an unlock are available. */
@@ -469,7 +471,7 @@ void UnlockManager::Load()
}
}
// Make sure that we don't have duplicate unlock IDs. This can cause problems
// 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 )
FOREACH_CONST( UnlockEntry, m_UnlockEntries, ue2 )
@@ -514,9 +516,7 @@ void UnlockManager::Load()
}
}
//
// Log unlocks
//
FOREACH_CONST( UnlockEntry, m_UnlockEntries, e )
{
RString str = ssprintf( "Unlock: %s; ", join("\n",e->m_cmd.m_vsArgs).c_str() );
@@ -558,7 +558,7 @@ float UnlockManager::PointsUntilNextUnlock( UnlockRequirement t ) const
for( unsigned a=0; a<m_UnlockEntries.size(); a++ )
if( m_UnlockEntries[a].m_fRequirement[t] > fScores[t] )
fSmallestPoints = min( fSmallestPoints, m_UnlockEntries[a].m_fRequirement[t] );
if( fSmallestPoints == FLT_MAX )
return 0; // no match found
return fSmallestPoints - fScores[t];
@@ -673,6 +673,17 @@ public:
if( pSong ) { pSong->PushSelf(L); return 1; }
return 0;
}
static int GetCourse( T* p, lua_State *L )
{
Course *pCourse = p->m_Course.ToCourse();
if( pCourse ) { pCourse->PushSelf(L); return 1; }
return 0;
}
static int GetCode( T* p, lua_State *L )
{
lua_pushstring( L, p->m_sEntryID );
return 1;
}
static int GetArgs( T* p, lua_State *L )
{
@@ -701,11 +712,13 @@ public:
LunaUnlockEntry()
{
ADD_METHOD( IsLocked );
ADD_METHOD( GetCode );
ADD_METHOD( GetDescription );
ADD_METHOD( GetUnlockRewardType );
ADD_METHOD( GetRequirement );
ADD_METHOD( GetRequirePassHardSteps );
ADD_METHOD( GetSong );
ADD_METHOD( GetCourse );
ADD_METHOD( song );
ADD_METHOD( steps );
ADD_METHOD( course );
+2 -1
View File
@@ -25,6 +25,7 @@ enum UnlockRequirement
UnlockRequirement_ExtraFailed,
UnlockRequirement_Toasties,
UnlockRequirement_StagesCleared,
UnlockRequirement_NumUnlocked,
NUM_UnlockRequirement,
UnlockRequirement_Invalid,
};
@@ -100,7 +101,7 @@ public:
// Option is locked due to a #SELECTABLE tag.
#define LOCKED_SELECTABLE 0x4
// Option is disabled by the operator. (For courses, this means that a song in the
// Option is disabled by the operator. (For courses, this means that a song in the
// course is disabled.)
#define LOCKED_DISABLED 0x8