From b9adeeb063400477e53e093438c51fb9714d9786 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Thu, 10 May 2018 21:35:26 -0300 Subject: [PATCH 01/11] Add ScreenBreadcrumbControl. --- .../Visual/TestCaseScreenBreadcrumbs.cs | 108 ++++++++++++++++++ .../UserInterface/ScreenBreadcrumbControl.cs | 78 +++++++++++++ 2 files changed, 186 insertions(+) create mode 100644 osu.Game.Tests/Visual/TestCaseScreenBreadcrumbs.cs create mode 100644 osu.Game/Graphics/UserInterface/ScreenBreadcrumbControl.cs diff --git a/osu.Game.Tests/Visual/TestCaseScreenBreadcrumbs.cs b/osu.Game.Tests/Visual/TestCaseScreenBreadcrumbs.cs new file mode 100644 index 0000000000..5055b0e114 --- /dev/null +++ b/osu.Game.Tests/Visual/TestCaseScreenBreadcrumbs.cs @@ -0,0 +1,108 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using NUnit.Framework; +using osu.Framework.Allocation; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Game.Graphics; +using osu.Game.Graphics.Sprites; +using osu.Game.Graphics.UserInterface; +using osu.Game.Screens; +using OpenTK; + +namespace osu.Game.Tests.Visual +{ + [TestFixture] + public class TestCaseScreenBreadcrumbs : OsuTestCase + { + private readonly ScreenBreadcrumbControl breadcrumbs; + + public TestCaseScreenBreadcrumbs() + { + TestScreen startScreen; + OsuSpriteText titleText; + + Children = new Drawable[] + { + new FillFlowContainer + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Direction = FillDirection.Vertical, + Spacing = new Vector2(10), + Children = new Drawable[] + { + breadcrumbs = new ScreenBreadcrumbControl + { + RelativeSizeAxes = Axes.X, + }, + titleText = new OsuSpriteText(), + }, + }, + startScreen = new TestScreenOne(), + }; + + breadcrumbs.OnScreenChanged += s => titleText.Text = $"Changed to {s.ToString()}"; + breadcrumbs.CurrentScreen = startScreen; + } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + breadcrumbs.StripColour = colours.Blue; + } + + private abstract class TestScreen : OsuScreen + { + protected abstract string Title { get; } + protected abstract string NextTitle { get; } + protected abstract TestScreen CreateNextScreen(); + + public override string ToString() => Title; + + protected TestScreen() + { + Child = new FillFlowContainer + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + AutoSizeAxes = Axes.Both, + Direction = FillDirection.Vertical, + Spacing = new Vector2(10), + Children = new Drawable[] + { + new OsuSpriteText + { + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, + Text = Title, + }, + new TriangleButton + { + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, + Width = 100, + Text = $"Push {NextTitle}", + Action = () => Push(CreateNextScreen()), + }, + }, + }; + } + } + + private class TestScreenOne : TestScreen + { + protected override string Title => @"Screen One"; + protected override string NextTitle => @"Two"; + protected override TestScreen CreateNextScreen() => new TestScreenTwo(); + } + + private class TestScreenTwo : TestScreen + { + protected override string Title => @"Screen Two"; + protected override string NextTitle => @"One"; + protected override TestScreen CreateNextScreen() => new TestScreenOne(); + } + } +} diff --git a/osu.Game/Graphics/UserInterface/ScreenBreadcrumbControl.cs b/osu.Game/Graphics/UserInterface/ScreenBreadcrumbControl.cs new file mode 100644 index 0000000000..fbdb27a81c --- /dev/null +++ b/osu.Game/Graphics/UserInterface/ScreenBreadcrumbControl.cs @@ -0,0 +1,78 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System; +using System.Linq; +using osu.Framework.Extensions.IEnumerableExtensions; +using osu.Framework.Screens; + +namespace osu.Game.Graphics.UserInterface +{ + public class ScreenBreadcrumbControl : ScreenBreadcrumbControl + { + } + + public class ScreenBreadcrumbControl : BreadcrumbControl where T : Screen + { + private T currentScreen; + public T CurrentScreen + { + get { return currentScreen; } + set + { + if (value == currentScreen) return; + + if (CurrentScreen != null) + { + CurrentScreen.Exited -= onExited; + CurrentScreen.ModePushed -= onPushed; + } + else + { + // this is the first screen in the stack, so call the initial onPushed + currentScreen = value; + onPushed(CurrentScreen); + } + + currentScreen = value; + + if (CurrentScreen != null) + { + CurrentScreen.Exited += onExited; + CurrentScreen.ModePushed += onPushed; + Current.Value = CurrentScreen; + OnScreenChanged?.Invoke(CurrentScreen); + } + } + } + + public event Action OnScreenChanged; + + public ScreenBreadcrumbControl() + { + Current.ValueChanged += s => + { + if (s != CurrentScreen) + { + CurrentScreen = s; + s.MakeCurrent(); + } + }; + } + + private void onExited(Screen screen) + { + CurrentScreen = screen as T; + } + + private void onPushed(Screen screen) + { + var newScreen = screen as T; + + Items.ToList().SkipWhile(i => i != Current.Value).Skip(1).ForEach(RemoveItem); + AddItem(newScreen); + + CurrentScreen = newScreen; + } + } +} From a294f187ee90a187604d7e3788842f46c2e592fe Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Thu, 10 May 2018 21:52:26 -0300 Subject: [PATCH 02/11] Add steps and asserts to TestCaseScreenBreadcrumbs. --- .../Visual/TestCaseScreenBreadcrumbs.cs | 38 +++++++++++++++++-- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/osu.Game.Tests/Visual/TestCaseScreenBreadcrumbs.cs b/osu.Game.Tests/Visual/TestCaseScreenBreadcrumbs.cs index 5055b0e114..6bb6b09746 100644 --- a/osu.Game.Tests/Visual/TestCaseScreenBreadcrumbs.cs +++ b/osu.Game.Tests/Visual/TestCaseScreenBreadcrumbs.cs @@ -17,6 +17,7 @@ namespace osu.Game.Tests.Visual public class TestCaseScreenBreadcrumbs : OsuTestCase { private readonly ScreenBreadcrumbControl breadcrumbs; + private TestScreen currentScreen, changedScreen = null; public TestCaseScreenBreadcrumbs() { @@ -40,11 +41,29 @@ namespace osu.Game.Tests.Visual titleText = new OsuSpriteText(), }, }, - startScreen = new TestScreenOne(), + currentScreen = startScreen = new TestScreenOne(), }; - breadcrumbs.OnScreenChanged += s => titleText.Text = $"Changed to {s.ToString()}"; - breadcrumbs.CurrentScreen = startScreen; + breadcrumbs.OnScreenChanged += s => + { + titleText.Text = $"Changed to {s.ToString()}"; + changedScreen = s; + }; + + AddStep(@"make start current", () => breadcrumbs.CurrentScreen = startScreen); + assertCurrent(); + pushNext(); + assertCurrent(); + pushNext(); + assertCurrent(); + + AddStep(@"make start current", () => + { + startScreen.MakeCurrent(); + currentScreen = startScreen; + }); + + assertCurrent(); } [BackgroundDependencyLoader] @@ -53,6 +72,9 @@ namespace osu.Game.Tests.Visual breadcrumbs.StripColour = colours.Blue; } + private void pushNext() => AddStep(@"push next screen", () => currentScreen = currentScreen.PushNext()); + private void assertCurrent() => AddAssert(@"assert the current screen is correct", () => currentScreen == changedScreen); + private abstract class TestScreen : OsuScreen { protected abstract string Title { get; } @@ -61,6 +83,14 @@ namespace osu.Game.Tests.Visual public override string ToString() => Title; + public TestScreen PushNext() + { + TestScreen screen = CreateNextScreen(); + Push(screen); + + return screen; + } + protected TestScreen() { Child = new FillFlowContainer @@ -84,7 +114,7 @@ namespace osu.Game.Tests.Visual Origin = Anchor.TopCentre, Width = 100, Text = $"Push {NextTitle}", - Action = () => Push(CreateNextScreen()), + Action = () => PushNext(), }, }, }; From 6f7d0c19efe10356d91a243a08d13ed01112a2a0 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Thu, 10 May 2018 22:02:22 -0300 Subject: [PATCH 03/11] Remove redundant default value. --- osu.Game.Tests/Visual/TestCaseScreenBreadcrumbs.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Tests/Visual/TestCaseScreenBreadcrumbs.cs b/osu.Game.Tests/Visual/TestCaseScreenBreadcrumbs.cs index 6bb6b09746..3e0dd9e018 100644 --- a/osu.Game.Tests/Visual/TestCaseScreenBreadcrumbs.cs +++ b/osu.Game.Tests/Visual/TestCaseScreenBreadcrumbs.cs @@ -17,7 +17,7 @@ namespace osu.Game.Tests.Visual public class TestCaseScreenBreadcrumbs : OsuTestCase { private readonly ScreenBreadcrumbControl breadcrumbs; - private TestScreen currentScreen, changedScreen = null; + private TestScreen currentScreen, changedScreen; public TestCaseScreenBreadcrumbs() { From fa403e4e2ae4a2a0ad36f5f2261239093994c2d3 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Fri, 11 May 2018 04:45:27 -0300 Subject: [PATCH 04/11] Add test step to test pushing after a previous screen is made current. --- osu.Game.Tests/Visual/TestCaseScreenBreadcrumbs.cs | 3 +++ osu.Game/Graphics/UserInterface/BreadcrumbControl.cs | 1 + 2 files changed, 4 insertions(+) diff --git a/osu.Game.Tests/Visual/TestCaseScreenBreadcrumbs.cs b/osu.Game.Tests/Visual/TestCaseScreenBreadcrumbs.cs index 3e0dd9e018..f477a0b97e 100644 --- a/osu.Game.Tests/Visual/TestCaseScreenBreadcrumbs.cs +++ b/osu.Game.Tests/Visual/TestCaseScreenBreadcrumbs.cs @@ -1,6 +1,7 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System.Linq; using NUnit.Framework; using osu.Framework.Allocation; using osu.Framework.Graphics; @@ -64,6 +65,8 @@ namespace osu.Game.Tests.Visual }); assertCurrent(); + pushNext(); + AddAssert(@"assert there are only 2 items", () => breadcrumbs.Items.Count() == 2); } [BackgroundDependencyLoader] diff --git a/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs b/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs index 3f59eeca97..6b7f235b34 100644 --- a/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs +++ b/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs @@ -47,6 +47,7 @@ namespace osu.Game.Graphics.UserInterface public override bool HandleKeyboardInput => State == Visibility.Visible; public override bool HandleMouseInput => State == Visibility.Visible; + public override bool IsRemovable => true; private Visibility state; From 0325b1bd7ac7b9b0af4bc9f2bd210bfe00aa12bf Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 15 May 2018 19:42:30 +0900 Subject: [PATCH 05/11] Remove unused class --- osu.Game/Graphics/UserInterface/ScreenBreadcrumbControl.cs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/ScreenBreadcrumbControl.cs b/osu.Game/Graphics/UserInterface/ScreenBreadcrumbControl.cs index fbdb27a81c..ae03a06b4f 100644 --- a/osu.Game/Graphics/UserInterface/ScreenBreadcrumbControl.cs +++ b/osu.Game/Graphics/UserInterface/ScreenBreadcrumbControl.cs @@ -8,10 +8,6 @@ using osu.Framework.Screens; namespace osu.Game.Graphics.UserInterface { - public class ScreenBreadcrumbControl : ScreenBreadcrumbControl - { - } - public class ScreenBreadcrumbControl : BreadcrumbControl where T : Screen { private T currentScreen; From 28df77e83887d2eae75454bdd6de5b3a8afca46a Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 15 May 2018 21:08:55 +0900 Subject: [PATCH 06/11] Simplify code and remove generic --- ....cs => TestCaseScreenBreadcrumbControl.cs} | 18 ++--- .../UserInterface/ScreenBreadcrumbControl.cs | 75 +++++++------------ 2 files changed, 36 insertions(+), 57 deletions(-) rename osu.Game.Tests/Visual/{TestCaseScreenBreadcrumbs.cs => TestCaseScreenBreadcrumbControl.cs} (89%) diff --git a/osu.Game.Tests/Visual/TestCaseScreenBreadcrumbs.cs b/osu.Game.Tests/Visual/TestCaseScreenBreadcrumbControl.cs similarity index 89% rename from osu.Game.Tests/Visual/TestCaseScreenBreadcrumbs.cs rename to osu.Game.Tests/Visual/TestCaseScreenBreadcrumbControl.cs index f477a0b97e..a64e60dbd6 100644 --- a/osu.Game.Tests/Visual/TestCaseScreenBreadcrumbs.cs +++ b/osu.Game.Tests/Visual/TestCaseScreenBreadcrumbControl.cs @@ -6,6 +6,7 @@ using NUnit.Framework; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; +using osu.Framework.Screens; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; using osu.Game.Graphics.UserInterface; @@ -15,18 +16,19 @@ using OpenTK; namespace osu.Game.Tests.Visual { [TestFixture] - public class TestCaseScreenBreadcrumbs : OsuTestCase + public class TestCaseScreenBreadcrumbControl : OsuTestCase { - private readonly ScreenBreadcrumbControl breadcrumbs; - private TestScreen currentScreen, changedScreen; + private readonly ScreenBreadcrumbControl breadcrumbs; + private Screen currentScreen, changedScreen; - public TestCaseScreenBreadcrumbs() + public TestCaseScreenBreadcrumbControl() { TestScreen startScreen; OsuSpriteText titleText; Children = new Drawable[] { + changedScreen = currentScreen = startScreen = new TestScreenOne(), new FillFlowContainer { RelativeSizeAxes = Axes.X, @@ -35,23 +37,21 @@ namespace osu.Game.Tests.Visual Spacing = new Vector2(10), Children = new Drawable[] { - breadcrumbs = new ScreenBreadcrumbControl + breadcrumbs = new ScreenBreadcrumbControl(startScreen) { RelativeSizeAxes = Axes.X, }, titleText = new OsuSpriteText(), }, }, - currentScreen = startScreen = new TestScreenOne(), }; - breadcrumbs.OnScreenChanged += s => + breadcrumbs.Current.ValueChanged += s => { titleText.Text = $"Changed to {s.ToString()}"; changedScreen = s; }; - AddStep(@"make start current", () => breadcrumbs.CurrentScreen = startScreen); assertCurrent(); pushNext(); assertCurrent(); @@ -75,7 +75,7 @@ namespace osu.Game.Tests.Visual breadcrumbs.StripColour = colours.Blue; } - private void pushNext() => AddStep(@"push next screen", () => currentScreen = currentScreen.PushNext()); + private void pushNext() => AddStep(@"push next screen", () => currentScreen = ((TestScreen)currentScreen).PushNext()); private void assertCurrent() => AddAssert(@"assert the current screen is correct", () => currentScreen == changedScreen); private abstract class TestScreen : OsuScreen diff --git a/osu.Game/Graphics/UserInterface/ScreenBreadcrumbControl.cs b/osu.Game/Graphics/UserInterface/ScreenBreadcrumbControl.cs index ae03a06b4f..49d854ccd2 100644 --- a/osu.Game/Graphics/UserInterface/ScreenBreadcrumbControl.cs +++ b/osu.Game/Graphics/UserInterface/ScreenBreadcrumbControl.cs @@ -8,67 +8,46 @@ using osu.Framework.Screens; namespace osu.Game.Graphics.UserInterface { - public class ScreenBreadcrumbControl : BreadcrumbControl where T : Screen + /// + /// A which follows the active screen (and allows navigation) in a stack. + /// + public class ScreenBreadcrumbControl : BreadcrumbControl { - private T currentScreen; - public T CurrentScreen + private Screen last; + + public ScreenBreadcrumbControl(Screen initialScreen) { - get { return currentScreen; } - set + Current.ValueChanged += newScreen => { - if (value == currentScreen) return; - - if (CurrentScreen != null) - { - CurrentScreen.Exited -= onExited; - CurrentScreen.ModePushed -= onPushed; - } - else - { - // this is the first screen in the stack, so call the initial onPushed - currentScreen = value; - onPushed(CurrentScreen); - } - - currentScreen = value; - - if (CurrentScreen != null) - { - CurrentScreen.Exited += onExited; - CurrentScreen.ModePushed += onPushed; - Current.Value = CurrentScreen; - OnScreenChanged?.Invoke(CurrentScreen); - } - } - } - - public event Action OnScreenChanged; - - public ScreenBreadcrumbControl() - { - Current.ValueChanged += s => - { - if (s != CurrentScreen) - { - CurrentScreen = s; - s.MakeCurrent(); - } + if (last != newScreen && !newScreen.IsCurrentScreen) + newScreen.MakeCurrent(); }; + + onPushed(initialScreen); } - private void onExited(Screen screen) + private void screenChanged(Screen newScreen) { - CurrentScreen = screen as T; + if (last != null) + { + last.Exited -= screenChanged; + last.ModePushed -= onPushed; + } + + last = newScreen; + + newScreen.Exited += screenChanged; + newScreen.ModePushed += onPushed; + + Current.Value = newScreen; } private void onPushed(Screen screen) { - var newScreen = screen as T; - Items.ToList().SkipWhile(i => i != Current.Value).Skip(1).ForEach(RemoveItem); - AddItem(newScreen); + AddItem(screen); - CurrentScreen = newScreen; + screenChanged(screen); } } } From c0c449e453d2a71043386cf120a633c40ff2c123 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 15 May 2018 22:53:33 +0900 Subject: [PATCH 07/11] Remove unused using --- osu.Game/Graphics/UserInterface/ScreenBreadcrumbControl.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game/Graphics/UserInterface/ScreenBreadcrumbControl.cs b/osu.Game/Graphics/UserInterface/ScreenBreadcrumbControl.cs index 49d854ccd2..ba3927b771 100644 --- a/osu.Game/Graphics/UserInterface/ScreenBreadcrumbControl.cs +++ b/osu.Game/Graphics/UserInterface/ScreenBreadcrumbControl.cs @@ -1,7 +1,6 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System; using System.Linq; using osu.Framework.Extensions.IEnumerableExtensions; using osu.Framework.Screens; From b9d99b5f4049531bcb9c255d78c088652c094b29 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Tue, 15 May 2018 19:42:50 -0300 Subject: [PATCH 08/11] Fix nullref when exiting the last screen. --- osu.Game/Graphics/UserInterface/ScreenBreadcrumbControl.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/osu.Game/Graphics/UserInterface/ScreenBreadcrumbControl.cs b/osu.Game/Graphics/UserInterface/ScreenBreadcrumbControl.cs index ba3927b771..adcf401546 100644 --- a/osu.Game/Graphics/UserInterface/ScreenBreadcrumbControl.cs +++ b/osu.Game/Graphics/UserInterface/ScreenBreadcrumbControl.cs @@ -27,6 +27,8 @@ namespace osu.Game.Graphics.UserInterface private void screenChanged(Screen newScreen) { + if (newScreen == null) return; + if (last != null) { last.Exited -= screenChanged; From f67ad7b8e879be7c789e9c763a335f966e4b786a Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Tue, 15 May 2018 19:52:28 -0300 Subject: [PATCH 09/11] Add exit test. --- osu.Game.Tests/Visual/TestCaseScreenBreadcrumbControl.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/osu.Game.Tests/Visual/TestCaseScreenBreadcrumbControl.cs b/osu.Game.Tests/Visual/TestCaseScreenBreadcrumbControl.cs index a64e60dbd6..edd2e9fd11 100644 --- a/osu.Game.Tests/Visual/TestCaseScreenBreadcrumbControl.cs +++ b/osu.Game.Tests/Visual/TestCaseScreenBreadcrumbControl.cs @@ -66,7 +66,9 @@ namespace osu.Game.Tests.Visual assertCurrent(); pushNext(); - AddAssert(@"assert there are only 2 items", () => breadcrumbs.Items.Count() == 2); + AddAssert(@"only 2 items", () => breadcrumbs.Items.Count() == 2); + AddStep(@"exit current", () => changedScreen.Exit()); + AddAssert(@"current screen is first", () => startScreen == changedScreen); } [BackgroundDependencyLoader] @@ -76,7 +78,7 @@ namespace osu.Game.Tests.Visual } private void pushNext() => AddStep(@"push next screen", () => currentScreen = ((TestScreen)currentScreen).PushNext()); - private void assertCurrent() => AddAssert(@"assert the current screen is correct", () => currentScreen == changedScreen); + private void assertCurrent() => AddAssert(@"current screen is correct", () => currentScreen == changedScreen); private abstract class TestScreen : OsuScreen { From dda253758bfb4ade3bc3f6686cb2fccac6e17fc3 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Tue, 15 May 2018 19:56:47 -0300 Subject: [PATCH 10/11] Cleanup test step wording. --- osu.Game.Tests/Visual/TestCaseScreenBreadcrumbControl.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/osu.Game.Tests/Visual/TestCaseScreenBreadcrumbControl.cs b/osu.Game.Tests/Visual/TestCaseScreenBreadcrumbControl.cs index edd2e9fd11..7a743655f4 100644 --- a/osu.Game.Tests/Visual/TestCaseScreenBreadcrumbControl.cs +++ b/osu.Game.Tests/Visual/TestCaseScreenBreadcrumbControl.cs @@ -28,7 +28,7 @@ namespace osu.Game.Tests.Visual Children = new Drawable[] { - changedScreen = currentScreen = startScreen = new TestScreenOne(), + currentScreen = startScreen = new TestScreenOne(), new FillFlowContainer { RelativeSizeAxes = Axes.X, @@ -52,6 +52,8 @@ namespace osu.Game.Tests.Visual changedScreen = s; }; + breadcrumbs.Current.TriggerChange(); + assertCurrent(); pushNext(); assertCurrent(); @@ -78,7 +80,7 @@ namespace osu.Game.Tests.Visual } private void pushNext() => AddStep(@"push next screen", () => currentScreen = ((TestScreen)currentScreen).PushNext()); - private void assertCurrent() => AddAssert(@"current screen is correct", () => currentScreen == changedScreen); + private void assertCurrent() => AddAssert(@"changedScreen correct", () => currentScreen == changedScreen); private abstract class TestScreen : OsuScreen { From 2fc1939d650f8187d97155455a2dff4350f9a76e Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Wed, 16 May 2018 19:43:01 +0900 Subject: [PATCH 11/11] Fix hold notes never dying --- .../Judgements/HoldNoteJudgement.cs | 13 +++++++++++++ .../Objects/Drawables/DrawableHoldNote.cs | 13 +++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 osu.Game.Rulesets.Mania/Judgements/HoldNoteJudgement.cs diff --git a/osu.Game.Rulesets.Mania/Judgements/HoldNoteJudgement.cs b/osu.Game.Rulesets.Mania/Judgements/HoldNoteJudgement.cs new file mode 100644 index 0000000000..9630ba9273 --- /dev/null +++ b/osu.Game.Rulesets.Mania/Judgements/HoldNoteJudgement.cs @@ -0,0 +1,13 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Game.Rulesets.Scoring; + +namespace osu.Game.Rulesets.Mania.Judgements +{ + public class HoldNoteJudgement : ManiaJudgement + { + public override bool AffectsCombo => false; + protected override int NumericResultFor(HitResult result) => 0; + } +} diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs index f8b2311a13..3661c0be04 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs @@ -99,6 +99,19 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables protected override void UpdateState(ArmedState state) { + switch (state) + { + case ArmedState.Hit: + // Good enough for now, we just want them to have a lifetime end + this.Delay(2000).Expire(); + break; + } + } + + protected override void CheckForJudgements(bool userTriggered, double timeOffset) + { + if (tail.AllJudged) + AddJudgement(new HoldNoteJudgement { Result = HitResult.Perfect }); } protected override void Update()