public virtual void Draw(SpriteBatch spriteBatch, GameTime gameTime, Vector2 origin, float alpha) { Vector2 offset = new Vector2(36, 0); Vector2 imageOffset = new Vector2(0, 12); if (IsSelected) { if (Selected != null) spriteBatch.Draw(InputState.InputMethod == InputMethods.Gamepad ? GameSession.Current.ButtonImages[Buttons.A] : GameSession.Current.KeyImages["X"], new Rectangle((int)origin.X + (int)imageOffset.X, (int)origin.Y + (int)imageOffset.Y, 32, 32), Color.White); if (InputState.InputMethod == InputMethods.KeyboardMouse) { // TODO: Remove this once we get images for the gamepad left and right buttons if (SwipeLeft != null) spriteBatch.Draw(InputState.InputMethod == InputMethods.Gamepad ? GameSession.Current.ButtonImages[Buttons.DPadLeft] : GameSession.Current.KeyImages["Left"], new Rectangle((int)origin.X + (int)imageOffset.X, (int)origin.Y + (int)imageOffset.Y, 32, 32), Color.White); if (SwipeRight != null) spriteBatch.Draw(InputState.InputMethod == InputMethods.Gamepad ? GameSession.Current.ButtonImages[Buttons.DPadRight] : GameSession.Current.KeyImages["Right"], new Rectangle((int)origin.X + (Text2 == null ? (int)imageOffset.X + (int)offset.X + 4 + (int)GenericMenu.Font.MeasureString(Text).X : GenericMenu.EntriesWidth - (int)imageOffset.X - 32), (int)origin.Y + (int)imageOffset.Y, 32, 32), Color.White); } } spriteBatch.DrawStringOutlined(GenericMenu.Font, Text, origin + offset, Enabled ? (IsSelected ? Color.White : new Color(192, 192, 192)) : new Color(96, 96, 96) * alpha); if (Text2 != null) spriteBatch.DrawStringOutlined(GenericMenu.Font, Text2, origin - offset + new Vector2(GenericMenu.EntriesWidth - GenericMenu.Font.MeasureString(Text2).X, 0), Enabled ? (IsSelected ? Color.White : new Color(192, 192, 192)) : new Color(96, 96, 96) * alpha); }
public override void Draw(SpriteBatch spriteBatch, GameTime gameTime, Vector2 origin, float alpha) { //int width = (int)(GenericMenu.Font.MeasureString(Text).X * scale); int width = GenericMenu.EntriesWidth; spriteBatch.Draw(GameSession.Current.Pixel, new Rectangle((int)origin.X, (int)origin.Y + (int)(GenericMenu.Font.MeasureString(Text).Y * scale) - 6, width, 2), Color.Gray); spriteBatch.DrawStringOutlined(GenericMenu.Font, Text, origin, Color.Gray * alpha, Color.Black, 0f, Vector2.Zero, scale); }
public void Draw(SpriteBatch spriteBatch, SpriteFont font, Vector2 position, TextAlign align, int? width, float alpha) { Vector2 offset = new Vector2(0, 0); //foreach (Word w in Words) { for (int i = 0; i <= (FullyTyped ? Words.Count - 1 : CurrentWordIndex); i++) { Word w = Words[i]; switch (w.Type) { case Word.WordType.Newline: offset.X = 0; offset.Y += font.LineSpacing; break; case Word.WordType.Text: if (offset.X + font.MeasureString(w.Text + " ").X > width) { offset.X = 0; offset.Y += font.LineSpacing; } spriteBatch.DrawStringOutlined(font, w.Text + " ", position + offset, w.Color * alpha); offset.X += font.MeasureString(w.Text + " ").X; break; case Word.WordType.Icon: int iconHeight = (int)font.LineSpacing; if (w.Icon == GameSession.Current.Pixel) { spriteBatch.DrawStringOutlined(GameSession.Current.KeyboardFont, w.Text, position + offset, w.Color * alpha); offset.X += GameSession.Current.KeyboardFont.MeasureString(w.Text).X + font.MeasureString(" ").X; } else { int iconWidth = w.Icon.Width / w.Icon.Height * iconHeight; if (offset.X + w.Icon.Width > width) { offset.X = 0; offset.Y += font.LineSpacing; } spriteBatch.Draw(w.Icon, new Rectangle((int)(position.X + offset.X), (int)(position.Y + offset.Y), iconWidth, iconHeight), Color.White * alpha); offset.X += iconWidth + font.MeasureString(" ").X; } break; } } }