Add backward compatibility for skin.

This commit is contained in:
2023-02-17 16:24:24 +08:00
parent db0165d145
commit 675ce68073
5 changed files with 32 additions and 17 deletions

View File

@@ -26,12 +26,21 @@ namespace Cryville.Crtr {
public void LoadPdt(DirectoryInfo dir) {
using (StreamReader pdtreader = new StreamReader(dir.FullName + "/" + data + ".pdt", Encoding.UTF8)) {
var src = pdtreader.ReadToEnd();
Root = (PdtSkin)new SkinInterpreter(src, null).Interpret();
var interpreter = new SkinInterpreter(src, null);
var format = interpreter.GetFormatVersion();
if (format.Length == 1) {
Root = new PdtSkin();
Root.elements = (SkinElement)new SkinInterpreter(src, new PdtBinder()).Interpret(typeof(SkinElement));
}
else {
if (format[1] == 1) {
Root = (PdtSkin)new SkinInterpreter(src, new PdtBinder()).Interpret(typeof(PdtSkin));
}
}
}
}
}
[Binder(typeof(PdtBinder))]
public class PdtSkin {
public Dictionary<Identifier, AnimationSpan> animations
= new Dictionary<Identifier, AnimationSpan>();