public static List <ActionEvent> EventList(bool excludestatics = false, bool excludejournal = false, bool excludeui = false)
        {
            List <ActionEvent> eventlist = new List <ActionEvent>();

            if (!excludejournal)
            {
                List <string> jevents = EliteDangerousCore.JournalEntry.GetListOfEventsWithOptMethod(towords: false);
                jevents.Sort();
                eventlist.AddRange(ActionEventEDList.EventsFromNames(jevents, "", "NewEntry", "Journal"));      // presume NewEntry as its the most prevalent.  Trigger type is not used in this circumstance except in Perform
            }

            if (!excludeui)
            {
                List <string> uievents = Enum.GetNames(typeof(EliteDangerousCore.UITypeEnum)).ToList();
                uievents.Sort();
                eventlist.AddRange(ActionEventEDList.EventsFromNames(uievents, "UI", "EliteUIEvent", "UIEvents"));
            }

            if (!excludestatics)
            {
                eventlist.AddRange(ActionEventEDList.StaticDefinedEvents());
            }

            return(eventlist);
        }
        public static List <ActionEvent> EventList(bool excludestatics = false, bool excludejournal = false, bool excludeui = false, bool excludejournaluitranslatedevents = false)
        {
            List <ActionEvent> eventlist = new List <ActionEvent>();

            if (!excludejournal)
            {
                List <string> jevents = EliteDangerousCore.JournalEntry.GetNameOfEvents();
                if (excludejournaluitranslatedevents)
                {
                    jevents.Remove("Music");        // manually synchronise with EDJournalReader .
                    jevents.Remove("UnderAttack");
                    jevents.Remove("FSDTarget");
                }

                jevents.Sort();
                eventlist.AddRange(ActionEventEDList.EventsFromNames(jevents, "", "NewEntry", "Journal"));      // presume NewEntry as its the most prevalent.  Trigger type is not used in this circumstance except in Perform
            }

            if (!excludeui)
            {
                List <string> uievents = Enum.GetNames(typeof(EliteDangerousCore.UITypeEnum)).ToList();
                uievents.Sort();
                eventlist.AddRange(ActionEventEDList.EventsFromNames(uievents, "UI", "EliteUIEvent", "UIEvents"));
            }

            if (!excludestatics)
            {
                eventlist.AddRange(ActionEventEDList.StaticDefinedEvents());
            }

            return(eventlist);
        }
Exemple #3
0
        private bool EditActionFile(string name)            // edit pack name
        {
            List <string> jevents = JournalEntry.GetListOfEventsWithOptMethod(towords: false);

            jevents.Sort();
            List <ActionEvent> eventlist = ActionEventEDList.EventsFromNames(jevents, "Journal");

            eventlist.AddRange(ActionEventEDList.events); // our ED events
            eventlist.AddRange(ActionEvent.events);       // core events

            ActionPackEditorForm frm = new ActionPackEditorForm();

            frm.AdditionalNames      += Frm_onAdditionalNames;
            frm.CreateActionPackEdit += SetPackEditorAndCondition;
            ActionFile f = actionfiles.Get(name);

            if (f != null)
            {
                frm.Init("Edit pack " + name, this.Icon, this, AppFolder, f, eventlist);
                frm.TopMost = discoveryform.FindForm().TopMost;

                frm.ShowDialog(discoveryform.FindForm()); // don't care about the result, the form does all the saving

                ActionConfigureKeys();

                lasteditedpack = name;
                SQLiteConnectionUser.PutSettingString("ActionPackLastFile", lasteditedpack);
                return(true);
            }
            else
            {
                return(false);
            }
        }
        public bool EditPack(string name)            // edit pack name
        {
            ActionPackEditorForm frm = new ActionPackEditorForm();

            frm.AdditionalNames      += Frm_onAdditionalNames;
            frm.CreateActionPackEdit += SetPackEditorAndCondition;
            ActionFile f = actionfiles.Get(name);

            if (f != null)
            {
                string collapsestate = SQLiteConnectionUser.GetSettingString("ActionEditorCollapseState_" + name, "");  // get any collapsed state info for this pack

                frm.Init("Edit pack " + name, this.Icon, this, AppFolder, f, ActionEventEDList.EventList(), collapsestate);

                frm.ShowDialog(discoveryform);                                                                    // don't care about the result, the form does all the saving

                SQLiteConnectionUser.PutSettingString("ActionEditorCollapseState_" + name, frm.CollapsedState()); // get any collapsed state info for this pack

                ActionConfigureKeys();                                                                            // kick it to load in case its changed
                VoiceLoadEvents();

                lasteditedpack = name;
                SQLiteConnectionUser.PutSettingString("ActionPackLastFile", lasteditedpack);
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemple #5
0
        public bool EditPack(string name)            // edit pack name
        {
            List <string> jevents = JournalEntry.GetListOfEventsWithOptMethod(towords: false);

            jevents.Sort();
            List <ActionEvent> eventlist = ActionEventEDList.EventsFromNames(jevents, "Journal");

            List <string> uievents = Enum.GetNames(typeof(UITypeEnum)).ToList();

            uievents.Sort();
            eventlist.AddRange(ActionEventEDList.EventsFromNames(uievents, "UIEvents"));

            eventlist.AddRange(ActionEventEDList.events); // our ED events
            eventlist.AddRange(ActionEvent.events);       // core events

            ActionPackEditorForm frm = new ActionPackEditorForm();

            frm.AdditionalNames      += Frm_onAdditionalNames;
            frm.CreateActionPackEdit += SetPackEditorAndCondition;
            ActionFile f = actionfiles.Get(name);

            if (f != null)
            {
                string collapsestate = SQLiteConnectionUser.GetSettingString("ActionEditorCollapseState_" + name, "");  // get any collapsed state info for this pack

                frm.Init("Edit pack " + name, this.Icon, this, AppFolder, f, eventlist, collapsestate);

                frm.ShowDialog(discoveryform);                                                                    // don't care about the result, the form does all the saving

                SQLiteConnectionUser.PutSettingString("ActionEditorCollapseState_" + name, frm.CollapsedState()); // get any collapsed state info for this pack

                ActionConfigureKeys();                                                                            // kick it to load in case its changed
                VoiceLoadEvents();

                lasteditedpack = name;
                SQLiteConnectionUser.PutSettingString("ActionPackLastFile", lasteditedpack);
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemple #6
0
        public void ActionRunOnRefresh()
        {
            string prevcommander = Globals.Exists("Commander") ? Globals["Commander"] : "None";
            string commander     = (discoverycontroller.history.CommanderId < 0) ? "Hidden" : EDCommander.Current.Name;

            string refreshcount = prevcommander.Equals(commander) ? Globals.AddToVar("RefreshCount", 1, 1) : "1";

            SetInternalGlobal("RefreshCount", refreshcount);
            SetInternalGlobal("Commander", commander);

            if (actionfiles.IsConditionFlagSet(ConditionVariables.flagRunAtRefresh))      // any events have this flag? .. don't usually do this, so worth checking first
            {
                foreach (HistoryEntry he in discoverycontroller.history.EntryOrder)
                {
                    ActionRunOnEntry(he, ActionEventEDList.RefreshJournal(he), ConditionVariables.flagRunAtRefresh);
                }
            }

            ActionRun(ActionEventEDList.onRefreshEnd);
        }
        private List <TypeHelpers.PropertyNameInfo> Frm_onAdditionalNames(string evname)       // call back to discover name list.  evname may be empty
        {
            System.Diagnostics.Debug.WriteLine("Get variables for " + evname);

            List <TypeHelpers.PropertyNameInfo> fieldnames =
                (from x in discoveryform.Globals.NameList select new BaseUtils.TypeHelpers.PropertyNameInfo(x, "Global Variable String or Number" + Environment.NewLine + "Not part of an event, set up by either EDD or one of the action packs", null, "Global")).ToList();

            if (evname.HasChars())
            {
                fieldnames.Add(new TypeHelpers.PropertyNameInfo("TriggerName", "Name of event, either the JournalEntryName, or UI<event>", ConditionEntry.MatchType.Equals, "Event Trigger Info"));
                fieldnames.Add(new TypeHelpers.PropertyNameInfo("TriggerType", "Type of trigger, either UIEvent or JournalEvent", ConditionEntry.MatchType.Equals, "Event Trigger Info"));

                var events = ActionEventEDList.StaticDefinedEvents();

                ActionEvent ty = events.Find(x => x.TriggerName == evname);
                if (ty?.Variables != null)                                             // if its a static event and it has variables, add..
                {
                    fieldnames.AddRange(ty.Variables);
                }

                // first see if its a journal event..
                List <TypeHelpers.PropertyNameInfo> classnames = BaseUtils.TypeHelpers.GetPropertyFieldNames(JournalEntry.TypeOfJournalEntry(evname), "EventClass_", comment: "Event Variable");
                // then if its an UI
                if (classnames == null)
                {
                    classnames = BaseUtils.TypeHelpers.GetPropertyFieldNames(UIEvent.TypeOfUIEvent(evname), "EventClass_", comment: "Event Variable");
                }

                if (classnames != null)
                {
                    fieldnames.AddRange(classnames);
                }
            }

            return(fieldnames);
        }
Exemple #8
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);
        }
Exemple #9
0
        public bool EditPack(string name)            // edit pack name
        {
            ActionPackEditPackForm frm = new ActionPackEditPackForm();

            frm.AdditionalNames      += Frm_onAdditionalNames;
            frm.CreateActionPackEdit += SetPackEditorAndCondition;
            ActionFile f = actionfiles.Get(name);

            if (f != null)
            {
                string collapsestate = EliteDangerousCore.DB.UserDatabase.Instance.GetSettingString("ActionEditorCollapseState_" + name, "");  // get any collapsed state info for this pack

                frm.Init("Edit pack " + name, this.Icon, this, EDDOptions.Instance.ActionsAppDirectory(), f, ActionEventEDList.EventList(excludejournaluitranslatedevents: true), collapsestate);

                frm.ShowDialog(discoveryform);                                                                                           // don't care about the result, the form does all the saving

                EliteDangerousCore.DB.UserDatabase.Instance.PutSettingString("ActionEditorCollapseState_" + name, frm.CollapsedState()); // get any collapsed state info for this pack

                ActionConfigureKeys();                                                                                                   // kick it to load in case its changed
                VoiceLoadEvents();

                lasteditedpack = name;
                EliteDangerousCore.DB.UserDatabase.Instance.PutSettingString("ActionPackLastFile", lasteditedpack);
                return(true);
            }
            else
            {
                return(false);
            }
        }