Go to Page... |
Thread Tools | Display Modes |
03-17-16, 09:58 PM | #1 |
[FixMyCode] beginner working with OnEnter and UIFrameFadeIn
Hi all! Wondering if I could get another pair of eyes on this....
trying to get the minimap to fade in when moused over, otherwise be faded out. What it actually does: nothing Code:
------------------ --Config local fadeTime = .5 -- fade time in seconds ------------------ local DaftFade = CreateFrame('Frame') --Events local event = CreateFrame('Frame') event:SetScript('OnEvent', function(self, event, ...) self[event](self, ...) end) --Fading function DaftFade:FadeIn(frame) local alpha = frame:GetAlpha() UIFrameFadeIn(frame, fadeTime*(1-alpha), alpha, 1) end function DaftFade:FadeOut(frame) local alpha = frame:GetAlpha() UIFrameFadeOut(frame, fadeTime*alpha, alpha, 0) end --Main Minimap:HookScript("OnEnter", function() DaftFade:FadeIn(self.GetName()) end) Minimap:HookScript("OnLeave", function() DaftFade:FadeOut(self.GetName()) end) |
|
03-17-16, 10:49 PM | #2 |
If you're indoors you can't alter the opacity of the minimap, and even if you're outdoors it doesn't change the opacity of the tracking dots, it only fades the background.
Even if you could fade the minimap, your code has a few issues; I would just rewrite it like this.. Lua Code:
Last edited by semlar : 03-17-16 at 10:59 PM. |
|
03-18-16, 05:27 AM | #3 |
Thanks semlar. I So in my code the issue might be calling a nil value when trying to get the alpha?
While I appreciate the rewrite, I have it this way because I'm trying to expand the fading to other frames later. Any tips on my crappy code, especially glaring issues? |
|
03-18-16, 09:04 AM | #4 |
Just wanted to drop by and mention that UIFrameFadeIn can potentially spread execution taint, since it's used by some of the protected code in the standard UI. I investigated this a long time ago, since I ran into it without a clue what was causing it. I believe there might even be a post about the issue on these forums.
I suggest using a custom animation manager instead, which removes any chance of spreading taint. This code is 95% stolen from someone else (can't remember who), but it does the trick. You can include this "file" as is in your toc, then grab the functions from your addon table, which also solves the issue of reuseability since you can reach it from any file in your addon. Lua Code:
Last edited by MunkDev : 03-18-16 at 09:11 AM. |
|
03-18-16, 08:44 PM | #5 |
Hey, thanks MunkDev for the sample code
So I troubleshot this a bit tonight just to learn from what I did wrong. Found my mistake: Minimap:HookScript("OnEnter", function() DaftFade:FadeIn(self.GetName()) end) the self.GetName() isn't working here. If I replace it with "Minimap" it works fine. |
|
03-18-16, 09:09 PM | #6 |
If you changed:
Code:
Minimap:HookScript("OnEnter", function() DaftFade:FadeIn(self.GetName()) end) Code:
Minimap:HookScript("OnEnter", function(self) DaftFade:FadeIn(self.GetName()) end)
__________________
Fizzlemizz Maintainer of Discord Unit Frames and Discord Art. Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus. |
|
03-19-16, 05:46 AM | #7 |
First of all, you should pass the frame itself to your function wrapper, not the name of the frame. Secondly, calling a function like this:
Lua Code:
Lua Code:
https://coronalabs.com/blog/2015/12/...-dot-operator/ Try this: Lua Code:
Last edited by MunkDev : 03-19-16 at 05:50 AM. |
|
03-22-16, 08:48 PM | #8 |
So i spent many hours over the past week and ended up with this! My code is getting a little better as I gain experience, as expected. Thanks everyone for your insights.
http://www.wowinterface.com/download...-DaftFade.html |
|
WoWInterface » Developer Discussions » Lua/XML Help » [FixMyCode] beginner working with OnEnter and UIFrameFadeIn |
«
Previous Thread
|
Next Thread
»
|
Display Modes |
Linear Mode |
Switch to Hybrid Mode |
Switch to Threaded Mode |
|
|