Beispiel #1
0
        static public EDDDLLInterfaces.EDDDLLIF.JournalEntry CreateFromHistoryEntry(EliteDangerousCore.HistoryEntry he, bool storedflag = false)
        {
            if (he == null)
            {
                return(new EDDDLLInterfaces.EDDDLLIF.JournalEntry()
                {
                    ver = 1, indexno = -1
                });
            }
            else
            {
                EDDDLLInterfaces.EDDDLLIF.JournalEntry je = new EDDDLLInterfaces.EDDDLLIF.JournalEntry()
                {
                    ver               = 2,
                    indexno           = he.Indexno,
                    utctime           = he.EventTimeUTC.ToStringZulu(),
                    name              = he.EventSummary,
                    systemname        = he.System.Name,
                    x                 = he.System.X,
                    y                 = he.System.Y,
                    z                 = he.System.Z,
                    travelleddistance = he.TravelledDistance,
                    travelledseconds  = (long)he.TravelledSeconds.TotalSeconds,
                    islanded          = he.IsLanded,
                    isdocked          = he.IsDocked,
                    whereami          = he.WhereAmI,
                    shiptype          = he.ShipType,
                    gamemode          = he.GameMode,
                    group             = he.Group,
                    credits           = he.Credits,
                    eventid           = he.journalEntry.EventTypeStr,
                    json              = he.journalEntry.GetJsonString(),
                    cmdrname          = he.Commander.Name,
                    cmdrfid           = he.Commander.FID,
                    shipident         = he.ShipInformation?.ShipUserIdent ?? "Unknown",
                    shipname          = he.ShipInformation?.ShipUserName ?? "Unknown",
                    hullvalue         = he.ShipInformation?.HullValue ?? 0,
                    rebuy             = he.ShipInformation?.Rebuy ?? 0,
                    modulesvalue      = he.ShipInformation?.ModulesValue ?? 0,
                    stored            = storedflag
                };

                he.journalEntry.FillInformation(out je.info, out je.detailedinfo);

                je.materials       = (from x in he.MaterialCommodity.Sort(false) select x.Details.Name + ":" + x.Count.ToStringInvariant() + ":" + x.Details.FDName).ToArray();
                je.commodities     = (from x in he.MaterialCommodity.Sort(true) select x.Details.Name + ":" + x.Count.ToStringInvariant() + ":" + x.Details.FDName).ToArray();
                je.currentmissions = he.MissionList.GetAllCurrentMissions(he.EventTimeUTC).Select(x => x.DLLInfo()).ToArray();
                return(je);
            }
        }
Beispiel #2
0
        static public EDDDLLIF.JournalEntry CreateFromHistoryEntry(EliteDangerousCore.HistoryEntry he)
        {
            if (he == null)
            {
                return(new EDDDLLIF.JournalEntry()
                {
                    ver = 1, indexno = -1
                });
            }
            else
            {
                EDDDLLIF.JournalEntry je = new EDDDLLIF.JournalEntry()
                {
                    ver               = 1,
                    indexno           = he.Indexno,
                    utctime           = he.EventTimeUTC.ToStringZulu(),
                    name              = he.EventSummary,
                    systemname        = he.System.Name,
                    x                 = he.System.X,
                    y                 = he.System.Y,
                    z                 = he.System.Z,
                    travelleddistance = he.TravelledDistance,
                    travelledseconds  = (long)he.TravelledSeconds.TotalSeconds,
                    islanded          = he.IsLanded,
                    isdocked          = he.IsDocked,
                    whereami          = he.WhereAmI,
                    shiptype          = he.ShipType,
                    gamemode          = he.GameMode,
                    group             = he.Group,
                    credits           = he.Credits,
                    eventid           = he.journalEntry.EventTypeStr
                };

                he.journalEntry.FillInformation(out je.info, out je.detailedinfo);

                je.materials       = (from x in he.MaterialCommodity.Sort(false) select x.Details.Name + ":" + x.Count.ToStringInvariant() + ":" + x.Details.FDName).ToArray();
                je.commodities     = (from x in he.MaterialCommodity.Sort(true) select x.Details.Name + ":" + x.Count.ToStringInvariant() + ":" + x.Details.FDName).ToArray();
                je.currentmissions = he.MissionList.GetAllCurrentMissions(he.EventTimeUTC).Select(x => x.FullInfo()).ToArray();
                return(je);
            }
        }
Beispiel #3
0
        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.PopOuts.PopOut(PanelInformation.PanelIDs.Map2D);
                    }
                    else if (cmdname.Equals("edsm"))
                    {
                        ActionController ac = (ap.ActionController as ActionController);

                        EliteDangerousCore.EDSM.EDSMClass edsm = new EliteDangerousCore.EDSM.EDSMClass();

                        if (edsm.ValidCredentials)
                        {
                            ac.DiscoveryForm.EDSMSend();
                        }
                        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.EventList.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.EventList.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.EventList.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);
                                        (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);
        }
Beispiel #4
0
 public static ActionEvent UserRightClick(EliteDangerousCore.HistoryEntry he)
 {
     return(new ActionEventEDList(he.journalEntry.EventTypeStr, "UserRightClick", ""));
 }
Beispiel #5
0
 public static ActionEvent EventCmd(EliteDangerousCore.HistoryEntry he)
 {
     return(new ActionEventEDList(he.journalEntry.EventTypeStr, "ActionProgram", ""));
 }
Beispiel #6
0
 public static ActionEvent NewEntry(EliteDangerousCore.HistoryEntry he)
 {
     return(new ActionEventEDList(he.journalEntry.EventTypeStr, "NewEntry", ""));
 }
Beispiel #7
0
        }                                                                      // TBD for voice, fix index

        public static ActionEvent RefreshJournal(EliteDangerousCore.HistoryEntry he)
        {
            return(new ActionEventEDList(he.journalEntry.EventTypeStr, "onRefresh", ""));
        }