mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 15:33:05 +08:00
Fix sample changes not being applied in patcher
This commit is contained in:
parent
2ce150ba2b
commit
e0b7539c2a
@ -5,6 +5,7 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@ -15,7 +16,7 @@ using osu.Framework.Graphics.Textures;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Beatmaps.ControlPoints;
|
||||
using osu.Game.Beatmaps.Formats;
|
||||
using osu.Game.Beatmaps.Legacy;
|
||||
using osu.Game.Extensions;
|
||||
using osu.Game.IO;
|
||||
using osu.Game.Rulesets.Objects.Types;
|
||||
using osu.Game.Skinning;
|
||||
@ -44,7 +45,7 @@ namespace osu.Game.Screens.Edit
|
||||
editorBeatmap.BeginChange();
|
||||
processHitObjects(result, () => newBeatmap ??= readBeatmap(newState));
|
||||
processTimingPoints(() => newBeatmap ??= readBeatmap(newState));
|
||||
processSliderVelocity(() => newBeatmap ??= readBeatmap(newState));
|
||||
processHitObjectLocalData(() => newBeatmap ??= readBeatmap(newState));
|
||||
editorBeatmap.EndChange();
|
||||
}
|
||||
|
||||
@ -74,17 +75,6 @@ namespace osu.Game.Screens.Edit
|
||||
}
|
||||
}
|
||||
|
||||
private void processSliderVelocity(Func<IBeatmap> getNewBeatmap)
|
||||
{
|
||||
var legacyControlPoints = (LegacyControlPointInfo)getNewBeatmap().ControlPointInfo;
|
||||
|
||||
foreach (var hitObject in editorBeatmap.HitObjects.Where(ho => ho is IHasSliderVelocity))
|
||||
{
|
||||
var difficultyPoint = legacyControlPoints.DifficultyPointAt(hitObject.StartTime);
|
||||
((IHasSliderVelocity)hitObject).SliderVelocity = difficultyPoint.SliderVelocity;
|
||||
}
|
||||
}
|
||||
|
||||
private void processHitObjects(DiffResult result, Func<IBeatmap> getNewBeatmap)
|
||||
{
|
||||
findChangedIndices(result, LegacyDecoder<Beatmap>.Section.HitObjects, out var removedIndices, out var addedIndices);
|
||||
@ -101,6 +91,36 @@ namespace osu.Game.Screens.Edit
|
||||
}
|
||||
}
|
||||
|
||||
private void processHitObjectLocalData(Func<IBeatmap> getNewBeatmap)
|
||||
{
|
||||
// This method handles data that are stored in control points in the legacy format,
|
||||
// but were moved to the hitobjects themselves in lazer.
|
||||
// Specifically, the data being referred to here consists of: slider velocity and sample information.
|
||||
|
||||
// For simplicity, this implementation relies on the editor beatmap already having the same hitobjects in sequence as the new beatmap.
|
||||
// To guarantee that, `processHitObjects()` must be ran prior to this method for correct operation.
|
||||
// This is done to avoid the necessity of reimplementing/reusing parts of LegacyBeatmapDecoder that already treat this data correctly.
|
||||
|
||||
var oldObjects = editorBeatmap.HitObjects;
|
||||
var newObjects = getNewBeatmap().HitObjects;
|
||||
|
||||
Debug.Assert(oldObjects.Count == newObjects.Count);
|
||||
|
||||
foreach (var (oldObject, newObject) in oldObjects.Zip(newObjects))
|
||||
{
|
||||
if (oldObject is IHasSliderVelocity oldWithVelocity && newObject is IHasSliderVelocity newWithVelocity)
|
||||
oldWithVelocity.SliderVelocity = newWithVelocity.SliderVelocity;
|
||||
|
||||
oldObject.Samples = newObject.Samples;
|
||||
|
||||
if (oldObject is IHasRepeats oldWithRepeats && newObject is IHasRepeats newWithRepeats)
|
||||
{
|
||||
oldWithRepeats.NodeSamples.Clear();
|
||||
oldWithRepeats.NodeSamples.AddRange(newWithRepeats.NodeSamples);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void findChangedIndices(DiffResult result, LegacyDecoder<Beatmap>.Section section, out List<int> removedIndices, out List<int> addedIndices)
|
||||
{
|
||||
removedIndices = new List<int>();
|
||||
|
Loading…
Reference in New Issue
Block a user