Advertisement
Kygo

Frames.lua new w/ aurabars

Aug 2nd, 2014
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 8.33 KB | None | 0 0
  1. --[[-----------------------------------------------------------
  2.     oUF_Kygo
  3.     PvE oriented oUF layout.
  4.     Modifications and edits are allowed to be uploaded to http://www.wowinterface.com
  5.    
  6. ---------------------------------------------------------------]]
  7.  
  8.  
  9. --Some Tags
  10. oUF.Tags.Events["shorthp"] = "UNIT_HEALTH"
  11. oUF.Tags.Methods["shorthp"] = function(unit)
  12.     if not UnitIsDeadOrGhost(unit) then
  13.         local hp = UnitHealth(unit)
  14.         return AbbreviateLargeNumbers(hp)
  15.     end
  16. end
  17.  
  18. oUF.Tags.Events["shortpp"] = "UNIT_POWER"
  19. oUF.Tags.Methods["shortpp"] = function(unit)
  20.     if not UnitIsDeadOrGhost(unit) then
  21.         local pp = UnitPower(unit)
  22.         return AbbreviateLargeNumbers(pp)
  23.     end
  24. end
  25.  
  26. -- Aura Bars
  27. local function bar_OnUpdate(frame, elapsed)
  28.     local t = frame.timeLeft - elapsed
  29.     frame:SetValue(t > 0 and t or 0)
  30.     frame.timeLeft = t
  31. end
  32.  
  33. local function auras_PostCreateIcon(frame, icon)
  34.     local frame = frame.__owner
  35.  
  36.     local bar = CreateFrame("StatusBar", nil, icon)
  37.     bar:SetPoint("LEFT", icon, "RIGHT")
  38.     bar:SetWidth(frame:GetWidth() - BUFF_HEIGHT)
  39.     bar:SetHeight(BUFF_HEIGHT)
  40.     bar:SetStatusBarTexture("Interface\\TargetingFrame\\UI-StatusBar")
  41.     bar:SetStatusBarColor(0, 0.6, 0)
  42.  
  43.     local bg = bar:CreateTexture(nil, "BACKGROUND")
  44.     bg:SetAllPoints(true)
  45.     bg:SetTexture("Interface\\TargetingFrame\\UI-StatusBar")
  46.     bg:SetVertexColor(0, 0.2, 0)
  47.     bar.bg = bg
  48.  
  49.     bar.timeLeft = 0
  50.     icon.bar = bar
  51. end
  52. --
  53.  
  54. local function Portrait_PostUpdate(portrait, unit)
  55.     portrait:SetCamera(0)
  56. end
  57.  
  58.  
  59. local function Style(frame, unit, isSingle)
  60.     frame:SetSize(150, 35)
  61.    
  62.     frame:RegisterForClicks("AnyUp")
  63.  
  64.     frame:SetScript("OnEnter", UnitFrame_OnEnter)
  65.     frame:SetScript("OnLeave", UnitFrame_OnLeave)
  66.  
  67.  
  68.    
  69.         ---------------------------------
  70.     --          Aurabars           --
  71.     ---------------------------------
  72.     if unit == "player" or unit == "target" then
  73.     local BUFF_HEIGHT = 20
  74.  
  75.     local Auras = CreateFrame("Frame", nil, frame)
  76.     Auras:SetPoint("BOTTOMLEFT", frame, "TOPLEFT", 0, 10)
  77.     Auras:SetWidth(BUFF_HEIGHT) -- no, Width/HEIGHT is not a mistake
  78.  
  79.     Auras["initialAnchor"] = "BOTTOMLEFT"
  80.     Auras["growth-y"] = "UP"
  81.     Auras["spacing-y"] = 1 -- 1px gap between bars, adjust as desired
  82.     Auras["num"] = 10 -- limit to showing 5 bars, adjust as desired
  83.     Auras["size"] = BUFF_HEIGHT
  84.  
  85.     Auras.PostCreateIcon = auras_PostCreateIcon
  86.  
  87.     if unit == "player" then
  88.         function Auras:CustomFilter(unit, icon, name, rank, texture, count, debuffType, duration, timeLeft, caster, isStealable, shouldConsolidate, spellID, canApplyAura, isBossDebuff)
  89.             if duration < 30 then
  90.                 icon.bar.timeLeft = timeLeft
  91.                 icon.bar:SetMinMaxValues(0, duration)
  92.                 icon.bar:SetValue(timeLeft)
  93.                 return true
  94.             end
  95.         end
  96.         frame.Buffs = Auras
  97.     elseif unit == "target" then
  98.         function Auras:CustomFilter(unit, icon, name, rank, texture, count, debuffType, duration, timeLeft, caster, isStealable, shouldConsolidate, spellID, canApplyAura, isBossDebuff)
  99.             if canApplyAura then
  100.                 icon.bar.timeLeft = timeLeft
  101.                 icon.bar:SetMinMaxValues(0, duration)
  102.                 icon.bar:SetValue(timeLeft)
  103.                 return true
  104.             end
  105.         end
  106.         frame.Debuffs = Auras
  107.     end
  108.     end
  109.  
  110.     -----------------------------------
  111.     --  Frame background and border  --
  112.     -----------------------------------
  113.     frame:SetBackdrop({
  114.             bgFile = "Interface\\AddOns\\oUF_Kygo\\Media\\backdrop", tile = false,
  115.             edgeFile = "Interface\\AddOns\\oUF_Kygo\\Media\\backdrop_edge", edgeSize = 5,
  116.             insets = { left = 1, right = 1 , top = 1, bottom = 1 }
  117.     })
  118.     frame:SetBackdropColor(0, 0, 0, .1)
  119.     frame:SetBackdropBorderColor(0, 0, 0, 1)
  120.        
  121.  
  122.        
  123.     -----------------------------------
  124.     --           Health bar          --
  125.     -----------------------------------
  126.     local health = CreateFrame("StatusBar", nil, frame)
  127.     health:SetPoint("TOPLEFT", frame, 5, -5)
  128.     health:SetPoint("TOPRIGHT", frame, -5, 5)
  129.     health:SetHeight(20)
  130.  
  131.    
  132.     -- Health bar background
  133.     local healthBG = health:CreateTexture(nil, "BACKGROUND")
  134.     healthBG:SetAllPoints()
  135.     healthBG:SetTexture("Interface\\AddOns\\oUF_Kygo\\Media\\alu") 
  136.     health.bg = healthBG   
  137.    
  138.    
  139.     -- Health bar colors
  140.     health:SetStatusBarTexture("Interface\\AddOns\\oUF_Kygo\\Media\\alu")
  141.     health:SetStatusBarColor(0.55, 0.55, 0.55) -- foreground color
  142.     health.bg:SetVertexColor(0.7, 0, 0) --background color
  143.    
  144.    
  145.     --Health bar text
  146.     local healthText = health:CreateFontString(nil, "OVERLAY", "GameFontNormal")
  147.     healthText:SetPoint("RIGHT", health, "RIGHT")
  148.     healthText:SetTextColor(1, 1, 1, 1)
  149.     healthText:SetFont("Interface\\AddOns\\oUF_Kygo\\Media\\neuropol.ttf", 10)
  150.     frame:Tag(healthText, "[dead][shorthp]")
  151.    
  152.    
  153.     -- % HP on target and target of target
  154.     if unit == "target" or unit == "targettarget" then
  155.     local healthPer = health:CreateFontString(nil, "OVERLAY", "GameFontNormal")
  156.     healthPer:SetPoint("LEFT", health, "LEFT", 2, 0)
  157.     healthPer:SetTextColor(1, 1, 1, 1)
  158.     healthPer:SetFont("Interface\\AddOns\\oUF_Kygo\\Media\\neuropol.ttf", 6)
  159.     frame:Tag(healthPer, "[perhp]")
  160.     end
  161.        
  162.        
  163.     frame.Health = health
  164.        
  165.        
  166.     -----------------------------------
  167.     --           Power bar           --
  168.     -----------------------------------
  169.     local power = CreateFrame("StatusBar", nil, frame)
  170.     power:SetPoint("TOPLEFT", health, "BOTTOMLEFT")
  171.     power:SetPoint("TOPRIGHT", health, "BOTTOMRIGHT")
  172.     power:SetPoint("BOTTOM", frame, 0, 5)
  173.    
  174.    
  175.     --Power background
  176.     local powerBG = power:CreateTexture(nil, "BACKGROUND")
  177.     powerBG:SetAllPoints()
  178.     powerBG:SetTexture("Interface\\AddOns\\oUF_Kygo\\Media\\Neal")
  179.     power:SetStatusBarTexture("Interface\\AddOns\\oUF_Kygo\\Media\\Neal")
  180.     powerBG.multiplier = 0.3
  181.     power.bg = powerBG
  182.    
  183.    
  184.     --Power Text
  185.     local powerText = power:CreateFontString(nil, "OVERLAY", "GameFontNormal")
  186.     powerText:SetFont("Interface\\AddOns\\oUF_Kygo\\Media\\neuropol.ttf", 6)
  187.     powerText:SetPoint("RIGHT", power, "RIGHT")
  188.     powerText:SetTextColor(1, 1, 1, 1)
  189.     frame:Tag(powerText, "[shortpp]")
  190.        
  191.        
  192.     power.colorPower = true
  193.     frame.Power = power
  194.    
  195.  
  196.     ---------------------------------
  197.     --            Name text        --
  198.     ---------------------------------
  199.     local name = frame:CreateFontString(nil, "OVERLAY", "GameFontNormal")
  200.     name:SetPoint("LEFT", frame, 5, -22)
  201.     name:SetFont("Interface\\AddOns\\oUF_Kygo\\Media\\neuropol.ttf", 10)
  202.     name:SetTextColor(1, 1, 1, 1)
  203.     frame:Tag(name, "[name]")
  204.    
  205.    
  206.     ---------------------------------
  207.     --Level and classification text--
  208.     ---------------------------------
  209.     local level = frame:CreateFontString(nil, "OVERLAY", "GameFontNormal")
  210.     level:SetPoint("RIGHT", frame, "RIGHT", -5, -22)
  211.     level:SetFont("Interface\\AddOns\\oUF_Kygo\\Media\\neuropol.ttf", 10)
  212.     level:SetTextColor(1, 1, 1, 1)
  213.     frame:Tag(level, "[smartlevel][shortclassification]")
  214.    
  215.    
  216.     --------------------------------
  217.     --          Portrait          --
  218.     --------------------------------
  219.     if unit == "player" or unit == "target" then
  220.         local portrait = CreateFrame("PlayerModel", nil, frame)
  221.         portrait:SetWidth(50)
  222.         portrait:SetAlpha(0.8)
  223.         if unit == "player" then
  224.             portrait:SetPoint("TOPRIGHT", frame, "TOPLEFT")
  225.             portrait:SetPoint("BOTTOMRIGHT", frame, "BOTTOMLEFT")
  226.         else
  227.             portrait:SetPoint("TOPLEFT", frame, "TOPRIGHT")
  228.             portrait:SetPoint("BOTTOMLEFT", frame, "BOTTOMRIGHT")
  229.         end
  230.    
  231.     frame.Portrait = portrait
  232.     end
  233.    
  234.    
  235.     ---------------------------------  
  236.     --        Combo Points         --
  237.     ---------------------------------
  238.     if unit == "target" then
  239.             local CPoints = {}
  240.  
  241.             for index = 1, MAX_COMBO_POINTS do
  242.                     local CPoint = health:CreateTexture(nil, "OVERLAY")
  243.                     -- Position and size of the combo point.
  244.                     CPoint:SetSize(10, 10)
  245.                     CPoint:SetPoint("LEFT", health, "LEFT", index * CPoint:GetWidth(), 0, 20)
  246.                     CPoint:SetTexture("Interface\\AddOns\\oUF_Kygo\\Media\\CPoint")
  247.                     CPoints[index] = CPoint
  248.             end
  249.  
  250.             frame.CPoints = CPoints
  251.                    
  252.     end
  253.    
  254. end
  255.  
  256.  
  257.  
  258.  
  259.  
  260.  
  261. oUF:RegisterStyle("Kygo", Style)
  262. oUF:SetActiveStyle("Kygo")
  263. --Spawning units!
  264. local player = oUF:Spawn("player")
  265. player:SetPoint("CENTER", UIParent, "CENTER", 0, 0)
  266.  
  267. local target = oUF:Spawn("target")
  268. target:SetPoint("LEFT", player, "RIGHT", 20, 0)
  269.  
  270. local pet = oUF:Spawn("pet")
  271. pet:SetPoint("BOTTOMLEFT", player, "TOPLEFT", 0, 20)
  272.  
  273. local tot = oUF:Spawn("targettarget")
  274. tot:SetPoint("BOTTOMLEFT", target, "TOPLEFT", 0, 20)
  275.  
  276. local focus = oUF:Spawn("focus")
  277. focus:SetPoint("CENTER", player, "CENTER", 0, 40)
  278.  
  279. local boss1 = oUF:Spawn("boss")
  280. boss1:SetPoint("CENTER", player, "CENTER", 0, 70)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement