Code cleanup.
This commit is contained in:
@@ -23,7 +23,7 @@ namespace Cryville.Crtr {
|
||||
_judge = judge;
|
||||
foreach (var i in ruleset.inputs) {
|
||||
_use.Add(i.Key, 0);
|
||||
_rev.Add(i.Key, new List<string>());
|
||||
_rev.Add(i.Key, new List<Identifier>());
|
||||
}
|
||||
foreach (var i in ruleset.inputs) {
|
||||
if (i.Value.pass != null) {
|
||||
@@ -33,15 +33,15 @@ namespace Cryville.Crtr {
|
||||
}
|
||||
}
|
||||
#region Settings
|
||||
readonly Dictionary<string, InputProxyEntry> _tproxies = new Dictionary<string, InputProxyEntry>();
|
||||
readonly Dictionary<Identifier, InputProxyEntry> _tproxies = new Dictionary<Identifier, InputProxyEntry>();
|
||||
readonly Dictionary<InputSource, InputProxyEntry> _sproxies = new Dictionary<InputSource, InputProxyEntry>();
|
||||
readonly Dictionary<string, int> _use = new Dictionary<string, int>();
|
||||
readonly Dictionary<string, List<string>> _rev = new Dictionary<string, List<string>>();
|
||||
readonly Dictionary<Identifier, int> _use = new Dictionary<Identifier, int>();
|
||||
readonly Dictionary<Identifier, List<Identifier>> _rev = new Dictionary<Identifier, List<Identifier>>();
|
||||
public event EventHandler<ProxyChangedEventArgs> ProxyChanged;
|
||||
public void LoadFrom(Dictionary<string, RulesetConfig.InputEntry> config) {
|
||||
foreach (var cfg in config) {
|
||||
Set(new InputProxyEntry {
|
||||
Target = cfg.Key,
|
||||
Target = new Identifier(cfg.Key),
|
||||
Source = new InputSource {
|
||||
Handler = Game.InputManager.GetHandler(cfg.Value.handler),
|
||||
Type = cfg.Value.type
|
||||
@@ -52,7 +52,7 @@ namespace Cryville.Crtr {
|
||||
public void SaveTo(Dictionary<string, RulesetConfig.InputEntry> config) {
|
||||
config.Clear();
|
||||
foreach (var p in _tproxies) {
|
||||
config.Add(p.Key, new RulesetConfig.InputEntry {
|
||||
config.Add((string)p.Key.Name, new RulesetConfig.InputEntry {
|
||||
handler = ReflectionHelper.GetNamespaceQualifiedName(p.Value.Source.Value.Handler.GetType()),
|
||||
type = p.Value.Source.Value.Type
|
||||
});
|
||||
@@ -88,7 +88,7 @@ namespace Cryville.Crtr {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
void IncrementUseRecursive(string name) {
|
||||
void IncrementUseRecursive(Identifier name) {
|
||||
BroadcastProxyChanged(name);
|
||||
var passes = _ruleset.inputs[name].pass;
|
||||
if (passes != null) {
|
||||
@@ -98,14 +98,14 @@ namespace Cryville.Crtr {
|
||||
}
|
||||
}
|
||||
}
|
||||
void IncrementReversedUseRecursive(string name) {
|
||||
void IncrementReversedUseRecursive(Identifier name) {
|
||||
foreach (var p in _rev[name]) {
|
||||
_use[p]++;
|
||||
BroadcastProxyChanged(p);
|
||||
IncrementReversedUseRecursive(p);
|
||||
}
|
||||
}
|
||||
void DecrementUseRecursive(string name) {
|
||||
void DecrementUseRecursive(Identifier name) {
|
||||
BroadcastProxyChanged(name);
|
||||
var passes = _ruleset.inputs[name].pass;
|
||||
if (passes != null) {
|
||||
@@ -115,18 +115,18 @@ namespace Cryville.Crtr {
|
||||
}
|
||||
}
|
||||
}
|
||||
void DecrementReversedUseRecursive(string name) {
|
||||
void DecrementReversedUseRecursive(Identifier name) {
|
||||
foreach (var p in _rev[name]) {
|
||||
_use[p]--;
|
||||
BroadcastProxyChanged(p);
|
||||
DecrementReversedUseRecursive(p);
|
||||
}
|
||||
}
|
||||
void BroadcastProxyChanged(string name) {
|
||||
void BroadcastProxyChanged(Identifier name) {
|
||||
var del = ProxyChanged;
|
||||
if (del != null) del(this, this[name]);
|
||||
}
|
||||
public ProxyChangedEventArgs this[string name] {
|
||||
public ProxyChangedEventArgs this[Identifier name] {
|
||||
get {
|
||||
return new ProxyChangedEventArgs(name, _tproxies.ContainsKey(name) ? _tproxies[name].Source : null, _use[name] > 0);
|
||||
}
|
||||
@@ -263,10 +263,10 @@ namespace Cryville.Crtr {
|
||||
}
|
||||
|
||||
public class ProxyChangedEventArgs : EventArgs {
|
||||
public string Name { get; private set; }
|
||||
public Identifier Name { get; private set; }
|
||||
public InputSource? Proxy { get; private set; }
|
||||
public bool Used { get; private set; }
|
||||
public ProxyChangedEventArgs(string name, InputSource? src, bool used) {
|
||||
public ProxyChangedEventArgs(Identifier name, InputSource? src, bool used) {
|
||||
Name = name;
|
||||
Proxy = src;
|
||||
Used = used;
|
||||
@@ -275,7 +275,7 @@ namespace Cryville.Crtr {
|
||||
|
||||
public class InputProxyEntry {
|
||||
public InputSource? Source { get; set; }
|
||||
public string Target { get; set; }
|
||||
public Identifier Target { get; set; }
|
||||
public byte[] Mapping { get; private set; }
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user