mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 20:22:55 +08:00
Add a body piece
This commit is contained in:
parent
ad950cfc90
commit
2ee56e4a78
@ -0,0 +1,18 @@
|
|||||||
|
// 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.Game.Graphics;
|
||||||
|
using osu.Game.Rulesets.Mania.Objects.Drawables.Pieces;
|
||||||
|
|
||||||
|
namespace osu.Game.Rulesets.Mania.Edit.Blueprints.Components
|
||||||
|
{
|
||||||
|
public class EditBodyPiece : BodyPiece
|
||||||
|
{
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(OsuColour colours)
|
||||||
|
{
|
||||||
|
AccentColour = colours.Yellow;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,16 +1,19 @@
|
|||||||
// 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 System;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Input.Events;
|
using osu.Framework.Input.Events;
|
||||||
using osu.Game.Rulesets.Mania.Edit.Blueprints.Components;
|
using osu.Game.Rulesets.Mania.Edit.Blueprints.Components;
|
||||||
using osu.Game.Rulesets.Mania.Objects;
|
using osu.Game.Rulesets.Mania.Objects;
|
||||||
using osu.Game.Rulesets.Mania.UI;
|
using osu.Game.Rulesets.Mania.UI;
|
||||||
|
using OpenTK;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Mania.Edit.Blueprints
|
namespace osu.Game.Rulesets.Mania.Edit.Blueprints
|
||||||
{
|
{
|
||||||
public class HoldNotePlacementBlueprint : ManiaPlacementBlueprint<HoldNote>
|
public class HoldNotePlacementBlueprint : ManiaPlacementBlueprint<HoldNote>
|
||||||
{
|
{
|
||||||
|
private readonly EditBodyPiece bodyPiece;
|
||||||
private readonly EditNotePiece headPiece;
|
private readonly EditNotePiece headPiece;
|
||||||
private readonly EditNotePiece tailPiece;
|
private readonly EditNotePiece tailPiece;
|
||||||
|
|
||||||
@ -21,8 +24,9 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints
|
|||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both;
|
RelativeSizeAxes = Axes.Both;
|
||||||
|
|
||||||
InternalChildren = new[]
|
InternalChildren = new Drawable[]
|
||||||
{
|
{
|
||||||
|
bodyPiece = new EditBodyPiece { Origin = Anchor.TopCentre },
|
||||||
headPiece = new EditNotePiece { Origin = Anchor.Centre },
|
headPiece = new EditNotePiece { Origin = Anchor.Centre },
|
||||||
tailPiece = new EditNotePiece { Origin = Anchor.Centre }
|
tailPiece = new EditNotePiece { Origin = Anchor.Centre }
|
||||||
};
|
};
|
||||||
@ -35,14 +39,20 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints
|
|||||||
switch (state)
|
switch (state)
|
||||||
{
|
{
|
||||||
case PlacementState.Start:
|
case PlacementState.Start:
|
||||||
headPiece.Position = SnappedMousePosition;
|
headPiece.Position = tailPiece.Position = SnappedMousePosition;
|
||||||
headPiece.Width = SnappedWidth;
|
headPiece.Width = tailPiece.Width = SnappedWidth;
|
||||||
break;
|
break;
|
||||||
case PlacementState.End:
|
case PlacementState.End:
|
||||||
tailPiece.Position = SnappedMousePosition;
|
tailPiece.Position = new Vector2(headPiece.Position.X, SnappedMousePosition.Y);
|
||||||
tailPiece.Width = headPiece.Width;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool OnMouseDown(MouseDownEvent e)
|
protected override bool OnMouseDown(MouseDownEvent e)
|
||||||
@ -74,7 +84,6 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints
|
|||||||
HitObject.Duration = endTime - HitObject.StartTime;
|
HitObject.Duration = endTime - HitObject.StartTime;
|
||||||
|
|
||||||
EndPlacement();
|
EndPlacement();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables.Pieces
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents length-wise portion of a hold note.
|
/// Represents length-wise portion of a hold note.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal class BodyPiece : Container, IHasAccentColour
|
public class BodyPiece : Container, IHasAccentColour
|
||||||
{
|
{
|
||||||
private readonly Container subtractionLayer;
|
private readonly Container subtractionLayer;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user