Code cleanup.

This commit is contained in:
2022-11-09 13:53:53 +08:00
parent 1f621082c6
commit 55efc7a428
4 changed files with 9 additions and 16 deletions

View File

@@ -86,11 +86,9 @@ namespace Cryville.Crtr {
AudioClient.Start();
ChartPlayer.motionRegistry = new Dictionary<string, MotionRegistry> {
{ "pt" , new MotionRegistry(typeof(VecPt)) },
{ "dir" , new MotionRegistry(typeof(Vec3)) },
{ "normal" , new MotionRegistry(typeof(Vec3)) },
// { "pdirz", new MotionRegistry(typeof(Vec1)) },
{ "pt" , new MotionRegistry(typeof(VecPt)) },
// { "visible", new MotionRegistry(typeof(VecI1)) },
{ "sv" , new MotionRegistry(new VecPtComp(0f, 0f), new VecPtComp(0f, 1f)) },
{ "svm" , new MotionRegistry(new Vec1m(1f)) },
{ "dist" , new MotionRegistry(new VecPtComp(0f, 0f), new VecPtComp(0f, float.PositiveInfinity)) },
@@ -98,8 +96,6 @@ namespace Cryville.Crtr {
{ "ctrl0" , new MotionRegistry(typeof(VecCtrl)) },
{ "ctrl1" , new MotionRegistry(typeof(VecCtrl)) },
{ "track" , new MotionRegistry(typeof(Vec1)) },
// { "judge" , new MotionRegistry(typeof(Vec1)) },
// { "width" , new MotionRegistry(new Vec1(0), new Vec1(1)) },
};
var dir = new DirectoryInfo(Settings.Default.GameDataPath + "/charts");

View File

@@ -22,13 +22,16 @@ namespace Cryville.Crtr {
public 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();
public Dictionary<int, string> GetFormattedScoreStrings() {
lock (_lock) {
if (ScoreCache.Count == 0) {
foreach (var s in scores)
ScoreCache.Add(s.Key, s.Value.ToString(scoreDefs[s.Key].format));
}
return ScoreCache;
}
}
public string GetFullFormattedScoreString() {
bool flag = false;
string result = "";

View File

@@ -70,7 +70,7 @@ namespace Cryville.Crtr {
}
else if (sig.Name == _op_sep) {
result = new op_arr(sig.ParamCount);
_shortops.Add(new PdtOperatorSignature(",", sig.ParamCount), result);
_shortops.Add(new PdtOperatorSignature(_op_sep, sig.ParamCount), result);
return result;
}
else if (_longops.TryGetValue(sig.Name, out result)) {
@@ -234,13 +234,13 @@ namespace Cryville.Crtr {
int type = o0.Type;
int len = o0.Length;
bool blit = !IsBlittable(type);
for (var i = 1; i < ParamCount; i++) {
for (var i = 1; i < LoadedOperandCount; i++) {
var o = GetOperand(i);
if (o.Type != type) throw new InvalidOperationException("Cannot create variant type array");
else if (!IsBlittable(o.Type)) blit = true;
len += o.Length;
}
if (blit) GetReturnFrame(PdtInternalType.Array, len + 2 * sizeof(int)).SetArraySuffix(type, ParamCount);
if (blit) GetReturnFrame(PdtInternalType.Array, len + 2 * sizeof(int)).SetArraySuffix(type, LoadedOperandCount);
else GetReturnFrame(PdtInternalType.Vector, len + sizeof(int)).SetArraySuffix(type);
}
bool IsBlittable(int type) {

View File

@@ -32,17 +32,11 @@ namespace Cryville.Crtr {
}
public void Forward(Action<T> callback = null) {
ForwardToTime(float.PositiveInfinity, ev => {
if (callback != null)
callback(ev);
});
ForwardToTime(float.PositiveInfinity, callback);
}
public void ForwardByTime(float time, Action<T> callback = null) {
ForwardToTime(Time + time, ev => {
if (callback != null)
callback(ev);
});
ForwardToTime(Time + time, callback);
}
public void ForwardOnceByTime(float time, Action<T> callback = null) {