]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Fix some lathe recipe textures showing up blank (#28683)
authorPlykiya <58439124+Plykiya@users.noreply.github.com>
Wed, 19 Jun 2024 03:18:45 +0000 (20:18 -0700)
committerGitHub <noreply@github.com>
Wed, 19 Jun 2024 03:18:45 +0000 (13:18 +1000)
* Update lathes to use entity prototype

* ScrollContainer my hero

* gets rid of excess newlines

---------

Co-authored-by: plykiya <plykiya@protonmail.com>
Content.Client/Lathe/UI/LatheMenu.xaml
Content.Client/Lathe/UI/LatheMenu.xaml.cs
Content.Client/Lathe/UI/RecipeControl.xaml
Content.Client/Lathe/UI/RecipeControl.xaml.cs

index 6f484d8c7be8286395dce5a9256a217cd33d4200..e3247fe7037af77b111fe96ede78d43af96bdac3 100644 (file)
                             Margin="5 0 0 0"
                             Text="{Loc 'lathe-menu-fabricating-message'}">
                         </Label>
-                        <TextureRect
-                            Name="Icon"
-                            HorizontalExpand="True"
-                            SizeFlagsStretchRatio="2"
-                            Margin="100 0 0 0">
-                        </TextureRect>
+                        <EntityPrototypeView
+                            Name="FabricatingEntityProto"
+                            HorizontalAlignment="Left"
+                            Margin="100 0 0 0"
+                             />
                         <Label
                             Name="NameLabel"
                             RectClipContent="True"
                         </Label>
                     </PanelContainer>
                 </BoxContainer>
-                <ItemList
-                    Name="QueueList"
-                    VerticalExpand="True"
-                    SizeFlagsStretchRatio="3"
-                    SelectMode="None">
-                </ItemList>
+                <ScrollContainer VerticalExpand="True" HScrollEnabled="False">
+                    <BoxContainer
+                        Name="QueueList"
+                        Orientation="Vertical"
+                        HorizontalExpand="True"
+                        VerticalExpand="True"
+                        RectClipContent="True">
+                    </BoxContainer>
+                </ScrollContainer>
             </BoxContainer>
             <BoxContainer
             VerticalExpand="True"
index 40f553fcd663180bf772c741f813dbded4fd835e..d4bbe89c51fa19d28d5be868ce42325f1288006f 100644 (file)
@@ -105,21 +105,13 @@ public sealed partial class LatheMenu : DefaultWindow
         RecipeList.Children.Clear();
         foreach (var prototype in sortedRecipesToShow)
         {
-            List<Texture> textures;
+            EntityPrototype? recipeProto = null;
             if (_prototypeManager.TryIndex(prototype.Result, out EntityPrototype? entityProto) && entityProto != null)
-            {
-                textures = SpriteComponent.GetPrototypeTextures(entityProto, _resources).Select(o => o.Default).ToList();
-            }
-            else
-            {
-                textures = prototype.Icon == null
-                    ? new List<Texture> { _spriteSystem.GetPrototypeIcon(prototype.Result).Default }
-                    : new List<Texture> { _spriteSystem.Frame0(prototype.Icon) };
-            }
+                recipeProto = entityProto;
 
             var canProduce = _lathe.CanProduce(_owner, prototype, quantity);
 
-            var control = new RecipeControl(prototype, () => GenerateTooltipText(prototype), canProduce, textures);
+            var control = new RecipeControl(prototype, () => GenerateTooltipText(prototype), canProduce, recipeProto);
             control.OnButtonPressed += s =>
             {
                 if (!int.TryParse(AmountLineEdit.Text, out var amount) || amount <= 0)
@@ -216,14 +208,23 @@ public sealed partial class LatheMenu : DefaultWindow
     /// <param name="queue"></param>
     public void PopulateQueueList(List<LatheRecipePrototype> queue)
     {
-        QueueList.Clear();
+        QueueList.DisposeAllChildren();
+
         var idx = 1;
         foreach (var recipe in queue)
         {
-            var icon = recipe.Icon == null
-                ? _spriteSystem.GetPrototypeIcon(recipe.Result).Default
-                : _spriteSystem.Frame0(recipe.Icon);
-            QueueList.AddItem($"{idx}. {recipe.Name}", icon);
+            var queuedRecipeBox = new BoxContainer();
+            queuedRecipeBox.Orientation = BoxContainer.LayoutOrientation.Horizontal;
+
+            var queuedRecipeProto = new EntityPrototypeView();
+            if (_prototypeManager.TryIndex(recipe.Result, out EntityPrototype? entityProto) && entityProto != null)
+                queuedRecipeProto.SetPrototype(entityProto);
+
+            var queuedRecipeLabel = new Label();
+            queuedRecipeLabel.Text = $"{idx}. {recipe.Name}";
+            queuedRecipeBox.AddChild(queuedRecipeProto);
+            queuedRecipeBox.AddChild(queuedRecipeLabel);
+            QueueList.AddChild(queuedRecipeBox);
             idx++;
         }
     }
@@ -233,9 +234,10 @@ public sealed partial class LatheMenu : DefaultWindow
         FabricatingContainer.Visible = recipe != null;
         if (recipe == null)
             return;
-        Icon.Texture = recipe.Icon == null
-            ? _spriteSystem.GetPrototypeIcon(recipe.Result).Default
-            : _spriteSystem.Frame0(recipe.Icon);
+
+        if (_prototypeManager.TryIndex(recipe.Result, out EntityPrototype? entityProto) && entityProto != null)
+            FabricatingEntityProto.SetPrototype(entityProto);
+
         NameLabel.Text = $"{recipe.Name}";
     }
 
index d1371a026a22a61f2315ab4a521d92d067ee7655..19e20c7c06d3e553887294cb5efc587e9725230e 100644 (file)
@@ -5,14 +5,12 @@
         Margin="0"
         StyleClasses="ButtonSquare">
         <BoxContainer Orientation="Horizontal">
-            <LayeredTextureRect
-                Name="RecipeTextures"
+            <EntityPrototypeView
+                Name="RecipePrototype"
                 Margin="0 0 4 0"
                 HorizontalAlignment="Center"
                 VerticalAlignment="Center"
-                Stretch="KeepAspectCentered"
                 MinSize="32 32"
-                CanShrink="true"
                 />
             <Label Name="RecipeName" HorizontalExpand="True" />
         </BoxContainer>
index 47b6b5932c475d5deda22e61c5cc3da6ae8a5ba9..db428d3cf0e92967d77a676a5d8c59b5155fd390 100644 (file)
@@ -4,6 +4,7 @@ using Robust.Client.Graphics;
 using Robust.Client.UserInterface;
 using Robust.Client.UserInterface.Controls;
 using Robust.Client.UserInterface.XAML;
+using Robust.Shared.Prototypes;
 
 namespace Content.Client.Lathe.UI;
 
@@ -13,12 +14,13 @@ public sealed partial class RecipeControl : Control
     public Action<string>? OnButtonPressed;
     public Func<string> TooltipTextSupplier;
 
-    public RecipeControl(LatheRecipePrototype recipe, Func<string> tooltipTextSupplier, bool canProduce, List<Texture> textures)
+    public RecipeControl(LatheRecipePrototype recipe, Func<string> tooltipTextSupplier, bool canProduce, EntityPrototype? entityPrototype = null)
     {
         RobustXamlLoader.Load(this);
 
         RecipeName.Text = recipe.Name;
-        RecipeTextures.Textures = textures;
+        if (entityPrototype != null)
+            RecipePrototype.SetPrototype(entityPrototype);
         Button.Disabled = !canProduce;
         TooltipTextSupplier = tooltipTextSupplier;
         Button.TooltipSupplier = SupplyTooltip;