Add description in lathe recipe mouseover tooltip (#22621)

* Add description in lathe recipe mouseover tooltip

* Remove old tooltip
This commit is contained in:
Justin
2023-12-16 18:06:38 -08:00
committed by GitHub
parent 432c87f7e2
commit 07f87f93d2
5 changed files with 52 additions and 1 deletions

View 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(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 var icon = prototype.Icon == null
? _spriteSystem.GetPrototypeIcon(prototype.Result).Default ? _spriteSystem.GetPrototypeIcon(prototype.Result).Default
: _spriteSystem.Frame0(prototype.Icon); : _spriteSystem.Frame0(prototype.Icon);

View File

@@ -12,18 +12,26 @@ public sealed partial class RecipeControl : Control
{ {
public Action<string>? OnButtonPressed; public Action<string>? OnButtonPressed;
public string TooltipText;
public RecipeControl(LatheRecipePrototype recipe, string tooltip, bool canProduce, Texture? texture = null) public RecipeControl(LatheRecipePrototype recipe, string tooltip, bool canProduce, Texture? texture = null)
{ {
RobustXamlLoader.Load(this); RobustXamlLoader.Load(this);
RecipeName.Text = recipe.Name; RecipeName.Text = recipe.Name;
RecipeTexture.Texture = texture; RecipeTexture.Texture = texture;
Button.ToolTip = tooltip;
Button.Disabled = !canProduce; Button.Disabled = !canProduce;
TooltipText = tooltip;
Button.TooltipSupplier = SupplyTooltip;
Button.OnPressed += (_) => Button.OnPressed += (_) =>
{ {
OnButtonPressed?.Invoke(recipe.ID); OnButtonPressed?.Invoke(recipe.ID);
}; };
} }
private Control? SupplyTooltip(Control sender)
{
return new RecipeTooltip(TooltipText);
}
} }

View File

@@ -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>

View File

@@ -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);
}
}

View File

@@ -7,6 +7,7 @@ lathe-menu-search-filter = Filter
lathe-menu-amount = Amount: lathe-menu-amount = Amount:
lathe-menu-material-display = {$material} ({$amount}) lathe-menu-material-display = {$material} ({$amount})
lathe-menu-tooltip-display = {$amount} of {$material} lathe-menu-tooltip-display = {$amount} of {$material}
lathe-menu-description-display = {$description}
lathe-menu-material-amount = { $amount -> lathe-menu-material-amount = { $amount ->
[1] {NATURALFIXED($amount, 2)} {$unit} [1] {NATURALFIXED($amount, 2)} {$unit}
*[other] {NATURALFIXED($amount, 2)} {MAKEPLURAL($unit)} *[other] {NATURALFIXED($amount, 2)} {MAKEPLURAL($unit)}