WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   AddOn Search/Requests (https://www.wowinterface.com/forums/forumdisplay.php?f=6)
-   -   Hide UI automatically hide after not moving my mouse for 3 or so seconds? (https://www.wowinterface.com/forums/showthread.php?t=54642)

Krainz 10-13-16 09:14 AM

Hide UI automatically hide after not moving my mouse for 3 or so seconds?
 
Basically what the title says. Is there a way to do that? I have Kong, Move Everything and Dominos installed.

If it's something easy to code I can perhaps do it myself if you show me the way.

tonyis3l33t 10-13-16 02:07 PM

event PLAYER_STOPPED_MOVING combined with the command to hide all the ui, UIParent:Hide()

Code:

local addonName, addonTable = ... ;
local addon = CreateFrame("Frame");

addon:RegisterEvent("PLAYER_STOPPED_MOVING");
addon:RegisterEvent("PLAYER_STARTED_MOVING");

addon:SetScript("OnEvent", function(self, event, ...)

        if event == "PLAYER_STOPPED_MOVING" then
                UIParent:Hide();
        end;
        if event == "PLAYER_STARTED_MOVING" then
                UIParent:Show();
        end;
end);


Seerah 10-13-16 03:09 PM

That would hide the UI immediately after the player character stopped moving. The OP wants it to wait until 3 seconds of not moving the *mouse*.

There is no event for when the mouse moves. You would need to have an OnUpdate script constantly calling :GetPoint() on the mouse and keep track of it changing or not as well as a timer.

tonyis3l33t 10-13-16 05:54 PM

haha sorry didnt see the mouse part

check out this if you want to try hiding your UI unless mouse-over or in combat.
http://www.wowinterface.com/download...FrameFade.html

Krainz 10-13-16 06:56 PM

Basic beginner question: how do I add a timer of 3 seconds after that player stopped moving event?

I imagine that the scrpit constantly checking the mouse position would have quite a heavy load on performance.

Seerah 10-13-16 07:40 PM

It wouldn't be too bad, but using the event is much easier in addition to being lighter on resources.

Lua Code:
  1. local function HideUI()
  2.      UIParent:Hide()
  3. end
  4.  
  5. local f = CreateFrame("Frame")
  6. f:RegisterEvent("PLAYER_STOPPED_MOVING")
  7. f:RegisterEvent("PLAYER_STARTED_MOVING")
  8.  
  9. f:SetScript("OnEvent", function(self, event)
  10.      if event == "PLAYER_STOPPED_MOVING" then
  11.           C_Timer.After(3, HideUI)
  12.      end
  13.      if event == "PLAYER_STARTED_MOVING" then
  14.           UIParent:Show()
  15.      end
  16. end)

Torhal 10-13-16 07:50 PM

That's a slightly naive implementation, though; no matter what happens, the UI will be hidden after 3 seconds. This means you can stop moving, the 3 second timer will start. You start moving again, and the UI will still be hidden when the timer ends, despite the fact that you're actively moving.

Krainz 10-13-16 10:55 PM

Quote:

Originally Posted by Torhal (Post 319900)
That's a slightly naive implementation, though; no matter what happens, the UI will be hidden after 3 seconds. This means you can stop moving, the 3 second timer will start. You start moving again, and the UI will still be hidden when the timer ends, despite the fact that you're actively moving.

That can be resolved through variables, can't it?


ie, when the player starts moving, the variable is set to 1. When the player stops moving, the variable is set to 0.

HideUI() checks the variable and only hides it when the value equals 0.

This way, if the player starts moving, it will register PLAYER_STARTED_MOVING, and then after 3 seconds it won't be able to hide the UI because the variable's value will be 1.

However, I don't know for sure if it will work that way and if it will, whether or not it will be a constantly checking script. Makes me think of the mouse position checker solution.

MunkDev 10-13-16 11:28 PM

I would suggest doing something like this if you want to use the cursor position:
Lua Code:
  1. local frame = CreateFrame("Frame")
  2. local GetCursorPosition, IsMouselooking = GetCursorPosition, IsMouselooking
  3. local GetMouseFocus = GetMouseFocus
  4. local UIParent, WorldFrame = UIParent, WorldFrame
  5.  
  6. frame.timer = 0
  7. frame:SetScript("OnUpdate", function(self, elapsed)
  8.         self.timer = self.timer + elapsed
  9.         local x, y = GetCursorPosition()
  10.         if self.x ~= x or self.y ~= y then
  11.             UIParent:SetAlpha(UIParent:GetAlpha()+elapsed)
  12.         elseif not IsMouselooking() then
  13.             self.timer = 0
  14.             UIParent:SetAlpha(UIParent:GetAlpha()-elapsed)
  15.         end
  16.         if self.timer > 3 then
  17.             -- check mouse looking here since the cursor position is static while
  18.             -- holding down right mouse button, also check that you're not mousing
  19.             -- over a frame since that may not be desirable either
  20.             if not IsMouselooking() and GetMouseFocus() == WorldFrame then
  21.                 self.x = x
  22.                 self.y = y
  23.             end
  24.            
  25.             self.timer = 0
  26.         end
  27. end)

This will fade out the UIParent smoothly instead of hiding/showing it, which isn't something you can do without causing problems. A lot of secure frames, from addons and Blizzard alike, are children of UIParent, and this would break stuff if you were to insecurely attempt to hide the frame in combat.

The performance dent is negligible with localized shortcuts to the global functions used in this script and you're only operating on simple true/false statements anyway. You don't have to worry about performance with such a small script.

Seerah 10-14-16 06:51 PM

Quote:

Originally Posted by Torhal (Post 319900)
That's a slightly naive implementation, though; no matter what happens, the UI will be hidden after 3 seconds. This means you can stop moving, the 3 second timer will start. You start moving again, and the UI will still be hidden when the timer ends, despite the fact that you're actively moving.

You're right. I wrote it in a hurry and wasn't thinking. :o

Torhal 10-14-16 08:07 PM

Quote:

Originally Posted by Seerah (Post 319914)
You're right. I wrote it in a hurry and wasn't thinking. :o

I try to think as little as possible. >.>

Krainz 10-16-16 04:16 AM

Yup, exactly what I wanted. Thank you very much!

Now slightly off topic, is it possible to also code a short "fade from black" after every loading screen? For immersive purposes.

If needed I'll open another topic for that.

EDIT:

So I coded this:

Lua Code:
  1. frame.timer = 0
  2. frame:SetScript("OnUpdate", function(self, elapsed)
  3.         self.timer = self.timer + elapsed
  4.         local x, y = GetCursorPosition()
  5.         if event == "PLAYER_REGEN_ENABLED" then
  6.             if event == "PLAYER_STOPPED_MOVING" then
  7.                 if self.x ~= x or self.y ~= y then
  8.                     UIParent:SetAlpha(1)
  9.                     -- UIParent:SetAlpha(UIParent:GetAlpha()+elapsed)
  10.                 elseif not IsMouselooking() then
  11.                     self.timer = 0
  12.                     UIParent:SetAlpha(UIParent:GetAlpha()-elapsed)
  13.                 end
  14.                 if self.timer > 3 then
  15.                     -- check mouse looking here since the cursor position is static while
  16.                     -- holding down right mouse button, also check that you're not mousing
  17.                     -- over a frame since that may not be desirable either
  18.                     if not IsMouselooking() and GetMouseFocus() == WorldFrame then
  19.                         self.x = x
  20.                         self.y = y
  21.                     end
  22.                    
  23.                     self.timer = 0
  24.                 end
  25.             else if player started moving
  26.                 if event == "PLAYER_STARTED_MOVING" then
  27.                     UIParent:SetAlpha(1)
  28.                 end
  29.             end
  30.         end
  31. end)

It's basically:

if player is not in combat and
if player is not moving
hide UI

Added to the '3 seconds without moving the mouse' code.

But it's not working. What did I do wrong?

Alternatively, I'm trying to do this through a variable checking way. It would would set a variable (ihide) to 1 whenever I'd want the UI to hide, and to 0 whenever I wouldn't want it to hide (combat, when the character is moving).

Still, it doesn't work. Why?

lua Code:
  1. local frame = CreateFrame("Frame")
  2. local GetCursorPosition, IsMouselooking = GetCursorPosition, IsMouselooking
  3. local GetMouseFocus = GetMouseFocus
  4. local UIParent, WorldFrame = UIParent, WorldFrame
  5. local ihide = 1
  6.  
  7.  
  8. frame:RegisterEvent("PLAYER_STOPPED_MOVING")
  9. frame:RegisterEvent("PLAYER_STARTED_MOVING")
  10. frame:RegisterEvent("PLAYER_REGEN_DISABLED")
  11. frame.timer = 0
  12.  
  13.  
  14. frame:SetScript("OnEvent", function(self, event)
  15.     if event == "PLAYER_STOPPED_MOVING" then
  16.         if event == "PLAYER_REGEN_ENABLED" then
  17.             ihide = 1
  18.         end
  19.         if event == "PLAYER_REGEN_DISABLED" then
  20.             ihide = 0
  21.         end
  22.     end
  23.     if event == "PLAYER_STARTED_MOVING" then
  24.         ihide = 0
  25.         UIParent:SetAlpha(1)
  26.     end
  27.     if event == "PLAYER_REGEN_DISABLED" then
  28.         ihide = 0
  29.     end
  30.    
  31. end)
  32.  
  33.  
  34. frame:SetScript("OnUpdate", function(self, elapsed)
  35.         self.timer = self.timer + elapsed
  36.         local x, y = GetCursorPosition()
  37.         if self.x ~= x or self.y ~= y then
  38.             UIParent:SetAlpha(1)
  39.             ihide = 0
  40.             -- UIParent:SetAlpha(UIParent:GetAlpha()+elapsed)
  41.         elseif not IsMouselooking() then
  42.             if ihide > 0 then
  43.                 self.timer = 0
  44.                 UIParent:SetAlpha(UIParent:GetAlpha()-elapsed)
  45.             end
  46.         end
  47.         if self.timer > 3 then
  48.             -- check mouse looking here since the cursor position is static while
  49.             -- holding down right mouse button, also check that you're not mousing
  50.             -- over a frame since that may not be desirable either
  51.             if not IsMouselooking() and GetMouseFocus() == WorldFrame then
  52.                 self.x = x
  53.                 self.y = y
  54.             end
  55.            
  56.             self.timer = 0
  57.         end
  58. end)
  59.  
  60. function HelloWorld(self)
  61.         print("Immersive Hide loaded.");
  62. end

How can I make this idea work?

Krainz 10-20-16 07:35 AM

Guys? Help?

tonyis3l33t 10-20-16 01:08 PM

at this point there is very little difference from daftFrameFade

nonetheless... try this. Note that this doesn't have the mouse moving code in it.

Lua Code:
  1. local addonName, addonTable = ... ;
  2.  
  3. local addon = CreateFrame("Frame");
  4. addon:RegisterEvent("PLAYER_LOGIN");
  5. addon:RegisterEvent("PLAYER_REGEN_DISABLED");
  6. addon:RegisterEvent("PLAYER_REGEN_ENABLED");
  7. addon:RegisterEvent("PLAYER_STARTED_MOVING");
  8. addon:RegisterEvent("PLAYER_STOPPED_MOVING");
  9.  
  10.  
  11. addon:SetScript("OnEvent", function(self, event, ...)
  12.  
  13.     if event == "PLAYER_LOGIN"
  14.     or event == "PLAYER_REGEN_DISABLED"
  15.     or event == "PLAYER_STOPPED_MOVING" then
  16.        
  17.         if not UnitAffectingCombat("player") then
  18.             UIFrameFadeOut(UIParent, 3, UIParent:GetAlpha(), 0);
  19.         end;
  20.     else
  21.         UIFrameFadeIn(UIParent, 1, UIParent:GetAlpha(), 1);
  22.     end;
  23.    
  24.     if UnitAffectingCombat("player") then
  25.         UIFrameFadeIn(UIParent, 1, UIParent:GetAlpha(), 1);
  26.     end;
  27. end);

tonyis3l33t 10-20-16 02:55 PM

Add this portion for mouse being on a frame or on a unit

Lua Code:
  1. addon:SetScript("OnUpdate", function(self, elapsed)
  2.  
  3.     local speed = GetUnitSpeed("player");
  4.     if speed ~=0 then
  5.         UIFrameFadeIn(UIParent, 1, UIParent:GetAlpha(), 1);
  6.     else
  7.         if GetMouseFocus() then
  8.             if GetMouseFocus():GetName() ~= "WorldFrame" then
  9.                 UIFrameFadeIn(UIParent, 1, UIParent:GetAlpha(), 1);
  10.             else
  11.                 if not UnitAffectingCombat("player") then
  12.                     UIFrameFadeOut(UIParent, 3, UIParent:GetAlpha(), 0.1);
  13.                 end;
  14.             end;
  15.         end;
  16.     end;
  17.    
  18.     if UnitName("mouseover") then
  19.         UIFrameFadeIn(UIParent, 1, UIParent:GetAlpha(), 1);
  20.     end;
  21. end);

tonyis3l33t 10-20-16 09:31 PM

Welp I ended up developing this further into an addon with a few options. I'll post it tomorrow.

Krainz 10-20-16 10:50 PM

Thanks for the help!

What I want to do isn't offered by any other addon.

ie, I'm using 'C_Timer.After()' to set a specific time out of combat or without moving for the UI to fade.

Like a soft AFK check, that would hide the UI while idle.

As of now I'm doing tests with C_Timer.After(3, UIFrameFadeOut(UIParent, 3, UIParent:GetAlpha(), 0)) within the code you provided.

I replaced all UIFrameFadeIn(UIParent, 1, UIParent:GetAlpha(), 1); for UIParent:SetAlpha(1); though, because I don't want fade-ins. They're bad for User Experience.

However, after the UI hides, it tends to quickly hide away back again and it seems to be hard to keep the UI visible while I'm active. I want it to not be visible while I'm not active.

What is weird is that the UI is hiding immediately when I talk to an NPC, like a shopkeeper for example.

Once the UI starts hiding, if I start moving it will also not make it stop hiding. It will instead start a loop.

I think the checker should start AFTER three seconds of idleness.

In essence, the UI should not hide when there's any activity going on, and that's not happening.

With the code you provided, the interactions work as intended (except for the wait time that's not yet in the code, and the fade-in that I'd like to be replaced for an instant show). With my edits, they get all clunky. I'll make a separate post for feedback for each code attempt.

Something like

if not (moved mouse/character moved/in combat) -> wait 3 seconds -> AFK!

AFK! -> fade UI over 2 seconds down to 0 (yes, zero)

moved mouse/character moved/in combat -> UI instantly shows (no fade-in)

The code you provided is very close to that.

Krainz 10-20-16 10:52 PM

lua Code:
  1. local addon = CreateFrame("Frame");
  2. addon:RegisterEvent("PLAYER_LOGIN");
  3. addon:RegisterEvent("PLAYER_REGEN_DISABLED");
  4. addon:RegisterEvent("PLAYER_REGEN_ENABLED");
  5. addon:RegisterEvent("PLAYER_STARTED_MOVING");
  6. addon:RegisterEvent("PLAYER_STOPPED_MOVING");
  7.  
  8.  
  9. local addon = CreateFrame("Frame");
  10. addon:RegisterEvent("PLAYER_LOGIN");
  11. addon:RegisterEvent("PLAYER_REGEN_DISABLED");
  12. addon:RegisterEvent("PLAYER_REGEN_ENABLED");
  13. addon:RegisterEvent("PLAYER_STARTED_MOVING");
  14. addon:RegisterEvent("PLAYER_STOPPED_MOVING");
  15.  
  16.  
  17. addon:SetScript("OnEvent", function(self, event, ...)
  18.  
  19.     if event == "PLAYER_LOGIN"
  20.     or event == "PLAYER_REGEN_DISABLED"
  21.     or event == "PLAYER_STOPPED_MOVING" then
  22.        
  23.         if not UnitAffectingCombat("player") then
  24.             UIFrameFadeOut(UIParent, 3, UIParent:GetAlpha(), 0);
  25.         end;
  26.     else
  27.         UIFrameFadeIn(UIParent, 1, UIParent:GetAlpha(), 1);
  28.     end;
  29.    
  30.     if UnitAffectingCombat("player") then
  31.         UIFrameFadeIn(UIParent, 1, UIParent:GetAlpha(), 1);
  32.     end;
  33. end);
  34.  
  35. addon:SetScript("OnUpdate", function(self, elapsed)
  36.  
  37.     local speed = GetUnitSpeed("player");
  38.     if speed ~=0 then
  39.         UIFrameFadeIn(UIParent, 1, UIParent:GetAlpha(), 1);
  40.     else
  41.         if GetMouseFocus() then
  42.             if GetMouseFocus():GetName() ~= "WorldFrame" then
  43.                 UIFrameFadeIn(UIParent, 1, UIParent:GetAlpha(), 1);
  44.             else
  45.                 if not UnitAffectingCombat("player") then
  46.                     UIFrameFadeOut(UIParent, 3, UIParent:GetAlpha(), 0.1);
  47.                 end;
  48.             end;
  49.         end;
  50.     end;
  51.    
  52.     if UnitName("mouseover") then
  53.         UIFrameFadeIn(UIParent, 1, UIParent:GetAlpha(), 1);
  54.     end;
  55. end);
  • When showing the UI, it should be instantly showed with 100% opacity, no fade-in
  • There should be a wait time of 3 or 4 seconds, and then the UI fades over 2 seconds. This is a more smooth transition and works better with the 'soft AFK detection' interaction.

Krainz 10-20-16 10:54 PM

lua Code:
  1. local addon = CreateFrame("Frame");
  2. addon:RegisterEvent("PLAYER_LOGIN");
  3. addon:RegisterEvent("PLAYER_REGEN_DISABLED");
  4. addon:RegisterEvent("PLAYER_REGEN_ENABLED");
  5. addon:RegisterEvent("PLAYER_STARTED_MOVING");
  6. addon:RegisterEvent("PLAYER_STOPPED_MOVING");
  7.  
  8.  
  9. addon:SetScript("OnEvent", function(self, event, ...)
  10.  
  11.     if event == "PLAYER_LOGIN"
  12.     or event == "PLAYER_REGEN_DISABLED"
  13.     or event == "PLAYER_STOPPED_MOVING" then
  14.        
  15.         if not UnitAffectingCombat("player") then
  16.             UIFrameFadeOut(UIParent, 3, UIParent:GetAlpha(), 0);
  17.         end;
  18.     else
  19.         UIParent:SetAlpha(1);
  20.     end;
  21.    
  22.     if UnitAffectingCombat("player") then
  23.         UIParent:SetAlpha(1);
  24.     end;
  25. end);
  26.  
  27. addon:SetScript("OnUpdate", function(self, elapsed)
  28.  
  29.     local speed = GetUnitSpeed("player");
  30.     if speed ~=0 then
  31.         UIParent:SetAlpha(1);
  32.     else
  33.         if GetMouseFocus() then
  34.             if GetMouseFocus():GetName() ~= "WorldFrame" then
  35.                 UIParent:SetAlpha(1);
  36.             else
  37.                 if not UnitAffectingCombat("player") then
  38.                     UIFrameFadeOut(UIParent, 3, UIParent:GetAlpha(), 0.1);
  39.                 end;
  40.             end;
  41.         end;
  42.     end;
  43.    
  44.     if UnitName("mouseover") then
  45.         UIParent:SetAlpha(1);
  46.     end;
  47. end);

I tried to workaround the fade-in problem by changing it to SetAlpha(1).

It let to lots of clunky interactions, with the UI fading down and then showing up and then disappearing again, only to be hard to make it appear again and such. Lots of suboptimal interactions.

Krainz 10-20-16 10:56 PM

lua Code:
  1. local addon = CreateFrame("Frame");
  2. addon:RegisterEvent("PLAYER_LOGIN");
  3. addon:RegisterEvent("PLAYER_REGEN_DISABLED");
  4. addon:RegisterEvent("PLAYER_REGEN_ENABLED");
  5. addon:RegisterEvent("PLAYER_STARTED_MOVING");
  6. addon:RegisterEvent("PLAYER_STOPPED_MOVING");
  7.  
  8.  
  9. addon:SetScript("OnEvent", function(self, event, ...)
  10.  
  11.     if event == "PLAYER_LOGIN"
  12.     or event == "PLAYER_REGEN_DISABLED"
  13.     or event == "PLAYER_STOPPED_MOVING" then
  14.        
  15.         if not UnitAffectingCombat("player") then
  16.             C_Timer.After(3, UIFrameFadeOut(UIParent, 3, UIParent:GetAlpha(), 0));
  17.         end;
  18.     else
  19.         UIParent:SetAlpha(1);
  20.     end;
  21.    
  22.     if UnitAffectingCombat("player") then
  23.         UIParent:SetAlpha(1);
  24.     end;
  25. end);
  26.  
  27. addon:SetScript("OnUpdate", function(self, elapsed)
  28.  
  29.     local speed = GetUnitSpeed("player");
  30.     if speed ~=0 then
  31.         UIParent:SetAlpha(1);
  32.     else
  33.         if GetMouseFocus() then
  34.             if GetMouseFocus():GetName() ~= "WorldFrame" then
  35.                 UIParent:SetAlpha(1);
  36.             else
  37.                 if not UnitAffectingCombat("player") then
  38.                 C_Timer.After(3, UIFrameFadeOut(UIParent, 3, UIParent:GetAlpha(), 0))
  39.                 end;
  40.             end;
  41.         end;
  42.     end;
  43.    
  44.     if UnitName("mouseover") then
  45.         UIParent:SetAlpha(1);
  46.     end;
  47. end);

I also tried to work around the "timer" solution through C_Timer, but then I realized that the interaction was already happening after out of combat, but just delayed. The user must STAY idle for that amount of time in order for the interaction to be optimal.

It ended up working like a delayed time bomb. Very, very clunky.

Krainz 10-20-16 10:58 PM

lua Code:
  1. local addon = CreateFrame("Frame");
  2. addon:RegisterEvent("PLAYER_LOGIN");
  3. addon:RegisterEvent("PLAYER_REGEN_DISABLED");
  4. addon:RegisterEvent("PLAYER_REGEN_ENABLED");
  5. addon:RegisterEvent("PLAYER_STARTED_MOVING");
  6. addon:RegisterEvent("PLAYER_STOPPED_MOVING");
  7.  
  8. local function wait(seconds)
  9.   local start = os.time()
  10.   repeat until os.time() > start + seconds
  11. end
  12.  
  13. addon:SetScript("OnEvent", function(self, event, ...)
  14.  
  15.     if event == "PLAYER_LOGIN"
  16.     or event == "PLAYER_REGEN_DISABLED"
  17.     or event == "PLAYER_STOPPED_MOVING" then
  18.        
  19.         if not UnitAffectingCombat("player") then
  20.             wait(3)
  21.             if not UnitAffectingCombat("player") then
  22.                 C_Timer.After(1, UIFrameFadeOut(UIParent, 3, UIParent:GetAlpha(), 0));
  23.             end;
  24.         end;
  25.     else
  26.         UIParent:SetAlpha(1);
  27.     end;
  28.    
  29.     if UnitAffectingCombat("player") then
  30.         UIParent:SetAlpha(1);
  31.     end;
  32. end);
  33.  
  34. addon:SetScript("OnUpdate", function(self, elapsed)
  35.  
  36.     local speed = GetUnitSpeed("player");
  37.     if speed ~=0 then
  38.         UIParent:SetAlpha(1);
  39.     else
  40.         if GetMouseFocus() then
  41.             if GetMouseFocus():GetName() ~= "WorldFrame" then
  42.                 UIParent:SetAlpha(1);
  43.             else
  44.                 if not UnitAffectingCombat("player") then
  45.                     wait(3)
  46.                     if not UnitAffectingCombat("player") then
  47.                         C_Timer.After(1, UIFrameFadeOut(UIParent, 3, UIParent:GetAlpha(), 0))
  48.                     end;
  49.                 end;
  50.             end;
  51.         end;
  52.     end;
  53.    
  54.     if UnitName("mouseover") then
  55.         UIParent:SetAlpha(1);
  56.     end;
  57. end);

And in the end I basically tried inserting a wait() function that just basically didn't work out in the end. That code doesn't work and does nothing when I log in.

zork 10-21-16 12:56 AM

Why don't you just call a c_timer.after every 3 seconds and check if the mouse cursor position has changed inbetween. Ontop it should be possible to get the player facing direction and coordinates. You can check that too. If both are the same you can hide the ui if not you reset the c_timer.

ObbleYeah 10-21-16 04:09 AM

that seems like it would cause problems if you were to stop to look at the world map, or any other ui panel d:

tonyis3l33t 10-21-16 04:47 AM

Quote:

Originally Posted by ObbleYeah (Post 320104)
that seems like it would cause problems if you were to stop to look at the world map, or any other ui panel d:

Those can all be fixed with a big If statement.

Lua Code:
  1. if UnitAffectingCombat("Player")
  2.     or InCombatLockdown()
  3.     or ChatFrame1EditBox:IsShown()
  4.     or WorldMapFrame:IsShown()
  5.     or MailFrame:IsShown()
  6.     or GossipFrame:IsShown()
  7.     or GameTooltipTextLeft1:GetText()
  8.     or UnitCastingInfo("Player")
  9.     or UnitChannelInfo("Player")
  10.     or UnitExists("Target") then
  11.         addon:FadeIn();
  12.     end;

I ended up liking what this looked like the more I worked on it, and now prefer it over my daftFrameFade (which fades frames individually) since using UIParent will "support" all addons. So I threw it up as daftUIFade. Note this one doesn't do the show-while-moving, the show-while-mouselooking, or the hide-after-not-moving-mouse stuff.

Krainz 10-23-16 02:46 PM

It's fantastic. Truly amazing work there, tonyis3l33t.

Quote:

Originally Posted by tonyis3l33t (Post 320106)
Note this one doesn't do the show-while-moving, the show-while-mouselooking, or the hide-after-not-moving-mouse stuff.

I tried implementing that by expanding the big if statement and merging it with MunkDev's code:

lua Code:
  1. addon.timer = 0
  2. addon:SetScript("OnUpdate", function(self, elapsed)
  3.         self.timer = self.timer + elapsed
  4.         local speed = GetUnitSpeed("player");
  5.         local x, y = GetCursorPosition();
  6.         if self.x ~= x
  7.         or self.y ~= y
  8.         or UnitAffectingCombat("Player")
  9.         or InCombatLockdown()
  10.         or speed ~=0
  11.         or UnitName("mouseover")
  12.         or ChatFrame1EditBox:IsShown()
  13.         or WorldMapFrame:IsShown()
  14.         or MailFrame:IsShown()
  15.         or GossipFrame:IsShown()
  16.         or GameTooltipTextLeft1:GetText()
  17.         or UnitCastingInfo("Player")
  18.         or UnitChannelInfo("Player")
  19.         or UnitExists("Target") then
  20.             addon:FadeIn();
  21.         elseif not IsMouselooking() then
  22.             self.timer = 0
  23.             addon:FadeOut();
  24.         end;
  25.         if self.timer > 5 then
  26.             -- check mouse looking here since the cursor position is static while
  27.             -- holding down right mouse button, also check that you're not mousing
  28.             -- over a frame since that may not be desirable either
  29.             if not IsMouselooking() and GetMouseFocus() == WorldFrame then
  30.                 self.x = x
  31.                 self.y = y
  32.             end
  33.            
  34.             self.timer = 0
  35.         end
  36. end)

Needs more testing though.

Krainz 10-25-16 08:52 PM

How do I make the uI not appear during cutscenes? (like those in Hyjal and uldum)

Krainz 10-30-16 10:17 PM

ALT+Z doesn't work while the addon is loaded...


All times are GMT -6. The time now is 12:50 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI