mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-09 18:31:17 +03:00
* IoC source gen compatibility Can be merged before or after https://github.com/space-wizards/RobustToolbox/pull/6549 doesn't really matter. * Missed a spot
63 lines
1.8 KiB
C#
63 lines
1.8 KiB
C#
using System.Diagnostics.CodeAnalysis;
|
|
using System.Linq;
|
|
using Content.Client.Guidebook.Richtext;
|
|
using Content.Shared.Kitchen;
|
|
using JetBrains.Annotations;
|
|
using Robust.Client.UserInterface.Controls;
|
|
using Robust.Client.UserInterface;
|
|
using Robust.Shared.Prototypes;
|
|
|
|
namespace Content.Client.Guidebook.Controls;
|
|
|
|
/// <summary>
|
|
/// Control for listing microwave recipes in a guidebook
|
|
/// </summary>
|
|
[UsedImplicitly]
|
|
public sealed partial class GuideMicrowaveGroupEmbed : BoxContainer, IDocumentTag
|
|
{
|
|
[Dependency] private ILogManager _logManager = default!;
|
|
[Dependency] private IPrototypeManager _prototype = default!;
|
|
|
|
private readonly ISawmill _sawmill;
|
|
|
|
public GuideMicrowaveGroupEmbed()
|
|
{
|
|
Orientation = LayoutOrientation.Vertical;
|
|
IoCManager.InjectDependencies(this);
|
|
_sawmill = _logManager.GetSawmill("guidebook.microwave_group");
|
|
MouseFilter = MouseFilterMode.Stop;
|
|
}
|
|
|
|
public GuideMicrowaveGroupEmbed(string group) : this()
|
|
{
|
|
CreateEntries(group);
|
|
}
|
|
|
|
public bool TryParseTag(Dictionary<string, string> args, [NotNullWhen(true)] out Control? control)
|
|
{
|
|
control = null;
|
|
if (!args.TryGetValue("Group", out var group))
|
|
{
|
|
_sawmill.Error("Microwave group embed tag is missing group argument");
|
|
return false;
|
|
}
|
|
|
|
CreateEntries(group);
|
|
|
|
control = this;
|
|
return true;
|
|
}
|
|
|
|
private void CreateEntries(string group)
|
|
{
|
|
var prototypes = _prototype.EnumeratePrototypes<FoodRecipePrototype>()
|
|
.Where(p => p.Group.Equals(group))
|
|
.OrderBy(p => p.Name);
|
|
|
|
foreach (var recipe in prototypes)
|
|
{
|
|
var embed = new GuideMicrowaveEmbed(recipe);
|
|
AddChild(embed);
|
|
}
|
|
}
|
|
}
|