1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-05 10:33:22 +08:00

Move CountdownOffset out of BeatmapInfo

This commit is contained in:
Bartłomiej Dach 2024-06-12 14:03:02 +02:00
parent d373f752d6
commit dd50d6fa6e
No known key found for this signature in database
13 changed files with 31 additions and 16 deletions

View File

@ -89,7 +89,7 @@ namespace osu.Game.Tests.Beatmaps.Formats
Assert.IsFalse(beatmap.WidescreenStoryboard);
Assert.IsFalse(beatmap.SamplesMatchPlaybackRate);
Assert.AreEqual(CountdownType.None, beatmap.Countdown);
Assert.AreEqual(0, beatmapInfo.CountdownOffset);
Assert.AreEqual(0, beatmap.CountdownOffset);
}
}
@ -958,7 +958,7 @@ namespace osu.Game.Tests.Beatmaps.Formats
Assert.That(decoded.EpilepsyWarning, Is.False);
Assert.That(decoded.SamplesMatchPlaybackRate, Is.False);
Assert.That(decoded.Countdown, Is.EqualTo(CountdownType.Normal));
Assert.That(decoded.BeatmapInfo.CountdownOffset, Is.EqualTo(0));
Assert.That(decoded.CountdownOffset, Is.EqualTo(0));
Assert.That(decoded.BeatmapInfo.Metadata.PreviewTime, Is.EqualTo(-1));
Assert.That(decoded.BeatmapInfo.Ruleset.OnlineID, Is.EqualTo(0));
});

View File

@ -58,7 +58,7 @@ namespace osu.Game.Tests.Beatmaps.Formats
Assert.AreEqual(false, beatmap.LetterboxInBreaks);
Assert.AreEqual(false, beatmap.WidescreenStoryboard);
Assert.AreEqual(CountdownType.None, beatmap.Countdown);
Assert.AreEqual(0, beatmapInfo.CountdownOffset);
Assert.AreEqual(0, beatmap.CountdownOffset);
}
[Test]

View File

@ -41,7 +41,7 @@ namespace osu.Game.Tests.Database
Assert.That(lastChanges?.ModifiedIndices, Is.Empty);
Assert.That(lastChanges?.NewModifiedIndices, Is.Empty);
realm.Write(r => r.All<BeatmapSetInfo>().First().Beatmaps.First().CountdownOffset = 5);
realm.Write(r => r.All<BeatmapSetInfo>().First().Beatmaps.First().EditorTimestamp = 5);
realm.Run(r => r.Refresh());
Assert.That(collectionChanges, Is.EqualTo(1));

View File

@ -94,7 +94,7 @@ namespace osu.Game.Tests.Visual.Editing
AddStep("commit text", () => InputManager.Key(Key.Enter));
AddAssert($"displayed value is {expectedFinalValue}", () => designSection.CountdownOffset.Current.Value == expectedFinalValue.ToString(CultureInfo.InvariantCulture));
AddAssert($"beatmap value is {expectedFinalValue}", () => editorBeatmap.BeatmapInfo.CountdownOffset == expectedFinalValue);
AddAssert($"beatmap value is {expectedFinalValue}", () => editorBeatmap.CountdownOffset == expectedFinalValue);
}
private partial class TestDesignSection : DesignSection

View File

@ -136,6 +136,8 @@ namespace osu.Game.Beatmaps
public CountdownType Countdown { get; set; } = CountdownType.Normal;
public int CountdownOffset { get; set; }
IBeatmap IBeatmap.Clone() => Clone();
public Beatmap<T> Clone() => (Beatmap<T>)MemberwiseClone();

View File

@ -77,6 +77,7 @@ namespace osu.Game.Beatmaps
beatmap.DistanceSpacing = original.DistanceSpacing;
beatmap.GridSize = original.GridSize;
beatmap.TimelineZoom = original.TimelineZoom;
beatmap.CountdownOffset = original.CountdownOffset;
return beatmap;
}

View File

@ -148,11 +148,6 @@ namespace osu.Game.Beatmaps
/// </summary>
public double? EditorTimestamp { get; set; }
/// <summary>
/// The number of beats to move the countdown backwards (compared to its default location).
/// </summary>
public int CountdownOffset { get; set; }
#endregion
public bool Equals(BeatmapInfo? other)

View File

@ -309,7 +309,7 @@ namespace osu.Game.Beatmaps.Formats
break;
case @"CountdownOffset":
beatmap.BeatmapInfo.CountdownOffset = Parsing.ParseInt(pair.Value);
beatmap.CountdownOffset = Parsing.ParseInt(pair.Value);
break;
}
}

View File

@ -97,8 +97,8 @@ namespace osu.Game.Beatmaps.Formats
// writer.WriteLine(@"SkinPreference:" + b.SkinPreference);
if (beatmap.EpilepsyWarning)
writer.WriteLine(@"EpilepsyWarning: 1");
if (beatmap.BeatmapInfo.CountdownOffset > 0)
writer.WriteLine(FormattableString.Invariant($@"CountdownOffset: {beatmap.BeatmapInfo.CountdownOffset}"));
if (beatmap.CountdownOffset > 0)
writer.WriteLine(FormattableString.Invariant($@"CountdownOffset: {beatmap.CountdownOffset}"));
if (onlineRulesetID == 3)
writer.WriteLine(FormattableString.Invariant($"SpecialStyle: {(beatmap.SpecialStyle ? '1' : '0')}"));
writer.WriteLine(FormattableString.Invariant($"WidescreenStoryboard: {(beatmap.WidescreenStoryboard ? '1' : '0')}"));

View File

@ -101,6 +101,11 @@ namespace osu.Game.Beatmaps
CountdownType Countdown { get; internal set; }
/// <summary>
/// The number of beats to move the countdown backwards (compared to its default location).
/// </summary>
int CountdownOffset { get; internal set; }
/// <summary>
/// Creates a shallow-clone of this beatmap and returns it.
/// </summary>

View File

@ -403,6 +403,12 @@ namespace osu.Game.Rulesets.Difficulty
set => baseBeatmap.Countdown = value;
}
public int CountdownOffset
{
get => baseBeatmap.CountdownOffset;
set => baseBeatmap.CountdownOffset = value;
}
#endregion
}
}

View File

@ -250,6 +250,12 @@ namespace osu.Game.Screens.Edit
set => PlayableBeatmap.Countdown = value;
}
public int CountdownOffset
{
get => PlayableBeatmap.CountdownOffset;
set => PlayableBeatmap.CountdownOffset = value;
}
public IBeatmap Clone() => (EditorBeatmap)MemberwiseClone();
private IList mutableHitObjects => (IList)PlayableBeatmap.HitObjects;

View File

@ -58,7 +58,7 @@ namespace osu.Game.Screens.Edit.Setup
CountdownOffset = new LabelledNumberBox
{
Label = EditorSetupStrings.CountdownOffset,
Current = { Value = Beatmap.BeatmapInfo.CountdownOffset.ToString() },
Current = { Value = Beatmap.CountdownOffset.ToString() },
Description = EditorSetupStrings.CountdownOffsetDescription,
}
}
@ -113,13 +113,13 @@ namespace osu.Game.Screens.Edit.Setup
{
updateBeatmap();
// update displayed text to ensure parsed value matches display (i.e. if empty string was provided).
CountdownOffset.Current.Value = Beatmap.BeatmapInfo.CountdownOffset.ToString(CultureInfo.InvariantCulture);
CountdownOffset.Current.Value = Beatmap.CountdownOffset.ToString(CultureInfo.InvariantCulture);
}
private void updateBeatmap()
{
Beatmap.Countdown = EnableCountdown.Current.Value ? CountdownSpeed.Current.Value : CountdownType.None;
Beatmap.BeatmapInfo.CountdownOffset = int.TryParse(CountdownOffset.Current.Value, NumberStyles.None, CultureInfo.InvariantCulture, out int offset) ? offset : 0;
Beatmap.CountdownOffset = int.TryParse(CountdownOffset.Current.Value, NumberStyles.None, CultureInfo.InvariantCulture, out int offset) ? offset : 0;
Beatmap.WidescreenStoryboard = widescreenSupport.Current.Value;
Beatmap.EpilepsyWarning = epilepsyWarning.Current.Value;