예제 #1
0
        private bool RefreshStockButton()
        {
            bool result = false;

            try
            {
                stockToolbar = StockToolbar.Instance;
                if (stockToolbar != null)
                {
                    result = true;
                    stockToolbar.ButtonNeeded = true;
                    stockToolbar.CreateButton();

                    if (!stockToolbar.ButtonNeeded)
                    {
                        result           = false;
                        windowPos.height = 20;
                        lostToStaging    = true;
                    }
                }
            }
            catch (Exception ex)
            {
                print("Proximity - RefreshStockButton(): " + ex.Message);
            }
            return(result);
        }
예제 #2
0
        private bool RefreshStockButton()
        {
            bool result = false;

            //print("@@@RefreshStockButton");

            if (useStockToolBar)
            {
                //print("@@@RefreshStockButton, using stock tb");
                StockToolbar stb = (StockToolbar)StockToolbar.FindObjectOfType(typeof(StockToolbar));
                if (stb != null)
                {
                    //print("@@@RefreshStockButton, got stock tb");
                    result           = true;
                    stb.ButtonNeeded = true;
                    stb.CreateButton();
                    //print("@@@RefreshStockButton: stb.CreateButton() called, result " + stb.ButtonNeeded.ToString());
                    if (!stb.ButtonNeeded)
                    {
                        result           = false;
                        windowPos.height = 20;
                        lostToStaging    = true;
                        //print("@@@RefreshStockButton, set lostToStaging = true");
                    }
                }
            }

            return(result);
        }
예제 #3
0
        internal void ToggleSystemOn()
        {
            SystemOn   = !SystemOn;
            sizechange = true;

            {
                StockToolbar stb = (StockToolbar)StockToolbar.FindObjectOfType(typeof(StockToolbar));
                if (stb != null)
                {
                    stb.RefreshButtonTexture();
                }
            }
        }
예제 #4
0
        private void ShowSettings()
        {
            //print("@@@ShowSettings");
            if (UseToolbar && toolbarShowSettings)
            {
                //print("@@@ShowSettings - showing");
                // Activation height
                GUILayout.BeginHorizontal(GUILayout.Width(fixedwidth - margin));
                GUILayout.Label("Active below:");
                if (GUILayout.Button("-", styleButton, GUILayout.ExpandWidth(true)))
                {
                    ActivationHeight -= 500;
                    if (ActivationHeight < 500)
                    {
                        ActivationHeight = 500;
                    }
                }

                GUILayout.Label(ActivationHeight.ToString() + " m", styleValue);

                if (GUILayout.Button("+", styleButton, GUILayout.ExpandWidth(true)))
                {
                    ActivationHeight += 500;
                    if (ActivationHeight > 10000)
                    {
                        ActivationHeight = 10000;
                    }
                }

                GUILayout.EndHorizontal();

                // Visual type
                GUILayout.BeginHorizontal(GUILayout.Width(fixedwidth - margin));
                string cap = "Visual: " + visualType[visualIndex];
                cap = cap.Replace("%", DSThreshold.ToString());
                if (GUILayout.Button(cap, styleButton, GUILayout.ExpandWidth(true)))
                {
                    visualIndex++;
                    if (visualIndex == visualType.Length)
                    {
                        visualIndex = 0;
                    }
                    if (visualIndex == 2 || visualIndex == 3) // change size due to threshold field appearing / disappearing
                    {
                        sizechange = true;
                    }
                }
                GUILayout.EndHorizontal();

#if !PERSONAL_VERSION
                // Visual threshold subtype
                if (visualIndex == 2)
                {
                    ThresholdHeight(styleValue);
                }
#endif

                // Sound type
                GUILayout.BeginHorizontal(GUILayout.Width(fixedwidth - margin));
                if (GUILayout.Button("Sound: " + beepType[beepIndex], styleButton, GUILayout.ExpandWidth(true)))
                {
                    beepIndex++;
                    if (beepIndex == beepType.Length)
                    {
                        beepIndex = 0;
                    }
                }
                GUILayout.EndHorizontal();

                // beep pitch
                GUILayout.BeginHorizontal(GUILayout.Width(fixedwidth - margin));
                if (GUILayout.Button("Pitch: " + pitchType[pitchIndex], styleButton, GUILayout.ExpandWidth(true)))
                {
                    pitchIndex++;
                    if (pitchIndex == pitchType.Length)
                    {
                        pitchIndex = 0;
                    }
                }
                GUILayout.EndHorizontal();

                // beep volume
                float oldvol = volume;
                GUILayout.BeginHorizontal(GUILayout.Width(fixedwidth - margin));
                GUILayout.Label("Volume:", GUILayout.ExpandWidth(false));
                volume = GUILayout.HorizontalSlider(volume, 0.01f, 1f, GUILayout.ExpandWidth(true));
                GUILayout.EndHorizontal();
                if (volume != oldvol)
                {
                    obj.audio.volume = volume;
                }

                // beep length
                GUILayout.BeginHorizontal(GUILayout.Width(fixedwidth - margin));
                GUILayout.Label("Beep length: ");
                if (GUILayout.Button("-", styleButton, GUILayout.ExpandWidth(true)))
                {
                    beepLength--;
                    if (beepLength < 1)
                    {
                        beepLength = 1;
                    }
                    MakeBeep();
                }

                GUILayout.Label(beepLength.ToString(), styleValue);

                if (GUILayout.Button("+", styleButton, GUILayout.ExpandWidth(true)))
                {
                    beepLength++;
                    if (beepLength > 10)
                    {
                        beepLength = 10;
                    }
                    MakeBeep();
                }

                GUILayout.EndHorizontal();

                // parachutes
                GUILayout.BeginHorizontal(GUILayout.Width(fixedwidth - margin));
                deactivateOnParachute = GUILayout.Toggle(deactivateOnParachute, " Off if parachuting", styleToggle, null);
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal(GUILayout.Width(fixedwidth - margin));
                deactivateIfRover = GUILayout.Toggle(deactivateIfRover, " Off if vessel is rover", styleToggle, null);
                GUILayout.EndHorizontal();

#if PERSONAL_VERSION
                // Configure ship for landing
                styleValue.normal.textColor = styleValue.focused.textColor = styleValue.hover.textColor = styleValue.active.textColor = Color.green;
                styleValue.alignment        = TextAnchor.MiddleCenter;

                bool oldauto = autoExtendLandingLegs;
                GUILayout.BeginHorizontal(GUILayout.Width(fixedwidth - margin));
                autoExtendLandingLegs = GUILayout.Toggle(autoExtendLandingLegs, " Autodeploy landing legs", styleToggle, null);
                GUILayout.EndHorizontal();
                if (autoExtendLandingLegs != oldauto)
                {
                    sizechange = true;
                }

                oldauto = autoParachute;
                GUILayout.BeginHorizontal(GUILayout.Width(fixedwidth - margin));
                autoParachute = GUILayout.Toggle(autoParachute, " Autodeploy parachute", styleToggle, null);
                GUILayout.EndHorizontal();
                if (autoParachute != oldauto)
                {
                    sizechange = true;
                }

                // Visual threshold subtype
                if (visualIndex == 2 || autoExtendLandingLegs || autoParachute)
                {
                    ThresholdHeight(styleValue);
                }
#endif

                styleButton.normal.textColor = styleButton.focused.textColor = styleButton.hover.textColor = styleButton.active.textColor = SystemOn ? Color.red: Color.green;
                styleValue.normal.textColor  = styleValue.focused.textColor = styleValue.hover.textColor = styleValue.active.textColor = Color.white;

                GUILayout.BeginHorizontal(GUILayout.Width(fixedwidth - margin));
                GUILayout.Label("Proximity ", styleValue);
                styleValue.normal.textColor = styleValue.focused.textColor = styleValue.hover.textColor = styleValue.active.textColor = SystemOn ? Color.green: Color.red;
                GUILayout.Label(SystemOn ? "ON ": "OFF ", styleValue);
                if (GUILayout.Button(SystemOn ? "Switch off": "Switch on", styleButton, GUILayout.ExpandWidth(true)))
                {
                    SystemOn   = !SystemOn;
                    sizechange = true;

                    if (!useStockToolBar)
                    {
                        RefreshBlizzyButton();
                    }
                    else
                    {
                        // here be twiddles
                        //RefreshStockButton();
                        //print("@@@ShowSettings, toggling on off");
                        StockToolbar stb = (StockToolbar)StockToolbar.FindObjectOfType(typeof(StockToolbar));
                        if (stb != null)
                        {
                            stb.RefreshButtonTexture();
                        }
                    }
                }
                GUILayout.EndHorizontal();
            }
        }
예제 #5
0
 void Start()
 {
     Instance = this;
     DontDestroyOnLoad(this);
 }