Everything: Rich text redux (#5625)
* lord save me * UI/ChatBox: Use the new `defStyle` param for `RenderMarkup` The previous iteration didn't work because `AddMessage` can't inherit its color from the PushColor (since we're not doing actual tag stacks anymore). * rebase touchup
This commit is contained in:
@@ -13,6 +13,7 @@ using Robust.Shared.Map;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Utility;
|
||||
using Robust.Shared.Utility.Markup;
|
||||
using static Content.Shared.Interaction.SharedInteractionSystem;
|
||||
|
||||
namespace Content.Shared.Examine
|
||||
@@ -25,7 +26,7 @@ namespace Content.Shared.Examine
|
||||
/// </summary>
|
||||
/// <param name="message">The message to append to which will be displayed.</param>
|
||||
/// <param name="inDetailsRange">Whether the examiner is within the 'Details' range, allowing you to show information logically only availabe when close to the examined entity.</param>
|
||||
void Examine(FormattedMessage message, bool inDetailsRange);
|
||||
void Examine(FormattedMessage.Builder message, bool inDetailsRange);
|
||||
}
|
||||
|
||||
public abstract class ExamineSystemShared : EntitySystem
|
||||
@@ -212,11 +213,11 @@ namespace Content.Shared.Examine
|
||||
|
||||
public FormattedMessage GetExamineText(EntityUid entity, EntityUid? examiner)
|
||||
{
|
||||
var message = new FormattedMessage();
|
||||
var message = new FormattedMessage.Builder();
|
||||
|
||||
if (examiner == null)
|
||||
{
|
||||
return message;
|
||||
return new(new Section[] {});
|
||||
}
|
||||
|
||||
var doNewline = false;
|
||||
@@ -238,21 +239,15 @@ namespace Content.Shared.Examine
|
||||
//Add component statuses from components that report one
|
||||
foreach (var examineComponent in EntityManager.GetComponents<IExamine>(entity))
|
||||
{
|
||||
var subMessage = new FormattedMessage();
|
||||
examineComponent.Examine(subMessage, isInDetailsRange);
|
||||
if (subMessage.Tags.Count == 0)
|
||||
continue;
|
||||
examineComponent.Examine(message, isInDetailsRange);
|
||||
|
||||
if (doNewline)
|
||||
message.AddText("\n");
|
||||
|
||||
message.AddMessage(subMessage);
|
||||
doNewline = true;
|
||||
}
|
||||
|
||||
message.Pop();
|
||||
|
||||
return message;
|
||||
return message.Build();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -269,7 +264,7 @@ namespace Content.Shared.Examine
|
||||
/// <seealso cref="PushMessage"/>
|
||||
/// <seealso cref="PushMarkup"/>
|
||||
/// <seealso cref="PushText"/>
|
||||
public FormattedMessage Message { get; }
|
||||
public FormattedMessage.Builder Message { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The entity performing the examining.
|
||||
@@ -288,7 +283,7 @@ namespace Content.Shared.Examine
|
||||
|
||||
private bool _doNewLine;
|
||||
|
||||
public ExaminedEvent(FormattedMessage message, EntityUid examined, EntityUid examiner, bool isInDetailsRange, bool doNewLine)
|
||||
public ExaminedEvent(FormattedMessage.Builder message, EntityUid examined, EntityUid examiner, bool isInDetailsRange, bool doNewLine)
|
||||
{
|
||||
Message = message;
|
||||
Examined = examined;
|
||||
@@ -304,9 +299,6 @@ namespace Content.Shared.Examine
|
||||
/// <seealso cref="PushText"/>
|
||||
public void PushMessage(FormattedMessage message)
|
||||
{
|
||||
if (message.Tags.Count == 0)
|
||||
return;
|
||||
|
||||
if (_doNewLine)
|
||||
Message.AddText("\n");
|
||||
|
||||
@@ -321,7 +313,7 @@ namespace Content.Shared.Examine
|
||||
/// <seealso cref="PushMessage"/>
|
||||
public void PushMarkup(string markup)
|
||||
{
|
||||
PushMessage(FormattedMessage.FromMarkup(markup));
|
||||
PushMessage(Basic.RenderMarkup(markup));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -329,11 +321,6 @@ namespace Content.Shared.Examine
|
||||
/// </summary>
|
||||
/// <seealso cref="PushMarkup"/>
|
||||
/// <seealso cref="PushMessage"/>
|
||||
public void PushText(string text)
|
||||
{
|
||||
var msg = new FormattedMessage();
|
||||
msg.AddText(text);
|
||||
PushMessage(msg);
|
||||
}
|
||||
public void PushText(string text) => Message.AddText(text);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user