Skip to content

Commit

Permalink
Fixed tooltip sometimes sticking around
Browse files Browse the repository at this point in the history
  • Loading branch information
Nestorboy committed Dec 18, 2023
1 parent 757a031 commit 24ba702
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions Assets/Nessie/ASE/Editor/ColorDebug.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ internal class ColorDebug

private static bool m_didBindKeyPress;
private static bool m_isHoldingHotkey;
private static bool m_tooltipActive;

#endregion Private Fields

Expand Down Expand Up @@ -66,19 +67,28 @@ private static void PostAssemblyReload()

private static void OnGlobalKeyPress()
{
m_isHoldingHotkey = Event.current != null && Event.current.control && Event.current.type == EventType.KeyDown;
m_isHoldingHotkey = Event.current != null && Event.current.control;
}

[HarmonyPatch(typeof(AmplifyShaderEditorWindow), nameof(AmplifyShaderEditorWindow.UpdateNodePreviewListAndTime))]
private static class PatchWindowUpdate
{
private static void Prefix(AmplifyShaderEditorWindow __instance, ref bool ___m_repaintIsDirty)
{
if (!UseHotkey || !m_didBindKeyPress) return;

if (UIUtils.CurrentWindow != __instance) return;

if (UseHotkey && m_didBindKeyPress && !m_isHoldingHotkey) return;

___m_repaintIsDirty = true;
if (m_isHoldingHotkey)
{
m_tooltipActive = true;
___m_repaintIsDirty = true;
}
else if (m_tooltipActive)
{
m_tooltipActive = false;
___m_repaintIsDirty = true;
}
}
}

Expand All @@ -87,7 +97,7 @@ private static class PatchWindowOnGUI
{
private static void Postfix(ParentGraph ___m_customGraph, ParentGraph ___m_mainGraphInstance, Vector2 ___m_currentMousePos2D)
{
if (UseHotkey && Event.current != null && !Event.current.control) return;
if (!m_tooltipActive) return;

ParentGraph currentGraph = ___m_customGraph ? ___m_customGraph : ___m_mainGraphInstance;
ParentNode node = ASEExtensions.GetActiveNode(___m_currentMousePos2D, currentGraph.AllNodes);
Expand Down

0 comments on commit 24ba702

Please sign in to comment.