Skip to content

Commit 582b9c0

Browse files
committed
feat: 读取 AssetBundleImages\jacket\*.png 作为封面
1 parent dc92467 commit 582b9c0

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

MaiChartManager/Controllers/MusicController.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,11 @@ public ActionResult GetJacket(int id)
144144
return File(System.IO.File.OpenRead(music.JacketPath), "image/png");
145145
}
146146

147+
if (System.IO.File.Exists(music.PseudoAssetBundleJacket))
148+
{
149+
return File(System.IO.File.OpenRead(music.PseudoAssetBundleJacket), "image/png");
150+
}
151+
147152
if (music.AssetBundleJacket is null) return NotFound();
148153

149154
var manager = new AssetsManager();

MaiChartManager/Models/MusicXmlWithABJacket.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@ namespace MaiChartManager.Models;
55
public class MusicXmlWithABJacket(string filePath, string gamePath) : MusicXml(filePath, gamePath)
66
{
77
public string? AssetBundleJacket => StaticSettings.AssetBundleJacketMap.GetValueOrDefault(NonDxId);
8+
public string? PseudoAssetBundleJacket => StaticSettings.PseudoAssetBundleJacketMap.GetValueOrDefault(NonDxId);
89

910
// 在 mod 里文件的 jacket 是优先的
10-
public new bool HasJacket => JacketPath is not null || AssetBundleJacket is not null;
11+
public new bool HasJacket => JacketPath is not null || AssetBundleJacket is not null || PseudoAssetBundleJacket is not null;
1112

1213
public record ChartAvailable(int index, int levelId);
1314

MaiChartManager/StaticSettings.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ public string AssetDir
5353
public static List<GenreXml> GenreList { get; set; } = [];
5454
public static List<VersionXml> VersionList { get; set; } = [];
5555
public static Dictionary<int, string> AssetBundleJacketMap { get; set; } = new();
56+
public static Dictionary<int, string> PseudoAssetBundleJacketMap { get; set; } = new();
5657
public static Dictionary<string, string> AcbAwb { get; set; } = new();
5758

5859
public void ScanMusicList()
@@ -128,14 +129,18 @@ public void ScanVersionList()
128129
public void ScanAssetBundles()
129130
{
130131
AssetBundleJacketMap.Clear();
132+
PseudoAssetBundleJacketMap.Clear();
131133
foreach (var a in AssetsDirs)
132134
{
133135
if (!Directory.Exists(Path.Combine(StreamingAssets, a, @"AssetBundleImages\jacket"))) continue;
134-
foreach (var jacketFile in Directory.EnumerateFiles(Path.Combine(StreamingAssets, a, @"AssetBundleImages\jacket"), "*.ab"))
136+
foreach (var jacketFile in Directory.EnumerateFiles(Path.Combine(StreamingAssets, a, @"AssetBundleImages\jacket")))
135137
{
136138
var idStr = Path.GetFileName(jacketFile).Substring("ui_jacket_".Length, 6);
137139
if (!int.TryParse(idStr, out var id)) continue;
138-
AssetBundleJacketMap[id] = jacketFile;
140+
if (Path.GetExtension(jacketFile) == ".ab")
141+
AssetBundleJacketMap[id] = jacketFile;
142+
else if (((string[]) [".png", ".jpg", ".jpeg"]).Contains(Path.GetExtension(jacketFile)))
143+
PseudoAssetBundleJacketMap[id] = jacketFile;
139144
}
140145
}
141146

0 commit comments

Comments
 (0)