private static string GetPartHighlightColor() { string strColor = "clear"; // Here, we need to also account for a part selected in the Control window. // so we can have a part revert to nothing... //if (PrevMouseOverPart == MouseOverPart || PrevMouseOverPart == null) return strColor; if (SMAddon.SmVessel.SelectedPartsSource.Contains(PrevMouseOverPart)) { strColor = SMSettings.SourcePartColor; } else if (SMAddon.SmVessel.SelectedPartsTarget.Contains(PrevMouseOverPart)) { if (SMConditions.GetSelectedResourceType(SMAddon.SmVessel.SelectedResources) == SMConditions.ResourceType.Crew && SMConditions.IsClsHighlightingEnabled()) { strColor = SMSettings.TargetPartCrewColor; } else { strColor = SMSettings.TargetPartColor; } } else if (SMAddon.SmVessel.SelectedResourcesParts.Contains(PrevMouseOverPart) && !SMSettings.OnlySourceTarget) { strColor = SMConditions.IsClsHighlightingEnabled() ? "green" : "yellow"; } return(strColor); }
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; } } }
internal static void RevertMouseOverHighlight() { // Lets get the right color... if (PrevMouseOverParts != null) { // Only vessel Transfers have multiple parts highlighted so clear is the default. // now lets set the part colors. ClearPartsHighlight(PrevMouseOverParts);; EdgeHighight(PrevMouseOverParts, false); // now set selected part colors... if (!SMSettings.OnlySourceTarget && SMAddon.SmVessel.SelectedResourcesParts != null) { SetPartsHighlight(SMAddon.SmVessel.SelectedResourcesParts, SMSettings.Colors[SMSettings.ResourcePartColor], true); } if (SMAddon.SmVessel.SelectedPartsSource != null) { SetPartsHighlight(SMAddon.SmVessel.SelectedPartsSource, SMSettings.Colors[SMSettings.SourcePartColor], true); } if (SMAddon.SmVessel.SelectedPartsTarget != null) { if (SMConditions.IsClsEnabled() && SMConditions.GetTransferMode() == SMConditions.TransferMode.Crew) { SetPartsHighlight(SMAddon.SmVessel.SelectedPartsTarget, SMSettings.Colors[SMSettings.TargetPartCrewColor], true); } else { SetPartsHighlight(SMAddon.SmVessel.SelectedPartsTarget, SMSettings.Colors[SMSettings.TargetPartColor], true); } } if (!IsMouseOver) { PrevMouseOverParts = null; } } if (PrevMouseOverPart != null) { string strColor = GetPartHighlightColor(); Color partColor = SMSettings.Colors[strColor]; // Now lets set the part color if (partColor == Color.clear) { ClearPartHighlight(PrevMouseOverPart); EdgeHighight(PrevMouseOverPart, false); if (!IsMouseOver) { PrevMouseOverPart = null; } return; } SetPartHighlight(PrevMouseOverPart, partColor); EdgeHighight(PrevMouseOverPart, true, strColor); if (!IsMouseOver) { PrevMouseOverPart = null; } } }
// 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; } } }