public void AnalyzeRawModLua(string content) { Dictionary <object, object> dct = MainStructure.CreateAttributeDictFromLua(content); foreach (KeyValuePair <object, object> kvp in dct) { string modName = (string)kvp.Key; Modifier m = new Modifier(); m.name = modName; Dictionary <object, object> innerDict = (Dictionary <object, object>)kvp.Value; if (innerDict.ContainsKey("device")) { m.device = (string)innerDict["device"]; } if (innerDict.ContainsKey("key")) { m.key = (string)innerDict["key"]; } if (innerDict.ContainsKey("switch")) { m.sw = (bool)innerDict["switch"]; } if (!modifiers.ContainsKey(modName)) { modifiers.Add(modName, m); } } }
public void AnalyzeRawLuaInput(string content) { if (!content.Contains('{')) { return; } string cleaned = MainStructure.GetContentBetweenSymbols(content, "{", "}"); Dictionary <object, object> dct = MainStructure.CreateAttributeDictFromLua(content); if (dct.ContainsKey("axisDiffs")) { foreach (KeyValuePair <object, object> kvp in (Dictionary <object, object>)dct["axisDiffs"]) { DCSLuaDiffsAxisElement current = new DCSLuaDiffsAxisElement(); current.Keyname = (string)kvp.Key; if (axisDiffs.ContainsKey(current.Keyname)) { axisDiffs[current.Keyname] = current; } else { axisDiffs.Add(current.Keyname, current); } if (((Dictionary <object, object>)kvp.Value).ContainsKey("name")) { current.Title = (string)((Dictionary <object, object>)kvp.Value)["name"]; } if (((Dictionary <object, object>)kvp.Value).ContainsKey("added")) { Dictionary <object, object> dictAdded = (Dictionary <object, object>)((Dictionary <object, object>)kvp.Value)["added"]; foreach (KeyValuePair <object, object> kvpAdded in dictAdded) { if (((Dictionary <object, object>)kvpAdded.Value).ContainsKey("key")) { DCSAxisBind dab = new DCSAxisBind(); dab.key = (string)((Dictionary <object, object>)kvpAdded.Value)["key"]; if (((Dictionary <object, object>)kvpAdded.Value).ContainsKey("filter")) { DCSAxisFilter daf = new DCSAxisFilter(); dab.filter = daf; daf.deadzone = (double)((Dictionary <object, object>)((Dictionary <object, object>)kvpAdded.Value)["filter"])["deadzone"]; daf.inverted = (bool)((Dictionary <object, object>)((Dictionary <object, object>)kvpAdded.Value)["filter"])["invert"]; daf.slider = (bool)((Dictionary <object, object>)((Dictionary <object, object>)kvpAdded.Value)["filter"])["slider"]; daf.saturationX = (double)((Dictionary <object, object>)((Dictionary <object, object>)kvpAdded.Value)["filter"])["saturationX"]; daf.saturationY = (double)((Dictionary <object, object>)((Dictionary <object, object>)kvpAdded.Value)["filter"])["saturationY"]; foreach (KeyValuePair <object, object> kvpCurve in (Dictionary <object, object>)((Dictionary <object, object>)((Dictionary <object, object>)kvpAdded.Value)["filter"])["curvature"]) { daf.curviture.Add((double)kvpCurve.Value); } } if (!current.doesAddedContainKey(dab.key)) { current.added.Add(dab); current.removeItemFromRemoved(dab.key); } } } } if (((Dictionary <object, object>)kvp.Value).ContainsKey("removed")) { Dictionary <object, object> dictRemoved = (Dictionary <object, object>)((Dictionary <object, object>)kvp.Value)["removed"]; foreach (KeyValuePair <object, object> kvpRemoved in dictRemoved) { if (((Dictionary <object, object>)kvpRemoved.Value).ContainsKey("key")) { DCSAxisBind dab = new DCSAxisBind(); dab.key = (string)((Dictionary <object, object>)kvpRemoved.Value)["key"]; if (!current.doesRemovedContainKey(dab.key)) { current.removed.Add(dab); current.removeItemFromAdded(dab.key); } } } } } } if (dct.ContainsKey("keyDiffs")) { foreach (KeyValuePair <object, object> kvp in (Dictionary <object, object>)dct["keyDiffs"]) { DCSLuaDiffsButtonElement current = new DCSLuaDiffsButtonElement(); current.Keyname = (string)kvp.Key; if (keyDiffs.ContainsKey(current.Keyname)) { keyDiffs[current.Keyname] = current; } else { keyDiffs.Add(current.Keyname, current); } if (((Dictionary <object, object>)kvp.Value).ContainsKey("name")) { current.Title = (string)((Dictionary <object, object>)kvp.Value)["name"]; } if (((Dictionary <object, object>)kvp.Value).ContainsKey("added")) { Dictionary <object, object> dictAdded = (Dictionary <object, object>)((Dictionary <object, object>)kvp.Value)["added"]; foreach (KeyValuePair <object, object> kvpAdded in dictAdded) { if (((Dictionary <object, object>)kvpAdded.Value).ContainsKey("key")) { DCSButtonBind dab = new DCSButtonBind(); dab.key = (string)((Dictionary <object, object>)kvpAdded.Value)["key"]; if (!current.doesAddedContainKey(dab.key)) { current.added.Add(dab); current.removeItemFromRemoved(dab.key); } if (((Dictionary <object, object>)kvpAdded.Value).ContainsKey("reformers")) { foreach (KeyValuePair <object, object> kvpReformers in (Dictionary <object, object>)((Dictionary <object, object>)kvpAdded.Value)["reformers"]) { if (!dab.reformers.Contains((string)kvpReformers.Value)) { dab.reformers.Add((string)kvpReformers.Value); } } } } } } if (((Dictionary <object, object>)kvp.Value).ContainsKey("removed")) { Dictionary <object, object> dictRemoved = (Dictionary <object, object>)((Dictionary <object, object>)kvp.Value)["removed"]; foreach (KeyValuePair <object, object> kvpRemoved in dictRemoved) { if (((Dictionary <object, object>)kvpRemoved.Value).ContainsKey("key")) { DCSButtonBind dab = new DCSButtonBind(); dab.key = (string)((Dictionary <object, object>)kvpRemoved.Value)["key"]; if (!current.doesRemovedContainKey(dab.key)) { current.removed.Add(dab); current.removeItemFromAdded(dab.key); } } } } } } }