diff --git a/Content.Client/LateJoin/LateJoinGui.cs b/Content.Client/LateJoin/LateJoinGui.cs index 7e9b72acf4..3d87e39875 100644 --- a/Content.Client/LateJoin/LateJoinGui.cs +++ b/Content.Client/LateJoin/LateJoinGui.cs @@ -5,10 +5,10 @@ using Content.Client.Players.PlayTimeTracking; using Content.Shared.CCVar; using Content.Shared.Roles; using Robust.Client.Console; +using Robust.Client.GameObjects; using Robust.Client.UserInterface; using Robust.Client.UserInterface.Controls; using Robust.Client.UserInterface.CustomControls; -using Robust.Client.Utility; using Robust.Shared.Configuration; using Robust.Shared.Prototypes; using Robust.Shared.Utility; @@ -21,9 +21,15 @@ namespace Content.Client.LateJoin [Dependency] private readonly IPrototypeManager _prototypeManager = default!; [Dependency] private readonly IClientConsoleHost _consoleHost = default!; [Dependency] private readonly IConfigurationManager _configManager = default!; + [Dependency] private readonly IEntitySystemManager _entitySystem = default!; + [Dependency] private readonly PlayTimeTrackingManager _playTimeTracking = default!; public event Action<(EntityUid, string)> SelectedId; + private readonly ClientGameTicker _gameTicker; + private readonly SpriteSystem _sprites; + private readonly CrewManifestSystem _crewManifest; + private readonly Dictionary> _jobButtons = new(); private readonly Dictionary> _jobCategories = new(); private readonly List _jobLists = new(); @@ -34,15 +40,16 @@ namespace Content.Client.LateJoin { MinSize = SetSize = (360, 560); IoCManager.InjectDependencies(this); + _sprites = _entitySystem.GetEntitySystem(); + _crewManifest = _entitySystem.GetEntitySystem(); + _gameTicker = _entitySystem.GetEntitySystem(); - var gameTicker = EntitySystem.Get(); Title = Loc.GetString("late-join-gui-title"); _base = new BoxContainer() { Orientation = LayoutOrientation.Vertical, VerticalExpand = true, - Margin = new Thickness(0), }; Contents.AddChild(_base); @@ -57,7 +64,7 @@ namespace Content.Client.LateJoin Close(); }; - gameTicker.LobbyJobsAvailableUpdated += JobsAvailableUpdated; + _gameTicker.LobbyJobsAvailableUpdated += JobsAvailableUpdated; } private void RebuildUI() @@ -67,17 +74,15 @@ namespace Content.Client.LateJoin _jobButtons.Clear(); _jobCategories.Clear(); - var gameTicker = EntitySystem.Get(); - var tracker = IoCManager.Resolve(); - - if (!gameTicker.DisallowedLateJoin && gameTicker.StationNames.Count == 0) + if (!_gameTicker.DisallowedLateJoin && _gameTicker.StationNames.Count == 0) Logger.Warning("No stations exist, nothing to display in late-join GUI"); - foreach (var (id, name) in gameTicker.StationNames) + foreach (var (id, name) in _gameTicker.StationNames) { var jobList = new BoxContainer { - Orientation = LayoutOrientation.Vertical + Orientation = LayoutOrientation.Vertical, + Margin = new Thickness(0, 0, 5f, 0), }; var collapseButton = new ContainerButton() @@ -98,7 +103,8 @@ namespace Content.Client.LateJoin _base.AddChild(new StripeBack() { - Children = { + Children = + { new PanelContainer() { Children = @@ -115,16 +121,13 @@ namespace Content.Client.LateJoin } }); - if (_configManager.GetCVar(CCVars.CrewManifestWithoutEntity)) + if (_configManager.GetCVar(CCVars.CrewManifestWithoutEntity)) { var crewManifestButton = new Button() { Text = Loc.GetString("crew-manifest-button-label") }; - crewManifestButton.OnPressed += args => - { - EntitySystem.Get().RequestCrewManifest(id); - }; + crewManifestButton.OnPressed += _ => _crewManifest.RequestCrewManifest(id); _base.AddChild(crewManifestButton); } @@ -159,7 +162,7 @@ namespace Content.Client.LateJoin var departmentName = Loc.GetString($"department-{department.ID}"); _jobCategories[id] = new Dictionary(); _jobButtons[id] = new Dictionary(); - var stationAvailable = gameTicker.JobsAvailable[id]; + var stationAvailable = _gameTicker.JobsAvailable[id]; var category = new BoxContainer { @@ -199,7 +202,9 @@ namespace Content.Client.LateJoin foreach (var jobId in department.Roles) { - if (!stationAvailable.ContainsKey(jobId)) continue; + if (!stationAvailable.ContainsKey(jobId)) + continue; + jobsAvailable.Add(_prototypeManager.Index(jobId)); } @@ -223,28 +228,24 @@ namespace Content.Client.LateJoin }; var specifier = new SpriteSpecifier.Rsi(new ResourcePath("/Textures/Interface/Misc/job_icons.rsi"), prototype.Icon); - icon.Texture = specifier.Frame0(); + icon.Texture = _sprites.Frame0(specifier); jobSelector.AddChild(icon); var jobLabel = new Label { + Margin = new Thickness(5f, 0, 0, 0), Text = value != null ? Loc.GetString("late-join-gui-job-slot-capped", ("jobName", prototype.LocalizedName), ("amount", value)) : - Loc.GetString("late-join-gui-job-slot-uncapped", ("jobName", prototype.LocalizedName)) + Loc.GetString("late-join-gui-job-slot-uncapped", ("jobName", prototype.LocalizedName)), }; jobSelector.AddChild(jobLabel); jobButton.AddChild(jobSelector); category.AddChild(jobButton); - jobButton.OnPressed += _ => - { - SelectedId?.Invoke((id, jobButton.JobId)); - }; + jobButton.OnPressed += _ => SelectedId.Invoke((id, jobButton.JobId)); - string? reason = null; - - if (!tracker.IsAllowed(prototype, out reason)) + if (!_playTimeTracking.IsAllowed(prototype, out var reason)) { jobButton.Disabled = true; @@ -252,6 +253,15 @@ namespace Content.Client.LateJoin { jobButton.ToolTip = reason; } + + jobSelector.AddChild(new TextureRect + { + TextureScale = (0.4f, 0.4f), + Stretch = TextureRect.StretchMode.KeepCentered, + Texture = _sprites.Frame0(new SpriteSpecifier.Texture(new ResourcePath("/Textures/Interface/Nano/lock.svg.192dpi.png"))), + HorizontalExpand = true, + HorizontalAlignment = HAlignment.Right, + }); } else if (value == 0) { @@ -275,7 +285,7 @@ namespace Content.Client.LateJoin if (disposing) { - EntitySystem.Get().LobbyJobsAvailableUpdated -= JobsAvailableUpdated; + _gameTicker.LobbyJobsAvailableUpdated -= JobsAvailableUpdated; _jobButtons.Clear(); _jobCategories.Clear(); } diff --git a/Resources/Locale/en-US/late-join/late-join-gui.ftl b/Resources/Locale/en-US/late-join/late-join-gui.ftl index 56e53fd034..ae3b252056 100644 --- a/Resources/Locale/en-US/late-join/late-join-gui.ftl +++ b/Resources/Locale/en-US/late-join/late-join-gui.ftl @@ -2,4 +2,4 @@ late-join-gui-title = Late Join late-join-gui-jobs-amount-in-department-tooltip = Jobs in the {$departmentName} department late-join-gui-department-jobs-label = {$departmentName} jobs late-join-gui-job-slot-capped = {$jobName} ({$amount} open) -late-join-gui-job-slot-uncapped = {$jobName} (No limit) +late-join-gui-job-slot-uncapped = {$jobName} (∞ open)