diff --git a/osu.Game/Localisation/SongSelectStrings.cs b/osu.Game/Localisation/SongSelectStrings.cs index e715ba8880..ecf68e33a8 100644 --- a/osu.Game/Localisation/SongSelectStrings.cs +++ b/osu.Game/Localisation/SongSelectStrings.cs @@ -54,6 +54,21 @@ namespace osu.Game.Localisation /// public static LocalisableString EditBeatmap => new TranslatableString(getKey(@"edit_beatmap"), @"Edit beatmap"); + /// + /// "Below 1 Star" + /// + public static LocalisableString BelowStar => new TranslatableString(getKey(@"below_star"), @"Below 1 Star"); + + /// + /// "1 Star" + /// + public static LocalisableString Star => new TranslatableString(getKey(@"star"), @"1 Star"); + + /// + /// "{0} Stars" + /// + public static LocalisableString Stars(int starNumber) => new TranslatableString(getKey(@"stars"), @"{0} Stars", starNumber); + private static string getKey(string key) => $@"{prefix}:{key}"; } } diff --git a/osu.Game/Screens/SelectV2/PanelGroupStarDifficulty.cs b/osu.Game/Screens/SelectV2/PanelGroupStarDifficulty.cs index a238539102..2fba25b3f0 100644 --- a/osu.Game/Screens/SelectV2/PanelGroupStarDifficulty.cs +++ b/osu.Game/Screens/SelectV2/PanelGroupStarDifficulty.cs @@ -5,17 +5,17 @@ using System.Diagnostics; 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.Framework.Graphics.Sprites; -using osu.Game.Beatmaps; -using osu.Game.Beatmaps.Drawables; using osu.Game.Graphics; +using osu.Game.Graphics.Backgrounds; using osu.Game.Graphics.Sprites; -using osu.Game.Graphics.UserInterface; using osu.Game.Overlays; using osuTK; using osuTK.Graphics; +using osu.Game.Localisation; namespace osu.Game.Screens.SelectV2 { @@ -27,28 +27,50 @@ namespace osu.Game.Screens.SelectV2 [Resolved] private OverlayColourProvider colourProvider { get; set; } = null!; - private Drawable chevronIcon = null!; + private Drawable iconContainer = null!; private Box contentBackground = null!; - private StarRatingDisplay starRatingDisplay = null!; - private StarCounter starCounter = null!; + private OsuSpriteText starRatingText = null!; + private TrianglesV2 triangles = null!; + private Box glow = null!; [BackgroundDependencyLoader] private void load() { Height = PanelGroup.HEIGHT; - Icon = chevronIcon = new SpriteIcon + Icon = iconContainer = new Container { AlwaysPresent = true, - Icon = FontAwesome.Solid.ChevronDown, - Size = new Vector2(12), - Margin = new MarginPadding { Horizontal = 5f }, - X = 2f, + RelativeSizeAxes = Axes.Y, + Child = new SpriteIcon + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Icon = FontAwesome.Solid.ChevronDown, + Size = new Vector2(12), + }, }; - Background = contentBackground = new Box + Background = new Container { RelativeSizeAxes = Axes.Both, - Colour = colourProvider.Dark1, + Children = new Drawable[] + { + contentBackground = new Box + { + RelativeSizeAxes = Axes.Both, + }, + triangles = new TrianglesV2 + { + RelativeSizeAxes = Axes.Both, + Thickness = 0.02f, + SpawnRatio = 0.6f, + }, + glow = new Box + { + RelativeSizeAxes = Axes.Both, + Width = 0.5f, + }, + }, }; AccentColour = colourProvider.Highlight1; Content.Children = new Drawable[] @@ -62,17 +84,13 @@ namespace osu.Game.Screens.SelectV2 Margin = new MarginPadding { Left = 10f }, Children = new Drawable[] { - starRatingDisplay = new StarRatingDisplay(default, StarRatingDisplaySize.Small) + starRatingText = new OsuSpriteText { Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft, - }, - starCounter = new StarCounter - { - Anchor = Anchor.CentreLeft, - Origin = Anchor.CentreLeft, - Scale = new Vector2(8f / 20f), - }, + UseFullGlyphHeight = false, + Font = OsuFont.Style.Heading2, + } } }, new CircularContainer @@ -110,6 +128,8 @@ namespace osu.Game.Screens.SelectV2 Expanded.BindValueChanged(_ => onExpanded(), true); } + private Color4 ratingColour; + protected override void PrepareForUse() { base.PrepareForUse(); @@ -118,25 +138,52 @@ namespace osu.Game.Screens.SelectV2 int starNumber = (int)((GroupDefinition)Item.Model).Data; - Color4 colour = starNumber >= 9 ? OsuColour.Gray(0.2f) : colours.ForStarDifficulty(starNumber); - Color4 contentColour = starNumber >= 7 ? colours.Orange1 : colourProvider.Background5; + ratingColour = starNumber >= 9 ? OsuColour.Gray(0.2f) : colours.ForStarDifficulty(starNumber); - AccentColour = colour; - contentBackground.Colour = colour.Darken(0.3f); + AccentColour = ratingColour; + contentBackground.Colour = ratingColour.Darken(1f); + glow.Colour = ColourInfo.GradientHorizontal(ratingColour, ratingColour.Opacity(0f)); - starRatingDisplay.Current.Value = new StarDifficulty(starNumber, 0); - starCounter.Current = starNumber; + switch (starNumber) + { + case 0: + starRatingText.Text = SongSelectStrings.BelowStar; + break; - chevronIcon.Colour = contentColour; - starCounter.Colour = contentColour; + case 1: + starRatingText.Text = SongSelectStrings.Star; + break; + + default: + starRatingText.Text = SongSelectStrings.Stars(starNumber); + break; + } + + iconContainer.Colour = starNumber >= 7 ? colourProvider.Content1 : colourProvider.Background5; + starRatingText.Colour = colourProvider.Content1; + + ColourInfo colour; + + if (starNumber >= 8) + colour = ColourInfo.GradientHorizontal(ratingColour, ratingColour.Darken(0.2f)); + else + colour = ColourInfo.GradientHorizontal(ratingColour.Darken(0.6f), ratingColour.Darken(0.8f)); + + triangles.Colour = colour; + + onExpanded(); } private void onExpanded() { const float duration = 500; - chevronIcon.ResizeWidthTo(Expanded.Value ? 12f : 0f, duration, Easing.OutQuint); - chevronIcon.FadeTo(Expanded.Value ? 1f : 0f, duration, Easing.OutQuint); + Debug.Assert(Item != null); + + iconContainer.ResizeWidthTo(Expanded.Value ? 20f : 5f, duration, Easing.OutQuint); + iconContainer.FadeTo(Expanded.Value ? 1f : 0f, duration, Easing.OutQuint); + + glow.FadeTo(Expanded.Value ? 0.4f : 0, duration, Easing.OutQuint); } } }