using Content.Client._NF.LateJoin.Interfaces; using Content.Client.GameTicking.Managers; using Content.Shared.GameTicking; using Robust.Client.AutoGenerated; using Robust.Client.UserInterface.Controls; using Robust.Client.UserInterface.XAML; namespace Content.Client._NF.LateJoin.Controls; [GenerateTypedNameReferences] public sealed partial class StationOrCrewLargeControl : PickerControl { [Dependency] private readonly IEntitySystemManager _entitySystem = default!; private readonly ClientGameTicker _gameTicker; public Action? OnTabChange; public StationOrCrewLargeControl() { RobustXamlLoader.Load(this); IoCManager.InjectDependencies(this); _gameTicker = _entitySystem.GetEntitySystem(); StationButton.OnPressed += StationButtonOnOnPressed; CrewButton.OnPressed += CrewButtonOnOnPressed; UpdateUi(_gameTicker.StationJobInformationList); } public override void UpdateUi(IReadOnlyDictionary obj) { StationButton.Disabled = !StationJobInformationExtensions.IsAnyStationAvailable(obj); NoStationsAvailableLabel.Visible = !StationJobInformationExtensions.IsAnyStationAvailable(obj); CrewButton.Disabled = !StationJobInformationExtensions.IsAnyCrewJobAvailable(obj); NoCrewsAvailableLabel.Visible = !StationJobInformationExtensions.IsAnyCrewJobAvailable(obj); } protected override void EnteredTree() { base.EnteredTree(); _gameTicker.LobbyJobsAvailableUpdated += UpdateUi; } protected override void ExitedTree() { base.ExitedTree(); _gameTicker.LobbyJobsAvailableUpdated -= UpdateUi; } private void StationButtonOnOnPressed(BaseButton.ButtonEventArgs obj) { OnTabChange?.Invoke(Windows.PickerWindow.PickerType.Station); } private void CrewButtonOnOnPressed(BaseButton.ButtonEventArgs obj) { OnTabChange?.Invoke(Windows.PickerWindow.PickerType.Crew); } }