diff --git a/Content.Client/DeviceLinking/Systems/RandomGateSystem.cs b/Content.Client/DeviceLinking/Systems/RandomGateSystem.cs new file mode 100644 index 0000000000..db0d956c72 --- /dev/null +++ b/Content.Client/DeviceLinking/Systems/RandomGateSystem.cs @@ -0,0 +1,5 @@ +using Content.Shared.DeviceLinking.Systems; + +namespace Content.Client.DeviceLinking.Systems; + +public sealed class RandomGateSystem : SharedRandomGateSystem; diff --git a/Content.Client/DeviceLinking/UI/RandomGateBoundUserInterface.cs b/Content.Client/DeviceLinking/UI/RandomGateBoundUserInterface.cs new file mode 100644 index 0000000000..c8c97b84c6 --- /dev/null +++ b/Content.Client/DeviceLinking/UI/RandomGateBoundUserInterface.cs @@ -0,0 +1,37 @@ +using Content.Shared.DeviceLinking; +using JetBrains.Annotations; +using Robust.Client.UserInterface; + +namespace Content.Client.DeviceLinking.UI; + +[UsedImplicitly] +public sealed class RandomGateBoundUserInterface : BoundUserInterface +{ + private RandomGateSetupWindow? _window; + + public RandomGateBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey) { } + + protected override void Open() + { + base.Open(); + _window = this.CreateWindow(); + _window.OnApplyPressed += OnProbabilityChanged; + } + + private void OnProbabilityChanged(string value) + { + if (!float.TryParse(value, out var probability)) + return; + + SendPredictedMessage(new RandomGateProbabilityChangedMessage(probability)); + } + + protected override void UpdateState(BoundUserInterfaceState state) + { + base.UpdateState(state); + if (state is not RandomGateBoundUserInterfaceState castState || _window == null) + return; + + _window.SetProbability(castState.SuccessProbability * 100); + } +} diff --git a/Content.Client/DeviceLinking/UI/RandomGateSetupWindow.xaml b/Content.Client/DeviceLinking/UI/RandomGateSetupWindow.xaml new file mode 100644 index 0000000000..d9273c9110 --- /dev/null +++ b/Content.Client/DeviceLinking/UI/RandomGateSetupWindow.xaml @@ -0,0 +1,19 @@ + + + + + + +