Skip to content

Commit

Permalink
Merge pull request #194 from WilliamQiufeng/fix-ssf-serialization
Browse files Browse the repository at this point in the history
Fix SSF not serialized for default group
  • Loading branch information
Swan authored Nov 14, 2024
2 parents 745ff93 + eeb17d6 commit abb040a
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion Quaver.API/Maps/Qua.cs
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,15 @@ public List<SliderVelocityInfo> SliderVelocities
private set => DefaultScrollGroup.ScrollVelocities = value;
}

/// <summary>
/// SSF for default group
/// </summary>
public List<ScrollSpeedFactorInfo> ScrollSpeedFactors
{
get => DefaultScrollGroup.ScrollSpeedFactors;
private set => DefaultScrollGroup.ScrollSpeedFactors = value;
}

/// <summary>
/// HitObject .qua data
/// </summary>
Expand Down Expand Up @@ -372,6 +381,7 @@ x.Signature is TimeSignature.Quadruple
var originalSoundEffects = SoundEffects;
var originalBookmarks = Bookmarks;
var originalTimingGroups = TimingGroups;
var originalDefaultSsfs = ScrollSpeedFactors;

TimingPoints = originalTimingPoints.Select(SerializableTimingPoint).ToList();
HitObjects = originalHitObjects.Select(SerializableHitObject).ToList();
Expand All @@ -381,7 +391,7 @@ x.Signature is TimeSignature.Quadruple

// Remove empty global scroll group
var globalScrollGroup = GlobalScrollGroup;
if (globalScrollGroup.ScrollVelocities.Count == 0)
if (globalScrollGroup.ScrollVelocities.Count == 0 && globalScrollGroup.ScrollSpeedFactors.Count == 0)
TimingGroups.Remove(GlobalScrollGroupId);

// Don't serialize the field at all if we dont have additional timing groups
Expand All @@ -393,6 +403,9 @@ x.Signature is TimeSignature.Quadruple
if (Bookmarks.Count == 0)
Bookmarks = null;

if (ScrollSpeedFactors.Count == 0)
ScrollSpeedFactors = null;

using var stringWriter = new StringWriter { NewLine = "\r\n" };
Serializer.Serialize(stringWriter, this);
var serialized = stringWriter.ToString();
Expand All @@ -402,6 +415,7 @@ x.Signature is TimeSignature.Quadruple
HitObjects = originalHitObjects;
SoundEffects = originalSoundEffects;
Bookmarks = originalBookmarks;
ScrollSpeedFactors = originalDefaultSsfs;

TimingGroups = originalTimingGroups;
LinkDefaultScrollGroup();
Expand Down

0 comments on commit abb040a

Please sign in to comment.