Adds a bool (#5372)
This commit is contained in:
committed by
GitHub
parent
fc22e71ae1
commit
86a7eece40
@@ -363,19 +363,22 @@ namespace Content.Client.Chat.Managers
|
||||
private void OnChatMessage(MsgChatMessage msg)
|
||||
{
|
||||
// Log all incoming chat to repopulate when filter is un-toggled
|
||||
var storedMessage = new StoredChatMessage(msg);
|
||||
_history.Add(storedMessage);
|
||||
MessageAdded?.Invoke(storedMessage);
|
||||
|
||||
if (!storedMessage.Read)
|
||||
if (!msg.HideChat)
|
||||
{
|
||||
Logger.Debug($"Message filtered: {storedMessage.Channel}: {storedMessage.Message}");
|
||||
if (!_unreadMessages.TryGetValue(msg.Channel, out var count))
|
||||
count = 0;
|
||||
var storedMessage = new StoredChatMessage(msg);
|
||||
_history.Add(storedMessage);
|
||||
MessageAdded?.Invoke(storedMessage);
|
||||
|
||||
count += 1;
|
||||
_unreadMessages[msg.Channel] = count;
|
||||
UnreadMessageCountsUpdated?.Invoke();
|
||||
if (!storedMessage.Read)
|
||||
{
|
||||
Logger.Debug($"Message filtered: {storedMessage.Channel}: {storedMessage.Message}");
|
||||
if (!_unreadMessages.TryGetValue(msg.Channel, out var count))
|
||||
count = 0;
|
||||
|
||||
count += 1;
|
||||
_unreadMessages[msg.Channel] = count;
|
||||
UnreadMessageCountsUpdated?.Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
// Local messages that have an entity attached get a speech bubble.
|
||||
|
||||
@@ -61,7 +61,7 @@ namespace Content.Server.Advertise
|
||||
return;
|
||||
|
||||
if (_prototypeManager.TryIndex(advertise.PackPrototypeId, out AdvertisementsPackPrototype? advertisements))
|
||||
_chatManager.EntitySay(advertise.Owner, Loc.GetString(_random.Pick(advertisements.Advertisements)));
|
||||
_chatManager.EntitySay(advertise.Owner, Loc.GetString(_random.Pick(advertisements.Advertisements)), hideChat: true);
|
||||
|
||||
if(refresh)
|
||||
RefreshTimer(uid, true, advertise);
|
||||
|
||||
@@ -108,7 +108,7 @@ namespace Content.Server.Chat.Managers
|
||||
_netManager.ServerSendMessage(msg, player.ConnectedClient);
|
||||
}
|
||||
|
||||
public void EntitySay(IEntity source, string message)
|
||||
public void EntitySay(IEntity source, string message, bool hideChat=false)
|
||||
{
|
||||
if (!EntitySystem.Get<ActionBlockerSystem>().CanSpeak(source.Uid))
|
||||
{
|
||||
@@ -190,6 +190,7 @@ namespace Content.Server.Chat.Managers
|
||||
msg.Message = message;
|
||||
msg.MessageWrap = Loc.GetString("chat-manager-entity-say-wrap-message",("entityName", source.Name));
|
||||
msg.SenderEntity = source.Uid;
|
||||
msg.HideChat = hideChat;
|
||||
_netManager.ServerSendToMany(msg, clients);
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,8 @@ namespace Content.Server.Chat.Managers
|
||||
|
||||
void DispatchServerMessage(IPlayerSession player, string message);
|
||||
|
||||
void EntitySay(IEntity source, string message);
|
||||
/// <param name="hideChat">If true, message will not be logged to chat boxes but will still produce a speech bubble.</param>
|
||||
void EntitySay(IEntity source, string message, bool hideChat=false);
|
||||
void EntityMe(IEntity source, string action);
|
||||
|
||||
void SendOOC(IPlayerSession player, string message);
|
||||
|
||||
@@ -40,6 +40,8 @@ namespace Content.Shared.Chat
|
||||
/// </summary>
|
||||
public Color MessageColorOverride { get; set; } = Color.Transparent;
|
||||
|
||||
public bool HideChat { get; set; }
|
||||
|
||||
|
||||
public override void ReadFromBuffer(NetIncomingMessage buffer)
|
||||
{
|
||||
@@ -57,6 +59,7 @@ namespace Content.Shared.Chat
|
||||
break;
|
||||
}
|
||||
MessageColorOverride = buffer.ReadColor();
|
||||
HideChat = buffer.ReadBoolean();
|
||||
}
|
||||
|
||||
public override void WriteToBuffer(NetOutgoingMessage buffer)
|
||||
@@ -75,6 +78,7 @@ namespace Content.Shared.Chat
|
||||
break;
|
||||
}
|
||||
buffer.Write(MessageColorOverride);
|
||||
buffer.Write(HideChat);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user