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:
ShadowCommander
2019-07-31 16:38:24 -07:00
committed by Pieter-Jan Briers
parent 1d9d01b355
commit 151d3a3672
8 changed files with 84 additions and 21 deletions

View File

@@ -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
};