/Tukui_Raid/oUF_Tukz_Raid40.lua

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