move screen-specific BGAs into overlay and broadcast change messages instead
add lesson fail/pass logic
This commit is contained in:
@@ -57,7 +57,11 @@ static const CString MessageNames[] = {
|
||||
"PreferredSongGroupChanged",
|
||||
"PreferredCourseGroupChanged",
|
||||
"SortOrderChanged",
|
||||
"LessonYourTurn",
|
||||
"LessonTry1",
|
||||
"LessonTry2",
|
||||
"LessonTry3",
|
||||
"LessonCleared",
|
||||
"LessonFailed",
|
||||
};
|
||||
XToString( Message, NUM_Message );
|
||||
|
||||
|
||||
@@ -72,7 +72,11 @@ enum Message
|
||||
Message_PreferredSongGroupChanged,
|
||||
Message_PreferredCourseGroupChanged,
|
||||
Message_SortOrderChanged,
|
||||
Message_LessonYourTurn,
|
||||
Message_LessonTry1,
|
||||
Message_LessonTry2,
|
||||
Message_LessonTry3,
|
||||
Message_LessonCleared,
|
||||
Message_LessonFailed,
|
||||
NUM_Message, // leave this at the end
|
||||
Message_Invalud
|
||||
};
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
#define GRADE_PERCENT_TIER(i) THEME->GetMetricF("PlayerStageStats",ssprintf("GradePercent%s",GradeToString((Grade)i).c_str()))
|
||||
#define GRADE_TIER02_IS_ALL_PERFECTS THEME->GetMetricB("PlayerStageStats","GradeTier02IsAllPerfects")
|
||||
|
||||
const float LESSON_PASS_THRESHOLD = 0.8f;
|
||||
|
||||
void PlayerStageStats::Init()
|
||||
{
|
||||
vpPlayedSteps.clear();
|
||||
@@ -260,16 +262,14 @@ int PlayerStageStats::GetLessonScoreActual() const
|
||||
return iScore;
|
||||
}
|
||||
|
||||
int PlayerStageStats::GetLessonScorePossible() const
|
||||
int PlayerStageStats::GetLessonScoreNeeded() const
|
||||
{
|
||||
int iScore = 0;
|
||||
|
||||
FOREACH_TapNoteScore( tns )
|
||||
iScore += iTapNoteScores[tns];
|
||||
|
||||
FOREACH_HoldNoteScore( hns )
|
||||
iScore += iHoldNoteScores[hns];
|
||||
FOREACH_CONST( const Steps*, vpPossibleSteps, steps )
|
||||
iScore += (*steps)->GetRadarValues().m_Values.v.fNumTapsAndHolds;
|
||||
|
||||
iScore = (int)floorf( iScore * LESSON_PASS_THRESHOLD );
|
||||
return iScore;
|
||||
}
|
||||
|
||||
@@ -595,18 +595,18 @@ class LunaPlayerStageStats: public Luna<PlayerStageStats>
|
||||
public:
|
||||
LunaPlayerStageStats() { LUA->Register( Register ); }
|
||||
|
||||
static int GetCaloriesBurned( T* p, lua_State *L ) { lua_pushnumber(L, p->fCaloriesBurned ); return 1; }
|
||||
static int GetLifeRemainingSeconds( T* p, lua_State *L ) { lua_pushnumber(L, p->fLifeRemainingSeconds); return 1; }
|
||||
static int GetSurvivalSeconds( T* p, lua_State *L ) { lua_pushnumber(L, p->GetSurvivalSeconds()); return 1; }
|
||||
static int FullCombo( T* p, lua_State *L ) { lua_pushnumber(L, p->FullCombo()); return 1; }
|
||||
static int MaxCombo( T* p, lua_State *L ) { lua_pushnumber(L, p->GetMaxCombo().cnt); return 1; }
|
||||
static int GetGrade( T* p, lua_State *L ) { lua_pushnumber(L, p->GetGrade()); return 1; }
|
||||
static int GetLessonScoreActual( T* p, lua_State *L ) { lua_pushnumber(L, p->GetLessonScoreActual()); return 1; }
|
||||
static int GetLessonScorePossible( T* p, lua_State *L ) { lua_pushnumber(L, p->GetLessonScorePossible()); return 1; }
|
||||
static int GetPersonalHighScoreIndex( T* p, lua_State *L ) { lua_pushnumber( L, p->m_iPersonalHighScoreIndex ); return 1; }
|
||||
static int GetMachineHighScoreIndex( T* p, lua_State *L ) { lua_pushnumber( L, p->m_iMachineHighScoreIndex ); return 1; }
|
||||
static int GetPerDifficultyAward( T* p, lua_State *L ) { lua_pushnumber( L, p->m_pdaToShow ); return 1; }
|
||||
static int GetPeakComboAward( T* p, lua_State *L ) { lua_pushnumber( L, p->m_pcaToShow ); return 1; }
|
||||
DEFINE_METHOD( GetCaloriesBurned, fCaloriesBurned )
|
||||
DEFINE_METHOD( GetLifeRemainingSeconds, fLifeRemainingSeconds )
|
||||
DEFINE_METHOD( GetSurvivalSeconds, GetSurvivalSeconds() )
|
||||
DEFINE_METHOD( FullCombo, FullCombo() )
|
||||
DEFINE_METHOD( MaxCombo, GetMaxCombo().cnt )
|
||||
DEFINE_METHOD( GetGrade, GetGrade() )
|
||||
DEFINE_METHOD( GetLessonScoreActual, GetLessonScoreActual() )
|
||||
DEFINE_METHOD( GetLessonScoreNeeded, GetLessonScoreNeeded() )
|
||||
DEFINE_METHOD( GetPersonalHighScoreIndex, m_iPersonalHighScoreIndex )
|
||||
DEFINE_METHOD( GetMachineHighScoreIndex, m_iMachineHighScoreIndex )
|
||||
DEFINE_METHOD( GetPerDifficultyAward, m_pdaToShow )
|
||||
DEFINE_METHOD( GetPeakComboAward, m_pcaToShow )
|
||||
|
||||
static void Register(lua_State *L)
|
||||
{
|
||||
@@ -617,7 +617,7 @@ public:
|
||||
ADD_METHOD( MaxCombo );
|
||||
ADD_METHOD( GetGrade );
|
||||
ADD_METHOD( GetLessonScoreActual );
|
||||
ADD_METHOD( GetLessonScorePossible );
|
||||
ADD_METHOD( GetLessonScoreNeeded );
|
||||
ADD_METHOD( GetPersonalHighScoreIndex );
|
||||
ADD_METHOD( GetMachineHighScoreIndex );
|
||||
ADD_METHOD( GetPerDifficultyAward );
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
class Steps;
|
||||
struct lua_State;
|
||||
|
||||
|
||||
class PlayerStageStats
|
||||
{
|
||||
public:
|
||||
@@ -25,7 +24,7 @@ public:
|
||||
float GetCurMaxPercentDancePoints() const;
|
||||
|
||||
int GetLessonScoreActual() const;
|
||||
int GetLessonScorePossible() const;
|
||||
int GetLessonScoreNeeded() const;
|
||||
void ResetScoreForLesson();
|
||||
|
||||
vector<Steps*> vpPlayedSteps;
|
||||
|
||||
@@ -626,6 +626,24 @@ DateTime Profile::GetSongLastPlayedDateTime( const Song* pSong ) const
|
||||
return dtLatest;
|
||||
}
|
||||
|
||||
bool Profile::HasPassedAnyStepsInSong( const Song* pSong ) const
|
||||
{
|
||||
FOREACH_CONST( const Steps*, pSong->GetAllSteps(), steps )
|
||||
{
|
||||
const HighScoreList &hsl = GetStepsHighScoreList( pSong, *steps );
|
||||
Grade grade = hsl.GetTopScore().GetGrade();
|
||||
switch( grade )
|
||||
{
|
||||
case Grade_Failed:
|
||||
case Grade_NoData:
|
||||
break;
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void Profile::IncrementStepsPlayCount( const Song* pSong, const Steps* pSteps )
|
||||
{
|
||||
DateTime now = DateTime::GetNowDate();
|
||||
@@ -1966,6 +1984,20 @@ public:
|
||||
lua_pushnil( L );
|
||||
return 1;
|
||||
}
|
||||
static int GetSongNumTimesPlayed( T* p, lua_State *L )
|
||||
{
|
||||
ASSERT( !lua_isnil(L,1) );
|
||||
Song *pS = Luna<Song>::check(L,1);
|
||||
lua_pushnumber( L, p->GetSongNumTimesPlayed(pS) );
|
||||
return 1;
|
||||
}
|
||||
static int HasPassedAnyStepsInSong( T* p, lua_State *L )
|
||||
{
|
||||
ASSERT( !lua_isnil(L,1) );
|
||||
Song *pS = Luna<Song>::check(L,1);
|
||||
lua_pushboolean( L, p->HasPassedAnyStepsInSong(pS) );
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void Register(lua_State *L)
|
||||
{
|
||||
@@ -1997,6 +2029,8 @@ public:
|
||||
ADD_METHOD( GetDisplayTotalCaloriesBurned );
|
||||
ADD_METHOD( GetMostPopularSong );
|
||||
ADD_METHOD( GetMostPopularCourse );
|
||||
ADD_METHOD( GetSongNumTimesPlayed );
|
||||
ADD_METHOD( HasPassedAnyStepsInSong );
|
||||
|
||||
Luna<T>::Register( L );
|
||||
}
|
||||
|
||||
@@ -169,6 +169,7 @@ public:
|
||||
int GetSongNumTimesPlayed( const Song* pSong ) const;
|
||||
int GetSongNumTimesPlayed( const SongID& songID ) const;
|
||||
DateTime GetSongLastPlayedDateTime( const Song* pSong ) const;
|
||||
bool HasPassedAnyStepsInSong( const Song* pSong ) const;
|
||||
|
||||
//
|
||||
// Course high scores
|
||||
|
||||
@@ -61,17 +61,6 @@ void ScreenGameplayLesson::Init()
|
||||
(*aa)->PlayCommand( "On" );
|
||||
}
|
||||
|
||||
|
||||
// load Try graphics
|
||||
for( int i=0; i<NUM_Try; i++ )
|
||||
{
|
||||
CString s = ssprintf("Try%d",i+1);
|
||||
m_sprTry[i].Load( THEME->GetPathB(m_sName,s) );
|
||||
m_sprTry[i]->PlayCommand( "Hide" );
|
||||
m_sprTry[i]->SetDrawOrder( DRAW_ORDER_OVERLAY+1 );
|
||||
this->AddChild( m_sprTry[i] );
|
||||
}
|
||||
|
||||
this->SortByDrawOrder();
|
||||
}
|
||||
|
||||
@@ -104,25 +93,26 @@ void ScreenGameplayLesson::HandleScreenMessage( const ScreenMessage SM )
|
||||
}
|
||||
else
|
||||
{
|
||||
bool bCleared = false; // TODO
|
||||
PlayerStageStats &pss = STATSMAN->m_CurStageStats.m_player[PLAYER_1];
|
||||
bool bCleared = pss.GetLessonScoreActual() >= pss.GetLessonScoreNeeded();
|
||||
bool bAnyTriesLeft = m_Try + 1 < NUM_Try;
|
||||
|
||||
if( bCleared )
|
||||
{
|
||||
MESSAGEMAN->Broadcast( Message_LessonCleared );
|
||||
this->HandleScreenMessage( SM_LeaveGameplay );
|
||||
}
|
||||
else if( bAnyTriesLeft )
|
||||
{
|
||||
ResetAndRestartCurrentSong();
|
||||
|
||||
m_sprTry[m_Try]->PlayCommand( "Hide" );
|
||||
m_Try = (Try)(m_Try+1);
|
||||
m_sprTry[m_Try]->PlayCommand( "Show" );
|
||||
MESSAGEMAN->Broadcast( (Message)(Message_LessonTry1+m_Try) );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_sprTry[m_Try]->PlayCommand( "Hide" );
|
||||
this->HandleScreenMessage( SM_BeginFailed );
|
||||
MESSAGEMAN->Broadcast( Message_LessonFailed );
|
||||
}
|
||||
}
|
||||
return; // handled
|
||||
@@ -156,11 +146,10 @@ void ScreenGameplayLesson::ChangeLessonPage( int iDir )
|
||||
{
|
||||
m_vPages[m_iCurrentPageIndex]->PlayCommand( "Hide" );
|
||||
m_iCurrentPageIndex = -1;
|
||||
m_sprTry[m_Try]->PlayCommand( "Show" );
|
||||
|
||||
ResetAndRestartCurrentSong();
|
||||
|
||||
MESSAGEMAN->Broadcast( Message_LessonYourTurn );
|
||||
MESSAGEMAN->Broadcast( (Message)(Message_LessonTry1+m_Try) );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -32,7 +32,6 @@ protected:
|
||||
Try_3,
|
||||
NUM_Try
|
||||
};
|
||||
AutoActor m_sprTry[NUM_Try];
|
||||
Try m_Try;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user