From b053e931c219590a41cfa616f53c075a1e8dffb9 Mon Sep 17 00:00:00 2001 From: AJ Kelly Date: Sat, 30 Apr 2011 18:41:14 -0500 Subject: [PATCH] [UnlockEntry] Added GetCourse, GetCode Lua bindings. [UnlockManager] Added UnlockRequirement_NumUnlocked enum. --- Docs/Changelog_sm-ssc.txt | 2 ++ Themes/_fallback/metrics.ini | 30 ++++++++++++++++++++++++++++-- src/UnlockManager.cpp | 23 ++++++++++++++++++----- src/UnlockManager.h | 3 ++- 4 files changed, 50 insertions(+), 8 deletions(-) diff --git a/Docs/Changelog_sm-ssc.txt b/Docs/Changelog_sm-ssc.txt index 2bf5b96c4b..d4dd8722a6 100644 --- a/Docs/Changelog_sm-ssc.txt +++ b/Docs/Changelog_sm-ssc.txt @@ -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 -------- diff --git a/Themes/_fallback/metrics.ini b/Themes/_fallback/metrics.ini index 11d8c16f2b..95db410a9f 100644 --- a/Themes/_fallback/metrics.ini +++ b/Themes/_fallback/metrics.ini @@ -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] diff --git a/src/UnlockManager.cpp b/src/UnlockManager.cpp index b85c908118..7fd8dbe82d 100644 --- a/src/UnlockManager.cpp +++ b/src/UnlockManager.cpp @@ -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 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 ); diff --git a/src/UnlockManager.h b/src/UnlockManager.h index f042b60da2..6c085e6680 100644 --- a/src/UnlockManager.h +++ b/src/UnlockManager.h @@ -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