Merge branch 'master' into drawable-hit-object-hit-state-fix

This commit is contained in:
Dean Herbert
2020-11-05 17:07:52 +09:00
42 changed files with 294 additions and 264 deletions

2
.gitignore vendored
View File

@ -334,3 +334,5 @@ inspectcode
# BenchmarkDotNet # BenchmarkDotNet
/BenchmarkDotNet.Artifacts /BenchmarkDotNet.Artifacts
*.GeneratedMSBuildEditorConfig.editorconfig

View File

@ -4,5 +4,6 @@ M:System.ValueType.Equals(System.Object)~System.Boolean;Don't use object.Equals(
M:System.Nullable`1.Equals(System.Object)~System.Boolean;Use == instead. M:System.Nullable`1.Equals(System.Object)~System.Boolean;Use == instead.
T:System.IComparable;Don't use non-generic IComparable. Use generic version instead. T:System.IComparable;Don't use non-generic IComparable. Use generic version instead.
M:osu.Framework.Graphics.Sprites.SpriteText.#ctor;Use OsuSpriteText. M:osu.Framework.Graphics.Sprites.SpriteText.#ctor;Use OsuSpriteText.
M:osu.Framework.Bindables.IBindableList`1.GetBoundCopy();Fails on iOS. Use manual ctor + BindTo instead. (see https://github.com/mono/mono/issues/19900)
T:Microsoft.EntityFrameworkCore.Internal.EnumerableExtensions;Don't use internal extension methods. T:Microsoft.EntityFrameworkCore.Internal.EnumerableExtensions;Don't use internal extension methods.
T:Microsoft.EntityFrameworkCore.Internal.TypeExtensions;Don't use internal extension methods. T:Microsoft.EntityFrameworkCore.Internal.TypeExtensions;Don't use internal extension methods.

View File

@ -295,7 +295,7 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor
private void assertControlPointPosition(int index, Vector2 position) => private void assertControlPointPosition(int index, Vector2 position) =>
AddAssert($"control point {index} at {position}", () => Precision.AlmostEquals(position, getSlider().Path.ControlPoints[index].Position.Value, 1)); AddAssert($"control point {index} at {position}", () => Precision.AlmostEquals(position, getSlider().Path.ControlPoints[index].Position.Value, 1));
private Slider getSlider() => HitObjectContainer.Count > 0 ? (Slider)((DrawableSlider)HitObjectContainer[0]).HitObject : null; private Slider getSlider() => HitObjectContainer.Count > 0 ? ((DrawableSlider)HitObjectContainer[0]).HitObject : null;
protected override DrawableHitObject CreateHitObject(HitObject hitObject) => new DrawableSlider((Slider)hitObject); protected override DrawableHitObject CreateHitObject(HitObject hitObject) => new DrawableSlider((Slider)hitObject);
protected override PlacementBlueprint CreateBlueprint() => new SliderPlacementBlueprint(); protected override PlacementBlueprint CreateBlueprint() => new SliderPlacementBlueprint();

View File

@ -171,7 +171,7 @@ namespace osu.Game.Rulesets.Osu.Tests
} }
hitObjectContainer.Add(drawableObject); hitObjectContainer.Add(drawableObject);
followPointRenderer.AddFollowPoints(drawableObject); followPointRenderer.AddFollowPoints(objects[i]);
} }
}); });
} }
@ -180,10 +180,10 @@ namespace osu.Game.Rulesets.Osu.Tests
{ {
AddStep("remove hitobject", () => AddStep("remove hitobject", () =>
{ {
var drawableObject = getFunc?.Invoke(); var drawableObject = getFunc.Invoke();
hitObjectContainer.Remove(drawableObject); hitObjectContainer.Remove(drawableObject);
followPointRenderer.RemoveFollowPoints(drawableObject); followPointRenderer.RemoveFollowPoints(drawableObject.HitObject);
}); });
} }
@ -215,10 +215,10 @@ namespace osu.Game.Rulesets.Osu.Tests
DrawableOsuHitObject expectedStart = getObject(i); DrawableOsuHitObject expectedStart = getObject(i);
DrawableOsuHitObject expectedEnd = i < hitObjectContainer.Count - 1 ? getObject(i + 1) : null; DrawableOsuHitObject expectedEnd = i < hitObjectContainer.Count - 1 ? getObject(i + 1) : null;
if (getGroup(i).Start != expectedStart) if (getGroup(i).Start != expectedStart.HitObject)
throw new AssertionException($"Object {i} expected to be the start of group {i}."); throw new AssertionException($"Object {i} expected to be the start of group {i}.");
if (getGroup(i).End != expectedEnd) if (getGroup(i).End != expectedEnd?.HitObject)
throw new AssertionException($"Object {(expectedEnd == null ? "null" : i.ToString())} expected to be the end of group {i}."); throw new AssertionException($"Object {(expectedEnd == null ? "null" : i.ToString())} expected to be the end of group {i}.");
} }

View File

@ -112,10 +112,10 @@ namespace osu.Game.Rulesets.Osu.Tests
new HitSampleInfo { Name = HitSampleInfo.HIT_WHISTLE }, new HitSampleInfo { Name = HitSampleInfo.HIT_WHISTLE },
}); });
AddAssert("head samples updated", () => assertSamples(((Slider)slider.HitObject).HeadCircle)); AddAssert("head samples updated", () => assertSamples(slider.HitObject.HeadCircle));
AddAssert("tick samples not updated", () => ((Slider)slider.HitObject).NestedHitObjects.OfType<SliderTick>().All(assertTickSamples)); AddAssert("tick samples not updated", () => slider.HitObject.NestedHitObjects.OfType<SliderTick>().All(assertTickSamples));
AddAssert("repeat samples updated", () => ((Slider)slider.HitObject).NestedHitObjects.OfType<SliderRepeat>().All(assertSamples)); AddAssert("repeat samples updated", () => slider.HitObject.NestedHitObjects.OfType<SliderRepeat>().All(assertSamples));
AddAssert("tail has no samples", () => ((Slider)slider.HitObject).TailCircle.Samples.Count == 0); AddAssert("tail has no samples", () => slider.HitObject.TailCircle.Samples.Count == 0);
static bool assertTickSamples(SliderTick tick) => tick.Samples.Single().Name == "slidertick"; static bool assertTickSamples(SliderTick tick) => tick.Samples.Single().Name == "slidertick";
@ -136,7 +136,7 @@ namespace osu.Game.Rulesets.Osu.Tests
slider = (DrawableSlider)createSlider(repeats: 1); slider = (DrawableSlider)createSlider(repeats: 1);
for (int i = 0; i < 2; i++) for (int i = 0; i < 2; i++)
((Slider)slider.HitObject).NodeSamples.Add(new List<HitSampleInfo> { new HitSampleInfo { Name = HitSampleInfo.HIT_FINISH } }); slider.HitObject.NodeSamples.Add(new List<HitSampleInfo> { new HitSampleInfo { Name = HitSampleInfo.HIT_FINISH } });
Add(slider); Add(slider);
}); });
@ -147,10 +147,10 @@ namespace osu.Game.Rulesets.Osu.Tests
new HitSampleInfo { Name = HitSampleInfo.HIT_WHISTLE }, new HitSampleInfo { Name = HitSampleInfo.HIT_WHISTLE },
}); });
AddAssert("head samples not updated", () => assertSamples(((Slider)slider.HitObject).HeadCircle)); AddAssert("head samples not updated", () => assertSamples(slider.HitObject.HeadCircle));
AddAssert("tick samples not updated", () => ((Slider)slider.HitObject).NestedHitObjects.OfType<SliderTick>().All(assertTickSamples)); AddAssert("tick samples not updated", () => slider.HitObject.NestedHitObjects.OfType<SliderTick>().All(assertTickSamples));
AddAssert("repeat samples not updated", () => ((Slider)slider.HitObject).NestedHitObjects.OfType<SliderRepeat>().All(assertSamples)); AddAssert("repeat samples not updated", () => slider.HitObject.NestedHitObjects.OfType<SliderRepeat>().All(assertSamples));
AddAssert("tail has no samples", () => ((Slider)slider.HitObject).TailCircle.Samples.Count == 0); AddAssert("tail has no samples", () => slider.HitObject.TailCircle.Samples.Count == 0);
static bool assertTickSamples(SliderTick tick) => tick.Samples.Single().Name == "slidertick"; static bool assertTickSamples(SliderTick tick) => tick.Samples.Single().Name == "slidertick";

View File

@ -82,7 +82,7 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders
protected override void OnSelected() protected override void OnSelected()
{ {
AddInternal(ControlPointVisualiser = new PathControlPointVisualiser((Slider)slider.HitObject, true) AddInternal(ControlPointVisualiser = new PathControlPointVisualiser(slider.HitObject, true)
{ {
RemoveControlPointsRequested = removeControlPoints RemoveControlPointsRequested = removeControlPoints
}); });

View File

@ -2,6 +2,7 @@
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using System; using System;
using System.Diagnostics;
using JetBrains.Annotations; using JetBrains.Annotations;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Graphics; using osu.Framework.Graphics;
@ -31,19 +32,19 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Connections
/// The <see cref="DrawableOsuHitObject"/> which <see cref="FollowPoint"/>s will exit from. /// The <see cref="DrawableOsuHitObject"/> which <see cref="FollowPoint"/>s will exit from.
/// </summary> /// </summary>
[NotNull] [NotNull]
public readonly DrawableOsuHitObject Start; public readonly OsuHitObject Start;
/// <summary> /// <summary>
/// Creates a new <see cref="FollowPointConnection"/>. /// Creates a new <see cref="FollowPointConnection"/>.
/// </summary> /// </summary>
/// <param name="start">The <see cref="DrawableOsuHitObject"/> which <see cref="FollowPoint"/>s will exit from.</param> /// <param name="start">The <see cref="DrawableOsuHitObject"/> which <see cref="FollowPoint"/>s will exit from.</param>
public FollowPointConnection([NotNull] DrawableOsuHitObject start) public FollowPointConnection([NotNull] OsuHitObject start)
{ {
Start = start; Start = start;
RelativeSizeAxes = Axes.Both; RelativeSizeAxes = Axes.Both;
StartTime.BindTo(Start.HitObject.StartTimeBindable); StartTime.BindTo(start.StartTimeBindable);
} }
protected override void LoadComplete() protected override void LoadComplete()
@ -52,13 +53,13 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Connections
bindEvents(Start); bindEvents(Start);
} }
private DrawableOsuHitObject end; private OsuHitObject end;
/// <summary> /// <summary>
/// The <see cref="DrawableOsuHitObject"/> which <see cref="FollowPoint"/>s will enter. /// The <see cref="DrawableOsuHitObject"/> which <see cref="FollowPoint"/>s will enter.
/// </summary> /// </summary>
[CanBeNull] [CanBeNull]
public DrawableOsuHitObject End public OsuHitObject End
{ {
get => end; get => end;
set set
@ -75,10 +76,10 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Connections
} }
} }
private void bindEvents(DrawableOsuHitObject drawableObject) private void bindEvents(OsuHitObject obj)
{ {
drawableObject.HitObject.PositionBindable.BindValueChanged(_ => scheduleRefresh()); obj.PositionBindable.BindValueChanged(_ => scheduleRefresh());
drawableObject.HitObject.DefaultsApplied += _ => scheduleRefresh(); obj.DefaultsApplied += _ => scheduleRefresh();
} }
private void scheduleRefresh() private void scheduleRefresh()
@ -88,23 +89,20 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Connections
private void refresh() private void refresh()
{ {
OsuHitObject osuStart = Start.HitObject; double startTime = Start.GetEndTime();
double startTime = osuStart.GetEndTime();
LifetimeStart = startTime; LifetimeStart = startTime;
OsuHitObject osuEnd = End?.HitObject; if (End == null || End.NewCombo || Start is Spinner || End is Spinner)
if (osuEnd == null || osuEnd.NewCombo || osuStart is Spinner || osuEnd is Spinner)
{ {
// ensure we always set a lifetime for full LifetimeManagementContainer benefits // ensure we always set a lifetime for full LifetimeManagementContainer benefits
LifetimeEnd = LifetimeStart; LifetimeEnd = LifetimeStart;
return; return;
} }
Vector2 startPosition = osuStart.StackedEndPosition; Vector2 startPosition = Start.StackedEndPosition;
Vector2 endPosition = osuEnd.StackedPosition; Vector2 endPosition = End.StackedPosition;
double endTime = osuEnd.StartTime; double endTime = End.StartTime;
Vector2 distanceVector = endPosition - startPosition; Vector2 distanceVector = endPosition - startPosition;
int distance = (int)distanceVector.Length; int distance = (int)distanceVector.Length;
@ -130,10 +128,12 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Connections
AddInternal(fp = new FollowPoint()); AddInternal(fp = new FollowPoint());
Debug.Assert(End != null);
fp.Position = pointStartPosition; fp.Position = pointStartPosition;
fp.Rotation = rotation; fp.Rotation = rotation;
fp.Alpha = 0; fp.Alpha = 0;
fp.Scale = new Vector2(1.5f * osuEnd.Scale); fp.Scale = new Vector2(1.5f * End.Scale);
firstTransformStartTime ??= fadeInTime; firstTransformStartTime ??= fadeInTime;
@ -141,12 +141,12 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Connections
using (fp.BeginAbsoluteSequence(fadeInTime)) using (fp.BeginAbsoluteSequence(fadeInTime))
{ {
fp.FadeIn(osuEnd.TimeFadeIn); fp.FadeIn(End.TimeFadeIn);
fp.ScaleTo(osuEnd.Scale, osuEnd.TimeFadeIn, Easing.Out); fp.ScaleTo(End.Scale, End.TimeFadeIn, Easing.Out);
fp.MoveTo(pointEndPosition, osuEnd.TimeFadeIn, Easing.Out); fp.MoveTo(pointEndPosition, End.TimeFadeIn, Easing.Out);
fp.Delay(fadeOutTime - fadeInTime).FadeOut(osuEnd.TimeFadeIn); fp.Delay(fadeOutTime - fadeInTime).FadeOut(End.TimeFadeIn);
finalTransformEndTime = fadeOutTime + osuEnd.TimeFadeIn; finalTransformEndTime = fadeOutTime + End.TimeFadeIn;
} }
point++; point++;

View File

@ -24,19 +24,19 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Connections
public override bool RemoveCompletedTransforms => false; public override bool RemoveCompletedTransforms => false;
/// <summary> /// <summary>
/// Adds the <see cref="FollowPoint"/>s around a <see cref="DrawableOsuHitObject"/>. /// Adds the <see cref="FollowPoint"/>s around an <see cref="OsuHitObject"/>.
/// This includes <see cref="FollowPoint"/>s leading into <paramref name="hitObject"/>, and <see cref="FollowPoint"/>s exiting <paramref name="hitObject"/>. /// This includes <see cref="FollowPoint"/>s leading into <paramref name="hitObject"/>, and <see cref="FollowPoint"/>s exiting <paramref name="hitObject"/>.
/// </summary> /// </summary>
/// <param name="hitObject">The <see cref="DrawableOsuHitObject"/> to add <see cref="FollowPoint"/>s for.</param> /// <param name="hitObject">The <see cref="OsuHitObject"/> to add <see cref="FollowPoint"/>s for.</param>
public void AddFollowPoints(DrawableOsuHitObject hitObject) public void AddFollowPoints(OsuHitObject hitObject)
=> addConnection(new FollowPointConnection(hitObject).With(g => g.StartTime.BindValueChanged(_ => onStartTimeChanged(g)))); => addConnection(new FollowPointConnection(hitObject).With(g => g.StartTime.BindValueChanged(_ => onStartTimeChanged(g))));
/// <summary> /// <summary>
/// Removes the <see cref="FollowPoint"/>s around a <see cref="DrawableOsuHitObject"/>. /// Removes the <see cref="FollowPoint"/>s around an <see cref="OsuHitObject"/>.
/// This includes <see cref="FollowPoint"/>s leading into <paramref name="hitObject"/>, and <see cref="FollowPoint"/>s exiting <paramref name="hitObject"/>. /// This includes <see cref="FollowPoint"/>s leading into <paramref name="hitObject"/>, and <see cref="FollowPoint"/>s exiting <paramref name="hitObject"/>.
/// </summary> /// </summary>
/// <param name="hitObject">The <see cref="DrawableOsuHitObject"/> to remove <see cref="FollowPoint"/>s for.</param> /// <param name="hitObject">The <see cref="OsuHitObject"/> to remove <see cref="FollowPoint"/>s for.</param>
public void RemoveFollowPoints(DrawableOsuHitObject hitObject) => removeGroup(connections.Single(g => g.Start == hitObject)); public void RemoveFollowPoints(OsuHitObject hitObject) => removeGroup(connections.Single(g => g.Start == hitObject));
/// <summary> /// <summary>
/// Adds a <see cref="FollowPointConnection"/> to this <see cref="FollowPointRenderer"/>. /// Adds a <see cref="FollowPointConnection"/> to this <see cref="FollowPointRenderer"/>.

View File

@ -4,7 +4,6 @@
using System; using System;
using System.Diagnostics; using System.Diagnostics;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Input; using osu.Framework.Input;
@ -21,28 +20,25 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
{ {
public class DrawableHitCircle : DrawableOsuHitObject, IDrawableHitObjectWithProxiedApproach public class DrawableHitCircle : DrawableOsuHitObject, IDrawableHitObjectWithProxiedApproach
{ {
public ApproachCircle ApproachCircle { get; }
private readonly IBindable<Vector2> positionBindable = new Bindable<Vector2>();
private readonly IBindable<int> stackHeightBindable = new Bindable<int>();
private readonly IBindable<float> scaleBindable = new BindableFloat();
public OsuAction? HitAction => HitArea.HitAction; public OsuAction? HitAction => HitArea.HitAction;
public readonly HitReceptor HitArea;
public readonly SkinnableDrawable CirclePiece;
private readonly Container scaleContainer;
protected virtual OsuSkinComponents CirclePieceComponent => OsuSkinComponents.HitCircle; protected virtual OsuSkinComponents CirclePieceComponent => OsuSkinComponents.HitCircle;
public ApproachCircle ApproachCircle { get; private set; }
public HitReceptor HitArea { get; private set; }
public SkinnableDrawable CirclePiece { get; private set; }
private Container scaleContainer;
private InputManager inputManager; private InputManager inputManager;
public DrawableHitCircle(HitCircle h) public DrawableHitCircle(HitCircle h)
: base(h) : base(h)
{ {
Origin = Anchor.Centre; }
Position = HitObject.StackedPosition; [BackgroundDependencyLoader]
private void load()
{
Origin = Anchor.Centre;
InternalChildren = new Drawable[] InternalChildren = new Drawable[]
{ {
@ -75,19 +71,10 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
}; };
Size = HitArea.DrawSize; Size = HitArea.DrawSize;
}
[BackgroundDependencyLoader]
private void load()
{
positionBindable.BindValueChanged(_ => Position = HitObject.StackedPosition);
stackHeightBindable.BindValueChanged(_ => Position = HitObject.StackedPosition);
scaleBindable.BindValueChanged(scale => scaleContainer.Scale = new Vector2(scale.NewValue), true);
positionBindable.BindTo(HitObject.PositionBindable);
stackHeightBindable.BindTo(HitObject.StackHeightBindable);
scaleBindable.BindTo(HitObject.ScaleBindable);
PositionBindable.BindValueChanged(_ => Position = HitObject.StackedPosition, true);
StackHeightBindable.BindValueChanged(_ => Position = HitObject.StackedPosition, true);
ScaleBindable.BindValueChanged(scale => scaleContainer.Scale = new Vector2(scale.NewValue), true);
AccentColour.BindValueChanged(accent => ApproachCircle.Colour = accent.NewValue, true); AccentColour.BindValueChanged(accent => ApproachCircle.Colour = accent.NewValue, true);
} }

View File

@ -2,18 +2,24 @@
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using System; using System;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.Objects.Drawables;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Game.Rulesets.Judgements; using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Osu.Judgements; using osu.Game.Rulesets.Osu.Judgements;
using osu.Game.Graphics.Containers; using osu.Game.Graphics.Containers;
using osu.Game.Rulesets.Osu.UI; using osu.Game.Rulesets.Osu.UI;
using osuTK;
namespace osu.Game.Rulesets.Osu.Objects.Drawables namespace osu.Game.Rulesets.Osu.Objects.Drawables
{ {
public class DrawableOsuHitObject : DrawableHitObject<OsuHitObject> public class DrawableOsuHitObject : DrawableHitObject<OsuHitObject>
{ {
private readonly ShakeContainer shakeContainer; public readonly IBindable<Vector2> PositionBindable = new Bindable<Vector2>();
public readonly IBindable<int> StackHeightBindable = new Bindable<int>();
public readonly IBindable<float> ScaleBindable = new BindableFloat();
public readonly IBindable<int> IndexInCurrentComboBindable = new Bindable<int>();
// Must be set to update IsHovered as it's used in relax mdo to detect osu hit objects. // Must be set to update IsHovered as it's used in relax mdo to detect osu hit objects.
public override bool HandlePositionalInput => true; public override bool HandlePositionalInput => true;
@ -26,16 +32,28 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
/// </summary> /// </summary>
public Func<DrawableHitObject, double, bool> CheckHittable; public Func<DrawableHitObject, double, bool> CheckHittable;
private ShakeContainer shakeContainer;
protected DrawableOsuHitObject(OsuHitObject hitObject) protected DrawableOsuHitObject(OsuHitObject hitObject)
: base(hitObject) : base(hitObject)
{ {
}
[BackgroundDependencyLoader]
private void load()
{
Alpha = 0;
base.AddInternal(shakeContainer = new ShakeContainer base.AddInternal(shakeContainer = new ShakeContainer
{ {
ShakeDuration = 30, ShakeDuration = 30,
RelativeSizeAxes = Axes.Both RelativeSizeAxes = Axes.Both
}); });
Alpha = 0; IndexInCurrentComboBindable.BindTo(HitObject.IndexInCurrentComboBindable);
PositionBindable.BindTo(HitObject.PositionBindable);
StackHeightBindable.BindTo(HitObject.StackHeightBindable);
ScaleBindable.BindTo(HitObject.ScaleBindable);
} }
// Forward all internal management to shakeContainer. // Forward all internal management to shakeContainer.

View File

@ -2,22 +2,17 @@
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Game.Configuration; using osu.Game.Configuration;
using osuTK; using osuTK;
using osu.Game.Rulesets.Judgements; using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Skinning;
using osuTK.Graphics;
namespace osu.Game.Rulesets.Osu.Objects.Drawables namespace osu.Game.Rulesets.Osu.Objects.Drawables
{ {
public class DrawableOsuJudgement : DrawableJudgement public class DrawableOsuJudgement : DrawableJudgement
{ {
protected SkinnableSprite Lighting; protected SkinnableLighting Lighting { get; private set; }
private Bindable<Color4> lightingColour;
[Resolved] [Resolved]
private OsuConfigManager config { get; set; } private OsuConfigManager config { get; set; }
@ -34,7 +29,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load() private void load()
{ {
AddInternal(Lighting = new SkinnableSprite("lighting") AddInternal(Lighting = new SkinnableLighting
{ {
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre, Origin = Anchor.Centre,
@ -59,19 +54,8 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
{ {
base.PrepareForUse(); base.PrepareForUse();
lightingColour?.UnbindAll();
Lighting.ResetAnimation(); Lighting.ResetAnimation();
Lighting.SetColourFrom(JudgedObject, Result);
if (JudgedObject != null)
{
lightingColour = JudgedObject.AccentColour.GetBoundCopy();
lightingColour.BindValueChanged(colour => Lighting.Colour = Result.IsHit ? colour.NewValue : Color4.Transparent, true);
}
else
{
Lighting.Colour = Color4.White;
}
} }
private double fadeOutDelay; private double fadeOutDelay;

View File

@ -20,62 +20,54 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
{ {
public class DrawableSlider : DrawableOsuHitObject, IDrawableHitObjectWithProxiedApproach public class DrawableSlider : DrawableOsuHitObject, IDrawableHitObjectWithProxiedApproach
{ {
public new Slider HitObject => (Slider)base.HitObject;
public DrawableSliderHead HeadCircle => headContainer.Child; public DrawableSliderHead HeadCircle => headContainer.Child;
public DrawableSliderTail TailCircle => tailContainer.Child; public DrawableSliderTail TailCircle => tailContainer.Child;
public readonly SliderBall Ball; public SliderBall Ball { get; private set; }
public readonly SkinnableDrawable Body; public SkinnableDrawable Body { get; private set; }
public override bool DisplayResult => false; public override bool DisplayResult => false;
private PlaySliderBody sliderBody => Body.Drawable as PlaySliderBody; private PlaySliderBody sliderBody => Body.Drawable as PlaySliderBody;
private readonly Container<DrawableSliderHead> headContainer; public readonly IBindable<int> PathVersion = new Bindable<int>();
private readonly Container<DrawableSliderTail> tailContainer;
private readonly Container<DrawableSliderTick> tickContainer;
private readonly Container<DrawableSliderRepeat> repeatContainer;
private readonly Slider slider; private Container<DrawableSliderHead> headContainer;
private Container<DrawableSliderTail> tailContainer;
private readonly IBindable<Vector2> positionBindable = new Bindable<Vector2>(); private Container<DrawableSliderTick> tickContainer;
private readonly IBindable<int> stackHeightBindable = new Bindable<int>(); private Container<DrawableSliderRepeat> repeatContainer;
private readonly IBindable<float> scaleBindable = new BindableFloat();
public DrawableSlider(Slider s) public DrawableSlider(Slider s)
: base(s) : base(s)
{ {
slider = s; }
Position = s.StackedPosition;
[BackgroundDependencyLoader]
private void load()
{
InternalChildren = new Drawable[] InternalChildren = new Drawable[]
{ {
Body = new SkinnableDrawable(new OsuSkinComponent(OsuSkinComponents.SliderBody), _ => new DefaultSliderBody(), confineMode: ConfineMode.NoScaling), Body = new SkinnableDrawable(new OsuSkinComponent(OsuSkinComponents.SliderBody), _ => new DefaultSliderBody(), confineMode: ConfineMode.NoScaling),
tailContainer = new Container<DrawableSliderTail> { RelativeSizeAxes = Axes.Both }, tailContainer = new Container<DrawableSliderTail> { RelativeSizeAxes = Axes.Both },
tickContainer = new Container<DrawableSliderTick> { RelativeSizeAxes = Axes.Both }, tickContainer = new Container<DrawableSliderTick> { RelativeSizeAxes = Axes.Both },
repeatContainer = new Container<DrawableSliderRepeat> { RelativeSizeAxes = Axes.Both }, repeatContainer = new Container<DrawableSliderRepeat> { RelativeSizeAxes = Axes.Both },
Ball = new SliderBall(s, this) Ball = new SliderBall(this)
{ {
GetInitialHitAction = () => HeadCircle.HitAction, GetInitialHitAction = () => HeadCircle.HitAction,
BypassAutoSizeAxes = Axes.Both, BypassAutoSizeAxes = Axes.Both,
Scale = new Vector2(s.Scale),
AlwaysPresent = true, AlwaysPresent = true,
Alpha = 0 Alpha = 0
}, },
headContainer = new Container<DrawableSliderHead> { RelativeSizeAxes = Axes.Both }, headContainer = new Container<DrawableSliderHead> { RelativeSizeAxes = Axes.Both },
}; };
}
[BackgroundDependencyLoader] PathVersion.BindTo(HitObject.Path.Version);
private void load()
{
positionBindable.BindValueChanged(_ => Position = HitObject.StackedPosition);
stackHeightBindable.BindValueChanged(_ => Position = HitObject.StackedPosition);
scaleBindable.BindValueChanged(scale => Ball.Scale = new Vector2(scale.NewValue));
positionBindable.BindTo(HitObject.PositionBindable); PositionBindable.BindValueChanged(_ => Position = HitObject.StackedPosition, true);
stackHeightBindable.BindTo(HitObject.StackHeightBindable); StackHeightBindable.BindValueChanged(_ => Position = HitObject.StackedPosition, true);
scaleBindable.BindTo(HitObject.ScaleBindable); ScaleBindable.BindValueChanged(scale => Ball.Scale = new Vector2(scale.NewValue), true);
AccentColour.BindValueChanged(colour => AccentColour.BindValueChanged(colour =>
{ {
@ -162,20 +154,20 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
switch (hitObject) switch (hitObject)
{ {
case SliderTailCircle tail: case SliderTailCircle tail:
return new DrawableSliderTail(slider, tail); return new DrawableSliderTail(tail);
case SliderHeadCircle head: case SliderHeadCircle head:
return new DrawableSliderHead(slider, head) return new DrawableSliderHead(HitObject, head)
{ {
OnShake = Shake, OnShake = Shake,
CheckHittable = (d, t) => CheckHittable?.Invoke(d, t) ?? true CheckHittable = (d, t) => CheckHittable?.Invoke(d, t) ?? true
}; };
case SliderTick tick: case SliderTick tick:
return new DrawableSliderTick(tick) { Position = tick.Position - slider.Position }; return new DrawableSliderTick(tick) { Position = tick.Position - HitObject.Position };
case SliderRepeat repeat: case SliderRepeat repeat:
return new DrawableSliderRepeat(repeat, this) { Position = repeat.Position - slider.Position }; return new DrawableSliderRepeat(repeat, this) { Position = repeat.Position - HitObject.Position };
} }
return base.CreateNestedHitObject(hitObject); return base.CreateNestedHitObject(hitObject);
@ -200,14 +192,14 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
// keep the sliding sample playing at the current tracking position // keep the sliding sample playing at the current tracking position
slidingSample.Balance.Value = CalculateSamplePlaybackBalance(Ball.X / OsuPlayfield.BASE_SIZE.X); slidingSample.Balance.Value = CalculateSamplePlaybackBalance(Ball.X / OsuPlayfield.BASE_SIZE.X);
double completionProgress = Math.Clamp((Time.Current - slider.StartTime) / slider.Duration, 0, 1); double completionProgress = Math.Clamp((Time.Current - HitObject.StartTime) / HitObject.Duration, 0, 1);
Ball.UpdateProgress(completionProgress); Ball.UpdateProgress(completionProgress);
sliderBody?.UpdateProgress(completionProgress); sliderBody?.UpdateProgress(completionProgress);
foreach (DrawableHitObject hitObject in NestedHitObjects) foreach (DrawableHitObject hitObject in NestedHitObjects)
{ {
if (hitObject is ITrackSnaking s) s.UpdateSnakingPosition(slider.Path.PositionAt(sliderBody?.SnakedStart ?? 0), slider.Path.PositionAt(sliderBody?.SnakedEnd ?? 0)); if (hitObject is ITrackSnaking s) s.UpdateSnakingPosition(HitObject.Path.PositionAt(sliderBody?.SnakedStart ?? 0), HitObject.Path.PositionAt(sliderBody?.SnakedEnd ?? 0));
if (hitObject is IRequireTracking t) t.Tracking = Ball.Tracking; if (hitObject is IRequireTracking t) t.Tracking = Ball.Tracking;
} }
@ -239,7 +231,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
protected override void CheckForResult(bool userTriggered, double timeOffset) protected override void CheckForResult(bool userTriggered, double timeOffset)
{ {
if (userTriggered || Time.Current < slider.EndTime) if (userTriggered || Time.Current < HitObject.EndTime)
return; return;
ApplyResult(r => r.Type = r.Judgement.MaxResult); ApplyResult(r => r.Type = r.Judgement.MaxResult);

View File

@ -5,13 +5,11 @@ using System;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Game.Rulesets.Objects.Types; using osu.Game.Rulesets.Objects.Types;
using osuTK;
namespace osu.Game.Rulesets.Osu.Objects.Drawables 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<int> pathVersion = new Bindable<int>(); private readonly IBindable<int> pathVersion = new Bindable<int>();
protected override OsuSkinComponents CirclePieceComponent => OsuSkinComponents.SliderHeadHitCircle; protected override OsuSkinComponents CirclePieceComponent => OsuSkinComponents.SliderHeadHitCircle;
@ -27,10 +25,9 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load() private void load()
{ {
positionBindable.BindTo(HitObject.PositionBindable);
pathVersion.BindTo(slider.Path.Version); pathVersion.BindTo(slider.Path.Version);
positionBindable.BindValueChanged(_ => updatePosition()); PositionBindable.BindValueChanged(_ => updatePosition());
pathVersion.BindValueChanged(_ => updatePosition(), true); pathVersion.BindValueChanged(_ => updatePosition(), true);
} }

View File

@ -4,7 +4,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Utils; using osu.Framework.Utils;
@ -22,9 +21,9 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
private double animDuration; private double animDuration;
private readonly Drawable scaleContainer; public Drawable CirclePiece { get; private set; }
private Drawable scaleContainer;
public readonly Drawable CirclePiece; private ReverseArrowPiece arrow;
public override bool DisplayResult => false; public override bool DisplayResult => false;
@ -33,10 +32,13 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
{ {
this.sliderRepeat = sliderRepeat; this.sliderRepeat = sliderRepeat;
this.drawableSlider = drawableSlider; this.drawableSlider = drawableSlider;
}
Size = new Vector2(OsuHitObject.OBJECT_RADIUS * 2); [BackgroundDependencyLoader]
private void load()
{
Origin = Anchor.Centre; Origin = Anchor.Centre;
Size = new Vector2(OsuHitObject.OBJECT_RADIUS * 2);
InternalChild = scaleContainer = new Container InternalChild = scaleContainer = new Container
{ {
@ -50,15 +52,8 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
arrow = new ReverseArrowPiece(), arrow = new ReverseArrowPiece(),
} }
}; };
}
private readonly IBindable<float> scaleBindable = new BindableFloat(); ScaleBindable.BindValueChanged(scale => scaleContainer.Scale = new Vector2(scale.NewValue), true);
[BackgroundDependencyLoader]
private void load()
{
scaleBindable.BindValueChanged(scale => scaleContainer.Scale = new Vector2(scale.NewValue), true);
scaleBindable.BindTo(HitObject.ScaleBindable);
} }
protected override void CheckForResult(bool userTriggered, double timeOffset) protected override void CheckForResult(bool userTriggered, double timeOffset)
@ -100,8 +95,6 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
private bool hasRotation; private bool hasRotation;
private readonly ReverseArrowPiece arrow;
public void UpdateSnakingPosition(Vector2 start, Vector2 end) public void UpdateSnakingPosition(Vector2 start, Vector2 end)
{ {
// When the repeat is hit, the arrow should fade out on spot rather than following the slider // When the repeat is hit, the arrow should fade out on spot rather than following the slider

View File

@ -3,7 +3,6 @@
using System.Diagnostics; using System.Diagnostics;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.Objects.Drawables;
@ -23,18 +22,19 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
public bool Tracking { get; set; } public bool Tracking { get; set; }
private readonly IBindable<float> scaleBindable = new BindableFloat(); private SkinnableDrawable circlePiece;
private Container scaleContainer;
private readonly SkinnableDrawable circlePiece; public DrawableSliderTail(SliderTailCircle tailCircle)
private readonly Container scaleContainer;
public DrawableSliderTail(Slider slider, SliderTailCircle tailCircle)
: base(tailCircle) : base(tailCircle)
{ {
this.tailCircle = tailCircle; this.tailCircle = tailCircle;
Origin = Anchor.Centre; }
[BackgroundDependencyLoader]
private void load()
{
Origin = Anchor.Centre;
Size = new Vector2(OsuHitObject.OBJECT_RADIUS * 2); Size = new Vector2(OsuHitObject.OBJECT_RADIUS * 2);
InternalChildren = new Drawable[] InternalChildren = new Drawable[]
@ -51,13 +51,8 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
} }
}, },
}; };
}
[BackgroundDependencyLoader] ScaleBindable.BindValueChanged(scale => scaleContainer.Scale = new Vector2(scale.NewValue), true);
private void load()
{
scaleBindable.BindValueChanged(scale => scaleContainer.Scale = new Vector2(scale.NewValue), true);
scaleBindable.BindTo(HitObject.ScaleBindable);
} }
protected override void UpdateInitialTransforms() protected override void UpdateInitialTransforms()

View File

@ -2,7 +2,6 @@
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.Objects.Drawables;
using osuTK; using osuTK;
@ -23,10 +22,15 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
public override bool DisplayResult => false; public override bool DisplayResult => false;
private readonly SkinnableDrawable scaleContainer; private SkinnableDrawable scaleContainer;
public DrawableSliderTick(SliderTick sliderTick) public DrawableSliderTick(SliderTick sliderTick)
: base(sliderTick) : base(sliderTick)
{
}
[BackgroundDependencyLoader]
private void load()
{ {
Size = new Vector2(OsuHitObject.OBJECT_RADIUS * 2); Size = new Vector2(OsuHitObject.OBJECT_RADIUS * 2);
Origin = Anchor.Centre; Origin = Anchor.Centre;
@ -49,15 +53,8 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre, Origin = Anchor.Centre,
}; };
}
private readonly IBindable<float> scaleBindable = new BindableFloat(); ScaleBindable.BindValueChanged(scale => scaleContainer.Scale = new Vector2(scale.NewValue), true);
[BackgroundDependencyLoader]
private void load()
{
scaleBindable.BindValueChanged(scale => scaleContainer.Scale = new Vector2(scale.NewValue), true);
scaleBindable.BindTo(HitObject.ScaleBindable);
} }
protected override void CheckForResult(bool userTriggered, double timeOffset) protected override void CheckForResult(bool userTriggered, double timeOffset)

View File

@ -16,34 +16,33 @@ using osu.Game.Rulesets.Osu.Skinning;
using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.Scoring;
using osu.Game.Screens.Ranking; using osu.Game.Screens.Ranking;
using osu.Game.Skinning; using osu.Game.Skinning;
using osuTK;
namespace osu.Game.Rulesets.Osu.Objects.Drawables namespace osu.Game.Rulesets.Osu.Objects.Drawables
{ {
public class DrawableSpinner : DrawableOsuHitObject public class DrawableSpinner : DrawableOsuHitObject
{ {
protected readonly Spinner Spinner; public new Spinner HitObject => (Spinner)base.HitObject;
private readonly Container<DrawableSpinnerTick> ticks; public SpinnerRotationTracker RotationTracker { get; private set; }
public SpinnerSpmCounter SpmCounter { get; private set; }
public readonly SpinnerRotationTracker RotationTracker; private Container<DrawableSpinnerTick> ticks;
public readonly SpinnerSpmCounter SpmCounter; private SpinnerBonusDisplay bonusDisplay;
private readonly SpinnerBonusDisplay bonusDisplay;
private readonly IBindable<Vector2> positionBindable = new Bindable<Vector2>();
private Bindable<bool> isSpinning;
private bool spinnerFrequencyModulate; private bool spinnerFrequencyModulate;
public DrawableSpinner(Spinner s) public DrawableSpinner(Spinner s)
: base(s) : base(s)
{
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{ {
Origin = Anchor.Centre; Origin = Anchor.Centre;
Position = s.Position;
RelativeSizeAxes = Axes.Both; RelativeSizeAxes = Axes.Both;
Spinner = s;
InternalChildren = new Drawable[] InternalChildren = new Drawable[]
{ {
ticks = new Container<DrawableSpinnerTick>(), ticks = new Container<DrawableSpinnerTick>(),
@ -55,7 +54,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
Children = new Drawable[] Children = new Drawable[]
{ {
new SkinnableDrawable(new OsuSkinComponent(OsuSkinComponents.SpinnerBody), _ => new DefaultSpinnerDisc()), new SkinnableDrawable(new OsuSkinComponent(OsuSkinComponents.SpinnerBody), _ => new DefaultSpinnerDisc()),
RotationTracker = new SpinnerRotationTracker(Spinner) RotationTracker = new SpinnerRotationTracker(this)
} }
}, },
SpmCounter = new SpinnerSpmCounter SpmCounter = new SpinnerSpmCounter
@ -72,9 +71,9 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
Y = -120, Y = -120,
} }
}; };
}
private Bindable<bool> isSpinning; PositionBindable.BindValueChanged(pos => Position = pos.NewValue, true);
}
protected override void LoadComplete() protected override void LoadComplete()
{ {
@ -172,13 +171,6 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
return base.CreateNestedHitObject(hitObject); return base.CreateNestedHitObject(hitObject);
} }
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
positionBindable.BindValueChanged(pos => Position = pos.NewValue);
positionBindable.BindTo(HitObject.PositionBindable);
}
protected override void ApplySkin(ISkinSource skin, bool allowFallback) protected override void ApplySkin(ISkinSource skin, bool allowFallback)
{ {
base.ApplySkin(skin, allowFallback); base.ApplySkin(skin, allowFallback);
@ -192,12 +184,12 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
{ {
get get
{ {
if (Spinner.SpinsRequired == 0) if (HitObject.SpinsRequired == 0)
// some spinners are so short they can't require an integer spin count. // some spinners are so short they can't require an integer spin count.
// these become implicitly hit. // these become implicitly hit.
return 1; return 1;
return Math.Clamp(RotationTracker.RateAdjustedRotation / 360 / Spinner.SpinsRequired, 0, 1); return Math.Clamp(RotationTracker.RateAdjustedRotation / 360 / HitObject.SpinsRequired, 0, 1);
} }
} }
@ -207,7 +199,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
RotationTracker.Complete.Value = Progress >= 1; RotationTracker.Complete.Value = Progress >= 1;
if (userTriggered || Time.Current < Spinner.EndTime) if (userTriggered || Time.Current < HitObject.EndTime)
return; return;
// Trigger a miss result for remaining ticks to avoid infinite gameplay. // Trigger a miss result for remaining ticks to avoid infinite gameplay.
@ -222,7 +214,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
r.Type = HitResult.Ok; r.Type = HitResult.Ok;
else if (Progress > .75) else if (Progress > .75)
r.Type = HitResult.Meh; r.Type = HitResult.Meh;
else if (Time.Current >= Spinner.EndTime) else if (Time.Current >= HitObject.EndTime)
r.Type = r.Judgement.MinResult; r.Type = r.Judgement.MinResult;
}); });
} }
@ -274,7 +266,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
{ {
tick.TriggerResult(true); tick.TriggerResult(true);
if (tick is DrawableSpinnerBonusTick) if (tick is DrawableSpinnerBonusTick)
bonusDisplay.SetBonusCount(spins - Spinner.SpinsRequired); bonusDisplay.SetBonusCount(spins - HitObject.SpinsRequired);
} }
wholeSpins++; wholeSpins++;

View File

@ -36,7 +36,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
Origin = Anchor.Centre, Origin = Anchor.Centre,
Texture = textures.Get(@"Gameplay/osu/disc"), Texture = textures.Get(@"Gameplay/osu/disc"),
}, },
new TrianglesPiece((int)drawableHitObject.HitObject.StartTime) new TrianglesPiece(drawableHitObject.GetHashCode())
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Blending = BlendingParameters.Additive, Blending = BlendingParameters.Additive,

View File

@ -18,8 +18,6 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
{ {
private DrawableSpinner drawableSpinner; private DrawableSpinner drawableSpinner;
private Spinner spinner;
private const float initial_scale = 1.3f; private const float initial_scale = 1.3f;
private const float idle_alpha = 0.2f; private const float idle_alpha = 0.2f;
private const float tracking_alpha = 0.4f; private const float tracking_alpha = 0.4f;
@ -52,7 +50,6 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
private void load(OsuColour colours, DrawableHitObject drawableHitObject) private void load(OsuColour colours, DrawableHitObject drawableHitObject)
{ {
drawableSpinner = (DrawableSpinner)drawableHitObject; drawableSpinner = (DrawableSpinner)drawableHitObject;
spinner = (Spinner)drawableSpinner.HitObject;
normalColour = colours.BlueDark; normalColour = colours.BlueDark;
completeColour = colours.YellowLight; completeColour = colours.YellowLight;
@ -130,6 +127,8 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
if (!(drawableHitObject is DrawableSpinner)) if (!(drawableHitObject is DrawableSpinner))
return; return;
Spinner spinner = drawableSpinner.HitObject;
using (BeginAbsoluteSequence(spinner.StartTime - spinner.TimePreempt, true)) using (BeginAbsoluteSequence(spinner.StartTime - spinner.TimePreempt, true))
{ {
this.ScaleTo(initial_scale); this.ScaleTo(initial_scale);

View File

@ -45,7 +45,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(DrawableHitObject drawableObject) private void load(DrawableHitObject drawableObject)
{ {
OsuHitObject osuObject = (OsuHitObject)drawableObject.HitObject; var drawableOsuObject = (DrawableOsuHitObject)drawableObject;
state.BindTo(drawableObject.State); state.BindTo(drawableObject.State);
state.BindValueChanged(updateState, true); state.BindValueChanged(updateState, true);
@ -58,7 +58,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
circle.Colour = colour.NewValue; circle.Colour = colour.NewValue;
}, true); }, true);
indexInCurrentCombo.BindTo(osuObject.IndexInCurrentComboBindable); indexInCurrentCombo.BindTo(drawableOsuObject.IndexInCurrentComboBindable);
indexInCurrentCombo.BindValueChanged(index => number.Text = (index.NewValue + 1).ToString(), true); indexInCurrentCombo.BindValueChanged(index => number.Text = (index.NewValue + 1).ToString(), true);
} }

View File

@ -17,23 +17,18 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
private IBindable<int> pathVersion; private IBindable<int> pathVersion;
private IBindable<Color4> accentColour; private IBindable<Color4> accentColour;
[Resolved]
private DrawableHitObject drawableObject { get; set; }
[Resolved(CanBeNull = true)] [Resolved(CanBeNull = true)]
private OsuRulesetConfigManager config { get; set; } private OsuRulesetConfigManager config { get; set; }
private Slider slider;
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(ISkinSource skin) private void load(ISkinSource skin, DrawableHitObject drawableObject)
{ {
slider = (Slider)drawableObject.HitObject; var drawableSlider = (DrawableSlider)drawableObject;
scaleBindable = slider.ScaleBindable.GetBoundCopy(); scaleBindable = drawableSlider.ScaleBindable.GetBoundCopy();
scaleBindable.BindValueChanged(scale => PathRadius = OsuHitObject.OBJECT_RADIUS * scale.NewValue, true); scaleBindable.BindValueChanged(scale => PathRadius = OsuHitObject.OBJECT_RADIUS * scale.NewValue, true);
pathVersion = slider.Path.Version.GetBoundCopy(); pathVersion = drawableSlider.PathVersion.GetBoundCopy();
pathVersion.BindValueChanged(_ => Refresh()); pathVersion.BindValueChanged(_ => Refresh());
accentColour = drawableObject.AccentColour.GetBoundCopy(); accentColour = drawableObject.AccentColour.GetBoundCopy();

View File

@ -30,15 +30,13 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
set => ball.Colour = value; set => ball.Colour = value;
} }
private readonly Slider slider;
private readonly Drawable followCircle; private readonly Drawable followCircle;
private readonly DrawableSlider drawableSlider; private readonly DrawableSlider drawableSlider;
private readonly Drawable ball; private readonly Drawable ball;
public SliderBall(Slider slider, DrawableSlider drawableSlider = null) public SliderBall(DrawableSlider drawableSlider)
{ {
this.drawableSlider = drawableSlider; this.drawableSlider = drawableSlider;
this.slider = slider;
Origin = Anchor.Centre; Origin = Anchor.Centre;
@ -133,7 +131,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
if (headCircleHitAction == null) if (headCircleHitAction == null)
timeToAcceptAnyKeyAfter = null; timeToAcceptAnyKeyAfter = null;
var actions = drawableSlider?.OsuActionInputManager?.PressedActions; var actions = drawableSlider.OsuActionInputManager?.PressedActions;
// if the head circle was hit with a specific key, tracking should only occur while that key is pressed. // if the head circle was hit with a specific key, tracking should only occur while that key is pressed.
if (headCircleHitAction != null && timeToAcceptAnyKeyAfter == null) if (headCircleHitAction != null && timeToAcceptAnyKeyAfter == null)
@ -147,7 +145,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
Tracking = Tracking =
// in valid time range // in valid time range
Time.Current >= slider.StartTime && Time.Current < slider.EndTime && Time.Current >= drawableSlider.HitObject.StartTime && Time.Current < drawableSlider.HitObject.EndTime &&
// in valid position range // in valid position range
lastScreenSpaceMousePosition.HasValue && followCircle.ReceivePositionalInputAt(lastScreenSpaceMousePosition.Value) && lastScreenSpaceMousePosition.HasValue && followCircle.ReceivePositionalInputAt(lastScreenSpaceMousePosition.Value) &&
// valid action // valid action
@ -172,9 +170,9 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
public void UpdateProgress(double completionProgress) public void UpdateProgress(double completionProgress)
{ {
var newPos = slider.CurvePositionAt(completionProgress); var newPos = drawableSlider.HitObject.CurvePositionAt(completionProgress);
var diff = lastPosition.HasValue ? lastPosition.Value - newPos : newPos - slider.CurvePositionAt(completionProgress + 0.01f); var diff = lastPosition.HasValue ? lastPosition.Value - newPos : newPos - drawableSlider.HitObject.CurvePositionAt(completionProgress + 0.01f);
if (diff == Vector2.Zero) if (diff == Vector2.Zero)
return; return;

View File

@ -51,18 +51,23 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
/// </summary> /// </summary>
private Vector2 snakedPathOffset; private Vector2 snakedPathOffset;
private Slider slider; private DrawableSlider drawableSlider;
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(DrawableHitObject drawableObject) private void load(DrawableHitObject drawableObject)
{ {
slider = (Slider)drawableObject.HitObject; drawableSlider = (DrawableSlider)drawableObject;
Refresh(); Refresh();
} }
public void UpdateProgress(double completionProgress) public void UpdateProgress(double completionProgress)
{ {
if (drawableSlider == null)
return;
Slider slider = drawableSlider.HitObject;
var span = slider.SpanAt(completionProgress); var span = slider.SpanAt(completionProgress);
var spanProgress = slider.ProgressAt(completionProgress); var spanProgress = slider.ProgressAt(completionProgress);
@ -87,8 +92,11 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
public void Refresh() public void Refresh()
{ {
if (drawableSlider == null)
return;
// Generate the entire curve // Generate the entire curve
slider.Path.GetPathToProgress(CurrentCurve, 0, 1); drawableSlider.HitObject.Path.GetPathToProgress(CurrentCurve, 0, 1);
SetVertices(CurrentCurve); SetVertices(CurrentCurve);
// Force the body to be the final path size to avoid excessive autosize computations // Force the body to be the final path size to avoid excessive autosize computations
@ -132,7 +140,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
SnakedStart = p0; SnakedStart = p0;
SnakedEnd = p1; SnakedEnd = p1;
slider.Path.GetPathToProgress(CurrentCurve, p0, p1); drawableSlider.HitObject.Path.GetPathToProgress(CurrentCurve, p0, p1);
SetVertices(CurrentCurve); SetVertices(CurrentCurve);

View File

@ -15,13 +15,13 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
{ {
public class SpinnerRotationTracker : CircularContainer public class SpinnerRotationTracker : CircularContainer
{ {
private readonly Spinner spinner;
public override bool IsPresent => true; // handle input when hidden public override bool IsPresent => true; // handle input when hidden
public SpinnerRotationTracker(Spinner s) private readonly DrawableSpinner drawableSpinner;
public SpinnerRotationTracker(DrawableSpinner drawableSpinner)
{ {
spinner = s; this.drawableSpinner = drawableSpinner;
RelativeSizeAxes = Axes.Both; RelativeSizeAxes = Axes.Both;
} }
@ -64,7 +64,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
/// <summary> /// <summary>
/// Whether currently in the correct time range to allow spinning. /// Whether currently in the correct time range to allow spinning.
/// </summary> /// </summary>
private bool isSpinnableTime => spinner.StartTime <= Time.Current && spinner.EndTime > Time.Current; private bool isSpinnableTime => drawableSpinner.HitObject.StartTime <= Time.Current && drawableSpinner.HitObject.EndTime > Time.Current;
protected override bool OnMouseMove(MouseMoveEvent e) protected override bool OnMouseMove(MouseMoveEvent e)
{ {

View File

@ -0,0 +1,48 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Skinning;
using osuTK.Graphics;
namespace osu.Game.Rulesets.Osu.Objects.Drawables
{
public class SkinnableLighting : SkinnableSprite
{
private DrawableHitObject targetObject;
private JudgementResult targetResult;
public SkinnableLighting()
: base("lighting")
{
}
protected override void SkinChanged(ISkinSource skin, bool allowFallback)
{
base.SkinChanged(skin, allowFallback);
updateColour();
}
/// <summary>
/// Updates the lighting colour from a given hitobject and result.
/// </summary>
/// <param name="targetObject">The <see cref="DrawableHitObject"/> that's been judged.</param>
/// <param name="targetResult">The <see cref="JudgementResult"/> that <paramref name="targetObject"/> was judged with.</param>
public void SetColourFrom(DrawableHitObject targetObject, JudgementResult targetResult)
{
this.targetObject = targetObject;
this.targetResult = targetResult;
updateColour();
}
private void updateColour()
{
if (targetObject == null || targetResult == null)
Colour = Color4.White;
else
Colour = targetResult.IsHit ? targetObject.AccentColour.Value : Color4.Transparent;
}
}
}

View File

@ -11,6 +11,7 @@ using osu.Game.Graphics;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Osu.Objects; using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Rulesets.Osu.Objects.Drawables;
using osu.Game.Skinning; using osu.Game.Skinning;
using osuTK; using osuTK;
using osuTK.Graphics; using osuTK.Graphics;
@ -47,7 +48,7 @@ namespace osu.Game.Rulesets.Osu.Skinning
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(DrawableHitObject drawableObject) private void load(DrawableHitObject drawableObject)
{ {
OsuHitObject osuObject = (OsuHitObject)drawableObject.HitObject; var drawableOsuObject = (DrawableOsuHitObject)drawableObject;
bool allowFallback = false; bool allowFallback = false;
@ -111,7 +112,7 @@ namespace osu.Game.Rulesets.Osu.Skinning
state.BindTo(drawableObject.State); state.BindTo(drawableObject.State);
accentColour.BindTo(drawableObject.AccentColour); accentColour.BindTo(drawableObject.AccentColour);
indexInCurrentCombo.BindTo(osuObject.IndexInCurrentComboBindable); indexInCurrentCombo.BindTo(drawableOsuObject.IndexInCurrentComboBindable);
Texture getTextureWithFallback(string name) Texture getTextureWithFallback(string name)
{ {

View File

@ -76,10 +76,10 @@ namespace osu.Game.Rulesets.Osu.Skinning
private void updateStateTransforms(DrawableHitObject drawableHitObject, ArmedState state) private void updateStateTransforms(DrawableHitObject drawableHitObject, ArmedState state)
{ {
if (!(drawableHitObject is DrawableSpinner)) if (!(drawableHitObject is DrawableSpinner d))
return; return;
var spinner = (Spinner)drawableSpinner.HitObject; Spinner spinner = d.HitObject;
using (BeginAbsoluteSequence(spinner.StartTime - spinner.TimePreempt, true)) using (BeginAbsoluteSequence(spinner.StartTime - spinner.TimePreempt, true))
this.FadeOut(); this.FadeOut();

View File

@ -8,6 +8,7 @@ using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Framework.Utils; using osu.Framework.Utils;
using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Rulesets.Osu.Objects.Drawables; using osu.Game.Rulesets.Osu.Objects.Drawables;
using osu.Game.Skinning; using osu.Game.Skinning;
using osuTK; using osuTK;
@ -94,10 +95,10 @@ namespace osu.Game.Rulesets.Osu.Skinning
private void updateStateTransforms(DrawableHitObject drawableHitObject, ArmedState state) private void updateStateTransforms(DrawableHitObject drawableHitObject, ArmedState state)
{ {
if (!(drawableHitObject is DrawableSpinner)) if (!(drawableHitObject is DrawableSpinner d))
return; return;
var spinner = drawableSpinner.HitObject; Spinner spinner = d.HitObject;
using (BeginAbsoluteSequence(spinner.StartTime - spinner.TimePreempt, true)) using (BeginAbsoluteSequence(spinner.StartTime - spinner.TimePreempt, true))
this.FadeOut(); this.FadeOut();

View File

@ -5,7 +5,6 @@ using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Skinning; using osu.Game.Skinning;
using osuTK.Graphics; using osuTK.Graphics;
@ -26,7 +25,7 @@ namespace osu.Game.Rulesets.Osu.Skinning
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(ISkinSource skin, DrawableHitObject drawableObject) private void load(ISkinSource skin)
{ {
var ballColour = skin.GetConfig<OsuSkinColour, Color4>(OsuSkinColour.SliderBall)?.Value ?? Color4.White; var ballColour = skin.GetConfig<OsuSkinColour, Color4>(OsuSkinColour.SliderBall)?.Value ?? Color4.White;

View File

@ -4,12 +4,15 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Pooling; using osu.Framework.Graphics.Pooling;
using osu.Game.Rulesets.Judgements; using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Osu.Configuration;
using osu.Game.Rulesets.Osu.Objects.Drawables; using osu.Game.Rulesets.Osu.Objects.Drawables;
using osu.Game.Rulesets.Osu.Objects.Drawables.Connections; using osu.Game.Rulesets.Osu.Objects.Drawables.Connections;
using osu.Game.Rulesets.Osu.Scoring; using osu.Game.Rulesets.Osu.Scoring;
@ -17,9 +20,6 @@ using osu.Game.Rulesets.Osu.UI.Cursor;
using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.Scoring;
using osu.Game.Rulesets.UI; using osu.Game.Rulesets.UI;
using osu.Game.Skinning; using osu.Game.Skinning;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Game.Rulesets.Osu.Configuration;
using osuTK; using osuTK;
namespace osu.Game.Rulesets.Osu.UI namespace osu.Game.Rulesets.Osu.UI
@ -95,6 +95,8 @@ namespace osu.Game.Rulesets.Osu.UI
public override void Add(DrawableHitObject h) public override void Add(DrawableHitObject h)
{ {
DrawableOsuHitObject osuHitObject = (DrawableOsuHitObject)h;
h.OnNewResult += onNewResult; h.OnNewResult += onNewResult;
h.OnLoadComplete += d => h.OnLoadComplete += d =>
{ {
@ -107,18 +109,19 @@ namespace osu.Game.Rulesets.Osu.UI
base.Add(h); base.Add(h);
DrawableOsuHitObject osuHitObject = (DrawableOsuHitObject)h;
osuHitObject.CheckHittable = hitPolicy.IsHittable; osuHitObject.CheckHittable = hitPolicy.IsHittable;
followPoints.AddFollowPoints(osuHitObject); followPoints.AddFollowPoints(osuHitObject.HitObject);
} }
public override bool Remove(DrawableHitObject h) public override bool Remove(DrawableHitObject h)
{ {
DrawableOsuHitObject osuHitObject = (DrawableOsuHitObject)h;
bool result = base.Remove(h); bool result = base.Remove(h);
if (result) if (result)
followPoints.RemoveFollowPoints((DrawableOsuHitObject)h); followPoints.RemoveFollowPoints(osuHitObject.HitObject);
return result; return result;
} }

View File

@ -22,7 +22,7 @@ namespace osu.Game.Rulesets.Taiko.Audio
private readonly ControlPointInfo controlPoints; private readonly ControlPointInfo controlPoints;
private readonly Dictionary<double, DrumSample> mappings = new Dictionary<double, DrumSample>(); private readonly Dictionary<double, DrumSample> mappings = new Dictionary<double, DrumSample>();
private IBindableList<SampleControlPoint> samplePoints; private readonly IBindableList<SampleControlPoint> samplePoints = new BindableList<SampleControlPoint>();
public DrumSampleContainer(ControlPointInfo controlPoints) public DrumSampleContainer(ControlPointInfo controlPoints)
{ {
@ -32,7 +32,7 @@ namespace osu.Game.Rulesets.Taiko.Audio
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load() private void load()
{ {
samplePoints = controlPoints.SamplePoints.GetBoundCopy(); samplePoints.BindTo(controlPoints.SamplePoints);
samplePoints.BindCollectionChanged((_, __) => recreateMappings(), true); samplePoints.BindCollectionChanged((_, __) => recreateMappings(), true);
} }

View File

@ -43,7 +43,7 @@ namespace osu.Game.Tests.Visual.Gameplay
private Replay replay; private Replay replay;
private IBindableList<int> users; private readonly IBindableList<int> users = new BindableList<int>();
private TestReplayRecorder recorder; private TestReplayRecorder recorder;
@ -67,7 +67,7 @@ namespace osu.Game.Tests.Visual.Gameplay
{ {
replay = new Replay(); replay = new Replay();
users = streamingClient.PlayingUsers.GetBoundCopy(); users.BindTo(streamingClient.PlayingUsers);
users.BindCollectionChanged((obj, args) => users.BindCollectionChanged((obj, args) =>
{ {
switch (args.Action) switch (args.Action)

View File

@ -20,7 +20,7 @@ namespace osu.Game.Overlays.Dashboard
{ {
internal class CurrentlyPlayingDisplay : CompositeDrawable internal class CurrentlyPlayingDisplay : CompositeDrawable
{ {
private IBindableList<int> playingUsers; private readonly IBindableList<int> playingUsers = new BindableList<int>();
private FillFlowContainer<PlayingUserPanel> userFlow; private FillFlowContainer<PlayingUserPanel> userFlow;
@ -48,7 +48,7 @@ namespace osu.Game.Overlays.Dashboard
{ {
base.LoadComplete(); base.LoadComplete();
playingUsers = spectatorStreaming.PlayingUsers.GetBoundCopy(); playingUsers.BindTo(spectatorStreaming.PlayingUsers);
playingUsers.BindCollectionChanged((sender, e) => Schedule(() => playingUsers.BindCollectionChanged((sender, e) => Schedule(() =>
{ {
switch (e.Action) switch (e.Action)

View File

@ -125,14 +125,14 @@ namespace osu.Game.Rulesets.Objects.Drawables
Result = CreateResult(judgement); Result = CreateResult(judgement);
if (Result == null) if (Result == null)
throw new InvalidOperationException($"{GetType().ReadableName()} must provide a {nameof(JudgementResult)} through {nameof(CreateResult)}."); throw new InvalidOperationException($"{GetType().ReadableName()} must provide a {nameof(JudgementResult)} through {nameof(CreateResult)}.");
LoadSamples();
} }
protected override void LoadAsyncComplete() protected override void LoadAsyncComplete()
{ {
base.LoadAsyncComplete(); base.LoadAsyncComplete();
LoadSamples();
HitObject.DefaultsApplied += onDefaultsApplied; HitObject.DefaultsApplied += onDefaultsApplied;
startTimeBindable = HitObject.StartTimeBindable.GetBoundCopy(); startTimeBindable = HitObject.StartTimeBindable.GetBoundCopy();

View File

@ -14,13 +14,13 @@ namespace osu.Game.Screens.Edit.Components.Timelines.Summary.Parts
/// </summary> /// </summary>
public class ControlPointPart : TimelinePart<GroupVisualisation> public class ControlPointPart : TimelinePart<GroupVisualisation>
{ {
private IBindableList<ControlPointGroup> controlPointGroups; private readonly IBindableList<ControlPointGroup> controlPointGroups = new BindableList<ControlPointGroup>();
protected override void LoadBeatmap(WorkingBeatmap beatmap) protected override void LoadBeatmap(WorkingBeatmap beatmap)
{ {
base.LoadBeatmap(beatmap); base.LoadBeatmap(beatmap);
controlPointGroups = beatmap.Beatmap.ControlPointInfo.Groups.GetBoundCopy(); controlPointGroups.BindTo(beatmap.Beatmap.ControlPointInfo.Groups);
controlPointGroups.BindCollectionChanged((sender, args) => controlPointGroups.BindCollectionChanged((sender, args) =>
{ {
switch (args.Action) switch (args.Action)

View File

@ -15,7 +15,7 @@ namespace osu.Game.Screens.Edit.Components.Timelines.Summary.Parts
{ {
public readonly ControlPointGroup Group; public readonly ControlPointGroup Group;
private BindableList<ControlPoint> controlPoints; private readonly IBindableList<ControlPoint> controlPoints = new BindableList<ControlPoint>();
[Resolved] [Resolved]
private OsuColour colours { get; set; } private OsuColour colours { get; set; }
@ -30,7 +30,7 @@ namespace osu.Game.Screens.Edit.Components.Timelines.Summary.Parts
{ {
base.LoadComplete(); base.LoadComplete();
controlPoints = (BindableList<ControlPoint>)Group.ControlPoints.GetBoundCopy(); controlPoints.BindTo(Group.ControlPoints);
controlPoints.BindCollectionChanged((_, __) => controlPoints.BindCollectionChanged((_, __) =>
{ {
if (controlPoints.Count == 0) if (controlPoints.Count == 0)

View File

@ -16,7 +16,7 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
/// </summary> /// </summary>
public class TimelineControlPointDisplay : TimelinePart<TimelineControlPointGroup> public class TimelineControlPointDisplay : TimelinePart<TimelineControlPointGroup>
{ {
private IBindableList<ControlPointGroup> controlPointGroups; private readonly IBindableList<ControlPointGroup> controlPointGroups = new BindableList<ControlPointGroup>();
public TimelineControlPointDisplay() public TimelineControlPointDisplay()
{ {
@ -27,7 +27,7 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
{ {
base.LoadBeatmap(beatmap); base.LoadBeatmap(beatmap);
controlPointGroups = beatmap.Beatmap.ControlPointInfo.Groups.GetBoundCopy(); controlPointGroups.BindTo(beatmap.Beatmap.ControlPointInfo.Groups);
controlPointGroups.BindCollectionChanged((sender, args) => controlPointGroups.BindCollectionChanged((sender, args) =>
{ {
switch (args.Action) switch (args.Action)

View File

@ -14,7 +14,7 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
{ {
public readonly ControlPointGroup Group; public readonly ControlPointGroup Group;
private BindableList<ControlPoint> controlPoints; private readonly IBindableList<ControlPoint> controlPoints = new BindableList<ControlPoint>();
[Resolved] [Resolved]
private OsuColour colours { get; set; } private OsuColour colours { get; set; }
@ -34,7 +34,7 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
{ {
base.LoadComplete(); base.LoadComplete();
controlPoints = (BindableList<ControlPoint>)Group.ControlPoints.GetBoundCopy(); controlPoints.BindTo(Group.ControlPoints);
controlPoints.BindCollectionChanged((_, __) => controlPoints.BindCollectionChanged((_, __) =>
{ {
ClearInternal(); ClearInternal();

View File

@ -98,7 +98,7 @@ namespace osu.Game.Screens.Edit.Timing
private class ControlGroupAttributes : CompositeDrawable private class ControlGroupAttributes : CompositeDrawable
{ {
private readonly IBindableList<ControlPoint> controlPoints; private readonly IBindableList<ControlPoint> controlPoints = new BindableList<ControlPoint>();
private readonly FillFlowContainer fill; private readonly FillFlowContainer fill;
@ -112,7 +112,7 @@ namespace osu.Game.Screens.Edit.Timing
Spacing = new Vector2(2) Spacing = new Vector2(2)
}; };
controlPoints = group.ControlPoints.GetBoundCopy(); controlPoints.BindTo(group.ControlPoints);
} }
[Resolved] [Resolved]

View File

@ -56,7 +56,7 @@ namespace osu.Game.Screens.Edit.Timing
private OsuButton deleteButton; private OsuButton deleteButton;
private ControlPointTable table; private ControlPointTable table;
private IBindableList<ControlPointGroup> controlGroups; private readonly IBindableList<ControlPointGroup> controlPointGroups = new BindableList<ControlPointGroup>();
[Resolved] [Resolved]
private EditorClock clock { get; set; } private EditorClock clock { get; set; }
@ -124,11 +124,10 @@ namespace osu.Game.Screens.Edit.Timing
selectedGroup.BindValueChanged(selected => { deleteButton.Enabled.Value = selected.NewValue != null; }, true); selectedGroup.BindValueChanged(selected => { deleteButton.Enabled.Value = selected.NewValue != null; }, true);
controlGroups = Beatmap.Value.Beatmap.ControlPointInfo.Groups.GetBoundCopy(); controlPointGroups.BindTo(Beatmap.Value.Beatmap.ControlPointInfo.Groups);
controlPointGroups.BindCollectionChanged((sender, args) =>
controlGroups.BindCollectionChanged((sender, args) =>
{ {
table.ControlGroups = controlGroups; table.ControlGroups = controlPointGroups;
changeHandler.SaveState(); changeHandler.SaveState();
}, true); }, true);
} }

View File

@ -4,6 +4,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Threading;
using osu.Game.Audio; using osu.Game.Audio;
using osu.Game.Screens.Play; using osu.Game.Screens.Play;
@ -25,6 +26,8 @@ namespace osu.Game.Skinning
private readonly IBindable<bool> samplePlaybackDisabled = new Bindable<bool>(); private readonly IBindable<bool> samplePlaybackDisabled = new Bindable<bool>();
private ScheduledDelegate scheduledStart;
[BackgroundDependencyLoader(true)] [BackgroundDependencyLoader(true)]
private void load(ISamplePlaybackDisabler samplePlaybackDisabler) private void load(ISamplePlaybackDisabler samplePlaybackDisabler)
{ {
@ -39,12 +42,14 @@ namespace osu.Game.Skinning
// let non-looping samples that have already been started play out to completion (sounds better than abruptly cutting off). // let non-looping samples that have already been started play out to completion (sounds better than abruptly cutting off).
if (!Looping) return; if (!Looping) return;
cancelPendingStart();
if (disabled.NewValue) if (disabled.NewValue)
base.Stop(); base.Stop();
else else
{ {
// schedule so we don't start playing a sample which is no longer alive. // schedule so we don't start playing a sample which is no longer alive.
Schedule(() => scheduledStart = Schedule(() =>
{ {
if (RequestedPlaying) if (RequestedPlaying)
base.Play(); base.Play();
@ -56,6 +61,7 @@ namespace osu.Game.Skinning
public override void Play() public override void Play()
{ {
cancelPendingStart();
RequestedPlaying = true; RequestedPlaying = true;
if (samplePlaybackDisabled.Value) if (samplePlaybackDisabled.Value)
@ -66,8 +72,15 @@ namespace osu.Game.Skinning
public override void Stop() public override void Stop()
{ {
cancelPendingStart();
RequestedPlaying = false; RequestedPlaying = false;
base.Stop(); base.Stop();
} }
private void cancelPendingStart()
{
scheduledStart?.Cancel();
scheduledStart = null;
}
} }
} }

View File

@ -73,6 +73,14 @@
<PackageReference Include="ppy.osu.Framework.iOS" Version="2020.1029.1" /> <PackageReference Include="ppy.osu.Framework.iOS" Version="2020.1029.1" />
<PackageReference Include="ppy.osu.Game.Resources" Version="2020.1030.0" /> <PackageReference Include="ppy.osu.Game.Resources" Version="2020.1030.0" />
</ItemGroup> </ItemGroup>
<!-- See https://github.com/dotnet/runtime/issues/35988 (can be removed after Xamarin uses net5.0 / net6.0) -->
<PropertyGroup>
<NoWarn>$(NoWarn);NU1605</NoWarn>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="3.0.3" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.0.3" />
</ItemGroup>
<!-- Xamarin.iOS does not automatically handle transitive dependencies from NuGet packages. --> <!-- Xamarin.iOS does not automatically handle transitive dependencies from NuGet packages. -->
<ItemGroup Label="Transitive Dependencies"> <ItemGroup Label="Transitive Dependencies">
<PackageReference Include="DiffPlex" Version="1.6.3" /> <PackageReference Include="DiffPlex" Version="1.6.3" />