Beispiel #1
0
        void AddModuleLine(ShipModule sm, ShipInformation si = null)
        {
            string infoentry = "";

            if (si != null)
            {
                infoentry = si.ShipNameIdentType;
            }
            else if (sm.AmmoHopper.HasValue)
            {
                infoentry = sm.AmmoHopper.Value.ToString();
                if (sm.AmmoClip.HasValue)
                {
                    infoentry += "/" + sm.AmmoClip.ToString();
                }
            }

            string value = (sm.Value.HasValue && sm.Value.Value > 0) ? sm.Value.Value.ToString("N0") : "";

            string typename = sm.LocalisedItem;

            if (typename.IsEmpty())
            {
                typename = ShipModuleData.Instance.GetItemProperties(sm.ItemFD).ModType;
            }

            string eng = "";

            if (sm.Engineering != null)
            {
                eng = sm.Engineering.FriendlyBlueprintName + ":" + sm.Engineering.Level.ToStringInvariant();
            }

            object[] rowobj = { typename,
                                sm.Item,                                           sm.Slot, infoentry,
                                sm.Mass > 0 ? (sm.Mass.ToString("0.#") + "t") : "",
                                eng,
                                value,                                             sm.PE() };

            dataGridViewModules.Rows.Add(rowobj);

            if (sm.Engineering != null)
            {
                string text = sm.Engineering.ToString();
                EliteDangerousCalculations.FSDSpec spec = sm.GetFSDSpec();
                if (spec != null)
                {
                    text += spec.ToString();
                }

                dataGridViewModules.Rows[dataGridViewModules.Rows.Count - 1].Cells[5].ToolTipText = text;
            }
        }
        void AddModuleLine(ShipModule sm)
        {
            string ammo = "";

            if (sm.AmmoHopper.HasValue)
            {
                ammo = sm.AmmoHopper.Value.ToString();
                if (sm.AmmoClip.HasValue)
                {
                    ammo += "/" + sm.AmmoClip.ToString();
                }
            }

            string value = (sm.Value.HasValue && sm.Value.Value > 0) ? sm.Value.Value.ToStringInvariant("N0") : "";

            string typename = sm.LocalisedItem;

            if (typename.IsEmpty())
            {
                typename = ShipModuleData.Instance.GetItemProperties(sm.ItemFD).ModType;
            }

            object[] rowobj = { typename,
                                sm.Item,                                               sm.Slot, ammo,
                                sm.Mass > 0 ? (sm.Mass.ToStringInvariant() + "t") : "",
                                sm.Engineering?.FriendlyBlueprintName ?? "",
                                value,                                                 sm.PE() };

            dataGridViewModules.Rows.Add(rowobj);

            if (sm.Engineering != null)
            {
                string text = sm.Engineering.ToString();
                EliteDangerousCalculations.FSDSpec spec = sm.GetFSDSpec();
                if (spec != null)
                {
                    text += spec.ToString();
                }

                dataGridViewModules.Rows[dataGridViewModules.Rows.Count - 1].Cells[5].ToolTipText = text;
            }
        }
Beispiel #3
0
        private void DisplayShip(ShipInformation si)
        {
            //System.Diagnostics.Debug.WriteLine("HE " + last_he.Indexno);
            last_si = si;

            foreach (string key in si.Modules.Keys)
            {
                EliteDangerousCore.ShipModule sm = si.Modules[key];
                AddModuleLine(sm);
            }

            double hullmass   = si.HullMass();
            double modulemass = si.ModuleMass();

            EliteDangerousCalculations.FSDSpec fsdspec = si.GetFSDSpec();
            if (fsdspec != null)
            {
                EliteDangerousCalculations.FSDSpec.JumpInfo ji = fsdspec.GetJumpInfo(0, modulemass + hullmass, si.FuelCapacity, si.FuelCapacity / 2);
                AddInfoLine("FSD Avg Jump".T(EDTx.UserControlModules_FSDAvgJump), ji.avgsinglejumpnocargo.ToString("N2") + "ly", "Half tank, no cargo".T(EDTx.UserControlModules_HT), fsdspec.ToString());
                DataGridViewRow rw = dataGridViewModules.Rows[dataGridViewModules.Rows.Count - 1];
                AddInfoLine("FSD Max Range".T(EDTx.UserControlModules_FSDMaxRange), ji.maxjumprange.ToString("N2") + "ly", "Full Tank, no cargo".T(EDTx.UserControlModules_FT), fsdspec.ToString());
                AddInfoLine("FSD Maximum Fuel per jump".T(EDTx.UserControlModules_FSDMaximumFuelperjump), fsdspec.MaxFuelPerJump.ToString() + "t", "", fsdspec.ToString());
            }

            if (si.HullValue > 0)
            {
                AddValueLine("Hull Value".T(EDTx.UserControlModules_HullValue), si.HullValue);
            }
            if (si.ModulesValue > 0)
            {
                AddValueLine("Modules Value".T(EDTx.UserControlModules_ModulesValue), si.ModulesValue);
            }
            if (si.HullValue > 0 && si.ModulesValue > 0)
            {
                AddValueLine("Total Cost".T(EDTx.UserControlModules_TotalCost), si.HullValue + si.ModulesValue);
            }
            if (si.Rebuy > 0)
            {
                AddValueLine("Rebuy Cost".T(EDTx.UserControlModules_RebuyCost), si.Rebuy);
            }

            AddMassLine("Mass Hull".T(EDTx.UserControlModules_MassHull), hullmass.ToString("N1") + "t");
            AddMassLine("Mass Unladen".T(EDTx.UserControlModules_MassUnladen), (hullmass + modulemass).ToString("N1") + "t");
            if (si.UnladenMass > 0)
            {
                AddMassLine("Mass FD Unladen".T(EDTx.UserControlModules_MassFDUnladen), si.UnladenMass.ToString("N1") + "t");
            }
            AddMassLine("Mass Modules".T(EDTx.UserControlModules_MassModules), modulemass.ToString("N1") + "t");

            AddInfoLine("Manufacturer".T(EDTx.UserControlModules_Manufacturer), si.Manufacturer);

            if (si.FuelCapacity > 0)
            {
                AddInfoLine("Fuel Capacity".T(EDTx.UserControlModules_FuelCapacity), si.FuelCapacity.ToString("N1") + "t");
            }
            if (si.FuelLevel > 0)
            {
                AddInfoLine("Fuel Level".T(EDTx.UserControlModules_FuelLevel), si.FuelLevel.ToString("N1") + "t");
            }
            if (si.ReserveFuelCapacity > 0)
            {
                AddInfoLine("Fuel Reserve Capacity".T(EDTx.UserControlModules_FuelReserveCapacity), si.ReserveFuelCapacity.ToString("N2") + "t");
            }
            if (si.HullHealthAtLoadout > 0)
            {
                AddInfoLine("Hull Health (Loadout)".T(EDTx.UserControlModules_HullHealth), si.HullHealthAtLoadout.ToString("N1") + "%");
            }

            double fuelwarn = si.FuelWarningPercent;

            AddInfoLine("Fuel Warning %".T(EDTx.UserControlModules_FuelWarning), fuelwarn > 0 ? fuelwarn.ToString("N1") + "%" : "Off".T(EDTx.Off));

            AddInfoLine("Pad Size".T(EDTx.UserControlModules_PadSize), si.PadSize);
            AddInfoLine("Main Thruster Speed".T(EDTx.UserControlModules_MainThrusterSpeed), si.Speed.ToString("0.#"));
            AddInfoLine("Main Thruster Boost".T(EDTx.UserControlModules_MainThrusterBoost), si.Boost.ToString("0.#"));

            if (si.InTransit)
            {
                AddInfoLine("In Transit to ".T(EDTx.UserControlModules_InTransitto), (si.StoredAtSystem ?? "Unknown".T(EDTx.Unknown)) + ":" + (si.StoredAtStation ?? "Unknown".T(EDTx.Unknown)));
            }
            else if (si.StoredAtSystem != null)
            {
                AddInfoLine("Stored at".T(EDTx.UserControlModules_Storedat), si.StoredAtSystem + ":" + (si.StoredAtStation ?? "Unknown".T(EDTx.Unknown)));
            }

            int cc = si.CargoCapacity();

            if (cc > 0)
            {
                AddInfoLine("Cargo Capacity".T(EDTx.UserControlModules_CargoCapacity), cc.ToString("N0") + "t");
            }

            labelVehicle.Visible       = true;
            labelVehicle.Text          = si.ShipFullInfo(cargo: false, fuel: false);
            buttonExtConfigure.Visible = true;
            buttonExtCoriolis.Visible  = buttonExtEDShipyard.Visible = si.CheckMinimumJSONModules();
        }
Beispiel #4
0
        private void Display(HistoryEntry he, HistoryList hl, bool selectedEntry)
        {
            //System.Diagnostics.Debug.WriteLine("SI:Display ");

            if (neverdisplayed)
            {
                UpdateViewOnSelection();  // then turn the right ones on
                neverdisplayed = false;
            }

            last_he = he;

            if (last_he != null)
            {
                SetControlText(he.System.Name);

                HistoryEntry lastfsd = hl.GetLastHistoryEntry(x => x.journalEntry is EliteDangerousCore.JournalEvents.JournalFSDJump, he);

                textBoxSystem.Text      = he.System.Name;
                panelFD.BackgroundImage = (lastfsd != null && (lastfsd.journalEntry as EliteDangerousCore.JournalEvents.JournalFSDJump).EDSMFirstDiscover) ? EDDiscovery.Icons.Controls.firstdiscover : EDDiscovery.Icons.Controls.notfirstdiscover;

                discoveryform.history.FillEDSM(he); // Fill in any EDSM info we have

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

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

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

                    textBoxPosition.Text = he.System.X.ToString(SingleCoordinateFormat) + separ + he.System.Y.ToString(SingleCoordinateFormat) + separ + he.System.Z.ToString(SingleCoordinateFormat);

                    ISystem homesys = EDCommander.Current.HomeSystemIOrSol;

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

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

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

                buttonRoss.Enabled = buttonEDDB.Enabled = enableedddross;

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

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

                List <MissionState> mcurrent = (from MissionState ms in he.MissionList.Missions.Values where ms.InProgressDateTime(last_he.EventTimeUTC) orderby ms.Mission.EventTimeUTC descending select ms).ToList();

                if (mcurrent == null || mcurrent.Count == 0)
                {
                    richTextBoxScrollMissions.Text = "No Missions".T(EDTx.UserControlSysInfo_NoMissions);
                }
                else
                {
                    string t = "";
                    foreach (MissionState ms in mcurrent)
                    {
                        t = ObjectExtensionsStrings.AppendPrePad(t,
                                                                 JournalFieldNaming.ShortenMissionName(ms.Mission.Name)
                                                                 + " Exp:" + (EDDiscoveryForm.EDDConfig.DisplayUTC ? ms.Mission.Expiry : ms.Mission.Expiry.ToLocalTime())
                                                                 + " @ " + ms.DestinationSystemStation(),
                                                                 Environment.NewLine);
                    }

                    richTextBoxScrollMissions.Text = t;
                }

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

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

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

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

                textBoxJumpRange.Text = "";

                if (he.ShipInformation != null)
                {
                    ShipInformation si = he.ShipInformation;

                    textBoxShip.Text = si.ShipFullInfo(cargo: false, fuel: false);
                    if (si.FuelCapacity > 0 && si.FuelLevel > 0)
                    {
                        textBoxFuel.Text = si.FuelLevel.ToStringInvariant("0.#") + "/" + si.FuelCapacity.ToStringInvariant("0.#");
                    }
                    else if (si.FuelCapacity > 0)
                    {
                        textBoxFuel.Text = si.FuelCapacity.ToStringInvariant("0.#");
                    }
                    else
                    {
                        textBoxFuel.Text = "N/A".T(EDTx.UserControlSysInfo_NA);
                    }

                    EliteDangerousCalculations.FSDSpec fsd = si.GetFSDSpec();
                    if (fsd != null)
                    {
                        EliteDangerousCalculations.FSDSpec.JumpInfo ji = fsd.GetJumpInfo(he.MaterialCommodity.CargoCount,
                                                                                         si.ModuleMass() + si.HullMass(), si.FuelLevel, si.FuelCapacity / 2);

                        //System.Diagnostics.Debug.WriteLine("Jump range " + si.FuelLevel + " " + si.FuelCapacity + " " + ji.cursinglejump);
                        textBoxJumpRange.Text = ji.cursinglejump.ToString("N2") + "ly";
                    }
                }
                else
                {
                    textBoxShip.Text = textBoxFuel.Text = "";
                }

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

                buttonRoss.Enabled = buttonEDDB.Enabled = false;
                SetNote("");
            }
        }
Beispiel #5
0
        public JToken NewSRec(EliteDangerousCore.HistoryList hl, string type, int entry)       // entry = -1 means latest
        {
            HistoryEntry he = hl.EntryOrder()[entry];

            JObject response = new JObject();

            response["responsetype"] = type;
            response["entry"]        = entry;

            JObject systemdata = new JObject();

            systemdata["System"]        = he.System.Name;
            systemdata["SystemAddress"] = he.System.SystemAddress;
            systemdata["PosX"]          = he.System.X.ToStringInvariant("0.00");
            systemdata["PosY"]          = he.System.Y.ToStringInvariant("0.00");
            systemdata["PosZ"]          = he.System.Z.ToStringInvariant("0.00");
            systemdata["EDSMID"]        = he.System.EDSMID.ToStringInvariant();
            systemdata["VisitCount"]    = hl.GetVisitsCount(he.System.Name);
            response["SystemData"]      = systemdata;

            // TBD.. if EDSMID = 0 , we may not have looked at it in the historywindow, do we want to do a lookup?

            JObject sysstate = new JObject();

            hl.ReturnSystemInfo(he, out string allegiance, out string economy, out string gov, out string faction, out string factionstate, out string security);
            sysstate["State"]      = factionstate;
            sysstate["Allegiance"] = allegiance;
            sysstate["Gov"]        = gov;
            sysstate["Economy"]    = economy;
            sysstate["Faction"]    = faction;
            sysstate["Security"]   = security;
            sysstate["MarketID"]   = he.MarketID;
            response["EDDB"]       = sysstate;

            var mcl = hl.MaterialCommoditiesMicroResources.Get(he.MaterialCommodity);

            int    cargocount = MaterialCommoditiesMicroResourceList.CargoCount(mcl);
            string shipname = "N/A", fuel = "N/A", range = "N/A", tanksize = "N/A";
            string cargo = cargocount.ToStringInvariant();

            ShipInformation si = he.ShipInformation;

            if (si != null)
            {
                shipname = si.ShipFullInfo(cargo: false, fuel: false);
                if (si.FuelLevel > 0)
                {
                    fuel = si.FuelLevel.ToStringInvariant("0.#");
                }
                if (si.FuelCapacity > 0)
                {
                    tanksize = si.FuelCapacity.ToStringInvariant("0.#");
                }

                EliteDangerousCalculations.FSDSpec fsd = si.GetFSDSpec();
                if (fsd != null)
                {
                    EliteDangerousCalculations.FSDSpec.JumpInfo ji = fsd.GetJumpInfo(cargocount,
                                                                                     si.ModuleMass() + si.HullMass(), si.FuelLevel, si.FuelCapacity / 2);
                    range = ji.cursinglejump.ToString("N2") + "ly";
                }

                int cargocap = si.CargoCapacity();

                if (cargocap > 0)
                {
                    cargo += "/" + cargocap.ToStringInvariant();
                }
            }

            JObject ship = new JObject();

            ship["Ship"]           = shipname;
            ship["Fuel"]           = fuel;
            ship["Range"]          = range;
            ship["TankSize"]       = tanksize;
            ship["Cargo"]          = cargo;
            ship["Data"]           = MaterialCommoditiesMicroResourceList.DataCount(mcl).ToStringInvariant();
            ship["Materials"]      = MaterialCommoditiesMicroResourceList.MaterialsCount(mcl).ToStringInvariant();
            ship["MicroResources"] = MaterialCommoditiesMicroResourceList.MicroResourcesCount(mcl).ToStringInvariant();
            response["Ship"]       = ship;

            JObject travel = new JObject();

            if (he.isTravelling)
            {
                travel["Dist"]         = he.TravelledDistance.ToStringInvariant("0.0");
                travel["Jumps"]        = he.Travelledjumps.ToStringInvariant();
                travel["UnknownJumps"] = he.TravelledMissingjump.ToStringInvariant();
                travel["Time"]         = he.TravelledSeconds.ToString();
            }
            else
            {
                travel["Time"] = travel["Jumps"] = travel["Dist"] = "";
            }

            response["Travel"] = travel;

            response["Bodyname"] = he.WhereAmI;

            if (he.System.HasCoordinate)         // cursystem has them?
            {
                response["HomeDist"] = he.System.Distance(EDCommander.Current.HomeSystemIOrSol).ToString("0.##");
                response["SolDist"]  = he.System.Distance(0, 0, 0).ToString("0.##");
            }
            else
            {
                response["SolDist"] = response["HomeDist"] = "-";
            }

            response["GameMode"]  = he.GameModeGroup;
            response["Credits"]   = he.Credits.ToStringInvariant();
            response["Commander"] = EDCommander.Current.Name;
            response["Mode"]      = he.TravelState.ToString();

            return(response);
        }