From 6feb10502f7a418429806f2b48ce60871cb21426 Mon Sep 17 00:00:00 2001 From: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Date: Fri, 12 Aug 2022 02:56:26 +1000 Subject: [PATCH] Disable role timer latejoin roles (#10512) On master it will just close the GUI and do nothing if the role timer is not met. This PR just means it shows as disabled and also provides the reason on tooltip as well. --- Content.Client/LateJoin/LateJoinGui.cs | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/Content.Client/LateJoin/LateJoinGui.cs b/Content.Client/LateJoin/LateJoinGui.cs index 966ae6f350..de02f29d02 100644 --- a/Content.Client/LateJoin/LateJoinGui.cs +++ b/Content.Client/LateJoin/LateJoinGui.cs @@ -3,6 +3,7 @@ using Content.Client.CrewManifest; using Content.Client.Eui; using Content.Client.GameTicking.Managers; using Content.Client.HUD.UI; +using Content.Client.Players.PlayTimeTracking; using Content.Shared.CCVar; using Content.Shared.CrewManifest; using Content.Shared.Roles; @@ -70,6 +71,7 @@ namespace Content.Client.LateJoin _jobCategories.Clear(); var gameTicker = EntitySystem.Get(); + var tracker = IoCManager.Resolve(); if (!gameTicker.DisallowedLateJoin && gameTicker.StationNames.Count == 0) Logger.Warning("No stations exist, nothing to display in late-join GUI"); @@ -223,12 +225,8 @@ namespace Content.Client.LateJoin Stretch = TextureRect.StretchMode.KeepCentered }; - if (prototype.Icon != null) - { - var specifier = new SpriteSpecifier.Rsi(new ResourcePath("/Textures/Interface/Misc/job_icons.rsi"), prototype.Icon); - icon.Texture = specifier.Frame0(); - } - + var specifier = new SpriteSpecifier.Rsi(new ResourcePath("/Textures/Interface/Misc/job_icons.rsi"), prototype.Icon); + icon.Texture = specifier.Frame0(); jobSelector.AddChild(icon); var jobLabel = new Label @@ -247,9 +245,16 @@ namespace Content.Client.LateJoin SelectedId?.Invoke((id, jobButton.JobId)); }; - if (value == 0) + string? reason = null; + + if (value == 0 || !tracker.IsAllowed(prototype, out reason)) { jobButton.Disabled = true; + + if (!string.IsNullOrEmpty(reason)) + { + jobButton.ToolTip = reason; + } } _jobButtons[id][prototype.ID] = jobButton;