Skip to content

Commit

Permalink
FIX: Prevent background image from being set to video
Browse files Browse the repository at this point in the history
  • Loading branch information
QingQiz committed Sep 1, 2022
1 parent c7c8167 commit 0a9038c
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions BmsToOsu/Converter/Osu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public static (string, HashSet<string> fileToCp) ToOsuBeatMap(

var bg = "";

var imgExt = new[] { ".jpg", ".png", ".jpeg" };
if (File.Exists(Path.Join(dir, data.Metadata.BackBmp)))
{
bg = data.Metadata.BackBmp;
Expand All @@ -77,15 +78,22 @@ public static (string, HashSet<string> fileToCp) ToOsuBeatMap(
}
else if (data.BgaFrames.Any())
{
bg = data.BgaFrames[data.BgaFrames.Count / 2].File;
var bga = data.BgaFrames
.Where(x => imgExt
.Any(ext => x.File.EndsWith(ext, StringComparison.OrdinalIgnoreCase)))
.ToList();

if (bga.Any())
{
bg = bga[bga.Count / 2].File;
}
}

if (string.IsNullOrEmpty(bg))
{
var ext = new[] { ".jpg", ".png", ".jpeg" };
bg = Directory
.GetFiles(dir, "*.*", SearchOption.TopDirectoryOnly)
.FirstOrDefault(f => ext.Any(e => f.EndsWith(e, StringComparison.OrdinalIgnoreCase))) ?? "";
.FirstOrDefault(f => imgExt.Any(e => f.EndsWith(e, StringComparison.OrdinalIgnoreCase))) ?? "";
}

if (!string.IsNullOrEmpty(bg))
Expand Down

0 comments on commit 0a9038c

Please sign in to comment.