Example #1
0
 public Label(UIElement parent, Vector2 position, string text="")
     : base(parent, position)
 {
     if (_font == null)
         _font = ContentInterface.LoadFont("font2");
     _text = text;
 }
Example #2
0
 public ItemIcon(UIElement parent, Vector2 position, Logic.ICollectible item)
     : base(parent, position, new Vector2(32, 32), item != null ? item.Texture : null)
 {
     oldPos = position;
     _item = item;
     backgroundPanel = new Panel(this, new Vector2(-2, -2), new Vector2(40, 40), Content.ContentInterface.LoadTexture("UITest"));
 }
Example #3
0
 public UIElement(UIElement parent, Vector2 offset)
 {
     _parent = parent;
     _offset = offset;
     _childs = new List<UIElement>();
     depth=minDepth;
     if (parent != null)
         depth = parent.depth + maxDepth - parent.depth / 10.0f;
 }
Example #4
0
 public Button(UIElement parent, Vector2 position, Vector2 size, Texture2D buttonTex, Action action, string text="")
     : base(parent, position)
 {
     buttonBorder = new Panel(this, Vector2.Zero, size, buttonTex);
     this.AddChild(buttonBorder);
     _action=action;
     _size = size;
     if (_font == null)
         _font = ContentInterface.LoadFont("font2");
     Text = text;
     _state = UIButtonState.Nothing;
 }
Example #5
0
 public void Drop(UIElement element)
 {
     IDroppable drop = _parent as IDroppable;
     if (_parent != null)
     {
         drop.Remove(this);
     }
     else
     {
         _parent.RemoveChild(this);
     }
 }
Example #6
0
 public bool TryDrop(UIElement caller, IDraggable obj)
 {
     IDroppable drop = this as IDroppable;
     if(drop!=null && obj.Rect.Intersects(new Rectangle((int)TotalOffset.X,(int)TotalOffset.Y,(int)_size.X,(int)_size.Y)))
     {
         if (drop.Drop(obj))
             return true;
     }
     for (int x = 0; x < _childs.Count; x++)
         if (_childs[x] != caller) if (_childs[x].TryDrop(this, obj)) return true;
     if (_parent!=null && _parent != caller)
         if (_parent.TryDrop(this, obj)) return true;
     return false;
 }
Example #7
0
 //Texture is assumed to be consisting of 3x3 tiles which are 8x8 pixels each, one for each side, one for each corner and the center
 public Panel(UIElement parent, Vector2 offset, Vector2 size, Texture2D texture)
     : base(parent,offset)
 {
     SetSize(size);
     _texture = texture;
 }
Example #8
0
 public void RemoveChild(UIElement element)
 {
     _childs.Remove(element);
 }
Example #9
0
 public void AddChild(UIElement element)
 {
     _childs.Add(element);
     element._parent = this;
 }
Example #10
0
 public PictureBox(UIElement parent, Vector2 offset, Vector2 size, Texture2D texture)
     : base(parent, offset)
 {
     _texture = texture;
     _size = size;
 }