From 8ee150386133cf0718cf57f6d6f8c8b65e0d7e6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Guardia=20Fern=C3=A1ndez?= Date: Wed, 16 Mar 2022 22:58:35 +0100 Subject: [PATCH] Make the admin set OOC and LOOC buttons a toggle (#7152) --- .../Administration/UI/Tabs/ServerTab.xaml | 4 +-- .../Administration/UI/Tabs/ServerTab.xaml.cs | 36 ++++++++++++++++++- Content.Shared/CCVar/CCVars.cs | 4 +-- 3 files changed, 39 insertions(+), 5 deletions(-) diff --git a/Content.Client/Administration/UI/Tabs/ServerTab.xaml b/Content.Client/Administration/UI/Tabs/ServerTab.xaml index 4691a9da9f..57a87dcb83 100644 --- a/Content.Client/Administration/UI/Tabs/ServerTab.xaml +++ b/Content.Client/Administration/UI/Tabs/ServerTab.xaml @@ -7,7 +7,7 @@ Columns="4" > - - + + diff --git a/Content.Client/Administration/UI/Tabs/ServerTab.xaml.cs b/Content.Client/Administration/UI/Tabs/ServerTab.xaml.cs index e76b390aae..24b92e42ce 100644 --- a/Content.Client/Administration/UI/Tabs/ServerTab.xaml.cs +++ b/Content.Client/Administration/UI/Tabs/ServerTab.xaml.cs @@ -1,10 +1,44 @@ -using Robust.Client.AutoGenerated; +using Content.Shared.CCVar; +using Robust.Client.AutoGenerated; using Robust.Client.UserInterface; +using Robust.Client.UserInterface.XAML; +using Robust.Shared.Configuration; namespace Content.Client.Administration.UI.Tabs { [GenerateTypedNameReferences] public sealed partial class ServerTab : Control { + [Dependency] private readonly IConfigurationManager _config = default!; + + public ServerTab() + { + RobustXamlLoader.Load(this); + IoCManager.InjectDependencies(this); + + _config.OnValueChanged(CCVars.OocEnabled, OocEnabledChanged, true); + _config.OnValueChanged(CCVars.LoocEnabled, LoocEnabledChanged, true); + } + + private void OocEnabledChanged(bool value) + { + SetOocButton.Pressed = value; + } + + private void LoocEnabledChanged(bool value) + { + SetLoocButton.Pressed = value; + } + + protected override void Dispose(bool disposing) + { + base.Dispose(disposing); + + if (disposing) + { + _config.UnsubValueChanged(CCVars.OocEnabled, OocEnabledChanged); + _config.UnsubValueChanged(CCVars.LoocEnabled, LoocEnabledChanged); + } + } } } diff --git a/Content.Shared/CCVar/CCVars.cs b/Content.Shared/CCVar/CCVars.cs index 9754c654a8..7a428b222d 100644 --- a/Content.Shared/CCVar/CCVars.cs +++ b/Content.Shared/CCVar/CCVars.cs @@ -507,7 +507,7 @@ namespace Content.Shared.CCVar * OOC */ - public static readonly CVarDef OocEnabled = CVarDef.Create("ooc.enabled", true, CVar.NOTIFY); + public static readonly CVarDef OocEnabled = CVarDef.Create("ooc.enabled", true, CVar.NOTIFY | CVar.REPLICATED); public static readonly CVarDef AdminOocEnabled = CVarDef.Create("ooc.enabled_admin", true, CVar.NOTIFY); @@ -516,7 +516,7 @@ namespace Content.Shared.CCVar * LOOC */ - public static readonly CVarDef LoocEnabled = CVarDef.Create("looc.enabled", true, CVar.NOTIFY); + public static readonly CVarDef LoocEnabled = CVarDef.Create("looc.enabled", true, CVar.NOTIFY | CVar.REPLICATED); public static readonly CVarDef AdminLoocEnabled = CVarDef.Create("looc.enabled_admin", true, CVar.NOTIFY);