Code cleanup.

This commit is contained in:
2022-12-24 19:12:16 +08:00
parent 94107de97d
commit e589e37640
3 changed files with 14 additions and 7 deletions

View File

@@ -5,7 +5,7 @@ using System.Linq;
using UnityEngine;
namespace Cryville.Crtr {
class GroupHandler : ContainerHandler {
public class GroupHandler : ContainerHandler {
public ChartHandler ch;
SquareMatrix matFrame;

View File

@@ -1,13 +1,13 @@
using Cryville.Common;
using Cryville.Common.Buffers;
using Cryville.Common.Pdt;
using Cryville.Crtr.Event;
using System;
using System.Collections.Generic;
using System.Globalization;
namespace Cryville.Crtr {
public class Judge {
#region Data
readonly PdtEvaluator _etor;
readonly PdtRuleset _rs;
readonly Dictionary<Identifier, float> ct
@@ -22,7 +22,7 @@ namespace Cryville.Crtr {
public double StartClip { get; set; }
public double EndClip { get; set; }
public JudgeDefinition Definition { get; set; }
public ContainerState State { get; set; }
public NoteHandler Handler { get; set; }
}
static readonly IComparer<JudgeEvent> _stcmp = new JudgeEventStartTimeComparer();
class JudgeEventStartTimeComparer : IComparer<JudgeEvent> {
@@ -35,7 +35,7 @@ namespace Cryville.Crtr {
_rs = rs;
InitScores();
}
public void Prepare(double st, double et, Identifier input, JudgeDefinition def, ContainerState container) {
public void Prepare(double st, double et, Identifier input, JudgeDefinition def, NoteHandler handler) {
List<JudgeEvent> list;
if (!evs.TryGetValue(input, out list)) {
ct.Add(input, 0);
@@ -48,12 +48,14 @@ namespace Cryville.Crtr {
StartClip = st + def.clip[0],
EndClip = et + def.clip[1],
Definition = def,
State = container,
Handler = handler,
};
var index = list.BinarySearch(ev, _stcmp);
if (index < 0) index = ~index;
list.Insert(index, ev);
}
#endregion
#region Judge
static bool _flag;
static readonly PropOp.Boolean _flagop = new PropOp.Boolean(v => _flag = v);
static readonly int _var_fn = IdentifierManager.SharedInstance.Request("fn");
@@ -174,6 +176,8 @@ namespace Cryville.Crtr {
}
}
}
#endregion
#region Score
readonly Dictionary<int, int> scoreStringKeys = new Dictionary<int, int>();
readonly Dictionary<int, int> scoreStringKeysRev = new Dictionary<int, int>();
readonly Dictionary<int, PropSrc> scoreSrcs = new Dictionary<int, PropSrc>();
@@ -253,7 +257,9 @@ namespace Cryville.Crtr {
}
}
}
#endregion
}
#region Definitions
public class InputDefinition {
public int dim;
public bool notnull;
@@ -282,4 +288,5 @@ namespace Cryville.Crtr {
public float init = 0;
public string format = "";
}
#endregion
}

View File

@@ -7,7 +7,7 @@ using System.Collections.Generic;
using UnityEngine;
namespace Cryville.Crtr {
class NoteHandler : ContainerHandler {
public class NoteHandler : ContainerHandler {
readonly GroupHandler gh;
public readonly Chart.Note Event;
readonly PdtRuleset ruleset;
@@ -90,7 +90,7 @@ namespace Cryville.Crtr {
ChartPlayer.etor.ContextEvent = tev;
ChartPlayer.etor.ContextState = s;
ChartPlayer.etor.Evaluate(new PropOp.Identifier(v => name = new Identifier(v)), ruleset.judges[tev.Id].input);
judge.Prepare(ev.Time, ev.Time + ev.Duration, name, ruleset.judges[tev.Id], cs);
judge.Prepare(ev.Time, ev.Time + ev.Duration, name, ruleset.judges[tev.Id], this);
ChartPlayer.etor.ContextState = null;
ChartPlayer.etor.ContextEvent = null;
}