Add chart, ruleset, and skin file resource importer.
This commit is contained in:
22
Assets/Cryville/Crtr/Browsing/ChartResourceImporter.cs
Normal file
22
Assets/Cryville/Crtr/Browsing/ChartResourceImporter.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using Newtonsoft.Json;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace Cryville.Crtr.Browsing {
|
||||
public class ChartResourceImporter : ResourceConverter {
|
||||
static readonly string[] SUPPORTED_FORMATS = { ".umgc" };
|
||||
public override string[] GetSupportedFormats() {
|
||||
return SUPPORTED_FORMATS;
|
||||
}
|
||||
|
||||
public override IEnumerable<Resource> ConvertFrom(FileInfo file) {
|
||||
var meta = Path.Combine(file.Directory.FullName, "meta.json");
|
||||
if (!File.Exists(meta)) throw new FileNotFoundException("Meta file for the chart not found");
|
||||
using (StreamReader reader = new StreamReader(meta, Encoding.UTF8)) {
|
||||
var data = JsonConvert.DeserializeObject<ChartMeta>(reader.ReadToEnd());
|
||||
return new Resource[] { new ChartResource(data.name, file) };
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user