Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        // 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;
                }
            }
        }
Ejemplo n.º 3
0
        // 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;
                }
            }
        }