Thread Tools Display Modes
03-29-10, 07:32 AM   #1
Blooblahguy
A Deviate Faerie Dragon
AddOn Author - Click to view addons
Join Date: Oct 2009
Posts: 18
Layers/Strata?

Hey there. Never really worked with LUA before, or any programming language, but I decided to try this all from ground up and figure it out. So far I've come up with this:


I'd like to find out how to make the name text go behind the castbar, but I can't figure out layers or strata at all. The other thing that bothers me is my mana text updates slow and not quickly like the default text does.


If it would help to see my code here it is. Its not all originally mine, and I'm sorry that its kind of a mess.

Code:
local bartexture = 'Interface\\AddOns\\oUF_bloo\\media\\bartexture'
local bufftexture = 'Interface\\AddOns\\oUF_bloo\\media\\buff'
local numberfont = 'Interface\\AddOns\\oUF_bloo\\media\\numberfont.ttf'
local namefont = 'Interface\\AddOns\\oUF_bloo\\media\\namefont.ttf'

local function SetFontString(parent, fontName, fontHeight, fontStyle)
	local fs = parent:CreateFontString(nil, 'OVERLAY')
	fs:SetFont(fontName, fontHeight, fontStyle)
	fs:SetJustifyH('LEFT')
	fs:SetShadowColor(0,0,0)
	fs:SetShadowOffset(1.25, -1.25)
	return fs
end

local function Hex(r, g, b)
	if type(r) == "table" then
		if r.r then r, g, b = r.r, r.g, r.b else r, g, b = unpack(r) end
	end
	return string.format("|cff%02x%02x%02x", r*255, g*255, b*255)
end

-- [[ Menu ]] --
local menu = function(self)
	local unit = self.unit:sub(1, -2)
	local cunit = self.unit:gsub('(.)', string.upper, 1)

	if(unit == 'party' or unit == 'partypet') then
		ToggleDropDownMenu(1, nil, _G['PartyMemberFrame'..self.id..'DropDown'], 'cursor', 0, 0)
	elseif(_G[cunit..'FrameDropDown']) then
		ToggleDropDownMenu(1, nil, _G[cunit..'FrameDropDown'], "cursor", 0, 0)
	end
end

--[[ short hp value ]]--
local function shorthpval(value)
	if(value >= 1e6) then
		return string.format('%.1fm', value / 1e6)
	elseif(value >= 1e4) then
		return string.format('%.1fk', value / 1e3)
	elseif value >= 1e3 then
		return string.format('%.1fk', value / 1e3)
	else
		return value
	end
end

--[[ colors ]]--
oUF.colors.power["MANA"] = { 26/255, 139/255, 255/255 };
oUF.colors.power["RAGE"] = { 255/255, 26/255, 48/255 };
oUF.colors.power["FOCUS"] = { 255/255, 150/255, 26/255 };
oUF.colors.power["ENERGY"] = { 255/255, 225/255, 26/255 };
oUF.colors.power["HAPPINESS"] = { 0.00, 1.00, 1.00 };
oUF.colors.power["RUNES"] = { 0.50, 0.50, 0.50 };
oUF.colors.power["RUNIC_POWER"] = { 0.00, 0.82, 1.00 };
oUF.colors.power["AMMOSLOT"] = { 0.80, 0.60, 0.00 };
oUF.colors.power["FUEL"] = { 0.0, 0.55, 0.5 }; 

--[[ aura icon skin ]]--
local auraIcon = function(self, button, icons)
	icons.showDebuffType = true
	
	button.icon:SetTexCoord(.07, .93, .07, .93)
	button.icon:SetPoint('TOPLEFT', button, 'TOPLEFT', 1, -1)
	button.icon:SetPoint('BOTTOMRIGHT', button, 'BOTTOMRIGHT', -1, 1)
	
	button.overlay:SetTexture(bufftexture)
	button.overlay:SetTexCoord(0,1,0,1)
	button.overlay.Hide = function(self) self:SetVertexColor(0.3, 0.3, 0.3) end
	
	button.cd:SetReverse()
	button.cd:SetPoint('TOPLEFT', button, 'TOPLEFT', 2, -2) 
	button.cd:SetPoint('BOTTOMRIGHT', button, 'BOTTOMRIGHT', -2, 2)     
end

--[[ castbar format ]]--
local lolCastBarTime = function(self, duration)
	if self.channeling then
		self.Time:SetFormattedText("%.1f|cff357EC7s|r", duration)
        self.Time:SetFont(numberfont, 10)
	elseif self.casting then
		self.Time:SetFormattedText("%.1f|cff357EC7s|r", self.max - duration)
	    self.Time:SetFont(numberfont, 10)
    end
end

-- Tags --
local colors = setmetatable({
	power = setmetatable({
		['MANA'] = {0, 144/255, 1}
	}, {__index = oUF.colors.power}),
}, {__index = oUF.colors})

local numberize = function(v)
	if v <= 9999 then return v end
	if v >= 1000000 then
		local value = string.format("%.1fm", v/1000000)
		return value
	elseif v >= 10000 then
		local value = string.format("%.1fk", v/1000)
		return value
	end
end

if (not oUF.Tags['[colorhp]']) then
oUF.Tags['[colorhp]'] = function(unit)
	local cur = UnitHealth(unit)
	local max = UnitHealthMax(unit)
	local r, g, b	
	r, g, b = oUF.ColorGradient(cur/max, 0.69, 0.31, 0.31, 0.65, 0.63, 0.35, 0.33, 0.59, 0.33)
	return string.format("|cff%02x%02x%02x",r*255,g*255,b*255)
end
end

if (not oUF.Tags['[shortcurhp]']) then
oUF.Tags['[shortcurhp]'] = function(unit)
	local cur = UnitHealth(unit)
	local max = UnitHealthMax(unit)
	local r, g, b	
	r, g, b = oUF.ColorGradient(cur/max, 0.69, 0.31, 0.31, 0.65, 0.63, 0.35, 0.33, 0.59, 0.33)	
	return string.format(numberize(cur))
end
end

local function Hex(r, g, b)
	if type(r) == 'table' then
		if r.r then r, g, b = r.r, r.g, r.b else r, g, b = unpack(r) end
	end
	return string.format('|cff%02x%02x%02x', r*255, g*255, b*255)
end

oUF.Tags['[shortcurpp]'] = function(u)
local _, powerTypeString = UnitPowerType(u)
return powerTypeString and Hex(oUF.colors.power[powerTypeString])..shorthpval(UnitPower(u)) or shorthpval(UnitPower(u))
end

------------------------------------------------------------------------
--      Layout
------------------------------------------------------------------------
local function layout(self, unit)

	self.menu = menu
	self:RegisterForClicks('AnyDown')
	self:SetScript('OnEnter', UnitFrame_OnEnter)
	self:SetScript('OnLeave', UnitFrame_OnLeave)
	self:SetAttribute('*type2', 'menu')
    self:SetFormattedText(numberfont, 14)
  
-----------------------------------------------------------------------
--      Health / Power
-----------------------------------------------------------------------
    -- Health --
	local hp = CreateFrame('StatusBar', nil, self)
	hp:SetStatusBarTexture(bartexture)
    
    hp:SetParent(self)
    hp:SetPoint'TOP'
	hp:SetPoint'LEFT'
	hp:SetPoint'RIGHT'
    
    local healthbg = hp:CreateTexture(nil, 'BORDER')
	healthbg:SetPoint('CENTER', hp, 'CENTER', 0, 0)
	healthbg:SetTexture(bartexture)
	healthbg:SetVertexColor(0.16,0.16,0.16,1)
    
	hp.colorClass = true
	hp.colorTapping = true
	hp.colorReaction = true
	hp.frequentUpdates = true
    self.Health = hp

    -- Power --
	pp = CreateFrame('StatusBar', nil, self)
	pp:SetStatusBarTexture(bartexture)
	pp:SetHeight(3)
    pp:SetPoint("TOP", hp, "BOTTOM", 0, 29)
  
    local powerbg = pp:CreateTexture(nil, 'BORDER')
	powerbg:SetPoint('CENTER', pp, 'CENTER', 0, 0)
	powerbg:SetTexture(bartexture)
	powerbg:SetWidth(220)
	powerbg:SetHeight(3)
	powerbg:SetVertexColor(0.16,0.16,0.16,1)
    
    pp:SetParent(self)
	pp:SetPoint'LEFT'
	pp:SetPoint'RIGHT'
    pp.colorPower = true
    self.Power = pp

-- [[ Backgrounds ]] --
    if unit=='player' then
	    hp:SetBackdrop({bgFile = [=[Interface\ChatFrame\ChatFrameBackground]=], level = '0', insets = {top = -2, left = -2, bottom = -2, right = -2}})
	    hp:SetBackdropColor(0, 0, 0, 1)
        
        pp:SetBackdrop({bgFile = [=[Interface\ChatFrame\ChatFrameBackground]=], level = '0', insets = {top = -3, left = -2, bottom = -3, right = -2}})
	    pp:SetBackdropColor(0, 0, 0, 1)
    end
    
    if unit=='target' then
	    hp:SetBackdrop({bgFile = [=[Interface\ChatFrame\ChatFrameBackground]=], level = '0', insets = {top = -2, left = -2, bottom = -2, right = -3}})
	    hp:SetBackdropColor(0, 0, 0, 1)
        
        pp:SetBackdrop({bgFile = [=[Interface\ChatFrame\ChatFrameBackground]=], level = '0', insets = {top = -3, left = -2, bottom = -3, right = -3}})
	    pp:SetBackdropColor(0, 0, 0, 1)
    end
    
    if unit=='targettarget' then
	    hp:SetBackdrop({bgFile = [=[Interface\ChatFrame\ChatFrameBackground]=], level = '0', insets = {top = -3, left = -2, bottom = -2, right = -2}})
	    hp:SetBackdropColor(0, 0, 0, 1)
    end
    
    if unit=='focus' then
	    hp:SetBackdrop({bgFile = [=[Interface\ChatFrame\ChatFrameBackground]=], level = '0', insets = {top = -2, left = -2, bottom = -2, right = -2}})
	    hp:SetBackdropColor(0, 0, 0, 1)
    end

 if unit=='pet' then
	    hp:SetBackdrop({bgFile = [=[Interface\ChatFrame\ChatFrameBackground]=], level = '0', insets = {top = -2, left = -2, bottom = -2, right = -3}})
	    hp:SetBackdropColor(0, 0, 0, 1)
    end
    
    
-----------------------------------------------------------------------
--      Texts
-----------------------------------------------------------------------
-- [[ Health Text ]] --
	local curhealth = hp:CreateFontString(nil, 'OVERLAY')
    curhealth:SetFont(numberfont, 16)
    self:Tag(curhealth,'[shortcurhp] | [colorhp][perhp]%')  
    curhealth:SetShadowOffset(1, -1)
    
-- [[ Power Text ]] --
	local curpower = pp:CreateFontString(nil, 'OVERLAY')
    curpower:SetFont(numberfont, 14)
	self:Tag(curpower,'[shortcurpp]')
    curpower:SetShadowOffset(1, -1)
    
-- [[ Name Text ]] --
	local unitnames = hp:CreateFontString(nil, 'OVERLAY')
    unitnames:SetFont(namefont, 14)
	self:Tag(unitnames,'[name]')
    unitnames:SetShadowOffset(1, -1)

--[[ raid icon ]]--
	self.RaidIcon = hp:CreateTexture(nil, "OVERLAY")
	self.RaidIcon:SetHeight(16)
	self.RaidIcon:SetWidth(16)
	self.RaidIcon:SetPoint('Center', self, 0, 0)
	self.RaidIcon:SetTexture'Interface\\TargetingFrame\\UI-RaidTargetingIcons'

-----------------------------------------------------------------------
--      Buffs / Debuffs
-----------------------------------------------------------------------
    --[[ buffs ]]--
	self.Buffs = CreateFrame("Frame", nil, self)
	self.Buffs.size = 22
	self.Buffs:SetHeight(self.Buffs.size)
	self.Buffs:SetWidth(self.Buffs.size * 10)
	self.Buffs:SetPoint('BOTTOMLEFT', self, 'TOPLEFT', -2, 13)
	self.Buffs.initialAnchor = 'BOTTOMLEFT'
	self.Buffs["growth-y"] = 'TOP'
	self.Buffs.num = 20
	self.Buffs.spacing = 2

    --[[ debuffs ]]--
	self.Debuffs = CreateFrame("Frame", nil, self)
	self.Debuffs.size = 22
	self.Debuffs:SetHeight(self.Debuffs.size)
	self.Debuffs:SetWidth(self.Debuffs.size * 10)
	self.Debuffs:SetPoint('BOTTOMLEFT', oUF.units.player, 'TOPLEFT', -2, 13)
	self.Debuffs.initialAnchor = 'BOTTOMLEFT'
	self.Debuffs["growth-y"] = 'TOP'
	self.Debuffs.num = 20
	self.Debuffs.spacing = 3
    
-----------------------------------------------------------------------
--      Cast Bars
-----------------------------------------------------------------------
    --[[ player cast bar ]]--
	if unit=='player' then
		self.Castbar = CreateFrame('StatusBar', nil, self)
		self.Castbar:SetWidth(220)
		self.Castbar:SetHeight(12)
		self.Castbar:SetPoint('CENTER', oUF.units.player, 'CENTER', 0, -22)
		self.Castbar:SetStatusBarTexture(bartexture)
		self.Castbar:SetStatusBarColor(0.4, 0.5, 0.7)

        self.Castbar:SetBackdrop({bgFile = [=[Interface\ChatFrame\ChatFrameBackground]=], level = '0', insets = {top = -2, left = -2, bottom = -2, right = -2}})
	    self.Castbar:SetBackdropColor(0, 0, 0, 1)

		self.Castbar.bg = self.Castbar:CreateTexture(nil, 'BORDER')
		self.Castbar.bg:SetAllPoints(self.Castbar)
		self.Castbar.bg:SetTexture(bartexture)
		self.Castbar.bg:SetVertexColor(0.16,0.16,0.16,1)
		
		self.Castbar.Text = self.Castbar:CreateFontString(nil, 'OVERLAY', 'GameFontHighlightLeft')
		self.Castbar.Text:SetPoint('Center', self.Castbar, 0, -13)
        self.Castbar.Text:SetFont(namefont, 13)
		self.Castbar.Text:SetTextColor(1, 1, 1)
	
		self.Castbar.Time = self.Castbar:CreateFontString(nil, 'OVERLAY', 'GameFontHighlightSmallRight')
		self.Castbar.Time:SetPoint('Left', self.Castbar, 224, 1)
		self.Castbar.Time:SetTextColor(1, 1, 1)
		self.Castbar.CustomTimeText = lolCastBarTime

		self.Castbar.Icon = self.Castbar:CreateTexture(nil, "ARTWORK")
		self.Castbar.Icon:SetHeight(20)
		self.Castbar.Icon:SetWidth(20)
		self.Castbar.Icon:SetTexCoord(0,1,0,1)
		self.Castbar.Icon:SetPoint("LEFT", -28, 0)

		self.IconOverlay = self.Castbar:CreateTexture(nil, "OVERLAY")
		self.IconOverlay:SetPoint("TOPLEFT", self.Castbar.Icon, "TOPLEFT")
		self.IconOverlay:SetPoint("BOTTOMRIGHT", self.Castbar.Icon, "BOTTOMRIGHT")
		self.IconOverlay:SetTexture(bufftexture)
		self.IconOverlay:SetVertexColor(0.25, 0.25, 0.25)
        
        self.Castbar.SafeZone = self.Castbar:CreateTexture(nil,"ARTWORK")
		self.Castbar.SafeZone:SetTexture(CBtex)
		self.Castbar.SafeZone:SetVertexColor(0.85,0.10,0.10,0.50)
		self.Castbar.SafeZone:SetPoint("TOPRIGHT")
		self.Castbar.SafeZone:SetPoint("BOTTOMRIGHT")	

	end

--[[ target cast bar ]]--
	if unit=='target' then
		self.Castbar = CreateFrame('StatusBar', nil, self)
		self.Castbar:SetWidth(220)
		self.Castbar:SetHeight(12)
		self.Castbar:SetPoint('CENTER', oUF.units.target, 'CENTER', 0, -22)
		self.Castbar:SetStatusBarTexture(bartexture)
		self.Castbar:SetStatusBarColor(0.4, 0.5, 0.7)
        
        self.Castbar:SetBackdrop({bgFile = [=[Interface\ChatFrame\ChatFrameBackground]=], level = '0', insets = {top = -2, left = -2, bottom = -2, right = -3}})
	    self.Castbar:SetBackdropColor(0, 0, 0, 1)

		self.Castbar.bg = self.Castbar:CreateTexture(nil, 'BORDER')
		self.Castbar.bg:SetAllPoints(self.Castbar)
		self.Castbar.bg:SetTexture(bartexture)
		self.Castbar.bg:SetVertexColor(0.16,0.16,0.16,1)

		self.Castbar.Text = self.Castbar:CreateFontString(nil, 'OVERLAY', 'GameFontHighlightSmallLeft')
		self.Castbar.Text:SetPoint('Center', self.Castbar, 0, -13)
        self.Castbar.Text:SetFont(namefont, 14)
		self.Castbar.Text:SetTextColor(1, 1, 1)
	
		self.Castbar.Time = self.Castbar:CreateFontString(nil, 'OVERLAY', 'GameFontHighlightSmallRight')
		self.Castbar.Time:SetPoint('RIGHT', self.Castbar, -224, 2)
		self.Castbar.Time:SetTextColor(1, 1, 1)
		self.Castbar.CustomTimeText = lolCastBarTime

		self.Castbar.Icon = self.Castbar:CreateTexture(nil, "ARTWORK")
		self.Castbar.Icon:SetHeight(20)
		self.Castbar.Icon:SetWidth(20)
		self.Castbar.Icon:SetTexCoord(0,1,0,1)
		self.Castbar.Icon:SetPoint("RIGHT", 28, 0)

		self.IconOverlay = self.Castbar:CreateTexture(nil, "OVERLAY")
		self.IconOverlay:SetPoint("TOPLEFT", self.Castbar.Icon, "TOPLEFT")
		self.IconOverlay:SetPoint("BOTTOMRIGHT", self.Castbar.Icon, "BOTTOMRIGHT")
		self.IconOverlay:SetTexture(bufftexture)
		self.IconOverlay:SetVertexColor(0.25, 0.25, 0.25)
	end

--[[ focus castbar ]]--
	if unit=='focus' then
		self.Castbar = CreateFrame('StatusBar', nil, self)
		self.Castbar:SetWidth(300)
		self.Castbar:SetHeight(10)
		self.Castbar:SetPoint('CENTER', 0, 600)
		self.Castbar:SetStatusBarTexture(bartexture)
		self.Castbar:SetStatusBarColor(0.4, 0.5, 0.7)
        
        self.Castbar:SetBackdrop({bgFile = [=[Interface\ChatFrame\ChatFrameBackground]=], level = '0', insets = {top = -2, left = -3, bottom = -3, right = -2}})
	    self.Castbar:SetBackdropColor(0, 0, 0, 1)

		self.Castbar.bg = self.Castbar:CreateTexture(nil, 'BORDER')
		self.Castbar.bg:SetAllPoints(self.Castbar)
		self.Castbar.bg:SetTexture(bartexture)
		self.Castbar.bg:SetVertexColor(0.16,0.16,0.16,1)

		self.Castbar.Text = self.Castbar:CreateFontString(nil, 'OVERLAY', 'GameFontHighlightLeft')
		self.Castbar.Text:SetPoint('Left', self.Castbar, 0, 16)
        self.Castbar.Text:SetFont(namefont, 12)
		self.Castbar.Text:SetTextColor(1, 1, 1)
	
		self.Castbar.Time = self.Castbar:CreateFontString(nil, 'OVERLAY', 'GameFontHighlightSmallRight')
		self.Castbar.Time:SetPoint('Right', self.Castbar, -2, 16)
		self.Castbar.Time:SetTextColor(1, 1, 1)
		self.Castbar.CustomTimeText = lolCastBarTime

		self.Castbar.Icon = self.Castbar:CreateTexture(nil, "ARTWORK")
		self.Castbar.Icon:SetHeight(50)
		self.Castbar.Icon:SetWidth(50)
		self.Castbar.Icon:SetTexCoord(0,1,0,1)
		self.Castbar.Icon:SetPoint("Center", 0, -36)

		self.IconOverlay = self.Castbar:CreateTexture(nil, "OVERLAY")
		self.IconOverlay:SetPoint("TOPLEFT", self.Castbar.Icon, "TOPLEFT")
		self.IconOverlay:SetPoint("BOTTOMRIGHT", self.Castbar.Icon, "BOTTOMRIGHT")
		self.IconOverlay:SetTexture(bufftexture)
		self.IconOverlay:SetVertexColor(0.25, 0.25, 0.25)

	end

--[[ pet castbar ]]--
	if unit=='pet' then
		self.Castbar = CreateFrame('StatusBar', nil, self)
		self.Castbar:SetWidth(220)
		self.Castbar:SetHeight(10)
		self.Castbar:SetPoint('CENTER', oUF.units.pet, 'CENTER', 0, 17)
		self.Castbar:SetStatusBarTexture(bartexture)
		self.Castbar:SetStatusBarColor(0.4, 0.5, 0.7)
        
        self.Castbar:SetBackdrop({bgFile = [=[Interface\ChatFrame\ChatFrameBackground]=], level = '0', insets = {top = -2, left = -2, bottom = -3, right = -3}})
	    self.Castbar:SetBackdropColor(0, 0, 0, 1)

		self.Castbar.bg = self.Castbar:CreateTexture(nil, 'BORDER')
		self.Castbar.bg:SetAllPoints(self.Castbar)
		self.Castbar.bg:SetTexture(bartexture)
		self.Castbar.bg:SetVertexColor(0.16,0.16,0.16,1)

		self.Castbar.Text = self.Castbar:CreateFontString(nil, 'OVERLAY', 'GameFontHighlightLeft')
		self.Castbar.Text:SetPoint('LEFT', self.Castbar, 0, 15)
        self.Castbar.Text:SetFont(namefont, 12)
		self.Castbar.Text:SetTextColor(1, 1, 1)
	
		self.Castbar.Time = self.Castbar:CreateFontString(nil, 'OVERLAY', 'GameFontHighlightSmallRight')
		self.Castbar.Time:SetPoint('RIGHT', self.Castbar, -2, 15)
		self.Castbar.Time:SetTextColor(1, 1, 1)
		self.Castbar.CustomTimeText = lolCastBarTime

		self.Castbar.Icon = self.Castbar:CreateTexture(nil, "ARTWORK")
		self.Castbar.Icon:SetHeight(20)
		self.Castbar.Icon:SetWidth(20)
		self.Castbar.Icon:SetTexCoord(0,1,0,1)
		self.Castbar.Icon:SetPoint("LEFT", -28, 0)

		self.IconOverlay = self.Castbar:CreateTexture(nil, "OVERLAY")
		self.IconOverlay:SetPoint("TOPLEFT", self.Castbar.Icon, "TOPLEFT")
		self.IconOverlay:SetPoint("BOTTOMRIGHT", self.Castbar.Icon, "BOTTOMRIGHT")
		self.IconOverlay:SetTexture(bufftexture)
		self.IconOverlay:SetVertexColor(0.25, 0.25, 0.25)

	end

--[[ combo points ]]--
	if unit=='target' then
		self.CPoints = {}
		self.CPoints.unit = 'player'
			for i = 1, 5 do
				self.CPoints[i] = self.Power:CreateTexture(nil, 'OVERLAY')
				self.CPoints[i]:SetHeight(12)
				self.CPoints[i]:SetWidth(12)
				self.CPoints[i]:SetTexture(combotexture)
				if (i == 1) then
					self.CPoints[i]:SetPoint('BOTTOMRIGHT', self, 3, -20)
				else
					self.CPoints[i]:SetPoint('RIGHT', self.CPoints[i-1], 'LEFT', 1)
				end
			end
		end

-----------------------------------------------------------------------
--      Frame Settings
-----------------------------------------------------------------------
  
    if unit=='player' then
		self:SetAttribute('initial-height', 20)
	    self:SetAttribute('initial-width', 220)
		self.Power:Show()
		unitnames:SetPoint('Center', self, 0, -21)
		curhealth:Show()
		curpower:Show()
        curhealth:SetPoint('Right', self, -230, 0)
        curpower:SetPoint('Right', self, -230, 18)
        healthbg:SetWidth(220)
	    healthbg:SetHeight(20)
    end

	if unit == 'target' then
		self:SetAttribute('initial-height', 20)
	    self:SetAttribute('initial-width', 220)
		self.Power:Show()
		unitnames:SetPoint('Center', self, 0, -21)
		curhealth:Show()
		curpower:Show()
        curhealth:SetPoint('Left', self, 230, 0)
        curpower:SetPoint('Left', self, 230, 18)
        healthbg:SetWidth(220)
	    healthbg:SetHeight(20)
	end

	if unit ~= 'target' then
		self.Buffs:Hide()
		self.Debuffs:Hide()
	end
	
	if unit=='focus' then
	    self:SetAttribute('initial-height', 16)
	    self:SetAttribute('initial-width', 100)
		self.Power:Hide()
	    unitnames:SetPoint('Center', self, 0, 21)
		curhealth:Hide()
		curpower:Hide()
        healthbg:SetWidth(100)
	    healthbg:SetHeight(16)
	end
    
    if unit=='targettarget' then
	    self:SetAttribute('initial-height', 16)
	    self:SetAttribute('initial-width', 100)
		self.Power:Hide()
	    unitnames:SetPoint('Center', self, 0, -21)
		curhealth:Hide()
		curpower:Hide()
        healthbg:SetWidth(100)
	    healthbg:SetHeight(16)
	end

	if unit=='pet' then
		self:SetAttribute('initial-height', 12)
	    self:SetAttribute('initial-width', 220)
		self.Power:Hide()
	    unitnames:SetPoint('Right', self, -230, 1)
		curhealth:Hide()
		curpower:Hide()
	end
		self.PostCreateAuraIcon = auraIcon
	
		return self
	end

    oUF:RegisterStyle('oUF_bloo', layout)
    oUF:SetActiveStyle('oUF_bloo')
	
	oUF:Spawn('player'):SetPoint('CENTER', -200, -300)
	oUF:Spawn('focus'):SetPoint('CENTER', 0, -279)
	oUF:Spawn('target'):SetPoint('CENTER', 200, -300)
	oUF:Spawn('targettarget'):SetPoint('CENTER', 0, -301)
	oUF:Spawn('pet'):SetPoint('Center', -200, -269)
Any other constructive criticism is more than welcome as well! Thanks

Last edited by Blooblahguy : 03-29-10 at 05:52 PM.
  Reply With Quote
03-29-10, 08:40 AM   #2
Dawn
A Molten Giant
 
Dawn's Avatar
AddOn Author - Click to view addons
Join Date: May 2006
Posts: 918
Take a look at power.lua and health.lua in oUF\elements.

power
Code:
	
	 The following settings are listed by priority:
	 - colorTapping
	 - colorDisconnected
	 - colorHappiness
	 - colorPower
	 - colorClass (Colors player units based on class)
	 - colorClassPet (Colors pet units based on class)
	 - colorClassNPC (Colors non-player units based on class)
	 - colorReaction
	 - colorSmooth - will use smoothGradient instead of the internal gradient if set.
and health
Code:
	Shared:
	 The following settings are listed by priority:
	 - colorTapping
	 - colorDisconnected
	 - colorHappiness
	 - colorClass (Colors player units based on class)
	 - colorClassPet (Colors pet units based on class)
	 - colorClassNPC (Colors non-player units based on class)
	 - colorReaction
	 - colorSmooth - will use smoothGradient instead of the internal gradient if set.
	 - colorHealth

To increase the updating

Code:
	 - frequentUpdates - do OnUpdate polling of health data.

example
Code:
	self.Power.frequentUpdates = true
	self.Power.colorHappiness = true
	self.Power.colorClass = true
This will class color the power bar, happiness color if it's the player's pet and frequent updates are enabled.
__________________
Rock: "We're sub-standard DPS. Nerf Paper, Scissors are fine."
Paper: "OMG, WTF, Scissors!"
Scissors: "Rock is OP and Paper are QQers. We need PvP buffs."

"neeh the game wont be remembered as the game who made blizz the most money, it will be remembered as the game who had the most QQ'ers that just couldnt quit the game for some reason..."

  Reply With Quote
03-29-10, 02:52 PM   #3
Blooblahguy
A Deviate Faerie Dragon
AddOn Author - Click to view addons
Join Date: Oct 2009
Posts: 18
I have some of that code already in my layout but for some reason it doesn't work at all. This is where I'm completely confused and wondering if its a formatting error.
  Reply With Quote
03-29-10, 03:32 PM   #4
Rostok
A Flamescale Wyrmkin
Join Date: Jul 2008
Posts: 127
Hi there,

Some code that might be useful for your layout :

Code:
local function Hex(r, g, b)
	if type(r) == 'table' then
		if r.r then r, g, b = r.r, r.g, r.b else r, g, b = unpack(r) end
	end
	return string.format('|cff%02x%02x%02x', r*255, g*255, b*255)
end

oUF.Tags['[shortcurpp]'] = function(u)
local _, powerTypeString = UnitPowerType(u)
return powerTypeString and Hex(oUF.colors.power[powerTypeString])..shorthpval(UnitPower(u)) or shorthpval(UnitPower(u))
end
Didn't test it but should work, as for the health text look for a gradient color (you should find clues on these forums).
  Reply With Quote
03-29-10, 04:31 PM   #5
Blooblahguy
A Deviate Faerie Dragon
AddOn Author - Click to view addons
Join Date: Oct 2009
Posts: 18
I updated the code listed in my original post. I was able to finally color health with some of the help from you two, thank you. The power in my layout is colored as well however i'm running into an issue that I once again need help with. My power value, as in the actual number, will not update unless you retarget or reloadui. Any ideas?
  Reply With Quote
03-29-10, 05:34 PM   #6
Blooblahguy
A Deviate Faerie Dragon
AddOn Author - Click to view addons
Join Date: Oct 2009
Posts: 18
Figured it out. though I'm still not able to get the texts to frequentupdate. the bars of course do, but "curhealth.frequentUpdates = true" doesn't have any effect.
  Reply With Quote
03-30-10, 12:03 AM   #7
Rostok
A Flamescale Wyrmkin
Join Date: Jul 2008
Posts: 127
Try "curhealth.frequentUpdates = 0.1".
  Reply With Quote
03-30-10, 02:01 AM   #8
Blooblahguy
A Deviate Faerie Dragon
AddOn Author - Click to view addons
Join Date: Oct 2009
Posts: 18
no dice :P
  Reply With Quote
03-30-10, 07:08 AM   #9
Dawn
A Molten Giant
 
Dawn's Avatar
AddOn Author - Click to view addons
Join Date: May 2006
Posts: 918
I might be wrong, but tags don't profit from frequentUpdates, afaik. A normal health function would do it, though.

Edit: something like this

Code:
local updateHealth = function(self, event, unit, bar, min, max)
    local d =(round(min/max, 2)*100)
	bar.PERvalue:SetText((round(min/max, 2)*100))
	bar.value:SetText(min)	
	bar.value:SetTextColor(1,1,1])
	bar.PERvalue:SetTextColor(1,1,1)
end
or
Code:
local updatePower = function(self, event, unit, bar, min, max)
	local dp =(round(min/max, 2)*100)
	bar.value:SetText(min)
	bar.value:SetTextColor(1,1,1)
end
note: just examples, nothing that insta-fits into your layout
__________________
Rock: "We're sub-standard DPS. Nerf Paper, Scissors are fine."
Paper: "OMG, WTF, Scissors!"
Scissors: "Rock is OP and Paper are QQers. We need PvP buffs."

"neeh the game wont be remembered as the game who made blizz the most money, it will be remembered as the game who had the most QQ'ers that just couldnt quit the game for some reason..."


Last edited by Dawn : 03-30-10 at 07:14 AM.
  Reply With Quote
03-30-10, 10:47 AM   #10
Waverian
A Chromatic Dragonspawn
AddOn Author - Click to view addons
Join Date: Dec 2006
Posts: 188
Tags support OnUpdate polling.

tags.lua: line 417
Code:
	if((unit and unit:match'%w+target') or fs.frequentUpdates) then
		local timer
		if(type(fs.frequentUpdates) == 'number') then
			timer = fs.frequentUpdates
		else
			timer = .5
		end

		if(not eventlessUnits[timer]) then eventlessUnits[timer] = {} end
		table.insert(eventlessUnits[timer], fs)

		createOnUpdate(timer)
	else
  Reply With Quote

WoWInterface » Featured Projects » oUF (Otravi Unit Frames) » Colored health text

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