]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
add mixing categories to chem guidebook (#22566)
authorNemanja <98561806+EmoGarbage404@users.noreply.github.com>
Fri, 15 Dec 2023 23:59:54 +0000 (18:59 -0500)
committerGitHub <noreply@github.com>
Fri, 15 Dec 2023 23:59:54 +0000 (16:59 -0700)
Content.Client/Guidebook/Controls/GuideReagentEmbed.xaml.cs
Content.Client/Guidebook/Controls/GuideReagentReaction.xaml
Content.Shared/Chemistry/Reaction/MixingCategoryPrototype.cs
Resources/Locale/en-US/chemistry/components/mixing-component.ftl
Resources/Locale/en-US/guidebook/chemistry/core.ftl
Resources/Prototypes/Chemistry/mixing_types.yml

index a292a93ea6d024086ced7c067cf7f1ee84a9c648..cf5a1b6e59cf7536e2a623d7a7dc467201967a0a 100644 (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;
     }
 }
index 3f10592519d74ac8dfcf7b9e34440ffe1eb8b41b..69c14a59af7a056bf76a3f8517493aa23afa7940 100644 (file)
@@ -8,13 +8,15 @@
                        VerticalAlignment="Center"
                        Access="Public"/>
     </BoxContainer>
-    <BoxContainer Orientation="Vertical"  VerticalAlignment="Center">
+    <BoxContainer Orientation="Vertical" HorizontalAlignment="Center" VerticalAlignment="Center">
         <TextureRect TexturePath="/Textures/Interface/Misc/beakerlarge.png"
-                     HorizontalAlignment="Center"/>
-        <Label Name="MixLabel"
-               Text="{Loc 'guidebook-reagent-recipes-mix'}"
-               HorizontalAlignment="Center"
-               Access="Public"/>
+                     HorizontalAlignment="Center"
+                     Name="MixTexture"
+                     Access="Public"/>
+        <RichTextLabel Name="MixLabel"
+                       HorizontalAlignment="Center"
+                       Access="Public"
+                       Margin="2 0 0 0"/>
     </BoxContainer>
     <BoxContainer Orientation="Vertical" HorizontalExpand="True" VerticalAlignment="Center">
         <RichTextLabel Name="ProductsLabel"
index 30d110a45994d4038f9d0f0164da98748644fa5a..2456fbf7335403070945d6a32609a50e9f4bd99a 100644 (file)
@@ -1,4 +1,5 @@
 using Robust.Shared.Prototypes;
+using Robust.Shared.Utility;
 
 namespace Content.Shared.Chemistry.Reaction;
 
@@ -11,4 +12,16 @@ public sealed partial class MixingCategoryPrototype : IPrototype
     /// <inheritdoc/>
     [IdDataField]
     public string ID { get; } = default!;
+
+    /// <summary>
+    /// A locale string used in the guidebook to describe this mixing category.
+    /// </summary>
+    [DataField(required: true)]
+    public LocId VerbText;
+
+    /// <summary>
+    /// An icon used to represent this mixing category in the guidebook.
+    /// </summary>
+    [DataField(required: true)]
+    public SpriteSpecifier Icon = default!;
 }
index 2abe5644f59cad2c2505291c82e9e82c3e583a40..1ad9958804b73726bb46e3a7820f0bc3338f5e59 100644 (file)
@@ -1,3 +1,8 @@
+# Types
+mixing-verb-centrifuge = centrifugation
+mixing-verb-electrolysis = electrolyze
+mixing-verb-holy = bless
+
 ## Entity
 
 default-mixing-success = You mix the {$mixed} with the {$mixer}
index 960a9972c4ced8837d8e60ee551299c5f6305f74..7b39a6317573585ec80986206b084428afa18d69 100644 (file)
@@ -11,7 +11,16 @@ guidebook-reagent-name = [bold][color={$color}]{CAPITALIZE($name)}[/color][/bold
 guidebook-reagent-recipes-header = Recipe
 guidebook-reagent-recipes-reagent-display = [bold]{$reagent}[/bold] \[{$ratio}\]
 guidebook-reagent-recipes-mix = Mix
-guidebook-reagent-recipes-mix-and-heat = Mix at above {$temperature}K
 guidebook-reagent-effects-header = Effects
 guidebook-reagent-effects-metabolism-group-rate = [bold]{$group}[/bold] [color=gray]({$rate} units per second)[/color]
 guidebook-reagent-physical-description = [italic]Seems to be {$description}.[/italic]
+guidebook-reagent-recipes-mix-info = {$minTemp ->
+    [0] {$hasMax ->
+            [true] {$verb} below {$maxTemp}K
+            *[false] {$verb}
+        }
+    *[other] {$verb} {$hasMax ->
+            [true] between {$minTemp}K and {$maxTemp}K
+            *[false] above {$minTemp}K
+        }
+}
index e32afa43fa4714b057e10a6b18926baee7a08ef3..dbf14c19c1fbde4df34c4453de495331b0512d8e 100644 (file)
@@ -1,8 +1,20 @@
 - type: mixingCategory
   id: Centrifuge
+  verbText: mixing-verb-centrifuge
+  icon:
+    sprite: Structures/Machines/Medical/centrifuge.rsi
+    state: base
 
 - type: mixingCategory
   id: Electrolysis
+  verbText: mixing-verb-electrolysis
+  icon:
+    sprite: Structures/Machines/Medical/electrolysis.rsi
+    state: base
 
 - type: mixingCategory
   id: Holy
+  verbText: mixing-verb-holy
+  icon:
+    sprite: Objects/Specific/Chapel/bible.rsi
+    state: icon