using Robust.Client.AutoGenerated;
using Robust.Client.Graphics;
using Robust.Client.UserInterface.Controls;
+using Robust.Client.UserInterface.CustomControls;
using Robust.Client.UserInterface.XAML;
using Robust.Client.Utility;
using Robust.Shared.Utility;
Disabled = true;
}
- ToolTip = verb.Message ?? verb.Text;
+ TooltipSupplier = sender =>
+ {
+ var label = new RichTextLabel();
+ label.SetMessage(FormattedMessage.FromMarkupOrThrow(verb.Message ?? verb.Text));
+
+ var tooltip = new Tooltip();
+ tooltip.GetChild(0).Children.Clear();
+ tooltip.GetChild(0).Children.Add(label);
+
+ return tooltip;
+ };
Icon = new TextureRect
{
{
Name = "ExamineButtonsHBox",
Orientation = LayoutOrientation.Horizontal,
- HorizontalAlignment = Control.HAlignment.Right,
+ HorizontalAlignment = Control.HAlignment.Stretch,
VerticalAlignment = Control.VAlignment.Bottom,
};
+ var hoverExamineBox = new BoxContainer
+ {
+ Name = "HoverExamineHBox",
+ Orientation = LayoutOrientation.Horizontal,
+ HorizontalAlignment = Control.HAlignment.Left,
+ VerticalAlignment = Control.VAlignment.Center,
+ HorizontalExpand = true
+ };
+
+ var clickExamineBox = new BoxContainer
+ {
+ Name = "ClickExamineHBox",
+ Orientation = LayoutOrientation.Horizontal,
+ HorizontalAlignment = Control.HAlignment.Right,
+ VerticalAlignment = Control.VAlignment.Center,
+ HorizontalExpand = true
+ };
+
// Examine button time
foreach (var verb in verbs)
{
var button = new ExamineButton(examine);
- button.OnPressed += VerbButtonPressed;
- buttonsHBox.AddChild(button);
+ if (examine.HoverVerb)
+ {
+ hoverExamineBox.AddChild(button);
+ }
+ else
+ {
+ button.OnPressed += VerbButtonPressed;
+ clickExamineBox.AddChild(button);
+ }
}
var vbox = _examineTooltipOpen?.GetChild(0).GetChild(0);
{
vbox.Children.Remove(hbox.First());
}
+ buttonsHBox.AddChild(hoverExamineBox);
+ buttonsHBox.AddChild(clickExamineBox);
vbox.AddChild(buttonsHBox);
}
using Content.Shared.Verbs;
using Robust.Client.GameObjects;
using Robust.Client.UserInterface.Controls;
+using Robust.Client.UserInterface.CustomControls;
using Robust.Client.Utility;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Maths;
+using Robust.Shared.Utility;
namespace Content.Client.Verbs.UI
{
public VerbMenuElement(Verb verb) : base(verb.Text)
{
- ToolTip = verb.Message;
+ TooltipSupplier = sender =>
+ {
+ var label = new RichTextLabel();
+ label.SetMessage(FormattedMessage.FromMarkupOrThrow(verb.Message ?? verb.Text));
+
+ var tooltip = new Tooltip();
+ tooltip.GetChild(0).Children.Clear();
+ tooltip.GetChild(0).Children.Add(label);
+
+ return tooltip;
+ };
Disabled = verb.Disabled;
Verb = verb;
{
// maybe send an informative pop-up message.
if (!string.IsNullOrWhiteSpace(verb.Message))
- _popupSystem.PopupEntity(verb.Message, user);
+ _popupSystem.PopupEntity(FormattedMessage.RemoveMarkupOrThrow(verb.Message), user);
return;
}
using Content.Shared.Hands.Components;
using Content.Shared.Inventory.VirtualItem;
using Content.Shared.Verbs;
+using Robust.Shared.Utility;
namespace Content.Server.Verbs
{
{
// Send an informative pop-up message
if (!string.IsNullOrWhiteSpace(verb.Message))
- _popupSystem.PopupEntity(verb.Message, user, user);
+ _popupSystem.PopupEntity(FormattedMessage.RemoveMarkupOrThrow(verb.Message), user, user);
return;
}
/// <summary>
/// Either sends the details to a GroupExamineComponent if it finds one, or adds a details examine verb itself.
/// </summary>
- public void AddDetailedExamineVerb(GetVerbsEvent<ExamineVerb> verbsEvent, Component component, List<ExamineEntry> entries, string verbText, string iconTexture = DefaultIconTexture, string hoverMessage = "")
+ public void AddDetailedExamineVerb(GetVerbsEvent<ExamineVerb> verbsEvent, Component component, List<ExamineEntry> entries, string verbText, string iconTexture = DefaultIconTexture, string hoverMessage = "", bool isHoverExamine = false)
{
// If the entity has the GroupExamineComponent
if (TryComp<GroupExamineComponent>(verbsEvent.Target, out var groupExamine))
}
var formattedMessage = GetFormattedMessageFromExamineEntries(entries);
+ var act = () =>
+ {
+ SendExamineTooltip(verbsEvent.User, verbsEvent.Target, formattedMessage, false, false);
+ };
+ if (isHoverExamine)
+ {
+ act = () => { };
+ }
var examineVerb = new ExamineVerb()
{
- Act = () =>
- {
- SendExamineTooltip(verbsEvent.User, verbsEvent.Target, formattedMessage, false, false);
- },
+ Act = act,
Text = verbText,
Message = hoverMessage,
Category = VerbCategory.Examine,
Icon = new SpriteSpecifier.Texture(new(iconTexture)),
+ HoverVerb = isHoverExamine
};
verbsEvent.Verbs.Add(examineVerb);
/// <summary>
/// Either adds a details examine verb, or sends the details to a GroupExamineComponent if it finds one.
/// </summary>
- public void AddDetailedExamineVerb(GetVerbsEvent<ExamineVerb> verbsEvent, Component component, ExamineEntry entry, string verbText, string iconTexture = DefaultIconTexture, string hoverMessage = "")
+ public void AddDetailedExamineVerb(GetVerbsEvent<ExamineVerb> verbsEvent, Component component, ExamineEntry entry, string verbText, string iconTexture = DefaultIconTexture, string hoverMessage = "", bool isHoverExamine = false)
{
- AddDetailedExamineVerb(verbsEvent, component, new List<ExamineEntry> { entry }, verbText, iconTexture, hoverMessage);
+ AddDetailedExamineVerb(verbsEvent, component, new List<ExamineEntry> { entry }, verbText, iconTexture, hoverMessage, isHoverExamine);
}
/// <summary>
/// Either adds a details examine verb, or sends the details to a GroupExamineComponent if it finds one.
/// </summary>
- public void AddDetailedExamineVerb(GetVerbsEvent<ExamineVerb> verbsEvent, Component component, FormattedMessage message, string verbText, string iconTexture = DefaultIconTexture, string hoverMessage = "")
+ public void AddDetailedExamineVerb(GetVerbsEvent<ExamineVerb> verbsEvent, Component component, FormattedMessage message, string verbText, string iconTexture = DefaultIconTexture, string hoverMessage = "", bool isHoverExamine = false)
{
var componentName = _componentFactory.GetComponentName(component.GetType());
- AddDetailedExamineVerb(verbsEvent, component, new ExamineEntry(componentName, 0f, message), verbText, iconTexture, hoverMessage);
+ AddDetailedExamineVerb(verbsEvent, component, new ExamineEntry(componentName, 0f, message), verbText, iconTexture, hoverMessage, isHoverExamine);
+ }
+
+ /// <summary>
+ /// Adds an icon aligned to the left of examine window that gives you info on hover.
+ /// </summary>
+ public void AddHoverExamineVerb(GetVerbsEvent<ExamineVerb> verbsEvent, Component component, string hoverMessage, string iconTexture = DefaultIconTexture)
+ {
+ AddDetailedExamineVerb(verbsEvent, component, FormattedMessage.Empty, "", iconTexture, hoverMessage, true);
}
}
}
public override bool CloseMenuDefault => false; // for examine verbs, this will close the examine tooltip.
public bool ShowOnExamineTooltip = true;
+ public bool HoverVerb = false; // aligned to the left, gives text on hover
}
/// <summary>