Fix rules popup (#8485)
* CVar to show rules popup for localhost.
For testing purposes.
* Fix rules popup being broken and throwing.
😐
This commit is contained in:
committed by
GitHub
parent
38368d1341
commit
4c1b0b87fb
@@ -1,9 +1,11 @@
|
||||
using Content.Client.EscapeMenu.UI;
|
||||
using Content.Shared.CCVar;
|
||||
using Robust.Client.ResourceManagement;
|
||||
using Robust.Client.UserInterface;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.UserInterface.CustomControls;
|
||||
using Robust.Shared.Configuration;
|
||||
using Robust.Shared.ContentPack;
|
||||
|
||||
namespace Content.Client.Info
|
||||
{
|
||||
@@ -44,7 +46,7 @@ namespace Content.Client.Info
|
||||
|
||||
private void PopulateRules(Info rulesList)
|
||||
{
|
||||
AddSection(rulesList, Loc.GetString("ui-rules-header"), _cfgManager.GetCVar(CCVars.RulesFile), true);
|
||||
AddSection(rulesList, MakeRules(_cfgManager, _resourceManager));
|
||||
}
|
||||
|
||||
private void PopulateTutorial(Info tutorialList)
|
||||
@@ -58,10 +60,24 @@ namespace Content.Client.Info
|
||||
infoControlSection.ControlsButton.OnPressed += _ => optionsMenu.OpenCentered();
|
||||
}
|
||||
|
||||
private static void AddSection(Info info, Control control)
|
||||
{
|
||||
info.InfoContainer.AddChild(control);
|
||||
}
|
||||
|
||||
private void AddSection(Info info, string title, string path, bool markup = false)
|
||||
{
|
||||
info.InfoContainer.AddChild(new InfoSection(title,
|
||||
_resourceManager.ContentFileReadAllText($"/Server Info/{path}"), markup));
|
||||
AddSection(info, MakeSection(title, path, markup, _resourceManager));
|
||||
}
|
||||
|
||||
private static Control MakeSection(string title, string path, bool markup, IResourceManager res)
|
||||
{
|
||||
return new InfoSection(title, res.ContentFileReadAllText($"/Server Info/{path}"), markup);
|
||||
}
|
||||
|
||||
public static Control MakeRules(IConfigurationManager cfg, IResourceManager res)
|
||||
{
|
||||
return MakeSection(Loc.GetString("ui-rules-header"), cfg.GetCVar(CCVars.RulesFile), true, res);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,9 +19,6 @@ public sealed partial class RulesControl : BoxContainer
|
||||
RobustXamlLoader.Load(this);
|
||||
IoCManager.InjectDependencies(this);
|
||||
|
||||
var path = "Server Info/" + _cfgManager.GetCVar(CCVars.RulesFile);
|
||||
|
||||
AddChild(new InfoSection(Loc.GetString("ui-rules-header"),
|
||||
_resourceManager.ContentFileReadAllText(path), true));
|
||||
AddChild(RulesAndInfoWindow.MakeRules(_cfgManager, _resourceManager));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
using System.Net;
|
||||
using Content.Server.Database;
|
||||
using Content.Shared.CCVar;
|
||||
using Content.Shared.Info;
|
||||
using Robust.Shared.Configuration;
|
||||
using Robust.Shared.Network;
|
||||
|
||||
namespace Content.Server.Info;
|
||||
@@ -9,6 +11,7 @@ public sealed class RulesManager : SharedRulesManager
|
||||
{
|
||||
[Dependency] private readonly IServerDbManager _dbManager = default!;
|
||||
[Dependency] private readonly INetManager _netManager = default!;
|
||||
[Dependency] private readonly IConfigurationManager _cfg = default!;
|
||||
|
||||
private static DateTime LastValidReadTime => DateTime.UtcNow - TimeSpan.FromDays(60);
|
||||
|
||||
@@ -22,7 +25,7 @@ public sealed class RulesManager : SharedRulesManager
|
||||
|
||||
private async void OnConnected(object? sender, NetChannelArgs e)
|
||||
{
|
||||
if (IPAddress.IsLoopback(e.Channel.RemoteEndPoint.Address))
|
||||
if (IPAddress.IsLoopback(e.Channel.RemoteEndPoint.Address) && _cfg.GetCVar(CCVars.RulesExemptLocal))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -906,6 +906,13 @@ namespace Content.Shared.CCVar
|
||||
public static readonly CVarDef<float> RulesWaitTime =
|
||||
CVarDef.Create("rules.time", 45f, CVar.SERVER | CVar.REPLICATED);
|
||||
|
||||
/// <summary>
|
||||
/// Don't show rules to localhost/loopback interface.
|
||||
/// </summary>
|
||||
public static readonly CVarDef<bool> RulesExemptLocal =
|
||||
CVarDef.Create("rules.exempt_local", true, CVar.SERVERONLY);
|
||||
|
||||
|
||||
/*
|
||||
* Autogeneration
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user