1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 11:20:04 +08:00

Fix direction reversal not quite working correctly

This commit is contained in:
smoogipoo 2018-07-19 19:30:20 +09:00
parent b7721edc80
commit be297ddf76
2 changed files with 36 additions and 2 deletions

View File

@ -2,6 +2,10 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using NUnit.Framework; 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; using osu.Game.Tests.Visual;
namespace osu.Game.Rulesets.Mania.Tests namespace osu.Game.Rulesets.Mania.Tests
@ -9,9 +13,20 @@ namespace osu.Game.Rulesets.Mania.Tests
[TestFixture] [TestFixture]
public class TestCaseEditor : EditorTestCase public class TestCaseEditor : EditorTestCase
{ {
private readonly Bindable<ManiaScrollingDirection> direction = new Bindable<ManiaScrollingDirection>();
public TestCaseEditor() public TestCaseEditor()
: base(new ManiaRuleset()) : 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);
} }
} }
} }

View File

@ -2,17 +2,25 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Configuration;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Rulesets.Edit; using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Mania.Objects.Drawables; using osu.Game.Rulesets.Mania.Objects.Drawables;
using osu.Game.Rulesets.Mania.Objects.Drawables.Pieces; 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; using OpenTK.Graphics;
namespace osu.Game.Rulesets.Mania.Edit.Layers.Selection.Overlays namespace osu.Game.Rulesets.Mania.Edit.Layers.Selection.Overlays
{ {
public class HoldNoteMask : HitObjectMask public class HoldNoteMask : HitObjectMask
{ {
public new DrawableHoldNote HitObject => (DrawableHoldNote)base.HitObject;
private readonly IBindable<ScrollingDirection> direction = new Bindable<ScrollingDirection>();
private readonly BodyPiece body; private readonly BodyPiece body;
public HoldNoteMask(DrawableHoldNote hold) public HoldNoteMask(DrawableHoldNote hold)
@ -30,17 +38,25 @@ namespace osu.Game.Rulesets.Mania.Edit.Layers.Selection.Overlays
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuColour colours) private void load(OsuColour colours, IScrollingInfo scrollingInfo)
{ {
body.BorderColour = colours.Yellow; body.BorderColour = colours.Yellow;
direction.BindTo(scrollingInfo.Direction);
} }
protected override void Update() protected override void Update()
{ {
base.Update(); base.Update();
Size = HitObject.DrawSize; Size = HitObject.DrawSize + new Vector2(0, HitObject.Tail.DrawHeight);
Position = Parent.ToLocalSpace(HitObject.ScreenSpaceDrawQuad.TopLeft); 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 private class HoldNoteNoteMask : NoteMask
@ -55,6 +71,9 @@ namespace osu.Game.Rulesets.Mania.Edit.Layers.Selection.Overlays
{ {
base.Update(); base.Update();
Anchor = HitObject.Anchor;
Origin = HitObject.Origin;
Position = HitObject.DrawPosition; Position = HitObject.DrawPosition;
} }
} }