using Microsoft.Xna.Framework;
namespace MonoGame.Extended.Tilemaps
{
///
/// Represents a text object in a tilemap.
///
///
/// Text objects store text display information. Rendering is the user's responsibility.
///
public class TilemapTextObject : TilemapObject
{
///
/// Gets or sets the bounding size for the text.
///
public Vector2 Size { get; set; }
///
/// Gets or sets the text content.
///
public string Text { get; set; }
///
/// Gets or sets the font family name.
///
public string FontFamily { get; set; }
///
/// Gets or sets the font size in pixels.
///
public int PixelSize { get; set; }
///
/// Gets or sets a value indicating whether the text is bold.
///
public bool Bold { get; set; }
///
/// Gets or sets a value indicating whether the text is italic.
///
public bool Italic { get; set; }
///
/// Gets or sets a value indicating whether the text is underlined.
///
public bool Underline { get; set; }
///
/// Gets or sets a value indicating whether the text is struck through.
///
public bool Strikethrough { get; set; }
///
/// Gets or sets the text color.
///
public Color Color { get; set; }
///
/// Gets or sets a value indicating whether text wraps within the bounding box.
///
public bool WordWrap { get; set; }
///
/// Gets or sets the horizontal alignment of the text.
///
public TilemapTextObjectHorizontalAlignment HorizontalAlign { get; set; }
///
/// Gets or sets the vertical alignment of the text.
///
public TilemapTextObjectVerticalAlignment VerticalAlign { get; set; }
///
public override RectangleF Bounds
{
get
{
return new RectangleF(Position.X, Position.Y, Size.X, Size.Y);
}
}
// NOTE: Will use BoundingBox2D
///
/// Initializes a new instance of the class.
///
/// The unique identifier for the object.
/// The position of the text.
/// The bounding size for the text.
/// The text content.
public TilemapTextObject(int id, Vector2 position, Vector2 size, string text) : base(id, position)
{
Size = size;
Text = text;
FontFamily = "sans-serif";
PixelSize = 16;
Color = Color.Black;
HorizontalAlign = TilemapTextObjectHorizontalAlignment.Left;
VerticalAlign = TilemapTextObjectVerticalAlignment.Top;
}
}
///
/// Specifies horizontal text alignment.
///
public enum TilemapTextObjectHorizontalAlignment
{
///
/// Align text to the left.
///
Left,
///
/// Center text horizontally.
///
Center,
///
/// Align text to the right.
///
Right,
///
/// Justify text to fill the width.
///
Justify
}
///
/// Specifies vertical text alignment.
///
public enum TilemapTextObjectVerticalAlignment
{
///
/// Align text to the top.
///
Top,
///
/// Center text vertically.
///
Center,
///
/// Align text to the bottom.
///
Bottom
}
}