6
StarHorizon_Public/Content.Client/_NF/LateJoin/Controls/StationOrCrewLargeControl.xaml.cs
2026-01-24 12:49:55 +03:00

59 lines
2.0 KiB
C#

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<Windows.PickerWindow.PickerType>? OnTabChange;
public StationOrCrewLargeControl()
{
RobustXamlLoader.Load(this);
IoCManager.InjectDependencies(this);
_gameTicker = _entitySystem.GetEntitySystem<ClientGameTicker>();
StationButton.OnPressed += StationButtonOnOnPressed;
CrewButton.OnPressed += CrewButtonOnOnPressed;
UpdateUi(_gameTicker.StationJobInformationList);
}
public override void UpdateUi(IReadOnlyDictionary<NetEntity, StationJobInformation> 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);
}
}