2019-01-24 08:43:03 +00:00
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
2018-11-19 09:38:06 +00:00
|
|
|
|
2018-11-19 09:59:05 +00:00
|
|
|
using System;
|
2018-11-19 09:38:06 +00:00
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Game.Rulesets.Mania.Edit.Blueprints.Components;
|
|
|
|
using osu.Game.Rulesets.Mania.Objects;
|
2018-11-29 06:14:07 +00:00
|
|
|
using osuTK;
|
2018-11-19 09:38:06 +00:00
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Mania.Edit.Blueprints
|
|
|
|
{
|
|
|
|
public class HoldNotePlacementBlueprint : ManiaPlacementBlueprint<HoldNote>
|
|
|
|
{
|
2018-11-19 09:59:05 +00:00
|
|
|
private readonly EditBodyPiece bodyPiece;
|
2018-11-19 09:38:06 +00:00
|
|
|
private readonly EditNotePiece headPiece;
|
|
|
|
private readonly EditNotePiece tailPiece;
|
|
|
|
|
|
|
|
public HoldNotePlacementBlueprint()
|
|
|
|
: base(new HoldNote())
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both;
|
|
|
|
|
2018-11-19 09:59:05 +00:00
|
|
|
InternalChildren = new Drawable[]
|
2018-11-19 09:38:06 +00:00
|
|
|
{
|
2018-11-19 09:59:05 +00:00
|
|
|
bodyPiece = new EditBodyPiece { Origin = Anchor.TopCentre },
|
2018-11-19 09:38:06 +00:00
|
|
|
headPiece = new EditNotePiece { Origin = Anchor.Centre },
|
|
|
|
tailPiece = new EditNotePiece { Origin = Anchor.Centre }
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override void Update()
|
|
|
|
{
|
|
|
|
base.Update();
|
|
|
|
|
2018-11-29 10:29:36 +00:00
|
|
|
if (Column != null)
|
2018-11-19 09:38:06 +00:00
|
|
|
{
|
2018-11-29 10:29:36 +00:00
|
|
|
headPiece.Y = PositionAt(HitObject.StartTime);
|
|
|
|
tailPiece.Y = PositionAt(HitObject.EndTime);
|
2018-11-19 09:38:06 +00:00
|
|
|
}
|
2018-11-19 09:59:05 +00:00
|
|
|
|
|
|
|
var topPosition = new Vector2(headPiece.DrawPosition.X, Math.Min(headPiece.DrawPosition.Y, tailPiece.DrawPosition.Y));
|
|
|
|
var bottomPosition = new Vector2(headPiece.DrawPosition.X, Math.Max(headPiece.DrawPosition.Y, tailPiece.DrawPosition.Y));
|
|
|
|
|
|
|
|
bodyPiece.Position = topPosition;
|
|
|
|
bodyPiece.Width = headPiece.Width;
|
|
|
|
bodyPiece.Height = (bottomPosition - topPosition).Y;
|
2018-11-19 09:38:06 +00:00
|
|
|
}
|
|
|
|
|
2018-11-29 10:29:36 +00:00
|
|
|
private double originalStartTime;
|
2018-11-19 09:38:06 +00:00
|
|
|
|
2019-10-03 07:14:42 +00:00
|
|
|
public override void UpdatePosition(Vector2 screenSpacePosition)
|
2018-11-19 09:38:06 +00:00
|
|
|
{
|
2019-10-03 07:14:42 +00:00
|
|
|
base.UpdatePosition(screenSpacePosition);
|
2018-11-29 10:29:36 +00:00
|
|
|
|
|
|
|
if (PlacementBegun)
|
2018-11-19 09:38:06 +00:00
|
|
|
{
|
2019-10-03 07:14:42 +00:00
|
|
|
var endTime = TimeAt(screenSpacePosition);
|
2018-11-29 10:29:36 +00:00
|
|
|
|
|
|
|
HitObject.StartTime = endTime < originalStartTime ? endTime : originalStartTime;
|
|
|
|
HitObject.Duration = Math.Abs(endTime - originalStartTime);
|
2018-11-19 09:38:06 +00:00
|
|
|
}
|
2018-11-29 10:29:36 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
headPiece.Width = tailPiece.Width = SnappedWidth;
|
|
|
|
headPiece.X = tailPiece.X = SnappedMousePosition.X;
|
2018-11-19 09:38:06 +00:00
|
|
|
|
2019-10-03 07:14:42 +00:00
|
|
|
originalStartTime = HitObject.StartTime = TimeAt(screenSpacePosition);
|
2018-11-29 10:29:36 +00:00
|
|
|
}
|
2018-11-19 09:38:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|