-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Add tier colour to ranked play ranking on profile overlay #38197
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
diquoks
wants to merge
1
commit into
ppy:master
Choose a base branch
from
diquoks:feature/ranked-colour
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+53
−18
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -12,6 +12,7 @@ | |
| using osu.Game.Graphics.Sprites; | ||
| using osu.Game.Online.API.Requests.Responses; | ||
| using osu.Game.Resources.Localisation.Web; | ||
| using osu.Game.Scoring; | ||
|
|
||
| namespace osu.Game.Overlays.Profile.Header.Components | ||
| { | ||
|
|
@@ -107,32 +108,59 @@ private void updateDisplay() | |
| return; | ||
| } | ||
|
|
||
| APIUserMatchmakingStatistics[] stats = User.Value.User.MatchmakingStatistics; | ||
| APIUserMatchmakingStatistics[] allStats = User.Value.User.MatchmakingStatistics; | ||
|
|
||
| if (stats.Length == 0) | ||
| if (allStats.Length == 0) | ||
| { | ||
| Hide(); | ||
| return; | ||
| } | ||
|
|
||
| int? highestRank = null; | ||
| APIUserMatchmakingStatistics? highestRankStats = null; | ||
|
|
||
| foreach (var stat in stats) | ||
| foreach (var stats in allStats) | ||
| { | ||
| if (stat.Pool.Active && stat.Rank != null) | ||
| { | ||
| if (highestRank == null || stat.Rank < highestRank) | ||
| highestRank = stat.Rank; | ||
| } | ||
| if (stats.Pool.Active && (highestRankStats == null || stats.Rank < highestRankStats.Rank)) | ||
| highestRankStats = stats; | ||
| } | ||
|
Comment on lines
+111
to
125
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. see reference |
||
|
|
||
| rankText.Text = highestRank == null ? "-" : $"#{highestRank:N0}"; | ||
| rankText.Text = highestRankStats == null ? "-" : $"#{highestRankStats.Rank:N0}"; | ||
|
|
||
| if (highestRankStats != null) | ||
| rankText.Colour = OsuColour.ForRankingTier(GetRankingTier(highestRankStats)); | ||
|
|
||
| TooltipContent = new MatchmakingStatsTooltipData(colourProvider, stats.OrderByDescending(s => s.PoolId).ToArray()); | ||
| TooltipContent = new MatchmakingStatsTooltipData(colourProvider, allStats.OrderByDescending(s => s.PoolId).ToArray()); | ||
|
|
||
| Show(); | ||
| } | ||
|
|
||
| /// <seealso href="https://github.com/ppy/osu-web/blob/9f136df53a1c436229b0e4eb192011c15514dcf9/resources/js/profile-page/matchmaking.tsx#L15-L34"/> | ||
| public static RankingTier GetRankingTier(APIUserMatchmakingStatistics stats) | ||
| { | ||
| int rank = stats.Rank; | ||
| float percent = stats.RankPercent; | ||
|
|
||
| if (rank <= 100) | ||
| return RankingTier.Lustrous; | ||
|
|
||
| if (percent < 0.05) | ||
| return RankingTier.Radiant; | ||
|
|
||
| if (percent < 0.2) | ||
| return RankingTier.Rhodium; | ||
|
|
||
| if (percent < 0.5) | ||
| return RankingTier.Platinum; | ||
|
|
||
| if (percent < 0.75) | ||
| return RankingTier.Gold; | ||
|
|
||
| if (percent < 0.95) | ||
| return RankingTier.Silver; | ||
|
|
||
| return RankingTier.Bronze; | ||
| } | ||
|
|
||
| public ITooltip<MatchmakingStatsTooltipData> GetCustomTooltip() => new MatchmakingStatsTooltip(); | ||
|
|
||
| public MatchmakingStatsTooltipData? TooltipContent { get; private set; } | ||
|
|
||
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see reference