Пример #1
0
        public ScienceWindow(ScienceChecklistAddon Parent, SettingsWindow settingsWindow, HelpWindow helpWindow)
        {
            _parent         = Parent;
            _settingsWindow = settingsWindow;
            _helpWindow     = helpWindow;

            _logger       = new Logger(this);
            _defaultSize  = new Vector2(500, 400);
            _rect         = wScale(new Rect(40, 40, _defaultSize.x, _defaultSize.y));
            _defaultSize3 = new Vector2(400, 200);
            _rect3        = wScale(new Rect(40, 40, _defaultSize3.x, _defaultSize3.y));
            _scrollPos    = new Vector2();
            _filter       = new ExperimentFilter(_parent);

            _progressTexture         = TextureHelper.FromResource("ScienceChecklist.icons.scienceProgress.png", 13, 13);
            _completeTexture         = TextureHelper.FromResource("ScienceChecklist.icons.scienceComplete.png", 13, 13);
            _progressTextureCompact  = TextureHelper.FromResource("ScienceChecklist.icons.scienceProgressCompact.png", 8, 8);
            _completeTextureCompact  = TextureHelper.FromResource("ScienceChecklist.icons.scienceCompleteCompact.png", 8, 8);
            _currentSituationTexture = TextureHelper.FromResource("ScienceChecklist.icons.currentSituation.png", 25, 21);
            _currentVesselTexture    = TextureHelper.FromResource("ScienceChecklist.icons.currentVessel.png", 25, 21);
            _notCurrentVesselTexture = TextureHelper.FromResource("ScienceChecklist.icons.notCurrentVessel.png", 25, 21);
            _unlockedTexture         = TextureHelper.FromResource("ScienceChecklist.icons.unlocked.png", 25, 21);
            _allTexture         = TextureHelper.FromResource("ScienceChecklist.icons.all.png", 25, 21);
            _searchTexture      = TextureHelper.FromResource("ScienceChecklist.icons.search.png", 25, 21);
            _clearSearchTexture = TextureHelper.FromResource("ScienceChecklist.icons.clearSearch.png", 25, 21);
            _minimizeTexture    = TextureHelper.FromResource("ScienceChecklist.icons.minimize.png", 16, 16);
            _maximizeTexture    = TextureHelper.FromResource("ScienceChecklist.icons.maximize.png", 16, 16);
            _closeTexture       = TextureHelper.FromResource("ScienceChecklist.icons.close.png", 16, 16);
            _helpTexture        = TextureHelper.FromResource("ScienceChecklist.icons.help.png", 16, 16);
            _settingsTexture    = TextureHelper.FromResource("ScienceChecklist.icons.settings.png", 16, 16);

            _emptyTexture = new Texture2D(1, 1, TextureFormat.ARGB32, false);
            _emptyTexture.SetPixels(new[] { Color.clear });
            _emptyTexture.Apply();

            _parent.Config.HideCompleteEventsChanged      += (s, e) => RefreshFilter(s, e);
            _parent.Config.CompleteWithoutRecoveryChanged += (s, e) => RefreshFilter(s, e);

            _parent.ScienceEventHandler.FilterUpdateEvent += (s, e) => RefreshFilter(s, e);
            _parent.ScienceEventHandler.SituationChanged  += (s, e) => UpdateSituation(s, e);

            _parent.Config.UiScaleChanged += OnUiScaleChange;
        }
Пример #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);
                }
            }
        }