]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Add description in lathe recipe mouseover tooltip (#22621)
authorJustin <justinly@usc.edu>
Sun, 17 Dec 2023 02:06:38 +0000 (18:06 -0800)
committerGitHub <noreply@github.com>
Sun, 17 Dec 2023 02:06:38 +0000 (21:06 -0500)
* Add description in lathe recipe mouseover tooltip

* Remove old tooltip

Content.Client/Lathe/UI/LatheMenu.xaml.cs
Content.Client/Lathe/UI/RecipeControl.xaml.cs
Content.Client/Lathe/UI/RecipeTooltip.xaml [new file with mode: 0644]
Content.Client/Lathe/UI/RecipeTooltip.xaml.cs [new file with mode: 0644]
Resources/Locale/en-US/lathe/ui/lathe-menu.ftl

index 3b3d90293c174cb542c10e6aadc1c83cb3264a0c..71b45fc7dc61b552d7b8b3b23d8b343135a46683 100644 (file)
@@ -157,6 +157,9 @@ public sealed partial class LatheMenu : DefaultWindow
                 sb.Append(Loc.GetString("lathe-menu-tooltip-display", ("material", name), ("amount", amountText)));
             }
 
+            sb.Append('\n');
+            sb.Append(Loc.GetString("lathe-menu-description-display", ("description", prototype.Description)));
+
             var icon = prototype.Icon == null
                 ? _spriteSystem.GetPrototypeIcon(prototype.Result).Default
                 : _spriteSystem.Frame0(prototype.Icon);
index 87ebd6e338e3a5c1c183b9398f6df3e60ddfa4ea..451a988765f8db72a40a9e14981ee3196b561e1f 100644 (file)
@@ -12,18 +12,26 @@ public sealed partial class RecipeControl : Control
 {
     public Action<string>? OnButtonPressed;
 
+    public string TooltipText;
+
     public RecipeControl(LatheRecipePrototype recipe, string tooltip, bool canProduce, Texture? texture = null)
     {
         RobustXamlLoader.Load(this);
 
         RecipeName.Text = recipe.Name;
         RecipeTexture.Texture = texture;
-        Button.ToolTip = tooltip;
         Button.Disabled = !canProduce;
+        TooltipText = tooltip;
+        Button.TooltipSupplier = SupplyTooltip;
 
         Button.OnPressed += (_) =>
         {
             OnButtonPressed?.Invoke(recipe.ID);
         };
     }
+
+    private Control? SupplyTooltip(Control sender)
+    {
+        return new RecipeTooltip(TooltipText);
+    }
 }
diff --git a/Content.Client/Lathe/UI/RecipeTooltip.xaml b/Content.Client/Lathe/UI/RecipeTooltip.xaml
new file mode 100644 (file)
index 0000000..8cb0ec5
--- /dev/null
@@ -0,0 +1,19 @@
+<Control xmlns="https://spacestation14.io"
+         xmlns:gfx="clr-namespace:Robust.Client.Graphics;assembly=Robust.Client"
+         MaxWidth="400">
+    <PanelContainer>
+        <PanelContainer.PanelOverride>
+            <gfx:StyleBoxFlat 
+                BorderThickness="2" 
+                BorderColor="#464966"
+                BackgroundColor="#25252A"
+            />
+        </PanelContainer.PanelOverride>
+        <BoxContainer 
+            Orientation="Vertical"
+            RectClipContent="True"
+            Margin="4">
+            <RichTextLabel Name="RecipeTooltipLabel" HorizontalExpand="True" />
+        </BoxContainer>
+    </PanelContainer>
+</Control>
diff --git a/Content.Client/Lathe/UI/RecipeTooltip.xaml.cs b/Content.Client/Lathe/UI/RecipeTooltip.xaml.cs
new file mode 100644 (file)
index 0000000..5d2e3ca
--- /dev/null
@@ -0,0 +1,20 @@
+using Content.Shared.Research.Prototypes;
+using Robust.Client.AutoGenerated;
+using Robust.Client.Graphics;
+using Robust.Client.UserInterface;
+using Robust.Client.UserInterface.XAML;
+using Robust.Shared.Graphics;
+
+namespace Content.Client.Lathe.UI;
+
+[GenerateTypedNameReferences]
+public sealed partial class RecipeTooltip : Control
+{
+
+    public RecipeTooltip(string tooltip)
+    {
+        RobustXamlLoader.Load(this);
+
+        RecipeTooltipLabel.SetMessage(tooltip);
+    }
+}
index 914bb64b4ff74f3aa097681cdbac7630fc6eeb60..3ccdb2b0eb3c4a169a10fb7962b81df353b8a286 100644 (file)
@@ -7,6 +7,7 @@ lathe-menu-search-filter = Filter
 lathe-menu-amount = Amount:
 lathe-menu-material-display = {$material} ({$amount})
 lathe-menu-tooltip-display = {$amount} of {$material}
+lathe-menu-description-display = {$description}
 lathe-menu-material-amount = { $amount ->
     [1] {NATURALFIXED($amount, 2)} {$unit}
     *[other] {NATURALFIXED($amount, 2)} {MAKEPLURAL($unit)}