felinid for admin (#187)
This commit is contained in:
committed by
Aviu00
parent
cc45a18fea
commit
17c8c7070d
@@ -1,10 +1,10 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using Content.Client.Administration.Managers;
|
||||||
using Content.Client.White.Sponsors;
|
using Content.Client.White.Sponsors;
|
||||||
|
using Content.Shared.Administration;
|
||||||
using Content.Shared.Preferences;
|
using Content.Shared.Preferences;
|
||||||
using Robust.Client;
|
using Robust.Client;
|
||||||
using Robust.Shared.IoC;
|
using Robust.Client.Player;
|
||||||
using Robust.Shared.Network;
|
using Robust.Shared.Network;
|
||||||
using Robust.Shared.Utility;
|
using Robust.Shared.Utility;
|
||||||
|
|
||||||
@@ -22,6 +22,8 @@ namespace Content.Client.Preferences
|
|||||||
|
|
||||||
//WD-EDIT
|
//WD-EDIT
|
||||||
[Dependency] private readonly SponsorsManager _sponsorsManager = default!;
|
[Dependency] private readonly SponsorsManager _sponsorsManager = default!;
|
||||||
|
[Dependency] private readonly IPlayerManager _playerManager = default!;
|
||||||
|
[Dependency] private readonly IClientAdminManager _adminManager = default!;
|
||||||
//WD-EDIT
|
//WD-EDIT
|
||||||
|
|
||||||
public event Action? OnServerDataLoaded;
|
public event Action? OnServerDataLoaded;
|
||||||
@@ -67,7 +69,7 @@ namespace Content.Client.Preferences
|
|||||||
{
|
{
|
||||||
//WD-EDIT
|
//WD-EDIT
|
||||||
var allowedMarkings = _sponsorsManager.TryGetInfo(out var sponsor) ? sponsor.AllowedMarkings : new string[]{};
|
var allowedMarkings = _sponsorsManager.TryGetInfo(out var sponsor) ? sponsor.AllowedMarkings : new string[]{};
|
||||||
profile.EnsureValid(allowedMarkings);
|
profile.EnsureValid(allowedMarkings, _adminManager.HasFlag(AdminFlags.AdminSpecies));
|
||||||
//WD-EDIT
|
//WD-EDIT
|
||||||
var characters = new Dictionary<int, ICharacterProfile>(Preferences.Characters) {[slot] = profile};
|
var characters = new Dictionary<int, ICharacterProfile>(Preferences.Characters) {[slot] = profile};
|
||||||
Preferences = new PlayerPreferences(characters, Preferences.SelectedCharacterIndex, Preferences.AdminOOCColor);
|
Preferences = new PlayerPreferences(characters, Preferences.SelectedCharacterIndex, Preferences.AdminOOCColor);
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Numerics;
|
using System.Numerics;
|
||||||
|
using Content.Client.Administration.Managers;
|
||||||
using Content.Client.Humanoid;
|
using Content.Client.Humanoid;
|
||||||
using Content.Client.Lobby.UI;
|
using Content.Client.Lobby.UI;
|
||||||
using Content.Client.Message;
|
using Content.Client.Message;
|
||||||
@@ -7,6 +8,7 @@ using Content.Client.Players.PlayTimeTracking;
|
|||||||
using Content.Client.Stylesheets;
|
using Content.Client.Stylesheets;
|
||||||
using Content.Client.UserInterface.Controls;
|
using Content.Client.UserInterface.Controls;
|
||||||
using Content.Client.White.Sponsors;
|
using Content.Client.White.Sponsors;
|
||||||
|
using Content.Shared.Administration;
|
||||||
using Content.Shared.CCVar;
|
using Content.Shared.CCVar;
|
||||||
using Content.Shared.GameTicking;
|
using Content.Shared.GameTicking;
|
||||||
using Content.Shared.Humanoid;
|
using Content.Shared.Humanoid;
|
||||||
@@ -27,11 +29,13 @@ using Robust.Client.UserInterface.XAML;
|
|||||||
using Robust.Client.Utility;
|
using Robust.Client.Utility;
|
||||||
using Robust.Shared.Configuration;
|
using Robust.Shared.Configuration;
|
||||||
using Robust.Shared.Enums;
|
using Robust.Shared.Enums;
|
||||||
|
using Robust.Shared.Log;
|
||||||
using Robust.Shared.Map;
|
using Robust.Shared.Map;
|
||||||
using Robust.Shared.Prototypes;
|
using Robust.Shared.Prototypes;
|
||||||
using Robust.Shared.Random;
|
using Robust.Shared.Random;
|
||||||
using Robust.Shared.Timing;
|
using Robust.Shared.Timing;
|
||||||
using Robust.Shared.Utility;
|
using Robust.Shared.Utility;
|
||||||
|
using TerraFX.Interop.Windows;
|
||||||
using static Robust.Client.UserInterface.Controls.BoxContainer;
|
using static Robust.Client.UserInterface.Controls.BoxContainer;
|
||||||
using Direction = Robust.Shared.Maths.Direction;
|
using Direction = Robust.Shared.Maths.Direction;
|
||||||
|
|
||||||
@@ -58,6 +62,7 @@ namespace Content.Client.Preferences.UI
|
|||||||
|
|
||||||
//WD-EDIT
|
//WD-EDIT
|
||||||
private readonly SponsorsManager _sponsorsManager;
|
private readonly SponsorsManager _sponsorsManager;
|
||||||
|
private readonly IClientAdminManager _adminManager;
|
||||||
//WD-EDIT
|
//WD-EDIT
|
||||||
|
|
||||||
private readonly IClientPreferencesManager _preferencesManager;
|
private readonly IClientPreferencesManager _preferencesManager;
|
||||||
@@ -128,6 +133,7 @@ namespace Content.Client.Preferences.UI
|
|||||||
{
|
{
|
||||||
RobustXamlLoader.Load(this);
|
RobustXamlLoader.Load(this);
|
||||||
_sponsorsManager = IoCManager.Resolve<SponsorsManager>();
|
_sponsorsManager = IoCManager.Resolve<SponsorsManager>();
|
||||||
|
_adminManager = IoCManager.Resolve<IClientAdminManager>();
|
||||||
_prototypeManager = prototypeManager;
|
_prototypeManager = prototypeManager;
|
||||||
_entMan = entityManager;
|
_entMan = entityManager;
|
||||||
_preferencesManager = preferencesManager;
|
_preferencesManager = preferencesManager;
|
||||||
@@ -208,37 +214,11 @@ namespace Content.Client.Preferences.UI
|
|||||||
#region Species
|
#region Species
|
||||||
|
|
||||||
//WD EDIT
|
//WD EDIT
|
||||||
_speciesList = prototypeManager.EnumeratePrototypes<SpeciesPrototype>().Where(o => o.RoundStart).ToList();
|
_speciesList = GetAllowedSpecies();
|
||||||
|
|
||||||
if (_sponsorsManager.TryGetInfo(out var sponsor))
|
|
||||||
{
|
|
||||||
for (int i = _speciesList.Count - 1; i >= 0; i--)
|
|
||||||
{
|
|
||||||
var specie = _speciesList[i];
|
|
||||||
|
|
||||||
if (specie.SponsorOnly && !sponsor.AllowedMarkings.Contains(specie.ID))
|
|
||||||
{
|
|
||||||
_speciesList.RemoveAt(i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
for (int i = _speciesList.Count - 1; i >= 0; i--)
|
|
||||||
{
|
|
||||||
var specie = _speciesList[i];
|
|
||||||
|
|
||||||
if (specie.SponsorOnly)
|
|
||||||
{
|
|
||||||
_speciesList.RemoveAt(i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//WD EDIT END
|
//WD EDIT END
|
||||||
|
|
||||||
for (var i = 0; i < _speciesList.Count; i++)
|
for (var i = 0; i < _speciesList.Count; i++)
|
||||||
{
|
{
|
||||||
|
|
||||||
var specie = _speciesList[i]; // WD EDIT
|
var specie = _speciesList[i]; // WD EDIT
|
||||||
var name = Loc.GetString(specie.Name);
|
var name = Loc.GetString(specie.Name);
|
||||||
|
|
||||||
@@ -1228,6 +1208,54 @@ namespace Content.Client.Preferences.UI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//WD EDIT
|
||||||
|
private List<SpeciesPrototype> GetAllowedSpecies()
|
||||||
|
{
|
||||||
|
var allowedSpecies = new List<SpeciesPrototype>();
|
||||||
|
|
||||||
|
var rawSpecieList = _prototypeManager.EnumeratePrototypes<SpeciesPrototype>()
|
||||||
|
.Where((specie) =>
|
||||||
|
{
|
||||||
|
if (specie.RoundStart && (specie.SponsorOnly || specie.ForAdmins))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (specie.RoundStart)
|
||||||
|
{
|
||||||
|
allowedSpecies.Add(specie);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}).ToList();
|
||||||
|
|
||||||
|
if (_sponsorsManager.TryGetInfo(out var sponsor))
|
||||||
|
{
|
||||||
|
foreach (var specie in rawSpecieList)
|
||||||
|
{
|
||||||
|
if (specie.SponsorOnly
|
||||||
|
&& sponsor.AllowedMarkings.Contains(specie.ID)
|
||||||
|
&& !allowedSpecies.Contains(specie))
|
||||||
|
{
|
||||||
|
allowedSpecies.Add(specie);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_adminManager.HasFlag(AdminFlags.AdminSpecies))
|
||||||
|
{
|
||||||
|
foreach (var specie in rawSpecieList)
|
||||||
|
{
|
||||||
|
if (specie.ForAdmins && !allowedSpecies.Contains(specie))
|
||||||
|
{
|
||||||
|
allowedSpecies.Add(specie);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return allowedSpecies;
|
||||||
|
}
|
||||||
|
//WD EDIT END
|
||||||
|
|
||||||
private void UpdateJobPriorities()
|
private void UpdateJobPriorities()
|
||||||
{
|
{
|
||||||
foreach (var prioritySelector in _jobPriorities)
|
foreach (var prioritySelector in _jobPriorities)
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ using System.Diagnostics.CodeAnalysis;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Content.Server.Administration.Managers;
|
||||||
using Content.Server.Database;
|
using Content.Server.Database;
|
||||||
using Content.Server.Humanoid;
|
using Content.Server.Humanoid;
|
||||||
using Content.Server.White.Sponsors;
|
using Content.Server.White.Sponsors;
|
||||||
@@ -29,7 +30,9 @@ namespace Content.Server.Preferences.Managers
|
|||||||
[Dependency] private readonly IPrototypeManager _protos = default!;
|
[Dependency] private readonly IPrototypeManager _protos = default!;
|
||||||
|
|
||||||
// WD-EDIT
|
// WD-EDIT
|
||||||
|
[Dependency] private readonly IPlayerManager _playerManager = default!;
|
||||||
[Dependency] private readonly SponsorsManager _sponsors = default!;
|
[Dependency] private readonly SponsorsManager _sponsors = default!;
|
||||||
|
[Dependency] private readonly IAdminManager _adminManager = default!;
|
||||||
// WD-EDIT
|
// WD-EDIT
|
||||||
|
|
||||||
// Cache player prefs on the server so we don't need as much async hell related to them.
|
// Cache player prefs on the server so we don't need as much async hell related to them.
|
||||||
@@ -104,7 +107,14 @@ namespace Content.Server.Preferences.Managers
|
|||||||
|
|
||||||
// WD-EDIT
|
// WD-EDIT
|
||||||
var allowedMarkings = _sponsors.TryGetInfo(message.MsgChannel.UserId, out var sponsor) ? sponsor.AllowedMarkings : new string[]{};
|
var allowedMarkings = _sponsors.TryGetInfo(message.MsgChannel.UserId, out var sponsor) ? sponsor.AllowedMarkings : new string[]{};
|
||||||
profile.EnsureValid(allowedMarkings);
|
|
||||||
|
bool isAdminSpecie = false;
|
||||||
|
if (_playerManager.TryGetSessionById(message.MsgChannel.UserId, out var session))
|
||||||
|
{
|
||||||
|
isAdminSpecie = _adminManager.HasAdminFlag(session, Shared.Administration.AdminFlags.AdminSpecies);
|
||||||
|
}
|
||||||
|
|
||||||
|
profile.EnsureValid(allowedMarkings, isAdminSpecie);
|
||||||
// WD-EDIT
|
// WD-EDIT
|
||||||
|
|
||||||
var profiles = new Dictionary<int, ICharacterProfile>(curPrefs.Characters)
|
var profiles = new Dictionary<int, ICharacterProfile>(curPrefs.Characters)
|
||||||
@@ -204,7 +214,8 @@ namespace Content.Server.Preferences.Managers
|
|||||||
foreach (var (_, profile) in prefs.Characters)
|
foreach (var (_, profile) in prefs.Characters)
|
||||||
{
|
{
|
||||||
var allowedMarkings = _sponsors.TryGetInfo(session.UserId, out var sponsor) ? sponsor.AllowedMarkings : new string[]{};
|
var allowedMarkings = _sponsors.TryGetInfo(session.UserId, out var sponsor) ? sponsor.AllowedMarkings : new string[]{};
|
||||||
profile.EnsureValid(allowedMarkings);
|
bool isAdminSpecie = _adminManager.HasAdminFlag(session, Shared.Administration.AdminFlags.AdminSpecies);
|
||||||
|
profile.EnsureValid(allowedMarkings, isAdminSpecie);
|
||||||
}
|
}
|
||||||
// WD-EDIT
|
// WD-EDIT
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
namespace Content.Shared.Administration
|
namespace Content.Shared.Administration
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Permissions that admins can have.
|
/// Permissions that admins can have.
|
||||||
@@ -94,6 +94,8 @@
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
MeatyOre = 1 << 15,
|
MeatyOre = 1 << 15,
|
||||||
|
|
||||||
|
AdminSpecies = 1 << 16,
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Dangerous host permissions like scsi.
|
/// Dangerous host permissions like scsi.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -128,6 +128,9 @@ public sealed partial class SpeciesPrototype : IPrototype
|
|||||||
|
|
||||||
[DataField("sponsorOnly")]
|
[DataField("sponsorOnly")]
|
||||||
public bool SponsorOnly { get; } = false;
|
public bool SponsorOnly { get; } = false;
|
||||||
|
|
||||||
|
[DataField("forAmins")]
|
||||||
|
public bool ForAdmins { get; } = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum SpeciesNaming : byte
|
public enum SpeciesNaming : byte
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ using Robust.Shared.Prototypes;
|
|||||||
using Robust.Shared.Random;
|
using Robust.Shared.Random;
|
||||||
using Robust.Shared.Serialization;
|
using Robust.Shared.Serialization;
|
||||||
using Robust.Shared.Utility;
|
using Robust.Shared.Utility;
|
||||||
|
using Content.Shared.Administration.Managers;
|
||||||
|
using Content.Shared.Administration;
|
||||||
|
|
||||||
namespace Content.Shared.Preferences
|
namespace Content.Shared.Preferences
|
||||||
{
|
{
|
||||||
@@ -406,7 +408,7 @@ namespace Content.Shared.Preferences
|
|||||||
return Appearance.MemberwiseEquals(other.Appearance);
|
return Appearance.MemberwiseEquals(other.Appearance);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void EnsureValid(string[] sponsorMarkings) //WD-EDIT
|
public void EnsureValid(string[] sponsorMarkings, bool isAdminSpecie) //WD-EDIT
|
||||||
{
|
{
|
||||||
var prototypeManager = IoCManager.Resolve<IPrototypeManager>();
|
var prototypeManager = IoCManager.Resolve<IPrototypeManager>();
|
||||||
|
|
||||||
@@ -416,7 +418,8 @@ namespace Content.Shared.Preferences
|
|||||||
speciesPrototype = prototypeManager.Index<SpeciesPrototype>(Species);
|
speciesPrototype = prototypeManager.Index<SpeciesPrototype>(Species);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (speciesPrototype.SponsorOnly && !sponsorMarkings.Contains(Species))
|
if (speciesPrototype.SponsorOnly && !sponsorMarkings.Contains(Species)
|
||||||
|
&& speciesPrototype.ForAdmins && !isAdminSpecie)
|
||||||
{
|
{
|
||||||
Species = SharedHumanoidAppearanceSystem.DefaultSpecies;
|
Species = SharedHumanoidAppearanceSystem.DefaultSpecies;
|
||||||
speciesPrototype = prototypeManager.Index<SpeciesPrototype>(Species);
|
speciesPrototype = prototypeManager.Index<SpeciesPrototype>(Species);
|
||||||
|
|||||||
@@ -13,6 +13,6 @@ namespace Content.Shared.Preferences
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Makes this profile valid so there's no bad data like negative ages.
|
/// Makes this profile valid so there's no bad data like negative ages.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
void EnsureValid(string[] sponsorMarkings); //WD-EDIT
|
void EnsureValid(string[] sponsorMarkings, bool isAdminSpecie); //WD-EDIT
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
bodyTypes:
|
bodyTypes:
|
||||||
- HumanNormal
|
- HumanNormal
|
||||||
sponsorOnly: true
|
sponsorOnly: true
|
||||||
|
forAmins: true
|
||||||
|
|
||||||
- type: markingPoints
|
- type: markingPoints
|
||||||
id: MobFelinidMarkingLimits
|
id: MobFelinidMarkingLimits
|
||||||
|
|||||||
Reference in New Issue
Block a user