1
0
mirror of https://github.com/ppy/osu.git synced 2025-03-03 23:23:25 +08:00

Move Countdown out of BeatmapInfo

This commit is contained in:
Bartłomiej Dach 2024-06-12 13:58:00 +02:00
parent 7f2a6f6f5a
commit d373f752d6
No known key found for this signature in database
11 changed files with 28 additions and 15 deletions

View File

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

View File

@ -57,7 +57,7 @@ namespace osu.Game.Tests.Beatmaps.Formats
Assert.IsTrue(beatmapInfo.Ruleset.OnlineID == 0); Assert.IsTrue(beatmapInfo.Ruleset.OnlineID == 0);
Assert.AreEqual(false, beatmap.LetterboxInBreaks); Assert.AreEqual(false, beatmap.LetterboxInBreaks);
Assert.AreEqual(false, beatmap.WidescreenStoryboard); Assert.AreEqual(false, beatmap.WidescreenStoryboard);
Assert.AreEqual(CountdownType.None, beatmapInfo.Countdown); Assert.AreEqual(CountdownType.None, beatmap.Countdown);
Assert.AreEqual(0, beatmapInfo.CountdownOffset); Assert.AreEqual(0, beatmapInfo.CountdownOffset);
} }

View File

@ -51,7 +51,7 @@ namespace osu.Game.Tests.Visual.Editing
{ {
AddStep("turn countdown off", () => designSection.EnableCountdown.Current.Value = false); AddStep("turn countdown off", () => designSection.EnableCountdown.Current.Value = false);
AddAssert("beatmap has correct type", () => editorBeatmap.BeatmapInfo.Countdown == CountdownType.None); AddAssert("beatmap has correct type", () => editorBeatmap.Countdown == CountdownType.None);
AddUntilStep("other controls hidden", () => !designSection.CountdownSettings.IsPresent); AddUntilStep("other controls hidden", () => !designSection.CountdownSettings.IsPresent);
} }
@ -60,12 +60,12 @@ namespace osu.Game.Tests.Visual.Editing
{ {
AddStep("turn countdown on", () => designSection.EnableCountdown.Current.Value = true); AddStep("turn countdown on", () => designSection.EnableCountdown.Current.Value = true);
AddAssert("beatmap has correct type", () => editorBeatmap.BeatmapInfo.Countdown == CountdownType.Normal); AddAssert("beatmap has correct type", () => editorBeatmap.Countdown == CountdownType.Normal);
AddUntilStep("other controls shown", () => designSection.CountdownSettings.IsPresent); AddUntilStep("other controls shown", () => designSection.CountdownSettings.IsPresent);
AddStep("change countdown speed", () => designSection.CountdownSpeed.Current.Value = CountdownType.DoubleSpeed); AddStep("change countdown speed", () => designSection.CountdownSpeed.Current.Value = CountdownType.DoubleSpeed);
AddAssert("beatmap has correct type", () => editorBeatmap.BeatmapInfo.Countdown == CountdownType.DoubleSpeed); AddAssert("beatmap has correct type", () => editorBeatmap.Countdown == CountdownType.DoubleSpeed);
AddUntilStep("other controls still shown", () => designSection.CountdownSettings.IsPresent); AddUntilStep("other controls still shown", () => designSection.CountdownSettings.IsPresent);
} }
@ -74,7 +74,7 @@ namespace osu.Game.Tests.Visual.Editing
{ {
AddStep("turn countdown on", () => designSection.EnableCountdown.Current.Value = true); AddStep("turn countdown on", () => designSection.EnableCountdown.Current.Value = true);
AddAssert("beatmap has correct type", () => editorBeatmap.BeatmapInfo.Countdown == CountdownType.Normal); AddAssert("beatmap has correct type", () => editorBeatmap.Countdown == CountdownType.Normal);
checkOffsetAfter("1", 1); checkOffsetAfter("1", 1);
checkOffsetAfter(string.Empty, 0); checkOffsetAfter(string.Empty, 0);

View File

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

View File

@ -148,9 +148,6 @@ namespace osu.Game.Beatmaps
/// </summary> /// </summary>
public double? EditorTimestamp { get; set; } public double? EditorTimestamp { get; set; }
[Ignored]
public CountdownType Countdown { get; set; } = CountdownType.Normal;
/// <summary> /// <summary>
/// The number of beats to move the countdown backwards (compared to its default location). /// The number of beats to move the countdown backwards (compared to its default location).
/// </summary> /// </summary>

View File

@ -305,7 +305,7 @@ namespace osu.Game.Beatmaps.Formats
break; break;
case @"Countdown": case @"Countdown":
beatmap.BeatmapInfo.Countdown = Enum.Parse<CountdownType>(pair.Value); beatmap.Countdown = Enum.Parse<CountdownType>(pair.Value);
break; break;
case @"CountdownOffset": case @"CountdownOffset":

View File

@ -81,7 +81,7 @@ namespace osu.Game.Beatmaps.Formats
if (!string.IsNullOrEmpty(beatmap.Metadata.AudioFile)) writer.WriteLine(FormattableString.Invariant($"AudioFilename: {Path.GetFileName(beatmap.Metadata.AudioFile)}")); if (!string.IsNullOrEmpty(beatmap.Metadata.AudioFile)) writer.WriteLine(FormattableString.Invariant($"AudioFilename: {Path.GetFileName(beatmap.Metadata.AudioFile)}"));
writer.WriteLine(FormattableString.Invariant($"AudioLeadIn: {beatmap.AudioLeadIn}")); writer.WriteLine(FormattableString.Invariant($"AudioLeadIn: {beatmap.AudioLeadIn}"));
writer.WriteLine(FormattableString.Invariant($"PreviewTime: {beatmap.Metadata.PreviewTime}")); writer.WriteLine(FormattableString.Invariant($"PreviewTime: {beatmap.Metadata.PreviewTime}"));
writer.WriteLine(FormattableString.Invariant($"Countdown: {(int)beatmap.BeatmapInfo.Countdown}")); writer.WriteLine(FormattableString.Invariant($"Countdown: {(int)beatmap.Countdown}"));
writer.WriteLine(FormattableString.Invariant( writer.WriteLine(FormattableString.Invariant(
$"SampleSet: {toLegacySampleBank(((beatmap.ControlPointInfo as LegacyControlPointInfo)?.SamplePoints.FirstOrDefault() ?? SampleControlPoint.DEFAULT).SampleBank)}")); $"SampleSet: {toLegacySampleBank(((beatmap.ControlPointInfo as LegacyControlPointInfo)?.SamplePoints.FirstOrDefault() ?? SampleControlPoint.DEFAULT).SampleBank)}"));
writer.WriteLine(FormattableString.Invariant($"StackLeniency: {beatmap.StackLeniency}")); writer.WriteLine(FormattableString.Invariant($"StackLeniency: {beatmap.StackLeniency}"));

View File

@ -99,6 +99,8 @@ namespace osu.Game.Beatmaps
double TimelineZoom { get; internal set; } double TimelineZoom { get; internal set; }
CountdownType Countdown { get; internal set; }
/// <summary> /// <summary>
/// Creates a shallow-clone of this beatmap and returns it. /// Creates a shallow-clone of this beatmap and returns it.
/// </summary> /// </summary>

View File

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

View File

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

View File

@ -38,7 +38,7 @@ namespace osu.Game.Screens.Edit.Setup
EnableCountdown = new LabelledSwitchButton EnableCountdown = new LabelledSwitchButton
{ {
Label = EditorSetupStrings.EnableCountdown, Label = EditorSetupStrings.EnableCountdown,
Current = { Value = Beatmap.BeatmapInfo.Countdown != CountdownType.None }, Current = { Value = Beatmap.Countdown != CountdownType.None },
Description = EditorSetupStrings.CountdownDescription Description = EditorSetupStrings.CountdownDescription
}, },
CountdownSettings = new FillFlowContainer CountdownSettings = new FillFlowContainer
@ -52,7 +52,7 @@ namespace osu.Game.Screens.Edit.Setup
CountdownSpeed = new LabelledEnumDropdown<CountdownType> CountdownSpeed = new LabelledEnumDropdown<CountdownType>
{ {
Label = EditorSetupStrings.CountdownSpeed, Label = EditorSetupStrings.CountdownSpeed,
Current = { Value = Beatmap.BeatmapInfo.Countdown != CountdownType.None ? Beatmap.BeatmapInfo.Countdown : CountdownType.Normal }, Current = { Value = Beatmap.Countdown != CountdownType.None ? Beatmap.Countdown : CountdownType.Normal },
Items = Enum.GetValues<CountdownType>().Where(type => type != CountdownType.None) Items = Enum.GetValues<CountdownType>().Where(type => type != CountdownType.None)
}, },
CountdownOffset = new LabelledNumberBox CountdownOffset = new LabelledNumberBox
@ -118,7 +118,7 @@ namespace osu.Game.Screens.Edit.Setup
private void updateBeatmap() private void updateBeatmap()
{ {
Beatmap.BeatmapInfo.Countdown = EnableCountdown.Current.Value ? CountdownSpeed.Current.Value : CountdownType.None; 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.BeatmapInfo.CountdownOffset = int.TryParse(CountdownOffset.Current.Value, NumberStyles.None, CultureInfo.InvariantCulture, out int offset) ? offset : 0;
Beatmap.WidescreenStoryboard = widescreenSupport.Current.Value; Beatmap.WidescreenStoryboard = widescreenSupport.Current.Value;