diff --git a/osu.Game/Screens/Edit/Screens/Compose/BeatSnap/BeatSnapVisualiser.cs b/osu.Game/Screens/Edit/Screens/Compose/BeatSnap/BeatSnapVisualiser.cs index 696d491c21..8262c06ba8 100644 --- a/osu.Game/Screens/Edit/Screens/Compose/BeatSnap/BeatSnapVisualiser.cs +++ b/osu.Game/Screens/Edit/Screens/Compose/BeatSnap/BeatSnapVisualiser.cs @@ -1,6 +1,7 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System; using osu.Framework.Allocation; using osu.Framework.Configuration; using osu.Framework.Graphics; @@ -183,5 +184,86 @@ namespace osu.Game.Screens.Edit.Screens.Compose.BeatSnap FlashColour = colours.Gray9; } } + + private class TickContainer : CompositeDrawable + { + public readonly BindableInt Divisor = new BindableInt(); + + public new MarginPadding Padding + { + set => base.Padding = value; + } + + private EquilateralTriangle marker; + + private readonly int[] availableDivisors; + private readonly float tickSpacing; + + public TickContainer(params int[] divisors) + { + availableDivisors = divisors; + tickSpacing = 1f / (availableDivisors.Length + 1); + } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + InternalChild = marker = new EquilateralTriangle + { + Anchor = Anchor.BottomLeft, + Origin = Anchor.BottomCentre, + RelativePositionAxes = Axes.X, + Height = 7, + EdgeSmoothness = new Vector2(1), + Colour = colours.Gray4, + }; + + for (int i = 0; i < availableDivisors.Length; i++) + { + AddInternal(new Tick(availableDivisors[i]) + { + Anchor = Anchor.TopLeft, + Origin = Anchor.TopCentre, + RelativePositionAxes = Axes.X, + X = getTickPosition(i) + }); + } + } + + protected override void LoadComplete() + { + base.LoadComplete(); + + Divisor.ValueChanged += v => updatePosition(); + updatePosition(); + } + + private void updatePosition() => marker.MoveToX(getTickPosition(Array.IndexOf(availableDivisors, Divisor.Value)), 100, Easing.OutQuint); + + private float getTickPosition(int index) => (index + 1) * tickSpacing; + + private class Tick : Box + { + private readonly int divisor; + + public Tick(int divisor) + { + this.divisor = divisor; + + Size = new Vector2(2, 10); + } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + if (divisor >= 16) + Colour = colours.Red; + else if (divisor >= 8) + Colour = colours.Yellow; + else + Colour = colours.Gray4; + } + } + } } } diff --git a/osu.Game/Screens/Edit/Screens/Compose/BeatSnap/TickContainer.cs b/osu.Game/Screens/Edit/Screens/Compose/BeatSnap/TickContainer.cs deleted file mode 100644 index deb22742bc..0000000000 --- a/osu.Game/Screens/Edit/Screens/Compose/BeatSnap/TickContainer.cs +++ /dev/null @@ -1,92 +0,0 @@ -// Copyright (c) 2007-2018 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - -using System; -using osu.Framework.Allocation; -using osu.Framework.Configuration; -using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Shapes; -using osu.Game.Graphics; -using OpenTK; - -namespace osu.Game.Screens.Edit.Screens.Compose.BeatSnap -{ - public class TickContainer : CompositeDrawable - { - public readonly BindableInt Divisor = new BindableInt(); - - public new MarginPadding Padding { set => base.Padding = value; } - - private EquilateralTriangle marker; - - private readonly int[] availableDivisors; - private readonly float tickSpacing; - - public TickContainer(params int[] divisors) - { - availableDivisors = divisors; - tickSpacing = 1f / (availableDivisors.Length + 1); - } - - [BackgroundDependencyLoader] - private void load(OsuColour colours) - { - InternalChild = marker = new EquilateralTriangle - { - Anchor = Anchor.BottomLeft, - Origin = Anchor.BottomCentre, - RelativePositionAxes = Axes.X, - Height = 7, - EdgeSmoothness = new Vector2(1), - Colour = colours.Gray4, - }; - - for (int i = 0; i < availableDivisors.Length; i++) - { - AddInternal(new Tick(availableDivisors[i]) - { - Anchor = Anchor.TopLeft, - Origin = Anchor.TopCentre, - RelativePositionAxes = Axes.X, - X = getTickPosition(i) - }); - } - } - - protected override void LoadComplete() - { - base.LoadComplete(); - - Divisor.ValueChanged += v => updatePosition(); - updatePosition(); - } - - private void updatePosition() => marker.MoveToX(getTickPosition(Array.IndexOf(availableDivisors, Divisor.Value)), 100, Easing.OutQuint); - - private float getTickPosition(int index) => (index + 1) * tickSpacing; - - private class Tick : Box - { - private readonly int divisor; - - public Tick(int divisor) - { - this.divisor = divisor; - - Size = new Vector2(2, 10); - } - - [BackgroundDependencyLoader] - private void load(OsuColour colours) - { - if (divisor >= 16) - Colour = colours.Red; - else if (divisor >= 8) - Colour = colours.Yellow; - else - Colour = colours.Gray4; - } - } - } -} diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 744ca7bcf2..75b69fad76 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -381,7 +381,6 @@ -