Implement legacy skin resource browser.

This commit is contained in:
2023-12-19 16:48:13 +08:00
parent 4dd4c5f20d
commit aa84fb8544
5 changed files with 73 additions and 1 deletions

View File

@@ -0,0 +1,27 @@
using Cryville.Crtr.Skin;
using Newtonsoft.Json;
using System.IO;
namespace Cryville.Crtr.Browsing.Legacy {
internal class LegacySkinResourceManager : LegacyResourceManager<LegacySkinDetail> {
protected override string Extension { get { return ".umgs"; } }
public LegacySkinResourceManager(string rootPath) : base(rootPath) { }
protected override string GetSubRootPath(string rootPath) {
return Path.Combine(rootPath, "skins");
}
protected override LegacySkinDetail GetMeta(DirectoryInfo dir) {
SkinDefinition meta = null;
var metaFile = new FileInfo(Path.Combine(dir.FullName, Extension));
if (metaFile.Exists) {
using (var reader = new StreamReader(metaFile.FullName)) {
meta = JsonConvert.DeserializeObject<SkinDefinition>(reader.ReadToEnd());
}
return new LegacySkinDetail { Meta = meta };
}
else
return new LegacySkinDetail { Name = dir.Name };
}
}
}