public Label(UIElement parent, Vector2 position, string text="") : base(parent, position) { if (_font == null) _font = ContentInterface.LoadFont("font2"); _text = text; }
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")); }
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; }
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; }
public void Drop(UIElement element) { IDroppable drop = _parent as IDroppable; if (_parent != null) { drop.Remove(this); } else { _parent.RemoveChild(this); } }
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; }
//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; }
public void RemoveChild(UIElement element) { _childs.Remove(element); }
public void AddChild(UIElement element) { _childs.Add(element); element._parent = this; }
public PictureBox(UIElement parent, Vector2 offset, Vector2 size, Texture2D texture) : base(parent, offset) { _texture = texture; _size = size; }