Code cleanup.
This commit is contained in:
@@ -107,8 +107,14 @@ namespace Cryville.Crtr {
|
|||||||
bool firstFrame;
|
bool firstFrame;
|
||||||
double atime0;
|
double atime0;
|
||||||
void Update() {
|
void Update() {
|
||||||
// if (Input.GetKeyDown(KeyCode.Return)) TogglePlay();
|
if (started) GameUpdate();
|
||||||
if (started) {
|
#if !NO_THREAD
|
||||||
|
else if (loadThread != null) LoadUpdate();
|
||||||
|
#endif
|
||||||
|
if (logEnabled) LogUpdate();
|
||||||
|
else Game.MainLogger.Enumerate((level, module, msg) => { });
|
||||||
|
}
|
||||||
|
void GameUpdate() {
|
||||||
try {
|
try {
|
||||||
if (Screen.width != screenSize.x || Screen.height != screenSize.y)
|
if (Screen.width != screenSize.x || Screen.height != screenSize.y)
|
||||||
throw new InvalidOperationException("Window resized while playing");
|
throw new InvalidOperationException("Window resized while playing");
|
||||||
@@ -144,8 +150,7 @@ namespace Cryville.Crtr {
|
|||||||
Stop();
|
Stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#if !NO_THREAD
|
void LoadUpdate() {
|
||||||
else if (loadThread != null) {
|
|
||||||
if (texLoader != null) {
|
if (texLoader != null) {
|
||||||
string url = texLoader.url;
|
string url = texLoader.url;
|
||||||
string name = StringUtils.TrimExt(url.Substring(url.LastIndexOfAny(new char[] {'/', '\\'}) + 1));
|
string name = StringUtils.TrimExt(url.Substring(url.LastIndexOfAny(new char[] {'/', '\\'}) + 1));
|
||||||
@@ -203,8 +208,8 @@ namespace Cryville.Crtr {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
string timetext = string.Empty;
|
||||||
if (logEnabled) {
|
void LogUpdate() {
|
||||||
string _logs = logs.text;
|
string _logs = logs.text;
|
||||||
Game.MainLogger.Enumerate((level, module, msg) => {
|
Game.MainLogger.Enumerate((level, module, msg) => {
|
||||||
string color;
|
string color;
|
||||||
@@ -239,18 +244,18 @@ namespace Cryville.Crtr {
|
|||||||
UnityEngine.Profiling.Profiler.GetTotalReservedMemory()
|
UnityEngine.Profiling.Profiler.GetTotalReservedMemory()
|
||||||
#endif
|
#endif
|
||||||
);
|
);
|
||||||
if (started) sttext += string.Format(
|
sttext += timetext;
|
||||||
|
if (judge != null) sttext += "\n== Scores ==\n" + judge.GetFullFormattedScoreString();
|
||||||
|
status.text = sttext;
|
||||||
|
}
|
||||||
|
void OnCameraPostRender(Camera cam) {
|
||||||
|
if (started) timetext = string.Format(
|
||||||
"\nSTime: {0:R}\nATime: {1:R}\nITime: {2:R}",
|
"\nSTime: {0:R}\nATime: {1:R}\nITime: {2:R}",
|
||||||
cbus.Time,
|
cbus.Time,
|
||||||
Game.AudioClient.Position - atime0,
|
Game.AudioClient.Position - atime0,
|
||||||
inputProxy.GetTimestampAverage()
|
inputProxy.GetTimestampAverage()
|
||||||
);
|
);
|
||||||
if (judge != null) sttext += "\n== Scores ==\n" + judge.GetFullFormattedScoreString();
|
else timetext = string.Empty;
|
||||||
status.text = sttext;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
Game.MainLogger.Enumerate((level, module, msg) => { });
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@@ -309,6 +314,8 @@ namespace Cryville.Crtr {
|
|||||||
Game.NetworkTaskWorker.SuspendBackgroundTasks();
|
Game.NetworkTaskWorker.SuspendBackgroundTasks();
|
||||||
Game.AudioSession = Game.AudioSequencer.NewSession();
|
Game.AudioSession = Game.AudioSequencer.NewSession();
|
||||||
|
|
||||||
|
Camera.onPostRender += OnCameraPostRender;
|
||||||
|
|
||||||
var hitPlane = new Plane(Vector3.forward, Vector3.zero);
|
var hitPlane = new Plane(Vector3.forward, Vector3.zero);
|
||||||
var r0 = Camera.main.ViewportPointToRay(new Vector3(0, 0, 1));
|
var r0 = Camera.main.ViewportPointToRay(new Vector3(0, 0, 1));
|
||||||
float dist;
|
float dist;
|
||||||
@@ -430,6 +437,7 @@ namespace Cryville.Crtr {
|
|||||||
if (nbus != null) nbus.Dispose();
|
if (nbus != null) nbus.Dispose();
|
||||||
inputProxy.Deactivate();
|
inputProxy.Deactivate();
|
||||||
foreach (var t in texs) Texture.Destroy(t.Value);
|
foreach (var t in texs) Texture.Destroy(t.Value);
|
||||||
|
Camera.onPostRender -= OnCameraPostRender;
|
||||||
Logger.Log("main", 1, "Game", "Stopped");
|
Logger.Log("main", 1, "Game", "Stopped");
|
||||||
}
|
}
|
||||||
catch (Exception ex) {
|
catch (Exception ex) {
|
||||||
|
@@ -21,6 +21,7 @@ namespace Cryville.Crtr.Extensions.Malody {
|
|||||||
src = JsonConvert.DeserializeObject<MalodyChart>(reader.ReadToEnd());
|
src = JsonConvert.DeserializeObject<MalodyChart>(reader.ReadToEnd());
|
||||||
}
|
}
|
||||||
if (src.meta.mode != 0) throw new NotImplementedException("The chart mode is not supported");
|
if (src.meta.mode != 0) throw new NotImplementedException("The chart mode is not supported");
|
||||||
|
if (src.meta.mode_ext.column != 4) throw new NotImplementedException("The key count is not supported");
|
||||||
|
|
||||||
ChartMeta meta = new ChartMeta() {
|
ChartMeta meta = new ChartMeta() {
|
||||||
song = new ChartMeta.MetaInfo() {
|
song = new ChartMeta.MetaInfo() {
|
||||||
@@ -68,7 +69,7 @@ namespace Cryville.Crtr.Extensions.Malody {
|
|||||||
float pbeat = 0f, ctime = 0f;
|
float pbeat = 0f, ctime = 0f;
|
||||||
int[] endbeat = new int[] { 0, 0, 1 };
|
int[] endbeat = new int[] { 0, 0, 1 };
|
||||||
foreach (var ev in events) {
|
foreach (var ev in events) {
|
||||||
float cbeat = bp(ev.beat);
|
float cbeat = ConvertBeat(ev.beat);
|
||||||
ctime += baseBpm == null ? 0 : (cbeat - pbeat) / baseBpm.Value * 60f;
|
ctime += baseBpm == null ? 0 : (cbeat - pbeat) / baseBpm.Value * 60f;
|
||||||
pbeat = cbeat;
|
pbeat = cbeat;
|
||||||
if (ev is MalodyChart.Time) {
|
if (ev is MalodyChart.Time) {
|
||||||
@@ -105,7 +106,7 @@ namespace Cryville.Crtr.Extensions.Malody {
|
|||||||
else throw new NotImplementedException();
|
else throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (bp(tev.beat) > bp(endbeat)) endbeat = tev.beat;
|
if (ConvertBeat(tev.beat) > ConvertBeat(endbeat)) endbeat = tev.beat;
|
||||||
var rn = new Chart.Note() {
|
var rn = new Chart.Note() {
|
||||||
time = new BeatTime(tev.beat[0], tev.beat[1], tev.beat[2]),
|
time = new BeatTime(tev.beat[0], tev.beat[1], tev.beat[2]),
|
||||||
motions = new List<Chart.Motion> {
|
motions = new List<Chart.Motion> {
|
||||||
@@ -113,7 +114,7 @@ namespace Cryville.Crtr.Extensions.Malody {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
if (tev.endbeat != null) {
|
if (tev.endbeat != null) {
|
||||||
if (bp(tev.endbeat) > bp(endbeat)) endbeat = tev.endbeat;
|
if (ConvertBeat(tev.endbeat) > ConvertBeat(endbeat)) endbeat = tev.endbeat;
|
||||||
rn.endtime = new BeatTime(tev.endbeat[0], tev.endbeat[1], tev.endbeat[2]);
|
rn.endtime = new BeatTime(tev.endbeat[0], tev.endbeat[1], tev.endbeat[2]);
|
||||||
longEvents.Add(ev, new StartEventState {
|
longEvents.Add(ev, new StartEventState {
|
||||||
Destination = rn,
|
Destination = rn,
|
||||||
@@ -152,7 +153,7 @@ namespace Cryville.Crtr.Extensions.Malody {
|
|||||||
public ChartEvent Destination { get; set; }
|
public ChartEvent Destination { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
float bp(int[] beat) {
|
float ConvertBeat(int[] beat) {
|
||||||
return beat[0] + (float)beat[1] / beat[2];
|
return beat[0] + (float)beat[1] / beat[2];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user