private void UpdateLabel() { labelNum = stack != null ? stack.Count : -1; Vector2 position = index != -1 ? rect.Position + SIZE / 2 : rect.Position; if (labelNum <= 1) { labelChild.Hide(); } else { labelChild.Text = "" + labelNum; labelChild.Show(); } }
// TODO: use the invUpdate delegate idea to refactor the inventory with GUI synchronisation system public GUIInventorySlot(GUIInventorySlot exchangeSlot_, Item.ItemType type_, int index_, Vector2 pos, Func <ItemStack, bool> quickMoveItem_ = null, Action invUpdate_ = null, Func <bool> shouldShow = null) : base(new Vector2(), SIZE, Game.guiResourceLoader.GetResource(SLOT_TEXTURE) as Texture, shouldShow) { SetPosition(pos); exchangeSlot = exchangeSlot_; quickMoveItem = quickMoveItem_; invUpdate = invUpdate_; index = index_; type = type_; labelChild = new GUILabel(); labelChild.SetZAsRelative(true); labelChild.SetZIndex(LABEL_Z); hoverLabel = new GUILabel(); hoverLabel.Hide(); hoverLabel.SetZAsRelative(true); hoverLabel.SetZIndex(HOVER_LABEL_Z); AddChild(hoverLabel); AssignItemStack(null); }
public override void OnHoverOff() { hoverLabel.Hide(); }