mirror of
https://github.com/ppy/osu.git
synced 2025-03-04 07:04:04 +08:00
Fix enum to STRING????????? conversion (and use bindable flow)
This commit is contained in:
parent
5852a09003
commit
05797cb9e5
@ -1,7 +1,6 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
@ -78,11 +77,6 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters
|
|||||||
judgementsFlow.Clear();
|
judgementsFlow.Clear();
|
||||||
judgementsFlow.Height = HitShapeCount.Value * (drawable_judgement_size + HitShapeSpacing.Value) - HitShapeSpacing.Value;
|
judgementsFlow.Height = HitShapeCount.Value * (drawable_judgement_size + HitShapeSpacing.Value) - HitShapeSpacing.Value;
|
||||||
}, true);
|
}, true);
|
||||||
HitShape.BindValueChanged(_ =>
|
|
||||||
{
|
|
||||||
judgementsFlow.Shape = getShapeStyle(HitShape.Value);
|
|
||||||
judgementsFlow.Clear();
|
|
||||||
}, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Clear() => judgementsFlow.Clear();
|
public override void Clear() => judgementsFlow.Clear();
|
||||||
@ -90,7 +84,8 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters
|
|||||||
private class JudgementFlow : FillFlowContainer<HitErrorShape>
|
private class JudgementFlow : FillFlowContainer<HitErrorShape>
|
||||||
{
|
{
|
||||||
public override IEnumerable<Drawable> FlowingChildren => base.FlowingChildren.Reverse();
|
public override IEnumerable<Drawable> FlowingChildren => base.FlowingChildren.Reverse();
|
||||||
internal string Shape = null!;
|
|
||||||
|
public readonly Bindable<ShapeStyle> Shape = new Bindable<ShapeStyle>();
|
||||||
|
|
||||||
public JudgementFlow()
|
public JudgementFlow()
|
||||||
{
|
{
|
||||||
@ -102,7 +97,10 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters
|
|||||||
|
|
||||||
public void Push(Color4 colour, int maxErrorShapeCount)
|
public void Push(Color4 colour, int maxErrorShapeCount)
|
||||||
{
|
{
|
||||||
Add(new HitErrorShape(colour, drawable_judgement_size, Shape));
|
Add(new HitErrorShape(colour, drawable_judgement_size)
|
||||||
|
{
|
||||||
|
Shape = { BindTarget = Shape },
|
||||||
|
});
|
||||||
|
|
||||||
if (Children.Count > maxErrorShapeCount)
|
if (Children.Count > maxErrorShapeCount)
|
||||||
Children.FirstOrDefault(c => !c.IsRemoved)?.Remove();
|
Children.FirstOrDefault(c => !c.IsRemoved)?.Remove();
|
||||||
@ -113,13 +111,25 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters
|
|||||||
{
|
{
|
||||||
public bool IsRemoved { get; private set; }
|
public bool IsRemoved { get; private set; }
|
||||||
|
|
||||||
public HitErrorShape(Color4 colour, int size, string shape)
|
public readonly Bindable<ShapeStyle> Shape = new Bindable<ShapeStyle>();
|
||||||
{
|
|
||||||
Size = new Vector2(size);
|
|
||||||
|
|
||||||
switch (shape)
|
private readonly Color4 colour;
|
||||||
|
|
||||||
|
public HitErrorShape(Color4 colour, int size)
|
||||||
{
|
{
|
||||||
case "circle":
|
this.colour = colour;
|
||||||
|
Size = new Vector2(size);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void LoadComplete()
|
||||||
|
{
|
||||||
|
base.LoadComplete();
|
||||||
|
|
||||||
|
Shape.BindValueChanged(shape =>
|
||||||
|
{
|
||||||
|
switch (shape.NewValue)
|
||||||
|
{
|
||||||
|
case ShapeStyle.Circle:
|
||||||
Child = new Circle
|
Child = new Circle
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
@ -128,7 +138,7 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters
|
|||||||
};
|
};
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "square":
|
case ShapeStyle.Square:
|
||||||
Child = new Box
|
Child = new Box
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
@ -137,11 +147,7 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters
|
|||||||
};
|
};
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}, true);
|
||||||
|
|
||||||
protected override void LoadComplete()
|
|
||||||
{
|
|
||||||
base.LoadComplete();
|
|
||||||
|
|
||||||
Child.FadeInFromZero(animation_duration, Easing.OutQuint);
|
Child.FadeInFromZero(animation_duration, Easing.OutQuint);
|
||||||
Child.MoveToY(-DrawSize.Y);
|
Child.MoveToY(-DrawSize.Y);
|
||||||
@ -156,21 +162,6 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private string getShapeStyle(ShapeStyle shape)
|
|
||||||
{
|
|
||||||
switch (shape)
|
|
||||||
{
|
|
||||||
case ShapeStyle.Circle:
|
|
||||||
return "circle";
|
|
||||||
|
|
||||||
case ShapeStyle.Square:
|
|
||||||
return "square";
|
|
||||||
|
|
||||||
default:
|
|
||||||
throw new ArgumentOutOfRangeException(nameof(shape), shape, @"Unsupported animation style");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum ShapeStyle
|
public enum ShapeStyle
|
||||||
{
|
{
|
||||||
Circle,
|
Circle,
|
||||||
|
Loading…
Reference in New Issue
Block a user