Add ruleset config.
This commit is contained in:
@@ -86,6 +86,7 @@ namespace Cryville.Crtr.Browsing {
|
|||||||
|
|
||||||
void SetDataSettings(int id, ChartDetail detail) {
|
void SetDataSettings(int id, ChartDetail detail) {
|
||||||
Settings.Default.LoadRuleset = detail.Meta.ruleset + "/.umgr";
|
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.LoadSkin = detail.Meta.ruleset + "/Old KeyUI/.umgs";
|
||||||
Settings.Default.LoadChart = MainBrowser.ResourceManager.GetItemPath(id);
|
Settings.Default.LoadChart = MainBrowser.ResourceManager.GetItemPath(id);
|
||||||
}
|
}
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
using Cryville.Common;
|
using Cryville.Common;
|
||||||
using Cryville.Common.Plist;
|
using Cryville.Common.Plist;
|
||||||
using Cryville.Common.Unity.Input;
|
using Cryville.Crtr.Config;
|
||||||
using Cryville.Crtr.Event;
|
using Cryville.Crtr.Event;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using System;
|
using System;
|
||||||
@@ -330,6 +330,9 @@ namespace Cryville.Crtr {
|
|||||||
FileInfo rulesetFile = new FileInfo(
|
FileInfo rulesetFile = new FileInfo(
|
||||||
Game.GameDataPath + "/rulesets/" + Settings.Default.LoadRuleset
|
Game.GameDataPath + "/rulesets/" + Settings.Default.LoadRuleset
|
||||||
);
|
);
|
||||||
|
FileInfo rulesetConfigFile = new FileInfo(
|
||||||
|
Game.GameDataPath + "/config/rulesets/" + Settings.Default.LoadRulesetConfig
|
||||||
|
);
|
||||||
FileInfo skinFile = new FileInfo(
|
FileInfo skinFile = new FileInfo(
|
||||||
Game.GameDataPath + "/skins/" + Settings.Default.LoadSkin
|
Game.GameDataPath + "/skins/" + Settings.Default.LoadSkin
|
||||||
);
|
);
|
||||||
@@ -337,6 +340,7 @@ namespace Cryville.Crtr {
|
|||||||
loadThread.Start(new LoadInfo() {
|
loadThread.Start(new LoadInfo() {
|
||||||
chartFile = chartFile,
|
chartFile = chartFile,
|
||||||
rulesetFile = rulesetFile,
|
rulesetFile = rulesetFile,
|
||||||
|
rulesetConfigFile = rulesetConfigFile,
|
||||||
skinFile = skinFile,
|
skinFile = skinFile,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -367,23 +371,7 @@ namespace Cryville.Crtr {
|
|||||||
}
|
}
|
||||||
Logger.Log("main", 0, "Load/Prehandle", "Initializing states");
|
Logger.Log("main", 0, "Load/Prehandle", "Initializing states");
|
||||||
cbus.BroadcastInit();
|
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();
|
inputProxy.Activate();
|
||||||
|
|
||||||
if (logEnabled) ToggleLogs();
|
if (logEnabled) ToggleLogs();
|
||||||
Logger.Log("main", 0, "Load/Prehandle", "Cleaning up");
|
Logger.Log("main", 0, "Load/Prehandle", "Cleaning up");
|
||||||
GC.Collect();
|
GC.Collect();
|
||||||
@@ -445,6 +433,7 @@ namespace Cryville.Crtr {
|
|||||||
struct LoadInfo {
|
struct LoadInfo {
|
||||||
public FileInfo chartFile;
|
public FileInfo chartFile;
|
||||||
public FileInfo rulesetFile;
|
public FileInfo rulesetFile;
|
||||||
|
public FileInfo rulesetConfigFile;
|
||||||
public FileInfo skinFile;
|
public FileInfo skinFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -482,7 +471,7 @@ namespace Cryville.Crtr {
|
|||||||
|
|
||||||
etor = new PdtEvaluator();
|
etor = new PdtEvaluator();
|
||||||
|
|
||||||
LoadRuleset(info.rulesetFile);
|
LoadRuleset(info.rulesetFile, info.rulesetConfigFile);
|
||||||
Logger.Log("main", 0, "Load/WorkerThread", "Applying ruleset (iteration 1)");
|
Logger.Log("main", 0, "Load/WorkerThread", "Applying ruleset (iteration 1)");
|
||||||
pruleset.PrePatch(chart);
|
pruleset.PrePatch(chart);
|
||||||
|
|
||||||
@@ -497,6 +486,7 @@ namespace Cryville.Crtr {
|
|||||||
judge = new Judge(pruleset);
|
judge = new Judge(pruleset);
|
||||||
etor.ContextJudge = judge;
|
etor.ContextJudge = judge;
|
||||||
|
|
||||||
|
inputProxy = new InputProxy(pruleset, judge);
|
||||||
cbus.AttachSystems(pskin, judge);
|
cbus.AttachSystems(pskin, judge);
|
||||||
Logger.Log("main", 0, "Load/WorkerThread", "Attaching handlers");
|
Logger.Log("main", 0, "Load/WorkerThread", "Attaching handlers");
|
||||||
var ch = new ChartHandler(chart, dir);
|
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;
|
DirectoryInfo dir = file.Directory;
|
||||||
Logger.Log("main", 0, "Load/WorkerThread", "Loading ruleset: {0}", file);
|
Logger.Log("main", 0, "Load/WorkerThread", "Loading ruleset: {0}", file);
|
||||||
using (StreamReader reader = new StreamReader(file.FullName, Encoding.UTF8)) {
|
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");
|
if (ruleset.format != 1) throw new FormatException("Invalid ruleset file version");
|
||||||
ruleset.LoadPdt(dir);
|
ruleset.LoadPdt(dir);
|
||||||
pruleset = ruleset.Root;
|
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);
|
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)]
|
[Browsable(false)]
|
||||||
[Category("data")]
|
[Category("data")]
|
||||||
[Description("The skin file to load.")]
|
[Description("The skin file to load.")]
|
||||||
|
Reference in New Issue
Block a user