Repository navigation
Add ranked play division badges #38989
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
5
commits into
ppy:master
Choose a base branch
from
LiquidPL:rp-division-badge
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.
+387
−0
Open
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
c7a4d80
Add ranked play division badges
LiquidPL d922918
Move enums around
LiquidPL 0f7eb21
Move `CompactDivisionBadge` into right location
LiquidPL bbb2094
Move stars layer under ruleset layer
LiquidPL eee70c8
Actually rename enum
LiquidPL 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
78 changes: 78 additions & 0 deletions
78
osu.Game.Tests/Visual/RankedPlay/TestSceneCompactDivisionBadge.cs
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,78 @@ | ||
| // 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 System.Linq; | ||
| using osu.Framework.Graphics; | ||
| using osu.Framework.Graphics.Containers; | ||
| using osu.Game.Online.API.Requests.Responses; | ||
| using osu.Game.Online.RankedPlay; | ||
| using osuTK; | ||
|
|
||
| namespace osu.Game.Tests.Visual.RankedPlay | ||
| { | ||
| public partial class TestSceneCompactDivisionBadge : OsuTestScene | ||
| { | ||
| public TestSceneCompactDivisionBadge() | ||
| { | ||
| Child = new GridContainer | ||
| { | ||
| RelativeSizeAxes = Axes.Both, | ||
| ColumnDimensions = new[] | ||
| { | ||
| new Dimension(), | ||
| new Dimension(), | ||
| }, | ||
| Content = new[] | ||
| { | ||
| new Drawable[] | ||
| { | ||
| new FillFlowContainer | ||
| { | ||
| AutoSizeAxes = Axes.Y, | ||
| Width = 150, | ||
| Anchor = Anchor.Centre, | ||
| Origin = Anchor.Centre, | ||
| Direction = FillDirection.Full, | ||
| Spacing = new Vector2(10), | ||
| Children = DIVISIONS.Select(d => new CompactDivisionBadge(d)).ToArray(), | ||
| }, | ||
| new FillFlowContainer | ||
| { | ||
| AutoSizeAxes = Axes.Both, | ||
| Anchor = Anchor.Centre, | ||
| Origin = Anchor.Centre, | ||
| Direction = FillDirection.Vertical, | ||
| Spacing = new Vector2(10), | ||
| ChildrenEnumerable = Enumerable.Range(1, 100).Where(i => i == 1 || i == 100 || i % 5 == 0).Select(i => new CompactDivisionBadge( | ||
| new RankedPlayDivision { Tier = Tier.Lustrous, DisplayName = "Lustrous", StartRating = 2400, EndRating = 3000 }, | ||
| i | ||
| )), | ||
| } | ||
| } | ||
| }, | ||
| }; | ||
| } | ||
|
|
||
| public static readonly RankedPlayDivision[] DIVISIONS = | ||
| [ | ||
| new RankedPlayDivision { Key = "Bronze-I", Tier = Tier.Bronze, Division = Division.I, DisplayName = "Bronze I", StartRating = 600, EndRating = 699 }, | ||
| new RankedPlayDivision { Key = "Bronze-II", Tier = Tier.Bronze, Division = Division.II, DisplayName = "Bronze II", StartRating = 700, EndRating = 799 }, | ||
| new RankedPlayDivision { Key = "Bronze-III", Tier = Tier.Bronze, Division = Division.III, DisplayName = "Bronze III", StartRating = 800, EndRating = 899 }, | ||
| new RankedPlayDivision { Key = "Silver-I", Tier = Tier.Silver, Division = Division.I, DisplayName = "Silver I", StartRating = 900, EndRating = 999 }, | ||
| new RankedPlayDivision { Key = "Silver-II", Tier = Tier.Silver, Division = Division.II, DisplayName = "Silver II", StartRating = 1000, EndRating = 1099 }, | ||
| new RankedPlayDivision { Key = "Silver-III", Tier = Tier.Silver, Division = Division.III, DisplayName = "Silver III", StartRating = 1100, EndRating = 1199 }, | ||
| new RankedPlayDivision { Key = "Gold-I", Tier = Tier.Gold, Division = Division.I, DisplayName = "Gold I", StartRating = 1200, EndRating = 1299 }, | ||
| new RankedPlayDivision { Key = "Gold-II", Tier = Tier.Gold, Division = Division.II, DisplayName = "Gold II", StartRating = 1300, EndRating = 1399 }, | ||
| new RankedPlayDivision { Key = "Gold-III", Tier = Tier.Gold, Division = Division.III, DisplayName = "Gold III", StartRating = 1400, EndRating = 1499 }, | ||
| new RankedPlayDivision { Key = "Platinum-I", Tier = Tier.Platinum, Division = Division.I, DisplayName = "Platinum I", StartRating = 1500, EndRating = 1599 }, | ||
| new RankedPlayDivision { Key = "Platinum-II", Tier = Tier.Platinum, Division = Division.II, DisplayName = "Platinum II", StartRating = 1600, EndRating = 1699 }, | ||
| new RankedPlayDivision { Key = "Platinum-III", Tier = Tier.Platinum, Division = Division.III, DisplayName = "Platinum III", StartRating = 1700, EndRating = 1799 }, | ||
| new RankedPlayDivision { Key = "Rhodium-I", Tier = Tier.Rhodium, Division = Division.I, DisplayName = "Rhodium I", StartRating = 1800, EndRating = 1899 }, | ||
| new RankedPlayDivision { Key = "Rhodium-II", Tier = Tier.Rhodium, Division = Division.II, DisplayName = "Rhodium II", StartRating = 1900, EndRating = 1999 }, | ||
| new RankedPlayDivision { Key = "Rhodium-III", Tier = Tier.Rhodium, Division = Division.III, DisplayName = "Rhodium III", StartRating = 2000, EndRating = 2099 }, | ||
| new RankedPlayDivision { Key = "Radiant-I", Tier = Tier.Radiant, Division = Division.I, DisplayName = "Radiant I", StartRating = 2100, EndRating = 2199 }, | ||
| new RankedPlayDivision { Key = "Radiant-II", Tier = Tier.Radiant, Division = Division.II, DisplayName = "Radiant II", StartRating = 2200, EndRating = 2299 }, | ||
| new RankedPlayDivision { Key = "Radiant-III", Tier = Tier.Radiant, Division = Division.III, DisplayName = "Radiant III", StartRating = 2300, EndRating = 2399 }, | ||
| ]; | ||
| } | ||
| } |
71 changes: 71 additions & 0 deletions
71
osu.Game.Tests/Visual/RankedPlay/TestSceneDivisionBadge.cs
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,71 @@ | ||
| // 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 System.Linq; | ||
| using NUnit.Framework; | ||
| using osu.Framework.Allocation; | ||
| using osu.Framework.Graphics; | ||
| using osu.Framework.Graphics.Containers; | ||
| using osu.Game.Online.API.Requests.Responses; | ||
| using osu.Game.Rulesets; | ||
| using osu.Game.Screens.OnlinePlay.Matchmaking.RankedPlay.Components; | ||
| using osuTK; | ||
|
|
||
| namespace osu.Game.Tests.Visual.RankedPlay | ||
| { | ||
| public partial class TestSceneDivisionBadge : OsuTestScene | ||
| { | ||
| [Resolved] | ||
| private RulesetStore rulesetStore { get; set; } = null!; | ||
|
|
||
| [TestCase("osu")] | ||
| [TestCase("taiko")] | ||
| [TestCase("fruits")] | ||
| [TestCase("mania")] | ||
| public void TestRuleset(string rulesetName) | ||
| { | ||
| var ruleset = rulesetStore.GetRuleset(rulesetName)!; | ||
| AddStep("create", () => | ||
| { | ||
| Child = new GridContainer | ||
| { | ||
| RelativeSizeAxes = Axes.Both, | ||
| ColumnDimensions = new[] | ||
| { | ||
| new Dimension(), | ||
| new Dimension(), | ||
| }, | ||
| Content = new[] | ||
| { | ||
| new Drawable[] | ||
| { | ||
| new FillFlowContainer | ||
| { | ||
| AutoSizeAxes = Axes.Y, | ||
| Width = 400, | ||
| Anchor = Anchor.Centre, | ||
| Origin = Anchor.Centre, | ||
| Direction = FillDirection.Full, | ||
| Spacing = new Vector2(10), | ||
| ChildrenEnumerable = TestSceneCompactDivisionBadge.DIVISIONS.Select(d => new DivisionBadge(d, ruleset)), | ||
| }, | ||
| new FillFlowContainer | ||
| { | ||
| AutoSizeAxes = Axes.Both, | ||
| Anchor = Anchor.Centre, | ||
| Origin = Anchor.Centre, | ||
| Direction = FillDirection.Vertical, | ||
| Spacing = new Vector2(10), | ||
| ChildrenEnumerable = Enumerable.Range(1, 100).Where(i => i == 1 || i == 100 || i % 20 == 0).Select(i => new DivisionBadge( | ||
| new RankedPlayDivision { Key = "Lustrous", Tier = Tier.Lustrous, DisplayName = "Lustrous", StartRating = 2400, EndRating = 3000 }, | ||
| ruleset, | ||
| i | ||
| )), | ||
| }, | ||
| }, | ||
| }, | ||
| }; | ||
| }); | ||
| } | ||
| } | ||
| } |
53 changes: 53 additions & 0 deletions
53
osu.Game/Online/API/Requests/Responses/RankedPlayDivision.cs
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,53 @@ | ||
| // 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 System.Diagnostics.CodeAnalysis; | ||
| using Newtonsoft.Json; | ||
| using Newtonsoft.Json.Converters; | ||
|
|
||
| namespace osu.Game.Online.API.Requests.Responses | ||
| { | ||
| public class RankedPlayDivision | ||
| { | ||
| [JsonProperty(@"key")] | ||
| public string Key = string.Empty; | ||
|
|
||
| [JsonProperty(@"tier")] | ||
| public Tier Tier; | ||
|
|
||
| [JsonProperty(@"division")] | ||
| public Division Division; | ||
|
|
||
| [JsonProperty(@"display_name")] | ||
| public string DisplayName = string.Empty; | ||
|
|
||
| [JsonProperty(@"start_rating")] | ||
| public int StartRating; | ||
|
|
||
| [JsonProperty("@end_rating")] | ||
| public int EndRating; | ||
|
|
||
| public int Width => EndRating - StartRating + 1; | ||
| } | ||
|
|
||
| [JsonConverter(typeof(StringEnumConverter))] | ||
| public enum Tier | ||
| { | ||
| Bronze, | ||
| Silver, | ||
| Gold, | ||
| Platinum, | ||
| Rhodium, | ||
| Radiant, | ||
| Lustrous, | ||
| } | ||
|
|
||
| [SuppressMessage("ReSharper", "InconsistentNaming")] | ||
| [JsonConverter(typeof(StringEnumConverter))] | ||
| public enum Division | ||
| { | ||
| I = 1, | ||
| II = 2, | ||
| III = 3, | ||
| } | ||
| } | ||
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,87 @@ | ||
| // 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 System; | ||
| using System.Linq; | ||
| using osu.Framework.Allocation; | ||
| using osu.Framework.Extensions.Color4Extensions; | ||
| using osu.Framework.Extensions.LocalisationExtensions; | ||
| using osu.Framework.Graphics; | ||
| using osu.Framework.Graphics.Containers; | ||
| using osu.Framework.Graphics.Cursor; | ||
| using osu.Framework.Graphics.Shapes; | ||
| using osu.Framework.Graphics.Sprites; | ||
| using osu.Framework.Graphics.Textures; | ||
| using osu.Framework.Localisation; | ||
| using osu.Game.Graphics; | ||
| using osu.Game.Graphics.Sprites; | ||
| using osu.Game.Online.API.Requests.Responses; | ||
| using osuTK; | ||
| using osuTK.Graphics; | ||
|
|
||
| namespace osu.Game.Online.RankedPlay | ||
| { | ||
| public partial class CompactDivisionBadge : CompositeDrawable, IHasTooltip | ||
| { | ||
| private readonly RankedPlayDivision division; | ||
| private readonly int? rank; | ||
|
|
||
| public CompactDivisionBadge(RankedPlayDivision division, int? rank = null) | ||
| { | ||
| if (division.Tier == Tier.Lustrous && rank == null) | ||
| throw new ArgumentException("Must specify a rank for Lustrous tier."); | ||
|
|
||
| this.division = division; | ||
| this.rank = rank; | ||
| } | ||
|
|
||
| [BackgroundDependencyLoader] | ||
| private void load(TextureStore textures) | ||
| { | ||
| Size = new Vector2(36, 19.5f); | ||
|
|
||
| InternalChild = new Sprite | ||
| { | ||
| RelativeSizeAxes = Axes.Both, | ||
| Texture = textures.Get(@$"Online/RankedPlay/Tiers/Compact/{division.Tier}"), | ||
| }; | ||
|
|
||
| if (division.Tier != Tier.Lustrous) | ||
| { | ||
| AddInternal(new FillFlowContainer | ||
| { | ||
| AutoSizeAxes = Axes.Both, | ||
| Anchor = Anchor.Centre, | ||
| Origin = Anchor.Centre, | ||
| Direction = FillDirection.Horizontal, | ||
| Spacing = new Vector2(4), | ||
| ChildrenEnumerable = Enumerable.Range(1, (int)division.Division) | ||
| .Select(_ => new Container | ||
| { | ||
| Size = new Vector2(3, 10), | ||
| Masking = true, | ||
| CornerRadius = 1.5f, | ||
| Child = new Box | ||
| { | ||
| RelativeSizeAxes = Axes.Both, | ||
| Colour = Color4.Black.Opacity(0.75f), | ||
| }, | ||
| }), | ||
| }); | ||
| } | ||
| else if (rank != null) | ||
| { | ||
| AddInternal(new OsuSpriteText | ||
| { | ||
| Anchor = Anchor.Centre, | ||
| Origin = Anchor.Centre, | ||
| Font = OsuFont.Torus.With(size: 18, weight: FontWeight.Bold), | ||
| Colour = Colour4.Black.Opacity(0.75f), | ||
| Text = rank.ToLocalisableString(@"N0"), | ||
| }); | ||
| } | ||
| } | ||
|
|
||
| public LocalisableString TooltipText => division.DisplayName; | ||
| } | ||
| } |
95 changes: 95 additions & 0 deletions
95
osu.Game/Screens/OnlinePlay/Matchmaking/RankedPlay/Components/DivisionBadge.cs
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,95 @@ | ||
| // 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 System; | ||
| using osu.Framework.Allocation; | ||
| using osu.Framework.Graphics; | ||
| using osu.Framework.Graphics.Containers; | ||
| using osu.Framework.Graphics.Cursor; | ||
| using osu.Framework.Graphics.Sprites; | ||
| using osu.Framework.Graphics.Textures; | ||
| using osu.Framework.Localisation; | ||
| using osu.Game.Online.API.Requests.Responses; | ||
| using osu.Game.Online.RankedPlay; | ||
| using osu.Game.Rulesets; | ||
| using osuTK; | ||
|
|
||
| namespace osu.Game.Screens.OnlinePlay.Matchmaking.RankedPlay.Components | ||
| { | ||
| public partial class DivisionBadge : CompositeDrawable, IHasTooltip | ||
| { | ||
| private readonly RankedPlayDivision division; | ||
| private readonly RulesetInfo ruleset; | ||
| private readonly int? rank; | ||
|
|
||
| public DivisionBadge(RankedPlayDivision division, RulesetInfo ruleset, int? rank = null) | ||
| { | ||
| if (division.Tier == Tier.Lustrous && rank == null) | ||
| throw new ArgumentException("Must specify a rank for Lustrous tier."); | ||
|
|
||
| this.division = division; | ||
| this.ruleset = ruleset; | ||
| this.rank = rank; | ||
| } | ||
|
|
||
| [BackgroundDependencyLoader] | ||
| private void load(TextureStore textures) | ||
| { | ||
| Size = division.Tier switch | ||
| { | ||
| Tier.Bronze => new Vector2(120, 96), | ||
| Tier.Silver => new Vector2(120, 99.75f), | ||
| Tier.Gold => new Vector2(120, 100.5f), | ||
| Tier.Platinum => new Vector2(120, 107.25f), | ||
| Tier.Rhodium => new Vector2(120, 108), | ||
| Tier.Radiant => new Vector2(120, 112.5f), | ||
| Tier.Lustrous => new Vector2(120, 122.5f), | ||
| _ => throw new ArgumentOutOfRangeException() | ||
| }; | ||
|
|
||
| InternalChildren = new Drawable[] | ||
| { | ||
| new Sprite | ||
| { | ||
| RelativeSizeAxes = Axes.Both, | ||
| Texture = textures.Get($@"Online/RankedPlay/Tiers/Base/{division.Tier}"), | ||
| FillMode = FillMode.Fit, | ||
| }, | ||
| new Sprite | ||
| { | ||
| Size = division.Tier switch | ||
| { | ||
| Tier.Bronze => new Vector2(33), | ||
| Tier.Silver => new Vector2(34.5f), | ||
| _ => new Vector2(36), | ||
| }, | ||
| Position = division.Tier switch | ||
| { | ||
| Tier.Bronze => new Vector2(43.5f, 24.75f), | ||
| Tier.Silver => new Vector2(42.75f, 27), | ||
| Tier.Gold => new Vector2(42, 23.25f), | ||
| Tier.Platinum => new Vector2(42, 28.5f), | ||
| Tier.Rhodium => new Vector2(42, 30), | ||
| Tier.Radiant => new Vector2(42, 33), | ||
| Tier.Lustrous => new Vector2(42, 43.5f), | ||
| _ => throw new ArgumentOutOfRangeException() | ||
| }, | ||
| Texture = textures.Get($@"Online/RankedPlay/Tiers/Rulesets/{ruleset.ShortName}"), | ||
| }, | ||
| new Sprite | ||
| { | ||
| RelativeSizeAxes = Axes.Both, | ||
| Texture = textures.Get($@"Online/RankedPlay/Tiers/Stars/{division.Key}"), | ||
| FillMode = FillMode.Fit, | ||
| }, | ||
|
Contributor
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. the shine layer will go above the stars but below the ruleset icon, so probably a good idea to swap the draw order these two |
||
| new CompactDivisionBadge(division, rank) | ||
| { | ||
| Anchor = Anchor.BottomCentre, | ||
| Origin = Anchor.BottomCentre, | ||
| }, | ||
| }; | ||
| } | ||
|
|
||
| public LocalisableString TooltipText => division.DisplayName; | ||
| } | ||
| } | ||
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.
Would not put these in the same file as
RankedPlayDivision. MaybeRankedPlayTier/RankedPlayDivisionso that they're distinct fromRankingTier(if we even want this to be separate in the first place).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.
I completely missed
RankingTierexisting, will use that for now. Also will split out the division enum to a separate file and rename the model toAPIRankedPlayDivisionor something like that (is there a reason some response models have theAPIprefix and some don't?).