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:32:44 +08:00
|
|
|
|
2022-06-17 15:37:17 +08:00
|
|
|
#nullable disable
|
|
|
|
|
2018-11-12 17:32:44 +08:00
|
|
|
using osu.Framework.Graphics;
|
2018-11-13 13:13:29 +08:00
|
|
|
using osu.Framework.Input.Events;
|
2018-11-12 17:32:44 +08:00
|
|
|
using osu.Game.Rulesets.Edit;
|
|
|
|
using osu.Game.Rulesets.Mania.Objects;
|
2022-05-12 15:13:31 +08:00
|
|
|
using osu.Game.Rulesets.Mania.Skinning.Default;
|
2018-11-12 17:32:44 +08:00
|
|
|
using osu.Game.Rulesets.Mania.UI;
|
2022-05-12 15:13:31 +08:00
|
|
|
using osu.Game.Rulesets.UI.Scrolling;
|
|
|
|
using osuTK;
|
2020-05-13 13:43:50 +08:00
|
|
|
using osuTK.Input;
|
2018-11-12 17:32:44 +08:00
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Mania.Edit.Blueprints
|
|
|
|
{
|
2024-09-23 22:33:36 +08:00
|
|
|
public abstract partial class ManiaPlacementBlueprint<T> : HitObjectPlacementBlueprint
|
2018-11-12 17:32:44 +08:00
|
|
|
where T : ManiaHitObject
|
|
|
|
{
|
|
|
|
protected new T HitObject => (T)base.HitObject;
|
|
|
|
|
2020-05-20 20:13:08 +08:00
|
|
|
private Column column;
|
|
|
|
|
|
|
|
public Column Column
|
|
|
|
{
|
|
|
|
get => column;
|
|
|
|
set
|
|
|
|
{
|
|
|
|
if (value == column)
|
|
|
|
return;
|
|
|
|
|
|
|
|
column = value;
|
|
|
|
HitObject.Column = column.Index;
|
|
|
|
}
|
|
|
|
}
|
2018-11-29 18:29:36 +08:00
|
|
|
|
2018-11-19 16:59:52 +08:00
|
|
|
protected ManiaPlacementBlueprint(T hitObject)
|
2018-11-12 17:32:44 +08:00
|
|
|
: base(hitObject)
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.None;
|
|
|
|
}
|
|
|
|
|
2018-11-29 18:29:36 +08:00
|
|
|
protected override bool OnMouseDown(MouseDownEvent e)
|
|
|
|
{
|
2020-05-13 13:43:50 +08:00
|
|
|
if (e.Button != MouseButton.Left)
|
|
|
|
return false;
|
|
|
|
|
2018-11-29 18:29:36 +08:00
|
|
|
if (Column == null)
|
2020-05-20 20:13:08 +08:00
|
|
|
return false;
|
2018-11-29 18:29:36 +08:00
|
|
|
|
2020-05-20 17:46:15 +08:00
|
|
|
BeginPlacement(true);
|
2018-11-29 18:29:36 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2020-11-26 18:16:18 +08:00
|
|
|
public override void UpdateTimeAndPosition(SnapResult result)
|
2018-11-13 13:13:29 +08:00
|
|
|
{
|
2020-11-26 18:16:18 +08:00
|
|
|
base.UpdateTimeAndPosition(result);
|
2020-05-21 13:38:40 +08:00
|
|
|
|
2022-05-19 14:53:53 +08:00
|
|
|
if (result.Playfield is Column col)
|
2022-05-12 15:13:31 +08:00
|
|
|
{
|
2022-05-19 14:53:53 +08:00
|
|
|
// Apply an offset to better align with the visual grid.
|
|
|
|
// This should only be applied during placement, as during selection / drag operations the movement is relative
|
|
|
|
// to the initial point of interaction rather than the grid.
|
|
|
|
switch (col.ScrollingInfo.Direction.Value)
|
|
|
|
{
|
|
|
|
case ScrollingDirection.Down:
|
|
|
|
result.ScreenSpacePosition -= new Vector2(0, getNoteHeight(col) / 2);
|
|
|
|
break;
|
2022-05-12 15:13:31 +08:00
|
|
|
|
2022-05-19 14:53:53 +08:00
|
|
|
case ScrollingDirection.Up:
|
|
|
|
result.ScreenSpacePosition += new Vector2(0, getNoteHeight(col) / 2);
|
|
|
|
break;
|
|
|
|
}
|
2022-05-12 15:13:31 +08:00
|
|
|
|
2022-05-19 14:53:53 +08:00
|
|
|
if (PlacementActive == PlacementState.Waiting)
|
|
|
|
Column = col;
|
|
|
|
}
|
2018-11-12 17:32:44 +08:00
|
|
|
}
|
2022-05-12 15:13:31 +08:00
|
|
|
|
|
|
|
private float getNoteHeight(Column resultPlayfield) =>
|
|
|
|
resultPlayfield.ToScreenSpace(new Vector2(DefaultNotePiece.NOTE_HEIGHT)).Y -
|
|
|
|
resultPlayfield.ToScreenSpace(Vector2.Zero).Y;
|
2018-11-12 17:32:44 +08:00
|
|
|
}
|
|
|
|
}
|