public override void Init() { base.Init(); uiItem = new UiItem { OnTop = true }; Area.Add(uiItem); var area = inventory.Player.Area; Subscribe <ItemUsedEvent>(area); Subscribe <ItemAddedEvent>(area); var anim = Animations.Get("ui"); activeSide = anim.GetSlice("active_side"); activeBorder = anim.GetSlice("active_border"); activeEmpty = anim.GetSlice("active_empty"); activeFull = anim.GetSlice("active_full"); if (inventory.Player?.GetComponent <ActiveItemComponent>().Item != null) { ActivePosition = 0; } }
public override void Init() { base.Init(); uiItem = new UiItem { OnTop = true }; Area.Add(uiItem); var area = inventory.Player.Area; Subscribe <WeaponSwappedEvent>(area); Subscribe <ItemAddedEvent>(area); }
private void RemoveArtifact(Item item) { if (multiplayer) { return; } UiItem old = null; var j = 0; foreach (var i in items) { if (i.Id == item.Id) { old = i; break; } j++; } if (old == null) { return; } if (old.Count > 1) { old.Count--; return; } items.Remove(old); old.Done = true; for (var i = j; i < items.Count; i++) { items[i].Right = items[i - 1].X - 8; } }
private void RenderTop() { var show = Run.Depth > 0; if (show && Player != null) { if (UiItem.Hovered != null) { var item = UiItem.Hovered; if (lastItem != UiItem.Hovered) { lastItem = UiItem.Hovered; description.Label = item.Description; description.FinishTyping(); } var x = MathUtils.Clamp(item.OnTop ? 40 : 4, Display.UiWidth - 6 - Math.Max(item.DescriptionSize.X, item.NameSize.X), item.Position.X); var y = item.OnTop ? MathUtils.Clamp(8 + item.NameSize.Y, Display.UiHeight - 6 - item.DescriptionSize.Y, item.Y) : MathUtils.Clamp(4, Display.UiHeight - 6 - item.DescriptionSize.Y - item.NameSize.Y - 4, item.Y - 7); Graphics.Color = new Color(1f, 1f, 1f, item.TextA); Graphics.Print(item.Name, Font.Small, new Vector2(x, y - item.DescriptionSize.Y + 2)); // Graphics.Print(item.Description, Font.Small, new Vector2(x, y)); description.X = x; description.Y = y - 2; Graphics.Color = ColorUtils.WhiteColor; description.Tint.A = (byte)(item.TextA * 255f); description.RenderString(); } } }
private void AddArtifact(Item item) { if (item.Hide || multiplayer) { return; } UiItem old = null; foreach (var i in items) { if (i.Id == item.Id) { old = i; break; } } if (old == null) { var x = Display.UiWidth - 8f; if (items.Count > 0) { x = items[items.Count - 1].X - 8; } old = new UiItem(); old.Id = item.Id; old.Scourged = item.Scourged; Area.Add(old); items.Add(old); old.Right = x; old.Bottom = Display.UiHeight - 8f; if (items.Count > 6) { more.Label = $"+{items.Count - 6}"; more.Enabled = true; more.Right = Display.UiWidth - 8; more.Bottom = Display.UiHeight - 5f; for (var i = 0; i < items.Count - 6; i++) { var it = items[i]; it.X = Display.UiWidth + 32; } var ps = Display.UiWidth - 8f; ps -= more.Width + 8; for (var i = items.Count - 6; i < items.Count; i++) { var it = items[i]; it.Right = ps; ps -= 8 + it.Width; } } } else { old.Count++; } }