Advertisement
Guest User

Untitled

a guest
Jul 14th, 2014
366
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 6.44 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. -- Define functions like this *outside* of your Style function
  8. -- so you can just reuse one copy instead of making duplicates:
  9. local functition Portrait_PostUpdate(portrait, unit)
  10.     portrait:SetCamera(0)
  11. end
  12.  
  13. local function Style(frame, unit, isSingle)
  14.     frame:SetSize(150, 35)
  15.     -- ^ Add 5px on each side for the border so you can
  16.     --   avoid wasting memory on creating another frame.
  17.  
  18.     frame:RegisterForClicks("AnyUp")
  19.  
  20.     frame:SetScript("OnEnter", UnitFrame_OnEnter)
  21.     frame:SetScript("OnLeave", UnitFrame_OnLeave)
  22.  
  23.     ------------------------------
  24.     -- Frame background and border
  25.     ------------------------------
  26.     frame:SetBackdrop({
  27.         bgFile = "Interface\\AddOns\\oUF_Kygo\\Media\\Neal", tile = false,
  28.         edgeFile = "Interface\\AddOns\\oUF_Kygo\\Media\\backdrop_edge", edgeSize = 5,
  29.         insets = { left = 1, right = 1 , top = 1, bottom = 1 }
  30.     })
  31.     frame:SetBackdropColor(1, 1, 1)
  32.     frame:SetBackdropBorderColor(0, 0, 0)
  33.     -- ^ Just set the backdrop right on the frame.
  34.  
  35.     -------------
  36.     -- Health bar
  37.     -------------
  38.     local health = CreateFrame("StatusBar", nil, frame)
  39.     health:SetPoint("TOPLEFT", frame, 5, -5)
  40.     health:SetPoint("TOPRIGHT", frame, -5, -5)
  41.     health:SetHeight(20)
  42.     -- ^ Move the bar 5px in from each edge to account for the border,
  43.     --   and use multiple anchors so the bar will automatically expand
  44.     --   if you change the width of the frame. Only set the height
  45.     --   explicitly since that doesn't match the total frame height.
  46.  
  47.     -- Health bar background
  48.     local healthBG = health:CreateTexture(nil, "BACKGROUND")
  49.     healthBG:SetAllPoints()
  50.     healthBG:SetTexture("Interface\\AddOns\\oUF_Kygo\\Media\\Neal")
  51.     health.bg = healthBG
  52.  
  53.     -- Health bar colors
  54.     health:SetStatusBarTexture("Interface\\AddOns\\oUF_Kygo\\Media\\Neal")
  55.     health:SetStatusBarColor(0.35, 0.35, 0.35) -- foreground color
  56.     health.bg:SetVertexColor(0.25, 0, 0) --background color
  57.  
  58.     -- Health bar text
  59.     local healthText = health:CreateFontString(nil, "OVERLAY", "GameFontNormal")
  60.     healthText:SetPoint("RIGHT", health, "RIGHT")
  61.     healthText:SetTextColor(1, 1, 1, 1)
  62.     healthText:SetFont("Interface\\AddOns\\oUF_Kygo\\Media\\neuropol.ttf", 10)
  63.     frame:Tag(healthText, "[dead][curhp]")
  64.  
  65.     -- % HP on target and target of target
  66.     if unit == "target" or unit == "targettarget" then
  67.         local healthPer = health:CreateFontString(nil, "OVERLAY", "GameFontNormal")
  68.         healthPer:SetPoint("LEFT", health, 7, 0)
  69.         healthPer:SetFont("Interface\\AddOns\\oUF_Kygo\\Media\\neuropol.ttf", 6)
  70.         healthPer:SetTextColor(1, 1, 1, 1)
  71.         frame:Tag(healthPer, "[perhp]")
  72.     end
  73.  
  74.     -- Register with oUF
  75.     frame.Health = health
  76.  
  77.     ------------
  78.     -- Power bar
  79.     ------------
  80.     local power = CreateFrame("StatusBar", nil, frame)
  81.     power:SetPoint("TOPLEFT", health, "BOTTOMLEFT")
  82.     power:SetPoint("TOPRIGHT", health, "BOTTOMRIGHT")
  83.     power:SetPoint("BOTTOM", frame, 0, 5)
  84.     -- ^ Again, use multiple anchors instead of explicit dimensions,
  85.     --   and relative points instead of hardcoded offsets. This way
  86.     --   you can adjust the size of one element without having to
  87.     --   manually change the sizes and offsets of every single thing.
  88.  
  89.     -- Power bar background
  90.     local powerBG = power:CreateTexture(nil, "BACKGROUND")
  91.     powerBG:SetAllPoints()
  92.     powerBG:SetTexture("Interface\\AddOns\\oUF_Kygo\\Media\\Neal")
  93.     power:SetStatusBarTexture("Interface\\AddOns\\oUF_Kygo\\Media\\Neal")
  94.     powerBG.multiplier = 0.3
  95.     power.bg = powerBG
  96.  
  97.     --Power bar text
  98.     local powerText = power:CreateFontString(nil, "OVERLAY", "GameFontNormal")
  99.     powerText:SetFont("Interface\\AddOns\\oUF_Kygo\\Media\\ExpresswayRg.ttf", 6, "OUTLINE")
  100.     powerText:SetPoint("RIGHT", power, "RIGHT")
  101.     powerText:SetTextColor(1, 1, 1, 1)
  102.     frame:Tag(powerText, "[curpp]")
  103.  
  104.     -- Register with oUF
  105.     power.colorPower = true
  106.     frame.Power = power
  107.  
  108.     ------------
  109.     -- Name text
  110.     ------------
  111.     local name = frame:CreateFontString(nil, "OVERLAY", "GameFontNormal")
  112.     name:SetPoint("LEFT", frame, 5, -27)
  113.     name:SetFont("Interface\\AddOns\\oUF_Kygo\\Media\\neuropol.ttf", 10)
  114.     name:SetTextColor(1, 1, 1, 1)
  115.     frame:Tag(name, "[name]")
  116.  
  117.     --------------------------------
  118.     -- Level and classification text
  119.     --------------------------------
  120.     local level = frame:CreateFontString(nil, "OVERLAY", "GameFontNormal")
  121.     level:SetPoint("RIGHT", frame, -5, -27)
  122.     level:SetFont("Interface\\AddOns\\oUF_Kygo\\Media\\ExpresswayRg.ttf", 10)
  123.     level:SetTextColor(1, 1, 1, 1)
  124.     frame:Tag(level, "[smartlevel][shortclassification]")
  125.  
  126.     -----------
  127.     -- Portrait
  128.     -----------
  129.     if unit == "player" or unit == "target" then
  130.         -- ^ You can check multiple conditions at a time. Since you
  131.         --   do the same thing whether the unit is "player" or "target"
  132.         --   there's no need to duplicate this code block.
  133.  
  134.         local portrait = CreateFrame("PlayerModel", nil, frame)
  135.         portrait:SetPoint("TOPLEFT", frame, "TOP", -130, -0)
  136.         portrait:SetPoint("BOTTOMLEFT", frame, "BOTTOM", -130, -0)
  137.         portrait:SetWidth(50)
  138.         portrait:SetAlpha(0.8)
  139.  
  140.         portrait.PostUpdate = Portrait_PostUpdate
  141.         frame.Portrait = portrait
  142.     end
  143.  
  144.     ---------------
  145.     -- Combo points
  146.     ---------------
  147.     if unit == "target" then
  148.         local CPoints = {}
  149.  
  150.         for index = 1, MAX_COMBO_POINTS do
  151.             local CPoint = health:CreateTexture(nil, "BACKGROUND")
  152.             -- ^ The CreateTexture method does not require the parent
  153.             --   as a third argument, since the parent is obvious based
  154.             --   on which object you called the method on.
  155.  
  156.             -- Position and size of the combo point.
  157.             CPoint:SetSize(12, 16)
  158.             CPoint:SetPoint("LEFT", health, "LEFT", index * CPoint:GetWidth(), 10)
  159.  
  160.             CPoints[index] = CPoint
  161.         end
  162.  
  163.         frame.CPoints = CPoints
  164.         -- ^ Pay attention to your objects. The CPoints key needs to be
  165.         --   on the frame, not on the health bar or anything else, or
  166.         --   oUF won't recognize it as an element.
  167.     end
  168.  
  169.     ------------
  170.     -- All done!
  171.     ------------
  172. end
  173.  
  174. oUF:RegisterStyle("Kygo", Style)
  175. oUF:SetActiveStyle("Kygo")
  176.  
  177. --Spawning units!
  178. local player = oUF:Spawn("player")
  179. player:SetPoint("CENTER", UIParent, "CENTER", 0, 0)
  180.  
  181. local target = oUF:Spawn("target")
  182. target:SetPoint("LEFT", player, "RIGHT", 20, 0)
  183.  
  184. local pet = oUF:Spawn("pet")
  185. pet:SetPoint("BOTTOMLEFT", player, "TOPLEFT", 0, 20)
  186.  
  187. local tot = oUF:Spawn("targettarget")
  188. tot:SetPoint("BOTTOMLEFT", target, "TOPLEFT", 0, 20)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement