From a107fca5d0a774178d8bd3b0fd1ff2725dfeb61b Mon Sep 17 00:00:00 2001 From: mk56-spn Date: Mon, 12 Dec 2022 00:33:28 +0100 Subject: [PATCH] Hide "Full" option from counter flow directions --- .../Gameplay/TestSceneJudgementCounter.cs | 4 +- .../JudgementCounterDisplay.cs | 39 ++++++++++++++++--- 2 files changed, 36 insertions(+), 7 deletions(-) diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneJudgementCounter.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneJudgementCounter.cs index 885b182a6f..1cded54b3e 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneJudgementCounter.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneJudgementCounter.cs @@ -97,8 +97,8 @@ namespace osu.Game.Tests.Visual.Gameplay [Test] public void TestChangeFlowDirection() { - AddStep("Set direction vertical", () => counter.Direction.Value = FillDirection.Vertical); - AddStep("Set direction horizontal", () => counter.Direction.Value = FillDirection.Vertical); + AddStep("Set direction vertical", () => counter.FlowDirection.Value = JudgementCounterDisplay.Flow.Vertical); + AddStep("Set direction horizontal", () => counter.FlowDirection.Value = JudgementCounterDisplay.Flow.Horizonal); } [Test] diff --git a/osu.Game/Screens/Play/HUD/JudgementCounter/JudgementCounterDisplay.cs b/osu.Game/Screens/Play/HUD/JudgementCounter/JudgementCounterDisplay.cs index b392ce8e04..3ac9e7fc55 100644 --- a/osu.Game/Screens/Play/HUD/JudgementCounter/JudgementCounterDisplay.cs +++ b/osu.Game/Screens/Play/HUD/JudgementCounter/JudgementCounterDisplay.cs @@ -19,7 +19,7 @@ namespace osu.Game.Screens.Play.HUD.JudgementCounter public bool UsesFixedAnchor { get; set; } [SettingSource("Counter direction")] - public Bindable Direction { get; set; } = new Bindable(); + public Bindable FlowDirection { get; set; } = new Bindable(); [SettingSource("Show judgement names")] public BindableBool ShowName { get; set; } = new BindableBool(true); @@ -40,7 +40,7 @@ namespace osu.Game.Screens.Play.HUD.JudgementCounter { InternalChild = JudgementContainer = new FillFlowContainer { - Direction = Direction.Value, + Direction = getFlow(FlowDirection.Value), Spacing = new Vector2(10), AutoSizeAxes = Axes.Both }; @@ -61,9 +61,17 @@ namespace osu.Game.Screens.Play.HUD.JudgementCounter { base.LoadComplete(); - Direction.BindValueChanged(direction => JudgementContainer.Direction = direction.NewValue); - Mode.BindValueChanged(_ => updateCounter(), true); + FlowDirection.BindValueChanged(direction => + { + JudgementContainer.Direction = getFlow(direction.NewValue); + //Can't pass directly due to Enum conversion + foreach (var counter in JudgementContainer.Children.OfType()) + { + counter.Direction.Value = getFlow(direction.NewValue); + } + }); + Mode.BindValueChanged(_ => updateCounter(), true); ShowMax.BindValueChanged(value => { var firstChild = JudgementContainer.Children.FirstOrDefault(); @@ -113,6 +121,28 @@ namespace osu.Game.Screens.Play.HUD.JudgementCounter } } + private FillDirection getFlow(Flow flow) + { + switch (flow) + { + case Flow.Horizonal: + return FillDirection.Horizontal; + + case Flow.Vertical: + return FillDirection.Vertical; + + default: + throw new ArgumentOutOfRangeException(nameof(flow), flow, @"Unsupported direction"); + } + } + + //Used to hide default full option in FillDirection + public enum Flow + { + Horizonal, + Vertical + } + public enum DisplayMode { Simple, @@ -125,7 +155,6 @@ namespace osu.Game.Screens.Play.HUD.JudgementCounter JudgementCounter counter = new JudgementCounter(info) { ShowName = { BindTarget = ShowName }, - Direction = { BindTarget = Direction } }; return counter; }