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