From cfb14fbca64a87d53cf9a54fdc34ea1d77fca76c Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 19 Mar 2025 16:32:17 +0900 Subject: [PATCH] Remove unnecessary customisation settings in `DifficultySpectrumDisplay` --- .../TestSceneDifficultySpectrumDisplay.cs | 29 +---------- .../Cards/BeatmapCardExtraInfoRow.cs | 4 +- .../Drawables/DifficultySpectrumDisplay.cs | 50 +++---------------- osu.Game/Screens/SelectV2/PanelBeatmapSet.cs | 2 - 4 files changed, 12 insertions(+), 73 deletions(-) diff --git a/osu.Game.Tests/Visual/Beatmaps/TestSceneDifficultySpectrumDisplay.cs b/osu.Game.Tests/Visual/Beatmaps/TestSceneDifficultySpectrumDisplay.cs index 11fa6ed92d..d4e5c1d966 100644 --- a/osu.Game.Tests/Visual/Beatmaps/TestSceneDifficultySpectrumDisplay.cs +++ b/osu.Game.Tests/Visual/Beatmaps/TestSceneDifficultySpectrumDisplay.cs @@ -15,8 +15,6 @@ namespace osu.Game.Tests.Visual.Beatmaps { public partial class TestSceneDifficultySpectrumDisplay : OsuTestScene { - private DifficultySpectrumDisplay display; - private static APIBeatmapSet createBeatmapSetWith(params (int rulesetId, double stars)[] difficulties) => new APIBeatmapSet { Beatmaps = difficulties.Select(difficulty => new APIBeatmap @@ -78,32 +76,9 @@ namespace osu.Game.Tests.Visual.Beatmaps createDisplay(beatmapSet); } - [Test] - public void TestAdjustableDotSize() - { - var beatmapSet = createBeatmapSetWith( - (rulesetId: 0, stars: 2.0), - (rulesetId: 3, stars: 2.3), - (rulesetId: 0, stars: 3.2), - (rulesetId: 1, stars: 4.3), - (rulesetId: 0, stars: 5.6)); - - createDisplay(beatmapSet); - - AddStep("change dot dimensions", () => - { - display.DotSize = new Vector2(8, 12); - display.DotSpacing = 2; - }); - AddStep("change dot dimensions back", () => - { - display.DotSize = new Vector2(4, 8); - display.DotSpacing = 1; - }); - } - - private void createDisplay(IBeatmapSetInfo beatmapSetInfo) => AddStep("create spectrum display", () => Child = display = new DifficultySpectrumDisplay(beatmapSetInfo) + private void createDisplay(IBeatmapSetInfo beatmapSetInfo) => AddStep("create spectrum display", () => Child = new DifficultySpectrumDisplay { + BeatmapSet = beatmapSetInfo, Anchor = Anchor.Centre, Origin = Anchor.Centre, Scale = new Vector2(3) diff --git a/osu.Game/Beatmaps/Drawables/Cards/BeatmapCardExtraInfoRow.cs b/osu.Game/Beatmaps/Drawables/Cards/BeatmapCardExtraInfoRow.cs index a11ef0f95c..41513ec7a2 100644 --- a/osu.Game/Beatmaps/Drawables/Cards/BeatmapCardExtraInfoRow.cs +++ b/osu.Game/Beatmaps/Drawables/Cards/BeatmapCardExtraInfoRow.cs @@ -36,11 +36,11 @@ namespace osu.Game.Beatmaps.Drawables.Cards Origin = Anchor.CentreLeft, TextSize = 13f }, - new DifficultySpectrumDisplay(beatmapSet) + new DifficultySpectrumDisplay { + BeatmapSet = beatmapSet, Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft, - DotSize = new Vector2(5, 10) } } }; diff --git a/osu.Game/Beatmaps/Drawables/DifficultySpectrumDisplay.cs b/osu.Game/Beatmaps/Drawables/DifficultySpectrumDisplay.cs index 56f6c77ba8..60685cd31d 100644 --- a/osu.Game/Beatmaps/Drawables/DifficultySpectrumDisplay.cs +++ b/osu.Game/Beatmaps/Drawables/DifficultySpectrumDisplay.cs @@ -18,34 +18,6 @@ namespace osu.Game.Beatmaps.Drawables { public partial class DifficultySpectrumDisplay : CompositeDrawable { - private Vector2 dotSize = new Vector2(4, 8); - - public Vector2 DotSize - { - get => dotSize; - set - { - dotSize = value; - - if (IsLoaded) - updateDisplay(); - } - } - - private float dotSpacing = 1; - - public float DotSpacing - { - get => dotSpacing; - set - { - dotSpacing = value; - - if (IsLoaded) - updateDisplay(); - } - } - private IBeatmapSetInfo? beatmapSet; public IBeatmapSetInfo? BeatmapSet @@ -60,9 +32,10 @@ namespace osu.Game.Beatmaps.Drawables } } - private readonly FillFlowContainer flow; + private FillFlowContainer flow = null!; - public DifficultySpectrumDisplay(IBeatmapSetInfo? beatmapSet = null) + [BackgroundDependencyLoader] + private void load() { AutoSizeAxes = Axes.Both; @@ -72,8 +45,6 @@ namespace osu.Game.Beatmaps.Drawables Spacing = new Vector2(10, 0), Direction = FillDirection.Horizontal, }; - - BeatmapSet = beatmapSet; } protected override void LoadComplete() @@ -94,10 +65,7 @@ namespace osu.Game.Beatmaps.Drawables foreach (var rulesetGrouping in beatmapSet.Beatmaps.GroupBy(beatmap => beatmap.Ruleset).OrderBy(group => group.Key)) { - flow.Add(new RulesetDifficultyGroup(rulesetGrouping.Key.OnlineID, rulesetGrouping, collapsed, dotSize) - { - Spacing = new Vector2(DotSpacing, 0f), - }); + flow.Add(new RulesetDifficultyGroup(rulesetGrouping.Key.OnlineID, rulesetGrouping, collapsed)); } } @@ -106,14 +74,12 @@ namespace osu.Game.Beatmaps.Drawables private readonly int rulesetId; private readonly IEnumerable beatmapInfos; private readonly bool collapsed; - private readonly Vector2 dotSize; - public RulesetDifficultyGroup(int rulesetId, IEnumerable beatmapInfos, bool collapsed, Vector2 dotSize) + public RulesetDifficultyGroup(int rulesetId, IEnumerable beatmapInfos, bool collapsed) { this.rulesetId = rulesetId; this.beatmapInfos = beatmapInfos; this.collapsed = collapsed; - this.dotSize = dotSize; } [BackgroundDependencyLoader] @@ -133,7 +99,7 @@ namespace osu.Game.Beatmaps.Drawables if (!collapsed) { foreach (var beatmapInfo in beatmapInfos.OrderBy(bi => bi.StarRating)) - Add(new DifficultyDot(beatmapInfo.StarRating, dotSize)); + Add(new DifficultyDot(beatmapInfo.StarRating)); } else { @@ -153,10 +119,10 @@ namespace osu.Game.Beatmaps.Drawables { private readonly double starDifficulty; - public DifficultyDot(double starDifficulty, Vector2 dotSize) + public DifficultyDot(double starDifficulty) { this.starDifficulty = starDifficulty; - Size = dotSize; + Size = new Vector2(5, 10); } [BackgroundDependencyLoader] diff --git a/osu.Game/Screens/SelectV2/PanelBeatmapSet.cs b/osu.Game/Screens/SelectV2/PanelBeatmapSet.cs index 512fbacec1..c599c3e534 100644 --- a/osu.Game/Screens/SelectV2/PanelBeatmapSet.cs +++ b/osu.Game/Screens/SelectV2/PanelBeatmapSet.cs @@ -106,8 +106,6 @@ namespace osu.Game.Screens.SelectV2 }, difficultiesDisplay = new DifficultySpectrumDisplay { - DotSize = new Vector2(5, 10), - DotSpacing = 2, Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft, },