Reply
Thread Tools Display Modes
Unread 09-02-12, 05:25 PM   #1
Irongunner
A Deviate Faerie Dragon
Join Date: Mar 2011
Posts: 11
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 is offline   Reply With Quote
Unread 09-06-12, 07:49 AM   #2
Irongunner
A Deviate Faerie Dragon
Join Date: Mar 2011
Posts: 11
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
Irongunner is offline   Reply With Quote
Reply

Go BackWoWInterface » Featured Projects » oUF (Otravi Unit Frames) » Problem with castbar icon in PostCastStart

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off