| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170 |
- #region File Description
- //-----------------------------------------------------------------------------
- // TextItem.cs
- //
- // Microsoft XNA Community Game Platform
- // Copyright (C) Microsoft Corporation. All rights reserved.
- //-----------------------------------------------------------------------------
- #endregion
- #region Using Statements
- using System;
- using System.Collections.Generic;
- using System.Text;
- using Microsoft.Xna.Framework;
- using Microsoft.Xna.Framework.Graphics;
- using RobotGameData.GameInterface;
- #endregion
- namespace RobotGameData.Text
- {
- /// <summary>
- /// a structure with text information to be drawn on screen.
- /// </summary>
- public class TextItem : IIdentity
- {
- #region Fields
- protected int id = 0;
- protected SpriteFont spriteFont = null;
- protected string stringText = String.Empty;
- protected Vector2 position = Vector2.Zero;
- protected Color textColor = Color.White;
- protected float rotation = 0.0f;
- protected float scale = 1.0f;
- protected bool visible = true;
- #endregion
- #region Properties
- public int Id
- {
- get
- {
- if (id == 0)
- {
- id = GetHashCode();
- }
- return id;
- }
- }
- public SpriteFont Font
- {
- get { return spriteFont; }
- set { spriteFont = value; }
- }
- public string Text
- {
- get { return stringText; }
- set { stringText = value; }
- }
- public int PosX
- {
- get { return (int)position.X; }
- set { position.X = (float)value; }
- }
- public int PosY
- {
- get { return (int)position.Y; }
- set { position.Y = (float)value; }
- }
- public Vector2 Position
- {
- get { return position; }
- set { position = value; }
- }
- public Color Color
- {
- get { return textColor; }
- set { textColor = value; }
- }
- public float Rotation
- {
- get { return rotation; }
- set { rotation = value; }
- }
- public float Scale
- {
- get { return scale; }
- set { scale = value; }
- }
- public bool Visible
- {
- get { return visible; }
- set { visible = value; }
- }
- #endregion
- /// <summary>
- /// Constructor.
- /// </summary>
- public TextItem() { }
- /// <summary>
- /// Constructor.
- /// </summary>
- /// <param name="font">sprite font</param>
- /// <param name="text">text</param>
- /// <param name="x">position x</param>
- /// <param name="y">position y</param>
- /// <param name="color">text color</param>
- public TextItem(SpriteFont font, string text, int x, int y, Color color)
- {
- if (font == null)
- {
- throw new ArgumentNullException("font");
- }
- if (String.IsNullOrEmpty(text))
- {
- throw new ArgumentNullException("text");
- }
- spriteFont = font;
- stringText = text;
- position.X = (int)x;
- position.Y = (int)y;
- textColor = color;
- }
- public void CopyTo(TextItem target)
- {
- target.Font = Font;
- target.Text = Text;
- target.PosX = PosX;
- target.PosY = PosY;
- target.Color = Color;
- }
- public bool IsSameValue(TextItem item)
- {
- if (Font != item.Font)
- return false;
- if (Text != item.Text)
- return false;
- if (PosX != item.PosX)
- return false;
- if (PosY != item.PosY)
- return false;
- if (Color != item.Color)
- return false;
- return true;
- }
- }
- }
|