Implement the new input config.

This commit is contained in:
2023-12-01 16:52:21 +08:00
parent 4d05d0d135
commit 5c38245e23
16 changed files with 2400 additions and 165 deletions

View File

@@ -25,9 +25,11 @@ namespace Cryville.Crtr.Browsing.UI {
public RulesetDefinition ruleset;
RulesetConfig _rscfg;
string _rulesetName;
bool _loaded;
public void Load(string rulesetName) {
_rulesetName = rulesetName;
FileInfo file = new FileInfo(Path.Combine(
Game.GameDataPath, "rulesets", rulesetName, ".umgr"
));
@@ -59,12 +61,7 @@ namespace Cryville.Crtr.Browsing.UI {
m_genericConfigPanel.Adapter = new DefaultPropertyMasterAdapter(_rscfg.generic);
m_rulesetConfigPanel.Adapter = new RulesetConfigPropertyMasterAdapter(ruleset.Root.configs, _rscfg.configs);
//var proxy = new InputProxy(ruleset.Root, null, new Vector2(Screen.width, Screen.height));
//proxy.LoadFrom(_rscfg.inputs);
//m_inputConfigPanel.proxy = proxy;
//m_inputConfigPanel.OnConfigEnable();
m_inputConfigPanel.Load(ruleset.Root, _rscfg);
_loaded = true;
}
@@ -78,15 +75,13 @@ namespace Cryville.Crtr.Browsing.UI {
void OnDisable() {
if (_loaded) {
//m_inputConfigPanel.proxy.SaveTo(_rscfg.inputs);
//m_inputConfigPanel.proxy.Dispose();
//FileInfo cfgfile = new FileInfo(Path.Combine(
// Game.GameDataPath, "config", "rulesets", Settings.Default.LoadRulesetConfig
//));
//using (StreamWriter cfgwriter = new StreamWriter(cfgfile.FullName, false, Encoding.UTF8)) {
// cfgwriter.Write(JsonConvert.SerializeObject(_rscfg, Game.GlobalJsonSerializerSettings));
//}
//m_inputConfigPanel.OnConfigDisable();
m_inputConfigPanel.SaveTo(_rscfg.inputs);
FileInfo cfgFile = new FileInfo(Path.Combine(
Game.GameDataPath, "config", "rulesets", _rulesetName + ".json"
));
using (StreamWriter cfgWriter = new StreamWriter(cfgFile.FullName, false, Encoding.UTF8)) {
cfgWriter.Write(JsonConvert.SerializeObject(_rscfg, Game.GlobalJsonSerializerSettings));
}
}
}