From be297ddf76b51cfa108f2d30e7d9563575dc105a Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Thu, 19 Jul 2018 19:30:20 +0900 Subject: [PATCH] Fix direction reversal not quite working correctly --- .../TestCaseEditor.cs | 15 ++++++++++++ .../Layers/Selection/Overlays/HoldNoteMask.cs | 23 +++++++++++++++++-- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/osu.Game.Rulesets.Mania.Tests/TestCaseEditor.cs b/osu.Game.Rulesets.Mania.Tests/TestCaseEditor.cs index 799bb9efd8..6c0f931cda 100644 --- a/osu.Game.Rulesets.Mania.Tests/TestCaseEditor.cs +++ b/osu.Game.Rulesets.Mania.Tests/TestCaseEditor.cs @@ -2,6 +2,10 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using NUnit.Framework; +using osu.Framework.Allocation; +using osu.Framework.Configuration; +using osu.Game.Rulesets.Mania.Configuration; +using osu.Game.Rulesets.Mania.UI; using osu.Game.Tests.Visual; namespace osu.Game.Rulesets.Mania.Tests @@ -9,9 +13,20 @@ namespace osu.Game.Rulesets.Mania.Tests [TestFixture] public class TestCaseEditor : EditorTestCase { + private readonly Bindable direction = new Bindable(); + public TestCaseEditor() : base(new ManiaRuleset()) { + AddStep("upwards scroll", () => direction.Value = ManiaScrollingDirection.Up); + AddStep("downwards scroll", () => direction.Value = ManiaScrollingDirection.Down); + } + + [BackgroundDependencyLoader] + private void load(RulesetConfigCache configCache) + { + var config = (ManiaConfigManager)configCache.GetConfigFor(Ruleset.Value.CreateInstance()); + config.BindWith(ManiaSetting.ScrollDirection, direction); } } } diff --git a/osu.Game.Rulesets.Mania/Edit/Layers/Selection/Overlays/HoldNoteMask.cs b/osu.Game.Rulesets.Mania/Edit/Layers/Selection/Overlays/HoldNoteMask.cs index d0faea564c..745ce25a3e 100644 --- a/osu.Game.Rulesets.Mania/Edit/Layers/Selection/Overlays/HoldNoteMask.cs +++ b/osu.Game.Rulesets.Mania/Edit/Layers/Selection/Overlays/HoldNoteMask.cs @@ -2,17 +2,25 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using osu.Framework.Allocation; +using osu.Framework.Configuration; using osu.Framework.Graphics; using osu.Game.Graphics; using osu.Game.Rulesets.Edit; using osu.Game.Rulesets.Mania.Objects.Drawables; using osu.Game.Rulesets.Mania.Objects.Drawables.Pieces; +using osu.Game.Rulesets.Mania.UI; +using osu.Game.Rulesets.UI.Scrolling; +using OpenTK; using OpenTK.Graphics; namespace osu.Game.Rulesets.Mania.Edit.Layers.Selection.Overlays { public class HoldNoteMask : HitObjectMask { + public new DrawableHoldNote HitObject => (DrawableHoldNote)base.HitObject; + + private readonly IBindable direction = new Bindable(); + private readonly BodyPiece body; public HoldNoteMask(DrawableHoldNote hold) @@ -30,17 +38,25 @@ namespace osu.Game.Rulesets.Mania.Edit.Layers.Selection.Overlays } [BackgroundDependencyLoader] - private void load(OsuColour colours) + private void load(OsuColour colours, IScrollingInfo scrollingInfo) { body.BorderColour = colours.Yellow; + + direction.BindTo(scrollingInfo.Direction); } protected override void Update() { base.Update(); - Size = HitObject.DrawSize; + Size = HitObject.DrawSize + new Vector2(0, HitObject.Tail.DrawHeight); Position = Parent.ToLocalSpace(HitObject.ScreenSpaceDrawQuad.TopLeft); + + // This is a side-effect of not matching the hitobject's anchors/origins, which is kinda hard to do + // When scrolling upwards our origin is at the top of the head note (which is where the origin already is), + // but when scrolling downwards our origin is at the _bottom_ of the tail note (where we need to be at the _top_ of the tail note) + if (direction.Value == ScrollingDirection.Down) + Y -= HitObject.Tail.DrawHeight; } private class HoldNoteNoteMask : NoteMask @@ -55,6 +71,9 @@ namespace osu.Game.Rulesets.Mania.Edit.Layers.Selection.Overlays { base.Update(); + Anchor = HitObject.Anchor; + Origin = HitObject.Origin; + Position = HitObject.DrawPosition; } }