Quantcast WoWInterface - View Single Post - oUF - Layout discussion
View Single Post
09-25-09, 03:33 PM   #1192
Wimpface
A Molten Giant
 
Wimpface's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 648
So I've been trying to add Auras to my target frame for some time now but I must be doing something terribly wrong as it just won't show them.

My aura code is based on oUF_ALZA, however my layout code is based on oUF_P3lim. Here's the code I try to spawn my auras with.
Code:
		if(unit == 'target') then
			local auras = CreateFrame("Frame", nil, self)
	        auras:SetPoint("TOPLEFT", self, "BOTTOMLEFT", -2, -3)
	        auras.initialAnchor = "TOPLEFT"
	        auras["growth-x"] = "RIGHT"
	        auras["growth-y"] = "DOWN"
	        auras.numDebuffs = 16
	        auras:SetHeight(500)
	        auras:SetWidth(180 + 30 / 2)
	        auras.spacing = 1
	        auras.size = 30
	        auras.gap = true
	        --auras.onlyShowPlayer = true
	        self.Auras = auras
			self.PostCreateAuraIcon = PostCreateAuraIcon
		end
Here's my entire layout, sorry for the long paste.
Code:
--[[

  Adrian L Lange grants anyone the right to use this work for any purpose,
  without any conditions, unless such conditions are required by law.

--]]

local max = math.max
local floor = math.floor

local barTex = [=[Interface\AddOns\!media\textures\statusbar.tga]=]
local backdrop = {
	bgFile = [=[Interface\ChatFrame\ChatFrameBackground]=],
	insets = {top = -1, bottom = -1, left = -1, right = -1}
}

local bordertex = "Interface\\AddOns\\!media\\textures\\gloss"  -- border for aura icons
local debufftex = "Interface\\AddOns\\!media\\textures\\dh"     -- for oUF_DebuffHighlight

-- Configure font settings here.															http://www.wowwiki.com/API_FontInstance_SetFont
local font = [=[Interface\AddOns\!media\fonts\Semplice Regular.ttf]=]
local fsize = 8
local fstyle = 'THINOUTLINE'
local removeShadows = true

local MyUnits = { -- used for hiding cooldowns on target frame
    player = true,
    pet = true,
    vehicle = true,
}

local _, class = UnitClass('player')
r = RAID_CLASS_COLORS[class].r
g = RAID_CLASS_COLORS[class].g
b = RAID_CLASS_COLORS[class].b

local colors = setmetatable({
	power = setmetatable({
		MANA = {0, 144/255, 1}
	}, {__index = oUF.colors.power}),
	runes = setmetatable({
		[1] = {0.8, 0, 0},
		[3] = {0, 0.4, 0.7},
		[4] = {0.8, 0.8, 0.8}
	}, {__index = oUF.colors.runes})
}, {__index = oUF.colors})

local buffFilter = {
	[GetSpellInfo(62600)] = true,
	[GetSpellInfo(61336)] = true,
	[GetSpellInfo(52610)] = true,
	[GetSpellInfo(22842)] = true,
	[GetSpellInfo(22812)] = true,
	[GetSpellInfo(16870)] = true
}

local function menu(self)
	local drop = _G[string.gsub(self.unit, '(.)', string.upper, 1) .. 'FrameDropDown']
	if(drop) then
		ToggleDropDownMenu(1, nil, drop, 'cursor')
	end
end

--[[ Font creation func ]]
MakeFS = function(parent, justify)
    local f = parent:CreateFontString(nil, "OVERLAY")
    f:SetFont(font, fsize, fstyle)
    f:SetShadowColor(0, 0, 0, 0)
    if(justify) then f:SetJustifyH(justify) end
    return f
end

--[[ Background creation func ]]
MakeBG = function(parent)
    local bg = parent:CreateTexture(nil, "BACKGROUND")
    bg:SetPoint("TOPLEFT", parent, -2, 2)
    bg:SetPoint("BOTTOMRIGHT", parent, 2, -2)
    bg:SetTexture(0, 0, 0)
end

local function updateCombo(self, event, unit)
	if(unit == PlayerFrame.unit and unit ~= self.CPoints.unit) then
		self.CPoints.unit = unit
	end
end

local function updatePower(self, event, unit, bar, minVal, maxVal)
	if(unit ~= 'target') then return end

	if(maxVal ~= 0) then
		self.Health:SetHeight(22)
		bar:Show()
	else
		self.Health:SetHeight(27)
		bar:Hide()
	end
end

local function castIcon(self, event, unit)
	local castbar = self.Castbar
	if(castbar.interrupt) then
		castbar.Button:SetBackdropColor(0, 0.9, 1)
	else
		castbar.Button:SetBackdropColor(0, 0, 0)
	end
end 

local function castTime(self, duration)
	if(self.channeling) then
		self.Time:SetFormattedText('%.1f ', duration)
	elseif(self.casting) then
		self.Time:SetFormattedText('%.1f ', self.max - duration)
	end
end

local function updateTime(self, elapsed)
	self.remaining = max(self.remaining - elapsed, 0)
	self.time:SetText(self.remaining < 90 and floor(self.remaining) or '')
end

local noHide = function(self)
    self:SetVertexColor(0, 0, 0)
end

local PostCreateAuraIcon = function(self, button, icons, index, isDebuff)
    button.cd:SetReverse()

    button.count:ClearAllPoints()
    button.count:SetPoint("TOP")
    button.count:SetJustifyH("CENTER")
    button.count:SetFont(font, fsize, fstyle)
    button.count:SetTextColor(.8, .8, .8)

    button.icon:SetTexCoord(0, 1, 0, 1)

    button.overlay:SetTexture(bordertex)
    button.overlay:SetTexCoord(0, 1, 0, 1)   
    button.overlay.Hide = noHide
end

local PostUpdateAuraIcon = function(self, icons, unit, icon, index, offset, filter, isDebuff)
    if(icon.cd:IsShown() and isDebuff and not MyUnits[icon.owner] and not UnitIsPlayer(self.unit)) then
        icon.cd:Hide()
    end
end

local function customFilter(icons, unit, icon, name, rank, texture, count, dtype, duration, expiration, caster)
	if(buffFilter[name] and caster == 'player') then
		return true
	end
end

--[[ Disabling default buff frames ]]
_G["BuffFrame"]:Hide()
_G["BuffFrame"]:UnregisterAllEvents()
_G["BuffFrame"]:SetScript("OnUpdate", nil)

--[[ Temporary enchant stuff ]]
for i = 1, 2 do
    _G["TempEnchant"..i.."Icon"]:Hide()
    _G["TempEnchant"..i.."Count"]:Hide()
    _G["TempEnchant"..i.."Border"]:Hide()
    _G["TempEnchant"..i.."Duration"] = MakeFS(UIParent)
    _G["TempEnchant"..i]:ClearAllPoints()
    _G["TempEnchant"..i]:SetAllPoints(_G["TempEnchant"..i.."Duration"])
end

local function style(self, unit)
	self.colors = colors
	self.menu = menu

	self:RegisterForClicks('AnyUp')
	self:SetAttribute('type2', 'menu')

	self:SetScript('OnEnter', UnitFrame_OnEnter)
	self:SetScript('OnLeave', UnitFrame_OnLeave)

	self:SetBackdrop(backdrop)
	self:SetBackdropColor(0, 0, 0)

	self.Health = CreateFrame('StatusBar', nil, self)
	self.Health:SetPoint('TOPRIGHT')
	self.Health:SetPoint('TOPLEFT')
	self.Health:SetStatusBarTexture(barTex)
	self.Health.colorClass = false
	self.Health.colorReaction = false
	self.Health:SetStatusBarColor(0.2, 0.2, 0.2)
	self.Health:SetHeight((unit == 'focus' or unit == 'targettarget') and 20 or 22)
	self.Health.frequentUpdates = true

	self.Health.bg = self.Health:CreateTexture(nil, 'BORDER')
	self.Health.bg:SetAllPoints(self.Health)
	self.Health.bg:SetTexture(0.3, 0.3, 0.3)

	local health = self.Health:CreateFontString(nil, 'OVERLAY', 'GameFontHighlightSmallRight')
	health:SetPoint('RIGHT', self.Health, -2, -1)
	health.frequentUpdates = 0.25
	self:Tag(health, '[phealth]')	
	
	local power = self.Health:CreateFontString(nil, 'OVERLAY', 'GameFontHighlightSmallLeft')
	power:SetPoint('LEFT', self.Health, 2, -1)
	power.frequentUpdates = 0.1
	self:Tag(power, '[ppower]')	
	
	local info = self.Health:CreateFontString(nil, 'OVERLAY', 'GameFontHighlightSmallLeft')
	info:SetPoint('LEFT', self.Health, 2, -1)
	info:SetPoint('RIGHT', health, 'LEFT')
	self:Tag(info, '[raidcolor][name]')	
	
	if removeShadows == true then
		info:SetShadowOffset(0, 0)
		power:SetShadowOffset(0, 0)
		health:SetShadowOffset(0, 0)
	end
	
	self.RaidIcon = self.Health:CreateTexture(nil, 'OVERLAY')
	self.RaidIcon:SetPoint('TOP', self, 0, 8)
	self.RaidIcon:SetHeight(16)
	self.RaidIcon:SetWidth(16)

	if(unit == 'focus' or unit == 'targettarget') then
	else
		self.Power = CreateFrame('StatusBar', nil, self)
		self.Power:SetPoint('BOTTOMRIGHT')
		self.Power:SetPoint('BOTTOMLEFT')
		self.Power:SetPoint('TOP', self.Health, 'BOTTOM', 0, -1)
		self.Power:SetStatusBarTexture(barTex)
		self.Power.frequentUpdates = true

		self.Power.colorClass = false
		self.Power.colorTapping = false
		self.Power.colorDisconnected = false
		self.Power.colorReaction = false
		self.Power.colorHappiness = unit == 'pet'
		self.Power.colorPower = true

		self.Power.bg = self.Power:CreateTexture(nil, 'BORDER')
		self.Power.bg:SetAllPoints(self.Power)
		self.Power.bg:SetTexture([=[Interface\ChatFrame\ChatFrameBackground]=])
		self.Power.bg.multiplier = 0.3
	end

	if(unit == 'player') then
		if IsAddOnLoaded("oUF_Experience") and UnitLevel("Player") < 80 then
			self.Experience = CreateFrame('StatusBar', nil, self)
			--self.Experience:SetPoint('TOPLEFT', self, 'BOTTOMLEFT', 0, -20)
			--self.Experience:SetPoint('TOPRIGHT', self, 'BOTTOMRIGHT', 0, -20)
			self.Experience:SetPoint('CENTER', self, 'CENTER', 0, -19)
			self.Experience:SetHeight(4)
			self.Experience:SetWidth(180)
			self.Experience:SetStatusBarTexture(barTex)
			self.Experience:SetStatusBarColor(0.15, 0.7, 0.1)
			self.Experience.Tooltip = true

			self.Experience.Rested = CreateFrame('StatusBar', nil, self)
			self.Experience.Rested:SetAllPoints(self.Experience)
			self.Experience.Rested:SetStatusBarTexture(barTex)
			self.Experience.Rested:SetStatusBarColor(0, 0.4, 1, 0.6)
			self.Experience.Rested:SetBackdrop(backdrop)
			self.Experience.Rested:SetBackdropColor(0, 0, 0)

			self.Experience.Text = self.Experience:CreateFontString(nil, 'OVERLAY', 'GameFontHighlightSmall')
			self.Experience.Text:SetPoint('CENTER', self.Experience, 'CENTER', 0, -15)
			self.Experience.Text:SetFont(font, fsize, fstyle)

			self.Experience.bg = self.Experience.Rested:CreateTexture(nil, 'BORDER')
			self.Experience.bg:SetAllPoints(self.Experience)
			self.Experience.bg:SetTexture(0.2, 0.2, 0.2)
		end
	end
	if(unit == 'player') then
		if IsAddOnLoaded('oUF_Reputation') and UnitLevel("player") == 80 then
			self.Reputation = CreateFrame('StatusBar', nil, self)
			--self.Reputation:SetPoint('TOPLEFT', self, 'BOTTOMLEFT', 0, -20)
			--self.Reputation:SetPoint('TOPRIGHT', self, 'BOTTOMRIGHT', 0, -20)
			self.Reputation:SetPoint('CENTER', self, 'CENTER', 0, -116)
			self.Reputation:SetHeight(11)
			self.Reputation:SetWidth(417)
			self.Reputation:SetStatusBarTexture(barTex)
			self.Reputation:SetStatusBarColor(0.15, 0.7, 0.1)
			self.Reputation.Tooltip = true
			
			self.Reputation:SetBackdrop(backdrop)
			self.Reputation:SetBackdropColor(0, 0, 0)
			
			self.Reputation.Text = self.Reputation:CreateFontString(nil, 'OVERLAY', 'GameFontHighlightSmall')
			self.Reputation.Text:SetPoint('CENTER', self.Reputation)
			
			self.Reputation.bg = self.Reputation:CreateTexture(nil, 'BORDER')
			self.Reputation.bg:SetAllPoints(self.Reputation)
			self.Reputation.bg:SetTexture(0.2, 0.2, 0.2)
		end
		
	    local buffs = CreateFrame("Frame", nill, self)
        buffs:SetPoint("TOPRIGHT", UIParent, "TOPRIGHT", -25, -25)
        buffs.initialAnchor = "TOPRIGHT"
        buffs["growth-y"] = "DOWN"
        buffs["growth-x"] = "LEFT"
        buffs:SetHeight(500)
        buffs:SetWidth((30 + 3) * 10)
        buffs.spacing = 3
        buffs.size = 30
        self.Buffs = buffs

        local debuffs = CreateFrame("Frame", nill, self)
        debuffs:SetPoint("TOPRIGHT", self, "BOTTOMRIGHT", 2, -23)
        debuffs.initialAnchor = "TOPRIGHT"
        debuffs["growth-x"] = "LEFT"
        debuffs["growth-y"] = "DOWN"
        debuffs:SetHeight(500)
        debuffs:SetWidth(180 + 30 / 2)
        debuffs.spacing = 3
        debuffs.size = 30
        self.Debuffs = debuffs
		
		local dur1 = _G["TempEnchant1Duration"]
        local dur2 = _G["TempEnchant2Duration"]
        if(self.RuneBar or self.DruidPower) then
            dur2:SetPoint("TOPRIGHT", ppp or hpp, "TOPLEFT")
            dur1:SetPoint("TOPRIGHT", dur2, "TOPLEFT")
        else
            dur1:SetPoint("BOTTOMLEFT", self, "TOPLEFT", -2, 3)
            dur2:SetPoint("TOPLEFT", dur1, "TOPRIGHT")
        end
        dur1:SetVertexColor(1, 1, 1)
        dur2:SetVertexColor(1, 1, 1)
        dur1.SetVertexColor = function() end
        dur2.SetVertexColor = function() end
		
		self.PostCreateAuraIcon = PostCreateAuraIcon
		self.PostUpdateAuraIcon = PostUpdateAuraIcon
	end

	if(unit == 'pet') then
		self.Auras = CreateFrame('Frame', nil, self)
		self.Auras:SetPoint('TOPRIGHT', self, 'TOPLEFT', -4, 0)
		self.Auras:SetHeight(4)
		self.Auras:SetWidth(256)
		self.Auras.size = 22
		self.Auras.spacing = 4
		self.Auras.initialAnchor = 'TOPRIGHT'
		self.Auras['growth-x'] = 'LEFT'
		self.PostCreateAuraIcon = PostCreateAuraIcon
	end

	if(unit == 'player' or unit == 'target') then
		if(unit == 'target') then
			local auras = CreateFrame("Frame", nil, self)
	        auras:SetPoint("TOPLEFT", self, "BOTTOMLEFT", -2, -3)
	        auras.initialAnchor = "TOPLEFT"
	        auras["growth-x"] = "RIGHT"
	        auras["growth-y"] = "DOWN"
	        auras.numDebuffs = 16
	        auras:SetHeight(500)
	        auras:SetWidth(180 + 30 / 2)
	        auras.spacing = 1
	        auras.size = 30
	        auras.gap = true
	        --auras.onlyShowPlayer = true
	        self.Auras = auras
			self.PostCreateAuraIcon = PostCreateAuraIcon
		end

		self.Castbar = CreateFrame('StatusBar', nil, self)
		self.Castbar:SetHeight(16)
		self.Castbar:SetStatusBarTexture(barTex)
		self.Castbar:SetBackdrop(backdrop)
		self.Castbar:SetBackdropColor(0, 0, 0)

		self.Castbar.bg = self.Castbar:CreateTexture(nil, 'BORDER')
		self.Castbar.bg:SetAllPoints(self.Castbar)
		self.Castbar.bg:SetTexture(barTex)

		self.Castbar.Text = self.Castbar:CreateFontString(nil, 'OVERLAY', 'GameFontHighlightSmallLeft')

		self.Castbar.Time = self.Castbar:CreateFontString(nil, 'OVERLAY', 'GameFontHighlightSmallRight')
		self.Castbar.CustomTimeText = castTime

		self.Castbar.Button = CreateFrame('Frame', nil, self.Castbar)
		self.Castbar.Button:SetHeight(16)
		self.Castbar.Button:SetWidth(16)
		self.Castbar.Button:SetBackdrop(backdrop)
		self.Castbar.Button:SetBackdropColor(0, 0, 0)

		self.Castbar.Icon = self.Castbar.Button:CreateTexture(nil, 'ARTWORK')
		self.Castbar.Icon:SetAllPoints(self.Castbar.Button)
		self.Castbar.Icon:SetTexCoord(0.08, 0.92, 0.08, 0.92)
		self.Castbar.Time:SetFont(font, fsize, fstyle)
		self.Castbar.Text:SetFont(font, fsize, fstyle)

		if(unit == 'target') then
			self.PostCastStart = castIcon
			self.PostChannelStart = castIcon
			self.Castbar:SetPoint('TOPLEFT', self, 'BOTTOMLEFT', 0, -60)
			self.Castbar.Button:SetPoint('LEFT', self.Castbar, 'RIGHT', 4, 0)
			self.Castbar:SetStatusBarColor(1, 0, 0)
			self.Castbar.bg:SetVertexColor(0.3, 0.3, 0,3)
			self.Castbar.Text:SetPoint('LEFT', 2, 1)
			self.Castbar.Time:SetPoint('RIGHT', -2, 1)
			self.Castbar:SetWidth(230)
		else
			self.Castbar:SetPoint('TOPRIGHT', self, 'BOTTOMRIGHT', 0, 50)
			--self.Castbar.Button:SetPoint('BOTTOMRIGHT', self.Castbar, 'BOTTOMLEFT', -3, 0)
			self.Castbar:SetStatusBarColor(r, g, b)
			self.Castbar.bg:SetVertexColor(0.3, 0.3, 0,3)
			self.Castbar.Text:SetPoint('LEFT', 0, 17)
			self.Castbar.Time:SetPoint('RIGHT', 0, 17)
			self.Castbar:SetWidth(180)
		end

		self.PostUpdatePower = updatePower
	end
	
	if(unit == 'player') then
		self:SetAttribute('initial-height', 22)
		self:SetAttribute('initial-width', 180)
		
		self.Health:SetHeight(17)
		self.Power:SetHeight(5)
		
		power:SetFont(font, fsize, fstyle)
		health:SetFont(font, fsize, fstyle)
		
		info:Hide()
	elseif(unit == 'target') then
		self:SetAttribute('initial-height', 27)
		self:SetAttribute('initial-width', 230)
		
		health:SetFont(font, fsize, fstyle)
		info:SetFont(font, fsize, fstyle)
		
		power:Hide()
	elseif(unit == 'focus') then
		self:SetAttribute('initial-height', 15)
		self:SetAttribute('initial-width', 180)
		
		self.Health:SetHeight(15)
		--self.Power:Hide()
		
		health:SetFont(font, fsize, fstyle)
		info:SetFont(font, fsize, fstyle)
		
		health:SetPoint('RIGHT', self.Health, -2, 0)
		info:SetPoint('LEFT', self.Health, 2, 0)
		
		power:Hide()
	elseif(unit == 'targettarget') then
		self:SetAttribute('initial-height', 15)
		self:SetAttribute('initial-width', 230)
		
		self.Health:SetHeight(15)
		
		health:SetFont(font, fsize, fstyle)
		info:SetFont(font, fsize, fstyle)
		
		health:SetPoint('RIGHT', self.Health, -2, 0)
		info:SetPoint('LEFT', self.Health, 2, 0)
		
		power:Hide()
	elseif(unit == 'pet') then
		self:SetAttribute('initial-height', 22)
		self:SetAttribute('initial-width', 140)
		
		self.Health:SetHeight(17)
		self.Power:SetHeight(5)
		
		power:SetFont(font, fsize, fstyle)
		health:SetFont(font, fsize, fstyle)
		
		info:Hide()
	end

	if(unit == 'target') then
		self.CPoints = self:CreateFontString(nil, 'OVERLAY', 'SubZoneTextFont')
		self.CPoints:SetPoint('RIGHT', self, 'LEFT', -9, 0)
		self.CPoints:SetTextColor(1, 1, 1)
		self.CPoints:SetJustifyH('RIGHT')
		self.CPoints.unit = PlayerFrame.unit
		self:RegisterEvent('UNIT_COMBO_POINTS', updateCombo)
		self.CustomAuraFilter = customFilter
	end

	if(unit == 'player') then
		if(select(2, UnitClass('player')) == 'DEATHKNIGHT') then
			self.Runes = CreateFrame('Frame', nil, self)
			self.Runes:SetPoint('TOPLEFT', self, 'BOTTOMLEFT', 0, -1)
			self.Runes:SetHeight(4)
			self.Runes:SetWidth(180)
			self.Runes:SetBackdrop(backdrop)
			self.Runes:SetBackdropColor(0, 0, 0)
			self.Runes.anchor = 'TOPLEFT'
			self.Runes.growth = 'RIGHT'
			self.Runes.height = 4
			self.Runes.width = 180 / 6 - 0.85

			for index = 1, 6 do
				self.Runes[index] = CreateFrame('StatusBar', nil, self.Runes)
				self.Runes[index]:SetStatusBarTexture(barTex)

				self.Runes[index].bg = self.Runes[index]:CreateTexture(nil, 'BACKGROUND')
				self.Runes[index].bg:SetAllPoints(self.Runes[index])
				self.Runes[index].bg:SetTexture(0.2, 0.2, 0,2)
			end
		end

		self.Leader = self.Health:CreateTexture(nil, 'OVERLAY')
		self.Leader:SetPoint('TOPLEFT', self, 0, 8)
		self.Leader:SetHeight(16)
		self.Leader:SetWidth(16)

		self.Assistant = self.Health:CreateTexture(nil, 'OVERLAY')
		self.Assistant:SetPoint('TOPLEFT', self, 0, 8)
		self.Assistant:SetHeight(16)
		self.Assistant:SetWidth(16)

	end

	self.DebuffHighlightBackdrop = true
	self.DebuffHighlightFilter = true
	
end

oUF:RegisterStyle('Hariyama', style)
oUF:SetActiveStyle('Hariyama')

oUF:Spawn('player', 'oUF_Player'):SetPoint('CENTER', UIParent, 0, -350)
oUF:Spawn('target', 'oUF_Target'):SetPoint('CENTER', UIParent, 220, -100)
oUF:Spawn('targettarget', 'oUF_ToT'):SetPoint('BOTTOMRIGHT', oUF.units.target, 'TOPRIGHT', 0, 3)
oUF:Spawn('focus', 'oUF_Focus'):SetPoint('BOTTOMLEFT', oUF.units.player, 'TOPLEFT', 0, 5)
oUF:Spawn('pet', 'oUF_Pet'):SetPoint('RIGHT', oUF.units.player, 'LEFT', -25, 0)
Thanks in advance.
- Wimpzter.
__________________
All I see is strobe lights blinding me in my hindsight.