mirror of
https://github.com/ppy/osu.git
synced 2025-03-15 15:27:20 +08:00
Clone and copy ControlPointInfo when retrieving a playable beatmap
This commit is contained in:
parent
cd7a5ca23a
commit
ba4e411422
@ -28,5 +28,22 @@ namespace osu.Game.Beatmaps.ControlPoints
|
||||
/// <param name="existing">An existing control point to compare with.</param>
|
||||
/// <returns>Whether this <see cref="ControlPoint"/> is redundant when placed alongside <paramref name="existing"/>.</returns>
|
||||
public abstract bool IsRedundant(ControlPoint existing);
|
||||
|
||||
/// <summary>
|
||||
/// Create a copy of this room without online information.
|
||||
/// Should be used to create a local copy of a room for submitting in the future.
|
||||
/// </summary>
|
||||
public ControlPoint CreateCopy()
|
||||
{
|
||||
var copy = (ControlPoint)Activator.CreateInstance(GetType());
|
||||
|
||||
copy.CopyFrom(this);
|
||||
|
||||
return copy;
|
||||
}
|
||||
|
||||
public virtual void CopyFrom(ControlPoint other)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ using osu.Framework.Lists;
|
||||
namespace osu.Game.Beatmaps.ControlPoints
|
||||
{
|
||||
[Serializable]
|
||||
public class ControlPointInfo
|
||||
public class ControlPointInfo : ICloneable
|
||||
{
|
||||
/// <summary>
|
||||
/// All control points grouped by time.
|
||||
@ -297,5 +297,15 @@ namespace osu.Game.Beatmaps.ControlPoints
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public object Clone()
|
||||
{
|
||||
var controlPointInfo = new ControlPointInfo();
|
||||
|
||||
foreach (var point in AllControlPoints)
|
||||
controlPointInfo.Add(point.Time, point.CreateCopy());
|
||||
|
||||
return controlPointInfo;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -39,5 +39,12 @@ namespace osu.Game.Beatmaps.ControlPoints
|
||||
public override bool IsRedundant(ControlPoint existing)
|
||||
=> existing is DifficultyControlPoint existingDifficulty
|
||||
&& SpeedMultiplier == existingDifficulty.SpeedMultiplier;
|
||||
|
||||
public override void CopyFrom(ControlPoint other)
|
||||
{
|
||||
SpeedMultiplier = ((DifficultyControlPoint)other).SpeedMultiplier;
|
||||
|
||||
base.CopyFrom(other);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -50,5 +50,13 @@ namespace osu.Game.Beatmaps.ControlPoints
|
||||
&& existing is EffectControlPoint existingEffect
|
||||
&& KiaiMode == existingEffect.KiaiMode
|
||||
&& OmitFirstBarLine == existingEffect.OmitFirstBarLine;
|
||||
|
||||
public override void CopyFrom(ControlPoint other)
|
||||
{
|
||||
KiaiMode = ((EffectControlPoint)other).KiaiMode;
|
||||
OmitFirstBarLine = ((EffectControlPoint)other).OmitFirstBarLine;
|
||||
|
||||
base.CopyFrom(other);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -72,5 +72,13 @@ namespace osu.Game.Beatmaps.ControlPoints
|
||||
=> existing is SampleControlPoint existingSample
|
||||
&& SampleBank == existingSample.SampleBank
|
||||
&& SampleVolume == existingSample.SampleVolume;
|
||||
|
||||
public override void CopyFrom(ControlPoint other)
|
||||
{
|
||||
SampleVolume = ((SampleControlPoint)other).SampleVolume;
|
||||
SampleBank = ((SampleControlPoint)other).SampleBank;
|
||||
|
||||
base.CopyFrom(other);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -69,5 +69,13 @@ namespace osu.Game.Beatmaps.ControlPoints
|
||||
|
||||
// Timing points are never redundant as they can change the time signature.
|
||||
public override bool IsRedundant(ControlPoint existing) => false;
|
||||
|
||||
public override void CopyFrom(ControlPoint other)
|
||||
{
|
||||
TimeSignature = ((TimingControlPoint)other).TimeSignature;
|
||||
BeatLength = ((TimingControlPoint)other).BeatLength;
|
||||
|
||||
base.CopyFrom(other);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -164,13 +164,24 @@ namespace osu.Game.Beatmaps.Formats
|
||||
/// Legacy BPM multiplier that introduces floating-point errors for rulesets that depend on it.
|
||||
/// DO NOT USE THIS UNLESS 100% SURE.
|
||||
/// </summary>
|
||||
public readonly float BpmMultiplier;
|
||||
public float BpmMultiplier { get; set; }
|
||||
|
||||
public LegacyDifficultyControlPoint(double beatLength)
|
||||
: this()
|
||||
{
|
||||
BpmMultiplier = beatLength < 0 ? Math.Clamp((float)-beatLength, 10, 10000) / 100f : 1;
|
||||
}
|
||||
|
||||
public LegacyDifficultyControlPoint()
|
||||
{
|
||||
SpeedMultiplierBindable.Precision = double.Epsilon;
|
||||
}
|
||||
|
||||
BpmMultiplier = beatLength < 0 ? Math.Clamp((float)-beatLength, 10, 10000) / 100f : 1;
|
||||
public override void CopyFrom(ControlPoint other)
|
||||
{
|
||||
base.CopyFrom(other);
|
||||
|
||||
BpmMultiplier = ((LegacyDifficultyControlPoint)other).BpmMultiplier;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,7 @@ namespace osu.Game.Beatmaps
|
||||
/// <summary>
|
||||
/// The control points in this beatmap.
|
||||
/// </summary>
|
||||
ControlPointInfo ControlPointInfo { get; }
|
||||
ControlPointInfo ControlPointInfo { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The breaks in this beatmap.
|
||||
|
@ -14,6 +14,7 @@ using osu.Framework.Graphics.Textures;
|
||||
using osu.Framework.Logging;
|
||||
using osu.Framework.Statistics;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Beatmaps.ControlPoints;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Rulesets.Objects.Types;
|
||||
@ -111,6 +112,8 @@ namespace osu.Game.Beatmaps
|
||||
// Convert
|
||||
IBeatmap converted = converter.Convert(cancellationSource.Token);
|
||||
|
||||
converted.ControlPointInfo = (ControlPointInfo)converted.ControlPointInfo.Clone();
|
||||
|
||||
// Apply conversion mods to the result
|
||||
foreach (var mod in mods.OfType<IApplicableAfterBeatmapConversion>())
|
||||
{
|
||||
|
@ -74,7 +74,11 @@ namespace osu.Game.Screens.Edit
|
||||
|
||||
public BeatmapMetadata Metadata => PlayableBeatmap.Metadata;
|
||||
|
||||
public ControlPointInfo ControlPointInfo => PlayableBeatmap.ControlPointInfo;
|
||||
public ControlPointInfo ControlPointInfo
|
||||
{
|
||||
get => PlayableBeatmap.ControlPointInfo;
|
||||
set => PlayableBeatmap.ControlPointInfo = value;
|
||||
}
|
||||
|
||||
public List<BreakPeriod> Breaks => PlayableBeatmap.Breaks;
|
||||
|
||||
|
@ -29,7 +29,11 @@ namespace osu.Game.Screens.Play
|
||||
|
||||
public BeatmapMetadata Metadata => PlayableBeatmap.Metadata;
|
||||
|
||||
public ControlPointInfo ControlPointInfo => PlayableBeatmap.ControlPointInfo;
|
||||
public ControlPointInfo ControlPointInfo
|
||||
{
|
||||
get => PlayableBeatmap.ControlPointInfo;
|
||||
set => PlayableBeatmap.ControlPointInfo = value;
|
||||
}
|
||||
|
||||
public List<BreakPeriod> Breaks => PlayableBeatmap.Breaks;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user