Fix config scene stuck on ruleset format error.

This commit is contained in:
2023-01-22 22:29:16 +08:00
parent 9f73c8ffad
commit 02794d88b9

View File

@@ -4,6 +4,7 @@ using System.IO;
using System.Text; using System.Text;
using UnityEngine; using UnityEngine;
using UnityEngine.SceneManagement; using UnityEngine.SceneManagement;
using Logger = Cryville.Common.Logger;
namespace Cryville.Crtr.Config { namespace Cryville.Crtr.Config {
public class ConfigScene : MonoBehaviour { public class ConfigScene : MonoBehaviour {
@@ -20,14 +21,13 @@ namespace Cryville.Crtr.Config {
RulesetConfig _rscfg; RulesetConfig _rscfg;
void Start() { void Start() {
try {
ChartPlayer.etor = new PdtEvaluator(); ChartPlayer.etor = new PdtEvaluator();
FileInfo file = new FileInfo( FileInfo file = new FileInfo(
Game.GameDataPath + "/rulesets/" + Settings.Default.LoadRuleset Game.GameDataPath + "/rulesets/" + Settings.Default.LoadRuleset
); );
if (!file.Exists) { if (!file.Exists) {
Popup.Create("Ruleset for the chart not found\nMake sure you have imported the ruleset"); throw new FileNotFoundException("Ruleset for the chart not found\nMake sure you have imported the ruleset");
ReturnToMenu();
return;
} }
DirectoryInfo dir = file.Directory; DirectoryInfo dir = file.Directory;
using (StreamReader reader = new StreamReader(file.FullName, Encoding.UTF8)) { using (StreamReader reader = new StreamReader(file.FullName, Encoding.UTF8)) {
@@ -58,6 +58,12 @@ namespace Cryville.Crtr.Config {
proxy.LoadFrom(_rscfg.inputs); proxy.LoadFrom(_rscfg.inputs);
m_inputConfigPanel.proxy = proxy; m_inputConfigPanel.proxy = proxy;
} }
catch (Exception ex) {
Popup.CreateException(ex);
Logger.Log("main", 4, "Config", "An error occured while loading the config: {0}", ex);
ReturnToMenu();
}
}
public void SwitchCategory(GameObject cat) { public void SwitchCategory(GameObject cat) {
foreach (Transform c in m_content) { foreach (Transform c in m_content) {