/Tukui_Raid_Healing/oUF_hTukz_Raid16_40.lua

http://github.com/Asphyxia/Tukui · Lua · 349 lines · 280 code · 49 blank · 20 comment · 36 complexity · 0ace005386eab09cc388f7a5b71f8d4d MD5 · raw file

  1. local ADDON_NAME, ns = ...
  2. local oUF = oUFTukui or oUF
  3. assert(oUF, "Tukui was unable to locate oUF install.")
  4. ns._Objects = {}
  5. ns._Headers = {}
  6. local T, C, L = unpack(Tukui) -- Import: T - functions, constants, variables; C - config; L - locales
  7. if not C["unitframes"].enable == true then return end
  8. local font2 = C["media"].uffont
  9. local font1 = C["media"].font
  10. local normTex = C["media"].normTex
  11. local font = C["media"].pixelfont
  12. local function Shared(self, unit)
  13. self.colors = T.oUF_colors
  14. self:RegisterForClicks("AnyUp")
  15. self:SetScript('OnEnter', UnitFrame_OnEnter)
  16. self:SetScript('OnLeave', UnitFrame_OnLeave)
  17. self.menu = T.SpawnMenu
  18. local health = CreateFrame('StatusBar', nil, self)
  19. health:SetPoint("TOPLEFT")
  20. health:SetPoint("TOPRIGHT")
  21. health:Height(28*C["unitframes"].gridscale*T.raidscale)
  22. health:SetStatusBarTexture(C["media"].normTex)
  23. self.Health = health
  24. if C["unitframes"].gridhealthvertical == true then
  25. health:SetOrientation('VERTICAL')
  26. end
  27. health.bg = health:CreateTexture(nil, 'BORDER')
  28. health.bg:SetAllPoints(health)
  29. health.bg:SetTexture(C["media"].normTex)
  30. health.bg:SetTexture(1, 1, 1)
  31. health.bg.multiplier = (0.3)
  32. self.Health.bg = health.bg
  33. local HealthBorder = CreateFrame("Frame", nil, health)
  34. HealthBorder:SetPoint("TOPLEFT", health, "TOPLEFT", T.Scale(-2), T.Scale(2))
  35. HealthBorder:SetPoint("BOTTOMRIGHT", health, "BOTTOMRIGHT", T.Scale(2), T.Scale(-2))
  36. HealthBorder:SetTemplate("Default")
  37. HealthBorder:CreateShadow("Default")
  38. HealthBorder:SetFrameLevel(2)
  39. self.HealthBorder = HealthBorder
  40. health.value = health:CreateFontString(nil, "OVERLAY")
  41. health.value:Point("CENTER", health, 1, -1)
  42. health.value:SetFont(font, C["datatext"].fontsize, "MONOCHROMEOUTLINE")
  43. health.value:SetTextColor(1,1,1)
  44. health.value:SetShadowOffset(1, -1)
  45. self.Health.value = health.value
  46. health.PostUpdate = T.PostUpdateHealthRaid
  47. health.frequentUpdates = true
  48. if C.unitframes.unicolor == true then
  49. health.colorDisconnected = false
  50. health.colorClass = false
  51. health:SetStatusBarColor(.150, .150, .150, 1)
  52. health.bg:SetVertexColor(0, 0, 0, 1)
  53. else
  54. health.colorDisconnected = true
  55. health.colorClass = true
  56. health.colorReaction = true
  57. end
  58. if C.unitframes.gradienthealth and C.unitframes.unicolor then
  59. self:HookScript("OnEnter", function(self)
  60. if not UnitIsConnected(self.unit) or UnitIsDead(self.unit) or UnitIsGhost(self.unit) or (not UnitInRange(self.unit) and not UnitIsPlayer(self.unit)) then return end
  61. local hover = RAID_CLASS_COLORS[select(2, UnitClass(self.unit))]
  62. health:SetStatusBarColor(hover.r, hover.g, hover.b)
  63. health.classcolored = true
  64. end)
  65. self:HookScript("OnLeave", function(self)
  66. if not UnitIsConnected(self.unit) or UnitIsDead(self.unit) or UnitIsGhost(self.unit) then return end
  67. local r, g, b = oUF.ColorGradient(UnitHealth(self.unit)/UnitHealthMax(self.unit), unpack(C["unitframes"].gradient))
  68. health:SetStatusBarColor(r, g, b)
  69. health.classcolored = false
  70. end)
  71. end
  72. local power = CreateFrame("StatusBar", nil, self)
  73. power:SetHeight(1.5*C["unitframes"].gridscale*T.raidscale)
  74. power:SetWidth(54)
  75. power:Point("CENTER", self.Health, "CENTER", 0, -10)
  76. power:SetStatusBarTexture(C["media"].normTex)
  77. power:SetFrameLevel(self.Health:GetFrameLevel() + 2)
  78. self.Power = power
  79. power.frequentUpdates = true
  80. power.colorDisconnected = true
  81. power.bg = power:CreateTexture(nil, "BORDER")
  82. power.bg:SetAllPoints(power)
  83. power.bg:SetTexture(C["media"].normTex)
  84. power.bg:SetAlpha(1)
  85. power.bg.multiplier = .4
  86. local PowerBorder = CreateFrame("Frame", nil, power)
  87. PowerBorder:SetPoint("TOPLEFT", power, "TOPLEFT", T.Scale(-2), T.Scale(2))
  88. PowerBorder:SetPoint("BOTTOMRIGHT", power, "BOTTOMRIGHT", T.Scale(2), T.Scale(-2))
  89. PowerBorder:SetTemplate("Thin")
  90. PowerBorder:SetFrameLevel(power:GetFrameLevel() - 1)
  91. self.PowerBorder = PowerBorder
  92. if C.unitframes.unicolor == true then
  93. power.colorClass = true
  94. power.bg.multiplier = 0.1
  95. else
  96. power.colorPower = true
  97. end
  98. local name = self.Health:CreateFontString(nil, "OVERLAY")
  99. name:SetPoint("TOP", 0, 18)
  100. name:SetPoint("BOTTOM")
  101. name:SetPoint("LEFT", 4, 0)
  102. name:SetPoint("RIGHT")
  103. name:SetFont(font, C["datatext"].fontsize, "MONOCHROMEOUTLINE")
  104. name:SetShadowOffset(1.25, -1.25)
  105. self:Tag(name, "[Tukui:getnamecolor][Tukui:nameshort]")
  106. self.Name = name
  107. local leader = health:CreateTexture(nil, "OVERLAY")
  108. leader:Height(12*T.raidscale)
  109. leader:Width(12*T.raidscale)
  110. leader:SetPoint("TOPLEFT", 0, 10)
  111. self.Leader = leader
  112. local MasterLooter = health:CreateTexture(nil, "OVERLAY")
  113. MasterLooter:Height(12*T.raidscale)
  114. MasterLooter:Width(12*T.raidscale)
  115. self.MasterLooter = MasterLooter
  116. self:RegisterEvent("PARTY_LEADER_CHANGED", T.MLAnchorUpdate)
  117. self:RegisterEvent("PARTY_MEMBERS_CHANGED", T.MLAnchorUpdate)
  118. local LFDRole = health:CreateTexture(nil, "OVERLAY")
  119. LFDRole:Height(14*T.raidscale)
  120. LFDRole:Width(14*T.raidscale)
  121. LFDRole:Point("TOP", 0, 10)
  122. LFDRole:SetTexture("Interface\\AddOns\\Tukui\\medias\\textures\\lfdicons.blp")
  123. self.LFDRole = LFDRole
  124. if C["unitframes"].aggro == true then
  125. table.insert(self.__elements, T.UpdateThreat)
  126. self:RegisterEvent('PLAYER_TARGET_CHANGED', T.UpdateThreat)
  127. self:RegisterEvent('UNIT_THREAT_LIST_UPDATE', T.UpdateThreat)
  128. self:RegisterEvent('UNIT_THREAT_SITUATION_UPDATE', T.UpdateThreat)
  129. end
  130. if C["unitframes"].showsymbols == true then
  131. local RaidIcon = power:CreateTexture(nil, 'OVERLAY')
  132. RaidIcon:Height(18*T.raidscale)
  133. RaidIcon:Width(18*T.raidscale)
  134. RaidIcon:SetPoint('CENTER', self, 'TOP')
  135. RaidIcon:SetTexture("Interface\\AddOns\\Tukui\\medias\\textures\\raidicons.blp") -- thx hankthetank for texture
  136. self.RaidIcon = RaidIcon
  137. end
  138. local ReadyCheck = health:CreateTexture(nil, "OVERLAY")
  139. ReadyCheck:Height(12*C["unitframes"].gridscale*T.raidscale)
  140. ReadyCheck:Width(12*C["unitframes"].gridscale*T.raidscale)
  141. ReadyCheck:Point("TOP", 0, 6)
  142. self.ReadyCheck = ReadyCheck
  143. --local picon = self.Health:CreateTexture(nil, 'OVERLAY')
  144. --picon:SetPoint('CENTER', self.Health)
  145. --picon:SetSize(16, 16)
  146. --picon:SetTexture[[Interface\AddOns\Tukui\medias\textures\picon]]
  147. --picon.Override = T.Phasing
  148. --self.PhaseIcon = picon
  149. if not C["unitframes"].raidunitdebuffwatch == true then
  150. self.DebuffHighlightAlpha = 1
  151. self.DebuffHighlightBackdrop = true
  152. self.DebuffHighlightFilter = true
  153. end
  154. if C["unitframes"].showrange == true then
  155. local range = {insideAlpha = 1, outsideAlpha = C["unitframes"].raidalphaoor}
  156. self.Range = range
  157. end
  158. if C["unitframes"].showsmooth == true then
  159. health.Smooth = true
  160. power.Smooth = true
  161. end
  162. if C["unitframes"].healcomm then
  163. local mhpb = CreateFrame('StatusBar', nil, self.Health)
  164. if C["unitframes"].gridhealthvertical then
  165. mhpb:SetOrientation("VERTICAL")
  166. mhpb:SetPoint('BOTTOM', self.Health:GetStatusBarTexture(), 'TOP', 0, 0)
  167. mhpb:Width(66*C["unitframes"].gridscale*T.raidscale)
  168. mhpb:Height(50*C["unitframes"].gridscale*T.raidscale)
  169. else
  170. mhpb:SetPoint('TOPLEFT', self.Health:GetStatusBarTexture(), 'TOPRIGHT', 0, 0)
  171. mhpb:SetPoint('BOTTOMLEFT', self.Health:GetStatusBarTexture(), 'BOTTOMRIGHT', 0, 0)
  172. mhpb:Width(66*C["unitframes"].gridscale*T.raidscale)
  173. end
  174. mhpb:SetStatusBarTexture(C["media"].normTex)
  175. mhpb:SetStatusBarColor(0, 1, 0.5, 0.25)
  176. local ohpb = CreateFrame('StatusBar', nil, self.Health)
  177. if C["unitframes"].gridhealthvertical then
  178. ohpb:SetOrientation("VERTICAL")
  179. ohpb:SetPoint('BOTTOM', mhpb:GetStatusBarTexture(), 'TOP', 0, 0)
  180. ohpb:Width(66*C["unitframes"].gridscale*T.raidscale)
  181. ohpb:Height(50*C["unitframes"].gridscale*T.raidscale)
  182. else
  183. ohpb:SetPoint('TOPLEFT', mhpb:GetStatusBarTexture(), 'TOPRIGHT', 0, 0)
  184. ohpb:SetPoint('BOTTOMLEFT', mhpb:GetStatusBarTexture(), 'BOTTOMRIGHT', 0, 0)
  185. ohpb:Width(6*C["unitframes"].gridscale*T.raidscale)
  186. end
  187. ohpb:SetStatusBarTexture(C["media"].normTex)
  188. ohpb:SetStatusBarColor(0, 1, 0, 0.25)
  189. self.HealPrediction = {
  190. myBar = mhpb,
  191. otherBar = ohpb,
  192. maxOverflow = 1,
  193. }
  194. end
  195. --Resurrect Indicator
  196. local Resurrect = CreateFrame('Frame', nil, self)
  197. Resurrect:SetFrameLevel(20)
  198. local ResurrectIcon = Resurrect:CreateTexture(nil, "OVERLAY")
  199. ResurrectIcon:Point(health.value:GetPoint())
  200. ResurrectIcon:Size(30, 25)
  201. ResurrectIcon:SetDrawLayer('OVERLAY', 7)
  202. self.ResurrectIcon = ResurrectIcon
  203. if C["unitframes"].raidunitdebuffwatch == true then
  204. T.createAuraWatch(self,unit)
  205. -- Raid Debuffs (big middle icon)
  206. local RaidDebuffs = CreateFrame('Frame', nil, self)
  207. RaidDebuffs:Height(21*C["unitframes"].gridscale)
  208. RaidDebuffs:Width(21*C["unitframes"].gridscale)
  209. RaidDebuffs:Point('CENTER', health, 1,1)
  210. RaidDebuffs:SetFrameStrata(power:GetFrameStrata())
  211. RaidDebuffs:SetFrameLevel(power:GetFrameLevel() + 2)
  212. RaidDebuffs:SetTemplate("Default")
  213. RaidDebuffs.icon = RaidDebuffs:CreateTexture(nil, 'OVERLAY')
  214. RaidDebuffs.icon:SetTexCoord(.1,.9,.1,.9)
  215. RaidDebuffs.icon:Point("TOPLEFT", 2, -2)
  216. RaidDebuffs.icon:Point("BOTTOMRIGHT", -2, 2)
  217. -- just in case someone want to add this feature, uncomment to enable it
  218. if C["unitframes"].auratimer then
  219. RaidDebuffs.cd = CreateFrame('Cooldown', nil, RaidDebuffs)
  220. RaidDebuffs.cd:SetPoint("TOPLEFT", T.Scale(2), T.Scale(-2))
  221. RaidDebuffs.cd:SetPoint("BOTTOMRIGHT", T.Scale(-2), T.Scale(2))
  222. RaidDebuffs.cd.noOCC = true -- remove this line if you want cooldown number on it
  223. end
  224. RaidDebuffs.count = RaidDebuffs:CreateFontString(nil, 'OVERLAY')
  225. RaidDebuffs.count:SetFont(C["media"].pixelfont, C["datatext"].fontsize, "MONOCHROMEOUTLINE")
  226. RaidDebuffs.count:SetPoint('BOTTOMRIGHT', RaidDebuffs, 'BOTTOMRIGHT', 0, 2)
  227. RaidDebuffs.count:SetTextColor(1, .9, 0)
  228. RaidDebuffs:FontString('time', C["media"].pixelfont, C["datatext"].fontsize, "MONOCHROMEOUTLINE")
  229. RaidDebuffs.time:SetPoint('CENTER')
  230. RaidDebuffs.time:SetTextColor(1, .9, 0)
  231. self.RaidDebuffs = RaidDebuffs
  232. end
  233. return self
  234. end
  235. --[[ -- switch layout
  236. local swlicon = CreateFrame("Frame", "TukuiSwitchLayoutIcon", UIParent)
  237. swlicon:CreatePanel("Default", 20, 20, "LEFT", TukuiInfoLeft, "RIGHT", 8, 0)
  238. swlicon:SetFrameStrata("BACKGROUND")
  239. swlicon:SetFrameLevel(2)
  240. swlicon:CreateShadow("Hydra")
  241. local tex = swlicon:CreateTexture(nil, "OVERLAY")
  242. tex:SetTexture(C.media.switchlayoutheal)
  243. tex:SetPoint("TOPLEFT", swlicon, "TOPLEFT", 2, -2)
  244. tex:SetPoint("BOTTOMRIGHT", swlicon, "BOTTOMRIGHT", -2, 2)--]]
  245. oUF:RegisterStyle('TukuiHealR25R40', Shared)
  246. oUF:Factory(function(self)
  247. oUF:SetActiveStyle("TukuiHealR25R40")
  248. if C["unitframes"].gridonly then
  249. local raid = self:SpawnHeader("TukuiGrid", nil, "raid,party",
  250. 'oUF-initialConfigFunction', [[
  251. local header = self:GetParent()
  252. self:SetWidth(header:GetAttribute('initial-width'))
  253. self:SetHeight(header:GetAttribute('initial-height'))
  254. ]],
  255. 'initial-width', 68,
  256. 'initial-height', 32,
  257. "showParty", true,
  258. "showPlayer", C["unitframes"].showplayerinparty,
  259. "showRaid", true,
  260. "xoffset", 4,
  261. "yOffset", -1,
  262. "point", "LEFT",
  263. "groupFilter", "1,2,3,4,5,6,7,8",
  264. "groupingOrder", "1,2,3,4,5,6,7,8",
  265. "groupBy", "GROUP",
  266. "maxColumns", 8,
  267. "unitsPerColumn", 5,
  268. "columnSpacing", 1,
  269. "columnAnchorPoint", "TOP"
  270. )
  271. local RaidMove = CreateFrame("Frame")
  272. RaidMove:RegisterEvent("PLAYER_LOGIN")
  273. RaidMove:RegisterEvent("RAID_ROSTER_UPDATE")
  274. RaidMove:RegisterEvent("PARTY_LEADER_CHANGED")
  275. RaidMove:RegisterEvent("PARTY_MEMBERS_CHANGED")
  276. RaidMove:SetScript("OnEvent", function(self)
  277. local numraid = GetNumRaidMembers()
  278. if numraid > 25 then
  279. raid:Point("TOP", UIParent, "BOTTOM", 0, 415)
  280. else
  281. raid:Point("TOP", UIParent, "BOTTOM", 0 , 350)
  282. end
  283. end)
  284. end
  285. end)
  286. -- only show 5 groups in raid (25 mans raid)
  287. local MaxGroup = CreateFrame("Frame")
  288. MaxGroup:RegisterEvent("PLAYER_ENTERING_WORLD")
  289. MaxGroup:RegisterEvent("ZONE_CHANGED_NEW_AREA")
  290. MaxGroup:SetScript("OnEvent", function(self)
  291. local inInstance, instanceType = IsInInstance()
  292. local _, _, _, _, maxPlayers, _, _ = GetInstanceInfo()
  293. if inInstance and instanceType == "raid" and maxPlayers ~= 40 then
  294. TukuiGrid:SetAttribute("groupFilter", "1,2,3,4,5")
  295. else
  296. TukuiGrid:SetAttribute("groupFilter", "1,2,3,4,5,6,7,8")
  297. end
  298. end)