add mixing categories to chem guidebook (#22566)

This commit is contained in:
Nemanja
2023-12-15 18:59:54 -05:00
committed by GitHub
parent 7e834489fe
commit 267c44fffd
6 changed files with 78 additions and 14 deletions

View File

@@ -6,8 +6,10 @@ using Content.Client.Message;
using Content.Client.UserInterface.ControlExtensions;
using Content.Shared.Chemistry.Reaction;
using Content.Shared.Chemistry.Reagent;
using Content.Shared.Localizations;
using JetBrains.Annotations;
using Robust.Client.AutoGenerated;
using Robust.Client.GameObjects;
using Robust.Client.Graphics;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
@@ -53,7 +55,7 @@ public sealed partial class GuideReagentEmbed : BoxContainer, IDocumentTag, ISea
public void SetHiddenState(bool state, string query)
{
this.Visible = CheckMatchesSearch(query) ? state : !state;
Visible = CheckMatchesSearch(query) ? state : !state;
}
public bool TryParseTag(Dictionary<string, string> args, [NotNullWhen(true)] out Control? control)
@@ -183,12 +185,6 @@ public sealed partial class GuideReagentEmbed : BoxContainer, IDocumentTag, ISea
reactantMsg.Pop();
control.ReactantsLabel.SetMessage(reactantMsg);
if (reactionPrototype.MinimumTemperature > 0.0f)
{
control.MixLabel.Text = Loc.GetString("guidebook-reagent-recipes-mix-and-heat",
("temperature", reactionPrototype.MinimumTemperature));
}
var productMsg = new FormattedMessage();
var productCount = reactionPrototype.Products.Count;
var u = 0;
@@ -202,6 +198,33 @@ public sealed partial class GuideReagentEmbed : BoxContainer, IDocumentTag, ISea
}
productMsg.Pop();
control.ProductsLabel.SetMessage(productMsg);
var mixingCategories = new List<MixingCategoryPrototype>();
if (reactionPrototype.MixingCategories != null)
{
foreach (var category in reactionPrototype.MixingCategories)
{
mixingCategories.Add(_prototype.Index(category));
}
}
// only use the first one for the icon.
if (mixingCategories.FirstOrDefault() is { } primaryCategory)
{
control.MixTexture.Texture = _systemManager.GetEntitySystem<SpriteSystem>().Frame0(primaryCategory.Icon);
}
var mixingVerb = mixingCategories.Count == 0
? Loc.GetString("guidebook-reagent-recipes-mix")
: ContentLocalizationManager.FormatList(mixingCategories.Select(p => Loc.GetString(p.VerbText)).ToList());
var text = Loc.GetString("guidebook-reagent-recipes-mix-info",
("verb", mixingVerb),
("minTemp", reactionPrototype.MinimumTemperature),
("maxTemp", reactionPrototype.MaximumTemperature),
("hasMax", !float.IsPositiveInfinity(reactionPrototype.MaximumTemperature)));
control.MixLabel.SetMarkup(text);
return control;
}
}