1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 12:57:36 +08:00

Make the hitobject masks move within their placement/selection

# Conflicts:
#	osu.Game.Rulesets.Osu/Edit/Masks/HitCircleMasks/Components/HitCircleMask.cs
#	osu.Game.Rulesets.Osu/Edit/Masks/HitCircleMasks/HitCircleSelectionMask.cs
#	osu.Game.Rulesets.Osu/Edit/Masks/HitCirclePlacementMask.cs
#	osu.Game/Rulesets/Edit/PlacementMask.cs
This commit is contained in:
smoogipoo 2018-10-25 18:16:25 +09:00
parent 4051864bb4
commit 9656186b64
10 changed files with 138 additions and 94 deletions

View File

@ -13,23 +13,30 @@ namespace osu.Game.Rulesets.Osu.Edit.Masks.HitCircleMasks.Components
{
public class HitCircleMask : CompositeDrawable
{
private readonly HitCircle hitCircle;
public HitCircleMask(HitCircle hitCircle)
{
Anchor = Anchor.Centre;
this.hitCircle = hitCircle;
Origin = Anchor.Centre;
Size = new Vector2((float)OsuHitObject.OBJECT_RADIUS * 2);
Scale = new Vector2(hitCircle.Scale);
CornerRadius = Size.X / 2;
AddInternal(new RingPiece());
InternalChild = new RingPiece();
hitCircle.PositionChanged += _ => UpdatePosition();
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
Colour = colours.Yellow;
UpdatePosition();
}
protected virtual void UpdatePosition() => Position = hitCircle.StackedPosition;
}
}

View File

@ -1,7 +1,6 @@
// 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.Graphics;
using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Osu.Edit.Masks.HitCircleMasks.Components;
using osu.Game.Rulesets.Osu.Objects;
@ -14,13 +13,7 @@ namespace osu.Game.Rulesets.Osu.Edit.Masks.HitCircleMasks
public HitCircleSelectionMask(DrawableHitCircle hitCircle)
: base(hitCircle)
{
Origin = Anchor.Centre;
AutoSizeAxes = Axes.Both;
Position = hitCircle.Position;
InternalChild = new HitCircleMask((HitCircle)hitCircle.HitObject);
hitCircle.HitObject.PositionChanged += _ => Position = hitCircle.Position;
}
}
}

View File

@ -0,0 +1,51 @@
// 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.Framework.Graphics.Containers;
using osu.Game.Graphics;
using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Rulesets.Osu.Objects.Drawables.Pieces;
using OpenTK.Graphics;
namespace osu.Game.Rulesets.Osu.Edit.Masks.SliderMasks.Components
{
public class SliderBodyMask : CompositeDrawable
{
private readonly Slider slider;
private readonly SliderBody body;
public SliderBodyMask(Slider slider)
{
this.slider = slider;
InternalChild = body = new SliderBody(slider)
{
AccentColour = Color4.Transparent,
PathWidth = slider.Scale * 64
};
slider.PositionChanged += _ => updatePosition();
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
body.BorderColour = colours.Yellow;
updatePosition();
}
private void updatePosition() => Position = slider.StackedPosition;
protected override void Update()
{
base.Update();
Size = body.Size;
OriginPosition = body.PathOffset;
// Need to cause one update
body.UpdateProgress(0);
}
}
}

View File

@ -0,0 +1,34 @@
// 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.Game.Rulesets.Osu.Edit.Masks.HitCircleMasks.Components;
using osu.Game.Rulesets.Osu.Objects;
namespace osu.Game.Rulesets.Osu.Edit.Masks.SliderMasks.Components
{
public class SliderCircleMask : HitCircleMask
{
private readonly Slider slider;
private readonly SliderPosition position;
public SliderCircleMask(Slider slider, SliderPosition position)
: base(slider.HeadCircle)
{
this.slider = slider;
this.position = position;
}
protected override void UpdatePosition()
{
switch (position)
{
case SliderPosition.Start:
Position = slider.StackedPosition + slider.Curve.PositionAt(0);
break;
case SliderPosition.End:
Position = slider.StackedPosition + slider.Curve.PositionAt(1);
break;
}
}
}
}

View File

@ -1,60 +1,23 @@
// 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.Framework.Graphics;
using osu.Game.Graphics;
using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Osu.Edit.Masks.SliderMasks.Components;
using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Rulesets.Osu.Objects.Drawables;
using osu.Game.Rulesets.Osu.Objects.Drawables.Pieces;
using OpenTK;
namespace osu.Game.Rulesets.Osu.Edit.Masks.SliderMasks
{
public class SliderCircleSelectionMask : SelectionMask
{
public SliderCircleSelectionMask(DrawableHitCircle sliderHead, DrawableSlider slider)
: this(sliderHead, Vector2.Zero, slider)
{
}
public SliderCircleSelectionMask(DrawableSliderTail sliderTail, DrawableSlider slider)
: this(sliderTail, ((Slider)slider.HitObject).Curve.PositionAt(1), slider)
{
}
private readonly DrawableOsuHitObject hitObject;
private SliderCircleSelectionMask(DrawableOsuHitObject hitObject, Vector2 position, DrawableSlider slider)
public SliderCircleSelectionMask(DrawableOsuHitObject hitObject, Slider slider, SliderPosition position)
: base(hitObject)
{
this.hitObject = hitObject;
Origin = Anchor.Centre;
Position = position;
Size = slider.HeadCircle.Size;
Scale = slider.HeadCircle.Scale;
AddInternal(new RingPiece());
InternalChild = new SliderCircleMask(slider, position);
Select();
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
Colour = colours.Yellow;
}
protected override void Update()
{
base.Update();
RelativeAnchorPosition = hitObject.RelativeAnchorPosition;
}
// Todo: This is temporary, since the slider circle masks don't do anything special yet. In the future they will handle input.
public override bool HandlePositionalInput => false;
}

View File

@ -0,0 +1,11 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
namespace osu.Game.Rulesets.Osu.Edit.Masks.SliderMasks
{
public enum SliderPosition
{
Start,
End
}
}

View File

@ -1,67 +1,32 @@
// 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.Framework.Graphics;
using osu.Framework.Graphics.Primitives;
using osu.Game.Graphics;
using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Osu.Edit.Masks.SliderMasks.Components;
using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Rulesets.Osu.Objects.Drawables;
using osu.Game.Rulesets.Osu.Objects.Drawables.Pieces;
using OpenTK;
using OpenTK.Graphics;
namespace osu.Game.Rulesets.Osu.Edit.Masks.SliderMasks
{
public class SliderSelectionMask : SelectionMask
{
private readonly SliderBody body;
private readonly DrawableSlider slider;
private readonly SliderCircleSelectionMask headMask;
public SliderSelectionMask(DrawableSlider slider)
: base(slider)
{
this.slider = slider;
Position = slider.Position;
var sliderObject = (Slider)slider.HitObject;
InternalChildren = new Drawable[]
{
body = new SliderBody(sliderObject)
{
AccentColour = Color4.Transparent,
PathWidth = sliderObject.Scale * 64
},
new SliderCircleSelectionMask(slider.HeadCircle, slider),
new SliderCircleSelectionMask(slider.TailCircle, slider),
new SliderBodyMask(sliderObject),
headMask = new SliderCircleSelectionMask(slider.HeadCircle, sliderObject, SliderPosition.Start),
new SliderCircleSelectionMask(slider.TailCircle, sliderObject, SliderPosition.End),
};
sliderObject.PositionChanged += _ => Position = slider.Position;
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
body.BorderColour = colours.Yellow;
}
protected override void Update()
{
base.Update();
Size = slider.Size;
OriginPosition = slider.OriginPosition;
// Need to cause one update
body.UpdateProgress(0);
}
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => body.ReceivePositionalInputAt(screenSpacePos);
public override Vector2 SelectionPoint => ToScreenSpace(OriginPosition);
public override Quad SelectionQuad => body.PathDrawQuad;
public override Vector2 SelectionPoint => headMask.SelectionPoint;
}
}

View File

@ -22,7 +22,7 @@ namespace osu.Game.Rulesets.Osu.Objects
private Vector2 position;
public Vector2 Position
public virtual Vector2 Position
{
get => position;
set

View File

@ -70,6 +70,21 @@ namespace osu.Game.Rulesets.Osu.Objects
set { Curve.Distance = value; }
}
public override Vector2 Position
{
get => base.Position;
set
{
base.Position = value;
if (HeadCircle != null)
HeadCircle.Position = value;
if (TailCircle != null)
TailCircle.Position = EndPosition;
}
}
public double? LegacyLastTickOffset { get; set; }
/// <summary>

View File

@ -3,6 +3,7 @@
using System;
using osu.Framework;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Primitives;
using osu.Framework.Input.Events;
@ -52,6 +53,8 @@ namespace osu.Game.Rulesets.Edit
{
HitObject = hitObject;
RelativeSizeAxes = Axes.Both;
AlwaysPresent = true;
Alpha = 0;
}
@ -94,6 +97,8 @@ namespace osu.Game.Rulesets.Edit
public bool IsSelected => State == SelectionState.Selected;
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => HitObject.ReceivePositionalInputAt(screenSpacePos);
private bool selectionRequested;
protected override bool OnMouseDown(MouseDownEvent e)
@ -132,11 +137,11 @@ namespace osu.Game.Rulesets.Edit
/// <summary>
/// The screen-space point that causes this <see cref="SelectionMask"/> to be selected.
/// </summary>
public virtual Vector2 SelectionPoint => ScreenSpaceDrawQuad.Centre;
public virtual Vector2 SelectionPoint => HitObject.ScreenSpaceDrawQuad.Centre;
/// <summary>
/// The screen-space quad that outlines this <see cref="SelectionMask"/> for selections.
/// </summary>
public virtual Quad SelectionQuad => ScreenSpaceDrawQuad;
public virtual Quad SelectionQuad => HitObject.ScreenSpaceDrawQuad;
}
}