Skip to content

Commit

Permalink
Add configurable hover time
Browse files Browse the repository at this point in the history
  • Loading branch information
Nytra authored and Banane9 committed Dec 18, 2024
1 parent 9266a18 commit 1b6b56c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ private static void RunHoverEnterPostfix(Button __instance, ButtonEventData even
var localOffset = canvasBounds.Center.x_ + canvasBounds.Min._y - canvasHitPoint.xy;
var offset = tooltipParent.LocalVectorToGlobal(localOffset.xy_) + (0.01f * tooltipParent.Backward);

__instance.World.RunInSeconds(0.5f, () =>
__instance.World.RunInSeconds(TooltipConfig.Instance.HoverTime, () =>
{
if (!TooltipManager.HasTooltip(__instance))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ public sealed class TooltipConfig : SingletonConfigSection<TooltipConfig>
new ConfigKeyRange<float>(.5f, 4)
};

private static readonly DefiningConfigKey<float> _hoverTime = new("Hover Time", "The amount of time required to hover on the button before the tooltip opens.", () => 0.5f)
{
new ConfigKeyRange<float>(0, 2)
};

/// <summary>
/// Gets the background color for tooltips.
/// </summary>
Expand Down Expand Up @@ -51,6 +56,8 @@ public sealed class TooltipConfig : SingletonConfigSection<TooltipConfig>
/// </summary>
public float TextScale => _textScaleKey;

public float HoverTime => _hoverTime;

/// <inheritdoc/>
public override Version Version { get; } = new Version(1, 0, 0);
}
Expand Down

0 comments on commit 1b6b56c

Please sign in to comment.