View Single Post
09-12-12, 10:29 PM   #8
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
I'm not sure what "frame options" you mean, but there are a couple issues with your code.

For one, oUF expects 5 objects, not 3, so you should be getting errors from that. Paladins start out with a max of 3 holy power, but gain an additional 2 (for a total of 5) from the Boundless Conviction passive ability at level 85. oUF will automatically hide the ones that aren't currently in use.

Also, oUF will try to call :SetVertexColor on your objects; since StatusBar objects don't have this method, this should trigger another error unless you remap it to SetStatusBarColor (if you want oUF to color your objects) or a dummy function (if you don't).

Make sure you have BugSack or Swatter or something running when you're working on addons; it will make your life a lot easier.

Try this. It will make sure the last holy power is always the one with the different color, and stop oUF from setting its own holy power color.

Code:
local noop = function() return end

local HolyPostUpdate = function(icons, cur, max, changed)
	for i = 1, 5 do
		if i == max then
			ClassIcons[i]:SetStatusBarColor(0.65, 0.63, 0.35)
		else
			ClassIcons[i]:SetStatusBarColor(0.69, 0.31, 0.31)
		end
	end
end

lib.genHoly = function(self)
	if select(2, UnitClass("player")) ~= "PALADIN" then return end
	local ClassIcons = {}
	for i = 1, 5 do
		local Icon = CreateFrame("StatusBar", nil, ClassIcons)
		Icon:SetSize(20, 20)
		Icon:SetPoint("BOTTOMLEFT", self, "TOPLEFT", 0, 7)
		Icon:SetStatusBarTexture(config.statusbar_texture)
		Icon:GetStatusBarTexture():SetHorizTile(false)
		Icon:SetBackdrop(backdrop)
		Icon:SetBackdropColor(0,0,0,1)
		-- Map the method oUF tries to call to one that actually exists:
		Icon.SetVertexColor = noop
		if i == 1 then
			ClassIcons[i]:SetPoint("LEFT", ClassIcons)
		else
			ClassIcons[i]:SetPoint("LEFT", ClassIcons[i-1], "RIGHT", 10, 0)
		end
		ClassIcons[i] = Icon
	end
	ClassIcons.PostUpdate = HolyPostUpdate
	self.ClassIcons = ClassIcons
end
If you want to let oUF color the bars, change:

Code:
Icon.SetVertexColor = noop
to:

Code:
Icon.SetVertexColor = Icon.SetStatusBarColor
... and feel free to delete the noop function definition.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote