Skip to content

Commit

Permalink
Move bookmarks out of BeatmapInfo
Browse files Browse the repository at this point in the history
Not sure why I didn't do that in ppy#28473...
  • Loading branch information
bdach committed Dec 3, 2024
1 parent f09d8f0 commit 8089345
Show file tree
Hide file tree
Showing 12 changed files with 26 additions and 12 deletions.
4 changes: 2 additions & 2 deletions osu.Game.Tests/Beatmaps/Formats/LegacyBeatmapDecoderTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,9 @@ public void TestDecodeBeatmapEditor()
95901, 106450, 116999, 119637, 130186, 140735, 151285,
161834, 164471, 175020, 185570, 196119, 206669, 209306
};
Assert.AreEqual(expectedBookmarks.Length, beatmap.BeatmapInfo.Bookmarks.Length);
Assert.AreEqual(expectedBookmarks.Length, beatmap.Bookmarks.Length);
for (int i = 0; i < expectedBookmarks.Length; i++)
Assert.AreEqual(expectedBookmarks[i], beatmap.BeatmapInfo.Bookmarks[i]);
Assert.AreEqual(expectedBookmarks[i], beatmap.Bookmarks[i]);
Assert.AreEqual(1.8, beatmap.DistanceSpacing);
Assert.AreEqual(4, beatmap.BeatmapInfo.BeatDivisor);
Assert.AreEqual(4, beatmap.GridSize);
Expand Down
4 changes: 2 additions & 2 deletions osu.Game.Tests/Beatmaps/Formats/OsuJsonDecoderTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ public void TestDecodeEditor()
95901, 106450, 116999, 119637, 130186, 140735, 151285,
161834, 164471, 175020, 185570, 196119, 206669, 209306
};
Assert.AreEqual(expectedBookmarks.Length, beatmapInfo.Bookmarks.Length);
Assert.AreEqual(expectedBookmarks.Length, beatmap.Bookmarks.Length);
for (int i = 0; i < expectedBookmarks.Length; i++)
Assert.AreEqual(expectedBookmarks[i], beatmapInfo.Bookmarks[i]);
Assert.AreEqual(expectedBookmarks[i], beatmap.Bookmarks[i]);
Assert.AreEqual(1.8, beatmap.DistanceSpacing);
Assert.AreEqual(4, beatmapInfo.BeatDivisor);
Assert.AreEqual(4, beatmap.GridSize);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public TestSceneEditorSummaryTimeline()
beatmap.ControlPointInfo.Add(50000, new DifficultyControlPoint { SliderVelocity = 2 });
beatmap.ControlPointInfo.Add(80000, new EffectControlPoint { KiaiMode = true });
beatmap.ControlPointInfo.Add(110000, new EffectControlPoint { KiaiMode = false });
beatmap.BeatmapInfo.Bookmarks = new[] { 75000, 125000 };
beatmap.Bookmarks = new[] { 75000, 125000 };
beatmap.Breaks.Add(new ManualBreakPeriod(90000, 120000));

editorBeatmap = new EditorBeatmap(beatmap);
Expand Down
2 changes: 2 additions & 0 deletions osu.Game/Beatmaps/Beatmap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ public double GetMostCommonBeatLength()

public int CountdownOffset { get; set; }

public int[] Bookmarks { get; set; } = Array.Empty<int>();

IBeatmap IBeatmap.Clone() => Clone();

public Beatmap<T> Clone() => (Beatmap<T>)MemberwiseClone();
Expand Down
1 change: 1 addition & 0 deletions osu.Game/Beatmaps/BeatmapConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ protected virtual Beatmap<T> ConvertBeatmap(IBeatmap original, CancellationToken
beatmap.TimelineZoom = original.TimelineZoom;
beatmap.Countdown = original.Countdown;
beatmap.CountdownOffset = original.CountdownOffset;
beatmap.Bookmarks = original.Bookmarks;

return beatmap;
}
Expand Down
3 changes: 0 additions & 3 deletions osu.Game/Beatmaps/BeatmapInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -231,9 +231,6 @@ public void UpdateLocalScores(Realm realm)
[Obsolete("Use ScoreManager.GetMaximumAchievableComboAsync instead.")]
public int? MaxCombo { get; set; }

[Ignored]
public int[] Bookmarks { get; set; } = Array.Empty<int>();

public int BeatmapVersion;

public BeatmapInfo Clone() => (BeatmapInfo)this.Detach().MemberwiseClone();
Expand Down
2 changes: 1 addition & 1 deletion osu.Game/Beatmaps/Formats/LegacyBeatmapDecoder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ private void handleEditor(string line)
switch (pair.Key)
{
case @"Bookmarks":
beatmap.BeatmapInfo.Bookmarks = pair.Value.Split(',').Select(v =>
beatmap.Bookmarks = pair.Value.Split(',').Select(v =>
{
bool result = int.TryParse(v, out int val);
return new { result, val };
Expand Down
4 changes: 2 additions & 2 deletions osu.Game/Beatmaps/Formats/LegacyBeatmapEncoder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ private void handleEditor(TextWriter writer)
{
writer.WriteLine("[Editor]");

if (beatmap.BeatmapInfo.Bookmarks.Length > 0)
writer.WriteLine(FormattableString.Invariant($"Bookmarks: {string.Join(',', beatmap.BeatmapInfo.Bookmarks)}"));
if (beatmap.Bookmarks.Length > 0)
writer.WriteLine(FormattableString.Invariant($"Bookmarks: {string.Join(',', beatmap.Bookmarks)}"));
writer.WriteLine(FormattableString.Invariant($"DistanceSpacing: {beatmap.DistanceSpacing}"));
writer.WriteLine(FormattableString.Invariant($"BeatDivisor: {beatmap.BeatmapInfo.BeatDivisor}"));
writer.WriteLine(FormattableString.Invariant($"GridSize: {beatmap.GridSize}"));
Expand Down
2 changes: 2 additions & 0 deletions osu.Game/Beatmaps/IBeatmap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ public interface IBeatmap
/// </summary>
int CountdownOffset { get; internal set; }

int[] Bookmarks { get; internal set; }

/// <summary>
/// Creates a shallow-clone of this beatmap and returns it.
/// </summary>
Expand Down
6 changes: 6 additions & 0 deletions osu.Game/Rulesets/Difficulty/DifficultyCalculator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,12 @@ public int CountdownOffset
set => baseBeatmap.CountdownOffset = value;
}

public int[] Bookmarks
{
get => baseBeatmap.Bookmarks;
set => baseBeatmap.Bookmarks = value;
}

#endregion
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public partial class BookmarkPart : TimelinePart
protected override void LoadBeatmap(EditorBeatmap beatmap)
{
base.LoadBeatmap(beatmap);
foreach (int bookmark in beatmap.BeatmapInfo.Bookmarks)
foreach (int bookmark in beatmap.Bookmarks)
Add(new BookmarkVisualisation(bookmark));
}

Expand Down
6 changes: 6 additions & 0 deletions osu.Game/Screens/Edit/EditorBeatmap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,12 @@ public int CountdownOffset
set => PlayableBeatmap.CountdownOffset = value;
}

public int[] Bookmarks
{
get => PlayableBeatmap.Bookmarks;
set => PlayableBeatmap.Bookmarks = value;
}

public IBeatmap Clone() => (EditorBeatmap)MemberwiseClone();

private IList mutableHitObjects => (IList)PlayableBeatmap.HitObjects;
Expand Down

0 comments on commit 8089345

Please sign in to comment.