protected override void Update(GameTime gameTime)
        {
            var keyboardState           = Keyboard.GetState();
            var mouseState              = Mouse.GetState();
            var previousViewportAdapter = _currentViewportAdapter;

            if (keyboardState.IsKeyDown(Keys.Escape))
            {
                Exit();
            }

            if (keyboardState.IsKeyDown(Keys.D))
            {
                SwitchAdapter(_defaultViewportAdapter);
            }

            if (keyboardState.IsKeyDown(Keys.S))
            {
                SwitchAdapter(_scalingViewportAdapter);
            }

            if (keyboardState.IsKeyDown(Keys.B))
            {
                SwitchAdapter(_boxingViewportAdapter);
            }

            // if we've changed the viewport adapter mid game we need to reset the viewport back to the window size
            // this wouldn't normally be required if you're only ever using one viewport adapter
            if (previousViewportAdapter != _currentViewportAdapter)
            {
                GraphicsDevice.Viewport = new Viewport(0, 0, Window.ClientBounds.Width, Window.ClientBounds.Height);
                _currentViewportAdapter.Reset();
            }

            // the viewport adapters can also scale mouse and touch input to the virtual resolution
            _mousePosition = _currentViewportAdapter.PointToScreen(mouseState.X, mouseState.Y);

            base.Update(gameTime);
        }
Example #2
0
        public override void Draw(GameTime gameTime)
        {
            _viewportAdapter.Reset();

            /*
             * UserInterface.Active.Draw(_spriteBatch);
             *
             * _viewportAdapter.Reset();
             *
             * OnPreGuiDraw(gameTime);
             *
             * var cameraMatrix = _camera.GetViewMatrix();
             *
             * UserInterface.Active.RenderTargetTransformMatrix = cameraMatrix;
             * UserInterface.Active.DrawMainRenderTarget(_spriteBatch);
             *
             */
            //float scaleY = HarvestMoon.Instance.Graphics.GraphicsDevice.Viewport.Height / 480.0f;
            //UserInterface.Active.GlobalScale = scaleY;

            UserInterface.Active.Draw(_spriteBatch);
        }