Thread Tools Display Modes
10-22-10, 10:21 AM   #1
drakull
A Cyclonian
 
drakull's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2008
Posts: 49
Lunar/Solar eclipse glowing border

I wanted to create a visual hint when the player gains the Eclipse buff so I tried to make eclipseBar's border to glow blue or yellow (depending on the buff) while the player has it. The way i found do accomplish this was to hook the UNIT_AURA event and check eclipsebar's properties "hasSolarEclipse" and "hasLunarEclipse".
The problem is, the moment I get the eclipse buff and the UNIT_AURA event is triggered, the corresponding property isn't yet set to true and so the border color isn't changed.
If I trigger the aura event again after that (e.g. by buffing myself) the properties are already set. It seems that the event is triggered before oUF updates eclipsebar's properties.

I wonder if there's a better way to do this. I tried finding a better event but all i got was "ECLIPSE_DIRECTION_CHANGE", which just triggers when the player gains the buff, but not when he loses it.

Here's my eclipsebar code:
lua Code:
  1. -- Eclipse Bar function
  2. local eBuff = function(self, event, unit)
  3.     if self.EclipseBar.hasSolarEclipse then
  4.         self.EclipseBar.eBarBG:SetBackdropBorderColor(1,1,1,0.4)
  5.         self.EclipseBar.eBarBG:SetBackdropColor(1,1,0,1)
  6.     elseif self.EclipseBar.hasLunarEclipse then
  7.         self.EclipseBar.eBarBG:SetBackdropBorderColor(1,1,1,0.4)
  8.         self.EclipseBar.eBarBG:SetBackdropColor(0,0,1,1)
  9.     else
  10.         self.EclipseBar.eBarBG:SetBackdropBorderColor(0,0,0,1)
  11.         self.EclipseBar.eBarBG:SetBackdropColor(0,0,0,1)
  12.     end
  13. end
  14.  
  15. lib.addEclipseBar = function(self)
  16.     if playerClass ~= "DRUID" then return end
  17.    
  18.     local eclipseBar = CreateFrame('Frame', nil, self)
  19.     eclipseBar:SetPoint('BOTTOMLEFT', self.Portrait, 'TOPLEFT', 0, 2)
  20.     eclipseBar:SetHeight(4)
  21.     eclipseBar:SetWidth(self.Portrait:GetWidth())
  22.     eclipseBar:SetFrameLevel(4)
  23.     local h = CreateFrame("Frame", nil, eclipseBar)
  24.     h:SetPoint("TOPLEFT",-5,5)
  25.     h:SetPoint("BOTTOMRIGHT",5,-5)
  26.     lib.gen_backdrop(h)
  27.     eclipseBar.eBarBG = h
  28.  
  29.     local lunarBar = CreateFrame('StatusBar', nil, eclipseBar)
  30.     lunarBar:SetPoint('LEFT', eclipseBar, 'LEFT', 0, 0)
  31.     lunarBar:SetSize(eclipseBar:GetWidth(), eclipseBar:GetHeight())
  32.     lunarBar:SetStatusBarTexture(cfg.statusbar_texture)
  33.     lunarBar:SetStatusBarColor(0, .1, .7)
  34.     lunarBar:SetFrameLevel(5)
  35.  
  36.     local solarBar = CreateFrame('StatusBar', nil, eclipseBar)
  37.     solarBar:SetPoint('LEFT', lunarBar:GetStatusBarTexture(), 'RIGHT', 0, 0)
  38.     solarBar:SetSize(eclipseBar:GetWidth(), eclipseBar:GetHeight())
  39.     solarBar:SetStatusBarTexture(cfg.statusbar_texture)
  40.     solarBar:SetStatusBarColor(1,1,.13)
  41.     solarBar:SetFrameLevel(5)
  42.  
  43.     local EBText = lib.gen_fontstring(solarBar, cfg.font, 10, "OUTLINE")
  44.     EBText:SetPoint('CENTER', eclipseBar, 'CENTER', 0, 0)
  45.     self:Tag(EBText, '[pereclipse]')
  46.    
  47.     eclipseBar.SolarBar = solarBar
  48.     eclipseBar.LunarBar = lunarBar
  49.     self.EclipseBar = eclipseBar
  50.     self:RegisterEvent("UNIT_AURA", eBuff)
  51. end
  Reply With Quote
10-22-10, 11:01 AM   #2
yj589794
A Rage Talon Dragon Guard
AddOn Author - Click to view addons
Join Date: Mar 2009
Posts: 314
You should try reading the eclipsebar element code. I added post-event functionality that you can use in your layout for just such a scenario:

Code:
self.EclipseBar.PostUpdatePower = function(element, unit)
     -- do stuff here after UNIT_POWER has been processed
end
Code:
self.EclipseBar.PostUpdateVisibility = function(element, unit)
     -- do stuff here after PLAYER_TALENT_UPDATE or UPDATE_SHAPESHIFT_FORM has been processed
end
Code:
self.EclipseBar.PostUnitAura = function(element, unit)
     -- do stuff here after UNIT_AURA has been processed
end
Code:
self.EclipseBar.PostDirectionChange = function(element, unit)
     -- do stuff here after ECLIPSE_DIRECTION_CHANGE has been processed
end

Make use of these and you should not have to add your own event handlers.


p.s. Yes, I know this info should be on the wiki. I'll get around to it soon(tm)
  Reply With Quote
10-22-10, 11:49 AM   #3
drakull
A Cyclonian
 
drakull's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2008
Posts: 49
Originally Posted by yj589794 View Post
You should try reading the eclipsebar element code. I added post-event functionality that you can use in your layout for just such a scenario:
Yup, I have read it. I went there looking for some PostUpdate function but then I learned about the "hasLunarEclipse" and "hasLunarEclipse" properties and when I came up with the event idea I got so excited that never noted the "PostUnitAura" post-event right before my eyes.

Working fine now, ty!!!

Last edited by drakull : 10-22-10 at 11:52 AM.
  Reply With Quote
10-23-10, 07:28 AM   #4
neverg
A Frostmaul Preserver
 
neverg's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2007
Posts: 268
Was thinking about adding the same functionality to my layout, thanks for the hints. That's awesome.
__________________
My oUF Layout: oUF Lumen
  Reply With Quote
10-25-10, 09:13 AM   #5
azsh
A Fallenroot Satyr
Join Date: May 2010
Posts: 21
Hello i have problem, after change form to cat or travel form glowing at icon (when i have eclipse) stay's (don't hide) i don't no why, mayby someone sees error ?

ss from my problem : http://yfrog.com/71wowscrnshot102510171614j
my full code
Code:
if playerClass == "DRUID" then
	self.Name:SetPoint("TOPLEFT", self.Health, "TOPLEFT", 18, 40)
	self.Debuffs:SetPoint(cfg.PlayerDebufAnchor1, self.Health, cfg.PlayerDebufAnchor2, cfg.PlayerDebufOffset_X, cfg.PlayerDebufOffset_Y+20)
	local eclipseBar = CreateFrame('Frame', nil, self)
	eclipseBar:SetPoint('TOPLEFT', self, 'BOTTOMLEFT', 23, 56)
	eclipseBar:SetSize(cfg.widthP-45, 12)
	eclipseBar:SetBackdrop{edgeFile = cfg.glowtex2, edgeSize = 5, insets = {left = 3, right = 3, top = 3, bottom = 3}}
	eclipseBar:SetBackdropColor(0, 0, 0, 0)
	eclipseBar:SetBackdropBorderColor(0, 0, 0, 0.8)	
	
	local lunarBar = CreateFrame('StatusBar', nil, eclipseBar)
	lunarBar:SetPoint('LEFT', eclipseBar, 'LEFT', 0, 0)
	lunarBar:SetSize(cfg.widthP-42, 12)
	lunarBar:SetStatusBarTexture(cfg.PPtex)
	lunarBar:SetStatusBarColor(1, 3/5, 0)
	eclipseBar.LunarBar = lunarBar
	
	local solarBar = CreateFrame('StatusBar', nil, eclipseBar)
	solarBar:SetPoint('LEFT', lunarBar:GetStatusBarTexture(), 'RIGHT', 0, 0)
	solarBar:SetSize(cfg.widthP-42, 12)
	solarBar:SetStatusBarTexture(cfg.PPtex)
	solarBar:SetStatusBarColor(0, 0, 1)
	eclipseBar.SolarBar = solarBar

	local eclipseBarText = solarBar:CreateFontString(nil, 'OVERLAY')
	eclipseBarText:SetPoint('CENTER', eclipseBar, 'CENTER', 0, 0)
	eclipseBarText:SetFont(cfg.NumbFont, cfg.NumbFS, "THINOUTLINE")
	self:Tag(eclipseBarText, '[eecc]')

	self.Glow.eclipseBar = CreateFrame("Frame", nil, eclipseBar)
	self.Glow.eclipseBar:SetPoint("TOPLEFT", eclipseBar, "TOPLEFT", -5, 5)
	self.Glow.eclipseBar:SetPoint("BOTTOMRIGHT", eclipseBar, "BOTTOMRIGHT", 5, -5)
	self.Glow.eclipseBar:SetBackdrop{edgeFile = cfg.glowtex2, edgeSize = 5, insets = {left = 3, right = 3, top = 3, bottom = 3}}
	self.Glow.eclipseBar:SetBackdropColor(0, 0, 0, 0)
	self.Glow.eclipseBar:SetBackdropBorderColor(0, 0, 0, 0.8)
			
	self.iconS = eclipseBar:CreateTexture(nil, 'OVERLAY')
	self.iconS:SetPoint("LEFT", eclipseBar, "RIGHT", 4, 2)
	self.iconS:SetHeight(20)
	self.iconS:SetWidth(20)
	self.iconS:SetTexture(select(3,GetSpellInfo(48517)))
	self.iconS:SetVertexColor(unpack(cfg.trdcolor))

	self.iconL = eclipseBar:CreateTexture(nil, 'OVERLAY')
	self.iconL:SetPoint("RIGHT", eclipseBar, "LEFT", -4, 2)
	self.iconL:SetHeight(20)
	self.iconL:SetWidth(20)
	self.iconL:SetTexture(select(3,GetSpellInfo(48518)))
	self.iconL:SetVertexColor(unpack(cfg.trdcolor))
			
	local bgl = CreateFrame("Frame", nil, iconL)
	bgl:SetPoint("TOPLEFT", self.iconL, "TOPLEFT", -10, 10)
	bgl:SetPoint("BOTTOMRIGHT", self.iconL, "BOTTOMRIGHT", 10, -10)
	bgl:SetBackdrop{edgeFile = cfg.glowtex, edgeSize = 10, insets = {left = 3, right = 3, top = 3, bottom = 3}}
	bgl:SetBackdropColor(0,0,0,0)
	bgl:SetBackdropBorderColor(1,1,1,0)
			
	local bgs = CreateFrame("Frame", nil, iconL)
	bgs:SetPoint("TOPLEFT", self.iconS, "TOPLEFT", -10, 10)
	bgs:SetPoint("BOTTOMRIGHT", self.iconS, "BOTTOMRIGHT", 10, -10)
	bgs:SetBackdrop{edgeFile = cfg.glowtex, edgeSize = 10, insets = {left = 3, right = 3, top = 3, bottom = 3}}
	bgs:SetBackdropColor(0,0,0,0)
	bgs:SetBackdropBorderColor(1,1,1,0)
			
	local eclipseBarSpark = solarBar:CreateFontString(nil, 'OVERLAY')
	eclipseBarSpark:SetFont(cfg.NumbFont, cfg.NumbFS+4, "THINOUTLINE")
			
	local eclipseBarBuff = function(self, unit)
		if self.hasSolarEclipse then
			self.bgs:SetBackdropBorderColor(1,1,1,1)
		elseif self.hasLunarEclipse then
			self.bgl:SetBackdropBorderColor(1,1,1,1)
		else
			self.bgs:SetBackdropBorderColor(1,1,1,0)
			self.bgl:SetBackdropBorderColor(1,1,1,0)
		end
		if(self.directionIsLunar) then
		eclipseBarSpark:SetPoint('CENTER', eclipseBar, 'LEFT', 18, -1)
		eclipseBarSpark:SetText(">>>")
		else
		eclipseBarSpark:SetPoint('CENTER', eclipseBar, 'RIGHT', -12, -1)
		eclipseBarSpark:SetText("<<<")
		end
	end
	eclipseBar.bgs = bgs
	eclipseBar.bgl = bgl
	self.EclipseBar = eclipseBar
	self.EclipseBar.PostUnitAura = eclipseBarBuff
end

Last edited by azsh : 10-25-10 at 09:18 AM.
  Reply With Quote
10-25-10, 10:55 AM   #6
yj589794
A Rage Talon Dragon Guard
AddOn Author - Click to view addons
Join Date: Mar 2009
Posts: 314
Originally Posted by azsh View Post
Code:
	local bgl = CreateFrame("Frame", nil, iconL)
...
	local bgs = CreateFrame("Frame", nil, iconL)
Just a guess as I have not run the code, but iconL does not exists. change it to self.iconL.
  Reply With Quote
10-25-10, 11:46 AM   #7
azsh
A Fallenroot Satyr
Join Date: May 2010
Posts: 21
YeY not to self.icon but to eclipseBar and it's working Thanks for the idea
  Reply With Quote

WoWInterface » Featured Projects » oUF (Otravi Unit Frames) » Lunar/Solar eclipse glowing border


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