2019-08-07 15:56:22 -07:00
|
|
|
|
using System;
|
2020-12-13 14:28:20 -08:00
|
|
|
|
using System.Collections.Generic;
|
2021-06-09 22:19:39 +02:00
|
|
|
|
using Content.Client.HUD;
|
|
|
|
|
|
using Content.Client.Items.UI;
|
2019-08-07 15:56:22 -07:00
|
|
|
|
using Content.Shared.Input;
|
2021-06-09 22:19:39 +02:00
|
|
|
|
using Content.Shared.Inventory;
|
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;
|
2021-02-11 01:13:03 -08:00
|
|
|
|
using Robust.Shared.GameObjects;
|
2020-05-05 23:59:31 +02:00
|
|
|
|
using Robust.Shared.Input;
|
2019-07-23 23:24:47 +02:00
|
|
|
|
using Robust.Shared.IoC;
|
|
|
|
|
|
|
2021-06-09 22:19:39 +02:00
|
|
|
|
namespace Content.Client.Inventory
|
2019-07-23 23:24:47 +02:00
|
|
|
|
{
|
|
|
|
|
|
public abstract class InventoryInterfaceController : IDisposable
|
|
|
|
|
|
{
|
2020-08-24 14:10:28 +02:00
|
|
|
|
[Dependency] protected readonly IGameHud GameHud = default!;
|
2019-07-23 23:24:47 +02:00
|
|
|
|
|
|
|
|
|
|
protected InventoryInterfaceController(ClientInventoryComponent owner)
|
|
|
|
|
|
{
|
|
|
|
|
|
Owner = owner;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public virtual void Initialize()
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-03-10 14:48:29 +01:00
|
|
|
|
public abstract SS14Window? Window { get; }
|
2019-07-23 23:24:47 +02:00
|
|
|
|
protected ClientInventoryComponent Owner { get; }
|
|
|
|
|
|
|
|
|
|
|
|
public virtual void PlayerAttached()
|
|
|
|
|
|
{
|
2020-08-24 14:10:28 +02:00
|
|
|
|
GameHud.InventoryButtonVisible = true;
|
2019-07-23 23:24:47 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public virtual void PlayerDetached()
|
|
|
|
|
|
{
|
2020-08-24 14:10:28 +02:00
|
|
|
|
GameHud.InventoryButtonVisible = false;
|
2019-07-23 23:24:47 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public virtual void Dispose()
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-12-13 14:28:20 -08:00
|
|
|
|
/// <returns>the button controls associated with the
|
|
|
|
|
|
/// specified slot, if any. Empty if none.</returns>
|
|
|
|
|
|
public abstract IEnumerable<ItemSlotButton> GetItemSlotButtons(EquipmentSlotDefines.Slots slot);
|
|
|
|
|
|
|
2019-07-23 23:24:47 +02:00
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
}
|