Start refactoring results. Doing this piecemeal, so I can keep track of what

I'm doing.  Pull out CommitScores.  StageResults won't remain in SEval (not
yet sure whether it should be part of PlayerStageStats).
This commit is contained in:
Glenn Maynard
2005-09-11 00:02:22 +00:00
parent f61f5ddfed
commit 69edbcee97
2 changed files with 61 additions and 50 deletions
+45 -39
View File
@@ -81,6 +81,20 @@ static const int NUM_SHOWN_RADAR_CATEGORIES = 5;
AutoScreenMessage( SM_PlayCheer ) AutoScreenMessage( SM_PlayCheer )
AutoScreenMessage( SM_AddBonus ) AutoScreenMessage( SM_AddBonus )
StageResults::StageResults()
{
Init();
}
void StageResults::Init()
{
m_iPersonalHighScoreIndex = -1;
m_iMachineHighScoreIndex = -1;
m_rc = RANKING_INVALID;
m_pdaToShow = PER_DIFFICULTY_AWARD_INVALID;
m_pcaToShow = PEAK_COMBO_AWARD_INVALID;
}
REGISTER_SCREEN_CLASS( ScreenEvaluation ); REGISTER_SCREEN_CLASS( ScreenEvaluation );
ScreenEvaluation::ScreenEvaluation( CString sClassName ) : ScreenWithMenuElements(sClassName) ScreenEvaluation::ScreenEvaluation( CString sClassName ) : ScreenWithMenuElements(sClassName)
@@ -255,8 +269,7 @@ void ScreenEvaluation::Init()
// //
// update persistent statistics // update persistent statistics
// //
RankingCategory rc[NUM_PLAYERS];; CommitScores( m_StageStats, m_StageResults, m_Type );
CommitScores( m_StageStats, m_iPersonalHighScoreIndex, m_iMachineHighScoreIndex, rc, m_pdaToShow, m_pcaToShow );
m_bTryExtraStage = m_bTryExtraStage =
GAMESTATE->HasEarnedExtraStage() && GAMESTATE->HasEarnedExtraStage() &&
@@ -680,16 +693,16 @@ void ScreenEvaluation::Init()
{ {
FOREACH_EnabledPlayer( p ) FOREACH_EnabledPlayer( p )
{ {
if( m_iMachineHighScoreIndex[p] != -1 ) if( m_StageResults[p].m_iMachineHighScoreIndex != -1 )
{ {
m_sprMachineRecord[p].Load( THEME->GetPathG( m_sName, ssprintf("MachineRecord %02d",m_iMachineHighScoreIndex[p]+1) ) ); m_sprMachineRecord[p].Load( THEME->GetPathG( m_sName, ssprintf("MachineRecord %02d",m_StageResults[p].m_iMachineHighScoreIndex+1) ) );
m_sprMachineRecord[p]->SetName( ssprintf("MachineRecordP%d",p+1) ); m_sprMachineRecord[p]->SetName( ssprintf("MachineRecordP%d",p+1) );
SET_XY_AND_ON_COMMAND( m_sprMachineRecord[p] ); SET_XY_AND_ON_COMMAND( m_sprMachineRecord[p] );
this->AddChild( m_sprMachineRecord[p] ); this->AddChild( m_sprMachineRecord[p] );
} }
if( m_iPersonalHighScoreIndex[p] != -1 ) if( m_StageResults[p].m_iPersonalHighScoreIndex != -1 )
{ {
m_sprPersonalRecord[p].Load( THEME->GetPathG( m_sName, ssprintf("PersonalRecord %02d",m_iPersonalHighScoreIndex[p]+1) ) ); m_sprPersonalRecord[p].Load( THEME->GetPathG( m_sName, ssprintf("PersonalRecord %02d",m_StageResults[p].m_iPersonalHighScoreIndex+1) ) );
m_sprPersonalRecord[p]->SetName( ssprintf("PersonalRecordP%d",p+1) ); m_sprPersonalRecord[p]->SetName( ssprintf("PersonalRecordP%d",p+1) );
SET_XY_AND_ON_COMMAND( m_sprPersonalRecord[p] ); SET_XY_AND_ON_COMMAND( m_sprPersonalRecord[p] );
this->AddChild( m_sprPersonalRecord[p] ); this->AddChild( m_sprPersonalRecord[p] );
@@ -699,7 +712,7 @@ void ScreenEvaluation::Init()
bool bOneHasNewTopRecord = false; bool bOneHasNewTopRecord = false;
FOREACH_PlayerNumber( p ) FOREACH_PlayerNumber( p )
if( GAMESTATE->IsPlayerEnabled(p) && (m_iMachineHighScoreIndex[p] != -1 || m_iPersonalHighScoreIndex[p] != -1) ) if( GAMESTATE->IsPlayerEnabled(p) && (m_StageResults[p].m_iMachineHighScoreIndex != -1 || m_StageResults[p].m_iPersonalHighScoreIndex != -1) )
bOneHasNewTopRecord = true; bOneHasNewTopRecord = true;
Grade best_grade = Grade_NoData; Grade best_grade = Grade_NoData;
@@ -769,19 +782,12 @@ void ScreenEvaluation::Init()
void ScreenEvaluation::CommitScores( void ScreenEvaluation::CommitScores(
const StageStats &m_StageStats, const StageStats &m_StageStats,
int iPersonalHighScoreIndexOut[NUM_PLAYERS], StageResults out[NUM_PLAYERS],
int iMachineHighScoreIndexOut[NUM_PLAYERS], ScreenEvaluation::Type type )
RankingCategory rcOut[NUM_PLAYERS],
PerDifficultyAward pdaToShowOut[NUM_PLAYERS],
PeakComboAward pcaToShowOut[NUM_PLAYERS] )
{ {
FOREACH_PlayerNumber( pn ) FOREACH_PlayerNumber( pn )
{ {
iPersonalHighScoreIndexOut[pn] = -1; out[pn].Init();
iMachineHighScoreIndexOut[pn] = -1;
rcOut[pn] = RANKING_INVALID;
pdaToShowOut[pn] = PER_DIFFICULTY_AWARD_INVALID;
pcaToShowOut[pn] = PEAK_COMBO_AWARD_INVALID;
} }
switch( GAMESTATE->m_PlayMode ) switch( GAMESTATE->m_PlayMode )
@@ -795,8 +801,8 @@ void ScreenEvaluation::CommitScores(
{ {
FOREACH_PlayerNumber( pn ) FOREACH_PlayerNumber( pn )
{ {
iPersonalHighScoreIndexOut[pn] = 0; out[pn].m_iPersonalHighScoreIndex = 0;
iMachineHighScoreIndexOut[pn] = 0; out[pn].m_iMachineHighScoreIndex = 0;
} }
} }
@@ -819,7 +825,7 @@ void ScreenEvaluation::CommitScores(
// depends on if this is a course or not ... it's handled // depends on if this is a course or not ... it's handled
// below in the switch // below in the switch
HighScore &hs = m_HighScore[p]; HighScore &hs = out[p].m_HighScore;
hs.SetName( RANKING_TO_FILL_IN_MARKER[p] ); hs.SetName( RANKING_TO_FILL_IN_MARKER[p] );
hs.SetGrade( m_StageStats.m_player[p].GetGrade() ); hs.SetGrade( m_StageStats.m_player[p].GetGrade() );
hs.SetScore( m_StageStats.m_player[p].iScore ); hs.SetScore( m_StageStats.m_player[p].iScore );
@@ -840,7 +846,7 @@ void ScreenEvaluation::CommitScores(
StepsType st = GAMESTATE->GetCurrentStyle()->m_StepsType; StepsType st = GAMESTATE->GetCurrentStyle()->m_StepsType;
switch( m_Type ) switch( type )
{ {
case stage: case stage:
{ {
@@ -850,7 +856,7 @@ void ScreenEvaluation::CommitScores(
ASSERT( pSteps ); ASSERT( pSteps );
PROFILEMAN->AddStepsScore( pSong, pSteps, p, hs, iPersonalHighScoreIndexOut[p], iMachineHighScoreIndexOut[p] ); PROFILEMAN->AddStepsScore( pSong, pSteps, p, hs, out[p].m_iPersonalHighScoreIndex, out[p].m_iMachineHighScoreIndex );
} }
break; break;
@@ -861,12 +867,12 @@ void ScreenEvaluation::CommitScores(
continue; continue;
int iAverageMeter = m_StageStats.GetAverageMeter(p); int iAverageMeter = m_StageStats.GetAverageMeter(p);
rcOut[p] = AverageMeterToRankingCategory( iAverageMeter ); out[p].m_rc = AverageMeterToRankingCategory( iAverageMeter );
PROFILEMAN->AddCategoryScore( st, rcOut[p], p, hs, iPersonalHighScoreIndexOut[p], iMachineHighScoreIndexOut[p] ); PROFILEMAN->AddCategoryScore( st, out[p].m_rc, p, hs, out[p].m_iPersonalHighScoreIndex, out[p].m_iMachineHighScoreIndex );
// TRICKY: Increment play count here, and not on ScreenGameplay like the others. // TRICKY: Increment play count here, and not on ScreenGameplay like the others.
PROFILEMAN->IncrementCategoryPlayCount( st, rcOut[p], p ); PROFILEMAN->IncrementCategoryPlayCount( st, out[p].m_rc, p );
} }
break; break;
@@ -876,7 +882,7 @@ void ScreenEvaluation::CommitScores(
ASSERT( pCourse ); ASSERT( pCourse );
Trail* pTrail = GAMESTATE->m_pCurTrail[p]; Trail* pTrail = GAMESTATE->m_pCurTrail[p];
PROFILEMAN->AddCourseScore( pCourse, pTrail, p, hs, iPersonalHighScoreIndexOut[p], iMachineHighScoreIndexOut[p] ); PROFILEMAN->AddCourseScore( pCourse, pTrail, p, hs, out[p].m_iPersonalHighScoreIndex, out[p].m_iMachineHighScoreIndex );
} }
break; break;
default: default:
@@ -891,15 +897,15 @@ void ScreenEvaluation::CommitScores(
// the HighScoreList and re-get the high score index. // the HighScoreList and re-get the high score index.
FOREACH_HumanPlayer( p ) FOREACH_HumanPlayer( p )
{ {
if( iMachineHighScoreIndexOut[p] == -1 ) // no record if( out[p].m_iMachineHighScoreIndex == -1 ) // no record
continue; // skip continue; // skip
HighScore &hs = m_HighScore[p]; HighScore &hs = out[p].m_HighScore;
Profile* pProfile = PROFILEMAN->GetMachineProfile(); Profile* pProfile = PROFILEMAN->GetMachineProfile();
StepsType st = GAMESTATE->GetCurrentStyle()->m_StepsType; StepsType st = GAMESTATE->GetCurrentStyle()->m_StepsType;
const HighScoreList *pHSL = NULL; const HighScoreList *pHSL = NULL;
switch( m_Type ) switch( type )
{ {
case stage: case stage:
{ {
@@ -910,7 +916,7 @@ void ScreenEvaluation::CommitScores(
break; break;
case summary: case summary:
{ {
pHSL = &pProfile->GetCategoryHighScoreList( st, rcOut[p] ); pHSL = &pProfile->GetCategoryHighScoreList( st, out[p].m_rc );
} }
break; break;
case course: case course:
@@ -928,9 +934,9 @@ void ScreenEvaluation::CommitScores(
vector<HighScore>::const_iterator iter = find( pHSL->vHighScores.begin(), pHSL->vHighScores.end(), hs ); vector<HighScore>::const_iterator iter = find( pHSL->vHighScores.begin(), pHSL->vHighScores.end(), hs );
if( iter == pHSL->vHighScores.end() ) if( iter == pHSL->vHighScores.end() )
iMachineHighScoreIndexOut[p] = -1; out[p].m_iMachineHighScoreIndex = -1;
else else
iMachineHighScoreIndexOut[p] = iter - pHSL->vHighScores.begin(); out[p].m_iMachineHighScoreIndex = iter - pHSL->vHighScores.begin();
} }
@@ -943,7 +949,7 @@ void ScreenEvaluation::CommitScores(
LOG->Trace( "per difficulty awards" ); LOG->Trace( "per difficulty awards" );
// per-difficulty awards // per-difficulty awards
switch( m_Type ) switch( type )
{ {
case stage: case stage:
case course: case course:
@@ -981,7 +987,7 @@ void ScreenEvaluation::CommitScores(
vPdas.erase( vPdas.begin(), vPdas.end()-1 ); vPdas.erase( vPdas.begin(), vPdas.end()-1 );
if( !vPdas.empty() ) if( !vPdas.empty() )
pdaToShowOut[p] = vPdas.back(); out[p].m_pdaToShow = vPdas.back();
LOG->Trace( "done with per difficulty awards" ); LOG->Trace( "done with per difficulty awards" );
@@ -1001,7 +1007,7 @@ void ScreenEvaluation::CommitScores(
} }
if( !GAMESTATE->m_vLastPeakComboAwards[p].empty() ) if( !GAMESTATE->m_vLastPeakComboAwards[p].empty() )
pcaToShowOut[p] = GAMESTATE->m_vLastPeakComboAwards[p].back(); out[p].m_pcaToShow = GAMESTATE->m_vLastPeakComboAwards[p].back();
LOG->Trace( "done with per combo awards" ); LOG->Trace( "done with per combo awards" );
} }
@@ -1273,10 +1279,10 @@ class LunaScreenEvaluation: public Luna<ScreenEvaluation>
public: public:
LunaScreenEvaluation() { LUA->Register( Register ); } LunaScreenEvaluation() { LUA->Register( Register ); }
static int GetEvalStageStats( T* p, lua_State *L ) { p->m_StageStats.PushSelf( L ); return 1; } static int GetEvalStageStats( T* p, lua_State *L ) { p->m_StageStats.PushSelf( L ); return 1; }
static int GetPersonalHighScoreIndex( T* p, lua_State *L ) { lua_pushnumber( L, p->m_iPersonalHighScoreIndex[IArg(1)] ); return 1; } static int GetPersonalHighScoreIndex( T* p, lua_State *L ) { lua_pushnumber( L, p->m_StageResults[IArg(1)].m_iPersonalHighScoreIndex ); return 1; }
static int GetMachineHighScoreIndex( T* p, lua_State *L ) { lua_pushnumber( L, p->m_iMachineHighScoreIndex[IArg(1)] ); return 1; } static int GetMachineHighScoreIndex( T* p, lua_State *L ) { lua_pushnumber( L, p->m_StageResults[IArg(1)].m_iMachineHighScoreIndex ); return 1; }
static int GetPerDifficultyAward( T* p, lua_State *L ) { lua_pushnumber( L, p->m_pdaToShow[IArg(1)] ); return 1; } static int GetPerDifficultyAward( T* p, lua_State *L ) { lua_pushnumber( L, p->m_StageResults[IArg(1)].m_pdaToShow ); return 1; }
static int GetPeakComboAward( T* p, lua_State *L ) { lua_pushnumber( L, p->m_pcaToShow[IArg(1)] ); return 1; } static int GetPeakComboAward( T* p, lua_State *L ) { lua_pushnumber( L, p->m_StageResults[IArg(1)].m_pcaToShow ); return 1; }
static void Register( Lua *L ) static void Register( Lua *L )
{ {
+16 -11
View File
@@ -15,6 +15,20 @@
#include "HighScore.h" #include "HighScore.h"
#include "RageSound.h" #include "RageSound.h"
class StageResults
{
public:
StageResults();
void Init();
int m_iPersonalHighScoreIndex;
int m_iMachineHighScoreIndex;
RankingCategory m_rc;
PerDifficultyAward m_pdaToShow;
PeakComboAward m_pcaToShow;
HighScore m_HighScore;
};
const int MAX_SONGS_TO_SHOW = 5; // In summary, we show last 3 stages, plus extra stages if passed const int MAX_SONGS_TO_SHOW = 5; // In summary, we show last 3 stages, plus extra stages if passed
enum JudgeLine { marvelous, perfect, great, good, boo, miss, ok, max_combo, error, NUM_JUDGE_LINES }; enum JudgeLine { marvelous, perfect, great, good, boo, miss, ok, max_combo, error, NUM_JUDGE_LINES };
enum StatsLine { jumps, holds, mines, hands, rolls, NUM_STATS_LINES }; enum StatsLine { jumps, holds, mines, hands, rolls, NUM_STATS_LINES };
@@ -38,19 +52,10 @@ public:
virtual void PushSelf( lua_State *L ); virtual void PushSelf( lua_State *L );
StageStats m_StageStats; StageStats m_StageStats;
int m_iPersonalHighScoreIndex[NUM_PLAYERS]; StageResults m_StageResults[NUM_PLAYERS];
int m_iMachineHighScoreIndex[NUM_PLAYERS];
PerDifficultyAward m_pdaToShow[NUM_PLAYERS];
PeakComboAward m_pcaToShow[NUM_PLAYERS];
protected: protected:
void CommitScores( static void CommitScores( const StageStats &stageStats, StageResults out[NUM_PLAYERS], ScreenEvaluation::Type type );
const StageStats &stageStats,
int iPersonalHighScoreIndexOut[NUM_PLAYERS],
int iMachineHighScoreIndexOut[NUM_PLAYERS],
RankingCategory rcOut[NUM_PLAYERS],
PerDifficultyAward pdaToShowOut[NUM_PLAYERS],
PeakComboAward pcaToShowOut[NUM_PLAYERS] );
void EndScreen(); void EndScreen();
Type m_Type; Type m_Type;