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 <SystemClass> systems = rows.Select(r => r.Cells[0].Tag as SystemClass).ToList(); SystemClass sys0 = systems.FirstOrDefault(s => s != null && s.HasCoordinate); if (sys0 != null) { foreach (var sys in systems.Where(s => s != null)) { double dist = SystemClass.Distance(sys0, sys); if (dist > maxdist) { maxdist = dist; } } } return((float)maxdist); }
public void RefreshTargetDisplay() // 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; textBoxTargetDist.Text = "No Pos"; HistoryEntry cs = _discoveryForm.history.GetLastWithPosition; if (cs != null) { textBoxTargetDist.Text = SystemClass.Distance(cs.System, x, y, z).ToString("0.00"); } toolTipEddb.SetToolTip(textBoxTarget, "Position is " + x.ToString("0.00") + "," + y.ToString("0.00") + "," + z.ToString("0.00")); } else { textBoxTarget.Text = "Set target"; textBoxTargetDist.Text = ""; toolTipEddb.SetToolTip(textBoxTarget, "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"); } }
public ReferenceSystem(SystemClass refsys, SystemClass EstimatedPosition) { this.refSys = refsys; Azimuth = Math.Atan2(refSys.y - EstimatedPosition.y, refSys.x - EstimatedPosition.x); Distance = SystemClass.Distance(refSys, EstimatedPosition); Altitude = Math.Acos((refSys.z - EstimatedPosition.z) / Distance); }
private string DistToStar(HistoryEntry he, Point3D tpos) { string res = ""; if (!double.IsNaN(tpos.X)) { double dist = SystemClass.Distance(he.System, tpos.X, tpos.Y, tpos.Z); if (dist >= 0) { res = dist.ToString("0.00"); } } return(res); }
public void RefreshTarget(DataGridView vsc, List <VisitedSystemsClass> vscl) { SuspendLayout(); string name; double x, y, z; bool targetpresent = TargetClass.GetTargetPosition(out name, out x, out y, out z); if (vsc != null && targetpresent && (config & Configuration.showTargetLine) != 0) { SystemClass cs = VisitedSystemsClass.GetSystemClassFirstPosition(vscl); string dist = (cs != null) ? SystemClass.Distance(cs, x, y, z).ToString("0.00") : "Unknown"; List <ControlEntryProperties> cep = new List <ControlEntryProperties>(); int pos = 4 + (((config & Configuration.showEDSMButton) != 0) ? (int)(40 * tabscalar) : 0); cep.Add(new ControlEntryProperties(FontSel(vsc.Columns[1].DefaultCellStyle.Font, vsc.Font), ref pos, 60 * tabscalar, panel_grip.ForeColor, "Target:")); cep.Add(new ControlEntryProperties(FontSel(vsc.Columns[2].DefaultCellStyle.Font, vsc.Font), ref pos, 150 * tabscalar, panel_grip.ForeColor, name)); cep.Add(new ControlEntryProperties(FontSel(vsc.Columns[3].DefaultCellStyle.Font, vsc.Font), ref pos, 60 * tabscalar, panel_grip.ForeColor, dist)); if (statictoplines == 0) { int row = lt.Add(-1, cep, 0); // insert with rowid -1, at 0 lt.SetFormat(row, cep); statictoplines = 1; UpdateEventsOnControls(this); } else { lt.RefreshTextAtID(-1, cep); // just refresh data, with a row ID of -1 } } else { if (statictoplines == 1) { lt.RemoveAt(0); statictoplines = 0; } } labelExt_NoSystems.Visible = (lt.Count == statictoplines); ResumeLayout(); }
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 = SystemClass.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) { SystemNoteClass sn = SystemNoteClass.GetNoteOnSystem(sys.name, sys.id_edsm); dataGridViewRouteSystems[2, rowindex].Value = sn != null ? sn.Note : ""; } if (sys == null && sysname != "") { dataGridViewRouteSystems.Rows[rowindex].ErrorText = "System not known to EDSM"; } else { dataGridViewRouteSystems.Rows[rowindex].ErrorText = ""; } } }
private void buttonShow_Click(object sender, EventArgs e) { // Class not used broken for now due to systemdata removal. would need work, maybe a helper func in systemclass.cs #if false SystemClass sys = SystemClass.GetSystem(textBox_From.Text); if (sys == null) { return; } var syslist = (from c in SystemData.SystemList orderby(c.x - sys.x) * (c.x - sys.x) + (c.y - sys.y) * (c.y - sys.y) + (c.z - sys.z) * (c.z - sys.z) select c).ToList <SystemClass>(); dataGridView1.Rows.Clear(); dataGridView1.Columns.Clear(); dataGridView1.Columns.Add("Name", "Name"); dataGridView1.Columns.Add("Dist", "Dist"); dataGridView1.Columns.Add("Government", "Government"); dataGridView1.Columns.Add("Government", "Allegiance"); dataGridView1.Columns.Add("Government", "Population"); foreach (SystemClass sys2 in syslist) { double dist = SystemClass.Distance(sys, sys2); object[] rowobj = { sys2.name, dist.ToString("0.00"), sys2.government.ToString(), sys2.allegiance.ToString(), sys2.population }; int rownr; dataGridView1.Rows.Add(rowobj); rownr = dataGridView1.Rows.Count - 1; var cell = dataGridView1.Rows[rownr].Cells[1]; cell.Tag = sys2; } #endif }
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 = SystemClass.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 = Tools.WordWrap(note, 60); } if (sys == null && sysname != "") { dataGridViewRouteSystems.Rows[rowindex].ErrorText = "System not known to EDSM"; } else { dataGridViewRouteSystems.Rows[rowindex].ErrorText = ""; } } }
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; } if (hl.GetLast == null) { return; } ISystem currentSystem = hl.GetLast.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 = SystemClass.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 == EliteDangerous.EDStar.AeBe) { info = info + " " + "AeBe"; } if (scan.StarTypeID == EliteDangerous.EDStar.N) { info = info + " " + "NS"; } if (scan.StarTypeID == EliteDangerous.EDStar.H) { info = info + " " + "BH"; } } else { if (scan.PlanetTypeID == EliteDangerous.EDPlanet.Earthlike_body) { info = info + " " + "ELW"; } if (scan.PlanetTypeID == EliteDangerous.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 = Tools.WordWrap(note, 60); } if (sys == null && sysname != "") { dataGridViewExplore.Rows[rowindex].ErrorText = "System not known"; } else { dataGridViewExplore.Rows[rowindex].ErrorText = ""; } } }
public static HistoryEntry FromJournalEntry(EliteDangerous.JournalEntry je, HistoryEntry prev, bool checkedsm, out bool journalupdate, SQLiteConnectionSystem conn = 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; if (je.EventTypeID == EliteDangerous.JournalTypeEnum.Location || je.EventTypeID == EliteDangerous.JournalTypeEnum.FSDJump) { EDDiscovery.EliteDangerous.JournalEvents.JournalLocOrJump jl = je as EDDiscovery.EliteDangerous.JournalEvents.JournalLocOrJump; EDDiscovery.EliteDangerous.JournalEvents.JournalFSDJump jfsd = je as EDDiscovery.EliteDangerous.JournalEvents.JournalFSDJump; ISystem newsys; if (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); newsys.id_edsm = jl.EdsmID < 0 ? 0 : jl.EdsmID; // pass across the EDSMID for the lazy load process. if (jfsd != null && jfsd.JumpDist <= 0 && isys.HasCoordinate) // if we don't have a jump distance (pre 2.2) but the last sys does, we can compute { jfsd.JumpDist = SystemClass.Distance(isys, newsys); // fill it out here journalupdate = true; } } else { // Default one newsys = new SystemClass(jl.StarSystem); newsys.id_edsm = jl.EdsmID; if (checkedsm) // see if we can find the right system { SystemClass s = SystemClass.FindEDSM(newsys, conn); // 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.. 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 = SystemClass.Distance(isys, newsys); // fill it out here. EDSM systems always have co-ords, but we should check anyway journalupdate = true; } if (jl.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 = SystemClass.Distance(isys, newsys); // fill it out here journalupdate = true; } mapcolour = jfsd.MapColor; } isys = newsys; starposfromedsm = jl.HasCoordinate ? jl.StarPosFromEDSM : newsys.HasCoordinate; } 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, StartMarker = je.StartMarker, StopMarker = je.StopMarker, EventSummary = summary, EventDescription = info, EventDetailedInfo = detailed, IsStarPosFromEDSM = starposfromedsm }; if (prev != null && prev.travelling) // if we are travelling.. { he.travelled_distance = prev.travelled_distance; he.travelled_missingjump = prev.travelled_missingjump; if (he.IsFSDJump) { double dist = ((EliteDangerous.JournalEvents.JournalFSDJump)je).JumpDist; if (dist <= 0) { he.travelled_missingjump++; } else { he.travelled_distance += dist; } } he.travelled_seconds = prev.travelled_seconds; TimeSpan diff = he.EventTimeUTC.Subtract(prev.EventTimeUTC); if (he.EntryType != EliteDangerous.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) { he.travelling = false; he.EventDetailedInfo += ((he.EventDetailedInfo.Length > 0) ? Environment.NewLine : "") + "Travelled " + he.travelled_distance.ToString("0.0") + ((he.travelled_missingjump > 0) ? " LY(" + he.travelled_missingjump + " unknown distance jumps)" : " LY") + " time " + he.travelled_seconds; he.travelled_distance = 0; he.travelled_seconds = new TimeSpan(0); } else { he.travelling = true; he.EventDetailedInfo += ((he.EventDetailedInfo.Length > 0) ? Environment.NewLine : "") + "Travelling"; if (he.IsFSDJump) { he.EventDetailedInfo += " distance " + he.travelled_distance.ToString("0.0") + ((he.travelled_missingjump > 0) ? " LY (*)" : " LY"); } he.EventDetailedInfo += " time " + he.travelled_seconds; } } if (he.StartMarker) { he.travelling = true; } // 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; } he.wheredocked = prev.wheredocked; } if (je.EventTypeID == JournalTypeEnum.Location) { EliteDangerous.JournalEvents.JournalLocation jl = je as EliteDangerous.JournalEvents.JournalLocation; he.docked = jl.Docked; he.wheredocked = jl.Docked ? jl.StationName : ""; } else if (je.EventTypeID == JournalTypeEnum.Docked) { EliteDangerous.JournalEvents.JournalDocked jl = je as EliteDangerous.JournalEvents.JournalDocked; he.docked = true; he.wheredocked = 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.LoadGame) { he.landed = (je as EliteDangerous.JournalEvents.JournalLoadGame).StartLanded; } return(he); }
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.ControlHelpers.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.ControlHelpers.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 = SystemClass.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 EliteDangerous.JournalTypeEnum.FuelScoop: fuel = (he.journalEntry as EliteDangerous.JournalEvents.JournalFuelScoop).Total; break; case EliteDangerous.JournalTypeEnum.FSDJump: fuel = (he.journalEntry as EliteDangerous.JournalEvents.JournalFSDJump).FuelLevel; break; case EliteDangerous.JournalTypeEnum.RefuelAll: fuelhe = discoveryform.history.GetLastHistoryEntry(x => x.journalEntry.EventTypeID == JournalTypeEnum.FSDJump || x.journalEntry.EventTypeID == JournalTypeEnum.FuelScoop); if (fuelhe.journalEntry.EventTypeID == EliteDangerous.JournalTypeEnum.FSDJump) { fuel = (fuelhe.journalEntry as EliteDangerous.JournalEvents.JournalFSDJump).FuelLevel; } else { fuel = (fuelhe.journalEntry as EliteDangerous.JournalEvents.JournalFuelScoop).Total; } fuel += (he.journalEntry as EliteDangerous.JournalEvents.JournalRefuelAll).Amount; break; case EliteDangerous.JournalTypeEnum.RefuelPartial: fuelhe = discoveryform.history.GetLastHistoryEntry(x => x.journalEntry.EventTypeID == JournalTypeEnum.FSDJump || x.journalEntry.EventTypeID == JournalTypeEnum.FuelScoop); if (fuelhe.journalEntry.EventTypeID == EliteDangerous.JournalTypeEnum.FSDJump) { fuel = (fuelhe.journalEntry as EliteDangerous.JournalEvents.JournalFSDJump).FuelLevel; } else { fuel = (fuelhe.journalEntry as EliteDangerous.JournalEvents.JournalFuelScoop).Total; } fuel += (he.journalEntry as EliteDangerous.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 = RoutingUtils.maxJumpDistance(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 EliteDangerous.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(); } }
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 = SystemClass.Distance(he.System, homesys).ToString(SingleCoordinateFormat); textBoxSolDist.Text = SystemClass.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); } }
public static void UpdateVisitedSystemsEntries(VisitedSystemsClass item, VisitedSystemsClass item2, bool usedistancedb) // this is a split in two version with the same code of AddHistoryRow.. { SystemClass sys1 = SystemClass.GetSystem(item.Name); if (sys1 == null) { sys1 = new SystemClass(item.Name); if (item.HasTravelCoordinates) { sys1.x = item.X; sys1.y = item.Y; sys1.z = item.Z; } } SystemClass sys2 = null; if (item2 != null) { sys2 = SystemClass.GetSystem(item2.Name); if (sys2 == null) { sys2 = new SystemClass(item2.Name); if (item2.HasTravelCoordinates) { sys2.x = item2.X; sys2.y = item2.Y; sys2.z = item2.Z; } } } else { sys2 = null; } item.curSystem = sys1; item.prevSystem = sys2; string diststr = ""; if (sys2 != null) { double dist = usedistancedb ? SystemClass.DistanceIncludeDB(sys1, sys2) : SystemClass.Distance(sys1, sys2); if (dist > 0) { diststr = dist.ToString("0.00"); } } item.strDistance = diststr; }
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 = fieldfilter.FilterHistory(result, 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) ? SystemClass.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(); }
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]; SystemClass firstSystem = SystemClass.GetSystem(firstSystemName); SystemClass finalSystem = SystemClass.GetSystem(_currentRoute.Systems[_currentRoute.Systems.Count - 1]); if (finalSystem != null) { string mesg = "remain"; double distX = SystemClass.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); } SystemClass nearestSystem = null; double minDist = double.MaxValue; int nearestidx = -1; for (int i = 0; i < _currentRoute.Systems.Count; i++) { String sys = _currentRoute.Systems[i]; SystemClass sc = SystemClass.GetSystem(sys); if (sc == null) { continue; } double dist = SystemClass.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 = SystemClass.Distance(firstSystem, nearestSystem); double first2Me = SystemClass.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; } SystemClass nextSystem = SystemClass.GetSystem(name); if (nextSystem == null) { bottomLine = String.Format("WP{0}: {1} {2}", wp, nextName, autoCopyWPToolStripMenuItem.Checked ? " (AUTO)" : ""); } else { double distance = SystemClass.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); }