public static EliteBinds getBinds(ref Dictionary <string, object> state, ref Dictionary <string, string> textValues, ref Dictionary <string, bool?> booleanValues, Elite.MessageBus messageBus) { EliteBinds eliteBinds = null; if (needsBindsReload(ref state, ref textValues, ref booleanValues) == true) { Tuple <string, string> tResponse = Elite.getBindsFilename(); string bindsPreset = tResponse.Item1; string bindsFile = tResponse.Item2; if (bindsPreset != null && bindsFile != null) { Debug.Write("Current Binds file: " + bindsFile); var bindsTree = XElement.Load(bindsFile); state["VAEDbindsFile"] = bindsFile; state["VAEDbindsPreset"] = bindsPreset; state["VAEDlastPresetTimestamp"] = File.GetLastWriteTime(bindsPreset); state["VAEDlastBindsTimestamp"] = File.GetLastWriteTime(bindsFile); XElement keyboardLayout = bindsTree.Element("KeyboardLayout"); string lang = keyboardLayout.Value.ToString(); Debug.Write("Elite key bindings language set to: " + lang); state["VAEDbindsLanguage"] = lang; eliteBinds = new EliteBinds(bindsTree, lang); state["VAEDeliteBinds"] = eliteBinds; } } else { eliteBinds = (EliteBinds)state["VAEDeliteBinds"]; } return(eliteBinds); }
public EliteBinds() { // TODO: move hard-coded file names to defines or similar var bindsFile = Elite.getBindsFilename(); // TODO: do something if file not found var bindsTree = XElement.Load(bindsFile); _bindList = new Dictionary<string, List<string>>(); foreach (var element in bindsTree.Elements()) { var keys = ParseBindControlNode(element); if (keys == null) continue; _bindList.Add(element.Name.LocalName, keys); } _bindList.Add("HUD", new List < string >{ "LeftControl", "LeftAlt", "G" } ); _bindList.Add("FrameRate", new List<string> { "LeftControl", "F" }); _bindList.Add("ConnectionStatus", new List<string> { "LeftControl", "B" }); _bindList.Add("Snapshot", new List<string> { "F10" }); _bindList.Add("HighResSnapshot", new List<string> { "LeftAlt", "F10" }); _bindList.Add("CloseQuickComms", new List<string> { "Esc" }); // TODO: look at version in file and balk if unknown }
public static void VA_Init1(ref Dictionary <string, object> state, ref Dictionary <string, Int16?> shortIntValues, ref Dictionary <string, string> textValues, ref Dictionary <string, int?> intValues, ref Dictionary <string, decimal?> decimalValues, ref Dictionary <string, bool?> booleanValues, ref Dictionary <string, object> extendedValues) { try { Debug.Write("---------------------- Ocellus Plugin Initializing ----------------------"); // Setup Speech engine if (EliteGrammar.downloadGrammar()) { SpeechRecognitionEngine recognitionEngine = new SpeechRecognitionEngine(); recognitionEngine.SetInputToDefaultAudioDevice(); Grammar grammar = new Grammar(Path.Combine(Config.Path(), "systems_grammar.xml")); Task.Run(() => recognitionEngine.LoadGrammar(grammar)); state.Add("VAEDrecognitionEngine", recognitionEngine); } // Setup plugin storage directory - used for cookies and debug logs string appPath = Config.Path(); string cookieFile = Config.CookiePath(); string debugFile = Config.DebugPath(); textValues["VAEDdebugPath"] = debugFile; // Determine Elite Dangerous directories string gamePath = Elite.getGamePath(); string gameStartString = PluginRegistry.getStringValue("startPath"); string gameStartParams = PluginRegistry.getStringValue("startParams"); state.Add("VAEDgamePath", gamePath); textValues["VAEDgameStartString"] = gameStartString; textValues["VAEDgameStartParams"] = gameStartParams; // Load EDDB Index into memory Eddb.loadEddbIndex(ref state); // Load Atlas Index into memory Atlas.loadAtlasIndex(ref state); Dictionary <string, dynamic> tempAtlas = (Dictionary <string, dynamic>)state["VAEDatlasIndex"]; // Load Tracked Systems into memory TrackSystems.Load(ref state); CookieContainer cookieJar = new CookieContainer(); if (File.Exists(cookieFile)) { // If we have cookies then we are likely already logged in cookieJar = Web.ReadCookiesFromDisk(cookieFile); Tuple <CookieContainer, string> tAuthentication = Companion.loginToAPI(cookieJar); if (tAuthentication.Item2 == "ok") { cookieJar = tAuthentication.Item1; state.Add("VAEDcookieContainer", cookieJar); state["VAEDloggedIn"] = "ok"; } } else { state.Add("VAEDloggedIn", "no"); } EliteBinds eliteBinds = new EliteBinds(); state.Add("VAEDeliteBinds", eliteBinds); string bindsFile = Elite.getBindsFilename(); DateTime fileTime = File.GetLastWriteTime(bindsFile); state.Add("VAEDbindsFile", bindsFile); state.Add("VAEDbindsTimestamp", fileTime); } catch (Exception ex) { Debug.Write(ex.ToString()); } }