diff --git a/osu.Game/Online/Leaderboards/DrawableRank.cs b/osu.Game/Online/Leaderboards/DrawableRank.cs index b7beb4ffb0..60653382e3 100644 --- a/osu.Game/Online/Leaderboards/DrawableRank.cs +++ b/osu.Game/Online/Leaderboards/DrawableRank.cs @@ -12,48 +12,46 @@ using System; namespace osu.Game.Online.Leaderboards { - public class DrawableRank : ModelBackedDrawable + public class UpdateableRank : ModelBackedDrawable { - private TextureStore textures; - public ScoreRank Rank { get => Model; set => Model = value; } + public UpdateableRank(ScoreRank rank) => Rank = rank; + + protected override Drawable CreateDrawable(ScoreRank rank) => new DrawableRank(rank) + { + RelativeSizeAxes = Axes.Both, + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + FillMode = FillMode.Fit, + }; + } + + public class DrawableRank : Sprite + { private ScoreRank rank; - public DrawableRank(ScoreRank rank) - { - this.rank = rank; - } + public DrawableRank(ScoreRank rank) => this.rank = rank; - [BackgroundDependencyLoader] + [BackgroundDependencyLoader(true)] private void load(TextureStore ts) { - textures = ts ?? throw new ArgumentNullException(nameof(ts)); - Rank = rank; - } + if (ts == null) + throw new ArgumentNullException(nameof(ts)); - protected override Drawable CreateDrawable(ScoreRank rank) - { - return new Sprite - { - RelativeSizeAxes = Axes.Both, - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - FillMode = FillMode.Fit, - Texture = textures.Get($"Grades/{getTextureName()}"), - }; + Texture = ts.Get($@"Grades/{getTextureName()}"); } private string getTextureName() { - switch (Rank) + switch (rank) { default: - return Rank.GetDescription(); + return rank.GetDescription(); case ScoreRank.SH: return "SPlus"; diff --git a/osu.Game/Online/Leaderboards/LeaderboardScore.cs b/osu.Game/Online/Leaderboards/LeaderboardScore.cs index c6db939f6b..323c17b101 100644 --- a/osu.Game/Online/Leaderboards/LeaderboardScore.cs +++ b/osu.Game/Online/Leaderboards/LeaderboardScore.cs @@ -193,7 +193,7 @@ namespace osu.Game.Online.Leaderboards Size = new Vector2(40f, 20f), Children = new[] { - scoreRank = new DrawableRank(score.Rank) + scoreRank = new UpdateableRank(score.Rank) { Anchor = Anchor.Centre, Origin = Anchor.Centre, diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs index 693ce958dd..5db409a2c6 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs @@ -103,7 +103,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores Text = $"#{index + 1}", Font = OsuFont.GetFont(size: text_size, weight: FontWeight.Bold) }, - new DrawableRank(score.Rank) + new UpdateableRank(score.Rank) { Size = new Vector2(30, 20) }, diff --git a/osu.Game/Overlays/BeatmapSet/Scores/TopScoreUserSection.cs b/osu.Game/Overlays/BeatmapSet/Scores/TopScoreUserSection.cs index cbcf3e6160..651b8ce9a7 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/TopScoreUserSection.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/TopScoreUserSection.cs @@ -22,7 +22,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores public class TopScoreUserSection : CompositeDrawable { private readonly SpriteText rankText; - private readonly DrawableRank rank; + private readonly UpdateableRank rank; private readonly UpdateableAvatar avatar; private readonly LinkFlowContainer usernameText; private readonly SpriteText date; @@ -46,7 +46,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores Text = "#1", Font = OsuFont.GetFont(size: 30, weight: FontWeight.Bold, italics: true) }, - rank = new DrawableRank(ScoreRank.D) + rank = new UpdateableRank(ScoreRank.D) { Anchor = Anchor.Centre, Origin = Anchor.Centre, @@ -121,7 +121,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores usernameText.Clear(); usernameText.AddUserLink(value.User); - rank.UpdateRank(value.Rank); + rank.Rank = value.Rank; } } } diff --git a/osu.Game/Overlays/Profile/Header/DetailHeaderContainer.cs b/osu.Game/Overlays/Profile/Header/DetailHeaderContainer.cs index f26cc360a2..afafc120e4 100644 --- a/osu.Game/Overlays/Profile/Header/DetailHeaderContainer.cs +++ b/osu.Game/Overlays/Profile/Header/DetailHeaderContainer.cs @@ -200,7 +200,7 @@ namespace osu.Game.Overlays.Profile.Header Direction = FillDirection.Vertical, Children = new Drawable[] { - new DrawableRank(rank) + new UpdateableRank(rank) { RelativeSizeAxes = Axes.X, Height = 30, diff --git a/osu.Game/Overlays/Profile/Sections/Ranks/DrawableProfileScore.cs b/osu.Game/Overlays/Profile/Sections/Ranks/DrawableProfileScore.cs index f4e08b8db1..0a90c9b135 100644 --- a/osu.Game/Overlays/Profile/Sections/Ranks/DrawableProfileScore.cs +++ b/osu.Game/Overlays/Profile/Sections/Ranks/DrawableProfileScore.cs @@ -59,7 +59,7 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks modsContainer.Add(new ModIcon(mod) { Scale = new Vector2(0.5f) }); } - protected override Drawable CreateLeftVisual() => new DrawableRank(Score.Rank) + protected override Drawable CreateLeftVisual() => new UpdateableRank(Score.Rank) { RelativeSizeAxes = Axes.Y, Width = 60, diff --git a/osu.Game/Overlays/Profile/Sections/Recent/DrawableRecentActivity.cs b/osu.Game/Overlays/Profile/Sections/Recent/DrawableRecentActivity.cs index 8fab29e42c..b5a508bff7 100644 --- a/osu.Game/Overlays/Profile/Sections/Recent/DrawableRecentActivity.cs +++ b/osu.Game/Overlays/Profile/Sections/Recent/DrawableRecentActivity.cs @@ -58,7 +58,7 @@ namespace osu.Game.Overlays.Profile.Sections.Recent switch (activity.Type) { case RecentActivityType.Rank: - return new DrawableRank(activity.ScoreRank) + return new UpdateableRank(activity.ScoreRank) { RelativeSizeAxes = Axes.Y, Width = 60, diff --git a/osu.Game/Screens/Ranking/Pages/ScoreResultsPage.cs b/osu.Game/Screens/Ranking/Pages/ScoreResultsPage.cs index fab227c7f4..a82156e34e 100644 --- a/osu.Game/Screens/Ranking/Pages/ScoreResultsPage.cs +++ b/osu.Game/Screens/Ranking/Pages/ScoreResultsPage.cs @@ -74,7 +74,7 @@ namespace osu.Game.Screens.Ranking.Pages RelativeSizeAxes = Axes.X, Height = user_header_height, }, - new DrawableRank(Score.Rank) + new UpdateableRank(Score.Rank) { Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre,