/// <summary> /// Updates the cache that contains the result of laying out the label's text. /// </summary> /// <param name="availableSize">The size of the space that is available for laying out text.</param> private void UpdateTextLayoutResult(Size2D availableSize) { textLayoutCommands.Clear(); if (textParserResult.Count > 0 && Font.IsLoaded) { var unconstrainedWidth = Double.IsPositiveInfinity(availableSize.Width) && HorizontalAlignment != HorizontalAlignment.Stretch; var unconstrainedHeight = Double.IsPositiveInfinity(availableSize.Height) && VerticalAlignment != VerticalAlignment.Stretch; var constraintX = unconstrainedWidth ? null : (Int32?)Math.Ceiling(Display.DipsToPixels(availableSize.Width)); var constraintY = unconstrainedHeight ? null : (Int32?)Math.Ceiling(Display.DipsToPixels(availableSize.Height)); var cursorpos = textLayoutCommands.CursorPosition; var textRenderingMode = TextOptions.GetTextRenderingMode(this); var textScript = TextOptions.GetTextScript(this); var textLanguage = TextOptions.GetTextLanguage(this); var textDirection = FlowDirection == FlowDirection.RightToLeft ? TextDirection.RightToLeft : TextDirection.LeftToRight; var options = (textRenderingMode == TextRenderingMode.Shaped) ? TextLayoutOptions.Shape : TextLayoutOptions.None; var flags = LayoutUtil.ConvertAlignmentsToTextFlags(HorizontalContentAlignment, VerticalContentAlignment); var settings = new TextLayoutSettings(Font, constraintX, constraintY, flags, options, textDirection, textScript, FontStyle, null, textLanguage); View.Resources.TextRenderer.CalculateLayout(textParserResult, textLayoutCommands, settings); View.Resources.TextRenderer.UpdateCursor(textLayoutCommands, cursorpos); } }
public Text(string name, UltravioletFont spriteFont, string text) { _name = name; _text = text; _textRenderer = new TextRenderer(); _settings = new TextLayoutSettings(spriteFont, null, null, TextFlags.Standard); }
/// <summary> /// Called when the scene is being rendered. /// </summary> /// <param name="time">Time elapsed since the last call to Draw.</param> protected override void OnDrawing(UltravioletTime time) { spriteBatch.Begin(); //player sprite draw spriteBatch.DrawSprite(this.playerObj.animations[this.playerObj.animationIndex], this.playerObj.position); //if a bullet is being fired, draw it if (firingBullet) { spriteBatch.DrawSprite(this.firedBullet.animations[this.firedBullet.animationIndex], this.firedBullet.position); } textFormatter.Reset(); textFormatter.AddArgument(Ultraviolet.GetGraphics().FrameRate); textFormatter.AddArgument(GC.GetTotalMemory(false) / 1024); textFormatter.AddArgument(Environment.Is64BitProcess ? "64-bit" : "32-bit"); textFormatter.Format("{0:decimals:2} FPS\nAllocated: {1:decimals:2} kb\n{2}", textBuffer); spriteBatch.DrawString(spriteFont, textBuffer, Vector2.One * 8f, TwistedLogik.Ultraviolet.Color.White); var size = Ultraviolet.GetPlatform().Windows.GetCurrent().ClientSize; var settings = new TextLayoutSettings(spriteFont, size.Width, size.Height, TextFlags.AlignCenter | TextFlags.AlignMiddle); textRenderer.Draw(spriteBatch, "Welcome to the |c:FFFF00C0|Ultraviolet Framework|c|!", Vector2.Zero, TwistedLogik.Ultraviolet.Color.White, settings); //physicsTestObject.DrawObject(spriteBatch, true, textRenderer, settings); groundTestObject.DrawObject(spriteBatch, true, textRenderer, settings); spriteBatch.End(); base.OnDrawing(time); }
protected override void OnDrawing(UltravioletTime time) { var window = Ultraviolet.GetPlatform().Windows.GetPrimary(); var width = window.DrawableSize.Width; var height = window.DrawableSize.Height; spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend); var instruction = Ultraviolet.Platform == UltravioletPlatform.Android || Ultraviolet.Platform == UltravioletPlatform.iOS ? "|c:FFFFFF00|Tap the screen|c| to activate one of the sound effect players." : "Press the |c:FFFFFF00|1-8 number keys|c| to activate one of the sound effect players."; var attribution = instruction + "\n\n" + "\"|c:FFFFFF00|grenade.wav|c|\" by ljudman (http://freesound.org/people/ljudman)\n" + "Licensed under Creative Commons: Sampling+\n" + "|c:FF808080|http://creativecommons.org/licenses/sampling+/1.0/|c|"; var settings = new TextLayoutSettings(spriteFont, width, height, TextFlags.AlignMiddle | TextFlags.AlignCenter); textRenderer.CalculateLayout(attribution, textLayoutCommands, settings); textRenderer.Draw(spriteBatch, textLayoutCommands, Vector2.Zero, Color.White); spriteBatch.End(); base.OnDrawing(time); }
protected override void OnDrawing(UltravioletTime time) { spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend); var settings = new TextLayoutSettings(spriteFont, null, null, TextFlags.Standard); if (Ultraviolet.Platform == UltravioletPlatform.Android || Ultraviolet.Platform == UltravioletPlatform.iOS) { textRenderer.Draw(spriteBatch, "Tap the screen to reset the scrolling text.", Vector2.One * 8f, Color.White, settings); } else { textRenderer.Draw(spriteBatch, $"Press {Ultraviolet.GetInput().GetActions().ResetScrollingText.Primary} to reset the scrolling text.", Vector2.One * 8f, Color.White, settings); } var window = Ultraviolet.GetPlatform().Windows.GetPrimary(); var x = (window.DrawableSize.Width - textBlock.Width.Value) / 2; var y = (window.DrawableSize.Height - textBlock.Height.Value) / 2; textBlock.Draw(time, spriteBatch, new Vector2(x, y), Color.White); spriteBatch.End(); base.OnDrawing(time); }
private void DrawAlignedText() { var window = Ultraviolet.GetPlatform().Windows.GetPrimary(); var width = window.DrawableSize.Width; var height = window.DrawableSize.Height; var settingsTopLeft = new TextLayoutSettings(spriteFontSegoe, width, height, TextFlags.AlignTop | TextFlags.AlignLeft); textRenderer.Draw(spriteBatch, "Aligned top left", Vector2.Zero, Color.White, settingsTopLeft); var settingsTopCenter = new TextLayoutSettings(spriteFontSegoe, width, height, TextFlags.AlignTop | TextFlags.AlignCenter); textRenderer.Draw(spriteBatch, "Aligned top center", Vector2.Zero, Color.White, settingsTopCenter); var settingsTopRight = new TextLayoutSettings(spriteFontSegoe, width, height, TextFlags.AlignTop | TextFlags.AlignRight); textRenderer.Draw(spriteBatch, "Aligned top right", Vector2.Zero, Color.White, settingsTopRight); var settingsBottomLeft = new TextLayoutSettings(spriteFontSegoe, width, height, TextFlags.AlignBottom | TextFlags.AlignLeft); textRenderer.Draw(spriteBatch, "Aligned bottom left", Vector2.Zero, Color.White, settingsBottomLeft); var settingsBottomCenter = new TextLayoutSettings(spriteFontSegoe, width, height, TextFlags.AlignBottom | TextFlags.AlignCenter); textRenderer.Draw(spriteBatch, "Aligned bottom center", Vector2.Zero, Color.White, settingsBottomCenter); var settingsBottomRight = new TextLayoutSettings(spriteFontSegoe, width, height, TextFlags.AlignBottom | TextFlags.AlignRight); textRenderer.Draw(spriteBatch, "Aligned bottom right", Vector2.Zero, Color.White, settingsBottomRight); }
private void DrawColoredAndStyledText() { var window = Ultraviolet.GetPlatform().Windows.GetPrimary(); var width = window.DrawableSize.Width; var height = window.DrawableSize.Height; if (textLayoutCommands.Settings.Width != width || textLayoutCommands.Settings.Height != height) { const string text = "Ultraviolet Formatting Commands\n" + "\n" + "||c:AARRGGBB| - Changes the color of text.\n" + "|c:FFFF0000|red|c| |c:FFFF8000|orange|c| |c:FFFFFF00|yellow|c| |c:FF00FF00|green|c| |c:FF0000FF|blue|c| |c:FF6F00FF|indigo|c| |c:FFFF00FF|magenta|c|\n" + "\n" + "||font:name| - Changes the current font.\n" + "We can |font:segoe|transition to a completely different font|font| within a single line\n" + "\n" + "||b| and ||i| - Changes the current font style.\n" + "|b|bold|b| |i|italic|i| |b||i|bold italic|i||b|\n" + "\n" + "||style:name| - Changes to a preset style.\n" + "|style:preset1|this is preset1|style| |style:preset2|this is preset2|style|\n" + "\n" + "||icon:name| - Draws an icon in the text.\n" + "[|icon:ok| OK] [|icon:cancel| Cancel]"; var settings = new TextLayoutSettings(spriteFontGaramond, width, height, TextFlags.AlignMiddle | TextFlags.AlignCenter); textRenderer.CalculateLayout(text, textLayoutCommands, settings); } textRenderer.Draw(spriteBatch, textLayoutCommands, Vector2.Zero, Color.White); }
protected override void OnDrawingForeground(UltravioletTime time, SpriteBatch spriteBatch) { spriteBatch.Draw(blankTexture, new RectangleF(0, 0, Width, Height), Color.Black * TransitionPosition); var settings = new TextLayoutSettings(font, Width, Height, TextFlags.AlignCenter | TextFlags.AlignMiddle); textRenderer.Draw(spriteBatch, message, Vector2.Zero, Color.White * TransitionPosition, settings); base.OnDrawingForeground(time, spriteBatch); }
/// <summary> /// Handles the Drawing event for ultravioletPanel1. /// </summary> /// <param name="sender">The object that raised the event.</param> /// <param name="e">An EventArgs that contains the event data.</param> private void ultravioletPanel1_Drawing(Object sender, EventArgs e) { spriteBatch.Begin(); var size = Ultraviolet.GetPlatform().Windows.GetCurrent().Compositor.Size; var settings = new TextLayoutSettings(spriteFont, size.Width, size.Height, TextFlags.AlignCenter | TextFlags.AlignMiddle); textRenderer.Draw(spriteBatch, "Welcome to the |c:FFFF00C0|Ultraviolet Framework|c|!", Vector2.Zero, Color.White, settings); spriteBatch.End(); }
/// <summary> /// Handles the Drawing event for ultravioletPanel2. /// </summary> /// <param name="sender">The object that raised the event.</param> /// <param name="e">An EventArgs that contains the event data.</param> private void ultravioletPanel2_Drawing(object sender, EventArgs e) { Ultraviolet.GetGraphics().Clear(Color.Black); spriteBatch.Begin(); var size = Ultraviolet.GetPlatform().Windows.GetCurrent().Compositor.Size; var settings = new TextLayoutSettings(spriteFont, size.Width, size.Height, TextFlags.AlignCenter | TextFlags.AlignMiddle); textRenderer.Draw(spriteBatch, "This is a |c:FF00FF00|secondary tool window|c|.", Vector2.Zero, Color.White, settings); spriteBatch.End(); }
public override void Draw(SpriteBatch spriteBatch) { Resources.gfx.Clear(new Color(0, 0, 0)); var settings = new TextLayoutSettings(spriteFont, null, null, TextFlags.Standard, SpriteFontStyle.Bold); textRenderer.Draw(spriteBatch, GetString(MMenuHighligh.Play), new Vector2(1550, 700), selected == MMenuHighligh.Play ? Color.White : Color.Gray, settings); textRenderer.Draw(spriteBatch, GetString(MMenuHighligh.Options), new Vector2(1550, 800), selected == MMenuHighligh.Options ? Color.White : Color.Gray, settings); textRenderer.Draw(spriteBatch, GetString(MMenuHighligh.Exit), new Vector2(1550, 900), selected == MMenuHighligh.Exit ? Color.White : Color.Gray, settings); spriteBatch.DrawScaledSprite(selector["selectorplaceholder"].Controller, GetPosition(), new Vector2(1, 1)); }
public override void Draw(SpriteBatch spriteBatch) { foreach (var actor in Resources.actors) { actor.Draw(spriteBatch); } player.Draw(spriteBatch); var settings = new TextLayoutSettings(Trebuchet, null, null, TextFlags.Standard); tr.Draw(spriteBatch, collected, new Vector2f(10, 10), Color.Black, settings); tr.Draw(spriteBatch, death, new Vector2f(10, 30), Color.Black, settings); }
protected override void OnDrawingForeground(UltravioletTime time, SpriteBatch spriteBatch) { spriteBatch.Draw(blankTexture, new RectangleF(0, 0, Width, Height), new Color(180, 0, 0)); #if ANDROID var text = "This is SampleScreen1\nTap to open SampleScreen2"; #else var text = "This is SampleScreen1\nPress right arrow key to open SampleScreen2"; #endif var settings = new TextLayoutSettings(font, Width, Height, TextFlags.AlignCenter | TextFlags.AlignMiddle); textRenderer.Draw(spriteBatch, text, Vector2.Zero, Color.White * TransitionPosition, settings); base.OnDrawingForeground(time, spriteBatch); }
protected override void OnDrawing(UltravioletTime time) { var gfx = Ultraviolet.GetGraphics(); gfx.Clear(new Color(222, 206, 206)); var viewMatrix = camera.GetTransform(); spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.DepthRead, RasterizerState.CullNone, null, viewMatrix * Matrix.CreateScale(screenScale)); _current.Draw(spriteBatch); var settings = new TextLayoutSettings(Trebuchet, null, null, TextFlags.Standard); tr.Draw(spriteBatch, "|shader:wavy|Hallo Welt ich teste gerade |shader:shaky|glyph shaders|shader| !!!", new Vector2(100, 100), Color.White, settings); spriteBatch.End(); base.OnDrawing(time); }
/// <summary> /// Updates the cache which contains the element's laid-out text. /// </summary> /// <param name="availableSize">The amount of space in which the element's text can be laid out.</param> private void UpdateTextLayoutCache(Size2D availableSize) { if (textLayoutCommands != null) { textLayoutCommands.Clear(); } if (View == null) { return; } var content = Content; var contentElement = content as UIElement; if (contentElement == null) { if (textLayoutCommands == null) { textLayoutCommands = new TextLayoutCommandStream(); } var font = GetValue <SourcedResource <UltravioletFont> >(TextElement.FontProperty); var fontStyle = GetValue <UltravioletFontStyle>(TextElement.FontStyleProperty); if (font.IsLoaded) { var availableSizeInPixels = Display.DipsToPixels(availableSize); var cursorpos = textLayoutCommands.CursorPosition; var textRenderingMode = TextOptions.GetTextRenderingMode(this); var textScript = TextOptions.GetTextScript(this); var textLanguage = TextOptions.GetTextLanguage(this); var textDirection = FlowDirection == FlowDirection.RightToLeft ? TextDirection.RightToLeft : TextDirection.LeftToRight; var options = (textRenderingMode == TextRenderingMode.Shaped) ? TextLayoutOptions.Shape : TextLayoutOptions.None; var flags = LayoutUtil.ConvertAlignmentsToTextFlags(HorizontalAlignment, VerticalAlignment); var settings = new TextLayoutSettings(font, (Int32)Math.Ceiling(availableSizeInPixels.Width), (Int32)Math.Ceiling(availableSizeInPixels.Height), flags, options, textDirection, textScript, fontStyle, null, textLanguage); View.Resources.TextRenderer.CalculateLayout(textParserResult, textLayoutCommands, settings); View.Resources.TextRenderer.UpdateCursor(textLayoutCommands, cursorpos); } } }
protected override void OnDrawingForeground(UltravioletTime time, SpriteBatch spriteBatch) { var offset = GetScreenOffset(); spriteBatch.Draw(blankTexture, new RectangleF(offset, 0, Width, Height), new Color(0, 0, 180)); #if ANDROID || IOS var text = "This is SampleScreen2\nTap to open SampleScreen1"; #else var text = "This is SampleScreen2\nPress left arrow key to open SampleScreen1"; #endif var settings = new TextLayoutSettings(font, Width, Height, TextFlags.AlignCenter | TextFlags.AlignMiddle); textRenderer.Draw(spriteBatch, text, new Vector2(offset, 0), Color.White, settings); base.OnDrawingForeground(time, spriteBatch); }
/// <summary> /// Updates the cache that contains the result of laying out the label's text. /// </summary> /// <param name="availableSize">The size of the space that is available for laying out text.</param> private void UpdateTextLayoutResult(Size2D availableSize) { textLayoutCommands.Clear(); if (textParserResult.Count > 0 && Font.IsLoaded) { var unconstrainedWidth = Double.IsPositiveInfinity(availableSize.Width) && HorizontalAlignment != HorizontalAlignment.Stretch; var unconstrainedHeight = Double.IsPositiveInfinity(availableSize.Height) && VerticalAlignment != VerticalAlignment.Stretch; var constraintX = unconstrainedWidth ? null : (Int32?)Math.Ceiling(Display.DipsToPixels(availableSize.Width)); var constraintY = unconstrainedHeight ? null : (Int32?)Math.Ceiling(Display.DipsToPixels(availableSize.Height)); var flags = LayoutUtil.ConvertAlignmentsToTextFlags(HorizontalContentAlignment, VerticalContentAlignment); var settings = new TextLayoutSettings(Font, constraintX, constraintY, flags, FontStyle); View.Resources.TextRenderer.CalculateLayout(textParserResult, textLayoutCommands, settings); } }
/// <summary> /// Called when the scene is being rendered. /// </summary> /// <param name="time">Time elapsed since the last call to Draw.</param> protected override void OnDrawing(UltravioletTime time) { spriteBatch.Begin(); textFormatter.Reset(); textFormatter.AddArgument(Ultraviolet.GetGraphics().FrameRate); textFormatter.AddArgument(GC.GetTotalMemory(false) / 1024); textFormatter.AddArgument(Environment.Is64BitProcess ? "64-bit" : "32-bit"); textFormatter.Format("{0:decimals:2} FPS\nAllocated: {1:decimals:2} kb\n{2}", textBuffer); spriteBatch.DrawString(spriteFont, textBuffer, Vector2.One * 8f, Color.White); var size = Ultraviolet.GetPlatform().Windows.GetCurrent().Compositor.Size; var settings = new TextLayoutSettings(spriteFont, size.Width, size.Height, TextFlags.AlignCenter | TextFlags.AlignMiddle); textRenderer.Draw(spriteBatch, "Welcome to the |c:FFFF00C0|Ultraviolet Framework|c|!", Vector2.Zero, Color.White, settings); spriteBatch.End(); base.OnDrawing(time); }
/// <summary> /// Updates the cache which contains the element's laid-out text. /// </summary> /// <param name="availableSize">The amount of space in which the element's text can be laid out.</param> private void UpdateTextLayoutCache(Size2D availableSize) { if (textLayoutCommands != null) { textLayoutCommands.Clear(); } if (View == null || containingControl == null) { return; } var content = Content; var contentElement = content as UIElement; if (contentElement == null) { if (textLayoutCommands == null) { textLayoutCommands = new TextLayoutCommandStream(); } var font = containingControl.Font; if (font.IsLoaded) { var availableSizeInPixels = Display.DipsToPixels(availableSize); var cursorpos = textLayoutCommands.CursorPosition; var flags = LayoutUtil.ConvertAlignmentsToTextFlags(HorizontalAlignment, VerticalAlignment); var settings = new TextLayoutSettings(font, (Int32)Math.Ceiling(availableSizeInPixels.Width), (Int32)Math.Ceiling(availableSizeInPixels.Height), flags, containingControl.FontStyle); View.Resources.TextRenderer.CalculateLayout(textParserResult, textLayoutCommands, settings); View.Resources.TextRenderer.UpdateCursor(textLayoutCommands, cursorpos); } } }
protected override void OnDrawing(UltravioletTime time) { var window = Ultraviolet.GetPlatform().Windows.GetPrimary(); var width = window.DrawableSize.Width; var height = window.DrawableSize.Height; stringFormatter.Reset(); stringFormatter.AddArgument(songPlayer.Position.Minutes); stringFormatter.AddArgument(songPlayer.Position.Seconds); stringFormatter.AddArgument(songPlayer.Duration.Minutes); stringFormatter.AddArgument(songPlayer.Duration.Seconds); stringFormatter.Format("{0:pad:2}:{1:pad:2} / {2:pad:2}:{3:pad:2}", stringBuffer); spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend); var attribution = "|c:FFFFFF00|Now Playing|c|\n\n" + "\"|c:FFFFFF00|Deep Haze|c|\" by Kevin MacLeod (incompetech.com)\n" + "Licensed under Creative Commons: By Attribution 3.0\n" + "|c:FF808080|http://creativecommons.org/licenses/by/3.0/|c|\n\n\n"; var settings = new TextLayoutSettings(spriteFont, width, height, TextFlags.AlignMiddle | TextFlags.AlignCenter); textRenderer.CalculateLayout(attribution, textLayoutCommands, settings); textRenderer.Draw(spriteBatch, textLayoutCommands, Vector2.Zero, Color.White); var timerSize = spriteFont.Regular.MeasureString(stringBuffer); var timerPosition = new Vector2( (Int32)(textLayoutCommands.Bounds.Left + ((textLayoutCommands.Bounds.Width - timerSize.Width) / 2f)), (Int32)(textLayoutCommands.Bounds.Bottom - timerSize.Height)); spriteBatch.DrawString(spriteFont.Regular, stringBuffer, timerPosition, Color.White); spriteBatch.End(); base.OnDrawing(time); }
/// <summary> /// Updates the cache which contains the element's laid-out text. /// </summary> /// <param name="availableSize">The amount of space in which the element's text can be laid out.</param> private void UpdateTextLayoutCache(Size2D availableSize) { if (textLayoutCommands != null) { textLayoutCommands.Clear(); } if (View == null || containingControl == null) { return; } var content = Content; var contentElement = content as UIElement; if (contentElement == null) { if (textLayoutCommands == null) { textLayoutCommands = new TextLayoutCommandStream(); } var font = containingControl.Font; if (font.IsLoaded) { var availableSizeInPixels = Display.DipsToPixels(availableSize); var settings = new TextLayoutSettings(font, (Int32)Math.Ceiling(availableSizeInPixels.Width), (Int32)Math.Ceiling(availableSizeInPixels.Height), TextFlags.Standard, containingControl.FontStyle); View.Resources.TextRenderer.CalculateLayout(textParserResult, textLayoutCommands, settings); } } }
public void Draw(SpriteBatch spriteBatch) { var settings = new TextLayoutSettings(Trebuchet, null, null, TextFlags.Standard); tr.Draw(spriteBatch, _curr, position, Color.Black, settings); }
private void DrawGamePadState(Int32 playerIndex, Rectangle area) { var input = Ultraviolet.GetInput(); var device = input.GetGamePadForPlayer(playerIndex); var font = content.Load <SpriteFont>(GlobalFontID.SegoeUI); var x = area.X; var y = area.Y; var textArea = RectangleF.Empty; spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.Default, RasterizerState.CullCounterClockwise); textFormatter.Reset(); textFormatter.AddArgument(playerIndex + 1); textFormatter.AddArgument(device == null ? "(not connected)" : device.Name); textFormatter.AddArgument((device == null) ? "" : device.GetButtonState(GamePadButton.A).ToString()); textFormatter.Format("|c:FFFFFF00|Player {0}|c|\n{1}", textBuffer); var headerSettings = new TextLayoutSettings(font, area.Width, area.Height, TextFlags.AlignCenter | TextFlags.AlignTop); textArea = textRenderer.Draw(spriteBatch, textBuffer, new Vector2(x, y), Color.White, headerSettings); y += (Int32)textArea.Height + font.Regular.LineSpacing; if (device != null) { textFormatter.Reset(); textFormatter.AddArgument(device.IsButtonDown(GamePadButton.LeftShoulder) ? "LeftShoulder" : "LeftShoulderDisabled"); textFormatter.AddArgument(device.IsButtonDown(GamePadButton.RightShoulder) ? "RightShoulder" : "RightShoulderDisabled"); textFormatter.AddArgument(device.IsButtonDown(GamePadButton.A) ? "AButton" : "AButtonDisabled"); textFormatter.AddArgument(device.IsButtonDown(GamePadButton.B) ? "BButton" : "BButtonDisabled"); textFormatter.AddArgument(device.IsButtonDown(GamePadButton.X) ? "XButton" : "XButtonDisabled"); textFormatter.AddArgument(device.IsButtonDown(GamePadButton.Y) ? "YButton" : "YButtonDisabled"); textFormatter.AddArgument(device.IsButtonDown(GamePadButton.Back) ? "BackButton" : "BackButtonDisabled"); textFormatter.AddArgument(device.IsButtonDown(GamePadButton.Start) ? "StartButton" : "StartButtonDisabled"); textFormatter.AddArgument(device.IsButtonDown(GamePadButton.DPadUp) ? "DPadUp" : "DPadUpDisabled"); textFormatter.AddArgument(device.IsButtonDown(GamePadButton.DPadDown) ? "DPadDown" : "DPadDownDisabled"); textFormatter.AddArgument(device.IsButtonDown(GamePadButton.DPadLeft) ? "DPadLeft" : "DPadLeftDisabled"); textFormatter.AddArgument(device.IsButtonDown(GamePadButton.DPadRight) ? "DPadRight" : "DPadRightDisabled"); textFormatter.AddArgument(device.IsButtonDown(GamePadButton.LeftStick) ? "LeftJoystick" : "LeftJoystickDisabled"); textFormatter.AddArgument(device.IsButtonDown(GamePadButton.RightStick) ? "RightJoystick" : "RightJoystickDisabled"); textFormatter.Format( "|c:FFFFFF00|Buttons|c|\n\n" + "|icon:{0}| |icon:{1}|\n" + "|icon:{2}| |icon:{3}| |icon:{4}| |icon:{5}|\n" + "|icon:{6}| |icon:{7}|\n" + "|icon:{8}| |icon:{9}| |icon:{10}| |icon:{11}|\n" + "|icon:{12}| |icon:{13}|\n\n" + "|c:FFFFFF00|Axes|c|", textBuffer); var buttonSettings = new TextLayoutSettings(font, area.Width, area.Height, TextFlags.AlignCenter | TextFlags.AlignTop); textArea = textRenderer.Draw(spriteBatch, textBuffer, new Vector2(x, y), Color.White, buttonSettings); y += (Int32)textArea.Height + font.Regular.LineSpacing; var axesLeftSettings = new TextLayoutSettings(font, area.Width, area.Height, TextFlags.AlignLeft | TextFlags.AlignTop); var axesRightSettings = new TextLayoutSettings(font, area.Width, area.Height, TextFlags.AlignRight | TextFlags.AlignTop); textFormatter.Reset(); textFormatter.AddArgument(device.LeftTrigger); textFormatter.Format("|icon:LeftTrigger|{0:decimals:2}", textBuffer); textArea = textRenderer.Draw(spriteBatch, textBuffer, new Vector2(x, y), Color.White, axesLeftSettings); textFormatter.Reset(); textFormatter.AddArgument(device.RightTrigger); textFormatter.Format("{0:decimals:2}|icon:RightTrigger|", textBuffer); textArea = textRenderer.Draw(spriteBatch, textBuffer, new Vector2(x, y), Color.White, axesRightSettings); y += (Int32)textArea.Height; textFormatter.Reset(); textFormatter.AddArgument(device.LeftJoystickX); textFormatter.AddArgument(device.LeftJoystickY); textFormatter.Format("|icon:LeftJoystick|\nX={0:decimals:2}\nY={1:decimals:2}", textBuffer); textArea = textRenderer.Draw(spriteBatch, textBuffer, new Vector2(x, y), Color.White, axesLeftSettings); textFormatter.Reset(); textFormatter.AddArgument(device.RightJoystickX); textFormatter.AddArgument(device.RightJoystickY); textFormatter.Format("|icon:RightJoystick|\nX={0:decimals:2}\nY={1:decimals:2}", textBuffer); textArea = textRenderer.Draw(spriteBatch, textBuffer, new Vector2(x, y), Color.White, axesRightSettings); } spriteBatch.End(); }
public void DrawObject(SpriteBatch batch, bool debug = false, TextRenderer rend = null, TextLayoutSettings settings = new TextLayoutSettings()) { if (debug) { if (rend != null) { rend.Draw(batch, "yo", body2D.GetPosition().ToScreenVector(), TwistedLogik.Ultraviolet.Color.Gold, settings); } else { Console.WriteLine("Hey yo you didn't give me a TextRenderer"); } } }