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