Advertisement
Guest User

ElvUI/Modules/UnitFrames/Groups/Party.lua

a guest
Sep 30th, 2019
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.34 KB | None | 0 0
  1. local E, L, V, P, G = unpack(select(2, ...)); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
  2. local UF = E:GetModule('UnitFrames');
  3. local _, ns = ...
  4. local ElvUF = ns.oUF
  5. assert(ElvUF, "ElvUI was unable to locate oUF.")
  6.  
  7. --Lua functions
  8. local _G = _G
  9. --WoW API / Variables
  10. local CreateFrame = CreateFrame
  11. local GetInstanceInfo = GetInstanceInfo
  12. local InCombatLockdown = InCombatLockdown
  13. local RegisterStateDriver = RegisterStateDriver
  14. local UnregisterStateDriver = UnregisterStateDriver
  15.  
  16. function UF:Construct_PartyFrames()
  17. self:SetScript('OnEnter', _G.UnitFrame_OnEnter)
  18. self:SetScript('OnLeave', _G.UnitFrame_OnLeave)
  19.  
  20. self.RaisedElementParent = CreateFrame('Frame', nil, self)
  21. self.RaisedElementParent.TextureParent = CreateFrame('Frame', nil, self.RaisedElementParent)
  22. self.RaisedElementParent:SetFrameLevel(self:GetFrameLevel() + 100)
  23. self.BORDER = E.Border
  24. self.SPACING = E.Spacing
  25. self.SHADOW_SPACING = 3
  26. if self.isChild then
  27. self.Health = UF:Construct_HealthBar(self, true)
  28. self.MouseGlow = UF:Construct_MouseGlow(self)
  29. self.TargetGlow = UF:Construct_TargetGlow(self)
  30. self.Name = UF:Construct_NameText(self)
  31. self.RaidTargetIndicator = UF:Construct_RaidIcon(self)
  32.  
  33. self.originalParent = self:GetParent()
  34.  
  35. self.childType = "pet"
  36. if self == _G[self.originalParent:GetName()..'Target'] then
  37. self.childType = "target"
  38. end
  39.  
  40. self.unitframeType = "party"..self.childType
  41. else
  42. self.Health = UF:Construct_HealthBar(self, true, true, 'RIGHT')
  43. self.Power = UF:Construct_PowerBar(self, true, true, 'LEFT')
  44. self.Power.frequentUpdates = false;
  45. self.PowerPrediction = UF:Construct_PowerPrediction(self)
  46.  
  47. self.Portrait3D = UF:Construct_Portrait(self, 'model')
  48. self.Portrait2D = UF:Construct_Portrait(self, 'texture')
  49. self.InfoPanel = UF:Construct_InfoPanel(self)
  50. self.Name = UF:Construct_NameText(self)
  51. self.Buffs = UF:Construct_Buffs(self)
  52. self.Debuffs = UF:Construct_Debuffs(self)
  53. self.AuraWatch = UF:Construct_AuraWatch(self)
  54. self.RaidDebuffs = UF:Construct_RaidDebuffs(self)
  55. self.DebuffHighlight = UF:Construct_DebuffHighlight(self)
  56. self.RaidRoleFramesAnchor = UF:Construct_RaidRoleFrames(self)
  57. self.MouseGlow = UF:Construct_MouseGlow(self)
  58. self.PhaseIndicator = UF:Construct_PhaseIcon(self)
  59. self.TargetGlow = UF:Construct_TargetGlow(self)
  60. self.RaidTargetIndicator = UF:Construct_RaidIcon(self)
  61. self.ReadyCheckIndicator = UF:Construct_ReadyCheckIcon(self)
  62. self.HealthPrediction = UF:Construct_HealComm(self)
  63. self.customTexts = {}
  64.  
  65. self.Sparkle = CreateFrame("Frame", nil, self)
  66. self.Sparkle:SetAllPoints(self.Health)
  67. self.Castbar = UF:Construct_Castbar(self)
  68. self.unitframeType = "party"
  69. end
  70.  
  71. self.Fader = UF:Construct_Fader()
  72. self.Cutaway = UF:Construct_Cutaway(self)
  73.  
  74. return self
  75. end
  76.  
  77. function UF:Update_PartyHeader(header, db)
  78. header.db = db
  79.  
  80. local headerHolder = header:GetParent()
  81. headerHolder.db = db
  82.  
  83. if not headerHolder.positioned then
  84. headerHolder:ClearAllPoints()
  85. headerHolder:Point("BOTTOMLEFT", E.UIParent, "BOTTOMLEFT", 4, 195)
  86.  
  87. E:CreateMover(headerHolder, headerHolder:GetName()..'Mover', L["Party Frames"], nil, nil, nil, 'ALL,PARTY', nil, 'unitframe,party,generalGroup')
  88. headerHolder.positioned = true;
  89.  
  90. headerHolder:RegisterEvent("PLAYER_ENTERING_WORLD")
  91. headerHolder:RegisterEvent("ZONE_CHANGED_NEW_AREA")
  92. headerHolder:SetScript("OnEvent", UF.PartySmartVisibility)
  93. end
  94.  
  95. UF.PartySmartVisibility(headerHolder)
  96. end
  97.  
  98. function UF:PartySmartVisibility(event)
  99. if not self.db or (self.db and not self.db.enable) or (UF.db and not UF.db.smartRaidFilter) or self.isForced then
  100. self.blockVisibilityChanges = false
  101. return
  102. end
  103.  
  104. if event == "PLAYER_REGEN_ENABLED" then
  105. self:UnregisterEvent("PLAYER_REGEN_ENABLED")
  106. end
  107.  
  108. if not InCombatLockdown() then
  109. local _, instanceType = GetInstanceInfo()
  110. if instanceType == "raid" or instanceType == "pvp" then
  111. UnregisterStateDriver(self, "visibility")
  112. self.blockVisibilityChanges = true
  113. self:Hide()
  114. elseif self.db.visibility then
  115. RegisterStateDriver(self, "visibility", self.db.visibility)
  116. self.blockVisibilityChanges = false
  117. end
  118. else
  119. self:RegisterEvent("PLAYER_REGEN_ENABLED")
  120. end
  121. end
  122.  
  123. function UF:Update_PartyFrames(frame, db)
  124. frame.db = db
  125.  
  126. frame.Portrait = frame.Portrait or (db.portrait.style == '2D' and frame.Portrait2D or frame.Portrait3D)
  127. frame.colors = ElvUF.colors
  128. frame:RegisterForClicks(self.db.targetOnMouseDown and 'AnyDown' or 'AnyUp')
  129.  
  130. do
  131. if(self.thinBorders) then
  132. frame.SPACING = 0
  133. frame.BORDER = E.mult
  134. else
  135. frame.BORDER = E.Border
  136. frame.SPACING = E.Spacing
  137. end
  138.  
  139. frame.ORIENTATION = db.orientation --allow this value to change when unitframes position changes on screen?
  140. frame.UNIT_WIDTH = db.width
  141. frame.UNIT_HEIGHT = db.infoPanel.enable and (db.height + db.infoPanel.height) or db.height
  142.  
  143. frame.USE_POWERBAR = db.power.enable
  144. frame.POWERBAR_DETACHED = db.power.detachFromFrame
  145. frame.USE_INSET_POWERBAR = not frame.POWERBAR_DETACHED and db.power.width == 'inset' and frame.USE_POWERBAR
  146. frame.USE_MINI_POWERBAR = (not frame.POWERBAR_DETACHED and db.power.width == 'spaced' and frame.USE_POWERBAR)
  147. frame.USE_POWERBAR_OFFSET = db.power.offset ~= 0 and frame.USE_POWERBAR and not frame.POWERBAR_DETACHED
  148. frame.POWERBAR_OFFSET = frame.USE_POWERBAR_OFFSET and db.power.offset or 0
  149.  
  150. frame.POWERBAR_HEIGHT = not frame.USE_POWERBAR and 0 or db.power.height
  151. frame.POWERBAR_WIDTH = frame.USE_MINI_POWERBAR and (frame.UNIT_WIDTH - (frame.BORDER*2))/2 or (frame.POWERBAR_DETACHED and db.power.detachedWidth or (frame.UNIT_WIDTH - ((frame.BORDER+frame.SPACING)*2)))
  152.  
  153. frame.USE_PORTRAIT = db.portrait and db.portrait.enable
  154. frame.USE_PORTRAIT_OVERLAY = frame.USE_PORTRAIT and (db.portrait.overlay or frame.ORIENTATION == "MIDDLE")
  155. frame.PORTRAIT_WIDTH = (frame.USE_PORTRAIT_OVERLAY or not frame.USE_PORTRAIT) and 0 or db.portrait.width
  156. frame.CLASSBAR_YOFFSET = 0
  157.  
  158. frame.USE_INFO_PANEL = not frame.USE_MINI_POWERBAR and not frame.USE_POWERBAR_OFFSET and db.infoPanel.enable
  159. frame.INFO_PANEL_HEIGHT = frame.USE_INFO_PANEL and db.infoPanel.height or 0
  160.  
  161. frame.BOTTOM_OFFSET = UF:GetHealthBottomOffset(frame)
  162.  
  163. frame.VARIABLES_SET = true
  164. end
  165.  
  166. if frame.isChild then
  167. frame.USE_PORTAIT = false
  168. frame.USE_PORTRAIT_OVERLAY = false
  169. frame.PORTRAIT_WIDTH = 0
  170. frame.USE_POWERBAR = false
  171. frame.USE_INSET_POWERBAR = false
  172. frame.USE_MINI_POWERBAR = false
  173. frame.USE_POWERBAR_OFFSET = false
  174. frame.POWERBAR_OFFSET = 0
  175.  
  176. frame.POWERBAR_HEIGHT = 0
  177. frame.POWERBAR_WIDTH = 0
  178.  
  179. frame.BOTTOM_OFFSET = 0
  180.  
  181. local childDB = db.petsGroup
  182. if frame.childType == "target" then
  183. childDB = db.targetsGroup
  184. end
  185.  
  186. if not frame.originalParent.childList then
  187. frame.originalParent.childList = {}
  188. end
  189. frame.originalParent.childList[frame] = true;
  190.  
  191. if not InCombatLockdown() then
  192. if childDB.enable then
  193. frame:SetParent(frame.originalParent)
  194. frame:Size(childDB.width, childDB.height)
  195. frame:ClearAllPoints()
  196. frame:Point(E.InversePoints[childDB.anchorPoint], frame.originalParent, childDB.anchorPoint, childDB.xOffset, childDB.yOffset)
  197. else
  198. frame:SetParent(E.HiddenFrame)
  199. end
  200. end
  201.  
  202. --Health
  203. UF:Configure_HealthBar(frame)
  204.  
  205. UF:Configure_RaidIcon(frame)
  206.  
  207. --Name
  208. UF:UpdateNameSettings(frame, frame.childType)
  209. else
  210. if not InCombatLockdown() then
  211. frame:Size(frame.UNIT_WIDTH, frame.UNIT_HEIGHT)
  212. end
  213.  
  214. UF:Configure_InfoPanel(frame)
  215. UF:Configure_HealthBar(frame)
  216.  
  217. UF:UpdateNameSettings(frame)
  218.  
  219. UF:Configure_PhaseIcon(frame)
  220.  
  221. UF:Configure_Power(frame)
  222.  
  223. -- Power Predicition
  224. UF:Configure_PowerPrediction(frame)
  225.  
  226. UF:Configure_Portrait(frame)
  227.  
  228. UF:EnableDisable_Auras(frame)
  229. UF:Configure_Auras(frame, 'Buffs')
  230. UF:Configure_Auras(frame, 'Debuffs')
  231.  
  232. UF:Configure_RaidDebuffs(frame)
  233.  
  234. UF:Configure_Castbar(frame)
  235.  
  236. UF:Configure_RaidIcon(frame)
  237.  
  238. UF:Configure_DebuffHighlight(frame)
  239.  
  240. UF:Configure_HealComm(frame)
  241.  
  242. UF:Configure_RaidRoleIcons(frame)
  243.  
  244. UF:UpdateAuraWatch(frame)
  245.  
  246. UF:Configure_ReadyCheckIcon(frame)
  247.  
  248. UF:Configure_CustomTexts(frame)
  249. end
  250.  
  251. --Fader
  252. UF:Configure_Fader(frame)
  253.  
  254. --Cutaway
  255. UF:Configure_Cutaway(frame)
  256.  
  257. frame:UpdateAllElements("ElvUI_UpdateAllElements")
  258. end
  259.  
  260. UF.headerstoload.party = {nil, 'ELVUI_UNITPET, ELVUI_UNITTARGET'}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement