private static void ResourceDetailsViewer() { try { _resourceScrollViewerPosition = GUILayout.BeginScrollView(_resourceScrollViewerPosition, SMStyle.ScrollStyle, GUILayout.Height(100), GUILayout.Width(300)); GUILayout.BeginVertical(); if (SMAddon.SmVessel.SelectedResources.Count > 0) { List <Part> .Enumerator pParts = SMAddon.SmVessel.SelectedResourcesParts.GetEnumerator(); while (pParts.MoveNext()) { if (pParts.Current == null) { continue; } Part part = pParts.Current; if (SMConditions.AreSelectedResourcesTypeOther(SMAddon.SmVessel.SelectedResources)) { GUIStyle noWrap = SMStyle.LabelStyleNoWrap; GUILayout.Label($"{part.partInfo.title}", noWrap, GUILayout.Width(265), GUILayout.Height(18)); GUIStyle noPad = SMStyle.LabelStyleNoPad; List <string> .Enumerator sResources = SMAddon.SmVessel.SelectedResources.GetEnumerator(); while (sResources.MoveNext()) { if (sResources.Current == null) { continue; } GUILayout.Label( $" - {sResources.Current}: ({part.Resources[sResources.Current].amount:######0.####}/{part.Resources[sResources.Current].maxAmount:######0.####})", noPad, GUILayout.Width(265), GUILayout.Height(16)); } sResources.Dispose(); } else if (SMAddon.SmVessel.SelectedResources.Contains(SMConditions.ResourceType.Crew.ToString())) { GUILayout.BeginHorizontal(); GUILayout.Label( $"{part.partInfo.title}, ({SmUtils.GetPartCrewCount(part)}/{part.CrewCapacity})", GUILayout.Width(265), GUILayout.Height(20)); GUILayout.EndHorizontal(); } else if (SMAddon.SmVessel.SelectedResources.Contains(SMConditions.ResourceType.Science.ToString())) { int scienceCount = 0; IEnumerator pModules = part.Modules.GetEnumerator(); while (pModules.MoveNext()) { if (pModules.Current == null) { continue; } PartModule pm = (PartModule)pModules.Current; ModuleScienceContainer container = pm as ModuleScienceContainer; if (container != null) { scienceCount += container.GetScienceCount(); } else if (pm is ModuleScienceExperiment) { scienceCount += ((ModuleScienceExperiment)pm).GetScienceCount(); } } GUILayout.BeginHorizontal(); GUILayout.Label($"{part.partInfo.title}, ({scienceCount})", GUILayout.Width(265)); GUILayout.EndHorizontal(); } } pParts.Dispose(); } } catch (Exception ex) { if (!SMAddon.FrameErrTripped) { SmUtils.LogMessage( $" in WindowManifest.ResourceDetailsViewer. Error: {ex.Message} \r\n\r\n{ex.StackTrace}", SmUtils.LogType.Error, true); // in, Error SMAddon.FrameErrTripped = true; } } GUILayout.EndVertical(); GUILayout.EndScrollView(); }