Beispiel #1
0
        private void Display()
        {
            DataGridViewColumn sortcol   = dataGridViewModules.SortedColumn != null ? dataGridViewModules.SortedColumn : dataGridViewModules.Columns[0];
            SortOrder          sortorder = dataGridViewModules.SortOrder;

            dataGridViewModules.Rows.Clear();

            LabelVehicleText.Visible  = false;
            labelVehicle.Visible      = false;
            buttonExtCoriolis.Visible = false;

            if (comboBoxShips.Text.Contains("Stored"))
            {
                if (last_he != null && last_he.StoredModules != null)
                {
                    ModulesInStore mi = last_he.StoredModules;
                    labelVehicle.Text = "";
                    int i = 1;
                    foreach (EliteDangerousCore.JournalEvents.JournalLoadout.ShipModule sm in mi.StoredModules)
                    {
                        object[] rowobj = { i.ToString(), sm.Item, sm.LocalisedItem.ToNullSafeString() };
                        dataGridViewModules.Rows.Add(rowobj);
                        i++;
                    }
                }
            }
            else if (comboBoxShips.Text.Contains("Travel") || comboBoxShips.Text.Length == 0)  // second is due to the order History gets called vs this on start
            {
                if (last_he != null && last_he.ShipInformation != null)
                {
                    Display(last_he.ShipInformation);
                }
            }
            else
            {
                ShipInformation si = discoveryform.history.shipinformationlist.GetShipByShortName(comboBoxShips.Text);
                if (si != null)
                {
                    Display(si);
                }
            }

            dataGridViewModules.Sort(sortcol, (sortorder == SortOrder.Descending) ? ListSortDirection.Descending : ListSortDirection.Ascending);
            dataGridViewModules.Columns[sortcol.Index].HeaderCell.SortGlyphDirection = sortorder;
        }
        public void AddShip(JsonElement[] sendData)
        {
            var connectionId = Context.ConnectionId;
            int headX        = sendData[0].GetInt32();
            int headY        = sendData[1].GetInt32();
            int tailX        = sendData[2].GetInt32();
            int tailY        = sendData[3].GetInt32();
            int length       = sendData[4].GetInt32();
            int playerId     = Int32.Parse(sendData[5].GetString());

            Game   game     = _activeGames.GetGameByPlayerId(playerId);
            Player player   = _activeGames.GetPlayerById(playerId);
            var    head     = new Coords(headX, headY);
            var    shipInfo = new ShipInformation()
            {
                Location = new ShipLocation()
                {
                    Coords    = head,
                    Direction = GetDirection(head, new Coords(tailX, tailY))
                },
                Ship = new Ship(length)
            };
            bool addedsuccessfull = true;

            try
            {
                game.AddShip(player, shipInfo);
            }
            catch (Exception ex)
            {
                if (ex.Data["type"] != null && (GameException)ex.Data["type"] == GameException.ShipsTouch)
                {
                    Clients.Client(connectionId).SendAsync("ShipsCantTouch");
                }
                addedsuccessfull = false;
            }
            if (addedsuccessfull)
            {
                var jsonCoordList = JsonConvert.SerializeObject(shipInfo.GetCoordsFromShipInformation());
                Clients.Client(connectionId).SendAsync("AddShip", jsonCoordList, length);
            }
        }
Beispiel #3
0
        private void Display(ShipInformation si)
        {
            foreach (string key in si.Modules.Keys)
            {
                EliteDangerousCore.JournalEvents.JournalLoadout.ShipModule sm = si.Modules[key];

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

                string blueprint = "";
                if (sm.Blueprint != null)
                {
                    blueprint = sm.Blueprint;
                    if (sm.BlueprintLevel.HasValue)
                    {
                        blueprint += ":" + sm.BlueprintLevel.ToString();
                    }
                }

                string value = (sm.Value.HasValue && sm.Value.Value > 0) ? sm.Value.Value.ToString(System.Globalization.CultureInfo.InvariantCulture) : "";


                object[] rowobj = { sm.Slot, sm.Item, sm.LocalisedItem.ToNullSafeString(), ammo, blueprint, value, sm.PE() };
                // debug object[] rowobj = { sm.Slot+":" + sm.SlotFD, sm.Item + ":" + sm.ItemFD, sm.LocalisedItem.ToNullSafeString() , ammo, blueprint , value, sm.PE() };
                dataGridViewModules.Rows.Add(rowobj);
            }

            LabelVehicleText.Visible  = labelVehicle.Visible = true;
            labelVehicle.Text         = si.ShipFullInfo();
            buttonExtCoriolis.Visible = si.CheckMinimumJSONModules();
        }
Beispiel #4
0
        private void buttonExtCoriolis_Click(object sender, EventArgs e)
        {
            ShipInformation si = null;

            if (comboBoxShips.Text.Contains("Travel") || comboBoxShips.Text.Length == 0)  // second is due to the order History gets called vs this on start
            {
                if (last_he != null && last_he.ShipInformation != null)
                {
                    si = last_he.ShipInformation;
                }
            }
            else
            {
                si = discoveryform.history.shipinformationlist.GetShipByNameIdentType(comboBoxShips.Text);
            }

            if (si != null)
            {
                string errstr;
                string s = si.ToJSONCoriolis(out errstr);

                if (errstr.Length > 0)
                {
                    ExtendedControls.MessageBoxTheme.Show(FindForm(), errstr + Environment.NewLine + "This is probably a new or powerplay module" + Environment.NewLine + "Report to EDD Team by Github giving the full text above", "Unknown Module Type");
                }

                string uri = Properties.Resources.URLCoriolis + "data=" + BaseUtils.HttpUriEncode.URIGZipBase64Escape(s) + "&bn=" + Uri.EscapeDataString(si.Name);

                if (!BaseUtils.BrowserInfo.LaunchBrowser(uri))
                {
                    ExtendedControls.InfoForm info = new ExtendedControls.InfoForm();
                    info.Info("Cannot launch browser, use this JSON for manual Coriolis import", Icon.ExtractAssociatedIcon(System.Reflection.Assembly.GetExecutingAssembly().Location),
                              s, new int[] { 0, 100 });
                    info.ShowDialog(FindForm());
                }
            }
        }
        private void buttonExtCoriolis_Click(object sender, EventArgs e)
        {
            ShipInformation si = null;

            if (comboBoxShips.Text == travelhistorytext || comboBoxShips.Text.Length == 0)  // second is due to the order History gets called vs this on start
            {
                if (last_he?.ShipInformation != null)
                {
                    si = last_he.ShipInformation;
                }
            }
            else
            {
                si = discoveryform.history.ShipInformationList.GetShipByNameIdentType(comboBoxShips.Text);
            }

            if (si != null)
            {
                string errstr;
                string s = si.ToJSONCoriolis(out errstr);

                if (errstr.Length > 0)
                {
                    ExtendedControls.MessageBoxTheme.Show(FindForm(), errstr + Environment.NewLine + "This is probably a new or powerplay module" + Environment.NewLine + "Report to EDD Team by Github giving the full text above", "Unknown Module Type");
                }

                string uri = EDDConfig.Instance.CoriolisURL + "data=" + BaseUtils.HttpUriEncode.URIGZipBase64Escape(s) + "&bn=" + Uri.EscapeDataString(si.Name);

                if (!BaseUtils.BrowserInfo.LaunchBrowser(uri))
                {
                    ExtendedControls.InfoForm info = new ExtendedControls.InfoForm();
                    info.Info("Cannot launch browser, use this JSON for manual Coriolis import", FindForm().Icon, s);
                    info.ShowDialog(FindForm());
                }
            }
        }
Beispiel #6
0
        public void SendShipInfo(ShipInformation si, int cargo, ShipInformation sicurrent, long cash, long loan,
                                 JournalProgress progress, JournalRank rank     // both may be null
                                 )
        {
            lock (LockShipInfo)               // lets not double send in different threads.
            {
                if (!si.Equals(LastShipInfo)) // if we are sending new ship info..
                {
                    System.Diagnostics.Debug.WriteLine("Update EDSM with ship info" + si.ID + " " + si.ShipType + " " + cargo);
                    CommanderUpdateShip(si.ID, si.ShipType.Alt("Unknown"), si, cargo);
                    LastShipInfo = si;
                }

                if (LastShipID != sicurrent.ID) // if we have a new current ship
                {
                    System.Diagnostics.Debug.WriteLine("Update EDSM with current ship" + sicurrent.ID);
                    CommanderSetCurrentShip(sicurrent.ID);
                    LastShipID = sicurrent.ID;
                }

                if (LastEDSMCredits != cash)    // if our cash has changed..
                {
                    System.Diagnostics.Debug.WriteLine("Update EDSM with credits" + cash);
                    SetCredits(cash, loan);
                    LastEDSMCredits = cash;
                }

                if (progress != null && rank != null && (!Object.ReferenceEquals(progress, LastProgress) || !Object.ReferenceEquals(rank, LastRank)))
                {
                    System.Diagnostics.Debug.WriteLine("Update EDSM with ranks");
                    SetRanks((int)rank.Combat, progress.Combat, (int)rank.Trade, progress.Trade, (int)rank.Explore, progress.Explore, (int)rank.CQC, progress.CQC, (int)rank.Federation, progress.Federation, (int)rank.Empire, progress.Empire);
                    LastProgress = progress;
                    LastRank     = rank;
                }
            }
        }
Beispiel #7
0
        void displayLastFSDOrScoop(HistoryEntry he)
        {
            pictureBox.ClearImageList();

            lastHE = he;

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

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

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

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

                EliteDangerousCalculations.FSDSpec.JumpInfo ji = he.GetJumpInfo();          // may be null

                String line = "  Target Not Set";

                if (TargetClass.GetTargetPosition(out string name, out Point3D tpos))
                {
                    double dist = he.System.Distance(tpos.X, tpos.Y, tpos.Z);

                    string mesg = "Left";

                    if (ji != null)
                    {
                        int jumps = (int)Math.Ceiling(dist / ji.avgsinglejump);
                        if (jumps > 0)
                        {
                            mesg = "@ " + jumps.ToString() + ((jumps == 1) ? " jump" : " jumps");
                        }
                    }

                    line = String.Format("{0} | {1:N2}ly {2}", name, dist, mesg);
                }

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

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

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

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

                ShipInformation si = he.ShipInformation;
                if (si != null)
                {
                    double fuel                = si.FuelLevel;
                    double tanksize            = si.FuelCapacity;
                    double warninglevelpercent = si.FuelWarningPercent;

                    line = String.Format("{0}/{1}t", fuel.ToString("N1"), tanksize.ToString("N1"));

                    if (warninglevelpercent > 0 && fuel < tanksize * warninglevelpercent / 100.0)
                    {
                        textcolour = discoveryform.theme.TextBlockHighlightColor;
                        line      += String.Format(" < {0}%", warninglevelpercent.ToString("N1"));
                    }

                    if (ji != null)
                    {
                        HistoryEntry lastJet = discoveryform.history.GetLastHistoryEntry(x => x.journalEntry.EventTypeID == JournalTypeEnum.JetConeBoost);
                        if (lastJet != null && lastJet.EventTimeLocal > lastHE.EventTimeLocal)
                        {
                            double jumpdistance = ji.avgsinglejump * (lastJet.journalEntry as EliteDangerousCore.JournalEvents.JournalJetConeBoost).BoostValue;
                            line += String.Format(" [{0:N1}ly @ BOOST]", jumpdistance);
                        }
                        else
                        {
                            line += String.Format(" [{0:N1}ly, {1:N1}ly / {2:N0}]", ji.avgsinglejump, ji.maxjumprange, ji.maxjumps);
                        }
                    }

                    pictureBox.AddTextAutoSize(new Point(botlineleft.pos.Right, 35), new Size(1000, 40), line, displayfont, textcolour, backcolour, 1.0F);
                }


                pictureBox.Render();
            }
        }
Beispiel #8
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("");
            }
        }
        void DisplayState(HistoryEntry he, HistoryEntry lastfsd)
        {
            pictureBox.ClearImageList();

            lastHE  = he;
            lastFSD = lastfsd;

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

                int leftstart = 5;
                int topstart  = 5;
                int coltext   = leftstart;

                ExtendedControls.ExtPictureBox.ImageElement iedsm = null;

                if (showEDSMStartButtonsToolStripMenuItem.Checked)
                {
                    iedsm = pictureBox.AddTextAutoSize(new Point(leftstart, topstart), new Size(1000, 1000), "EDSM", displayfont, backcolour, textcolour, 0.5F, he, "View system on EDSM");
                    iedsm.SetAlternateImage(BaseUtils.BitMapHelpers.DrawTextIntoAutoSizedBitmap("EDSM", iedsm.img.Size, displayfont, backcolour, textcolour.Multiply(1.2F), 0.5F), iedsm.pos, true);
                    coltext = iedsm.pos.Right + displayfont.ScalePixels(8);
                }

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

                EliteDangerousCalculations.FSDSpec.JumpInfo ji = he.GetJumpInfo();          // may be null

                string line = String.Format("{0} [{1}]", he.System.Name, discoveryform.history.GetVisitsCount(he.System.Name));

                if (showTargetToolStripMenuItem.Checked)
                {
                    if (TargetClass.GetTargetPosition(out string name, out Point3D tpos))
                    {
                        double dist = he.System.Distance(tpos.X, tpos.Y, tpos.Z);

                        string mesg = "Left".T(EDTx.UserControlTrippanel_Left);

                        if (ji != null)
                        {
                            int jumps = (int)Math.Ceiling(dist / ji.avgsinglejump);
                            if (jumps > 0)
                            {
                                mesg = jumps.ToString() + " " + ((jumps == 1) ? "jump".T(EDTx.UserControlTrippanel_jump) : "jumps".T(EDTx.UserControlTrippanel_jumps));
                            }
                        }

                        line += String.Format("-> {0} {1:N1}ly {2}", name, dist, mesg);
                    }
                    else
                    {
                        line += " -> Target not set".T(EDTx.UserControlTrippanel_NoT);
                    }
                }

                bool firstdiscovery = (lastfsd != null && (lastfsd.journalEntry as EliteDangerousCore.JournalEvents.JournalFSDJump).EDSMFirstDiscover);

                int line1hpos = coltext;
                if (firstdiscovery)
                {
                    var i1 = pictureBox.AddImage(new Rectangle(line1hpos, 5, 24, 24), Icons.Controls.firstdiscover, null, "Shows if EDSM indicates your it's first discoverer".T(EDTx.UserControlTrippanel_FDEDSM), false);
                    line1hpos = i1.pos.Right + Font.ScalePixels(8);
                }

                var eline1    = pictureBox.AddTextAutoSize(new Point(line1hpos, topstart), new Size(1000, 1000), line, displayfont, textcolour, backcolour, 1.0F);
                int line2vpos = eline1.pos.Bottom + displayfont.ScalePixels(8);

                line = "";

                if (showTravelledDistanceToolStripMenuItem.Checked)
                {
                    line = String.Format("{0:N1}{1},{2} " + "jumps".T(EDTx.UserControlTrippanel_jumps) + ", {3}", he.TravelledDistance, ((he.TravelledMissingjump > 0) ? "ly*" : "ly"),
                                         he.Travelledjumps,
                                         he.TravelledSeconds);
                }

                ShipInformation si = he.ShipInformation;

                if (si != null)
                {
                    string addtext = "";

                    if (showFuelLevelToolStripMenuItem.Checked)
                    {
                        double fuel                = si.FuelLevel;
                        double tanksize            = si.FuelCapacity;
                        double warninglevelpercent = si.FuelWarningPercent;

                        addtext = String.Format("{0}/{1}t", fuel.ToString("N1"), tanksize.ToString("N1"));

                        if (warninglevelpercent > 0 && fuel < tanksize * warninglevelpercent / 100.0)
                        {
                            textcolour = discoveryform.theme.TextBlockHighlightColor;
                            addtext   += String.Format(" < {0}%", warninglevelpercent.ToString("N1"));
                        }
                    }

                    if (ji != null)
                    {
                        HistoryEntry lastJet = discoveryform.history.GetLastHistoryEntry(x => x.journalEntry.EventTypeID == JournalTypeEnum.JetConeBoost);

                        double boostval = 1;

                        if (lastJet != null && lastfsd != null && lastJet.EventTimeLocal > lastfsd.EventTimeLocal)
                        {
                            boostval = (lastJet.journalEntry as EliteDangerousCore.JournalEvents.JournalJetConeBoost).BoostValue;
                        }

                        string range = "";
                        if (showCurrentFSDRangeToolStripMenuItem.Checked)
                        {
                            range += String.Format("cur {0:N1}ly{1}", ji.cursinglejump * boostval, boostval > 1 ? " Boost" : "");
                        }
                        if (showAvgFSDRangeToolStripMenuItem.Checked)
                        {
                            range = range.AppendPrePad(String.Format("avg {0:N1}ly{1}", ji.avgsinglejump * boostval, boostval > 1 ? " Boost" : ""), ", ");
                        }
                        if (showMaxFSDRangeToolStripMenuItem.Checked)
                        {
                            range = range.AppendPrePad(String.Format("max {0:N1}ly{1}", ji.curfumessinglejump * boostval, boostval > 1 ? " Boost" : ""), ", ");
                        }
                        if (showFSDRangeToolStripMenuItem.Checked)
                        {
                            range = range.AppendPrePad(String.Format("{0:N1}ly/{1:N0}", ji.maxjumprange, ji.maxjumps), ", ");
                        }

                        if (range.HasChars())
                        {
                            addtext = addtext.AppendPrePad(range, " | ");
                        }
                    }

                    if (addtext.HasChars())
                    {
                        line = line.AppendPrePad(addtext, " | ");
                    }
                }

                if (showEDSMStartButtonsToolStripMenuItem.Checked)
                {
                    ExtendedControls.ExtPictureBox.ImageElement start = pictureBox.AddTextFixedSizeC(new Point(leftstart, line2vpos), iedsm.img.Size, "Start", displayfont, backcolour, textcolour, 0.5F, true, "Start", "Set a journey start point");
                    start.SetAlternateImage(BaseUtils.BitMapHelpers.DrawTextIntoFixedSizeBitmapC("Start", start.img.Size, displayfont, backcolour, textcolour.Multiply(1.2F), 0.5F, true), start.pos, true);
                }

                if (line.HasChars())
                {
                    pictureBox.AddTextAutoSize(new Point(coltext, line2vpos), new Size(1000, 40), line, displayfont, textcolour, backcolour, 1.0F);
                }

                pictureBox.Render();
            }
        }
 void Start()
 {
     info = gameObject.GetComponent <ShipInformation>();
 }
Beispiel #11
0
        static public void ShipModuleInformation(ActionLanguage.ActionProgramRun vars, ShipInformation si, string prefix)
        {
            if (si != null && si.Modules != null)
            {
                vars[prefix + "Ship_Module_Count"] = si.Modules.Count.ToString(System.Globalization.CultureInfo.InvariantCulture);

                int ind = 0;
                foreach (ShipModule m in si.Modules.Values)
                {
                    string mi = prefix + "Ship_Module[" + ind.ToString() + "]_";
                    vars[mi + "Slot"]          = m.Slot;
                    vars[mi + "Item"]          = m.Item;
                    vars[mi + "ItemLocalised"] = m.LocalisedItem.Alt(m.Item);
                    vars[mi + "Enabled"]       = m.Enabled.ToStringInvariant();
                    vars[mi + "AmmoClip"]      = m.AmmoClip.ToStringInvariant();
                    vars[mi + "AmmoHopper"]    = m.AmmoHopper.ToStringInvariant();
                    vars[mi + "Blueprint"]     = (m.Engineering != null) ? m.Engineering.FriendlyBlueprintName : "";
                    vars[mi + "Health"]        = m.Health.ToStringInvariant();
                    vars[mi + "Value"]         = m.Value.ToStringInvariant();
                    vars[mi + "Mass"]          = m.Mass.ToStringInvariant();
                    ind++;
                }
            }
        }
Beispiel #12
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);
        }
Beispiel #13
0
        static public void ShipModuleInformation(ActionLanguage.ActionProgramRun vars, ShipInformation si, string prefix)
        {
            if (si != null && si.Modules != null)
            {
                vars[prefix + "Ship_Module_Count"] = si.Modules.Count.ToString(System.Globalization.CultureInfo.InvariantCulture);

                int ind = 0;
                foreach (EliteDangerousCore.JournalEvents.JournalLoadout.ShipModule m in si.Modules.Values)
                {
                    string mi = prefix + "Ship_Module[" + ind.ToString() + "]_";
                    vars[mi + "Slot"]          = m.Slot;
                    vars[mi + "Item"]          = m.Item;
                    vars[mi + "ItemLocalised"] = m.LocalisedItem.Alt(m.Item);
                    vars[mi + "Enabled"]       = m.Enabled.ToStringInvariant();
                    vars[mi + "AmmoClip"]      = m.AmmoClip.ToStringInvariant();
                    vars[mi + "AmmoHopper"]    = m.AmmoHopper.ToStringInvariant();
                    vars[mi + "Blueprint"]     = m.Blueprint.ToNullSafeString();
                    vars[mi + "Health"]        = m.Health.ToStringInvariant();
                    vars[mi + "Value"]         = m.Value.ToStringInvariant();
                    ind++;
                }
            }
        }
Beispiel #14
0
 public void AddShip(Player currentPlayer, ShipInformation shipInfo)
 {
     currentPlayer.CurrentMap.AddShip(shipInfo);
 }
 // Use this for initialization
 void Start()
 {
     ship     = GameObject.Find("Ship");
     shipInfo = ship.GetComponent <ShipInformation>();
 }
        private void Display()      // allow redisplay of last data
        {
            DataGridViewColumn sortcolprev   = dataGridViewModules.SortedColumn != null ? dataGridViewModules.SortedColumn : dataGridViewModules.Columns[0];
            SortOrder          sortorderprev = dataGridViewModules.SortedColumn != null ? dataGridViewModules.SortOrder : SortOrder.Ascending;
            int firstline = dataGridViewModules.SafeFirstDisplayedScrollingRowIndex();

            dataGridViewModules.Rows.Clear();

            dataViewScrollerPanel.SuspendLayout();

            last_si = null;     // no ship info

            dataGridViewModules.Columns[2].HeaderText = "Slot".T(EDTx.UserControlModules_SlotCol);
            dataGridViewModules.Columns[3].HeaderText = "Info".T(EDTx.UserControlModules_ItemInfo);
            dataGridViewModules.Columns[6].HeaderText = "Value".T(EDTx.UserControlModules_Value);

            if (comboBoxShips.Text == storedmoduletext)
            {
                labelVehicle.Visible = buttonExtCoriolis.Visible = buttonExtEDShipyard.Visible = buttonExtConfigure.Visible = false;

                if (last_he != null && last_he.StoredModules != null)
                {
                    ModulesInStore mi = last_he.StoredModules;
                    labelVehicle.Text = "";

                    foreach (ModulesInStore.StoredModule sm in mi.StoredModules)
                    {
                        object[] rowobj = { sm.Name_Localised.Alt(sm.Name),                                       sm.Name,
                                            sm.StarSystem.Alt("In Transit".T(EDTx.UserControlModules_InTransit)), sm.TransferTimeString,
                                            sm.Mass > 0 ? (sm.Mass.ToString() + "t") : "",
                                            sm.EngineerModifications.Alt(""),
                                            sm.TransferCost > 0 ? sm.TransferCost.ToString("N0") : "",
                                            "" };
                        dataGridViewModules.Rows.Add(rowobj);
                    }

                    dataGridViewModules.Columns[2].HeaderText = "System".T(EDTx.UserControlModules_System);
                    dataGridViewModules.Columns[3].HeaderText = "Tx Time".T(EDTx.UserControlModules_TxTime);
                    dataGridViewModules.Columns[6].HeaderText = "Cost".T(EDTx.UserControlModules_Cost);
                }
            }
            else if (comboBoxShips.Text == allmodulestext)
            {
                labelVehicle.Visible = buttonExtCoriolis.Visible = buttonExtEDShipyard.Visible = buttonExtConfigure.Visible = false;

                ShipInformationList shm = discoveryform.history.ShipInformationList;
                var ownedships          = (from x1 in shm.Ships where x1.Value.State == ShipInformation.ShipState.Owned && ItemData.IsShip(x1.Value.ShipFD) select x1.Value);

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

                if (last_he != null && last_he.StoredModules != null)
                {
                    ModulesInStore mi = last_he.StoredModules;
                    labelVehicle.Text = "";

                    foreach (ModulesInStore.StoredModule sm in mi.StoredModules)
                    {
                        string info = sm.StarSystem.Alt("In Transit".T(EDTx.UserControlModules_InTransit));
                        info = info.AppendPrePad(sm.TransferTimeString, ":");
                        object[] rowobj = { sm.Name_Localised.Alt(sm.Name),                            sm.Name, "Stored".TxID(EDTx.UserControlModules_Stored),
                                            info,
                                            sm.Mass > 0 ? (sm.Mass.ToString() + "t") : "",
                                            sm.EngineerModifications.Alt(""),
                                            sm.TransferCost > 0 ? sm.TransferCost.ToString("N0") : "",
                                            "" };
                        dataGridViewModules.Rows.Add(rowobj);
                    }
                }
            }
            else if (comboBoxShips.Text == travelhistorytext || comboBoxShips.Text.Length == 0)  // second is due to the order History gets called vs this on start
            {
                if (last_he?.ShipInformation != null)
                {
                    DisplayShip(last_he.ShipInformation);
                }
            }
            else
            {
                ShipInformation si = discoveryform.history.ShipInformationList.GetShipByNameIdentType(comboBoxShips.Text);
                if (si != null)
                {
                    DisplayShip(si);
                }
            }

            dataViewScrollerPanel.ResumeLayout();

            dataGridViewModules.Sort(sortcolprev, (sortorderprev == SortOrder.Descending) ? ListSortDirection.Descending : ListSortDirection.Ascending);
            dataGridViewModules.Columns[sortcolprev.Index].HeaderCell.SortGlyphDirection = sortorderprev;
            if (firstline >= 0 && firstline < dataGridViewModules.RowCount)
            {
                dataGridViewModules.SafeFirstDisplayedScrollingRowIndex(firstline);
            }
        }
Beispiel #17
0
        private void buttonExtCoriolis_Click(object sender, EventArgs e)
        {
            ShipInformation si = null;

            if (comboBoxShips.Text.Contains("Travel") || comboBoxShips.Text.Length == 0)  // second is due to the order History gets called vs this on start
            {
                if (last_he != null && last_he.ShipInformation != null)
                {
                    si = last_he.ShipInformation;
                }
            }
            else
            {
                si = discoveryform.history.shipinformationlist.GetShipByShortName(comboBoxShips.Text);
            }

            if (si != null)
            {
                string errstr;
                string s = si.ToJSON(out errstr);

                if (errstr.Length > 0)
                {
                    ExtendedControls.MessageBoxTheme.Show(FindForm(), errstr + Environment.NewLine + "This is probably a new or powerplay module" + Environment.NewLine + "Report to EDD Team by Github giving the full text above", "Unknown Module Type");
                }

                string uri = null;

                var bytes = Encoding.UTF8.GetBytes(s);
                using (MemoryStream indata = new MemoryStream(bytes))
                {
                    using (MemoryStream outdata = new MemoryStream())
                    {
                        using (System.IO.Compression.GZipStream gzipStream = new System.IO.Compression.GZipStream(outdata, System.IO.Compression.CompressionLevel.Optimal, true))
                            indata.CopyTo(gzipStream);      // important to clean up gzip otherwise all the data is not written.. using

                        uri += Properties.Resources.URLCoriolis + "data=" + Uri.EscapeDataString(Convert.ToBase64String(outdata.ToArray()));
                        uri += "&bn=" + Uri.EscapeDataString(si.Name);

                        string browser = BaseUtils.BrowserInfo.GetDefault();

                        if (browser != null)
                        {
                            string path = BaseUtils.BrowserInfo.GetPath(browser);

                            if (path != null)
                            {
                                try
                                {
                                    System.Diagnostics.ProcessStartInfo p = new System.Diagnostics.ProcessStartInfo(path, uri);
                                    p.UseShellExecute = false;
                                    System.Diagnostics.Process.Start(p);
                                    return;
                                }
                                catch (Exception ex)
                                {
                                    ExtendedControls.MessageBoxTheme.Show(FindForm(), "Unable to launch browser" + ex.Message, "Browser Launch Error");
                                }
                            }
                        }
                    }
                }

                ExtendedControls.InfoForm info = new ExtendedControls.InfoForm();
                info.Info("Cannot launch browser, use this JSON for manual Coriolis import", Icon.ExtractAssociatedIcon(System.Reflection.Assembly.GetExecutingAssembly().Location),
                          s, new Font("MS Sans Serif", 10), new int[] { 0, 100 });
                info.ShowDialog(FindForm());
            }
        }
        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 = ItemData.Instance.GetShipModuleProperties(sm.ItemFD).ModType;
            }

            string eng        = "";
            string engtooltip = null;

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

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

                if (displayfilters.Contains("fullblueprint"))
                {
                    eng = engtooltip;
                }
            }

            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 (engtooltip != null)
            {
                dataGridViewModules.Rows[dataGridViewModules.Rows.Count - 1].Cells[5].ToolTipText = engtooltip;
            }
        }
Beispiel #19
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 #20
0
        public void SendShipInfo(ShipInformation si, MaterialCommoditiesList matcommod, int cargo, ShipInformation sicurrent, long cash, long loan,
                                 JournalProgress progress, JournalRank rank     // both may be null
                                 )
        {
            lock (LockShipInfo)               // lets not double send in different threads.
            {
                if (!si.Equals(LastShipInfo)) // if we are sending new ship info..
                {
                    System.Diagnostics.Debug.WriteLine("Update EDSM with ship info" + si.ID + " " + si.ShipType + " " + cargo);
                    CommanderUpdateShip(si.ID, si.ShipType.Alt("Unknown"), si, cargo);
                    LastShipInfo = si;
                }

                if (LastShipID != sicurrent.ID) // if we have a new current ship
                {
                    System.Diagnostics.Debug.WriteLine("Update EDSM with current ship" + sicurrent.ID);
                    CommanderSetCurrentShip(sicurrent.ID);
                    LastShipID = sicurrent.ID;
                }

                if (LastEDSMCredits != cash)    // if our cash has changed..
                {
                    System.Diagnostics.Debug.WriteLine("Update EDSM with credits" + cash);
                    SetCredits(cash, loan);
                    LastEDSMCredits = cash;
                }

                if (progress != null && rank != null && (!Object.ReferenceEquals(progress, LastProgress) || !Object.ReferenceEquals(rank, LastRank)))
                {
                    System.Diagnostics.Debug.WriteLine("Update EDSM with ranks");
                    SetRanks((int)rank.Combat, progress.Combat, (int)rank.Trade, progress.Trade, (int)rank.Explore, progress.Explore, (int)rank.CQC, progress.CQC, (int)rank.Federation, progress.Federation, (int)rank.Empire, progress.Empire);
                    LastProgress = progress;
                    LastRank     = rank;
                }

                if (matcommod != null && matcommod != LastMats)
                {
                    System.Diagnostics.Debug.WriteLine("Update EDSM with materials and cargo");
                    List <MaterialCommodities> lmats  = matcommod.Sort(false);
                    List <MaterialCommodities> lcargo = matcommod.Sort(true);
                    List <MaterialCommodities> ldata  = lmats.Where(m => m.category == MaterialCommodities.MaterialEncodedCategory).ToList();
                    lmats = lmats.Where(m => m.category != MaterialCommodities.MaterialEncodedCategory).ToList();
                    SetInventoryMaterials(lmats.Where(m => m.count > 0).ToDictionary(m => m.fdname, m => m.count));
                    SetInventoryData(ldata.Where(m => m.count > 0).ToDictionary(m => m.fdname, m => m.count));
                    SetInventoryCargo(lcargo.Where(m => m.count > 0).ToDictionary(m => m.fdname, m => m.count));
                    LastMats = matcommod;
                }
            }
        }