Skip to content

Commit

Permalink
Merge branch 'master' into test_branch_feature
Browse files Browse the repository at this point in the history
  • Loading branch information
Schrodinger71 authored Apr 3, 2024
2 parents 440c52e + 5f82200 commit a5e32f5
Show file tree
Hide file tree
Showing 300 changed files with 3,467 additions and 691 deletions.
2 changes: 1 addition & 1 deletion ADT_STATION
31 changes: 31 additions & 0 deletions Content.Client/ADT/CollectiveMind/CollectiveMindSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using Content.Client.Chat.Managers;
using Content.Shared.Sirena.CollectiveMind;
using Robust.Client.Player;

namespace Content.Client.Sirena.CollectiveMind;

public sealed class CollectiveMindSystem : EntitySystem
{
[Dependency] private readonly IChatManager _chatManager = default!;
[Dependency] private readonly IPlayerManager _playerManager = default!;

public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<CollectiveMindComponent, ComponentInit>(OnInit);
SubscribeLocalEvent<CollectiveMindComponent, ComponentRemove>(OnRemove);
}

public CollectiveMindComponent? Player => CompOrNull<CollectiveMindComponent>(_playerManager.LocalPlayer?.ControlledEntity);
public bool IsCollectiveMind => Player != null;

private void OnInit(EntityUid uid, CollectiveMindComponent component, ComponentInit args)
{
_chatManager.UpdatePermissions();
}

private void OnRemove(EntityUid uid, CollectiveMindComponent component, ComponentRemove args)
{
_chatManager.UpdatePermissions();
}
}
10 changes: 10 additions & 0 deletions Content.Client/Chat/Managers/ChatManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ internal sealed class ChatManager : IChatManager
[Dependency] private readonly IEntitySystemManager _systems = default!;

private ISawmill _sawmill = default!;
public event Action? PermissionsUpdated;

public void Initialize()
{
Expand Down Expand Up @@ -67,9 +68,18 @@ public void SendMessage(string text, ChatSelectChannel channel)
_consoleHost.ExecuteCommand($"whisper \"{CommandParsing.Escape(str)}\"");
break;

case ChatSelectChannel.CollectiveMind:
_consoleHost.ExecuteCommand($"cmsay \"{CommandParsing.Escape(str)}\"");
break;

default:
throw new ArgumentOutOfRangeException(nameof(channel), channel, null);
}
}

public void UpdatePermissions()
{
PermissionsUpdated?.Invoke();
}
}
}
6 changes: 6 additions & 0 deletions Content.Client/Chat/Managers/IChatManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ public interface IChatManager
{
void Initialize();

/// <summary>
/// Will refresh perms.
/// </summary>
event Action PermissionsUpdated;

public void SendMessage(string text, ChatSelectChannel channel);
public void UpdatePermissions();
}
}
1 change: 1 addition & 0 deletions Content.Client/Input/ContentContexts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public static void SetupContexts(IInputContextContainer contexts)
common.AddFunction(ContentKeyFunctions.FocusChat);
common.AddFunction(ContentKeyFunctions.FocusLocalChat);
common.AddFunction(ContentKeyFunctions.FocusEmote);
common.AddFunction(ContentKeyFunctions.FocusCollectiveMind);
common.AddFunction(ContentKeyFunctions.FocusWhisperChat);
common.AddFunction(ContentKeyFunctions.FocusRadio);
common.AddFunction(ContentKeyFunctions.FocusLOOC);
Expand Down
1 change: 1 addition & 0 deletions Content.Client/Options/UI/Tabs/KeyRebindTab.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ void AddCheckBox(string checkBoxName, bool currentState, Action<BaseButton.Butto
AddButton(ContentKeyFunctions.FocusLocalChat);
AddButton(ContentKeyFunctions.FocusEmote);
AddButton(ContentKeyFunctions.FocusWhisperChat);
AddButton(ContentKeyFunctions.FocusCollectiveMind);
AddButton(ContentKeyFunctions.FocusRadio);
AddButton(ContentKeyFunctions.FocusLOOC);
AddButton(ContentKeyFunctions.FocusOOC);
Expand Down
25 changes: 21 additions & 4 deletions Content.Client/UserInterface/Systems/Chat/ChatUIController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@
using Robust.Shared.Replays;
using Robust.Shared.Timing;
using Robust.Shared.Utility;
using Content.Client.Sirena.CollectiveMind;
using System.Globalization;
using System.Linq;
using System.Numerics;

namespace Content.Client.UserInterface.Systems.Chat;

Expand All @@ -64,6 +68,7 @@ public sealed class ChatUIController : UIController
[UISystemDependency] private readonly GhostSystem? _ghost = default;
[UISystemDependency] private readonly TypingIndicatorSystem? _typingIndicator = default;
[UISystemDependency] private readonly ChatSystem? _chatSys = default;
[UISystemDependency] private readonly CollectiveMindSystem? _collectiveMind = default!;

[ValidatePrototypeId<ColorPalettePrototype>]
private const string ChatNamePalette = "ChatNames";
Expand All @@ -78,6 +83,7 @@ public sealed class ChatUIController : UIController
{
{SharedChatSystem.LocalPrefix, ChatSelectChannel.Local},
{SharedChatSystem.WhisperPrefix, ChatSelectChannel.Whisper},
{SharedChatSystem.CollectiveMindPrefix, ChatSelectChannel.CollectiveMind},
{SharedChatSystem.ConsolePrefix, ChatSelectChannel.Console},
{SharedChatSystem.LOOCPrefix, ChatSelectChannel.LOOC},
{SharedChatSystem.OOCPrefix, ChatSelectChannel.OOC},
Expand All @@ -92,6 +98,7 @@ public sealed class ChatUIController : UIController
{
{ChatSelectChannel.Local, SharedChatSystem.LocalPrefix},
{ChatSelectChannel.Whisper, SharedChatSystem.WhisperPrefix},
{ChatSelectChannel.CollectiveMind, SharedChatSystem.CollectiveMindPrefix},
{ChatSelectChannel.Console, SharedChatSystem.ConsolePrefix},
{ChatSelectChannel.LOOC, SharedChatSystem.LOOCPrefix},
{ChatSelectChannel.OOC, SharedChatSystem.OOCPrefix},
Expand Down Expand Up @@ -204,6 +211,9 @@ public override void Initialize()
_input.SetInputCommand(ContentKeyFunctions.FocusWhisperChat,
InputCmdHandler.FromDelegate(_ => FocusChannel(ChatSelectChannel.Whisper)));

_input.SetInputCommand(ContentKeyFunctions.FocusCollectiveMind,
InputCmdHandler.FromDelegate(_ => FocusChannel(ChatSelectChannel.CollectiveMind)));

_input.SetInputCommand(ContentKeyFunctions.FocusLOOC,
InputCmdHandler.FromDelegate(_ => FocusChannel(ChatSelectChannel.LOOC)));

Expand Down Expand Up @@ -501,7 +511,7 @@ private void UpdateChannelPermissions()

// Can only send local / radio / emote when attached to a non-ghost entity.
// TODO: this logic is iffy (checking if controlling something that's NOT a ghost), is there a better way to check this?
if (_ghost is not {IsGhost: true})
if (_ghost is not { IsGhost: true })
{
CanSendChannels |= ChatSelectChannel.Local;
CanSendChannels |= ChatSelectChannel.Whisper;
Expand All @@ -511,7 +521,7 @@ private void UpdateChannelPermissions()
}

// Only ghosts and admins can send / see deadchat.
if (_admin.HasFlag(AdminFlags.Admin) || _ghost is {IsGhost: true})
if (_admin.HasFlag(AdminFlags.Admin) || _ghost is { IsGhost: true })
{
FilterableChannels |= ChatChannel.Dead;
CanSendChannels |= ChatSelectChannel.Dead;
Expand All @@ -524,6 +534,13 @@ private void UpdateChannelPermissions()
FilterableChannels |= ChatChannel.AdminAlert;
FilterableChannels |= ChatChannel.AdminChat;
CanSendChannels |= ChatSelectChannel.Admin;
FilterableChannels |= ChatChannel.CollectiveMind;
}
// if (_collectiveMind != null && _collectiveMind is { IsCollectiveMind: true })
if (_collectiveMind != null)
{
CanSendChannels |= ChatSelectChannel.CollectiveMind;
FilterableChannels |= ChatChannel.CollectiveMind;
}

SelectableChannels = CanSendChannels;
Expand Down Expand Up @@ -641,7 +658,7 @@ private void SetBubbles(List<SpeechBubble> bubbles, bool visible)

public ChatSelectChannel MapLocalIfGhost(ChatSelectChannel channel)
{
if (channel == ChatSelectChannel.Local && _ghost is {IsGhost: true})
if (channel == ChatSelectChannel.Local && _ghost is { IsGhost: true })
return ChatSelectChannel.Dead;

return channel;
Expand Down Expand Up @@ -824,7 +841,7 @@ public void ProcessChatMessage(ChatMessage msg, bool speechBubble = true)
break;

case ChatChannel.Dead:
if (_ghost is not {IsGhost: true})
if (_ghost is not { IsGhost: true })
break;

AddSpeechBubble(msg, SpeechBubble.SpeechType.Say);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Content.Shared.Chat;
using Content.Shared.Chat;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.XAML;
Expand All @@ -16,6 +16,7 @@ public sealed partial class ChannelFilterPopup : Popup
ChatChannel.Whisper,
ChatChannel.Emotes,
ChatChannel.Radio,
ChatChannel.CollectiveMind,
ChatChannel.LOOC,
ChatChannel.OOC,
ChatChannel.Dead,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public sealed class ChannelSelectorPopup : Popup
ChatSelectChannel.Whisper,
ChatSelectChannel.Emotes,
ChatSelectChannel.Radio,
ChatSelectChannel.CollectiveMind,
ChatSelectChannel.LOOC,
ChatSelectChannel.OOC,
ChatSelectChannel.Dead,
Expand Down
Loading

0 comments on commit a5e32f5

Please sign in to comment.