2020-08-15 20:33:42 +02:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using Content.Client.UserInterface;
|
|
|
|
|
|
using Content.Shared.GameObjects.Components.GUI;
|
|
|
|
|
|
using JetBrains.Annotations;
|
2021-02-11 01:13:03 -08:00
|
|
|
|
using Robust.Client.GameObjects;
|
2020-08-25 08:54:23 -04:00
|
|
|
|
using Robust.Shared.GameObjects;
|
|
|
|
|
|
using Robust.Shared.Localization;
|
2020-09-13 14:23:52 +02:00
|
|
|
|
using Robust.Shared.ViewVariables;
|
2020-08-15 20:33:42 +02:00
|
|
|
|
using static Content.Shared.GameObjects.Components.Inventory.EquipmentSlotDefines;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Content.Client.GameObjects.Components.HUD.Inventory
|
|
|
|
|
|
{
|
|
|
|
|
|
[UsedImplicitly]
|
|
|
|
|
|
public class StrippableBoundUserInterface : BoundUserInterface
|
|
|
|
|
|
{
|
|
|
|
|
|
public Dictionary<Slots, string> Inventory { get; private set; }
|
|
|
|
|
|
public Dictionary<string, string> Hands { get; private set; }
|
2020-08-25 08:54:23 -04:00
|
|
|
|
public Dictionary<EntityUid, string> Handcuffs { get; private set; }
|
2020-08-15 20:33:42 +02:00
|
|
|
|
|
|
|
|
|
|
[ViewVariables]
|
|
|
|
|
|
private StrippingMenu _strippingMenu;
|
|
|
|
|
|
|
|
|
|
|
|
public StrippableBoundUserInterface(ClientUserInterfaceComponent owner, object uiKey) : base(owner, uiKey)
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected override void Open()
|
|
|
|
|
|
{
|
|
|
|
|
|
base.Open();
|
|
|
|
|
|
|
|
|
|
|
|
_strippingMenu = new StrippingMenu($"{Owner.Owner.Name}'s inventory");
|
2020-08-25 12:44:06 +02:00
|
|
|
|
|
|
|
|
|
|
_strippingMenu.OnClose += Close;
|
2020-08-15 20:33:42 +02:00
|
|
|
|
_strippingMenu.OpenCentered();
|
|
|
|
|
|
UpdateMenu();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected override void Dispose(bool disposing)
|
|
|
|
|
|
{
|
|
|
|
|
|
base.Dispose(disposing);
|
2020-10-06 10:16:42 +02:00
|
|
|
|
if (!disposing)
|
|
|
|
|
|
return;
|
2020-08-15 20:33:42 +02:00
|
|
|
|
|
2020-10-06 10:16:42 +02:00
|
|
|
|
_strippingMenu.Dispose();
|
2020-08-15 20:33:42 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void UpdateMenu()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (_strippingMenu == null) return;
|
|
|
|
|
|
|
|
|
|
|
|
_strippingMenu.ClearButtons();
|
|
|
|
|
|
|
2020-08-25 08:54:23 -04:00
|
|
|
|
if (Inventory != null)
|
|
|
|
|
|
{
|
2020-08-15 20:33:42 +02:00
|
|
|
|
foreach (var (slot, name) in Inventory)
|
|
|
|
|
|
{
|
2020-09-13 14:23:52 +02:00
|
|
|
|
_strippingMenu.AddButton(SlotNames[slot], name, (ev) =>
|
2020-08-15 20:33:42 +02:00
|
|
|
|
{
|
|
|
|
|
|
SendMessage(new StrippingInventoryButtonPressed(slot));
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
2020-08-25 08:54:23 -04:00
|
|
|
|
}
|
2020-08-15 20:33:42 +02:00
|
|
|
|
|
2020-08-25 08:54:23 -04:00
|
|
|
|
if (Hands != null)
|
|
|
|
|
|
{
|
2020-08-15 20:33:42 +02:00
|
|
|
|
foreach (var (hand, name) in Hands)
|
|
|
|
|
|
{
|
|
|
|
|
|
_strippingMenu.AddButton(hand, name, (ev) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
SendMessage(new StrippingHandButtonPressed(hand));
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
2020-08-25 08:54:23 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (Handcuffs != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
foreach (var (id, name) in Handcuffs)
|
|
|
|
|
|
{
|
|
|
|
|
|
_strippingMenu.AddButton(Loc.GetString("Restraints"), name, (ev) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
SendMessage(new StrippingHandcuffButtonPressed(id));
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2020-08-15 20:33:42 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected override void UpdateState(BoundUserInterfaceState state)
|
|
|
|
|
|
{
|
|
|
|
|
|
base.UpdateState(state);
|
|
|
|
|
|
|
2020-11-26 14:33:31 +01:00
|
|
|
|
if (state is not StrippingBoundUserInterfaceState stripState) return;
|
2020-08-15 20:33:42 +02:00
|
|
|
|
|
|
|
|
|
|
Inventory = stripState.Inventory;
|
|
|
|
|
|
Hands = stripState.Hands;
|
2020-08-25 08:54:23 -04:00
|
|
|
|
Handcuffs = stripState.Handcuffs;
|
2020-08-15 20:33:42 +02:00
|
|
|
|
|
|
|
|
|
|
UpdateMenu();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|