mirror of
https://github.com/ppy/osu.git
synced 2025-03-15 22:27:46 +08:00
Update BeatDivisorControl
to better match new designs and metrics
This commit is contained in:
parent
4a88affd03
commit
3c2e57bf00
@ -5,11 +5,13 @@ using System;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Cursor;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Game.Screens.Edit;
|
||||
using osu.Game.Screens.Edit.Compose.Components;
|
||||
using osuTK;
|
||||
@ -25,6 +27,9 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
private SliderBar<int> tickSliderBar => beatDivisorControl.ChildrenOfType<SliderBar<int>>().Single();
|
||||
private EquilateralTriangle tickMarkerHead => tickSliderBar.ChildrenOfType<EquilateralTriangle>().Single();
|
||||
|
||||
[Cached]
|
||||
private readonly OverlayColourProvider overlayColour = new OverlayColourProvider(OverlayColourScheme.Green);
|
||||
|
||||
[SetUp]
|
||||
public void SetUp() => Schedule(() =>
|
||||
{
|
||||
|
@ -8,9 +8,7 @@ using Humanizer;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Extensions;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Colour;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Cursor;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
@ -22,6 +20,7 @@ using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Graphics.UserInterfaceV2;
|
||||
using osu.Game.Overlays;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
using osuTK.Input;
|
||||
@ -38,18 +37,17 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
private void load(OverlayColourProvider colourProvider)
|
||||
{
|
||||
Masking = true;
|
||||
CornerRadius = 5;
|
||||
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
Name = "Gray Background",
|
||||
Name = "Main background",
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = colours.Gray4
|
||||
Colour = colourProvider.Background3,
|
||||
},
|
||||
new GridContainer
|
||||
{
|
||||
@ -65,9 +63,9 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
{
|
||||
new Box
|
||||
{
|
||||
Name = "Black Background",
|
||||
Name = "Tick area background",
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = Color4.Black
|
||||
Colour = colourProvider.Background5,
|
||||
},
|
||||
new TickSliderBar(beatDivisor)
|
||||
{
|
||||
@ -86,7 +84,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = colours.Gray4
|
||||
Colour = colourProvider.Background3
|
||||
},
|
||||
new Container
|
||||
{
|
||||
@ -139,11 +137,6 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = colours.Gray4
|
||||
},
|
||||
new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
@ -402,15 +395,15 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
ClearInternal();
|
||||
CurrentNumber.ValueChanged -= moveMarker;
|
||||
|
||||
foreach (int t in beatDivisor.ValidDivisors.Value.Presets)
|
||||
foreach (int divisor in beatDivisor.ValidDivisors.Value.Presets)
|
||||
{
|
||||
AddInternal(new Tick
|
||||
AddInternal(new Tick(divisor)
|
||||
{
|
||||
Anchor = Anchor.TopLeft,
|
||||
Origin = Anchor.TopCentre,
|
||||
RelativePositionAxes = Axes.X,
|
||||
Colour = BindableBeatDivisor.GetColourFor(t, colours),
|
||||
X = getMappedPosition(t)
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.Centre,
|
||||
RelativePositionAxes = Axes.Both,
|
||||
Colour = BindableBeatDivisor.GetColourFor(divisor, colours),
|
||||
X = getMappedPosition(divisor),
|
||||
});
|
||||
}
|
||||
|
||||
@ -422,7 +415,6 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
private void moveMarker(ValueChangedEvent<int> divisor)
|
||||
{
|
||||
marker.MoveToX(getMappedPosition(divisor.NewValue), 100, Easing.OutQuint);
|
||||
marker.Flash();
|
||||
}
|
||||
|
||||
protected override void UpdateValue(float value)
|
||||
@ -489,29 +481,26 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
|
||||
private float getMappedPosition(float divisor) => MathF.Pow((divisor - 1) / (beatDivisor.ValidDivisors.Value.Presets.Last() - 1), 0.90f);
|
||||
|
||||
private class Tick : CompositeDrawable
|
||||
private class Tick : Circle
|
||||
{
|
||||
public Tick()
|
||||
public Tick(int divisor)
|
||||
{
|
||||
Size = new Vector2(2.5f, 10);
|
||||
|
||||
Size = new Vector2(6f, 12) * BindableBeatDivisor.GetSize(divisor);
|
||||
InternalChild = new Box { RelativeSizeAxes = Axes.Both };
|
||||
|
||||
CornerRadius = 0.5f;
|
||||
Masking = true;
|
||||
}
|
||||
}
|
||||
|
||||
private class Marker : CompositeDrawable
|
||||
{
|
||||
private Color4 defaultColour;
|
||||
[Resolved]
|
||||
private OverlayColourProvider colourProvider { get; set; }
|
||||
|
||||
private const float size = 7;
|
||||
private const float size = 10;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
private void load()
|
||||
{
|
||||
Colour = defaultColour = colours.Gray4;
|
||||
Colour = colourProvider.Background3;
|
||||
Anchor = Anchor.TopLeft;
|
||||
Origin = Anchor.TopCentre;
|
||||
|
||||
@ -521,15 +510,6 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
Width = 2,
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
Origin = Anchor.BottomCentre,
|
||||
Anchor = Anchor.BottomCentre,
|
||||
Colour = ColourInfo.GradientVertical(Color4.White.Opacity(0.2f), Color4.White),
|
||||
Blending = BlendingParameters.Additive,
|
||||
},
|
||||
new EquilateralTriangle
|
||||
{
|
||||
Origin = Anchor.BottomCentre,
|
||||
@ -548,22 +528,10 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
get => active;
|
||||
set
|
||||
{
|
||||
this.FadeColour(value ? Color4.White : defaultColour, 500, Easing.OutQuint);
|
||||
this.FadeColour(value ? colourProvider.Background1 : colourProvider.Background3, 500, Easing.OutQuint);
|
||||
active = value;
|
||||
}
|
||||
}
|
||||
|
||||
public void Flash()
|
||||
{
|
||||
bool wasActive = active;
|
||||
|
||||
Active = true;
|
||||
|
||||
if (wasActive) return;
|
||||
|
||||
using (BeginDelayedSequence(50))
|
||||
Active = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user