KLF.KLFManager.vesselStatusLabels C# (CSharp) Method

vesselStatusLabels() private method

private vesselStatusLabels ( VesselStatusInfo status, bool big ) : void
status VesselStatusInfo
big bool
return void
        private void vesselStatusLabels(VesselStatusInfo status, bool big)
        {
            bool name_pressed = false;

            playerNameStyle.normal.textColor = status.color * 0.75f + Color.white * 0.25f;

            if (big)
                GUILayout.BeginHorizontal();

            if (status.ownerName != null)
                name_pressed |= GUILayout.Button(status.ownerName, playerNameStyle);

            if (status.vesselName != null && status.vesselName.Length > 0)
            {
                String vessel_name = status.vesselName;

                if (status.info != null && status.info.detail != null && status.info.detail.idle)
                    vessel_name = "(Idle) " + vessel_name;

                name_pressed |= GUILayout.Button(vessel_name, vesselNameStyle);
            }

            if (big)
                GUILayout.EndHorizontal();

            //Build the detail text
            StringBuilder sb = new StringBuilder();

            //Check if the status has specific detail text
            if (status.detailText != null && status.detailText.Length > 0 && KLFInfoDisplay.infoDisplayDetailed)
                sb.Append(status.detailText);
            else if (status.info != null && status.info.detail != null)
            {

                bool exploded = false;
                bool situation_determined = false;

                if (status.info.situation == Situation.DESTROYED || status.info.detail.mass <= 0.0f)
                {
                    sb.Append("Exploded at ");
                    exploded = true;
                    situation_determined = true;
                }
                else
                {

                    //Check if the vessel's activity overrides the situation
                    switch (status.info.detail.activity)
                    {
                        case Activity.AEROBRAKING:
                            sb.Append("Aerobraking at ");
                            situation_determined = true;
                            break;

                        case Activity.DOCKING:
                            if (KLFVessel.situationIsGrounded(status.info.situation))
                                sb.Append("Docking on ");
                            else
                                sb.Append("Docking above ");
                            situation_determined = true;
                            break;

                        case Activity.PARACHUTING:
                            sb.Append("Parachuting to ");
                            situation_determined = true;
                            break;
                    }

                    if (!situation_determined)
                    {
                        switch (status.info.situation)
                        {
                            case Situation.DOCKED:
                                sb.Append("Docked at ");
                                break;

                            case Situation.ENCOUNTERING:
                                sb.Append("Encountering ");
                                break;

                            case Situation.ESCAPING:
                                sb.Append("Escaping ");
                                break;

                            case Situation.FLYING:
                                sb.Append("Flying at ");
                                break;

                            case Situation.LANDED:
                                sb.Append("Landed at ");
                                break;

                            case Situation.ORBITING:
                                sb.Append("Orbiting ");
                                break;

                            case Situation.PRELAUNCH:
                                sb.Append("Prelaunch at ");
                                break;

                            case Situation.SPLASHED:
                                sb.Append("Splashed at ");
                                break;

                            case Situation.ASCENDING:
                                sb.Append("Ascending from ");
                                break;

                            case Situation.DESCENDING:
                                sb.Append("Descending to ");
                                break;
                        }
                    }

                }

                sb.Append(status.info.bodyName);

                if (!exploded && KLFInfoDisplay.infoDisplayDetailed)
                {

                    bool show_mass = status.info.detail.mass >= 0.05f;
                    bool show_fuel = status.info.detail.percentFuel < byte.MaxValue;
                    bool show_rcs = status.info.detail.percentRCS < byte.MaxValue;
                    bool show_crew = status.info.detail.numCrew < byte.MaxValue;

                    if (show_mass || show_fuel || show_rcs || show_crew)
                        sb.Append(" - ");

                    if (show_mass)
                    {
                        sb.Append("Mass: ");
                        sb.Append(status.info.detail.mass.ToString("0.0"));
                        sb.Append(' ');
                    }

                    if (show_fuel)
                    {
                        sb.Append("Fuel: ");
                        sb.Append(status.info.detail.percentFuel);
                        sb.Append("% ");
                    }

                    if (show_rcs)
                    {
                        sb.Append("RCS: ");
                        sb.Append(status.info.detail.percentRCS);
                        sb.Append("% ");
                    }

                    if (show_crew)
                    {
                        sb.Append("Crew: ");
                        sb.Append(status.info.detail.numCrew);
                    }
                }

            }

            if (sb.Length > 0)
                GUILayout.Label(sb.ToString(), stateTextStyle);

            //If the name was pressed, then focus on that players' reference body
            if (name_pressed
                && HighLogic.LoadedSceneHasPlanetarium && planetariumCam != null
                    && status.info != null
                    && status.info.bodyName.Length > 0)
            {
                if (!MapView.MapIsEnabled)
                    MapView.EnterMapView();

                foreach (MapObject target in planetariumCam.targets)
                {
                    if (target.name == status.info.bodyName)
                    {
                        planetariumCam.SetTarget(target);
                        break;
                    }
                }
            }
        }