예제 #1
0
        void DumpInfo(ActionProgramRun ap, KeyValuePair <string, EliteDangerousCore.StarScan.ScanNode> scannode, string prefix, string subname)
        {
            EliteDangerousCore.JournalEvents.JournalScan sc = scannode.Value.ScanData;

            ap[prefix]                       = scannode.Key;
            ap[prefix + "_type"]             = scannode.Value.NodeType.ToString();
            ap[prefix + "_assignedname"]     = scannode.Value.OwnName;
            ap[prefix + "_assignedfullname"] = scannode.Value.FullName;
            ap[prefix + "_data"]             = (sc != null) ? "1" : "0";
            ap[prefix + "_signals"]          = scannode.Value.Signals != null?EliteDangerousCore.JournalEvents.JournalSAASignalsFound.SignalList(scannode.Value.Signals, 0, ",", true) : "";

            if (sc != null)
            {
                ap[prefix + "_isstar"]             = sc.IsStar ? "1" : "0";
                ap[prefix + "_edsmbody"]           = sc.IsEDSMBody ? "1" : "0";
                ap[prefix + "_bodyname"]           = sc.BodyName;
                ap[prefix + "_bodydesignation"]    = sc.BodyDesignationOrName;
                ap[prefix + "_orbitalperiod"]      = sc.nOrbitalPeriod.ToNANNullSafeString("0.###");
                ap[prefix + "_rotationperiod"]     = sc.nRotationPeriod.ToNANNullSafeString("0.###");
                ap[prefix + "_surfacetemperature"] = sc.nSurfaceTemperature.ToNANNullSafeString("0.###");
                ap[prefix + "_distls"]             = sc.DistanceFromArrivalLS.ToNANSafeString("0.###");

                if (sc.IsStar)
                {
                    ap[prefix + "_startype"]     = sc.StarType;
                    ap[prefix + "_startypetext"] = sc.StarTypeText;
                    ap[prefix + "_stellarmass"]  = (sc.nStellarMass ?? 0).ToString("0.###");
                    ap[prefix + "_age"]          = sc.nAge.ToNANNullSafeString("0.##");
                    ap[prefix + "_mag"]          = sc.nAbsoluteMagnitude.ToNANNullSafeString("0");
                    EliteDangerousCore.JournalEvents.JournalScan.HabZones hz = sc.GetHabZones();
                    ap[prefix + "_habinner"] = hz != null?hz.HabitableZoneInner.ToString("0.##") : "";

                    ap[prefix + "_habouter"] = hz != null?hz.HabitableZoneOuter.ToString("0.##") : "";
                }
                else
                {
                    ap[prefix + "_class"]          = sc.PlanetClass.ToNullSafeString();
                    ap[prefix + "_landable"]       = sc.IsLandable ? "Landable" : "Not Landable";
                    ap[prefix + "_atmosphere"]     = sc.Atmosphere.ToNullSafeString();
                    ap[prefix + "_terraformstate"] = sc.TerraformState.ToNullSafeString();
                    ap[prefix + "_volcanism"]      = sc.Volcanism.ToNullSafeString();
                    ap[prefix + "_gravity"]        = sc.nSurfaceGravity.ToNANNullSafeString("0.###");
                    ap[prefix + "_pressure"]       = sc.nSurfacePressure.ToNANNullSafeString("0.###");
                    ap[prefix + "_mass"]           = sc.nMassEM.ToNANNullSafeString("0.###");
                    ap.AddDataOfType(sc.Materials, typeof(Dictionary <string, double>), prefix + "_Materials");
                }

                ap[prefix + "_text"]  = sc.DisplayString();
                ap[prefix + "_value"] = sc.EstimatedValue.ToStringInvariant();
            }

            if (subname != null)
            {
                int totalchildren = (scannode.Value.Children != null) ? scannode.Value.Children.Count : 0;
                int totalbodies   = (scannode.Value.Children != null) ? (from x in scannode.Value.Children where x.Value.NodeType == StarScan.ScanNodeType.body select x).Count() : 0;
                ap[prefix + subname]           = totalchildren.ToStringInvariant();
                ap[prefix + subname + "_Only"] = totalbodies.ToStringInvariant();       // we do this, because children can be other than bodies..
            }
        }
예제 #2
0
        // draw scannode into an imagebox in widthavailable..
        // curmats may be null
        public void DrawSystem(ExtendedControls.ExtPictureBox imagebox, int widthavailable,
                               StarScan.SystemNode systemnode, List <MaterialCommodityMicroResource> historicmats, List <MaterialCommodityMicroResource> curmats, string opttext = null, string[] filter = null)
        {
            imagebox.ClearImageList();  // does not clear the image, render will do that

            if (systemnode != null)
            {
                var notscannedbitmap = (Bitmap)BaseUtils.Icons.IconSet.GetIcon("Bodies.Unknown");

                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, LabelColor, 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);

                bool drawnsignals = false;                                                // set if we drawn signals against any of the stars

                foreach (StarScan.ScanNode starnode in systemnode.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;
                    }

                    if (!starnode.DoesNodeHaveNonEDSMScansBelow() && !ShowEDSMBodies)      // if we don't have any non edsm bodies at or under the node, and we are not showing edsm bodies, ignore
                    {
                        continue;
                    }

                    {  // Draw star
                        Image barycentre = BaseUtils.Icons.IconSet.GetIcon("Controls.Scan.Bodies.Barycentre");

                        Point maxpos = DrawNode(starcontrols, starnode, historicmats, curmats,
                                                (starnode.NodeType == StarScan.ScanNodeType.barycentre) ? barycentre: notscannedbitmap,
                                                leftmiddle, false, out Rectangle starimagepos, StarSize, DrawLevel.TopLevelStar); // the last part nerfs the label down to the right position

                        maxitemspos = new Point(Math.Max(maxitemspos.X, maxpos.X), Math.Max(maxitemspos.Y, maxpos.Y));

                        if (!drawnsignals && systemnode.FSSSignalList.Count > 0)           // Draw signals, if not drawn
                        {
                            drawnsignals = true;
                            Point maxsignalpos = DrawSignals(starcontrols, new Point(starimagepos.Right + moonspacerx, leftmiddle.Y), systemnode.FSSSignalList, StarSize.Height * 6 / 4, 16);
                            maxitemspos = new Point(Math.Max(maxitemspos.X, maxsignalpos.X), Math.Max(maxitemspos.Y, maxsignalpos.Y));
                        }

                        leftmiddle = new Point(maxitemspos.X + starfirstplanetspacerx, leftmiddle.Y);       // move the cursor on to the right of the box, no spacing
                    }

                    if (starnode.Children != null)
                    {
                        Point firstcolumn = leftmiddle;

                        Queue <StarScan.ScanNode> belts;
                        if (starnode.ScanData != null && (!starnode.ScanData.IsEDSMBody || ShowEDSMBodies))                                       // have scandata on star, and its not edsm or allowed edsm
                        {
                            belts = new Queue <StarScan.ScanNode>(starnode.Children.Values.Where(s => s.NodeType == 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;

                        EliteDangerousCore.JournalEvents.JournalScan.HabZones hz = starnode.ScanData?.GetHabZones();

                        double habzonestartls = hz != null ? hz.HabitableZoneInner : 0;
                        double habzoneendls   = hz != null ? hz.HabitableZoneOuter : 0;

                        Image beltsi = BaseUtils.Icons.IconSet.GetIcon("Controls.Scan.Bodies.Belt");

                        // process body and stars only

                        List <StarScan.ScanNode> planetsinorder = starnode.Children.Values.Where(s => s.NodeType == StarScan.ScanNodeType.body || s.NodeType == 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 > widthavailable)                                             // 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, historicmats, curmats, beltsi, leftmiddle, false, out Rectangle 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() || ShowEDSMBodies)
                            {
                                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, historicmats, curmats, leftmiddle, filter, habzone, out int centreplanet);

                                Point pcnt = new Point(centreplanet, leftmiddle.Y);

                                if (maxplanetpos.X > widthavailable)          // 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 > widthavailable)                                             // 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, historicmats, curmats, beltsi, leftmiddle, false, out Rectangle 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 > widthavailable)                                                                 // 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));
                }

                if (!drawnsignals && systemnode.FSSSignalList.Count > 0)  // if no stars were drawn, but signals..
                {
                    Point maxpos = CreateImageAndLabel(starcontrols, notscannedbitmap, leftmiddle, StarSize, out Rectangle starpos, new string[] { "" }, "", false);
                    DrawSignals(starcontrols, new Point(starpos.Right + moonspacerx, leftmiddle.Y), systemnode.FSSSignalList, StarSize.Height * 6 / 4, 16);       // draw them, nothing else to follow
                }

                imagebox.AddRange(starcontrols);
            }

            imagebox.Render();      // replaces image..
        }