diff --git a/Content.Client/Info/LinkBanner.cs b/Content.Client/Info/LinkBanner.cs index 569cbc9095..4d8059df89 100644 --- a/Content.Client/Info/LinkBanner.cs +++ b/Content.Client/Info/LinkBanner.cs @@ -1,18 +1,19 @@ using Content.Client.Changelog; -using Content.Client.Credits; using Content.Client.UserInterface.Systems.EscapeMenu; using Content.Shared.CCVar; using Robust.Client.UserInterface; using Robust.Client.UserInterface.Controls; +using Robust.Shared.Collections; using Robust.Shared.Configuration; -using Robust.Shared.IoC; -using Robust.Shared.Localization; -using Robust.Shared.Utility; namespace Content.Client.Info { public sealed class LinkBanner : BoxContainer { + private readonly IConfigurationManager _cfg; + + private ValueList<(CVarDef cVar, Button button)> _infoLinks; + public LinkBanner() { var buttons = new BoxContainer @@ -22,7 +23,7 @@ namespace Content.Client.Info AddChild(buttons); var uriOpener = IoCManager.Resolve(); - var cfg = IoCManager.Resolve(); + _cfg = IoCManager.Resolve(); var rulesButton = new Button() {Text = Loc.GetString("server-info-rules-button")}; rulesButton.OnPressed += args => new RulesAndInfoWindow().Open(); @@ -39,13 +40,23 @@ namespace Content.Client.Info void AddInfoButton(string loc, CVarDef cVar) { - var link = cfg.GetCVar(cVar); - if (link == "") - return; - var button = new Button { Text = Loc.GetString(loc) }; - button.OnPressed += _ => uriOpener.OpenUri(link); + button.OnPressed += _ => uriOpener.OpenUri(_cfg.GetCVar(cVar)); buttons.AddChild(button); + _infoLinks.Add((cVar, button)); + } + } + + protected override void EnteredTree() + { + // LinkBanner is constructed before the client even connects to the server due to UI refactor stuff. + // We need to update these buttons when the UI is shown. + + base.EnteredTree(); + + foreach (var (cVar, link) in _infoLinks) + { + link.Visible = _cfg.GetCVar(cVar) != ""; } } }