mirror of
https://github.com/ppy/osu.git
synced 2025-01-30 02:22:55 +08:00
Merge pull request #18393 from peppy/editor-beat-divisor-size-static
Update beat snap divisor control to be more in line with new designs
This commit is contained in:
commit
8ca6f21dac
@ -9,6 +9,7 @@ using osu.Framework.Graphics;
|
|||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Testing;
|
using osu.Framework.Testing;
|
||||||
using osu.Game.Database;
|
using osu.Game.Database;
|
||||||
|
using osu.Game.Overlays;
|
||||||
using osu.Game.Rulesets.Edit;
|
using osu.Game.Rulesets.Edit;
|
||||||
using osu.Game.Rulesets.Mania.Beatmaps;
|
using osu.Game.Rulesets.Mania.Beatmaps;
|
||||||
using osu.Game.Screens.Edit;
|
using osu.Game.Screens.Edit;
|
||||||
@ -45,6 +46,7 @@ namespace osu.Game.Rulesets.Mania.Tests.Editor
|
|||||||
{
|
{
|
||||||
(typeof(EditorBeatmap), editorBeatmap),
|
(typeof(EditorBeatmap), editorBeatmap),
|
||||||
(typeof(IBeatSnapProvider), editorBeatmap),
|
(typeof(IBeatSnapProvider), editorBeatmap),
|
||||||
|
(typeof(OverlayColourProvider), new OverlayColourProvider(OverlayColourScheme.Green)),
|
||||||
},
|
},
|
||||||
Child = new ComposeScreen { State = { Value = Visibility.Visible } },
|
Child = new ComposeScreen { State = { Value = Visibility.Visible } },
|
||||||
};
|
};
|
||||||
|
@ -5,11 +5,13 @@ using System;
|
|||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Cursor;
|
using osu.Framework.Graphics.Cursor;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
using osu.Framework.Graphics.UserInterface;
|
using osu.Framework.Graphics.UserInterface;
|
||||||
using osu.Framework.Testing;
|
using osu.Framework.Testing;
|
||||||
|
using osu.Game.Overlays;
|
||||||
using osu.Game.Screens.Edit;
|
using osu.Game.Screens.Edit;
|
||||||
using osu.Game.Screens.Edit.Compose.Components;
|
using osu.Game.Screens.Edit.Compose.Components;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
@ -23,7 +25,10 @@ namespace osu.Game.Tests.Visual.Editing
|
|||||||
private BindableBeatDivisor bindableBeatDivisor;
|
private BindableBeatDivisor bindableBeatDivisor;
|
||||||
|
|
||||||
private SliderBar<int> tickSliderBar => beatDivisorControl.ChildrenOfType<SliderBar<int>>().Single();
|
private SliderBar<int> tickSliderBar => beatDivisorControl.ChildrenOfType<SliderBar<int>>().Single();
|
||||||
private EquilateralTriangle tickMarkerHead => tickSliderBar.ChildrenOfType<EquilateralTriangle>().Single();
|
private Triangle tickMarkerHead => tickSliderBar.ChildrenOfType<Triangle>().Single();
|
||||||
|
|
||||||
|
[Cached]
|
||||||
|
private readonly OverlayColourProvider overlayColour = new OverlayColourProvider(OverlayColourScheme.Green);
|
||||||
|
|
||||||
[SetUp]
|
[SetUp]
|
||||||
public void SetUp() => Schedule(() =>
|
public void SetUp() => Schedule(() =>
|
||||||
|
@ -9,6 +9,7 @@ using osu.Framework.Extensions.ObjectExtensions;
|
|||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Testing;
|
using osu.Framework.Testing;
|
||||||
|
using osu.Game.Overlays;
|
||||||
using osu.Game.Rulesets.Edit;
|
using osu.Game.Rulesets.Edit;
|
||||||
using osu.Game.Rulesets.Osu;
|
using osu.Game.Rulesets.Osu;
|
||||||
using osu.Game.Rulesets.Osu.Beatmaps;
|
using osu.Game.Rulesets.Osu.Beatmaps;
|
||||||
@ -47,6 +48,7 @@ namespace osu.Game.Tests.Visual.Editing
|
|||||||
{
|
{
|
||||||
(typeof(EditorBeatmap), editorBeatmap),
|
(typeof(EditorBeatmap), editorBeatmap),
|
||||||
(typeof(IBeatSnapProvider), editorBeatmap),
|
(typeof(IBeatSnapProvider), editorBeatmap),
|
||||||
|
(typeof(OverlayColourProvider), new OverlayColourProvider(OverlayColourScheme.Green)),
|
||||||
},
|
},
|
||||||
Child = new ComposeScreen { State = { Value = Visibility.Visible } },
|
Child = new ComposeScreen { State = { Value = Visibility.Visible } },
|
||||||
};
|
};
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Game.Overlays;
|
||||||
using osu.Game.Screens.Edit.Compose.Components;
|
using osu.Game.Screens.Edit.Compose.Components;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
|
|
||||||
@ -14,6 +15,9 @@ namespace osu.Game.Tests.Visual.Editing
|
|||||||
{
|
{
|
||||||
public override Drawable CreateTestComponent() => Empty(); // tick display is implicitly inside the timeline.
|
public override Drawable CreateTestComponent() => Empty(); // tick display is implicitly inside the timeline.
|
||||||
|
|
||||||
|
[Cached]
|
||||||
|
private readonly OverlayColourProvider overlayColour = new OverlayColourProvider(OverlayColourScheme.Green);
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load()
|
private void load()
|
||||||
{
|
{
|
||||||
|
@ -5,6 +5,7 @@ using System.Linq;
|
|||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Screens.Edit.Compose.Components;
|
using osu.Game.Screens.Edit.Compose.Components;
|
||||||
|
using osuTK;
|
||||||
using osuTK.Graphics;
|
using osuTK.Graphics;
|
||||||
|
|
||||||
namespace osu.Game.Screens.Edit
|
namespace osu.Game.Screens.Edit
|
||||||
@ -100,6 +101,32 @@ namespace osu.Game.Screens.Edit
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get a relative display size for the specified divisor.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="beatDivisor">The beat divisor.</param>
|
||||||
|
/// <returns>A relative size which can be used to display ticks.</returns>
|
||||||
|
public static Vector2 GetSize(int beatDivisor)
|
||||||
|
{
|
||||||
|
switch (beatDivisor)
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
case 2:
|
||||||
|
return new Vector2(0.6f, 0.9f);
|
||||||
|
|
||||||
|
case 3:
|
||||||
|
case 4:
|
||||||
|
return new Vector2(0.5f, 0.8f);
|
||||||
|
|
||||||
|
case 6:
|
||||||
|
case 8:
|
||||||
|
return new Vector2(0.4f, 0.7f);
|
||||||
|
|
||||||
|
default:
|
||||||
|
return new Vector2(0.3f, 0.6f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Retrieves the applicable divisor for a specific beat index.
|
/// Retrieves the applicable divisor for a specific beat index.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -8,9 +8,7 @@ using Humanizer;
|
|||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Extensions;
|
using osu.Framework.Extensions;
|
||||||
using osu.Framework.Extensions.Color4Extensions;
|
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Colour;
|
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Cursor;
|
using osu.Framework.Graphics.Cursor;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
@ -22,6 +20,7 @@ using osu.Game.Graphics.Containers;
|
|||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
using osu.Game.Graphics.UserInterfaceV2;
|
using osu.Game.Graphics.UserInterfaceV2;
|
||||||
|
using osu.Game.Overlays;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
using osuTK.Graphics;
|
using osuTK.Graphics;
|
||||||
using osuTK.Input;
|
using osuTK.Input;
|
||||||
@ -38,18 +37,17 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OsuColour colours)
|
private void load(OverlayColourProvider colourProvider)
|
||||||
{
|
{
|
||||||
Masking = true;
|
Masking = true;
|
||||||
CornerRadius = 5;
|
|
||||||
|
|
||||||
InternalChildren = new Drawable[]
|
InternalChildren = new Drawable[]
|
||||||
{
|
{
|
||||||
new Box
|
new Box
|
||||||
{
|
{
|
||||||
Name = "Gray Background",
|
Name = "Main background",
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Colour = colours.Gray4
|
Colour = colourProvider.Background3,
|
||||||
},
|
},
|
||||||
new GridContainer
|
new GridContainer
|
||||||
{
|
{
|
||||||
@ -65,9 +63,9 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
{
|
{
|
||||||
new Box
|
new Box
|
||||||
{
|
{
|
||||||
Name = "Black Background",
|
Name = "Tick area background",
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Colour = Color4.Black
|
Colour = colourProvider.Background5,
|
||||||
},
|
},
|
||||||
new TickSliderBar(beatDivisor)
|
new TickSliderBar(beatDivisor)
|
||||||
{
|
{
|
||||||
@ -86,7 +84,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
new Box
|
new Box
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Colour = colours.Gray4
|
Colour = colourProvider.Background3
|
||||||
},
|
},
|
||||||
new Container
|
new Container
|
||||||
{
|
{
|
||||||
@ -139,11 +137,6 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
new Box
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
Colour = colours.Gray4
|
|
||||||
},
|
|
||||||
new Container
|
new Container
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
@ -402,15 +395,15 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
ClearInternal();
|
ClearInternal();
|
||||||
CurrentNumber.ValueChanged -= moveMarker;
|
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,
|
Anchor = Anchor.CentreLeft,
|
||||||
Origin = Anchor.TopCentre,
|
Origin = Anchor.Centre,
|
||||||
RelativePositionAxes = Axes.X,
|
RelativePositionAxes = Axes.Both,
|
||||||
Colour = BindableBeatDivisor.GetColourFor(t, colours),
|
Colour = BindableBeatDivisor.GetColourFor(divisor, colours),
|
||||||
X = getMappedPosition(t)
|
X = getMappedPosition(divisor),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -422,7 +415,6 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
private void moveMarker(ValueChangedEvent<int> divisor)
|
private void moveMarker(ValueChangedEvent<int> divisor)
|
||||||
{
|
{
|
||||||
marker.MoveToX(getMappedPosition(divisor.NewValue), 100, Easing.OutQuint);
|
marker.MoveToX(getMappedPosition(divisor.NewValue), 100, Easing.OutQuint);
|
||||||
marker.Flash();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void UpdateValue(float value)
|
protected override void UpdateValue(float value)
|
||||||
@ -490,52 +482,36 @@ 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 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 };
|
InternalChild = new Box { RelativeSizeAxes = Axes.Both };
|
||||||
|
|
||||||
CornerRadius = 0.5f;
|
|
||||||
Masking = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class Marker : CompositeDrawable
|
private class Marker : CompositeDrawable
|
||||||
{
|
{
|
||||||
private Color4 defaultColour;
|
[Resolved]
|
||||||
|
private OverlayColourProvider colourProvider { get; set; }
|
||||||
private const float size = 7;
|
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OsuColour colours)
|
private void load()
|
||||||
{
|
{
|
||||||
Colour = defaultColour = colours.Gray4;
|
Colour = colourProvider.Background3;
|
||||||
Anchor = Anchor.TopLeft;
|
Anchor = Anchor.BottomLeft;
|
||||||
Origin = Anchor.TopCentre;
|
Origin = Anchor.BottomCentre;
|
||||||
|
|
||||||
|
Size = new Vector2(8, 6.5f);
|
||||||
|
|
||||||
Width = size;
|
|
||||||
RelativeSizeAxes = Axes.Y;
|
|
||||||
RelativePositionAxes = Axes.X;
|
RelativePositionAxes = Axes.X;
|
||||||
|
|
||||||
InternalChildren = new Drawable[]
|
InternalChildren = new Drawable[]
|
||||||
{
|
{
|
||||||
new Box
|
new Triangle
|
||||||
{
|
{
|
||||||
Width = 2,
|
RelativeSizeAxes = Axes.Both,
|
||||||
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,
|
|
||||||
Anchor = Anchor.BottomCentre,
|
|
||||||
Height = size,
|
|
||||||
EdgeSmoothness = new Vector2(1),
|
EdgeSmoothness = new Vector2(1),
|
||||||
Colour = Color4.White,
|
Colour = Color4.White,
|
||||||
}
|
}
|
||||||
@ -549,22 +525,10 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
get => active;
|
get => active;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
this.FadeColour(value ? Color4.White : defaultColour, 500, Easing.OutQuint);
|
this.FadeColour(value ? colourProvider.Background1 : colourProvider.Background3, 500, Easing.OutQuint);
|
||||||
active = value;
|
active = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Flash()
|
|
||||||
{
|
|
||||||
bool wasActive = active;
|
|
||||||
|
|
||||||
Active = true;
|
|
||||||
|
|
||||||
if (wasActive) return;
|
|
||||||
|
|
||||||
using (BeginDelayedSequence(50))
|
|
||||||
Active = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@ using osu.Game.Beatmaps;
|
|||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Screens.Edit.Components.Timelines.Summary.Parts;
|
using osu.Game.Screens.Edit.Components.Timelines.Summary.Parts;
|
||||||
using osu.Game.Screens.Edit.Components.Timelines.Summary.Visualisations;
|
using osu.Game.Screens.Edit.Components.Timelines.Summary.Visualisations;
|
||||||
|
using osuTK;
|
||||||
|
|
||||||
namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
||||||
{
|
{
|
||||||
@ -132,10 +133,15 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
|||||||
|
|
||||||
// even though "bar lines" take up the full vertical space, we render them in two pieces because it allows for less anchor/origin churn.
|
// even though "bar lines" take up the full vertical space, we render them in two pieces because it allows for less anchor/origin churn.
|
||||||
|
|
||||||
|
Vector2 size = Vector2.One;
|
||||||
|
|
||||||
|
if (indexInBar != 1)
|
||||||
|
size = BindableBeatDivisor.GetSize(divisor);
|
||||||
|
|
||||||
var line = getNextUsableLine();
|
var line = getNextUsableLine();
|
||||||
line.X = xPos;
|
line.X = xPos;
|
||||||
line.Width = PointVisualisation.MAX_WIDTH * getWidth(indexInBar, divisor);
|
line.Width = PointVisualisation.MAX_WIDTH * size.X;
|
||||||
line.Height = 0.9f * getHeight(indexInBar, divisor);
|
line.Height = 0.9f * size.Y;
|
||||||
line.Colour = colour;
|
line.Colour = colour;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -170,54 +176,6 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static float getWidth(int indexInBar, int divisor)
|
|
||||||
{
|
|
||||||
if (indexInBar == 0)
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
switch (divisor)
|
|
||||||
{
|
|
||||||
case 1:
|
|
||||||
case 2:
|
|
||||||
return 0.6f;
|
|
||||||
|
|
||||||
case 3:
|
|
||||||
case 4:
|
|
||||||
return 0.5f;
|
|
||||||
|
|
||||||
case 6:
|
|
||||||
case 8:
|
|
||||||
return 0.4f;
|
|
||||||
|
|
||||||
default:
|
|
||||||
return 0.3f;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static float getHeight(int indexInBar, int divisor)
|
|
||||||
{
|
|
||||||
if (indexInBar == 0)
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
switch (divisor)
|
|
||||||
{
|
|
||||||
case 1:
|
|
||||||
case 2:
|
|
||||||
return 0.9f;
|
|
||||||
|
|
||||||
case 3:
|
|
||||||
case 4:
|
|
||||||
return 0.8f;
|
|
||||||
|
|
||||||
case 6:
|
|
||||||
case 8:
|
|
||||||
return 0.7f;
|
|
||||||
|
|
||||||
default:
|
|
||||||
return 0.6f;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Dispose(bool isDisposing)
|
protected override void Dispose(bool isDisposing)
|
||||||
{
|
{
|
||||||
base.Dispose(isDisposing);
|
base.Dispose(isDisposing);
|
||||||
|
Loading…
Reference in New Issue
Block a user