WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   oUF (Otravi Unit Frames) (https://www.wowinterface.com/forums/forumdisplay.php?f=87)
-   -   Problem with castbar icon in PostCastStart (https://www.wowinterface.com/forums/showthread.php?t=44124)

Irongunner 09-02-12 05:25 PM

Problem with castbar icon in PostCastStart
 
Hey guys,

I am using parts of oUF_Hank in my own oUF layout. My castbar is based on the one in his addon. It has some nice fading animations based on whether the cast succeeded or not. To achieve this, a second 'dummy' castbar is used for playing the animation. In the PostCastStart function the texture of the spell icon, currently used in the 'real' castbar needs to be set in the 'dummy' castbar, so that the icon can be shown during the fade animation.

Here is the interesting part of the code from oUF_Hank:

Lua Code:
  1. oUF_Hank.PostCastStart = function(castbar, unit, name, rank, castid)
  2.     ...
  3.     castbar.Dummy.Icon:SetTexture(castbar.Icon:GetTexture())
  4.     ...

Unfortunately the GetTexture() call sometimes returns nil, so that the fading animation shows an icon from a previous cast. Is there a way to get the texture 100% of the time?

Bests
Iron

Irongunner 09-06-12 07:49 AM

For now my workaround looks like this. Strangely the problem does not occur inside OnUpdate(..):

Lua Code:
  1. -- PostCastStart / PostChannelStart:
  2. -- replace: castbar.Dummy.Icon:SetTexture(castbar.Icon:GetTexture())
  3. -- by: castbar.Dummy.IconTexture = nil
  4.      
  5. -- PostCastSucceeded / PostCastStop / PostChannelStop:
  6. -- add castbar.Dummy.Icon:SetTexture(castbar.Dummy.IconTexture)
  7.        
  8. local coreCastbarUpdate = function(castbar, elapsed)
  9.     -- insert code from oUF core castbar.lua onUpdate(..) here
  10. end
  11.      
  12. oUF_Iron.OnUpdate = function(castbar, elapsed)
  13.     if castbar.Dummy.IconTexture == nil then
  14.         local texture = castbar.Icon:GetTexture()
  15.         if texture ~= nil then
  16.             castbar.Dummy.IconTexture = texture
  17.         end
  18.     end
  19.     coreCastbarUpdate(castbar, elapsed)
  20. end
  21.      
  22. -- Register cb.OnUpdate = oUF_Iron.OnUpdate at castbar creation


All times are GMT -6. The time now is 12:07 PM.

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