2021-06-21 02:13:54 +02:00
|
|
|
using System.Collections.Generic;
|
2021-06-09 22:19:39 +02:00
|
|
|
using Content.Client.Strip;
|
|
|
|
|
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-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;
|
2021-06-09 22:19:39 +02:00
|
|
|
using static Content.Shared.Inventory.EquipmentSlotDefines;
|
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]
|
|
|
|
|
public class StrippableBoundUserInterface : BoundUserInterface
|
|
|
|
|
{
|
2021-03-10 14:48:29 +01:00
|
|
|
public Dictionary<Slots, string>? Inventory { get; private set; }
|
|
|
|
|
public Dictionary<string, string>? Hands { get; private set; }
|
|
|
|
|
public Dictionary<EntityUid, string>? Handcuffs { 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
|
|
|
|
|
|
|
|
public StrippableBoundUserInterface(ClientUserInterfaceComponent owner, object uiKey) : base(owner, uiKey)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void Open()
|
|
|
|
|
{
|
|
|
|
|
base.Open();
|
|
|
|
|
|
2021-06-21 02:13:54 +02:00
|
|
|
_strippingMenu = new StrippingMenu($"{Loc.GetString("strippable-bound-user-interface-stripping-menu-title",("ownerName", Owner.Owner.Name))}");
|
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
|
|
|
|
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)
|
|
|
|
|
{
|
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)
|
|
|
|
|
{
|
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));
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
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();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|