Advertisement
Guest User

Untitled

a guest
Feb 7th, 2015
258
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 7.94 KB | None | 0 0
  1. --get addon data
  2.     local oUF_naisz, addonTable = ...
  3.   --  local cfg = config.cfg
  4.  
  5.     local texture = "Interface\\AddOns\\oUF_naisz\\media\\statusbar"
  6.     local font = "Interface\\AddOns\\oUF_naisz\\fonts\\font.ttf"
  7.     local fontsize = 16
  8.     local color = {r = 0, g = 0, b = 0}
  9.     local scale = 1
  10.     local pos = 1 -- dieser Wert gibt den Abstand vom Frame an
  11.     local frameborder = "Interface\\ChatFrame\\ChatFrameBackground"
  12.  
  13. --
  14. --Tags , thank you Phanx!
  15. --
  16. oUF.Tags.Events["shorthp"] = "UNIT_HEALTH"
  17. oUF.Tags.Methods["shorthp"] = function(unit)
  18.         if not UnitIsDeadOrGhost(unit) then
  19.                 local hp = UnitHealth(unit)
  20.                 return AbbreviateLargeNumbers(hp)
  21.         end
  22. end
  23.  
  24. oUF.Tags.Events["mouseoverhp"] = "UNIT_HEALTH UNIT_MAXHEALTH UPDATE_MOUSEOVER_UNIT"
  25. oUF.Tags.Methods["mouseoverhp"] = function(unit)
  26.     if UnitIsDead(unit) then
  27.         return DEAD
  28.     end
  29.     local hp = UnitHealth(unit)
  30.     if UnitIsUnit(unit, "mouseover") then
  31.         return AbbreviateLargeNumbers(hp)
  32.     else
  33.         return format("%.0f%%", hp / UnitHealthMax(unit) * 100)
  34.     end
  35. end
  36. --
  37. --create statusbar func
  38. --
  39. local function Style(self, unit, isSingle)
  40. --SIZE! depending on unit
  41.   if unit == "player" or unit =="target" then
  42.     self:SetSize(250,24)
  43.   elseif unit =="targettarget" or unit == "pet" then
  44.     self:SetSize(125,24)
  45.   end
  46. --DROPDOWN
  47.     self:RegisterForClicks("AnyUp")
  48.     self:SetScript("OnEnter", UnitFrame_OnEnter)
  49.     self:SetScript("OnLeave", UnitFrame_OnLeave)
  50. --
  51. --Draw Beautiful 1px Border
  52. --
  53.     local TopLeft = self:CreateTexture(nil, "BORDER")
  54.     TopLeft:SetTexture(frameborder)
  55.     TopLeft:SetTexCoord(0, 1/3, 0, 1/3)
  56.     TopLeft:SetPoint("TOPLEFT", self, -pos+1, pos-1)
  57.     TopLeft:SetWidth(scale) TopLeft:SetHeight(scale)
  58.     TopLeft:SetVertexColor(color.r,color.g,color.b)
  59.     TopLeft:SetDrawLayer("BORDER")
  60.  
  61.     local TopRight = self:CreateTexture(nil, "BORDER")
  62.     TopRight:SetTexture(frameborder)
  63.     TopRight:SetTexCoord(2/3, 1, 0, 1/3)
  64.     TopRight:SetPoint("TOPRIGHT", self, pos-1, pos-1)
  65.     TopRight:SetWidth(scale) TopRight:SetHeight(scale)
  66.     TopRight:SetVertexColor(color.r,color.g,color.b)
  67.     TopRight:SetDrawLayer("BORDER")
  68.  
  69.     local BottomLeft = self:CreateTexture(nil, "BORDER")
  70.     BottomLeft:SetTexture(frameborder)
  71.     BottomLeft:SetTexCoord(0, 1/3, 2/3, 1)
  72.     BottomLeft:SetPoint("BOTTOMLEFT", self, -pos+1, -pos)
  73.     BottomLeft:SetWidth(scale) BottomLeft:SetHeight(scale)
  74.     BottomLeft:SetVertexColor(color.r,color.g,color.B)
  75.     BottomLeft:SetDrawLayer("BORDER")
  76.  
  77.     local BottomRight = self:CreateTexture(nil, "BORDER")
  78.     BottomRight:SetTexture(frameborder)
  79.     BottomRight:SetTexCoord(2/3, 1, 2/3, 1)
  80.     BottomRight:SetPoint("BOTTOMRIGHT", self, pos-1, -pos+1)
  81.     BottomRight:SetWidth(scale) BottomRight:SetHeight(scale)
  82.     BottomRight:SetVertexColor(color.r,color.g,color.B)
  83.     BottomRight:SetDrawLayer("BORDER")
  84.  
  85.     local TopEdge = self:CreateTexture(nil, "BORDER")
  86.     TopEdge:SetTexture(frameborder)
  87.     TopEdge:SetTexCoord(1/3, 2/3, 0, 1/3)
  88.     TopEdge:SetPoint("TOPLEFT", TopLeft, "TOPRIGHT")
  89.     TopEdge:SetPoint("TOPRIGHT", TopRight, "TOPLEFT")
  90.     TopEdge:SetHeight(scale)
  91.     TopEdge:SetVertexColor(color.r,color.g,color.B)
  92.     TopEdge:SetDrawLayer("BORDER")
  93.  
  94.     local BottomEdge = self:CreateTexture(nil, "BORDER")
  95.     BottomEdge:SetTexture(frameborder)
  96.     BottomEdge:SetTexCoord(1/3, 2/3, 2/3, 1)
  97.     BottomEdge:SetPoint("BOTTOMLEFT", BottomLeft, "BOTTOMRIGHT")
  98.     BottomEdge:SetPoint("BOTTOMRIGHT", BottomRight, "BOTTOMLEFT")
  99.     BottomEdge:SetHeight(scale)BottomEdge:SetVertexColor(color.r,color.g,color.B)
  100.     BottomEdge:SetDrawLayer("BORDER")
  101.  
  102.     local LeftEdge = self:CreateTexture(nil, "BORDER")
  103.     LeftEdge:SetTexture(frameborder)
  104.     LeftEdge:SetTexCoord(0, 1/3, 1/3, 2/3)
  105.     LeftEdge:SetPoint("TOPLEFT", TopLeft, "BOTTOMLEFT")
  106.     LeftEdge:SetPoint("BOTTOMLEFT", BottomLeft, "TOPLEFT")
  107.     LeftEdge:SetWidth(scale)
  108.     LeftEdge:SetVertexColor(color.r,color.g,color.B)
  109.     LeftEdge:SetDrawLayer("BORDER")
  110.  
  111.     local RightEdge = self:CreateTexture(nil, "BORDER")
  112.     RightEdge:SetTexture(frameborder)
  113.     RightEdge:SetTexCoord(2/3, 1, 1/3, 2/3)
  114.     RightEdge:SetPoint("TOPRIGHT", TopRight, "BOTTOMRIGHT")
  115.     RightEdge:SetPoint("BOTTOMRIGHT", BottomRight, "TOPRIGHT")
  116.     RightEdge:SetWidth(scale)
  117.     RightEdge:SetVertexColor(color.r,color.g,color.B)
  118.     RightEdge:SetDrawLayer("BORDER")
  119.  
  120. --Create HealthBar
  121.     local health = CreateFrame("StatusBar", nil, self)  
  122.     health:SetStatusBarTexture(texture)
  123.     health:SetPoint("TOPLEFT", self, 1, -1)
  124.     health:SetPoint("TOPRIGHT", self, -1, -1)
  125.     health:SetHeight(18)
  126. -- and Background
  127.     local Background = self:CreateTexture(nil, "BACKGROUND")
  128.     Background.multiplier = 0.3
  129.     Background.Alpha = 0.5
  130.     Background:SetAllPoints()
  131.     Background:SetTexture(texture)
  132.     health:SetStatusBarTexture(texture)
  133.  
  134.     health.bg = Background
  135. -- Text depending on Character! THANK PHANX: ShortVal instead of % on mouseover
  136.     local healthText = health:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
  137.     healthText:SetPoint("RIGHT", health)
  138.     healthText:SetFont(font, fontsize, "OUTLINE")
  139.     if unit == "player" then
  140.         self:Tag(healthText, "[dead][shorthp]")
  141.     elseif unit == "target" then
  142.         self:Tag(healthText, "[mouseoverhp]")
  143.     elseif unit == "focus" or unit =="targettarget" then
  144.         self:Tag(healthText, "[mouseoverhp]")
  145.     end
  146. --
  147. -- Register with oUF
  148. --
  149.     health.colorTapping = true
  150.     health.colorDisconnected = true
  151.     health.colorClass = true
  152.     health.colorReaction = true
  153.     health.colorHealth = true
  154.     health.FrequentUpdates = true
  155.     self.Health = health
  156. -- Create PowerBar
  157.     local power = CreateFrame("StatusBar", nil, self)
  158.     power:SetStatusBarTexture(texture)
  159.     power:SetPoint("TOPLEFT", health, "BOTTOMLEFT")
  160.     power:SetPoint("TOPRIGHT", health, "BOTTOMRIGHT")
  161.     power:SetPoint("BOTTOM", self, -1, 0)
  162. -- and Background
  163.     local Background = power:CreateTexture(nil, "BACKGROUND")
  164.     Background:SetAllPoints()
  165.     Background:SetTexture(texture)
  166.     power:SetStatusBarTexture(texture)
  167.     Background.multiplier = 0.3
  168.  
  169.     power.bg = Background
  170. -- Text depending on Character && next: ShortVal on Mouseover
  171.       local powerPer = power:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
  172. --      powerPer:SetPoint("LEFT", health, 5, 8)
  173.       powerPer:SetFont(font, fontsize, "OUTLINE")
  174.       powerPer:SetTextColor(1, 1, 1, 1)
  175.       if unit == "player" then
  176.        powerPer:SetPoint("LEFT", health, 5, 0)
  177.        self:Tag(powerPer, "[curpp]")
  178.       elseif unit == "target" then
  179.       powerPer:SetPoint("LEFT", health, 5, 8)
  180.       self:Tag(powerPer, "[smartlevel] [name]")
  181.       elseif  unit == "targettarget" or unit == "pet" then
  182.       powerPer:SetPoint("LEFT", health, 5, 8)
  183.       self:Tag(powerPer, "[name]")
  184.       end
  185.  
  186.     power.colorPower = true
  187.     power.FrequentUpdates = true
  188.     self.Power = power
  189.  
  190. --
  191. --COMBOPOINTS -- WIP
  192. --
  193.   if unit == "target" then
  194.     local CPoints = {}
  195.     for index = 1, MAX_COMBO_POINTS do
  196.       local CPoint = health:CreateTexture(nil, "OVERLAY")
  197.       -- Position and size of the combo point.
  198.       CPoint:SetSize(10, 10)
  199.       CPoint:SetPoint("LEFT", health, "LEFT", index * CPoint:GetWidth(), 0, 20)
  200.       CPoint:SetTexture(font, fontsize, "THINOUTLINE")
  201.       CPoints[index] = CPoint
  202.     end
  203.     self.CPoints = CPoints                                  
  204.   end
  205.  
  206. -- END OF FUNCTION
  207. end
  208.  
  209.     --register and activate style
  210.     oUF:RegisterStyle("oUF_naisz", Style)  
  211.     oUF:SetActiveStyle("oUF_naisz")
  212.  
  213.     --spawn player
  214.     local player = oUF:Spawn("player")
  215.     player:SetPoint("CENTER",-280,-50)
  216.  
  217.     --spawn target
  218.     local target = oUF:Spawn("target")
  219.     target:SetPoint("CENTER",280,-50)
  220.  
  221.     local tot = oUF:Spawn("targettarget")
  222.     tot:SetPoint("CENTER",342, -80)
  223.  
  224.     local pet = oUF:Spawn("pet")
  225.     pet:SetPoint("CENTER",-342,-80)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement