Advertisement
Guest User

Untitled

a guest
Aug 23rd, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.93 KB | None | 0 0
  1. local T, C, L = unpack(select(2, ...))
  2.  
  3. local _, ns = ...
  4. local oUF = ns.oUF
  5.  
  6. local MAX_COMBO_POINTS = MAX_COMBO_POINTS
  7.  
  8. local function Update(self, _, unit, powerType)
  9. if(self.unit ~= unit and (powerType and (powerType ~= "COMBO_POINTS"))) then return end
  10.  
  11. local element = self.CPoints
  12. local cur, max
  13.  
  14. if UnitHasVehicleUI("player") then
  15. cur = UnitPower("vehicle", 4)
  16. max = UnitPowerMax("vehicle", 4)
  17. else
  18. cur = UnitPower("player", 4)
  19. max = UnitPowerMax("player", 4)
  20. end
  21.  
  22. if max == 0 or max > 6 then
  23. max = MAX_COMBO_POINTS
  24. end
  25.  
  26. local spacing = select(4, element[5]:GetPoint())
  27. local w = element:GetWidth()
  28. local s = 0
  29.  
  30. if element.max ~= max then
  31. if max == 6 then
  32. element[6]:Show()
  33. else
  34. element[6]:Hide()
  35. end
  36.  
  37. for i = 1, max do
  38. if i ~= max then
  39. element[i]:SetWidth(w / max - spacing)
  40. s = s + (w / max)
  41. else
  42. element[i]:SetWidth(w - s)
  43. end
  44. end
  45.  
  46. element.max = max
  47. end
  48.  
  49. for i = 1, max do
  50. if i <= cur then
  51. element[i]:SetAlpha(1)
  52. else
  53. element[i]:SetAlpha(0.2)
  54. end
  55. end
  56.  
  57. if C.unitframe_class_bar.combo_old == true or (T.class ~= "DRUID" and T.class ~= "ROGUE") then
  58. if element[1]:GetAlpha() == 1 then
  59. for i = 1, max do
  60. element:Show()
  61. element[i]:Show()
  62. end
  63. else
  64. for i = 1, max do
  65. element:Hide()
  66. element[i]:Hide()
  67. end
  68. end
  69.  
  70. if self.RangeBar then
  71. if element[1]:IsShown() and self.RangeBar:IsShown() then
  72. element:SetPoint("BOTTOMLEFT", self, "TOPLEFT", 0, 21)
  73. if self.Auras then self.Auras:SetPoint("BOTTOMLEFT", self, "TOPLEFT", -2, 33) end
  74. elseif element[1]:IsShown() or self.RangeBar:IsShown() then
  75. element:SetPoint("BOTTOMLEFT", self, "TOPLEFT", 0, 7)
  76. if self.Auras then self.Auras:SetPoint("BOTTOMLEFT", self, "TOPLEFT", -2, 19) end
  77. else
  78. if self.Auras then self.Auras:SetPoint("BOTTOMLEFT", self, "TOPLEFT", -2, 5) end
  79. end
  80. else
  81. if element[1]:IsShown() then
  82. if self.Auras then self.Auras:SetPoint("BOTTOMLEFT", self, "TOPLEFT", -2, 19) end
  83. else
  84. if self.Auras then self.Auras:SetPoint("BOTTOMLEFT", self, "TOPLEFT", -2, 5) end
  85. end
  86. end
  87. end
  88. end
  89.  
  90. local function Path(self, ...)
  91. return (self.CPoints.Override or Update) (self, ...)
  92. end
  93.  
  94. local function Visibility(self)
  95. local element = self.CPoints
  96. local form = GetShapeshiftFormID()
  97.  
  98. if form == CAT_FORM or (UnitHasVehicleUI("player") and UnitPower("vehicle", 4) > 0) then
  99. element:Show()
  100. if self.Debuffs then self.Debuffs:SetPoint("BOTTOMRIGHT", self, "TOPRIGHT", 2, 19) end
  101. else
  102. element:Hide()
  103. if self.Debuffs then self.Debuffs:SetPoint("BOTTOMRIGHT", self, "TOPRIGHT", 2, 5) end
  104. end
  105. end
  106.  
  107. local function ForceUpdate(element)
  108. return Path(element.__owner, "ForceUpdate", element.__owner.unit, "COMBO_POINTS")
  109. end
  110.  
  111. local Enable = function(self)
  112. local element = self.CPoints
  113. if(element) then
  114. element.__owner = self
  115. element.ForceUpdate = ForceUpdate
  116.  
  117. self:RegisterEvent("UNIT_POWER_UPDATE", Path, true)
  118. self:RegisterEvent("UNIT_MAXPOWER", Path, true)
  119. self:RegisterEvent("PLAYER_TARGET_CHANGED", Path, true)
  120.  
  121. if T.class == "DRUID" and C.unitframe_class_bar.combo_always ~= true and C.unitframe_class_bar.combo_old ~= true then
  122. element.hadler = CreateFrame("Frame", nil, element)
  123. element.hadler:RegisterEvent("UPDATE_SHAPESHIFT_FORM")
  124. element.hadler:RegisterEvent("PLAYER_ENTERING_WORLD")
  125. element.hadler:SetScript("OnEvent", function() Visibility(self) end)
  126. end
  127.  
  128. for index = 1, MAX_COMBO_POINTS do
  129. local cpoint = element[index]
  130. if(cpoint:IsObjectType"Texture" and not cpoint:GetTexture()) then
  131. cpoint:SetTexture[[Interface\ComboFrame\ComboPoint]]
  132. cpoint:SetTexCoord(0, 0.375, 0, 1)
  133. end
  134. end
  135.  
  136. return true
  137. end
  138. end
  139.  
  140. local Disable = function(self)
  141. local element = self.CPoints
  142. if(element) then
  143. self:UnregisterEvent("UNIT_POWER_UPDATE", Path)
  144. self:UnregisterEvent("UNIT_MAXPOWER", Path)
  145. element.hadler:UnregisterEvent("UPDATE_SHAPESHIFT_FORM")
  146. element.hadler:UnregisterEvent("PLAYER_ENTERING_WORLD")
  147. end
  148. end
  149.  
  150. oUF:AddElement("CPoints", Path, Enable, Disable)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement