public static List <JournalScan> GetBodiesList(long edsmid) { try { if (DictEDSMBodies != null && DictEDSMBodies.ContainsKey(edsmid)) // Cache EDSM bidies during run of EDD. { return(DictEDSMBodies[edsmid]); } List <JournalScan> bodies = new List <JournalScan>(); EDSMClass edsm = new EDSMClass(); JObject jo = edsm.GetBodies(edsmid); // Colonia if (jo != null) { foreach (JObject bodie in jo["bodies"]) { try { EDSMClass.ConvertFromEDSMBodies(bodie); JournalScan js = new JournalScan(bodie); js.EdsmID = edsmid; bodies.Add(js); } catch (Exception ex) { BaseUtils.HttpCom.WriteLog($"Exception Loop: {ex.Message}", ""); BaseUtils.HttpCom.WriteLog($"ETrace: {ex.StackTrace}", ""); Trace.WriteLine($"Exception Loop: {ex.Message}"); Trace.WriteLine($"ETrace: {ex.StackTrace}"); } } DictEDSMBodies[edsmid] = bodies; return(bodies); } DictEDSMBodies[edsmid] = null; } catch (Exception ex) { Trace.WriteLine($"Exception: {ex.Message}"); Trace.WriteLine($"ETrace: {ex.StackTrace}"); return(null); } return(null); }
Point CreateMaterialNodes(List <PictureBoxHotspot.ImageElement> pc, JournalScan sn, Point matpos, Size matsize) { Point startpos = matpos; Point maximum = matpos; int noperline = 0; bool noncommon = checkBoxMaterialsRare.Checked; string matclicktext = sn.DisplayMaterials(2); foreach (KeyValuePair <string, double> sd in sn.Materials) { string abv = sd.Key.Substring(0, 1); string tooltip = sd.Key; Color fillc = Color.Yellow; MaterialCommodityDB mc = MaterialCommodityDB.GetCachedMaterial(sd.Key); if (mc != null) { abv = mc.shortname; fillc = mc.colour; tooltip = mc.name + " (" + mc.shortname + ") " + mc.type + " " + sd.Value.ToString("0.0") + "%"; if (noncommon && mc.type.IndexOf("common", StringComparison.InvariantCultureIgnoreCase) >= 0) { continue; } } CreateMaterialImage(pc, matpos, matsize, abv, tooltip + "\n\n" + "All " + matclicktext, tooltip, fillc, Color.Black); maximum = new Point(Math.Max(maximum.X, matpos.X + matsize.Width), Math.Max(maximum.Y, matpos.Y + matsize.Height)); if (++noperline == 4) { matpos = new Point(startpos.X, matpos.Y + matsize.Height + materialspacer); noperline = 0; } else { matpos.X += matsize.Width + materialspacer; } } return(maximum); }
private void ProcessBelts(JournalScan sc, ScanNode node) { if (sc.HasRings) { foreach (JournalScan.StarPlanetRing ring in sc.Rings) { ScanNode belt; string beltname = ring.Name; string stardesig = sc.BodyDesignation ?? sc.BodyName; if (beltname.StartsWith(stardesig, StringComparison.InvariantCultureIgnoreCase)) { beltname = beltname.Substring(stardesig.Length).Trim(); } else if (stardesig.ToLowerInvariant() == "lave" && beltname.ToLowerInvariant() == "castellan belt") { beltname = "A Belt"; } if (node.children == null || !node.children.TryGetValue(beltname, out belt)) { if (node.children == null) { node.children = new SortedList <string, ScanNode>(new DuplicateKeyComparer <string>()); } belt = new ScanNode { ownname = beltname, fullname = node.fullname + " " + beltname, customname = ring.Name, ScanData = null, BeltData = ring, children = null, type = ScanNodeType.belt, level = 1 }; node.children.Add(beltname, belt); } belt.BeltData = ring; } } }
private void buttonFind_Click(object sender, EventArgs e) { BaseUtils.ConditionLists cond = Valid(); if (cond != null) { this.Cursor = Cursors.WaitCursor; dataGridView.Rows.Clear(); DataGridViewColumn sortcol = dataGridView.SortedColumn != null ? dataGridView.SortedColumn : dataGridView.Columns[0]; SortOrder sortorder = dataGridView.SortedColumn != null ? dataGridView.SortOrder : SortOrder.Descending; ISystem cursystem = discoveryform.history.CurrentSystem; // could be null foreach (var he in discoveryform.history.FilterByScan) { JournalScan js = he.journalEntry as JournalScan; BaseUtils.Variables scandata = new BaseUtils.Variables(); scandata.AddPropertiesFieldsOfClass(js, "", new Type[] { typeof(System.Drawing.Icon), typeof(System.Drawing.Image), typeof(System.Drawing.Bitmap), typeof(Newtonsoft.Json.Linq.JObject) }, 5); bool?res = cond.CheckAll(scandata, out string errlist); // need function handler.. if (res.HasValue && res.Value == true) { ISystem sys = he.System; string sep = System.Globalization.CultureInfo.CurrentCulture.NumberFormat.NumberGroupSeparator + " "; object[] rowobj = { (EDDConfig.Instance.DisplayUTC ? he.EventTimeUTC : he.EventTimeLocal).ToString(), js.BodyName, js.DisplayString(0, true), (cursystem != null ? cursystem.Distance(sys).ToString("0.#") : ""), sys.X.ToString("0.#") + sep + sys.Y.ToString("0.#") + sep + sys.Z.ToString("0.#") }; dataGridView.Rows.Add(rowobj); dataGridView.Rows[dataGridView.Rows.Count - 1].Tag = sys; } } dataGridView.Sort(sortcol, (sortorder == SortOrder.Descending) ? ListSortDirection.Descending : ListSortDirection.Ascending); dataGridView.Columns[sortcol.Index].HeaderCell.SortGlyphDirection = sortorder; this.Cursor = Cursors.Default; } }
public JObject CreateEGOMessage(JournalScan journal, string starSystem, double x, double y, double z) { JObject detail = new JObject(); detail["input_1"] = ego_username; detail["input_2"] = ego_apikey; detail["input_3"] = application_id; detail["input_4"] = auth_code; detail["input_5"] = journal.GetJson().ToString().Replace("\"", "\\\""); detail["input_6"] = starSystem; detail["input_7"] = x; detail["input_8"] = y; detail["input_9"] = z; JObject msg = new JObject(); msg["input_values"] = detail; return(msg); }
private string InfoLine(ISystem sys, JournalScan sd) { var information = new StringBuilder(); if (sd.Mapped) { information.Append("\u2713"); // let the cmdr see that this body is already mapped - this is a check } string bodyname = sd.BodyName; // if [0] starts with [1], and there is more in [0] then [1], remove if (bodyname.StartsWith(sys.Name, StringComparison.InvariantCultureIgnoreCase) && bodyname.Length > sys.Name.Length) { bodyname = bodyname.Substring(sys.Name.Length).Trim(); } // Name information.Append(bodyname); // Additional information information.Append((sd.AmmoniaWorld) ? @" is an ammonia world.".T(EDTx.UserControlSurveyor_isanammoniaworld) : null); information.Append((sd.Earthlike) ? @" is an earth like world.".T(EDTx.UserControlSurveyor_isanearthlikeworld) : null); information.Append((sd.WaterWorld && !sd.Terraformable) ? @" is a water world.".T(EDTx.UserControlSurveyor_isawaterworld) : null); information.Append((sd.WaterWorld && sd.Terraformable) ? @" is a terraformable water world.".T(EDTx.UserControlSurveyor_isaterraformablewaterworld) : null); information.Append((sd.Terraformable && !sd.WaterWorld) ? @" is a terraformable planet.".T(EDTx.UserControlSurveyor_isaterraformableplanet) : null); information.Append((sd.HasRings) ? @" Has ring.".T(EDTx.UserControlSurveyor_Hasring) : null); information.Append((sd.HasMeaningfulVolcanism) ? @" Has ".T(EDTx.UserControlSurveyor_Has) + sd.Volcanism : null); information.Append((sd.nRadius < lowRadiusLimit) ? @" Low Radius.".T(EDTx.UserControlSurveyor_LowRadius) : null); information.Append(@" " + sd.DistanceFromArrivalText); if (sd.WasMapped == true && sd.WasDiscovered == true) { information.Append(" (Mapped & Discovered)".T(EDTx.UserControlSurveyor_MandD)); } else if (sd.WasMapped == true) { information.Append(" (Mapped)".T(EDTx.UserControlSurveyor_MP)); } else if (sd.WasDiscovered == true) { information.Append(" (Discovered)".T(EDTx.UserControlSurveyor_DIS)); } return(information.ToString()); }
public bool AddScanToBestSystem(JournalScan je, int startindex, List <HistoryEntry> hl, out HistoryEntry he, out JournalLocOrJump jl) { he = null; jl = null; if (je?.BodyName == null) { return(false); } // go thru the list of history entries looking for a Loc for (int j = startindex; j >= 0; j--) // same as FindBestSystem { he = hl[j]; if (he.IsLocOrJump) { jl = (JournalLocOrJump)he.journalEntry; // get the body designation, given the je/system name string designation = BodyDesignations.GetBodyDesignation(je, he.System.Name); System.Diagnostics.Debug.Assert(designation != null); // either the name/sys address matches, or the designation matches the star of the system name if (je.IsStarNameRelated(he.System.Name, he.System.SystemAddress, designation)) { je.BodyDesignation = designation; return(ProcessJournalScan(je, he.System, true)); } else if (jl.StarSystem != null && je.IsStarNameRelated(jl.StarSystem, jl.SystemAddress, designation)) // if we have a starsystem name, and its related, its a rename, ignore it { System.Diagnostics.Trace.WriteLine($"Rejecting body {designation} ({je.BodyName}) in system {he.System.Name} => {jl.StarSystem} due to system rename"); return(false); } } } je.BodyDesignation = BodyDesignations.GetBodyDesignation(je, hl[startindex].System.Name); return(ProcessJournalScan(je, hl[startindex].System, true)); // no relationship, add.. }
public JObject CreateEDDNMessage(JournalScan journal, string starSystem, double x, double y, double z) { JObject msg = new JObject(); msg["header"] = Header(); msg["$schemaRef"] = GetEDDNSchemaRef(); JObject message = (JObject)JObject.Parse(journal.EventDataString); message["StarSystem"] = starSystem; message["StarPos"] = new JArray(new float[] { (float)x, (float)y, (float)z }); if (!journal.BodyName.StartsWith(starSystem)) // For now test if its a different name ( a few exception for like sol system with named planets) To catch a rare out of sync bug in historylist. { return(null); } message = RemoveCommonKeys(message); msg["message"] = message; return(msg); }
private string InfoLine(ISystem sys, StarScan.ScanNode sn, JournalScan sd) { var information = new StringBuilder(); if (sd.Mapped) { information.Append("\u2713"); // let the cmdr see that this body is already mapped - this is a check } string bodyname = sd.BodyName.ReplaceIfStartsWith(sys.Name); // Name information.Append(bodyname); // Additional information information.Append((sd.AmmoniaWorld) ? @" is an ammonia world.".T(EDTx.UserControlSurveyor_isanammoniaworld) : null); information.Append((sd.Earthlike) ? @" is an earth like world.".T(EDTx.UserControlSurveyor_isanearthlikeworld) : null); information.Append((sd.WaterWorld && !sd.Terraformable) ? @" is a water world.".T(EDTx.UserControlSurveyor_isawaterworld) : null); information.Append((sd.WaterWorld && sd.Terraformable) ? @" is a terraformable water world.".T(EDTx.UserControlSurveyor_isaterraformablewaterworld) : null); information.Append((sd.Terraformable && !sd.WaterWorld) ? @" is a terraformable planet.".T(EDTx.UserControlSurveyor_isaterraformableplanet) : null); information.Append((sd.HasRings) ? @" Has ring.".T(EDTx.UserControlSurveyor_Hasring) : null); information.Append((sd.HasMeaningfulVolcanism) ? @" Has ".T(EDTx.UserControlSurveyor_Has) + sd.Volcanism + "." : null); information.Append((sd.nRadius < lowRadiusLimit) ? @" Low Radius.".T(EDTx.UserControlSurveyor_LowRadius) : null); information.Append((sn.Signals != null) ? " Has Signals.".T(EDTx.UserControlSurveyor_Signals) : null); information.Append(@" " + sd.DistanceFromArrivalText); if (sd.WasMapped == true && sd.WasDiscovered == true) { information.Append(" (Mapped & Discovered)".T(EDTx.UserControlSurveyor_MandD)); } else if (sd.WasMapped == true) { information.Append(" (Mapped)".T(EDTx.UserControlSurveyor_MP)); } else if (sd.WasDiscovered == true) { information.Append(" (Discovered)".T(EDTx.UserControlSurveyor_DIS)); } return(information.ToString()); }
private void CachePrimaryStar(JournalScan je, ISystem sys) { string system = sys.Name; if (!primaryStarScans.ContainsKey(system)) { primaryStarScans[system] = new List <JournalScan>(); } if (!primaryStarScans[system].Any(s => CompareEpsilon(s.nAge, je.nAge) && CompareEpsilon(s.nEccentricity, je.nEccentricity) && CompareEpsilon(s.nOrbitalInclination, je.nOrbitalInclination) && CompareEpsilon(s.nOrbitalPeriod, je.nOrbitalPeriod) && CompareEpsilon(s.nPeriapsis, je.nPeriapsis) && CompareEpsilon(s.nRadius, je.nRadius) && CompareEpsilon(s.nRotationPeriod, je.nRotationPeriod) && CompareEpsilon(s.nSemiMajorAxis, je.nSemiMajorAxis) && CompareEpsilon(s.nStellarMass, je.nStellarMass))) { primaryStarScans[system].Add(je); } }
// used by historylist directly for a single update during play, in foreground.. Also used by above.. so can be either in fore/back public bool AddScanToBestSystem(JournalScan je, int startindex, List <HistoryEntry> hl, out HistoryEntry he, out JournalLocOrJump jl) { if (je?.BodyName == null) { he = null; jl = null; return(false); } for (int j = startindex; j >= 0; j--) { he = hl[j]; if (he.IsLocOrJump) { jl = (JournalLocOrJump)he.journalEntry; string designation = GetBodyDesignation(je, he.System.Name); if (je.IsStarNameRelated(he.System.Name, designation, he.System.SystemAddress)) // if its part of the name, use it { je.BodyDesignation = designation; return(ProcessJournalScan(je, he.System, true)); } else if (jl != null && je.IsStarNameRelated(jl.StarSystem, designation, jl.SystemAddress)) { // Ignore scans where the system name has changed System.Diagnostics.Trace.WriteLine($"Rejecting body {designation} ({je.BodyName}) in system {he.System.Name} => {jl.StarSystem} due to system rename"); return(false); } } } jl = null; he = null; je.BodyDesignation = GetBodyDesignation(je, hl[startindex].System.Name); return(ProcessJournalScan(je, hl[startindex].System, true)); // no relationship, add.. }
public JObject CreateEDDNMessage(JournalScan journal, ISystem system) { JObject msg = new JObject(); msg["header"] = Header(); msg["$schemaRef"] = GetEDDNJournalSchemaRef(); JObject message = journal.GetJson(); message["StarSystem"] = system.Name; message["StarPos"] = new JArray(new float[] { (float)system.X, (float)system.Y, (float)system.Z }); if (system.SystemAddress != null) { message["SystemAddress"] = system.SystemAddress; } if (message["Materials"] != null && message["Materials"] is JArray) { foreach (JObject mmat in message["Materials"]) { mmat.Remove("Name_Localised"); } } string bodydesig = journal.BodyDesignation ?? journal.BodyName; if (!bodydesig.StartsWith(system.Name, StringComparison.InvariantCultureIgnoreCase)) // For now test if its a different name ( a few exception for like sol system with named planets) To catch a rare out of sync bug in historylist. { return(null); } message = RemoveCommonKeys(message); msg["message"] = message; return(msg); }
public JObject CreateEDDNMessage(JournalScan journal, string starSystem, double x, double y, double z) { JObject msg = new JObject(); msg["header"] = Header(); msg["$schemaRef"] = GetEDDNJournalSchemaRef(); JObject message = journal.GetJson(); message["StarSystem"] = starSystem; message["StarPos"] = new JArray(new float[] { (float)x, (float)y, (float)z }); string bodydesig = journal.BodyDesignation ?? journal.BodyName; if (!bodydesig.StartsWith(starSystem, StringComparison.InvariantCultureIgnoreCase)) // For now test if its a different name ( a few exception for like sol system with named planets) To catch a rare out of sync bug in historylist. { return(null); } message = RemoveCommonKeys(message); msg["message"] = message; return(msg); }
private void buttonExtExcel_Click(object sender, EventArgs e) { Forms.ExportForm frm = new Forms.ExportForm(); frm.Init(new string[] { "All", "Stars only", "Planets only", //2 "Exploration List Stars", //3 "Exploration List Planets", //4 "Sold Exploration Data", // 5 }); if (frm.ShowDialog(FindForm()) == DialogResult.OK) { BaseUtils.CSVWrite csv = new BaseUtils.CSVWrite(); csv.SetCSVDelimiter(frm.Comma); try { using (System.IO.StreamWriter writer = new System.IO.StreamWriter(frm.Path)) { if (frm.SelectedIndex == 5) { int count; List <HistoryEntry> data = HistoryList.FilterByJournalEvent(discoveryform.history.ToList(), "Sell Exploration Data", out count); data = (from he in data where he.EventTimeLocal >= frm.StartTime && he.EventTimeLocal <= frm.EndTime orderby he.EventTimeUTC descending select he).ToList(); List <HistoryEntry> scans = HistoryList.FilterByJournalEvent(discoveryform.history.ToList(), "Scan", out count); if (frm.IncludeHeader) { writer.Write(csv.Format("Time")); writer.Write(csv.Format("System")); writer.Write(csv.Format("Star type")); writer.Write(csv.Format("Planet type", false)); writer.WriteLine(); } foreach (HistoryEntry he in data) { JournalSellExplorationData jsed = he.journalEntry as JournalSellExplorationData; if (jsed == null || jsed.Discovered == null) { continue; } foreach (String system in jsed.Discovered) { writer.Write(csv.Format(jsed.EventTimeLocal)); writer.Write(csv.Format(system)); EDStar star = EDStar.Unknown; EDPlanet planet = EDPlanet.Unknown_Body_Type; foreach (HistoryEntry scanhe in scans) { JournalScan scan = scanhe.journalEntry as JournalScan; if (scan.BodyName.Equals(system, StringComparison.OrdinalIgnoreCase)) { star = scan.StarTypeID; planet = scan.PlanetTypeID; break; } } writer.Write(csv.Format((star != EDStar.Unknown) ? Enum.GetName(typeof(EDStar), star) : "")); writer.Write(csv.Format((planet != EDPlanet.Unknown_Body_Type) ? Enum.GetName(typeof(EDPlanet), planet) : "", false)); writer.WriteLine(); } } } else { List <JournalScan> scans = null; if (frm.SelectedIndex < 3) { var entries = JournalEntry.GetByEventType(JournalTypeEnum.Scan, EDCommander.CurrentCmdrID, frm.StartTime, frm.EndTime); scans = entries.ConvertAll(x => (JournalScan)x); } else { ExplorationSetClass currentExplorationSet = new ExplorationSetClass(); string file = currentExplorationSet.DialogLoad(FindForm()); if (file != null) { scans = new List <JournalScan>(); foreach (string system in currentExplorationSet.Systems) { ISystem sys = SystemCache.FindSystem(system); if (sys != null) { List <JournalScan> sysscans = EDSMClass.GetBodiesList(sys.EDSMID); if (sysscans != null) { scans.AddRange(sysscans); } } } } else { return; } } bool ShowStars = frm.SelectedIndex < 2 || frm.SelectedIndex == 3; bool ShowPlanets = frm.SelectedIndex == 0 || frm.SelectedIndex == 2 || frm.SelectedIndex == 4; List <JournalSAAScanComplete> mappings = ShowPlanets ? JournalEntry.GetByEventType(JournalTypeEnum.SAAScanComplete, EDCommander.CurrentCmdrID, frm.StartTime, frm.EndTime) .ConvertAll(x => (JournalSAAScanComplete)x) : null; if (frm.IncludeHeader) { // Write header writer.Write(csv.Format("Time")); writer.Write(csv.Format("BodyName")); writer.Write(csv.Format("Estimated Value")); writer.Write(csv.Format("DistanceFromArrivalLS")); writer.Write(csv.Format("WasMapped")); writer.Write(csv.Format("WasDiscovered")); if (ShowStars) { writer.Write(csv.Format("StarType")); writer.Write(csv.Format("StellarMass")); writer.Write(csv.Format("AbsoluteMagnitude")); writer.Write(csv.Format("Age MY")); writer.Write(csv.Format("Luminosity")); } writer.Write(csv.Format("Radius")); writer.Write(csv.Format("RotationPeriod")); writer.Write(csv.Format("SurfaceTemperature")); if (ShowPlanets) { writer.Write(csv.Format("TidalLock")); writer.Write(csv.Format("TerraformState")); writer.Write(csv.Format("PlanetClass")); writer.Write(csv.Format("Atmosphere")); writer.Write(csv.Format("Iron")); writer.Write(csv.Format("Silicates")); writer.Write(csv.Format("SulphurDioxide")); writer.Write(csv.Format("CarbonDioxide")); writer.Write(csv.Format("Nitrogen")); writer.Write(csv.Format("Oxygen")); writer.Write(csv.Format("Water")); writer.Write(csv.Format("Argon")); writer.Write(csv.Format("Ammonia")); writer.Write(csv.Format("Methane")); writer.Write(csv.Format("Hydrogen")); writer.Write(csv.Format("Helium")); writer.Write(csv.Format("Volcanism")); writer.Write(csv.Format("SurfaceGravity")); writer.Write(csv.Format("SurfacePressure")); writer.Write(csv.Format("Landable")); writer.Write(csv.Format("EarthMasses")); writer.Write(csv.Format("IcePercent")); writer.Write(csv.Format("RockPercent")); writer.Write(csv.Format("MetalPercent")); } // Common orbital param writer.Write(csv.Format("SemiMajorAxis")); writer.Write(csv.Format("Eccentricity")); writer.Write(csv.Format("OrbitalInclination")); writer.Write(csv.Format("Periapsis")); writer.Write(csv.Format("OrbitalPeriod")); writer.Write(csv.Format("AxialTilt")); if (ShowPlanets) { writer.Write(csv.Format("Carbon")); writer.Write(csv.Format("Iron")); writer.Write(csv.Format("Nickel")); writer.Write(csv.Format("Phosphorus")); writer.Write(csv.Format("Sulphur")); writer.Write(csv.Format("Arsenic")); writer.Write(csv.Format("Chromium")); writer.Write(csv.Format("Germanium")); writer.Write(csv.Format("Manganese")); writer.Write(csv.Format("Selenium")); writer.Write(csv.Format("Vanadium")); writer.Write(csv.Format("Zinc")); writer.Write(csv.Format("Zirconium")); writer.Write(csv.Format("Cadmium")); writer.Write(csv.Format("Mercury")); writer.Write(csv.Format("Molybdenum")); writer.Write(csv.Format("Niobium")); writer.Write(csv.Format("Tin")); writer.Write(csv.Format("Tungsten")); writer.Write(csv.Format("Antimony")); writer.Write(csv.Format("Polonium")); writer.Write(csv.Format("Ruthenium")); writer.Write(csv.Format("Technetium")); writer.Write(csv.Format("Tellurium")); writer.Write(csv.Format("Yttrium")); } writer.WriteLine(); } foreach (JournalScan je in scans) { JournalScan scan = je as JournalScan; if (ShowPlanets == true && !string.IsNullOrEmpty(scan.PlanetClass)) { var mapping = mappings?.FirstOrDefault(m => m.BodyID == scan.BodyID); if (mapping != null) { scan.SetMapped(true, mapping.ProbesUsed <= mapping.EfficiencyTarget); } } if (ShowPlanets == false) // Then only show stars. { if (String.IsNullOrEmpty(scan.StarType)) { continue; } } if (ShowStars == false) // Then only show planets { if (String.IsNullOrEmpty(scan.PlanetClass)) { continue; } } writer.Write(csv.Format(scan.EventTimeUTC)); writer.Write(csv.Format(scan.BodyName)); writer.Write(csv.Format(scan.EstimatedValue)); writer.Write(csv.Format(scan.DistanceFromArrivalLS)); writer.Write(csv.Format(scan.WasMapped)); writer.Write(csv.Format(scan.WasDiscovered)); if (ShowStars) { writer.Write(csv.Format(scan.StarType)); writer.Write(csv.Format((scan.nStellarMass.HasValue) ? scan.nStellarMass.Value : 0)); writer.Write(csv.Format((scan.nAbsoluteMagnitude.HasValue) ? scan.nAbsoluteMagnitude.Value : 0)); writer.Write(csv.Format((scan.nAge.HasValue) ? scan.nAge.Value : 0)); writer.Write(csv.Format(scan.Luminosity)); } writer.Write(csv.Format(scan.nRadius.HasValue ? scan.nRadius.Value : 0)); writer.Write(csv.Format(scan.nRotationPeriod.HasValue ? scan.nRotationPeriod.Value : 0)); writer.Write(csv.Format(scan.nSurfaceTemperature.HasValue ? scan.nSurfaceTemperature.Value : 0)); if (ShowPlanets) { writer.Write(csv.Format(scan.nTidalLock.HasValue ? scan.nTidalLock.Value : false)); writer.Write(csv.Format((scan.TerraformState != null) ? scan.TerraformState : "")); writer.Write(csv.Format((scan.PlanetClass != null) ? scan.PlanetClass : "")); writer.Write(csv.Format((scan.Atmosphere != null) ? scan.Atmosphere : "")); writer.Write(csv.Format(scan.GetAtmosphereComponent("Iron"))); writer.Write(csv.Format(scan.GetAtmosphereComponent("Silicates"))); writer.Write(csv.Format(scan.GetAtmosphereComponent("SulphurDioxide"))); writer.Write(csv.Format(scan.GetAtmosphereComponent("CarbonDioxide"))); writer.Write(csv.Format(scan.GetAtmosphereComponent("Nitrogen"))); writer.Write(csv.Format(scan.GetAtmosphereComponent("Oxygen"))); writer.Write(csv.Format(scan.GetAtmosphereComponent("Water"))); writer.Write(csv.Format(scan.GetAtmosphereComponent("Argon"))); writer.Write(csv.Format(scan.GetAtmosphereComponent("Ammonia"))); writer.Write(csv.Format(scan.GetAtmosphereComponent("Methane"))); writer.Write(csv.Format(scan.GetAtmosphereComponent("Hydrogen"))); writer.Write(csv.Format(scan.GetAtmosphereComponent("Helium"))); writer.Write(csv.Format((scan.Volcanism != null) ? scan.Volcanism : "")); writer.Write(csv.Format(scan.nSurfaceGravity.HasValue ? scan.nSurfaceGravity.Value : 0)); writer.Write(csv.Format(scan.nSurfacePressure.HasValue ? scan.nSurfacePressure.Value : 0)); writer.Write(csv.Format(scan.nLandable.HasValue ? scan.nLandable.Value : false)); writer.Write(csv.Format((scan.nMassEM.HasValue) ? scan.nMassEM.Value : 0)); writer.Write(csv.Format(scan.GetCompositionPercent("Ice"))); writer.Write(csv.Format(scan.GetCompositionPercent("Rock"))); writer.Write(csv.Format(scan.GetCompositionPercent("Metal"))); } // Common orbital param writer.Write(csv.Format(scan.nSemiMajorAxis.HasValue ? scan.nSemiMajorAxis.Value : 0)); writer.Write(csv.Format(scan.nEccentricity.HasValue ? scan.nEccentricity.Value : 0)); writer.Write(csv.Format(scan.nOrbitalInclination.HasValue ? scan.nOrbitalInclination.Value : 0)); writer.Write(csv.Format(scan.nPeriapsis.HasValue ? scan.nPeriapsis.Value : 0)); writer.Write(csv.Format(scan.nOrbitalPeriod.HasValue ? scan.nOrbitalPeriod.Value : 0)); writer.Write(csv.Format(scan.nAxialTilt.HasValue ? scan.nAxialTilt : null)); if (ShowPlanets) { writer.Write(csv.Format(scan.GetMaterial("Carbon"))); writer.Write(csv.Format(scan.GetMaterial("Iron"))); writer.Write(csv.Format(scan.GetMaterial("Nickel"))); writer.Write(csv.Format(scan.GetMaterial("Phosphorus"))); writer.Write(csv.Format(scan.GetMaterial("Sulphur"))); writer.Write(csv.Format(scan.GetMaterial("Arsenic"))); writer.Write(csv.Format(scan.GetMaterial("Chromium"))); writer.Write(csv.Format(scan.GetMaterial("Germanium"))); writer.Write(csv.Format(scan.GetMaterial("Manganese"))); writer.Write(csv.Format(scan.GetMaterial("Selenium"))); writer.Write(csv.Format(scan.GetMaterial("Vanadium"))); writer.Write(csv.Format(scan.GetMaterial("Zinc"))); writer.Write(csv.Format(scan.GetMaterial("Zirconium"))); writer.Write(csv.Format(scan.GetMaterial("Cadmium"))); writer.Write(csv.Format(scan.GetMaterial("Mercury"))); writer.Write(csv.Format(scan.GetMaterial("Molybdenum"))); writer.Write(csv.Format(scan.GetMaterial("Niobium"))); writer.Write(csv.Format(scan.GetMaterial("Tin"))); writer.Write(csv.Format(scan.GetMaterial("Tungsten"))); writer.Write(csv.Format(scan.GetMaterial("Antimony"))); writer.Write(csv.Format(scan.GetMaterial("Polonium"))); writer.Write(csv.Format(scan.GetMaterial("Ruthenium"))); writer.Write(csv.Format(scan.GetMaterial("Technetium"))); writer.Write(csv.Format(scan.GetMaterial("Tellurium"))); writer.Write(csv.Format(scan.GetMaterial("Yttrium"))); } writer.WriteLine(); } } writer.Close(); if (frm.AutoOpen) { System.Diagnostics.Process.Start(frm.Path); } } } catch { ExtendedControls.MessageBoxTheme.Show(FindForm(), "Failed to write to " + frm.Path, "Export Failed", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } }
string Infoline(List <HistoryEntry> syslist) { string infostr = ""; string jumponium = ""; bool hasMaterials = false; if (syslist.Count > 1) { infostr = string.Format("First visit {0}".Tx(this, "FV"), syslist.Last().EventTimeLocal.ToShortDateString()); } HistoryEntry he = syslist[0]; StarScan.SystemNode node = discoveryform.history.starscan?.FindSystem(he.System, false); #region information if (node != null) { if (node.starnodes != null) { infostr = infostr.AppendPrePad(string.Format("{0} Star(s)".Tx(this, "CS"), node.starnodes.Count), Environment.NewLine); string extrainfo = ""; string prefix = Environment.NewLine; int total = 0; foreach (StarScan.ScanNode sn in node.Bodies) { total++; if (sn.ScanData != null && checkBoxBodyClasses.Checked) { JournalScan sc = sn.ScanData; if (sc.IsStar) // brief notification for special or uncommon celestial bodies, useful to traverse the history and search for that special body you discovered. { // Sagittarius A* is a special body: is the centre of the Milky Way, and the only one which is classified as a Super Massive Black Hole. As far as we know... if (sc.StarTypeID == EDStar.SuperMassiveBlackHole) { extrainfo = extrainfo.AppendPrePad(string.Format("{0} is a super massive black hole".Tx(this, "SMBH"), sc.BodyName), prefix); } // black holes if (sc.StarTypeID == EDStar.H) { extrainfo = extrainfo.AppendPrePad(string.Format("{0} is a black hole".Tx(this, "BH"), sc.BodyName), prefix); } // neutron stars if (sc.StarTypeID == EDStar.N) { extrainfo = extrainfo.AppendPrePad(string.Format("{0} is a neutron star".Tx(this, "NS"), sc.BodyName), prefix); } // white dwarf (D, DA, DAB, DAO, DAZ, DAV, DB, DBZ, DBV, DO, DOV, DQ, DC, DCV, DX) string WhiteDwarf = "White Dwarf"; if (sc.StarTypeText.Contains(WhiteDwarf)) { extrainfo = extrainfo.AppendPrePad(string.Format("{0} is a {1} white dwarf star".Tx(this, "WD"), sc.BodyName, sc.StarTypeID), prefix); } // wolf rayet (W, WN, WNC, WC, WO) string WolfRayet = "Wolf-Rayet"; if (sc.StarTypeText.Contains(WolfRayet)) { extrainfo = extrainfo.AppendPrePad(string.Format("{0} is a {1} wolf-rayet star".Tx(this, "WR"), sc.BodyName, sc.StarTypeID), prefix); } // giants. It should recognize all classes of giants. if (sc.StarTypeText.Contains("Giant")) { extrainfo = extrainfo.AppendPrePad(string.Format("{0} is a {1}".Tx(this, "OTHER"), sc.BodyName, sc.StarTypeText), prefix); } // rogue planets - not sure if they really exists, but they are in the journal, so... if (sc.StarTypeID == EDStar.RoguePlanet) { extrainfo = extrainfo.AppendPrePad(string.Format("{0} is a rogue planet".Tx(this, "RP"), sc.BodyName), prefix); } } else { // Check if a non-star body is a moon or not. We want it to further refine our brief summary in the visited star list. // To avoid duplicates, we need to apply our filters before on the bodies recognized as a moon, than do the same for the other bodies that do not fulfill that criteria. if (sn.level >= 2 && sn.type == StarScan.ScanNodeType.body) // Tell us that that special body is a moon. After all, it can be quite an outstanding discovery... { // Earth-like moon if (sc.PlanetTypeID == EDPlanet.Earthlike_body) { extrainfo = extrainfo.AppendPrePad(string.Format("{0} is an earth like moon".Tx(this, "ELM"), sc.BodyName), prefix); } // Terraformable water moon if (sc.Terraformable == true && sc.PlanetTypeID == EDPlanet.Water_world) { extrainfo = extrainfo.AppendPrePad(string.Format("{0} is a terraformable water moon".Tx(this, "TWM"), sc.BodyName), prefix); } // Water moon if (sc.Terraformable == false && sc.PlanetTypeID == EDPlanet.Water_world) { extrainfo = extrainfo.AppendPrePad(string.Format("{0} is a water moon".Tx(this, "WM"), sc.BodyName), prefix); } // Terraformable moon if (sc.Terraformable == true && sc.PlanetTypeID != EDPlanet.Water_world) { extrainfo = extrainfo.AppendPrePad(string.Format("{0} is a terraformable moon".Tx(this, "TM"), sc.BodyName), prefix); } // Ammonia moon if (sc.PlanetTypeID == EDPlanet.Ammonia_world) { extrainfo = extrainfo.AppendPrePad(string.Format("{0} is an ammonia moon".Tx(this, "AM"), sc.BodyName), prefix); } } else // Do the same, for all planets { // Earth Like planet if (sc.PlanetTypeID == EDPlanet.Earthlike_body) { extrainfo = extrainfo.AppendPrePad(string.Format("{0} is an earth like planet".Tx(this, "ELP"), sc.BodyName), prefix); } // Terraformable water world if (sc.PlanetTypeID == EDPlanet.Water_world && sc.Terraformable == true) { extrainfo = extrainfo.AppendPrePad(string.Format("{0} is a terraformable water world".Tx(this, "TWW"), sc.BodyName), prefix); } // Water world if (sc.PlanetTypeID == EDPlanet.Water_world && sc.Terraformable == false) { extrainfo = extrainfo.AppendPrePad(string.Format("{0} is a water world".Tx(this, "WW"), sc.BodyName), prefix); } // Terraformable planet if (sc.Terraformable == true && sc.PlanetTypeID != EDPlanet.Water_world) { extrainfo = extrainfo.AppendPrePad(string.Format("{0} is a terraformable planet".Tx(this, "TP"), sc.BodyName), prefix); } // Ammonia world if (sc.PlanetTypeID == EDPlanet.Ammonia_world) { extrainfo = extrainfo.AppendPrePad(string.Format("{0} is an ammonia world".Tx(this, "AW"), sc.BodyName), prefix); } } } } // Landable bodies with valuable materials if (sn.ScanData != null && sn.ScanData.IsLandable == true && sn.ScanData.HasMaterials && checkBoxJumponium.Checked == true) { hasMaterials = true; int basic = 0; int standard = 0; int premium = 0; foreach (KeyValuePair <string, double> mat in sn.ScanData.Materials) { string usedin = Recipes.UsedInSythesisByFDName(mat.Key); if (usedin.Contains("FSD-Basic")) { basic++; } if (usedin.Contains("FSD-Standard")) { standard++; } if (usedin.Contains("FSD-Premium")) { premium++; } } // string MaterialsBrief = sn.ScanData.DisplayMaterials(4).ToString(); //System.Diagnostics.Debug.WriteLine("{0} {1} {2} {3} {4}", sn.fullname , basic, standard, premium, MaterialsBrief); if (basic > 0 || standard > 0 || premium > 0) { int mats = basic + standard + premium; StringBuilder jumpLevel = new StringBuilder(); if (basic != 0) { jumpLevel.AppendPrePad(basic + "/" + Recipes.FindSynthesis("FSD", "Basic").Count + " Basic".Tx(this, "BFSD"), ", "); } if (standard != 0) { jumpLevel.AppendPrePad(standard + "/" + Recipes.FindSynthesis("FSD", "Standard").Count + " Standard".Tx(this, "SFSD"), ", "); } if (premium != 0) { jumpLevel.AppendPrePad(premium + "/" + Recipes.FindSynthesis("FSD", "Premium").Count + " Premium".Tx(this, "PFSD"), ", "); } jumponium = jumponium.AppendPrePad(Environment.NewLine + string.Format("{0} has {1} level elements.".Tx(this, "LE"), sn.ScanData.BodyName, jumpLevel)); } } } total -= node.starnodes.Count; if (total > 0) { // tell us that a system has other bodies, and how much, beside stars infostr = infostr.AppendPrePad(string.Format("{0} Other bodies".Tx(this, "OB"), total.ToStringInvariant()), ", "); infostr = infostr.AppendPrePad(extrainfo, prefix); } else { // we need this to allow the panel to scan also through systems which has only stars infostr = infostr.AppendPrePad(extrainfo, prefix); } if (hasMaterials == true && checkBoxJumponium.Checked == true) { infostr = infostr.AppendPrePad(Environment.NewLine + Environment.NewLine + "This system has materials for FSD boost: ".Tx(this, "FSD")); infostr = infostr.AppendPrePad(jumponium); } } } return(infostr); }
// returns null if EDSM says not there, else if returns list of bodies and a flag indicating if from cache. // all this is done in a lock inside a task - the only way to sequence the code and prevent multiple lookups in an await structure // so we must pass back all the info we can to tell the caller what happened. // optional call back is allowed in lock - may not be used. // Verified Nov 20 public static Tuple <List <JournalScan>, bool> GetBodiesList(ISystem sys, bool edsmweblookup = true, Action <List <JournalScan>, ISystem> onnewbodies = null) { try { lock (bodylock) // only one request at a time going, this is to prevent multiple requests for the same body { // System.Threading.Thread.Sleep(2000); //debug - delay to show its happening // System.Diagnostics.Debug.WriteLine("EDSM Cache check " + sys.EDSMID + " " + sys.SystemAddress + " " + sys.Name); if (DictEDSMBodies != null && sys.EDSMID > 0 && DictEDSMBodies.ContainsKey(sys.EDSMID)) // Cache EDSM bidies during run of EDD. { System.Diagnostics.Debug.WriteLine("Found sys.EDSMID " + sys.EDSMID); return(new Tuple <List <JournalScan>, bool>(DictEDSMBodies[sys.EDSMID], true)); } else if (DictEDSMBodiesByID64 != null && sys.SystemAddress != null && sys.SystemAddress > 0 && DictEDSMBodiesByID64.ContainsKey(sys.SystemAddress.Value)) { System.Diagnostics.Debug.WriteLine("Found sys.EDSMID64 " + sys.SystemAddress.Value); return(new Tuple <List <JournalScan>, bool>(DictEDSMBodiesByID64[sys.SystemAddress.Value], true)); } if (!edsmweblookup) // must be set for a web lookup { return(null); } System.Diagnostics.Debug.WriteLine("EDSM Web lookup"); List <JournalScan> bodies = new List <JournalScan>(); EDSMClass edsm = new EDSMClass(); JObject jo = null; if (sys.EDSMID > 0) { jo = edsm.GetBodies(sys.EDSMID); // Colonia } else if (sys.SystemAddress != null && sys.SystemAddress > 0) { jo = edsm.GetBodiesByID64(sys.SystemAddress.Value); } else if (sys.Name != null) { jo = edsm.GetBodies(sys.Name); } if (jo != null && jo["bodies"] != null) { foreach (JObject edsmbody in jo["bodies"]) { try { JObject jbody = EDSMClass.ConvertFromEDSMBodies(edsmbody); JournalScan js = new JournalScan(jbody);//TBD, sys.EDSMID); bodies.Add(js); } catch (Exception ex) { BaseUtils.HttpCom.WriteLog($"Exception Loop: {ex.Message}", ""); BaseUtils.HttpCom.WriteLog($"ETrace: {ex.StackTrace}", ""); Trace.WriteLine($"Exception Loop: {ex.Message}"); Trace.WriteLine($"ETrace: {ex.StackTrace}"); } } if (sys.EDSMID > 0) { DictEDSMBodies[sys.EDSMID] = bodies; } if (sys.SystemAddress != null && sys.SystemAddress > 0) { DictEDSMBodiesByID64[sys.SystemAddress.Value] = bodies; } System.Diagnostics.Debug.WriteLine("EDSM Web Lookup complete " + sys.Name + " " + bodies.Count); onnewbodies?.Invoke(bodies, sys); // inside the lock, with new bodies, allow it to do processsing. return(new Tuple <List <JournalScan>, bool>(bodies, false)); } if (sys.EDSMID > 0) { DictEDSMBodies[sys.EDSMID] = null; } if (sys.SystemAddress != null && sys.SystemAddress > 0) { DictEDSMBodiesByID64[sys.SystemAddress.Value] = null; } } } catch (Exception ex) { Trace.WriteLine($"Exception: {ex.Message}"); Trace.WriteLine($"ETrace: {ex.StackTrace}"); return(null); } return(null); }
Dictionary <Bitmap, float> imageintensities = new Dictionary <Bitmap, float>(); // cached // return right bottom of area used from curpos Point DrawNode(List <ExtPictureBox.ImageElement> pc, StarScan.ScanNode sn, MaterialCommoditiesList curmats, // curmats may be null HistoryList hl, Image notscanned, // image if sn is not known Point position, // position is normally left/middle, unless xiscentre is set. bool xiscentre, out Rectangle imagepos, Size size, // nominal size DrawLevel drawtype, // drawing.. Color?backwash = null, // optional back wash on image string appendlabeltext = "" // any label text to append ) { string tip; Point endpoint = position; imagepos = Rectangle.Empty; JournalScan sc = sn.ScanData; if (sc != null && (!sc.IsEDSMBody || CheckEDSM)) // has a scan and its our scan, or we are showing EDSM { if (sn.NodeType != StarScan.ScanNodeType.ring) // not rings { tip = sc.DisplayString(historicmatlist: curmats, currentmatlist: hl.GetLast?.MaterialCommodity); if (sn.Signals != null) { tip += "\n" + "Signals".T(EDTx.ScanDisplayUserControl_Signals) + ":\n" + JournalSAASignalsFound.SignalList(sn.Signals, 4, "\n"); } Bitmap nodeimage = (Bitmap)(sc.IsStar ? sc.GetStarTypeImage() : sc.GetPlanetClassImage()); string overlaytext = ""; var nodelabels = new string[2] { "", "" }; nodelabels[0] = sn.CustomNameOrOwnname; if (sc.IsEDSMBody) { nodelabels[0] = "_" + nodelabels[0]; } if (sc.IsStar) { if (ShowStarClasses) { overlaytext = sc.StarClassificationAbv; } if (sc.nStellarMass.HasValue) { nodelabels[1] = nodelabels[1].AppendPrePad($"{sc.nStellarMass.Value:N2} SM", Environment.NewLine); } if (drawtype == DrawLevel.TopLevelStar) { if (sc.nAge.HasValue) { nodelabels[1] = nodelabels[1].AppendPrePad($"{sc.nAge.Value:N0} MY", Environment.NewLine); } if (ShowHabZone) { var habZone = sc.GetHabZoneStringLs(); if (habZone.HasChars()) { nodelabels[1] = nodelabels[1].AppendPrePad($"{habZone}", Environment.NewLine); } } } } else { if (ShowPlanetClasses) { overlaytext = Bodies.PlanetAbv(sc.PlanetTypeID); } if ((sn.ScanData.IsLandable || ShowAllG) && sn.ScanData.nSurfaceGravity != null) { nodelabels[1] = nodelabels[1].AppendPrePad($"{(sn.ScanData.nSurfaceGravity / JournalScan.oneGee_m_s2):N2}g", Environment.NewLine); } } if (ShowDist) { if (drawtype != DrawLevel.MoonLevel) // other than moons { if (sn.ScanData.IsOrbitingBaryCentre) // if in orbit of barycentre { string s = $"{(sn.ScanData.DistanceFromArrivalLS):N1}ls"; if (sn.ScanData.nSemiMajorAxis.HasValue) { s += "/" + sn.ScanData.SemiMajorAxisLSKM; } nodelabels[1] = nodelabels[1].AppendPrePad(s, Environment.NewLine); } else { //System.Diagnostics.Debug.WriteLine(sn.ScanData.BodyName + " SMA " + sn.ScanData.nSemiMajorAxis + " " + sn.ScanData.DistanceFromArrivalm); string s = sn.ScanData.nSemiMajorAxis.HasValue && Math.Abs(sn.ScanData.nSemiMajorAxis.Value - sn.ScanData.DistanceFromArrivalm) > JournalScan.oneAU_m ? (" / " + sn.ScanData.SemiMajorAxisLSKM) : ""; nodelabels[1] = nodelabels[1].AppendPrePad($"{sn.ScanData.DistanceFromArrivalLS:N1}ls" + s, Environment.NewLine); } } else { if (!sn.ScanData.IsOrbitingBaryCentre && sn.ScanData.nSemiMajorAxis.HasValue) // if not in orbit of barycentre { nodelabels[1] = nodelabels[1].AppendPrePad($"{(sn.ScanData.nSemiMajorAxis / JournalScan.oneLS_m):N1}ls", Environment.NewLine); } } } nodelabels[1] = nodelabels[1].AppendPrePad(appendlabeltext, Environment.NewLine); // nodelabels[1] = nodelabels[1].AppendPrePad("" + sn.ScanData?.BodyID, Environment.NewLine); bool valuable = sc.EstimatedValue >= ValueLimit; bool isdiscovered = sc.IsPreviouslyDiscovered && sc.IsPlanet; int iconoverlays = ShowOverlays ? ((sc.Terraformable ? 1 : 0) + (sc.HasMeaningfulVolcanism ? 1 : 0) + (valuable ? 1 : 0) + (sc.Mapped ? 1 : 0) + (isdiscovered ? 1 : 0) + (sc.IsPreviouslyMapped ? 1 : 0) + (sn.Signals != null ? 1 : 0)) : 0; // if (sc.BodyName.Contains("4 b")) iconoverlays = 0; bool materialsicon = sc.HasMaterials && !ShowMaterials; bool imageoverlays = sc.IsLandable || (sc.HasRings && drawtype != DrawLevel.TopLevelStar) || materialsicon; int bitmapheight = size.Height * nodeheightratio / noderatiodivider; int overlaywidth = bitmapheight / 6; int imagewidtharea = (imageoverlays ? 2 : 1) * size.Width; // area used by image+overlay if any int iconwidtharea = (iconoverlays > 0 ? overlaywidth : 0); // area used by icon width area on left int bitmapwidth = iconwidtharea + imagewidtharea; // total width int imageleft = iconwidtharea + imagewidtharea / 2 - size.Width / 2; // calculate where the left of the image is int imagetop = bitmapheight / 2 - size.Height / 2; // and the top Bitmap bmp = new Bitmap(bitmapwidth, bitmapheight); using (Graphics g = Graphics.FromImage(bmp)) { // backwash = Color.FromArgb(128, 40, 40, 40); // debug if (backwash.HasValue) { using (Brush b = new SolidBrush(backwash.Value)) { g.FillRectangle(b, new Rectangle(iconwidtharea, 0, imagewidtharea, bitmapheight)); } } g.DrawImage(nodeimage, imageleft, imagetop, size.Width, size.Height); if (sc.IsLandable) { int offset = size.Height * 4 / 16; int scale = 5; g.DrawImage(Icons.Controls.Scan_Bodies_Landable, new Rectangle(imageleft + size.Width / 2 - offset * scale / 2, imagetop + size.Height / 2 - offset * scale / 2, offset * scale, offset * scale)); } if (sc.HasRings && drawtype != DrawLevel.TopLevelStar) { g.DrawImage(sc.Rings.Count() > 1 ? Icons.Controls.Scan_Bodies_RingGap : Icons.Controls.Scan_Bodies_RingOnly, new Rectangle(imageleft - size.Width / 2, imagetop, size.Width * 2, size.Height)); } if (iconoverlays > 0) { int ovsize = bmp.Height / 6; int pos = 4; if (sc.Terraformable) { g.DrawImage(Icons.Controls.Scan_Bodies_Terraformable, new Rectangle(0, pos, ovsize, ovsize)); pos += ovsize + 1; } if (sc.HasMeaningfulVolcanism) //this renders below the terraformable icon if present { g.DrawImage(Icons.Controls.Scan_Bodies_Volcanism, new Rectangle(0, pos, ovsize, ovsize)); pos += ovsize + 1; } if (valuable) { g.DrawImage(Icons.Controls.Scan_Bodies_HighValue, new Rectangle(0, pos, ovsize, ovsize)); pos += ovsize + 1; } if (sc.Mapped) { g.DrawImage(Icons.Controls.Scan_Bodies_Mapped, new Rectangle(0, pos, ovsize, ovsize)); pos += ovsize + 1; } if (sc.IsPreviouslyMapped) { g.DrawImage(Icons.Controls.Scan_Bodies_MappedByOthers, new Rectangle(0, pos, ovsize, ovsize)); pos += ovsize + 1; } if (isdiscovered) { g.DrawImage(Icons.Controls.Scan_Bodies_DiscoveredByOthers, new Rectangle(0, pos, ovsize, ovsize)); pos += ovsize + 1; } if (sn.Signals != null) { g.DrawImage(Icons.Controls.Scan_Bodies_Signals, new Rectangle(0, pos, ovsize, ovsize)); } } if (materialsicon) { Image mm = Icons.Controls.Scan_Bodies_MaterialMore; g.DrawImage(mm, new Rectangle(bmp.Width - mm.Width, bmp.Height - mm.Height, mm.Width, mm.Height)); } if (overlaytext.HasChars()) { float ii; if (imageintensities.ContainsKey(nodeimage)) // find cache { ii = imageintensities[nodeimage]; //System.Diagnostics.Debug.WriteLine("Cached Image intensity of " + sn.fullname + " " + ii); } else { var imageintensity = nodeimage.Function(BitMapHelpers.BitmapFunction.Brightness, nodeimage.Width * 3 / 8, nodeimage.Height * 3 / 8, nodeimage.Width * 2 / 8, nodeimage.Height * 2 / 8); ii = imageintensity.Item2; imageintensities[nodeimage] = ii; //System.Diagnostics.Debug.WriteLine("Calculated Image intensity of " + sn.fullname + " " + ii); } Color text = ii > 0.3f ? Color.Black : Color.FromArgb(255, 200, 200, 200); using (Font f = new Font(EDDTheme.Instance.FontName, size.Width / 5.0f)) { using (Brush b = new SolidBrush(text)) { g.DrawString(overlaytext, f, b, new Rectangle(iconwidtharea, 0, bitmapwidth - iconwidtharea, bitmapheight), new StringFormat() { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center }); } } } } // need left middle, if xiscentre, translate to it Point postoplot = xiscentre ? new Point(position.X - bmp.Width / 2, position.Y) : position; //System.Diagnostics.Debug.WriteLine("Body " + sc.BodyName + " plot at " + postoplot + " " + bmp.Size + " " + (postoplot.X+imageleft) + "," + (postoplot.Y-bmp.Height/2+imagetop)); endpoint = CreateImageAndLabel(pc, bmp, postoplot, bmp.Size, out imagepos, nodelabels, tip); //System.Diagnostics.Debug.WriteLine("Draw {0} at {1} {2} out {3}", nodelabels[0], postoplot, bmp.Size, imagepos); if (sc.HasMaterials && ShowMaterials) { Point matpos = new Point(endpoint.X + 4, position.Y); Point endmat = CreateMaterialNodes(pc, sc, curmats, hl, matpos, materialsize); endpoint = new Point(Math.Max(endpoint.X, endmat.X), Math.Max(endpoint.Y, endmat.Y)); // record new right point.. } } } else if (sn.NodeType == StarScan.ScanNodeType.belt) { if (sn.BeltData != null) { tip = sn.BeltData.RingInformationMoons(true, ""); } else { tip = sn.OwnName + Environment.NewLine + Environment.NewLine + "No scan data available".T(EDTx.ScanDisplayUserControl_NSD); } if (sn.Children != null && sn.Children.Count != 0) { foreach (StarScan.ScanNode snc in sn.Children.Values) { if (snc.ScanData != null) { string sd = snc.ScanData.DisplayString() + "\n"; tip += "\n" + sd; } } } Size bmpsize = new Size(size.Width, planetsize.Height * nodeheightratio / noderatiodivider); endpoint = CreateImageAndLabel(pc, Icons.Controls.Scan_Bodies_Belt, position, bmpsize, out imagepos, new string[] { sn.OwnName.AppendPrePad(appendlabeltext, Environment.NewLine) }, tip, false); } else { if (sn.NodeType == StarScan.ScanNodeType.barycentre) { tip = string.Format("Barycentre of {0}".T(EDTx.ScanDisplayUserControl_BC), sn.OwnName); } else { tip = sn.OwnName + Environment.NewLine + Environment.NewLine + "No scan data available".T(EDTx.ScanDisplayUserControl_NSD); } string nodelabel = sn.CustomName ?? sn.OwnName; nodelabel = nodelabel.AppendPrePad(appendlabeltext, Environment.NewLine); endpoint = CreateImageAndLabel(pc, notscanned, position, size, out imagepos, new string[] { nodelabel }, tip, false); } // System.Diagnostics.Debug.WriteLine("Node " + sn.ownname + " " + position + " " + size + " -> "+ endpoint); return(endpoint); }
private void UpdateSystemRow(int rowindex) { const int idxVisits = 5; const int idxScans = 6; const int idxBodies = 7; const int idxstars = 8; const int idxInfo = 9; const int idxNote = 10; ISystem currentSystem = discoveryform.history.CurrentSystem; // may be null 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 = discoveryform.history.FindSystem(sysname); } if (sys != null && currentSystem != null) { double dist = sys.Distance(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 = discoveryform.history.GetVisitsCount(sysname).ToString(); StarScan.SystemNode sysnode = discoveryform.history.starscan.FindSystemSynchronous(sys, false); if (sysnode != null) { dataGridViewExplore[idxScans, rowindex].Value = sysnode.StarPlanetsScanned().ToString(); if (sysnode.FSSTotalBodies.HasValue) { dataGridViewExplore[idxBodies, rowindex].Value = sysnode.FSSTotalBodies.Value.ToString(); } dataGridViewExplore[idxstars, rowindex].Value = sysnode.StarTypesFound(false); string info = ""; foreach (var scan in sysnode.Bodies) { JournalScan sd = scan.ScanData; if (sd != null) { if (sd.IsStar) { if (sd.StarTypeID == EDStar.AeBe) { info = info + " " + "AeBe"; } if (sd.StarTypeID == EDStar.N) { info = info + " " + "NS"; } if (sd.StarTypeID == EDStar.H) { info = info + " " + "BH"; } } else { if (sd.PlanetTypeID == EDPlanet.Earthlike_body) { info = info + " " + (sd.Terraformable ? "T-ELW" : "ELW"); } else if (sd.PlanetTypeID == EDPlanet.Water_world) { info = info + " " + (sd.Terraformable ? "T-WW" : "WW"); } else if (sd.PlanetTypeID == EDPlanet.High_metal_content_body && sd.Terraformable) { info = info + " " + "T-HMC"; } } } } dataGridViewExplore[idxInfo, rowindex].Value = info.Trim(); } string note = ""; SystemNoteClass sn = SystemNoteClass.GetNoteOnSystem(sys.Name, sys.EDSMID); if (sn != null && !string.IsNullOrWhiteSpace(sn.Note)) { note = sn.Note; } else { BookmarkClass bkmark = GlobalBookMarkList.Instance.FindBookmarkOnSystem(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".T(EDTx.Systemnotknown); } else { dataGridViewExplore.Rows[rowindex].ErrorText = ""; } } }
private List <string> ExtractElements(JournalScan sc, ISystem sys, out bool isbeltcluster, out ScanNodeType starscannodetype) { starscannodetype = ScanNodeType.star; isbeltcluster = false; List <string> elements; string rest = sc.IsStarNameRelatedReturnRest(sys.Name); if (rest != null) // if we have a relationship.. { if (sc.IsStar && !sc.IsEDSMBody && sc.DistanceFromArrivalLS == 0 && rest.Length >= 2) { elements = new List <string> { rest }; starscannodetype = ScanNodeType.star; } else if (rest.Length > 0) { elements = rest.Split(' ').ToList(); if (elements.Count == 4 && elements[0].Length == 1 && char.IsLetter(elements[0][0]) && elements[1].Equals("belt", StringComparison.InvariantCultureIgnoreCase) && elements[2].Equals("cluster", StringComparison.InvariantCultureIgnoreCase)) { elements = new List <string> { "Main Star", elements[0] + " " + elements[1], elements[2] + " " + elements[3] }; isbeltcluster = true; } else if (elements.Count == 5 && elements[0].Length == 1 && elements[1].Length == 1 && char.IsLetter(elements[1][0]) && elements[2].Equals("belt", StringComparison.InvariantCultureIgnoreCase) && elements[3].Equals("cluster", StringComparison.InvariantCultureIgnoreCase)) { elements = new List <string> { elements[0], elements[1] + " " + elements[2], elements[3] + " " + elements[4] }; isbeltcluster = true; } if (char.IsDigit(elements[0][0])) // if digits, planet number, no star designator { elements.Insert(0, "Main Star"); // no star designator, main star, add MAIN } else if (elements[0].Length > 1) // designator, is it multiple chars.. { starscannodetype = ScanNodeType.barycentre; } } else { elements = new List <string>(); // only 1 item, the star, which is the same as the system name.. elements.Add("Main Star"); // Sol / SN:Sol should come thru here } } else if (sc.IsStar && !sc.IsEDSMBody && sc.DistanceFromArrivalLS == 0) { elements = new List <string> { sc.BodyName }; starscannodetype = ScanNodeType.star; } else { // so not part of starname elements = sc.BodyName.Split(' ').ToList(); // not related in any way (earth) so assume all bodyparts, and elements.Insert(0, "Main Star"); // insert the MAIN designator as the star designator } return(elements); }
string Infoline(ISystem system, StarScan.SystemNode sysnode) { string infostr = ""; if (sysnode != null) { if (sysnode.starnodes != null) { string st = sysnode.StarTypesFound(); if (st.HasChars()) { st = " " + st; } int stars = sysnode.StarsScanned(); infostr = infostr.AppendPrePad(string.Format("{0} Star(s){1}".T(EDTx.UserControlStarList_CS), stars, st), Environment.NewLine); string extrainfo = ""; string prefix = Environment.NewLine; string noprefix = ""; string jumponium = ""; foreach (StarScan.ScanNode sn in sysnode.Bodies) { string bodyinfo = ""; if (sn.ScanData != null && checkBoxBodyClasses.Checked) { JournalScan sc = sn.ScanData; string bodynameshort = sc.BodyName.ReplaceIfStartsWith(system.Name); if (sc.IsStar) // brief notification for special or uncommon celestial bodies, useful to traverse the history and search for that special body you discovered. { // Sagittarius A* is a special body: is the centre of the Milky Way, and the only one which is classified as a Super Massive Black Hole. As far as we know... if (sc.StarTypeID == EDStar.SuperMassiveBlackHole) { bodyinfo = bodyinfo.AppendPrePad(string.Format("{0} is a super massive black hole".T(EDTx.UserControlStarList_SMBH), sc.BodyName), prefix); } // black holes if (sc.StarTypeID == EDStar.H) { bodyinfo = bodyinfo.AppendPrePad(string.Format("{0} is a black hole".T(EDTx.UserControlStarList_BH), sc.BodyName), prefix); } // neutron stars if (sc.StarTypeID == EDStar.N) { bodyinfo = bodyinfo.AppendPrePad(string.Format("{0} is a neutron star".T(EDTx.UserControlStarList_NS), sc.BodyName), prefix); } // white dwarf (D, DA, DAB, DAO, DAZ, DAV, DB, DBZ, DBV, DO, DOV, DQ, DC, DCV, DX) string WhiteDwarf = "White Dwarf"; if (sc.StarTypeText.Contains(WhiteDwarf)) { bodyinfo = bodyinfo.AppendPrePad(string.Format("{0} is a {1} white dwarf star".T(EDTx.UserControlStarList_WD), sc.BodyName, sc.StarTypeID), prefix); } // wolf rayet (W, WN, WNC, WC, WO) string WolfRayet = "Wolf-Rayet"; if (sc.StarTypeText.Contains(WolfRayet)) { bodyinfo = bodyinfo.AppendPrePad(string.Format("{0} is a {1} wolf-rayet star".T(EDTx.UserControlStarList_WR), sc.BodyName, sc.StarTypeID), prefix); } // giants. It should recognize all classes of giants. if (sc.StarTypeText.Contains("Giant")) { bodyinfo = bodyinfo.AppendPrePad(string.Format("{0} is a {1}".T(EDTx.UserControlStarList_OTHER), sc.BodyName, sc.StarTypeText), prefix); } // rogue planets - not sure if they really exists, but they are in the journal, so... if (sc.StarTypeID == EDStar.RoguePlanet) { bodyinfo = bodyinfo.AppendPrePad(string.Format("{0} is a rogue planet".T(EDTx.UserControlStarList_RP), sc.BodyName), prefix); } } else { // Check if a non-star body is a moon or not. We want it to further refine our brief summary in the visited star list. // To avoid duplicates, we need to apply our filters before on the bodies recognized as a moon, than do the same for the other bodies that do not fulfill that criteria. if (sn.level >= 2 && sn.type == StarScan.ScanNodeType.body) // Tell us that that special body is a moon. After all, it can be quite an outstanding discovery... { // Earth-like moon if (sc.PlanetTypeID == EDPlanet.Earthlike_body) { bodyinfo = bodyinfo.AppendPrePad(string.Format("{0} is an earth like moon".T(EDTx.UserControlStarList_ELM), bodynameshort), prefix); } // Terraformable water moon if (sc.Terraformable == true && sc.PlanetTypeID == EDPlanet.Water_world) { bodyinfo = bodyinfo.AppendPrePad(string.Format("{0} is a terraformable water moon".T(EDTx.UserControlStarList_TWM), bodynameshort), prefix); } // Water moon if (sc.Terraformable == false && sc.PlanetTypeID == EDPlanet.Water_world) { bodyinfo = bodyinfo.AppendPrePad(string.Format("{0} is a water moon".T(EDTx.UserControlStarList_WM), bodynameshort), prefix); } // Terraformable moon if (sc.Terraformable == true && sc.PlanetTypeID != EDPlanet.Water_world) { bodyinfo = bodyinfo.AppendPrePad(string.Format("{0} is a terraformable moon".T(EDTx.UserControlStarList_TM), bodynameshort), prefix); } // Ammonia moon if (sc.PlanetTypeID == EDPlanet.Ammonia_world) { bodyinfo = bodyinfo.AppendPrePad(string.Format("{0} is an ammonia moon".T(EDTx.UserControlStarList_AM), bodynameshort), prefix); } } else // Do the same, for all planets { // Earth Like planet if (sc.PlanetTypeID == EDPlanet.Earthlike_body) { bodyinfo = bodyinfo.AppendPrePad(string.Format("{0} is an earth like planet".T(EDTx.UserControlStarList_ELP), bodynameshort), prefix); } // Terraformable water world if (sc.PlanetTypeID == EDPlanet.Water_world && sc.Terraformable == true) { bodyinfo = bodyinfo.AppendPrePad(string.Format("{0} is a terraformable water world".T(EDTx.UserControlStarList_TWW), bodynameshort), prefix); } // Water world if (sc.PlanetTypeID == EDPlanet.Water_world && sc.Terraformable == false) { bodyinfo = bodyinfo.AppendPrePad(string.Format("{0} is a water world".T(EDTx.UserControlStarList_WW), bodynameshort), prefix); } // Terraformable planet if (sc.Terraformable == true && sc.PlanetTypeID != EDPlanet.Water_world) { bodyinfo = bodyinfo.AppendPrePad(string.Format("{0} is a terraformable planet".T(EDTx.UserControlStarList_TP), bodynameshort), prefix); } // Ammonia world if (sc.PlanetTypeID == EDPlanet.Ammonia_world) { bodyinfo = bodyinfo.AppendPrePad(string.Format("{0} is an ammonia world".T(EDTx.UserControlStarList_AW), bodynameshort), prefix); } } if (sn.Signals != null) { bodyinfo = bodyinfo.AppendPrePad(string.Format("{0} has signals".T(EDTx.UserControlStarList_Signals), bodynameshort), prefix); } //Add Distance - Remember no newline if (bodyinfo != "") { double distance = sc.DistanceFromArrivalLS; bodyinfo = bodyinfo.AppendPrePad(string.Format(" ({0} ls)".T(EDTx.UserControlStarList_Distance), distance.ToString("n0")), noprefix); extrainfo = extrainfo.AppendPrePad(bodyinfo, prefix); } } } // Landable bodies with valuable materials, collect into jumponimum if (sn.ScanData != null && sn.ScanData.IsLandable == true && sn.ScanData.HasMaterials && checkBoxJumponium.Checked == true) { int basic = 0; int standard = 0; int premium = 0; foreach (KeyValuePair <string, double> mat in sn.ScanData.Materials) { string usedin = Recipes.UsedInSythesisByFDName(mat.Key); if (usedin.Contains("FSD-Basic")) { basic++; } if (usedin.Contains("FSD-Standard")) { standard++; } if (usedin.Contains("FSD-Premium")) { premium++; } } // string MaterialsBrief = sn.ScanData.DisplayMaterials(4).ToString(); //System.Diagnostics.Debug.WriteLine("{0} {1} {2} {3} {4}", sn.fullname , basic, standard, premium, MaterialsBrief); if (basic > 0 || standard > 0 || premium > 0) { int mats = basic + standard + premium; StringBuilder jumpLevel = new StringBuilder(); if (basic != 0) { jumpLevel.AppendPrePad(basic + "/" + Recipes.FindSynthesis("FSD", "Basic").Count + " Basic".T(EDTx.UserControlStarList_BFSD), ", "); } if (standard != 0) { jumpLevel.AppendPrePad(standard + "/" + Recipes.FindSynthesis("FSD", "Standard").Count + " Standard".T(EDTx.UserControlStarList_SFSD), ", "); } if (premium != 0) { jumpLevel.AppendPrePad(premium + "/" + Recipes.FindSynthesis("FSD", "Premium").Count + " Premium".T(EDTx.UserControlStarList_PFSD), ", "); } jumponium = jumponium.AppendPrePad(Environment.NewLine + string.Format("{0} has {1} level elements.".T(EDTx.UserControlStarList_LE), sn.ScanData.BodyName, jumpLevel)); } } } int total = sysnode.StarPlanetsScanned(); if (total > 0) { int totalwithoutstars = total - stars; if (totalwithoutstars > 0) { infostr = infostr.AppendPrePad(string.Format("{0} Other bodies".T(EDTx.UserControlStarList_OB), totalwithoutstars.ToString()), ", "); } if (sysnode.FSSTotalBodies.HasValue && total < sysnode.FSSTotalBodies.Value) // only show if you've not got them all { infostr += ", " + "Total".T(EDTx.UserControlStarList_Total) + " " + sysnode.FSSTotalBodies.Value.ToString(); } infostr = infostr.AppendPrePad(extrainfo, prefix); } else { // we need this to allow the panel to scan also through systems which has only stars infostr = infostr.AppendPrePad(extrainfo, prefix); } if (jumponium.HasChars()) { infostr = infostr.AppendPrePad(Environment.NewLine + Environment.NewLine + "This system has materials for FSD boost: ".T(EDTx.UserControlStarList_FSD)); infostr = infostr.AppendPrePad(jumponium); } } } return(infostr); }
private async void OnNewEntry(HistoryEntry he, HistoryList hl) { last_he = he; if (last_he != null) { if (bodyRadius == null || lastradiusbody != he.WhereAmI) // try and get radius, this is cleared on target selection { StarScan.SystemNode last_sn = await discoveryform.history.StarScan.FindSystemAsync(he.System, false); // find scan if we have one JournalScan sd = last_sn?.Find(he.WhereAmI)?.ScanData; // find body scan data if present, null if not bodyRadius = sd?.nRadius; if (bodyRadius.HasValue) { lastradiusbody = he.WhereAmI; System.Diagnostics.Debug.WriteLine("Compass Radius Set " + lastradiusbody + " " + bodyRadius.Value); } } switch (he.journalEntry.EventTypeID) { case JournalTypeEnum.Screenshot: JournalScreenshot js = he.journalEntry as JournalScreenshot; latitude = js.nLatitude; longitude = js.nLongitude; altitude = js.nAltitude; break; case JournalTypeEnum.Touchdown: JournalTouchdown jt = he.journalEntry as JournalTouchdown; if (jt.PlayerControlled.HasValue && jt.PlayerControlled.Value) { latitude = jt.Latitude; longitude = jt.Longitude; altitude = 0; } break; case JournalTypeEnum.Location: JournalLocation jl = he.journalEntry as JournalLocation; latitude = jl.Latitude; longitude = jl.Longitude; altitude = null; break; case JournalTypeEnum.Liftoff: JournalLiftoff jlo = he.journalEntry as JournalLiftoff; if (jlo.PlayerControlled.HasValue && jlo.PlayerControlled.Value) { latitude = jlo.Latitude; longitude = jlo.Longitude; altitude = 0; } break; case JournalTypeEnum.LeaveBody: latitude = null; longitude = null; altitude = null; break; case JournalTypeEnum.FSDJump: // to allow us to do PopulateBookmark.. case JournalTypeEnum.CarrierJump: break; default: return; } PopulateBookmarkCombo(); DisplayCompass(); } }
// draw scannode (may be null), // curmats may be null public void DrawSystem(StarScan.SystemNode scannode, MaterialCommoditiesList curmats, HistoryList hl, string opttext = null, string[] filter = null) { HideInfo(); imagebox.ClearImageList(); // does not clear the image, render will do that if (scannode != null) { Point leftmiddle = new Point(leftmargin, topmargin + StarSize.Height * nodeheightratio / 2 / noderatiodivider); // half down (h/2 * ratio) if (opttext != null) { ExtPictureBox.ImageElement lab = new ExtPictureBox.ImageElement(); lab.TextAutosize(new Point(leftmargin, 0), new Size(500, 30), opttext, largerfont, EDDTheme.Instance.LabelColor, this.BackColor); imagebox.Add(lab); leftmiddle.Y += lab.Image.Height + 8; } DisplayAreaUsed = leftmiddle; List <ExtPictureBox.ImageElement> starcontrols = new List <ExtPictureBox.ImageElement>(); bool displaybelts = filter == null || (filter.Contains("belt") || filter.Contains("All")); Point maxitemspos = new Point(0, 0); foreach (StarScan.ScanNode starnode in scannode.starnodes.Values) // always has scan nodes { if (filter != null && starnode.IsBodyInFilter(filter, true) == false) // if filter active, but no body or children in filter { // System.Diagnostics.Debug.WriteLine("SDUC Rejected " + starnode.fullname); continue; } // Draw star Point maxstarpos = DrawNode(starcontrols, starnode, curmats, hl, (starnode.type == StarScan.ScanNodeType.barycentre) ? Icons.Controls.Scan_Bodies_Barycentre : JournalScan.GetStarImageNotScanned(), leftmiddle, false, out int unusedstarcentre, StarSize, DrawLevel.TopLevelStar); // the last part nerfs the label down to the right position maxitemspos = new Point(Math.Max(maxitemspos.X, maxstarpos.X), Math.Max(maxitemspos.Y, maxstarpos.Y)); if (starnode.children != null) { leftmiddle = new Point(maxitemspos.X + starfirstplanetspacerx, leftmiddle.Y); Point firstcolumn = leftmiddle; Queue <StarScan.ScanNode> belts; if (starnode.ScanData != null && (!starnode.ScanData.IsEDSMBody || CheckEDSM)) // have scandata on star, and its not edsm or allowed edsm { belts = new Queue <StarScan.ScanNode>(starnode.children.Values.Where(s => s.type == StarScan.ScanNodeType.belt)); // find belts in children of star } else { belts = new Queue <StarScan.ScanNode>(); // empty array } StarScan.ScanNode lastbelt = belts.Count != 0 ? belts.Dequeue() : null; double habzonestartls = starnode.ScanData?.HabitableZoneInner ?? 0; double habzoneendls = starnode.ScanData?.HabitableZoneOuter ?? 0; // process body and stars only List <StarScan.ScanNode> planetsinorder = starnode.children.Values.Where(s => s.type == StarScan.ScanNodeType.body || s.type == StarScan.ScanNodeType.star).ToList(); var planetcentres = new Dictionary <StarScan.ScanNode, Point>(); for (int pn = 0; pn < planetsinorder.Count; pn++) { StarScan.ScanNode planetnode = planetsinorder[pn]; if (filter != null && planetnode.IsBodyInFilter(filter, true) == false) // if filter active, but no body or children in filter { //System.Diagnostics.Debug.WriteLine("SDUC Rejected " + planetnode.fullname); continue; } //System.Diagnostics.Debug.WriteLine("Draw " + planetnode.ownname + ":" + planetnode.type); // if belt is before this, display belts here while (displaybelts && lastbelt != null && planetnode.ScanData != null && (lastbelt.BeltData == null || planetnode.ScanData.IsOrbitingBaryCentre || lastbelt.BeltData.OuterRad < planetnode.ScanData.nSemiMajorAxis)) { // if too far across, go back to star if (leftmiddle.X + planetsize.Width > panelStars.Width - panelStars.ScrollBarWidth) // if too far across.. { leftmiddle = new Point(firstcolumn.X, maxitemspos.Y + planetspacery + planetsize.Height / 2); // move to left at maxy+space+h/2 } string appendlabel = ""; if (lastbelt.BeltData != null) { appendlabel = appendlabel.AppendPrePad($"{lastbelt.BeltData.OuterRad / JournalScan.oneLS_m:N1}ls", Environment.NewLine); } appendlabel = appendlabel.AppendPrePad("" + lastbelt.ScanData?.BodyID, Environment.NewLine); Point maxbeltpos = DrawNode(starcontrols, lastbelt, curmats, hl, Icons.Controls.Scan_Bodies_Belt, leftmiddle, false, out int unusedbeltcentre, beltsize, DrawLevel.PlanetLevel, appendlabeltext: appendlabel); leftmiddle = new Point(maxbeltpos.X + planetspacerx, leftmiddle.Y); lastbelt = belts.Count != 0 ? belts.Dequeue() : null; maxitemspos = new Point(Math.Max(maxitemspos.X, maxbeltpos.X), Math.Max(maxitemspos.Y, maxbeltpos.Y)); } //System.Diagnostics.Debug.WriteLine("Planet Node " + planetnode.ownname + " has scans " + nonedsmscans); if (planetnode.DoesNodeHaveNonEDSMScansBelow() || CheckEDSM) { List <ExtPictureBox.ImageElement> pc = new List <ExtPictureBox.ImageElement>(); bool habzone = false; if (ShowHabZone && planetnode.ScanData != null && !planetnode.ScanData.IsOrbitingBaryCentre && planetnode.ScanData.nSemiMajorAxis.HasValue) { double dist = planetnode.ScanData.nSemiMajorAxis.Value / JournalScan.oneLS_m; // m , converted to LS habzone = dist >= habzonestartls && dist <= habzoneendls; } Point maxplanetpos = CreatePlanetTree(pc, planetnode, curmats, hl, leftmiddle, filter, habzone, out int centreplanet); Point pcnt = new Point(centreplanet, leftmiddle.Y); if (maxplanetpos.X > panelStars.Width - panelStars.ScrollBarWidth) // uh oh too wide.. { int xoff = firstcolumn.X - leftmiddle.X; // shift to firstcolumn.x, maxitemspos.Y+planetspacer int yoff = (maxitemspos.Y + planetspacery) - (leftmiddle.Y - planetsize.Height / 2); RepositionTree(pc, xoff, yoff); // shift co-ords of all you've drawn - this will include any bary points drawn in moons pcnt.X += xoff; pcnt.Y += yoff; // need to account for planet centre maxplanetpos = new Point(maxplanetpos.X + xoff, maxplanetpos.Y + yoff); // remove the shift from maxpos leftmiddle = new Point(maxplanetpos.X + planetspacerx, leftmiddle.Y + yoff); // and set the curpos to maxpos.x + spacer, remove the shift from curpos.y } else { leftmiddle = new Point(maxplanetpos.X + planetspacerx, leftmiddle.Y); // shift current pos right, plus a spacer } maxitemspos = new Point(Math.Max(maxitemspos.X, maxplanetpos.X), Math.Max(maxitemspos.Y, maxplanetpos.Y)); starcontrols.AddRange(pc.ToArray()); planetcentres[planetnode] = pcnt; } } // do any futher belts after all planets while (displaybelts && lastbelt != null) { if (leftmiddle.X + planetsize.Width > panelStars.Width - panelStars.ScrollBarWidth) // if too far across.. { leftmiddle = new Point(firstcolumn.X, maxitemspos.Y + planetspacery + planetsize.Height / 2); // move to left at maxy+space+h/2 } string appendlabel = ""; if (lastbelt.BeltData != null) { appendlabel = appendlabel.AppendPrePad($"{lastbelt.BeltData.OuterRad / JournalScan.oneLS_m:N1}ls", Environment.NewLine); } appendlabel = appendlabel.AppendPrePad("" + lastbelt.ScanData?.BodyID, Environment.NewLine); Point maxbeltpos = DrawNode(starcontrols, lastbelt, curmats, hl, Icons.Controls.Scan_Bodies_Belt, leftmiddle, false, out int unusedbelt2centre, beltsize, DrawLevel.PlanetLevel, appendlabeltext: appendlabel); leftmiddle = new Point(maxbeltpos.X + planetspacerx, leftmiddle.Y); lastbelt = belts.Count != 0 ? belts.Dequeue() : null; maxitemspos = new Point(Math.Max(maxitemspos.X, maxbeltpos.X), Math.Max(maxitemspos.Y, maxbeltpos.Y)); } maxitemspos = leftmiddle = new Point(leftmargin, maxitemspos.Y + starplanetgroupspacery + StarSize.Height / 2); // move back to left margin and move down to next position of star, allowing gap // make a tree of the planets with their barycentres from the Parents information var barynodes = StarScan.ScanNode.PopulateBarycentres(planetsinorder); // children always made, barynode tree StarScan.ScanNode.DumpTree(barynodes, "TOP", 0); List <ExtPictureBox.ImageElement> pcb = new List <ExtPictureBox.ImageElement>(); foreach (var k in barynodes.children) // for all barynodes.. display { DisplayBarynode(k.Value, 0, planetcentres, planetsinorder, pcb, planetsize.Height / 2); // done after the reposition so true positions set up. } starcontrols.InsertRange(0, pcb); // insert at start so drawn under } else { // no planets, so just move across and plot another one leftmiddle = new Point(maxitemspos.X + starfirstplanetspacerx, leftmiddle.Y); if (leftmiddle.X + StarSize.Width > panelStars.Width - panelStars.ScrollBarWidth) // if too far across.. { maxitemspos = leftmiddle = new Point(leftmargin, maxitemspos.Y + starplanetgroupspacery + StarSize.Height / 2); // move to left at maxy+space+h/2 } } DisplayAreaUsed = new Point(Math.Max(DisplayAreaUsed.X, maxitemspos.X), Math.Max(DisplayAreaUsed.Y, maxitemspos.Y)); } imagebox.AddRange(starcontrols); } imagebox.Render(); // replaces image.. }
private bool Process(JournalScan sc, ISystem sys, bool reprocessPrimary = false) // background or foreground.. FALSE if you can't process it { SystemNode sn = GetOrCreateSystemNode(sys); // handle Earth, starname = Sol // handle Eol Prou LW-L c8-306 A 4 a and Eol Prou LW-L c8-306 // handle Colonia 4 , starname = Colonia, planet 4 // handle Aurioum B A BELT // Kyloasly OY-Q d5-906 13 1 ScanNodeType starscannodetype = ScanNodeType.star; // presuming.. bool isbeltcluster = false; // Extract elements from name List <string> elements = ExtractElements(sc, sys, out isbeltcluster, out starscannodetype); // Bail out if no elements extracted if (elements.Count == 0) { System.Diagnostics.Trace.WriteLine($"Failed to add body {sc.BodyName} to system {sys.Name} - not enough elements"); return(false); } // Bail out if more than 5 elements extracted else if (elements.Count > 5) { System.Diagnostics.Trace.WriteLine($"Failed to add body {sc.BodyName} to system {sys.Name} - too deep"); return(false); } // Get custom name if different to designation string customname = GetCustomName(sc, sys); // Process elements ScanNode node = ProcessElements(sc, sys, sn, customname, elements, starscannodetype, isbeltcluster); if (node.BodyID != null) { sn.NodesByID[(int)node.BodyID] = node; } // Process top-level star if (elements.Count == 1) { // Process any belts if present ProcessBelts(sc, node); // Process primary star in multi-star system if (elements[0].Equals("A", StringComparison.InvariantCultureIgnoreCase)) { CachePrimaryStar(sc, sys); // Reprocess if we've encountered the primary (A) star and we already have a "Main Star" if (reprocessPrimary && sn.starnodes.Any(n => n.Key.Length > 1 && n.Value.type == ScanNodeType.star)) { ReProcess(sn); } } } return(true); }
// return right bottom of area used from curpos Point CreatePlanetTree(List <ExtPictureBox.ImageElement> pc, StarScan.ScanNode planetnode, MaterialCommoditiesList curmats, HistoryList hl, Point leftmiddle, string[] filter, bool habzone, out int planetcentre) { Color?backwash = null; if (habzone) { backwash = Color.FromArgb(64, 0, 128, 0); // transparent in case we have a non black background } Point maxtreepos = DrawNode(pc, planetnode, curmats, hl, (planetnode.type == StarScan.ScanNodeType.barycentre) ? Icons.Controls.Scan_Bodies_Barycentre : JournalScan.GetPlanetImageNotScanned(), leftmiddle, false, out planetcentre, planetsize, DrawLevel.PlanetLevel, backwash: backwash); // offset passes in the suggested offset, returns the centre offset if (planetnode.children != null && ShowMoons) { Point moonposcentremid = new Point(planetcentre, maxtreepos.Y + moonspacery + moonsize.Height / 2); // moon pos, below planet, centre x coord var moonnodes = planetnode.children.Values.Where(n => n.type != StarScan.ScanNodeType.barycentre).ToList(); var mooncentres = new Dictionary <StarScan.ScanNode, Point>(); for (int mn = 0; mn < moonnodes.Count; mn++) { StarScan.ScanNode moonnode = moonnodes[mn]; if (filter != null && moonnode.IsBodyInFilter(filter, true) == false) // if filter active, but no body or children in filter { continue; } bool nonedsmscans = moonnode.DoesNodeHaveNonEDSMScansBelow(); // is there any scans here, either at this node or below? if (nonedsmscans || CheckEDSM) { Point mmax = DrawNode(pc, moonnode, curmats, hl, (moonnode.type == StarScan.ScanNodeType.barycentre) ? Icons.Controls.Scan_Bodies_Barycentre : JournalScan.GetMoonImageNotScanned(), moonposcentremid, true, out int mooncentre, moonsize, DrawLevel.MoonLevel); maxtreepos = new Point(Math.Max(maxtreepos.X, mmax.X), Math.Max(maxtreepos.Y, mmax.Y)); if (moonnode.children != null) { Point submoonpos = new Point(mmax.X + moonspacerx, moonposcentremid.Y); // first its left mid bool xiscentre = false; foreach (StarScan.ScanNode submoonnode in moonnode.children.Values) { if (filter != null && submoonnode.IsBodyInFilter(filter, true) == false) // if filter active, but no body or children in filter { continue; } bool nonedsmsubmoonscans = submoonnode.DoesNodeHaveNonEDSMScansBelow(); // is there any scans here, either at this node or below? if (nonedsmsubmoonscans || CheckEDSM) { Point sbmax = DrawNode(pc, submoonnode, curmats, hl, (moonnode.type == StarScan.ScanNodeType.barycentre) ? Icons.Controls.Scan_Bodies_Barycentre : JournalScan.GetMoonImageNotScanned(), submoonpos, xiscentre, out int xsubmooncentre, moonsize, DrawLevel.MoonLevel); if (xiscentre) { submoonpos = new Point(submoonpos.X, sbmax.Y + moonspacery + moonsize.Height / 2); } else { submoonpos = new Point(xsubmooncentre, sbmax.Y + moonspacery + moonsize.Height / 2); xiscentre = true; // now go to centre placing } maxtreepos = new Point(Math.Max(maxtreepos.X, sbmax.X), Math.Max(maxtreepos.Y, sbmax.Y)); } } } mooncentres[moonnode] = new Point(mooncentre, moonposcentremid.Y); moonposcentremid = new Point(moonposcentremid.X, maxtreepos.Y + moonspacery + moonsize.Height / 2); //System.Diagnostics.Debug.WriteLine("Next moon centre at " + moonposcentremid ); } } //// now, taking the moon modes, create a barycentre tree with those inserted in var barynodes = StarScan.ScanNode.PopulateBarycentres(moonnodes); // children always made, barynode tree foreach (var k in barynodes.children) // for all barynodes.. display { DisplayBarynode(k.Value, 0, mooncentres, moonnodes, pc, moonsize.Width * 5 / 4, true); } } return(maxtreepos); }
private ScanNode ProcessElements(JournalScan sc, ISystem sys, SystemNode sn, string customname, List <string> elements, ScanNodeType starscannodetype, bool isbeltcluster) { SortedList <string, ScanNode> cnodes = sn.starnodes; ScanNode node = null; List <JournalScan.BodyParent> ancestors = sc.Parents?.AsEnumerable()?.ToList(); List <JournalScan.BodyParent> ancestorbodies = ancestors?.Where(a => a.Type == "Star" || a.Type == "Planet" || a.Type == "Belt")?.Reverse()?.ToList(); ScanNode toplevelnode = null; if ((ancestorbodies != null) && (starscannodetype != ScanNodeType.star)) { ancestorbodies.Insert(0, null); } for (int lvl = 0; lvl < elements.Count; lvl++) { ScanNode sublv; ScanNodeType sublvtype; string ownname = elements[lvl]; if (lvl == 0) { sublvtype = starscannodetype; } else if (isbeltcluster) { sublvtype = lvl == 1 ? ScanNodeType.belt : ScanNodeType.beltcluster; } else { sublvtype = ScanNodeType.body; } if (cnodes == null || !cnodes.TryGetValue(elements[lvl], out sublv)) { if (node != null && node.children == null) { node.children = new SortedList <string, ScanNode>(new DuplicateKeyComparer <string>()); cnodes = node.children; } sublv = new ScanNode { ownname = ownname, fullname = lvl == 0 ? (sys.Name + (ownname.Contains("Main") ? "" : (" " + ownname))) : node.fullname + " " + ownname, ScanData = null, children = null, type = sublvtype, level = lvl, IsTopLevelNode = lvl == 0 }; cnodes.Add(ownname, sublv); } if (ancestorbodies != null && lvl < ancestorbodies.Count && ancestorbodies[lvl] != null) { if (sublv.BodyID == null) { sublv.BodyID = ancestorbodies[lvl].BodyID; sn.NodesByID[(int)sublv.BodyID] = sublv; } } node = sublv; cnodes = node.children; if (lvl == elements.Count - 1) { node.ScanData = sc; node.customname = customname; if (sc.BodyID != null) { node.BodyID = sc.BodyID; } } if (lvl == 0) { toplevelnode = node; } if (node.BodyID != null) { if (lvl == 0 && node.BodyID > sn.MaxTopLevelBodyID) { sn.MaxTopLevelBodyID = (int)node.BodyID; } else if (lvl > 0 && node.BodyID < sn.MinPlanetBodyID) { sn.MinPlanetBodyID = (int)node.BodyID; } } } if (ancestors != null && ancestorbodies != null && ancestorbodies[0] == null && toplevelnode.BodyID == null) { for (int lvl = 1; lvl < ancestors.Count; lvl++) { if (ancestors[lvl - 1].BodyID >= sn.MinPlanetBodyID && ancestors[lvl].BodyID <= sn.MaxTopLevelBodyID) { toplevelnode.BodyID = ancestors[lvl].BodyID; sn.NodesByID[(int)toplevelnode.BodyID] = toplevelnode; } } } return(node); }
public static List <JournalScan> GetBodiesList(long edsmid, bool edsmweblookup = true, long?id64 = null, string sysname = null) // get this edsmid, optionally lookup web protected against bad json { try { if (DictEDSMBodies != null && edsmid > 0 && DictEDSMBodies.ContainsKey(edsmid)) // Cache EDSM bidies during run of EDD. { // System.Diagnostics.Debug.WriteLine(".. found EDSM Lookup bodies from cache " + edsmid); return(DictEDSMBodies[edsmid]); } else if (DictEDSMBodiesByID64 != null && id64 != null && id64 > 0 && DictEDSMBodiesByID64.ContainsKey(id64.Value)) { return(DictEDSMBodiesByID64[id64.Value]); } if (!edsmweblookup) // must be set for a web lookup { return(null); } List <JournalScan> bodies = new List <JournalScan>(); EDSMClass edsm = new EDSMClass(); //System.Diagnostics.Debug.WriteLine("EDSM Web Lookup bodies " + edsmid); JObject jo = null; if (edsmid > 0) { jo = edsm.GetBodies(edsmid); // Colonia } else if (id64 != null && id64 > 0) { jo = edsm.GetBodiesByID64(id64.Value); } else if (sysname != null) { jo = edsm.GetBodies(sysname); } if (jo != null && jo["bodies"] != null) { foreach (JObject edsmbody in jo["bodies"]) { try { JObject jbody = EDSMClass.ConvertFromEDSMBodies(edsmbody); JournalScan js = new JournalScan(jbody, edsmid); bodies.Add(js); } catch (Exception ex) { BaseUtils.HttpCom.WriteLog($"Exception Loop: {ex.Message}", ""); BaseUtils.HttpCom.WriteLog($"ETrace: {ex.StackTrace}", ""); Trace.WriteLine($"Exception Loop: {ex.Message}"); Trace.WriteLine($"ETrace: {ex.StackTrace}"); } } if (edsmid > 0) { DictEDSMBodies[edsmid] = bodies; } if (id64 != null && id64 > 0) { DictEDSMBodiesByID64[id64.Value] = bodies; } return(bodies); } if (edsmid > 0) { DictEDSMBodies[edsmid] = null; } if (id64 != null && id64 > 0) { DictEDSMBodiesByID64[id64.Value] = null; } } catch (Exception ex) { Trace.WriteLine($"Exception: {ex.Message}"); Trace.WriteLine($"ETrace: {ex.StackTrace}"); return(null); } return(null); }
// look to see if there is a better body designation for a scan.. using lookup tables (bodyDesignationMap) and direct code private string GetBodyDesignation(JournalScan je, string system) { Dictionary <string, Dictionary <string, string> > desigmap = je.IsStar ? starDesignationMap : planetDesignationMap; int bodyid = je.BodyID ?? -1; if (je.BodyID != null && bodyIdDesignationMap.ContainsKey(system) && bodyIdDesignationMap[system].ContainsKey(bodyid) && bodyIdDesignationMap[system][bodyid].NameEquals(je.BodyName)) { return(bodyIdDesignationMap[system][bodyid].Designation); } // Special case for m Centauri if (je.IsStar && system.ToLowerInvariant() == "m centauri") { if (je.BodyName == "m Centauri") { return("m Centauri A"); } else if (je.BodyName == "M Centauri") { return("m Centauri B"); } } // Special case for Castellan Belt if (system.ToLowerInvariant() == "lave" && je.BodyName.StartsWith("Castellan Belt ", StringComparison.InvariantCultureIgnoreCase)) { return("Lave A Belt " + je.BodyName.Substring("Castellan Belt ".Length)); } // Special case for 9 Aurigae if (je.IsStar && system.ToLowerInvariant() == "9 Aurigae") { if (je.BodyName == "9 Aurigae C") { if (je.nSemiMajorAxis > 1e13) { return("9 Aurigae D"); } else { return("9 Aurigae C"); } } } if (desigmap.ContainsKey(system) && desigmap[system].ContainsKey(je.BodyName)) { return(desigmap[system][je.BodyName]); } if (je.IsStar && je.BodyName == system && je.nOrbitalPeriod != null) { return(system + " A"); } if (je.BodyName.Equals(system, StringComparison.InvariantCultureIgnoreCase) || je.BodyName.StartsWith(system + " ", StringComparison.InvariantCultureIgnoreCase)) { return(je.BodyName); } if (je.IsStar && primaryStarScans.ContainsKey(system)) { foreach (JournalScan primary in primaryStarScans[system]) { if (CompareEpsilon(je.nOrbitalPeriod, primary.nOrbitalPeriod) && CompareEpsilon(je.nPeriapsis, primary.nPeriapsis, acceptNull: true, fb: b => ((double)b + 180) % 360.0) && CompareEpsilon(je.nOrbitalInclination, primary.nOrbitalInclination) && CompareEpsilon(je.nEccentricity, primary.nEccentricity) && !je.BodyName.Equals(primary.BodyName, StringComparison.InvariantCultureIgnoreCase)) { return(system + " B"); } } } return(je.BodyName); }
string Infoline(List <HistoryEntry> syslist) { string infostr = ""; if (syslist.Count > 1) { infostr = "First visit " + syslist.Last().EventTimeLocal.ToShortDateString(); } HistoryEntry he = syslist[0]; StarScan.SystemNode node = discoveryform.history.starscan?.FindSystem(he.System); if (node != null) { if (node.starnodes != null) { infostr = infostr.AppendPrePad(node.starnodes.Count.ToStringInvariant() + " Star" + ((node.starnodes.Count > 1) ? "s" : ""), Environment.NewLine); string extrainfo = ""; string prefix = Environment.NewLine; int total = 0; foreach (StarScan.ScanNode sn in node.Bodies) { total++; if (sn.ScanData != null) { JournalScan sc = sn.ScanData; if (sc.IsStar) // brief notification for special or uncommon celestial bodies, useful to traverse the history and search for that special body you discovered. { // Sagittarius A* is a special body: is the centre of the Milky Way, and the only one which is classified as a Super Massive Black Hole. As far as we know... if (sc.StarTypeID == EDStar.SuperMassiveBlackHole) { extrainfo = extrainfo.AppendPrePad(sc.BodyName + " is a super massive black hole", prefix); } // black holes if (sc.StarTypeID == EDStar.H) { extrainfo = extrainfo.AppendPrePad(sc.BodyName + " is a black hole", prefix); } // neutron stars if (sc.StarTypeID == EDStar.N) { extrainfo = extrainfo.AppendPrePad(sc.BodyName + " is a neutron star", prefix); } // white dwarf (D, DA, DAB, DAO, DAZ, DAV, DB, DBZ, DBV, DO, DOV, DQ, DC, DCV, DX) string WhiteDwarf = "White Dwarf"; if (sc.StarTypeText.Contains(WhiteDwarf)) { extrainfo = extrainfo.AppendPrePad(sc.BodyName + " is a " + sc.StarTypeID + " white dwarf star", prefix); } // wolf rayet (W, WN, WNC, WC, WO) string WolfRayet = "Wolf-Rayet"; if (sc.StarTypeText.Contains(WolfRayet)) { extrainfo = extrainfo.AppendPrePad(sc.BodyName + " is a " + sc.StarTypeID + " wolf-rayet star", prefix); } // giants. It should recognize all classes of giants. string Giant = "Giant"; if (sc.StarTypeText.Contains(Giant)) { extrainfo = extrainfo.AppendPrePad(sc.BodyName + " is a " + sc.StarTypeText, prefix); } // rogue planets - not sure if they really exists, but they are in the journal, so... if (sc.StarTypeID == EDStar.RoguePlanet) { extrainfo = extrainfo.AppendPrePad(sc.BodyName + " is a rogue planet", prefix); } } else { // Check if a non-star body is a moon or not. We want it to further refine our brief summary in the visited star list. // To avoid duplicates, we need to apply our filters before on the bodies recognized as a moon, than do the same for the other bodies that do not fulfill that criteria. if (sn.level >= 2 && sn.type == StarScan.ScanNodeType.body) // Tell us that that special body is a moon. After all, it can be quite an outstanding discovery... { // Earth-like moon if (sc.PlanetTypeID == EDPlanet.Earthlike_body) { extrainfo = extrainfo.AppendPrePad(sc.BodyName + " is an earth like moon", prefix); } // Terraformable water moon if (sc.Terraformable == true && sc.PlanetTypeID == EDPlanet.Water_world) { extrainfo = extrainfo.AppendPrePad(sc.BodyName + " is a terraformable water moon", prefix); } // Water moon if (sc.Terraformable == false && sc.PlanetTypeID == EDPlanet.Water_world) { extrainfo = extrainfo.AppendPrePad(sc.BodyName + " is a water moon", prefix); } // Terraformable moon if (sc.Terraformable == true && sc.PlanetTypeID != EDPlanet.Water_world) { extrainfo = extrainfo.AppendPrePad(sc.BodyName + " is a terraformable moon", prefix); } // Ammonia moon if (sc.PlanetTypeID == EDPlanet.Ammonia_world) { extrainfo = extrainfo.AppendPrePad(sc.BodyName + " is an ammonia moon", prefix); } } else // Do the same, for all planets { // Earth Like planet if (sc.PlanetTypeID == EDPlanet.Earthlike_body) { extrainfo = extrainfo.AppendPrePad(sc.BodyName + " is an earth like planet", prefix); } // Terraformable water world if (sc.PlanetTypeID == EDPlanet.Water_world && sc.Terraformable == true) { extrainfo = extrainfo.AppendPrePad(sc.BodyName + " is a terraformable water world", prefix); } // Water world if (sc.PlanetTypeID == EDPlanet.Water_world && sc.Terraformable == false) { extrainfo = extrainfo.AppendPrePad(sc.BodyName + " is a water world", prefix); } // Terraformable planet if (sc.Terraformable == true && sc.PlanetTypeID != EDPlanet.Water_world) { extrainfo = extrainfo.AppendPrePad(sc.BodyName + " is a terraformable planet", prefix); } // Ammonia world if (sc.PlanetTypeID == EDPlanet.Ammonia_world) { extrainfo = extrainfo.AppendPrePad(sc.BodyName + " is an ammonia world", prefix); } } } } } total -= node.starnodes.Count; if (total > 0) { // tell us that a system has other bodies, and how much, beside stars infostr = infostr.AppendPrePad(total.ToStringInvariant() + " Other bod" + ((total > 1) ? "ies" : "y"), ", "); infostr = infostr.AppendPrePad(extrainfo, prefix); } else { // we need this to allow the panel to scan also through systems which has only stars infostr = infostr.AppendPrePad(extrainfo, prefix); } } } return(infostr); }
private void OnNewEntry(HistoryEntry he, HistoryList hl) { last_he = he; if (last_he != null) { // hmm. not checking EDSM for scan data.. do we want to ? prob not. JournalScan sd = discoveryform.history.GetScans(he.System.Name).Where(sc => sc.BodyName == he.WhereAmI).FirstOrDefault(); bodyRadius = sd?.nRadius; switch (he.journalEntry.EventTypeID) { case JournalTypeEnum.Screenshot: JournalScreenshot js = he.journalEntry as JournalScreenshot; latitude = js.nLatitude; longitude = js.nLongitude; altitude = js.nAltitude; break; case JournalTypeEnum.Touchdown: JournalTouchdown jt = he.journalEntry as JournalTouchdown; if (jt.PlayerControlled.HasValue && jt.PlayerControlled.Value) { latitude = jt.Latitude; longitude = jt.Longitude; altitude = 0; } break; case JournalTypeEnum.Location: JournalLocation jl = he.journalEntry as JournalLocation; latitude = jl.Latitude; longitude = jl.Longitude; altitude = null; break; case JournalTypeEnum.Liftoff: JournalLiftoff jlo = he.journalEntry as JournalLiftoff; if (jlo.PlayerControlled.HasValue && jlo.PlayerControlled.Value) { latitude = jlo.Latitude; longitude = jlo.Longitude; altitude = 0; } break; case JournalTypeEnum.LeaveBody: latitude = null; longitude = null; altitude = null; break; case JournalTypeEnum.FSDJump: // to allow us to do PopulateBookmark.. break; default: return; } PopulateBookmarkCombo(); DisplayCompass(); } }
// curmats may be null Point CreateMaterialNodes(List <ExtPictureBox.ImageElement> pc, JournalScan sn, MaterialCommoditiesList curmats, HistoryList hl, Point matpos, Size matsize) { Point startpos = matpos; Point maximum = matpos; int noperline = 0; string matclicktext = sn.DisplayMaterials(2, curmats, hl.GetLast?.MaterialCommodity); foreach (KeyValuePair <string, double> sd in sn.Materials) { string tooltip = sn.DisplayMaterial(sd.Key, sd.Value, curmats, hl.GetLast?.MaterialCommodity); Color fillc = Color.Yellow; string abv = sd.Key.Substring(0, 1); MaterialCommodityData mc = MaterialCommodityData.GetByFDName(sd.Key); if (mc != null) { abv = mc.Shortname; fillc = mc.Colour; if (HideFullMaterials) // check full { int?limit = mc.MaterialLimit(); MaterialCommodities matnow = curmats?.Find(mc); // allow curmats = null // debug if (matnow != null && mc.shortname == "Fe") matnow.count = 10000; if (matnow != null && limit != null && matnow.Count >= limit) // and limit { continue; } } if (ShowOnlyMaterialsRare && mc.IsCommonMaterial) { continue; } } System.Drawing.Imaging.ColorMap colormap = new System.Drawing.Imaging.ColorMap(); colormap.OldColor = Color.White; // this is the marker colour to replace colormap.NewColor = fillc; Bitmap mat = BaseUtils.BitMapHelpers.ReplaceColourInBitmap((Bitmap)Icons.Controls.Scan_Bodies_Material, new System.Drawing.Imaging.ColorMap[] { colormap }); BaseUtils.BitMapHelpers.DrawTextCentreIntoBitmap(ref mat, abv, stdfont, Color.Black); ExtPictureBox.ImageElement ie = new ExtPictureBox.ImageElement( new Rectangle(matpos.X, matpos.Y, matsize.Width, matsize.Height), mat, tooltip + "\n\n" + "All " + matclicktext, tooltip); pc.Add(ie); maximum = new Point(Math.Max(maximum.X, matpos.X + matsize.Width), Math.Max(maximum.Y, matpos.Y + matsize.Height)); if (++noperline == 4) { matpos = new Point(startpos.X, matpos.Y + matsize.Height + materiallinespacerxy); noperline = 0; } else { matpos.X += matsize.Width + materiallinespacerxy; } } return(maximum); }