mirror of
https://github.com/osukey/osukey.git
synced 2025-05-30 01:47:30 +09:00
Make the hitobject masks move within their placement/selection
This commit is contained in:
parent
72d48aa7f5
commit
ea6db8b793
@ -18,22 +18,28 @@ namespace osu.Game.Rulesets.Osu.Edit.Masks
|
|||||||
public HitCircleMask(HitCircle hitCircle)
|
public HitCircleMask(HitCircle hitCircle)
|
||||||
{
|
{
|
||||||
this.hitCircle = hitCircle;
|
this.hitCircle = hitCircle;
|
||||||
Anchor = Anchor.Centre;
|
|
||||||
Origin = Anchor.Centre;
|
Origin = Anchor.Centre;
|
||||||
|
|
||||||
Size = new Vector2((float)OsuHitObject.OBJECT_RADIUS * 2);
|
Size = new Vector2((float)OsuHitObject.OBJECT_RADIUS * 2);
|
||||||
|
|
||||||
CornerRadius = Size.X / 2;
|
CornerRadius = Size.X / 2;
|
||||||
|
|
||||||
AddInternal(new RingPiece());
|
InternalChild = new RingPiece();
|
||||||
|
|
||||||
|
hitCircle.PositionChanged += _ => UpdatePosition();
|
||||||
|
hitCircle.StackHeightChanged += _ => 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;
|
||||||
|
|
||||||
protected override void Update()
|
protected override void Update()
|
||||||
{
|
{
|
||||||
base.Update();
|
base.Update();
|
||||||
|
@ -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.Framework.Input.Events;
|
using osu.Framework.Input.Events;
|
||||||
using osu.Game.Rulesets.Edit;
|
using osu.Game.Rulesets.Edit;
|
||||||
using osu.Game.Rulesets.Osu.Objects;
|
using osu.Game.Rulesets.Osu.Objects;
|
||||||
@ -15,12 +14,7 @@ namespace osu.Game.Rulesets.Osu.Edit.Masks
|
|||||||
public HitCirclePlacementMask()
|
public HitCirclePlacementMask()
|
||||||
: base(new HitCircle())
|
: base(new HitCircle())
|
||||||
{
|
{
|
||||||
Origin = Anchor.Centre;
|
|
||||||
AutoSizeAxes = Axes.Both;
|
|
||||||
|
|
||||||
InternalChild = new HitCircleMask(HitObject);
|
InternalChild = new HitCircleMask(HitObject);
|
||||||
|
|
||||||
HitObject.PositionChanged += _ => Position = HitObject.StackedPosition;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
|
@ -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.Objects;
|
using osu.Game.Rulesets.Osu.Objects;
|
||||||
using osu.Game.Rulesets.Osu.Objects.Drawables;
|
using osu.Game.Rulesets.Osu.Objects.Drawables;
|
||||||
@ -13,14 +12,7 @@ namespace osu.Game.Rulesets.Osu.Edit.Masks
|
|||||||
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.HitObject.StackedPosition;
|
|
||||||
hitCircle.HitObject.StackHeightChanged += _ => Position = hitCircle.HitObject.StackedPosition;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
51
osu.Game.Rulesets.Osu/Edit/Masks/SliderBodyMask.cs
Normal file
51
osu.Game.Rulesets.Osu/Edit/Masks/SliderBodyMask.cs
Normal 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
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
33
osu.Game.Rulesets.Osu/Edit/Masks/SliderCircleMask.cs
Normal file
33
osu.Game.Rulesets.Osu/Edit/Masks/SliderCircleMask.cs
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
// 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.Objects;
|
||||||
|
|
||||||
|
namespace osu.Game.Rulesets.Osu.Edit.Masks
|
||||||
|
{
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,60 +1,22 @@
|
|||||||
// 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.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
|
namespace osu.Game.Rulesets.Osu.Edit.Masks
|
||||||
{
|
{
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
11
osu.Game.Rulesets.Osu/Edit/Masks/SliderPosition.cs
Normal file
11
osu.Game.Rulesets.Osu/Edit/Masks/SliderPosition.cs
Normal 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
|
||||||
|
{
|
||||||
|
public enum SliderPosition
|
||||||
|
{
|
||||||
|
Start,
|
||||||
|
End
|
||||||
|
}
|
||||||
|
}
|
@ -1,67 +1,31 @@
|
|||||||
// 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.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
|
namespace osu.Game.Rulesets.Osu.Edit.Masks
|
||||||
{
|
{
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,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
|
||||||
|
@ -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>
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Configuration;
|
using osu.Framework.Configuration;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Input;
|
using osu.Framework.Input;
|
||||||
using osu.Framework.Input.Events;
|
using osu.Framework.Input.Events;
|
||||||
@ -31,6 +32,8 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
public PlacementMask(HitObject hitObject)
|
public PlacementMask(HitObject hitObject)
|
||||||
{
|
{
|
||||||
HitObject = hitObject;
|
HitObject = hitObject;
|
||||||
|
|
||||||
|
RelativeSizeAxes = Axes.Both;
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user