Danmaku_no_Kyojin.Screens.OptionsScreen.Draw C# (CSharp) Method

Draw() public method

public Draw ( GameTime gameTime ) : void
gameTime Microsoft.Xna.Framework.GameTime
return void
        public override void Draw(GameTime gameTime)
        {
            GameRef.SpriteBatch.Begin();

            GameRef.SpriteBatch.Draw(_background, new Rectangle(0, 0, Config.Resolution.X, Config.Resolution.Y), Color.Yellow);

            GameRef.SpriteBatch.DrawString(_titleFont, _title,
                new Vector2(
                    Game.GraphicsDevice.Viewport.Width / 2f - _titleFont.MeasureString(_title).X / 2 + 5,
                    Game.GraphicsDevice.Viewport.Height / 2f - (_titleFont.MeasureString(_title).Y * 2) + 5),
                Color.Black);
            GameRef.SpriteBatch.DrawString(_titleFont, _title,
                new Vector2(
                    Game.GraphicsDevice.Viewport.Width / 2f - _titleFont.MeasureString(_title).X / 2,
                    Game.GraphicsDevice.Viewport.Height / 2f - (_titleFont.MeasureString(_title).Y * 2)),
                Color.White);

            for (int i = 0; i < _menuText.Length; i++)
            {
                Color textColor = Color.White;

                if (i == _menuIndex)
                    textColor = Color.OrangeRed;

                GameRef.SpriteBatch.DrawString(ControlManager.SpriteFont, _menuText[i], new Vector2(
                  _menuStartCoord.X - (ControlManager.SpriteFont.MeasureString(_menuText[i]).X / 2f) + 1,
                  _menuStartCoord.Y + (100 * i) + 1), Color.Black);
                GameRef.SpriteBatch.DrawString(ControlManager.SpriteFont, _menuText[i], new Vector2(
                  _menuStartCoord.X - (ControlManager.SpriteFont.MeasureString(_menuText[i]).X / 2f),
                  _menuStartCoord.Y + (100 * i)), textColor);

                if (i == 0 || i == 1)
                {
                    Color keyboardColor = Color.White;
                    Color gamepadColor = Color.White;

                    if (Config.PlayersController[i] == Config.Controller.Keyboard)
                        keyboardColor = Color.Red;
                    if (Config.PlayersController[i] == Config.Controller.GamePad)
                        gamepadColor = Color.Red;

                    GameRef.SpriteBatch.Draw(_keyboardIcon, new Rectangle(
                        _menuStartCoord.X - 50 - 20, _menuStartCoord.Y + 35 + (i * 100),
                        _keyboardIcon.Width, _keyboardIcon.Height), keyboardColor);
                    GameRef.SpriteBatch.Draw(_gamepadIcon, new Rectangle(
                        _menuStartCoord.X + 50 - 20, _menuStartCoord.Y + 35 + (i * 100),
                        _gamepadIcon.Width, _gamepadIcon.Height), gamepadColor);
                }

                // Sound volume
                if (i == 2)
                {
                    GameRef.SpriteBatch.Draw(_volumeBar, new Rectangle(
                       _menuStartCoord.X - 60, _menuStartCoord.Y + (100 * i) + 35,
                        (int)(150f * (Config.SoundVolume / 100f)), 20),
                    Color.White);

                    string soundVolume = Config.SoundVolume.ToString() + "%";
                    GameRef.SpriteBatch.DrawString(ControlManager.SpriteFont, soundVolume,
                        new Vector2(_menuStartCoord.X - ControlManager.SpriteFont.MeasureString(soundVolume).X / 4 + 1, _menuStartCoord.Y + (100 * i) + 60 + 1),
                        Color.Black);

                    GameRef.SpriteBatch.DrawString(ControlManager.SpriteFont, soundVolume,
                        new Vector2(_menuStartCoord.X - ControlManager.SpriteFont.MeasureString(soundVolume).X / 4, _menuStartCoord.Y + (100 * i) + 60),
                        Color.White);
                }
                // Music volume
                else if (i == 3)
                {
                    GameRef.SpriteBatch.Draw(_volumeBar, new Rectangle(
                       _menuStartCoord.X - 60, _menuStartCoord.Y + (100 * i) + 35,
                        (int)(150f * (Config.MusicVolume/100f)), 20),
                    Color.White);

                    string musicVolume = Config.MusicVolume.ToString() + "%";
                    GameRef.SpriteBatch.DrawString(ControlManager.SpriteFont, musicVolume,
                        new Vector2(_menuStartCoord.X - ControlManager.SpriteFont.MeasureString(musicVolume).X / 4 + 1, _menuStartCoord.Y + (100 * i) + 60 + 1),
                        Color.Black);

                    GameRef.SpriteBatch.DrawString(ControlManager.SpriteFont, musicVolume,
                        new Vector2(_menuStartCoord.X - ControlManager.SpriteFont.MeasureString(musicVolume).X / 4, _menuStartCoord.Y + (100 * i) + 60),
                        Color.White);
                }
            }

            GameRef.SpriteBatch.End();

            ControlManager.Draw(GameRef.SpriteBatch);

            base.Draw(gameTime);
        }