Blocks ruleset config if ruleset not found.

This commit is contained in:
2022-11-17 11:57:56 +08:00
parent a4fdb97424
commit 05124ac406
2 changed files with 11 additions and 2 deletions

Binary file not shown.

View File

@@ -1,4 +1,5 @@
using Newtonsoft.Json;
using JetBrains.Annotations;
using Newtonsoft.Json;
using System;
using System.IO;
using System.Text;
@@ -24,6 +25,11 @@ namespace Cryville.Crtr.Config {
FileInfo file = new FileInfo(
Game.GameDataPath + "/rulesets/" + Settings.Default.LoadRuleset
);
if (!file.Exists) {
Popup.Create("Ruleset for the chart not found\nMake sure you have imported the ruleset");
ReturnToMenu();
return;
}
DirectoryInfo dir = file.Directory;
using (StreamReader reader = new StreamReader(file.FullName, Encoding.UTF8)) {
ruleset = JsonConvert.DeserializeObject<Ruleset>(reader.ReadToEnd(), new JsonSerializerSettings() {
@@ -62,7 +68,7 @@ namespace Cryville.Crtr.Config {
cat.SetActive(true);
}
public void ReturnToMenu() {
public void SaveAndReturnToMenu() {
Game.InputManager.Deactivate();
m_inputConfigPanel.proxy.SaveTo(_rscfg.inputs);
m_inputConfigPanel.proxy.Dispose();
@@ -72,6 +78,9 @@ namespace Cryville.Crtr.Config {
using (StreamWriter cfgwriter = new StreamWriter(cfgfile.FullName, false, Encoding.UTF8)) {
cfgwriter.Write(JsonConvert.SerializeObject(_rscfg, Game.GlobalJsonSerializerSettings));
}
ReturnToMenu();
}
public void ReturnToMenu() {
GameObject.Find("Master").GetComponent<Master>().ShowMenu();
#if UNITY_5_5_OR_NEWER
SceneManager.UnloadSceneAsync("Config");