Allows stopping during chart loading.

This commit is contained in:
2023-05-09 21:27:48 +08:00
parent b983e32d56
commit 904581c520

View File

@@ -190,7 +190,11 @@ namespace Cryville.Crtr {
#endif
}
else if (texloaddone) {
if (texLoader == null) Stop();
else {
prehandler = new Coroutine(Prehandle());
texLoader = null;
}
loadThread = null;
}
}
@@ -260,12 +264,8 @@ namespace Cryville.Crtr {
MotionNodePool.Shared.RentedCount
);
}
if (loadThread != null) {
statusbuf.AppendFormat(
"\n(Loading textures) Progress: {0:P}\n(Loading files) Progress: {1:P}",
texLoader.Progress, loadPregress
);
}
if (texLoader != null) statusbuf.AppendFormat("\n(Loading textures) Progress: {0:P}", texLoader.Progress);
if (loadThread != null) statusbuf.AppendFormat("\n(Loading files) Progress: {0:P}", loadPregress);
if (prehandler != null) statusbuf.AppendFormat("\n(Prehandling) Progress: {0:P}", prehandler.Progress);
if (started) {
statusbuf.AppendFormat(
@@ -331,9 +331,19 @@ namespace Cryville.Crtr {
public void TogglePlay() {
if (started) Stop();
else if (prehandler != null) {
prehandler = null;
Stop();
}
else if (texLoader != null || loadThread != null) {
texloaddone = true;
texLoader = null;
if (loadThread.IsAlive) {
Logger.Log("main", 2, "Game", "Stop requested while the chart is loading. Waiting for the loading thread to exit...");
}
}
else {
if (texLoader == null && loadThread == null && prehandler == null) Play();
else Logger.Log("main", 2, "Load/MainThread", "The chart is currently loading");
Play();
}
}
@@ -527,15 +537,19 @@ namespace Cryville.Crtr {
Game.AudioClient.Start();
Game.AudioSession = Game.AudioSequencer.NewSession();
Camera.main.cullingMask &= ~1;
if (inputProxy != null) {
inputProxy.Deactivate();
inputProxy = null;
}
judge = null;
if (nbus != null) { nbus.Dispose(); nbus = null; }
if (tbus != null) { tbus.Dispose(); tbus = null; }
if (bbus != null) { bbus.Dispose(); bbus = null; }
if (cbus != null) { cbus.Dispose(); cbus.DisposeAll(); cbus = null; }
if (effectManager != null) {
effectManager.Dispose();
effectManager = null;
}
etor = null;
motionRegistry = null;
Logger.Log("main", 1, "Game", "Stopped");