From 608223cbb408d33b27c45c8183c13c0d49172c4f Mon Sep 17 00:00:00 2001 From: Unknown Date: Thu, 4 Jul 2019 11:59:38 +0200 Subject: [PATCH 01/26] Add setting to collapse the song progress graph --- .../Visual/Gameplay/TestSceneSongProgress.cs | 16 +++- osu.Game/Configuration/OsuConfigManager.cs | 2 + .../Sections/Gameplay/GeneralSettings.cs | 5 + osu.Game/Screens/Play/SongProgress.cs | 93 +++++++++++-------- osu.Game/Screens/Play/SongProgressBar.cs | 5 +- 5 files changed, 77 insertions(+), 44 deletions(-) diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneSongProgress.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneSongProgress.cs index af21007efe..eef7a25c7a 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneSongProgress.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneSongProgress.cs @@ -1,6 +1,7 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using System; using System.Collections.Generic; using NUnit.Framework; using osu.Framework.Allocation; @@ -15,6 +16,11 @@ namespace osu.Game.Tests.Visual.Gameplay [TestFixture] public class TestSceneSongProgress : OsuTestScene { + public override IReadOnlyList RequiredTypes => new[] + { + typeof(SongProgressBar), + }; + private readonly SongProgress progress; private readonly TestSongProgressGraph graph; @@ -46,24 +52,26 @@ namespace osu.Game.Tests.Visual.Gameplay Origin = Anchor.TopLeft, }); - AddWaitStep("wait some", 5); AddAssert("ensure not created", () => graph.CreationCount == 0); AddStep("display values", displayNewValues); - AddWaitStep("wait some", 5); AddUntilStep("wait for creation count", () => graph.CreationCount == 1); AddStep("Toggle Bar", () => progress.AllowSeeking = !progress.AllowSeeking); - AddWaitStep("wait some", 5); AddUntilStep("wait for creation count", () => graph.CreationCount == 1); AddStep("Toggle Bar", () => progress.AllowSeeking = !progress.AllowSeeking); - AddWaitStep("wait some", 5); AddUntilStep("wait for creation count", () => graph.CreationCount == 1); AddRepeatStep("New Values", displayNewValues, 5); AddWaitStep("wait some", 5); AddAssert("ensure debounced", () => graph.CreationCount == 2); + + AddStep("hide graph", () => progress.CollapseGraph.Value = true); + AddStep("show graph", () => progress.CollapseGraph.Value = false); + + AddStep("start", clock.Start); + AddStep("pause", clock.Stop); } private void displayNewValues() diff --git a/osu.Game/Configuration/OsuConfigManager.cs b/osu.Game/Configuration/OsuConfigManager.cs index 795f0b43f7..f3792fcb7f 100644 --- a/osu.Game/Configuration/OsuConfigManager.cs +++ b/osu.Game/Configuration/OsuConfigManager.cs @@ -77,6 +77,7 @@ namespace osu.Game.Configuration Set(OsuSetting.BlurLevel, 0, 0, 1, 0.01); Set(OsuSetting.ShowInterface, true); + Set(OsuSetting.CollapseProgressGraph, false); Set(OsuSetting.KeyOverlay, false); Set(OsuSetting.FloatingComments, false); @@ -131,6 +132,7 @@ namespace osu.Game.Configuration KeyOverlay, FloatingComments, ShowInterface, + CollapseProgressGraph, MouseDisableButtons, MouseDisableWheel, AudioOffset, diff --git a/osu.Game/Overlays/Settings/Sections/Gameplay/GeneralSettings.cs b/osu.Game/Overlays/Settings/Sections/Gameplay/GeneralSettings.cs index 997d1354b3..e365973c4b 100644 --- a/osu.Game/Overlays/Settings/Sections/Gameplay/GeneralSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/Gameplay/GeneralSettings.cs @@ -35,6 +35,11 @@ namespace osu.Game.Overlays.Settings.Sections.Gameplay Bindable = config.GetBindable(OsuSetting.ShowInterface) }, new SettingsCheckbox + { + LabelText = "Collapse song progress graph", + Bindable = config.GetBindable(OsuSetting.CollapseProgressGraph) + }, + new SettingsCheckbox { LabelText = "Always show key overlay", Bindable = config.GetBindable(OsuSetting.KeyOverlay) diff --git a/osu.Game/Screens/Play/SongProgress.cs b/osu.Game/Screens/Play/SongProgress.cs index 6642efdf8b..a535dc3333 100644 --- a/osu.Game/Screens/Play/SongProgress.cs +++ b/osu.Game/Screens/Play/SongProgress.cs @@ -11,6 +11,7 @@ using osu.Framework.Allocation; using System.Linq; using osu.Framework.Bindables; using osu.Framework.Timing; +using osu.Game.Configuration; using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Objects.Types; using osu.Game.Rulesets.UI; @@ -20,7 +21,7 @@ namespace osu.Game.Screens.Play public class SongProgress : OverlayContainer { private const int bottom_bar_height = 5; - + private const float graph_height = SquareGraph.Column.WIDTH * 6; private static readonly Vector2 handle_size = new Vector2(10, 18); private const float transition_duration = 200; @@ -30,13 +31,13 @@ namespace osu.Game.Screens.Play private readonly SongProgressInfo info; public Action RequestSeek; + public readonly Bindable CollapseGraph = new Bindable(); public override bool HandleNonPositionalInput => AllowSeeking; public override bool HandlePositionalInput => AllowSeeking; - private double lastHitTime => ((objects.Last() as IHasEndTime)?.EndTime ?? objects.Last().StartTime) + 1; - private double firstHitTime => objects.First().StartTime; + private double lastHitTime => ((objects.Last() as IHasEndTime)?.EndTime ?? objects.Last().StartTime) + 1; private IEnumerable objects; @@ -54,25 +55,28 @@ namespace osu.Game.Screens.Play } } + private bool allowSeeking; + + public bool AllowSeeking + { + get => allowSeeking; + set + { + if (allowSeeking == value) return; + + allowSeeking = value; + updateBarVisibility(); + } + } + private readonly BindableBool replayLoaded = new BindableBool(); public IClock ReferenceClock; private IClock gameplayClock; - [BackgroundDependencyLoader(true)] - private void load(OsuColour colours, GameplayClock clock) - { - if (clock != null) - gameplayClock = clock; - - graph.FillColour = bar.FillColour = colours.BlueLighter; - } - public SongProgress() { - const float graph_height = SquareGraph.Column.WIDTH * 6; - Height = bottom_bar_height + graph_height + handle_size.Y; Y = bottom_bar_height; @@ -104,12 +108,23 @@ namespace osu.Game.Screens.Play }; } + [BackgroundDependencyLoader(true)] + private void load(OsuColour colours, GameplayClock clock, OsuConfigManager config) + { + if (clock != null) + gameplayClock = clock; + + config.BindWith(OsuSetting.CollapseProgressGraph, CollapseGraph); + + graph.FillColour = bar.FillColour = colours.BlueLighter; + } + protected override void LoadComplete() { Show(); - replayLoaded.ValueChanged += loaded => AllowSeeking = loaded.NewValue; - replayLoaded.TriggerChange(); + replayLoaded.BindValueChanged(loaded => AllowSeeking = loaded.NewValue, true); + CollapseGraph.BindValueChanged(_ => updateGraphVisibility(), true); } public void BindDrawableRuleset(DrawableRuleset drawableRuleset) @@ -117,28 +132,6 @@ namespace osu.Game.Screens.Play replayLoaded.BindTo(drawableRuleset.HasReplayLoaded); } - private bool allowSeeking; - - public bool AllowSeeking - { - get => allowSeeking; - set - { - if (allowSeeking == value) return; - - allowSeeking = value; - updateBarVisibility(); - } - } - - private void updateBarVisibility() - { - bar.FadeTo(allowSeeking ? 1 : 0, transition_duration, Easing.In); - this.MoveTo(new Vector2(0, allowSeeking ? 0 : bottom_bar_height), transition_duration, Easing.In); - - info.Margin = new MarginPadding { Bottom = Height - (allowSeeking ? 0 : handle_size.Y) }; - } - protected override void PopIn() { updateBarVisibility(); @@ -165,5 +158,29 @@ namespace osu.Game.Screens.Play bar.CurrentTime = gameplayTime; graph.Progress = (int)(graph.ColumnCount * progress); } + + private void updateBarVisibility() + { + bar.FadeTo(allowSeeking ? 1 : 0, transition_duration, Easing.In); + this.MoveTo(new Vector2(0, allowSeeking ? 0 : bottom_bar_height), transition_duration, Easing.In); + + updateInfoMargin(); + } + + private void updateGraphVisibility() + { + float barHeight = bottom_bar_height + handle_size.Y; + + bar.ResizeHeightTo(CollapseGraph.Value ? barHeight : barHeight + graph_height, transition_duration, Easing.In); + graph.MoveToY(CollapseGraph.Value ? graph_height : 0, transition_duration, Easing.In); + + updateInfoMargin(); + } + + private void updateInfoMargin() + { + float finalMargin = bottom_bar_height + (allowSeeking ? handle_size.Y : 0) + (CollapseGraph.Value ? 0 : graph_height); + info.TransformTo(nameof(info.Margin), new MarginPadding { Bottom = finalMargin }, transition_duration, Easing.In); + } } } diff --git a/osu.Game/Screens/Play/SongProgressBar.cs b/osu.Game/Screens/Play/SongProgressBar.cs index dd7b5826d5..0a906845fc 100644 --- a/osu.Game/Screens/Play/SongProgressBar.cs +++ b/osu.Game/Screens/Play/SongProgressBar.cs @@ -18,6 +18,7 @@ namespace osu.Game.Screens.Play private readonly Box fill; private readonly Container handleBase; + private readonly Container handleContainer; public Color4 FillColour { @@ -73,7 +74,6 @@ namespace osu.Game.Screens.Play Origin = Anchor.BottomLeft, Anchor = Anchor.BottomLeft, Width = 2, - Height = barHeight + handleBarHeight, Colour = Color4.White, Position = new Vector2(2, 0), Children = new Drawable[] @@ -83,7 +83,7 @@ namespace osu.Game.Screens.Play Name = "HandleBar box", RelativeSizeAxes = Axes.Both, }, - new Container + handleContainer = new Container { Name = "Handle container", Origin = Anchor.BottomCentre, @@ -115,6 +115,7 @@ namespace osu.Game.Screens.Play { base.Update(); + handleBase.Height = Height - handleContainer.Height; float newX = (float)Interpolation.Lerp(handleBase.X, NormalizedValue * UsableWidth, MathHelper.Clamp(Time.Elapsed / 40, 0, 1)); fill.Width = newX; From e69160a0ce1f80bee073cc618c7205106ac5a206 Mon Sep 17 00:00:00 2001 From: Unknown Date: Fri, 5 Jul 2019 08:05:18 +0200 Subject: [PATCH 02/26] fix graph not completely hiding --- osu.Game/Screens/Play/SongProgress.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Screens/Play/SongProgress.cs b/osu.Game/Screens/Play/SongProgress.cs index a535dc3333..a201b04864 100644 --- a/osu.Game/Screens/Play/SongProgress.cs +++ b/osu.Game/Screens/Play/SongProgress.cs @@ -172,7 +172,7 @@ namespace osu.Game.Screens.Play float barHeight = bottom_bar_height + handle_size.Y; bar.ResizeHeightTo(CollapseGraph.Value ? barHeight : barHeight + graph_height, transition_duration, Easing.In); - graph.MoveToY(CollapseGraph.Value ? graph_height : 0, transition_duration, Easing.In); + graph.MoveToY(CollapseGraph.Value ? bottom_bar_height + graph_height : 0, transition_duration, Easing.In); updateInfoMargin(); } From c22667bdf79eed3048331c1350526041553761f5 Mon Sep 17 00:00:00 2001 From: Unknown Date: Fri, 5 Jul 2019 08:05:23 +0200 Subject: [PATCH 03/26] reorganise tests --- .../Visual/Gameplay/TestSceneSongProgress.cs | 128 ++++++++++++------ 1 file changed, 84 insertions(+), 44 deletions(-) diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneSongProgress.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneSongProgress.cs index eef7a25c7a..810659233b 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneSongProgress.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneSongProgress.cs @@ -7,6 +7,7 @@ using NUnit.Framework; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.MathUtils; +using osu.Framework.Testing; using osu.Framework.Timing; using osu.Game.Rulesets.Objects; using osu.Game.Screens.Play; @@ -21,65 +22,104 @@ namespace osu.Game.Tests.Visual.Gameplay typeof(SongProgressBar), }; - private readonly SongProgress progress; - private readonly TestSongProgressGraph graph; + private SongProgress progress; + private TestSongProgressGraph graph; private readonly StopwatchClock clock; + private readonly FramedClock framedClock; [Cached] private readonly GameplayClock gameplayClock; - private readonly FramedClock framedClock; - public TestSceneSongProgress() { - clock = new StopwatchClock(true); - + clock = new StopwatchClock(); gameplayClock = new GameplayClock(framedClock = new FramedClock(clock)); - - Add(progress = new SongProgress - { - RelativeSizeAxes = Axes.X, - Anchor = Anchor.BottomLeft, - Origin = Anchor.BottomLeft, - }); - - Add(graph = new TestSongProgressGraph - { - RelativeSizeAxes = Axes.X, - Height = 200, - Anchor = Anchor.TopLeft, - Origin = Anchor.TopLeft, - }); - - AddAssert("ensure not created", () => graph.CreationCount == 0); - - AddStep("display values", displayNewValues); - AddUntilStep("wait for creation count", () => graph.CreationCount == 1); - - AddStep("Toggle Bar", () => progress.AllowSeeking = !progress.AllowSeeking); - AddUntilStep("wait for creation count", () => graph.CreationCount == 1); - - AddStep("Toggle Bar", () => progress.AllowSeeking = !progress.AllowSeeking); - AddUntilStep("wait for creation count", () => graph.CreationCount == 1); - AddRepeatStep("New Values", displayNewValues, 5); - - AddWaitStep("wait some", 5); - AddAssert("ensure debounced", () => graph.CreationCount == 2); - - AddStep("hide graph", () => progress.CollapseGraph.Value = true); - AddStep("show graph", () => progress.CollapseGraph.Value = false); - - AddStep("start", clock.Start); - AddStep("pause", clock.Stop); } - private void displayNewValues() + [SetUpSteps] + public void SetupSteps() { - List objects = new List(); + AddStep("add new song progress", () => + { + if (progress != null) + { + progress.Expire(); + progress = null; + } + + Add(progress = new SongProgress + { + RelativeSizeAxes = Axes.X, + Anchor = Anchor.BottomLeft, + Origin = Anchor.BottomLeft, + }); + }); + + AddStep("add new big graph", () => + { + if (graph != null) + { + graph.Expire(); + graph = null; + } + + Add(graph = new TestSongProgressGraph + { + RelativeSizeAxes = Axes.X, + Height = 200, + Anchor = Anchor.TopLeft, + Origin = Anchor.TopLeft, + }); + }); + + AddStep("reset clock", clock.Reset); + } + + [Test] + public void TestGraphRecreation() + { + AddAssert("ensure not created", () => graph.CreationCount == 0); + AddStep("display values", displayRandomValues); + AddUntilStep("wait for creation count", () => graph.CreationCount == 1); + AddRepeatStep("new values", displayRandomValues, 5); + AddWaitStep("wait some", 5); + AddAssert("ensure recreation debounced", () => graph.CreationCount == 2); + } + + [Test] + public void TestDisplay() + { + AddStep("display max values", displayMaxValues); + AddStep("start", clock.Start); + AddStep("show bar", () => progress.AllowSeeking = true); + AddStep("hide graph", () => progress.CollapseGraph.Value = true); + AddStep("hide Bar", () => progress.AllowSeeking = false); + AddStep("show bar", () => progress.AllowSeeking = true); + AddStep("show graph", () => progress.CollapseGraph.Value = false); + AddStep("stop", clock.Stop); + } + + private void displayRandomValues() + { + var objects = new List(); for (double i = 0; i < 5000; i += RNG.NextDouble() * 10 + i / 1000) objects.Add(new HitObject { StartTime = i }); + replaceObjects(objects); + } + + private void displayMaxValues() + { + var objects = new List(); + for (double i = 0; i < 5000; i++) + objects.Add(new HitObject { StartTime = i }); + + replaceObjects(objects); + } + + private void replaceObjects(List objects) + { progress.Objects = objects; graph.Objects = objects; From 1cb7a9617be89f5f01f6b21bc6ce280fdf8e2c95 Mon Sep 17 00:00:00 2001 From: Unknown Date: Fri, 5 Jul 2019 08:29:57 +0200 Subject: [PATCH 04/26] move songprogress up to be able to see below for masking --- .../Visual/Gameplay/TestSceneSongProgress.cs | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneSongProgress.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneSongProgress.cs index 810659233b..550115846b 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneSongProgress.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneSongProgress.cs @@ -6,9 +6,12 @@ using System.Collections.Generic; using NUnit.Framework; using osu.Framework.Allocation; using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Shapes; using osu.Framework.MathUtils; using osu.Framework.Testing; using osu.Framework.Timing; +using osu.Game.Graphics; using osu.Game.Rulesets.Objects; using osu.Game.Screens.Play; @@ -24,6 +27,7 @@ namespace osu.Game.Tests.Visual.Gameplay private SongProgress progress; private TestSongProgressGraph graph; + private readonly Container progressContainer; private readonly StopwatchClock clock; private readonly FramedClock framedClock; @@ -35,6 +39,20 @@ namespace osu.Game.Tests.Visual.Gameplay { clock = new StopwatchClock(); gameplayClock = new GameplayClock(framedClock = new FramedClock(clock)); + + Add(progressContainer = new Container + { + RelativeSizeAxes = Axes.X, + Anchor = Anchor.BottomCentre, + Origin = Anchor.BottomCentre, + Height = 100, + Y = -100, + Child = new Box + { + RelativeSizeAxes = Axes.Both, + Colour = OsuColour.Gray(1), + } + }); } [SetUpSteps] @@ -48,7 +66,7 @@ namespace osu.Game.Tests.Visual.Gameplay progress = null; } - Add(progress = new SongProgress + progressContainer.Add(progress = new SongProgress { RelativeSizeAxes = Axes.X, Anchor = Anchor.BottomLeft, @@ -91,6 +109,7 @@ namespace osu.Game.Tests.Visual.Gameplay public void TestDisplay() { AddStep("display max values", displayMaxValues); + AddUntilStep("wait for graph", () => graph.CreationCount == 1); AddStep("start", clock.Start); AddStep("show bar", () => progress.AllowSeeking = true); AddStep("hide graph", () => progress.CollapseGraph.Value = true); From ed22c23f37bf57a9d1de77db3a905a718a5394db Mon Sep 17 00:00:00 2001 From: Unknown Date: Fri, 5 Jul 2019 08:30:32 +0200 Subject: [PATCH 05/26] mask SongProgress --- osu.Game/Screens/Play/SongProgress.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/osu.Game/Screens/Play/SongProgress.cs b/osu.Game/Screens/Play/SongProgress.cs index a201b04864..9ebfeb5c82 100644 --- a/osu.Game/Screens/Play/SongProgress.cs +++ b/osu.Game/Screens/Play/SongProgress.cs @@ -77,8 +77,8 @@ namespace osu.Game.Screens.Play public SongProgress() { - Height = bottom_bar_height + graph_height + handle_size.Y; - Y = bottom_bar_height; + Masking = true; + Height = bottom_bar_height + graph_height + handle_size.Y + OsuFont.Numeric.Size; Children = new Drawable[] { @@ -88,7 +88,6 @@ namespace osu.Game.Screens.Play Anchor = Anchor.BottomLeft, RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, - Margin = new MarginPadding { Bottom = bottom_bar_height + graph_height }, }, graph = new SongProgressGraph { From b425df6c75afa792aa97165a798d3a884c6a8c04 Mon Sep 17 00:00:00 2001 From: Unknown Date: Fri, 5 Jul 2019 08:48:40 +0200 Subject: [PATCH 06/26] various fixes - make AllowSeeking a Bindable which fixes incorrect initial position and removes unnecessary variables - make SongProgressInfo fixed height --- .../Visual/Gameplay/TestSceneSongProgress.cs | 6 +-- osu.Game/Screens/Play/SongProgress.cs | 45 ++++++++----------- 2 files changed, 22 insertions(+), 29 deletions(-) diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneSongProgress.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneSongProgress.cs index 550115846b..e16ad42558 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneSongProgress.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneSongProgress.cs @@ -111,10 +111,10 @@ namespace osu.Game.Tests.Visual.Gameplay AddStep("display max values", displayMaxValues); AddUntilStep("wait for graph", () => graph.CreationCount == 1); AddStep("start", clock.Start); - AddStep("show bar", () => progress.AllowSeeking = true); + AddStep("show bar", () => progress.AllowSeeking.Value = true); AddStep("hide graph", () => progress.CollapseGraph.Value = true); - AddStep("hide Bar", () => progress.AllowSeeking = false); - AddStep("show bar", () => progress.AllowSeeking = true); + AddStep("hide Bar", () => progress.AllowSeeking.Value = false); + AddStep("show bar", () => progress.AllowSeeking.Value = true); AddStep("show graph", () => progress.CollapseGraph.Value = false); AddStep("stop", clock.Stop); } diff --git a/osu.Game/Screens/Play/SongProgress.cs b/osu.Game/Screens/Play/SongProgress.cs index 9ebfeb5c82..9d1978e4cd 100644 --- a/osu.Game/Screens/Play/SongProgress.cs +++ b/osu.Game/Screens/Play/SongProgress.cs @@ -20,6 +20,7 @@ namespace osu.Game.Screens.Play { public class SongProgress : OverlayContainer { + private const int info_height = 20; private const int bottom_bar_height = 5; private const float graph_height = SquareGraph.Column.WIDTH * 6; private static readonly Vector2 handle_size = new Vector2(10, 18); @@ -31,10 +32,19 @@ namespace osu.Game.Screens.Play private readonly SongProgressInfo info; public Action RequestSeek; + + /// + /// Whether seeking is allowed and the progress bar should be shown. + /// + public readonly Bindable AllowSeeking = new Bindable(); + + /// + /// Whether the difficulty graph should be shown. + /// public readonly Bindable CollapseGraph = new Bindable(); - public override bool HandleNonPositionalInput => AllowSeeking; - public override bool HandlePositionalInput => AllowSeeking; + public override bool HandleNonPositionalInput => AllowSeeking.Value; + public override bool HandlePositionalInput => AllowSeeking.Value; private double firstHitTime => objects.First().StartTime; private double lastHitTime => ((objects.Last() as IHasEndTime)?.EndTime ?? objects.Last().StartTime) + 1; @@ -55,22 +65,6 @@ namespace osu.Game.Screens.Play } } - private bool allowSeeking; - - public bool AllowSeeking - { - get => allowSeeking; - set - { - if (allowSeeking == value) return; - - allowSeeking = value; - updateBarVisibility(); - } - } - - private readonly BindableBool replayLoaded = new BindableBool(); - public IClock ReferenceClock; private IClock gameplayClock; @@ -78,7 +72,7 @@ namespace osu.Game.Screens.Play public SongProgress() { Masking = true; - Height = bottom_bar_height + graph_height + handle_size.Y + OsuFont.Numeric.Size; + Height = bottom_bar_height + graph_height + handle_size.Y + info_height; Children = new Drawable[] { @@ -87,7 +81,7 @@ namespace osu.Game.Screens.Play Origin = Anchor.BottomLeft, Anchor = Anchor.BottomLeft, RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, + Height = info_height, }, graph = new SongProgressGraph { @@ -122,18 +116,17 @@ namespace osu.Game.Screens.Play { Show(); - replayLoaded.BindValueChanged(loaded => AllowSeeking = loaded.NewValue, true); + AllowSeeking.BindValueChanged(_ => updateBarVisibility(), true); CollapseGraph.BindValueChanged(_ => updateGraphVisibility(), true); } public void BindDrawableRuleset(DrawableRuleset drawableRuleset) { - replayLoaded.BindTo(drawableRuleset.HasReplayLoaded); + AllowSeeking.BindTo(drawableRuleset.HasReplayLoaded); } protected override void PopIn() { - updateBarVisibility(); this.FadeIn(500, Easing.OutQuint); } @@ -160,8 +153,8 @@ namespace osu.Game.Screens.Play private void updateBarVisibility() { - bar.FadeTo(allowSeeking ? 1 : 0, transition_duration, Easing.In); - this.MoveTo(new Vector2(0, allowSeeking ? 0 : bottom_bar_height), transition_duration, Easing.In); + bar.FadeTo(AllowSeeking.Value ? 1 : 0, transition_duration, Easing.In); + this.MoveTo(new Vector2(0, AllowSeeking.Value ? 0 : bottom_bar_height), transition_duration, Easing.In); updateInfoMargin(); } @@ -178,7 +171,7 @@ namespace osu.Game.Screens.Play private void updateInfoMargin() { - float finalMargin = bottom_bar_height + (allowSeeking ? handle_size.Y : 0) + (CollapseGraph.Value ? 0 : graph_height); + float finalMargin = bottom_bar_height + (AllowSeeking.Value ? handle_size.Y : 0) + (CollapseGraph.Value ? 0 : graph_height); info.TransformTo(nameof(info.Margin), new MarginPadding { Bottom = finalMargin }, transition_duration, Easing.In); } } From 2d5fd7f1c4fc789daabbebd0dad891ed3033a8f2 Mon Sep 17 00:00:00 2001 From: Unknown Date: Fri, 5 Jul 2019 08:49:56 +0200 Subject: [PATCH 07/26] remove unnecessarily setting value of bindable that was already bound to --- osu.Game/Screens/Play/HUDOverlay.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game/Screens/Play/HUDOverlay.cs b/osu.Game/Screens/Play/HUDOverlay.cs index 017bf70133..e0036cdeb9 100644 --- a/osu.Game/Screens/Play/HUDOverlay.cs +++ b/osu.Game/Screens/Play/HUDOverlay.cs @@ -106,7 +106,6 @@ namespace osu.Game.Screens.Play BindDrawableRuleset(drawableRuleset); Progress.Objects = drawableRuleset.Objects; - Progress.AllowSeeking = drawableRuleset.HasReplayLoaded.Value; Progress.RequestSeek = time => RequestSeek(time); Progress.ReferenceClock = drawableRuleset.FrameStableClock; From ee44caf964c59439449e8d65dfa4bf73ea9fb887 Mon Sep 17 00:00:00 2001 From: Unknown Date: Fri, 5 Jul 2019 08:52:44 +0200 Subject: [PATCH 08/26] better setting description --- osu.Game/Configuration/OsuConfigManager.cs | 4 ++-- .../Overlays/Settings/Sections/Gameplay/GeneralSettings.cs | 4 ++-- osu.Game/Screens/Play/SongProgress.cs | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/osu.Game/Configuration/OsuConfigManager.cs b/osu.Game/Configuration/OsuConfigManager.cs index f3792fcb7f..c055d7d321 100644 --- a/osu.Game/Configuration/OsuConfigManager.cs +++ b/osu.Game/Configuration/OsuConfigManager.cs @@ -77,7 +77,7 @@ namespace osu.Game.Configuration Set(OsuSetting.BlurLevel, 0, 0, 1, 0.01); Set(OsuSetting.ShowInterface, true); - Set(OsuSetting.CollapseProgressGraph, false); + Set(OsuSetting.ShowProgressGraph, true); Set(OsuSetting.KeyOverlay, false); Set(OsuSetting.FloatingComments, false); @@ -132,7 +132,7 @@ namespace osu.Game.Configuration KeyOverlay, FloatingComments, ShowInterface, - CollapseProgressGraph, + ShowProgressGraph, MouseDisableButtons, MouseDisableWheel, AudioOffset, diff --git a/osu.Game/Overlays/Settings/Sections/Gameplay/GeneralSettings.cs b/osu.Game/Overlays/Settings/Sections/Gameplay/GeneralSettings.cs index e365973c4b..2169fc69cc 100644 --- a/osu.Game/Overlays/Settings/Sections/Gameplay/GeneralSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/Gameplay/GeneralSettings.cs @@ -36,8 +36,8 @@ namespace osu.Game.Overlays.Settings.Sections.Gameplay }, new SettingsCheckbox { - LabelText = "Collapse song progress graph", - Bindable = config.GetBindable(OsuSetting.CollapseProgressGraph) + LabelText = "Show difficulty graph on progress bar", + Bindable = config.GetBindable(OsuSetting.ShowProgressGraph) }, new SettingsCheckbox { diff --git a/osu.Game/Screens/Play/SongProgress.cs b/osu.Game/Screens/Play/SongProgress.cs index 9d1978e4cd..7411afb688 100644 --- a/osu.Game/Screens/Play/SongProgress.cs +++ b/osu.Game/Screens/Play/SongProgress.cs @@ -107,7 +107,7 @@ namespace osu.Game.Screens.Play if (clock != null) gameplayClock = clock; - config.BindWith(OsuSetting.CollapseProgressGraph, CollapseGraph); + config.BindWith(OsuSetting.ShowProgressGraph, CollapseGraph); graph.FillColour = bar.FillColour = colours.BlueLighter; } From d05512a12a3d7c41f8276473d0fb08c31e2ba092 Mon Sep 17 00:00:00 2001 From: Unknown Date: Fri, 5 Jul 2019 09:16:50 +0200 Subject: [PATCH 09/26] invert usage corresponding to previous description change --- .../Visual/Gameplay/TestSceneSongProgress.cs | 4 ++-- osu.Game/Screens/Play/SongProgress.cs | 15 ++++++--------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneSongProgress.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneSongProgress.cs index e16ad42558..15bf907b4f 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneSongProgress.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneSongProgress.cs @@ -112,10 +112,10 @@ namespace osu.Game.Tests.Visual.Gameplay AddUntilStep("wait for graph", () => graph.CreationCount == 1); AddStep("start", clock.Start); AddStep("show bar", () => progress.AllowSeeking.Value = true); - AddStep("hide graph", () => progress.CollapseGraph.Value = true); + AddStep("hide graph", () => progress.ShowGraph.Value = false); AddStep("hide Bar", () => progress.AllowSeeking.Value = false); AddStep("show bar", () => progress.AllowSeeking.Value = true); - AddStep("show graph", () => progress.CollapseGraph.Value = false); + AddStep("show graph", () => progress.ShowGraph.Value = true); AddStep("stop", clock.Stop); } diff --git a/osu.Game/Screens/Play/SongProgress.cs b/osu.Game/Screens/Play/SongProgress.cs index 7411afb688..727fad84c9 100644 --- a/osu.Game/Screens/Play/SongProgress.cs +++ b/osu.Game/Screens/Play/SongProgress.cs @@ -38,10 +38,7 @@ namespace osu.Game.Screens.Play /// public readonly Bindable AllowSeeking = new Bindable(); - /// - /// Whether the difficulty graph should be shown. - /// - public readonly Bindable CollapseGraph = new Bindable(); + public readonly Bindable ShowGraph = new Bindable(); public override bool HandleNonPositionalInput => AllowSeeking.Value; public override bool HandlePositionalInput => AllowSeeking.Value; @@ -107,7 +104,7 @@ namespace osu.Game.Screens.Play if (clock != null) gameplayClock = clock; - config.BindWith(OsuSetting.ShowProgressGraph, CollapseGraph); + config.BindWith(OsuSetting.ShowProgressGraph, ShowGraph); graph.FillColour = bar.FillColour = colours.BlueLighter; } @@ -117,7 +114,7 @@ namespace osu.Game.Screens.Play Show(); AllowSeeking.BindValueChanged(_ => updateBarVisibility(), true); - CollapseGraph.BindValueChanged(_ => updateGraphVisibility(), true); + ShowGraph.BindValueChanged(_ => updateGraphVisibility(), true); } public void BindDrawableRuleset(DrawableRuleset drawableRuleset) @@ -163,15 +160,15 @@ namespace osu.Game.Screens.Play { float barHeight = bottom_bar_height + handle_size.Y; - bar.ResizeHeightTo(CollapseGraph.Value ? barHeight : barHeight + graph_height, transition_duration, Easing.In); - graph.MoveToY(CollapseGraph.Value ? bottom_bar_height + graph_height : 0, transition_duration, Easing.In); + bar.ResizeHeightTo(ShowGraph.Value ? barHeight + graph_height : barHeight, transition_duration, Easing.In); + graph.MoveToY(ShowGraph.Value ? 0 : bottom_bar_height + graph_height, transition_duration, Easing.In); updateInfoMargin(); } private void updateInfoMargin() { - float finalMargin = bottom_bar_height + (AllowSeeking.Value ? handle_size.Y : 0) + (CollapseGraph.Value ? 0 : graph_height); + float finalMargin = bottom_bar_height + (AllowSeeking.Value ? handle_size.Y : 0) + (ShowGraph.Value ? graph_height : 0); info.TransformTo(nameof(info.Margin), new MarginPadding { Bottom = finalMargin }, transition_duration, Easing.In); } } From c69e88eb97b90c73b3e2dcd2bebe18c8aa4b8540 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Sat, 21 Dec 2019 13:32:25 +0300 Subject: [PATCH 10/26] Add more types to dropdown --- osu.Game/Configuration/ScoreMeterType.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/osu.Game/Configuration/ScoreMeterType.cs b/osu.Game/Configuration/ScoreMeterType.cs index b85ef9309d..156c4b1377 100644 --- a/osu.Game/Configuration/ScoreMeterType.cs +++ b/osu.Game/Configuration/ScoreMeterType.cs @@ -18,5 +18,14 @@ namespace osu.Game.Configuration [Description("Hit Error (both)")] HitErrorBoth, + + [Description("Colour (left)")] + ColourLeft, + + [Description("Colour (right)")] + ColourRight, + + [Description("Colour (both)")] + ColourBoth, } } From 5b115d8d8a94fff0f265d8a5aba113c0c1b1ad53 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Sat, 21 Dec 2019 13:41:50 +0300 Subject: [PATCH 11/26] Implement basic logic --- osu.Game/Screens/Play/HUD/HitErrorDisplay.cs | 31 +++++++++++++++++ .../HUD/HitErrorMeters/ColourHitErrorMeter.cs | 33 +++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 osu.Game/Screens/Play/HUD/HitErrorMeters/ColourHitErrorMeter.cs diff --git a/osu.Game/Screens/Play/HUD/HitErrorDisplay.cs b/osu.Game/Screens/Play/HUD/HitErrorDisplay.cs index 6196ce4026..4d28f00f39 100644 --- a/osu.Game/Screens/Play/HUD/HitErrorDisplay.cs +++ b/osu.Game/Screens/Play/HUD/HitErrorDisplay.cs @@ -77,6 +77,19 @@ namespace osu.Game.Screens.Play.HUD case ScoreMeterType.HitErrorRight: createBar(true); break; + + case ScoreMeterType.ColourBoth: + createColour(false); + createColour(true); + break; + + case ScoreMeterType.ColourLeft: + createColour(false); + break; + + case ScoreMeterType.ColourRight: + createColour(true); + break; } } @@ -90,6 +103,24 @@ namespace osu.Game.Screens.Play.HUD Alpha = 0, }; + completeDisplayLoading(display); + } + + private void createColour(bool rightAligned) + { + var display = new ColourHitErrorMeter(hitWindows) + { + Margin = new MarginPadding(margin), + Anchor = rightAligned ? Anchor.CentreRight : Anchor.CentreLeft, + Origin = rightAligned ? Anchor.CentreRight : Anchor.CentreLeft, + Alpha = 0, + }; + + completeDisplayLoading(display); + } + + private void completeDisplayLoading(HitErrorMeter display) + { Add(display); display.FadeInFromZero(fade_duration, Easing.OutQuint); } diff --git a/osu.Game/Screens/Play/HUD/HitErrorMeters/ColourHitErrorMeter.cs b/osu.Game/Screens/Play/HUD/HitErrorMeters/ColourHitErrorMeter.cs new file mode 100644 index 0000000000..95d4940b17 --- /dev/null +++ b/osu.Game/Screens/Play/HUD/HitErrorMeters/ColourHitErrorMeter.cs @@ -0,0 +1,33 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System.Linq; +using osu.Framework.Allocation; +using osu.Framework.Extensions.Color4Extensions; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Colour; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Shapes; +using osu.Framework.Graphics.Sprites; +using osu.Game.Graphics; +using osu.Game.Rulesets.Judgements; +using osu.Game.Rulesets.Scoring; +using osuTK; +using osuTK.Graphics; + +namespace osu.Game.Screens.Play.HUD.HitErrorMeters +{ + public class ColourHitErrorMeter : HitErrorMeter + { + public ColourHitErrorMeter(HitWindows hitWindows) + : base(hitWindows) + { + + } + + public override void OnNewJudgement(JudgementResult judgement) + { + throw new System.NotImplementedException(); + } + } +} From 5e3c3f2a90190b9a785800627b44e4af136d6dba Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Sat, 21 Dec 2019 14:30:41 +0300 Subject: [PATCH 12/26] Make judgements work --- .../HUD/HitErrorMeters/ColourHitErrorMeter.cs | 70 +++++++++++++++++-- 1 file changed, 63 insertions(+), 7 deletions(-) diff --git a/osu.Game/Screens/Play/HUD/HitErrorMeters/ColourHitErrorMeter.cs b/osu.Game/Screens/Play/HUD/HitErrorMeters/ColourHitErrorMeter.cs index 95d4940b17..41401a0048 100644 --- a/osu.Game/Screens/Play/HUD/HitErrorMeters/ColourHitErrorMeter.cs +++ b/osu.Game/Screens/Play/HUD/HitErrorMeters/ColourHitErrorMeter.cs @@ -1,33 +1,89 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -using System.Linq; using osu.Framework.Allocation; -using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; -using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; -using osu.Framework.Graphics.Sprites; using osu.Game.Graphics; using osu.Game.Rulesets.Judgements; using osu.Game.Rulesets.Scoring; using osuTK; -using osuTK.Graphics; namespace osu.Game.Screens.Play.HUD.HitErrorMeters { public class ColourHitErrorMeter : HitErrorMeter { + private const int bar_height = 200; + + private readonly FillFlowContainer judgementsFlow; + public ColourHitErrorMeter(HitWindows hitWindows) : base(hitWindows) { - + AutoSizeAxes = Axes.Both; + InternalChild = judgementsFlow = new FillFlowContainer + { + AutoSizeAxes = Axes.X, + Height = bar_height, + Direction = FillDirection.Vertical, + Spacing = new Vector2(0, 2), + Masking = true, + }; } public override void OnNewJudgement(JudgementResult judgement) { - throw new System.NotImplementedException(); + judgementsFlow.Add(new DrawableJudgement(HitWindows.ResultFor(judgement.TimeOffset))); + } + + private class DrawableJudgement : CircularContainer + { + private readonly Box background; + private readonly HitResult result; + + public DrawableJudgement(HitResult result) + { + this.result = result; + + Masking = true; + Size = new Vector2(8); + Child = background = new Box + { + RelativeSizeAxes = Axes.Both, + }; + } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + switch (result) + { + case HitResult.Miss: + background.Colour = colours.Red; + break; + + case HitResult.Meh: + background.Colour = colours.Yellow; + break; + + case HitResult.Ok: + background.Colour = colours.Green; + break; + + case HitResult.Good: + background.Colour = colours.GreenLight; + break; + + case HitResult.Great: + background.Colour = colours.Blue; + break; + + default: + background.Colour = colours.BlueLight; + break; + } + } } } } From 5af126009488554a4322fa292c24e39f8ef0f898 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Sat, 21 Dec 2019 14:30:49 +0300 Subject: [PATCH 13/26] Improve testing --- ...rrorMeter.cs => TestSceneHitErrorMeter.cs} | 36 ++++++++++++++----- 1 file changed, 28 insertions(+), 8 deletions(-) rename osu.Game.Tests/Visual/Gameplay/{TestSceneBarHitErrorMeter.cs => TestSceneHitErrorMeter.cs} (75%) diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneBarHitErrorMeter.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneHitErrorMeter.cs similarity index 75% rename from osu.Game.Tests/Visual/Gameplay/TestSceneBarHitErrorMeter.cs rename to osu.Game.Tests/Visual/Gameplay/TestSceneHitErrorMeter.cs index e3688c276f..b208a2e0e7 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneBarHitErrorMeter.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneHitErrorMeter.cs @@ -19,18 +19,22 @@ using osu.Game.Screens.Play.HUD.HitErrorMeters; namespace osu.Game.Tests.Visual.Gameplay { - public class TestSceneBarHitErrorMeter : OsuTestScene + public class TestSceneHitErrorMeter : OsuTestScene { public override IReadOnlyList RequiredTypes => new[] { typeof(HitErrorMeter), + typeof(BarHitErrorMeter), + typeof(ColourHitErrorMeter) }; - private HitErrorMeter meter; - private HitErrorMeter meter2; + private BarHitErrorMeter barMeter; + private BarHitErrorMeter barMeter2; + private ColourHitErrorMeter colourMeter; + private ColourHitErrorMeter colourMeter2; private HitWindows hitWindows; - public TestSceneBarHitErrorMeter() + public TestSceneHitErrorMeter() { recreateDisplay(new OsuHitWindows(), 5); @@ -91,17 +95,31 @@ namespace osu.Game.Tests.Visual.Gameplay } }); - Add(meter = new BarHitErrorMeter(hitWindows, true) + Add(barMeter = new BarHitErrorMeter(hitWindows, true) { Anchor = Anchor.CentreRight, Origin = Anchor.CentreRight, }); - Add(meter2 = new BarHitErrorMeter(hitWindows, false) + Add(barMeter2 = new BarHitErrorMeter(hitWindows, false) { Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft, }); + + Add(colourMeter = new ColourHitErrorMeter(hitWindows) + { + Anchor = Anchor.CentreRight, + Origin = Anchor.CentreRight, + Margin = new MarginPadding { Right = 50 } + }); + + Add(colourMeter2 = new ColourHitErrorMeter(hitWindows) + { + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + Margin = new MarginPadding { Left = 50 } + }); } private void newJudgement(double offset = 0) @@ -112,8 +130,10 @@ namespace osu.Game.Tests.Visual.Gameplay Type = HitResult.Perfect, }; - meter.OnNewJudgement(judgement); - meter2.OnNewJudgement(judgement); + barMeter.OnNewJudgement(judgement); + barMeter2.OnNewJudgement(judgement); + colourMeter.OnNewJudgement(judgement); + colourMeter2.OnNewJudgement(judgement); } } } From b61aa660c63f0e126f32643ef17e7bb458d2a1ae Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Sat, 21 Dec 2019 14:52:53 +0300 Subject: [PATCH 14/26] Move colours to HitErrorMeter class --- .../HUD/HitErrorMeters/BarHitErrorMeter.cs | 25 +--------- .../HUD/HitErrorMeters/ColourHitErrorMeter.cs | 46 ++----------------- .../Play/HUD/HitErrorMeters/HitErrorMeter.cs | 30 ++++++++++++ 3 files changed, 37 insertions(+), 64 deletions(-) diff --git a/osu.Game/Screens/Play/HUD/HitErrorMeters/BarHitErrorMeter.cs b/osu.Game/Screens/Play/HUD/HitErrorMeters/BarHitErrorMeter.cs index 03a0f23fb6..208bdd17ad 100644 --- a/osu.Game/Screens/Play/HUD/HitErrorMeters/BarHitErrorMeter.cs +++ b/osu.Game/Screens/Play/HUD/HitErrorMeters/BarHitErrorMeter.cs @@ -163,30 +163,9 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters centre.Width = 2.5f; colourBars.Add(centre); - Color4 getColour(HitResult result) - { - switch (result) - { - case HitResult.Meh: - return colours.Yellow; - - case HitResult.Ok: - return colours.Green; - - case HitResult.Good: - return colours.GreenLight; - - case HitResult.Great: - return colours.Blue; - - default: - return colours.BlueLight; - } - } - Drawable createColourBar(HitResult result, float height, bool first = false) { - var colour = getColour(result); + var colour = GetColourForHitResult(result); if (first) { @@ -201,7 +180,7 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters new Box { RelativeSizeAxes = Axes.Both, - Colour = getColour(result), + Colour = colour, Height = height * gradient_start }, new Box diff --git a/osu.Game/Screens/Play/HUD/HitErrorMeters/ColourHitErrorMeter.cs b/osu.Game/Screens/Play/HUD/HitErrorMeters/ColourHitErrorMeter.cs index 41401a0048..6775b98f84 100644 --- a/osu.Game/Screens/Play/HUD/HitErrorMeters/ColourHitErrorMeter.cs +++ b/osu.Game/Screens/Play/HUD/HitErrorMeters/ColourHitErrorMeter.cs @@ -1,14 +1,13 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; -using osu.Game.Graphics; using osu.Game.Rulesets.Judgements; using osu.Game.Rulesets.Scoring; using osuTK; +using osuTK.Graphics; namespace osu.Game.Screens.Play.HUD.HitErrorMeters { @@ -34,56 +33,21 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters public override void OnNewJudgement(JudgementResult judgement) { - judgementsFlow.Add(new DrawableJudgement(HitWindows.ResultFor(judgement.TimeOffset))); + judgementsFlow.Add(new DrawableJudgement(GetColourForHitResult(HitWindows.ResultFor(judgement.TimeOffset)))); } private class DrawableJudgement : CircularContainer { - private readonly Box background; - private readonly HitResult result; - - public DrawableJudgement(HitResult result) + public DrawableJudgement(Color4 colour) { - this.result = result; - Masking = true; Size = new Vector2(8); - Child = background = new Box + Child = new Box { RelativeSizeAxes = Axes.Both, + Colour = colour }; } - - [BackgroundDependencyLoader] - private void load(OsuColour colours) - { - switch (result) - { - case HitResult.Miss: - background.Colour = colours.Red; - break; - - case HitResult.Meh: - background.Colour = colours.Yellow; - break; - - case HitResult.Ok: - background.Colour = colours.Green; - break; - - case HitResult.Good: - background.Colour = colours.GreenLight; - break; - - case HitResult.Great: - background.Colour = colours.Blue; - break; - - default: - background.Colour = colours.BlueLight; - break; - } - } } } } diff --git a/osu.Game/Screens/Play/HUD/HitErrorMeters/HitErrorMeter.cs b/osu.Game/Screens/Play/HUD/HitErrorMeters/HitErrorMeter.cs index dee25048ed..b3edfdedec 100644 --- a/osu.Game/Screens/Play/HUD/HitErrorMeters/HitErrorMeter.cs +++ b/osu.Game/Screens/Play/HUD/HitErrorMeters/HitErrorMeter.cs @@ -1,9 +1,12 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using osu.Framework.Allocation; using osu.Framework.Graphics.Containers; +using osu.Game.Graphics; using osu.Game.Rulesets.Judgements; using osu.Game.Rulesets.Scoring; +using osuTK.Graphics; namespace osu.Game.Screens.Play.HUD.HitErrorMeters { @@ -11,11 +14,38 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters { protected readonly HitWindows HitWindows; + [Resolved] + private OsuColour colours { get; set; } + protected HitErrorMeter(HitWindows hitWindows) { HitWindows = hitWindows; } public abstract void OnNewJudgement(JudgementResult judgement); + + protected Color4 GetColourForHitResult(HitResult result) + { + switch (result) + { + case HitResult.Miss: + return colours.Red; + + case HitResult.Meh: + return colours.Yellow; + + case HitResult.Ok: + return colours.Green; + + case HitResult.Good: + return colours.GreenLight; + + case HitResult.Great: + return colours.Blue; + + default: + return colours.BlueLight; + } + } } } From 14a77a8f16d849483a59c68cf726e7784966052a Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Sat, 21 Dec 2019 16:08:28 +0300 Subject: [PATCH 15/26] Improve animations --- .../HUD/HitErrorMeters/ColourHitErrorMeter.cs | 83 +++++++++++++++---- 1 file changed, 69 insertions(+), 14 deletions(-) diff --git a/osu.Game/Screens/Play/HUD/HitErrorMeters/ColourHitErrorMeter.cs b/osu.Game/Screens/Play/HUD/HitErrorMeters/ColourHitErrorMeter.cs index 6775b98f84..649f29810e 100644 --- a/osu.Game/Screens/Play/HUD/HitErrorMeters/ColourHitErrorMeter.cs +++ b/osu.Game/Screens/Play/HUD/HitErrorMeters/ColourHitErrorMeter.cs @@ -1,6 +1,10 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using System.Collections.Generic; +using System.Linq; +using osu.Framework.Bindables; +using osu.Framework.Extensions.IEnumerableExtensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; @@ -13,35 +17,86 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters { public class ColourHitErrorMeter : HitErrorMeter { - private const int bar_height = 200; + private const int max_available_judgements = 20; - private readonly FillFlowContainer judgementsFlow; + private readonly JudgementFlow judgementsFlow; + private readonly BindableList<(Color4 colour, JudgementResult result)> judgements = new BindableList<(Color4 colour, JudgementResult result)>(); public ColourHitErrorMeter(HitWindows hitWindows) : base(hitWindows) { AutoSizeAxes = Axes.Both; - InternalChild = judgementsFlow = new FillFlowContainer - { - AutoSizeAxes = Axes.X, - Height = bar_height, - Direction = FillDirection.Vertical, - Spacing = new Vector2(0, 2), - Masking = true, - }; + InternalChild = judgementsFlow = new JudgementFlow(); + } + + protected override void LoadComplete() + { + base.LoadComplete(); + judgementsFlow.Judgements.BindTo(judgements); } public override void OnNewJudgement(JudgementResult judgement) { - judgementsFlow.Add(new DrawableJudgement(GetColourForHitResult(HitWindows.ResultFor(judgement.TimeOffset)))); + judgements.Add((GetColourForHitResult(HitWindows.ResultFor(judgement.TimeOffset)), judgement)); + + if (judgements.Count > max_available_judgements) + judgements.RemoveAt(0); } - private class DrawableJudgement : CircularContainer + private class JudgementFlow : Container { - public DrawableJudgement(Color4 colour) + private const int drawable_judgement_size = 8; + private const int spacing = 2; + private const int animation_duration = 200; + + public readonly BindableList<(Color4 colour, JudgementResult result)> Judgements = new BindableList<(Color4 colour, JudgementResult result)>(); + + public JudgementFlow() { + AutoSizeAxes = Axes.X; + Height = max_available_judgements * (drawable_judgement_size + spacing); + } + + protected override void LoadComplete() + { + base.LoadComplete(); + Judgements.ItemsAdded += push; + Judgements.ItemsRemoved += pop; + } + + private void push(IEnumerable<(Color4 colour, JudgementResult result)> judgements) + { + Children.ForEach(c => c.FinishTransforms()); + + var (colour, result) = judgements.Single(); + var drawableJudgement = new DrawableResult(colour, result, drawable_judgement_size) + { + Alpha = 0, + Y = -(drawable_judgement_size + spacing) + }; + + Add(drawableJudgement); + drawableJudgement.FadeInFromZero(animation_duration, Easing.OutQuint); + + Children.ForEach(c => c.MoveToOffset(new Vector2(0, drawable_judgement_size + spacing), animation_duration, Easing.OutQuint)); + } + + private void pop(IEnumerable<(Color4 colour, JudgementResult result)> judgements) + { + Children.FirstOrDefault(c => c.Result == judgements.Single().result).FadeOut(animation_duration, Easing.OutQuint).Expire(); + } + } + + private class DrawableResult : CircularContainer + { + public JudgementResult Result { get; private set; } + + public DrawableResult(Color4 colour, JudgementResult result, int size) + { + Result = result; + Masking = true; - Size = new Vector2(8); + Size = new Vector2(size); Child = new Box { RelativeSizeAxes = Axes.Both, From 46501cf0ac2984537d8a96b885fc87804d4ece15 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Sun, 22 Dec 2019 03:06:57 +0300 Subject: [PATCH 16/26] Use FillFlowContainer --- .../HUD/HitErrorMeters/ColourHitErrorMeter.cs | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/osu.Game/Screens/Play/HUD/HitErrorMeters/ColourHitErrorMeter.cs b/osu.Game/Screens/Play/HUD/HitErrorMeters/ColourHitErrorMeter.cs index 649f29810e..d730a8d321 100644 --- a/osu.Game/Screens/Play/HUD/HitErrorMeters/ColourHitErrorMeter.cs +++ b/osu.Game/Screens/Play/HUD/HitErrorMeters/ColourHitErrorMeter.cs @@ -4,7 +4,6 @@ using System.Collections.Generic; using System.Linq; using osu.Framework.Bindables; -using osu.Framework.Extensions.IEnumerableExtensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; @@ -43,7 +42,7 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters judgements.RemoveAt(0); } - private class JudgementFlow : Container + private class JudgementFlow : FillFlowContainer { private const int drawable_judgement_size = 8; private const int spacing = 2; @@ -51,10 +50,16 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters public readonly BindableList<(Color4 colour, JudgementResult result)> Judgements = new BindableList<(Color4 colour, JudgementResult result)>(); + private int runningDepth; + public JudgementFlow() { AutoSizeAxes = Axes.X; Height = max_available_judgements * (drawable_judgement_size + spacing); + Spacing = new Vector2(0, spacing); + Direction = FillDirection.Vertical; + LayoutDuration = animation_duration; + LayoutEasing = Easing.OutQuint; } protected override void LoadComplete() @@ -66,24 +71,20 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters private void push(IEnumerable<(Color4 colour, JudgementResult result)> judgements) { - Children.ForEach(c => c.FinishTransforms()); - var (colour, result) = judgements.Single(); var drawableJudgement = new DrawableResult(colour, result, drawable_judgement_size) { Alpha = 0, - Y = -(drawable_judgement_size + spacing) }; - Add(drawableJudgement); + Insert(runningDepth--, drawableJudgement); drawableJudgement.FadeInFromZero(animation_duration, Easing.OutQuint); - - Children.ForEach(c => c.MoveToOffset(new Vector2(0, drawable_judgement_size + spacing), animation_duration, Easing.OutQuint)); } private void pop(IEnumerable<(Color4 colour, JudgementResult result)> judgements) { - Children.FirstOrDefault(c => c.Result == judgements.Single().result).FadeOut(animation_duration, Easing.OutQuint).Expire(); + var (colour, result) = judgements.Single(); + Children.FirstOrDefault(c => c.Result == result).FadeOut(animation_duration, Easing.OutQuint).Expire(); } } From eb75c6c70f342ff84d50b038af92e6873f1d080c Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Sun, 22 Dec 2019 03:17:56 +0300 Subject: [PATCH 17/26] Update FadeIn animation for new judgement --- .../HUD/HitErrorMeters/ColourHitErrorMeter.cs | 33 ++++++++++++------- 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/osu.Game/Screens/Play/HUD/HitErrorMeters/ColourHitErrorMeter.cs b/osu.Game/Screens/Play/HUD/HitErrorMeters/ColourHitErrorMeter.cs index d730a8d321..b76f2c7817 100644 --- a/osu.Game/Screens/Play/HUD/HitErrorMeters/ColourHitErrorMeter.cs +++ b/osu.Game/Screens/Play/HUD/HitErrorMeters/ColourHitErrorMeter.cs @@ -17,6 +17,7 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters public class ColourHitErrorMeter : HitErrorMeter { private const int max_available_judgements = 20; + private const int animation_duration = 200; private readonly JudgementFlow judgementsFlow; private readonly BindableList<(Color4 colour, JudgementResult result)> judgements = new BindableList<(Color4 colour, JudgementResult result)>(); @@ -46,7 +47,6 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters { private const int drawable_judgement_size = 8; private const int spacing = 2; - private const int animation_duration = 200; public readonly BindableList<(Color4 colour, JudgementResult result)> Judgements = new BindableList<(Color4 colour, JudgementResult result)>(); @@ -72,13 +72,7 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters private void push(IEnumerable<(Color4 colour, JudgementResult result)> judgements) { var (colour, result) = judgements.Single(); - var drawableJudgement = new DrawableResult(colour, result, drawable_judgement_size) - { - Alpha = 0, - }; - - Insert(runningDepth--, drawableJudgement); - drawableJudgement.FadeInFromZero(animation_duration, Easing.OutQuint); + Insert(runningDepth--, new DrawableResult(colour, result, drawable_judgement_size)); } private void pop(IEnumerable<(Color4 colour, JudgementResult result)> judgements) @@ -88,22 +82,37 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters } } - private class DrawableResult : CircularContainer + private class DrawableResult : Container { public JudgementResult Result { get; private set; } + private readonly CircularContainer content; + public DrawableResult(Color4 colour, JudgementResult result, int size) { Result = result; - Masking = true; Size = new Vector2(size); - Child = new Box + Child = content = new CircularContainer { RelativeSizeAxes = Axes.Both, - Colour = colour + Masking = true, + Alpha = 0, + Child = new Box + { + RelativeSizeAxes = Axes.Both, + Colour = colour + }, }; } + + protected override void LoadComplete() + { + base.LoadComplete(); + content.FadeInFromZero(animation_duration, Easing.OutQuint); + content.MoveToY(-DrawSize.Y); + content.MoveToY(0, animation_duration, Easing.OutQuint); + } } } } From aded12af9e157ea0535dfbf8da48ed7fe3a8c2f0 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Sun, 22 Dec 2019 03:30:17 +0300 Subject: [PATCH 18/26] Refactoor to avoid bindable usage --- .../HUD/HitErrorMeters/ColourHitErrorMeter.cs | 54 ++++++------------- 1 file changed, 15 insertions(+), 39 deletions(-) diff --git a/osu.Game/Screens/Play/HUD/HitErrorMeters/ColourHitErrorMeter.cs b/osu.Game/Screens/Play/HUD/HitErrorMeters/ColourHitErrorMeter.cs index b76f2c7817..196eb23da6 100644 --- a/osu.Game/Screens/Play/HUD/HitErrorMeters/ColourHitErrorMeter.cs +++ b/osu.Game/Screens/Play/HUD/HitErrorMeters/ColourHitErrorMeter.cs @@ -1,9 +1,7 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -using System.Collections.Generic; using System.Linq; -using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; @@ -16,11 +14,9 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters { public class ColourHitErrorMeter : HitErrorMeter { - private const int max_available_judgements = 20; private const int animation_duration = 200; private readonly JudgementFlow judgementsFlow; - private readonly BindableList<(Color4 colour, JudgementResult result)> judgements = new BindableList<(Color4 colour, JudgementResult result)>(); public ColourHitErrorMeter(HitWindows hitWindows) : base(hitWindows) @@ -29,69 +25,43 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters InternalChild = judgementsFlow = new JudgementFlow(); } - protected override void LoadComplete() - { - base.LoadComplete(); - judgementsFlow.Judgements.BindTo(judgements); - } - - public override void OnNewJudgement(JudgementResult judgement) - { - judgements.Add((GetColourForHitResult(HitWindows.ResultFor(judgement.TimeOffset)), judgement)); - - if (judgements.Count > max_available_judgements) - judgements.RemoveAt(0); - } + public override void OnNewJudgement(JudgementResult judgement) => judgementsFlow.Push(GetColourForHitResult(HitWindows.ResultFor(judgement.TimeOffset))); private class JudgementFlow : FillFlowContainer { + private const int max_available_judgements = 20; private const int drawable_judgement_size = 8; private const int spacing = 2; - public readonly BindableList<(Color4 colour, JudgementResult result)> Judgements = new BindableList<(Color4 colour, JudgementResult result)>(); - private int runningDepth; public JudgementFlow() { AutoSizeAxes = Axes.X; - Height = max_available_judgements * (drawable_judgement_size + spacing); + Height = max_available_judgements * (drawable_judgement_size + spacing) - spacing; Spacing = new Vector2(0, spacing); Direction = FillDirection.Vertical; LayoutDuration = animation_duration; LayoutEasing = Easing.OutQuint; } - protected override void LoadComplete() + public void Push(Color4 colour) { - base.LoadComplete(); - Judgements.ItemsAdded += push; - Judgements.ItemsRemoved += pop; - } + Insert(runningDepth--, new DrawableResult(colour, drawable_judgement_size)); - private void push(IEnumerable<(Color4 colour, JudgementResult result)> judgements) - { - var (colour, result) = judgements.Single(); - Insert(runningDepth--, new DrawableResult(colour, result, drawable_judgement_size)); - } - - private void pop(IEnumerable<(Color4 colour, JudgementResult result)> judgements) - { - var (colour, result) = judgements.Single(); - Children.FirstOrDefault(c => c.Result == result).FadeOut(animation_duration, Easing.OutQuint).Expire(); + if (Children.Count > max_available_judgements) + Children.FirstOrDefault(c => !c.IsRemoved).Remove(); } } private class DrawableResult : Container { - public JudgementResult Result { get; private set; } + public bool IsRemoved { get; private set; } private readonly CircularContainer content; - public DrawableResult(Color4 colour, JudgementResult result, int size) + public DrawableResult(Color4 colour, int size) { - Result = result; - Size = new Vector2(size); Child = content = new CircularContainer { @@ -113,6 +83,12 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters content.MoveToY(-DrawSize.Y); content.MoveToY(0, animation_duration, Easing.OutQuint); } + + public void Remove() + { + IsRemoved = true; + this.FadeOut(animation_duration, Easing.OutQuint).Expire(); + } } } } From 7a0d76ae77e5b830f158dcde6bfdb80797165e70 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Sun, 22 Dec 2019 03:41:19 +0300 Subject: [PATCH 19/26] Fix nullref --- osu.Game/Screens/Play/HUD/HitErrorMeters/ColourHitErrorMeter.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Screens/Play/HUD/HitErrorMeters/ColourHitErrorMeter.cs b/osu.Game/Screens/Play/HUD/HitErrorMeters/ColourHitErrorMeter.cs index 196eb23da6..d18f6f3743 100644 --- a/osu.Game/Screens/Play/HUD/HitErrorMeters/ColourHitErrorMeter.cs +++ b/osu.Game/Screens/Play/HUD/HitErrorMeters/ColourHitErrorMeter.cs @@ -50,7 +50,7 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters Insert(runningDepth--, new DrawableResult(colour, drawable_judgement_size)); if (Children.Count > max_available_judgements) - Children.FirstOrDefault(c => !c.IsRemoved).Remove(); + Children.FirstOrDefault(c => !c.IsRemoved)?.Remove(); } } From 6493f24547bd1eae1ecbfce3edb13f4ac0612d80 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Thu, 23 Jan 2020 15:56:01 +0300 Subject: [PATCH 20/26] Add TotalCommentsCounter to CommentsContainer --- osu.Game/Overlays/Comments/CommentsContainer.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/osu.Game/Overlays/Comments/CommentsContainer.cs b/osu.Game/Overlays/Comments/CommentsContainer.cs index 9f1d9d9488..433af5fb4e 100644 --- a/osu.Game/Overlays/Comments/CommentsContainer.cs +++ b/osu.Game/Overlays/Comments/CommentsContainer.cs @@ -38,6 +38,7 @@ namespace osu.Game.Overlays.Comments private readonly FillFlowContainer content; private readonly DeletedChildrenPlaceholder deletedChildrenPlaceholder; private readonly CommentsShowMoreButton moreButton; + private readonly TotalCommentsCounter commentCounter; public CommentsContainer() { @@ -56,6 +57,7 @@ namespace osu.Game.Overlays.Comments Direction = FillDirection.Vertical, Children = new Drawable[] { + commentCounter = new TotalCommentsCounter(), new CommentsHeader { Sort = { BindTarget = Sort }, @@ -133,6 +135,7 @@ namespace osu.Game.Overlays.Comments if (!IsLoaded) return; + commentCounter.Current.Value = 0; refetchComments(); } @@ -199,6 +202,8 @@ namespace osu.Game.Overlays.Comments moreButton.IsLoading = false; } + commentCounter.Current.Value = response.Total; + moreButton.FadeTo(response.HasMore ? 1 : 0); }, loadCancellation.Token); } From 5863576ce49721bb0cad638dfdeedb997c95fa48 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 24 Jan 2020 11:42:33 +0900 Subject: [PATCH 21/26] Add comment as to why counter is zeroes only in Show method --- osu.Game/Overlays/Comments/CommentsContainer.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/osu.Game/Overlays/Comments/CommentsContainer.cs b/osu.Game/Overlays/Comments/CommentsContainer.cs index 433af5fb4e..d252083411 100644 --- a/osu.Game/Overlays/Comments/CommentsContainer.cs +++ b/osu.Game/Overlays/Comments/CommentsContainer.cs @@ -135,7 +135,9 @@ namespace osu.Game.Overlays.Comments if (!IsLoaded) return; + // only reset when changing ID/type. other refetch ops are generally just changing sort order. commentCounter.Current.Value = 0; + refetchComments(); } From 851b89128559aee63f81b6dbccfa0f50e0f5dc66 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 24 Jan 2020 11:52:32 +0900 Subject: [PATCH 22/26] Fix incorrect insert logic --- .../Screens/Play/HUD/HitErrorMeters/ColourHitErrorMeter.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/osu.Game/Screens/Play/HUD/HitErrorMeters/ColourHitErrorMeter.cs b/osu.Game/Screens/Play/HUD/HitErrorMeters/ColourHitErrorMeter.cs index d18f6f3743..f06f6938a2 100644 --- a/osu.Game/Screens/Play/HUD/HitErrorMeters/ColourHitErrorMeter.cs +++ b/osu.Game/Screens/Play/HUD/HitErrorMeters/ColourHitErrorMeter.cs @@ -1,6 +1,7 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using System.Collections.Generic; using System.Linq; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -33,7 +34,7 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters private const int drawable_judgement_size = 8; private const int spacing = 2; - private int runningDepth; + public override IEnumerable FlowingChildren => base.FlowingChildren.Reverse(); public JudgementFlow() { @@ -47,7 +48,7 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters public void Push(Color4 colour) { - Insert(runningDepth--, new DrawableResult(colour, drawable_judgement_size)); + Add(new DrawableResult(colour, drawable_judgement_size)); if (Children.Count > max_available_judgements) Children.FirstOrDefault(c => !c.IsRemoved)?.Remove(); From eb5abcab8c129a47f11a56f178e32f50d4a6c8aa Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 24 Jan 2020 11:54:48 +0900 Subject: [PATCH 23/26] Rename and simplify circle logic --- .../HUD/HitErrorMeters/ColourHitErrorMeter.cs | 27 +++++++++---------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/osu.Game/Screens/Play/HUD/HitErrorMeters/ColourHitErrorMeter.cs b/osu.Game/Screens/Play/HUD/HitErrorMeters/ColourHitErrorMeter.cs index f06f6938a2..657235bfd4 100644 --- a/osu.Game/Screens/Play/HUD/HitErrorMeters/ColourHitErrorMeter.cs +++ b/osu.Game/Screens/Play/HUD/HitErrorMeters/ColourHitErrorMeter.cs @@ -28,7 +28,7 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters public override void OnNewJudgement(JudgementResult judgement) => judgementsFlow.Push(GetColourForHitResult(HitWindows.ResultFor(judgement.TimeOffset))); - private class JudgementFlow : FillFlowContainer + private class JudgementFlow : FillFlowContainer { private const int max_available_judgements = 20; private const int drawable_judgement_size = 8; @@ -48,46 +48,43 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters public void Push(Color4 colour) { - Add(new DrawableResult(colour, drawable_judgement_size)); + Add(new HitErrorCircle(colour, drawable_judgement_size)); if (Children.Count > max_available_judgements) Children.FirstOrDefault(c => !c.IsRemoved)?.Remove(); } } - private class DrawableResult : Container + private class HitErrorCircle : Container { public bool IsRemoved { get; private set; } - private readonly CircularContainer content; + private readonly Circle circle; - public DrawableResult(Color4 colour, int size) + public HitErrorCircle(Color4 colour, int size) { Size = new Vector2(size); - Child = content = new CircularContainer + Child = circle = new Circle { RelativeSizeAxes = Axes.Both, - Masking = true, Alpha = 0, - Child = new Box - { - RelativeSizeAxes = Axes.Both, - Colour = colour - }, + Colour = colour }; } protected override void LoadComplete() { base.LoadComplete(); - content.FadeInFromZero(animation_duration, Easing.OutQuint); - content.MoveToY(-DrawSize.Y); - content.MoveToY(0, animation_duration, Easing.OutQuint); + + circle.FadeInFromZero(animation_duration, Easing.OutQuint); + circle.MoveToY(-DrawSize.Y); + circle.MoveToY(0, animation_duration, Easing.OutQuint); } public void Remove() { IsRemoved = true; + this.FadeOut(animation_duration, Easing.OutQuint).Expire(); } } From e4702ffe9ef809a966fdc519c4039ce9ee076f06 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 24 Jan 2020 13:10:02 +0900 Subject: [PATCH 24/26] Fix editor rate adjustment polluting global beatmap rate --- .../Screens/Edit/Components/PlaybackControl.cs | 17 +++++++++++++---- osu.Game/Screens/Edit/Editor.cs | 9 ++------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/osu.Game/Screens/Edit/Components/PlaybackControl.cs b/osu.Game/Screens/Edit/Components/PlaybackControl.cs index 62d6c4648b..66df68418a 100644 --- a/osu.Game/Screens/Edit/Components/PlaybackControl.cs +++ b/osu.Game/Screens/Edit/Components/PlaybackControl.cs @@ -5,6 +5,8 @@ using System.Linq; using osuTK; using osuTK.Graphics; using osu.Framework.Allocation; +using osu.Framework.Audio; +using osu.Framework.Bindables; using osu.Framework.Extensions.IEnumerableExtensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -25,13 +27,13 @@ namespace osu.Game.Screens.Edit.Components private IAdjustableClock adjustableClock; + private readonly BindableNumber tempo = new BindableDouble(1); + [BackgroundDependencyLoader] private void load(IAdjustableClock adjustableClock) { this.adjustableClock = adjustableClock; - PlaybackTabControl tabs; - Children = new Drawable[] { playButton = new IconButton @@ -58,11 +60,18 @@ namespace osu.Game.Screens.Edit.Components RelativeSizeAxes = Axes.Both, Height = 0.5f, Padding = new MarginPadding { Left = 45 }, - Child = tabs = new PlaybackTabControl(), + Child = new PlaybackTabControl { Current = tempo }, } }; - tabs.Current.ValueChanged += tempo => Beatmap.Value.Track.Tempo.Value = tempo.NewValue; + Track?.AddAdjustment(AdjustableProperty.Tempo, tempo); + } + + protected override void Dispose(bool isDisposing) + { + Track?.RemoveAdjustment(AdjustableProperty.Tempo, tempo); + + base.Dispose(isDisposing); } protected override bool OnKeyDown(KeyDownEvent e) diff --git a/osu.Game/Screens/Edit/Editor.cs b/osu.Game/Screens/Edit/Editor.cs index 8d66cef16e..eae94a3c8e 100644 --- a/osu.Game/Screens/Edit/Editor.cs +++ b/osu.Game/Screens/Edit/Editor.cs @@ -46,6 +46,8 @@ namespace osu.Game.Screens.Edit public override bool DisallowExternalBeatmapRulesetChanges => true; + public override bool AllowRateAdjustments => false; + [Resolved] private BeatmapManager beatmapManager { get; set; } @@ -262,12 +264,6 @@ namespace osu.Game.Screens.Edit { } - public override void OnResuming(IScreen last) - { - base.OnResuming(last); - Beatmap.Value.Track?.Stop(); - } - public override void OnEntering(IScreen last) { base.OnEntering(last); @@ -291,7 +287,6 @@ namespace osu.Game.Screens.Edit private void resetTrack(bool seekToStart = false) { - Beatmap.Value.Track?.ResetSpeedAdjustments(); Beatmap.Value.Track?.Stop(); if (seekToStart) From 997b49f6dc872f0104a9680665b5dbb92c67c91f Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 24 Jan 2020 14:21:22 +0900 Subject: [PATCH 25/26] Change display to always show progress bar, only hiding seeking handle instead --- .../Visual/Gameplay/TestSceneSongProgress.cs | 3 +++ osu.Game/Screens/Play/HUDOverlay.cs | 1 - osu.Game/Screens/Play/SongProgress.cs | 8 +++---- osu.Game/Screens/Play/SongProgressBar.cs | 23 ++++++++++++++++++- 4 files changed, 29 insertions(+), 6 deletions(-) diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneSongProgress.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneSongProgress.cs index 0996b5b0c7..ff14846b68 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneSongProgress.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneSongProgress.cs @@ -6,6 +6,9 @@ using System.Collections.Generic; using NUnit.Framework; using osu.Framework.Allocation; using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Shapes; +using osu.Framework.Testing; using osu.Framework.Utils; using osu.Framework.Timing; using osu.Game.Graphics; diff --git a/osu.Game/Screens/Play/HUDOverlay.cs b/osu.Game/Screens/Play/HUDOverlay.cs index 236bdc8442..a5f8051557 100644 --- a/osu.Game/Screens/Play/HUDOverlay.cs +++ b/osu.Game/Screens/Play/HUDOverlay.cs @@ -131,7 +131,6 @@ namespace osu.Game.Screens.Play BindDrawableRuleset(drawableRuleset); Progress.Objects = drawableRuleset.Objects; - Progress.AllowSeeking = drawableRuleset.HasReplayLoaded.Value; Progress.RequestSeek = time => RequestSeek(time); Progress.ReferenceClock = drawableRuleset.FrameStableClock; } diff --git a/osu.Game/Screens/Play/SongProgress.cs b/osu.Game/Screens/Play/SongProgress.cs index 1368158938..aa745f5ba2 100644 --- a/osu.Game/Screens/Play/SongProgress.cs +++ b/osu.Game/Screens/Play/SongProgress.cs @@ -46,7 +46,6 @@ namespace osu.Game.Screens.Play public override bool HandlePositionalInput => AllowSeeking.Value; private double firstHitTime => objects.First().StartTime; - private double lastHitTime => ((objects.Last() as IHasEndTime)?.EndTime ?? objects.Last().StartTime) + 1; private IEnumerable objects; @@ -92,7 +91,6 @@ namespace osu.Game.Screens.Play }, bar = new SongProgressBar(bottom_bar_height, graph_height, handle_size) { - Alpha = 0, Anchor = Anchor.BottomLeft, Origin = Anchor.BottomLeft, OnSeek = time => RequestSeek?.Invoke(time), @@ -105,6 +103,9 @@ namespace osu.Game.Screens.Play { base.LoadComplete(); + if (clock != null) + gameplayClock = clock; + config.BindWith(OsuSetting.ShowProgressGraph, ShowGraph); graph.FillColour = bar.FillColour = colours.BlueLighter; @@ -151,8 +152,7 @@ namespace osu.Game.Screens.Play private void updateBarVisibility() { - bar.FadeTo(AllowSeeking.Value ? 1 : 0, transition_duration, Easing.In); - this.MoveTo(new Vector2(0, AllowSeeking.Value ? 0 : bottom_bar_height), transition_duration, Easing.In); + bar.ShowHandle = AllowSeeking.Value; updateInfoMargin(); } diff --git a/osu.Game/Screens/Play/SongProgressBar.cs b/osu.Game/Screens/Play/SongProgressBar.cs index 817b703fca..5052b32335 100644 --- a/osu.Game/Screens/Play/SongProgressBar.cs +++ b/osu.Game/Screens/Play/SongProgressBar.cs @@ -21,6 +21,22 @@ namespace osu.Game.Screens.Play private readonly Container handleBase; private readonly Container handleContainer; + private bool showHandle; + + public bool ShowHandle + { + get => showHandle; + set + { + if (value == showHandle) + return; + + showHandle = value; + + handleBase.FadeTo(showHandle ? 1 : 0, 200); + } + } + public Color4 FillColour { set => fill.Colour = value; @@ -75,6 +91,7 @@ namespace osu.Game.Screens.Play Origin = Anchor.BottomLeft, Anchor = Anchor.BottomLeft, Width = 2, + Alpha = 0, Colour = Color4.White, Position = new Vector2(2, 0), Children = new Drawable[] @@ -128,7 +145,11 @@ namespace osu.Game.Screens.Play protected override void OnUserChange(double value) { scheduledSeek?.Cancel(); - scheduledSeek = Schedule(() => OnSeek?.Invoke(value)); + scheduledSeek = Schedule(() => + { + if (showHandle) + OnSeek?.Invoke(value); + }); } } } From 2187dbd0c28b43684842593aa6f4f3b9427294d6 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 24 Jan 2020 14:37:37 +0900 Subject: [PATCH 26/26] Rename steps in test for clarity --- osu.Game.Tests/Visual/Gameplay/TestSceneSongProgress.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneSongProgress.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneSongProgress.cs index ff14846b68..b9b13d7bd8 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneSongProgress.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneSongProgress.cs @@ -111,10 +111,10 @@ namespace osu.Game.Tests.Visual.Gameplay AddStep("display max values", displayMaxValues); AddUntilStep("wait for graph", () => graph.CreationCount == 1); AddStep("start", clock.Start); - AddStep("show bar", () => progress.AllowSeeking.Value = true); + AddStep("allow seeking", () => progress.AllowSeeking.Value = true); AddStep("hide graph", () => progress.ShowGraph.Value = false); - AddStep("hide Bar", () => progress.AllowSeeking.Value = false); - AddStep("show bar", () => progress.AllowSeeking.Value = true); + AddStep("disallow seeking", () => progress.AllowSeeking.Value = false); + AddStep("allow seeking", () => progress.AllowSeeking.Value = true); AddStep("show graph", () => progress.ShowGraph.Value = true); AddStep("stop", clock.Stop); }