fix workout goal not working correctly when CurStageIndex > 0
This commit is contained in:
@@ -794,9 +794,8 @@ void GameState::Update( float fDelta )
|
||||
|
||||
if( WORKOUTMAN->m_pCurWorkout != NULL && !m_bWorkoutGoalComplete )
|
||||
{
|
||||
const StageStats &ssAccum = STATSMAN->GetAccumPlayedStageStats();
|
||||
const StageStats &ssCurrent = STATSMAN->m_CurStageStats;
|
||||
bool bGoalComplete = ssAccum.m_fGameplaySeconds + ssCurrent.m_fGameplaySeconds > WORKOUTMAN->m_pCurWorkout->m_iMinutes*60;
|
||||
bool bGoalComplete = ssCurrent.m_fGameplaySeconds > WORKOUTMAN->m_pCurWorkout->m_iMinutes*60;
|
||||
if( bGoalComplete )
|
||||
{
|
||||
MESSAGEMAN->Broadcast( "WorkoutGoalComplete" );
|
||||
@@ -1898,9 +1897,7 @@ Premium GameState::GetPremium() const
|
||||
float GameState::GetGoalPercentComplete( PlayerNumber pn )
|
||||
{
|
||||
const Profile *pProfile = PROFILEMAN->GetProfile(pn);
|
||||
const StageStats &ssAccum = STATSMAN->GetAccumPlayedStageStats();
|
||||
const StageStats &ssCurrent = STATSMAN->m_CurStageStats;
|
||||
const PlayerStageStats &pssAccum = ssAccum.m_player[pn];
|
||||
const PlayerStageStats &pssCurrent = ssCurrent.m_player[pn];
|
||||
|
||||
float fActual = 0;
|
||||
@@ -1908,11 +1905,11 @@ float GameState::GetGoalPercentComplete( PlayerNumber pn )
|
||||
switch( pProfile->m_GoalType )
|
||||
{
|
||||
case GoalType_Calories:
|
||||
fActual = pssAccum.m_fCaloriesBurned + pssCurrent.m_fCaloriesBurned;
|
||||
fActual = pssCurrent.m_fCaloriesBurned;
|
||||
fGoal = (float)pProfile->m_iGoalCalories;
|
||||
break;
|
||||
case GoalType_Time:
|
||||
fActual = ssAccum.m_fGameplaySeconds + ssCurrent.m_fGameplaySeconds;
|
||||
fActual = ssCurrent.m_fGameplaySeconds;
|
||||
fGoal = (float)pProfile->m_iGoalSeconds;
|
||||
break;
|
||||
case GoalType_None:
|
||||
@@ -2247,6 +2244,7 @@ public:
|
||||
{
|
||||
p->m_bJukeboxUsesModifiers = BArg(1); return 0;
|
||||
}
|
||||
DEFINE_METHOD( GetWorkoutGoalComplete, m_bWorkoutGoalComplete )
|
||||
|
||||
LunaGameState()
|
||||
{
|
||||
@@ -2329,6 +2327,7 @@ public:
|
||||
ADD_METHOD( GetStageSeed );
|
||||
ADD_METHOD( SaveLocalData );
|
||||
ADD_METHOD( SetJukeboxUsesModifiers );
|
||||
ADD_METHOD( GetWorkoutGoalComplete );
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -41,12 +41,12 @@ void WorkoutGraph::LoadFromNode( const XNode* pNode )
|
||||
Load();
|
||||
}
|
||||
|
||||
void WorkoutGraph::SetFromGameState()
|
||||
void WorkoutGraph::SetFromCurrentWorkout()
|
||||
{
|
||||
SetFromGameStateInternal( STATSMAN->m_CurStageStats.m_vpPlayedSongs.size() );
|
||||
SetInternal( 0 );
|
||||
}
|
||||
|
||||
void WorkoutGraph::SetFromGameStateInternal( int iNumSongsToShowForCurrentStage )
|
||||
void WorkoutGraph::SetInternal( int iMinSongsPlayed )
|
||||
{
|
||||
ASSERT( WORKOUTMAN->m_pCurWorkout );
|
||||
|
||||
@@ -57,11 +57,8 @@ void WorkoutGraph::SetFromGameStateInternal( int iNumSongsToShowForCurrentStage
|
||||
}
|
||||
m_vpBars.clear();
|
||||
|
||||
int iTotalSongsPlayed =
|
||||
STATSMAN->GetAccumPlayedStageStats().m_vpPlayedSongs.size() +
|
||||
iNumSongsToShowForCurrentStage;
|
||||
int iWorkoutEstimatedSongs = WORKOUTMAN->m_pCurWorkout->GetEstimatedNumSongs();
|
||||
int iNumSongsToShow = max( iTotalSongsPlayed, iWorkoutEstimatedSongs );
|
||||
int iNumSongsToShow = max( iMinSongsPlayed, iWorkoutEstimatedSongs );
|
||||
vector<int> viMeters;
|
||||
WORKOUTMAN->m_pCurWorkout->GetEstimatedMeters( iNumSongsToShow, viMeters );
|
||||
|
||||
@@ -105,7 +102,7 @@ void WorkoutGraph::SetFromGameStateInternal( int iNumSongsToShowForCurrentStage
|
||||
|
||||
void WorkoutGraph::SetFromGameStateAndHighlightSong( int iSongIndex )
|
||||
{
|
||||
SetFromGameStateInternal( iSongIndex+1 );
|
||||
SetInternal( iSongIndex+1 );
|
||||
|
||||
FOREACH( Sprite*, m_vpBars, spr )
|
||||
(*spr)->StopEffect();
|
||||
@@ -123,12 +120,12 @@ void WorkoutGraph::SetFromGameStateAndHighlightSong( int iSongIndex )
|
||||
class LunaWorkoutGraph: public Luna<WorkoutGraph>
|
||||
{
|
||||
public:
|
||||
static int SetFromGameState( T* p, lua_State *L ) { p->SetFromGameState(); return 0; }
|
||||
static int SetFromCurrentWorkout( T* p, lua_State *L ) { p->SetFromCurrentWorkout(); return 0; }
|
||||
static int SetFromGameStateAndHighlightSong( T* p, lua_State *L ) { p->SetFromGameStateAndHighlightSong(IArg(1)); return 0; }
|
||||
|
||||
LunaWorkoutGraph()
|
||||
{
|
||||
ADD_METHOD( SetFromGameState );
|
||||
ADD_METHOD( SetFromCurrentWorkout );
|
||||
ADD_METHOD( SetFromGameStateAndHighlightSong );
|
||||
}
|
||||
};
|
||||
|
||||
@@ -16,14 +16,14 @@ public:
|
||||
|
||||
void Load();
|
||||
void LoadFromNode( const XNode* pNode );
|
||||
void SetFromGameState();
|
||||
void SetFromCurrentWorkout();
|
||||
void SetFromGameStateAndHighlightSong( int iSongIndex );
|
||||
|
||||
// Lua
|
||||
void PushSelf( lua_State *L );
|
||||
|
||||
protected:
|
||||
void SetFromGameStateInternal( int iNumSongsToShowForCurrentStage );
|
||||
void SetInternal( int iNumSongsToShowForCurrentStage );
|
||||
void HighlightSong( int iSongIndex );
|
||||
|
||||
Sprite m_sprEmpty;
|
||||
|
||||
Reference in New Issue
Block a user