Exemplo n.º 1
0
        /// <summary>
        /// Draws the control screen
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values</param>
        public override void Draw(GameTime gameTime)
        {
            SpriteBatch spriteBatch  = ScreenManager.SpriteBatch;
            Vector2     textPosition = Vector2.Zero;

            spriteBatch.Begin();

            // Draw the background texture
            spriteBatch.Draw(backgroundTexture, Vector2.Zero, Color.White);

            // Draw the back icon and text
            spriteBatch.Draw(backTexture, backPosition, Color.White);
            spriteBatch.DrawString(Fonts.ButtonNamesFont, "Back",
                                   new Vector2(backPosition.X + 55, backPosition.Y + 5), Color.White);

            // Draw the plank
            spriteBatch.Draw(plankTexture, plankPosition, Color.White);

#if !XBOX
            // Draw the trigger buttons
            spriteBatch.Draw(leftTriggerButton, leftTriggerPosition, Color.White);
            spriteBatch.Draw(rightTriggerButton, rightTriggerPosition, Color.White);
#endif

            // Draw the base border
            spriteBatch.Draw(baseBorderTexture, baseBorderPosition, Color.White);

            // draw the control pad screen
            if (isShowControlPad)
            {
                spriteBatch.Draw(controlPadTexture, controlPosition,
                                 Color.White);

                for (int i = 0; i < leftStrings.Length; i++)
                {
                    spriteBatch.DrawString(Fonts.DescriptionFont, leftStrings[i].text,
                                           leftStrings[i].textPosition, Color.Black);
                }

                for (int i = 0; i < rightStrings.Length; i++)
                {
                    spriteBatch.DrawString(Fonts.DescriptionFont, rightStrings[i].text,
                                           rightStrings[i].textPosition, Color.Black);
                }

#if !XBOX
                // Near left trigger
                spriteBatch.DrawString(Fonts.PlayerStatisticsFont, "Keyboard",
                                       new Vector2(leftTriggerPosition.X + (leftTriggerButton.Width -
                                                                            Fonts.PlayerStatisticsFont.MeasureString("Keyboard").X) / 2,
                                                   rightTriggerPosition.Y + 85),
                                       Color.Black);

                // Near right trigger
                spriteBatch.DrawString(Fonts.PlayerStatisticsFont, "Keyboard",
                                       new Vector2(rightTriggerPosition.X + (rightTriggerButton.Width -
                                                                             Fonts.PlayerStatisticsFont.MeasureString("Keyboard").X) / 2,
                                                   rightTriggerPosition.Y + 85),
                                       Color.Black);
#endif

                // Draw the title text
                titlePosition.X = plankPosition.X + (plankTexture.Width -
                                                     Fonts.HeaderFont.MeasureString("Gamepad").X) / 2;
                titlePosition.Y = plankPosition.Y + (plankTexture.Height -
                                                     Fonts.HeaderFont.MeasureString("Gamepad").Y) / 2;
                spriteBatch.DrawString(Fonts.HeaderFont, "Gamepad", titlePosition,
                                       Fonts.TitleColor);
            }
            else // draws the keyboard screen
            {
                const float spacing = 47;
                string      keyboardString;

                spriteBatch.Draw(keyboardTexture, keyboardPosition, Color.White);
                for (int j = 0, i = startIndex; i < startIndex + maxActionDisplay;
                     i++, j++)
                {
                    keyboardString = InputManager.GetActionName((InputManager.Action)i);
                    textPosition.X = chartLine1Position +
                                     ((chartLine2Position - chartLine1Position) -
                                      Fonts.DescriptionFont.MeasureString(keyboardString).X) / 2;
                    textPosition.Y = 253 + (spacing * j);

                    // Draw the action
                    spriteBatch.DrawString(Fonts.DescriptionFont, keyboardString,
                                           textPosition, Color.Black);

                    // Draw the key one
                    keyboardString =
                        keyboardInfo.totalActionList[i].keyboardKeys[0].ToString();
                    textPosition.X = chartLine2Position +
                                     ((chartLine3Position - chartLine2Position) -
                                      Fonts.DescriptionFont.MeasureString(keyboardString).X) / 2;
                    spriteBatch.DrawString(Fonts.DescriptionFont, keyboardString,
                                           textPosition, Color.Black);

                    // Draw the key two
                    if (keyboardInfo.totalActionList[i].keyboardKeys.Count > 1)
                    {
                        keyboardString = keyboardInfo.totalActionList[i].
                                         keyboardKeys[1].ToString();
                        textPosition.X = chartLine3Position +
                                         ((chartLine4Position - chartLine3Position) -
                                          Fonts.DescriptionFont.MeasureString(keyboardString).X) / 2;
                        spriteBatch.DrawString(Fonts.DescriptionFont, keyboardString,
                                               textPosition, Color.Black);
                    }
                    else
                    {
                        textPosition.X = chartLine3Position +
                                         ((chartLine4Position - chartLine3Position) -
                                          Fonts.DescriptionFont.MeasureString("---").X) / 2;
                        spriteBatch.DrawString(Fonts.DescriptionFont, "---",
                                               textPosition, Color.Black);
                    }
                }

                // Draw the Action
                actionPosition.X = chartLine1Position +
                                   ((chartLine2Position - chartLine1Position) -
                                    Fonts.CaptionFont.MeasureString("Action").X) / 2;
                actionPosition.Y = 200;
                spriteBatch.DrawString(Fonts.CaptionFont, "Action", actionPosition,
                                       Fonts.CaptionColor);

                // Draw the Key 1
                key1Position.X = chartLine2Position +
                                 ((chartLine3Position - chartLine2Position) -
                                  Fonts.CaptionFont.MeasureString("Key 1").X) / 2;
                key1Position.Y = 200;
                spriteBatch.DrawString(Fonts.CaptionFont, "Key 1", key1Position,
                                       Fonts.CaptionColor);

                // Draw the Key 2
                key2Position.X = chartLine3Position +
                                 ((chartLine4Position - chartLine3Position) -
                                  Fonts.CaptionFont.MeasureString("Key 2").X) / 2;
                key2Position.Y = 200;
                spriteBatch.DrawString(Fonts.CaptionFont, "Key 2", key2Position,
                                       Fonts.CaptionColor);

                // Near left trigger
                spriteBatch.DrawString(Fonts.PlayerStatisticsFont, "Gamepad",
                                       new Vector2(leftTriggerPosition.X + (leftTriggerButton.Width -
                                                                            Fonts.PlayerStatisticsFont.MeasureString("Gamepad").X) / 2,
                                                   rightTriggerPosition.Y + 85), Color.Black);

                // Near right trigger
                spriteBatch.DrawString(Fonts.PlayerStatisticsFont, "Gamepad",
                                       new Vector2(rightTriggerPosition.X + (rightTriggerButton.Width -
                                                                             Fonts.PlayerStatisticsFont.MeasureString("Gamepad").X) / 2,
                                                   rightTriggerPosition.Y + 85), Color.Black);

                // Draw the title text
                titlePosition.X = plankPosition.X + (plankTexture.Width -
                                                     Fonts.HeaderFont.MeasureString("Keyboard").X) / 2;
                titlePosition.Y = plankPosition.Y + (plankTexture.Height -
                                                     Fonts.HeaderFont.MeasureString("Keyboard").Y) / 2;
                spriteBatch.DrawString(Fonts.HeaderFont, "Keyboard", titlePosition,
                                       Fonts.TitleColor);

                // Draw the scroll textures
                spriteBatch.Draw(scrollUpTexture, scrollUpPosition, Color.White);
                spriteBatch.Draw(scrollDownTexture, scrollDownPosition, Color.White);
            }

            spriteBatch.End();
        }