1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 20:03:22 +08:00

Use bindables for hitobject events

This commit is contained in:
smoogipoo 2018-11-09 13:58:46 +09:00
parent 0833ba2692
commit cc8531790a
12 changed files with 150 additions and 96 deletions

View File

@ -2,6 +2,7 @@
// 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.Allocation;
using osu.Framework.Configuration;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Game.Graphics; using osu.Game.Graphics;
@ -13,6 +14,10 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.HitCircles.Components
{ {
public class HitCirclePiece : CompositeDrawable public class HitCirclePiece : CompositeDrawable
{ {
private readonly IBindable<Vector2> positionBindable = new Bindable<Vector2>();
private readonly IBindable<int> stackHeightBindable = new Bindable<int>();
private readonly IBindable<float> scaleBindable = new Bindable<float>();
private readonly HitCircle hitCircle; private readonly HitCircle hitCircle;
public HitCirclePiece(HitCircle hitCircle) public HitCirclePiece(HitCircle hitCircle)
@ -25,10 +30,6 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.HitCircles.Components
CornerRadius = Size.X / 2; CornerRadius = Size.X / 2;
InternalChild = new RingPiece(); InternalChild = new RingPiece();
hitCircle.PositionChanged += _ => UpdatePosition();
hitCircle.StackHeightChanged += _ => UpdatePosition();
hitCircle.ScaleChanged += _ => Scale = new Vector2(hitCircle.Scale);
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
@ -36,7 +37,13 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.HitCircles.Components
{ {
Colour = colours.Yellow; Colour = colours.Yellow;
UpdatePosition(); positionBindable.BindValueChanged(_ => UpdatePosition());
stackHeightBindable.BindValueChanged(_ => UpdatePosition());
scaleBindable.BindValueChanged(v => Scale = new Vector2(v));
positionBindable.BindTo(hitCircle.PositionBindable);
stackHeightBindable.BindTo(hitCircle.StackHeightBindable);
scaleBindable.BindTo(hitCircle.ScaleBindable);
} }
protected virtual void UpdatePosition() => Position = hitCircle.StackedPosition; protected virtual void UpdatePosition() => Position = hitCircle.StackedPosition;

View File

@ -1,14 +1,19 @@
// 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.Configuration;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Game.Rulesets.Osu.Objects; using osu.Game.Rulesets.Osu.Objects;
using OpenTK;
namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
{ {
public class PathControlPointVisualiser : CompositeDrawable public class PathControlPointVisualiser : CompositeDrawable
{ {
private readonly IBindable<Vector2[]> controlPointsBindable = new Bindable<Vector2[]>();
private readonly Slider slider; private readonly Slider slider;
private readonly Container<PathControlPointPiece> pieces; private readonly Container<PathControlPointPiece> pieces;
@ -18,9 +23,13 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
this.slider = slider; this.slider = slider;
InternalChild = pieces = new Container<PathControlPointPiece> { RelativeSizeAxes = Axes.Both }; InternalChild = pieces = new Container<PathControlPointPiece> { RelativeSizeAxes = Axes.Both };
}
slider.ControlPointsChanged += _ => updatePathControlPoints(); [BackgroundDependencyLoader]
updatePathControlPoints(); private void load()
{
controlPointsBindable.BindValueChanged(_ => updatePathControlPoints());
controlPointsBindable.BindTo(slider.ControlPointsBindable);
} }
private void updatePathControlPoints() private void updatePathControlPoints()

View File

@ -3,6 +3,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Configuration;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Rulesets.Osu.Objects; using osu.Game.Rulesets.Osu.Objects;
@ -14,6 +15,9 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
{ {
public class SliderBodyPiece : CompositeDrawable public class SliderBodyPiece : CompositeDrawable
{ {
private readonly IBindable<Vector2> positionBindable = new Bindable<Vector2>();
private readonly IBindable<float> scaleBindable = new Bindable<float>();
private readonly Slider slider; private readonly Slider slider;
private readonly ManualSliderBody body; private readonly ManualSliderBody body;
@ -26,9 +30,6 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
AccentColour = Color4.Transparent, AccentColour = Color4.Transparent,
PathWidth = slider.Scale * 64 PathWidth = slider.Scale * 64
}; };
slider.PositionChanged += _ => updatePosition();
slider.ScaleChanged += _ => body.PathWidth = slider.Scale * 64;
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
@ -36,7 +37,11 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
{ {
body.BorderColour = colours.Yellow; body.BorderColour = colours.Yellow;
updatePosition(); positionBindable.BindValueChanged(_ => updatePosition());
scaleBindable.BindValueChanged(v => body.PathWidth = v * 64);
positionBindable.BindTo(slider.PositionBindable);
scaleBindable.BindTo(slider.ScaleBindable);
} }
private void updatePosition() => Position = slider.StackedPosition; private void updatePosition() => Position = slider.StackedPosition;

View File

@ -1,13 +1,18 @@
// 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.Configuration;
using osu.Game.Rulesets.Osu.Edit.Blueprints.HitCircles.Components; using osu.Game.Rulesets.Osu.Edit.Blueprints.HitCircles.Components;
using osu.Game.Rulesets.Osu.Objects; using osu.Game.Rulesets.Osu.Objects;
using OpenTK;
namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
{ {
public class SliderCirclePiece : HitCirclePiece public class SliderCirclePiece : HitCirclePiece
{ {
private readonly IBindable<Vector2[]> controlPointsBindable = new Bindable<Vector2[]>();
private readonly Slider slider; private readonly Slider slider;
private readonly SliderPosition position; private readonly SliderPosition position;
@ -16,8 +21,13 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
{ {
this.slider = slider; this.slider = slider;
this.position = position; this.position = position;
}
slider.ControlPointsChanged += _ => UpdatePosition(); [BackgroundDependencyLoader]
private void load()
{
controlPointsBindable.BindValueChanged(_ => UpdatePosition());
controlPointsBindable.BindTo(slider.ControlPointsBindable);
} }
protected override void UpdatePosition() protected override void UpdatePosition()

View File

@ -2,6 +2,7 @@
// 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.Allocation;
using osu.Framework.Configuration;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
@ -14,8 +15,13 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Spinners.Components
{ {
public class SpinnerPiece : CompositeDrawable public class SpinnerPiece : CompositeDrawable
{ {
private readonly IBindable<Vector2> positionBindable = new Bindable<Vector2>();
private readonly IBindable<int> stackHeightBindable = new Bindable<int>();
private readonly IBindable<float> scaleBindable = new Bindable<float>();
private readonly Spinner spinner; private readonly Spinner spinner;
private readonly CircularContainer circle; private readonly CircularContainer circle;
private readonly RingPiece ring;
public SpinnerPiece(Spinner spinner) public SpinnerPiece(Spinner spinner)
{ {
@ -27,7 +33,6 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Spinners.Components
FillMode = FillMode.Fit; FillMode = FillMode.Fit;
Size = new Vector2(1.3f); Size = new Vector2(1.3f);
RingPiece ring;
InternalChildren = new Drawable[] InternalChildren = new Drawable[]
{ {
circle = new CircularContainer circle = new CircularContainer
@ -45,18 +50,20 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Spinners.Components
}; };
ring.Scale = new Vector2(spinner.Scale); ring.Scale = new Vector2(spinner.Scale);
spinner.PositionChanged += _ => updatePosition();
spinner.StackHeightChanged += _ => updatePosition();
spinner.ScaleChanged += _ => ring.Scale = new Vector2(spinner.Scale);
updatePosition();
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuColour colours) private void load(OsuColour colours)
{ {
Colour = colours.Yellow; Colour = colours.Yellow;
positionBindable.BindValueChanged(_ => updatePosition());
stackHeightBindable.BindValueChanged(_ => updatePosition());
scaleBindable.BindValueChanged(v => ring.Scale = new Vector2(v));
positionBindable.BindTo(spinner.PositionBindable);
stackHeightBindable.BindTo(spinner.StackHeightBindable);
scaleBindable.BindTo(spinner.ScaleBindable);
} }
private void updatePosition() => Position = spinner.Position; private void updatePosition() => Position = spinner.Position;

View File

@ -2,6 +2,8 @@
// 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 System; using System;
using osu.Framework.Allocation;
using osu.Framework.Configuration;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Osu.Objects.Drawables.Pieces; using osu.Game.Rulesets.Osu.Objects.Drawables.Pieces;
@ -21,6 +23,10 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
private readonly NumberPiece number; private readonly NumberPiece number;
private readonly GlowPiece glow; private readonly GlowPiece glow;
private readonly IBindable<Vector2> positionBindable = new Bindable<Vector2>();
private readonly IBindable<int> stackHeightBindable = new Bindable<int>();
private readonly IBindable<float> scaleBindable = new Bindable<float>();
public DrawableHitCircle(HitCircle h) public DrawableHitCircle(HitCircle h)
: base(h) : base(h)
{ {
@ -59,10 +65,18 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
//may not be so correct //may not be so correct
Size = circle.DrawSize; Size = circle.DrawSize;
}
HitObject.PositionChanged += _ => Position = HitObject.StackedPosition; [BackgroundDependencyLoader]
HitObject.StackHeightChanged += _ => Position = HitObject.StackedPosition; private void load()
HitObject.ScaleChanged += s => Scale = new Vector2(s); {
positionBindable.BindValueChanged(_ => Position = HitObject.StackedPosition);
stackHeightBindable.BindValueChanged(_ => Position = HitObject.StackedPosition);
scaleBindable.BindValueChanged(v => Scale = new Vector2(v));
positionBindable.BindTo(HitObject.PositionBindable);
stackHeightBindable.BindTo(HitObject.StackHeightBindable);
scaleBindable.BindTo(HitObject.ScaleBindable);
} }
public override Color4 AccentColour public override Color4 AccentColour

View File

@ -8,6 +8,7 @@ using osu.Game.Rulesets.Osu.Objects.Drawables.Pieces;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Configuration;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Game.Configuration; using osu.Game.Configuration;
using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.Scoring;
@ -26,6 +27,10 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
public readonly SnakingSliderBody Body; public readonly SnakingSliderBody Body;
public readonly SliderBall Ball; public readonly SliderBall Ball;
private readonly IBindable<Vector2> positionBindable = new Bindable<Vector2>();
private readonly IBindable<float> scaleBindable = new Bindable<float>();
private readonly IBindable<Vector2[]> controlPointsBindable = new Bindable<Vector2[]>();
public DrawableSlider(Slider s) public DrawableSlider(Slider s)
: base(s) : base(s)
{ {
@ -83,15 +88,26 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
components.Add(drawableRepeatPoint); components.Add(drawableRepeatPoint);
AddNested(drawableRepeatPoint); AddNested(drawableRepeatPoint);
} }
}
HitObject.PositionChanged += _ => Position = HitObject.StackedPosition; [BackgroundDependencyLoader]
HitObject.ScaleChanged += _ => private void load(OsuConfigManager config)
{
config.BindWith(OsuSetting.SnakingInSliders, Body.SnakingIn);
config.BindWith(OsuSetting.SnakingOutSliders, Body.SnakingOut);
positionBindable.BindValueChanged(_ => Position = HitObject.StackedPosition);
scaleBindable.BindValueChanged(v =>
{ {
Body.PathWidth = HitObject.Scale * 64; Body.PathWidth = HitObject.Scale * 64;
Ball.Scale = new Vector2(HitObject.Scale); Ball.Scale = new Vector2(HitObject.Scale);
}; });
slider.ControlPointsChanged += _ => Body.Refresh(); controlPointsBindable.BindValueChanged(_ => Body.Refresh());
positionBindable.BindTo(HitObject.PositionBindable);
scaleBindable.BindTo(HitObject.ScaleBindable);
controlPointsBindable.BindTo(slider.ControlPointsBindable);
} }
public override Color4 AccentColour public override Color4 AccentColour
@ -108,13 +124,6 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
} }
} }
[BackgroundDependencyLoader]
private void load(OsuConfigManager config)
{
config.BindWith(OsuSetting.SnakingInSliders, Body.SnakingIn);
config.BindWith(OsuSetting.SnakingOutSliders, Body.SnakingOut);
}
public bool Tracking; public bool Tracking;
protected override void Update() protected override void Update()

View File

@ -2,6 +2,8 @@
// 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 System; using System;
using osu.Framework.Allocation;
using osu.Framework.Configuration;
using osu.Game.Rulesets.Objects.Types; using osu.Game.Rulesets.Objects.Types;
using OpenTK; using OpenTK;
@ -9,17 +11,25 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
{ {
public class DrawableSliderHead : DrawableHitCircle public class DrawableSliderHead : DrawableHitCircle
{ {
private readonly IBindable<Vector2> positionBindable = new Bindable<Vector2>();
private readonly IBindable<Vector2[]> controlPointsBindable = new Bindable<Vector2[]>();
private readonly Slider slider; private readonly Slider slider;
public DrawableSliderHead(Slider slider, HitCircle h) public DrawableSliderHead(Slider slider, HitCircle h)
: base(h) : base(h)
{ {
this.slider = slider; this.slider = slider;
}
h.PositionChanged += _ => updatePosition(); [BackgroundDependencyLoader]
slider.ControlPointsChanged += _ => updatePosition(); private void load()
{
positionBindable.BindValueChanged(_ => updatePosition());
controlPointsBindable.BindValueChanged(_ => updatePosition());
updatePosition(); positionBindable.BindTo(HitObject.PositionBindable);
controlPointsBindable.BindTo(slider.ControlPointsBindable);
} }
protected override void Update() protected override void Update()

View File

@ -1,8 +1,10 @@
// 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.Configuration;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.Scoring;
using OpenTK;
namespace osu.Game.Rulesets.Osu.Objects.Drawables namespace osu.Game.Rulesets.Osu.Objects.Drawables
{ {
@ -17,6 +19,9 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
public bool Tracking { get; set; } public bool Tracking { get; set; }
private readonly IBindable<Vector2> positionBindable = new Bindable<Vector2>();
private readonly IBindable<Vector2[]> controlPointsBindable = new Bindable<Vector2[]>();
public DrawableSliderTail(Slider slider, SliderTailCircle hitCircle) public DrawableSliderTail(Slider slider, SliderTailCircle hitCircle)
: base(hitCircle) : base(hitCircle)
{ {
@ -29,10 +34,11 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
AlwaysPresent = true; AlwaysPresent = true;
hitCircle.PositionChanged += _ => updatePosition(); positionBindable.BindValueChanged(_ => updatePosition());
slider.ControlPointsChanged += _ => updatePosition(); controlPointsBindable.BindValueChanged(_ => updatePosition());
updatePosition(); positionBindable.BindTo(hitCircle.PositionBindable);
controlPointsBindable.BindTo(slider.ControlPointsBindable);
} }
protected override void CheckForResult(bool userTriggered, double timeOffset) protected override void CheckForResult(bool userTriggered, double timeOffset)

View File

@ -11,6 +11,7 @@ using OpenTK.Graphics;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Configuration;
using osu.Game.Screens.Ranking; using osu.Game.Screens.Ranking;
using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.Scoring;
@ -36,6 +37,8 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
private readonly Color4 baseColour = OsuColour.FromHex(@"002c3c"); private readonly Color4 baseColour = OsuColour.FromHex(@"002c3c");
private readonly Color4 fillColour = OsuColour.FromHex(@"005b7c"); private readonly Color4 fillColour = OsuColour.FromHex(@"005b7c");
private readonly IBindable<Vector2> positionBindable = new Bindable<Vector2>();
private Color4 normalColour; private Color4 normalColour;
private Color4 completeColour; private Color4 completeColour;
@ -112,8 +115,23 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
Alpha = 0 Alpha = 0
} }
}; };
}
s.PositionChanged += _ => Position = s.Position; [BackgroundDependencyLoader]
private void load(OsuColour colours)
{
normalColour = baseColour;
Background.AccentColour = normalColour;
completeColour = colours.YellowLight.Opacity(0.75f);
Disc.AccentColour = fillColour;
circle.Colour = colours.BlueDark;
glow.Colour = colours.BlueDark;
positionBindable.BindValueChanged(v => Position = v);
positionBindable.BindTo(HitObject.PositionBindable);
} }
public float Progress => MathHelper.Clamp(Disc.RotationAbsolute / 360 / Spinner.SpinsRequired, 0, 1); public float Progress => MathHelper.Clamp(Disc.RotationAbsolute / 360 / Spinner.SpinsRequired, 0, 1);
@ -153,20 +171,6 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
}); });
} }
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
normalColour = baseColour;
Background.AccentColour = normalColour;
completeColour = colours.YellowLight.Opacity(0.75f);
Disc.AccentColour = fillColour;
circle.Colour = colours.BlueDark;
glow.Colour = colours.BlueDark;
}
protected override void Update() protected override void Update()
{ {
Disc.Tracking = OsuActionInputManager?.PressedActions.Any(x => x == OsuAction.LeftButton || x == OsuAction.RightButton) ?? false; Disc.Tracking = OsuActionInputManager?.PressedActions.Any(x => x == OsuAction.LeftButton || x == OsuAction.RightButton) ?? false;

View File

@ -1,7 +1,7 @@
// 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 System; using osu.Framework.Configuration;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Objects;
using OpenTK; using OpenTK;
@ -14,26 +14,15 @@ namespace osu.Game.Rulesets.Osu.Objects
{ {
public const double OBJECT_RADIUS = 64; public const double OBJECT_RADIUS = 64;
public event Action<Vector2> PositionChanged;
public event Action<int> StackHeightChanged;
public event Action<float> ScaleChanged;
public double TimePreempt = 600; public double TimePreempt = 600;
public double TimeFadeIn = 400; public double TimeFadeIn = 400;
private Vector2 position; public readonly Bindable<Vector2> PositionBindable = new Bindable<Vector2>();
public virtual Vector2 Position public virtual Vector2 Position
{ {
get => position; get => PositionBindable;
set set => PositionBindable.Value = value;
{
if (position == value)
return;
position = value;
PositionChanged?.Invoke(value);
}
} }
public float X => Position.X; public float X => Position.X;
@ -45,38 +34,24 @@ namespace osu.Game.Rulesets.Osu.Objects
public Vector2 StackedEndPosition => EndPosition + StackOffset; public Vector2 StackedEndPosition => EndPosition + StackOffset;
private int stackHeight; public readonly Bindable<int> StackHeightBindable = new Bindable<int>();
public int StackHeight public int StackHeight
{ {
get => stackHeight; get => StackHeightBindable;
set set => StackHeightBindable.Value = value;
{
if (stackHeight == value)
return;
stackHeight = value;
StackHeightChanged?.Invoke(value);
}
} }
public Vector2 StackOffset => new Vector2(StackHeight * Scale * -6.4f); public Vector2 StackOffset => new Vector2(StackHeight * Scale * -6.4f);
public double Radius => OBJECT_RADIUS * Scale; public double Radius => OBJECT_RADIUS * Scale;
private float scale = 1; public readonly Bindable<float> ScaleBindable = new Bindable<float>(1);
public float Scale public float Scale
{ {
get => scale; get => ScaleBindable;
set set => ScaleBindable.Value = value;
{
if (scale == value)
return;
scale = value;
ScaleChanged?.Invoke(value);
}
} }
public virtual bool NewCombo { get; set; } public virtual bool NewCombo { get; set; }

View File

@ -7,6 +7,7 @@ using osu.Game.Rulesets.Objects.Types;
using System.Collections.Generic; using System.Collections.Generic;
using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Objects;
using System.Linq; using System.Linq;
using osu.Framework.Configuration;
using osu.Game.Audio; using osu.Game.Audio;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Beatmaps.ControlPoints; using osu.Game.Beatmaps.ControlPoints;
@ -22,8 +23,6 @@ namespace osu.Game.Rulesets.Osu.Objects
/// </summary> /// </summary>
private const float base_scoring_distance = 100; private const float base_scoring_distance = 100;
public event Action<Vector2[]> ControlPointsChanged;
public double EndTime => StartTime + this.SpanCount() * Path.Distance / Velocity; public double EndTime => StartTime + this.SpanCount() * Path.Distance / Velocity;
public double Duration => EndTime - StartTime; public double Duration => EndTime - StartTime;
@ -54,17 +53,16 @@ namespace osu.Game.Rulesets.Osu.Objects
public SliderPath Path { get; } = new SliderPath(); public SliderPath Path { get; } = new SliderPath();
public readonly Bindable<Vector2[]> ControlPointsBindable = new Bindable<Vector2[]>(Array.Empty<Vector2>());
public Vector2[] ControlPoints public Vector2[] ControlPoints
{ {
get => Path.ControlPoints; get => ControlPointsBindable;
set set
{ {
if (Path.ControlPoints == value) ControlPointsBindable.Value = value;
return;
Path.ControlPoints = value; Path.ControlPoints = value;
ControlPointsChanged?.Invoke(value);
if (TailCircle != null) if (TailCircle != null)
TailCircle.Position = EndPosition; TailCircle.Position = EndPosition;
} }