// Shows a list of all available mission-profiles and returns true, if the player has selected one:
        public bool DisplayList()
        {
            CheckInternals();
            GUILayout.Label("<size=14><b>Mission Profile:</b></size>");
            scrollPos = GUILayout.BeginScrollView(scrollPos, GUI.scrollStyle);
            var green = "#00FF00";
            var red   = "#FF0000";

            // Show a list with all possible mission-profiles:
            if (MissionController.missionProfiles.Count == 0)
            {
                GUILayout.Label("No recordings found, switch to a new vessel to start recording a mission.");
            }
            else
            {
                var contents       = new List <GUIContent>();
                var invalidIndices = new List <int>(); // Profiles which fall out of the defined filters will get noted here.
                var index          = 0;
                foreach (var missionProfile in MissionController.missionProfiles.Values)
                {
                    var isValidProfile = true;
                    var color          = "";

                    // Build the descriptive text with highlighting:
                    var description = "<color=#F9FA86><b>" + missionProfile.profileName + "</b></color> <color=#FFFFFF>(" + missionProfile.vesselName + ")\n";
                    description += "<b>Mass:</b> " + missionProfile.launchMass.ToString("0.0t") + ", Cost: " + missionProfile.launchCost.ToString("#,##0√") + ", ";

                    // One-Way or Round-Trip:
                    var missionRouteDetails = "";
                    if (missionProfile.oneWayMission)
                    {
                        missionRouteDetails = "one-way";
                    }
                    else
                    {
                        missionRouteDetails = "round-trip";
                    }
                    if (this.filterRoundTrip != null)
                    {
                        if (this.filterRoundTrip != missionProfile.oneWayMission)
                        {
                            isValidProfile = false; color = red;
                        }
                        else
                        {
                            color = green;
                        }
                        missionRouteDetails = "<color=" + color + ">" + missionRouteDetails + "</color>";
                    }
                    description += missionRouteDetails + "\n";

                    // Mission-Type:
                    var missionType = MissionProfile.GetMissionProfileTypeName(missionProfile.missionType);
                    if (this.filterMissionType != null)
                    {
                        if (this.filterMissionType != missionProfile.missionType)
                        {
                            isValidProfile = false; color = red;
                        }
                        else
                        {
                            color = green;
                        }
                        missionType = "<color=" + color + ">" + missionType + "</color>";
                    }
                    description += "<b>Type:</b> " + missionType + ", ";

                    description += "<b>Duration:</b> " + GUI.FormatDuration(missionProfile.missionDuration) + "\n";

                    // Docking-Ports:
                    var dockingPorts = "";
                    if (missionProfile.missionType == MissionProfileType.TRANSPORT || this.filterDockingPortTypes != null)
                    {
                        var hasFittingPort = false;
                        var portNumber     = 0;
                        if (missionProfile.dockingPortTypes != null)
                        {
                            foreach (var portType in missionProfile.dockingPortTypes)
                            {
                                if (portNumber > 0)
                                {
                                    dockingPorts += ", ";
                                }
                                if (this.filterDockingPortTypes != null && this.filterDockingPortTypes.Contains(portType))
                                {
                                    hasFittingPort = true;
                                    dockingPorts  += "<color=" + green + ">" + TargetVessel.TranslateDockingPortName(portType) + "</color>";
                                }
                                else
                                {
                                    dockingPorts += TargetVessel.TranslateDockingPortName(portType);
                                }
                                portNumber++;
                            }
                        }
                        if (portNumber == 0)
                        {
                            dockingPorts = "N/A";
                        }
                        if (this.filterDockingPortTypes != null && !hasFittingPort)
                        {
                            dockingPorts   = "<color=" + red + ">" + dockingPorts + "</color>";
                            isValidProfile = false;
                        }
                    }
                    if (dockingPorts != "")
                    {
                        description += "<b>Docking-Ports:</b> " + dockingPorts + "\n";
                    }

                    // Payload:
                    var payloadMass = missionProfile.payloadMass.ToString("0.0t");
                    if (this.filterMass != null)
                    {
                        // We only display one digit after the pount, so we should round here to avoid confustion:
                        if (Math.Round((double)this.filterMass, 1) > Math.Round(missionProfile.payloadMass, 1))
                        {
                            isValidProfile = false; color = red;
                        }
                        else
                        {
                            color = green;
                        }
                        payloadMass = "<color=" + color + ">" + payloadMass + "</color>";
                    }
                    description += "<b>Payload:</b> " + payloadMass;

                    // Body:
                    var bodyName = missionProfile.bodyName;
                    if (this.filterBody != null)
                    {
                        if (this.filterBody.bodyName != missionProfile.bodyName)
                        {
                            isValidProfile = false; color = red;
                        }
                        else
                        {
                            color = green;
                        }
                        bodyName = "<color=" + color + ">" + bodyName + "</color>";
                    }
                    description += " to " + bodyName;

                    // Altitude:
                    var maxAltitude = GUI.FormatAltitude(missionProfile.maxAltitude);
                    if (this.filterAltitude != null)
                    {
                        if (this.filterAltitude > missionProfile.maxAltitude)
                        {
                            isValidProfile = false; color = red;
                        }
                        else
                        {
                            color = green;
                        }
                        maxAltitude = "<color=" + color + ">" + maxAltitude + "</color>";
                    }
                    description += " @ " + maxAltitude + "\n";

                    // Crew-Capacity:
                    var crewCapacity = missionProfile.crewCapacity.ToString("0");
                    if (this.filterCrewCapacity != null)
                    {
                        if (this.filterCrewCapacity > missionProfile.crewCapacity)
                        {
                            isValidProfile = false; color = red;
                        }
                        else
                        {
                            color = green;
                        }
                        crewCapacity = "<color=" + color + ">" + crewCapacity + "</color>";
                    }
                    description += "<b>Crew-Capacity:</b> " + crewCapacity;

                    description += "</color>";
                    contents.Add(new GUIContent(description, GUI.GetVesselThumbnail(missionProfile.vesselName)));

                    if (!isValidProfile)
                    {
                        invalidIndices.Add(index);
                    }
                    index++;
                }

                var newSelection = GUILayout.SelectionGrid(selectedIndex, contents.ToArray(), 1, GUI.selectionGridStyle);
                if (newSelection != selectedIndex && !invalidIndices.Contains(newSelection))
                {
                    selectedIndex   = newSelection;
                    selectedProfile = MissionController.missionProfiles.Values.ToList()[selectedIndex];
                }
            }

            GUILayout.EndScrollView();
            return(this.selectedProfile != null);
        }
        // Shows a list of all available target-vessels and returns true, if the player has selected one:
        public bool DisplayList()
        {
            GUILayout.Label("<size=14><b>Target:</b></size>");
            scrollPos = GUILayout.BeginScrollView(scrollPos, GUI.scrollStyle);
            string green = "#00FF00";
            string red   = "#FF0000";

            // Build a list with all valid vessels:
            List <Vessel> validTargets = new List <Vessel>();

            foreach (Vessel vessel in FlightGlobals.Vessels)
            {
                if (!TargetVessel.IsValidTarget(vessel))
                {
                    continue;
                }
                validTargets.Add(vessel);
            }
            if (selectedIndex >= validTargets.Count)
            {
                selectedIndex = -1;
                targetVessel  = null;
            }

            if (validTargets.Count == 0)
            {
                // No valid targest available:
                GUILayout.Label("No valid targets in orbit.");
            }
            else
            {
                // Show list with all possible vessels:
                List <GUIContent> contents        = new List <GUIContent>();
                List <int>        filteredIndices = new List <int>(); // Target-vessels which fall out of the defined filters will get noted here.
                int index = 0;
                foreach (Vessel vessel in validTargets)
                {
                    bool filterThisTarget = false;
                    if (!TargetVessel.IsValidTarget(vessel))
                    {
                        continue;
                    }
                    List <string> descriptions = new List <string>();
                    descriptions.Add("<color=#F9FA86><b>" + vessel.vesselName + "</b></color><color=#FFFFFF>");

                    // Orbital-Parameters:
                    descriptions.Add("<b>Apoapsis:</b> " + GUI.FormatAltitude(vessel.orbit.ApA) + ", <b>Periapsis:</b> " + GUI.FormatAltitude(vessel.orbit.PeA) + ", <b>MET:</b> " + GUI.FormatDuration(vessel.missionTime));

                    // Docking-Port Types:
                    List <string> dockingPortsTranslated = new List <string>();
                    foreach (string dockingPortType in TargetVessel.GetVesselDockingPortTypes(vessel))
                    {
                        dockingPortsTranslated.Add(TargetVessel.TranslateDockingPortName(dockingPortType));
                    }
                    if (dockingPortsTranslated.Count > 0)
                    {
                        descriptions.Add("<b>Docking-Ports:</b> " + string.Join(", ", dockingPortsTranslated.ToArray()));
                    }

                    // Resources:
                    double capacity = 0;
                    foreach (PayloadResource availableResource in TargetVessel.GetFreeResourcesCapacities(vessel))
                    {
                        capacity += availableResource.amount * availableResource.mass;
                    }
                    if (capacity > 0)
                    {
                        descriptions.Add("<b>Resource Capacity:</b> " + capacity.ToString("#,##0.00t"));
                    }

                    // Crew:
                    int seats = TargetVessel.GetCrewCapacity(vessel);
                    int crew  = TargetVessel.GetCrew(vessel).Count;
                    if (seats > 0)
                    {
                        descriptions.Add("<b>Crew:</b> " + crew.ToString() + "/" + seats.ToString());
                    }

                    // Maybe apply additional filters and show their attributes:
                    List <string> filterAttributes = new List <string>();;
                    if (filterVesselType != null)
                    {
                        bool   isValidType = vessel.vesselType == (VesselType)filterVesselType;
                        string color       = isValidType ? green : red;
                        filterAttributes.Add("<b>Type:</b> <color=" + color + ">" + vessel.vesselType.ToString() + "</color>");
                        if (!isValidType)
                        {
                            filterThisTarget = true;
                        }
                    }
                    if (filterHasCrewTrait != null)
                    {
                        int traitCount    = TargetVessel.GetCrewCountWithTrait(vessel, filterHasCrewTrait);
                        int requiredCount = 1;
                        if (filterHasCrewTraitCount != null)
                        {
                            requiredCount = (int)filterHasCrewTraitCount;
                        }
                        string color = traitCount >= requiredCount ? green : red;
                        filterAttributes.Add("<b>" + filterHasCrewTrait + "s:</b> <color=" + color + ">" + traitCount.ToString() + "/" + requiredCount.ToString() + "</color>");
                        if (traitCount < requiredCount)
                        {
                            filterThisTarget = true;
                        }
                    }
                    if (filterAttributes.Count > 0)
                    {
                        descriptions.Add(String.Join(" ", filterAttributes.ToArray()));
                    }

                    contents.Add(new GUIContent(String.Join("\n", descriptions.ToArray()) + "</color>"));
                    if (filterThisTarget)
                    {
                        filteredIndices.Add(index);                   // If there were filters, which did not match, we still show the target, but don't allow to select it.
                    }
                    index++;
                }

                int newSelection = GUILayout.SelectionGrid(selectedIndex, contents.ToArray(), 1, GUI.selectionGridStyle);
                if (newSelection >= 0 && !filteredIndices.Contains(newSelection))
                {
                    // The player has selected a payload:
                    selectedIndex = newSelection;
                    targetVessel  = validTargets[selectedIndex];
                }
            }
            GUILayout.EndScrollView();
            return(targetVessel != null);
        }