From 9643e9986a0889f7ee9fd0ae38fb788877483fb7 Mon Sep 17 00:00:00 2001 From: Steven Towle Date: Tue, 5 Apr 2005 08:50:55 +0000 Subject: [PATCH] Updated display options to work with percentage scoring --- stepmania/src/PercentageDisplay.cpp | 29 ++++++++++++++++++++++++++++- stepmania/src/PercentageDisplay.h | 4 ++++ stepmania/src/PlayerStageStats.cpp | 16 +++++++++++++++- stepmania/src/PlayerStageStats.h | 3 +++ stepmania/src/ScoreKeeperMAX2.cpp | 8 ++++++++ 5 files changed, 58 insertions(+), 2 deletions(-) diff --git a/stepmania/src/PercentageDisplay.cpp b/stepmania/src/PercentageDisplay.cpp index 220ed207c7..9f47170167 100644 --- a/stepmania/src/PercentageDisplay.cpp +++ b/stepmania/src/PercentageDisplay.cpp @@ -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 ); diff --git a/stepmania/src/PercentageDisplay.h b/stepmania/src/PercentageDisplay.h index 57aa2c6eda..5ba262e62d 100644 --- a/stepmania/src/PercentageDisplay.h +++ b/stepmania/src/PercentageDisplay.h @@ -9,6 +9,8 @@ #include "StageStats.h" #include "ThemeMetric.h" +struct PlayerState; + class PercentageDisplay: public ActorFrame { public: @@ -22,12 +24,14 @@ private: ThemeMetric PERCENT_DECIMAL_PLACES; ThemeMetric PERCENT_TOTAL_SIZE; ThemeMetric PERCENT_USE_REMAINDER; + ThemeMetric 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; }; diff --git a/stepmania/src/PlayerStageStats.cpp b/stepmania/src/PlayerStageStats.cpp index 3600b2a65d..dc8e719a1c 100644 --- a/stepmania/src/PlayerStageStats.cpp +++ b/stepmania/src/PlayerStageStats.cpp @@ -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 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]; diff --git a/stepmania/src/ScoreKeeperMAX2.cpp b/stepmania/src/ScoreKeeperMAX2.cpp index d5ef33e0e5..46e4825626 100644 --- a/stepmania/src/ScoreKeeperMAX2.cpp +++ b/stepmania/src/ScoreKeeperMAX2.cpp @@ -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 )