mirror of
https://github.com/DeltaV-Station/Delta-v.git
synced 2026-09-30 08:07:28 +00:00
71 lines
2.1 KiB
C#
71 lines
2.1 KiB
C#
using Content.Shared.MachineLinking;
|
|
using Robust.Client.GameObjects;
|
|
using Robust.Client.UserInterface;
|
|
using Robust.Shared.Timing;
|
|
|
|
namespace Content.Client.MachineLinking.UI;
|
|
|
|
public sealed class SignalTimerBoundUserInterface : BoundUserInterface
|
|
{
|
|
[ViewVariables]
|
|
private SignalTimerWindow? _window;
|
|
|
|
public SignalTimerBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
|
|
{
|
|
}
|
|
|
|
protected override void Open()
|
|
{
|
|
base.Open();
|
|
|
|
_window = this.CreateWindow<SignalTimerWindow>();
|
|
_window.OnStartTimer += StartTimer;
|
|
_window.OnCurrentTextChanged += OnTextChanged;
|
|
// Begin Monolith
|
|
// _window.OnCurrentDelayMinutesChanged += OnDelayChanged;
|
|
// _window.OnCurrentDelaySecondsChanged += OnDelayChanged;
|
|
_window.OnCurrentDelayChanged += OnDelayChanged;
|
|
// End Monolith
|
|
}
|
|
|
|
public void StartTimer()
|
|
{
|
|
SendMessage(new SignalTimerStartMessage());
|
|
}
|
|
|
|
private void OnTextChanged(string newText)
|
|
{
|
|
SendMessage(new SignalTimerTextChangedMessage(newText));
|
|
}
|
|
|
|
private void OnDelayChanged(TimeSpan newDelay) // Monolith - Change from string to TimeSpan
|
|
{
|
|
if (_window == null)
|
|
return;
|
|
SendMessage(new SignalTimerDelayChangedMessage(newDelay)); // Mono
|
|
}
|
|
|
|
/// <summary>
|
|
/// Update the UI state based on server-sent info
|
|
/// </summary>
|
|
/// <param name="state"></param>
|
|
protected override void UpdateState(BoundUserInterfaceState state)
|
|
{
|
|
base.UpdateState(state);
|
|
|
|
if (_window == null || state is not SignalTimerBoundUserInterfaceState cast)
|
|
return;
|
|
|
|
_window.SetCurrentText(cast.CurrentText);
|
|
// Begin Monolith
|
|
// _window.SetCurrentDelayMinutes(cast.CurrentDelayMinutes);
|
|
// _window.SetCurrentDelaySeconds(cast.CurrentDelaySeconds);
|
|
_window.SetCurrentDelay(cast.CurrentDelay);
|
|
// End Monolith
|
|
_window.SetShowText(cast.ShowText);
|
|
_window.SetTriggerTime(cast.TriggerTime);
|
|
_window.SetTimerStarted(cast.TimerStarted);
|
|
_window.SetHasAccess(cast.HasAccess);
|
|
}
|
|
}
|