Support extra annotations on skin property key. Code cleanup.
This commit is contained in:
@@ -1,6 +1,4 @@
|
||||
using Cryville.Common;
|
||||
using Cryville.Common.Pdt;
|
||||
using Cryville.Crtr.Components;
|
||||
using Cryville.Common.Pdt;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
@@ -58,41 +56,7 @@ namespace Cryville.Crtr {
|
||||
case ';':
|
||||
case ':':
|
||||
if (invalidKeyFlag) throw new FormatException("Invalid key format");
|
||||
if (a.Contains("has")) {
|
||||
if (k.Count != 1) throw new FormatException("Invalid anchor name");
|
||||
return new SkinPropertyKey.CreateAnchor {
|
||||
Name = IdentifierManager.SharedInstance.Request(k[0])
|
||||
};
|
||||
}
|
||||
else if (a.Contains("at")) {
|
||||
if (k.Count != 1) throw new FormatException("Invalid anchor name");
|
||||
return new SkinPropertyKey.SetAnchor {
|
||||
Name = IdentifierManager.SharedInstance.Request(k[0])
|
||||
};
|
||||
}
|
||||
else if (a.Contains("emit")) {
|
||||
if (k.Count != 1) throw new FormatException("Invalid effect name");
|
||||
return new SkinPropertyKey.EmitEffect {
|
||||
Name = IdentifierManager.SharedInstance.Request(k[0])
|
||||
};
|
||||
}
|
||||
switch (k.Count) {
|
||||
case 1:
|
||||
if (compKeyFlag) return new SkinPropertyKey.CreateComponent {
|
||||
Component = GetComponentByName(k[0])
|
||||
};
|
||||
else return new SkinPropertyKey.SetProperty {
|
||||
Component = typeof(TransformInterface),
|
||||
Name = IdentifierManager.SharedInstance.Request(k[0])
|
||||
};
|
||||
case 2:
|
||||
return new SkinPropertyKey.SetProperty {
|
||||
Component = GetComponentByName(k[0]),
|
||||
Name = IdentifierManager.SharedInstance.Request(k[1])
|
||||
};
|
||||
default:
|
||||
throw new FormatException("Unknown error"); // Unreachable
|
||||
}
|
||||
return SkinPropertyKey.Construct(a, k, compKeyFlag);
|
||||
case '{':
|
||||
return new SkinSelectors(s, a);
|
||||
case '}':
|
||||
@@ -127,7 +91,7 @@ namespace Cryville.Crtr {
|
||||
if (cc != '{') throw new FormatException("Invalid span format");
|
||||
return new Clip(start, end);
|
||||
}
|
||||
k.Clear();
|
||||
a.Clear(); k.Clear();
|
||||
while (true) {
|
||||
int pp = Position;
|
||||
switch (cc) {
|
||||
@@ -139,20 +103,7 @@ namespace Cryville.Crtr {
|
||||
break;
|
||||
case ';':
|
||||
case ':':
|
||||
switch (k.Count) {
|
||||
case 1:
|
||||
return new SkinPropertyKey.SetProperty {
|
||||
Component = typeof(TransformInterface),
|
||||
Name = IdentifierManager.SharedInstance.Request(k[0])
|
||||
};
|
||||
case 2:
|
||||
return new SkinPropertyKey.SetProperty {
|
||||
Component = GetComponentByName(k[0]),
|
||||
Name = IdentifierManager.SharedInstance.Request(k[1])
|
||||
};
|
||||
default:
|
||||
throw new FormatException("Unknown error"); // Unreachable
|
||||
}
|
||||
return SkinPropertyKey.Construct(a, k, false);
|
||||
case '{':
|
||||
throw new FormatException("Invalid token");
|
||||
case '}':
|
||||
@@ -167,10 +118,5 @@ namespace Cryville.Crtr {
|
||||
if (Position == pp) throw new FormatException("Invalid selector or key format");
|
||||
}
|
||||
}
|
||||
static Type GetComponentByName(string name) {
|
||||
Type result;
|
||||
if (GenericResources.Components.TryGetValue(name, out result)) return result;
|
||||
throw new ArgumentException(string.Format("Component type \"{0}\" not found", name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user