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:
@@ -1,4 +1,4 @@
|
|||||||
using Content.Client.UserInterface;
|
using Content.Client.UserInterface;
|
||||||
using Robust.Client.Console;
|
using Robust.Client.Console;
|
||||||
using Robust.Client.Interfaces.Input;
|
using Robust.Client.Interfaces.Input;
|
||||||
using Robust.Client.Interfaces.Placement;
|
using Robust.Client.Interfaces.Placement;
|
||||||
@@ -49,9 +49,8 @@ namespace Content.Client
|
|||||||
|
|
||||||
_escapeMenu.OnClose += () => _gameHud.EscapeButtonDown = false;
|
_escapeMenu.OnClose += () => _gameHud.EscapeButtonDown = false;
|
||||||
|
|
||||||
var escapeMenuCommand = InputCmdHandler.FromDelegate(Enabled);
|
_inputManager.SetInputCommand(EngineKeyFunctions.EscapeMenu,
|
||||||
|
InputCmdHandler.FromDelegate(s => Enabled()));
|
||||||
_inputManager.SetInputCommand(EngineKeyFunctions.EscapeMenu, escapeMenuCommand);
|
|
||||||
}
|
}
|
||||||
else if (obj.OldState is GameScreen)
|
else if (obj.OldState is GameScreen)
|
||||||
{
|
{
|
||||||
@@ -63,7 +62,7 @@ namespace Content.Client
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Enabled(ICommonSession session)
|
private void Enabled()
|
||||||
{
|
{
|
||||||
if (_escapeMenu.IsOpen)
|
if (_escapeMenu.IsOpen)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -127,18 +127,18 @@ namespace Content.Client.GameObjects
|
|||||||
_sprite?.LayerSetVisible(slot, false);
|
_sprite?.LayerSetVisible(slot, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SendUnequipMessage(Slots slot)
|
|
||||||
{
|
|
||||||
var unequipmessage = new ClientInventoryMessage(slot, ClientInventoryUpdate.Unequip);
|
|
||||||
SendNetworkMessage(unequipmessage);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SendEquipMessage(Slots slot)
|
public void SendEquipMessage(Slots slot)
|
||||||
{
|
{
|
||||||
var equipmessage = new ClientInventoryMessage(slot, ClientInventoryUpdate.Equip);
|
var equipmessage = new ClientInventoryMessage(slot, ClientInventoryUpdate.Equip);
|
||||||
SendNetworkMessage(equipmessage);
|
SendNetworkMessage(equipmessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SendUseMessage(Slots slot)
|
||||||
|
{
|
||||||
|
var equipmessage = new ClientInventoryMessage(slot, ClientInventoryUpdate.Use);
|
||||||
|
SendNetworkMessage(equipmessage);
|
||||||
|
}
|
||||||
|
|
||||||
public void SendOpenStorageUIMessage(Slots slot)
|
public void SendOpenStorageUIMessage(Slots slot)
|
||||||
{
|
{
|
||||||
SendNetworkMessage(new OpenSlotStorageUIMessage(slot));
|
SendNetworkMessage(new OpenSlotStorageUIMessage(slot));
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ namespace Content.Client.GameObjects
|
|||||||
foreach (var button in buttons)
|
foreach (var button in buttons)
|
||||||
{
|
{
|
||||||
button.SpriteView.Sprite = sprite;
|
button.SpriteView.Sprite = sprite;
|
||||||
button.OnPressed = RemoveFromInventory;
|
button.OnPressed = HandleInventoryKeybind;
|
||||||
button.StorageButton.Visible = hasInventory;
|
button.StorageButton.Visible = hasInventory;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,8 @@ namespace Content.Client.GameObjects
|
|||||||
AddChild(Button = new TextureButton
|
AddChild(Button = new TextureButton
|
||||||
{
|
{
|
||||||
TextureNormal = texture,
|
TextureNormal = texture,
|
||||||
Scale = (2, 2)
|
Scale = (2, 2),
|
||||||
|
NonFocusKeybinds = true
|
||||||
});
|
});
|
||||||
|
|
||||||
Button.OnPressed += e => OnPressed?.Invoke(e);
|
Button.OnPressed += e => OnPressed?.Invoke(e);
|
||||||
@@ -44,7 +45,8 @@ namespace Content.Client.GameObjects
|
|||||||
Scale = (0.75f, 0.75f),
|
Scale = (0.75f, 0.75f),
|
||||||
SizeFlagsHorizontal = SizeFlags.ShrinkEnd,
|
SizeFlagsHorizontal = SizeFlags.ShrinkEnd,
|
||||||
SizeFlagsVertical = SizeFlags.ShrinkEnd,
|
SizeFlagsVertical = SizeFlags.ShrinkEnd,
|
||||||
Visible = false
|
Visible = false,
|
||||||
|
NonFocusKeybinds = true
|
||||||
});
|
});
|
||||||
|
|
||||||
StorageButton.OnPressed += e => OnStoragePressed?.Invoke(e);
|
StorageButton.OnPressed += e => OnStoragePressed?.Invoke(e);
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using Content.Client.UserInterface;
|
using Content.Client.UserInterface;
|
||||||
using Content.Shared.GameObjects.Components.Inventory;
|
using Content.Shared.GameObjects.Components.Inventory;
|
||||||
|
using Content.Shared.Input;
|
||||||
using Robust.Client.UserInterface.Controls;
|
using Robust.Client.UserInterface.Controls;
|
||||||
using Robust.Client.UserInterface.CustomControls;
|
using Robust.Client.UserInterface.CustomControls;
|
||||||
using Robust.Shared.Interfaces.GameObjects;
|
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;
|
if (args.Event.Function == ContentKeyFunctions.ActivateItemInWorld)
|
||||||
var control = (InventoryButton) args.Button.Parent;
|
{
|
||||||
|
OpenStorage(args);
|
||||||
Owner.SendUnequipMessage(control.Slot);
|
}
|
||||||
|
else if (args.Event.CanFocus)
|
||||||
|
{
|
||||||
|
UseItemOnInventory(args);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void AddToInventory(BaseButton.ButtonEventArgs args)
|
protected void AddToInventory(BaseButton.ButtonEventArgs args)
|
||||||
{
|
{
|
||||||
|
if (!args.Event.CanFocus)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
args.Button.Pressed = false;
|
args.Button.Pressed = false;
|
||||||
var control = (InventoryButton) args.Button.Parent;
|
var control = (InventoryButton) args.Button.Parent;
|
||||||
|
|
||||||
Owner.SendEquipMessage(control.Slot);
|
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)
|
protected void OpenStorage(BaseButton.ButtonEventArgs args)
|
||||||
{
|
{
|
||||||
|
if (!args.Event.CanFocus && args.Event.Function != ContentKeyFunctions.ActivateItemInWorld)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
args.Button.Pressed = false;
|
args.Button.Pressed = false;
|
||||||
var control = (InventoryButton)args.Button.Parent;
|
var control = (InventoryButton)args.Button.Parent;
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using Content.Client.Utility;
|
using Content.Client.Utility;
|
||||||
using Content.Shared.Input;
|
using Content.Shared.Input;
|
||||||
using Robust.Client.Graphics;
|
using Robust.Client.Graphics;
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using Content.Server.GameObjects.EntitySystems;
|
||||||
using Content.Shared.GameObjects;
|
using Content.Shared.GameObjects;
|
||||||
using Robust.Server.GameObjects.Components.Container;
|
using Robust.Server.GameObjects.Components.Container;
|
||||||
using Robust.Server.Interfaces.Player;
|
using Robust.Server.Interfaces.Player;
|
||||||
@@ -19,6 +20,10 @@ namespace Content.Server.GameObjects
|
|||||||
[RegisterComponent]
|
[RegisterComponent]
|
||||||
public class InventoryComponent : SharedInventoryComponent
|
public class InventoryComponent : SharedInventoryComponent
|
||||||
{
|
{
|
||||||
|
#pragma warning disable 649
|
||||||
|
[Dependency] private readonly IEntitySystemManager _entitySystemManager;
|
||||||
|
#pragma warning restore 649
|
||||||
|
|
||||||
[ViewVariables]
|
[ViewVariables]
|
||||||
private readonly Dictionary<Slots, ContainerSlot> SlotContainers = new Dictionary<Slots, ContainerSlot>();
|
private readonly Dictionary<Slots, ContainerSlot> SlotContainers = new Dictionary<Slots, ContainerSlot>();
|
||||||
|
|
||||||
@@ -223,11 +228,13 @@ namespace Content.Server.GameObjects
|
|||||||
/// <param name="msg"></param>
|
/// <param name="msg"></param>
|
||||||
private void HandleInventoryMessage(ClientInventoryMessage msg)
|
private void HandleInventoryMessage(ClientInventoryMessage msg)
|
||||||
{
|
{
|
||||||
if (msg.Updatetype == ClientInventoryUpdate.Equip)
|
switch (msg.Updatetype)
|
||||||
|
{
|
||||||
|
case ClientInventoryUpdate.Equip:
|
||||||
{
|
{
|
||||||
var hands = Owner.GetComponent<HandsComponent>();
|
var hands = Owner.GetComponent<HandsComponent>();
|
||||||
var activehand = hands.GetActiveHand;
|
var activeHand = hands.GetActiveHand;
|
||||||
if (activehand != null && activehand.Owner.TryGetComponent(out ClothingComponent clothing))
|
if (activeHand != null && activeHand.Owner.TryGetComponent(out ClothingComponent clothing))
|
||||||
{
|
{
|
||||||
hands.Drop(hands.ActiveIndex);
|
hands.Drop(hands.ActiveIndex);
|
||||||
if (!Equip(msg.Inventoryslot, clothing))
|
if (!Equip(msg.Inventoryslot, clothing))
|
||||||
@@ -235,15 +242,27 @@ namespace Content.Server.GameObjects
|
|||||||
hands.PutInHand(clothing);
|
hands.PutInHand(clothing);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
else if (msg.Updatetype == ClientInventoryUpdate.Unequip)
|
case ClientInventoryUpdate.Use:
|
||||||
{
|
{
|
||||||
|
var interactionSystem = _entitySystemManager.GetEntitySystem<InteractionSystem>();
|
||||||
var hands = Owner.GetComponent<HandsComponent>();
|
var hands = Owner.GetComponent<HandsComponent>();
|
||||||
var activehand = hands.GetActiveHand;
|
var activeHand = hands.GetActiveHand;
|
||||||
var itemcontainedinslot = GetSlotItem(msg.Inventoryslot);
|
var itemContainedInSlot = GetSlotItem(msg.Inventoryslot);
|
||||||
if (activehand == null && itemcontainedinslot != null && Unequip(msg.Inventoryslot))
|
if (itemContainedInSlot != null)
|
||||||
{
|
{
|
||||||
hands.PutInHand(itemcontainedinslot);
|
if (activeHand != null)
|
||||||
|
{
|
||||||
|
interactionSystem.Interaction(Owner, activeHand.Owner, itemContainedInSlot.Owner,
|
||||||
|
new Robust.Shared.Map.GridCoordinates());
|
||||||
|
}
|
||||||
|
else if (Unequip(msg.Inventoryslot))
|
||||||
|
{
|
||||||
|
hands.PutInHand(itemContainedInSlot);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -472,12 +472,19 @@ namespace Content.Server.GameObjects
|
|||||||
var playerEntity = session.AttachedEntity;
|
var playerEntity = session.AttachedEntity;
|
||||||
var used = GetActiveHand?.Owner;
|
var used = GetActiveHand?.Owner;
|
||||||
|
|
||||||
if (playerEntity == Owner && used != null && slot.ContainedEntity != null)
|
if (playerEntity == Owner && slot.ContainedEntity != null)
|
||||||
{
|
{
|
||||||
var interactionSystem = _entitySystemManager.GetEntitySystem<InteractionSystem>();
|
var interactionSystem = _entitySystemManager.GetEntitySystem<InteractionSystem>();
|
||||||
|
if (used != null)
|
||||||
|
{
|
||||||
interactionSystem.Interaction(Owner, used, slot.ContainedEntity,
|
interactionSystem.Interaction(Owner, used, slot.ContainedEntity,
|
||||||
GridCoordinates.Nullspace);
|
GridCoordinates.Nullspace);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
interactionSystem.Interaction(Owner, slot.ContainedEntity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ namespace Content.Shared.GameObjects
|
|||||||
public enum ClientInventoryUpdate
|
public enum ClientInventoryUpdate
|
||||||
{
|
{
|
||||||
Equip = 0,
|
Equip = 0,
|
||||||
Unequip = 1
|
Use = 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Submodule RobustToolbox updated: f3f317385a...0adcc3c645
Reference in New Issue
Block a user