From 4e2ae72126c304ccbaa69d9ef170370be53889c2 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Wed, 12 Apr 2017 12:03:51 +0900 Subject: [PATCH 01/10] Implement proper masking support for taiko hit objects. --- osu.Game.Modes.Taiko/UI/TaikoPlayfield.cs | 36 ++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/osu.Game.Modes.Taiko/UI/TaikoPlayfield.cs b/osu.Game.Modes.Taiko/UI/TaikoPlayfield.cs index db3a1bc84e..5e5344eb6f 100644 --- a/osu.Game.Modes.Taiko/UI/TaikoPlayfield.cs +++ b/osu.Game.Modes.Taiko/UI/TaikoPlayfield.cs @@ -17,6 +17,7 @@ using osu.Framework.Graphics.Primitives; using System.Linq; using osu.Game.Modes.Taiko.Objects.Drawables; using System; +using osu.Framework.Graphics.OpenGL; namespace osu.Game.Modes.Taiko.UI { @@ -111,9 +112,11 @@ namespace osu.Game.Modes.Taiko.UI Anchor = Anchor.CentreLeft, Origin = Anchor.Centre, }, - hitObjectContainer = new Container + hitObjectContainer = new ExternalMaskingRectangleContainer { RelativeSizeAxes = Axes.Both, + Masking = true, + MaskingReference = () => this }, judgementContainer = new Container { @@ -269,5 +272,36 @@ namespace osu.Game.Modes.Taiko.UI } } } + + private class ExternalMaskingRectangleContainer : Container + { + public Func MaskingReference; + + protected override void ApplyDrawNode(DrawNode node) + { + base.ApplyDrawNode(node); + + Drawable maskingReference = MaskingReference?.Invoke(); + + if (MaskingReference == null) + return; + + var cn = node as ContainerDrawNode; + + cn.MaskingInfo = !Masking + ? (MaskingInfo?)null + : new MaskingInfo + { + ScreenSpaceAABB = maskingReference.ScreenSpaceDrawQuad.AABB, + MaskingRect = maskingReference.DrawRectangle, + ToMaskingSpace = cn.MaskingInfo.Value.ToMaskingSpace, + CornerRadius = cn.MaskingInfo.Value.CornerRadius, + BorderThickness = cn.MaskingInfo.Value.BorderThickness, + BorderColour = cn.MaskingInfo.Value.BorderColour, + BlendRange = cn.MaskingInfo.Value.BlendRange, + AlphaExponent = cn.MaskingInfo.Value.AlphaExponent + }; + } + } } } \ No newline at end of file From a922e677547210566ebf3441a3b6987093f200ea Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Wed, 12 Apr 2017 12:04:23 +0900 Subject: [PATCH 02/10] Because Ruleset only exposes HitRenderer, we need to have AspectAdjust in the base class. --- osu.Game/Modes/UI/HitRenderer.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/osu.Game/Modes/UI/HitRenderer.cs b/osu.Game/Modes/UI/HitRenderer.cs index afc525d686..dd5eff5a95 100644 --- a/osu.Game/Modes/UI/HitRenderer.cs +++ b/osu.Game/Modes/UI/HitRenderer.cs @@ -33,6 +33,11 @@ namespace osu.Game.Modes.UI /// public event Action OnAllJudged; + /// + /// Whether to apply adjustments to the child based on our own size. + /// + public bool AspectAdjust = true; + /// /// The input manager for this HitRenderer. /// @@ -168,11 +173,6 @@ namespace osu.Game.Modes.UI { public event Action OnJudgement; - /// - /// Whether to apply adjustments to the child based on our own size. - /// - public bool AspectAdjust = true; - public sealed override bool ProvidingUserCursor => !HasReplayLoaded && Playfield.ProvidingUserCursor; protected override Container Content => content; From 0c90ef79fa7e710253a48bae685ed5480c5fca47 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Wed, 12 Apr 2017 12:36:31 +0900 Subject: [PATCH 03/10] Make TestCaseTaikoPlayfield work again. --- .../Tests/TestCaseTaikoPlayfield.cs | 14 +++++++++----- osu.Game/Modes/UI/Playfield.cs | 3 +++ 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseTaikoPlayfield.cs b/osu.Desktop.VisualTests/Tests/TestCaseTaikoPlayfield.cs index a8e4382ebb..e886af6b83 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseTaikoPlayfield.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseTaikoPlayfield.cs @@ -27,6 +27,7 @@ namespace osu.Desktop.VisualTests.Tests private readonly Random rng = new Random(1337); private TaikoPlayfield playfield; + private Container playfieldContainer; public override void Reset() { @@ -51,11 +52,14 @@ namespace osu.Desktop.VisualTests.Tests var rateAdjustClock = new StopwatchClock(true) { Rate = 1 }; - Add(new Container + Add(playfieldContainer = new Container { - Clock = new FramedClock(rateAdjustClock), + Anchor = Anchor.Centre, + Origin = Anchor.Centre, RelativeSizeAxes = Axes.X, - Y = 200, + Height = TaikoPlayfield.DEFAULT_PLAYFIELD_HEIGHT, + Width = 0.8f, + Clock = new FramedClock(rateAdjustClock), Children = new[] { playfield = new TaikoPlayfield() @@ -81,11 +85,11 @@ namespace osu.Desktop.VisualTests.Tests break; case 5: addSwell(1000); - playfield.Delay(scroll_time - 100); + playfieldContainer.Delay(scroll_time - 100); break; } - playfield.ResizeTo(new Vector2(1, rng.Next(25, 400)), 500); + playfieldContainer.ResizeTo(new Vector2(1, rng.Next(25, 400)), 500); } private void addHitJudgement() diff --git a/osu.Game/Modes/UI/Playfield.cs b/osu.Game/Modes/UI/Playfield.cs index bf5f0acde5..e8e53ab1f0 100644 --- a/osu.Game/Modes/UI/Playfield.cs +++ b/osu.Game/Modes/UI/Playfield.cs @@ -38,6 +38,9 @@ namespace osu.Game.Modes.UI protected Playfield(float? customWidth = null) { AlwaysReceiveInput = true; + + // Default height since we force RelativeSizeAxes = Both + Size = Vector2.One; AddInternal(ScaledContent = new ScaledContainer { From 04baa9eb7227f94b8de0bf979449d4df01556300 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Wed, 12 Apr 2017 12:37:20 +0900 Subject: [PATCH 04/10] Reset stage to normal height after tests. --- .../Tests/TestCaseTaikoPlayfield.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseTaikoPlayfield.cs b/osu.Desktop.VisualTests/Tests/TestCaseTaikoPlayfield.cs index e886af6b83..a79790f8f8 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseTaikoPlayfield.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseTaikoPlayfield.cs @@ -49,6 +49,7 @@ namespace osu.Desktop.VisualTests.Tests AddStep("Height test 3", () => changePlayfieldSize(3)); AddStep("Height test 4", () => changePlayfieldSize(4)); AddStep("Height test 5", () => changePlayfieldSize(5)); + AddStep("Reset height", () => changePlayfieldSize(6)); var rateAdjustClock = new StopwatchClock(true) { Rate = 1 }; @@ -69,6 +70,7 @@ namespace osu.Desktop.VisualTests.Tests private void changePlayfieldSize(int step) { + // Add new hits switch (step) { case 1: @@ -89,7 +91,16 @@ namespace osu.Desktop.VisualTests.Tests break; } + // Tween playfield height + switch (step) + { + default: playfieldContainer.ResizeTo(new Vector2(1, rng.Next(25, 400)), 500); + break; + case 6: + playfieldContainer.ResizeTo(new Vector2(1, TaikoPlayfield.DEFAULT_PLAYFIELD_HEIGHT), 500); + break; + } } private void addHitJudgement() From 5d5040ee7326ff389e75d22b8949bd135fca6a6b Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Wed, 12 Apr 2017 14:34:49 +0900 Subject: [PATCH 05/10] Better masking. --- .../Tests/TestCaseTaikoPlayfield.cs | 8 ++- osu.Game.Modes.Taiko/UI/TaikoPlayfield.cs | 53 +++++++------------ 2 files changed, 26 insertions(+), 35 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseTaikoPlayfield.cs b/osu.Desktop.VisualTests/Tests/TestCaseTaikoPlayfield.cs index a79790f8f8..c8c264083c 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseTaikoPlayfield.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseTaikoPlayfield.cs @@ -4,6 +4,7 @@ using OpenTK; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Primitives; using osu.Framework.MathUtils; using osu.Framework.Testing; using osu.Framework.Timing; @@ -63,7 +64,12 @@ namespace osu.Desktop.VisualTests.Tests Clock = new FramedClock(rateAdjustClock), Children = new[] { - playfield = new TaikoPlayfield() + playfield = new TaikoPlayfield + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Height = 0.75f + } } }); } diff --git a/osu.Game.Modes.Taiko/UI/TaikoPlayfield.cs b/osu.Game.Modes.Taiko/UI/TaikoPlayfield.cs index 5e5344eb6f..eccf4aff09 100644 --- a/osu.Game.Modes.Taiko/UI/TaikoPlayfield.cs +++ b/osu.Game.Modes.Taiko/UI/TaikoPlayfield.cs @@ -53,6 +53,8 @@ namespace osu.Game.Modes.Taiko.UI public TaikoPlayfield() { + Masking = true; + AddInternal(new Drawable[] { rightBackgroundContainer = new Container @@ -112,11 +114,9 @@ namespace osu.Game.Modes.Taiko.UI Anchor = Anchor.CentreLeft, Origin = Anchor.Centre, }, - hitObjectContainer = new ExternalMaskingRectangleContainer + hitObjectContainer = new Container { RelativeSizeAxes = Axes.Both, - Masking = true, - MaskingReference = () => this }, judgementContainer = new Container { @@ -222,6 +222,22 @@ namespace osu.Game.Modes.Taiko.UI hitExplosionContainer.Children.FirstOrDefault(e => e.Judgement == judgedObject.Judgement)?.VisualiseSecondHit(); } + protected override void ApplyDrawNode(DrawNode node) + { + base.ApplyDrawNode(node); + + var cn = node as ContainerDrawNode; + + if (!Masking) + return; + + MaskingInfo old = cn.MaskingInfo.Value; + old.MaskingRect = new RectangleF(old.MaskingRect.X, old.MaskingRect.Y - 2000, old.MaskingRect.Width, old.MaskingRect.Height + 4000); + old.ScreenSpaceAABB = new System.Drawing.Rectangle(old.ScreenSpaceAABB.X, old.ScreenSpaceAABB.Y - 2000, old.ScreenSpaceAABB.Width, old.ScreenSpaceAABB.Height + 4000); + + cn.MaskingInfo = old; + } + /// /// This is a very special type of container. It serves a similar purpose to , however unlike , /// this will only adjust the scale relative to the height of its parent and will maintain the original width relative to its parent. @@ -272,36 +288,5 @@ namespace osu.Game.Modes.Taiko.UI } } } - - private class ExternalMaskingRectangleContainer : Container - { - public Func MaskingReference; - - protected override void ApplyDrawNode(DrawNode node) - { - base.ApplyDrawNode(node); - - Drawable maskingReference = MaskingReference?.Invoke(); - - if (MaskingReference == null) - return; - - var cn = node as ContainerDrawNode; - - cn.MaskingInfo = !Masking - ? (MaskingInfo?)null - : new MaskingInfo - { - ScreenSpaceAABB = maskingReference.ScreenSpaceDrawQuad.AABB, - MaskingRect = maskingReference.DrawRectangle, - ToMaskingSpace = cn.MaskingInfo.Value.ToMaskingSpace, - CornerRadius = cn.MaskingInfo.Value.CornerRadius, - BorderThickness = cn.MaskingInfo.Value.BorderThickness, - BorderColour = cn.MaskingInfo.Value.BorderColour, - BlendRange = cn.MaskingInfo.Value.BlendRange, - AlphaExponent = cn.MaskingInfo.Value.AlphaExponent - }; - } - } } } \ No newline at end of file From 7a24e5f5090a5bfe0c7b80bde70d15be187f7b82 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Wed, 12 Apr 2017 15:00:18 +0900 Subject: [PATCH 06/10] Revert "Implement proper masking support for taiko hit objects." This reverts commit 4e2ae72126c304ccbaa69d9ef170370be53889c2. --- osu.Game.Modes.Taiko/UI/TaikoPlayfield.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game.Modes.Taiko/UI/TaikoPlayfield.cs b/osu.Game.Modes.Taiko/UI/TaikoPlayfield.cs index eccf4aff09..cc5dad84cd 100644 --- a/osu.Game.Modes.Taiko/UI/TaikoPlayfield.cs +++ b/osu.Game.Modes.Taiko/UI/TaikoPlayfield.cs @@ -17,7 +17,6 @@ using osu.Framework.Graphics.Primitives; using System.Linq; using osu.Game.Modes.Taiko.Objects.Drawables; using System; -using osu.Framework.Graphics.OpenGL; namespace osu.Game.Modes.Taiko.UI { From 32c3e34eb77758f4f03fe5671ae2380417ef3fd5 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Wed, 12 Apr 2017 15:00:26 +0900 Subject: [PATCH 07/10] Revert "Better masking." This reverts commit 5d5040ee7326ff389e75d22b8949bd135fca6a6b. --- .../Tests/TestCaseTaikoPlayfield.cs | 8 +-- osu.Game.Modes.Taiko/UI/TaikoPlayfield.cs | 53 ++++++++++++------- 2 files changed, 35 insertions(+), 26 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseTaikoPlayfield.cs b/osu.Desktop.VisualTests/Tests/TestCaseTaikoPlayfield.cs index c8c264083c..a79790f8f8 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseTaikoPlayfield.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseTaikoPlayfield.cs @@ -4,7 +4,6 @@ using OpenTK; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Primitives; using osu.Framework.MathUtils; using osu.Framework.Testing; using osu.Framework.Timing; @@ -64,12 +63,7 @@ namespace osu.Desktop.VisualTests.Tests Clock = new FramedClock(rateAdjustClock), Children = new[] { - playfield = new TaikoPlayfield - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - Height = 0.75f - } + playfield = new TaikoPlayfield() } }); } diff --git a/osu.Game.Modes.Taiko/UI/TaikoPlayfield.cs b/osu.Game.Modes.Taiko/UI/TaikoPlayfield.cs index cc5dad84cd..a809cf338d 100644 --- a/osu.Game.Modes.Taiko/UI/TaikoPlayfield.cs +++ b/osu.Game.Modes.Taiko/UI/TaikoPlayfield.cs @@ -52,8 +52,6 @@ namespace osu.Game.Modes.Taiko.UI public TaikoPlayfield() { - Masking = true; - AddInternal(new Drawable[] { rightBackgroundContainer = new Container @@ -113,9 +111,11 @@ namespace osu.Game.Modes.Taiko.UI Anchor = Anchor.CentreLeft, Origin = Anchor.Centre, }, - hitObjectContainer = new Container + hitObjectContainer = new ExternalMaskingRectangleContainer { RelativeSizeAxes = Axes.Both, + Masking = true, + MaskingReference = () => this }, judgementContainer = new Container { @@ -221,22 +221,6 @@ namespace osu.Game.Modes.Taiko.UI hitExplosionContainer.Children.FirstOrDefault(e => e.Judgement == judgedObject.Judgement)?.VisualiseSecondHit(); } - protected override void ApplyDrawNode(DrawNode node) - { - base.ApplyDrawNode(node); - - var cn = node as ContainerDrawNode; - - if (!Masking) - return; - - MaskingInfo old = cn.MaskingInfo.Value; - old.MaskingRect = new RectangleF(old.MaskingRect.X, old.MaskingRect.Y - 2000, old.MaskingRect.Width, old.MaskingRect.Height + 4000); - old.ScreenSpaceAABB = new System.Drawing.Rectangle(old.ScreenSpaceAABB.X, old.ScreenSpaceAABB.Y - 2000, old.ScreenSpaceAABB.Width, old.ScreenSpaceAABB.Height + 4000); - - cn.MaskingInfo = old; - } - /// /// This is a very special type of container. It serves a similar purpose to , however unlike , /// this will only adjust the scale relative to the height of its parent and will maintain the original width relative to its parent. @@ -287,5 +271,36 @@ namespace osu.Game.Modes.Taiko.UI } } } + + private class ExternalMaskingRectangleContainer : Container + { + public Func MaskingReference; + + protected override void ApplyDrawNode(DrawNode node) + { + base.ApplyDrawNode(node); + + Drawable maskingReference = MaskingReference?.Invoke(); + + if (MaskingReference == null) + return; + + var cn = node as ContainerDrawNode; + + cn.MaskingInfo = !Masking + ? (MaskingInfo?)null + : new MaskingInfo + { + ScreenSpaceAABB = maskingReference.ScreenSpaceDrawQuad.AABB, + MaskingRect = maskingReference.DrawRectangle, + ToMaskingSpace = cn.MaskingInfo.Value.ToMaskingSpace, + CornerRadius = cn.MaskingInfo.Value.CornerRadius, + BorderThickness = cn.MaskingInfo.Value.BorderThickness, + BorderColour = cn.MaskingInfo.Value.BorderColour, + BlendRange = cn.MaskingInfo.Value.BlendRange, + AlphaExponent = cn.MaskingInfo.Value.AlphaExponent + }; + } + } } } \ No newline at end of file From 50a598dd05cbd3dd77a8cdea41a647c42f7ad438 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Wed, 12 Apr 2017 15:01:17 +0900 Subject: [PATCH 08/10] Revert another masking container. --- .../Tests/TestCaseTaikoPlayfield.cs | 1 - osu.Game.Modes.Taiko/UI/TaikoPlayfield.cs | 35 +------------------ 2 files changed, 1 insertion(+), 35 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseTaikoPlayfield.cs b/osu.Desktop.VisualTests/Tests/TestCaseTaikoPlayfield.cs index a79790f8f8..4e9ff4980e 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseTaikoPlayfield.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseTaikoPlayfield.cs @@ -59,7 +59,6 @@ namespace osu.Desktop.VisualTests.Tests Origin = Anchor.Centre, RelativeSizeAxes = Axes.X, Height = TaikoPlayfield.DEFAULT_PLAYFIELD_HEIGHT, - Width = 0.8f, Clock = new FramedClock(rateAdjustClock), Children = new[] { diff --git a/osu.Game.Modes.Taiko/UI/TaikoPlayfield.cs b/osu.Game.Modes.Taiko/UI/TaikoPlayfield.cs index a809cf338d..db3a1bc84e 100644 --- a/osu.Game.Modes.Taiko/UI/TaikoPlayfield.cs +++ b/osu.Game.Modes.Taiko/UI/TaikoPlayfield.cs @@ -111,11 +111,9 @@ namespace osu.Game.Modes.Taiko.UI Anchor = Anchor.CentreLeft, Origin = Anchor.Centre, }, - hitObjectContainer = new ExternalMaskingRectangleContainer + hitObjectContainer = new Container { RelativeSizeAxes = Axes.Both, - Masking = true, - MaskingReference = () => this }, judgementContainer = new Container { @@ -271,36 +269,5 @@ namespace osu.Game.Modes.Taiko.UI } } } - - private class ExternalMaskingRectangleContainer : Container - { - public Func MaskingReference; - - protected override void ApplyDrawNode(DrawNode node) - { - base.ApplyDrawNode(node); - - Drawable maskingReference = MaskingReference?.Invoke(); - - if (MaskingReference == null) - return; - - var cn = node as ContainerDrawNode; - - cn.MaskingInfo = !Masking - ? (MaskingInfo?)null - : new MaskingInfo - { - ScreenSpaceAABB = maskingReference.ScreenSpaceDrawQuad.AABB, - MaskingRect = maskingReference.DrawRectangle, - ToMaskingSpace = cn.MaskingInfo.Value.ToMaskingSpace, - CornerRadius = cn.MaskingInfo.Value.CornerRadius, - BorderThickness = cn.MaskingInfo.Value.BorderThickness, - BorderColour = cn.MaskingInfo.Value.BorderColour, - BlendRange = cn.MaskingInfo.Value.BlendRange, - AlphaExponent = cn.MaskingInfo.Value.AlphaExponent - }; - } - } } } \ No newline at end of file From f8076ec79252132b62c509e5986dcae0ba463e5b Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Wed, 12 Apr 2017 15:04:11 +0900 Subject: [PATCH 09/10] Better comment. --- osu.Game/Modes/UI/Playfield.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Modes/UI/Playfield.cs b/osu.Game/Modes/UI/Playfield.cs index e8e53ab1f0..27bc3baa3e 100644 --- a/osu.Game/Modes/UI/Playfield.cs +++ b/osu.Game/Modes/UI/Playfield.cs @@ -39,7 +39,7 @@ namespace osu.Game.Modes.UI { AlwaysReceiveInput = true; - // Default height since we force RelativeSizeAxes = Both + // Default height since we force relative size axes Size = Vector2.One; AddInternal(ScaledContent = new ScaledContainer From 6ab274abc0cd5f4128ac07976753c9c50188182f Mon Sep 17 00:00:00 2001 From: Dan Balasescu Date: Wed, 12 Apr 2017 15:06:46 +0900 Subject: [PATCH 10/10] Trim whitespace --- osu.Game/Modes/UI/Playfield.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Modes/UI/Playfield.cs b/osu.Game/Modes/UI/Playfield.cs index 27bc3baa3e..1e7cf6579c 100644 --- a/osu.Game/Modes/UI/Playfield.cs +++ b/osu.Game/Modes/UI/Playfield.cs @@ -38,7 +38,7 @@ namespace osu.Game.Modes.UI protected Playfield(float? customWidth = null) { AlwaysReceiveInput = true; - + // Default height since we force relative size axes Size = Vector2.One;