internal static ModuleInfoEvent Execute(string json, EliteDangerousAPI api)
        {
            var jsonEvent = api.FromJson <ModuleInfoEvent>(json);
            var fileEvent = api.FromJsonFile <ModuleInfoEvent>(Path.Combine(api.JournalDirectory.FullName, "ModulesInfo.json"));

            return(api.ShipEvents.InvokeEvent(fileEvent ?? jsonEvent));
        }
Exemple #2
0
 public CommanderStatus(EliteDangerousAPI api)
 {
     api.Events.LoadGameEvent   += (sender, e) => { Commander = e.Commander; Credits = e.Credits; };
     api.Events.RankEvent       += (sender, e) => { EmpireRank = e.Empire; FederationRank = e.Federation; CombatRank = e.Combat; TradeRank = e.Trade; ExplorationRank = e.Explore; CqcRank = e.Cqc; };
     api.Events.ProgressEvent   += (sender, e) => { EmpireRankProgress = e.Empire; FederationRankProgress = e.Federation; CombatRankProgress = e.Combat; TradeRankProgress = e.Trade; ExplorationRankProgress = e.Explore; CqcRankProgress = e.Cqc; };
     api.Events.StatisticsEvent += (sender, e) => { Statistics = e; };
 }
Exemple #3
0
        void vmInterface.ReceiveParams(string Param1, string Param2, string Param3, bool Synchron)
        {
            try
            {
                string command = Param1.ToLower();

                if (command == "updatejournal")
                {
                    SetJournalFolder();
                    api = new EliteDangerousAPI(playerJournalDirectory);
                    return;
                }
                else if (command == "drp on")
                {
                    api.DiscordRichPresence.TurnOn();
                    return;
                }
                else if (command == "drp off")
                {
                    api.DiscordRichPresence.TurnOff();
                    return;
                }
            }
            catch { }
        }
Exemple #4
0
        public void Ready()
        {
            Thread.Sleep(1000);

            SetProgress("Starting EliteAPI ...");
            try
            {
                EliteAPI = new EliteDangerousAPI(EliteDangerousAPI.StandardDirectory, false);
                EliteAPI.Logger.UseLogFile(new DirectoryInfo(Directory.GetCurrentDirectory()));
                ThirdPartyWrapper wrapper = new ThirdPartyWrapper(EliteAPI, "EliteHook");
                EliteAPI.ChangeJournal(wrapper.GetJournalFolder("EliteHook.ini"));
                if (!Directory.Exists(EliteAPI.JournalDirectory.FullName) || EliteAPI.JournalDirectory.GetFiles("Journal.*.log").Count() == 0)
                {
                    SetProgress("Please set a custom Journal Path in EliteHook.ini"); Thread.Sleep(5000); Environment.Exit(-1);
                }
                EliteAPI.Start();
            }
            catch (Exception ex) { SetProgress("Error: " + ex.Message); Thread.Sleep(5000); Environment.Exit(-1); }
            if (!EliteAPI.IsRunning)
            {
                SetProgress("Could not start EliteAPI. See log files for more information");  Thread.Sleep(5000); Environment.Exit(-1);
            }

            SetProgress("Loading program ...");
            Main main = new Main(EliteAPI);

            main.FormClosed += Main_FormClosed;
            this.Invoke(new Action(() => this.Hide()));
            Application.Run(main);
        }
Exemple #5
0
        public static void VA_Invoke1(dynamic vaProxy)
        {
            _vaProxy = vaProxy;

            try
            {
                string command = vaProxy.Context.ToString().ToLower();

                if (command == "updatejournal")
                {
                    SetJournalFolder();
                    api = new EliteDangerousAPI(playerJournalDirectory);
                    return;
                }
                else if (command == "drp on")
                {
                    api.DiscordRichPresence.TurnOn();
                    return;
                }
                else if (command == "drp off")
                {
                    api.DiscordRichPresence.TurnOff();
                    return;
                }
            }
            catch { }
        }
        public void Initialize(Settings settings)
        {
            // Initialize first. We are outputing to the console set up in this API
            eliteAPI = new EliteDangerousAPI();
            //eliteAPI.Logger.UseConsole(Severity.Info);

            foreach (var device in settings.Devices)
            {
                var ffDevice = new ForceFeedbackController();
                if (ffDevice.Initialize(
                        device.ProductGuid,
                        device.ProductName,
                        @".\Forces",
                        device.AutoCenter,
                        device.ForceFeedbackGain) == false)
                {
                    continue;
                }

                var deviceEvents = new DeviceEvents
                {
                    EventSettings = device.StatusEvents.ToDictionary(v => v.Event, v => v),
                    Device        = ffDevice
                };

                Devices.Add(deviceEvents);
            }

            eliteAPI.Start();

            eliteAPI.Events.AllEvent += Events_AllEvent;
        }
Exemple #7
0
 internal LocationStatus(EliteDangerousAPI api)
 {
     api.Events.LocationEvent         += (sender, e) => { StarSystem = e.StarSystem; Body = e.Body; BodyType = e.BodyType; };
     api.Events.ApproachBodyEvent     += (sender, e) => { StarSystem = e.StarSystem; Body = e.Body; BodyType = "Planet"; };
     api.Events.LeaveBodyEvent        += (sender, e) => { StarSystem = e.StarSystem; Body = e.Body; BodyType = "Planet"; };
     api.Events.DockedEvent           += (sender, e) => { Station = e.StationName; };
     api.Events.DockingRequestedEvent += (sender, e) => { Station = e.StationName; };
 }
Exemple #8
0
 public void Dispose()
 {
     if (Initialized)
     {
         EliteAPI?.Stop();
         EliteAPI = null;
     }
 }
Exemple #9
0
            public static void VA_Init1(dynamic vaProxy)
            {
                _vaProxy = vaProxy;

                FindJournalFolder(vaProxy);
                EliteAPI           = new EliteDangerousAPI(playerJournalDirectory, true);
                EliteAPI.AllEvent += EliteAPI_AllEvent;
                EliteAPI.Start();
            }
Exemple #10
0
        static void Main(string[] args)
        {
            EliteAPI = new EliteDangerousAPI(EliteDangerousAPI.StandardDirectory);
            EliteAPI.Logger.UseConsole().UseLogFile(new DirectoryInfo(Directory.GetCurrentDirectory()));
            //EliteAPI.Events.AllEvent += (sender, e) => EliteAPI.Logger.LogInfo(Newtonsoft.Json.JsonConvert.SerializeObject(e));
            EliteAPI.Start();

            Thread.Sleep(-1);
        }
Exemple #11
0
 internal MaterialWatcher(EliteDangerousAPI api)
 {
     EliteAPI = api;
     EliteAPI.Events.MaterialsEvent         += (sender, e) => EliteAPI.Materials = e;
     EliteAPI.Events.MaterialCollectedEvent += Events_MaterialCollectedEvent;
     EliteAPI.Events.MaterialDiscardedEvent += Events_MaterialDiscardedEvent;
     EliteAPI.Events.MaterialTradeEvent     += Events_MaterialTradeEvent;
     EliteAPI.Events.SynthesisEvent         += Events_SynthesisEvent;
 }
Exemple #12
0
        private static void Main(string[] args)
        {
            EliteAPI = new EliteDangerousAPI();
            EliteAPI.Logger.AddHandler(new ConsoleHandler());
            EliteAPI.Logger.AddHandler(new LogFileHandler(Directory.GetCurrentDirectory(), "EliteAPI"));
            EliteAPI.Start();

            Thread.Sleep(-1);
        }
Exemple #13
0
 internal CargoWatcher(EliteDangerousAPI api)
 {
     this.api         = api;
     CargoFileWatcher = new FileSystemWatcher(api.JournalDirectory.FullName, "Cargo.json")
     {
         EnableRaisingEvents = true
     };
     CargoFileWatcher.Changed += (sender, e) => Update();
     Update();
 }
Exemple #14
0
        static void Main(string[] args)
        {
            EliteAPI = new EliteDangerousAPI();
            EliteAPI.Logger.UseConsole(Severity.Debug).UseLogFile(Directory.GetCurrentDirectory());
            EliteAPI.Start();

            EliteAPI.Events.AllEvent += (sender, e) => Console.Beep();

            Thread.Sleep(-1);
        }
Exemple #15
0
        private static void InitEliteApi()
        {
            NexHudEngine.Log(NxLog.Type.Debug, "Elite API Initilization...");
            m_eliteApi = new EliteDangerousAPI();
            m_eliteApi.Logger.AddHandler(new EliteApiLogger());
            m_eliteApi.Start(false);

            NexHudEngine.Log(NxLog.Type.Info, "Welcome CMDR " + m_eliteApi.Commander.Commander);
            NexHudEngine.Log(NxLog.Type.Info, "Current Star system: " + m_eliteApi.Location.StarSystem);
        }
Exemple #16
0
        void vmInterface.Init()
        {
            SetJournalFolder();

            api = new EliteDangerousAPI(EliteDangerousAPI.StandardDirectory, true);
            api.Logger.UseLogFile(new DirectoryInfo(vmCommand.GetDataDirectory()));
            api.Logger.Log      += Logger_Log;
            api.Events.AllEvent += EliteAPI_AllEvent;
            api.Start();
        }
Exemple #17
0
        static void Main(string[] args)
        {
            DirectoryInfo playerJournalFolder = new DirectoryInfo(
                $@"C:\Users\{Environment.UserName}\Saved Games\Frontier Developments\Elite Dangerous");

            EliteAPI = new EliteDangerousAPI(playerJournalFolder);

            EliteAPI.Events.DockingGrantedEvent += EliteAPI_DockingGrantedEvent;

            EliteAPI.Start();
        }
Exemple #18
0
        private static void Main(string[] args)
        {
            EliteAPI = new EliteDangerousAPI();
            EliteAPI.Logger.AddHandler(new ConsoleHandler());
            EliteAPI.Logger.SetAllowedLevels(Severity.Info | Severity.Warning | Severity.Error);

            EliteAPI.Start();
            EliteAPI.Events.MarketSellEvent += Events_MarketSellEvent;

            Thread.Sleep(-1);
        }
Exemple #19
0
        public Main(EliteDangerousAPI elite)
        {
            InitializeComponent();
            EliteAPI    = elite;
            this.Shown += (sender, e) => Task.Run(() => Ready());

            EliteAPI.Logger.Log += (sender, e) =>
            {
                txtLog.Invoke(new Action(() => txtLog.AppendText(e.Message + Environment.NewLine)));
                txtLog.Invoke(new Action(() => txtLog.ScrollToCaret()));
            };
        }
Exemple #20
0
            public static void VA_Invoke1(dynamic vaProxy)
            {
                _vaProxy = vaProxy;

                if (vaProxy.Context.ToString().ToLower() == "updatejournal")
                {
                    FindJournalFolder(vaProxy);
                    EliteAPI = new EliteDangerousAPI(playerJournalDirectory);
                    return;
                }

                vaProxy.SetBoolean("EliteAPI.DOCKED", EliteAPI.Status.Docked);
                vaProxy.SetBoolean("EliteAPI.LANDED", EliteAPI.Status.Landed);
                vaProxy.SetBoolean("EliteAPI.GEAR", EliteAPI.Status.Gear);
                vaProxy.SetBoolean("EliteAPI.SHIELDS", EliteAPI.Status.Shields);
                vaProxy.SetBoolean("EliteAPI.SUPERCRUISE", EliteAPI.Status.Supercruise);
                vaProxy.SetBoolean("EliteAPI.FLIGHTASSIST", EliteAPI.Status.FlightAssist);
                vaProxy.SetBoolean("EliteAPI.HARDPOINTS", EliteAPI.Status.Hardpoints);
                vaProxy.SetBoolean("EliteAPI.WINGING", EliteAPI.Status.Winging);
                vaProxy.SetBoolean("EliteAPI.LIGHTS", EliteAPI.Status.Lights);
                vaProxy.SetBoolean("EliteAPI.CARGOSCOOP", EliteAPI.Status.CargoScoop);
                vaProxy.SetBoolean("EliteAPI.SILENTRUNNING", EliteAPI.Status.SilentRunning);
                vaProxy.SetBoolean("EliteAPI.SCOOPING", EliteAPI.Status.Scooping);
                vaProxy.SetBoolean("EliteAPI.SRVHANDBREAK", EliteAPI.Status.SrvHandbreak);
                vaProxy.SetBoolean("EliteAPI.SRVTURRENT", EliteAPI.Status.SrvTurrent);
                vaProxy.SetBoolean("EliteAPI.SRVNEARSHIP", EliteAPI.Status.SrvNearShip);
                vaProxy.SetBoolean("EliteAPI.SRVDRIVEASSIST", EliteAPI.Status.SrvDriveAssist);
                vaProxy.SetBoolean("EliteAPI.MASSLOCKED", EliteAPI.Status.MassLocked);
                vaProxy.SetBoolean("EliteAPI.FSDCHARGING", EliteAPI.Status.FsdCooldown);
                vaProxy.SetBoolean("EliteAPI.FSDCOOLDOWN", EliteAPI.Status.FsdCooldown);
                vaProxy.SetBoolean("EliteAPI.LOWFUEL", EliteAPI.Status.LowFuel);
                vaProxy.SetBoolean("EliteAPI.OVERHEATING", EliteAPI.Status.Overheating);
                vaProxy.SetBoolean("EliteAPI.HASLATLONG", EliteAPI.Status.HasLatLong);
                vaProxy.SetBoolean("EliteAPI.INDANGER", EliteAPI.Status.InDanger);
                vaProxy.SetBoolean("EliteAPI.ININTERDICTION", EliteAPI.Status.InInterdiction);
                vaProxy.SetBoolean("EliteAPI.INMOTHERSHIP", EliteAPI.Status.InMothership);
                vaProxy.SetBoolean("EliteAPI.INFIGHTER", EliteAPI.Status.InFighter);
                vaProxy.SetBoolean("EliteAPI.INSRV", EliteAPI.Status.InSRV);
                vaProxy.SetBoolean("EliteAPI.ANALYSISMODE", EliteAPI.Status.AnalysisMode);
                vaProxy.SetBoolean("EliteAPI.NIGHTVISION", EliteAPI.Status.NightVision);

                try
                {
                    vaProxy.SetInt("EliteAPI.Pips.SYSTEMS", EliteAPI.Status.Pips[0]);
                    vaProxy.SetInt("EliteAPI.Pips.ENGINES", EliteAPI.Status.Pips[1]);
                    vaProxy.SetInt("EliteAPI.Pips.WEAPONS", EliteAPI.Status.Pips[2]);
                    vaProxy.SetInt("EliteAPI.FIREGROUP", EliteAPI.Status.FireGroup);
                    vaProxy.SetInt("EliteAPI.GUIFOCUS", EliteAPI.Status.GuiFocus);
                    vaProxy.SetDecimal("EliteAPI.FUEL", (decimal)EliteAPI.Status.Fuel);
                    vaProxy.SetDecimal("EliteAPI.CARGO", (decimal)EliteAPI.Status.Cargo);
                }
                catch { vaProxy.WriteToLog("EliteVA - There was an error while setting some of the fields, make sure ED is running"); }
            }
Exemple #21
0
        internal StatusWatcher(EliteDangerousAPI api)
        {
            this.api = api;

            api.Events.ReceiveTextEvent += Events_ReceiveTextEvent;
            statusWatcher = new FileSystemWatcher(api.JournalDirectory.FullName, "Status.json")
            {
                EnableRaisingEvents = true
            };
            statusWatcher.Changed += (sender, e) => Update();

            Update();
        }
Exemple #22
0
        public void Initialize(Settings settings)
        {
            this.eventSettings = settings.StatusEvents.ToDictionary(v => v.Event, v => v);

            eliteAPI = new EliteDangerousAPI();
            eliteAPI.Logger.UseConsole(Severity.Info);
            eliteAPI.Start();

            msffb2 = new MicrosoftSidewinder();
            msffb2.ForceFeedback2(settings.ProductGuid);

            eliteAPI.Events.AllEvent += Events_AllEvent;
        }
Exemple #23
0
        internal static GameStatus FromFile(FileInfo file, EliteDangerousAPI api)
        {
            try
            {
                if (!File.Exists(file.FullName)) /*  api.Logger.Log(Severity.Error, "Could not find Status.json.", new FileNotFoundException("Status.json could not be found.", file.FullName)); */ return {
                    (new GameStatus());
                }

                //Create a stream from the log file.
                var fileStream = file.Open(FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                //Create a stream from the file stream.
                var streamReader = new StreamReader(fileStream);

                //Go through the stream.
                while (!streamReader.EndOfStream)
                {
                    try
                    {
                        //Process this string.
                        var json = streamReader.ReadLine();
                        var s    = Process(json);

                        if (s.Fuel == null)
                        {
                            s.Fuel = new Fuel();
                        }

                        if (s.Pips == null)
                        {
                            s.Pips = new List <long> {
                                0, 0, 0
                            };
                        }

                        return(s);
                    }
                    catch (Exception ex)
                    {
                        api.Logger.Log(Severity.Warning, "Could not update Status.json.", ex);
                    }
                }

                return(api.Status);
            }
            catch (Exception ex)
            {
                api.Logger.Log(Severity.Warning, "Could not update status.", ex);
            }

            return(new GameStatus());
        }
 /// <summary>
 /// Creates a new ThirdPartyWrapper object.
 /// </summary>
 /// <param name="api">The EliteDangerousAPI api</param>
 /// <param name="name">The name of the plugin</param>
 /// <param name="iniPath">The path to the configuration file</param>
 public ThirdPartyWrapper(EliteDangerousAPI api, string name, string iniPath)
 {
     EliteAPI = api;
     EliteAPI.Logger.Log(Severity.Debug, $"Enabled third party wrapper for {name}.");
     this.iniPath = iniPath;
     try
     {
         if (File.ReadAllLines(iniPath)[0] == "//Use this to set a custom path to your Journal directory.")
         {
             File.Delete(iniPath);
         }
     }
     catch { }
 }
Exemple #25
0
        static void Main(string[] args)
        {
            EliteDangerousAPI EliteAPI = new EliteDangerousAPI(EliteDangerousAPI.StandardDirectory, true);

            EliteAPI.Logger.UseConsole();
            EliteAPI.Start();

            VoiceMacroBuilder v = new VoiceMacroBuilder();

            v.CreateProfile("EliteAPI VMP (auto-gen)");

            //Landing gear.
            v.AddCommand(new CommandBuilder()
                         .UsePhrase("lower landing gear")
                         .AddAction(new ConditionAction()
            {
                Condition     = "EliteAPI.Gear_p = False",
                ActionsIfTrue = new List <IAction>()
                {
                    new KeyboardAction()
                    {
                        Key = Keys.L
                    }
                }
            })
                         );
            v.AddCommand(new CommandBuilder()
                         .UsePhrase("raise landing gear")
                         .AddAction(new ConditionAction()
            {
                Condition     = "EliteAPI.Gear_p = True",
                ActionsIfTrue = new List <IAction>()
                {
                    new KeyboardAction()
                    {
                        Key = Keys.L
                    }
                }
            }));
            v.AddCommand(new CommandBuilder()
                         .UsePhrase("landing gear")
                         .AddAction(new KeyboardAction()
            {
                Key = Keys.L
            }));

            v.BuildProfile(new DirectoryInfo(Directory.GetCurrentDirectory()));
        }
Exemple #26
0
        public static void VA_Init1(dynamic vaProxy)
        {
            _vaProxy = vaProxy;

            SetJournalFolder();

            api = new EliteDangerousAPI(playerJournalDirectory, true);
            api.Logger.UseLogFile(new DirectoryInfo(Directory.GetCurrentDirectory()));
            api.Logger.Log      += Logger_Log;
            api.Events.AllEvent += EliteAPI_AllEvent;
            api.Start();

            _vaProxy.SetText("EliteAPI.Version", api.Version);

            VA_Invoke1(vaProxy);
        }
Exemple #27
0
 internal StatusWatcher(EliteDangerousAPI api)
 {
     this.api = api;
     api.Events.ReceiveTextEvent      += Events_ReceiveTextEvent;
     api.Events.FSDJumpEvent          += Events_FSDJumpEvent;
     api.Events.LoadGameEvent         += Events_LoadGameEvent;
     api.Events.MusicEvent            += Events_MusicEvent;
     api.Events.SupercruiseEntryEvent += Events_SupercruiseEntryEvent;
     api.Events.StartJumpEvent        += Events_StartJumpEvent;
     statusWatcher = new FileSystemWatcher(api.JournalDirectory.FullName, "Status.json")
     {
         EnableRaisingEvents = true
     };
     statusWatcher.Changed += (sender, e) => Update();
     Update();
 }
Exemple #28
0
 void vmInterface.Init()
 {
     //Create new EliteAPI.
     EliteAPI = new EliteDangerousAPI(EliteDangerousAPI.StandardDirectory);
     //Create new Wrapper.
     Wrapper = new ThirdPartyWrapper(EliteAPI, DisplayName, $@"{vmCommand.GetDataDirectory()}\EliteMacro.ini");
     //Setup EliteAPI.
     EliteAPI.Logger.LogEvent += Logger_Log;
     EliteAPI.Logger.AddHandler(new LogFileHandler(Directory.GetCurrentDirectory(), "EliteAPI"));
     EliteAPI.ChangeJournal(Wrapper.GetJournalFolder());
     //Start the API.
     EliteAPI.Start(Wrapper.GetRichPresenceSetting());
     SetVariables(Wrapper.GetVariables());
     //Listen for events.
     EliteAPI.Events.AllEvent += Events_AllEvent;
 }
Exemple #29
0
 public static void VA_Init1(dynamic vaProxy)
 {
     proxy = vaProxy;
     //Create new EliteAPI.
     EliteAPI = new EliteDangerousAPI(EliteDangerousAPI.StandardDirectory);
     //Create new Wrapper.
     Wrapper = new ThirdPartyWrapper(EliteAPI, VA_DisplayName(), $@"{Directory.GetCurrentDirectory()}\EliteVA.ini");
     //Setup EliteAPI.
     EliteAPI.Logger.LogEvent += Logger_Log;
     EliteAPI.Logger.AddHandler(new LogFileHandler(Wrapper.GetLogFolder().ToString(), "EliteAPI"));
     EliteAPI.ChangeJournal(Wrapper.GetJournalFolder());
     //Start the API.
     EliteAPI.Start(Wrapper.GetRichPresenceSetting());
     SetVariables(Wrapper.GetVariables());
     //Listen for events.
     EliteAPI.Events.AllEvent += Events_AllEvent;
 }
Exemple #30
0
        void vmInterface.Init()
        {
            //Create new EliteAPI.
            EliteAPI = new EliteDangerousAPI(EliteDangerousAPI.StandardDirectory);

            //Create new Wrapper.
            Wrapper = new ThirdPartyWrapper(EliteAPI, DisplayName, $@"{vmCommand.GetDataDirectory()}\EliteMacro.ini");

            //Setup EliteAPI.
            EliteAPI.Logger.Log += Logger_Log;
            EliteAPI.Logger.UseLogFile(Wrapper.GetLogFolder().ToString());
            EliteAPI.ChangeJournal(Wrapper.GetJournalFolder());

            //Start the API.
            EliteAPI.Start();

            //Listen for events.
            EliteAPI.Events.AllEvent += Events_AllEvent;
        }