using System.Linq; using Content.Client.Chemistry.EntitySystems; using Content.Client.Guidebook.Controls; using Content.Client.UserInterface.ControlExtensions; using Content.Shared.Chemistry.Reagent; using Content.Shared.FixedPoint; using Content.Shared.Kitchen; using JetBrains.Annotations; using Robust.Client.AutoGenerated; using Robust.Client.GameObjects; using Robust.Client.Graphics; using Robust.Client.UserInterface.Controls; using Robust.Client.UserInterface.XAML; using Robust.Shared.Prototypes; using Robust.Shared.Utility; namespace Content.Client._NF.Guidebook.Controls; [UsedImplicitly, GenerateTypedNameReferences] public sealed partial class GuideMedicalSource : BoxContainer, ISearchableControl { private readonly IPrototypeManager _protoMan; private readonly SpriteSystem _sprites = default!; public GuideMedicalSource(IPrototypeManager protoMan) { RobustXamlLoader.Load(this); _protoMan = protoMan; _sprites = IoCManager.Resolve().GetEntitySystem(); } public GuideMedicalSource(EntityPrototype result, MedicalRecipeData entry, IPrototypeManager protoMan) : this(protoMan) { GenerateControl(entry); GenerateOutputs(result, entry); } private void GenerateControl(MedicalRecipeData entry) { if (!_protoMan.TryIndex(entry.Recipe, out var recipe)) { SourceLabel.Text = Loc.GetString("guidebook-food-unknown-proto", ("id", entry.Result)); // Frontier: SetMessage _protoMan.TryIndex(it.Key, out var proto) ? FormatIngredient(proto, it.Value) : "") .Where(it => it.Length > 0); var combinedLiquids = recipe.IngredientsReagents .Select(it => _protoMan.TryIndex(it.Key, out var proto) ? FormatIngredient(proto, it.Value) : "") .Where(it => it.Length > 0); var combinedIngredients = string.Join("\n", combinedLiquids.Union(combinedSolids)); SourceLabel.Text = Loc.GetString("guidebook-food-processing-recipe", ("ingredients", combinedIngredients)); // Frontier: SetMessage