Move UMG importers to extensions.

This commit is contained in:
2023-03-17 17:58:45 +08:00
parent c1b7e9ab55
commit 7aa2577059
10 changed files with 97 additions and 27 deletions

View File

@@ -0,0 +1,34 @@
using Cryville.Crtr.Extension;
using Newtonsoft.Json;
using System.Collections.Generic;
using System.IO;
using System.Text;
namespace Cryville.Crtr.Extensions.Umg {
public class SkinResourceImporter : ResourceConverter {
static readonly string[] SUPPORTED_FORMATS = { ".umgs" };
public override string[] GetSupportedFormats() {
return SUPPORTED_FORMATS;
}
public override IEnumerable<Resource> ConvertFrom(FileInfo file) {
using (StreamReader reader = new StreamReader(file.FullName, Encoding.UTF8)) {
var data = JsonConvert.DeserializeObject<Skin>(reader.ReadToEnd());
return new Resource[] { new SkinResource(data.name, file) };
}
}
}
public class SkinResource : FileResource {
public string RulesetName { get; private set; }
public SkinResource(string name, FileInfo master) : base(name, master) {
using (var reader = new StreamReader(master.FullName)) {
var meta = JsonConvert.DeserializeObject<Skin>(reader.ReadToEnd());
RulesetName = meta.ruleset;
Attachments.Add(new FileInfo(Path.Combine(master.Directory.FullName, meta.data + ".pdt")));
foreach (var frame in meta.frames) {
Attachments.Add(new FileInfo(Path.Combine(master.Directory.FullName, frame)));
}
}
}
}
}