Fixed HandsGui and added an icon to access worn inventories (#279)
* Fixed HandsGui children so that HandsGui is clickable * Added TextureButton for opening Storage items * Update ClientInventoryComponent.cs Fixed HandleComponentState so that it only updates the inventory when there are changes. * Implemented storage button on Inventory Adds a small button on the bottom right of Storage items when inside the inventory. When the button is pressed it opens the Storage UI.
This commit is contained in:
committed by
Pieter-Jan Briers
parent
1d9d01b355
commit
151d3a3672
@@ -1,7 +1,10 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Content.Client.GameObjects.Components.Clothing;
|
||||
using Content.Shared.GameObjects;
|
||||
using Content.Shared.GameObjects.Components.Inventory;
|
||||
using Content.Shared.GameObjects.Components.Storage;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Client.Interfaces.GameObjects.Components;
|
||||
using Robust.Shared.GameObjects;
|
||||
@@ -77,15 +80,12 @@ namespace Content.Client.GameObjects
|
||||
|
||||
foreach (var (slot, entityUid) in cast.Entities)
|
||||
{
|
||||
if (_slots.ContainsKey(slot))
|
||||
{
|
||||
_slots.Remove(slot);
|
||||
_clearSlot(slot);
|
||||
}
|
||||
|
||||
var entity = Owner.EntityManager.GetEntity(entityUid);
|
||||
_slots[slot] = entity;
|
||||
_setSlot(slot, entity);
|
||||
if (!_slots.ContainsKey(slot) || _slots[slot] != entity)
|
||||
{
|
||||
_slots[slot] = entity;
|
||||
_setSlot(slot, entity);
|
||||
}
|
||||
doneSlots.Add(slot);
|
||||
}
|
||||
|
||||
@@ -139,6 +139,11 @@ namespace Content.Client.GameObjects
|
||||
SendNetworkMessage(equipmessage);
|
||||
}
|
||||
|
||||
public void SendOpenStorageUIMessage(Slots slot)
|
||||
{
|
||||
SendNetworkMessage(new OpenSlotStorageUIMessage(slot));
|
||||
}
|
||||
|
||||
public override void HandleMessage(ComponentMessage message, INetChannel netChannel = null,
|
||||
IComponent component = null)
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using Content.Client.GameObjects.Components.Storage;
|
||||
using Content.Client.Utility;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.Interfaces.GameObjects.Components;
|
||||
@@ -52,9 +53,11 @@ namespace Content.Client.GameObjects
|
||||
void AddButton(out InventoryButton variable, Slots slot, string textureName)
|
||||
{
|
||||
var texture = _resourceCache.GetTexture($"/Textures/UserInterface/Inventory/{textureName}.png");
|
||||
variable = new InventoryButton(slot, texture)
|
||||
var storageTexture = _resourceCache.GetTexture($"/Textures/UserInterface/Inventory/back.png");
|
||||
variable = new InventoryButton(slot, texture, storageTexture)
|
||||
{
|
||||
OnPressed = AddToInventory
|
||||
OnPressed = AddToInventory,
|
||||
OnStoragePressed = OpenStorage
|
||||
};
|
||||
_inventoryButtons[slot].Add(variable);
|
||||
}
|
||||
@@ -89,11 +92,13 @@ namespace Content.Client.GameObjects
|
||||
}
|
||||
|
||||
entity.TryGetComponent(out ISpriteComponent sprite);
|
||||
var hasInventory = entity.HasComponent<ClientStorageComponent>();
|
||||
|
||||
foreach (var button in buttons)
|
||||
{
|
||||
button.SpriteView.Sprite = sprite;
|
||||
button.OnPressed = RemoveFromInventory;
|
||||
button.StorageButton.Visible = hasInventory;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,6 +115,7 @@ namespace Content.Client.GameObjects
|
||||
{
|
||||
button.SpriteView.Sprite = null;
|
||||
button.OnPressed = AddToInventory;
|
||||
button.StorageButton.Visible = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -152,7 +158,8 @@ namespace Content.Client.GameObjects
|
||||
void AddButton(Slots slot, string textureName, Vector2 position)
|
||||
{
|
||||
var texture = resourceCache.GetTexture($"/Textures/UserInterface/Inventory/{textureName}.png");
|
||||
var button = new InventoryButton(slot, texture)
|
||||
var storageTexture = resourceCache.GetTexture($"/Textures/UserInterface/Inventory/back.png");
|
||||
var button = new InventoryButton(slot, texture, storageTexture)
|
||||
{
|
||||
Position = position
|
||||
};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using Content.Shared.GameObjects.Components.Inventory;
|
||||
using Robust.Client.Graphics;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
@@ -13,10 +13,12 @@ namespace Content.Client.GameObjects
|
||||
|
||||
public BaseButton Button { get; }
|
||||
public SpriteView SpriteView { get; }
|
||||
public BaseButton StorageButton { get; }
|
||||
|
||||
public Action<BaseButton.ButtonEventArgs> OnPressed { get; set; }
|
||||
public Action<BaseButton.ButtonEventArgs> OnStoragePressed { get; set; }
|
||||
|
||||
public InventoryButton(EquipmentSlotDefines.Slots slot, Texture texture)
|
||||
public InventoryButton(EquipmentSlotDefines.Slots slot, Texture texture, Texture storageTexture)
|
||||
{
|
||||
Slot = slot;
|
||||
|
||||
@@ -25,7 +27,7 @@ namespace Content.Client.GameObjects
|
||||
AddChild(Button = new TextureButton
|
||||
{
|
||||
TextureNormal = texture,
|
||||
Scale = (2, 2),
|
||||
Scale = (2, 2)
|
||||
});
|
||||
|
||||
Button.OnPressed += e => OnPressed?.Invoke(e);
|
||||
@@ -35,6 +37,17 @@ namespace Content.Client.GameObjects
|
||||
MouseFilter = MouseFilterMode.Ignore,
|
||||
Scale = (2, 2)
|
||||
});
|
||||
|
||||
AddChild(StorageButton = new TextureButton
|
||||
{
|
||||
TextureNormal = storageTexture,
|
||||
Scale = (0.75f, 0.75f),
|
||||
SizeFlagsHorizontal = SizeFlags.ShrinkEnd,
|
||||
SizeFlagsVertical = SizeFlags.ShrinkEnd,
|
||||
Visible = false
|
||||
});
|
||||
|
||||
StorageButton.OnPressed += e => OnStoragePressed?.Invoke(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,5 +75,13 @@ namespace Content.Client.GameObjects
|
||||
|
||||
Owner.SendEquipMessage(control.Slot);
|
||||
}
|
||||
|
||||
protected void OpenStorage(BaseButton.ButtonEventArgs args)
|
||||
{
|
||||
args.Button.Pressed = false;
|
||||
var control = (InventoryButton)args.Button.Parent;
|
||||
|
||||
Owner.SendOpenStorageUIMessage(control.Slot);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user