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. |
event PLAYER_STOPPED_MOVING combined with the command to hide all the ui, UIParent:Hide()
Code:
local addonName, addonTable = ... ; |
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. |
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 |
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. |
It wouldn't be too bad, but using the event is much easier in addition to being lighter on resources.
Lua Code:
|
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.
|
Quote:
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. |
I would suggest doing something like this if you want to use the cursor position:
Lua Code:
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. |
Quote:
|
Quote:
|
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:
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:
How can I make this idea work? |
Guys? Help?
|
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:
|
Add this portion for mouse being on a frame or on a unit
Lua Code:
|
Welp I ended up developing this further into an addon with a few options. I'll post it tomorrow.
|
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. |
lua Code:
|
lua Code:
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. |
lua Code:
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. |
All times are GMT -6. The time now is 02:07 AM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI