void Start()
        {
            if (!CompatibilityChecker.IsAllCompatible())
            {
                this.enabled = false;
                return;
            }

            _vessel                = GetComponent <Vessel>();
            _vesselAero            = GetComponent <FARVesselAero>();
            _physicsCalcs          = new PhysicsCalcs(_vessel, _vesselAero);
            _flightStatusGUI       = new FlightStatusGUI();
            _stabilityAugmentation = new StabilityAugmentation(_vessel);
            _flightDataGUI         = new FlightDataGUI();
            _aeroVizGUI            = new AeroVisualizationGUI();

            settingsWindow = new GUIDropDown <int>(new string[4] {
                "Flt Data", "Stab Aug", "Air Spd", "Aero Viz"
            }, new int[4] {
                0, 1, 2, 3
            }, 0);
            //boxStyle.padding = new RectOffset(4, 4, 4, 4);

            if (vesselFlightGUI.ContainsKey(_vessel))
            {
                vesselFlightGUI[_vessel] = this;
            }
            else
            {
                vesselFlightGUI.Add(_vessel, this);
            }

            this.enabled = true;

            if (FARDebugValues.useBlizzyToolbar)
            {
                GenerateBlizzyToolbarButton();
            }
            else
            {
                OnGUIAppLauncherReady();
            }

            activeFlightGUICount++;

            if (_vessel == FlightGlobals.ActiveVessel || FlightGlobals.ActiveVessel == null)
            {
                LoadConfigs();
            }

            GameEvents.onShowUI.Add(ShowUI);
            GameEvents.onHideUI.Add(HideUI);
        }
Example #2
0
        void OnDestroy()
        {
            FlightGUIDrawer.SetGUIActive(this, false);
            GameEvents.onShowUI.Remove(ShowUI);
            GameEvents.onHideUI.Remove(HideUI);
            SaveConfigs();
            if (_vessel)
            {
                vesselFlightGUI.Remove(_vessel);
            }
            _physicsCalcs = null;

            if (_flightDataGUI != null)
            {
                _flightDataGUI.SaveSettings();
            }
            _flightDataGUI = null;

            if (_stabilityAugmentation != null)
            {
                _stabilityAugmentation.SaveAndDestroy();
            }
            _stabilityAugmentation = null;

            if (_airSpeedGUI != null)
            {
                _airSpeedGUI.SaveSettings();
            }
            _airSpeedGUI = null;

            if (_aeroVizGUI != null)
            {
                _aeroVizGUI.SaveSettings();
            }

            _flightStatusGUI = null;
            settingsWindow   = null;

            activeFlightGUICount--;

            if (activeFlightGUICount <= 0)
            {
                activeFlightGUICount = 0;
                if (blizzyFlightGUIButton != null)
                {
                    ClearBlizzyToolbarButton();
                }
            }

            savedShowGUI = showGUI;
        }
        void OnDestroy()
        {
            GameEvents.onShowUI.Remove(ShowUI);
            GameEvents.onHideUI.Remove(HideUI);
            SaveConfigs();
            if (_vessel)
            {
                vesselFlightGUI.Remove(_vessel);
            }
            _physicsCalcs = null;

            if (_flightDataGUI != null)
            {
                _flightDataGUI.SaveSettings();
            }
            _flightDataGUI = null;

            if (_stabilityAugmentation != null)
            {
                _stabilityAugmentation.SaveAndDestroy();
            }
            _stabilityAugmentation = null;

            if (_airSpeedGUI != null)
            {
                _airSpeedGUI.SaveSettings();
            }
            _airSpeedGUI = null;

            _flightStatusGUI = null;
            settingsWindow   = null;

            if (blizzyFlightGUIButton != null)
            {
                blizzyFlightGUIButton.Destroy();
            }
        }
Example #4
0
        protected override void OnStart()
        {
            base.OnStart();

            if (!CompatibilityChecker.IsAllCompatible())
            {
                enabled = false;
                return;
            }

            showGUI = savedShowGUI;
            //since we're sharing the button, we need these shenanigans now
            if (FARDebugAndSettings.FARDebugButtonStock && HighLogic.LoadedSceneIsFlight)
            {
                if (showGUI)
                {
                    FARDebugAndSettings.FARDebugButtonStock.SetTrue(false);
                }
                else
                {
                    FARDebugAndSettings.FARDebugButtonStock.SetFalse(false);
                }
            }


            _vessel                = GetComponent <Vessel>();
            _vesselAero            = GetComponent <FARVesselAero>();
            _physicsCalcs          = new PhysicsCalcs(_vessel, _vesselAero);
            _flightStatusGUI       = new FlightStatusGUI();
            _stabilityAugmentation = new StabilityAugmentation(_vessel);
            _flightDataGUI         = new FlightDataGUI();
            AeroVizGUI             = new AeroVisualizationGUI();

            settingsWindow = new GUIDropDown <int>(new[]
            {
                Localizer.Format("FARFlightGUIWindowSelect0"),
                Localizer.Format("FARFlightGUIWindowSelect1"),
                Localizer.Format("FARFlightGUIWindowSelect2"),
                Localizer.Format("FARFlightGUIWindowSelect3")
            },
                                                   new[] { 0, 1, 2, 3 });

            if (vesselFlightGUI.ContainsKey(_vessel))
            {
                vesselFlightGUI[_vessel] = this;
            }
            else
            {
                vesselFlightGUI.Add(_vessel, this);
            }

            enabled = true;

            if (FARDebugValues.useBlizzyToolbar)
            {
                GenerateBlizzyToolbarButton();
            }

            activeFlightGUICount++;

            if (_vessel == FlightGlobals.ActiveVessel || FlightGlobals.ActiveVessel == null)
            {
                LoadConfigs();
            }

            GameEvents.onShowUI.Add(ShowUI);
            GameEvents.onHideUI.Add(HideUI);
        }
        void OnDestroy()
        {
            GameEvents.onShowUI.Remove(ShowUI);
            GameEvents.onHideUI.Remove(HideUI);
            SaveConfigs();
            if (_vessel)
            {
                vesselFlightGUI.Remove(_vessel);
            }
            _physicsCalcs = null;

            if(_flightDataGUI != null)
                _flightDataGUI.SaveSettings();
            _flightDataGUI = null;

            if(_stabilityAugmentation != null)
                _stabilityAugmentation.SaveAndDestroy();
            _stabilityAugmentation = null;

            if(_airSpeedGUI != null)
                _airSpeedGUI.SaveSettings();
            _airSpeedGUI = null;

            if (_aeroVizGUI != null)
                _aeroVizGUI.SaveSettings();

            _flightStatusGUI = null;
            settingsWindow = null;

            activeFlightGUICount--;

            if (activeFlightGUICount <= 0)
            {
                activeFlightGUICount = 0;
                if (blizzyFlightGUIButton != null)
                    ClearBlizzyToolbarButton();
            }
            
        }
        void Start()
        {
            if (!CompatibilityChecker.IsAllCompatible())
            {
                this.enabled = false;
                return;
            }

            _vessel = GetComponent<Vessel>();
            _vesselAero = GetComponent<FARVesselAero>();
            _physicsCalcs = new PhysicsCalcs(_vessel, _vesselAero);
            _flightStatusGUI = new FlightStatusGUI();
            _stabilityAugmentation = new StabilityAugmentation(_vessel);
            _flightDataGUI = new FlightDataGUI();
            _aeroVizGUI = new AeroVisualizationGUI();

            settingsWindow = new GUIDropDown<int>(new string[4]{"Flt Data","Stab Aug", "Air Spd","Aero Viz"}, new int[4]{0,1,2,3}, 0);
            //boxStyle.padding = new RectOffset(4, 4, 4, 4);

            if (vesselFlightGUI.ContainsKey(_vessel))
                vesselFlightGUI[_vessel] = this;
            else
                vesselFlightGUI.Add(_vessel, this);

            this.enabled = true;

            if (FARDebugValues.useBlizzyToolbar)
            {
                GenerateBlizzyToolbarButton();
            }
            else
                OnGUIAppLauncherReady();

            activeFlightGUICount++;

            if(_vessel == FlightGlobals.ActiveVessel)
                LoadConfigs();

            GameEvents.onShowUI.Add(ShowUI);
            GameEvents.onHideUI.Add(HideUI);
        }
        void OnDestroy()
        {
            GameEvents.onShowUI.Remove(ShowUI);
            GameEvents.onHideUI.Remove(HideUI);
            SaveConfigs();
            if (_vessel)
            {
                vesselFlightGUI.Remove(_vessel);
            }
            _physicsCalcs = null;

            if(_flightDataGUI != null)
                _flightDataGUI.SaveSettings();
            _flightDataGUI = null;

            if(_stabilityAugmentation != null)
                _stabilityAugmentation.SaveAndDestroy();
            _stabilityAugmentation = null;

            if(_airSpeedGUI != null)
                _airSpeedGUI.SaveSettings();
            _airSpeedGUI = null;

            _flightStatusGUI = null;
            settingsWindow = null;

            if (blizzyFlightGUIButton != null)
                blizzyFlightGUIButton.Destroy();
        }