Ejemplo n.º 1
0
        /// <summary>
        /// Draws the menu entry. This can be overridden to customize the appearance.
        /// </summary>
        public override void Draw(GameScreen screen, GameTime gameTime, byte b)
        {
            // Draw the selected entry in yellow, otherwise white.
            Color color = mTextColor;

            // Pulsate the size of the selected menu entry.
            double time = gameTime.TotalGameTime.TotalSeconds;

            float pulsate = (float)Math.Sin(time * 6) + 1;

            float scale = 1 + pulsate * 0.05f * selectionFade;

            // Modify the alpha to fade text out during transitions.
            color = new Color(color.R, color.G, color.B, screen.TransitionAlpha);

            // Draw text, centered on the middle of each line.
            ScreenManager screenManager = screen.ScreenManager;
            SpriteBatch spriteBatch = screenManager.SpriteBatch;
            SpriteFont font = screenManager.Font;

            Vector2 textPosition = new Vector2(mRectangle.X + mPaddingX + (mRectangle.Width / 2) * (int)Alignment, mRectangle.Y);
            mOrigin = new Vector2(mRectangle.Width / 2.2f * (int)Alignment * scale, mRectangle.Height / 2.2f * scale);

            spriteBatch.DrawString(font, Text, textPosition, color, 0,
                                   mOrigin, scale, SpriteEffects.None, 0);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// The constructor is private: loading screens should
        /// be activated via the static Load method instead.
        /// </summary>
        private LoadingScreen(ScreenManager screenManager, bool loadingIsSlow,
                              GameScreen[] screensToLoad)
        {
            this.loadingIsSlow = loadingIsSlow;
            this.screensToLoad = screensToLoad;

            TransitionOnTime = TimeSpan.FromSeconds(0.5);
        }
Ejemplo n.º 3
0
 public virtual void LoadContent(GameScreen scrn)
 {
     UIFont = scrn.ScreenManager.Game.Content.Load<SpriteFont>("Fonts\\menufont");
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Adds a new screen to the screen manager.
        /// </summary>
        public void AddScreen(GameScreen screen, PlayerIndex? controllingPlayer)
        {
            screen.ControllingPlayer = controllingPlayer;
            screen.ScreenManager = this;
            screen.IsExiting = false;

            // If we have a graphics device, tell the screen to load content.
            if (isInitialized)
            {
                screen.LoadContent();
            }

            screens.Add(screen);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Removes a screen from the screen manager. You should normally
        /// use GameScreen.ExitScreen instead of calling this directly, so
        /// the screen can gradually transition off rather than just being
        /// instantly removed.
        /// </summary>
        public void RemoveScreen(GameScreen screen)
        {
            // If we have a graphics device, tell the screen to unload content.
            if (isInitialized)
            {
                screen.UnloadContent();
            }

            screens.Remove(screen);
            screensToUpdate.Remove(screen);
        }
Ejemplo n.º 6
0
        public override void LoadContent(GameScreen screen)
        {
            mainLabel.LoadContent(screen);

            int btnWidth = 0;
            foreach (Button btn in buttons)
            {
                btn.LoadContent(screen);
                btnWidth = (int)Math.Max(btnWidth, btn.Size.X);
            }

            mLabelWidth = (int)mainLabel.Size.X;
            ButtonWidth = btnWidth;
            mOrigin = Size / 2;
        }
Ejemplo n.º 7
0
        public override void LoadContent(GameScreen screen)
        {
            mainLabel.LoadContent(screen);
            valueLabel.LoadContent(screen);

            arrow = screen.ScreenManager.Game.Content.Load<Texture2D>("UI\\arrow");
            thumb = screen.ScreenManager.Game.Content.Load<Texture2D>("UI\\thumb");
            slider = screen.ScreenManager.Game.Content.Load<Texture2D>("UI\\slider");

            mLabelWidth = (int)mainLabel.Size.X;
            mOrigin = Size / 2;
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Draws the menu entry. This can be overridden to customize the appearance.
        /// </summary>
        public override void Draw(GameScreen screen, GameTime gameTime, byte b)
        {
            mainLabel.Draw(screen, gameTime, b);
            choiceLabel.Draw(screen, gameTime, b);

            Color arrowColor = (State == UIState.Selected) ? Color.White : Color.Gray;

            screen.ScreenManager.SpriteBatch.Draw(arrow, leftArrowPosition, arrow.Bounds, arrowColor, 0, Vector2.UnitY * 10, 1f, SpriteEffects.None, 1);
            screen.ScreenManager.SpriteBatch.Draw(arrow, rightArrowPosition, arrow.Bounds, arrowColor, 0, Vector2.UnitY * 10, 1f, SpriteEffects.FlipHorizontally, 1);
        }
Ejemplo n.º 9
0
        public override void Draw(GameScreen scrn, GameTime gameTime, byte alpha)
        {
            mTextColor.A = alpha;

            Vector2 textPosition = new Vector2(mRectangle.X + mPaddingX + (mRectangle.Width / 2) * (int)Alignment, mRectangle.Y);

            scrn.ScreenManager.SpriteBatch.DrawString(mFont, Text, textPosition, mTextColor, 0, mOrigin, 1, SpriteEffects.None, 1.0f);
        }
Ejemplo n.º 10
0
        public override void LoadContent(GameScreen scrn)
        {
            base.LoadContent(scrn);

            mBackground = scrn.ScreenManager.Game.Content.Load<Texture2D>("UI\\Buttons");
            State = mState;

            Vector2 mTextSize = UIFont.MeasureString(Text);
            mRectangle.Width  = (int)mTextSize.X;
            mRectangle.Height = (int)Math.Max(mTextSize.Y, UIFont.MeasureString(" ").Y);

            mOrigin = new Vector2(mTextSize.X / 2 * (int)Alignment, mTextSize.Y / 2);
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Draws the menu entry. This can be overridden to customize the appearance.
        /// </summary>
        public override void Draw(GameScreen screen, GameTime gameTime, byte b)
        {
            mainLabel.Draw(screen, gameTime, b);

            foreach (Button btn in buttons)
                btn.Draw(screen, gameTime, b);
        }
Ejemplo n.º 12
0
 public override void LoadContent(GameScreen screen)
 {
     Size = screen.ScreenManager.Font.MeasureString(Text) * 1.1f;
 }
Ejemplo n.º 13
0
 /// <summary>
 /// Draws the menu entry. This can be overridden to customize the appearance.
 /// </summary>
 public override void Draw(GameScreen screen, GameTime gameTime, byte b)
 {
     foreach (UIElement element in mElements)
         element.Draw(screen, gameTime, b);
 }
Ejemplo n.º 14
0
        public override void LoadContent(GameScreen screen)
        {
            foreach (UIElement element in mElements)
                element.LoadContent(screen);

            RecomputeSize();
        }
Ejemplo n.º 15
0
 public abstract void Draw(GameScreen scrn, GameTime gameTime, byte alpha);
Ejemplo n.º 16
0
 public void Draw(GameScreen scrn, GameTime gameTime)
 {
     Draw(scrn, gameTime, 255);
 }
Ejemplo n.º 17
0
        public override void Draw(GameScreen scrn, GameTime gameTime, byte alpha)
        {
            mDimColor.A = alpha;
            mTextColor.A = alpha;

            var outputRect = mRectangle;
            outputRect.Height += (int)Padding.Y * 2;
            outputRect.Width += (int)Padding.X * 2;

            Vector2 textPosition = new Vector2(mRectangle.X + mPaddingX + (mRectangle.Width / 2) * (int)Alignment, outputRect.Center.Y);

            scrn.ScreenManager.SpriteBatch.Draw(mBackground, outputRect, mSource, mDimColor);
            scrn.ScreenManager.SpriteBatch.DrawString(scrn.ScreenManager.Font, Text, textPosition, mTextColor, 0, mOrigin, 1, SpriteEffects.None, 1.0f);
        }
Ejemplo n.º 18
0
 public override void LoadContent(GameScreen scrn)
 {
     mFont = scrn.ScreenManager.Font;
     Size = mFont.MeasureString(mText);
     mOrigin = new Vector2(mRectangle.Width / 2 * (int)Alignment, mRectangle.Height / 2);
 }
Ejemplo n.º 19
0
        /// <summary>
        /// Draws the menu entry. This can be overridden to customize the appearance.
        /// </summary>
        public override void Draw(GameScreen screen, GameTime gameTime, byte b)
        {
            mainLabel.Draw(screen, gameTime, b);

            if(State == UIState.Selected || !HideInactive)
                foreach (Button btn in buttons)
                    btn.Draw(screen, gameTime, b);
        }
Ejemplo n.º 20
0
        public override void LoadContent(GameScreen screen)
        {
            mainLabel.LoadContent(screen);
            choiceLabel.LoadContent(screen);

            arrow = screen.ScreenManager.Game.Content.Load<Texture2D>("UI\\arrow");
            SpriteFont font = screen.ScreenManager.Game.Content.Load<SpriteFont>("Fonts\\menufont");
            maxChoiceSize = Vector2.Zero;

            for(int i = 0; i < choices.Length; i++)
            {
                Vector2 temp = font.MeasureString(choices[i]);
                maxChoiceSize.X = Math.Max(maxChoiceSize.X, temp.X);
            }

            LabelWidth = (int)mainLabel.Size.X;
            mOrigin = Size / 2;
        }
Ejemplo n.º 21
0
        /// <summary>
        /// Draws the menu entry. This can be overridden to customize the appearance.
        /// </summary>
        public override void Draw(GameScreen screen, GameTime gameTime, byte b)
        {
            mainLabel.Draw(screen, gameTime, b);
            valueLabel.Draw(screen, gameTime, b);

            Color textureColor = (State == UIState.Selected) ? Color.White : Color.Gray;

            screen.ScreenManager.SpriteBatch.Draw(arrow, leftArrowPosition, arrow.Bounds, textureColor, 0, Vector2.UnitY * 10, 1f, SpriteEffects.None, 1);
            screen.ScreenManager.SpriteBatch.Draw(arrow, rightArrowPosition, arrow.Bounds, textureColor, 0, Vector2.UnitY * 10, 1f, SpriteEffects.FlipHorizontally, 1);
            screen.ScreenManager.SpriteBatch.Draw(slider, sliderPosition, slider.Bounds, textureColor, 0, Vector2.UnitY * 5f, new Vector2(2, 1.5f), SpriteEffects.None, 1);
            screen.ScreenManager.SpriteBatch.Draw(thumb, thumbPosition, thumb.Bounds, textureColor, 0, new Vector2(2.5f, 7.5f), new Vector2(2, 1.5f), SpriteEffects.None, 1);
        }