Link to reagent ingredients on the same Guidebook page (#36700)
* Add in-page links for guidebook reagent recipes * Add links to microwave recipes * This function is too specific to be in Control extensions * Better naming * Wrap RichTextLabel instead of subclassing * "Activate" is ambiguous
This commit is contained in:
@@ -19,13 +19,15 @@ namespace Content.Client.Guidebook.Controls;
|
||||
/// Control for embedding a microwave recipe into a guidebook.
|
||||
/// </summary>
|
||||
[UsedImplicitly, GenerateTypedNameReferences]
|
||||
public sealed partial class GuideMicrowaveEmbed : PanelContainer, IDocumentTag, ISearchableControl
|
||||
public sealed partial class GuideMicrowaveEmbed : PanelContainer, IDocumentTag, ISearchableControl, IPrototypeRepresentationControl
|
||||
{
|
||||
[Dependency] private readonly IPrototypeManager _prototype = default!;
|
||||
[Dependency] private readonly ILogManager _logManager = default!;
|
||||
|
||||
private ISawmill _sawmill = default!;
|
||||
|
||||
public IPrototype? RepresentedPrototype { get; private set; }
|
||||
|
||||
public GuideMicrowaveEmbed()
|
||||
{
|
||||
RobustXamlLoader.Load(this);
|
||||
@@ -80,6 +82,8 @@ public sealed partial class GuideMicrowaveEmbed : PanelContainer, IDocumentTag,
|
||||
{
|
||||
var entity = _prototype.Index<EntityPrototype>(recipe.Result);
|
||||
|
||||
RepresentedPrototype = entity;
|
||||
|
||||
IconContainer.AddChild(new GuideEntityEmbed(recipe.Result, false, false));
|
||||
ResultName.SetMarkup(entity.Name);
|
||||
ResultDescription.SetMarkup(entity.Description);
|
||||
@@ -99,8 +103,9 @@ public sealed partial class GuideMicrowaveEmbed : PanelContainer, IDocumentTag,
|
||||
solidNameMsg.AddMarkupOrThrow(Loc.GetString("guidebook-microwave-solid-name-display", ("ingredient", ingredient.Name)));
|
||||
solidNameMsg.Pop();
|
||||
|
||||
var solidNameLabel = new RichTextLabel();
|
||||
var solidNameLabel = new GuidebookRichPrototypeLink();
|
||||
solidNameLabel.SetMessage(solidNameMsg);
|
||||
solidNameLabel.LinkedPrototype = ingredient;
|
||||
|
||||
IngredientsGrid.AddChild(solidNameLabel);
|
||||
|
||||
@@ -129,9 +134,10 @@ public sealed partial class GuideMicrowaveEmbed : PanelContainer, IDocumentTag,
|
||||
liquidColorMsg.AddMarkupOrThrow(Loc.GetString("guidebook-microwave-reagent-color-display", ("color", reagent.SubstanceColor)));
|
||||
liquidColorMsg.Pop();
|
||||
|
||||
var liquidColorLabel = new RichTextLabel();
|
||||
var liquidColorLabel = new GuidebookRichPrototypeLink();
|
||||
liquidColorLabel.SetMessage(liquidColorMsg);
|
||||
liquidColorLabel.HorizontalAlignment = Control.HAlignment.Center;
|
||||
liquidColorLabel.LinkedPrototype = reagent;
|
||||
|
||||
IngredientsGrid.AddChild(liquidColorLabel);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user