public void OnDestroy()
        {
            this.partWizardWindow.Hide();
            this.partWizardWindow = null;

            ToolbarController.Instance.Destroy();
            this.toolbarControl = null;
        }
Exemple #2
0
        public void OnDestroy()
        {
            this.partWizardWindow.OnVisibleChanged -= partWizardWindow_OnVisibleChanged;

            this.partWizardWindow.Hide();
            this.partWizardWindow = null;

            if (ToolbarIsStock)
            {
                GameEvents.onGUIApplicationLauncherReady.Remove(OnGUIAppLauncherReady);
                GameEvents.onGUIApplicationLauncherDestroyed.Remove(OnGUIAppLauncherDestroyed);
            }
            else
            {
                this.partWizardBlizzyButton.Destroy();
                this.partWizardBlizzyButton = null;
            }
        }
Exemple #3
0
        public void Awake()
        {
            if (HighLogic.LoadedSceneIsEditor)
            {
                this.partWizardWindow = new PartWizardWindow(PartWizardPlugin.Name, PartWizardPlugin.Version);
                this.partWizardWindow.OnVisibleChanged += partWizardWindow_OnVisibleChanged;

                // Are we using Blizzy's Toolbar?
                ToolbarIsStock = bool.Parse(Configuration.GetValue(PartWizardPlugin.keyToolbarIsStock, "False"));

                if (ToolbarManager.ToolbarAvailable && !ToolbarIsStock)
                {
                    this.toolbarIconActive   = Configuration.GetValue(PartWizardPlugin.KeyToolbarIconActive, PartWizardPlugin.BlizzyToolbarIconActive);
                    this.toolbarIconInactive = Configuration.GetValue(PartWizardPlugin.KeyToolbarIconInactive, PartWizardPlugin.BlizzyToolbarIconInactive);

                    Configuration.SetValue(PartWizardPlugin.keyToolbarIsStock, ToolbarIsStock.ToString());
                    Configuration.SetValue(PartWizardPlugin.KeyToolbarIconActive, this.toolbarIconActive);
                    Configuration.SetValue(PartWizardPlugin.KeyToolbarIconInactive, this.toolbarIconInactive);
                    Configuration.Save();

                    this.partWizardBlizzyButton            = ToolbarManager.Instance.add("PartWizardNS", "partWizardButton");
                    this.partWizardBlizzyButton.ToolTip    = PartWizardPlugin.Name;
                    this.partWizardBlizzyButton.OnClick   += this.partWizardButton_Click;
                    this.partWizardBlizzyButton.Visibility = new GameScenesVisibility(GameScenes.EDITOR);

                    this.UpdateToolbarIcon();
                }
                else
                {
                    // Blizzy toolbar not available, or Stock Toolbar selected Let's go stock :(
                    ToolbarIsStock = true;
                    GameEvents.onGUIApplicationLauncherReady.Add(OnGUIAppLauncherReady);
                    GameEvents.onGUIApplicationLauncherDestroyed.Add(OnGUIAppLauncherDestroyed);

                    this.toolbarIconActive   = Configuration.GetValue(PartWizardPlugin.KeyToolbarIconActive, PartWizardPlugin.StockToolbarIconActive);
                    this.toolbarIconInactive = Configuration.GetValue(PartWizardPlugin.KeyToolbarIconInactive, PartWizardPlugin.StockToolbarIconInactive);

                    Configuration.SetValue(PartWizardPlugin.keyToolbarIsStock, ToolbarIsStock.ToString());
                    Configuration.SetValue(PartWizardPlugin.KeyToolbarIconActive, this.toolbarIconActive);
                    Configuration.SetValue(PartWizardPlugin.KeyToolbarIconInactive, this.toolbarIconInactive);
                    Configuration.Save();
                }
            }
        }
        public void Awake()
        {
            Instance = this;
            if (HighLogic.LoadedSceneIsEditor)
            {
                this.partWizardWindow = new PartWizardWindow(Version.FriendlyName, Version.Text);

                this.toolbarControl = Toolbar.Button.Create(this
                                                            , ApplicationLauncher.AppScenes.VAB | ApplicationLauncher.AppScenes.SPH
                                                            , UI.Icon.StockToolbarIconActive, UI.Icon.StockToolbarIconInactive
                                                            , UI.Icon.BlizzyToolbarIconActive, UI.Icon.BlizzyToolbarIconInactive
                                                            , Version.FriendlyName
                                                            );

                this.toolbarControl.Toolbar.Add(Toolbar.Button.ToolbarEvents.Kind.Active, new Toolbar.Button.Event(this.ToggleVisibility, this.ToggleVisibility));

                ToolbarController.Instance.Add(this.toolbarControl);
            }
        }
        public void Awake()
        {
            if(HighLogic.LoadedSceneIsEditor)
            {
                this.partWizardWindow = new PartWizardWindow(PartWizardPlugin.Name, PartWizardPlugin.Version);
                this.partWizardWindow.OnVisibleChanged += partWizardWindow_OnVisibleChanged;

                // Are we using Blizzy's Toolbar?
                ToolbarIsStock = Configuration.GetValue(PartWizardPlugin.KeyToolbarIsStock, false);

                if(ToolbarManager.ToolbarAvailable && !ToolbarIsStock)
                {
                    this.toolbarIconActive = Configuration.GetValue(PartWizardPlugin.KeyToolbarIconActive, PartWizardPlugin.BlizzyToolbarIconActive);
                    this.toolbarIconInactive = Configuration.GetValue(PartWizardPlugin.KeyToolbarIconInactive, PartWizardPlugin.BlizzyToolbarIconInactive);

                    this.SaveToolbarConfiguration();

                    this.partWizardBlizzyButton = ToolbarManager.Instance.add("PartWizardNS", "partWizardButton");
                    this.partWizardBlizzyButton.ToolTip = PartWizardPlugin.Name;
                    this.partWizardBlizzyButton.OnClick += this.partWizardButton_Click;
                    this.partWizardBlizzyButton.Visibility = new GameScenesVisibility(GameScenes.EDITOR);

                    this.UpdateToolbarIcon();
                }
                else
                {
                    // Blizzy toolbar not available, or Stock Toolbar selected Let's go stock :(
                    ToolbarIsStock = true;
                    GameEvents.onGUIApplicationLauncherReady.Add(OnGUIAppLauncherReady);
                    GameEvents.onGUIApplicationLauncherDestroyed.Add(OnGUIAppLauncherDestroyed);

                    this.toolbarIconActive = Configuration.GetValue(PartWizardPlugin.KeyToolbarIconActive, PartWizardPlugin.StockToolbarIconActive);
                    this.toolbarIconInactive = Configuration.GetValue(PartWizardPlugin.KeyToolbarIconInactive, PartWizardPlugin.StockToolbarIconInactive);

                    this.SaveToolbarConfiguration();
                }
            }
        }
        public void OnDestroy()
        {
            this.partWizardWindow.OnVisibleChanged -= partWizardWindow_OnVisibleChanged;

            this.partWizardWindow.Hide();
            this.partWizardWindow = null;

            if(ToolbarIsStock)
            {
                GameEvents.onGUIApplicationLauncherReady.Remove(OnGUIAppLauncherReady);
                GameEvents.onGUIApplicationLauncherDestroyed.Remove(OnGUIAppLauncherDestroyed);

                if(this.partWizardStockButton != null)
                {
                    ApplicationLauncher.Instance.RemoveModApplication(this.partWizardStockButton);
                    this.partWizardStockButton = null;
                }
            }
            else
            {
                this.partWizardBlizzyButton.Destroy();
                this.partWizardBlizzyButton = null;
            }
        }