mirror of
https://github.com/ppy/osu.git
synced 2025-01-14 03:25:11 +08:00
Merge pull request #5894 from smoogipoo/accessible-beatdivisor-colours
Move beat divisor colour retrieval to BindableBeatDivisor
This commit is contained in:
commit
e479be3fba
@ -4,6 +4,9 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
|
using osu.Framework.Graphics.Colour;
|
||||||
|
using osu.Game.Graphics;
|
||||||
|
using osuTK.Graphics;
|
||||||
|
|
||||||
namespace osu.Game.Screens.Edit
|
namespace osu.Game.Screens.Edit
|
||||||
{
|
{
|
||||||
@ -35,5 +38,41 @@ namespace osu.Game.Screens.Edit
|
|||||||
protected override int DefaultMinValue => VALID_DIVISORS.First();
|
protected override int DefaultMinValue => VALID_DIVISORS.First();
|
||||||
protected override int DefaultMaxValue => VALID_DIVISORS.Last();
|
protected override int DefaultMaxValue => VALID_DIVISORS.Last();
|
||||||
protected override int DefaultPrecision => 1;
|
protected override int DefaultPrecision => 1;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Retrieves the appropriate colour for a beat divisor.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="beatDivisor">The beat divisor.</param>
|
||||||
|
/// <param name="colours">The set of colours.</param>
|
||||||
|
/// <returns>The applicable colour from <paramref name="colours"/> for <paramref name="beatDivisor"/>.</returns>
|
||||||
|
public static ColourInfo GetColourFor(int beatDivisor, OsuColour colours)
|
||||||
|
{
|
||||||
|
switch (beatDivisor)
|
||||||
|
{
|
||||||
|
case 2:
|
||||||
|
return colours.BlueLight;
|
||||||
|
|
||||||
|
case 4:
|
||||||
|
return colours.Blue;
|
||||||
|
|
||||||
|
case 8:
|
||||||
|
return colours.BlueDarker;
|
||||||
|
|
||||||
|
case 16:
|
||||||
|
return colours.PurpleDark;
|
||||||
|
|
||||||
|
case 3:
|
||||||
|
return colours.YellowLight;
|
||||||
|
|
||||||
|
case 6:
|
||||||
|
return colours.Yellow;
|
||||||
|
|
||||||
|
case 12:
|
||||||
|
return colours.YellowDarker;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return Color4.White;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -188,6 +188,9 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
{
|
{
|
||||||
private Marker marker;
|
private Marker marker;
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private OsuColour colours { get; set; }
|
||||||
|
|
||||||
private readonly BindableBeatDivisor beatDivisor;
|
private readonly BindableBeatDivisor beatDivisor;
|
||||||
private readonly int[] availableDivisors;
|
private readonly int[] availableDivisors;
|
||||||
|
|
||||||
@ -204,11 +207,12 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
{
|
{
|
||||||
foreach (var t in availableDivisors)
|
foreach (var t in availableDivisors)
|
||||||
{
|
{
|
||||||
AddInternal(new Tick(t)
|
AddInternal(new Tick
|
||||||
{
|
{
|
||||||
Anchor = Anchor.TopLeft,
|
Anchor = Anchor.TopLeft,
|
||||||
Origin = Anchor.TopCentre,
|
Origin = Anchor.TopCentre,
|
||||||
RelativePositionAxes = Axes.X,
|
RelativePositionAxes = Axes.X,
|
||||||
|
Colour = BindableBeatDivisor.GetColourFor(t, colours),
|
||||||
X = getMappedPosition(t)
|
X = getMappedPosition(t)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -284,11 +288,8 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
|
|
||||||
private class Tick : CompositeDrawable
|
private class Tick : CompositeDrawable
|
||||||
{
|
{
|
||||||
private readonly int divisor;
|
public Tick()
|
||||||
|
|
||||||
public Tick(int divisor)
|
|
||||||
{
|
{
|
||||||
this.divisor = divisor;
|
|
||||||
Size = new Vector2(2.5f, 10);
|
Size = new Vector2(2.5f, 10);
|
||||||
|
|
||||||
InternalChild = new Box { RelativeSizeAxes = Axes.Both };
|
InternalChild = new Box { RelativeSizeAxes = Axes.Both };
|
||||||
@ -296,42 +297,6 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
CornerRadius = 0.5f;
|
CornerRadius = 0.5f;
|
||||||
Masking = true;
|
Masking = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
|
||||||
private void load(OsuColour colours)
|
|
||||||
{
|
|
||||||
Colour = getColourForDivisor(divisor, colours);
|
|
||||||
}
|
|
||||||
|
|
||||||
private ColourInfo getColourForDivisor(int divisor, OsuColour colours)
|
|
||||||
{
|
|
||||||
switch (divisor)
|
|
||||||
{
|
|
||||||
case 2:
|
|
||||||
return colours.BlueLight;
|
|
||||||
|
|
||||||
case 4:
|
|
||||||
return colours.Blue;
|
|
||||||
|
|
||||||
case 8:
|
|
||||||
return colours.BlueDarker;
|
|
||||||
|
|
||||||
case 16:
|
|
||||||
return colours.PurpleDark;
|
|
||||||
|
|
||||||
case 3:
|
|
||||||
return colours.YellowLight;
|
|
||||||
|
|
||||||
case 6:
|
|
||||||
return colours.Yellow;
|
|
||||||
|
|
||||||
case 12:
|
|
||||||
return colours.YellowDarker;
|
|
||||||
|
|
||||||
default:
|
|
||||||
return Color4.White;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private class Marker : CompositeDrawable
|
private class Marker : CompositeDrawable
|
||||||
|
Loading…
Reference in New Issue
Block a user