diff --git a/Content.Client/AlertLevel/AlertLevelDisplaySystem.cs b/Content.Client/AlertLevel/AlertLevelDisplaySystem.cs index 845be2e429..b366ef6207 100644 --- a/Content.Client/AlertLevel/AlertLevelDisplaySystem.cs +++ b/Content.Client/AlertLevel/AlertLevelDisplaySystem.cs @@ -1,22 +1,16 @@ using System.Linq; using Content.Shared.AlertLevel; using Robust.Client.GameObjects; -using Robust.Client.Graphics; -using Robust.Shared.Utility; +using Robust.Shared.Prototypes; namespace Content.Client.AlertLevel; public sealed partial class AlertLevelDisplaySystem : EntitySystem { [Dependency] private SpriteSystem _sprite = default!; + [Dependency] private SharedAppearanceSystem _appearance = default!; - public override void Initialize() - { - base.Initialize(); - - SubscribeLocalEvent(OnAppearanceChange); - } - + [SubscribeLocalEvent] private void OnAppearanceChange(EntityUid uid, AlertLevelDisplayComponent alertLevelDisplay, ref AppearanceChangeEvent args) { if (args.Sprite == null) @@ -25,24 +19,19 @@ public sealed partial class AlertLevelDisplaySystem : EntitySystem } var layer = _sprite.LayerMapReserve((uid, args.Sprite), AlertLevelDisplay.Layer); - if (args.AppearanceData.TryGetValue(AlertLevelDisplay.Powered, out var poweredObject)) + if (_appearance.TryGetData(uid, AlertLevelDisplay.Powered, out var powered, component: args.Component)) { - _sprite.LayerSetVisible((uid, args.Sprite), layer, poweredObject is true); + _sprite.LayerSetVisible((uid, args.Sprite), layer, powered); } - if (!args.AppearanceData.TryGetValue(AlertLevelDisplay.CurrentLevel, out var level)) + if (!_appearance.TryGetData>(uid, AlertLevelDisplay.CurrentLevel, out var level, component: args.Component)) { _sprite.LayerSetRsiState((uid, args.Sprite), layer, alertLevelDisplay.AlertVisuals.Values.First()); return; } - if (alertLevelDisplay.AlertVisuals.TryGetValue((string)level, out var visual)) - { - _sprite.LayerSetRsiState((uid, args.Sprite), layer, visual); - } - else - { - _sprite.LayerSetRsiState((uid, args.Sprite), layer, alertLevelDisplay.AlertVisuals.Values.First()); - } + _sprite.LayerSetRsiState((uid, args.Sprite), + layer, + alertLevelDisplay.AlertVisuals.GetValueOrDefault(level) ?? alertLevelDisplay.AlertVisuals.Values.First()); } } diff --git a/Content.Client/Audio/Midi/MidiFileCollectionManager.cs b/Content.Client/Audio/Midi/MidiFileCollectionManager.cs index 9f84fad30b..0f8308ed8b 100644 --- a/Content.Client/Audio/Midi/MidiFileCollectionManager.cs +++ b/Content.Client/Audio/Midi/MidiFileCollectionManager.cs @@ -15,7 +15,7 @@ public sealed partial class MidiFileCollectionManager : IPostInjectInit /// /// Directory path to use inside UserData for storing MIDIs. /// - private static readonly ResPath UserMidiDirectory = new("/UserMidis/"); + public static readonly ResPath UserMidiDirectory = new("/UserMidis/"); private const string SawmillCategory = "midifilecollection"; diff --git a/Content.Client/Chemistry/Visualizers/SolutionContainerVisualsSystem.cs b/Content.Client/Chemistry/Visualizers/SolutionContainerVisualsSystem.cs index 7d2874bd11..7b39ad514b 100644 --- a/Content.Client/Chemistry/Visualizers/SolutionContainerVisualsSystem.cs +++ b/Content.Client/Chemistry/Visualizers/SolutionContainerVisualsSystem.cs @@ -80,6 +80,10 @@ public sealed partial class SolutionContainerVisualsSystem : VisualizerSystem(); + _menu.OnAnnounce += AnnounceButtonPressed; + _menu.OnBroadcast += BroadcastButtonPressed; + _menu.OnAlertLevel += AlertLevelSelected; + _menu.OnEmergencyLevel += EmergencyShuttleButtonPressed; + } - public CommunicationsConsoleBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey) + public void AlertLevelSelected(ProtoId level) + { + if (_menu!.AlertLevelSelectable) { + // TODO: This does not work until the console UI is predicted and uses component states. + // Also someone decided to send BUI states regularly in an update loop, so this just gets randomly bulldozed until the message reaches the server. + // _menu.CurrentAlertLevel = level; + // _menu.AlertLevelSelectable = false; + // _menu.AlertLevelButton.Disabled = true; + SendMessage(new CommunicationsConsoleSelectAlertLevelMessage(level)); } + } - protected override void Open() + public void EmergencyShuttleButtonPressed() + { + if (_menu!.CountdownStarted) + RecallShuttle(); + else + CallShuttle(); + } + + public void AnnounceButtonPressed(string message) + { + var maxLength = _cfg.GetCVar(CCVars.ChatMaxAnnouncementLength); + var msg = SharedChatSystem.SanitizeAnnouncement(message, maxLength); + SendMessage(new CommunicationsConsoleAnnounceMessage(msg)); + } + + public void BroadcastButtonPressed(string message) + { + SendMessage(new CommunicationsConsoleBroadcastMessage(message)); + } + + public void CallShuttle() + { + SendMessage(new CommunicationsConsoleCallEmergencyShuttleMessage()); + } + + public void RecallShuttle() + { + SendMessage(new CommunicationsConsoleRecallEmergencyShuttleMessage()); + } + + // TODO: Use component states and update in an AfterAutoHandleState subscription + protected override void UpdateState(BoundUserInterfaceState state) + { + base.UpdateState(state); + + if (state is not CommunicationsConsoleInterfaceState commsState) + return; + + var stationUid = _station.GetOwningStation(Owner); + + if (!EntMan.TryGetComponent(stationUid, out var alertComp)) + return; + + if (_menu != null) { - base.Open(); + _menu.CanAnnounce = commsState.CanAnnounce; + _menu.CanBroadcast = commsState.CanBroadcast; + _menu.CanCall = commsState.CanCall; + _menu.CountdownStarted = commsState.CountdownStarted; + _menu.CountdownEnd = commsState.ExpectedCountdownEnd; - _menu = this.CreateWindow(); - _menu.OnAnnounce += AnnounceButtonPressed; - _menu.OnBroadcast += BroadcastButtonPressed; - _menu.OnAlertLevel += AlertLevelSelected; - _menu.OnEmergencyLevel += EmergencyShuttleButtonPressed; - } + _menu.CurrentAlertLevel = alertComp.CurrentAlertLevel; + _menu.SelectableAlertLevels = _alertLevel.GetSelectableAlertLevels((stationUid.Value, alertComp)); + _menu.AlertLevelSelectable = _alertLevel.CanChangeAlertLevel((stationUid.Value, alertComp)); - public void AlertLevelSelected(string level) - { - if (_menu!.AlertLevelSelectable) - { - _menu.CurrentLevel = level; - SendMessage(new CommunicationsConsoleSelectAlertLevelMessage(level)); - } - } + _menu.UpdateCountdown(); + _menu.UpdateAlertLevels(); - public void EmergencyShuttleButtonPressed() - { - if (_menu!.CountdownStarted) - RecallShuttle(); - else - CallShuttle(); - } - - public void AnnounceButtonPressed(string message) - { - var maxLength = _cfg.GetCVar(CCVars.ChatMaxAnnouncementLength); - var msg = SharedChatSystem.SanitizeAnnouncement(message, maxLength); - SendMessage(new CommunicationsConsoleAnnounceMessage(msg)); - } - - public void BroadcastButtonPressed(string message) - { - SendMessage(new CommunicationsConsoleBroadcastMessage(message)); - } - - public void CallShuttle() - { - SendMessage(new CommunicationsConsoleCallEmergencyShuttleMessage()); - } - - public void RecallShuttle() - { - SendMessage(new CommunicationsConsoleRecallEmergencyShuttleMessage()); - } - - protected override void UpdateState(BoundUserInterfaceState state) - { - base.UpdateState(state); - - if (state is not CommunicationsConsoleInterfaceState commsState) - return; - - if (_menu != null) - { - _menu.CanAnnounce = commsState.CanAnnounce; - _menu.CanBroadcast = commsState.CanBroadcast; - _menu.CanCall = commsState.CanCall; - _menu.CountdownStarted = commsState.CountdownStarted; - _menu.AlertLevelSelectable = commsState.AlertLevels != null && !float.IsNaN(commsState.CurrentAlertDelay) && commsState.CurrentAlertDelay <= 0; - _menu.CurrentLevel = commsState.CurrentAlert; - _menu.CountdownEnd = commsState.ExpectedCountdownEnd; - - _menu.UpdateCountdown(); - _menu.UpdateAlertLevels(commsState.AlertLevels, _menu.CurrentLevel); - _menu.AlertLevelButton.Disabled = !_menu.AlertLevelSelectable; - _menu.EmergencyShuttleButton.Disabled = !_menu.CanCall; - _menu.AnnounceButton.Disabled = !_menu.CanAnnounce; - _menu.BroadcastButton.Disabled = !_menu.CanBroadcast; - } + _menu.AlertLevelButton.Disabled = !_menu.AlertLevelSelectable; + _menu.EmergencyShuttleButton.Disabled = !_menu.CanCall; + _menu.AnnounceButton.Disabled = !_menu.CanAnnounce; + _menu.BroadcastButton.Disabled = !_menu.CanBroadcast; } } } diff --git a/Content.Client/Communications/UI/CommunicationsConsoleMenu.xaml.cs b/Content.Client/Communications/UI/CommunicationsConsoleMenu.xaml.cs index 6aa938b2c6..106a3093b9 100644 --- a/Content.Client/Communications/UI/CommunicationsConsoleMenu.xaml.cs +++ b/Content.Client/Communications/UI/CommunicationsConsoleMenu.xaml.cs @@ -1,10 +1,12 @@ using System.Globalization; using Content.Client.UserInterface.Controls; +using Content.Shared.AlertLevel; using Content.Shared.CCVar; using Robust.Client.AutoGenerated; using Robust.Client.UserInterface.XAML; using Robust.Shared.Configuration; using Robust.Shared.Timing; +using Robust.Shared.Prototypes; using Robust.Shared.Utility; namespace Content.Client.Communications.UI @@ -19,13 +21,15 @@ namespace Content.Client.Communications.UI public bool CanAnnounce; public bool CanBroadcast; public bool CanCall; - public bool AlertLevelSelectable; public bool CountdownStarted; - public string CurrentLevel = string.Empty; public TimeSpan? CountdownEnd; + public ProtoId? CurrentAlertLevel; + public List> SelectableAlertLevels = new(); + public bool AlertLevelSelectable; + public event Action? OnEmergencyLevel; - public event Action? OnAlertLevel; + public event Action>? OnAlertLevel; public event Action? OnAnnounce; public event Action? OnBroadcast; @@ -61,7 +65,7 @@ namespace Content.Client.Communications.UI AlertLevelButton.OnItemSelected += args => { var metadata = AlertLevelButton.GetItemMetadata(args.Id); - if (metadata != null && metadata is string cast) + if (metadata != null && metadata is ProtoId cast) { OnAlertLevel?.Invoke(cast); } @@ -78,41 +82,32 @@ namespace Content.Client.Communications.UI { base.FrameUpdate(args); UpdateCountdown(); + // TODO: Countdown for alert level delay } - // The current alert could make levels unselectable, so we need to ensure that the UI reacts properly. - // If the current alert is unselectable, the only item in the alerts list will be - // the current alert. Otherwise, it will be the list of alerts, with the current alert - // selected. - public void UpdateAlertLevels(List? alerts, string currentAlert) + public void UpdateAlertLevels() { AlertLevelButton.Clear(); - if (alerts == null) + if (CurrentAlertLevel == null) + return; + + if (!AlertLevelSelectable) { - var name = currentAlert; - if (_loc.TryGetString($"alert-level-{currentAlert}", out var locName)) - { - name = locName; - } + // selection is locked, only show the current alert + var name = _loc.GetString($"alert-level-{CurrentAlertLevel}"); AlertLevelButton.AddItem(name); - AlertLevelButton.SetItemMetadata(AlertLevelButton.ItemCount - 1, currentAlert); + AlertLevelButton.SetItemMetadata(AlertLevelButton.ItemCount - 1, CurrentAlertLevel); } else { - foreach (var alert in alerts) + foreach (var alert in SelectableAlertLevels) { - var name = alert; - if (_loc.TryGetString($"alert-level-{alert}", out var locName)) - { - name = locName; - } + var name = _loc.GetString($"alert-level-{alert}"); AlertLevelButton.AddItem(name); AlertLevelButton.SetItemMetadata(AlertLevelButton.ItemCount - 1, alert); - if (alert == currentAlert) - { + if (alert == CurrentAlertLevel) AlertLevelButton.Select(AlertLevelButton.ItemCount - 1); - } } } } diff --git a/Content.Client/Entry/EntryPoint.cs b/Content.Client/Entry/EntryPoint.cs index b40593389b..d2404cc5a4 100644 --- a/Content.Client/Entry/EntryPoint.cs +++ b/Content.Client/Entry/EntryPoint.cs @@ -111,7 +111,6 @@ namespace Content.Client.Entry _prototypeManager.RegisterIgnore("utilityQuery"); _prototypeManager.RegisterIgnore("utilityCurvePreset"); - _prototypeManager.RegisterIgnore("accent"); _prototypeManager.RegisterIgnore("gasReaction"); _prototypeManager.RegisterIgnore("seed"); // Seeds prototypes are server-only. _prototypeManager.RegisterIgnore("objective"); diff --git a/Content.Client/Instruments/UI/BandMenu.xaml b/Content.Client/Instruments/UI/BandMenu.xaml deleted file mode 100644 index 620f38fa97..0000000000 --- a/Content.Client/Instruments/UI/BandMenu.xaml +++ /dev/null @@ -1,9 +0,0 @@ - - - -