Updated display options to work with percentage scoring
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
#include "ActorUtil.h"
|
||||
#include "RageLog.h"
|
||||
#include "StageStats.h"
|
||||
#include "PlayerState.h"
|
||||
|
||||
|
||||
PercentageDisplay::PercentageDisplay()
|
||||
@@ -20,11 +21,13 @@ void PercentageDisplay::Load( PlayerNumber pn, PlayerStageStats* pSource, const
|
||||
m_pSource = pSource;
|
||||
m_bAutoRefresh = bAutoRefresh;
|
||||
m_Last = -1;
|
||||
m_LastMax = -1;
|
||||
|
||||
DANCE_POINT_DIGITS.Load( sMetricsGroup, "DancePointsDigits" );
|
||||
PERCENT_DECIMAL_PLACES.Load( sMetricsGroup, "PercentDecimalPlaces" );
|
||||
PERCENT_TOTAL_SIZE.Load( sMetricsGroup, "PercentTotalSize" );
|
||||
PERCENT_USE_REMAINDER.Load( sMetricsGroup, "PercentUseRemainder" );
|
||||
APPLY_SCORE_DISPLAY_OPTIONS.Load( sMetricsGroup, "ApplyScoreDisplayOptions" );
|
||||
|
||||
|
||||
if( PREFSMAN->m_bDancePointsForOni )
|
||||
@@ -68,12 +71,16 @@ void PercentageDisplay::Update( float fDeltaTime )
|
||||
void PercentageDisplay::Refresh()
|
||||
{
|
||||
const int iActualDancePoints = m_pSource->iActualDancePoints;
|
||||
if( iActualDancePoints == m_Last )
|
||||
const int iCurPossibleDancePoints = m_pSource->iCurPossibleDancePoints;
|
||||
|
||||
if( iActualDancePoints == m_Last && iCurPossibleDancePoints == m_LastMax )
|
||||
return;
|
||||
|
||||
m_Last = iActualDancePoints;
|
||||
m_LastMax = iCurPossibleDancePoints;
|
||||
|
||||
CString sNumToDisplay;
|
||||
|
||||
if( PREFSMAN->m_bDancePointsForOni )
|
||||
{
|
||||
sNumToDisplay = ssprintf( "%*d", (int) DANCE_POINT_DIGITS, max( 0, iActualDancePoints ) );
|
||||
@@ -81,6 +88,26 @@ void PercentageDisplay::Refresh()
|
||||
else
|
||||
{
|
||||
float fPercentDancePoints = m_pSource->GetPercentDancePoints();
|
||||
float fCurMaxPercentDancePoints = m_pSource->GetCurMaxPercentDancePoints();
|
||||
|
||||
if ( APPLY_SCORE_DISPLAY_OPTIONS )
|
||||
{
|
||||
switch( GAMESTATE->m_pPlayerState[m_PlayerNumber]->m_CurrentPlayerOptions.m_ScoreDisplay )
|
||||
{
|
||||
case PlayerOptions::SCORING_ADD:
|
||||
// nothing to do
|
||||
break;
|
||||
case PlayerOptions::SCORING_SUBTRACT:
|
||||
fPercentDancePoints = 1.0f - ( fCurMaxPercentDancePoints - fPercentDancePoints );
|
||||
break;
|
||||
case PlayerOptions::SCORING_AVERAGE:
|
||||
if( fCurMaxPercentDancePoints == 0.0f ) // don't divide by zero fats
|
||||
fPercentDancePoints = 0.0f;
|
||||
else
|
||||
fPercentDancePoints = fPercentDancePoints / fCurMaxPercentDancePoints;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// clamp percentage - feedback is that negative numbers look weird here.
|
||||
CLAMP( fPercentDancePoints, 0.f, 1.f );
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
#include "StageStats.h"
|
||||
#include "ThemeMetric.h"
|
||||
|
||||
struct PlayerState;
|
||||
|
||||
class PercentageDisplay: public ActorFrame
|
||||
{
|
||||
public:
|
||||
@@ -22,12 +24,14 @@ private:
|
||||
ThemeMetric<int> PERCENT_DECIMAL_PLACES;
|
||||
ThemeMetric<int> PERCENT_TOTAL_SIZE;
|
||||
ThemeMetric<bool> PERCENT_USE_REMAINDER;
|
||||
ThemeMetric<bool> APPLY_SCORE_DISPLAY_OPTIONS;
|
||||
|
||||
void Refresh();
|
||||
PlayerNumber m_PlayerNumber;
|
||||
PlayerStageStats *m_pSource;
|
||||
bool m_bAutoRefresh;
|
||||
int m_Last;
|
||||
int m_LastMax;
|
||||
BitmapText m_textPercent;
|
||||
BitmapText m_textPercentRemainder;
|
||||
};
|
||||
|
||||
@@ -18,7 +18,7 @@ void PlayerStageStats::Init()
|
||||
vpSteps.clear();
|
||||
fAliveSeconds = 0;
|
||||
bFailed = bFailedEarlier = false;
|
||||
iPossibleDancePoints = iActualDancePoints = 0;
|
||||
iPossibleDancePoints = iCurPossibleDancePoints = iActualDancePoints = 0;
|
||||
iCurCombo = iMaxCombo = iCurMissCombo = iScore = iBonus = iMaxScore = iCurMaxScore = 0;
|
||||
iSongsPassed = iSongsPlayed = 0;
|
||||
iTotalError = 0;
|
||||
@@ -42,6 +42,7 @@ void PlayerStageStats::AddStats( const PlayerStageStats& other )
|
||||
bFailedEarlier |= other.bFailedEarlier;
|
||||
iPossibleDancePoints += other.iPossibleDancePoints;
|
||||
iActualDancePoints += other.iActualDancePoints;
|
||||
iCurPossibleDancePoints += other.iCurPossibleDancePoints;
|
||||
|
||||
for( int t=0; t<NUM_TAP_NOTE_SCORES; t++ )
|
||||
iTapNoteScores[t] += other.iTapNoteScores[t];
|
||||
@@ -208,6 +209,19 @@ float PlayerStageStats::GetPercentDancePoints() const
|
||||
return fPercentDancePoints;
|
||||
}
|
||||
|
||||
float PlayerStageStats::GetCurMaxPercentDancePoints() const
|
||||
{
|
||||
if ( iPossibleDancePoints == 0 )
|
||||
return 0; // div/0
|
||||
|
||||
if ( iCurPossibleDancePoints == iPossibleDancePoints )
|
||||
return 1; // correct for rounding error
|
||||
|
||||
float fCurMaxPercentDancePoints = iCurPossibleDancePoints / (float)iPossibleDancePoints;
|
||||
|
||||
return fCurMaxPercentDancePoints;
|
||||
}
|
||||
|
||||
void PlayerStageStats::SetLifeRecordAt( float fLife, float fSecond )
|
||||
{
|
||||
// Don't save life stats in endless courses, or could run OOM in a few hours.
|
||||
|
||||
@@ -20,6 +20,8 @@ struct PlayerStageStats
|
||||
static Grade GetGradeFromPercent( float fPercent );
|
||||
Grade GetGrade() const;
|
||||
float GetPercentDancePoints() const;
|
||||
float GetCurMaxPercentDancePoints() const;
|
||||
|
||||
vector<Steps*> vpSteps;
|
||||
float fAliveSeconds; // how far into the music did they last before failing? Updated by Gameplay, scaled by music rate.
|
||||
|
||||
@@ -32,6 +34,7 @@ struct PlayerStageStats
|
||||
* point during the song. It's set in all fail modes. */
|
||||
bool bFailedEarlier;
|
||||
int iPossibleDancePoints;
|
||||
int iCurPossibleDancePoints;
|
||||
int iActualDancePoints;
|
||||
int iTapNoteScores[NUM_TAP_NOTE_SCORES];
|
||||
int iHoldNoteScores[NUM_HOLD_NOTE_SCORES];
|
||||
|
||||
@@ -344,6 +344,10 @@ void ScoreKeeperMAX2::HandleTapRowScore( TapNoteScore scoreOfLastTap, int iNumTa
|
||||
// update judged row totals
|
||||
m_pPlayerStageStats->iTapNoteScores[scoreOfLastTap] += 1;
|
||||
|
||||
// increment the current total possible dance score
|
||||
|
||||
m_pPlayerStageStats->iCurPossibleDancePoints += TapNoteScoreToDancePoints( TNS_MARVELOUS );
|
||||
|
||||
//
|
||||
// Regular combo
|
||||
//
|
||||
@@ -432,6 +436,10 @@ void ScoreKeeperMAX2::HandleHoldScore( HoldNoteScore holdScore, TapNoteScore tap
|
||||
m_pPlayerStageStats->iActualDancePoints += HoldNoteScoreToDancePoints( holdScore );
|
||||
m_pPlayerStageStats->iHoldNoteScores[holdScore] ++;
|
||||
|
||||
// increment the current total possible dance score
|
||||
|
||||
m_pPlayerStageStats->iCurPossibleDancePoints += HoldNoteScoreToDancePoints( HNS_OK );
|
||||
|
||||
if( holdScore == HNS_OK )
|
||||
AddScore( TNS_MARVELOUS );
|
||||
else if ( holdScore == HNS_NG )
|
||||
|
||||
Reference in New Issue
Block a user