Skip to content

Commit

Permalink
Улучшение спонсорки (#282)
Browse files Browse the repository at this point in the history
* улучшение спонсорки
  • Loading branch information
SpicyDarkFox authored Oct 16, 2024
1 parent 555ac27 commit d820d14
Show file tree
Hide file tree
Showing 13 changed files with 130 additions and 195 deletions.
5 changes: 4 additions & 1 deletion Content.Client/LateJoin/LateJoinGui.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
using Robust.Shared.Utility;
using static Robust.Client.UserInterface.Controls.BoxContainer;
using Robust.Shared.Player;
using Robust.Client.Player;
#if LPP_Sponsors
using Content.Client._LostParadise.Sponsors;
#endif
Expand All @@ -29,6 +30,7 @@ namespace Content.Client.LateJoin
{
public sealed class LateJoinGui : DefaultWindow
{
[Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly IClientConsoleHost _consoleHost = default!;
[Dependency] private readonly IConfigurationManager _configManager = default!;
Expand Down Expand Up @@ -95,6 +97,7 @@ private void RebuildUI()
var sponsorTier = 0;
if (sys.TryGetInfo(out var sponsorInfo))
sponsorTier = sponsorInfo.Tier;
var uuid = _playerManager.LocalUser != null ? _playerManager.LocalUser.ToString() ?? "" : "";
#endif

if (!_gameTicker.DisallowedLateJoin && _gameTicker.StationNames.Count == 0)
Expand Down Expand Up @@ -286,7 +289,7 @@ private void RebuildUI()
_configManager,
out var reasons
#if LPP_Sponsors
, 0, sponsorTier
, 0, sponsorTier, uuid
#endif
))
{
Expand Down
9 changes: 8 additions & 1 deletion Content.Client/Preferences/UI/AntagPreferenceSelector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,13 @@
using Content.Shared.Customization.Systems;
using Content.Shared.Preferences;
using Content.Shared.Roles;
using System.Linq;
using System.Numerics;
using Robust.Shared.Configuration;
using Robust.Shared.Prototypes;
using Robust.Shared.Player;
using Robust.Client.Player;

#if LPP_Sponsors
using Content.Client._LostParadise.Sponsors;
#endif
Expand All @@ -12,6 +17,7 @@ namespace Content.Client.Preferences.UI;

public sealed class AntagPreferenceSelector : RequirementsSelector<AntagPrototype>
{
[Dependency] private readonly IPlayerManager _playerManager = default!;
// 0 is yes and 1 is no
public bool Preference
{
Expand Down Expand Up @@ -48,6 +54,7 @@ public AntagPreferenceSelector(AntagPrototype proto, JobPrototype highJob) : bas
var sponsorTier = 0;
if (sys.TryGetInfo(out var sponsorInfo))
sponsorTier = sponsorInfo.Tier;
var uuid = "";//_playerManager.LocalUser != null ? _playerManager.LocalUser.ToString() ?? "" : "";
#endif

if (proto.Requirements != null
Expand All @@ -63,7 +70,7 @@ public AntagPreferenceSelector(AntagPrototype proto, JobPrototype highJob) : bas
configMan,
out var reasons
#if LPP_Sponsors
, 0, sponsorTier
, 0, sponsorTier, uuid
#endif
))
LockRequirements(characterReqs.GetRequirementsText(reasons));
Expand Down
16 changes: 12 additions & 4 deletions Content.Client/Preferences/UI/HumanoidProfileEditor.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
using Robust.Shared.Physics;
using Robust.Shared.Prototypes;
using Robust.Shared.Utility;
using Robust.Shared.Player;
using Robust.Client.Player;
using Direction = Robust.Shared.Maths.Direction;
#if LPP_Sponsors
using Content.Client._LostParadise.Sponsors;
Expand All @@ -41,6 +43,7 @@ namespace Content.Client.Preferences.UI
[GenerateTypedNameReferences]
public sealed partial class HumanoidProfileEditor : BoxContainer
{
private readonly IPlayerManager _playerManager;
private readonly IEntityManager _entityManager;
private readonly IPrototypeManager _prototypeManager;
private readonly IClientPreferencesManager _preferencesManager;
Expand Down Expand Up @@ -121,6 +124,7 @@ public HumanoidProfileEditor(IClientPreferencesManager preferencesManager, IProt
IConfigurationManager configurationManager)
{
RobustXamlLoader.Load(this);
_playerManager = IoCManager.Resolve<IPlayerManager>();
_entityManager = IoCManager.Resolve<IEntityManager>();
_prototypeManager = prototypeManager;
_preferencesManager = preferencesManager;
Expand Down Expand Up @@ -734,6 +738,7 @@ private void UpdateRoleRequirements()
var sponsorTier = 0;
if (sys.TryGetInfo(out var sponsorInfo))
sponsorTier = sponsorInfo.Tier;
var uuid = _playerManager.LocalUser != null ? _playerManager.LocalUser.ToString() ?? "" : "";
#endif

var departments = _prototypeManager.EnumeratePrototypes<DepartmentPrototype>().ToArray();
Expand Down Expand Up @@ -804,7 +809,7 @@ private void UpdateRoleRequirements()
_configurationManager,
out var reasons
#if LPP_Sponsors
, 0, sponsorTier
, 0, sponsorTier, uuid
#endif
))
selector.LockRequirements(_characterRequirementsSystem.GetRequirementsText(reasons));
Expand Down Expand Up @@ -854,6 +859,7 @@ private void EnsureJobRequirementsValid()
var sponsorTier = 0;
if (sys.TryGetInfo(out var sponsorInfo))
sponsorTier = sponsorInfo.Tier;
var uuid = _playerManager.LocalUser != null ? _playerManager.LocalUser.ToString() ?? "" : "";
#endif
foreach (var selector in _jobPriorities)
{
Expand All @@ -870,7 +876,7 @@ private void EnsureJobRequirementsValid()
_configurationManager,
out _
#if LPP_Sponsors
, 0, sponsorTier
, 0, sponsorTier, uuid
#endif
))
continue;
Expand Down Expand Up @@ -1508,6 +1514,7 @@ private void UpdateTraits(bool showUnusable)
var sponsorTier = 0;
if (sys.TryGetInfo(out var sponsorInfo))
sponsorTier = sponsorInfo.Tier;
var uuid = _playerManager.LocalUser != null ? _playerManager.LocalUser.ToString() ?? "" : "";
#endif

_traits.Clear();
Expand All @@ -1525,7 +1532,7 @@ private void UpdateTraits(bool showUnusable)
_configurationManager,
out _
#if LPP_Sponsors
, 0, sponsorTier
, 0, sponsorTier, uuid
#endif
);
_traits.Add(trait, usable);
Expand Down Expand Up @@ -1824,6 +1831,7 @@ private void UpdateLoadouts(bool showUnusable)
var sponsorTier = 0;
if (sys.TryGetInfo(out var sponsorInfo))
sponsorTier = sponsorInfo.Tier;
var uuid = _playerManager.LocalUser != null ? _playerManager.LocalUser.ToString() ?? "" : "";
#endif

// Get the highest priority job to use for loadout filtering
Expand All @@ -1844,7 +1852,7 @@ private void UpdateLoadouts(bool showUnusable)
_configurationManager,
out _
#if LPP_Sponsors
, 0, sponsorTier
, 0, sponsorTier, uuid
#endif
);
_loadouts.Add(loadout, usable);
Expand Down
8 changes: 7 additions & 1 deletion Content.Client/Preferences/UI/LoadoutPreferenceSelector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
using Robust.Shared.Map;
using Robust.Shared.Prototypes;
using Robust.Shared.Utility;
using Robust.Shared.Player;
using Robust.Client.Player;
#if LPP_Sponsors
using Content.Client._LostParadise.Sponsors;
#endif
Expand All @@ -23,6 +25,7 @@ namespace Content.Client.Preferences.UI;

public sealed class LoadoutPreferenceSelector : Control
{
private readonly IPlayerManager _playerManager;
public LoadoutPrototype Loadout { get; }

public bool Valid;
Expand Down Expand Up @@ -66,6 +69,8 @@ public LoadoutPreferenceSelector(LoadoutPrototype loadout, JobPrototype highJob,
IEntityManager entityManager, IPrototypeManager prototypeManager, IConfigurationManager configManager,
CharacterRequirementsSystem characterRequirementsSystem, JobRequirementsManager jobRequirementsManager)
{
_playerManager = IoCManager.Resolve<IPlayerManager>();

Loadout = loadout;

SpriteView previewLoadout;
Expand Down Expand Up @@ -152,6 +157,7 @@ public LoadoutPreferenceSelector(LoadoutPrototype loadout, JobPrototype highJob,
var sponsorTier = 0;
if (sys.TryGetInfo(out var sponsorInfo))
sponsorTier = sponsorInfo.Tier;
var uuid = _playerManager.LocalUser != null ? _playerManager.LocalUser.ToString() ?? "" : "";
#endif

// Get requirement reasons
Expand All @@ -161,7 +167,7 @@ public LoadoutPreferenceSelector(LoadoutPrototype loadout, JobPrototype highJob,
entityManager, prototypeManager, configManager,
out var reasons
#if LPP_Sponsors
, 0, sponsorTier
, 0, sponsorTier, uuid
#endif
);

Expand Down
10 changes: 9 additions & 1 deletion Content.Client/Preferences/UI/TraitPreferenceSelector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
using Robust.Shared.Configuration;
using Robust.Shared.Prototypes;
using Robust.Shared.Utility;
using Robust.Shared.Player;
using Robust.Client.Player;
using System.Linq;
#if LPP_Sponsors
using Content.Client._LostParadise.Sponsors;
#endif
Expand All @@ -19,6 +22,8 @@ namespace Content.Client.Preferences.UI;

public sealed class TraitPreferenceSelector : Control
{
private readonly IPlayerManager _playerManager;

public TraitPrototype Trait { get; }

public bool Valid;
Expand Down Expand Up @@ -48,6 +53,8 @@ public TraitPreferenceSelector(TraitPrototype trait, JobPrototype highJob, Human
IEntityManager entityManager, IPrototypeManager prototypeManager, IConfigurationManager configManager,
CharacterRequirementsSystem characterRequirementsSystem, JobRequirementsManager jobRequirementsManager)
{
_playerManager = IoCManager.Resolve<IPlayerManager>();

Trait = trait;

// Create a checkbox to get the loadout
Expand Down Expand Up @@ -89,6 +96,7 @@ public TraitPreferenceSelector(TraitPrototype trait, JobPrototype highJob, Human
var sponsorTier = 0;
if (sys.TryGetInfo(out var sponsorInfo))
sponsorTier = sponsorInfo.Tier;
var uuid = _playerManager.LocalUser != null ? _playerManager.LocalUser.ToString() ?? "" : "";
#endif

// Get requirement reasons
Expand All @@ -98,7 +106,7 @@ public TraitPreferenceSelector(TraitPrototype trait, JobPrototype highJob, Human
entityManager, prototypeManager, configManager,
out var reasons
#if LPP_Sponsors
, 0, sponsorTier
, 0, sponsorTier, uuid
#endif
);

Expand Down
12 changes: 9 additions & 3 deletions Content.Server/Chat/Managers/ChatManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -243,14 +243,20 @@ private void SendOOC(ICommonSession player, string message)
return;
}

var wrappedMessage = Loc.GetString("chat-manager-send-ooc-wrap-message", ("playerName",player.Name), ("message", FormattedMessage.EscapeText(message)));
Color? colorOverride = null;
var wrappedMessage = Loc.GetString("chat-manager-send-ooc-wrap-message", ("playerName", player.Name), ("message", FormattedMessage.EscapeText(message)));
if (_adminManager.HasAdminFlag(player, AdminFlags.Admin))
{
var prefs = _preferencesManager.GetPreferences(player.UserId);
colorOverride = prefs.AdminOOCColor;
}
if (_netConfigManager.GetClientCVar(player.Channel, CCVars.ShowOocPatronColor) && player.Channel.UserData.PatronTier is { } patron && PatronOocColors.TryGetValue(patron, out var patronColor))
{
wrappedMessage = Loc.GetString("chat-manager-send-ooc-patron-wrap-message", ("patronColor", patronColor),("playerName", player.Name), ("message", FormattedMessage.EscapeText(message)));
wrappedMessage = Loc.GetString("chat-manager-send-ooc-patron-wrap-message", ("patronColor", patronColor), ("playerName", player.Name), ("message", FormattedMessage.EscapeText(message)));
}

#if LPP_Sponsors // _LostParadise-Sponsors
if (_sponsorsManager.TryGetInfo(player.UserId, out var sponsorData) && sponsorData.OOCColor != null)
if (_sponsorsManager.TryGetInfo(player.UserId, out var sponsorData) && sponsorData.Tier > 0)
{
wrappedMessage = Loc.GetString("chat-manager-send-ooc-patron-wrap-message", ("patronColor", sponsorData.OOCColor), ("playerName", player.Name), ("message", FormattedMessage.EscapeText(message)));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ public bool IsAllowed(ICommonSession player, string role)

#if LPP_Sponsors
var sponsorTier = _checkSponsor.CheckUser(player.UserId).Item2 ?? 0;
var uuid = player.UserId.ToString();
#endif

return _characterRequirements.CheckRequirementsValid(
Expand All @@ -201,7 +202,7 @@ public bool IsAllowed(ICommonSession player, string role)
_config,
out _
#if LPP_Sponsors
, 0, sponsorTier
, 0, sponsorTier, uuid
#endif
);
}
Expand All @@ -222,6 +223,7 @@ public HashSet<string> GetDisallowedJobs(ICommonSession player)

#if LPP_Sponsors
var sponsorTier = _checkSponsor.CheckUser(player.UserId).Item2 ?? 0;
var uuid = player.UserId.ToString();
#endif

foreach (var job in _prototypes.EnumeratePrototypes<JobPrototype>())
Expand All @@ -240,7 +242,7 @@ public HashSet<string> GetDisallowedJobs(ICommonSession player)
_config,
out _
#if LPP_Sponsors
, 0, sponsorTier
, 0, sponsorTier, uuid
#endif
))
continue;
Expand Down Expand Up @@ -272,6 +274,7 @@ public void RemoveDisallowedJobs(NetUserId userId, ref List<string> jobs)

#if LPP_Sponsors
var sponsorTier = _checkSponsor.CheckUser(player.UserId).Item2 ?? 0;
var uuid = player.UserId.ToString();
#endif

for (var i = 0; i < jobs.Count; i++)
Expand All @@ -295,7 +298,7 @@ public void RemoveDisallowedJobs(NetUserId userId, ref List<string> jobs)
_config,
out _
#if LPP_Sponsors
, 0, sponsorTier
, 0, sponsorTier, uuid
#endif
))
{
Expand Down
Loading

0 comments on commit d820d14

Please sign in to comment.