mirror of
https://github.com/osukey/osukey.git
synced 2025-07-03 01:09:57 +09:00
Support undo/redo for control points
This commit is contained in:
@ -71,31 +71,7 @@ namespace osu.Game.Screens.Edit
|
||||
public EditorBeatmap(IBeatmap playableBeatmap, ISkin beatmapSkin = null, BeatmapInfo beatmapInfo = null)
|
||||
{
|
||||
PlayableBeatmap = playableBeatmap;
|
||||
|
||||
// ensure we are not working with legacy control points.
|
||||
// if we leave the legacy points around they will be applied over any local changes on
|
||||
// ApplyDefaults calls. this should eventually be removed once the default logic is moved to the decoder/converter.
|
||||
if (PlayableBeatmap.ControlPointInfo is LegacyControlPointInfo)
|
||||
{
|
||||
var newControlPoints = new ControlPointInfo();
|
||||
|
||||
foreach (var controlPoint in PlayableBeatmap.ControlPointInfo.AllControlPoints)
|
||||
{
|
||||
switch (controlPoint)
|
||||
{
|
||||
case DifficultyControlPoint _:
|
||||
case SampleControlPoint _:
|
||||
// skip legacy types.
|
||||
continue;
|
||||
|
||||
default:
|
||||
newControlPoints.Add(controlPoint.Time, controlPoint);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
playableBeatmap.ControlPointInfo = newControlPoints;
|
||||
}
|
||||
PlayableBeatmap.ControlPointInfo = ConvertControlPoints(PlayableBeatmap.ControlPointInfo);
|
||||
|
||||
this.beatmapInfo = beatmapInfo ?? playableBeatmap.BeatmapInfo;
|
||||
|
||||
@ -108,6 +84,39 @@ namespace osu.Game.Screens.Edit
|
||||
trackStartTime(obj);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts a <see cref="ControlPointInfo"/> such that the resultant <see cref="ControlPointInfo"/> is non-legacy.
|
||||
/// </summary>
|
||||
/// <param name="incoming">The <see cref="ControlPointInfo"/> to convert.</param>
|
||||
/// <returns>The non-legacy <see cref="ControlPointInfo"/>. <paramref name="incoming"/> is returned if already non-legacy.</returns>
|
||||
public static ControlPointInfo ConvertControlPoints(ControlPointInfo incoming)
|
||||
{
|
||||
// ensure we are not working with legacy control points.
|
||||
// if we leave the legacy points around they will be applied over any local changes on
|
||||
// ApplyDefaults calls. this should eventually be removed once the default logic is moved to the decoder/converter.
|
||||
if (!(incoming is LegacyControlPointInfo))
|
||||
return incoming;
|
||||
|
||||
var newControlPoints = new ControlPointInfo();
|
||||
|
||||
foreach (var controlPoint in incoming.AllControlPoints)
|
||||
{
|
||||
switch (controlPoint)
|
||||
{
|
||||
case DifficultyControlPoint _:
|
||||
case SampleControlPoint _:
|
||||
// skip legacy types.
|
||||
continue;
|
||||
|
||||
default:
|
||||
newControlPoints.Add(controlPoint.Time, controlPoint);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return newControlPoints;
|
||||
}
|
||||
|
||||
public BeatmapInfo BeatmapInfo
|
||||
{
|
||||
get => beatmapInfo;
|
||||
|
Reference in New Issue
Block a user