Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…ngines into whitelist-fix
  • Loading branch information
DEATHB4DEFEAT committed Aug 13, 2024
2 parents 1984574 + 2ae464e commit 7371916
Show file tree
Hide file tree
Showing 1,177 changed files with 17,869 additions and 4,278 deletions.
21 changes: 7 additions & 14 deletions Content.Client/Administration/Systems/AdminSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,9 @@ public sealed partial class AdminSystem : EntitySystem
{
public event Action<List<PlayerInfo>>? PlayerListChanged;

private Dictionary<NetUserId, PlayerInfo>? _playerList;
public IReadOnlyList<PlayerInfo> PlayerList
{
get
{
if (_playerList != null) return _playerList.Values.ToList();

return new List<PlayerInfo>();
}
}
public Dictionary<NetUserId, PlayerInfo> PlayerInfos = new();
public IReadOnlyList<PlayerInfo> PlayerList =>
PlayerInfos != null ? PlayerInfos.Values.ToList() : new List<PlayerInfo>();

public override void Initialize()
{
Expand All @@ -40,15 +33,15 @@ private void OnPlayerInfoChanged(PlayerInfoChangedEvent ev)
{
if(ev.PlayerInfo == null) return;

if (_playerList == null) _playerList = new();
if (PlayerInfos == null) PlayerInfos = new();

_playerList[ev.PlayerInfo.SessionId] = ev.PlayerInfo;
PlayerListChanged?.Invoke(_playerList.Values.ToList());
PlayerInfos[ev.PlayerInfo.SessionId] = ev.PlayerInfo;
PlayerListChanged?.Invoke(PlayerInfos.Values.ToList());
}

private void OnPlayerListChanged(FullPlayerListEvent msg)
{
_playerList = msg.PlayersInfo.ToDictionary(x => x.SessionId, x => x);
PlayerInfos = msg.PlayersInfo.ToDictionary(x => x.SessionId, x => x);
PlayerListChanged?.Invoke(msg.PlayersInfo);
}
}
Expand Down
11 changes: 9 additions & 2 deletions Content.Client/Administration/Systems/BwoinkSystem.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
#nullable enable
using Content.Client.UserInterface.Systems.Bwoink;
using Content.Shared.Administration;
using JetBrains.Annotations;
using Robust.Client.Audio;
using Robust.Shared.Network;
using Robust.Shared.Player;
using Robust.Shared.Timing;

namespace Content.Client.Administration.Systems
Expand All @@ -10,6 +13,8 @@ namespace Content.Client.Administration.Systems
public sealed class BwoinkSystem : SharedBwoinkSystem
{
[Dependency] private readonly IGameTiming _timing = default!;
[Dependency] private readonly AudioSystem _audio = default!;
[Dependency] private readonly AdminSystem _adminSystem = default!;

public event EventHandler<BwoinkTextMessage>? OnBwoinkTextMessageRecieved;
private (TimeSpan Timestamp, bool Typing) _lastTypingUpdateSent;
Expand All @@ -21,6 +26,10 @@ protected override void OnBwoinkTextMessage(BwoinkTextMessage message, EntitySes

public void Send(NetUserId channelId, string text, bool playSound)
{
var info = _adminSystem.PlayerInfos.GetValueOrDefault(channelId)?.Connected ?? true;
_audio.PlayGlobal(info ? AHelpUIController.AHelpSendSound : AHelpUIController.AHelpErrorSound,
Filter.Local(), false);

// Reuse the channel ID as the 'true sender'.
// Server will ignore this and if someone makes it not ignore this (which is bad, allows impersonation!!!), that will help.
RaiseNetworkEvent(new BwoinkTextMessage(channelId, channelId, text, playSound: playSound));
Expand All @@ -31,9 +40,7 @@ public void SendInputTextUpdated(NetUserId channel, bool typing)
{
if (_lastTypingUpdateSent.Typing == typing &&
_lastTypingUpdateSent.Timestamp + TimeSpan.FromSeconds(1) > _timing.RealTime)
{
return;
}

_lastTypingUpdateSent = (_timing.RealTime, typing);
RaiseNetworkEvent(new BwoinkClientTypingUpdated(channel, typing));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
using Robust.Client.GameObjects;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface;
using Content.Client.UserInterface.Fragments;
using Content.Shared.CartridgeLoader.Cartridges;
using Content.Shared.CartridgeLoader;

namespace Content.Client.Nyanotrasen.CartridgeLoader.Cartridges;
namespace Content.Client.CartridgeLoader.Cartridges;

public sealed partial class GlimmerMonitorUi : UIFragment
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<cartridges:GlimmerMonitorUiFragment xmlns:cartridges="clr-namespace:Content.Client.Nyanotrasen.CartridgeLoader.Cartridges"
<cartridges:GlimmerMonitorUiFragment xmlns:cartridges="clr-namespace:Content.Client.CartridgeLoader.Cartridges"
xmlns="https://spacestation14.io" Margin="1 0 2 0">
<PanelContainer StyleClasses="BackgroundDark"></PanelContainer>
<BoxContainer Name="SettingsBox" Orientation="Horizontal" HorizontalExpand="True" VerticalExpand="False">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
using System.Linq;
using System.Numerics;
using Content.Client.Nyanotrasen.UserInterface;
using Content.Client.UserInterface;
using Robust.Client.AutoGenerated;
using Robust.Client.ResourceManagement;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.XAML;

namespace Content.Client.Nyanotrasen.CartridgeLoader.Cartridges;
namespace Content.Client.CartridgeLoader.Cartridges;

[GenerateTypedNameReferences]
public sealed partial class GlimmerMonitorUiFragment : BoxContainer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using Content.Client.Chat.Managers;
using Robust.Client.Player;

namespace Content.Client.Nyanotrasen.Chat
namespace Content.Client.Chat
{
public sealed class PsionicChatUpdateSystem : EntitySystem
{
Expand Down
47 changes: 47 additions & 0 deletions Content.Client/Eye/PenLight/UI/PenLightBoundUserInterface.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
using Content.Shared.Medical;
using JetBrains.Annotations;
using Robust.Client.GameObjects;

namespace Content.Client.Eye.PenLight.UI
{
[UsedImplicitly]
public sealed class PenLightBoundUserInterface : BoundUserInterface
{
[ViewVariables]
private PenLightWindow? _window;

public PenLightBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey) { }

protected override void Open()
{
base.Open();
_window = new PenLightWindow
{
Title = EntMan.GetComponent<MetaDataComponent>(Owner).EntityName,
};
_window.OnClose += Close;
_window.OpenCentered();
}

protected override void ReceiveMessage(BoundUserInterfaceMessage message)
{
if (_window == null
|| message is not PenLightUserMessage cast)
return;

_window.Diagnose(cast);
}

protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
if (!disposing)
return;

if (_window != null)
_window.OnClose -= Close;

_window?.Dispose();
}
}
}
11 changes: 11 additions & 0 deletions Content.Client/Eye/PenLight/UI/PenLightWindow.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<controls:FancyWindow xmlns="https://spacestation14.io"
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls"
Title="{Loc 'pen-light-exam-title'}"
SetSize="0 -300">
<ScrollContainer VerticalExpand="True">
<BoxContainer Name="RootContainer" Orientation="Vertical" HorizontalExpand="True">
<Label Name="NoPatientDataText" Text="{Loc 'pen-light-window-no-patient-data-text'}" Visible="False"/>
<Label Name="ExamDataLabel"/>
</BoxContainer>
</ScrollContainer>
</controls:FancyWindow>
78 changes: 78 additions & 0 deletions Content.Client/Eye/PenLight/UI/PenLightWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
using Content.Client.UserInterface.Controls;
using Content.Shared.Damage;
using Content.Shared.IdentityManagement;
using Content.Shared.Medical;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.XAML;
using System.Text;


namespace Content.Client.Eye.PenLight.UI
{
[GenerateTypedNameReferences]
public sealed partial class PenLightWindow : FancyWindow
{
private readonly IEntityManager _entityManager;
private const int LightHeight = 150;
private const int LightWidth = 900;

public PenLightWindow()
{
RobustXamlLoader.Load(this);

var dependencies = IoCManager.Instance!;
_entityManager = dependencies.Resolve<IEntityManager>();
}
public void Diagnose(PenLightUserMessage msg)
{
var target = _entityManager.GetEntity(msg.TargetEntity);

if (target == null || !_entityManager.TryGetComponent<DamageableComponent>(target, out var damageable))
{
NoPatientDataText.Visible = true;
ExamDataLabel.Text = string.Empty;
return;
}

NoPatientDataText.Visible = false;


string entityName = Loc.GetString("pen-light-window-entity-unknown-text");
if (_entityManager.HasComponent<MetaDataComponent>(target.Value))
entityName = Identity.Name(target.Value, _entityManager);

var sb = new StringBuilder();
sb.AppendLine(Loc.GetString("pen-light-window-entity-eyes-text", ("entityName", entityName)));

// Check if Blind and return early if true
if (msg.Blind == true)
{
sb.AppendLine(Loc.GetString("pen-light-exam-blind-text"));
ExamDataLabel.Text = sb.ToString();
SetHeight = LightHeight;
SetWidth = LightWidth;
return;
}
// EyeDamage
if (msg.EyeDamage == true)
sb.AppendLine(Loc.GetString("pen-light-exam-eyedamage-text"));

// Drunk
if (msg.Drunk == true)
sb.AppendLine(Loc.GetString("pen-light-exam-drunk-text"));

// Hallucinating
if (msg.SeeingRainbows == true)
sb.AppendLine(Loc.GetString("pen-light-exam-hallucinating-text"));

// Healthy
if (msg.Healthy == true)
sb.AppendLine(Loc.GetString("pen-light-exam-healthy-text"));

ExamDataLabel.Text = sb.ToString();

SetHeight = LightHeight;
SetWidth = LightWidth;
}
}
}
24 changes: 21 additions & 3 deletions Content.Client/LateJoin/LateJoinGui.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@
using Content.Client.GameTicking.Managers;
using Content.Client.UserInterface.Controls;
using Content.Client.Players.PlayTimeTracking;
using Content.Client.Preferences;
using Content.Shared.CCVar;
using Content.Shared.Customization.Systems;
using Content.Shared.Preferences;
using Content.Shared.Roles;
using Content.Shared.StatusIcon;
using Microsoft.Win32.SafeHandles;
using Robust.Client.Console;
using Robust.Client.GameObjects;
using Robust.Client.UserInterface;
Expand All @@ -26,12 +30,15 @@ public sealed class LateJoinGui : DefaultWindow
[Dependency] private readonly IConfigurationManager _configManager = default!;
[Dependency] private readonly IEntitySystemManager _entitySystem = default!;
[Dependency] private readonly JobRequirementsManager _jobRequirements = default!;
[Dependency] private readonly IEntityManager _entityManager = default!;
[Dependency] private readonly IClientPreferencesManager _prefs = default!;

public event Action<(NetEntity, string)> SelectedId;

private readonly ClientGameTicker _gameTicker;
private readonly SpriteSystem _sprites;
private readonly CrewManifestSystem _crewManifest;
private readonly CharacterRequirementsSystem _characterRequirements;

private readonly Dictionary<NetEntity, Dictionary<string, List<JobButton>>> _jobButtons = new();
private readonly Dictionary<NetEntity, Dictionary<string, BoxContainer>> _jobCategories = new();
Expand All @@ -46,6 +53,7 @@ public LateJoinGui()
_sprites = _entitySystem.GetEntitySystem<SpriteSystem>();
_crewManifest = _entitySystem.GetEntitySystem<CrewManifestSystem>();
_gameTicker = _entitySystem.GetEntitySystem<ClientGameTicker>();
_characterRequirements = _entitySystem.GetEntitySystem<CharacterRequirementsSystem>();

Title = Loc.GetString("late-join-gui-title");

Expand Down Expand Up @@ -254,14 +262,24 @@ private void RebuildUI()

jobButton.OnPressed += _ => SelectedId.Invoke((id, jobButton.JobId));

if (!_jobRequirements.IsAllowed(prototype, out var reason))
if (!_characterRequirements.CheckRequirementsValid(
prototype.Requirements ?? new(),
prototype,
(HumanoidCharacterProfile) (_prefs.Preferences?.SelectedCharacter
?? HumanoidCharacterProfile.DefaultWithSpecies()),
_jobRequirements.GetRawPlayTimeTrackers(),
_jobRequirements.IsWhitelisted(),
_entityManager,
_prototypeManager,
_configManager,
out var reasons))
{
jobButton.Disabled = true;

if (!reason.IsEmpty)
if (reasons.Count > 0)
{
var tooltip = new Tooltip();
tooltip.SetMessage(reason);
tooltip.SetMessage(_characterRequirements.GetRequirementsText(reasons));
jobButton.TooltipSupplier = _ => tooltip;
}

Expand Down
12 changes: 5 additions & 7 deletions Content.Client/Lobby/LobbyUIController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Content.Client.Humanoid;
using Content.Client.Inventory;
using Content.Client.Lobby.UI;
using Content.Client.Players.PlayTimeTracking;
using Content.Client.Preferences;
using Content.Client.Preferences.UI;
using Content.Shared.Clothing.Loadouts.Systems;
Expand All @@ -23,6 +24,7 @@ public sealed class LobbyUIController : UIController, IOnStateEntered<LobbyState
[Dependency] private readonly IClientPreferencesManager _preferencesManager = default!;
[Dependency] private readonly IStateManager _stateManager = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly JobRequirementsManager _jobRequirements = default!;
[UISystemDependency] private readonly HumanoidAppearanceSystem _humanoid = default!;
[UISystemDependency] private readonly ClientInventorySystem _inventory = default!;
[UISystemDependency] private readonly LoadoutSystem _loadouts = default!;
Expand Down Expand Up @@ -123,7 +125,8 @@ public void UpdateCharacterUI()
if (ShowClothes)
GiveDummyJobClothes(_previewDummy.Value, GetPreferredJob(maybeProfile), maybeProfile);
if (ShowLoadouts)
GiveDummyLoadouts(_previewDummy.Value, GetPreferredJob(maybeProfile), maybeProfile);
_loadouts.ApplyCharacterLoadout(_previewDummy.Value, GetPreferredJob(maybeProfile), maybeProfile,
_jobRequirements.GetRawPlayTimeTrackers(), _jobRequirements.IsWhitelisted());
UpdateClothes = false;
}

Expand Down Expand Up @@ -170,12 +173,7 @@ public void GiveDummyJobClothesLoadout(EntityUid dummy, HumanoidCharacterProfile
{
var job = GetPreferredJob(profile);
GiveDummyJobClothes(dummy, job, profile);
GiveDummyLoadouts(dummy, job, profile);
}

public void GiveDummyLoadouts(EntityUid dummy, JobPrototype job, HumanoidCharacterProfile profile)
{
_loadouts.ApplyCharacterLoadout(dummy, job, profile);
_loadouts.ApplyCharacterLoadout(dummy, job, profile, _jobRequirements.GetRawPlayTimeTrackers(), _jobRequirements.IsWhitelisted());
}

/// <summary>
Expand Down
Loading

0 comments on commit 7371916

Please sign in to comment.