mirror of
https://github.com/ppy/osu.git
synced 2024-11-13 16:47:46 +08:00
Implement mania selection movements
This commit is contained in:
parent
fc0030a391
commit
a9a33b1fcb
@ -0,0 +1,15 @@
|
|||||||
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Timing;
|
||||||
|
using osu.Game.Tests.Visual;
|
||||||
|
|
||||||
|
namespace osu.Game.Rulesets.Mania.Tests
|
||||||
|
{
|
||||||
|
public abstract class ManiaSelectionBlueprintTestCase : SelectionBlueprintTestCase
|
||||||
|
{
|
||||||
|
[Cached(Type = typeof(IAdjustableClock))]
|
||||||
|
private readonly IAdjustableClock clock = new StopwatchClock();
|
||||||
|
}
|
||||||
|
}
|
@ -15,7 +15,7 @@ using osu.Game.Tests.Visual;
|
|||||||
|
|
||||||
namespace osu.Game.Rulesets.Mania.Tests
|
namespace osu.Game.Rulesets.Mania.Tests
|
||||||
{
|
{
|
||||||
public class TestCaseHoldNoteSelectionBlueprint : SelectionBlueprintTestCase
|
public class TestCaseHoldNoteSelectionBlueprint : ManiaSelectionBlueprintTestCase
|
||||||
{
|
{
|
||||||
private readonly DrawableHoldNote drawableObject;
|
private readonly DrawableHoldNote drawableObject;
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ using OpenTK;
|
|||||||
|
|
||||||
namespace osu.Game.Rulesets.Mania.Tests
|
namespace osu.Game.Rulesets.Mania.Tests
|
||||||
{
|
{
|
||||||
public class TestCaseNoteSelectionBlueprint : SelectionBlueprintTestCase
|
public class TestCaseNoteSelectionBlueprint : ManiaSelectionBlueprintTestCase
|
||||||
{
|
{
|
||||||
private readonly DrawableNote drawableObject;
|
private readonly DrawableNote drawableObject;
|
||||||
|
|
||||||
|
@ -1,22 +1,36 @@
|
|||||||
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
// 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.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Input.Events;
|
using osu.Framework.Input.Events;
|
||||||
|
using osu.Framework.Timing;
|
||||||
using osu.Game.Rulesets.Edit;
|
using osu.Game.Rulesets.Edit;
|
||||||
using osu.Game.Rulesets.Objects.Drawables;
|
using osu.Game.Rulesets.Objects.Drawables;
|
||||||
|
using osu.Game.Rulesets.UI.Scrolling;
|
||||||
using OpenTK;
|
using OpenTK;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Mania.Edit.Blueprints
|
namespace osu.Game.Rulesets.Mania.Edit.Blueprints
|
||||||
{
|
{
|
||||||
public class ManiaSelectionBlueprint : SelectionBlueprint
|
public class ManiaSelectionBlueprint : SelectionBlueprint
|
||||||
{
|
{
|
||||||
|
protected IClock EditorClock { get; private set; }
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private IScrollingInfo scrollingInfo { get; set; }
|
||||||
|
|
||||||
public ManiaSelectionBlueprint(DrawableHitObject hitObject)
|
public ManiaSelectionBlueprint(DrawableHitObject hitObject)
|
||||||
: base(hitObject)
|
: base(hitObject)
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.None;
|
RelativeSizeAxes = Axes.None;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(IAdjustableClock clock)
|
||||||
|
{
|
||||||
|
EditorClock = clock;
|
||||||
|
}
|
||||||
|
|
||||||
protected override void Update()
|
protected override void Update()
|
||||||
{
|
{
|
||||||
base.Update();
|
base.Update();
|
||||||
@ -26,6 +40,25 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints
|
|||||||
|
|
||||||
public override void AdjustPosition(DragEvent dragEvent)
|
public override void AdjustPosition(DragEvent dragEvent)
|
||||||
{
|
{
|
||||||
|
var objectParent = HitObject.Parent;
|
||||||
|
|
||||||
|
// Using the hitobject position is required since AdjustPosition can be invoked multiple times per frame
|
||||||
|
// without the position having been updated by the parenting ScrollingHitObjectContainer
|
||||||
|
HitObject.Y += dragEvent.Delta.Y;
|
||||||
|
|
||||||
|
float targetPosition;
|
||||||
|
|
||||||
|
// If we're scrolling downwards, a position of 0 is actually further away from the hit target
|
||||||
|
// so we need to flip the vertical coordinate in the hitobject container's space
|
||||||
|
if (scrollingInfo.Direction.Value == ScrollingDirection.Down)
|
||||||
|
targetPosition = -HitObject.Position.Y;
|
||||||
|
else
|
||||||
|
targetPosition = HitObject.Position.Y;
|
||||||
|
|
||||||
|
HitObject.HitObject.StartTime = scrollingInfo.Algorithm.TimeAt(targetPosition,
|
||||||
|
EditorClock.CurrentTime,
|
||||||
|
scrollingInfo.TimeRange.Value,
|
||||||
|
objectParent.DrawHeight);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user