Thread Tools Display Modes
Prev Previous Post   Next Post Next
12-01-09, 05:57 PM   #1
Tastyfrog
A Deviate Faerie Dragon
Join Date: Mar 2009
Posts: 15
Layout help

I am working on creating my own layout. Right now i am just modding oUF Lily and using bits and pieces from other layouts... However, I am having trouble changing the font.

Here's my layout:
Code:
local statusbar = "Interface\\AddOns\\oUF_tSmooth\\textures\\HalM"
local font = "Interface\\AddOns\\oUF_tSmooth\\textures\\HalM"

local fontString = function(parent, size)
	local fs = parent:CreateFontString(nil, "OVERLAY")
	fs:SetFont("Interface\\AddOns\\oUF_tSmooth\\textures\\HalM", size, "OUTLINE")
	return fs
end
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

local updateName = function(self, event, unit)
	if(self.unit == unit) then
		local r, g, b, t
		if(UnitIsTapped(unit) and not UnitIsTappedByPlayer(unit) or not UnitIsConnected(unit)) then
			r, g, b = .6, .6, .6
		elseif(unit == 'pet') then
			t = self.colors.happiness[GetPetHappiness()]
		elseif(UnitIsPlayer(unit)) then
			local _, class = UnitClass(unit)
			t = self.colors.class[class]
		else
			r, g, b = UnitSelectionColor(unit)
		end

		if(t) then
			r, g, b = t[1], t[2], t[3]
		end

		if(r) then
			self.Name:SetTextColor(r, g, b)
		end
	end
end

local updateRIcon = function(self, event)
	local index = GetRaidTargetIndex(self.unit)
	if(index) then
		self.RIcon:SetText(ICON_LIST[index].."22|t")
	else
		self.RIcon:SetText()
	end
end

local shortValue = function(value)
	if value >= 1e6 then
		return ("%.1fm"):format(value / 1e6):gsub("%.?0+([km])$", "%1")
	elseif value >= 1e3 or value <= -1e3 then
		return ("%.1fk"):format(value / 1e3):gsub("%.?0+([km])$", "%1")
	else
		return value
	end
end

local PostCastStart = function(self, event, unit, spell, spellrank, castid)
	self.Name:SetText(spell)
end

local PostCastStop = function(self, event, unit)
	-- Needed as we use it as a general update function.
	if(unit ~= self.unit) then return end
	self.Name:SetText(UnitName(unit))
end

local updateHealth = function(self, event, unit, bar, min, max)
	if(UnitIsDead(unit)) then
		bar:SetValue(0)
		bar.value:SetText"Dead"
	elseif(UnitIsGhost(unit)) then
		bar:SetValue(0)
		bar.value:SetText"Ghost"
	elseif(not UnitIsConnected(unit)) then
		bar.value:SetText"Offline"
	else
		if(not UnitIsFriend('player', unit)) then
			bar.value:SetFormattedText('%s', shortValue(min))
		elseif(min ~= 0 and min ~= max) then
			bar.value:SetFormattedText("-%s", shortValue(max - min))
		else
			bar.value:SetText(max)
		end
	end
	updateName(self, event, unit)
end

local updatePower = function(self, event, unit, bar, min, max)
	if(min == 0 or max == 0 or not UnitIsConnected(unit)) then
		bar.value:SetText()
		bar:SetValue(0)
	elseif(UnitIsDead(unit) or UnitIsGhost(unit)) then
		bar:SetValue(0)
	else
		bar.value:SetFormattedText("%s | ", shortValue(min))
	end
end


local function hookTooltip(self)
	if(self.owner) then
		if(self.owner == 'vehicle' or self.owner == 'pet') then
			GameTooltip:AddLine(format('Cast by %s <%s>', UnitName(self.owner), UnitName('player')))
		elseif(self.owner:match('^partypet[1-4]$')) then
			GameTooltip:AddLine(format('Cast by %s <%s>', UnitName(self.owner), UnitName(format('party%d', self.owner:gsub('^partypet(%d)$', '%1')))))
		elseif(self.owner:match('^raidpet[1-40]$')) then
			GameTooltip:AddLine(format('Cast by %s <%s>', UnitName(self.owner), UnitName(format('raid%d', self.owner:gsub('^raidpet(%d)$', '%1')))))
		else
			GameTooltip:AddLine(format('Cast by %s', UnitName(self.owner)))
		end
	else
		GameTooltip:AddLine(format('Cast by %s', UNKNOWN))
	end

	GameTooltip:Show()
end

local function postCreate(self, button, icons)
	icons.showDebuffType = true
	icons.disableCooldown = true

	button:SetBackdrop({bgFile = [=[Interface\ChatFrame\ChatFrameBackground]=], insets = {top = -1, bottom = -1, left = -1, right = -1}})
	button:SetBackdropColor(0, 0, 0)
	button.icon:SetTexCoord(0.07, 0.93, 0.07, 0.93)
	button.icon:SetDrawLayer('ARTWORK')
	button.overlay:SetTexture()

	button.time = fontString(button, 7)
	button.time:SetPoint('BOTTOM', button, 0, -15)
	button.time:SetTextColor(1, 0.2, 0.2)

	button:HookScript('OnEnter', hookTooltip)
end

local function updateTime(self, elapsed)
	self.timeLeft = max(self.timeLeft - elapsed, 0)
	self.time:SetText(self.timeLeft < 90 and floor(self.timeLeft) or '')
	
	if(GameTooltip:IsOwned(self)) then
		GameTooltip:SetUnitAura(self.frame.unit, self:GetID(), self.filter)
		hookTooltip(self)
	end
end

local function postUpdate(self, icons, unit, icon, index)
	local _, _, _, _, dtype, duration, expiration, unitCaster = UnitAura(unit, index, icon.filter)
	if(unitCaster ~= 'player') then
		icon.icon:SetDesaturated(true)
	end
	if(duration and duration > 0 and expiration) then
		icon.timeLeft = expiration - GetTime()
		icon:SetScript('OnUpdate', updateTime)
	else
		icon.time:SetText()
		icon:SetScript('OnUpdate', nil)
	end
icon.time:SetText()
	if(icon.debuff) then
		local color = DebuffTypeColor[dtype] or DebuffTypeColor.none
		icon:SetBackdropColor(color.r * 0.6, color.g * 0.6, color.b * 0.6)
	else
		icon:SetBackdropColor(0,0,0)
	end
end

local function customFilter(icons, unit, icon, name, rank, texture, count, dtype, duration, expiration, owner)
	       local isPlayer
	       if(caster == 'player' or caster == 'vehicle') then
	               isPlayer = true
	       end
		
	       if((icons.onlyShowPlayer and isPlayer) or (not icons.onlyShowPlayer and name)) then
	               icon.isPlayer = isPlayer
	               icon.owner = caster
	               -- We set it to math.huge, because it lasts until cancelled.
	               if(timeLeft == nil) then
	                       icon.timeLeft = math.huge
	               else
	                       icon.timeLeft = timeLeft
	               end
	               return true
	       end
end

local prePosition = function(self, auras, n)
 for i=1, n do
              local icon = auras[i]
               if(not icon:IsShown()) then
                       icon.timeLeft = -1
               end
       end
	table.sort(auras, function(a,b) return (a.timeLeft and a.timeLeft) > (b.timeLeft and b.timeLeft) end)
end

local func = function(self, unit)
	self.menu = menu

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

	self:RegisterForClicks"anyup"
	self:SetAttribute("*type2", "menu")


	self.Health = CreateFrame("StatusBar")
	self.Health:SetStatusBarTexture(statusbar)
	self.Health:SetWidth((unit == "targettarget" and 50 or 149))
	self.Health:SetHeight(9)
	
	self.Health.colorTapping = true
	self.Health.colorReaction = true
	self.Health.colorDisconnected = true
	self.Health.frequentUpdates = true
	self.Health.colorClass = true

	self.Health:SetParent(self)
	self.Health:SetPoint("TOP")

	self.Health.bg = self.Health:CreateTexture(nil, "BORDER")
	self.Health.bg:SetPoint("TOPRIGHT", 1, 1)
	self.Health.bg:SetPoint("BOTTOMLEFT", -1, -1)
	self.Health.bg:SetTexture(statusbar)
	self.Health.bg.multiplier = 0.33

	self.Health.value = fontString(self.Health, 7)
	self.Health.value:SetPoint("RIGHT", -2, -1)
	self.Health.value:SetFontObject(GameFontNormalSmall)
	self.Health.value:SetTextColor(1, 1, 1)


	self.Power = CreateFrame"StatusBar"
	self.Power:SetHeight(1)
	self.Power:SetWidth((unit == "targettarget" and 50 or 149))
	self.Power:SetStatusBarTexture(statusbar)

	self.Power.frequentUpdates = true
	self.Power.colorTapping = true
	self.Power.colorPower = true

	self.Power:SetParent(self)
	self.Power:SetPoint("TOP")
	self.Power:SetPoint("TOP", self.Health, "BOTTOM",0,-1)
	
	self.Power.bg = self.Power:CreateTexture(nil, "BORDER")
	self.Power.bg:SetPoint("TOPRIGHT", 1, 1)
	self.Power.bg:SetPoint("BOTTOMLEFT", -1, -1)
	self.Power.bg:SetTexture(statusbar)
	self.Power.bg.multiplier = 0.33

	self.Power.value = self.Power:CreateFontString(nil, "OVERLAY")
	self.Power.value:SetPoint("RIGHT", self.Health.value, "LEFT", 0, 0)
	self.Power.value:SetFontObject(GameFontNormalSmall)
	self.Power.value:SetTextColor(1, 1, 1)

	self.PostUpdatePower = updatePower

	if(unit ~= 'targettarget') then
		self.Castbar = CreateFrame"StatusBar"
		self.Castbar:SetStatusBarTexture(statusbar)
		self.Castbar:SetStatusBarColor(1, .25, .35, .5)
		self.Castbar:SetParent(self)
		self.Castbar:SetAllPoints(self.Health)
		self.Castbar:SetToplevel(true)
	end

	self.Leader = self:CreateTexture(nil, "OVERLAY")
	self.Leader:SetHeight(16)
	self.Leader:SetWidth(16)
	self.Leader:SetPoint("BOTTOM", self.Health, "TOP", 0, -5)
	self.Leader:SetTexture"Interface\\GroupFrame\\UI-Group-LeaderIcon"

	self.MasterLooter = self:CreateTexture(nil, 'OVERLAY')
	self.MasterLooter:SetHeight(16)
	self.MasterLooter:SetWidth(16)
	self.MasterLooter:SetPoint('LEFT', leader, 'RIGHT')

	self.RIcon = self.Health:CreateFontString(nil, "OVERLAY")
	self.RIcon:SetPoint("LEFT", 2, 4)
	self.RIcon:SetJustifyH"LEFT"
	self.RIcon:SetFontObject(GameFontNormalSmall)
	self.RIcon:SetTextColor(1, 1, 1)
	self:RegisterEvent("RAID_TARGET_UPDATE", updateRIcon)
	table.insert(self.__elements, updateRIcon)

	self.Name = self.Health:CreateFontString(nil, "OVERLAY")
	self.Name:SetPoint("LEFT", ricon, "RIGHT", 0, -5)
	self.Name:SetPoint("RIGHT", self.Power.value, "LEFT")
	self.Name:SetJustifyH"LEFT"
	self.Name:SetFontObject(GameFontNormalSmall)
	self.Name:SetTextColor(1, 1, 1)
	
	if(unit == "player") then
		self.Buffs = CreateFrame('Frame', nil, UIParent)
		self.Buffs:SetPoint('TOPRIGHT', "UIParent", -10, -10)
		self.Buffs:SetHeight(110)
		self.Buffs:SetWidth(400)
		self.Buffs.size = 20
		self.Buffs.spacing = 12
		self.Buffs.initialAnchor = 'TOPRIGHT'
		self.Buffs['growth-x'] = 'LEFT'
		self.Buffs['growth-y'] = 'DOWN'

		self.Debuffs = CreateFrame('Frame', nil, UIParent)
		self.Debuffs:SetPoint('TOPRIGHT', self.Buffs, 'BOTTOMRIGHT', 0, -15)
		self.Debuffs:SetHeight(110)
		self.Debuffs:SetWidth(400)
		self.Debuffs.size = 20
		self.Debuffs.spacing = 12
		self.Debuffs.initialAnchor = 'TOPRIGHT'
		self.Debuffs['growth-x'] = 'LEFT'
		self.Debuffs['growth-y'] = 'DOWN'
	

		BuffFrame:Hide()
		BuffFrame:UnregisterEvent('UNIT_AURA')
		TemporaryEnchantFrame:Hide()
		TemporaryEnchantFrame:SetScript('OnUpdate', nil)
		TicketStatusFrame:EnableMouse(false)
		TicketStatusFrame:SetFrameStrata('BACKGROUND')
	elseif (unit == "focus" or unit == "target") then
		self.Buffs = CreateFrame('Frame', nil, UIParent)
		self.Buffs:SetPoint('TOPLEFT', self.Health, 0, -15)
		self.Buffs:SetHeight(15)
		self.Buffs:SetWidth(400)
		self.Buffs.size = 10
		self.Buffs.spacing = 4
		self.Buffs.initialAnchor = 'TOPLEFT'
		self.Buffs['growth-x'] = 'RIGHT'
		self.Buffs['growth-y'] = 'DOWN'

		self.Debuffs = CreateFrame('Frame', nil, UIParent)
		self.Debuffs:SetPoint('TOPLEFT', self.Buffs, 'BOTTOMLEFT', 0, -15)
		self.Debuffs:SetHeight(15)
		self.Debuffs:SetWidth(400)
		self.Debuffs.size = 10
		self.Debuffs.spacing = 4
		self.Debuffs.initialAnchor = 'TOPLEFT'
		self.Debuffs['growth-x'] = 'RIGHT'
		self.Debuffs['growth-y'] = 'DOWN'
		
		
		self.Buffs.numBuffs = 11
		self.Debuffs.numDebuffs = 11
		else
	end

	if(unit == 'pet') then
		self:RegisterEvent("UNIT_HAPPINESS", updateName)
	end

	if(not unit) then
		self.Range = true
		self.inRangeAlpha = 1
		self.outsideRangeAlpha = .5
	end

	self:SetAttribute('initial-height', 15)
	self:SetAttribute('initial-width', 200)


	-- We inject our fake name element early in the cycle, in-case there is a
	-- spell cast in progress on the unit we target.
	self:RegisterEvent('UNIT_NAME_UPDATE', PostCastStop)
	table.insert(self.__elements, 2, PostCastStop)

	self.PostCastStop = PostCastStop
	self.PostChannelStop = PostCastStop
	self.PreAuraSetPosition = prePosition
	self.PostCreateAuraIcon = postCreate
	self.PostUpdateAuraIcon = postUpdate
	self.CustomAuraFilter = customFilter
	


	return self
end

oUF:RegisterStyle("Lily", func)

--[[
-- oUF does to this for, but only for the first layout registered. I'm mainly
-- adding it here so people know about it, especially since it's required for
-- layouts using different styles between party/partypet/raid/raidpet. It is
-- however smart to execute this function regardless.
--
-- There is a possibility that another layout has been registered before yours.
--]]
oUF:SetActiveStyle"Lily"

-- :Spawn(unit, frame_name, isPet) --isPet is only used on headers.
local focus = oUF:Spawn"focus"
focus:SetPoint("CENTER", 0, -500)
local pet = oUF:Spawn'pet'
pet:SetPoint('CENTER', 0, -450)
local player = oUF:Spawn"player"
player:SetPoint("CENTER", 0, -100)
local target = oUF:Spawn"target"
target:SetPoint("CENTER", 200, 99)
local tot = oUF:Spawn"targettarget"
tot:SetPoint("CENTER", 311, 99)
local party = oUF:Spawn("header", "oUF_Party")
party:SetPoint("TOPLEFT", 30, -30)
party:SetManyAttributes("showParty", true, "yOffset", -25)
party:Show()
and i get this error:
Code:
[2009/12/01 15:53:56-1270-x1]: oUF_tSmooth-o.1\main.lua:164: <unnamed>:SetText(): Font not set
oUF_tSmooth-o.1\main.lua:164: in function `PostUpdateAuraIcon'
oUF-1.3.21\elements\aura.lua:173: in function <Interface\AddOns\oUF\elements\aura.lua:129>
oUF-1.3.21\elements\aura.lua:264: in function `func'
oUF-1.3.21\ouf.lua:506: in function <Interface\AddOns\oUF\ouf.lua:501>
(tail call): ?:
any suggestions?
  Reply With Quote
 

WoWInterface » Featured Projects » oUF (Otravi Unit Frames) » Layout help


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