mirror of
https://github.com/osukey/osukey.git
synced 2025-08-03 22:56:36 +09:00
Merge pull request #16420 from bdach/slider-paste-parsing-failures-2
Fix pasted sliders having sample points with time at infinity
This commit is contained in:
@ -87,23 +87,6 @@ namespace osu.Game.Rulesets.Objects
|
||||
[JsonIgnore]
|
||||
public SlimReadOnlyListWrapper<HitObject> NestedHitObjects => nestedHitObjects.AsSlimReadOnly();
|
||||
|
||||
public HitObject()
|
||||
{
|
||||
StartTimeBindable.ValueChanged += time =>
|
||||
{
|
||||
double offset = time.NewValue - time.OldValue;
|
||||
|
||||
foreach (var nested in nestedHitObjects)
|
||||
nested.StartTime += offset;
|
||||
|
||||
if (DifficultyControlPoint != DifficultyControlPoint.DEFAULT)
|
||||
DifficultyControlPoint.Time = time.NewValue;
|
||||
|
||||
if (SampleControlPoint != SampleControlPoint.DEFAULT)
|
||||
SampleControlPoint.Time = this.GetEndTime() + control_point_leniency;
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Applies default values to this HitObject.
|
||||
/// </summary>
|
||||
@ -115,24 +98,22 @@ namespace osu.Game.Rulesets.Objects
|
||||
var legacyInfo = controlPointInfo as LegacyControlPointInfo;
|
||||
|
||||
if (legacyInfo != null)
|
||||
{
|
||||
DifficultyControlPoint = (DifficultyControlPoint)legacyInfo.DifficultyPointAt(StartTime).DeepClone();
|
||||
DifficultyControlPoint.Time = StartTime;
|
||||
}
|
||||
else if (DifficultyControlPoint == DifficultyControlPoint.DEFAULT)
|
||||
DifficultyControlPoint = new DifficultyControlPoint();
|
||||
|
||||
DifficultyControlPoint.Time = StartTime;
|
||||
|
||||
ApplyDefaultsToSelf(controlPointInfo, difficulty);
|
||||
|
||||
// This is done here after ApplyDefaultsToSelf as we may require custom defaults to be applied to have an accurate end time.
|
||||
if (legacyInfo != null)
|
||||
{
|
||||
SampleControlPoint = (SampleControlPoint)legacyInfo.SamplePointAt(this.GetEndTime() + control_point_leniency).DeepClone();
|
||||
SampleControlPoint.Time = this.GetEndTime() + control_point_leniency;
|
||||
}
|
||||
else if (SampleControlPoint == SampleControlPoint.DEFAULT)
|
||||
SampleControlPoint = new SampleControlPoint();
|
||||
|
||||
SampleControlPoint.Time = this.GetEndTime() + control_point_leniency;
|
||||
|
||||
nestedHitObjects.Clear();
|
||||
|
||||
CreateNestedHitObjects(cancellationToken);
|
||||
@ -155,7 +136,28 @@ namespace osu.Game.Rulesets.Objects
|
||||
foreach (var h in nestedHitObjects)
|
||||
h.ApplyDefaults(controlPointInfo, difficulty, cancellationToken);
|
||||
|
||||
// `ApplyDefaults()` may be called multiple times on a single hitobject.
|
||||
// to prevent subscribing to `StartTimeBindable.ValueChanged` multiple times with the same callback,
|
||||
// remove the previous subscription (if present) before (re-)registering.
|
||||
StartTimeBindable.ValueChanged -= onStartTimeChanged;
|
||||
|
||||
// this callback must be (re-)registered after default application
|
||||
// to ensure that the read of `this.GetEndTime()` within `onStartTimeChanged` doesn't return an invalid value
|
||||
// if `StartTimeBindable` is changed prior to default application.
|
||||
StartTimeBindable.ValueChanged += onStartTimeChanged;
|
||||
|
||||
DefaultsApplied?.Invoke(this);
|
||||
|
||||
void onStartTimeChanged(ValueChangedEvent<double> time)
|
||||
{
|
||||
double offset = time.NewValue - time.OldValue;
|
||||
|
||||
foreach (var nested in nestedHitObjects)
|
||||
nested.StartTime += offset;
|
||||
|
||||
DifficultyControlPoint.Time = time.NewValue;
|
||||
SampleControlPoint.Time = this.GetEndTime() + control_point_leniency;
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void ApplyDefaultsToSelf(ControlPointInfo controlPointInfo, IBeatmapDifficultyInfo difficulty)
|
||||
|
Reference in New Issue
Block a user