mirror of
https://github.com/osukey/osukey.git
synced 2025-06-05 21:07:18 +09:00
Merge pull request #19022 from peppy/better-file-loading-exceptions
Add local handling of cases where a beatmap's file cannot be found on disk
This commit is contained in:
commit
d4c539687e
@ -137,8 +137,17 @@ namespace osu.Game.Beatmaps
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using (var stream = new LineBufferedReader(GetStream(BeatmapSetInfo.GetPathForFile(BeatmapInfo.Path))))
|
string fileStorePath = BeatmapSetInfo.GetPathForFile(BeatmapInfo.Path);
|
||||||
return Decoder.GetDecoder<Beatmap>(stream).Decode(stream);
|
var stream = GetStream(fileStorePath);
|
||||||
|
|
||||||
|
if (stream == null)
|
||||||
|
{
|
||||||
|
Logger.Log($"Beatmap failed to load (file {BeatmapInfo.Path} not found on disk at expected location {fileStorePath}).", level: LogLevel.Error);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
using (var reader = new LineBufferedReader(stream))
|
||||||
|
return Decoder.GetDecoder<Beatmap>(reader).Decode(reader);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
@ -154,7 +163,16 @@ namespace osu.Game.Beatmaps
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return resources.LargeTextureStore.Get(BeatmapSetInfo.GetPathForFile(Metadata.BackgroundFile));
|
string fileStorePath = BeatmapSetInfo.GetPathForFile(Metadata.BackgroundFile);
|
||||||
|
var texture = resources.LargeTextureStore.Get(fileStorePath);
|
||||||
|
|
||||||
|
if (texture == null)
|
||||||
|
{
|
||||||
|
Logger.Log($"Beatmap background failed to load (file {Metadata.BackgroundFile} not found on disk at expected location {fileStorePath}).", level: LogLevel.Error);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return texture;
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
@ -173,7 +191,16 @@ namespace osu.Game.Beatmaps
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return resources.Tracks.Get(BeatmapSetInfo.GetPathForFile(Metadata.AudioFile));
|
string fileStorePath = BeatmapSetInfo.GetPathForFile(Metadata.AudioFile);
|
||||||
|
var track = resources.Tracks.Get(fileStorePath);
|
||||||
|
|
||||||
|
if (track == null)
|
||||||
|
{
|
||||||
|
Logger.Log($"Beatmap failed to load (file {Metadata.AudioFile} not found on disk at expected location {fileStorePath}).", level: LogLevel.Error);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return track;
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
@ -192,8 +219,17 @@ namespace osu.Game.Beatmaps
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var trackData = GetStream(BeatmapSetInfo.GetPathForFile(Metadata.AudioFile));
|
string fileStorePath = BeatmapSetInfo.GetPathForFile(Metadata.AudioFile);
|
||||||
return trackData == null ? null : new Waveform(trackData);
|
|
||||||
|
var trackData = GetStream(fileStorePath);
|
||||||
|
|
||||||
|
if (trackData == null)
|
||||||
|
{
|
||||||
|
Logger.Log($"Beatmap waveform failed to load (file {Metadata.AudioFile} not found on disk at expected location {fileStorePath}).", level: LogLevel.Error);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Waveform(trackData);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
@ -211,20 +247,38 @@ namespace osu.Game.Beatmaps
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using (var stream = new LineBufferedReader(GetStream(BeatmapSetInfo.GetPathForFile(BeatmapInfo.Path))))
|
string fileStorePath = BeatmapSetInfo.GetPathForFile(BeatmapInfo.Path);
|
||||||
|
var beatmapFileStream = GetStream(fileStorePath);
|
||||||
|
|
||||||
|
if (beatmapFileStream == null)
|
||||||
{
|
{
|
||||||
var decoder = Decoder.GetDecoder<Storyboard>(stream);
|
Logger.Log($"Beatmap failed to load (file {BeatmapInfo.Path} not found on disk at expected location {fileStorePath})", level: LogLevel.Error);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
string storyboardFilename = BeatmapSetInfo?.Files.FirstOrDefault(f => f.Filename.EndsWith(".osb", StringComparison.OrdinalIgnoreCase))?.Filename;
|
using (var reader = new LineBufferedReader(beatmapFileStream))
|
||||||
|
{
|
||||||
|
var decoder = Decoder.GetDecoder<Storyboard>(reader);
|
||||||
|
|
||||||
// todo: support loading from both set-wide storyboard *and* beatmap specific.
|
Stream storyboardFileStream = null;
|
||||||
if (string.IsNullOrEmpty(storyboardFilename))
|
|
||||||
storyboard = decoder.Decode(stream);
|
if (BeatmapSetInfo?.Files.FirstOrDefault(f => f.Filename.EndsWith(".osb", StringComparison.OrdinalIgnoreCase))?.Filename is string storyboardFilename)
|
||||||
else
|
|
||||||
{
|
{
|
||||||
using (var secondaryStream = new LineBufferedReader(GetStream(BeatmapSetInfo.GetPathForFile(storyboardFilename))))
|
string storyboardFileStorePath = BeatmapSetInfo?.GetPathForFile(storyboardFilename);
|
||||||
storyboard = decoder.Decode(stream, secondaryStream);
|
storyboardFileStream = GetStream(storyboardFileStorePath);
|
||||||
|
|
||||||
|
if (storyboardFileStream == null)
|
||||||
|
Logger.Log($"Storyboard failed to load (file {storyboardFilename} not found on disk at expected location {storyboardFileStorePath})", level: LogLevel.Error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (storyboardFileStream != null)
|
||||||
|
{
|
||||||
|
// Stand-alone storyboard was found, so parse in addition to the beatmap's local storyboard.
|
||||||
|
using (var secondaryReader = new LineBufferedReader(storyboardFileStream))
|
||||||
|
storyboard = decoder.Decode(reader, secondaryReader);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
storyboard = decoder.Decode(reader);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user