diff options
author | whiteshark0 <whiteshark0@b956fd51-792f-4845-bead-9b4dfca2ff2c> | 2009-12-13 13:32:09 +0000 |
---|---|---|
committer | whiteshark0 <whiteshark0@b956fd51-792f-4845-bead-9b4dfca2ff2c> | 2009-12-13 13:32:09 +0000 |
commit | 46e4f20c37be63c326b9ac798c656c266301d5b0 (patch) | |
tree | e49952b531ea46acc3043620b5f1a3cd1ecf0799 | |
parent | bc2e9999248beb57e85d3ae9d0f154eb1c3c1c52 (diff) | |
download | usdx-46e4f20c37be63c326b9ac798c656c266301d5b0.tar.gz usdx-46e4f20c37be63c326b9ac798c656c266301d5b0.tar.xz usdx-46e4f20c37be63c326b9ac798c656c266301d5b0.zip |
fixed score display with linebonus=off
git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@2026 b956fd51-792f-4845-bead-9b4dfca2ff2c
Diffstat (limited to '')
-rw-r--r-- | src/base/USingScores.pas | 103 | ||||
-rw-r--r-- | src/screens/UScreenSing.pas | 4 |
2 files changed, 106 insertions, 1 deletions
diff --git a/src/base/USingScores.pas b/src/base/USingScores.pas index ed99e2c5..dc49e013 100644 --- a/src/base/USingScores.pas +++ b/src/base/USingScores.pas @@ -138,9 +138,18 @@ type FirstPopUp: PScorePopUp; LastPopUp: PScorePopUp; + // only defined during draw, time passed between + // current and previous call of draw + TimePassed: Cardinal; + // draws a popup by pointer procedure DrawPopUp(const PopUp: PScorePopUp); + // raises players score if RaiseScore was called + // has to be called after DrawPopUp and before + // DrawScore + procedure DoRaiseScore(const Index: integer); + // draws a score by playerindex procedure DrawScore(const Index: integer); @@ -149,6 +158,10 @@ type // removes a popup w/o destroying the list procedure KillPopUp(const last, cur: PScorePopUp); + + // calculate the amount of points for a player that is + // still in popups and therfore not displayed + function GetPopUpPoints(const Index: integer): integer; public Settings: record // Record containing some Displaying Options Phase1Time: real; // time for phase 1 to complete (in msecs) @@ -201,6 +214,12 @@ type // it gives every player a score position procedure Init; + // raises the score of a specified player to the specified score + procedure RaiseScore(Player: byte; Score: integer); + + // sets the score of a specified player to the specified score + procedure SetScore(Player: byte; Score: integer); + // spawns a new line bonus popup for the player procedure SpawnPopUp(const PlayerIndex: byte; const Rating: integer; const Score: integer); @@ -215,6 +234,7 @@ implementation uses SysUtils, + Math, SDL, TextGL, ULog, @@ -318,6 +338,7 @@ procedure TSingScores.ClearPlayers; begin KillAllPopUps; oPlayerCount := 0; + TimePassed := 0; end; {** @@ -328,6 +349,7 @@ begin KillAllPopUps; oPlayerCount := 0; oPositionCount := 0; + TimePassed := 0; end; {** @@ -400,6 +422,30 @@ begin end; {** + * raises the score of a specified player to the specified score + *} +procedure TSingScores.RaiseScore(Player: byte; Score: integer); +begin + if (Player <= PlayerCount - 1) then + aPlayers[Player].Score := Score; +end; + +{** + * sets the score of a specified player to the specified score + *} +procedure TSingScores.SetScore(Player: byte; Score: integer); + var + Diff: Integer; +begin + if (Player <= PlayerCount - 1) then + begin + Diff := Score - Players[Player].Score; + aPlayers[Player].Score := Score; + Inc(aPlayers[Player].ScoreDisplayed, Diff); + end; +end; + +{** * spawns a new line bonus popup for the player *} procedure TSingScores.SpawnPopUp(const PlayerIndex: byte; const Rating: integer; const Score: integer); @@ -515,6 +561,32 @@ begin end; {** + * calculate the amount of points for a player that is + * still in popups and therfore not displayed + *} +function TSingScores.GetPopUpPoints(const Index: integer): integer; + var + CurPopUp: PScorePopUp; +begin + Result := 0; + + // only check points if there is a difference between actual + // and displayed points + if (Players[Index].Score > Players[Index].ScoreDisplayed) then + begin + CurPopUp := FirstPopUp; + while (CurPopUp <> nil) do + begin + if (CurPopUp.Player = Index) then + begin // add points left "in" popup to result + Inc(Result, CurPopUp.ScoreDiff - CurPopUp.ScoreGiven); + end; + CurPopUp := CurPopUp.Next; + end; + end; +end; + +{** * has to be called after positions and players have been added, before first call of draw * it gives each player a score position *} @@ -616,6 +688,8 @@ var CurPopUp, LastPopUp: PScorePopUp; begin CurTime := SDL_GetTicks; + if (TimePassed <> 0) then + TimePassed := CurTime - TimePassed; if Visible then begin @@ -646,6 +720,7 @@ begin // draw players w/ rating bar for I := 0 to PlayerCount-1 do begin + DoRaiseScore(I); DrawScore(I); DrawRatingBar(I); end @@ -653,10 +728,38 @@ begin // draw players w/o rating bar for I := 0 to PlayerCount-1 do begin + DoRaiseScore(I); DrawScore(I); end; end; // eo visible + + TimePassed := CurTime; +end; + +{** + * raises players score if RaiseScore was called + * has to be called after DrawPopUp and before + * DrawScore + *} +procedure TSingScores.DoRaiseScore(const Index: integer); + var + S: integer; + Diff: integer; + const + RaisePerSecond = 500; +begin + S := (Players[Index].Score - Players[Index].ScoreDisplayed) + GetPopUpPoints(Index); + + if (S <> 0) then + begin + if (S > 0) then + Diff := Min(Round(RoundTo((RaisePerSecond * TimePassed) / 1000, 1)), S) + else + Diff := Max(Round(RoundTo((RaisePerSecond * TimePassed) / 1000, 1)), S); + + Inc(aPlayers[Index].ScoreDisplayed, Diff); + end; end; {** diff --git a/src/screens/UScreenSing.pas b/src/screens/UScreenSing.pas index 342abac1..20f3b15e 100644 --- a/src/screens/UScreenSing.pas +++ b/src/screens/UScreenSing.pas @@ -956,7 +956,9 @@ begin // spawn rating pop-up Rating := Round(LinePerfection * MAX_LINE_RATING); Scores.SpawnPopUp(PlayerIndex, Rating, CurrentPlayer.ScoreTotalInt); - end; + end + else + Scores.RaiseScore(PlayerIndex, CurrentPlayer.ScoreTotalInt); // PerfectLineTwinkle (effect), part 1 if (Ini.EffectSing = 1) then |