move screen-specific BGAs into overlay and broadcast change messages instead

add lesson fail/pass logic
This commit is contained in:
Chris Danford
2005-09-12 06:21:30 +00:00
parent 20d0d2f2e6
commit e628959ac0
8 changed files with 71 additions and 41 deletions
+5 -1
View File
@@ -57,7 +57,11 @@ static const CString MessageNames[] = {
"PreferredSongGroupChanged", "PreferredSongGroupChanged",
"PreferredCourseGroupChanged", "PreferredCourseGroupChanged",
"SortOrderChanged", "SortOrderChanged",
"LessonYourTurn", "LessonTry1",
"LessonTry2",
"LessonTry3",
"LessonCleared",
"LessonFailed",
}; };
XToString( Message, NUM_Message ); XToString( Message, NUM_Message );
+5 -1
View File
@@ -72,7 +72,11 @@ enum Message
Message_PreferredSongGroupChanged, Message_PreferredSongGroupChanged,
Message_PreferredCourseGroupChanged, Message_PreferredCourseGroupChanged,
Message_SortOrderChanged, Message_SortOrderChanged,
Message_LessonYourTurn, Message_LessonTry1,
Message_LessonTry2,
Message_LessonTry3,
Message_LessonCleared,
Message_LessonFailed,
NUM_Message, // leave this at the end NUM_Message, // leave this at the end
Message_Invalud Message_Invalud
}; };
+19 -19
View File
@@ -15,6 +15,8 @@
#define GRADE_PERCENT_TIER(i) THEME->GetMetricF("PlayerStageStats",ssprintf("GradePercent%s",GradeToString((Grade)i).c_str())) #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") #define GRADE_TIER02_IS_ALL_PERFECTS THEME->GetMetricB("PlayerStageStats","GradeTier02IsAllPerfects")
const float LESSON_PASS_THRESHOLD = 0.8f;
void PlayerStageStats::Init() void PlayerStageStats::Init()
{ {
vpPlayedSteps.clear(); vpPlayedSteps.clear();
@@ -260,16 +262,14 @@ int PlayerStageStats::GetLessonScoreActual() const
return iScore; return iScore;
} }
int PlayerStageStats::GetLessonScorePossible() const int PlayerStageStats::GetLessonScoreNeeded() const
{ {
int iScore = 0; int iScore = 0;
FOREACH_TapNoteScore( tns ) FOREACH_CONST( const Steps*, vpPossibleSteps, steps )
iScore += iTapNoteScores[tns]; iScore += (*steps)->GetRadarValues().m_Values.v.fNumTapsAndHolds;
FOREACH_HoldNoteScore( hns )
iScore += iHoldNoteScores[hns];
iScore = (int)floorf( iScore * LESSON_PASS_THRESHOLD );
return iScore; return iScore;
} }
@@ -595,18 +595,18 @@ class LunaPlayerStageStats: public Luna<PlayerStageStats>
public: public:
LunaPlayerStageStats() { LUA->Register( Register ); } LunaPlayerStageStats() { LUA->Register( Register ); }
static int GetCaloriesBurned( T* p, lua_State *L ) { lua_pushnumber(L, p->fCaloriesBurned ); return 1; } DEFINE_METHOD( GetCaloriesBurned, fCaloriesBurned )
static int GetLifeRemainingSeconds( T* p, lua_State *L ) { lua_pushnumber(L, p->fLifeRemainingSeconds); return 1; } DEFINE_METHOD( GetLifeRemainingSeconds, fLifeRemainingSeconds )
static int GetSurvivalSeconds( T* p, lua_State *L ) { lua_pushnumber(L, p->GetSurvivalSeconds()); return 1; } DEFINE_METHOD( GetSurvivalSeconds, GetSurvivalSeconds() )
static int FullCombo( T* p, lua_State *L ) { lua_pushnumber(L, p->FullCombo()); return 1; } DEFINE_METHOD( FullCombo, FullCombo() )
static int MaxCombo( T* p, lua_State *L ) { lua_pushnumber(L, p->GetMaxCombo().cnt); return 1; } DEFINE_METHOD( MaxCombo, GetMaxCombo().cnt )
static int GetGrade( T* p, lua_State *L ) { lua_pushnumber(L, p->GetGrade()); return 1; } DEFINE_METHOD( GetGrade, GetGrade() )
static int GetLessonScoreActual( T* p, lua_State *L ) { lua_pushnumber(L, p->GetLessonScoreActual()); return 1; } DEFINE_METHOD( GetLessonScoreActual, GetLessonScoreActual() )
static int GetLessonScorePossible( T* p, lua_State *L ) { lua_pushnumber(L, p->GetLessonScorePossible()); return 1; } DEFINE_METHOD( GetLessonScoreNeeded, GetLessonScoreNeeded() )
static int GetPersonalHighScoreIndex( T* p, lua_State *L ) { lua_pushnumber( L, p->m_iPersonalHighScoreIndex ); return 1; } DEFINE_METHOD( GetPersonalHighScoreIndex, m_iPersonalHighScoreIndex )
static int GetMachineHighScoreIndex( T* p, lua_State *L ) { lua_pushnumber( L, p->m_iMachineHighScoreIndex ); return 1; } DEFINE_METHOD( GetMachineHighScoreIndex, m_iMachineHighScoreIndex )
static int GetPerDifficultyAward( T* p, lua_State *L ) { lua_pushnumber( L, p->m_pdaToShow ); return 1; } DEFINE_METHOD( GetPerDifficultyAward, m_pdaToShow )
static int GetPeakComboAward( T* p, lua_State *L ) { lua_pushnumber( L, p->m_pcaToShow ); return 1; } DEFINE_METHOD( GetPeakComboAward, m_pcaToShow )
static void Register(lua_State *L) static void Register(lua_State *L)
{ {
@@ -617,7 +617,7 @@ public:
ADD_METHOD( MaxCombo ); ADD_METHOD( MaxCombo );
ADD_METHOD( GetGrade ); ADD_METHOD( GetGrade );
ADD_METHOD( GetLessonScoreActual ); ADD_METHOD( GetLessonScoreActual );
ADD_METHOD( GetLessonScorePossible ); ADD_METHOD( GetLessonScoreNeeded );
ADD_METHOD( GetPersonalHighScoreIndex ); ADD_METHOD( GetPersonalHighScoreIndex );
ADD_METHOD( GetMachineHighScoreIndex ); ADD_METHOD( GetMachineHighScoreIndex );
ADD_METHOD( GetPerDifficultyAward ); ADD_METHOD( GetPerDifficultyAward );
+1 -2
View File
@@ -10,7 +10,6 @@
class Steps; class Steps;
struct lua_State; struct lua_State;
class PlayerStageStats class PlayerStageStats
{ {
public: public:
@@ -25,7 +24,7 @@ public:
float GetCurMaxPercentDancePoints() const; float GetCurMaxPercentDancePoints() const;
int GetLessonScoreActual() const; int GetLessonScoreActual() const;
int GetLessonScorePossible() const; int GetLessonScoreNeeded() const;
void ResetScoreForLesson(); void ResetScoreForLesson();
vector<Steps*> vpPlayedSteps; vector<Steps*> vpPlayedSteps;
+34
View File
@@ -626,6 +626,24 @@ DateTime Profile::GetSongLastPlayedDateTime( const Song* pSong ) const
return dtLatest; 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 ) void Profile::IncrementStepsPlayCount( const Song* pSong, const Steps* pSteps )
{ {
DateTime now = DateTime::GetNowDate(); DateTime now = DateTime::GetNowDate();
@@ -1966,6 +1984,20 @@ public:
lua_pushnil( L ); lua_pushnil( L );
return 1; 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) static void Register(lua_State *L)
{ {
@@ -1997,6 +2029,8 @@ public:
ADD_METHOD( GetDisplayTotalCaloriesBurned ); ADD_METHOD( GetDisplayTotalCaloriesBurned );
ADD_METHOD( GetMostPopularSong ); ADD_METHOD( GetMostPopularSong );
ADD_METHOD( GetMostPopularCourse ); ADD_METHOD( GetMostPopularCourse );
ADD_METHOD( GetSongNumTimesPlayed );
ADD_METHOD( HasPassedAnyStepsInSong );
Luna<T>::Register( L ); Luna<T>::Register( L );
} }
+1
View File
@@ -169,6 +169,7 @@ public:
int GetSongNumTimesPlayed( const Song* pSong ) const; int GetSongNumTimesPlayed( const Song* pSong ) const;
int GetSongNumTimesPlayed( const SongID& songID ) const; int GetSongNumTimesPlayed( const SongID& songID ) const;
DateTime GetSongLastPlayedDateTime( const Song* pSong ) const; DateTime GetSongLastPlayedDateTime( const Song* pSong ) const;
bool HasPassedAnyStepsInSong( const Song* pSong ) const;
// //
// Course high scores // Course high scores
+6 -17
View File
@@ -61,17 +61,6 @@ void ScreenGameplayLesson::Init()
(*aa)->PlayCommand( "On" ); (*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(); this->SortByDrawOrder();
} }
@@ -104,25 +93,26 @@ void ScreenGameplayLesson::HandleScreenMessage( const ScreenMessage SM )
} }
else 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; bool bAnyTriesLeft = m_Try + 1 < NUM_Try;
if( bCleared ) if( bCleared )
{ {
MESSAGEMAN->Broadcast( Message_LessonCleared );
this->HandleScreenMessage( SM_LeaveGameplay ); this->HandleScreenMessage( SM_LeaveGameplay );
} }
else if( bAnyTriesLeft ) else if( bAnyTriesLeft )
{ {
ResetAndRestartCurrentSong(); ResetAndRestartCurrentSong();
m_sprTry[m_Try]->PlayCommand( "Hide" );
m_Try = (Try)(m_Try+1); m_Try = (Try)(m_Try+1);
m_sprTry[m_Try]->PlayCommand( "Show" ); MESSAGEMAN->Broadcast( (Message)(Message_LessonTry1+m_Try) );
} }
else else
{ {
m_sprTry[m_Try]->PlayCommand( "Hide" );
this->HandleScreenMessage( SM_BeginFailed ); this->HandleScreenMessage( SM_BeginFailed );
MESSAGEMAN->Broadcast( Message_LessonFailed );
} }
} }
return; // handled return; // handled
@@ -156,11 +146,10 @@ void ScreenGameplayLesson::ChangeLessonPage( int iDir )
{ {
m_vPages[m_iCurrentPageIndex]->PlayCommand( "Hide" ); m_vPages[m_iCurrentPageIndex]->PlayCommand( "Hide" );
m_iCurrentPageIndex = -1; m_iCurrentPageIndex = -1;
m_sprTry[m_Try]->PlayCommand( "Show" );
ResetAndRestartCurrentSong(); ResetAndRestartCurrentSong();
MESSAGEMAN->Broadcast( Message_LessonYourTurn ); MESSAGEMAN->Broadcast( (Message)(Message_LessonTry1+m_Try) );
} }
else else
{ {
-1
View File
@@ -32,7 +32,6 @@ protected:
Try_3, Try_3,
NUM_Try NUM_Try
}; };
AutoActor m_sprTry[NUM_Try];
Try m_Try; Try m_Try;
}; };