-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Extract rank component from BeatmapLeaderboardScore
#37064
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
LiquidPL
wants to merge
4
commits into
ppy:master
Choose a base branch
from
LiquidPL:leaderboard-rank-component
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.
+175
−107
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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 |
|---|---|---|
| @@ -0,0 +1,98 @@ | ||
| // Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. | ||
| // See the LICENCE file in the repository root for full licence text. | ||
|
|
||
| using osu.Framework.Allocation; | ||
| using osu.Framework.Extensions.Color4Extensions; | ||
| using osu.Framework.Graphics; | ||
| using osu.Framework.Graphics.Colour; | ||
| using osu.Framework.Graphics.Containers; | ||
| using osu.Framework.Graphics.Shapes; | ||
| using osu.Game.Graphics; | ||
| using osuTK.Graphics; | ||
|
|
||
| namespace osu.Game.Online.Leaderboards | ||
| { | ||
| public partial class LeaderboardRankDisplay : Container | ||
| { | ||
| public const int WIDTH = 40; | ||
|
|
||
| public readonly int? Rank; | ||
| public readonly HighlightType? Highlight; | ||
|
|
||
| [Resolved] | ||
| private OsuColour colours { get; set; } = null!; | ||
|
|
||
| private static readonly Color4 personal_best_gradient_left = Color4Extensions.FromHex("#66FFCC"); | ||
| private static readonly Color4 personal_best_gradient_right = Color4Extensions.FromHex("#51A388"); | ||
|
|
||
| private Container highlightGradient = null!; | ||
|
|
||
| private readonly bool sheared; | ||
|
|
||
| public LeaderboardRankDisplay(int? rank, bool sheared = false, HighlightType? highlight = null) | ||
| { | ||
| Rank = rank; | ||
| Highlight = highlight; | ||
|
|
||
| this.sheared = sheared; | ||
| } | ||
|
|
||
| [BackgroundDependencyLoader] | ||
| private void load() | ||
| { | ||
| Width = WIDTH; | ||
| RelativeSizeAxes = Axes.Y; | ||
| Children = new Drawable[] | ||
| { | ||
| highlightGradient = new Container | ||
| { | ||
| RelativeSizeAxes = Axes.Both, | ||
| Padding = new MarginPadding { Right = -10f }, | ||
| Alpha = Highlight != null ? 1 : 0, | ||
| Colour = getHighlightColour(Highlight), | ||
| Child = new Box { RelativeSizeAxes = Axes.Both }, | ||
| }, | ||
| new LeaderboardRankLabel(Rank, sheared, darkText: Highlight == HighlightType.Own) | ||
| { | ||
| RelativeSizeAxes = Axes.Both, | ||
| }, | ||
| }; | ||
| } | ||
|
|
||
| private ColourInfo getHighlightColour(HighlightType? highlightType, float lightenAmount = 0) | ||
| { | ||
| switch (highlightType) | ||
| { | ||
| case HighlightType.Own: | ||
| return ColourInfo.GradientHorizontal(personal_best_gradient_left.Lighten(lightenAmount), personal_best_gradient_right.Lighten(lightenAmount)); | ||
|
|
||
| case HighlightType.Friend: | ||
| return ColourInfo.GradientHorizontal(colours.Pink1.Lighten(lightenAmount), colours.Pink3.Lighten(lightenAmount)); | ||
|
|
||
| default: | ||
| return Colour4.White; | ||
| } | ||
| } | ||
|
|
||
| public void UpdateHighlightState(bool isHovered, double duration) | ||
| { | ||
| highlightGradient.FadeColour(getHighlightColour(Highlight, isHovered ? 0.2f : 0), duration, Easing.OutQuint); | ||
| } | ||
|
|
||
| public void Appear(double duration) | ||
| { | ||
| this.FadeIn(duration, Easing.OutQuint).ResizeWidthTo(WIDTH, duration, Easing.OutQuint); | ||
| } | ||
|
|
||
| public void Disappear(double duration) | ||
| { | ||
| this.FadeOut(duration, Easing.OutQuint).ResizeWidthTo(0, duration, Easing.OutQuint); | ||
| } | ||
|
|
||
| public enum HighlightType | ||
| { | ||
| Own, | ||
| Friend, | ||
| } | ||
| } | ||
| } |
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 |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| // Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. | ||
| // See the LICENCE file in the repository root for full licence text. | ||
|
|
||
| using osu.Framework.Allocation; | ||
| using osu.Framework.Graphics; | ||
| using osu.Framework.Graphics.Containers; | ||
| using osu.Framework.Graphics.Cursor; | ||
| using osu.Framework.Localisation; | ||
| using osu.Game.Graphics; | ||
| using osu.Game.Graphics.Sprites; | ||
| using osu.Game.Overlays; | ||
| using osu.Game.Utils; | ||
| using osuTK; | ||
|
|
||
| namespace osu.Game.Online.Leaderboards | ||
| { | ||
| public partial class LeaderboardRankLabel : Container, IHasTooltip | ||
| { | ||
| private readonly bool darkText; | ||
| private readonly OsuSpriteText text; | ||
|
|
||
| public LeaderboardRankLabel(int? rank, bool sheared, bool darkText) | ||
| { | ||
| this.darkText = darkText; | ||
| if (rank >= 1000) | ||
| TooltipText = $"#{rank:N0}"; | ||
|
|
||
| Child = text = new OsuSpriteText | ||
| { | ||
| Shear = sheared ? -OsuGame.SHEAR : Vector2.Zero, | ||
| Anchor = Anchor.Centre, | ||
| Origin = Anchor.Centre, | ||
| Font = OsuFont.Style.Heading2, | ||
| Text = rank?.FormatRank().Insert(0, "#") ?? "-", | ||
| Shadow = !darkText, | ||
| }; | ||
| } | ||
|
|
||
| [BackgroundDependencyLoader] | ||
| private void load(OverlayColourProvider colourProvider) | ||
| { | ||
| text.Colour = darkText ? colourProvider.Background3 : colourProvider.Content1; | ||
| } | ||
|
|
||
| public LocalisableString TooltipText { get; } | ||
| } | ||
| } |
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.
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.
Uh oh!
There was an error while loading. Please reload this page.