private static bool CanShowToolTip() { switch (Source) { case "WindowSettings": case "TabRealism": case "TabHighlight": case "TabSounds": case "TabToolTips": case "TabConfig": case "WindowRoster": return(HighLogic.LoadedScene == GameScenes.SPACECENTER && SMAddon.ShowUi && !SMConditions.IsPauseMenuOpen() || HighLogic.LoadedScene == GameScenes.FLIGHT && SMConditions.CanShowShipManifest()); case "WindowManifest": case "WindowTransfer": case "WindowControl": case "TabHatch": case "TabSolarPanel": case "TabAntenna": case "TabLight": return(SMConditions.CanShowShipManifest()); case "WindowDebugger": return(true); default: return(false); } }
// This method is expensive. Refactor to consume less CPU. internal static void Update_Highlighter() { string step = ""; try { // Do we even want to highlight? if (!SMSettings.EnableHighlighting) { return; } step = "Showhipmanifest = true"; if (!SMConditions.CanShowShipManifest()) { return; } //step = "Clear old highlighting"; // Clear Highlighting on everything, start fresh EdgeHighight(SMAddon.SmVessel.Vessel.parts, false); ClearPartsHighlight(SMAddon.SmVessel.Vessel.parts); if (SMAddon.SmVessel.SelectedResources != null && SMAddon.SmVessel.SelectedResources.Count > 0) { step = "Set non selected resource part color"; Color resourcePartColor = SMSettings.Colors[SMSettings.ResourcePartColor]; Color targetPartColor = SMSettings.Colors[SMSettings.TargetPartColor]; // If resource is Crew, and we the settings have enabled CLS highlighting support, use CLS colours if (SMConditions.IsClsHighlightingEnabled()) { step = "Highlight CLS vessel"; HighlightClsVessel(true, true); // Turn off the source and target cls highlighting. We are going to replace it. SMAddon.SmVessel.ClsPartSource?.Highlight(false, true); SMAddon.SmVessel.ClsPartTarget?.Highlight(false, true); // Override part colors to match CLS resourcePartColor = SMSettings.Colors[SMSettings.ClsSpaceColor]; targetPartColor = SMSettings.Colors[SMSettings.TargetPartCrewColor]; } // Highlight all parts containing the resource step = "Set Resource Part Colors"; if (!SMSettings.OnlySourceTarget) { SetPartsHighlight(SMAddon.SmVessel.SelectedResourcesParts, resourcePartColor); } // Highlight the Source and Target parts (if selected) step = "Set Selected Part Colors"; SetPartsHighlight(SMAddon.SmVessel.SelectedPartsSource, SMSettings.Colors[SMSettings.SourcePartColor], true); SetPartsHighlight(SMAddon.SmVessel.SelectedPartsTarget, targetPartColor, true); } } catch (Exception ex) { if (!SMAddon.FrameErrTripped) { SmUtils.LogMessage($" in SMHighlighter.UpdateHighlighting (repeating error). Error in step: {step}. Error: {ex.Message}\n\n{ex.StackTrace}", SmUtils.LogType.Error, true); SMAddon.FrameErrTripped = true; } } }
// This method is expensive. Refactor to consume less CPU. internal static void Update_Highlighter() { string step = ""; try { // Do we even want to highlight? if (!SMSettings.EnableHighlighting) { return; } step = "Showhipmanifest = true"; if (!SMConditions.CanShowShipManifest()) { return; } //step = "Clear old highlighting"; // Clear Highlighting on everything, start fresh EdgeHighight(SMAddon.SmVessel.Vessel.parts, false); ClearPartsHighlight(SMAddon.SmVessel.Vessel.parts); if (SMAddon.SmVessel.SelectedResources != null && SMAddon.SmVessel.SelectedResources.Count > 0) { // If Crew and cls, perform cls Highlighting if (SMConditions.IsClsHighlightingEnabled()) { step = "Highlight CLS vessel"; HighlightClsVessel(true, true); // Turn off the source and target cls highlighting. We are going to replace it. if (SMAddon.SmVessel.ClsPartSource != null) { SMAddon.SmVessel.ClsPartSource.Highlight(false, true); } if (SMAddon.SmVessel.ClsPartTarget != null) { SMAddon.SmVessel.ClsPartTarget.Highlight(false, true); } } // Default is yellow step = "Set non selected resource part color"; Color partColor = SMSettings.Colors[SMSettings.ResourcePartColor]; // match color used by CLS if active if (SMAddon.SmVessel.SelectedResources.Contains(SMConditions.ResourceType.Crew.ToString()) && SMSettings.EnableCls) { partColor = Color.green; } step = "Set Resource Part Colors"; if (!SMSettings.OnlySourceTarget) { SetPartsHighlight(SMAddon.SmVessel.SelectedResourcesParts, partColor); } step = "Set Selected Part Colors"; SetPartsHighlight(SMAddon.SmVessel.SelectedPartsSource, SMSettings.Colors[SMSettings.SourcePartColor], true); if (SMAddon.SmVessel.SelectedResources.Contains(SMConditions.ResourceType.Crew.ToString()) && SMSettings.EnableCls) { SetPartsHighlight(SMAddon.SmVessel.SelectedPartsTarget, SMSettings.Colors[SMSettings.TargetPartCrewColor], true); } else { SetPartsHighlight(SMAddon.SmVessel.SelectedPartsTarget, SMSettings.Colors[SMSettings.TargetPartColor], true); } } } catch (Exception ex) { if (!SMAddon.FrameErrTripped) { SmUtils.LogMessage($" in SMHighlighter.UpdateHighlighting (repeating error). Error in step: {step}. Error: {ex.Message}\n\n{ex.StackTrace}", SmUtils.LogType.Error, true); SMAddon.FrameErrTripped = true; } } }