예제 #1
0
        private void RefreshTargetDisplay(Object sender)              // called when a target has been changed.. via EDDiscoveryform
        {
            string name;
            double x, y, z;

            //System.Diagnostics.Debug.WriteLine("Refresh target display");

            if (TargetClass.GetTargetPosition(out name, out x, out y, out z))
            {
                textBoxTarget.Text = name;
                textBoxTarget.Select(textBoxTarget.Text.Length, textBoxTarget.Text.Length);
                textBoxTargetDist.Text = "No Pos";

                HistoryEntry cs = discoveryform.history.GetLastWithPosition;
                if (cs != null)
                {
                    textBoxTargetDist.Text = SystemClassDB.Distance(cs.System, x, y, z).ToString("0.0");
                }

                textBoxTarget.SetTipDynamically(toolTip1, "Position is " + x.ToString("0.00") + "," + y.ToString("0.00") + "," + z.ToString("0.00"));
            }
            else
            {
                textBoxTarget.Text     = "?";
                textBoxTargetDist.Text = "";
                textBoxTarget.SetTipDynamically(toolTip1, "On 3D Map right click to make a bookmark, region mark or click on a notemark and then tick on Set Target, or type it here and hit enter");
            }
        }
예제 #2
0
        private float CalculateRouteMaxDistFromOrigin()
        {
            if (dataGridViewRouteSystems.Rows.Count < 2)
            {
                return(100);
            }

            double maxdist = 25;
            var    systems = dataGridViewRouteSystems.Rows.OfType <DataGridViewRow>()
                             .Where(r => r.Index < dataGridViewRouteSystems.NewRowIndex && r.Cells[0].Tag != null)
                             .Select(r => r.Cells[0].Tag as ISystemBase)
                             .Where(s => s.HasCoordinate);
            var sys0 = systems.FirstOrDefault();

            if (sys0 != null)
            {
                foreach (var sys in systems)
                {
                    double dist = SystemClassDB.Distance(sys0, sys);

                    if (dist > maxdist)
                    {
                        maxdist = dist;
                    }
                }
            }

            return((float)maxdist);
        }
예제 #3
0
        private float CalculateRouteMaxDistFromOrigin()
        {
            if (dataGridViewRouteSystems.Rows.Count < 2)
            {
                return(100);
            }

            double maxdist = 25;
            var    rows    = dataGridViewRouteSystems.Rows.OfType <DataGridViewRow>().Where(r => r.Cells[0].Value != null).ToList();
            List <SystemClassDB> systems = rows.Select(r => r.Cells[0].Tag as SystemClassDB).ToList();
            SystemClassDB        sys0    = systems.FirstOrDefault(s => s != null && s.HasCoordinate);

            if (sys0 != null)
            {
                foreach (var sys in systems.Where(s => s != null))
                {
                    double dist = SystemClassDB.Distance(sys0, sys);

                    if (dist > maxdist)
                    {
                        maxdist = dist;
                    }
                }
            }

            return((float)maxdist);
        }
예제 #4
0
        private void DBLookup(Task <List <ISystem> > task)
        {
            System.Diagnostics.Debug.Assert(Application.MessageLoop);

            dataGridViewEDSM.Rows.Clear();

            List <ISystem> systems = task.Result;

            HistoryEntry helast = discoveryform.history.GetLast;
            ISystem      home   = helast != null ? helast.System : new SystemClass("Sol", 0, 0, 0);

            foreach (ISystem sys in systems)
            {
                string sep = System.Globalization.CultureInfo.CurrentCulture.NumberFormat.NumberGroupSeparator + " ";

                string dist = "";
                if (sys.HasCoordinate)
                {
                    dist = SystemClassDB.Distance(sys, home).ToString("0.#");
                }

                object[] rowobj = { sys.name, dist, sys.x.ToString("0.#") + sep + sys.y.ToString("0.#") + sep + sys.z.ToString("0.#"), sys.id_edsm.ToStringInvariant() };
                dataGridViewEDSM.Rows.Add(rowobj);
                dataGridViewEDSM.Rows[dataGridViewEDSM.Rows.Count - 1].Tag = sys;
            }

            Cursor = Cursors.Default;

            dataGridViewEDSM.Sort(ColumnStar, ListSortDirection.Ascending);
        }
예제 #5
0
        private void UpdateTotalDistances()
        {
            double distance = 0;

            txtCmlDistance.Text = distance.ToString("0.00") + "LY";
            txtP2PDIstance.Text = distance.ToString("0.00") + "LY";
            if (dataGridViewRouteSystems.Rows.Count > 1)
            {
                ISystem firstSC = null;
                ISystem lastSC  = null;
                for (int i = 0; i < dataGridViewRouteSystems.Rows.Count; i++)
                {
                    if (firstSC == null && dataGridViewRouteSystems[0, i].Tag != null)
                    {
                        firstSC = (ISystem)dataGridViewRouteSystems[0, i].Tag;
                    }
                    if (dataGridViewRouteSystems[0, i].Tag != null)
                    {
                        lastSC = (ISystem)dataGridViewRouteSystems[0, i].Tag;
                    }
                    String value = dataGridViewRouteSystems[1, i].Value as string;
                    if (!String.IsNullOrWhiteSpace(value))
                    {
                        distance += Double.Parse(value);
                    }
                }
                txtCmlDistance.Text = distance.ToString("0.00") + "LY";
                distance            = 0;
                if (firstSC != null && lastSC != null)
                {
                    distance            = SystemClassDB.Distance(firstSC, lastSC);
                    txtP2PDIstance.Text = distance.ToString("0.00") + "LY";
                }
            }
        }
예제 #6
0
        private static float CalculateRouteMaxDistFromOrigin(List <ISystem> systems)
        {
            var locSystems = systems?.Where(s => s != null && s.HasCoordinate).Distinct().ToList();

            if (locSystems == null || locSystems.Count < 2)
            {
                return(100);
            }

            return((float)locSystems
                   .Except(new[] { locSystems[0] })
                   .Select(s => SystemClassDB.Distance(locSystems[0], s))
                   .Max());
        }
예제 #7
0
        private string DistToStar(HistoryEntry he, Point3D tpos)
        {
            string res = "";

            if (!double.IsNaN(tpos.X))
            {
                double dist = SystemClassDB.Distance(he.System, tpos.X, tpos.Y, tpos.Z);
                if (dist >= 0)
                {
                    res = dist.ToString("0.00");
                }
            }

            return(res);
        }
예제 #8
0
        private void Display(HistoryEntry he, HistoryList hl)
        {
            if (neverdisplayed)
            {
                UpdateViewOnSelection();  // then turn the right ones on
                neverdisplayed = false;
            }

            last_he = he;

            if (last_he != null)
            {
                SetControlText(he.System.name);
                textBoxSystem.Text = he.System.name;
                discoveryform.history.FillEDSM(he, reload: true, useedsm: true); // Fill in any EDSM info we have, force it to try again.. in case system db updated

                textBoxBody.Text = he.WhereAmI + ((he.IsInHyperSpace) ? " (HS)": "");

                if (he.System.HasCoordinate)         // cursystem has them?
                {
                    string SingleCoordinateFormat = "0.##";

                    string separ = System.Globalization.CultureInfo.CurrentCulture.NumberFormat.NumberGroupSeparator + " ";

                    textBoxPosition.Text = he.System.x.ToString(SingleCoordinateFormat) + separ + he.System.y.ToString(SingleCoordinateFormat) + separ + he.System.z.ToString(SingleCoordinateFormat);

                    ISystem homesys = EDDConfig.Instance.HomeSystem;

                    textBoxHomeDist.Text = SystemClassDB.Distance(he.System, homesys).ToString(SingleCoordinateFormat);
                    textBoxSolDist.Text  = SystemClassDB.Distance(he.System, 0, 0, 0).ToString(SingleCoordinateFormat);
                }
                else
                {
                    textBoxPosition.Text = "?";
                    textBoxHomeDist.Text = "";
                    textBoxSolDist.Text  = "";
                }

                int count = discoveryform.history.GetVisitsCount(he.System.name);
                textBoxVisits.Text = count.ToString();

                bool enableedddross = (he.System.id_eddb > 0);  // Only enable eddb/ross for system that it knows about

                buttonRoss.Enabled = buttonEDDB.Enabled = enableedddross;

                string allegiance, economy, gov, faction, factionstate, security;
                hl.ReturnSystemInfo(he, out allegiance, out economy, out gov, out faction, out factionstate, out security);

                textBoxAllegiance.Text = allegiance;
                textBoxEconomy.Text    = economy;
                textBoxGovernment.Text = gov;
                textBoxState.Text      = factionstate;

                SetNote(he.snc != null ? he.snc.Note : "");
                textBoxGameMode.Text = he.GameModeGroup;
                if (he.isTravelling)
                {
                    textBoxTravelDist.Text  = he.TravelledDistance.ToStringInvariant("0.0") + "ly";
                    textBoxTravelTime.Text  = he.TravelledSeconds.ToString();
                    textBoxTravelJumps.Text = he.TravelledJumpsAndMisses;
                }
                else
                {
                    textBoxTravelDist.Text = textBoxTravelTime.Text = textBoxTravelJumps.Text = "";
                }

                int cc = (he.ShipInformation) != null?he.ShipInformation.CargoCapacity() : 0;

                if (cc > 0)
                {
                    textBoxCargo.Text = he.MaterialCommodity.CargoCount.ToStringInvariant() + "/" + cc.ToStringInvariant();
                }
                else
                {
                    textBoxCargo.Text = he.MaterialCommodity.CargoCount.ToStringInvariant();
                }

                textBoxMaterials.Text = he.MaterialCommodity.MaterialsCount.ToStringInvariant();
                textBoxData.Text      = he.MaterialCommodity.DataCount.ToStringInvariant();
                textBoxCredits.Text   = he.Credits.ToString("N0");

                if (he.ShipInformation != null)
                {
                    textBoxShip.Text = he.ShipInformation.ShipFullInfo(cargo: false, fuel: false);
                    if (he.ShipInformation.FuelCapacity > 0 && he.ShipInformation.FuelLevel > 0)
                    {
                        textBoxFuel.Text = he.ShipInformation.FuelLevel.ToStringInvariant("0.#") + "/" + he.ShipInformation.FuelCapacity.ToStringInvariant("0.#");
                    }
                    else if (he.ShipInformation.FuelCapacity > 0)
                    {
                        textBoxFuel.Text = he.ShipInformation.FuelCapacity.ToStringInvariant("0.#");
                    }
                    else
                    {
                        textBoxFuel.Text = "N/A";
                    }
                }
                else
                {
                    textBoxShip.Text = textBoxFuel.Text = "";
                }

                RefreshTargetDisplay(this);
            }
            else
            {
                SetControlText("");
                textBoxSystem.Text                = textBoxBody.Text = textBoxPosition.Text =
                    textBoxAllegiance.Text        = textBoxEconomy.Text = textBoxGovernment.Text =
                        textBoxVisits.Text        = textBoxState.Text = textBoxHomeDist.Text = textBoxSolDist.Text =
                            textBoxGameMode.Text  = textBoxTravelDist.Text = textBoxTravelTime.Text = textBoxTravelJumps.Text =
                                textBoxCargo.Text = textBoxMaterials.Text = textBoxData.Text = textBoxShip.Text = textBoxFuel.Text =
                                    "";

                buttonRoss.Enabled = buttonEDDB.Enabled = false;
                SetNote("");
            }
        }
예제 #9
0
        public override void Display(HistoryEntry he, HistoryList hl)
        {
            if (neverdisplayed)
            {
                UpdateViewOnSelection();  // then turn the right ones on
                neverdisplayed = false;
            }

            last_he = he;

            if (last_he != null)
            {
                SetControlText(he.System.name);
                textBoxSystem.Text = he.System.name;
                discoveryform.history.FillEDSM(he, reload: true); // Fill in any EDSM info we have, force it to try again.. in case system db updated

                textBoxBody.Text = he.WhereAmI;

                if (he.System.HasCoordinate)         // cursystem has them?
                {
                    string SingleCoordinateFormat = "0.##";

                    textBoxPosition.Text = he.System.x.ToString(SingleCoordinateFormat) + "," + he.System.y.ToString(SingleCoordinateFormat) + "," + he.System.z.ToString(SingleCoordinateFormat);

                    ISystem homesys = discoveryform.GetHomeSystem();

                    textBoxHomeDist.Text = SystemClassDB.Distance(he.System, homesys).ToString(SingleCoordinateFormat);
                    textBoxSolDist.Text  = SystemClassDB.Distance(he.System, 0, 0, 0).ToString(SingleCoordinateFormat);
                }
                else
                {
                    textBoxPosition.Text = "?";
                    textBoxHomeDist.Text = "";
                    textBoxSolDist.Text  = "";
                }

                int count = discoveryform.history.GetVisitsCount(he.System.name);
                textBoxVisits.Text = count.ToString();

                bool enableedddross = (he.System.id_eddb > 0);  // Only enable eddb/ross for system that it knows about

                buttonRoss.Enabled = buttonEDDB.Enabled = enableedddross;

                textBoxAllegiance.Text = he.System.allegiance.ToNullUnknownString();
                textBoxEconomy.Text    = he.System.primary_economy.ToNullUnknownString();
                textBoxGovernment.Text = he.System.government.ToNullUnknownString();
                textBoxState.Text      = he.System.state.ToNullUnknownString();
                SetNote(he.snc != null ? he.snc.Note : "");
                textBoxGameMode.Text = he.GameModeGroup;
                if (he.isTravelling)
                {
                    textBoxTravelDist.Text  = he.TravelledDistance.ToStringInvariant("0.0") + "ly";
                    textBoxTravelTime.Text  = he.TravelledSeconds.ToString();
                    textBoxTravelJumps.Text = he.TravelledJumpsAndMisses;
                }
                else
                {
                    textBoxTravelDist.Text = textBoxTravelTime.Text = textBoxTravelJumps.Text = "";
                }

                int cc = (he.ShipInformation) != null?he.ShipInformation.CargoCapacity() : 0;

                if (cc > 0)
                {
                    textBoxCargo.Text = he.MaterialCommodity.CargoCount.ToStringInvariant() + "/" + cc.ToStringInvariant();
                }
                else
                {
                    textBoxCargo.Text = he.MaterialCommodity.CargoCount.ToStringInvariant();
                }

                textBoxMaterials.Text = he.MaterialCommodity.MaterialsCount.ToStringInvariant();
                textBoxData.Text      = he.MaterialCommodity.DataCount.ToStringInvariant();
                textBoxCredits.Text   = he.Credits.ToString("N0");

                if (he.ShipInformation != null)
                {
                    textBoxShip.Text = he.ShipInformation.ShipFullInfo(cargo: false, fuel: false);
                    if (he.ShipInformation.FuelCapacity > 0 && he.ShipInformation.FuelLevel > 0)
                    {
                        textBoxFuel.Text = he.ShipInformation.FuelLevel.ToStringInvariant("0.#") + "/" + he.ShipInformation.FuelCapacity.ToStringInvariant("0.#");
                    }
                    else if (he.ShipInformation.FuelCapacity > 0)
                    {
                        textBoxFuel.Text = he.ShipInformation.FuelCapacity.ToStringInvariant("0.#");
                    }
                    else
                    {
                        textBoxFuel.Text = "N/A";
                    }
                }
                else
                {
                    textBoxShip.Text = textBoxFuel.Text = "";
                }

                RefreshTargetDisplay(this);
            }
            else
            {
                SetControlText("");
                textBoxSystem.Text                = textBoxBody.Text = textBoxPosition.Text =
                    textBoxAllegiance.Text        = textBoxEconomy.Text = textBoxGovernment.Text =
                        textBoxVisits.Text        = textBoxState.Text = textBoxHomeDist.Text = textBoxSolDist.Text =
                            textBoxGameMode.Text  = textBoxTravelDist.Text = textBoxTravelTime.Text = textBoxTravelJumps.Text =
                                textBoxCargo.Text = textBoxMaterials.Text = textBoxData.Text = textBoxShip.Text = textBoxFuel.Text =
                                    "";

                buttonRoss.Enabled = buttonEDDB.Enabled = false;
                SetNote("");
            }
        }
예제 #10
0
        public void Display(HistoryList hl)            // when user clicks around..  HE may be null here
        {
            pictureBox.ClearImageList();

            current_historylist = hl;

            if (hl != null && hl.Count > 0)                                                                 // just for safety
            {
                List <HistoryEntry> result = current_historylist.LastFirst;                                 // Standard filtering

                int ftotal;                                                                                 // event filter
                result = HistoryList.FilterByJournalEvent(result, SQLiteDBClass.GetSettingString(DbFilterSave, "All"), out ftotal);
                result = HistoryList.FilterHistory(result, fieldfilter, discoveryform.Globals, out ftotal); // and the field filter..

                RevertToNormalSize();                                                                       // ensure size is back to normal..
                scanpostextoffset = new Point(0, 0);                                                        // left/ top used by scan display

                Color textcolour = IsTransparent ? discoveryform.theme.SPanelColor : discoveryform.theme.LabelColor;
                Color backcolour = IsTransparent ? (Config(Configuration.showBlackBoxAroundText) ? Color.Black : Color.Transparent) : this.BackColor;

                bool drawnnootherstuff = DrawScanText(true, textcolour, backcolour); // go 1 for some of the scan positions

                if (!drawnnootherstuff)                                              // and it may indicate its overwriting all stuff, which is fine
                {
                    int rowpos    = scanpostextoffset.Y;
                    int rowheight = Config(Configuration.showIcon) ? 26 : 20;

                    if (Config(Configuration.showNothingWhenDocked) && (hl.GetLast.IsDocked || hl.GetLast.IsLanded))
                    {
                        AddColText(0, 0, rowpos, rowheight, (hl.GetLast.IsDocked) ? "Docked" : "Landed", textcolour, backcolour, null);
                    }
                    else
                    {
                        string  name;
                        Point3D tpos;
                        bool    targetpresent = TargetClass.GetTargetPosition(out name, out tpos);

                        if (targetpresent && Config(Configuration.showTargetLine) && hl.GetLast != null)
                        {
                            string dist = (hl.GetLast.System.HasCoordinate) ? SystemClassDB.Distance(hl.GetLast.System, tpos.X, tpos.Y, tpos.Z).ToString("0.00") : "Unknown";
                            AddColText(0, 0, rowpos, rowheight, "Target: " + name + " @ " + dist + " ly", textcolour, backcolour, null);
                            rowpos += rowheight;
                        }

                        foreach (HistoryEntry rhe in result)
                        {
                            DrawHistoryEntry(rhe, rowpos, rowheight, tpos, textcolour, backcolour);
                            rowpos += rowheight;

                            if (rowpos > ClientRectangle.Height)                // stop when off of screen
                            {
                                break;
                            }
                        }
                    }
                }

                DrawScanText(false, textcolour, backcolour);     // go 2
            }

            pictureBox.Render();
        }
예제 #11
0
        private void updateScreen()
        {
            if (currentSystem == null)
            {
                return;
            }

            if (_currentRoute == null)
            {
                DisplayText("Please set a route, by right clicking", "");
                return;
            }

            if (_currentRoute.Systems.Count == 0)
            {
                DisplayText(_currentRoute.Name, "Route contains no waypoints");
                return;
            }

            string        topline         = "";
            string        bottomLine      = "";
            string        firstSystemName = _currentRoute.Systems[0];
            SystemClassDB firstSystem     = SystemClassDB.GetSystem(firstSystemName);
            SystemClassDB finalSystem     = SystemClassDB.GetSystem(_currentRoute.Systems[_currentRoute.Systems.Count - 1]);

            if (finalSystem != null)
            {
                string mesg  = "remain";
                double distX = SystemClassDB.Distance(currentSystem.System, finalSystem);
                //Small hack to pull the jump range from TripPanel1
                var jumpRange = SQLiteDBClass.GetSettingDouble("TripPanel1" + "JumpRange", -1.0);
                if (jumpRange > 0)
                {
                    int jumps = (int)Math.Ceiling(distX / jumpRange);
                    if (jumps > 0)
                    {
                        mesg = "@ " + jumps.ToString() + ((jumps == 1) ? " jump" : " jumps");
                    }
                }
                topline = String.Format("{0} {1} WPs {2:N2}ly {3}", _currentRoute.Name, _currentRoute.Systems.Count, distX, mesg);
            }
            else
            {
                topline = String.Format("{0} {1} WPs remain", _currentRoute.Name, _currentRoute.Systems.Count);
            }
            SystemClassDB nearestSystem = null;
            double        minDist       = double.MaxValue;
            int           nearestidx    = -1;

            for (int i = 0; i < _currentRoute.Systems.Count; i++)
            {
                String        sys = _currentRoute.Systems[i];
                SystemClassDB sc  = SystemClassDB.GetSystem(sys);
                if (sc == null)
                {
                    continue;
                }
                double dist = SystemClassDB.Distance(currentSystem.System, sc);
                if (dist <= minDist)
                {
                    if (nearestSystem == null || !nearestSystem.name.Equals(sc.name))
                    {
                        minDist       = dist;
                        nearestidx    = i;
                        nearestSystem = sc;
                    }
                }
            }


            string name = null;

            if (nearestSystem != null && firstSystem != null)
            {
                double first2Neasest = SystemClassDB.Distance(firstSystem, nearestSystem);
                double first2Me      = SystemClassDB.Distance(firstSystem, currentSystem.System);

                string nextName = null;
                int    wp       = nearestidx + 1;
                if (nearestidx < _currentRoute.Systems.Count - 1)
                {
                    nextName = _currentRoute.Systems[nearestidx + 1];
                }
                if (first2Me >= first2Neasest && !String.IsNullOrWhiteSpace(nextName))
                {
                    name = nextName;
                    wp++;
                }
                else
                {
                    name = nearestSystem.name;
                }

                SystemClassDB nextSystem = SystemClassDB.GetSystem(name);
                if (nextSystem == null)
                {
                    bottomLine = String.Format("WP{0}: {1} {2}", wp, nextName, autoCopyWPToolStripMenuItem.Checked ? " (AUTO)" : "");
                }
                else
                {
                    double distance = SystemClassDB.Distance(currentSystem.System, nextSystem);
                    bottomLine = String.Format("{0:N2}ly to WP{1}: {2} {3}", distance, wp, name, autoCopyWPToolStripMenuItem.Checked ? " (AUTO)" : "");
                }
            }
            else
            {
                bottomLine = String.Format("WP{0}: {1} {2}", 1, firstSystemName, autoCopyWPToolStripMenuItem.Checked ? " (AUTO)" : "");
                name       = firstSystemName;
            }
            if (name != null && name.CompareTo(lastsystem) != 0)
            {
                if (autoCopyWPToolStripMenuItem.Checked)
                {
                    Clipboard.SetText(name);
                }
                if (autoSetTargetToolStripMenuItem.Checked)
                {
                    string targetName;
                    double x, y, z;
                    TargetClass.GetTargetPosition(out targetName, out x, out y, out z);
                    if (name.CompareTo(targetName) != 0)
                    {
                        RoutingUtils.setTargetSystem(discoveryform, name, false);
                    }
                }
            }
            lastsystem = name;
            DisplayText(topline, bottomLine);
        }
예제 #12
0
        public void ShowSystemInformation(DataGridViewRow rw)
        {
            StoreSystemNote(true);      // save any previous note

            HistoryEntry he = null;

            if (rw == null)
            {
                textBoxSystem.Text         = textBoxBody.Text = textBoxX.Text = textBoxY.Text = textBoxZ.Text =
                    textBoxAllegiance.Text = textBoxEconomy.Text = textBoxGovernment.Text =
                        textBoxVisits.Text = textBoxState.Text = textBoxHomeDist.Text = richTextBoxNote.Text = textBoxSolDist.Text = "";
                buttonRoss.Enabled         = buttonEDDB.Enabled = false;
            }
            else
            {
                he = userControlTravelGrid.GetHistoryEntry(rw.Index);     // reload, it may have changed
                Debug.Assert(he != null);

                _discoveryForm.history.FillEDSM(he, reload: true); // Fill in any EDSM info we have, force it to try again.. in case system db updated

                notedisplayedhe = he;

                textBoxSystem.Text = he.System.name;
                textBoxBody.Text   = he.WhereAmI;

                if (he.System.HasCoordinate)         // cursystem has them?
                {
                    textBoxX.Text = he.System.x.ToString(SingleCoordinateFormat);
                    textBoxY.Text = he.System.y.ToString(SingleCoordinateFormat);
                    textBoxZ.Text = he.System.z.ToString(SingleCoordinateFormat);

                    ISystem homesys = _discoveryForm.GetHomeSystem();

                    toolTipEddb.SetToolTip(textBoxHomeDist, $"Distance to home system ({homesys.name})");
                    textBoxHomeDist.Text = SystemClassDB.Distance(he.System, homesys).ToString(SingleCoordinateFormat);
                    textBoxSolDist.Text  = SystemClassDB.Distance(he.System, 0, 0, 0).ToString(SingleCoordinateFormat);
                }
                else
                {
                    textBoxX.Text        = "?";
                    textBoxY.Text        = "?";
                    textBoxZ.Text        = "?";
                    textBoxHomeDist.Text = "";
                    textBoxSolDist.Text  = "";
                }

                int count = _discoveryForm.history.GetVisitsCount(he.System.name);
                textBoxVisits.Text = count.ToString();

                bool enableedddross = (he.System.id_eddb > 0);  // Only enable eddb/ross for system that it knows about

                buttonRoss.Enabled = buttonEDDB.Enabled = enableedddross;

                textBoxAllegiance.Text = he.System.allegiance.ToNullUnknownString();
                textBoxEconomy.Text    = he.System.primary_economy.ToNullUnknownString();
                textBoxGovernment.Text = he.System.government.ToNullUnknownString();
                textBoxState.Text      = he.System.state.ToNullUnknownString();
                richTextBoxNote.Text   = he.snc != null ? he.snc.Note : "";

                _discoveryForm.CalculateClosestSystems(he.System, (s, d) => NewStarListComputed(s.name, d));
            }

            if (OnTravelSelectionChanged != null)
            {
                OnTravelSelectionChanged(he, _discoveryForm.history);
            }
        }
        void displayLastFSDOrScoop(HistoryEntry he)
        {
            pictureBox.ClearImageList();

            lastHE = he;

            if (he != null)
            {
                Color textcolour = IsTransparent ? discoveryform.theme.SPanelColor : discoveryform.theme.LabelColor;
                Color backcolour = IsTransparent ? Color.Black : this.BackColor;

                ExtendedControls.PictureBoxHotspot.ImageElement edsm = pictureBox.AddTextFixedSizeC(new Point(5, 5), new Size(80, 20), "EDSM", displayfont, backcolour, textcolour, 0.5F, true, he, "View system on EDSM");
                edsm.SetAlternateImage(ExtendedControls.BitMapHelpers.DrawTextIntoFixedSizeBitmapC("EDSM", edsm.img.Size, displayfont, backcolour, textcolour.Multiply(1.2F), 0.5F, true), edsm.pos, true);

                ExtendedControls.PictureBoxHotspot.ImageElement start = pictureBox.AddTextFixedSizeC(new Point(5, 35), new Size(80, 20), "Start", displayfont, backcolour, textcolour, 0.5F, true, "Start", "Set a journey start point");
                start.SetAlternateImage(ExtendedControls.BitMapHelpers.DrawTextIntoFixedSizeBitmapC("Start", edsm.img.Size, displayfont, backcolour, textcolour.Multiply(1.2F), 0.5F, true), start.pos, true);

                backcolour = IsTransparent ? Color.Transparent : this.BackColor;

                string  name;
                Point3D tpos;
                bool    targetpresent = TargetClass.GetTargetPosition(out name, out tpos);

                String topline = "  Route Not Set";

                if (targetpresent)
                {
                    double dist = SystemClassDB.Distance(he.System, tpos.X, tpos.Y, tpos.Z);

                    string mesg = "Left";
                    if (jumpRange > 0)
                    {
                        int jumps = (int)Math.Ceiling(dist / jumpRange);
                        if (jumps > 0)
                        {
                            mesg = "@ " + jumps.ToString() + ((jumps == 1) ? " jump" : " jumps");
                        }
                    }
                    topline = String.Format("{0} | {1:N2}ly {2}", name, dist, mesg);
                }

                topline = String.Format("{0} [{2}] | {1}", he.System.name, topline, discoveryform.history.GetVisitsCount(he.System.name));

                pictureBox.AddTextAutoSize(new Point(100, 5), new Size(1000, 40), topline, displayfont, textcolour, backcolour, 1.0F);

                string botline = "";

                botline += String.Format("{0:n}{1} @ {2} | {3} | ", he.TravelledDistance, ((he.TravelledMissingjump > 0) ? "ly (*)" : "ly"),
                                         he.Travelledjumps,
                                         he.TravelledSeconds);

                ExtendedControls.PictureBoxHotspot.ImageElement botlineleft = pictureBox.AddTextAutoSize(new Point(100, 35), new Size(1000, 40), botline, displayfont, textcolour, backcolour, 1.0F);


                double       fuel = 0.0;
                HistoryEntry fuelhe;


                switch (he.journalEntry.EventTypeID)
                {
                case JournalTypeEnum.FuelScoop:
                    fuel = (he.journalEntry as EliteDangerousCore.JournalEvents.JournalFuelScoop).Total;
                    break;

                case JournalTypeEnum.FSDJump:
                    fuel = (he.journalEntry as EliteDangerousCore.JournalEvents.JournalFSDJump).FuelLevel;
                    break;

                case JournalTypeEnum.RefuelAll:
                    fuelhe = discoveryform.history.GetLastHistoryEntry(x => x.journalEntry.EventTypeID == JournalTypeEnum.FSDJump ||
                                                                       x.journalEntry.EventTypeID == JournalTypeEnum.FuelScoop);
                    if (fuelhe.journalEntry.EventTypeID == EliteDangerousCore.JournalTypeEnum.FSDJump)
                    {
                        fuel = (fuelhe.journalEntry as EliteDangerousCore.JournalEvents.JournalFSDJump).FuelLevel;
                    }
                    else
                    {
                        fuel = (fuelhe.journalEntry as EliteDangerousCore.JournalEvents.JournalFuelScoop).Total;
                    }
                    fuel += (he.journalEntry as EliteDangerousCore.JournalEvents.JournalRefuelAll).Amount;
                    break;

                case JournalTypeEnum.RefuelPartial:
                    fuelhe = discoveryform.history.GetLastHistoryEntry(x => x.journalEntry.EventTypeID == JournalTypeEnum.FSDJump ||
                                                                       x.journalEntry.EventTypeID == JournalTypeEnum.FuelScoop);
                    if (fuelhe.journalEntry.EventTypeID == EliteDangerousCore.JournalTypeEnum.FSDJump)
                    {
                        fuel = (fuelhe.journalEntry as EliteDangerousCore.JournalEvents.JournalFSDJump).FuelLevel;
                    }
                    else
                    {
                        fuel = (fuelhe.journalEntry as EliteDangerousCore.JournalEvents.JournalFuelScoop).Total;
                    }
                    fuel += (he.journalEntry as EliteDangerousCore.JournalEvents.JournalRefuelPartial).Amount;
                    break;

                //fuel += (he.journalEntry as EliteDangerous.JournalEvents.JournalRefuelAll).Amount;
                //case EliteDangerous.JournalTypeEnum.RefuelPartial:
                ////fuel += (he.journalEntry as EliteDangerous.JournalEvents.JournalRefuelPartial).Amount;
                default:
                    break;
                }
                fuel = Math.Floor(fuel * 100.0) / 100.0;
                if (tankSize == -1 || tankWarning == -1)
                {
                    botline = "Please set ships details";
                }
                else
                {
                    if (fuel > tankSize)
                    {
                        fuel = tankSize;
                    }
                    botline = String.Format("{0}t / {1}t", fuel.ToString("N1"), tankSize.ToString("N1"));

                    if ((fuel / tankSize) < (tankWarning / 100.0))
                    {
                        textcolour = discoveryform.theme.TextBlockHighlightColor;
                        botline   += String.Format(" < {0}%", tankWarning.ToString("N1"));
                    }
                }

                if (currentCargo >= 0 && linearConstant > 0 && unladenMass > 0 && optimalMass > 0 &&
                    powerConstant > 0 && maxFuelPerJump > 0)
                {
                    double maxJumps        = 0;
                    double maxJumpDistance = EliteDangerousCore.EliteDangerousCalculations.CalculateMaxJumpDistance(fuel,
                                                                                                                    currentCargo, linearConstant, unladenMass,
                                                                                                                    optimalMass, powerConstant,
                                                                                                                    maxFuelPerJump, out maxJumps);
                    double JumpRange = Math.Pow(maxFuelPerJump / (linearConstant * 0.001), 1 / powerConstant) * optimalMass / (currentCargo + unladenMass + fuel);

                    HistoryEntry lastJet = discoveryform.history.GetLastHistoryEntry(x => x.journalEntry.EventTypeID == JournalTypeEnum.JetConeBoost);
                    if (lastJet != null && lastJet.EventTimeLocal > lastHE.EventTimeLocal)
                    {
                        JumpRange *= (lastJet.journalEntry as EliteDangerousCore.JournalEvents.JournalJetConeBoost).BoostValue;
                        botline   += String.Format(" [{0:N2}ly @ BOOST]", Math.Floor(JumpRange * 100) / 100);
                    }
                    else
                    {
                        botline += String.Format(" [{0:N2}ly @ {1:N2}ly / {2:N0}]",
                                                 Math.Floor(JumpRange * 100) / 100,
                                                 Math.Floor(maxJumpDistance * 100) / 100,
                                                 Math.Floor(maxJumps * 100) / 100);
                    }
                }
                pictureBox.AddTextAutoSize(new Point(botlineleft.pos.Right, 35), new Size(1000, 40), botline, displayfont, textcolour, backcolour, 1.0F);
                pictureBox.Render();
            }
        }
예제 #14
0
        private void Display(HistoryList hl)
        {
            pictureBox.ClearImageList();

            current_historylist = hl;
            System.Diagnostics.Debug.WriteLine("Display event ");

            if (hl != null && hl.Count > 0)                                                                   // just for safety
            {
                List <HistoryEntry> result = current_historylist.LastFirst;                                   // Standard filtering

                int ftotal;                                                                                   // event filter
                result = HistoryList.FilterByJournalEvent(result, SQLiteDBClass.GetSettingString(DbFilterSave, "All"), out ftotal);
                result = FilterHelpers.FilterHistory(result, fieldfilter, discoveryform.Globals, out ftotal); // and the field filter..

                RevertToNormalSize();                                                                         // ensure size is back to normal..
                scanpostextoffset = new Point(0, 0);                                                          // left/ top used by scan display

                Color textcolour = IsTransparent ? discoveryform.theme.SPanelColor : discoveryform.theme.LabelColor;
                Color backcolour = IsTransparent ? (Config(Configuration.showBlackBoxAroundText) ? Color.Black : Color.Transparent) : this.BackColor;

                bool drawnnootherstuff = DrawScanText(true, textcolour, backcolour); // go 1 for some of the scan positions

                if (!drawnnootherstuff)                                              // and it may indicate its overwriting all stuff, which is fine
                {
                    int rowpos    = scanpostextoffset.Y;
                    int rowheight = Config(Configuration.showIcon) ? 26 : 20;

                    if (Config(Configuration.showNothingWhenDocked) && (hl.IsCurrentlyDocked || hl.IsCurrentlyLanded))
                    {
                        AddColText(0, 0, rowpos, rowheight, (hl.IsCurrentlyDocked) ? "Docked" : "Landed", textcolour, backcolour, null);
                    }
                    else if ((uistate == UIState.GalMap && Config(Configuration.showNothingWhenGalmap)) || (uistate == UIState.SystemMap && Config(Configuration.showNothingWhenSysmap)))
                    {
                        AddColText(0, 0, rowpos, rowheight, (uistate == UIState.GalMap) ? "Galaxy Map" : "System Map", textcolour, backcolour, null);
                    }
                    else
                    {
                        string  name;
                        Point3D tpos;
                        bool    targetpresent = TargetClass.GetTargetPosition(out name, out tpos);

                        ISystem currentsystem = hl.CurrentSystem; // may be null

                        HistoryEntry last = hl.GetLast;

                        if (Config(Configuration.showSystemInformation) && last != null)
                        {
                            string allegiance, economy, gov, faction, factionstate, security;
                            hl.ReturnSystemInfo(last, out allegiance, out economy, out gov, out faction, out factionstate, out security);

                            string str = last.System.name + " : " + BaseUtils.FieldBuilder.Build(
                                "", faction,
                                "", factionstate,
                                "", security,
                                "", allegiance,
                                "", economy,
                                "", gov
                                );
                            AddColText(0, 0, rowpos, rowheight, str, textcolour, backcolour, null);

                            rowpos += rowheight;
                        }

                        if (Config(Configuration.showHabInformation) && last != null)
                        {
                            StarScan scan = hl.starscan;

                            StarScan.SystemNode sn = scan.FindSystem(last.System, true);    // EDSM look up here..

                            string res = null;

                            if (sn != null && sn.starnodes.Count > 0 && sn.starnodes.Values[0].ScanData != null)
                            {
                                JournalScan js = sn.starnodes.Values[0].ScanData;
                                res = js.HabZoneString().Replace("\r\n", " ");
                            }

                            if (res != null)
                            {
                                AddColText(0, 0, rowpos, rowheight, res, textcolour, backcolour, null);
                                rowpos += rowheight;
                            }
                        }

                        if (targetpresent && Config(Configuration.showTargetLine) && currentsystem != null)
                        {
                            string dist = (currentsystem.HasCoordinate) ? SystemClassDB.Distance(currentsystem, tpos.X, tpos.Y, tpos.Z).ToString("0.00") : "Unknown";
                            AddColText(0, 0, rowpos, rowheight, "Target: " + name + " @ " + dist + " ly", textcolour, backcolour, null);
                            rowpos += rowheight;
                        }

                        foreach (HistoryEntry rhe in result)
                        {
                            DrawHistoryEntry(rhe, rowpos, rowheight, tpos, textcolour, backcolour);
                            rowpos += rowheight;

                            if (rowpos > ClientRectangle.Height)                // stop when off of screen
                            {
                                break;
                            }
                        }
                    }
                }

                DrawScanText(false, textcolour, backcolour);     // go 2
            }

            pictureBox.Render();
        }
예제 #15
0
        private void UpdateSystemRow(int rowindex)
        {
            const int idxVisits  = 5;
            const int idxScans   = 6;
            const int idxPriStar = 7;
            const int idxInfo    = 8;
            const int idxNote    = 9;

            if (hl == null)
            {
                hl = discoveryform.history;
            }

            HistoryEntry last = hl.GetLast;

            if (last == null)
            {
                return;
            }

            ISystem currentSystem = last.System;

            if (rowindex < dataGridViewExplore.Rows.Count && dataGridViewExplore[0, rowindex].Value != null)
            {
                string  sysname = dataGridViewExplore[0, rowindex].Value.ToString();
                ISystem sys     = (ISystem)dataGridViewExplore[0, rowindex].Tag;

                if (sys == null)
                {
                    sys = GetSystem(sysname);
                }

                if (sys != null && currentSystem != null)
                {
                    double dist    = SystemClassDB.Distance(sys, currentSystem);
                    string strdist = dist >= 0 ? ((double)dist).ToString("0.00") : "";
                    dataGridViewExplore[1, rowindex].Value = strdist;
                }

                dataGridViewExplore[0, rowindex].Tag = sys;
                dataGridViewExplore.Rows[rowindex].DefaultCellStyle.ForeColor = (sys != null && sys.HasCoordinate) ? discoveryform.theme.VisitedSystemColor : discoveryform.theme.NonVisitedSystemColor;


                if (sys != null)
                {
                    if (sys.HasCoordinate)
                    {
                        dataGridViewExplore[2, rowindex].Value = sys.x.ToString("0.00");
                        dataGridViewExplore[3, rowindex].Value = sys.y.ToString("0.00");
                        dataGridViewExplore[4, rowindex].Value = sys.z.ToString("0.00");
                    }


                    dataGridViewExplore[idxVisits, rowindex].Value = hl.GetVisitsCount(sysname).ToString();

                    List <JournalScan> scans = hl.GetScans(sysname);
                    dataGridViewExplore[idxScans, rowindex].Value = scans.Count.ToString();

                    string pristar = "";
                    // Search for primary star
                    foreach (var scan in scans)
                    {
                        if (scan.IsStar && scan.DistanceFromArrivalLS == 0.0)
                        {
                            pristar = scan.StarType;
                            break;
                        }
                    }
                    dataGridViewExplore[idxPriStar, rowindex].Value = pristar;


                    string info = "";

                    foreach (var scan in scans)
                    {
                        if (scan.IsStar)
                        {
                            if (scan.StarTypeID == EDStar.AeBe)
                            {
                                info = info + " " + "AeBe";
                            }
                            if (scan.StarTypeID == EDStar.N)
                            {
                                info = info + " " + "NS";
                            }
                            if (scan.StarTypeID == EDStar.H)
                            {
                                info = info + " " + "BH";
                            }
                        }
                        else
                        {
                            if (scan.PlanetTypeID == EDPlanet.Earthlike_body)
                            {
                                info = info + " " + "ELW";
                            }
                            if (scan.PlanetTypeID == EDPlanet.Water_world)
                            {
                                info = info + " " + "WW";
                            }
                        }
                    }

                    dataGridViewExplore[idxInfo, rowindex].Value = info.Trim();


                    string          note = "";
                    SystemNoteClass sn   = SystemNoteClass.GetNoteOnSystem(sys.name, sys.id_edsm);
                    if (sn != null && !string.IsNullOrWhiteSpace(sn.Note))
                    {
                        note = sn.Note;
                    }
                    else
                    {
                        BookmarkClass bkmark = BookmarkClass.bookmarks.Find(x => x.StarName != null && x.StarName.Equals(sys.name));
                        if (bkmark != null && !string.IsNullOrWhiteSpace(bkmark.Note))
                        {
                            note = bkmark.Note;
                        }
                        else
                        {
                            var gmo = discoveryform.galacticMapping.Find(sys.name);
                            if (gmo != null && !string.IsNullOrWhiteSpace(gmo.description))
                            {
                                note = gmo.description;
                            }
                        }
                    }
                    dataGridViewExplore[idxNote, rowindex].Value = note.WordWrap(60);
                }

                if (sys == null && sysname != "")
                {
                    dataGridViewExplore.Rows[rowindex].ErrorText = "System not known";
                }
                else
                {
                    dataGridViewExplore.Rows[rowindex].ErrorText = "";
                }
            }
        }
예제 #16
0
        public static HistoryEntry FromJournalEntry(JournalEntry je, HistoryEntry prev, bool checkedsm, out bool journalupdate, SQLiteConnectionSystem conn = null, EDCommander cmdr = null)
        {
            ISystem isys    = prev == null ? new SystemClass("Unknown") : prev.System;
            int     indexno = prev == null ? 1 : prev.Indexno + 1;

            int mapcolour = 0;

            journalupdate = false;
            bool starposfromedsm = false;
            bool firstdiscover   = false;

            if (je.EventTypeID == JournalTypeEnum.Location || je.EventTypeID == JournalTypeEnum.FSDJump ||
                (je.EventTypeID == JournalTypeEnum.StartJump && (je as JournalStartJump)?.JumpType == "Hyperspace"))
            {
                JournalLocOrJump jl   = je as JournalLocOrJump;
                JournalFSDJump   jfsd = je as JournalFSDJump;
                JournalStartJump js   = je as JournalStartJump;

                ISystem newsys;

                if (jl != null && jl.HasCoordinate)       // LAZY LOAD IF it has a co-ord.. the front end will when it needs it
                {
                    newsys = new SystemClass(jl.StarSystem, jl.StarPos.X, jl.StarPos.Y, jl.StarPos.Z)
                    {
                        id_edsm         = jl.EdsmID < 0 ? 0 : jl.EdsmID, // pass across the EDSMID for the lazy load process.
                        faction         = jl.Faction,
                        government      = jl.EDGovernment,
                        primary_economy = jl.EDEconomy,
                        security        = jl.EDSecurity,
                        population      = jl.Population ?? 0,
                        state           = jl.EDState,
                        allegiance      = jl.EDAllegiance,
                        UpdateDate      = jl.EventTimeUTC,
                        status          = SystemStatusEnum.EDDiscovery,
                    };

                    if (jfsd != null && jfsd.JumpDist <= 0 && isys.HasCoordinate) // if we don't have a jump distance (pre 2.2) but the last sys does have pos, we can compute distance and update entry
                    {
                        jfsd.JumpDist = SystemClassDB.Distance(isys, newsys);     // fill it out here
                        journalupdate = true;
                    }

                    // If it was a new system, pass the coords back to the StartJump
                    if (prev != null && prev.System.name == newsys.name && !prev.System.HasCoordinate)
                    {
                        prev.System.x = newsys.x;
                        prev.System.y = newsys.y;
                        prev.System.z = newsys.z;
                    }
                }
                else
                {                           // Default one
                    string sysname = jl?.StarSystem ?? js?.StarSystem;

                    newsys         = new SystemClass(sysname);
                    newsys.id_edsm = je.EdsmID;

                    if (checkedsm)                                                                        // see if we can find the right system
                    {
                        ISystem s = SystemCache.FindEDSM(newsys, conn: conn, usedb: true, useedsm: true); // has no co-ord, did we find it?

                        if (s != null)                                                                    // yes, use, and update the journal with the esdmid, and also the position if we have a co-ord
                        {                                                                                 // so next time we don't have to do this again..
                            if (jl != null && jl.HasCoordinate)
                            {
                                s.x = Math.Round(jl.StarPos.X * 32.0) / 32.0;
                                s.y = Math.Round(jl.StarPos.Y * 32.0) / 32.0;
                                s.z = Math.Round(jl.StarPos.Z * 32.0) / 32.0;
                            }

                            newsys = s;

                            if (jfsd != null && jfsd.JumpDist <= 0 && newsys.HasCoordinate && isys.HasCoordinate) // if we don't have a jump distance (pre 2.2) but the last sys does, we can compute
                            {
                                jfsd.JumpDist = SystemClassDB.Distance(isys, newsys);                             // fill it out here.  EDSM systems always have co-ords, but we should check anyway
                                journalupdate = true;
                            }

                            if (je.EdsmID <= 0 && newsys.id_edsm > 0)
                            {
                                journalupdate = true;
                            }
                        }
                    }
                }

                if (jfsd != null)
                {
                    if (jfsd.JumpDist <= 0 && isys.HasCoordinate && newsys.HasCoordinate) // if no JDist, its a really old entry, and if previous has a co-ord
                    {
                        jfsd.JumpDist = SystemClassDB.Distance(isys, newsys);             // fill it out here
                        journalupdate = true;
                    }

                    mapcolour = jfsd.MapColor;
                }

                isys            = newsys;
                starposfromedsm = (jl != null && jl.HasCoordinate) ? jl.StarPosFromEDSM : newsys.HasCoordinate;
                firstdiscover   = jl == null ? false : jl.EDSMFirstDiscover;
            }

            string summary, info, detailed;

            je.FillInformation(out summary, out info, out detailed);

            HistoryEntry he = new HistoryEntry
            {
                Indexno             = indexno,
                EntryType           = je.EventTypeID,
                Journalid           = je.Id,
                journalEntry        = je,
                System              = isys,
                EventTimeUTC        = je.EventTimeUTC,
                MapColour           = mapcolour,
                EdsmSync            = je.SyncedEDSM,
                EDDNSync            = je.SyncedEDDN,
                EGOSync             = je.SyncedEGO,
                StartMarker         = je.StartMarker,
                StopMarker          = je.StopMarker,
                EventSummary        = summary,
                EventDescription    = info,
                EventDetailedInfo   = detailed,
                IsStarPosFromEDSM   = starposfromedsm,
                IsEDSMFirstDiscover = firstdiscover,
                Commander           = cmdr ?? EDCommander.GetCommander(je.CommanderId)
            };


            // WORK out docked/landed state

            if (prev != null)
            {
                if (prev.docked.HasValue)                   // copy docked..
                {
                    he.docked = prev.docked;
                }
                if (prev.landed.HasValue)
                {
                    he.landed = prev.landed;
                }
                if (prev.hyperspace.HasValue)
                {
                    he.hyperspace = prev.hyperspace;
                }

                he.shiptype          = prev.shiptype;
                he.shipid            = prev.shipid;
                he.whereami          = prev.whereami;
                he.onCrewWithCaptain = prev.onCrewWithCaptain;
                he.gamemode          = prev.gamemode;
                he.group             = prev.group;
            }

            if (je.EventTypeID == JournalTypeEnum.Location)
            {
                JournalLocation jl = je as JournalLocation;
                he.docked     = jl.Docked;
                he.whereami   = jl.Docked ? jl.StationName : jl.Body;
                he.hyperspace = false;
            }
            else if (je.EventTypeID == JournalTypeEnum.Docked)
            {
                JournalDocked jl = je as JournalDocked;
                he.docked   = true;
                he.whereami = jl.StationName;
            }
            else if (je.EventTypeID == JournalTypeEnum.Undocked)
            {
                he.docked = false;
            }
            else if (je.EventTypeID == JournalTypeEnum.Touchdown)
            {
                he.landed = true;
            }
            else if (je.EventTypeID == JournalTypeEnum.Liftoff)
            {
                he.landed = false;
            }
            else if (je.EventTypeID == JournalTypeEnum.SupercruiseEntry)
            {
                he.whereami   = (je as JournalSupercruiseEntry).StarSystem;
                he.hyperspace = true;
            }
            else if (je.EventTypeID == JournalTypeEnum.SupercruiseExit)
            {
                he.whereami   = (je as JournalSupercruiseExit).Body;
                he.hyperspace = false;
            }
            else if (je.EventTypeID == JournalTypeEnum.FSDJump)
            {
                he.whereami   = (je as JournalFSDJump).StarSystem;
                he.hyperspace = true;
            }
            else if (je.EventTypeID == JournalTypeEnum.StartJump)
            {
                he.hyperspace = true;   // some of these are just to make sure, as FSDJump will also set it
            }
            else if (je.EventTypeID == JournalTypeEnum.LoadGame)
            {
                JournalLoadGame jl = je as JournalLoadGame;

                he.onCrewWithCaptain = null;        // can't be in a crew at this point
                he.gamemode          = jl.GameMode; // set game mode
                he.group             = jl.Group;    // and group, may be empty
                he.landed            = jl.StartLanded;
                he.hyperspace        = false;

                if (jl.Ship.IndexOf("buggy", StringComparison.InvariantCultureIgnoreCase) == -1)        // load game with buggy, can't tell what ship we get back into, so ignore
                {
                    he.shiptype = (je as JournalLoadGame).Ship;
                    he.shipid   = (je as JournalLoadGame).ShipId;
                }
            }
            else if (je.EventTypeID == JournalTypeEnum.ShipyardBuy)         // BUY does not have ship id, but the new entry will that is written later - journals 8.34
            {
                he.shiptype = (je as JournalShipyardBuy).ShipType;
            }
            else if (je.EventTypeID == JournalTypeEnum.ShipyardNew)
            {
                he.shiptype = (je as JournalShipyardNew).ShipType;
                he.shipid   = (je as JournalShipyardNew).ShipId;
            }
            else if (je.EventTypeID == JournalTypeEnum.ShipyardSwap)
            {
                he.shiptype = (je as JournalShipyardSwap).ShipType;
                he.shipid   = (je as JournalShipyardSwap).ShipId;
            }
            else if (je.EventTypeID == JournalTypeEnum.JoinACrew)
            {
                he.onCrewWithCaptain = (je as JournalJoinACrew).Captain;
            }
            else if (je.EventTypeID == JournalTypeEnum.QuitACrew)
            {
                he.onCrewWithCaptain = null;
            }

            if (prev != null && prev.travelling)      // if we are travelling..
            {
                he.travelled_distance    = prev.travelled_distance;
                he.travelled_missingjump = prev.travelled_missingjump;
                he.travelled_jumps       = prev.travelled_jumps;

                if (he.IsFSDJump && !he.MultiPlayer)   // if jump, and not multiplayer..
                {
                    double dist = ((JournalFSDJump)je).JumpDist;
                    if (dist <= 0)
                    {
                        he.travelled_missingjump++;
                    }
                    else
                    {
                        he.travelled_distance += dist;
                        he.travelled_jumps++;
                    }
                }

                he.travelled_seconds = prev.travelled_seconds;
                TimeSpan diff = he.EventTimeUTC.Subtract(prev.EventTimeUTC);

                if (he.EntryType != JournalTypeEnum.LoadGame && diff < new TimeSpan(2, 0, 0))   // time between last entry and load game is not real time
                {
                    he.travelled_seconds += diff;
                }

                if (he.StopMarker || he.StartMarker)
                {
                    //Debug.WriteLine("Travelling stop at " + he.Indexno);
                    he.travelling         = false;
                    he.EventDetailedInfo += ((he.EventDetailedInfo.Length > 0) ? Environment.NewLine : "") + "Travelled " + he.travelled_distance.ToStringInvariant("0.0") + " LY"
                                            + ", " + he.travelled_jumps + " jumps"
                                            + ((he.travelled_missingjump > 0) ? ", " + he.travelled_missingjump + " unknown distance jumps" : "") +
                                            ", time " + he.travelled_seconds;

                    he.travelled_distance = 0;
                    he.travelled_seconds  = new TimeSpan(0);
                }
                else
                {
                    he.travelling = true;

                    if (he.IsFSDJump)
                    {
                        he.EventDetailedInfo += ((he.EventDetailedInfo.Length > 0) ? Environment.NewLine : "") + "Travelling" +
                                                " distance " + he.travelled_distance.ToString("0.0") + " LY"
                                                + ", " + he.travelled_jumps + " jumps"
                                                + ((he.travelled_missingjump > 0) ? ", " + he.travelled_missingjump + " unknown distance jumps" : "") +
                                                ", time " + he.travelled_seconds;
                    }
                }
            }

            if (he.StartMarker)
            {
                //Debug.WriteLine("Travelling start at " + he.Indexno);
                he.travelling = true;
            }

            return(he);
        }
예제 #17
0
        private void UpdateSystemRow(int rowindex)
        {
            if (rowindex < dataGridViewRouteSystems.Rows.Count &&
                dataGridViewRouteSystems[0, rowindex].Value != null)
            {
                string sysname = dataGridViewRouteSystems[0, rowindex].Value.ToString();
                var    sys     = GetSystem(sysname);
                dataGridViewRouteSystems[1, rowindex].Value = "";

                if (rowindex > 0 && rowindex < dataGridViewRouteSystems.Rows.Count &&
                    dataGridViewRouteSystems[0, rowindex - 1].Value != null &&
                    dataGridViewRouteSystems[0, rowindex].Value != null)
                {
                    string prevsysname = dataGridViewRouteSystems[0, rowindex - 1].Value.ToString();
                    var    prevsys     = GetSystem(prevsysname);

                    if (sys != null && prevsys != null)
                    {
                        double dist    = SystemClassDB.Distance(sys, prevsys);
                        string strdist = dist >= 0 ? ((double)dist).ToString("0.00") : "";
                        dataGridViewRouteSystems[1, rowindex].Value = strdist;
                    }
                }

                dataGridViewRouteSystems[0, rowindex].Tag = sys;
                dataGridViewRouteSystems.Rows[rowindex].DefaultCellStyle.ForeColor = (sys != null && sys.HasCoordinate) ? _discoveryForm.theme.VisitedSystemColor : _discoveryForm.theme.NonVisitedSystemColor;

                if (sys != null)
                {
                    string          note = "";
                    SystemNoteClass sn   = SystemNoteClass.GetNoteOnSystem(sys.name, sys.id_edsm);
                    if (sn != null && !string.IsNullOrWhiteSpace(sn.Note))
                    {
                        note = sn.Note;
                    }
                    else
                    {
                        BookmarkClass bkmark = BookmarkClass.bookmarks.Find(x => x.StarName != null && x.StarName.Equals(sys.name));
                        if (bkmark != null && !string.IsNullOrWhiteSpace(bkmark.Note))
                        {
                            note = bkmark.Note;
                        }
                        else
                        {
                            var gmo = _discoveryForm.galacticMapping.Find(sys.name);
                            if (gmo != null && !string.IsNullOrWhiteSpace(gmo.description))
                            {
                                note = gmo.description;
                            }
                        }
                    }
                    dataGridViewRouteSystems[2, rowindex].Value = note.WordWrap(60);
                }

                if (sys == null && sysname != "")
                {
                    dataGridViewRouteSystems.Rows[rowindex].ErrorText = "System not known to EDSM";
                }
                else
                {
                    dataGridViewRouteSystems.Rows[rowindex].ErrorText = "";
                }
            }
        }