public override void Draw(Graphics.Graphics graphics) { frameCounter++; SpriteFont fallbackFont = graphics.GetSpriteFontByName("fallback"); //Current screen should never be null. Previous could, however. graphics.GetSpriteBatch().DrawString(fallbackFont, $"CurrentScreen: {screenManager.CurrentScreen.ScreenName}", Vector2.Zero, Color.Black); if(screenManager.PreviousScreen != null) { graphics.GetSpriteBatch().DrawString(fallbackFont, $"PreviousScreen: {screenManager.PreviousScreen.ScreenName}", new Vector2(0, 16), Color.Black); } graphics.GetSpriteBatch().DrawString(fallbackFont, $"FPS: " + framerate, new Vector2(0, 64), Color.Black); if (screenManager.CurrentScreen != null && screenManager.CurrentScreen.GetType() == typeof(BlankScreen)) { var debugScreen = (BlankScreen)screenManager.CurrentScreen; //graphics.GetSpriteBatch().DrawString(fallbackFont, // $"Lights: " + debugScreen.LightsRenderer.Lights.Count(), new Vector2(0, 64 + 16), Color.Black); graphics.GetSpriteBatch().DrawString(fallbackFont, $"X-Velocity: " + debugScreen.TestEntity.xVelocity, new Vector2(0, 64 + 32), Color.Black); } graphics.GetSpriteBatch().DrawString(fallbackFont, $"Mouse Position: {Minecraft2D.InputHelper.MousePosition.ToString()}; Inside: {Minecraft2D.InputHelper.IsMouseInsideWindow()}" , new Vector2(0, 32), Color.Black); }
public override void Draw(Graphics.Graphics graphics) { var spriteFont = graphics.GetSpriteFontByName("minecraft"); var textSize = spriteFont.MeasureString(Text); var center = textSize / 2; graphics.GetSpriteBatch().DrawString ( spriteFont, Text, PositionSize.ToVector2(), Color.Yellow, (float)DegreesToRadians(-20), center, (float)Scale, Microsoft.Xna.Framework.Graphics.SpriteEffects.None, 1f ); }
public override void Draw(Graphics.Graphics graphics) { int textX = (int)(PositionSize.Center.X - graphics.GetSpriteFontByName("minecraft").MeasureString(Text).X / 2); if (Enabled == true) { if (Selected) { /*graphics.GetSpriteBatch().Draw(graphics.GetTexture2DByName("widgets"), new Rectangle(PositionSize.X, PositionSize.Y, (int)(PositionSize.Width * Math.Min(ScaleFactor, MaxScaleFactor)), (int)(PositionSize.Height * Math.Min(ScaleFactor, MaxScaleFactor))), new Rectangle(WidgetsMap.HighlightedButton.X, WidgetsMap.HighlightedButton.Y, WidgetsMap.HighlightedButton.RegionWidth, WidgetsMap.HighlightedButton.RegionHeight), Color.White); */ graphics.DrawText(Text, new Rectangle(textX, PositionSize.Y + 8, PositionSize.Width, PositionSize.Height), Color.Yellow, (float)Math.Min(ScaleFactor, MaxScaleFactor)); } else { /*graphics.GetSpriteBatch().Draw(graphics.GetTexture2DByName("widgets"), new Rectangle(PositionSize.X, PositionSize.Y, PositionSize.Width, PositionSize.Height), new Rectangle(WidgetsMap.EnabledButton.X, WidgetsMap.EnabledButton.Y, WidgetsMap.EnabledButton.RegionWidth, WidgetsMap.EnabledButton.RegionHeight), Color.White); */ graphics.DrawText(Text, new Rectangle(textX, PositionSize.Y + 8, PositionSize.Width, PositionSize.Height), Color.White, (float)Math.Min(ScaleFactor, MaxScaleFactor)); } } else { /*graphics.GetSpriteBatch().Draw(graphics.GetTexture2DByName("widgets"), new Rectangle(PositionSize.X, PositionSize.Y, PositionSize.Width, PositionSize.Height), new Rectangle(WidgetsMap.DisabledButton.X, WidgetsMap.DisabledButton.Y, WidgetsMap.DisabledButton.RegionWidth, WidgetsMap.DisabledButton.RegionHeight), Color.White); */ graphics.DrawText(Text, new Vector2((textX * Constants.SpriteScale), (PositionSize.Y + 8) * Constants.SpriteScale), Color.Gray); } }