Draft config definition.
This commit is contained in:
@@ -29,6 +29,11 @@ namespace Cryville.Crtr {
|
|||||||
ChartPlayer.etor.Evaluate(new PropOp.String(r => result = r), exp);
|
ChartPlayer.etor.Evaluate(new PropOp.String(r => result = r), exp);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
else if (type.IsEnum) {
|
||||||
|
object result = null;
|
||||||
|
ChartPlayer.etor.Evaluate(new PropOp.Enum(type, r => result = r), exp);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
else if (type.Equals(typeof(Clip))) {
|
else if (type.Equals(typeof(Clip))) {
|
||||||
Clip result = default(Clip);
|
Clip result = default(Clip);
|
||||||
ChartPlayer.etor.Evaluate(new PropOp.Clip(r => result = r), exp);
|
ChartPlayer.etor.Evaluate(new PropOp.Clip(r => result = r), exp);
|
||||||
|
|||||||
@@ -100,6 +100,26 @@ namespace Cryville.Crtr {
|
|||||||
_cb(GetOperand(0).AsIdentifier());
|
_cb(GetOperand(0).AsIdentifier());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public class Enum : PropOp {
|
||||||
|
readonly Type _type;
|
||||||
|
readonly IntKeyedDictionary<int> _cache = new IntKeyedDictionary<int>();
|
||||||
|
readonly Action<object> _cb;
|
||||||
|
public Enum(Type type, Action<object> cb) {
|
||||||
|
if (!type.IsEnum)
|
||||||
|
throw new ArgumentException("Type is not enum");
|
||||||
|
_type = type;
|
||||||
|
var names = type.GetFields(BindingFlags.Public | BindingFlags.Static);
|
||||||
|
for (int i = 0; i < names.Length; i++)
|
||||||
|
_cache[IdentifierManager.Shared.Request(names[i].Name)] = Convert.ToInt32(names[i].GetValue(null));
|
||||||
|
_cb = cb;
|
||||||
|
}
|
||||||
|
protected override void Execute() {
|
||||||
|
int result = 0;
|
||||||
|
for (int i = 0; i < LoadedOperandCount; i++)
|
||||||
|
result |= _cache[GetOperand(i).AsIdentifier()];
|
||||||
|
_cb(System.Enum.ToObject(_type, result));
|
||||||
|
}
|
||||||
|
}
|
||||||
public class Enum<T> : PropOp {
|
public class Enum<T> : PropOp {
|
||||||
static readonly IntKeyedDictionary<int> _cache = new IntKeyedDictionary<int>();
|
static readonly IntKeyedDictionary<int> _cache = new IntKeyedDictionary<int>();
|
||||||
readonly Action<T> _cb;
|
readonly Action<T> _cb;
|
||||||
|
|||||||
@@ -69,7 +69,12 @@ namespace Cryville.Crtr {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
public class ConfigDefinition {
|
public class ConfigDefinition {
|
||||||
// TODO
|
public ConfigType type;
|
||||||
|
public PdtExpression @default;
|
||||||
|
public PdtExpression value;
|
||||||
|
}
|
||||||
|
public enum ConfigType {
|
||||||
|
none, number,
|
||||||
}
|
}
|
||||||
public class MotionDefinition {
|
public class MotionDefinition {
|
||||||
// TODO
|
// TODO
|
||||||
|
|||||||
Reference in New Issue
Block a user