1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-16 11:57:30 +08:00
osu-lazer/osu.Game.Rulesets.Mania/Edit/Blueprints/NotePlacementBlueprint.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

50 lines
1.4 KiB
C#
Raw Normal View History

// 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;
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;
using osuTK.Input;
2018-11-12 17:24:18 +08:00
namespace osu.Game.Rulesets.Mania.Edit.Blueprints
{
public partial class NotePlacementBlueprint : ManiaPlacementBlueprint<Note>
2018-11-12 17:24:18 +08:00
{
private readonly EditNotePiece piece;
2018-11-12 17:24:18 +08:00
public NotePlacementBlueprint()
: base(new Note())
{
RelativeSizeAxes = Axes.Both;
2018-11-12 17:24:18 +08:00
InternalChild = piece = new EditNotePiece { Origin = Anchor.Centre };
2018-11-12 17:24:18 +08:00
}
public override void UpdateTimeAndPosition(SnapResult result)
2018-11-12 17:24:18 +08:00
{
base.UpdateTimeAndPosition(result);
2018-11-13 13:13:29 +08:00
2020-05-25 18:21:53 +08:00
if (result.Playfield != null)
{
2020-05-25 18:21:53 +08:00
piece.Width = result.Playfield.DrawWidth;
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
{
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
}
}