Files
tbd-station-14/Content.Client/Humanoid/HumanoidMarkingModifierBoundUserInterface.cs
metalgearsloth cbf329a82d Remove some BUI boilerplate (#28399)
* Remove some BUI boilerplate

- The disposals overrides got removed due to the helper method handling it.
- Replace window creation with CreateWindow helper.
- Fixed some stinky code which would cause exceptions.

* More

* moar

* weh

* done

* More BUIs

* More updates

* weh

* moar

* look who it is

* weh

* merge

* weh

* fixes
2024-07-20 15:40:16 +10:00

63 lines
1.8 KiB
C#

using Content.Shared.Humanoid;
using Content.Shared.Humanoid.Markings;
using Robust.Client.UserInterface;
namespace Content.Client.Humanoid;
// Marking BUI.
// Do not use this in any non-privileged instance. This just replaces an entire marking set
// with the set sent over.
public sealed class HumanoidMarkingModifierBoundUserInterface : BoundUserInterface
{
[ViewVariables]
private HumanoidMarkingModifierWindow? _window;
public HumanoidMarkingModifierBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}
protected override void Open()
{
base.Open();
_window = this.CreateWindow<HumanoidMarkingModifierWindow>();
_window.OnMarkingAdded += SendMarkingSet;
_window.OnMarkingRemoved += SendMarkingSet;
_window.OnMarkingColorChange += SendMarkingSetNoResend;
_window.OnMarkingRankChange += SendMarkingSet;
_window.OnLayerInfoModified += SendBaseLayer;
_window.OpenCenteredLeft();
}
protected override void UpdateState(BoundUserInterfaceState state)
{
base.UpdateState(state);
if (_window == null || state is not HumanoidMarkingModifierState cast)
{
return;
}
_window.SetState(cast.MarkingSet, cast.Species, cast.Sex, cast.SkinColor, cast.CustomBaseLayers);
}
private void SendMarkingSet(MarkingSet set)
{
SendMessage(new HumanoidMarkingModifierMarkingSetMessage(set, true));
}
private void SendMarkingSetNoResend(MarkingSet set)
{
SendMessage(new HumanoidMarkingModifierMarkingSetMessage(set, false));
}
private void SendBaseLayer(HumanoidVisualLayers layer, CustomBaseLayerInfo? info)
{
SendMessage(new HumanoidMarkingModifierBaseLayersSetMessage(layer, info, true));
}
}