Сообщения в ПДА 2 (#583)
* add: AdminLog * tweak: clean up * fix: Changeling -> Network * add: сортировка сообщений * fix: ТексТ
This commit is contained in:
@@ -23,6 +23,7 @@ using Content.Shared._White;
|
||||
using Content.Shared._White.Cult.Components;
|
||||
using Content.Shared._White.Utils;
|
||||
using Content.Shared._White.Cult.Systems;
|
||||
using Content.Shared._White.Radio;
|
||||
using Robust.Client.Graphics;
|
||||
using Robust.Client.Input;
|
||||
using Robust.Client.Player;
|
||||
@@ -575,6 +576,12 @@ public sealed class ChatUIController : UIController
|
||||
FilterableChannels |= ChatChannel.Changeling;
|
||||
CanSendChannels |= ChatSelectChannel.Changeling;
|
||||
}
|
||||
|
||||
if (_entities.HasComponent<NetworkChatComponent>(localEnt))
|
||||
{
|
||||
FilterableChannels |= ChatChannel.Network;
|
||||
CanSendChannels |= ChatSelectChannel.Network;
|
||||
}
|
||||
// WD EDIT END
|
||||
|
||||
SelectableChannels = CanSendChannels;
|
||||
|
||||
@@ -24,8 +24,11 @@ public sealed partial class ChannelFilterPopup : Popup
|
||||
ChatChannel.AdminAlert,
|
||||
ChatChannel.AdminChat,
|
||||
ChatChannel.Server,
|
||||
// WD EDIT START
|
||||
ChatChannel.Changeling,
|
||||
ChatChannel.Cult // WD EDIT
|
||||
ChatChannel.Cult,
|
||||
ChatChannel.Network
|
||||
// WD EDIT END
|
||||
};
|
||||
|
||||
private readonly Dictionary<ChatChannel, ChannelFilterCheckbox> _filterStates = new();
|
||||
|
||||
@@ -26,7 +26,7 @@ public sealed partial class MessagesUi : UIFragment
|
||||
if (state is not MessagesUiState messagesState)
|
||||
return;
|
||||
|
||||
_fragment.UpdateState(messagesState.Mode, messagesState.Contents, messagesState.Name);
|
||||
_fragment.UpdateState(messagesState.Mode, messagesState.Users, messagesState.Messages, messagesState.Name);
|
||||
}
|
||||
|
||||
private void SendMessagesMessage(MessagesUiAction action, string? stringInput, int? uidInput, BoundUserInterface userInterface)
|
||||
|
||||
@@ -29,10 +29,10 @@ public sealed partial class MessagesUiFragment : BoxContainer
|
||||
BackButton.OnPressed += _ => OnButtonPressed?.Invoke(null);
|
||||
SearchBar.OnTextChanged += OnSearchTextChanged;
|
||||
|
||||
UpdateState(MessagesUiStateMode.UserList, [], null);
|
||||
UpdateState(MessagesUiStateMode.UserList, [], [], null);
|
||||
}
|
||||
|
||||
public void UpdateState(MessagesUiStateMode mode, List<(MessagesUser, int?)>? contents, string? name)
|
||||
public void UpdateState(MessagesUiStateMode mode, List<(MessagesUserData, int?)>? users, List<(string, int?)>? messages, string? name)
|
||||
{
|
||||
MessageContainer.DisposeAllChildren();
|
||||
Input.Orphan();
|
||||
@@ -40,16 +40,13 @@ public sealed partial class MessagesUiFragment : BoxContainer
|
||||
|
||||
SearchBar.Visible = false;
|
||||
|
||||
if (contents == null)
|
||||
return;
|
||||
|
||||
if (mode == MessagesUiStateMode.Chat)
|
||||
if (mode == MessagesUiStateMode.Chat && messages != null)
|
||||
{
|
||||
HeaderLabel.Text = name;
|
||||
|
||||
foreach (var (senderName, message) in contents)
|
||||
foreach (var (senderName, message) in messages)
|
||||
{
|
||||
AddNote($"{senderName.Name} {message}");
|
||||
AddNote($"{senderName} {message}");
|
||||
}
|
||||
|
||||
OverContainer.AddChild(Input);
|
||||
@@ -61,11 +58,11 @@ public sealed partial class MessagesUiFragment : BoxContainer
|
||||
HeaderLabel.Text = Loc.GetString("messages-pda-error-header");
|
||||
AddNote(Loc.GetString("messages-pda-error-message"));
|
||||
}
|
||||
else
|
||||
else if (mode == MessagesUiStateMode.UserList && users != null)
|
||||
{
|
||||
SearchBar.Visible = true;
|
||||
HeaderLabel.Text = Loc.GetString("messages-pda-chat-choice");
|
||||
foreach (var (messagesUser, userUid) in contents)
|
||||
foreach (var (messagesUser, userUid) in users)
|
||||
{
|
||||
AddButton(userUid, messagesUser.Name + ", " + messagesUser.Job, messagesUser.Department);
|
||||
}
|
||||
@@ -123,7 +120,6 @@ public sealed partial class MessagesUiFragment : BoxContainer
|
||||
_searchText = args.Text;
|
||||
|
||||
UpdateVisibleButtons();
|
||||
// Reset scroll bar so they can see the relevant results.
|
||||
MessagesScroll.SetScrollValue(Vector2.Zero);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ using Content.Shared._White;
|
||||
using Content.Shared._White.Cult.Components;
|
||||
using Content.Shared.Speech;
|
||||
using Content.Shared._White.Cult.Systems;
|
||||
using Content.Shared._White.Radio;
|
||||
using Robust.Server.Player;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.Audio.Systems;
|
||||
@@ -773,7 +774,7 @@ public sealed partial class ChatSystem : SharedChatSystem
|
||||
.Select(p => p.Channel);
|
||||
}
|
||||
|
||||
// WD EDIT
|
||||
// WD EDIT START
|
||||
private void SendCultChat(EntityUid source, ICommonSession player, string message, bool hideChat)
|
||||
{
|
||||
var clients = GetCultChatClients();
|
||||
@@ -802,6 +803,28 @@ public sealed partial class ChatSystem : SharedChatSystem
|
||||
.Select(p => p.Channel);
|
||||
}
|
||||
|
||||
public void SendNetworkChat(EntityUid source, string message, bool hideChat)
|
||||
{
|
||||
var clients = GetNetworkChatClients();
|
||||
var wrappedMessage = Loc.GetString("chat-manager-send-message-chat-wrap-message",
|
||||
("channelName", Loc.GetString("chat-manager-message-channel-name")),
|
||||
("message", FormattedMessage.EscapeText(message)));
|
||||
|
||||
_chatManager.ChatMessageToMany(ChatChannel.Network, message, wrappedMessage, source, hideChat, false,
|
||||
clients.ToList());
|
||||
}
|
||||
|
||||
private IEnumerable<INetChannel> GetNetworkChatClients()
|
||||
{
|
||||
return Filter.Empty()
|
||||
.AddWhereAttachedEntity(HasComp<GhostComponent>)
|
||||
.AddWhereAttachedEntity(HasComp<NetworkChatComponent>)
|
||||
.Recipients
|
||||
.Union(_adminManager.ActiveAdmins)
|
||||
.Select(p => p.Channel);
|
||||
}
|
||||
// WD EDIT END
|
||||
|
||||
private void SendDeadChat(EntityUid source, ICommonSession player, string message, bool hideChat)
|
||||
{
|
||||
var clients = GetDeadChatClients();
|
||||
|
||||
@@ -1,19 +1,15 @@
|
||||
using Content.Server._White.Radio.Components;
|
||||
using System.Linq;
|
||||
using Content.Server._White.Radio.Components;
|
||||
using Content.Server._White.Radio.EntitySystems;
|
||||
using Content.Server.Administration.Commands;
|
||||
using Content.Server.CartridgeLoader;
|
||||
using Content.Shared.CartridgeLoader;
|
||||
using Content.Shared.PDA;
|
||||
using Robust.Shared.Map;
|
||||
using Content.Server.GameTicking;
|
||||
using Robust.Shared.Timing;
|
||||
using Content.Server.DeviceNetwork.Systems;
|
||||
using Content.Shared.DeviceNetwork;
|
||||
using Content.Server.Station.Systems;
|
||||
using Content.Shared._White.CartridgeLoader.Cartridges;
|
||||
using Content.Shared.Access.Components;
|
||||
using Content.Shared.Roles;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Server._White.CartridgeLoader.Cartridges;
|
||||
|
||||
@@ -26,7 +22,6 @@ public sealed class MessagesCartridgeSystem : EntitySystem
|
||||
[Dependency] private readonly DeviceNetworkSystem _deviceNetworkSystem = default!;
|
||||
[Dependency] private readonly SingletonDeviceNetServerSystem _singletonServerSystem = default!;
|
||||
[Dependency] private readonly StationSystem _stationSystem = default!;
|
||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
@@ -44,13 +39,13 @@ public sealed class MessagesCartridgeSystem : EntitySystem
|
||||
private void OnInit(EntityUid uid, MessagesCartridgeComponent component, ComponentInit args)
|
||||
{
|
||||
var stationId = _stationSystem.GetOwningStation(uid);
|
||||
if (stationId.HasValue &&
|
||||
_singletonServerSystem.TryGetActiveServerAddress<MessagesServerComponent>(stationId.Value,
|
||||
out var address) && TryComp(uid, out CartridgeComponent? cartComponent))
|
||||
{
|
||||
SendName(uid, component, cartComponent, address);
|
||||
component.UserUid = cartComponent.LoaderUid?.Id;
|
||||
}
|
||||
if (!stationId.HasValue ||
|
||||
!_singletonServerSystem.TryGetActiveServerAddress<MessagesServerComponent>(stationId.Value,
|
||||
out var address) || !TryComp(uid, out CartridgeComponent? cartComponent))
|
||||
return;
|
||||
|
||||
SendName(uid, component, cartComponent, address);
|
||||
component.UserUid = cartComponent.LoaderUid?.Id;
|
||||
}
|
||||
|
||||
private void OnRemove(EntityUid uid, MessagesCartridgeComponent component, ComponentRemove args)
|
||||
@@ -58,7 +53,7 @@ public sealed class MessagesCartridgeSystem : EntitySystem
|
||||
if (component.LastServer == null || !TryComp<MessagesServerComponent>(component.LastServer, out var messagesServerComponent) || component.UserUid == null)
|
||||
return;
|
||||
|
||||
messagesServerComponent.NameDict.Remove(component.UserUid.Value);
|
||||
messagesServerComponent.Dictionary.Remove(component.UserUid.Value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -69,6 +64,7 @@ public sealed class MessagesCartridgeSystem : EntitySystem
|
||||
var stationId = _stationSystem.GetOwningStation(uid);
|
||||
if (stationId.HasValue && _singletonServerSystem.TryGetActiveServerAddress<MessagesServerComponent>(stationId.Value, out var address) && TryComp(uid, out CartridgeComponent? cartComponent))
|
||||
SendName(uid, component, cartComponent, address);
|
||||
|
||||
UpdateUiState(uid, component);
|
||||
}
|
||||
|
||||
@@ -83,7 +79,7 @@ public sealed class MessagesCartridgeSystem : EntitySystem
|
||||
if (args is not MessagesUiMessageEvent messageEvent)
|
||||
return;
|
||||
|
||||
if (messageEvent.Action == MessagesUiAction.Send && TryComp(uid, out CartridgeComponent? cartComponent) && component.UserUid is { } userId && component.ChatUid != null && messageEvent.StringInput != null)
|
||||
if (messageEvent.Action == MessagesUiAction.Send && HasComp<CartridgeComponent>(uid) && component.UserUid is { } userId && component.ChatUid != null && messageEvent.StringInput != null)
|
||||
{
|
||||
var stationId = _stationSystem.GetOwningStation(uid);
|
||||
if (!stationId.HasValue)
|
||||
@@ -171,7 +167,7 @@ public sealed class MessagesCartridgeSystem : EntitySystem
|
||||
/// </summary>
|
||||
private void SendName(EntityUid uid, MessagesCartridgeComponent component, CartridgeComponent cartComponent, string? address)
|
||||
{
|
||||
TryGetMessagesUser(cartComponent, out var messagesUser);
|
||||
TryGetMessagesUser(component, cartComponent, out var messagesUser);
|
||||
|
||||
var packet = new NetworkPayload()
|
||||
{
|
||||
@@ -184,38 +180,38 @@ public sealed class MessagesCartridgeSystem : EntitySystem
|
||||
/// <summary>
|
||||
/// Retrieves the name of the given user from the last contacted server
|
||||
/// </summary>
|
||||
private bool TryGetName(int key, MessagesCartridgeComponent component, out string name)
|
||||
private void TryGetName(int key, MessagesCartridgeComponent component, out string name)
|
||||
{
|
||||
if (component.LastServer != null && _messagesServerSystem.TryGetUserFromDict(component.LastServer, key, out var messagesUser))
|
||||
{
|
||||
name = messagesUser.Name;
|
||||
return true;
|
||||
return;
|
||||
}
|
||||
|
||||
name = Loc.GetString("messages-pda-connection-error");
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the user's name, job title and job department
|
||||
/// </summary>
|
||||
public bool TryGetMessagesUser(CartridgeComponent component, out MessagesUser messagesUser)
|
||||
public bool TryGetMessagesUser(MessagesCartridgeComponent component, CartridgeComponent cartridgeComponent, out MessagesUserData messagesUserData)
|
||||
{
|
||||
var pda = component.LoaderUid;
|
||||
messagesUserData = new MessagesUserData();
|
||||
|
||||
if (component.LastServer != null &&
|
||||
TryComp<MessagesServerComponent>(component.LastServer, out var messagesServerComponent) &&
|
||||
component.UserUid != null)
|
||||
messagesUserData = messagesServerComponent.Dictionary[component.UserUid.Value];
|
||||
|
||||
var pda = cartridgeComponent.LoaderUid;
|
||||
if (pda == null)
|
||||
{
|
||||
messagesUser = new MessagesUser(Loc.GetString("messages-pda-unknown-name"), Loc.GetString("messages-pda-unknown-job"), "Specific");
|
||||
return false;
|
||||
}
|
||||
|
||||
var pdaComponent = CompOrNull<PdaComponent>(pda);
|
||||
if (pdaComponent?.OwnerName == null)
|
||||
{
|
||||
messagesUser = new MessagesUser(Loc.GetString("messages-pda-unknown-name"), Loc.GetString("messages-pda-unknown-job"), "Specific");
|
||||
return false;
|
||||
}
|
||||
|
||||
messagesUser = new MessagesUser(pdaComponent.OwnerName, pdaComponent.OwnerJob ?? Loc.GetString("messages-pda-unknown-job"), pdaComponent.OwnerDepartment ?? "Specific");
|
||||
messagesUserData.SetMessagesUser(pdaComponent.OwnerName, pdaComponent.OwnerJob, pdaComponent.OwnerDepartment);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -223,34 +219,39 @@ public sealed class MessagesCartridgeSystem : EntitySystem
|
||||
{
|
||||
if (!Resolve(uid, ref component))
|
||||
return;
|
||||
|
||||
if (!TryComp(uid, out CartridgeComponent? cartComponent))
|
||||
return;
|
||||
|
||||
if (cartComponent.LoaderUid == null)
|
||||
return;
|
||||
|
||||
var loaderUid = cartComponent.LoaderUid.Value;
|
||||
MessagesUiState state;
|
||||
MapId mapId = Transform(uid).MapID;
|
||||
int? currentUserId = component.UserUid;
|
||||
var currentUserId = component.UserUid;
|
||||
if (currentUserId == null || component.LastServer == null)
|
||||
{
|
||||
state = new MessagesUiState(MessagesUiStateMode.Error, [], null);
|
||||
state = new MessagesUiState(MessagesUiStateMode.Error);
|
||||
_cartridgeLoaderSystem.UpdateCartridgeUiState(loaderUid, state);
|
||||
return;
|
||||
}
|
||||
|
||||
if (component.ChatUid == null) //if no chat is loaded, list users
|
||||
{
|
||||
List<(MessagesUser, int?)> userList = [];
|
||||
List<(MessagesUserData, int?)> userList = [];
|
||||
|
||||
var nameDict = _messagesServerSystem.GetNameDict(component.LastServer);
|
||||
var dictionary = _messagesServerSystem.GetNameDict(component.LastServer);
|
||||
|
||||
foreach (var nameEntry in nameDict.Keys)
|
||||
foreach (var nameEntry in dictionary.Keys)
|
||||
{
|
||||
if (nameEntry == currentUserId)
|
||||
continue;
|
||||
userList.Add((nameDict[nameEntry], nameEntry));
|
||||
userList.Add((dictionary[nameEntry], nameEntry));
|
||||
}
|
||||
|
||||
state = new MessagesUiState(MessagesUiStateMode.UserList, userList, null);
|
||||
userList.Sort((a, b) => TimeSpan.Compare(b.Item1.Messages.LastOrDefault().Time, a.Item1.Messages.LastOrDefault().Time));
|
||||
|
||||
state = new MessagesUiState(MessagesUiStateMode.UserList, userList);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -259,31 +260,23 @@ public sealed class MessagesCartridgeSystem : EntitySystem
|
||||
foreach (var message in _messagesServerSystem.GetMessages(component.LastServer, component.ChatUid.Value, currentUserId.Value))
|
||||
{
|
||||
if (message.SenderId == component.ChatUid && message.ReceiverId == currentUserId || message.ReceiverId == component.ChatUid && message.SenderId == currentUserId)
|
||||
{
|
||||
messageList.Add(message);
|
||||
}
|
||||
}
|
||||
|
||||
messageList.Sort
|
||||
(
|
||||
delegate (MessagesMessageData a, MessagesMessageData b)
|
||||
{
|
||||
return TimeSpan.Compare(a.Time, b.Time);
|
||||
}
|
||||
);
|
||||
messageList.Sort((a, b) => TimeSpan.Compare(a.Time, b.Time));
|
||||
|
||||
List<(MessagesUser, int?)> formattedMessageList = [];
|
||||
List<(string, int?)> formattedMessageList = [];
|
||||
|
||||
foreach (var message in messageList)
|
||||
{
|
||||
TryGetName(message.SenderId, component, out var name);
|
||||
var stationTime = message.Time.Subtract(_gameTicker.RoundStartTimeSpan);
|
||||
var content = $"{stationTime.ToString("\\[hh\\:mm\\:ss\\]")} {name}: {message.Content}";
|
||||
formattedMessageList.Add((new MessagesUser(content, Loc.GetString("messages-pda-unknown-job"), "Specific"), null));
|
||||
var content = $"{stationTime:\\[hh\\:mm\\:ss\\]} {name}: {message.Content}";
|
||||
formattedMessageList.Add((content, null));
|
||||
}
|
||||
|
||||
TryGetName(component.ChatUid.Value, component, out var user);
|
||||
state = new MessagesUiState(MessagesUiStateMode.Chat, formattedMessageList, user);
|
||||
state = new MessagesUiState(MessagesUiStateMode.Chat, null, formattedMessageList, user);
|
||||
}
|
||||
_cartridgeLoaderSystem.UpdateCartridgeUiState(loaderUid, state);
|
||||
}
|
||||
|
||||
@@ -13,14 +13,8 @@ namespace Content.Server._White.Radio.Components;
|
||||
public sealed partial class MessagesServerComponent : Component
|
||||
{
|
||||
/// <summary>
|
||||
/// The list of messages cached by the server.
|
||||
/// Dictionary translating IDs to MessagesUser
|
||||
/// </summary>
|
||||
[DataField]
|
||||
public List<MessagesMessageData> Messages = [];
|
||||
|
||||
/// <summary>
|
||||
/// Dictionary translating uids to readable names
|
||||
/// </summary>
|
||||
[DataField]
|
||||
public Dictionary<int, MessagesUser> NameDict = [];
|
||||
public Dictionary<int, MessagesUserData> Dictionary = new();
|
||||
}
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
using System.Linq;
|
||||
using Content.Server._White.CartridgeLoader.Cartridges;
|
||||
using Content.Server._White.Radio.Components;
|
||||
using Content.Server.Administration.Logs;
|
||||
using Content.Server.Chat.Systems;
|
||||
using Content.Server.DeviceNetwork.Systems;
|
||||
using Content.Shared._White.CartridgeLoader.Cartridges;
|
||||
using Content.Shared.CartridgeLoader;
|
||||
using Content.Shared.Database;
|
||||
using Content.Shared.DeviceNetwork;
|
||||
|
||||
|
||||
@@ -14,6 +17,8 @@ public sealed class MessagesServerSystem : EntitySystem
|
||||
[Dependency] private readonly DeviceNetworkSystem _deviceNetworkSystem = default!;
|
||||
[Dependency] private readonly SingletonDeviceNetServerSystem _singletonServerSystem = default!;
|
||||
[Dependency] private readonly MessagesCartridgeSystem _messagesSystem = default!;
|
||||
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
|
||||
[Dependency] private readonly ChatSystem _chat = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
@@ -31,12 +36,12 @@ public sealed class MessagesServerSystem : EntitySystem
|
||||
if (!TryComp(entityUid, out CartridgeComponent? cartComponent))
|
||||
continue;
|
||||
|
||||
_messagesSystem.TryGetMessagesUser(cartComponent, out var messagesUser);
|
||||
_messagesSystem.TryGetMessagesUser(cartridge, cartComponent, out var messagesUser);
|
||||
|
||||
if (cartridge.UserUid == null || messagesUser.Name == Loc.GetString("messages-pda-unknown-name"))
|
||||
continue;
|
||||
|
||||
component.NameDict[cartridge.UserUid.Value] = messagesUser;
|
||||
component.Dictionary[cartridge.UserUid.Value] = messagesUser;
|
||||
cartridge.LastServer = uid;
|
||||
}
|
||||
}
|
||||
@@ -48,13 +53,15 @@ public sealed class MessagesServerSystem : EntitySystem
|
||||
{
|
||||
if (!_singletonServerSystem.IsActiveServer(uid))
|
||||
return;
|
||||
if (args.Data.TryGetValue<MessagesUser>(MessagesNetworkKeys.NewUser, out var messagesUser) && args.Data.TryGetValue<int>(MessagesNetworkKeys.UserId, out var userId))
|
||||
|
||||
if (args.Data.TryGetValue<MessagesUserData>(MessagesNetworkKeys.NewUser, out var messagesUser) && args.Data.TryGetValue<int>(MessagesNetworkKeys.UserId, out var userId))
|
||||
{
|
||||
component.NameDict[userId] = messagesUser;
|
||||
component.Dictionary[userId] = messagesUser;
|
||||
|
||||
var packet = new NetworkPayload();
|
||||
_deviceNetworkSystem.QueuePacket(uid, args.SenderAddress, packet);
|
||||
}
|
||||
|
||||
if (args.Data.TryGetValue<MessagesMessageData>(MessagesNetworkKeys.Message, out var message))
|
||||
SendMessage(uid, component, message);
|
||||
}
|
||||
@@ -64,7 +71,11 @@ public sealed class MessagesServerSystem : EntitySystem
|
||||
/// </summary>
|
||||
private void SendMessage(EntityUid uid, MessagesServerComponent component, MessagesMessageData message)
|
||||
{
|
||||
component.Messages.Add(message);
|
||||
component.Dictionary[message.ReceiverId].Messages.Add(message);
|
||||
component.Dictionary[message.SenderId].Messages.Add(message);
|
||||
|
||||
_adminLogger.Add(LogType.DeviceNetwork, $"{Loc.GetString("chat-manager-send-message", ("sender", component.Dictionary[message.SenderId].Name + $" ({message.SenderId})"), ("receiver", component.Dictionary[message.ReceiverId].Name + $" ({message.ReceiverId})"), ("message", message.Content))}");
|
||||
_chat.SendNetworkChat(uid, Loc.GetString("chat-manager-send-message", ("sender", component.Dictionary[message.SenderId].Name), ("receiver", component.Dictionary[message.ReceiverId].Name), ("message", message.Content)), false);
|
||||
|
||||
var packet = new NetworkPayload()
|
||||
{
|
||||
@@ -77,30 +88,23 @@ public sealed class MessagesServerSystem : EntitySystem
|
||||
/// <summary>
|
||||
/// Returns user
|
||||
/// </summary>
|
||||
public bool TryGetUserFromDict(EntityUid? uid, int key, out MessagesUser messagesUser)
|
||||
public bool TryGetUserFromDict(EntityUid? uid, int key, out MessagesUserData messagesUserData)
|
||||
{
|
||||
if (!TryComp(uid, out MessagesServerComponent? component))
|
||||
{
|
||||
messagesUser = new MessagesUser(Loc.GetString("messages-pda-connection-error"), Loc.GetString("messages-pda-unknown-job"), "Specific");
|
||||
messagesUserData = new MessagesUserData();
|
||||
|
||||
if (!TryComp(uid, out MessagesServerComponent? component) || !component.Dictionary.TryGetValue(key, out var keyValue))
|
||||
return false;
|
||||
}
|
||||
if (component.NameDict.TryGetValue(key, out var keyValue))
|
||||
{
|
||||
messagesUser = keyValue;
|
||||
return true;
|
||||
}
|
||||
messagesUser = new MessagesUser(Loc.GetString("messages-pda-user-missing"), Loc.GetString("messages-pda-unknown-job"), "Specific");
|
||||
return false;
|
||||
|
||||
messagesUserData = keyValue;
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the name dictionary cache
|
||||
/// Returns the user dictionary cache
|
||||
/// </summary>
|
||||
public Dictionary<int, MessagesUser> GetNameDict(EntityUid? uid)
|
||||
public Dictionary<int, MessagesUserData> GetNameDict(EntityUid? uid)
|
||||
{
|
||||
if (!TryComp(uid, out MessagesServerComponent? component))
|
||||
return new Dictionary<int, MessagesUser>();
|
||||
return component.NameDict;
|
||||
return !TryComp(uid, out MessagesServerComponent? component) ? new Dictionary<int, MessagesUserData>() : component.Dictionary;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -110,9 +114,11 @@ public sealed class MessagesServerSystem : EntitySystem
|
||||
{
|
||||
if (!TryComp(uid, out MessagesServerComponent? component))
|
||||
return [];
|
||||
|
||||
return
|
||||
[
|
||||
..component.Messages.Where(message =>
|
||||
..component.Dictionary[id1]
|
||||
.Messages.Where(message =>
|
||||
message.SenderId == id1 && message.ReceiverId == id2 ||
|
||||
message.SenderId == id2 && message.ReceiverId == id1)
|
||||
];
|
||||
|
||||
@@ -33,7 +33,7 @@ public sealed partial class CartridgeLoaderComponent : Component
|
||||
/// The maximum amount of programs that can be installed on the cartridge loader entity
|
||||
/// </summary>
|
||||
[DataField]
|
||||
public int DiskSpace = 5;
|
||||
public int DiskSpace = 7; // WD EDIT
|
||||
|
||||
/// <summary>
|
||||
/// Controls whether the cartridge loader will play notifications if it supports it at all
|
||||
|
||||
@@ -80,23 +80,26 @@ public enum ChatChannel : uint
|
||||
/// </summary>
|
||||
AdminChat = 1 << 13,
|
||||
|
||||
//WD EDIT START
|
||||
/// <summary>
|
||||
/// Changeling
|
||||
/// </summary>
|
||||
Changeling = 1 << 14,
|
||||
|
||||
//WD EDIT
|
||||
Cult = 1 << 15,
|
||||
|
||||
Network = 1 << 16,
|
||||
//WD EDIT END
|
||||
|
||||
/// <summary>
|
||||
/// Unspecified.
|
||||
/// </summary>
|
||||
Unspecified = 1 << 16,
|
||||
Unspecified = 1 << 17,
|
||||
|
||||
/// <summary>
|
||||
/// Channels considered to be IC.
|
||||
/// </summary>
|
||||
IC = Local | Whisper | Radio | Dead | Emotes | Damage | Visual | Notifications | Cult | Changeling,
|
||||
IC = Local | Whisper | Radio | Dead | Emotes | Damage | Visual | Notifications | Cult | Changeling | Network,
|
||||
|
||||
AdminRelated = Admin | AdminAlert | AdminChat,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,8 +15,11 @@ public static class ChatChannelExtensions
|
||||
ChatChannel.AdminAlert => Color.Red,
|
||||
ChatChannel.AdminChat => Color.HotPink,
|
||||
ChatChannel.Whisper => Color.DarkGray,
|
||||
// WD EDIT START
|
||||
ChatChannel.Cult => Color.DarkRed,
|
||||
ChatChannel.Changeling => Color.Purple,
|
||||
ChatChannel.Cult => Color.DarkRed, // WD EDIT
|
||||
ChatChannel.Network => Color.White,
|
||||
// WD EDIT END
|
||||
_ => Color.LightGray
|
||||
};
|
||||
}
|
||||
|
||||
@@ -46,15 +46,19 @@
|
||||
/// </summary>
|
||||
Dead = ChatChannel.Dead,
|
||||
|
||||
// WD EDIT START
|
||||
Cult = ChatChannel.Cult,
|
||||
|
||||
Changeling = ChatChannel.Changeling,
|
||||
|
||||
Network = ChatChannel.Network,
|
||||
// WD EDIT END
|
||||
|
||||
/// <summary>
|
||||
/// Admin chat
|
||||
/// </summary>
|
||||
Admin = ChatChannel.AdminChat,
|
||||
|
||||
Changeling = ChatChannel.Changeling,
|
||||
|
||||
Console = ChatChannel.Unspecified
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared._White.CartridgeLoader.Cartridges;
|
||||
|
||||
|
||||
///<summary>
|
||||
/// Data of a single message in the system, containing the ids of the sender and recipient, the text content and the time it was sent.
|
||||
///</summary>
|
||||
[Serializable, NetSerializable]
|
||||
public struct MessagesMessageData
|
||||
{
|
||||
public int SenderId;
|
||||
public int ReceiverId;
|
||||
public string Content;
|
||||
public TimeSpan Time;
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class MessagesUserData
|
||||
{
|
||||
public string Name = Loc.GetString("messages-pda-unknown-name");
|
||||
|
||||
public string Job = Loc.GetString("messages-pda-unknown-job");
|
||||
|
||||
public string Department = "Specific";
|
||||
|
||||
public List<MessagesMessageData> Messages = [];
|
||||
|
||||
public void SetMessagesUser(string? name, string? job, string? department)
|
||||
{
|
||||
Name = name ?? Loc.GetString("messages-pda-unknown-name");
|
||||
Job = job ?? Loc.GetString("messages-pda-unknown-job");
|
||||
Department = department ?? "Specific";
|
||||
}
|
||||
}
|
||||
@@ -4,18 +4,13 @@ using Robust.Shared.Serialization;
|
||||
namespace Content.Shared._White.CartridgeLoader.Cartridges;
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class MessagesUiMessageEvent : CartridgeMessageEvent
|
||||
public sealed class MessagesUiMessageEvent(MessagesUiAction action, string? stringInput, int? targetChatUid) : CartridgeMessageEvent
|
||||
{
|
||||
public readonly MessagesUiAction Action;
|
||||
public readonly int? TargetChatUid;
|
||||
public readonly string? StringInput;
|
||||
public readonly MessagesUiAction Action = action;
|
||||
|
||||
public MessagesUiMessageEvent(MessagesUiAction action, string? stringInput, int? targetChatUid)
|
||||
{
|
||||
Action = action;
|
||||
TargetChatUid = targetChatUid;
|
||||
StringInput = stringInput;
|
||||
}
|
||||
public readonly int? TargetChatUid = targetChatUid;
|
||||
|
||||
public readonly string? StringInput = stringInput;
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
|
||||
@@ -8,9 +8,10 @@ namespace Content.Shared._White.CartridgeLoader.Cartridges;
|
||||
/// Contents contains either the names of users and their ids in the messages system or simply a list of message strings.
|
||||
///</summary>
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class MessagesUiState(MessagesUiStateMode mode, List<(MessagesUser, int?)> contents, string? name = null) : BoundUserInterfaceState
|
||||
public sealed class MessagesUiState(MessagesUiStateMode mode, List<(MessagesUserData, int?)>? users = null, List<(string, int?)>? messages = null, string? name = null) : BoundUserInterfaceState
|
||||
{
|
||||
public List<(MessagesUser, int?)>? Contents = contents;
|
||||
public List<(MessagesUserData, int?)>? Users = users;
|
||||
public List<(string, int?)>? Messages = messages;
|
||||
public MessagesUiStateMode Mode = mode;
|
||||
public string? Name = name;
|
||||
}
|
||||
@@ -25,23 +26,3 @@ public enum MessagesUiStateMode : byte
|
||||
Chat,
|
||||
Error
|
||||
}
|
||||
|
||||
///<summary>
|
||||
/// Data of a single message in the system, containing the ids of the sender and recipient, the text content and the time it was sent.
|
||||
///</summary>
|
||||
[Serializable, NetSerializable]
|
||||
public struct MessagesMessageData
|
||||
{
|
||||
public int SenderId;
|
||||
public int ReceiverId;
|
||||
public string Content;
|
||||
public TimeSpan Time;
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public sealed class MessagesUser(string name, string job, string department)
|
||||
{
|
||||
public string Name = name;
|
||||
public string Job = job;
|
||||
public string Department = department;
|
||||
}
|
||||
|
||||
7
Content.Shared/_White/Radio/NetworkChatComponent.cs
Normal file
7
Content.Shared/_White/Radio/NetworkChatComponent.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
namespace Content.Shared._White.Radio;
|
||||
|
||||
[RegisterComponent]
|
||||
public sealed partial class NetworkChatComponent : Component
|
||||
{
|
||||
|
||||
}
|
||||
5
Resources/Locale/en-US/_white/message/message.ftl
Normal file
5
Resources/Locale/en-US/_white/message/message.ftl
Normal file
@@ -0,0 +1,5 @@
|
||||
chat-manager-send-message-chat-wrap-message = [bold]\[{ $channelName }\]:[/bold] [BubbleContent]{ $message }[/BubbleContent]
|
||||
chat-manager-message-channel-name = [color=blue]Network[/color]
|
||||
chat-manager-send-message = Message from { $sender } to { $receiver }. Message text: "{ $message }"
|
||||
hud-chatbox-select-channel-Servers = Network
|
||||
hud-chatbox-channel-Servers = Network
|
||||
5
Resources/Locale/ru-RU/_white/message/message.ftl
Normal file
5
Resources/Locale/ru-RU/_white/message/message.ftl
Normal file
@@ -0,0 +1,5 @@
|
||||
chat-manager-send-message-chat-wrap-message = [bold]\[{ $channelName }\]:[/bold] [BubbleContent]{ $message }[/BubbleContent]
|
||||
chat-manager-message-channel-name = [color=blue]Cеть[/color]
|
||||
chat-manager-send-message = Сообщение от { $sender } к { $receiver }. Текст сообщения: "{ $message }"
|
||||
hud-chatbox-select-channel-Servers = Cеть
|
||||
hud-chatbox-channel-Servers = Cеть
|
||||
@@ -683,7 +683,6 @@
|
||||
preinstalled:
|
||||
- CrewManifestCartridge
|
||||
- NotekeeperCartridge
|
||||
- MessagesCartridge
|
||||
- NewsReaderCartridge
|
||||
- LogProbeCartridge
|
||||
|
||||
|
||||
Reference in New Issue
Block a user