2019-01-24 16:43:03 +08: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-12 17:24:18 +08:00
|
|
|
|
|
|
|
using osu.Framework.Graphics;
|
2020-04-24 12:20:41 +08:00
|
|
|
using osu.Framework.Input.Events;
|
2020-05-20 18:23:17 +08:00
|
|
|
using osu.Game.Rulesets.Edit;
|
2018-11-12 17:24:18 +08:00
|
|
|
using osu.Game.Rulesets.Mania.Edit.Blueprints.Components;
|
|
|
|
using osu.Game.Rulesets.Mania.Objects;
|
2020-05-13 13:43:50 +08:00
|
|
|
using osuTK.Input;
|
2018-11-12 17:24:18 +08:00
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Mania.Edit.Blueprints
|
|
|
|
{
|
2018-11-12 17:32:44 +08:00
|
|
|
public class NotePlacementBlueprint : ManiaPlacementBlueprint<Note>
|
2018-11-12 17:24:18 +08:00
|
|
|
{
|
2020-05-20 18:23:17 +08:00
|
|
|
private readonly EditNotePiece piece;
|
|
|
|
|
2018-11-12 17:24:18 +08:00
|
|
|
public NotePlacementBlueprint()
|
|
|
|
: base(new Note())
|
|
|
|
{
|
2020-05-20 18:23:17 +08:00
|
|
|
RelativeSizeAxes = Axes.Both;
|
2018-11-12 17:24:18 +08:00
|
|
|
|
2020-05-20 18:23:17 +08:00
|
|
|
InternalChild = piece = new EditNotePiece { Origin = Anchor.Centre };
|
2018-11-12 17:24:18 +08:00
|
|
|
}
|
|
|
|
|
2020-05-20 18:23:17 +08:00
|
|
|
public override void UpdatePosition(SnapResult result)
|
2018-11-12 17:24:18 +08:00
|
|
|
{
|
2020-05-20 18:23:17 +08:00
|
|
|
base.UpdatePosition(result);
|
2018-11-13 13:13:29 +08:00
|
|
|
|
2020-05-25 18:21:53 +08:00
|
|
|
if (result.Playfield != null)
|
2020-05-20 18:23:17 +08:00
|
|
|
{
|
2020-05-25 18:21:53 +08:00
|
|
|
piece.Width = result.Playfield.DrawWidth;
|
2020-05-20 18:23:17 +08:00
|
|
|
piece.Position = ToLocalSpace(result.ScreenSpacePosition);
|
|
|
|
}
|
2018-11-12 17:24:18 +08:00
|
|
|
}
|
2020-04-23 11:05:34 +08:00
|
|
|
|
2020-04-24 12:20:41 +08:00
|
|
|
protected override bool OnMouseDown(MouseDownEvent e)
|
2020-04-23 11:05:34 +08:00
|
|
|
{
|
2020-05-13 13:43:50 +08:00
|
|
|
if (e.Button != MouseButton.Left)
|
|
|
|
return false;
|
|
|
|
|
2020-04-24 12:20:41 +08:00
|
|
|
base.OnMouseDown(e);
|
2020-04-23 11:05:34 +08:00
|
|
|
|
2020-04-24 12:20:41 +08:00
|
|
|
// Place the note immediately.
|
|
|
|
EndPlacement(true);
|
|
|
|
|
|
|
|
return true;
|
2020-04-23 11:05:34 +08:00
|
|
|
}
|
2018-11-12 17:24:18 +08:00
|
|
|
}
|
|
|
|
}
|