2021-06-09 22:19:39 +02:00
|
|
|
using Content.Client.Strip;
|
2022-07-10 18:36:53 -07:00
|
|
|
using Content.Shared.IdentityManagement;
|
2021-06-09 22:19:39 +02:00
|
|
|
using Content.Shared.Strip.Components;
|
2020-08-15 20:33:42 +02:00
|
|
|
using JetBrains.Annotations;
|
2021-02-11 01:13:03 -08:00
|
|
|
using Robust.Client.GameObjects;
|
2020-08-15 20:33:42 +02:00
|
|
|
|
2021-06-09 22:19:39 +02:00
|
|
|
namespace Content.Client.Inventory
|
2020-08-15 20:33:42 +02:00
|
|
|
{
|
|
|
|
|
[UsedImplicitly]
|
2022-02-16 00:23:23 -07:00
|
|
|
public sealed class StrippableBoundUserInterface : BoundUserInterface
|
2020-08-15 20:33:42 +02:00
|
|
|
{
|
2021-12-30 22:56:10 +01:00
|
|
|
public Dictionary<(string ID, string Name), string>? Inventory { get; private set; }
|
2021-03-10 14:48:29 +01:00
|
|
|
public Dictionary<string, string>? Hands { get; private set; }
|
|
|
|
|
public Dictionary<EntityUid, string>? Handcuffs { get; private set; }
|
2022-08-24 10:50:31 -04:00
|
|
|
public Dictionary<EntityUid, string>? Ensnare { get; private set; }
|
2020-08-15 20:33:42 +02:00
|
|
|
|
|
|
|
|
[ViewVariables]
|
2021-03-10 14:48:29 +01:00
|
|
|
private StrippingMenu? _strippingMenu;
|
2020-08-15 20:33:42 +02:00
|
|
|
|
2022-08-21 05:38:30 +12:00
|
|
|
public StrippableBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey)
|
2020-08-15 20:33:42 +02:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void Open()
|
|
|
|
|
{
|
|
|
|
|
base.Open();
|
|
|
|
|
|
2022-07-10 18:36:53 -07:00
|
|
|
var entMan = IoCManager.Resolve<IEntityManager>();
|
|
|
|
|
_strippingMenu = new StrippingMenu($"{Loc.GetString("strippable-bound-user-interface-stripping-menu-title", ("ownerName", Identity.Name(Owner.Owner, entMan)))}");
|
2020-08-25 12:44:06 +02:00
|
|
|
|
|
|
|
|
_strippingMenu.OnClose += Close;
|
2022-07-29 14:13:22 +12:00
|
|
|
_strippingMenu.OpenCenteredLeft();
|
2020-08-15 20:33:42 +02:00
|
|
|
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
|
|
|
|
2021-03-10 14:48:29 +01: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)
|
|
|
|
|
{
|
2021-12-30 22:56:10 +01:00
|
|
|
_strippingMenu.AddButton(slot.Name, name, (ev) =>
|
2020-08-15 20:33:42 +02:00
|
|
|
{
|
2021-12-30 22:56:10 +01:00
|
|
|
SendMessage(new StrippingInventoryButtonPressed(slot.ID));
|
2020-08-15 20:33:42 +02:00
|
|
|
});
|
|
|
|
|
}
|
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)
|
|
|
|
|
{
|
2021-06-21 02:13:54 +02:00
|
|
|
_strippingMenu.AddButton(Loc.GetString("strippable-bound-user-interface-stripping-menu-handcuffs-button"), name, (ev) =>
|
2020-08-25 08:54:23 -04:00
|
|
|
{
|
|
|
|
|
SendMessage(new StrippingHandcuffButtonPressed(id));
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-08-24 10:50:31 -04:00
|
|
|
|
|
|
|
|
if (Ensnare != null)
|
|
|
|
|
{
|
|
|
|
|
foreach (var (id, name) in Ensnare)
|
|
|
|
|
{
|
|
|
|
|
_strippingMenu.AddButton(Loc.GetString("strippable-bound-user-interface-stripping-menu-ensnare-button"), name, (ev) =>
|
|
|
|
|
{
|
|
|
|
|
SendMessage(new StrippingEnsnareButtonPressed(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;
|
2022-08-24 10:50:31 -04:00
|
|
|
Ensnare = stripState.Ensnare;
|
2020-08-15 20:33:42 +02:00
|
|
|
|
|
|
|
|
UpdateMenu();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|