Use framework Direction instead of local enum

It should be stable enough to use.
This commit is contained in:
Dean Herbert 2023-01-17 18:21:30 +09:00
parent 0a7d6948ca
commit f923dc5009
2 changed files with 16 additions and 23 deletions

View File

@ -94,8 +94,8 @@ namespace osu.Game.Tests.Visual.Gameplay
[Test] [Test]
public void TestChangeFlowDirection() public void TestChangeFlowDirection()
{ {
AddStep("Set direction vertical", () => counterDisplay.FlowDirection.Value = JudgementCounterDisplay.Flow.Vertical); AddStep("Set direction vertical", () => counterDisplay.FlowDirection.Value = Direction.Vertical);
AddStep("Set direction horizontal", () => counterDisplay.FlowDirection.Value = JudgementCounterDisplay.Flow.Horizontal); AddStep("Set direction horizontal", () => counterDisplay.FlowDirection.Value = Direction.Horizontal);
} }
[Test] [Test]

View File

@ -23,7 +23,7 @@ namespace osu.Game.Screens.Play.HUD.JudgementCounter
public Bindable<DisplayMode> Mode { get; set; } = new Bindable<DisplayMode>(); public Bindable<DisplayMode> Mode { get; set; } = new Bindable<DisplayMode>();
[SettingSource("Counter direction")] [SettingSource("Counter direction")]
public Bindable<Flow> FlowDirection { get; set; } = new Bindable<Flow>(); public Bindable<Direction> FlowDirection { get; set; } = new Bindable<Direction>();
[SettingSource("Show judgement names")] [SettingSource("Show judgement names")]
public BindableBool ShowName { get; set; } = new BindableBool(true); public BindableBool ShowName { get; set; } = new BindableBool(true);
@ -42,7 +42,7 @@ namespace osu.Game.Screens.Play.HUD.JudgementCounter
AutoSizeAxes = Axes.Both; AutoSizeAxes = Axes.Both;
InternalChild = JudgementContainer = new FillFlowContainer InternalChild = JudgementContainer = new FillFlowContainer
{ {
Direction = getFlow(FlowDirection.Value), Direction = getFillDirection(FlowDirection.Value),
Spacing = new Vector2(10), Spacing = new Vector2(10),
AutoSizeAxes = Axes.Both AutoSizeAxes = Axes.Both
}; };
@ -57,11 +57,11 @@ namespace osu.Game.Screens.Play.HUD.JudgementCounter
FlowDirection.BindValueChanged(direction => FlowDirection.BindValueChanged(direction =>
{ {
JudgementContainer.Direction = getFlow(direction.NewValue); JudgementContainer.Direction = getFillDirection(direction.NewValue);
//Can't pass directly due to Enum conversion //Can't pass directly due to Enum conversion
foreach (var counter in JudgementContainer.Children.OfType<JudgementCounter>()) foreach (var counter in JudgementContainer.Children.OfType<JudgementCounter>())
counter.Direction.Value = getFlow(direction.NewValue); counter.Direction.Value = getFillDirection(direction.NewValue);
}, true); }, true);
Mode.BindValueChanged(_ => updateMode(), true); Mode.BindValueChanged(_ => updateMode(), true);
ShowMax.BindValueChanged(value => ShowMax.BindValueChanged(value =>
@ -95,14 +95,14 @@ namespace osu.Game.Screens.Play.HUD.JudgementCounter
} }
} }
private FillDirection getFlow(Flow flow) private FillDirection getFillDirection(Direction flow)
{ {
switch (flow) switch (flow)
{ {
case Flow.Horizontal: case Direction.Horizontal:
return FillDirection.Horizontal; return FillDirection.Horizontal;
case Flow.Vertical: case Direction.Vertical:
return FillDirection.Vertical; return FillDirection.Vertical;
default: default:
@ -110,20 +110,6 @@ namespace osu.Game.Screens.Play.HUD.JudgementCounter
} }
} }
//Used to hide default full option in FillDirection
public enum Flow
{
Horizontal,
Vertical
}
public enum DisplayMode
{
Simple,
Normal,
All
}
private JudgementCounter createCounter(JudgementTally.JudgementCount info) private JudgementCounter createCounter(JudgementTally.JudgementCount info)
{ {
JudgementCounter counter = new JudgementCounter(info) JudgementCounter counter = new JudgementCounter(info)
@ -133,5 +119,12 @@ namespace osu.Game.Screens.Play.HUD.JudgementCounter
}; };
return counter; return counter;
} }
public enum DisplayMode
{
Simple,
Normal,
All
}
} }
} }