Added OpenStorage trigger on ActivateItemInWorld
When ActivateItemInWorld is pressed when hovering over a InventoryButton and the InventorySlot contains a storage item, it will open the StorageGUI.
This commit is contained in:
@@ -127,18 +127,18 @@ namespace Content.Client.GameObjects
|
||||
_sprite?.LayerSetVisible(slot, false);
|
||||
}
|
||||
|
||||
public void SendUnequipMessage(Slots slot)
|
||||
{
|
||||
var unequipmessage = new ClientInventoryMessage(slot, ClientInventoryUpdate.Unequip);
|
||||
SendNetworkMessage(unequipmessage);
|
||||
}
|
||||
|
||||
public void SendEquipMessage(Slots slot)
|
||||
{
|
||||
var equipmessage = new ClientInventoryMessage(slot, ClientInventoryUpdate.Equip);
|
||||
SendNetworkMessage(equipmessage);
|
||||
}
|
||||
|
||||
public void SendUseMessage(Slots slot)
|
||||
{
|
||||
var equipmessage = new ClientInventoryMessage(slot, ClientInventoryUpdate.Use);
|
||||
SendNetworkMessage(equipmessage);
|
||||
}
|
||||
|
||||
public void SendOpenStorageUIMessage(Slots slot)
|
||||
{
|
||||
SendNetworkMessage(new OpenSlotStorageUIMessage(slot));
|
||||
|
||||
@@ -97,7 +97,7 @@ namespace Content.Client.GameObjects
|
||||
foreach (var button in buttons)
|
||||
{
|
||||
button.SpriteView.Sprite = sprite;
|
||||
button.OnPressed = RemoveFromInventory;
|
||||
button.OnPressed = HandleInventoryKeybind;
|
||||
button.StorageButton.Visible = hasInventory;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,8 @@ namespace Content.Client.GameObjects
|
||||
AddChild(Button = new TextureButton
|
||||
{
|
||||
TextureNormal = texture,
|
||||
Scale = (2, 2)
|
||||
Scale = (2, 2),
|
||||
NonFocusKeybinds = true
|
||||
});
|
||||
|
||||
Button.OnPressed += e => OnPressed?.Invoke(e);
|
||||
@@ -44,7 +45,8 @@ namespace Content.Client.GameObjects
|
||||
Scale = (0.75f, 0.75f),
|
||||
SizeFlagsHorizontal = SizeFlags.ShrinkEnd,
|
||||
SizeFlagsVertical = SizeFlags.ShrinkEnd,
|
||||
Visible = false
|
||||
Visible = false,
|
||||
NonFocusKeybinds = true
|
||||
});
|
||||
|
||||
StorageButton.OnPressed += e => OnStoragePressed?.Invoke(e);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System;
|
||||
using Content.Client.UserInterface;
|
||||
using Content.Shared.GameObjects.Components.Inventory;
|
||||
using Content.Shared.Input;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.UserInterface.CustomControls;
|
||||
using Robust.Shared.Interfaces.GameObjects;
|
||||
@@ -60,24 +61,44 @@ namespace Content.Client.GameObjects
|
||||
{
|
||||
}
|
||||
|
||||
protected void RemoveFromInventory(BaseButton.ButtonEventArgs args)
|
||||
protected void HandleInventoryKeybind(BaseButton.ButtonEventArgs args)
|
||||
{
|
||||
args.Button.Pressed = false;
|
||||
var control = (InventoryButton) args.Button.Parent;
|
||||
|
||||
Owner.SendUnequipMessage(control.Slot);
|
||||
if (args.Event.Function == ContentKeyFunctions.ActivateItemInWorld)
|
||||
{
|
||||
OpenStorage(args);
|
||||
}
|
||||
else if (args.Event.CanFocus)
|
||||
{
|
||||
UseItemOnInventory(args);
|
||||
}
|
||||
}
|
||||
|
||||
protected void AddToInventory(BaseButton.ButtonEventArgs args)
|
||||
{
|
||||
if (!args.Event.CanFocus)
|
||||
{
|
||||
return;
|
||||
}
|
||||
args.Button.Pressed = false;
|
||||
var control = (InventoryButton) args.Button.Parent;
|
||||
|
||||
Owner.SendEquipMessage(control.Slot);
|
||||
}
|
||||
|
||||
protected void UseItemOnInventory(BaseButton.ButtonEventArgs args)
|
||||
{
|
||||
args.Button.Pressed = false;
|
||||
var control = (InventoryButton)args.Button.Parent;
|
||||
|
||||
Owner.SendUseMessage(control.Slot);
|
||||
}
|
||||
|
||||
protected void OpenStorage(BaseButton.ButtonEventArgs args)
|
||||
{
|
||||
if (!args.Event.CanFocus && args.Event.Function != ContentKeyFunctions.ActivateItemInWorld)
|
||||
{
|
||||
return;
|
||||
}
|
||||
args.Button.Pressed = false;
|
||||
var control = (InventoryButton)args.Button.Parent;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user