Esempio n. 1
0
        private void buttonEditCommander_Click(object sender, EventArgs e)
        {
            if (dataGridViewCommanders.SelectedRows.Count > 0)
            {
                int         row  = dataGridViewCommanders.SelectedRows[0].Index;
                EDCommander cmdr = dataGridViewCommanders.Rows[row].DataBoundItem as EDCommander;

                EliteDangerousCore.Forms.CommanderForm cf = new EliteDangerousCore.Forms.CommanderForm();
                cf.Init(cmdr, false);

                if (cf.ShowDialog(FindForm()) == DialogResult.OK)
                {
                    bool forceupdate = cf.Update(cmdr);
                    List <EDCommander> edcommanders = (List <EDCommander>)dataGridViewCommanders.DataSource;
                    discoveryform.LoadCommandersListBox();
                    EDCommander.Update(edcommanders, false);
                    dataGridViewCommanders.Refresh();

                    if (forceupdate)                         // journal loc change forcing update
                    {
                        discoveryform.RefreshHistoryAsync(); // do a resync
                    }
                }
            }
        }
        private void CmdrEdit(int row)
        {
            EDCommander cmdr = dataGridViewCommanders.Rows[row].DataBoundItem as EDCommander;

            cf = new EliteDangerousCore.Forms.CommanderForm(AdditionalCmdrControls());
            cf.Init(cmdr, false);
            SetCAPILabelState();
            discoveryform.FrontierCAPI.StatusChange += CAPICallBack;

            if (cf.ShowDialog(FindForm()) == DialogResult.OK)
            {
                bool forceupdate = cf.Update(cmdr);
                List <EDCommander> edcommanders = (List <EDCommander>)dataGridViewCommanders.DataSource;
                discoveryform.LoadCommandersListBox();
                EDCommander.Update(edcommanders, false);
                dataGridViewCommanders.Refresh();

                if (forceupdate)                         // journal loc change forcing update
                {
                    discoveryform.RefreshHistoryAsync(); // do a resync
                }
            }

            discoveryform.FrontierCAPI.StatusChange -= CAPICallBack;
        }
Esempio n. 3
0
        private void EditCmdr(int row)
        {
            EDCommander cmdr = dataGridViewCommanders.Rows[row].DataBoundItem as EDCommander;

            EliteDangerousCore.Forms.CommanderForm cf = new EliteDangerousCore.Forms.CommanderForm();
            cf.Init(cmdr, false, true, true);

            if (cf.ShowDialog(FindForm()) == DialogResult.OK)
            {
                bool forceupdate = cf.Update(cmdr);
                List <EDCommander> edcommanders = (List <EDCommander>)dataGridViewCommanders.DataSource;
                EDCommander.Update(edcommanders, false);
                dataGridViewCommanders.Refresh();
                controller.RequestRescan = true;
            }
        }
Esempio n. 4
0
        private void buttonEditCommander_Click(object sender, EventArgs e)
        {
            if (dataGridViewCommanders.CurrentCell != null)
            {
                int         row  = dataGridViewCommanders.CurrentCell.RowIndex;
                EDCommander cmdr = dataGridViewCommanders.Rows[row].DataBoundItem as EDCommander;

                CommanderForm cf = new CommanderForm();
                cf.Init(cmdr, false);

                if (cf.ShowDialog(FindForm()) == DialogResult.OK)
                {
                    cf.Update(cmdr);
                    List <EDCommander> edcommanders = (List <EDCommander>)dataGridViewCommanders.DataSource;
                    discoveryform.LoadCommandersListBox();
                    EDCommander.Update(edcommanders, false);
                }

                // CAPI Descoped discoveryform.Capi.Logout();       // logout.. CAPI may have changed
                discoveryform.RefreshHistoryAsync();           // do a resync, CAPI may have changed, anything else, make it work again
            }
        }
        private void CmdrEdit(int row)
        {
            EDCommander cmdr = dataGridViewCommanders.Rows[row].DataBoundItem as EDCommander;

            cf = new EliteDangerousCore.Forms.CommanderForm(AdditionalCmdrControls());
            cf.Init(cmdr, false);
            SetCAPILabelState();
            discoveryform.FrontierCAPI.StatusChange += CAPICallBack;
            capiloggedin = false;

            if (cf.ShowDialog(FindForm()) == DialogResult.OK)
            {
                bool forceupdate = cf.Update(cmdr);
                cmdr.Update();
                dataGridViewCommanders.Refresh();

                if (forceupdate || capiloggedin)                // either a critial journal item changed, or a capi was logged
                {
                    discoveryform.RefreshHistoryAsync();        // do a resync
                }
            }

            discoveryform.FrontierCAPI.StatusChange -= CAPICallBack;
        }
Esempio n. 6
0
        protected JournalReaderEntry ProcessLine(string line, bool resetOnError)
        {
            int cmdrid = -2;        //-1 is hidden, -2 is never shown

            if (TravelLogUnit.CommanderId.HasValue)
            {
                cmdrid = TravelLogUnit.CommanderId.Value;
                // System.Diagnostics.Trace.WriteLine(string.Format("TLU says commander {0} at {1}", cmdrid, TravelLogUnit.Name));
            }

            if (line.Length == 0)
            {
                return(null);
            }

            JObject      jo = null;
            JournalEntry je = null;

            try
            {
                jo = JObject.Parse(line);
                je = JournalEntry.CreateJournalEntry(jo);
            }
            catch
            {
                System.Diagnostics.Trace.WriteLine($"Bad journal line:\n{line}");

                if (resetOnError)
                {
                    throw;
                }
                else
                {
                    return(null);
                }
            }

            if (je == null)
            {
                System.Diagnostics.Trace.WriteLine($"Bad journal line:\n{line}");
                return(null);
            }

            if (je.EventTypeID == JournalTypeEnum.Fileheader)
            {
                JournalEvents.JournalFileheader header = (JournalEvents.JournalFileheader)je;

                if (header.Beta && !disable_beta_commander_check)
                {
                    TravelLogUnit.type |= 0x8000;
                }

                if (header.Part > 1)
                {
                    JournalEvents.JournalContinued contd = JournalEntry.GetLast <JournalEvents.JournalContinued>(je.EventTimeUTC.AddSeconds(1), e => e.Part == header.Part);

                    // Carry commander over from previous log if it ends with a Continued event.
                    if (contd != null && Math.Abs(header.EventTimeUTC.Subtract(contd.EventTimeUTC).TotalSeconds) < 5 && contd.CommanderId >= 0)
                    {
                        TravelLogUnit.CommanderId = contd.CommanderId;
                    }
                }
            }
            else if (je.EventTypeID == JournalTypeEnum.LoadGame)
            {
                string newname = (je as JournalEvents.JournalLoadGame).LoadGameCommander;

                if ((TravelLogUnit.type & 0x8000) == 0x8000)
                {
                    newname = "[BETA] " + newname;
                }

                EDCommander _commander = EDCommander.GetCommander(newname);

                if (_commander == null)
                {
                    EDCommander onlyc = EDCommander.GetAll().FirstOrDefault();
                    if (EDCommander.NumberOfCommanders == 1 && onlyc != null && onlyc.Name == "Jameson (Default)")
                    {
                        onlyc.Name     = newname;
                        onlyc.EdsmName = newname;
                        EDCommander.Update(new List <EDCommander> {
                            onlyc
                        }, false);
                    }
                    else
                    {
                        _commander = EDCommander.Create(newname, null, EDJournalClass.GetDefaultJournalDir().Equals(TravelLogUnit.Path) ? "" : TravelLogUnit.Path);
                    }
                }

                cmdrid = _commander.Nr;

                if (!TravelLogUnit.CommanderId.HasValue)
                {
                    TravelLogUnit.CommanderId = cmdrid;
                    TravelLogUnit.Update();
                    System.Diagnostics.Trace.WriteLine(string.Format("TLU {0} updated with commander {1}", TravelLogUnit.Path, cmdrid));
                }
            }

            je.TLUId       = (int)TravelLogUnit.id;
            je.CommanderId = cmdrid;

            return(new JournalReaderEntry {
                JournalEntry = je, Json = jo
            });
        }