1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 03:27:24 +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 public class HitCircleMask : CompositeDrawable
{ {
private readonly HitCircle hitCircle;
public HitCircleMask(HitCircle hitCircle) public HitCircleMask(HitCircle hitCircle)
{ {
Anchor = Anchor.Centre; this.hitCircle = hitCircle;
Origin = Anchor.Centre; Origin = Anchor.Centre;
Size = new Vector2((float)OsuHitObject.OBJECT_RADIUS * 2); Size = new Vector2((float)OsuHitObject.OBJECT_RADIUS * 2);
Scale = new Vector2(hitCircle.Scale); Scale = new Vector2(hitCircle.Scale);
CornerRadius = Size.X / 2; CornerRadius = Size.X / 2;
AddInternal(new RingPiece()); InternalChild = new RingPiece();
hitCircle.PositionChanged += _ => UpdatePosition();
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuColour colours) private void load(OsuColour colours)
{ {
Colour = colours.Yellow; 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>. // 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 osu.Framework.Graphics;
using osu.Game.Rulesets.Edit; using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Osu.Edit.Masks.HitCircleMasks.Components; using osu.Game.Rulesets.Osu.Edit.Masks.HitCircleMasks.Components;
using osu.Game.Rulesets.Osu.Objects; using osu.Game.Rulesets.Osu.Objects;
@ -14,13 +13,7 @@ namespace osu.Game.Rulesets.Osu.Edit.Masks.HitCircleMasks
public HitCircleSelectionMask(DrawableHitCircle hitCircle) public HitCircleSelectionMask(DrawableHitCircle hitCircle)
: base(hitCircle) : base(hitCircle)
{ {
Origin = Anchor.Centre;
AutoSizeAxes = Axes.Both;
Position = hitCircle.Position;
InternalChild = new HitCircleMask((HitCircle)hitCircle.HitObject); 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>. // 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 osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Game.Graphics;
using osu.Game.Rulesets.Edit; 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;
using osu.Game.Rulesets.Osu.Objects.Drawables; 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 namespace osu.Game.Rulesets.Osu.Edit.Masks.SliderMasks
{ {
public class SliderCircleSelectionMask : SelectionMask public class SliderCircleSelectionMask : SelectionMask
{ {
public SliderCircleSelectionMask(DrawableHitCircle sliderHead, DrawableSlider slider) public SliderCircleSelectionMask(DrawableOsuHitObject hitObject, Slider slider, SliderPosition position)
: 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)
: base(hitObject) : base(hitObject)
{ {
this.hitObject = hitObject; InternalChild = new SliderCircleMask(slider, position);
Origin = Anchor.Centre;
Position = position;
Size = slider.HeadCircle.Size;
Scale = slider.HeadCircle.Scale;
AddInternal(new RingPiece());
Select(); 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. // 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; 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>. // 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 osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Primitives;
using osu.Game.Graphics;
using osu.Game.Rulesets.Edit; 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;
using osu.Game.Rulesets.Osu.Objects.Drawables; using osu.Game.Rulesets.Osu.Objects.Drawables;
using osu.Game.Rulesets.Osu.Objects.Drawables.Pieces;
using OpenTK; using OpenTK;
using OpenTK.Graphics;
namespace osu.Game.Rulesets.Osu.Edit.Masks.SliderMasks namespace osu.Game.Rulesets.Osu.Edit.Masks.SliderMasks
{ {
public class SliderSelectionMask : SelectionMask public class SliderSelectionMask : SelectionMask
{ {
private readonly SliderBody body; private readonly SliderCircleSelectionMask headMask;
private readonly DrawableSlider slider;
public SliderSelectionMask(DrawableSlider slider) public SliderSelectionMask(DrawableSlider slider)
: base(slider) : base(slider)
{ {
this.slider = slider;
Position = slider.Position;
var sliderObject = (Slider)slider.HitObject; var sliderObject = (Slider)slider.HitObject;
InternalChildren = new Drawable[] InternalChildren = new Drawable[]
{ {
body = new SliderBody(sliderObject) new SliderBodyMask(sliderObject),
{ headMask = new SliderCircleSelectionMask(slider.HeadCircle, sliderObject, SliderPosition.Start),
AccentColour = Color4.Transparent, new SliderCircleSelectionMask(slider.TailCircle, sliderObject, SliderPosition.End),
PathWidth = sliderObject.Scale * 64
},
new SliderCircleSelectionMask(slider.HeadCircle, slider),
new SliderCircleSelectionMask(slider.TailCircle, slider),
}; };
sliderObject.PositionChanged += _ => Position = slider.Position;
} }
[BackgroundDependencyLoader] public override Vector2 SelectionPoint => headMask.SelectionPoint;
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;
} }
} }

View File

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

View File

@ -70,6 +70,21 @@ namespace osu.Game.Rulesets.Osu.Objects
set { Curve.Distance = value; } 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; } public double? LegacyLastTickOffset { get; set; }
/// <summary> /// <summary>

View File

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