예제 #1
0
        /// <summary>
        /// Calculates the position the Text should be drawn at given its alignment
        /// </summary>
        /// <param name="t"></param>
        /// <returns></returns>
        public Vector2 CalculatePosition(Text t)
        {
            switch (t.Alignment)
            {
                case Align.BottomLeft:
                    return new Vector2(0, t.Size.Y);
                case Align.Bottom:
                    return new Vector2(t.Size.X / 2, t.Size.Y);
                case Align.BottomRight:
                    return t.Size;
                case Align.Right:
                    return new Vector2(t.Size.X, t.Size.Y / 2);
                case Align.TopRight:
                    return new Vector2(t.Size.X, 0);
                case Align.Top:
                    return new Vector2(t.Size.X / 2, 0);
                case Align.TopLeft:
                    return Vector2.Zero;
                case Align.Left:
                    return new Vector2(0, t.Size.Y/2);
                case Align.Center:
                    return (t.Size / 2);
                default:
                    return Vector2.Zero;

            }
        }
예제 #2
0
 /// <summary>
 /// The default Delegate run when a menu Item is selected. Does nothing. Here to keep code happy
 /// </summary>
 /// <param name="t"> The Text object to do nothing to </param>
 private static void DefaultOnSelect(Text t)
 {
 }
예제 #3
0
 /// <summary>
 /// Adds a new Text object to MenuItems and sets its properties. Selects it if it is first item added to the menu
 /// </summary>
 /// <param name="t"> The Text object to add to the Menu </param>
 public void AddMenuItem(Text t)
 {
     t.TextColor = MenuColor;
     t.Font = Font;
     t.Alignment = Alignment;
     t.Scale = Scale;
     if (MenuItems.Count == 0) OnSelect(t);
     MenuItems.Add(t);
     TotalItems++;
 }
예제 #4
0
 public static void SelectText(Text t)
 {
     t.TextColor = Color.Red;
     t.Scale = new Vector2(0.75f);
 }
예제 #5
0
 public static void DeselectText(Text t)
 {
     t.TextColor = Color.White;
     t.Scale = new Vector2(0.5f);
 }
예제 #6
0
 /// <summary>
 /// Adds a new Text to the list of texts to be drawn if it is not already in the list
 /// </summary>
 /// <param name="t"></param>
 public void AddText(Text t)
 {
     if (!_texts.Contains(t)) _texts.Add(t);
 }