* Add ability for admins to change certain cvars via command. * Cleanup * More cleanup. * Even more cleanup. * WAITER! WAITER! ONE MORE COMMIT PLEASE! * Remove requirement for Admin AdminFlag Not needed as the command checks for the perms. * Add search function to CVars and help text * Move to controller instead. * Add another cvar for testing * Remove unused comment * Move to Post Server Initialize LoC does not work at the earlier stages of server initalization * Remove unneeded comment We clear out list so its no longer needed
39 lines
1.1 KiB
C#
39 lines
1.1 KiB
C#
using Content.Shared.Administration;
|
|
using Robust.Shared.Reflection;
|
|
|
|
namespace Content.Shared.CCVar.CVarAccess;
|
|
|
|
/// <summary>
|
|
/// Manages what admin flags can change the cvar value. With optional mins and maxes.
|
|
/// </summary>
|
|
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
|
|
[Reflect(discoverable: true)]
|
|
public sealed class CVarControl : Attribute
|
|
{
|
|
public AdminFlags AdminFlags { get; }
|
|
public object? Min { get; }
|
|
public object? Max { get; }
|
|
|
|
public CVarControl(AdminFlags adminFlags, object? min = null, object? max = null, string? helpText = null)
|
|
{
|
|
AdminFlags = adminFlags;
|
|
Min = min;
|
|
Max = max;
|
|
|
|
// Not actually sure if its a good idea to throw exceptions in attributes.
|
|
|
|
if (min != null && max != null)
|
|
{
|
|
if (min.GetType() != max.GetType())
|
|
{
|
|
throw new ArgumentException("Min and max must be of the same type.");
|
|
}
|
|
}
|
|
|
|
if (min == null && max != null || min != null && max == null)
|
|
{
|
|
throw new ArgumentException("Min and max must both be null or both be set.");
|
|
}
|
|
}
|
|
}
|