* DoAfters * Compact Clone() * Fix mice and cuffables * Try generalize attempt events * moves climbabledoafter event to shared, fixes issue with climbable target * Fix merge (cuffing) * Make all events netserializable * handful of doafter events moved * moves the rest of the events to their respective shared folders * Changes all mentions of server doafter to shared * stop stripping cancellation * fix merge errors * draw paused doafters * handle unpausing * missing netserializable ref * removes break on stun reference * removes cuffing state reference * Fix tools * Fix door prying. * Fix construction * Fix dumping * Fix wielding assert * fix rev * Fix test * more test fixes --------- Co-authored-by: keronshb <keronshb@live.com>
88 lines
2.3 KiB
C#
88 lines
2.3 KiB
C#
using Content.Client.Alerts;
|
|
using Content.Client.Gameplay;
|
|
using Content.Client.UserInterface.Systems.Alerts.Widgets;
|
|
using Content.Client.UserInterface.Systems.Gameplay;
|
|
using Content.Shared.Alert;
|
|
using Robust.Client.UserInterface;
|
|
using Robust.Client.UserInterface.Controllers;
|
|
|
|
namespace Content.Client.UserInterface.Systems.Alerts;
|
|
|
|
public sealed class AlertsUIController : UIController, IOnStateEntered<GameplayState>, IOnSystemChanged<ClientAlertsSystem>
|
|
{
|
|
[UISystemDependency] private readonly ClientAlertsSystem? _alertsSystem = default;
|
|
|
|
private AlertsUI? UI => UIManager.GetActiveUIWidgetOrNull<AlertsUI>();
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
var gameplayStateLoad = UIManager.GetUIController<GameplayStateLoadController>();
|
|
gameplayStateLoad.OnScreenLoad += OnScreenLoad;
|
|
gameplayStateLoad.OnScreenUnload += OnScreenUnload;
|
|
}
|
|
|
|
private void OnScreenUnload()
|
|
{
|
|
var widget = UI;
|
|
if (widget != null)
|
|
widget.AlertPressed -= OnAlertPressed;
|
|
}
|
|
|
|
private void OnScreenLoad()
|
|
{
|
|
var widget = UI;
|
|
if (widget != null)
|
|
widget.AlertPressed += OnAlertPressed;
|
|
|
|
SyncAlerts();
|
|
}
|
|
|
|
private void OnAlertPressed(object? sender, AlertType e)
|
|
{
|
|
_alertsSystem?.AlertClicked(e);
|
|
}
|
|
|
|
private void SystemOnClearAlerts(object? sender, EventArgs e)
|
|
{
|
|
UI?.ClearAllControls();
|
|
}
|
|
|
|
private void SystemOnSyncAlerts(object? sender, IReadOnlyDictionary<AlertKey, AlertState> e)
|
|
{
|
|
if (sender is ClientAlertsSystem system)
|
|
{
|
|
UI?.SyncControls(system, system.AlertOrder, e);
|
|
}
|
|
}
|
|
|
|
public void OnSystemLoaded(ClientAlertsSystem system)
|
|
{
|
|
system.SyncAlerts += SystemOnSyncAlerts;
|
|
system.ClearAlerts += SystemOnClearAlerts;
|
|
}
|
|
|
|
public void OnSystemUnloaded(ClientAlertsSystem system)
|
|
{
|
|
system.SyncAlerts -= SystemOnSyncAlerts;
|
|
system.ClearAlerts -= SystemOnClearAlerts;
|
|
}
|
|
|
|
|
|
public void OnStateEntered(GameplayState state)
|
|
{
|
|
// initially populate the frame if system is available
|
|
SyncAlerts();
|
|
}
|
|
|
|
public void SyncAlerts()
|
|
{
|
|
var alerts = _alertsSystem?.ActiveAlerts;
|
|
if (alerts != null)
|
|
{
|
|
SystemOnSyncAlerts(_alertsSystem, alerts);
|
|
}
|
|
}
|
|
}
|