/// <summary> /// Queries how much space this menu entry requires. /// </summary> public virtual int GetHeight(MenuScreen screen) { return Font.LineSpacing; }
/// <summary> /// Draws the menu entry. This can be overridden to customize the appearance. /// </summary> public virtual void Draw(MenuScreen screen, bool isSelected, GameTime gameTime) { // Draw the selected entry in yellow, otherwise white. Color color = isSelected ? Fonts.MenuSelectedColor : Fonts.TitleColor; // Draw text, centered on the middle of each line. ScreenManager screenManager = screen.ScreenManager; SpriteBatch spriteBatch = screenManager.SpriteBatch; if (texture != null) { spriteBatch.Draw(texture, position, Color.White); if ((spriteFont != null) && !String.IsNullOrEmpty(text)) { Vector2 textSize = spriteFont.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(spriteFont, text, textPosition, color); } } else if ((spriteFont != null) && !String.IsNullOrEmpty(text)) { spriteBatch.DrawString(spriteFont, text, position, color); } }
/// <summary> /// Updates the menu entry. /// </summary> public virtual void Update(MenuScreen screen, bool isSelected, GameTime gameTime) { }
/// <summary> /// Draws the menu entry. This can be overridden to customize the appearance. /// </summary> public virtual void Draw(MenuScreen screen, bool isSelected, GameTime gameTime) { // Draw the selected entry in yellow, otherwise white. Color color = isSelected ? Fonts.MenuSelectedColor : Fonts.TitleColor; // Draw text, centered on the middle of each line. ScreenManager screenManager = screen.ScreenManager; SpriteBatch spriteBatch = screenManager.SpriteBatch; if (texture != null) { spriteBatch.Draw(texture, position, Color.White); if ((spriteFont != null) && !String.IsNullOrEmpty(text)) { Vector2 TextPosition = new Vector2 (position.X,position.Y); // Vector2 textSize = spriteFont.MeasureString(text); //Vector2 position = leftTriggerTexturePosition; //TextPosition.Y += texture.Height + 20 ; //new Vector2 placeTextMid = spriteFont.MeasureString(text) ; TextPosition.X += (texture.Width - placeTextMid.X )/ 2; TextPosition.Y += (texture.Height - placeTextMid.Y) / 2; //ne/w // Vector2 TextureSize = new Vector2 (texture.Width, texture.Height); //TextureSize *= Scaler.Scale; //Vector2 TextSizer = textSize; //textSize *= Scaler.Scale; //textSize /= 2; //Vector2 difference =( TextureSize - (TextSizer / Scaler.Scale) )/2; //difference *= Scaler.Scale; //Vector2 difference =( TextureSize - (TextSizer / Scaler.Scale) )/2; //difference *= Scaler.Scale; //Vector2 textPosition = position + difference; //Vector2 textPosition = position;//(position + (textSize / 2)); // Vector2 textPosition = position + new Vector2( // (float)Math.Floor((texture.Width - textSize.X) / 2), // (float)Math.Floor((texture.Height - textSize.Y)/ 2)); spriteBatch.DrawString(spriteFont, text, TextPosition, color); } } else if ((spriteFont != null) && !String.IsNullOrEmpty(text)) { spriteBatch.DrawString(spriteFont, text, position, color); } }
/// <summary> /// Queries how much space this menu entry requires. /// </summary> public virtual int GetHeight(MenuScreen screen) { return(Font.LineSpacing); }