2019-08-07 15:56:22 -07:00
|
|
|
|
using System;
|
2019-07-23 23:24:47 +02:00
|
|
|
|
using Content.Client.UserInterface;
|
|
|
|
|
|
using Content.Shared.GameObjects.Components.Inventory;
|
2019-08-07 15:56:22 -07:00
|
|
|
|
using Content.Shared.Input;
|
2020-05-05 23:59:31 +02:00
|
|
|
|
using Robust.Client.UserInterface;
|
2019-07-23 23:24:47 +02:00
|
|
|
|
using Robust.Client.UserInterface.CustomControls;
|
2020-05-05 23:59:31 +02:00
|
|
|
|
using Robust.Shared.Input;
|
2019-07-23 23:24:47 +02:00
|
|
|
|
using Robust.Shared.Interfaces.GameObjects;
|
|
|
|
|
|
using Robust.Shared.IoC;
|
|
|
|
|
|
|
2020-08-13 14:40:27 +02:00
|
|
|
|
namespace Content.Client.GameObjects.Components.HUD.Inventory
|
2019-07-23 23:24:47 +02:00
|
|
|
|
{
|
|
|
|
|
|
public abstract class InventoryInterfaceController : IDisposable
|
|
|
|
|
|
{
|
2020-01-17 06:43:20 -08:00
|
|
|
|
#pragma warning disable 649
|
|
|
|
|
|
[Dependency] protected readonly IGameHud _gameHud;
|
|
|
|
|
|
#pragma warning restore 649
|
2019-07-23 23:24:47 +02:00
|
|
|
|
|
|
|
|
|
|
protected InventoryInterfaceController(ClientInventoryComponent owner)
|
|
|
|
|
|
{
|
|
|
|
|
|
Owner = owner;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public virtual void Initialize()
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public abstract SS14Window Window { get; }
|
|
|
|
|
|
protected ClientInventoryComponent Owner { get; }
|
|
|
|
|
|
|
|
|
|
|
|
public virtual void PlayerAttached()
|
|
|
|
|
|
{
|
2020-01-17 06:43:20 -08:00
|
|
|
|
_gameHud.InventoryButtonVisible = true;
|
|
|
|
|
|
_gameHud.InventoryButtonToggled = b =>
|
2019-07-23 23:24:47 +02:00
|
|
|
|
{
|
|
|
|
|
|
if (b)
|
|
|
|
|
|
{
|
|
|
|
|
|
Window.Open();
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
Window.Close();
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public virtual void PlayerDetached()
|
|
|
|
|
|
{
|
2020-01-17 06:43:20 -08:00
|
|
|
|
_gameHud.InventoryButtonVisible = false;
|
2019-07-23 23:24:47 +02:00
|
|
|
|
Window.Close();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public virtual void Dispose()
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public virtual void AddToSlot(EquipmentSlotDefines.Slots slot, IEntity entity)
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-07-26 07:25:38 -05:00
|
|
|
|
public virtual void HoverInSlot(EquipmentSlotDefines.Slots slot, IEntity entity, bool fits)
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2019-07-23 23:24:47 +02:00
|
|
|
|
public virtual void RemoveFromSlot(EquipmentSlotDefines.Slots slot)
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-05-05 23:59:31 +02:00
|
|
|
|
protected virtual void HandleInventoryKeybind(GUIBoundKeyEventArgs args, EquipmentSlotDefines.Slots slot)
|
2019-07-23 23:24:47 +02:00
|
|
|
|
{
|
2020-05-05 23:59:31 +02:00
|
|
|
|
if (args.Function == EngineKeyFunctions.UIClick)
|
2019-08-07 15:56:22 -07:00
|
|
|
|
{
|
2020-05-05 23:59:31 +02:00
|
|
|
|
UseItemOnInventory(slot);
|
2019-08-07 15:56:22 -07:00
|
|
|
|
}
|
2019-07-23 23:24:47 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
2020-05-05 23:59:31 +02:00
|
|
|
|
protected void AddToInventory(GUIBoundKeyEventArgs args, EquipmentSlotDefines.Slots slot)
|
2019-07-23 23:24:47 +02:00
|
|
|
|
{
|
2020-05-05 23:59:31 +02:00
|
|
|
|
if (args.Function != EngineKeyFunctions.UIClick)
|
2019-08-07 15:56:22 -07:00
|
|
|
|
{
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
2019-07-23 23:24:47 +02:00
|
|
|
|
|
2020-01-17 06:43:20 -08:00
|
|
|
|
Owner.SendEquipMessage(slot);
|
2019-07-23 23:24:47 +02:00
|
|
|
|
}
|
2019-07-29 13:32:04 -07:00
|
|
|
|
|
2020-05-05 23:59:31 +02:00
|
|
|
|
protected void UseItemOnInventory(EquipmentSlotDefines.Slots slot)
|
2019-08-07 15:56:22 -07:00
|
|
|
|
{
|
2020-01-17 06:43:20 -08:00
|
|
|
|
Owner.SendUseMessage(slot);
|
2019-08-07 15:56:22 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
2020-05-05 23:59:31 +02:00
|
|
|
|
protected void OpenStorage(GUIBoundKeyEventArgs args, EquipmentSlotDefines.Slots slot)
|
2019-07-29 13:32:04 -07:00
|
|
|
|
{
|
2020-05-05 23:59:31 +02:00
|
|
|
|
if (args.Function != EngineKeyFunctions.UIClick && args.Function != ContentKeyFunctions.ActivateItemInWorld)
|
2019-08-07 15:56:22 -07:00
|
|
|
|
{
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
2019-07-29 13:32:04 -07:00
|
|
|
|
|
2020-01-17 06:43:20 -08:00
|
|
|
|
Owner.SendOpenStorageUIMessage(slot);
|
2019-07-29 13:32:04 -07:00
|
|
|
|
}
|
2020-07-26 07:25:38 -05:00
|
|
|
|
|
|
|
|
|
|
protected void RequestItemHover(EquipmentSlotDefines.Slots slot)
|
|
|
|
|
|
{
|
|
|
|
|
|
Owner.SendHoverMessage(slot);
|
|
|
|
|
|
}
|
2019-07-23 23:24:47 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|