From 2ee56e4a789e12048b3dd1f2902e939b3ce5f531 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Mon, 19 Nov 2018 18:59:05 +0900 Subject: [PATCH] Add a body piece --- .../Blueprints/Components/EditBodyPiece.cs | 18 ++++++++++++++++ .../Blueprints/HoldNotePlacementBlueprint.cs | 21 +++++++++++++------ .../Objects/Drawables/Pieces/BodyPiece.cs | 2 +- 3 files changed, 34 insertions(+), 7 deletions(-) create mode 100644 osu.Game.Rulesets.Mania/Edit/Blueprints/Components/EditBodyPiece.cs diff --git a/osu.Game.Rulesets.Mania/Edit/Blueprints/Components/EditBodyPiece.cs b/osu.Game.Rulesets.Mania/Edit/Blueprints/Components/EditBodyPiece.cs new file mode 100644 index 0000000000..2695d8a911 --- /dev/null +++ b/osu.Game.Rulesets.Mania/Edit/Blueprints/Components/EditBodyPiece.cs @@ -0,0 +1,18 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// 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; + } + } +} diff --git a/osu.Game.Rulesets.Mania/Edit/Blueprints/HoldNotePlacementBlueprint.cs b/osu.Game.Rulesets.Mania/Edit/Blueprints/HoldNotePlacementBlueprint.cs index 0e5a381524..7d28a0cc1a 100644 --- a/osu.Game.Rulesets.Mania/Edit/Blueprints/HoldNotePlacementBlueprint.cs +++ b/osu.Game.Rulesets.Mania/Edit/Blueprints/HoldNotePlacementBlueprint.cs @@ -1,16 +1,19 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System; using osu.Framework.Graphics; using osu.Framework.Input.Events; using osu.Game.Rulesets.Mania.Edit.Blueprints.Components; using osu.Game.Rulesets.Mania.Objects; using osu.Game.Rulesets.Mania.UI; +using OpenTK; namespace osu.Game.Rulesets.Mania.Edit.Blueprints { public class HoldNotePlacementBlueprint : ManiaPlacementBlueprint { + private readonly EditBodyPiece bodyPiece; private readonly EditNotePiece headPiece; private readonly EditNotePiece tailPiece; @@ -21,8 +24,9 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints { RelativeSizeAxes = Axes.Both; - InternalChildren = new[] + InternalChildren = new Drawable[] { + bodyPiece = new EditBodyPiece { Origin = Anchor.TopCentre }, headPiece = new EditNotePiece { Origin = Anchor.Centre }, tailPiece = new EditNotePiece { Origin = Anchor.Centre } }; @@ -35,14 +39,20 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints switch (state) { case PlacementState.Start: - headPiece.Position = SnappedMousePosition; - headPiece.Width = SnappedWidth; + headPiece.Position = tailPiece.Position = SnappedMousePosition; + headPiece.Width = tailPiece.Width = SnappedWidth; break; case PlacementState.End: - tailPiece.Position = SnappedMousePosition; - tailPiece.Width = headPiece.Width; + tailPiece.Position = new Vector2(headPiece.Position.X, SnappedMousePosition.Y); 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) @@ -74,7 +84,6 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints HitObject.Duration = endTime - HitObject.StartTime; EndPlacement(); - return true; } diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/BodyPiece.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/BodyPiece.cs index 619fe06c73..46779b8c14 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/BodyPiece.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/BodyPiece.cs @@ -15,7 +15,7 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables.Pieces /// /// Represents length-wise portion of a hold note. /// - internal class BodyPiece : Container, IHasAccentColour + public class BodyPiece : Container, IHasAccentColour { private readonly Container subtractionLayer;