-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29585 from 424ever/daily-play-count-colours
Fix Daily Challenge play count using a different colour than osu-web
- Loading branch information
Showing
2 changed files
with
17 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the MIT Licence. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
using System; | ||
using osu.Framework.Allocation; | ||
using osu.Framework.Bindables; | ||
using osu.Framework.Extensions.LocalisationExtensions; | ||
|
@@ -11,9 +12,9 @@ | |
using osu.Game.Graphics; | ||
using osu.Game.Graphics.Containers; | ||
using osu.Game.Graphics.Sprites; | ||
using osu.Game.Localisation; | ||
using osu.Game.Online.API.Requests.Responses; | ||
using osu.Game.Scoring; | ||
using osu.Game.Localisation; | ||
|
||
namespace osu.Game.Overlays.Profile.Header.Components | ||
{ | ||
|
@@ -107,15 +108,18 @@ private void updateDisplay() | |
APIUserDailyChallengeStatistics stats = User.Value.User.DailyChallengeStatistics; | ||
|
||
dailyPlayCount.Text = DailyChallengeStatsDisplayStrings.UnitDay(stats.PlayCount.ToLocalisableString("N0")); | ||
dailyPlayCount.Colour = colours.ForRankingTier(tierForPlayCount(stats.PlayCount)); | ||
dailyPlayCount.Colour = colours.ForRankingTier(TierForPlayCount(stats.PlayCount)); | ||
|
||
TooltipContent = new DailyChallengeTooltipData(colourProvider, stats); | ||
|
||
Show(); | ||
|
||
static RankingTier tierForPlayCount(int playCount) => DailyChallengeStatsTooltip.TierForDaily(playCount / 3); | ||
} | ||
|
||
// Rounding up is needed here to ensure the overlay shows the same colour as osu-web for the play count. | ||
// This is because, for example, 31 / 3 > 10 in JavaScript because floats are used, while here it would | ||
// get truncated to 10 with an integer division and show a lower tier. | ||
public static RankingTier TierForPlayCount(int playCount) => DailyChallengeStatsTooltip.TierForDaily((int)Math.Ceiling(playCount / 3.0d)); | ||
|
||
public ITooltip<DailyChallengeTooltipData> GetCustomTooltip() => new DailyChallengeStatsTooltip(); | ||
} | ||
} |