From 5998d6454b7731168fd36da65ed6e1fa6295ccba Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Mon, 29 Oct 2018 15:56:17 +0900 Subject: [PATCH] Use ControlPointVisualiser instead of custom implementation --- .../Components/SliderControlPoint.cs | 92 ------------------- .../Masks/SliderMasks/SliderPlacementMask.cs | 9 +- 2 files changed, 1 insertion(+), 100 deletions(-) delete mode 100644 osu.Game.Rulesets.Osu/Edit/Masks/SliderMasks/Components/SliderControlPoint.cs diff --git a/osu.Game.Rulesets.Osu/Edit/Masks/SliderMasks/Components/SliderControlPoint.cs b/osu.Game.Rulesets.Osu/Edit/Masks/SliderMasks/Components/SliderControlPoint.cs deleted file mode 100644 index e9693e7a3c..0000000000 --- a/osu.Game.Rulesets.Osu/Edit/Masks/SliderMasks/Components/SliderControlPoint.cs +++ /dev/null @@ -1,92 +0,0 @@ -// 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.Framework.Caching; -using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Lines; -using osu.Framework.Graphics.Shapes; -using osu.Game.Graphics; -using OpenTK; - -namespace osu.Game.Rulesets.Osu.Edit.Masks.SliderMasks.Components -{ - public class SliderControlPoint : CompositeDrawable - { - private readonly Path path; - private readonly CircularContainer marker; - - private OsuColour colours; - - public SliderControlPoint() - { - Size = new Vector2(5); - Origin = Anchor.Centre; - - NextPoint = Position; - - InternalChildren = new Drawable[] - { - path = new SmoothPath - { - BypassAutoSizeAxes = Axes.Both, - Anchor = Anchor.Centre, - PathWidth = 1, - }, - marker = new CircularContainer - { - RelativeSizeAxes = Axes.Both, - Masking = true, - Child = new Box { RelativeSizeAxes = Axes.Both } - } - }; - } - - [BackgroundDependencyLoader] - private void load(OsuColour colours) - { - this.colours = colours; - - marker.Colour = colours.YellowDark; - } - - public bool SegmentSeparator - { - set => marker.Colour = value ? colours.Red : colours.YellowDark; - } - - private Vector2 nextPoint; - - public Vector2 NextPoint - { - set - { - nextPoint = value; - pathCache.Invalidate(); - } - } - - protected override void Update() - { - base.Update(); - - validatePath(); - } - - private Cached pathCache = new Cached(); - - private void validatePath() - { - if (pathCache.IsValid) - return; - - path.ClearVertices(); - path.AddVertex(nextPoint - Position); - path.AddVertex(Vector2.Zero); - path.OriginPosition = path.PositionInBoundingBox(Vector2.Zero); - - pathCache.Validate(); - } - } -} diff --git a/osu.Game.Rulesets.Osu/Edit/Masks/SliderMasks/SliderPlacementMask.cs b/osu.Game.Rulesets.Osu/Edit/Masks/SliderMasks/SliderPlacementMask.cs index 2ee996fb00..727ec4c8d5 100644 --- a/osu.Game.Rulesets.Osu/Edit/Masks/SliderMasks/SliderPlacementMask.cs +++ b/osu.Game.Rulesets.Osu/Edit/Masks/SliderMasks/SliderPlacementMask.cs @@ -7,7 +7,6 @@ using System.Linq; using osu.Framework.Allocation; using osu.Framework.Extensions.IEnumerableExtensions; using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; using osu.Framework.Input.Events; using osu.Game.Graphics; using osu.Game.Rulesets.Edit; @@ -23,8 +22,6 @@ namespace osu.Game.Rulesets.Osu.Edit.Masks.SliderMasks { public new Objects.Slider HitObject => (Objects.Slider)base.HitObject; - private Container controlPointContainer; - private readonly List segments = new List(); private Vector2 cursor; @@ -45,7 +42,7 @@ namespace osu.Game.Rulesets.Osu.Edit.Masks.SliderMasks new SliderBodyPiece(HitObject), new SliderCirclePiece(HitObject, SliderPosition.Start), new SliderCirclePiece(HitObject, SliderPosition.End), - controlPointContainer = new Container { RelativeSizeAxes = Axes.Both } + new ControlPointVisualiser(HitObject), }; setState(PlacementState.Initial); @@ -60,7 +57,6 @@ namespace osu.Game.Rulesets.Osu.Edit.Masks.SliderMasks return true; case PlacementState.Body: cursor = e.MousePosition - HitObject.Position; - controlPointContainer.Last().NextPoint = e.MousePosition; return true; } @@ -85,8 +81,6 @@ namespace osu.Game.Rulesets.Osu.Edit.Masks.SliderMasks break; } - controlPointContainer.Add(new SliderControlPoint { Position = e.MousePosition }); - return true; } @@ -100,7 +94,6 @@ namespace osu.Game.Rulesets.Osu.Edit.Masks.SliderMasks protected override bool OnDoubleClick(DoubleClickEvent e) { segments.Add(new Segment(segments[segments.Count - 1].ControlPoints.Last())); - controlPointContainer.Last().SegmentSeparator = true; return true; }