From 19ac29c9af9d834a3446a341bfef111622e97831 Mon Sep 17 00:00:00 2001 From: Steven Towle Date: Sun, 9 Jan 2005 07:47:38 +0000 Subject: [PATCH] added score display options --- stepmania/Themes/default/metrics.ini | 10 +++++++-- stepmania/src/PlayerOptions.cpp | 11 +++++++++- stepmania/src/PlayerOptions.h | 11 +++++++++- stepmania/src/ScoreDisplayNormal.cpp | 31 ++++++++++++++++++++++++++++ stepmania/src/ScoreKeeperMAX2.cpp | 8 +++++++ stepmania/src/StageStats.cpp | 4 +++- stepmania/src/StageStats.h | 2 ++ 7 files changed, 72 insertions(+), 5 deletions(-) diff --git a/stepmania/Themes/default/metrics.ini b/stepmania/Themes/default/metrics.ini index 8c8ac45bf5..b67068ce1b 100644 --- a/stepmania/Themes/default/metrics.ini +++ b/stepmania/Themes/default/metrics.ini @@ -3607,8 +3607,9 @@ Line9=list,Holds Line10=list,Mines Line11=list,Hide Line12=list,Persp -Line13=Steps -Line14=Characters +Line13=list,ScoreDisplay +Line14=Steps +Line15=Characters CancelAllP1X= CancelAllP1Y= CancelAllP1OnCommand= @@ -3833,6 +3834,11 @@ Persp,2=mod,overhead;name,Overhead Persp,3=mod,space;name,Space Persp,4=mod,hallway;name,Hallway Persp,5=mod,distant;name,Distant +ScoreDisplay=3 +ScoreDisplayDefault=mod,addscore +ScoreDisplay,1=mod,addscore;name,Add +ScoreDisplay,2=mod,subtractscore;name,Subtract +ScoreDisplay,3=mod,averagescore;name,Average # Song options LifeType=2,together diff --git a/stepmania/src/PlayerOptions.cpp b/stepmania/src/PlayerOptions.cpp index 8cd03e2519..93bb6b2c21 100644 --- a/stepmania/src/PlayerOptions.cpp +++ b/stepmania/src/PlayerOptions.cpp @@ -33,6 +33,7 @@ void PlayerOptions::Init() ZERO( m_bTurns ); ZERO( m_bTransforms ); m_bProTiming = false; + m_fScoreDisplay = SCORING_ADD; m_sPositioning = ""; // "null" m_sNoteSkin = "default"; } @@ -313,7 +314,14 @@ void PlayerOptions::FromString( CString sOptions ) m_sNoteSkin = sBit; else if( sBit == "noteskin" && !on ) /* "no noteskin" */ m_sNoteSkin = "default"; - else if ( sBit == "randomspeed" ) SET_FLOAT( fRandomSpeed ) + else if ( sBit == "randomspeed" ) + SET_FLOAT( fRandomSpeed ) + else if ( sBit == "addscore" ) + m_fScoreDisplay = SCORING_ADD; + else if ( sBit == "subtractscore" ) + m_fScoreDisplay = SCORING_SUBTRACT; + else if ( sBit == "averagescore" ) + m_fScoreDisplay = SCORING_AVERAGE; } } @@ -516,6 +524,7 @@ bool PlayerOptions::operator==( const PlayerOptions &other ) const COMPARE(m_fScrollSpeed); COMPARE(m_fScrollBPM); COMPARE(m_fRandomSpeed); + COMPARE(m_fScoreDisplay); COMPARE(m_fDark); COMPARE(m_fBlind); COMPARE(m_fCover); diff --git a/stepmania/src/PlayerOptions.h b/stepmania/src/PlayerOptions.h index a73d95948e..0b5159cc78 100644 --- a/stepmania/src/PlayerOptions.h +++ b/stepmania/src/PlayerOptions.h @@ -92,6 +92,13 @@ struct PlayerOptions SCROLL_CENTERED, NUM_SCROLLS }; + enum ScoreDisplay { + SCORING_ADD=0, + SCORING_SUBTRACT, + SCORING_AVERAGE, + NUM_SCOREDISPLAYS + }; + float GetReversePercentForColumn( int iCol ) const; // accounts for all Directions /* All floats have a corresponding speed setting, which determines how fast @@ -114,10 +121,12 @@ struct PlayerOptions /* If this is > 0, then the player must have life above this value at the end of * the song to pass. This is independent of SongOptions::m_FailType. */ float m_fPassmark, m_SpeedfPassmark; - + bool m_bTurns[NUM_TURNS]; bool m_bTransforms[NUM_TRANSFORMS]; bool m_bProTiming; + float m_fScoreDisplay; + CString m_sPositioning; /* The current positioning mode, or empty to use the normal positions. */ CString m_sNoteSkin; diff --git a/stepmania/src/ScoreDisplayNormal.cpp b/stepmania/src/ScoreDisplayNormal.cpp index 79bad6316c..bb3b75d9a1 100644 --- a/stepmania/src/ScoreDisplayNormal.cpp +++ b/stepmania/src/ScoreDisplayNormal.cpp @@ -6,6 +6,7 @@ #include "GameState.h" #include "ThemeManager.h" #include "PlayerState.h" +#include "StageStats.h" const float SCORE_TWEEN_TIME = 0.2f; @@ -24,6 +25,7 @@ ScoreDisplayNormal::ScoreDisplayNormal() m_text.SetShadowLength( 0 ); m_iScore = 0; + m_iTrailingScore = 0; m_iScoreVelocity = 0; @@ -48,6 +50,35 @@ void ScoreDisplayNormal::SetScore( int iNewScore ) { m_iScore = iNewScore; + // play some games to display the correct score -- the actual internal score does not change at all + // but the displayed one can (ie: displayed score for subtracrive is MaxScore - score) + + // TODO: Remove use of PlayerNumber. + PlayerNumber pn = m_pPlayerState->m_PlayerNumber; + + + if ( m_pPlayerState->m_CurrentPlayerOptions.m_fScoreDisplay == PlayerOptions::SCORING_SUBTRACT ) + { + if ( iNewScore == 0 && g_CurStageStats.m_player[pn].iMaxScoreToNow == 0 ) + { + m_iScore = g_CurStageStats.m_player[pn].iMaxScore; + } + else + { + m_iScore = g_CurStageStats.m_player[pn].iMaxScore - ( g_CurStageStats.m_player[pn].iMaxScoreToNow - iNewScore ); + } + } + else if ( m_pPlayerState->m_CurrentPlayerOptions.m_fScoreDisplay == PlayerOptions::SCORING_AVERAGE ) + { + if ( g_CurStageStats.m_player[pn].iMaxScoreToNow == 0 ) // don't divide by zero fats + m_iScore = 0; + else + { + float scoreRatio = ( (float) iNewScore / (float) g_CurStageStats.m_player[pn].iMaxScoreToNow ); + m_iScore = (int) ( scoreRatio * g_CurStageStats.m_player[pn].iMaxScore ); + } + } + int iDelta = m_iScore - m_iTrailingScore; m_iScoreVelocity = int(float(iDelta) / SCORE_TWEEN_TIME); // in score units per second diff --git a/stepmania/src/ScoreKeeperMAX2.cpp b/stepmania/src/ScoreKeeperMAX2.cpp index d84dae8461..9bd3170b5d 100644 --- a/stepmania/src/ScoreKeeperMAX2.cpp +++ b/stepmania/src/ScoreKeeperMAX2.cpp @@ -171,6 +171,7 @@ void ScoreKeeperMAX2::OnNextSong( int iSongInCourseIndex, const Steps* pSteps, c m_iNumTapsAndHolds = pNoteData->GetNumRowsWithTapOrHoldHead() + pNoteData->GetNumHoldNotes(); m_iPointBonus = m_iMaxPossiblePoints; + m_pPlayerStageStats->iMaxScore = m_iMaxScoreSoFar; ASSERT( m_iPointBonus >= 0 ); @@ -206,6 +207,7 @@ static int GetScore(int p, int B, int S, int n) void ScoreKeeperMAX2::AddScore( TapNoteScore score ) { int &iScore = m_pPlayerStageStats->iScore; + int &iMaxScoreToNow = m_pPlayerStageStats->iMaxScoreToNow; /* http://www.aaroninjapan.com/ddr2.html @@ -284,6 +286,8 @@ void ScoreKeeperMAX2::AddScore( TapNoteScore score ) /* Subtract the maximum this step could have been worth from the bonus. */ m_iPointBonus -= GetScore(10, B, sum, m_iTapNotesHit); + /* And add the maximum this step could have been worth to the max score up to now. */ + iMaxScoreToNow += GetScore(10, B, sum, m_iTapNotesHit); if ( m_iTapNotesHit == m_iNumTapsAndHolds && score >= TNS_PERFECT ) { @@ -292,11 +296,13 @@ void ScoreKeeperMAX2::AddScore( TapNoteScore score ) if ( m_bIsLastSongInCourse ) { iScore += 100000000 - m_iMaxScoreSoFar; + iMaxScoreToNow += 100000000 - m_iMaxScoreSoFar; /* If we're in Endless mode, we'll come around here again, so reset * the bonus counter. */ m_iMaxScoreSoFar = 0; } + iMaxScoreToNow += m_iPointBonus; } ASSERT( iScore >= 0 ); @@ -421,6 +427,8 @@ void ScoreKeeperMAX2::HandleHoldScore( HoldNoteScore holdScore, TapNoteScore tap if( holdScore == HNS_OK ) AddScore( TNS_MARVELOUS ); + else if ( holdScore == HNS_NG ) + AddScore( TNS_GOOD ); // required for subtractive score display to work properly // TODO: Remove indexing with PlayerNumber PlayerNumber pn = m_pPlayerState->m_PlayerNumber; diff --git a/stepmania/src/StageStats.cpp b/stepmania/src/StageStats.cpp index c1323d5557..6a0851355b 100644 --- a/stepmania/src/StageStats.cpp +++ b/stepmania/src/StageStats.cpp @@ -18,7 +18,7 @@ void PlayerStageStats::Init() fAliveSeconds = 0; bFailed = bFailedEarlier = false; iPossibleDancePoints = iActualDancePoints = 0; - iCurCombo = iMaxCombo = iCurMissCombo = iScore = iBonus = 0; + iCurCombo = iMaxCombo = iCurMissCombo = iScore = iBonus = iMaxScore = iMaxScoreToNow = 0; fSecondsBeforeFail = 0; iSongsPassed = iSongsPlayed = 0; iTotalError = 0; @@ -50,6 +50,8 @@ void PlayerStageStats::AddStats( const PlayerStageStats& other ) iMaxCombo += other.iMaxCombo; iCurMissCombo += other.iCurMissCombo; iScore += other.iScore; + iMaxScore += other.iMaxScore; + iMaxScoreToNow += other.iMaxScoreToNow; radarPossible += other.radarPossible; radarActual += other.radarActual; fSecondsBeforeFail += other.fSecondsBeforeFail; diff --git a/stepmania/src/StageStats.h b/stepmania/src/StageStats.h index 03034700ea..1e906dec15 100644 --- a/stepmania/src/StageStats.h +++ b/stepmania/src/StageStats.h @@ -40,6 +40,8 @@ struct PlayerStageStats int iMaxCombo; int iCurMissCombo; int iScore; + int iMaxScoreToNow; + int iMaxScore; int iBonus; // bonus to be added on screeneval RadarValues radarPossible; // filled in by ScreenGameplay on start of notes RadarValues radarActual;