Add ruleset config.
This commit is contained in:
@@ -86,6 +86,7 @@ namespace Cryville.Crtr.Browsing {
|
||||
|
||||
void SetDataSettings(int id, ChartDetail detail) {
|
||||
Settings.Default.LoadRuleset = detail.Meta.ruleset + "/.umgr";
|
||||
Settings.Default.LoadRulesetConfig = detail.Meta.ruleset + ".json";
|
||||
Settings.Default.LoadSkin = detail.Meta.ruleset + "/Old KeyUI/.umgs";
|
||||
Settings.Default.LoadChart = MainBrowser.ResourceManager.GetItemPath(id);
|
||||
}
|
||||
|
@@ -2,7 +2,7 @@
|
||||
|
||||
using Cryville.Common;
|
||||
using Cryville.Common.Plist;
|
||||
using Cryville.Common.Unity.Input;
|
||||
using Cryville.Crtr.Config;
|
||||
using Cryville.Crtr.Event;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
@@ -330,6 +330,9 @@ namespace Cryville.Crtr {
|
||||
FileInfo rulesetFile = new FileInfo(
|
||||
Game.GameDataPath + "/rulesets/" + Settings.Default.LoadRuleset
|
||||
);
|
||||
FileInfo rulesetConfigFile = new FileInfo(
|
||||
Game.GameDataPath + "/config/rulesets/" + Settings.Default.LoadRulesetConfig
|
||||
);
|
||||
FileInfo skinFile = new FileInfo(
|
||||
Game.GameDataPath + "/skins/" + Settings.Default.LoadSkin
|
||||
);
|
||||
@@ -337,6 +340,7 @@ namespace Cryville.Crtr {
|
||||
loadThread.Start(new LoadInfo() {
|
||||
chartFile = chartFile,
|
||||
rulesetFile = rulesetFile,
|
||||
rulesetConfigFile = rulesetConfigFile,
|
||||
skinFile = skinFile,
|
||||
});
|
||||
|
||||
@@ -367,23 +371,7 @@ namespace Cryville.Crtr {
|
||||
}
|
||||
Logger.Log("main", 0, "Load/Prehandle", "Initializing states");
|
||||
cbus.BroadcastInit();
|
||||
|
||||
inputProxy = new InputProxy(pruleset, judge);
|
||||
foreach (var i in Game.InputManager._handlers) {
|
||||
/*if (i is UnityKeyHandler<UnityKeyboardReceiver>) {
|
||||
inputProxy.Set(new InputProxyEntry { Source = new InputSource { Handler = i, Type = (int)KeyCode.Z }, Target = "track0" });
|
||||
inputProxy.Set(new InputProxyEntry { Source = new InputSource { Handler = i, Type = (int)KeyCode.X }, Target = "track1" });
|
||||
inputProxy.Set(new InputProxyEntry { Source = new InputSource { Handler = i, Type = (int)KeyCode.Comma }, Target = "track2" });
|
||||
inputProxy.Set(new InputProxyEntry { Source = new InputSource { Handler = i, Type = (int)KeyCode.Period }, Target = "track3" });
|
||||
break;
|
||||
}*/
|
||||
if (i is UnityMouseHandler) {
|
||||
inputProxy.Set(new InputProxyEntry { Source = new InputSource { Handler = i, Type = 0 }, Target = "screen_x" });
|
||||
break;
|
||||
}
|
||||
}
|
||||
inputProxy.Activate();
|
||||
|
||||
if (logEnabled) ToggleLogs();
|
||||
Logger.Log("main", 0, "Load/Prehandle", "Cleaning up");
|
||||
GC.Collect();
|
||||
@@ -445,6 +433,7 @@ namespace Cryville.Crtr {
|
||||
struct LoadInfo {
|
||||
public FileInfo chartFile;
|
||||
public FileInfo rulesetFile;
|
||||
public FileInfo rulesetConfigFile;
|
||||
public FileInfo skinFile;
|
||||
}
|
||||
|
||||
@@ -482,7 +471,7 @@ namespace Cryville.Crtr {
|
||||
|
||||
etor = new PdtEvaluator();
|
||||
|
||||
LoadRuleset(info.rulesetFile);
|
||||
LoadRuleset(info.rulesetFile, info.rulesetConfigFile);
|
||||
Logger.Log("main", 0, "Load/WorkerThread", "Applying ruleset (iteration 1)");
|
||||
pruleset.PrePatch(chart);
|
||||
|
||||
@@ -497,6 +486,7 @@ namespace Cryville.Crtr {
|
||||
judge = new Judge(pruleset);
|
||||
etor.ContextJudge = judge;
|
||||
|
||||
inputProxy = new InputProxy(pruleset, judge);
|
||||
cbus.AttachSystems(pskin, judge);
|
||||
Logger.Log("main", 0, "Load/WorkerThread", "Attaching handlers");
|
||||
var ch = new ChartHandler(chart, dir);
|
||||
@@ -531,7 +521,8 @@ namespace Cryville.Crtr {
|
||||
}
|
||||
}
|
||||
|
||||
void LoadRuleset(FileInfo file) {
|
||||
RulesetConfig _rscfg;
|
||||
void LoadRuleset(FileInfo file, FileInfo cfgfile) {
|
||||
DirectoryInfo dir = file.Directory;
|
||||
Logger.Log("main", 0, "Load/WorkerThread", "Loading ruleset: {0}", file);
|
||||
using (StreamReader reader = new StreamReader(file.FullName, Encoding.UTF8)) {
|
||||
@@ -541,6 +532,12 @@ namespace Cryville.Crtr {
|
||||
if (ruleset.format != 1) throw new FormatException("Invalid ruleset file version");
|
||||
ruleset.LoadPdt(dir);
|
||||
pruleset = ruleset.Root;
|
||||
if (!cfgfile.Exists) throw new FileNotFoundException("Ruleset config not found\nPlease open the config to generate");
|
||||
using (StreamReader cfgreader = new StreamReader(cfgfile.FullName, Encoding.UTF8)) {
|
||||
_rscfg = JsonConvert.DeserializeObject<RulesetConfig>(cfgreader.ReadToEnd(), new JsonSerializerSettings() {
|
||||
MissingMemberHandling = MissingMemberHandling.Error
|
||||
});
|
||||
}
|
||||
pruleset.Optimize(etor);
|
||||
}
|
||||
}
|
||||
|
12
Assets/Cryville/Crtr/Config/RulesetConfig.cs
Normal file
12
Assets/Cryville/Crtr/Config/RulesetConfig.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Cryville.Crtr.Config {
|
||||
public class RulesetConfig {
|
||||
public Dictionary<string, InputConfigEntry> inputs
|
||||
= new Dictionary<string, InputConfigEntry>();
|
||||
}
|
||||
public class InputConfigEntry {
|
||||
public string handler;
|
||||
public int type;
|
||||
}
|
||||
}
|
11
Assets/Cryville/Crtr/Config/RulesetConfig.cs.meta
Normal file
11
Assets/Cryville/Crtr/Config/RulesetConfig.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: aa140184f4b7acb4b994a0826e1f107d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -84,6 +84,18 @@ namespace Cryville.Crtr {
|
||||
}
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
[Category("data")]
|
||||
[Description("The ruleset config file to load.")]
|
||||
public string LoadRulesetConfig {
|
||||
get {
|
||||
return PlayerPrefs.GetString("LoadRulesetConfig", "");
|
||||
}
|
||||
set {
|
||||
PlayerPrefs.SetString("LoadRulesetConfig", value);
|
||||
}
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
[Category("data")]
|
||||
[Description("The skin file to load.")]
|
||||
|
Reference in New Issue
Block a user