Move ruleset config to main scene. Add title for UI.
This commit is contained in:
@@ -3,11 +3,13 @@ using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
using Logger = Cryville.Common.Logger;
|
||||
|
||||
namespace Cryville.Crtr.Config {
|
||||
public class ConfigScene : MonoBehaviour {
|
||||
public class ConfigPanelMaster : MonoBehaviour {
|
||||
[SerializeField]
|
||||
Menu m_menu;
|
||||
|
||||
[SerializeField]
|
||||
Transform m_content;
|
||||
|
||||
@@ -20,7 +22,7 @@ namespace Cryville.Crtr.Config {
|
||||
public Ruleset ruleset;
|
||||
RulesetConfig _rscfg;
|
||||
|
||||
void Start() {
|
||||
void OnEnable() {
|
||||
try {
|
||||
ChartPlayer.etor = new PdtEvaluator();
|
||||
FileInfo file = new FileInfo(
|
||||
@@ -57,11 +59,13 @@ namespace Cryville.Crtr.Config {
|
||||
var proxy = new InputProxy(ruleset.Root, null);
|
||||
proxy.LoadFrom(_rscfg.inputs);
|
||||
m_inputConfigPanel.proxy = proxy;
|
||||
|
||||
m_inputConfigPanel.OnConfigEnable();
|
||||
}
|
||||
catch (Exception ex) {
|
||||
Popup.CreateException(ex);
|
||||
Logger.Log("main", 4, "Config", "An error occured while loading the config: {0}", ex);
|
||||
ReturnToMenu();
|
||||
m_menu.Back();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,7 +76,7 @@ namespace Cryville.Crtr.Config {
|
||||
cat.SetActive(true);
|
||||
}
|
||||
|
||||
public void SaveAndReturnToMenu() {
|
||||
void OnDisable() {
|
||||
m_inputConfigPanel.proxy.SaveTo(_rscfg.inputs);
|
||||
m_inputConfigPanel.proxy.Dispose();
|
||||
FileInfo cfgfile = new FileInfo(
|
||||
@@ -81,15 +85,7 @@ 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");
|
||||
#elif UNITY_5_3_OR_NEWER
|
||||
SceneManager.UnloadScene("Config");
|
||||
#endif
|
||||
m_inputConfigPanel.OnConfigDisable();
|
||||
}
|
||||
}
|
||||
}
|
@@ -7,7 +7,7 @@ using UnityEngine.UI;
|
||||
namespace Cryville.Crtr.Config {
|
||||
public class InputConfigPanel : MonoBehaviour {
|
||||
[SerializeField]
|
||||
ConfigScene m_configScene;
|
||||
ConfigPanelMaster m_configScene;
|
||||
|
||||
[SerializeField]
|
||||
GameObject m_inputDialog;
|
||||
@@ -24,7 +24,7 @@ namespace Cryville.Crtr.Config {
|
||||
[SerializeField]
|
||||
GameObject m_prefabInputConfigEntry;
|
||||
|
||||
readonly SimpleInputConsumer _consumer = new SimpleInputConsumer(Game.InputManager);
|
||||
SimpleInputConsumer _consumer;
|
||||
public InputProxy proxy;
|
||||
readonly Dictionary<string, InputConfigPanelEntry> _entries = new Dictionary<string, InputConfigPanelEntry>();
|
||||
|
||||
@@ -50,7 +50,10 @@ namespace Cryville.Crtr.Config {
|
||||
CloseDialog();
|
||||
}
|
||||
|
||||
void Start() {
|
||||
public void OnConfigEnable() {
|
||||
CallHelper.Purge(m_entryList);
|
||||
_entries.Clear();
|
||||
_consumer = new SimpleInputConsumer(Game.InputManager);
|
||||
_consumer.Activate();
|
||||
foreach (var i in m_configScene.ruleset.Root.inputs) {
|
||||
var e = GameObject.Instantiate(m_prefabInputConfigEntry, m_entryList.transform).GetComponent<InputConfigPanelEntry>();
|
||||
@@ -61,7 +64,7 @@ namespace Cryville.Crtr.Config {
|
||||
proxy.ProxyChanged += OnProxyChanged;
|
||||
}
|
||||
|
||||
void OnDestroy() {
|
||||
public void OnConfigDisable() {
|
||||
_consumer.Deactivate();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user