Class TooltipManager
- Namespace
- MonkeyLoader.Resonite.UI.Tooltips
- Assembly
- MonkeyLoader.Resonite.Integration.dll
Handles resolving the labels as well as opening and closing the tooltips for FrooxEngine.IButtons.
public sealed class TooltipManager : ConfiguredResoniteCancelableEventHandlerMonkey<TooltipManager, TooltipConfig, ResolveTooltipLabelEvent>, IResoniteMonkey, ICancelableEventHandler<ResolveTooltipLabelEvent>, IPrioritizable, IConfiguredMonkey<TooltipConfig>, IConfiguredMonkey, IMonkey, IRun, IShutdown, IComparable<IMonkey>, INestedIdentifiable<Mod>, INestedIdentifiable, IIdentifiable, IAuthorable, IDisplayable, ICancelableEventSource<ResolveTooltipLabelEvent>
- Inheritance
-
ConfiguredResoniteCancelableEventHandlerMonkey<TooltipManager, TooltipConfig, ResolveTooltipLabelEvent>TooltipManager
- Implements
- Inherited Members
- Extension Methods
Properties
Priority
Gets the priority of this item. Use an agreed standard as a base.
public override int Priority { get; }
Property Value
- int
An interger used to sort the prioritizable items.
Higher comes first with the default comparer.
SkipCanceled
Gets whether this handler should be skipped for events that have been canceled by a previous event handler.
public override bool SkipCanceled { get; }
Property Value
Methods
CloseTooltip(IButton)
Closes the tooltip for the given button.
public static bool CloseTooltip(IButton button)
Parameters
buttonIButtonThe button the tooltip is attached to.
Returns
- bool
trueif the tooltip was closed;falseif there was no tooltip.
Handle(ResolveTooltipLabelEvent)
Handles the given event based on its data, if AppliesTo returned true.
protected override void Handle(ResolveTooltipLabelEvent eventData)
Parameters
eventDataResolveTooltipLabelEventAn object containing all the relevant information for the applicable event.
HasLabelForButton(IButton)
Checks whether the given button has a registered label.
public static bool HasLabelForButton(IButton button)
Parameters
buttonIButtonThe button to check for a registered label.
Returns
- bool
trueif the button has a registered label; otherwise,false.
HasTooltip(IButton)
Checks if there is a Tooltip associated with this FrooxEngine.IButton.
public static bool HasTooltip(IButton button)
Parameters
buttonIButtonThe button the tooltip is attached to.
Returns
MakeTooltip(IButton, Slot, in float3, in LocaleString)
Creates a tooltip according to the given parameters for the given button.
Any already existing open tooltip will be closed.
public static Tooltip MakeTooltip(IButton button, Slot parent, in float3 localPosition, in LocaleString label)
Parameters
buttonIButtonThe button the tooltip is attached to.
parentSlotThe slot the tooltip will be parented to.
localPositionfloat3The position of the tooltip inside its
parent.labelLocaleStringThe label that should be shown on the tooltip.
Returns
- Tooltip
The data for the newly created tooltip.
MakeTooltip(IButton, Slot, in float3, float, in LocaleString)
Creates a tooltip according to the given parameters for the given button.
Any already existing open tooltip will be closed.
public static Tooltip MakeTooltip(IButton button, Slot parent, in float3 localPosition, float localScale, in LocaleString label)
Parameters
buttonIButtonThe button the tooltip is attached to.
parentSlotThe slot the tooltip will be parented to.
localPositionfloat3The position of the tooltip inside its
parent.localScalefloatThe scale of the tooltip inside its
parent.labelLocaleStringThe label that should be shown on the tooltip.
Returns
- Tooltip
The data for the newly created tooltip.
OnEngineReady()
Override this method to be called when the FrooxEngine.Engine is ready.
This is the primary method for patching used by Resonite Mods as basic facilities of the game
are ready to use, while most other code hasn't been run yet.
Return true if patching was successful.
protected override bool OnEngineReady()
Returns
- bool
Whether the patching was successful.
Remarks
Override OnLoaded() to patch before anything is initialized,
but strongly consider also overriding this method if you do that.
Otherwise your patches will be applied twice, if you're using [HarmonyPatchCategory(nameof(MyPatcher))] attributes.
Easy to apply by using
[HarmonyPatchCategory(nameof(MyPatcher))] attribute.
OnShutdown(bool)
Lets this monkey cleanup and shutdown.
protected override bool OnShutdown(bool applicationExiting)
Parameters
applicationExitingboolWhether the shutdown was caused by the application exiting.
Returns
- bool
trueif it ran successfully; otherwise,false.
Remarks
By default: Unregisters
this monkey as an event handler for ResolveTooltipLabelEvents
and removes all Harmony patches done
using this Monkey's Harmony instance,
if not exiting, and returns true.
RegisterLabelForButton(IButton, in LocaleString)
Registers a label for the given undestroyed button, if it doesn't already have one.
public static bool RegisterLabelForButton(IButton button, in LocaleString label)
Parameters
buttonIButtonThe undestroyed button to register a label for.
labelLocaleStringThe label to register for the button.
Returns
- bool
trueif the label was registered for the button; otherwise,false.
TryGetLabelForButton(IButton, out LocaleString?)
Tries to get the registered label for the given button.
public static bool TryGetLabelForButton(IButton button, out LocaleString? label)
Parameters
buttonIButtonThe button to get the registered label for.
labelLocaleString?The registered label for the button if it has one; otherwise,
null.
Returns
- bool
trueif the button has a registered label; otherwise,false.
TryGetTooltip(IButton, out Tooltip?)
Tries to get the Tooltip associated with this FrooxEngine.IButton.
public static bool TryGetTooltip(IButton button, out Tooltip? tooltip)
Parameters
buttonIButtonThe button the tooltip is attached to.
tooltipTooltipThe associated Tooltip if one is open; otherwise,
null.
Returns
TryOpenTooltip(IButton, ButtonEventData, Slot, in float3, float)
Tries to open a tooltip for the given button details.
public static bool TryOpenTooltip(IButton button, ButtonEventData buttonEventData, Slot tooltipParent, in float3 globalOffset = default, float localScale = 1)
Parameters
buttonIButtonThe button the tooltip is attached to.
buttonEventDataButtonEventDataThe button event triggering opening the tooltip.
tooltipParentSlotThe slot the tooltip will be parented to.
globalOffsetfloat3The offset from the button hitpoint at which the tooltip should be opened in global space.
localScalefloatThe local scale of the tooltip to be opened inside the
tooltipParent.
Returns
Remarks
If the label for the tooltip fails to resolve or it's a locale key missing a message, no tooltip will be created.
TryOpenTooltip(IButton, ButtonEventData, Slot, out Tooltip?, in float3, float)
Tries to open a tooltip for the given button details, optionally returning the already open or newly created tooltip.
public static bool TryOpenTooltip(IButton button, ButtonEventData buttonEventData, Slot tooltipParent, out Tooltip? tooltip, in float3 globalOffset = default, float localScale = 1)
Parameters
buttonIButtonThe button the tooltip is attached to.
buttonEventDataButtonEventDataThe button event triggering opening the tooltip.
tooltipParentSlotThe slot the tooltip will be parented to.
tooltipTooltipThe tooltip if one was already open or newly opened; otherwise, null.
globalOffsetfloat3The offset from the button hitpoint at which the tooltip should be opened in global space.
localScalefloatThe local scale of the tooltip to be opened inside the
tooltipParent.
Returns
Remarks
If the label for the tooltip fails to resolve or it's a locale key missing a message, no tooltip will be created.
TryOpenTooltipWithDelay(IButton, float?, ButtonEventData, Slot, in float3, float)
Tries to open a tooltip for the given button details after the specified delay.
public static bool TryOpenTooltipWithDelay(IButton button, float? delay, ButtonEventData buttonEventData, Slot tooltipParent, in float3 globalOffset = default, float localScale = 1)
Parameters
buttonIButtonThe button the tooltip is attached to.
delayfloat?The time in seconds to wait before opening the tooltip. Defaults to HoverTime when passed null. Values
<= 0open it instantly.
When another tooltip is (attempted to be) opened orCloseTooltip(is called before the time has passed, no (new) tooltip will be created.button)buttonEventDataButtonEventDataThe button event triggering opening the tooltip.
tooltipParentSlotThe slot the tooltip will be parented to.
globalOffsetfloat3The offset from the button hitpoint at which the tooltip should be opened in global space.
localScalefloatThe local scale of the tooltip to be opened inside the
tooltipParent.
Returns
Remarks
If the label for the tooltip fails to resolve
or it's a locale key missing a message, no tooltip will be created.
When another tooltip is (attempted to be) opened or
CloseTooltip(
is called before the button)delay time has passed, no (new) tooltip will be created.
TryOpenTooltipWithDelay(IButton, float?, ButtonEventData, Slot, out Tooltip?, in float3, float)
Tries to open a tooltip for the given button details after the specified delay,
optionally returning the already open or instantly newly created tooltip.
public static bool TryOpenTooltipWithDelay(IButton button, float? delay, ButtonEventData buttonEventData, Slot tooltipParent, out Tooltip? tooltip, in float3 globalOffset = default, float localScale = 1)
Parameters
buttonIButtonThe button the tooltip is attached to.
delayfloat?The time in seconds to wait before opening the tooltip. Defaults to HoverTime when passed null. Values
<= 0open it instantly.
When another tooltip is (attempted to be) opened orCloseTooltip(is called before the time has passed, no (new) tooltip will be created.button)buttonEventDataButtonEventDataThe button event triggering opening the tooltip.
tooltipParentSlotThe slot the tooltip will be parented to.
tooltipTooltipThe tooltip if one was already open or instantly newly opened; otherwise, null.
globalOffsetfloat3The offset from the button hitpoint at which the tooltip should be opened in global space.
localScalefloatThe local scale of the tooltip to be opened inside the
tooltipParent.
Returns
Remarks
If the label for the tooltip fails to resolve
or it's a locale key missing a message, no tooltip will be created.
When another tooltip is (attempted to be) opened or
CloseTooltip(
is called before the button)delay time has passed, no (new) tooltip will be created.
TryResolveTooltipLabel(IButton, ButtonEventData, out LocaleString?)
Tries to resolve the tooltip label for the given button details.
public static bool TryResolveTooltipLabel(IButton button, ButtonEventData buttonEventData, out LocaleString? label)
Parameters
buttonIButtonThe button the tooltip is attached to.
buttonEventDataButtonEventDataThe button event triggering opening the tooltip.
labelLocaleString?The label if it was successfully resolved; otherwise, null.
Returns
Remarks
If the label for the tooltip is locale key missing a message, it's treated as unsuccessfully resolved.
UnregisterLabelForButton(IButton)
Removes the registered label for the given button.
public static bool UnregisterLabelForButton(IButton button)
Parameters
buttonIButtonThe button to remove the registered label of.