Evaluates clipping of judge events on load.

This commit is contained in:
2022-11-11 10:36:00 +08:00
parent 383fca1a8e
commit 990a42f71b
2 changed files with 17 additions and 2 deletions

View File

@@ -48,7 +48,7 @@ namespace Cryville.Crtr {
public Dictionary<Identifier, PdtExpression> pass; public Dictionary<Identifier, PdtExpression> pass;
} }
public class JudgeDefinition { public class JudgeDefinition {
public PdtExpression clip; public float[] clip;
public PdtExpression input; public PdtExpression input;
public PdtExpression hit; public PdtExpression hit;
public Identifier[] pass; public Identifier[] pass;

View File

@@ -44,7 +44,6 @@ namespace Cryville.Crtr {
} }
} }
foreach (var j in judges.Values) { foreach (var j in judges.Values) {
if (j.clip != null) etor.Optimize(j.clip);
if (j.hit != null) etor.Optimize(j.hit); if (j.hit != null) etor.Optimize(j.hit);
if (j.scores != null) foreach (var e in j.scores.Values) { if (j.scores != null) foreach (var e in j.scores.Values) {
etor.Optimize(e); etor.Optimize(e);
@@ -148,6 +147,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.Equals(typeof(float[]))) {
float[] result = null;
ChartPlayer.etor.Evaluate(new pop_numarr(r => result = r), exp);
return result;
}
else if (type.Equals(typeof(Identifier))) { else if (type.Equals(typeof(Identifier))) {
Identifier result = default(Identifier); Identifier result = default(Identifier);
ChartPlayer.etor.Evaluate(new pop_identstr(r => result = r), exp); ChartPlayer.etor.Evaluate(new pop_identstr(r => result = r), exp);
@@ -175,6 +179,17 @@ namespace Cryville.Crtr {
return base.ChangeType(value, type, culture); return base.ChangeType(value, type, culture);
} }
#pragma warning disable IDE1006 #pragma warning disable IDE1006
class pop_numarr : PdtOperator {
readonly Action<float[]> _cb;
public pop_numarr(Action<float[]> cb) : base(16) { _cb = cb; }
protected override void Execute() {
var result = new float[LoadedOperandCount];
for (int i = 0; i < LoadedOperandCount; i++) {
result[i] = GetOperand(i).AsNumber();
}
_cb(result);
}
}
class pop_identstr : PropOp { class pop_identstr : PropOp {
readonly Action<SIdentifier> _cb; readonly Action<SIdentifier> _cb;
public pop_identstr(Action<SIdentifier> cb) { _cb = cb; } public pop_identstr(Action<SIdentifier> cb) { _cb = cb; }