Advertisement
Kygo

Frames.lua 11/8-14

Aug 11th, 2014
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 13.04 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. oUF.Tags.Events["shortname"] = "UNIT_NAME"
  27. oUF.Tags.Methods["shortname"] = function(unit)
  28.     local name = UnitName(unit)
  29.     return string.sub(UnitName(unit), 1, 20)
  30. end
  31.  
  32. oUF.Tags.Events["readycheckicon"] = "DoReadyCheck"
  33. oUF.Tags.SharedEvents["IsInGroup"] = true
  34. oUF.Tags.Methods["readycheckicon"] = function(unit)
  35.     if unit == "player" and IsInGroup() then
  36.         return [[|TInterface\RAIDFRAME\ReadyCheck-Ready|t]]
  37.     end
  38. end
  39.  
  40. oUF.Tags.Events["rsicon"] = "PLAYER_UPDATE_RESTING"
  41. oUF.Tags.SharedEvents["PLAYER_UPDATE_RESTING"] = true
  42. oUF.Tags.Methods["rsicon"] = function(unit)
  43.     if unit == "player" and IsResting() then
  44.         return [[|TInterface\CharacterFrame\UI-StateIcon:0:0:0:-6:64:64:28:6:6:28|t]]
  45.     end
  46. end
  47. oUF.Tags.Events["combaticon"] = "PLAYER_REGEN_DISABLED PLAYER_REGEN_ENABLED"
  48. oUF.Tags.SharedEvents["PLAYER_REGEN_DISABLED"] = true
  49. oUF.Tags.SharedEvents["PLAYER_REGEN_ENABLED"] = true
  50. oUF.Tags.Methods["combaticon"] = function(unit)
  51.     if unit == "player" and UnitAffectingCombat("player") then
  52.         return [[|TInterface\CharacterFrame\UI-StateIcon:0:0:0:0:64:64:37:58:5:26|t]]
  53.     end
  54. end
  55.  
  56. oUF.Tags.Events["licon"] = "GROUP_ROSTER_UPDATE"
  57. oUF.Tags.SharedEvents["GROUP_ROSTER_UPDATE"] = true
  58. oUF.Tags.Methods["licon"] = function(unit)
  59.     if UnitIsGroupLeader(unit) then
  60.         return [[|TInterface\GroupFrame\UI-Group-LeaderIcon:0|t]]
  61.     elseif UnitInRaid(unit) and UnitIsGroupAssistant(unit) then
  62.         return [[|TInterface\GroupFrame\UI-Group-AssistantIcon:0|t]]
  63.     end
  64. end
  65.  
  66. oUF.Tags.Events["mastericon"] = "PARTY_LOOT_METHOD_CHANGED GROUP_ROSTER_UPDATE"
  67. oUF.Tags.SharedEvents["PARTY_LOOT_METHOD_CHANGED"] = true
  68. oUF.Tags.SharedEvents["GROUP_ROSTER_UPDATE"] = true
  69. oUF.Tags.Methods["mastericon"] = function(unit)
  70.     local method, pid, rid = GetLootMethod()
  71.     if method ~= "master" then return end
  72.     local munit
  73.     if pid then
  74.         if pid == 0 then
  75.             munit = "player"
  76.         else
  77.             munit = "party" .. pid
  78.         end
  79.     elseif rid then
  80.         munit = "raid" .. rid
  81.     end
  82.     if munit and UnitIsUnit(munit, unit) then
  83.         return [[|TInterface\GroupFrame\UI-Group-MasterLooter:0:0:0:2|t]]
  84.     end
  85. end
  86.  
  87. -- Aura Bars
  88. local BUFF_HEIGHT = 20
  89. local function bar_OnUpdate(frame, elapsed)
  90.     local t = frame.timeLeft - elapsed
  91.     frame:SetValue(t > 0 and t or 0)
  92.     frame.timeLeft = t
  93. end
  94.  
  95. local function auras_PostCreateIcon(element, icon)
  96.     local frame = element.__owner
  97.    
  98.     local bar = CreateFrame("StatusBar", nil, icon)
  99.     bar:SetPoint("LEFT", icon, "RIGHT")
  100.     bar:SetWidth(frame:GetWidth() - BUFF_HEIGHT)
  101.     bar:SetHeight(BUFF_HEIGHT)
  102.     bar:SetStatusBarTexture("Interface\\AddOns\\oUF_Kygo\\Media\\Neal")
  103.     bar:SetStatusBarColor(0, 0.6, 0)
  104.  
  105.     local bg = bar:CreateTexture(nil, "BACKGROUND")
  106.     bg:SetAllPoints(true)
  107.     bg:SetTexture("Interface\\AddOns\\oUF_Kygo\\Media\\Neal")
  108.     bg:SetVertexColor(0, 0.2, 0)
  109.     bar.bg = bg
  110.  
  111.     bar.timeLeft = 0
  112.     bar:SetMinMaxValues(0, 1)
  113.     bar:SetScript("OnUpdate", bar_OnUpdate)
  114.     icon.bar = bar
  115. end
  116. --
  117.  
  118. local function Portrait_PostUpdate(portrait, unit)
  119.     portrait:SetCamera(0)
  120. end
  121.  
  122.  
  123. local function Style(frame, unit, isSingle)
  124.     frame:SetSize(150, 35)
  125.    
  126.     frame:RegisterForClicks("AnyUp")
  127.  
  128.     frame:SetScript("OnEnter", UnitFrame_OnEnter)
  129.     frame:SetScript("OnLeave", UnitFrame_OnLeave)
  130.  
  131.  
  132.     -----------------------------------
  133.     --  Frame background and border  --
  134.     -----------------------------------
  135.     frame:SetBackdrop({
  136.             bgFile = "Interface\\AddOns\\oUF_Kygo\\Media\\backdrop", tile = false,
  137.             edgeFile = "Interface\\AddOns\\oUF_Kygo\\Media\\backdrop_edge", edgeSize = 5,
  138.             insets = { left = 1, right = 1 , top = 1, bottom = 1 }
  139.     })
  140.     frame:SetBackdropColor(0, 0, 0, .1)
  141.     frame:SetBackdropBorderColor(0, 0, 0, 1)
  142.        
  143.  
  144.        
  145.     -----------------------------------
  146.     --           Health bar          --
  147.     -----------------------------------
  148.     local health = CreateFrame("StatusBar", nil, frame)
  149.     health:SetPoint("TOPLEFT", frame, 5, -5)
  150.     health:SetPoint("TOPRIGHT", frame, -5, 5)
  151.     health:SetHeight(20)
  152.  
  153.    
  154.     -- Health bar background
  155.     local healthBG = health:CreateTexture(nil, "BACKGROUND")
  156.     healthBG:SetAllPoints()
  157.     healthBG:SetTexture("Interface\\AddOns\\oUF_Kygo\\Media\\Neal")
  158.     health.bg = healthBG   
  159.    
  160.    
  161.     -- Health bar colors
  162.     health:SetStatusBarTexture("Interface\\AddOns\\oUF_Kygo\\Media\\Neal")
  163.     health:SetStatusBarColor(0.2, 0.2, 0.2) -- foreground color
  164.     health.bg:SetVertexColor(0.2, 0, 0) --background color
  165.    
  166.    
  167.     --Health bar text
  168.     local healthText = health:CreateFontString(nil, "OVERLAY", "GameFontNormal")
  169.     healthText:SetPoint("RIGHT", health, "RIGHT")
  170.     healthText:SetTextColor(1, 1, 1, 1)
  171.     healthText:SetFont("Interface\\AddOns\\oUF_Kygo\\Media\\neuropol.ttf", 10)
  172.     frame:Tag(healthText, "[dead][shorthp]")
  173.    
  174.    
  175.     -- % HP on target and target of target
  176.     if unit == "target" or unit == "targettarget" then
  177.     local healthPer = health:CreateFontString(nil, "OVERLAY", "GameFontNormal")
  178.     healthPer:SetPoint("LEFT", health, "LEFT", 2, 0)
  179.     healthPer:SetTextColor(1, 1, 1, 1)
  180.     healthPer:SetFont("Interface\\AddOns\\oUF_Kygo\\Media\\neuropol.ttf", 6)
  181.     frame:Tag(healthPer, "[perhp]")
  182.     end
  183.        
  184.        
  185.     frame.Health = health
  186.        
  187.        
  188.     -----------------------------------
  189.     --           Power bar           --
  190.     -----------------------------------
  191.     local power = CreateFrame("StatusBar", nil, frame)
  192.     power:SetPoint("TOPLEFT", health, "BOTTOMLEFT")
  193.     power:SetPoint("TOPRIGHT", health, "BOTTOMRIGHT")
  194.     power:SetPoint("BOTTOM", frame, 0, 5)
  195.    
  196.    
  197.     --Power background
  198.     local powerBG = power:CreateTexture(nil, "BACKGROUND")
  199.     powerBG:SetAllPoints()
  200.     powerBG:SetTexture("Interface\\AddOns\\oUF_Kygo\\Media\\Neal")
  201.     power:SetStatusBarTexture("Interface\\AddOns\\oUF_Kygo\\Media\\Neal")
  202.     powerBG.multiplier = 0.3
  203.     power.bg = powerBG
  204.    
  205.    
  206.     --Power Text
  207.     local powerText = power:CreateFontString(nil, "OVERLAY", "GameFontNormal")
  208.     powerText:SetFont("Interface\\AddOns\\oUF_Kygo\\Media\\neuropol.ttf", 6)
  209.     powerText:SetPoint("RIGHT", power, "RIGHT")
  210.     powerText:SetTextColor(1, 1, 1, 1)
  211.     frame:Tag(powerText, "[shortpp]")
  212.        
  213.        
  214.     power.colorPower = true
  215.     frame.Power = power
  216.    
  217.  
  218.     ---------------------------------
  219.     --            Name text        --
  220.     ---------------------------------
  221.     if unit == "target" or unit == "targettarget" or unit == "focus" or unit == "boss1" then
  222.     local name = frame:CreateFontString(nil, "OVERLAY", "GameFontNormal")
  223.     name:SetPoint("LEFT", frame, 5, -22)
  224.     name:SetFont("Interface\\AddOns\\oUF_Kygo\\Media\\neuropol.ttf", 10)
  225.     name:SetTextColor(1, 1, 1, 1)
  226.     frame:Tag(name, "[raidcolor][shortname]")
  227.     end
  228.    
  229.     ---------------------------------
  230.     --Level and classification text--
  231.     ---------------------------------
  232.     local level = frame:CreateFontString(nil, "OVERLAY", "GameFontNormal")
  233.     level:SetPoint("RIGHT", frame, "RIGHT", -5, -22)
  234.     level:SetFont("Interface\\AddOns\\oUF_Kygo\\Media\\neuropol.ttf", 10)
  235.     level:SetTextColor(1, 1, 1, 1)
  236.     frame:Tag(level, "[smartlevel][shortclassification]")
  237.    
  238.     --------------------------------
  239.     --             Misc           --
  240.     --------------------------------
  241.     local resting = health:CreateFontString(nil, "OVERLAY", "GameFontNormal")
  242.     resting:SetPoint("TOPLEFT", frame)
  243.     resting:SetFont("Interface\\AddOns\\oUF_Kygo\\Media\\neuropol.ttf", 10)
  244.     frame:Tag(resting, "[rsicon]")
  245.    
  246.     local master = health:CreateFontString(nil, "OVERLAY", "GameFontNormal")
  247.     master:SetPoint("TOPLEFT", frame, "TOPRIGHT", -15, 0)
  248.     master:SetFont("Interface\\AddOns\\oUF_Kygo\\Media\\neuropol.ttf", 10)
  249.     frame:Tag(master, "[mastericon]")
  250.    
  251.     local combaticon = health:CreateFontString(nil, "OVERLAY", "GameFontNormal")
  252.     combaticon:SetPoint("TOPLEFT", frame)
  253.     combaticon:SetFont("Interface\\AddOns\\oUF_Kygo\\Media\\neuropol.ttf", 10)
  254.     frame:Tag(combaticon, "[combaticon]")
  255.    
  256.     local readycheckicon = health:CreateFontString(nil, "OVERLAY", "GameFontNormal")
  257.     readycheckicon:SetPoint("CENTER", frame)
  258.     readycheckicon:SetFont("Interface\\AddOns\\oUF_Kygo\\Media\\neuropol.ttf", 10)
  259.     frame.Tag(readycheckicon, "[readycheckicon]")
  260.    
  261.     local licon = health:CreateFontString(nil, "OVERLAY", "GameFontNormal")
  262.     licon:SetPoint("TOPLEFT", frame)
  263.     licon:SetFont("Interface\\AddOns\\oUF_Kygo\\Media\\neuropol.ttf", 10)
  264.     frame.Tag(licon, "[licon]")
  265.    
  266.     --------------------------------
  267.     --          Portrait          --
  268.     --------------------------------
  269.     if unit == "player" or unit == "target" then
  270.         local portrait = CreateFrame("PlayerModel", nil, frame)
  271.         portrait:SetWidth(30)
  272.         portrait:SetAlpha(0.8)
  273.         if unit == "player" then
  274.             portrait:SetPoint("TOPRIGHT", frame, "TOPLEFT")
  275.             portrait:SetPoint("BOTTOMRIGHT", frame, "BOTTOMLEFT")
  276.         else
  277.             portrait:SetPoint("TOPLEFT", frame, "TOPRIGHT")
  278.             portrait:SetPoint("BOTTOMLEFT", frame, "BOTTOMRIGHT")
  279.         end
  280.    
  281.     frame.Portrait = portrait
  282.     end
  283.    
  284.     if unit == "player" or unit == "target" then
  285.         local portraitBG = frame:CreateTexture(nil, "BACKGROUND")
  286.         portraitBG:SetWidth(32)
  287.         portraitBG:SetTexture("Interface\\AddOns\\oUF_Kygo\\Media\\BlackSquare")
  288.         portraitBG:SetAlpha(0.9)
  289.         if unit == "player" then
  290.             portraitBG:SetPoint("TOPRIGHT", frame, "TOPLEFT")
  291.             portraitBG:SetPoint("BOTTOMRIGHT", frame, "BOTTOMLEFT")
  292.         else
  293.             portraitBG:SetPoint("TOPLEFT", frame, "TOPRIGHT")
  294.             portraitBG:SetPoint("BOTTOMLEFT", frame, "BOTTOMRIGHT")
  295.     end
  296.     frame.portraitBG = portraitBG
  297.     end
  298.    
  299.     ---------------------------------  
  300.     --        Combo Points         --
  301.     ---------------------------------
  302.     if unit == "target" then
  303.             local CPoints = {}
  304.  
  305.             for index = 1, MAX_COMBO_POINTS do
  306.                     local CPoint = health:CreateTexture(nil, "OVERLAY")
  307.                     -- Position and size of the combo point.
  308.                     CPoint:SetSize(10, 10)
  309.                     CPoint:SetPoint("LEFT", health, "LEFT", index * CPoint:GetWidth(), 0, 20)
  310.                     CPoint:SetTexture("Interface\\AddOns\\oUF_Kygo\\Media\\CPoint")
  311.                     CPoints[index] = CPoint
  312.             end
  313.  
  314.             frame.CPoints = CPoints
  315.                    
  316.     end
  317.    
  318.     ---------------------------------
  319.     --          Aurabars           --
  320.     ---------------------------------
  321.     if unit == "player" or unit == "target" then
  322.    
  323.     local Auras = CreateFrame("Frame", nil, element)
  324.     Auras:SetPoint("BOTTOMLEFT", frame, "TOPLEFT", 0, 10)
  325.     Auras:SetWidth(BUFF_HEIGHT) -- no, Width/HEIGHT is not a mistake
  326.  
  327.     Auras["initialAnchor"] = "BOTTOMLEFT"
  328.     Auras["growth-y"] = "UP"
  329.     Auras["spacing-y"] = 1 -- 1px gap between bars, adjust as desired
  330.     Auras["num"] = 10 -- limit to showing 5 bars, adjust as desired
  331.     Auras["size"] = BUFF_HEIGHT
  332.  
  333.     Auras.PostCreateIcon = auras_PostCreateIcon
  334.    
  335.     if unit == "player" then
  336.         function Auras:CustomFilter(unit, icon, name, rank, texture, count, debuffType, duration, timeLeft, caster, isStealable, shouldConsolidate, spellID, canApplyAura, isBossDebuff)
  337.             if duration < 30 then
  338.                 icon.bar.timeLeft = timeLeft
  339.                 icon.bar:SetMinMaxValues(0, duration)
  340.                 icon.bar:SetValue(timeLeft)
  341.                 return true
  342.             end
  343.         end
  344.         frame.Buffs = Auras
  345.     elseif unit == "target" then
  346.         function Auras:CustomFilter(unit, icon, name, rank, texture, count, debuffType, duration, timeLeft, caster, isStealable, shouldConsolidate, spellID, canApplyAura, isBossDebuff)
  347.             if canApplyAura then
  348.                 icon.bar.timeLeft = timeLeft
  349.                 icon.bar:SetMinMaxValues(0, duration)
  350.                 icon.bar:SetValue(timeLeft)
  351.                 return true
  352.             end
  353.         end
  354.         frame.Debuffs = Auras
  355.     end
  356.     end
  357.    
  358.     --------------------------------
  359.     --       Misc PvE Stuff       --
  360.     --------------------------------
  361.     --[[
  362.     local RaidRole = frame:CreateTexture(nil, "OVERLAY")
  363.     RaidRole:SetSize(16, 16)
  364.     RaidRole:SetPoint("TOPLEFT")
  365.     frame.RaidRole = RaidRole
  366.    
  367.     local ReadyCheck = frame:CreateTexture(nil, "OVERLAY")
  368.     ReadyCheck:SetTexture("Interface\\AddOns\\oUF_Kygo\\Media\\CPoint")
  369.     ReadyCheck:SetSize(16, 16)
  370.     ReadyCheck:SetPoint("CENTER")
  371.     ReadyCheck.finishedTime = 10
  372.     ReadyCheck.fadeTime = 2
  373.     frame.ReadyCheck = ReadyCheck
  374.     --]]
  375.    
  376. end
  377.  
  378.  
  379.  
  380.  
  381.  
  382.  
  383. oUF:RegisterStyle("Kygo", Style)
  384. oUF:SetActiveStyle("Kygo")
  385. --Spawning units!
  386. local player = oUF:Spawn("player")
  387. player:SetPoint("CENTER", UIParent, "CENTER", 0, 0)
  388.  
  389. local target = oUF:Spawn("target")
  390. target:SetPoint("LEFT", player, "RIGHT", 20, 0)
  391.  
  392. local pet = oUF:Spawn("pet")
  393. pet:SetPoint("BOTTOMLEFT", player, "TOPLEFT", 0, 20)
  394.  
  395. local tot = oUF:Spawn("targettarget")
  396. tot:SetPoint("BOTTOMLEFT", target, "TOPLEFT", 0, 20)
  397.  
  398. local focus = oUF:Spawn("focus")
  399. focus:SetPoint("CENTER", player, "CENTER", 0, 40)
  400.  
  401. local boss1 = oUF:Spawn("boss1")
  402. boss1:SetPoint("CENTER", player, "CENTER", 0, 70)
  403.  
  404. local party1 = oUF:Spawn("party1")
  405. party1:SetPoint("CENTER", player, "CENTER", 0, 110)
  406.  
  407. local party2 = oUF:Spawn("party2")
  408. party2:SetPoint("CENTER", player, "CENTER", 0, 150)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement