Inline single usage of StoryboardFile to avoid interface default method woes

This commit is contained in:
Dean Herbert 2021-10-04 16:50:29 +09:00
parent 8bfdfe3672
commit 4df5f93152
3 changed files with 4 additions and 12 deletions

View File

@ -107,12 +107,14 @@ namespace osu.Game.Beatmaps
{ {
var decoder = Decoder.GetDecoder<Storyboard>(stream); var decoder = Decoder.GetDecoder<Storyboard>(stream);
var storyboardFilename = BeatmapSetInfo?.Files.FirstOrDefault(f => f.Filename.EndsWith(".osb", StringComparison.OrdinalIgnoreCase))?.Filename;
// todo: support loading from both set-wide storyboard *and* beatmap specific. // todo: support loading from both set-wide storyboard *and* beatmap specific.
if (BeatmapSetInfo?.StoryboardFile == null) if (string.IsNullOrEmpty(storyboardFilename))
storyboard = decoder.Decode(stream); storyboard = decoder.Decode(stream);
else else
{ {
using (var secondaryStream = new LineBufferedReader(GetStream(BeatmapSetInfo.GetPathForFile(BeatmapSetInfo.StoryboardFile)))) using (var secondaryStream = new LineBufferedReader(GetStream(BeatmapSetInfo.GetPathForFile(storyboardFilename))))
storyboard = decoder.Decode(stream, secondaryStream); storyboard = decoder.Decode(stream, secondaryStream);
} }
} }

View File

@ -6,7 +6,6 @@ using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using System.Linq; using System.Linq;
using JetBrains.Annotations; using JetBrains.Annotations;
using Newtonsoft.Json;
using osu.Framework.Testing; using osu.Framework.Testing;
using osu.Game.Database; using osu.Game.Database;
@ -62,9 +61,6 @@ namespace osu.Game.Beatmaps
public string Hash { get; set; } public string Hash { get; set; }
[JsonIgnore]
public string StoryboardFile => ((IBeatmapSetInfo)this).StoryboardFile;
/// <summary> /// <summary>
/// Returns the storage path for the file in this beatmapset with the given filename, if any exists, otherwise null. /// Returns the storage path for the file in this beatmapset with the given filename, if any exists, otherwise null.
/// The path returned is relative to the user file storage. /// The path returned is relative to the user file storage.

View File

@ -3,7 +3,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using osu.Game.Database; using osu.Game.Database;
#nullable enable #nullable enable
@ -49,10 +48,5 @@ namespace osu.Game.Beatmaps
/// The maximum BPM of all beatmaps in this set. /// The maximum BPM of all beatmaps in this set.
/// </summary> /// </summary>
double MaxBPM { get; } double MaxBPM { get; }
/// <summary>
/// The filename for the storyboard.
/// </summary>
string StoryboardFile => Files.FirstOrDefault(f => f.Filename.EndsWith(@".osb", StringComparison.OrdinalIgnoreCase))?.Filename ?? string.Empty;
} }
} }