Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[-----------------------------------------------------------
- oUF_Kygo
- PvE oriented oUF layout.
- Modifications and edits are allowed to be uploaded to http://www.wowinterface.com
- ---------------------------------------------------------------]]
- -- Define functions like this *outside* of your Style function
- -- so you can just reuse one copy instead of making duplicates:
- local functition Portrait_PostUpdate(portrait, unit)
- portrait:SetCamera(0)
- end
- local function Style(frame, unit, isSingle)
- frame:SetSize(150, 35)
- -- ^ Add 5px on each side for the border so you can
- -- avoid wasting memory on creating another frame.
- frame:RegisterForClicks("AnyUp")
- frame:SetScript("OnEnter", UnitFrame_OnEnter)
- frame:SetScript("OnLeave", UnitFrame_OnLeave)
- ------------------------------
- -- Frame background and border
- ------------------------------
- frame:SetBackdrop({
- bgFile = "Interface\\AddOns\\oUF_Kygo\\Media\\Neal", tile = false,
- edgeFile = "Interface\\AddOns\\oUF_Kygo\\Media\\backdrop_edge", edgeSize = 5,
- insets = { left = 1, right = 1 , top = 1, bottom = 1 }
- })
- frame:SetBackdropColor(1, 1, 1)
- frame:SetBackdropBorderColor(0, 0, 0)
- -- ^ Just set the backdrop right on the frame.
- -------------
- -- Health bar
- -------------
- local health = CreateFrame("StatusBar", nil, frame)
- health:SetPoint("TOPLEFT", frame, 5, -5)
- health:SetPoint("TOPRIGHT", frame, -5, -5)
- health:SetHeight(20)
- -- ^ Move the bar 5px in from each edge to account for the border,
- -- and use multiple anchors so the bar will automatically expand
- -- if you change the width of the frame. Only set the height
- -- explicitly since that doesn't match the total frame height.
- -- Health bar background
- local healthBG = health:CreateTexture(nil, "BACKGROUND")
- healthBG:SetAllPoints()
- healthBG:SetTexture("Interface\\AddOns\\oUF_Kygo\\Media\\Neal")
- health.bg = healthBG
- -- Health bar colors
- health:SetStatusBarTexture("Interface\\AddOns\\oUF_Kygo\\Media\\Neal")
- health:SetStatusBarColor(0.35, 0.35, 0.35) -- foreground color
- health.bg:SetVertexColor(0.25, 0, 0) --background color
- -- Health bar text
- local healthText = health:CreateFontString(nil, "OVERLAY", "GameFontNormal")
- healthText:SetPoint("RIGHT", health, "RIGHT")
- healthText:SetTextColor(1, 1, 1, 1)
- healthText:SetFont("Interface\\AddOns\\oUF_Kygo\\Media\\neuropol.ttf", 10)
- frame:Tag(healthText, "[dead][curhp]")
- -- % HP on target and target of target
- if unit == "target" or unit == "targettarget" then
- local healthPer = health:CreateFontString(nil, "OVERLAY", "GameFontNormal")
- healthPer:SetPoint("LEFT", health, 7, 0)
- healthPer:SetFont("Interface\\AddOns\\oUF_Kygo\\Media\\neuropol.ttf", 6)
- healthPer:SetTextColor(1, 1, 1, 1)
- frame:Tag(healthPer, "[perhp]")
- end
- -- Register with oUF
- frame.Health = health
- ------------
- -- Power bar
- ------------
- local power = CreateFrame("StatusBar", nil, frame)
- power:SetPoint("TOPLEFT", health, "BOTTOMLEFT")
- power:SetPoint("TOPRIGHT", health, "BOTTOMRIGHT")
- power:SetPoint("BOTTOM", frame, 0, 5)
- -- ^ Again, use multiple anchors instead of explicit dimensions,
- -- and relative points instead of hardcoded offsets. This way
- -- you can adjust the size of one element without having to
- -- manually change the sizes and offsets of every single thing.
- -- Power bar background
- local powerBG = power:CreateTexture(nil, "BACKGROUND")
- powerBG:SetAllPoints()
- powerBG:SetTexture("Interface\\AddOns\\oUF_Kygo\\Media\\Neal")
- power:SetStatusBarTexture("Interface\\AddOns\\oUF_Kygo\\Media\\Neal")
- powerBG.multiplier = 0.3
- power.bg = powerBG
- --Power bar text
- local powerText = power:CreateFontString(nil, "OVERLAY", "GameFontNormal")
- powerText:SetFont("Interface\\AddOns\\oUF_Kygo\\Media\\ExpresswayRg.ttf", 6, "OUTLINE")
- powerText:SetPoint("RIGHT", power, "RIGHT")
- powerText:SetTextColor(1, 1, 1, 1)
- frame:Tag(powerText, "[curpp]")
- -- Register with oUF
- power.colorPower = true
- frame.Power = power
- ------------
- -- Name text
- ------------
- local name = frame:CreateFontString(nil, "OVERLAY", "GameFontNormal")
- name:SetPoint("LEFT", frame, 5, -27)
- name:SetFont("Interface\\AddOns\\oUF_Kygo\\Media\\neuropol.ttf", 10)
- name:SetTextColor(1, 1, 1, 1)
- frame:Tag(name, "[name]")
- --------------------------------
- -- Level and classification text
- --------------------------------
- local level = frame:CreateFontString(nil, "OVERLAY", "GameFontNormal")
- level:SetPoint("RIGHT", frame, -5, -27)
- level:SetFont("Interface\\AddOns\\oUF_Kygo\\Media\\ExpresswayRg.ttf", 10)
- level:SetTextColor(1, 1, 1, 1)
- frame:Tag(level, "[smartlevel][shortclassification]")
- -----------
- -- Portrait
- -----------
- if unit == "player" or unit == "target" then
- -- ^ You can check multiple conditions at a time. Since you
- -- do the same thing whether the unit is "player" or "target"
- -- there's no need to duplicate this code block.
- local portrait = CreateFrame("PlayerModel", nil, frame)
- portrait:SetPoint("TOPLEFT", frame, "TOP", -130, -0)
- portrait:SetPoint("BOTTOMLEFT", frame, "BOTTOM", -130, -0)
- portrait:SetWidth(50)
- portrait:SetAlpha(0.8)
- portrait.PostUpdate = Portrait_PostUpdate
- frame.Portrait = portrait
- end
- ---------------
- -- Combo points
- ---------------
- if unit == "target" then
- local CPoints = {}
- for index = 1, MAX_COMBO_POINTS do
- local CPoint = health:CreateTexture(nil, "BACKGROUND")
- -- ^ The CreateTexture method does not require the parent
- -- as a third argument, since the parent is obvious based
- -- on which object you called the method on.
- -- Position and size of the combo point.
- CPoint:SetSize(12, 16)
- CPoint:SetPoint("LEFT", health, "LEFT", index * CPoint:GetWidth(), 10)
- CPoints[index] = CPoint
- end
- frame.CPoints = CPoints
- -- ^ Pay attention to your objects. The CPoints key needs to be
- -- on the frame, not on the health bar or anything else, or
- -- oUF won't recognize it as an element.
- end
- ------------
- -- All done!
- ------------
- end
- oUF:RegisterStyle("Kygo", Style)
- oUF:SetActiveStyle("Kygo")
- --Spawning units!
- local player = oUF:Spawn("player")
- player:SetPoint("CENTER", UIParent, "CENTER", 0, 0)
- local target = oUF:Spawn("target")
- target:SetPoint("LEFT", player, "RIGHT", 20, 0)
- local pet = oUF:Spawn("pet")
- pet:SetPoint("BOTTOMLEFT", player, "TOPLEFT", 0, 20)
- local tot = oUF:Spawn("targettarget")
- tot:SetPoint("BOTTOMLEFT", target, "TOPLEFT", 0, 20)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement