Permissions panel.
This commit is contained in:
@@ -58,7 +58,7 @@ namespace Content.Shared.Administration
|
||||
/// <summary>
|
||||
/// Makes you british.
|
||||
/// </summary>
|
||||
Piss = 1 << 9,
|
||||
//Piss = 1 << 9,
|
||||
|
||||
/// <summary>
|
||||
/// Dangerous host permissions like scsi.
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
|
||||
namespace Content.Shared.Administration
|
||||
@@ -11,10 +12,13 @@ namespace Content.Shared.Administration
|
||||
|
||||
public static readonly AdminFlags Everything;
|
||||
|
||||
public static readonly IReadOnlyList<AdminFlags> AllFlags;
|
||||
|
||||
static AdminFlagsExt()
|
||||
{
|
||||
var t = typeof(AdminFlags);
|
||||
var flags = (AdminFlags[]) Enum.GetValues(t);
|
||||
var allFlags = new List<AdminFlags>();
|
||||
|
||||
foreach (var value in flags)
|
||||
{
|
||||
@@ -25,10 +29,13 @@ namespace Content.Shared.Administration
|
||||
continue;
|
||||
}
|
||||
|
||||
allFlags.Add(value);
|
||||
Everything |= value;
|
||||
NameFlagsMap.Add(name, value);
|
||||
FlagsNameMap[BitOperations.Log2((uint) value)] = name;
|
||||
}
|
||||
|
||||
AllFlags = allFlags.ToArray();
|
||||
}
|
||||
|
||||
public static AdminFlags NamesToFlags(IEnumerable<string> names)
|
||||
@@ -69,5 +76,14 @@ namespace Content.Shared.Administration
|
||||
|
||||
return array;
|
||||
}
|
||||
|
||||
public static string PosNegFlagsText(AdminFlags posFlags, AdminFlags negFlags)
|
||||
{
|
||||
var posFlagNames = FlagsToNames(posFlags).Select(f => (flag: f, fText: $"+{f}"));
|
||||
var negFlagNames = FlagsToNames(negFlags).Select(f => (flag: f, fText: $"-{f}"));
|
||||
|
||||
var flagsText = string.Join(' ', posFlagNames.Concat(negFlagNames).OrderBy(f => f.flag).Select(p => p.fText));
|
||||
return flagsText;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
92
Content.Shared/Administration/PermissionsEuiState.cs
Normal file
92
Content.Shared/Administration/PermissionsEuiState.cs
Normal file
@@ -0,0 +1,92 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Content.Shared.Eui;
|
||||
using Robust.Shared.Network;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Administration
|
||||
{
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class PermissionsEuiState : EuiStateBase
|
||||
{
|
||||
public bool IsLoading;
|
||||
|
||||
public AdminData[] Admins;
|
||||
public Dictionary<int, AdminRankData> AdminRanks;
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public struct AdminData
|
||||
{
|
||||
public NetUserId UserId;
|
||||
public string UserName;
|
||||
public string Title;
|
||||
public AdminFlags PosFlags;
|
||||
public AdminFlags NegFlags;
|
||||
public int? RankId;
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public struct AdminRankData
|
||||
{
|
||||
public string Name;
|
||||
public AdminFlags Flags;
|
||||
}
|
||||
}
|
||||
|
||||
public static class PermissionsEuiMsg
|
||||
{
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class Close : EuiMessageBase
|
||||
{
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class AddAdmin : EuiMessageBase
|
||||
{
|
||||
public string UserNameOrId;
|
||||
public string Title;
|
||||
public AdminFlags PosFlags;
|
||||
public AdminFlags NegFlags;
|
||||
public int? RankId;
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class RemoveAdmin : EuiMessageBase
|
||||
{
|
||||
public NetUserId UserId;
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class UpdateAdmin : EuiMessageBase
|
||||
{
|
||||
public NetUserId UserId;
|
||||
public string Title;
|
||||
public AdminFlags PosFlags;
|
||||
public AdminFlags NegFlags;
|
||||
public int? RankId;
|
||||
}
|
||||
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class AddAdminRank : EuiMessageBase
|
||||
{
|
||||
public string Name;
|
||||
public AdminFlags Flags;
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class RemoveAdminRank : EuiMessageBase
|
||||
{
|
||||
public int Id;
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class UpdateAdminRank : EuiMessageBase
|
||||
{
|
||||
public int Id;
|
||||
|
||||
public string Name;
|
||||
public AdminFlags Flags;
|
||||
}
|
||||
}
|
||||
}
|
||||
10
Content.Shared/Eui/EuiMessageBase.cs
Normal file
10
Content.Shared/Eui/EuiMessageBase.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using System;
|
||||
|
||||
namespace Content.Shared.Eui
|
||||
{
|
||||
[Serializable]
|
||||
public abstract class EuiMessageBase
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
11
Content.Shared/Eui/EuiStateBase.cs
Normal file
11
Content.Shared/Eui/EuiStateBase.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using System;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Eui
|
||||
{
|
||||
[Serializable, NetSerializable]
|
||||
public abstract class EuiStateBase
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
55
Content.Shared/Network/NetMessages/MsgEuiCtl.cs
Normal file
55
Content.Shared/Network/NetMessages/MsgEuiCtl.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
using Lidgren.Network;
|
||||
using Robust.Shared.Interfaces.Network;
|
||||
using Robust.Shared.Network;
|
||||
|
||||
namespace Content.Shared.Network.NetMessages
|
||||
{
|
||||
/// <summary>
|
||||
/// Sent server -> client to signal that the client should open an EUI.
|
||||
/// </summary>
|
||||
public sealed class MsgEuiCtl : NetMessage
|
||||
{
|
||||
#region REQUIRED
|
||||
|
||||
public const MsgGroups GROUP = MsgGroups.Command;
|
||||
public const string NAME = nameof(MsgEuiCtl);
|
||||
|
||||
public MsgEuiCtl(INetChannel channel) : base(NAME, GROUP) { }
|
||||
|
||||
#endregion
|
||||
|
||||
public CtlType Type;
|
||||
public string OpenType;
|
||||
public uint Id;
|
||||
|
||||
public override void ReadFromBuffer(NetIncomingMessage buffer)
|
||||
{
|
||||
Id = buffer.ReadUInt32();
|
||||
Type = (CtlType) buffer.ReadByte();
|
||||
switch (Type)
|
||||
{
|
||||
case CtlType.Open:
|
||||
OpenType = buffer.ReadString();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public override void WriteToBuffer(NetOutgoingMessage buffer)
|
||||
{
|
||||
buffer.Write(Id);
|
||||
buffer.Write((byte) Type);
|
||||
switch (Type)
|
||||
{
|
||||
case CtlType.Open:
|
||||
buffer.Write(OpenType);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public enum CtlType : byte
|
||||
{
|
||||
Open,
|
||||
Close
|
||||
}
|
||||
}
|
||||
}
|
||||
48
Content.Shared/Network/NetMessages/MsgEuiMessage.cs
Normal file
48
Content.Shared/Network/NetMessages/MsgEuiMessage.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using Content.Shared.Eui;
|
||||
using Lidgren.Network;
|
||||
using Robust.Shared.Interfaces.Network;
|
||||
using Robust.Shared.Interfaces.Serialization;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Network;
|
||||
|
||||
namespace Content.Shared.Network.NetMessages
|
||||
{
|
||||
public sealed class MsgEuiMessage : NetMessage
|
||||
{
|
||||
#region REQUIRED
|
||||
|
||||
public const MsgGroups GROUP = MsgGroups.Command;
|
||||
public const string NAME = nameof(MsgEuiMessage);
|
||||
|
||||
public MsgEuiMessage(INetChannel channel) : base(NAME, GROUP) { }
|
||||
|
||||
#endregion
|
||||
|
||||
public uint Id;
|
||||
public EuiMessageBase Message;
|
||||
|
||||
public override void ReadFromBuffer(NetIncomingMessage buffer)
|
||||
{
|
||||
Id = buffer.ReadUInt32();
|
||||
|
||||
var ser = IoCManager.Resolve<IRobustSerializer>();
|
||||
var len = buffer.ReadVariableInt32();
|
||||
var stream = buffer.ReadAlignedMemory(len);
|
||||
Message = ser.Deserialize<EuiMessageBase>(stream);
|
||||
}
|
||||
|
||||
public override void WriteToBuffer(NetOutgoingMessage buffer)
|
||||
{
|
||||
buffer.Write(Id);
|
||||
var stream = new MemoryStream();
|
||||
|
||||
var ser = IoCManager.Resolve<IRobustSerializer>();
|
||||
ser.Serialize(stream, Message);
|
||||
var length = (int)stream.Length;
|
||||
buffer.WriteVariableInt32(length);
|
||||
buffer.Write(stream.GetBuffer().AsSpan(0, length));
|
||||
}
|
||||
}
|
||||
}
|
||||
48
Content.Shared/Network/NetMessages/MsgEuiState.cs
Normal file
48
Content.Shared/Network/NetMessages/MsgEuiState.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using Content.Shared.Eui;
|
||||
using Lidgren.Network;
|
||||
using Robust.Shared.Interfaces.Network;
|
||||
using Robust.Shared.Interfaces.Serialization;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Network;
|
||||
|
||||
namespace Content.Shared.Network.NetMessages
|
||||
{
|
||||
public sealed class MsgEuiState : NetMessage
|
||||
{
|
||||
#region REQUIRED
|
||||
|
||||
public const MsgGroups GROUP = MsgGroups.Command;
|
||||
public const string NAME = nameof(MsgEuiState);
|
||||
|
||||
public MsgEuiState(INetChannel channel) : base(NAME, GROUP) { }
|
||||
|
||||
#endregion
|
||||
|
||||
public uint Id;
|
||||
public EuiStateBase State;
|
||||
|
||||
public override void ReadFromBuffer(NetIncomingMessage buffer)
|
||||
{
|
||||
Id = buffer.ReadUInt32();
|
||||
|
||||
var ser = IoCManager.Resolve<IRobustSerializer>();
|
||||
var len = buffer.ReadVariableInt32();
|
||||
var stream = buffer.ReadAlignedMemory(len);
|
||||
State = ser.Deserialize<EuiStateBase>(stream);
|
||||
}
|
||||
|
||||
public override void WriteToBuffer(NetOutgoingMessage buffer)
|
||||
{
|
||||
buffer.Write(Id);
|
||||
var stream = new MemoryStream();
|
||||
|
||||
var ser = IoCManager.Resolve<IRobustSerializer>();
|
||||
ser.Serialize(stream, State);
|
||||
var length = (int)stream.Length;
|
||||
buffer.WriteVariableInt32(length);
|
||||
buffer.Write(stream.GetBuffer().AsSpan(0, length));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user