Implement score update.
This commit is contained in:
@@ -504,11 +504,11 @@ namespace Cryville.Crtr {
|
||||
cbus = batcher.Batch();
|
||||
Logger.Log("main", 0, "Load/WorkerThread", "Batched {0} event batches", cbus.events.Count);
|
||||
|
||||
LoadSkin(info.skinFile);
|
||||
|
||||
judge = new Judge(pruleset);
|
||||
etor.ContextJudge = judge;
|
||||
|
||||
LoadSkin(info.skinFile);
|
||||
|
||||
cbus.AttachSystems(pskin, judge);
|
||||
Logger.Log("main", 0, "Load/WorkerThread", "Attaching handlers");
|
||||
var ch = new ChartHandler(chart, dir);
|
||||
|
@@ -31,9 +31,12 @@ namespace Cryville.Crtr {
|
||||
_etor = ChartPlayer.etor;
|
||||
_rs = rs;
|
||||
foreach (var s in rs.scores) {
|
||||
var name = s.Key.Key;
|
||||
scoreDefs.Add(name, s.Value);
|
||||
scores.Add(name, s.Value.init);
|
||||
var key = s.Key;
|
||||
scoreSrcs.Add(key.Key, new PropSrc.Float(() => scores[key.Key]));
|
||||
scoreOps.Add(key.Key, new PropOp.Float(v => scores[key.Key] = v));
|
||||
scoreFmtKeys.Add(key.Key, IdentifierManager.SharedInstance.Request("_score_" + (string)key.Name));
|
||||
scoreDefs.Add(key.Key, s.Value);
|
||||
scores.Add(key.Key, s.Value.init);
|
||||
}
|
||||
}
|
||||
public void Prepare(float st, float et, Identifier input, JudgeDefinition def, ContainerState container) {
|
||||
@@ -143,12 +146,24 @@ namespace Cryville.Crtr {
|
||||
actlist.Insert(index, ev);
|
||||
}
|
||||
}
|
||||
void UpdateScore(Dictionary<ScoreOperation, PdtExpression> scores) {
|
||||
foreach (var score in scores) {
|
||||
// TODO
|
||||
void UpdateScore(Dictionary<ScoreOperation, PdtExpression> scoreops) {
|
||||
foreach (var scoreop in scoreops) {
|
||||
var key = scoreop.Key;
|
||||
_etor.ContextSelfValue = scoreSrcs[key.name.Key];
|
||||
_etor.Evaluate(scoreOps[key.name.Key], scoreop.Value);
|
||||
foreach (var s in _rs.scores) {
|
||||
if (s.Value.value != null) {
|
||||
_etor.ContextSelfValue = scoreSrcs[s.Key.Key];
|
||||
_etor.Evaluate(scoreOps[s.Key.Key], s.Value.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
ScoreCache.Clear();
|
||||
}
|
||||
public readonly Dictionary<int, ScoreDefinition> scoreDefs = new Dictionary<int, ScoreDefinition>();
|
||||
readonly Dictionary<int, int> scoreFmtKeys = new Dictionary<int, int>();
|
||||
readonly Dictionary<int, PropSrc> scoreSrcs = new Dictionary<int, PropSrc>();
|
||||
readonly Dictionary<int, PropOp> scoreOps = new Dictionary<int, PropOp>();
|
||||
readonly Dictionary<int, ScoreDefinition> scoreDefs = new Dictionary<int, ScoreDefinition>();
|
||||
public readonly Dictionary<int, float> scores = new Dictionary<int, float>();
|
||||
readonly Dictionary<int, string> ScoreCache = new Dictionary<int, string>();
|
||||
readonly object _lock = new object();
|
||||
@@ -156,7 +171,7 @@ namespace Cryville.Crtr {
|
||||
lock (_lock) {
|
||||
if (ScoreCache.Count == 0) {
|
||||
foreach (var s in scores)
|
||||
ScoreCache.Add(s.Key, s.Value.ToString(scoreDefs[s.Key].format));
|
||||
ScoreCache.Add(scoreFmtKeys[s.Key], s.Value.ToString(scoreDefs[s.Key].format));
|
||||
}
|
||||
return ScoreCache;
|
||||
}
|
||||
|
@@ -24,6 +24,7 @@ namespace Cryville.Crtr {
|
||||
var id = new Identifier(name);
|
||||
PropSrc prop;
|
||||
string str;
|
||||
float num;
|
||||
if (ContextEvent != null && ContextEvent.PropSrcs.TryGetValue(name, out prop)) {
|
||||
prop.Get(out type, out value);
|
||||
}
|
||||
@@ -31,6 +32,12 @@ namespace Cryville.Crtr {
|
||||
var vec = ContextState.GetRawValue(id);
|
||||
new VectorSrc(() => vec).Get(out type, out value);
|
||||
}
|
||||
else if (ContextJudge != null && ContextJudge.scores.TryGetValue(name, out num)) {
|
||||
type = PdtInternalType.Number;
|
||||
LoadNum(num);
|
||||
value = _numbuf;
|
||||
RevokePotentialConstant();
|
||||
}
|
||||
else if (ContextJudge != null && ContextJudge.GetFormattedScoreStrings().TryGetValue(name, out str)) {
|
||||
type = PdtInternalType.String;
|
||||
value = GetBytes(str);
|
||||
|
@@ -45,8 +45,12 @@ namespace Cryville.Crtr {
|
||||
}
|
||||
foreach (var j in judges.Values) {
|
||||
if (j.hit != null) etor.Optimize(j.hit);
|
||||
if (j.scores != null) foreach (var e in j.scores.Values) {
|
||||
etor.Optimize(e);
|
||||
if (j.scores != null) {
|
||||
foreach (var s in j.scores) {
|
||||
if (s.Key.op != default(Identifier))
|
||||
etor.PatchCompound(s.Key.name.Key, s.Key.op.Key, s.Value);
|
||||
etor.Optimize(s.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach (var s in scores.Values) {
|
||||
|
Reference in New Issue
Block a user