diff --git a/osu.Game.Tests/Visual/Beatmaps/TestSceneDifficultySpectrumDisplay.cs b/osu.Game.Tests/Visual/Beatmaps/TestSceneDifficultySpectrumDisplay.cs index 8925c68ef4..1f38b05879 100644 --- a/osu.Game.Tests/Visual/Beatmaps/TestSceneDifficultySpectrumDisplay.cs +++ b/osu.Game.Tests/Visual/Beatmaps/TestSceneDifficultySpectrumDisplay.cs @@ -13,6 +13,8 @@ namespace osu.Game.Tests.Visual.Beatmaps { public class TestSceneDifficultySpectrumDisplay : OsuTestScene { + private DifficultySpectrumDisplay display; + private static APIBeatmapSet createBeatmapSetWith(params (int rulesetId, double stars)[] difficulties) => new APIBeatmapSet { Beatmaps = difficulties.Select(difficulty => new APIBeatmap @@ -74,7 +76,31 @@ namespace osu.Game.Tests.Visual.Beatmaps createDisplay(beatmapSet); } - private void createDisplay(IBeatmapSetInfo beatmapSetInfo) => AddStep("create spectrum display", () => Child = new DifficultySpectrumDisplay(beatmapSetInfo) + [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) { Anchor = Anchor.Centre, Origin = Anchor.Centre, diff --git a/osu.Game/Beatmaps/Drawables/DifficultySpectrumDisplay.cs b/osu.Game/Beatmaps/Drawables/DifficultySpectrumDisplay.cs index a773f6b12c..1feaa88350 100644 --- a/osu.Game/Beatmaps/Drawables/DifficultySpectrumDisplay.cs +++ b/osu.Game/Beatmaps/Drawables/DifficultySpectrumDisplay.cs @@ -18,12 +18,40 @@ namespace osu.Game.Beatmaps.Drawables { public class DifficultySpectrumDisplay : CompositeDrawable { + private Vector2 dotSize = new Vector2(4, 8); + + public Vector2 DotSize + { + get => dotSize; + set + { + dotSize = value; + + if (IsLoaded) + updateDotDimensions(); + } + } + + private float dotSpacing = 1; + + public float DotSpacing + { + get => dotSpacing; + set + { + dotSpacing = value; + + if (IsLoaded) + updateDotDimensions(); + } + } + + private readonly FillFlowContainer flow; + public DifficultySpectrumDisplay(IBeatmapSetInfo beatmapSet) { AutoSizeAxes = Axes.Both; - FillFlowContainer flow; - InternalChild = flow = new FillFlowContainer { AutoSizeAxes = Axes.Both, @@ -40,6 +68,21 @@ namespace osu.Game.Beatmaps.Drawables } } + protected override void LoadComplete() + { + base.LoadComplete(); + updateDotDimensions(); + } + + private void updateDotDimensions() + { + foreach (var group in flow) + { + group.DotSize = DotSize; + group.DotSpacing = DotSpacing; + } + } + private class RulesetDifficultyGroup : FillFlowContainer { private readonly int rulesetId; @@ -53,6 +96,20 @@ namespace osu.Game.Beatmaps.Drawables this.collapsed = collapsed; } + public Vector2 DotSize + { + set + { + foreach (var dot in Children.OfType()) + dot.Size = value; + } + } + + public float DotSpacing + { + set => Spacing = new Vector2(value, 0); + } + [BackgroundDependencyLoader] private void load(RulesetStore rulesets) { @@ -98,8 +155,6 @@ namespace osu.Game.Beatmaps.Drawables [BackgroundDependencyLoader] private void load(OsuColour colours) { - Width = 4; - Height = 8; Anchor = Origin = Anchor.Centre; Masking = true;