committed by
GitHub
parent
f99f681815
commit
f57204b872
@@ -1,18 +1,19 @@
|
|||||||
using Content.Client.Changelog;
|
using Content.Client.Changelog;
|
||||||
using Content.Client.Credits;
|
|
||||||
using Content.Client.UserInterface.Systems.EscapeMenu;
|
using Content.Client.UserInterface.Systems.EscapeMenu;
|
||||||
using Content.Shared.CCVar;
|
using Content.Shared.CCVar;
|
||||||
using Robust.Client.UserInterface;
|
using Robust.Client.UserInterface;
|
||||||
using Robust.Client.UserInterface.Controls;
|
using Robust.Client.UserInterface.Controls;
|
||||||
|
using Robust.Shared.Collections;
|
||||||
using Robust.Shared.Configuration;
|
using Robust.Shared.Configuration;
|
||||||
using Robust.Shared.IoC;
|
|
||||||
using Robust.Shared.Localization;
|
|
||||||
using Robust.Shared.Utility;
|
|
||||||
|
|
||||||
namespace Content.Client.Info
|
namespace Content.Client.Info
|
||||||
{
|
{
|
||||||
public sealed class LinkBanner : BoxContainer
|
public sealed class LinkBanner : BoxContainer
|
||||||
{
|
{
|
||||||
|
private readonly IConfigurationManager _cfg;
|
||||||
|
|
||||||
|
private ValueList<(CVarDef<string> cVar, Button button)> _infoLinks;
|
||||||
|
|
||||||
public LinkBanner()
|
public LinkBanner()
|
||||||
{
|
{
|
||||||
var buttons = new BoxContainer
|
var buttons = new BoxContainer
|
||||||
@@ -22,7 +23,7 @@ namespace Content.Client.Info
|
|||||||
AddChild(buttons);
|
AddChild(buttons);
|
||||||
|
|
||||||
var uriOpener = IoCManager.Resolve<IUriOpener>();
|
var uriOpener = IoCManager.Resolve<IUriOpener>();
|
||||||
var cfg = IoCManager.Resolve<IConfigurationManager>();
|
_cfg = IoCManager.Resolve<IConfigurationManager>();
|
||||||
|
|
||||||
var rulesButton = new Button() {Text = Loc.GetString("server-info-rules-button")};
|
var rulesButton = new Button() {Text = Loc.GetString("server-info-rules-button")};
|
||||||
rulesButton.OnPressed += args => new RulesAndInfoWindow().Open();
|
rulesButton.OnPressed += args => new RulesAndInfoWindow().Open();
|
||||||
@@ -39,13 +40,23 @@ namespace Content.Client.Info
|
|||||||
|
|
||||||
void AddInfoButton(string loc, CVarDef<string> cVar)
|
void AddInfoButton(string loc, CVarDef<string> cVar)
|
||||||
{
|
{
|
||||||
var link = cfg.GetCVar(cVar);
|
|
||||||
if (link == "")
|
|
||||||
return;
|
|
||||||
|
|
||||||
var button = new Button { Text = Loc.GetString(loc) };
|
var button = new Button { Text = Loc.GetString(loc) };
|
||||||
button.OnPressed += _ => uriOpener.OpenUri(link);
|
button.OnPressed += _ => uriOpener.OpenUri(_cfg.GetCVar(cVar));
|
||||||
buttons.AddChild(button);
|
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) != "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user