From 8c5397709b242150f3fc7a2d020420bc86e81902 Mon Sep 17 00:00:00 2001 From: iiSaLMaN Date: Sun, 30 Jun 2019 04:20:42 +0300 Subject: [PATCH 1/6] Use drawables instead of textures --- osu.Game/Online/Leaderboards/DrawableRank.cs | 113 ++++++++++++++++--- 1 file changed, 99 insertions(+), 14 deletions(-) diff --git a/osu.Game/Online/Leaderboards/DrawableRank.cs b/osu.Game/Online/Leaderboards/DrawableRank.cs index 9bbaa28e2a..a944356681 100644 --- a/osu.Game/Online/Leaderboards/DrawableRank.cs +++ b/osu.Game/Online/Leaderboards/DrawableRank.cs @@ -3,43 +3,128 @@ using osu.Framework.Allocation; using osu.Framework.Extensions; -using osu.Framework.Graphics.Sprites; -using osu.Framework.Graphics.Textures; +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 osu.Game.Graphics.Backgrounds; +using osu.Game.Graphics.Sprites; using osu.Game.Scoring; -using System; +using osuTK; +using osuTK.Graphics; namespace osu.Game.Online.Leaderboards { - public class DrawableRank : Sprite + public class DrawableRank : CompositeDrawable { private readonly ScoreRank rank; + private readonly Box background; + private readonly Triangles triangles; + private readonly OsuSpriteText name; + public DrawableRank(ScoreRank rank) { this.rank = rank; + + RelativeSizeAxes = Axes.Both; + FillMode = FillMode.Fit; + FillAspectRatio = 2; + + InternalChild = new DrawSizePreservingFillContainer + { + TargetDrawSize = new Vector2(64, 32), + Strategy = DrawSizePreservationStrategy.Minimum, + Child = new CircularContainer + { + Masking = true, + RelativeSizeAxes = Axes.Both, + Children = new Drawable[] + { + background = new Box + { + RelativeSizeAxes = Axes.Both, + }, + triangles = new Triangles + { + RelativeSizeAxes = Axes.Both, + TriangleScale = 1.25f, + Velocity = 0.5f, + }, + name = new OsuSpriteText + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Padding = new MarginPadding { Top = 5 }, + Font = OsuFont.GetFont(Typeface.Venera, 25), + Text = getRankName(), + }, + } + } + }; } - [BackgroundDependencyLoader(true)] - private void load(TextureStore ts) + [BackgroundDependencyLoader] + private void load(OsuColour colours) { - if (ts == null) - throw new ArgumentNullException(nameof(ts)); + var rankColour = getRankColour(colours); + background.Colour = rankColour; + triangles.ColourDark = rankColour.Darken(0.3f); + triangles.ColourLight = rankColour.Lighten(0.1f); - Texture = ts.Get($@"Grades/{getTextureName()}"); + name.Colour = getRankNameColour(colours); } - private string getTextureName() + private string getRankName() => rank.GetDescription().TrimEnd('+'); + + /// + /// Retrieves the grade background colour. + /// + private Color4 getRankColour(OsuColour colours) { switch (rank) { - default: - return rank.GetDescription(); + case ScoreRank.XH: + case ScoreRank.X: + return colours.PinkDarker; case ScoreRank.SH: - return "SPlus"; + case ScoreRank.S: + return Color4.DarkCyan; + case ScoreRank.A: + return colours.Green; + + case ScoreRank.B: + return Color4.Orange; + + case ScoreRank.C: + return Color4.OrangeRed; + + default: + return colours.Red; + } + } + + /// + /// Retrieves the grade text colour. + /// + private ColourInfo getRankNameColour(OsuColour colours) + { + switch (rank) + { case ScoreRank.XH: - return "SSPlus"; + case ScoreRank.SH: + return ColourInfo.GradientVertical(Color4.White, Color4.LightGray); + + case ScoreRank.X: + case ScoreRank.S: + return ColourInfo.GradientVertical(Color4.Yellow, Color4.Orange); + + default: + return getRankColour(colours).Darken(2); } } } From 372d90de6ad53cb2e7319531f72d4fcc5abe29ce Mon Sep 17 00:00:00 2001 From: iiSaLMaN Date: Sun, 30 Jun 2019 04:25:47 +0300 Subject: [PATCH 2/6] Remove unnecessary assigns --- osu.Game/Online/Leaderboards/UpdateableRank.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/osu.Game/Online/Leaderboards/UpdateableRank.cs b/osu.Game/Online/Leaderboards/UpdateableRank.cs index 64230a92db..d9e8957281 100644 --- a/osu.Game/Online/Leaderboards/UpdateableRank.cs +++ b/osu.Game/Online/Leaderboards/UpdateableRank.cs @@ -22,10 +22,8 @@ namespace osu.Game.Online.Leaderboards protected override Drawable CreateDrawable(ScoreRank rank) => new DrawableRank(rank) { - RelativeSizeAxes = Axes.Both, Anchor = Anchor.Centre, Origin = Anchor.Centre, - FillMode = FillMode.Fit, }; } } From 20ad486d538ee16c940d7b929365c6e31ed210e7 Mon Sep 17 00:00:00 2001 From: iiSaLMaN Date: Sun, 30 Jun 2019 04:59:33 +0300 Subject: [PATCH 3/6] Scale adjustments --- osu.Game/Online/Leaderboards/DrawableRank.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Online/Leaderboards/DrawableRank.cs b/osu.Game/Online/Leaderboards/DrawableRank.cs index a944356681..f9e5d689d0 100644 --- a/osu.Game/Online/Leaderboards/DrawableRank.cs +++ b/osu.Game/Online/Leaderboards/DrawableRank.cs @@ -50,7 +50,7 @@ namespace osu.Game.Online.Leaderboards triangles = new Triangles { RelativeSizeAxes = Axes.Both, - TriangleScale = 1.25f, + TriangleScale = 1, Velocity = 0.5f, }, name = new OsuSpriteText From 9498fc2426aaaf3599783303a40bfbad548e4799 Mon Sep 17 00:00:00 2001 From: iiSaLMaN Date: Sun, 30 Jun 2019 05:47:52 +0300 Subject: [PATCH 4/6] Use proper colours for rank background and text --- osu.Game/Online/Leaderboards/DrawableRank.cs | 60 ++++++++++---------- 1 file changed, 29 insertions(+), 31 deletions(-) diff --git a/osu.Game/Online/Leaderboards/DrawableRank.cs b/osu.Game/Online/Leaderboards/DrawableRank.cs index f9e5d689d0..68dca97ff9 100644 --- a/osu.Game/Online/Leaderboards/DrawableRank.cs +++ b/osu.Game/Online/Leaderboards/DrawableRank.cs @@ -1,7 +1,6 @@ // Copyright (c) ppy Pty Ltd . 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; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; @@ -21,10 +20,6 @@ namespace osu.Game.Online.Leaderboards { private readonly ScoreRank rank; - private readonly Box background; - private readonly Triangles triangles; - private readonly OsuSpriteText name; - public DrawableRank(ScoreRank rank) { this.rank = rank; @@ -33,6 +28,7 @@ namespace osu.Game.Online.Leaderboards FillMode = FillMode.Fit; FillAspectRatio = 2; + var rankColour = getRankColour(); InternalChild = new DrawSizePreservingFillContainer { TargetDrawSize = new Vector2(64, 32), @@ -43,21 +39,25 @@ namespace osu.Game.Online.Leaderboards RelativeSizeAxes = Axes.Both, Children = new Drawable[] { - background = new Box + new Box { RelativeSizeAxes = Axes.Both, + Colour = rankColour, }, - triangles = new Triangles + new Triangles { RelativeSizeAxes = Axes.Both, + ColourDark = rankColour.Darken(0.1f), + ColourLight = rankColour.Lighten(0.1f), TriangleScale = 1, - Velocity = 0.5f, + Velocity = 0.25f, }, - name = new OsuSpriteText + new OsuSpriteText { Anchor = Anchor.Centre, Origin = Anchor.Centre, Padding = new MarginPadding { Top = 5 }, + Colour = getRankNameColour(), Font = OsuFont.GetFont(Typeface.Venera, 25), Text = getRankName(), }, @@ -66,65 +66,63 @@ namespace osu.Game.Online.Leaderboards }; } - [BackgroundDependencyLoader] - private void load(OsuColour colours) - { - var rankColour = getRankColour(colours); - background.Colour = rankColour; - triangles.ColourDark = rankColour.Darken(0.3f); - triangles.ColourLight = rankColour.Lighten(0.1f); - - name.Colour = getRankNameColour(colours); - } - private string getRankName() => rank.GetDescription().TrimEnd('+'); /// /// Retrieves the grade background colour. /// - private Color4 getRankColour(OsuColour colours) + private Color4 getRankColour() { switch (rank) { case ScoreRank.XH: case ScoreRank.X: - return colours.PinkDarker; + return OsuColour.FromHex(@"ce1c9d"); case ScoreRank.SH: case ScoreRank.S: - return Color4.DarkCyan; + return OsuColour.FromHex(@"00a8b5"); case ScoreRank.A: - return colours.Green; + return OsuColour.FromHex(@"7cce14"); case ScoreRank.B: - return Color4.Orange; + return OsuColour.FromHex(@"e3b130"); case ScoreRank.C: - return Color4.OrangeRed; + return OsuColour.FromHex(@"f18252"); default: - return colours.Red; + return OsuColour.FromHex(@"e95353"); } } /// /// Retrieves the grade text colour. /// - private ColourInfo getRankNameColour(OsuColour colours) + private ColourInfo getRankNameColour() { switch (rank) { case ScoreRank.XH: case ScoreRank.SH: - return ColourInfo.GradientVertical(Color4.White, Color4.LightGray); + return ColourInfo.GradientVertical(Color4.White, OsuColour.FromHex("afdff0")); case ScoreRank.X: case ScoreRank.S: - return ColourInfo.GradientVertical(Color4.Yellow, Color4.Orange); + return ColourInfo.GradientVertical(OsuColour.FromHex(@"ffe7a8"), OsuColour.FromHex(@"ffb800")); + + case ScoreRank.A: + return OsuColour.FromHex(@"275227"); + + case ScoreRank.B: + return OsuColour.FromHex(@"553a2b"); + + case ScoreRank.C: + return OsuColour.FromHex(@"473625"); default: - return getRankColour(colours).Darken(2); + return OsuColour.FromHex(@"512525"); } } } From c5b3572c285073186c2483c6e7bf69b7d27b3dd0 Mon Sep 17 00:00:00 2001 From: iiSaLMaN Date: Sun, 30 Jun 2019 08:05:45 +0300 Subject: [PATCH 5/6] Add missing details --- osu.Game/Online/Leaderboards/DrawableRank.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/osu.Game/Online/Leaderboards/DrawableRank.cs b/osu.Game/Online/Leaderboards/DrawableRank.cs index 68dca97ff9..4d81ead494 100644 --- a/osu.Game/Online/Leaderboards/DrawableRank.cs +++ b/osu.Game/Online/Leaderboards/DrawableRank.cs @@ -56,10 +56,14 @@ namespace osu.Game.Online.Leaderboards { Anchor = Anchor.Centre, Origin = Anchor.Centre, + Spacing = new Vector2(-3, 0), Padding = new MarginPadding { Top = 5 }, Colour = getRankNameColour(), Font = OsuFont.GetFont(Typeface.Venera, 25), Text = getRankName(), + ShadowColour = Color4.Black.Opacity(0.3f), + ShadowOffset = new Vector2(0, 0.08f), + Shadow = true, }, } } From 1189092e2033daa69f9fc224604de88fdbce546a Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 3 Jul 2019 12:49:16 +0900 Subject: [PATCH 6/6] Remove redundant scale specification --- osu.Game/Online/Leaderboards/DrawableRank.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game/Online/Leaderboards/DrawableRank.cs b/osu.Game/Online/Leaderboards/DrawableRank.cs index 4d81ead494..50cb58c6ab 100644 --- a/osu.Game/Online/Leaderboards/DrawableRank.cs +++ b/osu.Game/Online/Leaderboards/DrawableRank.cs @@ -49,7 +49,6 @@ namespace osu.Game.Online.Leaderboards RelativeSizeAxes = Axes.Both, ColourDark = rankColour.Darken(0.1f), ColourLight = rankColour.Lighten(0.1f), - TriangleScale = 1, Velocity = 0.25f, }, new OsuSpriteText