Exemple #1
0
 private void RemoveButtons( )
 {
     if (_checklistButton != null)
     {
         _checklistButton.ButtonOn  -= ChecklistButton_Open;
         _checklistButton.ButtonOff -= ChecklistButton_Close;
         _checklistButton.Remove( );
         _checklistButton = null;
     }
     if (_statusButton != null)
     {
         _statusButton.ButtonOn  -= StatusButton_Open;
         _statusButton.ButtonOff -= StatusButton_Close;
         _statusButton.Remove( );
         _statusButton = null;
     }
 }
Exemple #2
0
        // Add the buttons
        private void AddButtons( )
        {
            Texture2D StockTexture;



            _checklistButton = new UnifiedButton( );


            if (BlizzysToolbarButton.IsAvailable)
            {
                _checklistButton.UseBlizzyIfPossible = Config.UseBlizzysToolbar;

                var texturePath = "ScienceChecklist/ChecklistSmall.png";
                if (!GameDatabase.Instance.ExistsTexture(texturePath))
                {
                    var texture = TextureHelper.FromResource("ScienceChecklist.icons.icon-small.png", 24, 24);
                    var ti      = new GameDatabase.TextureInfo(null, texture, false, true, true);
                    ti.name = texturePath;
                    GameDatabase.Instance.databaseTexture.Add(ti);
                }
//				_logger.Info( "Load : Blizzy texture" );


                _checklistButton.BlizzyNamespace   = WINDOW_NAME_CHECKLIST;
                _checklistButton.BlizzyButtonId    = "checklist_button";
                _checklistButton.BlizzyToolTip     = "[x] Science! Checklist";
                _checklistButton.BlizzyText        = "Science Report and Checklist";
                _checklistButton.BlizzyTexturePath = texturePath;
                _checklistButton.BlizzyVisibility  = new GameScenesVisibility(GameScenes.SPACECENTER, GameScenes.EDITOR, GameScenes.FLIGHT, GameScenes.TRACKSTATION);
//				_logger.Info( "Load : Set Blizzy Stuff" );
            }



            StockTexture = TextureHelper.FromResource("ScienceChecklist.icons.icon.png", 38, 38);

/*			if( StockTexture != null )
 *                              _logger.Info( "Load : Stock texture" );
 *                      else
 *                              _logger.Info( "Load : cant load texture" );*/
            _checklistButton.LauncherTexture    = StockTexture;
            _checklistButton.LauncherVisibility =
                ApplicationLauncher.AppScenes.SPACECENTER |
                ApplicationLauncher.AppScenes.FLIGHT |
                ApplicationLauncher.AppScenes.MAPVIEW |
                ApplicationLauncher.AppScenes.VAB |
                ApplicationLauncher.AppScenes.SPH |
                ApplicationLauncher.AppScenes.TRACKSTATION;
//			_logger.Info( "Load : Set Stock Stuff" );


            _checklistButton.ButtonOn   += ChecklistButton_Open;
            _checklistButton.ButtonOff  += ChecklistButton_Close;
            _checklistButton.RightClick += ChecklistButton_RightClick;
            _checklistButton.Add( );



            if (Config.RighClickMutesMusic)              // So we need both buttons
            {
                _statusButton = new UnifiedButton( );


                if (BlizzysToolbarButton.IsAvailable)
                {
                    _statusButton.UseBlizzyIfPossible = Config.UseBlizzysToolbar;

                    var texturePath = "ScienceChecklist/StatusSmall.png";
                    if (!GameDatabase.Instance.ExistsTexture(texturePath))
                    {
                        var texture = TextureHelper.FromResource("ScienceChecklist.icons.icon-status-small.png", 24, 24);
                        var ti      = new GameDatabase.TextureInfo(null, texture, false, true, true);
                        ti.name = texturePath;
                        GameDatabase.Instance.databaseTexture.Add(ti);
                    }
                    //				_logger.Info( "Load : Blizzy texture" );


                    _statusButton.BlizzyNamespace   = WINDOW_NAME_CHECKLIST;
                    _statusButton.BlizzyButtonId    = "status_button";
                    _statusButton.BlizzyToolTip     = "[x] Science! Here & Now";
                    _statusButton.BlizzyText        = "Science Status Window";
                    _statusButton.BlizzyTexturePath = texturePath;
                    _statusButton.BlizzyVisibility  = new GameScenesVisibility(GameScenes.FLIGHT);
                    //				_logger.Info( "Load : Set Blizzy Stuff" );
                }



                StockTexture = TextureHelper.FromResource("ScienceChecklist.icons.icon-status.png", 38, 38);

                /*			if( StockTexture != null )
                 *                              _logger.Info( "Load : Stock texture" );
                 *                      else
                 *                              _logger.Info( "Load : cant load texture" );*/
                _statusButton.LauncherTexture    = StockTexture;
                _statusButton.LauncherVisibility =
                    ApplicationLauncher.AppScenes.FLIGHT |
                    ApplicationLauncher.AppScenes.MAPVIEW;
                //			_logger.Info( "Load : Set Stock Stuff" );


                _statusButton.ButtonOn  += StatusButton_Open;
                _statusButton.ButtonOff += StatusButton_Close;
                _statusButton.Add( );
            }
        }
        // Add the buttons
        private void AddButtons()
        {
            //Texture2D StockTexture;

            if (checklistToolbarControl == null)
            {
                checklistToolbarControl = gameObject.AddComponent <ToolbarControl>();
                checklistToolbarControl.AddToAllToolbars(null, null,
                                                         ApplicationLauncher.AppScenes.SPACECENTER |
                                                         ApplicationLauncher.AppScenes.FLIGHT |
                                                         ApplicationLauncher.AppScenes.MAPVIEW |
                                                         ApplicationLauncher.AppScenes.VAB |
                                                         ApplicationLauncher.AppScenes.SPH |
                                                         ApplicationLauncher.AppScenes.TRACKSTATION,
                                                         MODID,
                                                         "xScienceButton1",
                                                         "[x]_Science!/PluginData/Icons/icon",
                                                         "[x]_Science!/PluginData/Icons/icon-small",
                                                         MODNAME
                                                         );
                checklistToolbarControl.AddLeftRightClickCallbacks(LeftButtonToggle, RightButton);
            }

            //_checklistButton = new UnifiedButton( gameObject, 1);

#if false
            if (BlizzysToolbarButton.IsAvailable)
            {
                _checklistButton.UseBlizzyIfPossible = Config.UseBlizzysToolbar;

                var texturePath = "ScienceChecklist/ChecklistSmall.png";
                if (!GameDatabase.Instance.ExistsTexture(texturePath))
                {
                    var texture = TextureHelper.FromResource("ScienceChecklist.icons.icon-small.png", 24, 24);
                    var ti      = new GameDatabase.TextureInfo(null, texture, false, true, true);
                    ti.name = texturePath;
                    GameDatabase.Instance.databaseTexture.Add(ti);
                }
//				_logger.Info( "Load : Blizzy texture" );


                _checklistButton.BlizzyNamespace   = WINDOW_NAME_CHECKLIST;
                _checklistButton.BlizzyButtonId    = "checklist_button";
                _checklistButton.BlizzyToolTip     = "[x] Science! Checklist";
                _checklistButton.BlizzyText        = "Science Report and Checklist";
                _checklistButton.BlizzyTexturePath = texturePath;
                _checklistButton.BlizzyVisibility  = new GameScenesVisibility(GameScenes.SPACECENTER, GameScenes.EDITOR, GameScenes.FLIGHT, GameScenes.TRACKSTATION);
//				_logger.Info( "Load : Set Blizzy Stuff" );
            }



            StockTexture = TextureHelper.FromResource("ScienceChecklist.icons.icon.png", 38, 38);

/*			if( StockTexture != null )
 *                              _logger.Info( "Load : Stock texture" );
 *                      else
 *                              _logger.Info( "Load : cant load texture" );*/
            _checklistButton.LauncherTexture    = StockTexture;
            _checklistButton.LauncherVisibility =
                ApplicationLauncher.AppScenes.SPACECENTER |
                ApplicationLauncher.AppScenes.FLIGHT |
                ApplicationLauncher.AppScenes.MAPVIEW |
                ApplicationLauncher.AppScenes.VAB |
                ApplicationLauncher.AppScenes.SPH |
                ApplicationLauncher.AppScenes.TRACKSTATION;
//			_logger.Info( "Load : Set Stock Stuff" );


            _checklistButton.ButtonOn   += ChecklistButton_Open;
            _checklistButton.ButtonOff  += ChecklistButton_Close;
            _checklistButton.RightClick += ChecklistButton_RightClick;
            _checklistButton.Add( );
#endif


            if (Config.RighClickMutesMusic) // So we need both buttons
            {
#if false
                _statusButton = new UnifiedButton(gameObject, 2);

                if (BlizzysToolbarButton.IsAvailable)
                {
                    _statusButton.UseBlizzyIfPossible = Config.UseBlizzysToolbar;

                    var texturePath = "ScienceChecklist/StatusSmall.png";
                    if (!GameDatabase.Instance.ExistsTexture(texturePath))
                    {
                        var texture = TextureHelper.FromResource("ScienceChecklist.icons.icon-status-small.png", 24, 24);
                        var ti      = new GameDatabase.TextureInfo(null, texture, false, true, true);
                        ti.name = texturePath;
                        GameDatabase.Instance.databaseTexture.Add(ti);
                    }
                    //				_logger.Info( "Load : Blizzy texture" );


                    _statusButton.BlizzyNamespace   = WINDOW_NAME_CHECKLIST;
                    _statusButton.BlizzyButtonId    = "status_button";
                    _statusButton.BlizzyToolTip     = "[x] Science! Here & Now";
                    _statusButton.BlizzyText        = "Science Status Window";
                    _statusButton.BlizzyTexturePath = texturePath;
                    _statusButton.BlizzyVisibility  = new GameScenesVisibility(GameScenes.FLIGHT);
                    //				_logger.Info( "Load : Set Blizzy Stuff" );
                }
                UnifiedButton.toolbarControl.SetTexture("[x]_Science!/PluginData/Icons/icon-status", "[x]_Science!/PluginData/Icons/icon-status-small");



                StockTexture = TextureHelper.FromResource("ScienceChecklist.icons.icon-status.png", 38, 38);

                /*			if( StockTexture != null )
                 *                              _logger.Info( "Load : Stock texture" );
                 *                      else
                 *                              _logger.Info( "Load : cant load texture" );*/
                _statusButton.LauncherTexture    = StockTexture;
                _statusButton.LauncherVisibility =
                    ApplicationLauncher.AppScenes.FLIGHT |
                    ApplicationLauncher.AppScenes.MAPVIEW;
                //			_logger.Info( "Load : Set Stock Stuff" );


                _statusButton.ButtonOn  += StatusButton_Open;
                _statusButton.ButtonOff += StatusButton_Close;
                _statusButton.Add( );
#endif
                if (statusToolbarControl == null)
                {
                    statusToolbarControl = gameObject.AddComponent <ToolbarControl>();
                    statusToolbarControl.AddToAllToolbars(StatusButton_Open, StatusButton_Close,
                                                          ApplicationLauncher.AppScenes.FLIGHT |
                                                          ApplicationLauncher.AppScenes.MAPVIEW,
                                                          MODID + "2",
                                                          "xScienceButton2",
                                                          "[x]_Science!/PluginData/Icons/icon-status",
                                                          "[x]_Science!/PluginData/Icons/icon-status-small",
                                                          WINDOW_CHECKLIST
                                                          );
                }
            }
            if (statusToolbarControl != null)
            {
                if (_statusWindow.IsVisible())
                {
                    statusToolbarControl.SetTrue(true);
                }
                else
                {
                    statusToolbarControl.SetFalse(true);
                }
            }
        }