예제 #1
0
        public override void Draw(MenuScreen screen, GameTime gameTime)
        {
            if (IsVisible)
            {
                // Draw the selected entry in teal, otherwise white.
            Color color = IsSelected ? Color.Teal : Color.White;

                // Draw text, centered on the middle of each line.
                var spriteBatch = Game.Services.GetService<SpriteBatch>();
                spriteBatch.Begin();
                if ((Font != null) && !String.IsNullOrEmpty(Text))
                {
                    spriteBatch.DrawString(Font, Text, Position, color, 0, Vector2.Zero, _currentScale,
                                           SpriteEffects.None,
                                           0);
                }

                spriteBatch.End();
            }
        }
예제 #2
0
파일: MenuEntry.cs 프로젝트: sergik/Cardio
 /// <summary>
 /// Updates the menu entry.
 /// </summary>
 public virtual void Update(MenuScreen screen, GameTime gameTime)
 {
 }
예제 #3
0
파일: MenuEntry.cs 프로젝트: sergik/Cardio
        public virtual bool IsClicked(MenuScreen host)
        {
            Point size;
            if (Texture != null)
            {
                size = new Point(Texture.Width, Texture.Height);
            }
            else
            {
                var measuredSize = Font.MeasureString(Text);
                size = new Point((int)measuredSize.X, (int)measuredSize.Y);
            }

            // the hit bounds are the entire width of the screen, and the height of the entry
            // with some additional padding above and below.
            var rect = new Rectangle(
                (int)Position.X,
                (int)Position.Y,
                size.X + 2,
                size.Y + 2);

            return InputManager.IsButtonClicked(rect);
        }
예제 #4
0
파일: MenuEntry.cs 프로젝트: sergik/Cardio
        /// <summary>
        /// Draws the menu entry. This can be overridden to customize the appearance.
        /// </summary>
        public virtual void Draw(MenuScreen screen, GameTime gameTime)
        {
            // Draw the selected entry in teal, otherwise white.
            //Color color = isSelected ? Color.Teal : Color.White;
            var color = Color.White;

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

            if (Texture != null)
            {
                spriteBatch.Draw(Texture, Position, null, Color.White, 0f,
                    Vector2.Zero, 1f, SpriteEffects.None, 0f);
                if ((Font != null) && !String.IsNullOrEmpty(Text))
                {
                    Vector2 textSize = Font.MeasureString(Text);
                    Vector2 textPosition = Position + new Vector2(
                        (float)Math.Floor((Texture.Width - textSize.X) / 2),
                        (float)Math.Floor((Texture.Height - textSize.Y) / 2));
                    spriteBatch.DrawString(Font, Text, textPosition, color);
                }
            }
            else if ((Font != null) && !String.IsNullOrEmpty(Text))
            {
                spriteBatch.DrawString(Font, Text, Position, color);
            }
        }
예제 #5
0
        public virtual void Update(MenuScreen screen, GameTime gameTime)
        {
            _isSelected = _menuEntry.EntryArea.Contains(InputManager.CurrentMouseState.X,
                                                        InputManager.CurrentMouseState.Y) && !IsDisabled;

            _menuEntry.Position = new Vector2(ThumbnailRenderRectangle.X,
                                              ThumbnailRenderRectangle.Y + ThumbnailRenderRectangle.Height + 5);
            _menuEntry.EntryArea = new Rectangle((int) Position.X, (int) Position.Y, Texture.Width,
                                                 (int)
                                                 (Texture.Height + _menuEntry.Font.MeasureString(_menuEntry.Text).Y +
                                                  TextOffset.Y));
            _menuEntry.Update(screen, gameTime);
        }
예제 #6
0
 public bool IsClicked(MenuScreen host)
 {
     return InputManager.IsButtonClicked(ThumbnailRenderRectangle) || _menuEntry.IsClicked(host);
 }
예제 #7
0
 public void Initialize(Game game, MenuScreen host)
 {
     _menuEntry.Initialize(game);
     var gameState = game.Services.GetService<GameState>();
     StoryEntry = gameState.GameStory.GetStoryEntry(LevelName);
     if  (gameState.GameStory.IsLevelAvailable(StoryEntry))
     {
         Selected += (o, e) => InformativeLoadingScreen.Load(host.ScreenManager, true,
                                    TestData.BuildLevelScreen(game, StoryEntry.GetLevel));
     }
     else
     {
         IsDisabled = true;
         _menuEntry.IsDisabled = true;
     }
     Border = game.Content.Load<Texture2D>(@"Textures\Borders\Border1");
 }
예제 #8
0
        public void Draw(MenuScreen screen, GameTime gameTime)
        {
            SpriteBatch spriteBatch = screen.ScreenManager.SpriteBatch;

            if (Texture != null)
            {
                spriteBatch.Draw(Texture, ThumbnailRenderRectangle, IsDisabled ? _disabledTintColor : Color.White);
            }

            if (Border != null)
            {
                spriteBatch.Draw(Border, new Rectangle(_thumbnailRenderRectangle.X - 4, _thumbnailRenderRectangle.Y - 4, _thumbnailRenderRectangle.Width + 8, _thumbnailRenderRectangle.Height + 8), null, Color.White);
            }

            _menuEntry.Draw(screen, gameTime);
        }
예제 #9
0
        public override void Update(MenuScreen screen, GameTime gameTime)
        {
            IsSelected = EntryArea.Contains(InputManager.CurrentMouseState.X, InputManager.CurrentMouseState.Y) &&
                         !IsDisabled;

            float direction = IsSelected ? 1 : -1;
            _currentScale += direction * _scaleDelta * (float)gameTime.ElapsedGameTime.TotalMilliseconds;
            _currentScale = _currentScale > MaxScale
                                ? MaxScale
                                : _currentScale < DefaultScale ? DefaultScale : _currentScale;
        }
예제 #10
0
        public void Initialize(Game game, MenuScreen host)
        {
            _game = game;
            _host = host;

            int count = 0;
            var currentThumbnailY = (int)Position.Y;
            while (count < Thumbnails.Count)
            {
                var currentThumbnailX = (int)Position.X;

                for (int i = 0; i < ColumnsCount; i++ )
                {
                    var thumbnail = Thumbnails[count];
                    thumbnail.Initialize(game, host);
                    thumbnail.ThumbnailRenderRectangle = new Rectangle(currentThumbnailX, currentThumbnailY,
                                                                       ThumbnailWidth, ThumbnailHeight);
                    count++;
                    if (count >= Thumbnails.Count)
                    {
                        break;
                    }
                    currentThumbnailX += ThumbnailWidth + 40;
                }

                currentThumbnailY += ThumbnailHeight + 50;
            }
        }