void UpdateColors()
        {
            Color c = new Color();

            c.b = HighLogic.CurrentGame.Parameters.CustomParams <Workshop_MiscSettings>().highlightBlue;
            c.r = HighLogic.CurrentGame.Parameters.CustomParams <Workshop_MiscSettings>().highlightRed;
            c.g = HighLogic.CurrentGame.Parameters.CustomParams <Workshop_MiscSettings>().highlightGreen;
            c.a = 1;

            phl.UpdateHighlightColors(highlightID, c);
        }
        void UpdateHighlightColors()
        {
            //highlightActive = true;

            Color c = new Color(1, 1, 1, 1);

            // The following code is because the old way of storing the colors was a number from 0-100,
            // The new ColorPicker uses a number 0-1

            c.b = HighLogic.CurrentGame.Parameters.CustomParams <MSSRB_2>().highlightBlueA > 1 ? HighLogic.CurrentGame.Parameters.CustomParams <MSSRB_2>().highlightBlueA / 100f : HighLogic.CurrentGame.Parameters.CustomParams <MSSRB_2>().highlightBlueA;
            c.r = HighLogic.CurrentGame.Parameters.CustomParams <MSSRB_2>().highlightRedA > 1 ? HighLogic.CurrentGame.Parameters.CustomParams <MSSRB_2>().highlightRedA / 100f : HighLogic.CurrentGame.Parameters.CustomParams <MSSRB_2>().highlightRedA;
            c.g = HighLogic.CurrentGame.Parameters.CustomParams <MSSRB_2>().highlightGreenA > 1 ? HighLogic.CurrentGame.Parameters.CustomParams <MSSRB_2>().highlightGreenA / 100f : HighLogic.CurrentGame.Parameters.CustomParams <MSSRB_2>().highlightGreenA;

            phl.UpdateHighlightColors(highlightID, c);
        }
Exemple #3
0
        void UpdateHighlightColors()
        {
            {
                //highlightActive = true;

                Color c = new Color(1, 1, 1, 1);
                // The following code is because the old way of storing the colors was a number from 0-100,
                // The new ColorPicker uses a number 0-1

                c.b = HighLogic.CurrentGame.Parameters.CustomParams <PWBSettings>().highlightBlue > 1 ? HighLogic.CurrentGame.Parameters.CustomParams <PWBSettings>().highlightBlue / 100f : HighLogic.CurrentGame.Parameters.CustomParams <PWBSettings>().highlightBlue;
                c.r = HighLogic.CurrentGame.Parameters.CustomParams <PWBSettings>().highlightRed > 1 ? HighLogic.CurrentGame.Parameters.CustomParams <PWBSettings>().highlightRed / 100f : HighLogic.CurrentGame.Parameters.CustomParams <PWBSettings>().highlightRed;
                c.g = HighLogic.CurrentGame.Parameters.CustomParams <PWBSettings>().highlightGreen > 1 ? HighLogic.CurrentGame.Parameters.CustomParams <PWBSettings>().highlightGreen / 100f : HighLogic.CurrentGame.Parameters.CustomParams <PWBSettings>().highlightGreen;

                phl.UpdateHighlightColors(highlightID, c);
            }
        }
        /// <summary>
        /// Module re-start logic. OnStart will be called usually once for each scene, editor included.
        /// Put your custom start logic in DI_Start(): if you need to act on other part's
        /// variable, this is the place to do it, not DI_Reset()
        /// </summary>
        public override void OnStart(PartModule.StartState state)
        {
            Log.Info("FailureModule.OnStart, part: " + this.part.partInfo.title);
            try
            {
                if (HighLogic.LoadedSceneIsFlight) // nothing to do in editor
                {
                    this.FailureLog("Starting in flight: last reset " + TimeOfLastReset + ", now " + DangIt.Now());

                    if (!DangIt.Instance.CurrentSettings.EnabledForSave)
                    { //Disable if we've disabled DangIt
                        foreach (var e in this.Events)
                        {
                            e.guiActive = false;
                        }
                    }

                    #region Fail and repair events

                    this.Events["Fail"].guiName        = this.FailGuiName;
                    this.Events["EvaRepair"].guiName   = this.EvaRepairGuiName;
                    this.Events["Maintenance"].guiName = this.MaintenanceString;

                    #endregion

                    // Reset the internal state at the beginning of the flight
                    // this condition also catches a revert to launch (+1 second for safety)
                    if (DangIt.Now() < (this.TimeOfLastReset + 1))
                    {
                        this.Reset();
                    }

                    // If the part was saved when it was failed,
                    // re-run the failure logic to disable it
                    // ONLY THE DISABLING PART IS RUN!
                    if (this.HasFailed)
                    {
                        this.DI_Disable();
                    }

                    this.SetFailureState(this.HasFailed);

                    if (!vesselHighlightDict.ContainsKey(vessel.id))
                    {
                        var failedHighlightID = phl.CreateHighlightList(0);
                        if (failedHighlightID < 0)
                        {
                            return;
                        }
                        if (DangIt.Instance.CurrentSettings.FlashingGlow)
                        {
                            phl.SetFlashInterval(failedHighlightID, HighLogic.CurrentGame.Parameters.CustomParams <DangItCustomParams1>().flashingInterval);
                        }
                        vesselHighlightDict[vessel.id] = failedHighlightID;
                    }
                    phl.UpdateHighlightColors(vesselHighlightDict[vessel.id], Color.red);


                    if (DangIt.Instance.CurrentSettings.EnabledForSave)
                    {
                        this.DI_Start(state);
                        this.StartCoroutine("RuntimeFetch");
                    }
                }
            }
            catch (Exception e)
            {
                OnError(e);
            }
        }