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:
@@ -138,6 +138,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 Content.Client.GameObjects.Components.Storage;
|
||||
using Content.Client.Utility;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.Interfaces.GameObjects.Components;
|
||||
@@ -55,7 +56,8 @@ namespace Content.Client.GameObjects
|
||||
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);
|
||||
}
|
||||
@@ -90,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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,6 +115,7 @@ namespace Content.Client.GameObjects
|
||||
{
|
||||
button.SpriteView.Sprite = null;
|
||||
button.OnPressed = AddToInventory;
|
||||
button.StorageButton.Visible = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,8 +13,10 @@ 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, Texture storageTexture)
|
||||
{
|
||||
@@ -36,7 +38,7 @@ namespace Content.Client.GameObjects
|
||||
Scale = (2, 2)
|
||||
});
|
||||
|
||||
AddChild(Button = new TextureButton
|
||||
AddChild(StorageButton = new TextureButton
|
||||
{
|
||||
TextureNormal = storageTexture,
|
||||
Scale = (0.75f, 0.75f),
|
||||
@@ -44,6 +46,8 @@ namespace Content.Client.GameObjects
|
||||
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