View Single Post
09-07-12, 10:39 PM   #1
Senit24
A Fallenroot Satyr
AddOn Compiler - Click to view compilations
Join Date: Jul 2012
Posts: 28
Combo Points (and related class powers)

For days, I've been working on creating class class power (specifically combo points) bars. I'm working off some code from another layout. I've tried modifying it numerous ways, but I just can't get any result. I'm not getting any errors, it's just displaying nothing. Can anyone help me find a good sample, or solution to my problem?

Current code: --The function lib.genCPoints being called by my TargetStyle function, obviously.
Code:
do
	ComboDisplay = function(self, event, unit)
		if(unit == 'pet') then return end
		
		local cpoints = self.CPoints
		local cp
		if (UnitHasVehicleUI("player") or UnitHasVehicleUI("vehicle")) then
			cp = GetComboPoints('vehicle', 'target')
		else
			cp = GetComboPoints('player', 'target')
		end

		for i=1, MAX_COMBO_POINTS do
			if(i <= cp) then
				cpoints[i]:SetAlpha(1)
			else
				cpoints[i]:SetAlpha(0.15)
			end
		end
		
		if cpoints[1]:GetAlpha() == 1 then
			for i=1, MAX_COMBO_POINTS do
				cpoints[i]:Show()
			end
			
		else
			for i=1, MAX_COMBO_POINTS do
				cpoints[i]:Hide()
			end
			
		end
	end
end

lib.genCPoints = function(self)
	local bars = CreateFrame("Frame", nil, self)
	bars:SetPoint("BOTTOMLEFT", oUF_Player, "TOPLEFT", 0, 7)
	bars:SetWidth(210)
	bars:SetHeight(2)
	bars:SetBackdrop(backdrop)
	bars:SetBackdropBorderColor(0,0,0,0)
	bars:SetBackdropColor(0,0,0,0)
		
	for i = 1, 5 do		
	
		bars[i] = CreateFrame("StatusBar", self:GetName().."_Combo"..i, bars)
		bars[i]:SetHeight(20)					
		bars[i]:SetStatusBarTexture(config.statusbar_texture)
		bars[i]:GetStatusBarTexture():SetHorizTile(false)
							
		if i == 1 then
			bars[i]:SetPoint("LEFT", bars)
		else
			bars[i]:SetPoint("LEFT", bars[i-1], "RIGHT", 1, 0)
		end
		bars[i]:SetAlpha(1)
		bars[i]:SetWidth((210 - 4)/5)
	end
		
	bars[1]:SetStatusBarColor(0.69, 0.31, 0.31)		
	bars[2]:SetStatusBarColor(0.69, 0.31, 0.31)
	bars[3]:SetStatusBarColor(0.65, 0.63, 0.35)
	bars[4]:SetStatusBarColor(0.65, 0.63, 0.35)
	bars[5]:SetStatusBarColor(0.33, 0.59, 0.33)
		
	self.CPoints = bars
	self.CPoints.Override = ComboDisplay
		
	bars.FrameBackdrop = CreateFrame("Frame", nil, bars[1])
	bars:SetBackdrop(backdrop)
	bars.FrameBackdrop:SetBackdropBorderColor(0,0,0,1)
	bars.FrameBackdrop:SetPoint("TOPLEFT", bars, "TOPLEFT", -1, 1)
	bars.FrameBackdrop:SetPoint("BOTTOMRIGHT", bars, "BOTTOMRIGHT", 1, -1)
	bars.FrameBackdrop:SetFrameLevel(bars:GetFrameLevel() - 1)
end
  Reply With Quote