From 4f0f07d55a45be5ff93e271d3adfde3b71945138 Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Mon, 12 Feb 2024 21:30:10 +0300 Subject: [PATCH] Remove placeholder classes and inline everything --- .../Graphics/Sprites/SpriteIconWithTooltip.cs | 14 +++++++ .../Graphics/Sprites/SpriteTextWithTooltip.cs | 13 +++++++ .../Overlays/BeatmapSet/Scores/ScoreTable.cs | 20 ++++++++-- .../Scores/TopScoreStatisticsSection.cs | 19 +++++++-- .../Sections/Ranks/DrawableProfileScore.cs | 39 +++++++++++++++---- ...UnprocessedPerformancePointsPlaceholder.cs | 27 ------------- .../UnrankedPerformancePointsPlaceholder.cs | 26 ------------- 7 files changed, 91 insertions(+), 67 deletions(-) create mode 100644 osu.Game/Graphics/Sprites/SpriteIconWithTooltip.cs create mode 100644 osu.Game/Graphics/Sprites/SpriteTextWithTooltip.cs delete mode 100644 osu.Game/Scoring/Drawables/UnprocessedPerformancePointsPlaceholder.cs delete mode 100644 osu.Game/Scoring/Drawables/UnrankedPerformancePointsPlaceholder.cs diff --git a/osu.Game/Graphics/Sprites/SpriteIconWithTooltip.cs b/osu.Game/Graphics/Sprites/SpriteIconWithTooltip.cs new file mode 100644 index 0000000000..572a17571b --- /dev/null +++ b/osu.Game/Graphics/Sprites/SpriteIconWithTooltip.cs @@ -0,0 +1,14 @@ +using osu.Framework.Graphics.Cursor; +using osu.Framework.Graphics.Sprites; +using osu.Framework.Localisation; + +namespace osu.Game.Graphics.Sprites +{ + /// + /// A with a publicly settable tooltip text. + /// + public partial class SpriteIconWithTooltip : SpriteIcon, IHasTooltip + { + public LocalisableString TooltipText { get; set; } + } +} diff --git a/osu.Game/Graphics/Sprites/SpriteTextWithTooltip.cs b/osu.Game/Graphics/Sprites/SpriteTextWithTooltip.cs new file mode 100644 index 0000000000..db98e8ba57 --- /dev/null +++ b/osu.Game/Graphics/Sprites/SpriteTextWithTooltip.cs @@ -0,0 +1,13 @@ +using osu.Framework.Graphics.Cursor; +using osu.Framework.Localisation; + +namespace osu.Game.Graphics.Sprites +{ + /// + /// An with a publicly settable tooltip text. + /// + internal partial class SpriteTextWithTooltip : OsuSpriteText, IHasTooltip + { + public LocalisableString TooltipText { get; set; } + } +} diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs index 9dd0e26da2..7a817c43eb 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs @@ -23,9 +23,9 @@ using osuTK.Graphics; using osu.Framework.Localisation; using osu.Framework.Extensions.LocalisationExtensions; using osu.Framework.Graphics.Cursor; +using osu.Framework.Graphics.Sprites; using osu.Game.Resources.Localisation.Web; using osu.Game.Rulesets.Mods; -using osu.Game.Scoring.Drawables; namespace osu.Game.Overlays.BeatmapSet.Scores { @@ -181,9 +181,23 @@ namespace osu.Game.Overlays.BeatmapSet.Scores if (showPerformancePoints) { if (!score.Ranked) - content.Add(new UnrankedPerformancePointsPlaceholder(ScoresStrings.StatusNoPp) { Font = OsuFont.GetFont(size: text_size) }); + { + content.Add(new SpriteTextWithTooltip + { + Text = "-", + Font = OsuFont.GetFont(size: text_size), + TooltipText = ScoresStrings.StatusNoPp + }); + } else if (score.PP == null) - content.Add(new UnprocessedPerformancePointsPlaceholder { Size = new Vector2(text_size) }); + { + content.Add(new SpriteIconWithTooltip + { + Icon = FontAwesome.Solid.Sync, + Size = new Vector2(text_size), + TooltipText = ScoresStrings.StatusProcessing, + }); + } else content.Add(new StatisticText(score.PP, format: @"N0")); } diff --git a/osu.Game/Overlays/BeatmapSet/Scores/TopScoreStatisticsSection.cs b/osu.Game/Overlays/BeatmapSet/Scores/TopScoreStatisticsSection.cs index 4aad3cf953..17704f63ee 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/TopScoreStatisticsSection.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/TopScoreStatisticsSection.cs @@ -22,7 +22,6 @@ using osu.Game.Resources.Localisation.Web; using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.UI; using osu.Game.Scoring; -using osu.Game.Scoring.Drawables; using osuTK; namespace osu.Game.Overlays.BeatmapSet.Scores @@ -126,9 +125,23 @@ namespace osu.Game.Overlays.BeatmapSet.Scores ppColumn.Alpha = value.BeatmapInfo!.Status.GrantsPerformancePoints() ? 1 : 0; if (!value.Ranked) - ppColumn.Drawable = new UnrankedPerformancePointsPlaceholder(ScoresStrings.StatusNoPp) { Font = smallFont }; + { + ppColumn.Drawable = new SpriteTextWithTooltip + { + Text = "-", + Font = smallFont, + TooltipText = ScoresStrings.StatusNoPp + }; + } else if (value.PP is not double pp) - ppColumn.Drawable = new UnprocessedPerformancePointsPlaceholder { Size = new Vector2(smallFont.Size) }; + { + ppColumn.Drawable = new SpriteIconWithTooltip + { + Icon = FontAwesome.Solid.Sync, + Size = new Vector2(smallFont.Size), + TooltipText = ScoresStrings.StatusProcessing, + }; + } else ppColumn.Text = pp.ToLocalisableString(@"N0"); diff --git a/osu.Game/Overlays/Profile/Sections/Ranks/DrawableProfileScore.cs b/osu.Game/Overlays/Profile/Sections/Ranks/DrawableProfileScore.cs index 1211d65816..63afca8b74 100644 --- a/osu.Game/Overlays/Profile/Sections/Ranks/DrawableProfileScore.cs +++ b/osu.Game/Overlays/Profile/Sections/Ranks/DrawableProfileScore.cs @@ -8,6 +8,7 @@ using osu.Framework.Extensions.ObjectExtensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; +using osu.Framework.Graphics.Sprites; using osu.Framework.Localisation; using osu.Game.Beatmaps; using osu.Game.Graphics; @@ -18,7 +19,6 @@ using osu.Game.Resources.Localisation.Web; using osu.Game.Rulesets; using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.UI; -using osu.Game.Scoring.Drawables; using osu.Game.Utils; using osuTK; @@ -214,6 +214,8 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks private Drawable createDrawablePerformance() { + var font = OsuFont.GetFont(weight: FontWeight.Bold); + if (Score.PP.HasValue) { return new FillFlowContainer @@ -226,7 +228,7 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks { Anchor = Anchor.BottomLeft, Origin = Anchor.BottomLeft, - Font = OsuFont.GetFont(weight: FontWeight.Bold), + Font = font, Text = $"{Score.PP:0}", Colour = colourProvider.Highlight1 }, @@ -234,7 +236,7 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks { Anchor = Anchor.BottomLeft, Origin = Anchor.BottomLeft, - Font = OsuFont.GetFont(size: 12, weight: FontWeight.Bold), + Font = font.With(size: 12), Text = "pp", Colour = colourProvider.Light3 } @@ -244,23 +246,44 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks if (Score.Beatmap?.Status.GrantsPerformancePoints() != true) { - return new UnrankedPerformancePointsPlaceholder(UsersStrings.ShowExtraTopRanksNotRanked) + if (Score.Beatmap?.Status == BeatmapOnlineStatus.Loved) { + return new SpriteIconWithTooltip + { + Icon = FontAwesome.Solid.Heart, + Size = new Vector2(font.Size), + TooltipText = UsersStrings.ShowExtraTopRanksNotRanked, + Colour = colourProvider.Highlight1 + }; + } + + return new SpriteTextWithTooltip + { + Text = "-", Font = OsuFont.GetFont(weight: FontWeight.Bold), - Colour = colourProvider.Highlight1, + TooltipText = UsersStrings.ShowExtraTopRanksNotRanked, + Colour = colourProvider.Highlight1 }; } if (!Score.Ranked) { - return new UnrankedPerformancePointsPlaceholder(ScoresStrings.StatusNoPp) + return new SpriteTextWithTooltip { + Text = "-", Font = OsuFont.GetFont(weight: FontWeight.Bold), - Colour = colourProvider.Highlight1, + TooltipText = ScoresStrings.StatusNoPp, + Colour = colourProvider.Highlight1 }; } - return new UnprocessedPerformancePointsPlaceholder { Size = new Vector2(16), Colour = colourProvider.Highlight1 }; + return new SpriteIconWithTooltip + { + Icon = FontAwesome.Solid.Sync, + Size = new Vector2(font.Size), + TooltipText = ScoresStrings.StatusProcessing, + Colour = colourProvider.Highlight1 + }; } private partial class ScoreBeatmapMetadataContainer : BeatmapMetadataContainer diff --git a/osu.Game/Scoring/Drawables/UnprocessedPerformancePointsPlaceholder.cs b/osu.Game/Scoring/Drawables/UnprocessedPerformancePointsPlaceholder.cs deleted file mode 100644 index a2cb69062e..0000000000 --- a/osu.Game/Scoring/Drawables/UnprocessedPerformancePointsPlaceholder.cs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. -// See the LICENCE file in the repository root for full licence text. - -#nullable disable -using osu.Framework.Graphics; -using osu.Framework.Graphics.Cursor; -using osu.Framework.Graphics.Sprites; -using osu.Framework.Localisation; -using osu.Game.Resources.Localisation.Web; - -namespace osu.Game.Scoring.Drawables -{ - /// - /// A placeholder used in PP columns for scores with unprocessed PP value. - /// - public partial class UnprocessedPerformancePointsPlaceholder : SpriteIcon, IHasTooltip - { - public LocalisableString TooltipText => ScoresStrings.StatusProcessing; - - public UnprocessedPerformancePointsPlaceholder() - { - Anchor = Anchor.Centre; - Origin = Anchor.Centre; - Icon = FontAwesome.Solid.Sync; - } - } -} diff --git a/osu.Game/Scoring/Drawables/UnrankedPerformancePointsPlaceholder.cs b/osu.Game/Scoring/Drawables/UnrankedPerformancePointsPlaceholder.cs deleted file mode 100644 index 0097497ef1..0000000000 --- a/osu.Game/Scoring/Drawables/UnrankedPerformancePointsPlaceholder.cs +++ /dev/null @@ -1,26 +0,0 @@ -// 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.Graphics; -using osu.Framework.Graphics.Cursor; -using osu.Framework.Graphics.Sprites; -using osu.Framework.Localisation; - -namespace osu.Game.Scoring.Drawables -{ - /// - /// A placeholder used in PP columns for scores that do not award PP due to a reason specified by . - /// - public partial class UnrankedPerformancePointsPlaceholder : SpriteText, IHasTooltip - { - public LocalisableString TooltipText { get; } - - public UnrankedPerformancePointsPlaceholder(LocalisableString tooltipText) - { - Anchor = Anchor.Centre; - Origin = Anchor.Centre; - Text = "-"; - TooltipText = tooltipText; - } - } -}