/// <summary>Immediately releases all resources used the GUI manager</summary>
        public void Dispose()
        {
            // Unregister the service if we have registered it before
            if (_gameServices != null)
            {
                var registeredService = _gameServices.GetService(typeof(IGuiService));

                if (ReferenceEquals(registeredService, this))
                {
                    _gameServices.RemoveService(typeof(IGuiService));
                }
            }

            // Dispose the input capturer, if necessary
            if (_inputCapturer != null)
            {
                var disposableInputCapturer = _inputCapturer as IDisposable;

                disposableInputCapturer?.Dispose();

                _updateableInputCapturer = null;
                _inputCapturer           = null;
            }

            // Dispose the GUI visualizer, if necessary
            if (_guiVisualizer != null)
            {
                var disposableguiVisualizer = _guiVisualizer as IDisposable;

                disposableguiVisualizer?.Dispose();

                _updateableGuiVisualizer = null;
                _guiVisualizer           = null;
            }
        }
Exemple #2
0
        // unpause
        protected override void OnResume()
        {
            IsRunning = true;

            Gui.Visible       = true;
            Gui.InputCapturer = _capturer;
            _capturer         = null;
        }
Exemple #3
0
        // pause
        protected override void OnPause()
        {
            IsRunning = false;

            Gui.Visible       = false;
            _capturer         = Gui.InputCapturer;
            Gui.InputCapturer = null;
        }
        /// <summary>Handles second-stage initialization of the GUI manager</summary>
        public void Initialize()
        {
            // Set up a default input capturer if none was assigned by the user.
            // We only require an IInputService if the user doesn't use a custom input
            // capturer (which could be based on any other input library)
            if (_inputCapturer == null)
            {
                if (_inputService == null)
                {
                    _inputService = GetInputService(_gameServices);
                }

                //_inputCapturer = new Input.DefaultInputCapturer(_inputService);
                _inputCapturer = new DefaultInputCapturer(_inputService);

                // If a screen was assigned to the GUI before the input capturer was
                // created, then the input capturer hasn't been given the screen as its
                // input sink yet.
                if (_screen != null)
                {
                    _inputCapturer.InputReceiver = _screen;
                }
            }

            // Set up a default GUI visualizer if none was assigned by the user.
            // We only require an IGraphicsDeviceService if the user doesn't use a
            // custom visualizer (which could be using any kind of rendering)
            if (_guiVisualizer == null)
            {
                if (_graphicsDeviceService == null)
                {
                    _graphicsDeviceService = GetGraphicsDeviceService(_gameServices);
                }

                // Use a private service container. We know exactly what will be loaded from
                // the content manager our default GUI visualizer creates and if the user is
                // being funny, the graphics device service passed to the constructor might
                // be different from the one registered in the game service container.
                var services = new GameServiceContainer();
                services.AddService(typeof(IGraphicsDeviceService), _graphicsDeviceService);

                Visualizer = FlatGuiVisualizer.FromResource(services,
                                                            "MonoGame.Extended.NuclexGui.Resources.Skins.SuaveSkin.json");
            }
        }
Exemple #5
0
 /// <summary>
 /// Gives the game component a chance to initialize itself
 /// </summary>
 public override void Initialize()
 {
     base.Initialize();
     this.inputCapturer = new DefaultInputCapturer(this.inputService);
 }
Exemple #6
0
        // unpause
        protected override void OnResume()
        {
            IsRunning = true;

            Gui.Visible = true;
            Gui.InputCapturer = _capturer;
            _capturer = null;
        }
Exemple #7
0
        // pause
        protected override void OnPause()
        {
            IsRunning = false;

            Gui.Visible = false;
            _capturer = Gui.InputCapturer;
            Gui.InputCapturer = null;
        }