Thread Tools Display Modes
06-10-11, 11:54 AM   #1
Aftermathhqt
A Molten Giant
 
Aftermathhqt's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2009
Posts: 784
UIFrameFade

Hello there, i have a minor problem, i don't know it's not working but i'm trying to do a framefade, with castbars, and it's not working. Any reasons?

LUA Code:
  1. local f = CreateFrame('Frame')
  2.             f:RegisterEvent('PLAYER_TARGET_CHANGED')
  3.             f:RegisterEvent('PLAYER_FOCUS_CHANGED')
  4.             f:RegisterEvent("UNIT_SPELLCAST_SENT")
  5.             f:RegisterEvent("UNIT_SPELLCAST_START")
  6.             f:RegisterEvent("UNIT_SPELLCAST_CHANNEL_START")
  7.             f:RegisterEvent("UNIT_SPELLCAST_CHANNEL_STOP")
  8.             f:RegisterEvent("UNIT_SPELLCAST_STOP")
  9.             f:RegisterEvent('UNIT_SPELLCAST_FAILED')
  10.             f:RegisterEvent('UNIT_SPELLCAST_INTERRUPTED')
  11.             f:RegisterEvent('UNIT_SPELLCAST_DELAYED')
  12.             f:RegisterEvent('UNIT_SPELLCAST_CHANNEL_UPDATE')
  13.             f:RegisterEvent('UNIT_SPELLCAST_CHANNEL_INTERRUPTED')
  14.             f:SetScript('OnEvent', function(event)
  15.                     if unit == "player" or unit == "target" or unit == "focus" or unit == "pet" then
  16.                         if self.Castbar then
  17.                             if event == "UNIT_SPELLCAST_START" or event == "UNIT_SPELLCAST_CHANNEL_START" then
  18.                                 UIFrameFadeIn(self.Castbar, 0.8, self.Castbar:GetAlpha(), 1)
  19.                             elseif event == "UNIT_SPELLCAST_STOP" or event == "UNIT_SPELLCAST_SENT" or event == "UNIT_SPELLCAST_FAILED" then
  20.                                 UIFrameFadeOut(self.Castbar, 0.8, self.Castbar:GetAlpha(), 0.2)
  21.                             end
  22.                         end
  23.                     end
  24.                 end
  25.             end)
  26.         end
  27.     end
  Reply With Quote
06-10-11, 04:55 PM   #2
Saiket
A Chromatic Dragonspawn
 
Saiket's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 154
Your OnEvent function doesn't have "self" or "unit" arguments. Change line 14 to this and it should work:
lua Code:
  1. f:SetScript('OnEvent', function(self, event, unit)
  Reply With Quote
06-10-11, 05:31 PM   #3
Aftermathhqt
A Molten Giant
 
Aftermathhqt's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2009
Posts: 784
Originally Posted by Saiket View Post
Your OnEvent function doesn't have "self" or "unit" arguments. Change line 14 to this and it should work:
lua Code:
  1. f:SetScript('OnEvent', function(self, event, unit)
Hmm, nop didn't work


LUA Code:
  1. local f = CreateFrame('Frame')
  2.     f:RegisterEvent("UNIT_SPELLCAST_SENT")
  3.     f:RegisterEvent("UNIT_SPELLCAST_START")
  4.     f:RegisterEvent("UNIT_SPELLCAST_CHANNEL_START")
  5.     f:RegisterEvent("UNIT_SPELLCAST_CHANNEL_STOP")
  6.     f:RegisterEvent("UNIT_SPELLCAST_STOP")
  7.     f:RegisterEvent('UNIT_SPELLCAST_FAILED')
  8.     f:RegisterEvent('UNIT_SPELLCAST_INTERRUPTED')
  9.     f:RegisterEvent('UNIT_SPELLCAST_DELAYED')
  10.     f:RegisterEvent('UNIT_SPELLCAST_CHANNEL_UPDATE')
  11.     f:RegisterEvent('UNIT_SPELLCAST_CHANNEL_INTERRUPTED')
  12.     f:SetScript('OnEvent', function(self, event, unit)
  13.         if unit == "player" or unit == "target" or unit == "focus" or unit == "pet" then
  14.             if self.Castbar then
  15.                 if event == "UNIT_SPELLCAST_START" or event == "UNIT_SPELLCAST_CHANNEL_START" then
  16.                     UIFrameFadeIn(self.Castbar, 0.8, self.Castbar:GetAlpha(), 1)
  17.                 elseif event == "UNIT_SPELLCAST_STOP" or event == "UNIT_SPELLCAST_SENT" or event == "UNIT_SPELLCAST_FAILED" or event == "UNIT_SPELLCAST_INTERRUPTED" or event == "UNIT_SPELLCAST_CHANNEL_STOP" then
  18.                     UIFrameFadeOut(self.Castbar, 0.8, self.Castbar:GetAlpha(), 0.2)
  19.                 end
  20.             end
  21.         end
  22.     end)
  Reply With Quote
06-13-11, 11:59 AM   #4
Goldpaw
A Wyrmkin Dreamwalker
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 56
Once a fade is in motion, you have to stop it in order to start a new one, or the new one will simply be ignored.

Try adding this before each fadein/out:

lua Code:
  1. if UIFrameIsFading(frame) then
  2.     UIFrameFadeRemoveFrame(frame)
  3. end

Last edited by Goldpaw : 06-13-11 at 12:01 PM.
  Reply With Quote
06-13-11, 02:49 PM   #5
tecu
An Aku'mai Servant
AddOn Author - Click to view addons
Join Date: Apr 2006
Posts: 30
i bet 'self.Castbar' isn't defined because self, in this case, points to the event frame you created (f).

i'd suggest, if using things like .PostCastStart does not work, that you define a table in your layout when you create each .Castbar element:

Code:
local castbars = {}
--...
-- in your style function:
self.Castbar = YourCastBarFrame
castbars[unit] = YourCastBarFrame
and then in your onevent function you can just check for castbars[unit] and operate on that.
  Reply With Quote
06-13-11, 08:52 PM   #6
Justgiz
An Aku'mai Servant
Join Date: Jul 2006
Posts: 30
.. or you could just change the 'self' argument in the OnEvent function to something else, Then the variable self will refer to variable you want
  Reply With Quote
06-14-11, 11:19 PM   #7
Aftermathhqt
A Molten Giant
 
Aftermathhqt's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2009
Posts: 784
I don't know but i feel confused, anyways here is my castbar code, maybe it gets easier for you to come up with somthing

LUA Code:
  1. if AftermathhUI.config.castbars == true then
  2.         if(unit == 'player' or unit == 'focus' or unit == 'target' or unit == 'pet') then
  3.             self.Castbar = CreateFrame('StatusBar', nil, self)
  4.             self.Castbar:SetStatusBarTexture(AftermathhUI.media.texture)
  5.             self.Castbar:SetScale(1.139)
  6.             self.Castbar:SetStatusBarColor(.25, .25, .25)
  7.  
  8.             CreateBorder(self.Castbar, 12, 1, 1, 1, 3)
  9.  
  10.             self.Castbar.Bg = self.Castbar:CreateTexture(nil, 'BACKGROUND')
  11.             self.Castbar.Bg:SetAllPoints(self.Castbar)
  12.             self.Castbar.Bg:SetTexture(AftermathhUI.media.texture)
  13.             self.Castbar.Bg:SetVertexColor(0, 0, 0, 0.7)
  14.            
  15.             if(unit == 'player') then -- Player CastBar
  16.                 self.Castbar:SetPoint('BOTTOM', UIParent, -2, 80) -- here we move the player castbar.
  17.                 self.Castbar:SetSize(309, 25)
  18.                 self.Castbar:SetParent(self)
  19.            
  20.                 if AftermathhUI.config.castbarclasscolor == true then
  21.                    self.Castbar:SetStatusBarColor(playerColor.r, playerColor.g, playerColor.b)
  22.                    self.Castbar.Bg:SetVertexColor(playerColor.r*0.3, playerColor.g*0.3, playerColor.b*0.3, 0.8)
  23.                 end
  24.        
  25.                 if AftermathhUI.config.showsafezone == true then
  26.                     self.Castbar.SafeZone = self.Castbar:CreateTexture(nil, 'BORDER')
  27.                     self.Castbar.SafeZone:SetTexture(AftermathhUI.media.blank)
  28.                     self.Castbar.SafeZone:SetVertexColor(1, 0.5, 0, 1)
  29.                 end
  30.  
  31.                 if AftermathhUI.config.showlatency == true then
  32.                     self.Castbar.Latency = self:CreateFontString(nil, 'ARTWORK')
  33.                     self.Castbar.Latency:SetFont(AftermathhUI.media.font, AftermathhUI.config.latencyfontsize, AftermathhUI.media.fontflag)
  34.                     self.Castbar.Latency:SetParent(self.Castbar)
  35.                     self.Castbar.Latency:SetDrawLayer('OVERLAY')
  36.                     self.Castbar.Latency:SetVertexColor(0.6, 0.6, 0.6)
  37.                     self.Castbar.Latency:SetAlpha(1)
  38.                 end
  39.             end
  40.            
  41.             if(unit == 'target') then
  42.                 self.Castbar:SetSize(200, 26)
  43.                 self.Castbar:SetPoint('TOPRIGHT', self, 'BOTTOMRIGHT', 143, 94) -- here we move the target castbar
  44.                
  45.                 if AftermathhUI.config.targetcastbaricon == true then
  46.                     self.Castbar.Icon = self.Castbar:CreateTexture(nil, 'ARTWORK')
  47.                     self.Castbar.Icon:SetSize(39, 39)
  48.                     self.Castbar.Icon:SetPoint('RIGHT', 47, 4)
  49.                     self.IconOverlay = self.Castbar:CreateTexture(nil, 'OVERLAY')
  50.                     self.IconOverlay:SetPoint('TOPLEFT', self.Castbar.Icon, 'TOPLEFT')
  51.                     self.IconOverlay:SetPoint('BOTTOMRIGHT', self.Castbar.Icon, 'BOTTOMRIGHT')
  52.                     self.IconOverlay:SetTexture(AftermathhUI.media.border)
  53.                     self.IconOverlay:SetVertexColor(1, 1, 1, 1)
  54.                     self.Castbar.IconBg = self.Castbar:CreateTexture(nil, 'BACKGROUND')
  55.                     self.Castbar.IconBg:SetPoint('TOPLEFT',self.Castbar.Icon,'TOPLEFT',-5,5)
  56.                     self.Castbar.IconBg:SetPoint('BOTTOMRIGHT',self.Castbar.Icon,'BOTTOMRIGHT',5,-5)
  57.                     self.Castbar.IconBg:SetTexture(AftermathhUI.media.shadow)
  58.                     self.Castbar.IconBg:SetVertexColor(0, 0, 0, 0.9)
  59.                 end
  60.             end
  61.            
  62.             if(unit == 'focus') then -- Focus Castbar
  63.                 self.Castbar:SetSize(260, 25)
  64.                 self.Castbar:SetScale(1.210)
  65.                 self.Castbar:SetPoint('CENTER', UIParent, 'CENTER', -10, -10) -- here we move focus castbar
  66.                
  67.                 if AftermathhUI.config.focuscastbaricon == true then
  68.                     self.Castbar.Icon = self.Castbar:CreateTexture(nil, 'ARTWORK')
  69.                     self.Castbar.Icon:SetSize(39, 39)
  70.                     self.Castbar.Icon:SetPoint('LEFT', -48, 3)
  71.                     self.IconOverlay = self.Castbar:CreateTexture(nil, 'OVERLAY')
  72.                     self.IconOverlay:SetPoint('TOPLEFT', self.Castbar.Icon, 'TOPLEFT')
  73.                     self.IconOverlay:SetPoint('BOTTOMRIGHT', self.Castbar.Icon, 'BOTTOMRIGHT')
  74.                     self.IconOverlay:SetTexture(AftermathhUI.media.border)
  75.                     self.IconOverlay:SetVertexColor(1, 1, 1, 1)
  76.                     self.Castbar.IconBg = self.Castbar:CreateTexture(nil, 'BACKGROUND')
  77.                     self.Castbar.IconBg:SetPoint('TOPLEFT',self.Castbar.Icon,'TOPLEFT',-5,5)
  78.                     self.Castbar.IconBg:SetPoint('BOTTOMRIGHT',self.Castbar.Icon,'BOTTOMRIGHT',5,-5)
  79.                     self.Castbar.IconBg:SetTexture(AftermathhUI.media.shadow)
  80.                     self.Castbar.IconBg:SetVertexColor(0, 0, 0, 0.9)
  81.                 end
  82.             end
  83.            
  84.             if(unit == 'pet') then -- Pet Castbar
  85.                 self.Castbar:SetSize(200, 22)
  86.                 self.Castbar:SetPoint('TOPRIGHT', self, 'BOTTOMRIGHT', -12, 56) -- here we move the pet castbar
  87.             end
  88.            
  89.             self.Castbar.PostCastStart = function(Castbar, unit, spell, spellrank)
  90.                 if (unit == 'player') then
  91.                     if (Castbar.Latency) then
  92.                         local down, up, lagHome, lagWorld = GetNetStats();
  93.                         local avgLag = (lagHome + lagWorld) / 2
  94.                         Castbar.Latency:ClearAllPoints()
  95.                         Castbar.Latency:SetPoint('RIGHT', Castbar, 'BOTTOMRIGHT', -1, -1)
  96.                         Castbar.Latency:SetText(string.format('%.0f', avgLag)..'ms')
  97.                     end
  98.                 end
  99.             end    
  100.  
  101.             self.Castbar.PostChannelStart = function(Castbar, unit, spell, spellrank)
  102.                 if (unit == 'player') then
  103.                     if (Castbar.Latency) then
  104.                         local down, up, lagHome, lagWorld = GetNetStats();
  105.                         local avgLag = (lagHome + lagWorld) / 2
  106.                         Castbar.Latency:ClearAllPoints()
  107.                         Castbar.Latency:SetPoint('LEFT', self.Castbar, 'BOTTOMLEFT', 1, 1)
  108.                         Castbar.Latency:SetText(string.format('%.0f', avgLag)..'ms')
  109.                     end
  110.                 end
  111.             end
  112.  
  113.             self.Castbar.CustomDelayText = function(self, duration)
  114.                 self.Time:SetFormattedText('(|cffff0000-%.1f|r) %.1f | %.1f', self.delay, duration, self.max)
  115.             end
  116.    
  117.             self.Castbar.CustomTimeText = function(self, duration)
  118.                 self.Time:SetFormattedText('%.1f | %.1f', duration, self.max)
  119.             end
  120.  
  121.             self.Castbar.Time = self:CreateFontString(nil, 'ARTWORK')
  122.             self.Castbar.Time:SetFont(AftermathhUI.media.font, AftermathhUI.config.cbtimefontsize, AftermathhUI.media.fontflag)
  123.             self.Castbar.Time:SetPoint('RIGHT', self.Castbar, 'RIGHT', -7, 0)
  124.             self.Castbar.Time:SetHeight(25)
  125.             self.Castbar.Time:SetParent(self.Castbar)
  126.             self.Castbar.Time:SetJustifyH('RIGHT')
  127.  
  128.             self.Castbar.Text = self:CreateFontString(nil, 'ARTWORK')
  129.             self.Castbar.Text:SetFont(AftermathhUI.media.font, AftermathhUI.config.cbtextfontsize, AftermathhUI.media.fontflag)
  130.             self.Castbar.Text:SetPoint('LEFT', self.Castbar, 4, 0)
  131.             self.Castbar.Text:SetPoint('RIGHT', self.Castbar.Time, 'LEFT', -7, 0)
  132.             self.Castbar.Text:SetHeight(25)
  133.             self.Castbar.Text:SetParent(self.Castbar)
  134.             self.Castbar.Text:SetJustifyH('LEFT')
  135.  
  136. .....

Last edited by Aftermathhqt : 06-14-11 at 11:22 PM.
  Reply With Quote

WoWInterface » Featured Projects » oUF (Otravi Unit Frames) » UIFrameFade

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