/// <summary>
        /// Called by Unity once to initialize the class, just before Update is called.
        /// </summary>
        public void Start( )
        {
            _logger.Trace("Start");

            Config.Load( );

            _addonInitialized = true;
            _active           = false;
            _window           = new ScienceWindow( );
            _window.Settings.UseBlizzysToolbarChanged += Settings_UseBlizzysToolbarChanged;
            _window.OnCloseEvent += OnWindowClosed;
            _window.OnOpenEvent  += OnWindowOpened;



            // Callbacks for buttons - we init when the button is ready
            GameEvents.onGUIApplicationLauncherReady.Add(Load);
            GameEvents.onGUIApplicationLauncherDestroyed.Add(Unload);

            // Start event handlers
            _EventHandler = new xScienceEventHandler(this, _window);

            // Callbacks for F2
            GameEvents.onHideUI.Add(OnHideUI);
            GameEvents.onShowUI.Add(OnShowUI);

            DontDestroyOnLoad(this);
        }
示例#2
0
        // Called by Unity once to initialize the class, just before Update is called.
        public void Start( )
        {
            _logger.Trace("Start");

            if (_addonInitialized == true)
            {
                // For some reason the addon can be instantiated several times by the KSP addon loader (generally when going to/from the VAB),
                // even though we set onlyOnce to true in the KSPAddon attribute.
                HammerMusicMute( );                 // Ensure we enforce music volume anyway
                return;
            }
            _addonInitialized = true;
            _active           = false;



            // Config
            Config = new Config( );
            Config.Load( );



            // Music Muting
            if (Config.MusicStartsMuted)
            {
                Muted = true;
                ScreenMessages.PostScreenMessage("[x] Science! - Music Mute");
            }

            GameEvents.onGameSceneSwitchRequested.Add(this.onGameSceneSwitchRequested);
            GameEvents.onLevelWasLoaded.Add(this.onLevelWasLoaded);



//			_logger.Trace( "Making DMagic Factory" );
            DMagic = new DMagicFactory( );
//			_logger.Trace( "Made DMagic Factory" );



//			_logger.Trace( "Making ScienceContext" );
            Science = new ScienceContext(this);
//			_logger.Trace( "Made ScienceContext" );



            // Start event handlers
            ScienceEventHandler = new xScienceEventHandler(this);



            // Settings window
            _settingsWindow = new SettingsWindow(this);
            Config.UseBlizzysToolbarChanged   += Settings_UseBlizzysToolbarChanged;
            Config.RighClickMutesMusicChanged += Settings_RighClickMutesMusicChanged;



            // Help window
            _helpWindow = new HelpWindow(this);



            // Status window
            _alertNoise                 = gameObject.AddComponent <Noise>( );
            _statusWindow               = new StatusWindow(this);
            _statusWindow.NoiseEvent   += OnPlayNoise;
            _statusWindow.WindowClosed += OnStatusWindowClosed;
            _statusWindow.OnCloseEvent += OnStatusWindowClosed;
            _statusWindow.OnOpenEvent  += OnStatusWindowOpened;



            // Checklist window
            _checklistWindow = new ScienceWindow(this, _settingsWindow, _helpWindow);
            _checklistWindow.OnCloseEvent += OnChecklistWindowClosed;
            _checklistWindow.OnOpenEvent  += OnChecklistWindowOpened;



            // ShipState Window
            _shipStateWindow = new ShipStateWindow(this);



            // Save and load checklist window config when the game scene is changed
            // We are only visible in some scenes
            GameEvents.onGameSceneSwitchRequested.Add(new EventData <GameEvents.FromToAction <GameScenes, GameScenes> > .OnEvent(this.OnGameSceneSwitch));



            // Callbacks for buttons - we init when the "Launcher" toolbar is ready
            GameEvents.onGUIApplicationLauncherReady.Add(Load);
            GameEvents.onGUIApplicationLauncherDestroyed.Add(Unload);

            // Callbacks for F2
            GameEvents.onHideUI.Add(OnHideUI);
            GameEvents.onShowUI.Add(OnShowUI);


            DontDestroyOnLoad(this);


            _logger.Trace("Done Start");
        }