public override bool ExecuteAction(ActionProgramRun ap) { string exp; if (ap.functions.ExpandString(UserData, out exp) != ConditionFunctions.ExpandResult.Failed) { StringParser sp = new StringParser(exp); string handle = sp.NextWordComma(); if (handle != null && ap.dialogs.ContainsKey(handle)) { Forms.ConfigurableForm f = ap.dialogs[handle]; string cmd = sp.NextWord(lowercase: true); if (cmd == null) { ap.ReportError("Missing command in DialogControl"); } else if (cmd.Equals("continue")) { return(false); } else if (cmd.Equals("get")) { string control = sp.NextWord(); string r; if (control != null && (r = f.Get(control)) != null) { ap["DialogResult"] = r; } else { ap.ReportError("Missing or invalid dialog name in DialogControl get"); } } else if (cmd.Equals("set")) { string control = sp.NextWord(" ="); string value = sp.IsCharMoveOn('=') ? sp.NextQuotedWord() : null; if (control != null && value != null) { if (!f.Set(control, value)) { ap.ReportError("Cannot set control " + control + " in DialogControl set"); } } else { ap.ReportError("Missing or invalid dialog name and/or value in DialogControl set"); } } else if (cmd.Equals("close")) { f.Close(); ap.dialogs.Remove(handle); } else { ap.ReportError("Unknown command in DialogControl"); } } else { ap.ReportError("Missing handle in DialogControl"); } } else { ap.ReportError(exp); } return(true); }
public override bool ExecuteAction(ActionProgramRun ap) { string res; if (ap.functions.ExpandString(UserData, out res) != Conditions.ConditionFunctions.ExpandResult.Failed) { StringParser sp = new StringParser(res); string cmdname = sp.NextWord(" ", lowercase: true); if (cmdname == null) { ap.ReportError("Missing command in Perform"); } else if (cmdname.Equals("3dmap")) { (ap.actioncontroller as ActionController).DiscoveryForm.Open3DMap(null); } else if (cmdname.Equals("2dmap")) { (ap.actioncontroller as ActionController).DiscoveryForm.Open2DMap(); } else if (cmdname.Equals("edsm")) { EliteDangerousCore.EDSM.EDSMClass edsm = new EliteDangerousCore.EDSM.EDSMClass(); ActionController ac = (ap.actioncontroller as ActionController); ac.DiscoveryForm.EdsmSync.StartSync(edsm, ac.DiscoveryForm.history, EliteDangerousCore.EDCommander.Current.SyncToEdsm, EliteDangerousCore.EDCommander.Current.SyncFromEdsm, EDDiscovery.EDDConfig.Instance.DefaultMapColour); } else if (cmdname.Equals("refresh")) { (ap.actioncontroller as ActionController).DiscoveryForm.RefreshHistoryAsync(checkedsm: true); } else if (cmdname.Equals("url")) { string url = sp.LineLeft; if (url.StartsWith("http:", StringComparison.InvariantCultureIgnoreCase) || url.StartsWith("https:", StringComparison.InvariantCultureIgnoreCase)) // security.. { System.Diagnostics.Process.Start(url); } else { ap.ReportError("Perform url must start with http"); } } else if (cmdname.Equals("configurevoice")) { (ap.actioncontroller as ActionController).ConfigureVoice(sp.NextQuotedWord() ?? "Configure Voice Synthesis"); } else if (cmdname.Equals("manageaddons")) { (ap.actioncontroller as ActionController).ManageAddOns(); } else if (cmdname.Equals("editaddons")) { (ap.actioncontroller as ActionController).EditAddOns(); } else if (cmdname.Equals("editlastpack")) { (ap.actioncontroller as ActionController).EditLastPack(); } else if (cmdname.Equals("editspeechtext")) { (ap.actioncontroller as ActionController).EditSpeechText(); } else if (cmdname.Equals("configurewave")) { (ap.actioncontroller as ActionController).ConfigureWave(sp.NextQuotedWord() ?? "Configure Wave Output"); } else if (cmdname.Equals("enableeliteinput")) { (ap.actioncontroller as ActionController).EliteInput(true, true); } else if (cmdname.Equals("enableeliteinputnoaxis")) { (ap.actioncontroller as ActionController).EliteInput(true, false); } else if (cmdname.Equals("disableeliteinput")) { (ap.actioncontroller as ActionController).EliteInput(false, false); } else if (cmdname.Equals("enablevoicerecognition")) { (ap.actioncontroller as ActionController).VoiceRecon(true, sp.NextQuotedWord() ?? "en-gb"); } else if (cmdname.Equals("disablevoicerecognition")) { (ap.actioncontroller as ActionController).VoiceRecon(false); } else if (cmdname.Equals("listeliteinput")) { ap["EliteInput"] = (ap.actioncontroller as ActionController).EliteInputList(); ap["EliteInputCheck"] = (ap.actioncontroller as ActionController).EliteInputCheck(); } else if (cmdname.Equals("voicenames")) { ap["VoiceNames"] = (ap.actioncontroller as ActionController).SpeechSynthesizer.GetVoiceNames().QuoteStrings(); } else { ap.ReportError("Unknown command " + cmdname + " in Performaction"); } } else { ap.ReportError(res); } return(true); }
public override bool ExecuteAction(ActionProgramRun ap) { string res; if (ap.functions.ExpandString(UserData, out res) != ConditionFunctions.ExpandResult.Failed) { StringParser sp = new StringParser(res); string cmdname = sp.NextWord(" ", true); if (cmdname == null) { ap.ReportError("Missing command in Perform"); } else if (cmdname.Equals("3dmap")) { ap.actioncontroller.DiscoveryForm.Open3DMap(null); } else if (cmdname.Equals("2dmap")) { ap.actioncontroller.DiscoveryForm.Open2DMap(); } else if (cmdname.Equals("edsm")) { EDDiscovery.EDSM.EDSMClass edsm = new EDDiscovery.EDSM.EDSMClass(); ap.actioncontroller.DiscoveryForm.EdsmSync.StartSync(edsm, EDDiscovery.EDCommander.Current.SyncToEdsm, EDDiscovery.EDCommander.Current.SyncFromEdsm, EDDiscovery.EDDConfig.Instance.DefaultMapColour); } else if (cmdname.Equals("refresh")) { ap.actioncontroller.DiscoveryForm.RefreshHistoryAsync(checkedsm: true); } else if (cmdname.Equals("url")) { string url = sp.LineLeft; if (url.StartsWith("http:", StringComparison.InvariantCultureIgnoreCase) || url.StartsWith("https:", StringComparison.InvariantCultureIgnoreCase)) // security.. { System.Diagnostics.Process.Start(url); } else { ap.ReportError("Perform url must start with http"); } } else if (cmdname.Equals("configurevoice")) { ap.actioncontroller.ConfigureVoice(sp.NextQuotedWord() ?? "Configure Voice Synthesis"); } else if (cmdname.Equals("manageaddons")) { ap.actioncontroller.ManageAddOns(); } else if (cmdname.Equals("editaddons")) { ap.actioncontroller.EditAddOnActionFile(); } else if (cmdname.Equals("editspeechtext")) { ap.actioncontroller.EditSpeechText(); } else if (cmdname.Equals("editlasttext")) { ap.actioncontroller.EditLastTextFile(); } else if (cmdname.Equals("configurewave")) { ap.actioncontroller.ConfigureWave(sp.NextQuotedWord() ?? "Configure Wave Output"); } else { ap.ReportError("Unknown command " + cmdname + " in Performaction"); } } else { ap.ReportError(res); } return(true); }
public override bool ExecuteAction(ActionProgramRun ap) { string res; if (ap.Functions.ExpandString(UserData, out res) != BaseUtils.Functions.ExpandResult.Failed) { StringParser sp = new StringParser(res); string prefix = (commodities) ? "C_" : "M_"; string cmdname = sp.NextWord(); if (cmdname != null && cmdname.Equals("PREFIX", StringComparison.InvariantCultureIgnoreCase)) { prefix = sp.NextWord(); if (prefix == null) { ap.ReportError("Missing name after Prefix in Materials/Commodity"); return(true); } cmdname = sp.NextWord(); } if (cmdname != null) { long jid; if (!cmdname.InvariantParse(out jid)) { ap.ReportError("Non integer JID in Materials/Commodity"); return(true); } int jidindex = (ap.ActionController as ActionController).HistoryList.EntryOrder().FindIndex(x => x.Journalid == jid); if (jidindex == -1) { ap.ReportError("JID does not exist in Materials/Commodity"); return(true); } MaterialCommoditiesList mcl = (ap.ActionController as ActionController).HistoryList.EntryOrder()[jidindex].MaterialCommodity; List <MaterialCommodities> list = mcl.Sort(commodities); ap[prefix + "Count"] = list.Count.ToString(System.Globalization.CultureInfo.InvariantCulture); ap[prefix + "IndexOf"] = (ap.ActionController as ActionController).HistoryList.EntryOrder()[jidindex].EntryNumber.ToString(System.Globalization.CultureInfo.InvariantCulture); for (int i = 0; i < list.Count; i++) { string postfix = (i + 1).ToString(System.Globalization.CultureInfo.InvariantCulture); ap[prefix + "Name" + postfix] = list[i].Details.Name; ap[prefix + "Category" + postfix] = list[i].Details.Category.ToString(); ap[prefix + "fdname" + postfix] = list[i].Details.FDName; ap[prefix + "type" + postfix] = list[i].Details.Type.ToString().SplitCapsWord(); ap[prefix + "shortname" + postfix] = list[i].Details.Shortname; } } else { ap.ReportError("Missing JID in Materials"); } } else { ap.ReportError(res); } return(true); }
public override bool ExecuteAction(ActionProgramRun ap) { string res; if (ap.functions.ExpandString(UserData, out res) != BaseUtils.Functions.ExpandResult.Failed) { StringParser sp = new StringParser(res); string prefix = "B_"; string cmdname = sp.NextWord(); if (cmdname != null && cmdname.Equals("PREFIX", StringComparison.InvariantCultureIgnoreCase)) { prefix = sp.NextWord(); if (prefix == null) { ap.ReportError("Missing name after Prefix in Bookmarks"); return(true); } cmdname = sp.NextWord(); } if (cmdname != null) { if (cmdname.Equals("LIST", StringComparison.InvariantCultureIgnoreCase)) { string wildcard = sp.NextQuotedWord() ?? "*"; int bcount = 1; foreach (BookmarkClass b in GlobalBookMarkList.Instance.Bookmarks) { if (b.Name.WildCardMatch(wildcard)) { string nprefix = prefix + bcount++.ToStringInvariant() + "_"; ap[nprefix + "isstar"] = b.isStar.ToStringIntValue(); ap[nprefix + "name"] = b.Name; ap[nprefix + "x"] = b.x.ToStringInvariant(); ap[nprefix + "y"] = b.y.ToStringInvariant(); ap[nprefix + "z"] = b.z.ToStringInvariant(); ap[nprefix + "time"] = b.Time.ToStringUS(); // US Date format ap[nprefix + "note"] = b.Note; if (b.PlanetaryMarks != null) { string pprefix = nprefix + "Planet_"; ap[pprefix + "Count"] = b.PlanetaryMarks.Planets.Count().ToStringInvariant(); int pcount = 1; foreach (PlanetMarks.Planet p in b.PlanetaryMarks.Planets) { string plname = pprefix + pcount++.ToStringInvariant() + "_"; ap[plname + "name"] = p.Name; ap[plname + "Count"] = p.Locations.Count.ToStringInvariant(); int lcount = 1; foreach (PlanetMarks.Location l in p.Locations) { string locname = plname + lcount++.ToStringInvariant() + "_"; ap[locname + "name"] = l.Name; ap[locname + "comment"] = l.Comment; ap[locname + "latitude"] = l.Latitude.ToStringInvariant("0.#"); ap[locname + "longitude"] = l.Longitude.ToStringInvariant("0.#"); } } } } } ap[prefix + "MatchCount"] = (bcount - 1).ToStringInvariant(); ap[prefix + "TotalCount"] = GlobalBookMarkList.Instance.Bookmarks.Count.ToStringInvariant(); } else { string name = sp.NextQuotedWord(); bool region = name.Equals("REGION", StringComparison.InvariantCultureIgnoreCase); if (region) { name = sp.NextQuotedWord(); } if (name == null) { ap.ReportError("Missing name in command"); } else if (cmdname.Equals("ADD", StringComparison.InvariantCultureIgnoreCase)) { double?x = sp.NextDouble(); double?y = sp.NextDouble(); double?z = sp.NextDouble(); string notes = sp.NextQuotedWord(); // valid for it to be null. Means don't update notes if (x != null && y != null && z != null) { BookmarkClass bk = GlobalBookMarkList.Instance.FindBookmark(name, region); GlobalBookMarkList.Instance.AddOrUpdateBookmark(bk, !region, name, x.Value, y.Value, z.Value, DateTime.Now, notes); } else { ap.ReportError("Missing parameters in Add"); } } else if (cmdname.Equals("DELETE", StringComparison.InvariantCultureIgnoreCase)) { BookmarkClass bk = GlobalBookMarkList.Instance.FindBookmark(name, region); if (bk != null) { GlobalBookMarkList.Instance.Delete(bk); } else { ap.ReportError("Delete cannot find star or region " + name); } } else if (cmdname.Equals("UPDATENOTE", StringComparison.InvariantCultureIgnoreCase)) { string notes = sp.NextQuotedWord(); if (notes != null) { BookmarkClass bk = GlobalBookMarkList.Instance.FindBookmark(name, region); if (bk != null) { bk.UpdateNotes(notes); } else { ap.ReportError("UpdateNote cannot find star or region " + name); } } else { ap.ReportError("UpdateNote notes not present"); } } else { bool addstar = cmdname.Equals("ADDSTAR", StringComparison.InvariantCultureIgnoreCase); bool addplanet = cmdname.Equals("ADDPLANET", StringComparison.InvariantCultureIgnoreCase); bool deleteplanet = cmdname.Equals("DELETEPLANET", StringComparison.InvariantCultureIgnoreCase); bool updatenoteonplanet = cmdname.Equals("UPDATEPLANETNOTE", StringComparison.InvariantCultureIgnoreCase); bool planetmarkexists = cmdname.Equals("PLANETMARKEXISTS", StringComparison.InvariantCultureIgnoreCase); if (!addstar && !addplanet && !deleteplanet && !updatenoteonplanet && !planetmarkexists) { ap.ReportError("Unknown command"); } else if (region) { ap.ReportError("Command and REGION are incompatible"); } else if (addstar) { ISystem sys = (ap.actioncontroller as ActionController).DiscoveryForm.history.FindSystem(name); if (sys != null) { string notes = sp.NextQuotedWord(); // valid for it to be null, means don't override or set to empty BookmarkClass bk = GlobalBookMarkList.Instance.FindBookmarkOnSystem(name); GlobalBookMarkList.Instance.AddOrUpdateBookmark(bk, true, name, sys.X, sys.Y, sys.Z, DateTime.Now, notes); } else { ap.ReportError("AddStar cannot find star " + name + " in database"); } } else { BookmarkClass bk = GlobalBookMarkList.Instance.FindBookmarkOnSystem(name); if (bk != null) { string planet = sp.NextQuotedWord(); string placename = sp.NextQuotedWord(); if (planet != null && placename != null) { if (addplanet) { double?latp = sp.NextDouble(); double?longp = sp.NextDouble(); string comment = sp.NextQuotedWord(); // can be null if (planet != null && latp != null && longp != null) { bk.AddOrUpdateLocation(planet, placename, comment ?? "", latp.Value, longp.Value); } else { ap.ReportError("AddPlanet missing parameters"); } } else if (updatenoteonplanet) { string comment = sp.NextQuotedWord(); if (comment != null) { if (!bk.UpdateLocationComment(planet, placename, comment)) { ap.ReportError("UpdatePlanetNote no such placename"); } } else { ap.ReportError("UpdatePlanetNote no comment"); } } else if (deleteplanet) { if (!bk.DeleteLocation(planet, placename)) { ap.ReportError("DeletePlanet no such placename"); } } else if (planetmarkexists) { ap[prefix + "Exists"] = bk.HasLocation(planet, placename).ToStringIntValue(); } } else { ap.ReportError("Missing planet and/or placename"); } } else { ap.ReportError("Cannot find bookmark for " + name); } } } } } else { ap.ReportError("Missing Bookmarks command"); } } else { ap.ReportError(res); } return(true); }
public override bool ExecuteAction(ActionProgramRun ap) { List <string> ctrl = FromString(UserData); if (ctrl != null) { List <string> exp; if (ap.functions.ExpandStrings(ctrl, out exp) != Functions.ExpandResult.Failed) { string cmdname = exp[0].ToLowerInvariant(); string nextword = exp.Count >= 2 ? exp[1] : null; string thirdword = exp.Count >= 3 ? exp[2] : null; string fourthword = exp.Count >= 4 ? exp[3] : null; string fifthword = exp.Count >= 5 ? exp[4] : null; if (cmdname == null) { ap.ReportError("Missing command in Perform"); } else if (cmdname.Equals("3dmap")) { (ap.actioncontroller as ActionController).DiscoveryForm.Open3DMap(null); } else if (cmdname.Equals("2dmap")) { (ap.actioncontroller as ActionController).DiscoveryForm.Open2DMap(); } else if (cmdname.Equals("edsm")) { ActionController ac = (ap.actioncontroller as ActionController); EliteDangerousCore.EDSM.EDSMClass edsm = new EliteDangerousCore.EDSM.EDSMClass(); if (edsm.ValidCredentials) { EliteDangerousCore.EDSM.EDSMJournalSync.SendEDSMEvents(ap.actioncontroller.LogLine, ac.DiscoveryForm.history); } else { ap.ReportError("No valid EDSM Credentials"); } } else if (cmdname.Equals("refresh")) { (ap.actioncontroller as ActionController).DiscoveryForm.RefreshHistoryAsync(); } else if (cmdname.Equals("url")) { if (nextword != null && nextword.StartsWith("http:", StringComparison.InvariantCultureIgnoreCase) || nextword.StartsWith("https:", StringComparison.InvariantCultureIgnoreCase)) // security.. { System.Diagnostics.Process.Start(nextword); } else { ap.ReportError("Perform url must start with http"); } } else if (cmdname.Equals("configurevoice")) { (ap.actioncontroller as ActionController).ConfigureVoice(nextword ?? "Configure Voice Synthesis"); } else if (cmdname.Equals("manageaddons")) { (ap.actioncontroller as ActionController).ManageAddOns(); } else if (cmdname.Equals("editaddons")) { (ap.actioncontroller as ActionController).EditAddOns(); } else if (cmdname.Equals("editlastpack")) { (ap.actioncontroller as ActionController).EditLastPack(); } else if (cmdname.Equals("editpack")) { if (nextword != null) { if (!(ap.actioncontroller as ActionController).EditPack(nextword)) { ap.ReportError("Pack " + nextword + " not found"); } } else { ap.ReportError("EditPack requires a pack name"); } } else if (cmdname.Equals("editspeechtext")) { (ap.actioncontroller as ActionController).EditSpeechText(); } else if (cmdname.Equals("configurewave")) { (ap.actioncontroller as ActionController).ConfigureWave(nextword ?? "Configure Wave Output"); } else if (cmdname.Equals("enableeliteinput")) { (ap.actioncontroller as ActionController).EliteInput(true, true); } else if (cmdname.Equals("enableeliteinputnoaxis")) { (ap.actioncontroller as ActionController).EliteInput(true, false); } else if (cmdname.Equals("disableeliteinput")) { (ap.actioncontroller as ActionController).EliteInput(false, false); } else if (cmdname.Equals("enablevoicerecognition")) { if (nextword != null) { ap["VoiceRecognitionEnabled"] = ((ap.actioncontroller as ActionController).VoiceReconOn(nextword)).ToStringIntValue(); } else { ap.ReportError("EnableVoiceRecognition requires a culture"); } } else if (cmdname.Equals("disablevoicerecognition")) { (ap.actioncontroller as ActionController).VoiceReconOff(); } else if (cmdname.Equals("beginvoicerecognition")) { (ap.actioncontroller as ActionController).VoiceLoadEvents(); } else if (cmdname.Equals("voicerecognitionconfidencelevel")) { float?conf = nextword.InvariantParseFloatNull(); if (conf != null) { (ap.actioncontroller as ActionController).VoiceReconConfidence(conf.Value); } else { ap.ReportError("VoiceRecognitionConfidencelLevel requires a confidence value"); } } else if (cmdname.Equals("voicerecognitionparameters")) { int?babble = nextword.InvariantParseIntNull(); // babble at end int?initialsilence = thirdword.InvariantParseIntNull(); // silence at end int?endsilence = fourthword.InvariantParseIntNull(); // unambigious timeout int?endsilenceambigious = fifthword.InvariantParseIntNull(); // ambiguous timeout if (babble != null && initialsilence != null && endsilence != null && endsilenceambigious != null) { (ap.actioncontroller as ActionController).VoiceReconParameters(babble.Value, initialsilence.Value, endsilence.Value, endsilenceambigious.Value); } else { ap.ReportError("VoiceRecognitionParameters requires four values"); } } else if (cmdname.Equals("voicerecognitionphrases")) { ap["Phrases"] = (ap.actioncontroller as ActionController).VoicePhrases(Environment.NewLine); } else if (cmdname.Equals("listeliteinput")) { ap["EliteInput"] = (ap.actioncontroller as ActionController).EliteInputList(); ap["EliteInputCheck"] = (ap.actioncontroller as ActionController).EliteInputCheck(); } else if (cmdname.Equals("voicenames")) { ap["VoiceNames"] = (ap.actioncontroller as ActionController).SpeechSynthesizer.GetVoiceNames().QuoteStrings(); } else if (cmdname.Equals("bindings")) { ap["Bindings"] = (ap.actioncontroller as ActionController).FrontierBindings.ListBindings(); } else if (cmdname.Equals("bindingvalues")) { ap["BindingValues"] = (ap.actioncontroller as ActionController).FrontierBindings.ListValues(); } else if (cmdname.Equals("actionfile")) { ActionFile f = (ap.actioncontroller as ActionController).Get(nextword); if (f != null) { int i = 0; foreach (var x in f.actioneventlist.Enumerable) { ap["Events[" + i++ + "]"] = x.ToString(true); // list hooked events ap["Events_" + x.eventname] = x.ToString(true); // list hooked events } i = 0; foreach (string jname in Enum.GetNames(typeof(EliteDangerousCore.JournalTypeEnum))) { List <Condition> cl = f.actioneventlist.GetConditionListByEventName(jname); if (cl != null) { int v = 0; foreach (var c in cl) { ap["JEvents[" + i++ + "]"] = c.ToString(true); ap["JEvents_" + c.eventname + "_" + v++] = c.ToString(true); } } else { ap["JEvents[" + i++ + "]"] = jname + ", None"; ap["JEvents_" + jname] = "None"; } } i = 0; foreach (string iname in Enum.GetNames(typeof(EliteDangerousCore.UITypeEnum))) { List <Condition> cl = f.actioneventlist.GetConditionListByEventName("UI" + iname); if (cl != null) { int v = 0; foreach (var c in cl) { ap["UIEvents[" + i++ + "]"] = c.ToString(true); ap["UIEvents_" + c.eventname + "_" + v++] = c.ToString(true); } } else { ap["UIEvents[" + i++ + "]"] = iname + ", None"; ap["UIEvents_" + iname] = "None"; } } i = 0; foreach (var x in f.installationvariables.NameEnumuerable) { ap["Install[" + i++ + "]"] = x + "," + f.installationvariables[x]; // list hooked events } i = 0; foreach (var x in f.filevariables.NameEnumuerable) { ap["FileVar[" + i++ + "]"] = x + "," + f.filevariables[x]; // list hooked events } ap["Enabled"] = f.enabled.ToStringIntValue(); } else { ap.ReportError("Action file " + nextword + " is not loaded"); } } else if (cmdname.Equals("datadownload")) { string gitfolder = nextword; string filewildcard = thirdword; string directory = fourthword; string optclean = fifthword; if (gitfolder != null && filewildcard != null && directory != null) { if (System.IO.Directory.Exists(directory)) { BaseUtils.GitHubClass ghc = new BaseUtils.GitHubClass(EDDiscovery.Properties.Resources.URLGithubDataDownload); bool worked = ghc.Download(directory, gitfolder, filewildcard, optclean != null && optclean == "1"); ap["Downloaded"] = worked.ToStringIntValue(); } else { ap.ReportError("Download folder " + directory + " does not exist"); } } else { ap.ReportError("Missing parameters in Perform Datadownload"); } } else if (cmdname.Equals("generateevent")) { if (nextword != null) { ActionEvent f = ActionEventEDList.EventList(excludejournal: true).Find(x => x.TriggerName.Equals(nextword)); if (f != null) { BaseUtils.Variables c = new BaseUtils.Variables(); for (int w = 2; w < exp.Count; w++) { string vname = exp[w]; int asterisk = vname.IndexOf('*'); if (asterisk >= 0) // pass in name* no complaining if not there { string prefix = vname.Substring(0, asterisk); foreach (string jkey in ap.variables.NameEnumuerable) { if (jkey.StartsWith(prefix)) { c[jkey] = ap.variables[jkey]; } } } else { if (ap.variables.Exists(vname)) // pass in explicit name { c[vname] = ap.variables[vname]; } else { ap.ReportError("No such variable '" + vname + "'"); return(true); } } } if (f.TriggerName.StartsWith("UI") || f.TriggerName.Equals("onEliteUIEvent")) { c["EventClass_EventTimeUTC"] = DateTime.UtcNow.ToStringUS(); c["EventClass_EventTypeID"] = c["EventClass_EventTypeStr"] = f.TriggerName.Substring(2); c["EventClass_UIDisplayed"] = "0"; (ap.actioncontroller as ActionController).ActionRun(Actions.ActionEventEDList.onUIEvent, c); } (ap.actioncontroller as ActionController).ActionRun(f, c, now: true); } else { try { EliteDangerousCore.JournalEntry je = EliteDangerousCore.JournalEntry.CreateJournalEntry(nextword); ap["GenerateEventName"] = je.EventTypeStr; if (je is EliteDangerousCore.JournalEvents.JournalUnknown) { ap.ReportError("Unknown journal event"); } else { EliteDangerousCore.HistoryEntry he = EliteDangerousCore.HistoryEntry.FromJournalEntry(je, null, true, out bool journalupdate); (ap.actioncontroller as ActionController).ActionRunOnEntry(he, Actions.ActionEventEDList.NewEntry(he), now: true); } } catch { ap.ReportError("Journal event not in correct JSON form"); } } } else { ap.ReportError("No journal event or event name after GenerateEvent"); } } else { ap.ReportError("Unknown command " + cmdname + " in Performaction"); } } else { ap.ReportError(exp[0]); } } else { ap.ReportError("Perform command line not in correct format"); } return(true); }
public override bool ExecuteAction(ActionProgramRun ap) { string res; if (ap.functions.ExpandString(UserData, out res) != BaseUtils.Functions.ExpandResult.Failed) { StringParser sp = new StringParser(res); string prefix = "P_"; string cmdname = sp.NextQuotedWord(); if (cmdname != null && cmdname.Equals("PREFIX", StringComparison.InvariantCultureIgnoreCase)) { prefix = sp.NextWord(); if (prefix == null) { ap.ReportError("Missing name after Prefix in in Popout"); return(true); } cmdname = sp.NextQuotedWord(); } PopOutControl poc = (ap.actioncontroller as ActionController).DiscoveryForm.PopOuts; if (cmdname == null) { ap.ReportError("Missing command or popout name in Popout"); } else if (cmdname.Equals("Status", StringComparison.InvariantCultureIgnoreCase)) { ap[prefix + "Count"] = poc.Count.ToString(System.Globalization.CultureInfo.InvariantCulture); for (int i = 0; i < poc.Count; i++) { ap[prefix + i.ToString(System.Globalization.CultureInfo.InvariantCulture)] = poc[i].Name; } } else { Forms.UserControlForm ucf = poc.GetByWindowsRefName(cmdname); string nextcmd = sp.NextWordLCInvariant(" "); if (nextcmd == null) { ap.ReportError("Missing command after popout name in Popout"); } else if (nextcmd.Equals("status")) { ap[prefix + "Exists"] = (ucf != null) ? "1" : "0"; if (ucf != null) { ap[prefix + "Transparent"] = ucf.IsTransparent ? "1" : "0"; ap[prefix + "TopMost"] = ucf.TopMost ? "1" : "0"; ap[prefix + "DisplayTitle"] = ucf.displayTitle ? "1" : "0"; ap[prefix + "ShowInTaskbar"] = ucf.ShowInTaskbar ? "1" : "0"; ap[prefix + "WindowState"] = ucf.WindowState.ToString(); ap[prefix + "Top"] = ucf.Top.ToString(System.Globalization.CultureInfo.InvariantCulture); ap[prefix + "Left"] = ucf.Left.ToString(System.Globalization.CultureInfo.InvariantCulture); ap[prefix + "Width"] = ucf.Width.ToString(System.Globalization.CultureInfo.InvariantCulture); ap[prefix + "Height"] = ucf.Height.ToString(System.Globalization.CultureInfo.InvariantCulture); } } else if (ucf != null) // found a panel with the name { if (nextcmd.Equals("toggle") || nextcmd.Equals("off")) { ucf.Close(); } else if (nextcmd.Equals("on")) // does nothing { } else if (nextcmd.Equals("transparent")) { ucf.SetTransparency(Forms.UserControlForm.TransparencyMode.On); } else if (nextcmd.Equals("opaque")) { ucf.SetTransparency(Forms.UserControlForm.TransparencyMode.Off); } else if (nextcmd.Equals("title")) { ucf.SetShowInTaskBar(true); } else if (nextcmd.Equals("notitle")) { ucf.SetShowInTaskBar(false); } else if (nextcmd.Equals("topmost")) { ucf.SetTopMost(true); } else if (nextcmd.Equals("normalz")) { ucf.SetTopMost(false); } else if (nextcmd.Equals("showintaskbar")) { ucf.SetShowInTaskBar(true); } else if (nextcmd.Equals("notshowintaskbar")) { ucf.SetShowInTaskBar(false); } else if (nextcmd.Equals("minimize")) { ucf.WindowState = FormWindowState.Minimized; } else if (nextcmd.Equals("normal")) { ucf.WindowState = FormWindowState.Normal; } else if (nextcmd.Equals("maximize")) { ucf.WindowState = FormWindowState.Maximized; } else if (nextcmd.Equals("location")) { int?x = sp.NextWordComma().InvariantParseIntNull(); int?y = sp.NextWordComma().InvariantParseIntNull(); int?w = sp.NextWordComma().InvariantParseIntNull(); int?h = sp.NextWord().InvariantParseIntNull(); if (x.HasValue && y.HasValue && w.HasValue && h.HasValue) { ucf.Location = new Point(x.Value, y.Value); ucf.Size = new Size(w.Value, h.Value); } else { ap.ReportError("Location needs x,y,w,h in Popout"); } } else if (nextcmd.Equals("position")) { int?x = sp.NextWordComma().InvariantParseIntNull(); int?y = sp.NextWord().InvariantParseIntNull(); if (x.HasValue && y.HasValue) { ucf.Location = new Point(x.Value, y.Value); } else { ap.ReportError("Position needs x,y in Popout"); } } else if (nextcmd.Equals("size")) { int?w = sp.NextWordComma().InvariantParseIntNull(); int?h = sp.NextWord().InvariantParseIntNull(); if (w.HasValue && h.HasValue) { ucf.Size = new Size(w.Value, h.Value); } else { ap.ReportError("Size needs x,y,w,h in Popout"); } } else { ap.ReportError("Unknown option " + nextcmd + " after popout name in Popout"); } } else { // pop out not found.. PanelInformation.PanelIDs?id = PanelInformation.GetPanelIDByWindowsRefName(cmdname); if (id != null) { if (nextcmd.Equals("off")) // if off, do nothing { } else if (nextcmd.Equals("toggle") || nextcmd.Equals("on")) { poc.PopOut(id.Value); } else { ap.ReportError("Cannot use command " + nextcmd + " after generic popout name in Popout"); } } else { ap.ReportError("Cannot find generic popout name " + cmdname + " in Popout"); } } } } else { ap.ReportError(res); } return(true); }
public override bool ExecuteAction(ActionProgramRun ap) { string res; if (ap.functions.ExpandString(UserData, out res) != BaseUtils.Functions.ExpandResult.Failed) { StringParser sp = new StringParser(res); string prefix = "S_"; string cmdname = sp.NextQuotedWord(); if (cmdname != null && cmdname.Equals("PREFIX", StringComparison.InvariantCultureIgnoreCase)) { prefix = sp.NextWord(); if (prefix == null) { ap.ReportError("Missing name after Prefix in Scan"); return(true); } cmdname = sp.NextQuotedWord(); } bool edsm = false; if (cmdname != null && cmdname.Equals("EDSM", StringComparison.InvariantCultureIgnoreCase)) { edsm = true; cmdname = sp.NextQuotedWord(); } if (cmdname != null) { StarScan scan = (ap.actioncontroller as ActionController).HistoryList.starscan; ISystem sc = SystemClassDB.GetSystem(cmdname); if (sc == null) { sc = new SystemClass(cmdname); sc.EDSMID = 0; } StarScan.SystemNode sn = scan.FindSystem(sc, edsm); System.Globalization.CultureInfo ct = System.Globalization.CultureInfo.InvariantCulture; if (sn != null) { int starno = 1; ap[prefix + "Stars"] = sn.starnodes.Count.ToString(ct); foreach (KeyValuePair <string, StarScan.ScanNode> scannode in sn.starnodes) { DumpInfo(ap, scannode, prefix + "Star_" + starno.ToString(ct), "_Planets"); int pcount = 1; if (scannode.Value.children != null) { foreach (KeyValuePair <string, StarScan.ScanNode> planetnodes in scannode.Value.children) { DumpInfo(ap, planetnodes, prefix + "Planet_" + starno.ToString(ct) + "_" + pcount.ToString(ct), "_Moons"); if (planetnodes.Value.children != null) { int mcount = 1; foreach (KeyValuePair <string, StarScan.ScanNode> moonnodes in planetnodes.Value.children) { DumpInfo(ap, moonnodes, prefix + "Moon_" + starno.ToString(ct) + "_" + pcount.ToString(ct) + "_" + mcount.ToString(ct), "_Submoons"); if (moonnodes.Value.children != null) { int smcount = 1; foreach (KeyValuePair <string, StarScan.ScanNode> submoonnodes in moonnodes.Value.children) { DumpInfo(ap, submoonnodes, prefix + "SubMoon_" + starno.ToString(ct) + "_" + pcount.ToString(ct) + "_" + mcount.ToString(ct) + "_" + smcount.ToString(ct), null); smcount++; } } mcount++; } } pcount++; } } starno++; } } else { ap[prefix + "Stars"] = "0"; } } else { ap.ReportError("Missing starname in Scan"); } } else { ap.ReportError(res); } return(true); }
private void DoExecute() // MAIN thread only.. { executing = true; System.Diagnostics.Stopwatch timetaken = new System.Diagnostics.Stopwatch(); timetaken.Start(); while (true) { if (progcurrent != null) { if (progcurrent.GetErrorList != null) // any errors pending, handle { actioncontroller.LogLine("Error at " + progcurrent.Location + ": Line " + progcurrent.GetLastStep().LineNumber + ": " + progcurrent.GetLastStep().Name + Environment.NewLine + progcurrent.GetErrorList); TerminateCurrent(); } else if (progcurrent.IsProgramFinished) // if current program ran out, cancel it { // this catches a LOOP without a statement at the end.. or a DO without a WHILE at the end.. if (progcurrent.ExecLevel > 0 && progcurrent.LevelUp(progcurrent.ExecLevel, null)) // see if we have any pending LOOP (or a DO without a while) and continue.. { continue; // errors or movement causes it to go back.. errors will be picked up above } TerminateCurrent(); } } while (progcurrent == null && progqueue.Count > 0) // if no program,but something in queue { progcurrent = progqueue[0]; progqueue.RemoveAt(0); if (progcurrent.variables != null) // if not null, its because its just been restarted after a call.. reset globals { progcurrent.Add(actioncontroller.Globals); // in case they have been updated... } else { progcurrent.PrepareToRun(new ConditionVariables(progcurrent.inputvariables, actioncontroller.Globals), new ConditionFileHandles(), new Dictionary <string, Forms.ConfigurableForm>(), true); // with new file handles and close at end.. } if (progcurrent.IsProgramFinished) // reject empty programs.. { TerminateCurrent(); continue; // and try again } } if (progcurrent == null) // Still nothing, game over { break; } Action ac = progcurrent.GetNextStep(); // get the step. move PC on. if (ac.LevelUp > 0 && progcurrent.LevelUp(ac.LevelUp, ac)) // level up.. { System.Diagnostics.Debug.WriteLine((Environment.TickCount % 10000).ToString("00000") + " Abort Lv" + progcurrent.ExecLevel + " e " + (progcurrent.IsExecuteOn ? "1" : "0") + " up " + ac.LevelUp + ": " + progcurrent.StepNumber + " " + ac.Name + " " + ac.DisplayedUserData); continue; } System.Diagnostics.Debug.WriteLine((Environment.TickCount % 10000).ToString("00000") + " Exec Lv" + progcurrent.ExecLevel + " e " + (progcurrent.IsExecuteOn ? "1" : "0") + " up " + ac.LevelUp + ": " + progcurrent.StepNumber + " " + ac.Name + " " + ac.DisplayedUserData); if (progcurrent.DoExecute(ac)) // execute is on.. { if (ac.Type == Action.ActionType.Call) // Call needs to pass info back up thru to us, need a different call { ActionCall acall = ac as ActionCall; string prog; ConditionVariables paravars; if (acall.ExecuteCallAction(progcurrent, out prog, out paravars)) // if execute ok { //System.Diagnostics.Debug.WriteLine("Call " + prog + " with " + paravars.ToString()); Tuple <ActionFile, ActionProgram> ap = actionfilelist.FindProgram(prog, progcurrent.actionfile); // find program using this name, prefer this action file first if (ap != null) { Run(true, ap.Item1, ap.Item2, paravars, progcurrent.functions.handles, progcurrent.dialogs, false); // run now with these para vars } else { progcurrent.ReportError("Call cannot find " + prog); } } } else if (ac.Type == Action.ActionType.Return) // Return needs to pass info back up thru to us, need a different call { ActionReturn ar = ac as ActionReturn; string retstr; if (ar.ExecuteActionReturn(progcurrent, out retstr)) { TerminateCurrent(); if (progqueue.Count > 0) // pass return value if program is there.. { progqueue[0]["ReturnValue"] = retstr; } continue; // back to top, next action from returned function. } } else if (!ac.ExecuteAction(progcurrent)) // if execute says, stop, i'm waiting for something { return; // exit, with executing set true. ResumeAfterPause will restart it. } } if (async && timetaken.ElapsedMilliseconds > 100) // no more than 100ms per go to stop the main thread being blocked { System.Diagnostics.Debug.WriteLine((Environment.TickCount % 10000).ToString("00000") + " *** SUSPEND"); restarttick.Start(); break; } } executing = false; }
public override bool ExecuteAction(ActionProgramRun ap) { string res; if (ap.Functions.ExpandString(UserData, out res) != BaseUtils.Functions.ExpandResult.Failed) { StringParser sp = new StringParser(res); string prefix = "ST_"; string cmdname = sp.NextQuotedWord(); if (cmdname != null && cmdname.Equals("PREFIX", StringComparison.InvariantCultureIgnoreCase)) { prefix = sp.NextWord(); if (prefix == null) { ap.ReportError("Missing name after Prefix in Star"); return(true); } cmdname = sp.NextQuotedWord(); } if (cmdname != null) { ISystem sc = SystemCache.FindSystem(cmdname); ap[prefix + "Found"] = sc != null ? "1" : "0"; if (sc != null) { BaseUtils.Variables vars = new BaseUtils.Variables(); ActionVars.SystemVars(vars, sc, prefix); ap.Add(vars); ActionVars.SystemVarsFurtherInfo(ap, (ap.ActionController as ActionController).HistoryList, sc, prefix); string options = sp.NextWord(); if (options != null) { if (options.Equals("NEAREST", StringComparison.InvariantCultureIgnoreCase)) { double mindist = sp.NextDouble(0.01); double maxdist = sp.NextDouble(20.0); int number = sp.NextInt(50); bool cube = (sp.NextWord() ?? "Spherical").Equals("Cube", StringComparison.InvariantCultureIgnoreCase); // spherical default for all but cube StarDistanceComputer computer = new StarDistanceComputer(); apr = ap; ret_prefix = prefix; computer.CalculateClosestSystems(sc, (sys, list) => (apr.ActionController as ActionController).DiscoveryForm.BeginInvoke(new Action(() => NewStarListComputed(sys, list))), (mindist > 0) ? (number - 1) : number, // adds an implicit 1 on for centre star mindist, maxdist, !cube); return(false); // go to sleep until value computed } } } } else { ap.ReportError("Missing starname in Star"); } } else { ap.ReportError(res); } return(true); }
public override bool ExecuteAction(ActionProgramRun ap) { string res; if (ap.Functions.ExpandString(UserData, out res) != BaseUtils.Functions.ExpandResult.Failed) { StringParser sp = new StringParser(res); string cmdname = sp.NextWord(); if (cmdname == null) { ap.ReportError("Missing panel name in Historytab"); } else { ExtendedControls.TabStrip ts = (ap.ActionController as ActionController).DiscoveryForm.PrimarySplitter.GetTabStrip(cmdname); // case insensitive if (ts != null) { string nextcmd = sp.NextWordLCInvariant(" "); if (nextcmd == null) { ap.ReportError("Missing command after panel name in Historytab"); } else if (nextcmd.Equals("toggle")) { ts.Toggle(); } else { PopOutControl poc = (ap.ActionController as ActionController).DiscoveryForm.PopOuts; PanelInformation.PanelIDs?id = PanelInformation.GetPanelIDByWindowsRefName(nextcmd); if (id != null) { PanelInformation.PanelIDs[] list = ts.TagList.Cast <PanelInformation.PanelIDs>().ToArray(); int index = Array.IndexOf(list, id.Value); if (!ts.ChangePanel(index)) { ap.ReportError("Panel " + nextcmd + " cannot be used in Historytab"); } } else { ap.ReportError("Cannot find generic panel type name " + nextcmd + " in Historytab"); } } } else { ap.ReportError("Unknown panel name or panels re-ordered " + cmdname + " in Historytab"); } } } else { ap.ReportError(res); } return(true); }
public override bool ExecuteAction(ActionProgramRun ap) { List <string> preexpand = FromString(UserData); if (preexpand != null) { List <string> exp; if (ap.functions.ExpandStrings(preexpand, out exp) != ConditionFunctions.ExpandResult.Failed && preexpand.Count >= 2) { System.Diagnostics.Debug.WriteLine("dll call " + string.Join(",", preexpand)); if (exp[1].Equals("JournalEntry", StringComparison.InvariantCultureIgnoreCase)) { long?jid = null; if (exp.Count == 3) { jid = exp[2].InvariantParseLongNull(); } if (jid.HasValue) { HistoryEntry h = (ap.actioncontroller as ActionController).DiscoveryForm.history.GetByJID(jid.Value); if (h != null) { Tuple <bool, bool> ret = (ap.actioncontroller as ActionController).DiscoveryForm.DLLManager.ActionJournalEntry(exp[0], DLL.EDDDLLCallerHE.CreateFromHistoryEntry(h)); if (ret.Item1 == false) { ap.ReportError("DLLCall cannot find DLL '" + exp[0] + "'"); } else if (ret.Item2 == false) { ap.ReportError("DLL '" + exp[0] + "' does not implement ActionJournalEntry"); } } else { ap.ReportError("DLLCall JournalEntry history does not have that JID"); } } else { ap.ReportError("DLLCall JournalEntry missing Journal ID"); } } else { string[] paras = exp.GetRange(2, exp.Count - 2).ToArray(); List <Tuple <bool, string, string> > res = (ap.actioncontroller as ActionController).DiscoveryForm.DLLManager.ActionCommand(exp[0], exp[1], paras); ap["DLLCalled"] = res.Count.ToStringInvariant(); if (res.Count == 0) // if no calls { ap.ReportError("No DLLs found"); } else { for (int i = 0; i < res.Count; i++) { ap["DLL[" + (i + 1).ToStringInvariant() + "]"] = res[i].Item2; if (res[i].Item1 == false) // error, create an error { ap.ReportError("DLL " + res[i].Item2 + ": " + res[i].Item3); } else { ap["DLLResult[" + (i + 1).ToStringInvariant() + "]"] = res[i].Item3; } } } } } else { ap.ReportError(exp[0]); } } else { ap.ReportError("DLLCall command line not in correct format"); } return(true); }
public override bool ExecuteAction(ActionProgramRun ap) { string res; if (ap.functions.ExpandString(UserData, out res) != ConditionFunctions.ExpandResult.Failed) { StringParser p = new StringParser(res); string cmd; while ((cmd = p.NextWord(" ", true)) != null) { if (cmd.Equals("dumpvars")) { string rest = p.NextQuotedWord(); if (rest != null && rest.Length > 0) { ConditionVariables filtered = ap.variables.FilterVars(rest); foreach (string key in filtered.NameEnumuerable) { ap.actioncontroller.LogLine(key + "=" + filtered[key]); } } else { ap.ReportError("Missing variable wildcard after Pragma DumpVars"); return(true); } } else if (cmd.Equals("log")) { string rest = p.NextQuotedWord(replaceescape: true); if (rest != null) { ap.actioncontroller.LogLine(rest); } else { ap.ReportError("Missing string after Pragma Log"); return(true); } } else if (cmd.Equals("debug")) { string rest = p.NextQuotedWord(replaceescape: true); if (rest != null) { #if DEBUG ap.actioncontroller.LogLine(rest); #endif } else { ap.ReportError("Missing string after Debug"); } return(true); } else if (cmd.Equals("ignoreerrors")) { ap.SetContinueOnErrors(true); } else if (cmd.Equals("allowerrors")) { ap.SetContinueOnErrors(true); } } } else { ap.ReportError(res); } return(true); }
public override bool ExecuteAction(ActionProgramRun ap) { string res; if (ap.functions.ExpandString(UserData, out res) != Conditions.ConditionFunctions.ExpandResult.Failed) { StringParser sp = new StringParser(res); string prefix = "SH_"; string cmdname = sp.NextQuotedWord(); if (cmdname != null && cmdname.Equals("PREFIX", StringComparison.InvariantCultureIgnoreCase)) { prefix = sp.NextWord(); if (prefix == null) { ap.ReportError("Missing name after Prefix in Ship"); return(true); } cmdname = sp.NextQuotedWord(); } if (cmdname != null) { EliteDangerousCore.ShipInformationList lst = (ap.actioncontroller as ActionController).HistoryList.shipinformationlist; ConditionVariables values = new ConditionVariables(); if (cmdname.Length > 0) { EliteDangerousCore.ShipInformation si = lst.GetShipByFullInfoMatch(cmdname); if (si != null) { ActionVars.ShipBasicInformation(values, si, prefix); ActionVars.ShipModuleInformation(ap, si, prefix); } values[prefix + "Found"] = (si != null) ? "1" : "0"; } values[prefix + "Ships"] = lst.Ships.Count.ToString(System.Globalization.CultureInfo.InvariantCulture); int ind = 0; foreach (EliteDangerousCore.ShipInformation si in lst.Ships.Values) { string p = prefix + "Ships[" + ind.ToString() + "]_"; ActionVars.ShipBasicInformation(values, si, p); ind++; } ap.Add(values); } else { ap.ReportError("Missing ship name in Ship"); } } else { ap.ReportError(res); } return(true); }
public override bool ExecuteAction(ActionProgramRun ap) { string res; if (ap.functions.ExpandString(UserData, out res) != Conditions.ConditionFunctions.ExpandResult.Failed) { StringParser sp = new StringParser(res); string cmdname = sp.NextWord(" ", lowercase: true); if (cmdname == null) { ap.ReportError("Missing command in Perform"); } else if (cmdname.Equals("3dmap")) { (ap.actioncontroller as ActionController).DiscoveryForm.Open3DMap(null); } else if (cmdname.Equals("2dmap")) { (ap.actioncontroller as ActionController).DiscoveryForm.Open2DMap(); } else if (cmdname.Equals("edsm")) { ActionController ac = (ap.actioncontroller as ActionController); EliteDangerousCore.EDSM.EDSMClass edsm = new EliteDangerousCore.EDSM.EDSMClass(); if (edsm.ValidCredentials) { EliteDangerousCore.EDSM.EDSMJournalSync.SendEDSMEvents(ap.actioncontroller.LogLine, ac.DiscoveryForm.history); } else { ap.ReportError("No valid EDSM Credentials"); } } else if (cmdname.Equals("refresh")) { (ap.actioncontroller as ActionController).DiscoveryForm.RefreshHistoryAsync(); } else if (cmdname.Equals("url")) { string url = sp.LineLeft; if (url.StartsWith("http:", StringComparison.InvariantCultureIgnoreCase) || url.StartsWith("https:", StringComparison.InvariantCultureIgnoreCase)) // security.. { System.Diagnostics.Process.Start(url); } else { ap.ReportError("Perform url must start with http"); } } else if (cmdname.Equals("configurevoice")) { (ap.actioncontroller as ActionController).ConfigureVoice(sp.NextQuotedWord() ?? "Configure Voice Synthesis"); } else if (cmdname.Equals("manageaddons")) { (ap.actioncontroller as ActionController).ManageAddOns(); } else if (cmdname.Equals("editaddons")) { (ap.actioncontroller as ActionController).EditAddOns(); } else if (cmdname.Equals("editlastpack")) { (ap.actioncontroller as ActionController).EditLastPack(); } else if (cmdname.Equals("editpack")) { string pack = sp.NextQuotedWord(); if (pack != null) { if (!(ap.actioncontroller as ActionController).EditPack(pack)) { ap.ReportError("Pack " + pack + " not found"); } } else { ap.ReportError("EditPack requires a pack name"); } } else if (cmdname.Equals("editspeechtext")) { (ap.actioncontroller as ActionController).EditSpeechText(); } else if (cmdname.Equals("configurewave")) { (ap.actioncontroller as ActionController).ConfigureWave(sp.NextQuotedWord() ?? "Configure Wave Output"); } else if (cmdname.Equals("enableeliteinput")) { (ap.actioncontroller as ActionController).EliteInput(true, true); } else if (cmdname.Equals("enableeliteinputnoaxis")) { (ap.actioncontroller as ActionController).EliteInput(true, false); } else if (cmdname.Equals("disableeliteinput")) { (ap.actioncontroller as ActionController).EliteInput(false, false); } else if (cmdname.Equals("enablevoicerecognition")) { string culture = sp.NextQuotedWord(); if (culture != null) { ap["VoiceRecognitionEnabled"] = ((ap.actioncontroller as ActionController).VoiceReconOn(culture)).ToStringInvariant(); } else { ap.ReportError("EnableVoiceRecognition requires a culture"); } } else if (cmdname.Equals("disablevoicerecognition")) { (ap.actioncontroller as ActionController).VoiceReconOff(); } else if (cmdname.Equals("beginvoicerecognition")) { (ap.actioncontroller as ActionController).VoiceLoadEvents(); } else if (cmdname.Equals("voicerecognitionconfidencelevel")) { float?conf = sp.NextWord().InvariantParseFloatNull(); if (conf != null) { (ap.actioncontroller as ActionController).VoiceReconConfidence(conf.Value); } else { ap.ReportError("VoiceRecognitionConfidencelLevel requires a confidence value"); } } else if (cmdname.Equals("voicerecognitionparameters")) { int?babble = sp.NextWordComma().InvariantParseIntNull(); // babble at end int?initialsilence = sp.NextWordComma().InvariantParseIntNull(); // silence at end int?endsilence = sp.NextWordComma().InvariantParseIntNull(); // unambigious timeout int?endsilenceambigious = sp.NextWordComma().InvariantParseIntNull(); // ambiguous timeout if (babble != null && initialsilence != null && endsilence != null && endsilenceambigious != null) { (ap.actioncontroller as ActionController).VoiceReconParameters(babble.Value, initialsilence.Value, endsilence.Value, endsilenceambigious.Value); } else { ap.ReportError("VoiceRecognitionParameters requires four values"); } } else if (cmdname.Equals("voicerecognitionphrases")) { ap["Phrases"] = (ap.actioncontroller as ActionController).VoicePhrases(Environment.NewLine); } else if (cmdname.Equals("listeliteinput")) { ap["EliteInput"] = (ap.actioncontroller as ActionController).EliteInputList(); ap["EliteInputCheck"] = (ap.actioncontroller as ActionController).EliteInputCheck(); } else if (cmdname.Equals("voicenames")) { ap["VoiceNames"] = (ap.actioncontroller as ActionController).SpeechSynthesizer.GetVoiceNames().QuoteStrings(); } else if (cmdname.Equals("bindings")) { ap["Bindings"] = (ap.actioncontroller as ActionController).FrontierBindings.ListBindings(); } else if (cmdname.Equals("bindingvalues")) { ap["BindingValues"] = (ap.actioncontroller as ActionController).FrontierBindings.ListValues(); } else { ap.ReportError("Unknown command " + cmdname + " in Performaction"); } } else { ap.ReportError(res); } return(true); }
public override bool ExecuteAction(ActionProgramRun ap) { string res; if (ap.functions.ExpandString(UserData, out res) != Conditions.ConditionFunctions.ExpandResult.Failed) { StringParser sp = new StringParser(res); string cmdname = sp.NextWord(); if (cmdname == null) { ap.ReportError("Missing panel name in Historytab"); } else { ExtendedControls.TabStrip ts = (ap.actioncontroller as ActionController).DiscoveryForm.TravelControl.GetTabStrip(cmdname); // case insensitive if (ts != null) { string nextcmd = sp.NextWord(" ", true); if (nextcmd == null) { ap.ReportError("Missing command after panel name in Historytab"); } else if (nextcmd.Equals("toggle")) { ts.Toggle(); } else { Forms.PopOutControl poc = (ap.actioncontroller as ActionController).DiscoveryForm.PopOuts; int poi = Forms.PanelInformation.GetPanelIndexByName(nextcmd); if (poi >= 0) { if (!ts.ChangeTo(poi)) { ap.ReportError("Panel " + nextcmd + " cannot be used in Historytab"); } } else { ap.ReportError("Cannot find generic panel type name " + nextcmd + " in Historytab"); } } } else { ap.ReportError("Unknown panel name " + cmdname + " in Historytab"); } } } else { ap.ReportError(res); } return(true); }
public override bool ExecuteAction(ActionProgramRun ap) { string res; if (ap.functions.ExpandString(UserData, out res) != Conditions.ConditionFunctions.ExpandResult.Failed) { BaseUtils.StringParser sp = new BaseUtils.StringParser(res); string nextcmd = sp.NextWord(" ", true); if (nextcmd == null) { ap.ReportError("Missing command in ProgramWindow"); } else if (nextcmd.Equals("tab")) { string tabname = sp.NextWord(" ", true); if (!(ap.actioncontroller as ActionController).DiscoveryForm.SelectTabPage(tabname)) { ap.ReportError("Tab page name " + tabname + " not found"); } } else if (nextcmd.Equals("topmost")) { (ap.actioncontroller as ActionController).DiscoveryForm.TopMost = true; } else if (nextcmd.Equals("normalz")) { (ap.actioncontroller as ActionController).DiscoveryForm.TopMost = false; } else if (nextcmd.Equals("showintaskbar")) { (ap.actioncontroller as ActionController).DiscoveryForm.ShowInTaskbar = true; } else if (nextcmd.Equals("notshowintaskbar")) { (ap.actioncontroller as ActionController).DiscoveryForm.ShowInTaskbar = false; } else if (nextcmd.Equals("minimize")) { (ap.actioncontroller as ActionController).DiscoveryForm.WindowState = FormWindowState.Minimized; } else if (nextcmd.Equals("normal")) { (ap.actioncontroller as ActionController).DiscoveryForm.WindowState = FormWindowState.Normal; } else if (nextcmd.Equals("maximize")) { (ap.actioncontroller as ActionController).DiscoveryForm.WindowState = FormWindowState.Maximized; } else if (nextcmd.Equals("location")) { int?x = sp.NextWordComma().InvariantParseIntNull(); int?y = sp.NextWordComma().InvariantParseIntNull(); int?w = sp.NextWordComma().InvariantParseIntNull(); int?h = sp.NextWord().InvariantParseIntNull(); if (x.HasValue && y.HasValue && w.HasValue && h.HasValue) { (ap.actioncontroller as ActionController).DiscoveryForm.Location = new Point(x.Value, y.Value); (ap.actioncontroller as ActionController).DiscoveryForm.Size = new Size(w.Value, h.Value); } else { ap.ReportError("Location needs x,y,w,h in Popout"); } } else if (nextcmd.Equals("position")) { int?x = sp.NextWordComma().InvariantParseIntNull(); int?y = sp.NextWord().InvariantParseIntNull(); if (x.HasValue && y.HasValue) { (ap.actioncontroller as ActionController).DiscoveryForm.Location = new Point(x.Value, y.Value); } else { ap.ReportError("Position needs x,y in Popout"); } } else if (nextcmd.Equals("size")) { int?w = sp.NextWordComma().InvariantParseIntNull(); int?h = sp.NextWord().InvariantParseIntNull(); if (w.HasValue && h.HasValue) { (ap.actioncontroller as ActionController).DiscoveryForm.Size = new Size(w.Value, h.Value); } else { ap.ReportError("Size needs x,y,w,h in Popout"); } } else { ap.ReportError("Unknown command " + nextcmd + " in Popout"); } } else { ap.ReportError(res); } return(true); }
public override bool ExecuteAction(ActionProgramRun ap) { string res; if (ap.Functions.ExpandString(UserData, out res) != BaseUtils.Functions.ExpandResult.Failed) { StringParser sp = new StringParser(res); string prefix = "CL_"; string cmdname = sp.NextWord(); if (cmdname != null && cmdname.Equals("PREFIX", StringComparison.InvariantCultureIgnoreCase)) { prefix = sp.NextWord(); if (prefix == null) { ap.ReportError("Missing name after Prefix"); return(true); } cmdname = sp.NextWord(); } int cmdrid = EDCommander.CurrentCmdrID; if (cmdname != null && cmdname.Equals("CMDR", StringComparison.InvariantCultureIgnoreCase)) { string name = sp.NextQuotedWord() ?? "-----!"; EDCommander cmdr = EDCommander.GetCommander(name); if (cmdr != null) { cmdrid = cmdr.Id; } else { ap.ReportError("Commander not found"); } cmdname = sp.NextWord(); } List <CaptainsLogClass> cllist = GlobalCaptainsLogList.Instance.LogEntriesCmdrTimeOrder(cmdrid); EDDiscoveryForm discoveryform = (ap.ActionController as ActionController).DiscoveryForm; if (cmdname != null) { if (cmdname.Equals("LIST", StringComparison.InvariantCultureIgnoreCase)) { string wildcard = sp.NextQuotedWord() ?? "*"; Func <CaptainsLogClass, string, bool> validate = CheckSystemBody; string field = sp.NextQuotedWord() ?? "--"; if (field.Equals("Body", StringComparison.InvariantCultureIgnoreCase)) { validate = CheckBody; } else if (field.Equals("System", StringComparison.InvariantCultureIgnoreCase)) { validate = CheckSystem; } else if (field.Equals("Tag", StringComparison.InvariantCultureIgnoreCase)) { validate = CheckTags; } else if (field.Equals("Note", StringComparison.InvariantCultureIgnoreCase)) { validate = CheckNote; } else if (field != "--") { ap.ReportError("Unknown field type to list"); return(true); } int count = 1; foreach (CaptainsLogClass cl in cllist) // only current commander ID considered { if (validate(cl, wildcard)) { DumpCL(ap, prefix + count++.ToStringInvariant() + "_", cl); } } ap[prefix + "MatchCount"] = (count - 1).ToStringInvariant(); ap[prefix + "TotalCount"] = cllist.Count.ToStringInvariant(); } else if (cmdname.Equals("ADDHERE", StringComparison.InvariantCultureIgnoreCase)) { string note = sp.NextQuotedWord(); string taglist = sp.NextQuotedWord(); HistoryEntry he = discoveryform.history.GetLast; if (he != null) { // taglist can be null.. note must be set. GlobalCaptainsLogList.Instance.AddOrUpdate(null, cmdrid, he.System.Name, he.WhereAmI, DateTime.UtcNow, note ?? "", taglist); } else { ap.ReportError("History has no locations"); } } else if (cmdname.Equals("ADD", StringComparison.InvariantCultureIgnoreCase)) { string systemname = sp.NextQuotedWord(); string bodyname = sp.NextQuotedWord(); DateTime?dte = sp.NextDateTime(System.Globalization.CultureInfo.GetCultureInfo("en-us"), System.Globalization.DateTimeStyles.AssumeUniversal | System.Globalization.DateTimeStyles.AdjustToUniversal); string note = sp.NextQuotedWord(); string taglist = sp.NextQuotedWord(); if (systemname != null && bodyname != null && dte != null) { GlobalCaptainsLogList.Instance.AddOrUpdate(null, cmdrid, systemname, bodyname, dte.Value, note ?? "", taglist); } else { ap.ReportError("Missing parameters in ADD"); } } else if (cmdname.Equals("TAGLIST", StringComparison.InvariantCultureIgnoreCase)) { string tags = EDDConfig.Instance.CaptainsLogTags; ap[prefix + "Tags"] = tags; } else if (cmdname.Equals("SETTAGLIST", StringComparison.InvariantCultureIgnoreCase)) { string tags = sp.NextQuotedWord(); if (tags != null) { EDDConfig.Instance.CaptainsLogTags = tags; } else { ap.ReportError("Missing tag list"); } } else if (cmdname.Equals("APPENDTAGLIST", StringComparison.InvariantCultureIgnoreCase)) { string tags = sp.NextQuotedWord(); if (tags != null) { EDDConfig.Instance.CaptainsLogTags = EDDConfig.Instance.CaptainsLogTags.AppendPrePad(tags, ";"); } else { ap.ReportError("Missing tag list"); } } else { // ********************** Iterator forms, FROM/LAST/FIRST/TIME [Forward|Backward] long?cid = -1; if (cmdname.Equals("From", StringComparison.InvariantCultureIgnoreCase)) { cid = sp.NextWord().InvariantParseLongNull(); if (cid == null) { ap.ReportError("Non integer CID after FROM"); return(true); } } else if (cmdname.Equals("First", StringComparison.InvariantCultureIgnoreCase)) { if (cllist.Count > 0) //prevent crash if cllist is empty { var mintime = cllist.Min(x => x.TimeUTC); cid = cllist.First(x => x.TimeUTC == mintime).ID; } } else if (cmdname.Equals("Last", StringComparison.InvariantCultureIgnoreCase)) { if (cllist.Count > 0) { var maxtime = cllist.Max(x => x.TimeUTC); cid = cllist.Last(x => x.TimeUTC == maxtime).ID; } } else if (cmdname.Equals("Time", StringComparison.InvariantCultureIgnoreCase)) { DateTime?dte = sp.NextDateTime(System.Globalization.CultureInfo.GetCultureInfo("en-us"), System.Globalization.DateTimeStyles.AssumeUniversal | System.Globalization.DateTimeStyles.AdjustToUniversal); if (dte != null) { if (cllist.Count > 0) { var firstafter = cllist.FirstOrDefault(x => x.TimeUTC >= dte); if (firstafter != null) { cid = firstafter.ID; } } } else { ap.ReportError("Missing US date from Time"); return(true); } } else { ap.ReportError("Unknown command"); return(true); } int indexof = cllist.FindIndex(x => x.ID == cid); // -1 if not found.. string nextcmd = sp.NextWord(); if (nextcmd != null) { if (nextcmd.Equals("FORWARD", StringComparison.InvariantCultureIgnoreCase)) { if (indexof >= 0) // don't ruin -1 if set { indexof++; } nextcmd = sp.NextWord(); } else if (nextcmd.Equals("BACKWARD", StringComparison.InvariantCultureIgnoreCase)) { indexof--; // if -1, its okay to make it -2. nextcmd = sp.NextWord(); } } bool validindex = indexof >= 0 && indexof < cllist.Count; if (nextcmd != null) { if (!validindex) // these must have a valid target.. { ap.ReportError("Entry is not found"); } else { CaptainsLogClass cl = cllist[indexof]; if (nextcmd.Equals("DELETE", StringComparison.InvariantCultureIgnoreCase)) { GlobalCaptainsLogList.Instance.Delete(cl); } else { string text = sp.NextQuotedWord(); if (text != null && sp.IsEOL) { if (nextcmd.Equals("NOTE", StringComparison.InvariantCultureIgnoreCase)) { GlobalCaptainsLogList.Instance.AddOrUpdate(cl, cl.Commander, cl.SystemName, cl.BodyName, cl.TimeUTC, text, cl.Tags, cl.Parameters); } else if (nextcmd.Equals("SYSTEM", StringComparison.InvariantCultureIgnoreCase)) { GlobalCaptainsLogList.Instance.AddOrUpdate(cl, cl.Commander, text, cl.BodyName, cl.TimeUTC, cl.Note, cl.Tags, cl.Parameters); } else if (nextcmd.Equals("BODY", StringComparison.InvariantCultureIgnoreCase)) { GlobalCaptainsLogList.Instance.AddOrUpdate(cl, cl.Commander, cl.SystemName, text, cl.TimeUTC, cl.Note, cl.Tags, cl.Parameters); } else { ap.ReportError("Unknown command " + nextcmd); } } else { ap.ReportError("Missing text or unquoted spaced text after " + nextcmd); } } } return(true); } if (nextcmd != null) { ap.ReportError("Unknown iterator or command " + nextcmd); } else { // straight report if (validindex) { DumpCL(ap, prefix, cllist[indexof]); } else { ap[prefix + "Id"] = "-1"; } } return(true); } } else { ap.ReportError("Missing command"); } } else { ap.ReportError(res); } return(true); }
public override bool ExecuteAction(ActionProgramRun ap) { string res; if (ap.Functions.ExpandString(UserData, out res) != Functions.ExpandResult.Failed) { HistoryList hl = (ap.ActionController as ActionController).HistoryList; StringParser sp = new StringParser(res); string prefix = "EC_"; string cmdname = sp.NextWordLCInvariant(" "); if (cmdname != null && cmdname.Equals("prefix")) { prefix = sp.NextWord(); if (prefix == null) { ap.ReportError("Missing name after Prefix in Event"); return(true); } cmdname = sp.NextWordLCInvariant(" "); } int jidindex = -1; if (cmdname != null && (cmdname.Equals("from") || cmdname.Equals("thpos"))) { long?jid; if (cmdname.Equals("thpos")) { HistoryEntry he = (ap.ActionController as ActionController).DiscoveryForm.PrimaryCursor.GetCurrentHistoryEntry; if (he == null) { ReportEntry(ap, null, 0, prefix); return(true); } jid = he.Journalid; } else { jid = sp.NextWord().InvariantParseLongNull(); if (!jid.HasValue) { ap.ReportError("Non integer JID after FROM in Event"); return(true); } } jidindex = hl.GetIndex(jid.Value); if (jidindex == -1) { ReportEntry(ap, null, 0, prefix); return(true); } cmdname = sp.NextWordLCInvariant(" "); } if (cmdname == null) { if (jidindex != -1) { ReportEntry(ap, hl.EntryOrder(), jidindex, prefix); } else { ap.ReportError("No commands in Event"); } return(true); } bool fwd = cmdname.Equals("forward") || cmdname.Equals("first"); bool back = cmdname.Equals("backward") || cmdname.Equals("last"); if (fwd || back) { List <string> eventnames = sp.NextOptionallyBracketedList(); // single entry, list of events bool not = eventnames.Count == 1 && eventnames[0].Equals("NOT", StringComparison.InvariantCultureIgnoreCase); // if it goes NOT if (not) { eventnames = sp.NextOptionallyBracketedList(); // then get another list } // is it "WHERE" bool whereasfirst = eventnames.Count == 1 && eventnames[0].Equals("WHERE", StringComparison.InvariantCultureIgnoreCase); ConditionLists cond = new ConditionLists(); string nextword; // if WHERE cond, or eventname WHERE cond if (whereasfirst || ((nextword = sp.NextWord()) != null && nextword.Equals("WHERE", StringComparison.InvariantCultureIgnoreCase))) { if (whereasfirst) // clear out event names if it was WHERE cond.. { eventnames.Clear(); } string resc = cond.Read(sp.LineLeft); // rest of it is the condition.. if (resc != null) { ap.ReportError(resc + " in Where of Event"); return(true); } } List <HistoryEntry> hltest; if (jidindex == -1) // if no JID given.. { hltest = hl.EntryOrder(); // the whole list } else if (fwd) { hltest = hl.EntryOrder().GetRange(jidindex + 1, hl.Count - (jidindex + 1)); // cut down list, excluding this entry } else { hltest = hl.EntryOrder().GetRange(0, jidindex); } if (eventnames.Count > 0) // screen out event names { hltest = (from h in hltest where eventnames.Contains(h.journalEntry.EventTypeStr, StringComparer.OrdinalIgnoreCase) == !not select h).ToList(); } if (cond.Count > 0) // if we have filters, apply, filter out, true only stays { hltest = UserControls.FilterHelpers.CheckFilterTrue(hltest, cond, new Variables()); // apply filter.. } if (fwd) { ReportEntry(ap, hltest, 0, prefix); } else { ReportEntry(ap, hltest, hltest.Count - 1, prefix); } return(true); } else { if (jidindex == -1) { ap.ReportError("Valid JID must be given for command " + cmdname + " in Event"); } else { HistoryEntry he = hl.EntryOrder()[jidindex]; ap[prefix + "JID"] = jidindex.ToStringInvariant(); if (cmdname.Equals("action")) { var ctrl = (ap.ActionController as ActionController); int count = ctrl.ActionRunOnEntry(he, Actions.ActionEventEDList.EventCmd(he), now: true); ap[prefix + "Count"] = count.ToString(System.Globalization.CultureInfo.InvariantCulture); } else if (cmdname.Equals("edsm")) { EliteDangerousCore.EDSM.EDSMClass edsm = new EliteDangerousCore.EDSM.EDSMClass(); string url = edsm.GetUrlCheckSystemExists(he.System.Name); ap[prefix + "URL"] = url; if (url.Length > 0) // may pass back empty string if not known, this solves another exception { BaseUtils.BrowserInfo.LaunchBrowser(url); } } else if (cmdname.Equals("ross")) { ap.ReportError("Not implemented"); } else if (cmdname.Equals("eddb")) { string url = Properties.Resources.URLEDDBSystemName + System.Web.HttpUtility.UrlEncode(he.System.Name); BaseUtils.BrowserInfo.LaunchBrowser(url); ap[prefix + "URL"] = url; } else if (cmdname.Equals("info")) { ActionVars.SystemVarsFurtherInfo(ap, hl, he.System, prefix); ActionVars.ShipModuleInformation(ap, he.ShipInformation, prefix); } else if (cmdname.Equals("missions")) { ActionVars.MissionInformation(ap, hl.MissionListAccumulator.GetMissionList(he.MissionList), prefix); } else if (cmdname.Equals("setstartmarker")) { he.journalEntry.SetStartFlag(); } else if (cmdname.Equals("setstopmarker")) { he.journalEntry.SetEndFlag(); } else if (cmdname.Equals("clearstartstopmarker")) { he.journalEntry.ClearStartEndFlag(); } else if (cmdname.Equals("note")) { string note = sp.NextQuotedWord(); if (note != null && sp.IsEOL) { he.SetJournalSystemNoteText(note, true, EDCommander.Current.SyncToEdsm); (ap.ActionController as ActionController).DiscoveryForm.NoteChanged(this, he, true); } else { ap.ReportError("Missing note text or unquoted text in Event NOTE"); } } else { ap.ReportError("Unknown command " + cmdname + " in Event"); } } } } else { ap.ReportError(res); } return(true); }
public override bool ExecuteAction(ActionProgramRun ap) { string res; if (ap.Functions.ExpandString(UserData, out res) != BaseUtils.Functions.ExpandResult.Failed) { StringParser sp = new StringParser(res); string prefix = "T_"; string cmdname = sp.NextWord(); if (cmdname != null && cmdname.Equals("PREFIX", StringComparison.InvariantCultureIgnoreCase)) { prefix = sp.NextWord(); if (prefix == null) { ap.ReportError("Missing name after Prefix in Target"); return(true); } cmdname = sp.NextWord(); } EDDiscoveryForm discoveryform = (ap.ActionController as ActionController).DiscoveryForm; if (cmdname != null) { if (cmdname.Equals("GET", StringComparison.InvariantCultureIgnoreCase)) { bool tset = EliteDangerousCore.DB.TargetClass.IsTargetSet(); ap[prefix + "TargetSet"] = tset.ToStringIntValue(); if (tset) { EliteDangerousCore.DB.TargetClass.GetTargetPosition(out string name, out double x, out double y, out double z); ap[prefix + "TargetType"] = EliteDangerousCore.DB.TargetClass.GetTargetType().ToString(); ap[prefix + "TargetPositionFullName"] = name; ap[prefix + "TargetPositionName"] = EliteDangerousCore.DB.TargetClass.GetNameWithoutPrefix(name); if (!double.IsNaN(x) && !double.IsNaN(y) && !double.IsNaN(z)) { ap[prefix + "TargetPositionX"] = x.ToStringInvariant("0.##"); ap[prefix + "TargetPositionY"] = y.ToStringInvariant("0.##"); ap[prefix + "TargetPositionZ"] = z.ToStringInvariant("0.##"); } } } else if (cmdname.Equals("CLEAR", StringComparison.InvariantCultureIgnoreCase)) { bool tset = EliteDangerousCore.DB.TargetClass.IsTargetSet(); ap[prefix + "TargetClear"] = tset.ToStringIntValue(); if (tset) { TargetClass.ClearTarget(); discoveryform.NewTargetSet(this); } } else { string name = sp.NextQuotedWord(); if (name != null) { if (cmdname.Equals("BOOKMARK", StringComparison.InvariantCultureIgnoreCase)) { BookmarkClass bk = GlobalBookMarkList.Instance.FindBookmarkOnSystem(name); // has it been bookmarked? if (bk != null) { TargetClass.SetTargetBookmark(name, bk.id, bk.x, bk.y, bk.z); discoveryform.NewTargetSet(this); } else { ap.ReportError("Bookmark '" + name + "' not found"); } } else if (cmdname.Equals("GMO", StringComparison.InvariantCultureIgnoreCase)) { EliteDangerousCore.EDSM.GalacticMapObject gmo = discoveryform.galacticMapping.Find(name, true); if (gmo != null) { TargetClass.SetTargetGMO("G:" + gmo.Name, gmo.ID, gmo.Points[0].X, gmo.Points[0].Y, gmo.Points[0].Z); discoveryform.NewTargetSet(this); } else { ap.ReportError("GMO '" + name + "' not found"); } } else if (cmdname.Equals("NOTE", StringComparison.InvariantCultureIgnoreCase)) { SystemNoteClass nc = SystemNoteClass.GetNoteOnSystem(name); // has it got a note? ISystem sc = SystemCache.FindSystem(name, discoveryform.galacticMapping, true); if (sc != null && sc.HasCoordinate && nc != null) { TargetClass.SetTargetNotedSystem(name, nc.id, sc.X, sc.Y, sc.Z); discoveryform.NewTargetSet(this); } else { ap.ReportError("No Note found on entries in system '" + name + "'"); } } else { ap.ReportError("Unknown TARGET command"); } } else { ap.ReportError("Missing name in command"); } } } else { ap.ReportError("Missing TARGET command"); } } else { ap.ReportError(res); } return(true); }
public override bool ExecuteAction(ActionProgramRun ap) { string res; if (ap.Functions.ExpandString(UserData, out res) != BaseUtils.Functions.ExpandResult.Failed) { StringParser sp = new StringParser(res); string prefix = "G_"; string cmdname = sp.NextWord(); if (cmdname != null && cmdname.Equals("PREFIX", StringComparison.InvariantCultureIgnoreCase)) { prefix = sp.NextWord(); if (prefix == null) { ap.ReportError("Missing name after Prefix in GMO"); return(true); } cmdname = sp.NextWord(); } if (cmdname != null) { EDDiscoveryForm discoveryform = (ap.ActionController as ActionController).DiscoveryForm; if (cmdname.Equals("LIST", StringComparison.InvariantCultureIgnoreCase)) { string wildcard = sp.NextQuotedWord() ?? "*"; int count = 1; foreach (var g in discoveryform.galacticMapping.galacticMapObjects) { if (g.name.WildCardMatch(wildcard, true)) { string nprefix = prefix + (count++).ToStringInvariant() + "_"; DumpGMO(ap, nprefix, g); } } ap[prefix + "MatchCount"] = (count - 1).ToStringInvariant(); ap[prefix + "TotalCount"] = discoveryform.galacticMapping.galacticMapObjects.Count.ToStringInvariant(); } else { string name = sp.NextQuotedWord(); if (name != null) { if (cmdname.Equals("EXISTS", StringComparison.InvariantCultureIgnoreCase)) { EliteDangerousCore.EDSM.GalacticMapObject gmo = discoveryform.galacticMapping.Find(name, false); ap[prefix + "Exists"] = (gmo != null).ToStringIntValue(); if (gmo != null) { DumpGMO(ap, prefix, gmo); } } else { ap.ReportError("Unknown GMO command"); } } else { ap.ReportError("Missing name in command"); } } } else { ap.ReportError("Missing GMO command"); } } else { ap.ReportError(res); } return(true); }
public override bool ExecuteAction(ActionProgramRun ap) { string res; if (ap.functions.ExpandString(UserData, out res) != ConditionFunctions.ExpandResult.Failed) { HistoryList hl = (ap.actioncontroller as ActionController).HistoryList; StringParser sp = new StringParser(res); string prefix = "EC_"; string cmdname = sp.NextWord(" ", true); if (cmdname != null && cmdname.Equals("prefix")) { prefix = sp.NextWord(); if (prefix == null) { ap.ReportError("Missing name after Prefix in Event"); return(true); } cmdname = sp.NextWord(" ", true); } int jidindex = -1; if (cmdname != null && (cmdname.Equals("from") || cmdname.Equals("thpos"))) { long?jid; if (cmdname.Equals("thpos")) { HistoryEntry he = (ap.actioncontroller as ActionController).DiscoveryForm.TravelControl.GetTravelHistoryCurrent; if (he == null) { ReportEntry(ap, null, 0, prefix); return(true); } jid = he.Journalid; } else { jid = sp.NextWord().InvariantParseLongNull(); if (!jid.HasValue) { ap.ReportError("Non integer JID after FROM in Event"); return(true); } } jidindex = hl.GetIndex(jid.Value); if (jidindex == -1) { ReportEntry(ap, null, 0, prefix); return(true); } cmdname = sp.NextWord(" ", true); } if (cmdname == null) { if (jidindex != -1) { ReportEntry(ap, hl.EntryOrder, jidindex, prefix); } else { ap.ReportError("No commands in Event"); } return(true); } bool fwd = cmdname.Equals("forward") || cmdname.Equals("first"); bool back = cmdname.Equals("backward") || cmdname.Equals("last"); if (fwd || back) { List <string> eventnames = sp.NextOptionallyBracketedList(); bool whereasfirst = eventnames.Count == 1 && eventnames[0].Equals("WHERE", StringComparison.InvariantCultureIgnoreCase); ConditionLists cond = new ConditionLists(); string nextword; if (whereasfirst || ((nextword = sp.NextWord()) != null && nextword.Equals("WHERE", StringComparison.InvariantCultureIgnoreCase))) { if (whereasfirst) // clear out event names if it was WHERE cond.. { eventnames.Clear(); } string resc = cond.Read(sp.LineLeft); // rest of it is the condition.. if (resc != null) { ap.ReportError(resc + " in Where of Event"); return(true); } } List <HistoryEntry> hltest; if (jidindex == -1) // if no JID given.. { hltest = hl.EntryOrder; // the whole list } else if (fwd) { hltest = hl.EntryOrder.GetRange(jidindex + 1, hl.Count - (jidindex + 1)); // cut down list, excluding this entry } else { hltest = hl.EntryOrder.GetRange(0, jidindex); } if (eventnames.Count > 0) { hltest = (from h in hltest where eventnames.Contains(h.journalEntry.EventTypeStr, StringComparer.OrdinalIgnoreCase) select h).ToList(); } if (cond.Count > 0) // if we have filters, apply, filter out, true only stays { hltest = HistoryList.CheckFilterTrue(hltest, cond, new ConditionVariables()); // apply filter.. } if (fwd) { ReportEntry(ap, hltest, 0, prefix); } else { ReportEntry(ap, hltest, hltest.Count - 1, prefix); } return(true); } else { if (jidindex == -1) { ap.ReportError("Valid JID must be given for command " + cmdname + " in Event"); } else if (cmdname.Equals("action")) { int count = (ap.actioncontroller as ActionController).ActionRunOnEntry(hl.EntryOrder[jidindex], "ActionProgram", now: true); ap[prefix + "Count"] = count.ToString(System.Globalization.CultureInfo.InvariantCulture); } else if (cmdname.Equals("edsm")) { HistoryEntry he = hl.EntryOrder[jidindex]; (ap.actioncontroller as ActionController).HistoryList.FillEDSM(he, reload: true); long?id_edsm = he.System.id_edsm; if (id_edsm <= 0) { id_edsm = null; } EDDiscovery.EDSM.EDSMClass edsm = new EDDiscovery.EDSM.EDSMClass(); string url = edsm.GetUrlToEDSMSystem(he.System.name, id_edsm); ap[prefix + "URL"] = url; if (url.Length > 0) // may pass back empty string if not known, this solves another exception { System.Diagnostics.Process.Start(url); } } else if (cmdname.Equals("ross")) { HistoryEntry he = hl.EntryOrder[jidindex]; (ap.actioncontroller as ActionController).HistoryList.FillEDSM(he, reload: true); string url = ""; if (he.System.id_eddb > 0) { url = "http://ross.eddb.io/system/update/" + he.System.id_eddb.ToString(); System.Diagnostics.Process.Start(url); } ap[prefix + "URL"] = url; } else if (cmdname.Equals("info")) { HistoryEntry he = hl.EntryOrder[jidindex]; ActionVars.HistoryEventFurtherInfo(ap, hl, he, prefix); ActionVars.SystemVarsFurtherInfo(ap, hl, he.System, prefix); ActionVars.ShipModuleInformation(ap, he.ShipInformation, prefix); } else if (cmdname.Equals("missions")) { HistoryEntry he = hl.EntryOrder[jidindex]; ActionVars.MissionInformation(ap, he.MissionList, prefix); } else { ap.ReportError("Unknown command " + cmdname + " in Event"); } } } else { ap.ReportError(res); } return(true); }
public override bool ExecuteAction(ActionProgramRun ap) { string res; if (ap.Functions.ExpandString(UserData, out res) != BaseUtils.Functions.ExpandResult.Failed) { StringParser sp = new StringParser(res); string prefix = "EB_"; string cmdname = sp.NextQuotedWord(); if (cmdname != null && cmdname.Equals("PREFIX", StringComparison.InvariantCultureIgnoreCase)) { prefix = sp.NextWord(); if (prefix == null) { ap.ReportError("Missing name after Prefix in EliteBindings"); return(true); } cmdname = sp.NextQuotedWord(); } BindingsFile bf = (ap.ActionController as ActionController).FrontierBindings; int matchno = 1; string list = ""; while (cmdname != null) { bool partial = false; int i = cmdname.IndexOf("*"); if (i >= 0) { cmdname = cmdname.Substring(0, i); partial = true; } List <BindingsFile.Assignment> matches = bf.Find(cmdname, partial); if (matches.Count > 0) { foreach (BindingsFile.Assignment a in matches) { ap[prefix + "Binding" + matchno.ToStringInvariant()] = a.ToString(); list += a.ToString() + Environment.NewLine; matchno++; } } Dictionary <string, string> values = bf.BindingValue(cmdname, partial); foreach (string k in values.Keys) { ap[prefix + k] = values[k]; list += k + "=" + values[k] + Environment.NewLine; } cmdname = sp.NextQuotedWord(); } ap[prefix + "Text"] = list; } else { ap.ReportError(res); } return(true); }
public override bool ExecuteAction(ActionProgramRun ap) { List <string> ctrl = FromString(UserData); if (ctrl != null) { List <string> exp; if (ap.functions.ExpandStrings(ctrl, out exp) != Conditions.ConditionFunctions.ExpandResult.Failed) { int time; if (exp[1].InvariantParse(out time)) { HistoryEntry he = null; long jid; if (exp.Count >= 3) { if (exp[2].InvariantParse(out jid)) { he = (ap.actioncontroller as ActionController).HistoryList.GetByJID(jid); if (he == null) { ap.ReportError("Timer could not find event " + jid); return(true); } } else { ap.ReportError("Timer JID is not an integer "); return(true); } } if (exp[0].StartsWith("+")) // + name means replace if running { exp[0] = exp[0].Substring(1); Timer told = timers.Find(x => ((TimerInfo)x.Tag).name.Equals(exp[0])); //System.Diagnostics.Debug.WriteLine("Timers " + timers.Count); if (told != null) { System.Diagnostics.Debug.WriteLine("Replace timer " + exp[0]); told.Stop(); told.Interval = time; told.Start(); return(true); } } Timer t = new Timer() { Interval = time }; t.Tick += Timer_Tick; t.Tag = new TimerInfo() { ap = ap, name = exp[0], he = he }; timers.Add(t); t.Start(); System.Diagnostics.Debug.WriteLine("Timer Go " + exp[0]); } else { ap.ReportError("Timer bad name or time count"); } } else { ap.ReportError(exp[0]); } } else { ap.ReportError("Timer command line not in correct format"); } return(true); }
public override bool ExecuteAction(ActionProgramRun ap) { string res; if (ap.Functions.ExpandString(UserData, out res) != BaseUtils.Functions.ExpandResult.Failed) { StringParser sp = new StringParser(res); string prefix = "CMDR_"; string cmdname = sp.NextWord(); if (cmdname != null && cmdname.Equals("PREFIX", StringComparison.InvariantCultureIgnoreCase)) { prefix = sp.NextWord(); if (prefix == null) { ap.ReportError("Missing name after Prefix"); return(true); } cmdname = sp.NextWord(); } int cmdrid = EDCommander.CurrentCmdrID; if (cmdname != null && cmdname.Equals("CMDR", StringComparison.InvariantCultureIgnoreCase)) { string name = sp.NextQuotedWord() ?? "-----!"; EDCommander cmdr = EDCommander.GetCommander(name); if (cmdr != null) { cmdrid = cmdr.Id; } else { ap.ReportError("Commander not found"); } cmdname = sp.NextWord(); } EDDiscoveryForm discoveryform = (ap.ActionController as ActionController).DiscoveryForm; List <EDCommander> cmdrlist = EDCommander.GetListCommanders(); if (cmdname != null) { if (cmdname.Equals("LIST", StringComparison.InvariantCultureIgnoreCase)) { string wildcard = sp.NextQuotedWord() ?? "*"; int count = 1; foreach (var cmdr in cmdrlist) // only current commander ID considered { if (cmdr.Name.WildCardMatch(wildcard)) { DumpCMDR(ap, prefix + count++.ToStringInvariant() + "_", cmdr); } } ap[prefix + "MatchCount"] = (count - 1).ToStringInvariant(); ap[prefix + "TotalCount"] = cmdrlist.Count.ToStringInvariant(); } else if (cmdname.Equals("CHANGETO", StringComparison.InvariantCultureIgnoreCase)) { discoveryform.ChangeToCommander(cmdrid); // which will cause DIsplay to be called as some point } else { ap.ReportError("Unknown command"); } } else { ap.ReportError("Missing command"); } } else { ap.ReportError(res); } return(true); }
public override bool ExecuteAction(ActionProgramRun ap) { string res; if (ap.Functions.ExpandString(UserData, out res) != BaseUtils.Functions.ExpandResult.Failed) { StringParser sp = new StringParser(res); string prefix = "L_"; string cmdname = sp.NextWord(); if (cmdname != null && cmdname.Equals("PREFIX", StringComparison.InvariantCultureIgnoreCase)) { prefix = sp.NextWord(); if (prefix == null) { ap.ReportError("Missing name after Prefix in Ledger"); return(true); } cmdname = sp.NextWord(); } bool nextvalidentry = false; if (cmdname != null && cmdname.Equals("ATORBEFORE", StringComparison.InvariantCultureIgnoreCase)) { nextvalidentry = true; // means, find next ledger entry BEFORE this JID.. cmdname = sp.NextWord(); } if (cmdname != null) { long jid; if (!cmdname.InvariantParse(out jid)) { ap.ReportError("Non integer JID in Ledger"); return(true); } Ledger ml = (ap.ActionController as ActionController).HistoryList.CashLedger; Ledger.Transaction tx = ml.Transactions.Find(x => x.jid == jid); // try and find it in the ledger int jidindex = (ap.ActionController as ActionController).HistoryList.EntryOrder().FindIndex(x => x.Journalid == jid); // find it in the journal if (tx == null && nextvalidentry) // if not directly found.. { while (jidindex > 0) // go back, to 0. if jidindex is -1 above, nothing happens { jidindex--; // predec so we don't test first one jid = (ap.ActionController as ActionController).HistoryList.EntryOrder()[jidindex].Journalid; tx = ml.Transactions.Find(x => x.jid == jid); if (tx != null) { break; } } } if (tx == null) { ap.ReportError("Cannot find entry in Ledger"); return(true); } ap[prefix + "JID"] = jid.ToString(System.Globalization.CultureInfo.InvariantCulture); ap[prefix + "IndexOf"] = (ap.ActionController as ActionController).HistoryList.EntryOrder()[jidindex].EntryNumber.ToString(System.Globalization.CultureInfo.InvariantCulture); ap[prefix + "UTCTime"] = tx.utctime.ToStringUSInvariant(); ap[prefix + "EntryType"] = tx.jtype.ToString(); ap[prefix + "Notes"] = tx.notes; ap[prefix + "Value"] = tx.cashadjust.ToString(System.Globalization.CultureInfo.InvariantCulture); ap[prefix + "PPU"] = tx.profitperunit.ToString(System.Globalization.CultureInfo.InvariantCulture); ap[prefix + "Credits"] = tx.cash.ToString(System.Globalization.CultureInfo.InvariantCulture); } else { ap.ReportError("Missing JID in Ledger"); } } else { ap.ReportError(res); } return(true); }
public override bool ExecuteAction(ActionProgramRun ap) { string res; if (ap.functions.ExpandString(UserData, out res) != ConditionFunctions.ExpandResult.Failed) { StringParser sp = new StringParser(res); string cmdname = sp.NextWord(", ", true); if (cmdname.Equals("folder")) { sp.IsCharMoveOn(','); FolderBrowserDialog fbd = new FolderBrowserDialog(); string descr = sp.NextQuotedWordComma(); if (descr != null) { fbd.Description = descr; } string rootfolder = sp.NextQuotedWordComma(); if (rootfolder != null) { Environment.SpecialFolder sf; if (Enum.TryParse <Environment.SpecialFolder>(rootfolder, out sf)) { fbd.RootFolder = sf; } else { return(ap.ReportError("FileDialog folder does not recognise folder location " + rootfolder)); } } string fileret = (fbd.ShowDialog(ap.actioncontroller.DiscoveryForm) == DialogResult.OK) ? fbd.SelectedPath : ""; ap["FolderName"] = fileret; } else if (cmdname.Equals("openfile")) { sp.IsCharMoveOn(','); OpenFileDialog fd = new OpenFileDialog(); fd.Multiselect = false; fd.CheckPathExists = true; try { string rootfolder = sp.NextQuotedWordComma(); if (rootfolder != null) { fd.InitialDirectory = rootfolder; } string filter = sp.NextQuotedWordComma(); if (filter != null) { fd.Filter = filter; } string defext = sp.NextQuotedWordComma(); if (defext != null) { fd.DefaultExt = defext; } string check = sp.NextQuotedWordComma(); if (check != null && check.Equals("On", StringComparison.InvariantCultureIgnoreCase)) { fd.CheckFileExists = true; } string fileret = (fd.ShowDialog(ap.actioncontroller.DiscoveryForm) == DialogResult.OK) ? fd.FileName : ""; ap["FileName"] = fileret; } catch { ap.ReportError("FileDialog file failed to generate dialog, check options"); } } else if (cmdname.Equals("savefile")) { sp.IsCharMoveOn(','); SaveFileDialog fd = new SaveFileDialog(); try { string rootfolder = sp.NextQuotedWordComma(); if (rootfolder != null) { fd.InitialDirectory = rootfolder; } string filter = sp.NextQuotedWordComma(); if (filter != null) { fd.Filter = filter; } string defext = sp.NextQuotedWordComma(); if (defext != null) { fd.DefaultExt = defext; } string check = sp.NextQuotedWordComma(); if (check != null && check.Equals("On", StringComparison.InvariantCultureIgnoreCase)) { fd.OverwritePrompt = true; } string fileret = (fd.ShowDialog(ap.actioncontroller.DiscoveryForm) == DialogResult.OK) ? fd.FileName : ""; ap["FileName"] = fileret; } catch { ap.ReportError("FileDialog file failed to generate dialog, check options"); } } else { ap.ReportError("FileDialog does not recognise command " + cmdname); } } else { ap.ReportError(res); } return(true); }