PageRenderTime 1646ms CodeModel.GetById 157ms app.highlight 990ms RepoModel.GetById 344ms app.codeStats 28ms

/Tukui/core/functions.lua

http://github.com/Asphyxia/Tukui
Lua | 1335 lines | 1098 code | 150 blank | 87 comment | 244 complexity | 81ac438be0ecf1eccc30dbe7aaf196b6 MD5 | raw file
   1local T, C, L = unpack(select(2, ...)) -- Import: T - functions, constants, variables; C - config; L - locales
   2
   3T.IsPTRVersion = function()
   4	if T.toc > 40200 then
   5		return true
   6	else
   7		return false
   8	end
   9end
  10
  11-- just for creating text
  12T.SetFontString = function(parent, fontName, fontHeight, fontStyle)
  13	local fs = parent:CreateFontString(nil, "OVERLAY")
  14	fs:SetFont(fontName, fontHeight, fontStyle)
  15	fs:SetJustifyH("LEFT")
  16	fs:SetShadowColor(0, 0, 0)
  17	fs:SetShadowOffset(1.25, -1.25)
  18	return fs
  19end
  20
  21-- datatext panel position
  22T.PP = function(p, obj)
  23	local left = TukuiInfoLeft
  24	local right = TukuiInfoRight
  25	local mapleft = TukuiMinimapStatsLeft
  26	local mapright = TukuiMinimapStatsRight
  27	local center = TukuiInfoCenter
  28	local centerleft = TukuiInfoCenterLeft
  29	local centerright = TukuiInfoCenterRight
  30	
  31	if p == 1 then
  32		obj:SetParent(left)
  33		obj:SetHeight(left:GetHeight())
  34		obj:SetPoint("LEFT", left, 30, 1)
  35		obj:SetPoint('TOP', left)
  36		obj:SetPoint('BOTTOM', left)
  37	elseif p == 2 then
  38		obj:SetParent(left)
  39		obj:SetHeight(left:GetHeight())
  40		obj:SetPoint('TOP', left)
  41		obj:SetPoint('BOTTOM', left)
  42	elseif p == 3 then
  43		obj:SetParent(left)
  44		obj:SetHeight(left:GetHeight())
  45		obj:SetPoint("RIGHT", left, -30, 1)
  46		obj:SetPoint('TOP', left)
  47		obj:SetPoint('BOTTOM', left)
  48	elseif p == 4 then
  49		obj:SetParent(right)
  50		obj:SetHeight(right:GetHeight())
  51		obj:SetPoint("LEFT", right, 30, 1)
  52		obj:SetPoint('TOP', right)
  53		obj:SetPoint('BOTTOM', right)
  54	elseif p == 5 then
  55		obj:SetParent(right)
  56		obj:SetHeight(right:GetHeight())
  57		obj:SetPoint('TOP', right)
  58		obj:SetPoint('BOTTOM', right)
  59	elseif p == 6 then
  60		obj:SetParent(right)
  61		obj:SetHeight(right:GetHeight())
  62		obj:SetPoint("RIGHT", right, -30, 1)
  63		obj:SetPoint('TOP', right)
  64		obj:SetPoint('BOTTOM', right)
  65	elseif p == 7 then
  66		obj:SetParent(TukuiInfoCenterLeft)
  67		obj:Height(TukuiInfoCenterLeft:GetHeight())
  68		obj:Point("CENTER", TukuiInfoCenterLeft, 0, 1)					
  69	elseif p == 8 then
  70		obj:SetParent(center)
  71		obj:SetHeight(center:GetHeight())
  72		obj:SetPoint("LEFT", center, 30, 1)
  73		obj:SetPoint('TOP', center, 0, 1)
  74		obj:SetPoint('BOTTOM', center)
  75	elseif p == 9 then
  76		obj:SetParent(center)
  77		obj:SetHeight(center:GetHeight())
  78		obj:SetPoint('TOP', center, 0, 1)
  79		obj:SetPoint('BOTTOM', center)
  80	elseif p ==10 then
  81		obj:SetParent(center)
  82		obj:SetHeight(center:GetHeight())
  83		obj:SetPoint("RIGHT", center, -30, 1)
  84		obj:SetPoint('TOP', center, 0, 1)
  85		obj:SetPoint('BOTTOM', center)
  86	elseif p == 11 then
  87		obj:SetParent(TukuiInfoCenterRight)
  88		obj:Height(TukuiInfoCenterRight:GetHeight())
  89		obj:Point("CENTER", TukuiInfoCenterRight, 0, 1)		
  90	elseif p == 12 then
  91		obj:SetParent(Tukuiwatch)
  92		obj:Height(Tukuiwatch:GetHeight())
  93		obj:Point("CENTER", Tukuiwatch, 0, 1)			
  94	end	
  95end
  96	
  97	--[[if TukuiMinimap then
  98		if p == 7 then
  99			obj:SetParent(mapleft)
 100			obj:SetHeight(mapleft:GetHeight())
 101			obj:SetPoint('TOP', mapleft)
 102			obj:SetPoint('BOTTOM', mapleft)
 103		elseif p == 8 then
 104			obj:SetParent(mapright)
 105			obj:SetHeight(mapright:GetHeight())
 106			obj:SetPoint('TOP', mapright)
 107			obj:SetPoint('BOTTOM', mapright)
 108		end
 109	end--]]
 110
 111T.DataTextTooltipAnchor = function(self)
 112	local panel = self:GetParent()
 113	local anchor = "ANCHOR_TOP"
 114	local xoff = 0
 115	local yoff = T.Scale(5)
 116	
 117	if panel == TukuiInfoLeft then
 118		anchor = "ANCHOR_TOPLEFT"
 119	elseif panel == TukuiInfoRight then
 120		anchor = "ANCHOR_TOPRIGHT"
 121	elseif panel == TukuiMinimapStatsLeft or panel == TukuiMinimapStatsRight then
 122		local position = TukuiMinimap:GetPoint()
 123		if position:match("LEFT") then
 124			anchor = "ANCHOR_BOTTOMRIGHT"
 125			yoff = T.Scale(-6)
 126			xoff = 0 - TukuiMinimapStatsRight:GetWidth()
 127		elseif position:match("RIGHT") then
 128			anchor = "ANCHOR_BOTTOMLEFT"
 129			yoff = T.Scale(-6)
 130			xoff = TukuiMinimapStatsRight:GetWidth()
 131		else
 132			anchor = "ANCHOR_BOTTOM"
 133			yoff = T.Scale(-6)
 134		end
 135	end
 136	
 137	return anchor, panel, xoff, yoff
 138end
 139
 140-- Classcolored Datatext
 141if C["datatext"].classcolored == true then
 142	C["datatext"].color = T.oUF_colors.class[T.myclass]
 143end
 144
 145-- convert datatext color from rgb decimal to hex 
 146local dr, dg, db = unpack(C["datatext"].color)
 147T.datacolor = ("|cff%.2x%.2x%.2x"):format(dr * 255, dg * 255, db * 255)
 148
 149T.DataBarPoint = function(p, obj)
 150	obj:SetPoint("TOPRIGHT", T.databars[p], "TOPRIGHT", -2, -2)
 151	obj:SetPoint("BOTTOMLEFT", T.databars[p], "BOTTOMLEFT", 2, 2)
 152end
 153
 154T.DataBarTooltipAnchor = function(barNum)
 155	local xoff = -T.databars[barNum]:GetWidth()
 156	local yoff = T.Scale(-5)
 157	
 158	if C.databars.settings.vertical then
 159		xoff = T.Scale(5)
 160		yoff = T.databars[barNum]:GetHeight()
 161	end
 162	
 163	return xoff, yoff
 164end
 165
 166T.TukuiShiftBarUpdate = function()
 167	local numForms = GetNumShapeshiftForms()
 168	local texture, name, isActive, isCastable
 169	local button, icon, cooldown
 170	local start, duration, enable
 171	for i = 1, NUM_SHAPESHIFT_SLOTS do
 172		button = _G["ShapeshiftButton"..i]
 173		icon = _G["ShapeshiftButton"..i.."Icon"]
 174		if i <= numForms then
 175			texture, name, isActive, isCastable = GetShapeshiftFormInfo(i)
 176			icon:SetTexture(texture)
 177			
 178			cooldown = _G["ShapeshiftButton"..i.."Cooldown"]
 179			if texture then
 180				cooldown:SetAlpha(1)
 181			else
 182				cooldown:SetAlpha(0)
 183			end
 184			
 185			start, duration, enable = GetShapeshiftFormCooldown(i)
 186			CooldownFrame_SetTimer(cooldown, start, duration, enable)
 187			
 188			if isActive then
 189				ShapeshiftBarFrame.lastSelected = button:GetID()
 190				button:SetChecked(1)
 191			else
 192				button:SetChecked(0)
 193			end
 194
 195			if isCastable then
 196				icon:SetVertexColor(1.0, 1.0, 1.0)
 197			else
 198				icon:SetVertexColor(0.4, 0.4, 0.4)
 199			end
 200		end
 201	end
 202end
 203
 204T.TukuiPetBarUpdate = function(self, event)
 205	local petActionButton, petActionIcon, petAutoCastableTexture, petAutoCastShine
 206	for i=1, NUM_PET_ACTION_SLOTS, 1 do
 207		local buttonName = "PetActionButton" .. i
 208		petActionButton = _G[buttonName]
 209		petActionIcon = _G[buttonName.."Icon"]
 210		petAutoCastableTexture = _G[buttonName.."AutoCastable"]
 211		petAutoCastShine = _G[buttonName.."Shine"]
 212		local name, subtext, texture, isToken, isActive, autoCastAllowed, autoCastEnabled = GetPetActionInfo(i)
 213		
 214		if not isToken then
 215			petActionIcon:SetTexture(texture)
 216			petActionButton.tooltipName = name
 217		else
 218			petActionIcon:SetTexture(_G[texture])
 219			petActionButton.tooltipName = _G[name]
 220		end
 221		
 222		petActionButton.isToken = isToken
 223		petActionButton.tooltipSubtext = subtext
 224
 225		if isActive and name ~= "PET_ACTION_FOLLOW" then
 226			petActionButton:SetChecked(1)
 227			if IsPetAttackAction(i) then
 228				PetActionButton_StartFlash(petActionButton)
 229			end
 230		else
 231			petActionButton:SetChecked(0)
 232			if IsPetAttackAction(i) then
 233				PetActionButton_StopFlash(petActionButton)
 234			end			
 235		end
 236		
 237		if autoCastAllowed then
 238			petAutoCastableTexture:Show()
 239		else
 240			petAutoCastableTexture:Hide()
 241		end
 242		
 243		if autoCastEnabled then
 244			AutoCastShine_AutoCastStart(petAutoCastShine)
 245		else
 246			AutoCastShine_AutoCastStop(petAutoCastShine)
 247		end
 248		
 249		-- grid display
 250		if name then
 251			if not C["actionbar"].showgrid then
 252				petActionButton:SetAlpha(1)
 253			end			
 254		else
 255			if not C["actionbar"].showgrid then
 256				petActionButton:SetAlpha(0)
 257			end
 258		end
 259		
 260		if texture then
 261			if GetPetActionSlotUsable(i) then
 262				SetDesaturation(petActionIcon, nil)
 263			else
 264				SetDesaturation(petActionIcon, 1)
 265			end
 266			petActionIcon:Show()
 267		else
 268			petActionIcon:Hide()
 269		end
 270		
 271		-- between level 1 and 10 on cata, we don't have any control on Pet. (I lol'ed so hard)
 272		-- Setting desaturation on button to true until you learn the control on class trainer.
 273		-- you can at least control "follow" button.
 274		if not PetHasActionBar() and texture and name ~= "PET_ACTION_FOLLOW" then
 275			PetActionButton_StopFlash(petActionButton)
 276			SetDesaturation(petActionIcon, 1)
 277			petActionButton:SetChecked(0)
 278		end
 279	end
 280end
 281
 282-- Define action bar buttons size
 283T.buttonsize = T.Scale(C.actionbar.buttonsize)
 284T.petbuttonsize = T.Scale(C.actionbar.petbuttonsize)
 285T.stancebuttonsize = T.Scale(C.actionbar.stancebuttonsize)
 286T.buttonspacing = T.Scale(C.actionbar.buttonspacing)
 287
 288T.Round = function(number, decimals)
 289	if not decimals then decimals = 0 end
 290    return (("%%.%df"):format(decimals)):format(number)
 291end
 292
 293T.Round = function(number, decimals)
 294	if not decimals then decimals = 0 end
 295    return (("%%.%df"):format(decimals)):format(number)
 296end
 297
 298T.RGBToHex = function(r, g, b)
 299	r = r <= 1 and r >= 0 and r or 0
 300	g = g <= 1 and g >= 0 and g or 0
 301	b = b <= 1 and b >= 0 and b or 0
 302	return string.format("|cff%02x%02x%02x", r*255, g*255, b*255)
 303end
 304
 305--Check Player's Role
 306local RoleUpdater = CreateFrame("Frame")
 307local function CheckRole(self, event, unit)
 308	local tree = GetPrimaryTalentTree()
 309	local resilience
 310	local resilperc = GetCombatRatingBonus(COMBAT_RATING_RESILIENCE_PLAYER_DAMAGE_TAKEN)
 311	if resilperc > GetDodgeChance() and resilperc > GetParryChance() then
 312		resilience = true
 313	else
 314		resilience = false
 315	end
 316	if ((T.myclass == "PALADIN" and tree == 2) or
 317	(T.myclass == "WARRIOR" and tree == 3) or
 318	(T.myclass == "DEATHKNIGHT" and tree == 1)) and
 319	resilience == false or
 320	(T.myclass == "DRUID" and tree == 2 and GetBonusBarOffset() == 3) then
 321		T.Role = "Tank"
 322	else
 323		local playerint = select(2, UnitStat("player", 4))
 324		local playeragi	= select(2, UnitStat("player", 2))
 325		local base, posBuff, negBuff = UnitAttackPower("player");
 326		local playerap = base + posBuff + negBuff;
 327
 328		if (((playerap > playerint) or (playeragi > playerint)) and not (T.myclass == "SHAMAN" and tree ~= 1 and tree ~= 3) and not (UnitBuff("player", GetSpellInfo(24858)) or UnitBuff("player", GetSpellInfo(65139)))) or T.myclass == "ROGUE" or T.myclass == "HUNTER" or (T.myclass == "SHAMAN" and tree == 2) then
 329			T.Role = "Melee"
 330		else
 331			T.Role = "Caster"
 332		end
 333	end
 334end
 335RoleUpdater:RegisterEvent("PLAYER_ENTERING_WORLD")
 336RoleUpdater:RegisterEvent("ACTIVE_TALENT_GROUP_CHANGED")
 337RoleUpdater:RegisterEvent("PLAYER_TALENT_UPDATE")
 338RoleUpdater:RegisterEvent("CHARACTER_POINTS_CHANGED")
 339RoleUpdater:RegisterEvent("UNIT_INVENTORY_CHANGED")
 340RoleUpdater:RegisterEvent("UPDATE_BONUS_ACTIONBAR")
 341RoleUpdater:SetScript("OnEvent", CheckRole)
 342CheckRole()
 343
 344--Return short value of a number
 345function T.ShortValue(v)
 346	if v >= 1e6 then
 347		return ("%.1fm"):format(v / 1e6):gsub("%.?0+([km])$", "%1")
 348	elseif v >= 1e3 or v <= -1e3 then
 349		return ("%.1fk"):format(v / 1e3):gsub("%.?0+([km])$", "%1")
 350	else
 351		return v
 352	end
 353end
 354
 355--Add time before calling a function
 356--Usage T.Delay(seconds, functionToCall, ...)
 357local waitTable = {}
 358local waitFrame
 359function T.Delay(delay, func, ...)
 360	if(type(delay)~="number" or type(func)~="function") then
 361		return false
 362	end
 363	if(waitFrame == nil) then
 364		waitFrame = CreateFrame("Frame","WaitFrame", UIParent)
 365		waitFrame:SetScript("onUpdate",function (self,elapse)
 366			local count = #waitTable
 367			local i = 1
 368			while(i<=count) do
 369				local waitRecord = tremove(waitTable,i)
 370				local d = tremove(waitRecord,1)
 371				local f = tremove(waitRecord,1)
 372				local p = tremove(waitRecord,1)
 373				if(d>elapse) then
 374				  tinsert(waitTable,i,{d-elapse,f,p})
 375				  i = i + 1
 376				else
 377				  count = count - 1
 378				  f(unpack(p))
 379				end
 380			end
 381		end)
 382	end
 383	tinsert(waitTable,{delay,func,{...}})
 384	return true
 385end
 386
 387function T.update_alpha(self)
 388	if self.parent:GetAlpha() == 0 then 
 389		self.parent:Hide()
 390		self:Hide()
 391	end
 392end
 393
 394function T.fadeOut(self) 
 395	UIFrameFadeOut(self,.4,1,0) 
 396	self.frame:Show() 
 397end
 398
 399function T.fadeIn(p)
 400	p.frame = CreateFrame("Frame", nil , p)
 401	p.frame:Hide()
 402	p.frame.parent = p -- lol!
 403	p.frame:SetScript("OnUpdate",T.update_alpha)
 404	p:SetScript("OnShow", function() 
 405		p.frame:Hide() 
 406		UIFrameFadeIn(p,.4,0,1)
 407	end)
 408	p.fadeOut = T.fadeOut
 409end
 410
 411--[[function T.ApplyHover(self)
 412	self:HookScript("OnEnter", T.SetModifiedBackdrop)
 413	self:HookScript("OnLeave", T.SetOriginalBackdrop)
 414end--]]
 415
 416------------------------------------------------------------------------
 417--	unitframes Functions
 418------------------------------------------------------------------------
 419
 420local ADDON_NAME, ns = ...
 421local oUF = ns.oUF or oUF
 422assert(oUF, "Tukui was unable to locate oUF install.")
 423
 424T.updateAllElements = function(frame)
 425	for _, v in ipairs(frame.__elements) do
 426		v(frame, "UpdateElement", frame.unit)
 427	end
 428end
 429
 430local SetUpAnimGroup = function(self)
 431	self.anim = self:CreateAnimationGroup("Flash")
 432	self.anim.fadein = self.anim:CreateAnimation("ALPHA", "FadeIn")
 433	self.anim.fadein:SetChange(1)
 434	self.anim.fadein:SetOrder(2)
 435
 436	self.anim.fadeout = self.anim:CreateAnimation("ALPHA", "FadeOut")
 437	self.anim.fadeout:SetChange(-1)
 438	self.anim.fadeout:SetOrder(1)
 439end
 440
 441local Flash = function(self, duration)
 442	if not self.anim then
 443		SetUpAnimGroup(self)
 444	end
 445
 446	self.anim.fadein:SetDuration(duration)
 447	self.anim.fadeout:SetDuration(duration)
 448	self.anim:Play()
 449end
 450
 451local StopFlash = function(self)
 452	if self.anim then
 453		self.anim:Finish()
 454	end
 455end
 456
 457T.SpawnMenu = function(self)
 458	local unit = self.unit:gsub("(.)", string.upper, 1)
 459	if unit == "Targettarget" or unit == "focustarget" or unit == "pettarget" then return end
 460
 461	if _G[unit.."FrameDropDown"] then
 462		ToggleDropDownMenu(1, nil, _G[unit.."FrameDropDown"], "cursor")
 463	elseif (self.unit:match("party")) then
 464		ToggleDropDownMenu(1, nil, _G["PartyMemberFrame"..self.id.."DropDown"], "cursor")
 465	else
 466		FriendsDropDown.unit = self.unit
 467		FriendsDropDown.id = self.id
 468		FriendsDropDown.initialize = RaidFrameDropDown_Initialize
 469		ToggleDropDownMenu(1, nil, FriendsDropDown, "cursor")
 470	end
 471end
 472
 473T.PostUpdatePower = function(element, unit, min, max)
 474	element:GetParent().Health:SetHeight(max ~= 0 and 20 or 22)
 475end
 476
 477local ShortValue = function(value)
 478	if value >= 1e6 then
 479		return ("%.1fm"):format(value / 1e6):gsub("%.?0+([km])$", "%1")
 480	elseif value >= 1e3 or value <= -1e3 then
 481		return ("%.1fk"):format(value / 1e3):gsub("%.?0+([km])$", "%1")
 482	else
 483		return value
 484	end
 485end
 486
 487local ShortValueNegative = function(v)
 488	if v <= 999 then return v end
 489	if v >= 1000000 then
 490		local value = string.format("%.1fm", v/1000000)
 491		return value
 492	elseif v >= 1000 then
 493		local value = string.format("%.1fk", v/1000)
 494		return value
 495	end
 496end
 497
 498T.PostUpdateHealth = function(health, unit, min, max)
 499	if not UnitIsConnected(unit) or UnitIsDead(unit) or UnitIsGhost(unit) then
 500		if not UnitIsConnected(unit) then
 501			health.value:SetText("|cffD7BEA5"..L.unitframes_ouf_offline.."|r")
 502		elseif UnitIsDead(unit) then
 503			health.value:SetText("|cffD7BEA5"..L.unitframes_ouf_dead.."|r")
 504		elseif UnitIsGhost(unit) then
 505			health.value:SetText("|cffD7BEA5"..L.unitframes_ouf_ghost.."|r")
 506		end
 507	else
 508		local r, g, b
 509		
 510	if C.unitframes.gradienthealth and C.unitframes.unicolor then
 511		local r, g, b = oUF.ColorGradient(min/max, unpack(C["unitframes"].gradient))
 512		health:SetStatusBarColor(r, g, b)
 513	end
 514	
 515	T.AuraFilter = function(icons, unit, icon, name, rank, texture, count, dtype, duration, timeLeft, caster, isStealable, shouldConsolidate, spellID)	
 516	local inInstance, instanceType = IsInInstance()
 517	icon.owner = caster
 518	icon.isStealable = isStealable
 519	
 520	if (unit and unit:find("arena%d")) then --Arena frames
 521		if dtype then
 522			if T.DebuffWhiteList[name] then
 523				return true
 524			else
 525				return false
 526			end			
 527		else
 528			if T.ArenaBuffWhiteList[name] then
 529				return true
 530			else
 531				return false
 532			end		
 533		end
 534	elseif unit == "target" or (unit and unit:find("boss%d")) then --Target/Boss Only
 535		if C["unitframes"].playerdebuffsonly == true then
 536			-- Show all debuffs on friendly targets
 537			if UnitIsFriend("player", "target") then return true end
 538			
 539			local isPlayer
 540			
 541			if(caster == 'player' or caster == 'vehicle') then
 542				isPlayer = true
 543			else
 544				isPlayer = false
 545			end
 546
 547			if isPlayer then
 548				return true
 549			elseif T.DebuffWhiteList[name] or (inInstance and ((instanceType == "pvp" or instanceType == "arena") and T.TargetPVPOnly[name])) then
 550				return true
 551			else
 552				return false
 553			end
 554		else
 555			return true
 556		end
 557	else --Everything else
 558		if unit ~= "player" and unit ~= "targettarget" and unit ~= "focus" and inInstance and (instanceType == "pvp" or instanceType == "arena") then
 559			if T.DebuffWhiteList[name] or T.TargetPVPOnly[name] then
 560				return true
 561			else
 562				return false
 563			end
 564		else
 565			if T.DebuffBlacklist[name] then
 566				return false
 567			else
 568				return true
 569			end
 570		end
 571	end
 572end	
 573		
 574		-- overwrite healthbar color for enemy player (a tukui option if enabled), target vehicle/pet too far away returning unitreaction nil and friend unit not a player. (mostly for overwrite tapped for friendly)
 575		-- I don't know if we really need to call C["unitframes"].unicolor but anyway, it's safe this way.
 576		if (C["unitframes"].unicolor ~= true and C["unitframes"].enemyhcolor and unit == "target" and UnitIsEnemy(unit, "player") and UnitIsPlayer(unit)) or (C["unitframes"].unicolor ~= true and unit == "target" and not UnitIsPlayer(unit) and UnitIsFriend(unit, "player")) then
 577			local c = T.oUF_colors.reaction[UnitReaction(unit, "player")]
 578			if c then 
 579				r, g, b = c[1], c[2], c[3]
 580				health:SetStatusBarColor(r, g, b)
 581			else
 582				-- if "c" return nil it's because it's a vehicle or pet unit too far away, we force friendly color
 583				-- this should fix color not updating for vehicle/pet too far away from yourself.
 584				r, g, b = 75/255,  175/255, 76/255
 585				health:SetStatusBarColor(r, g, b)
 586			end					
 587		end
 588
 589		if min ~= max then
 590			local r, g, b
 591			r, g, b = oUF.ColorGradient(min/max, 0.69, 0.31, 0.31, 0.65, 0.63, 0.35, 0.33, 0.59, 0.33)
 592			if unit == "player" and health:GetAttribute("normalUnit") ~= "pet" then
 593				if C["unitframes"].showtotalhpmp == true then
 594					health.value:SetFormattedText("|cff559655%s|r |cffD7BEA5|||r |cff559655%s|r", ShortValue(min), ShortValue(max))
 595				else
 596					health.value:SetFormattedText("|cffAF5050%d|r |cffD7BEA5-|r |cff%02x%02x%02x%d%%|r", min, r * 255, g * 255, b * 255, floor(min / max * 100))
 597				end
 598			elseif unit == "target" or (unit and unit:find("boss%d")) then
 599				if C["unitframes"].showtotalhpmp == true then
 600					health.value:SetFormattedText("|cff559655%s|r |cffD7BEA5|||r |cff559655%s|r", ShortValue(min), ShortValue(max))
 601				else
 602					health.value:SetFormattedText("|cffAF5050%s|r |cffD7BEA5-|r |cff%02x%02x%02x%d%%|r", ShortValue(min), r * 255, g * 255, b * 255, floor(min / max * 100))
 603				end
 604			elseif (unit and unit:find("arena%d")) or unit == "focus" or unit == "focustarget" then
 605				health.value:SetText("|cff559655"..ShortValue(min).."|r")
 606			else
 607				health.value:SetText("|cff559655-"..ShortValueNegative(max-min).."|r")
 608			end
 609		else
 610			if unit == "player" and health:GetAttribute("normalUnit") ~= "pet" then
 611				health.value:SetText("|cff559655"..max.."|r")
 612			elseif unit == "target" or unit == "focus"  or unit == "focustarget" or (unit and unit:find("arena%d")) then
 613				health.value:SetText("|cff559655"..ShortValue(max).."|r")
 614			else
 615				health.value:SetText(" ")
 616			end
 617		end
 618	end
 619end
 620
 621T.PostUpdateHealthRaid = function(health, unit, min, max)
 622	if not UnitIsConnected(unit) or UnitIsDead(unit) or UnitIsGhost(unit) then
 623		if not UnitIsConnected(unit) then
 624			health.value:SetText("|cffD7BEA5"..L.unitframes_ouf_offline.."|r")
 625		elseif UnitIsDead(unit) then
 626			health.value:SetText("|cffD7BEA5"..L.unitframes_ouf_dead.."|r")
 627		elseif UnitIsGhost(unit) then
 628			health.value:SetText("|cffD7BEA5"..L.unitframes_ouf_ghost.."|r")
 629		end
 630	else
 631		-- doing this here to force friendly unit (vehicle or pet) very far away from you to update color correcly
 632		-- because if vehicle or pet is too far away, unitreaction return nil and color of health bar is white.
 633		if not UnitIsPlayer(unit) and UnitIsFriend(unit, "player") and C["unitframes"].unicolor ~= true then
 634			local c = T.oUF_colors.reaction[5]
 635			local r, g, b = c[1], c[2], c[3]
 636			health:SetStatusBarColor(r, g, b)
 637			health.bg:SetTexture(.1, .1, .1)
 638		end
 639		
 640		if C.unitframes.gradienthealth and C.unitframes.unicolor then
 641			if not UnitIsConnected(unit) or UnitIsDead(unit) or UnitIsGhost(unit) then return end
 642			if not health.classcolored then
 643				local r, g, b = oUF.ColorGradient(min/max, unpack(C["unitframes"].gradient))
 644				health:SetStatusBarColor(r, g, b)
 645			end
 646		end
 647		
 648		if min ~= max then
 649			health.value:SetText("|cff559655-"..ShortValueNegative(max-min).."|r")
 650		else
 651			health.value:SetText(" ")
 652		end
 653	end
 654end
 655
 656T.PostUpdatePetColor = function(health, unit, min, max)
 657	-- doing this here to force friendly unit (vehicle or pet) very far away from you to update color correcly
 658	-- because if vehicle or pet is too far away, unitreaction return nil and color of health bar is white.
 659	if not UnitIsPlayer(unit) and UnitIsFriend(unit, "player") and C["unitframes"].unicolor ~= true then
 660		local c = T.oUF_colors.reaction[5]
 661		local r, g, b = c[1], c[2], c[3]
 662
 663		if health then health:SetStatusBarColor(r, g, b) end
 664		if health.bg then health.bg:SetTexture(.1, .1, .1) end
 665	end
 666end
 667
 668T.PostNamePosition = function(self)
 669	self.Name:ClearAllPoints()
 670	if (self.Power.value:GetText() and UnitIsEnemy("player", "target") and C["unitframes"].targetpowerpvponly == true) or (self.Power.value:GetText() and C["unitframes"].targetpowerpvponly == false) then
 671		self.Name:SetPoint("CENTER", health, "CENTER", 0, 3)
 672		 if C["unitframes"].style == "Smelly" then
 673            self.Name:SetPoint("CENTER", self.Health, "CENTER", 0, 3)
 674        end
 675	else
 676		self.Power.value:SetAlpha(0)
 677		self.Name:SetPoint("LEFT", self.Health, "LEFT", 4, 3)
 678	end
 679end
 680
 681T.PreUpdatePower = function(power, unit)
 682	local _, pType = UnitPowerType(unit)
 683	
 684	local color = T.oUF_colors.power[pType]
 685	if color then
 686		power:SetStatusBarColor(color[1], color[2], color[3])
 687	end
 688end
 689
 690T.PostUpdatePower = function(power, unit, min, max)
 691	local self = power:GetParent()
 692	local pType, pToken = UnitPowerType(unit)
 693	local color = T.oUF_colors.power[pToken]
 694
 695	if color then
 696		power.value:SetTextColor(color[1], color[2], color[3])
 697	end
 698
 699	if not UnitIsPlayer(unit) and not UnitPlayerControlled(unit) or not UnitIsConnected(unit) then
 700		power.value:SetText()
 701	elseif UnitIsDead(unit) or UnitIsGhost(unit) then
 702		power.value:SetText()
 703	else
 704		if min ~= max then
 705			if pType == 0 then
 706				if unit == "target" then
 707					if C["unitframes"].showtotalhpmp == true then
 708						power.value:SetFormattedText("%s |cffD7BEA5|||r %s", ShortValue(max - (max - min)), ShortValue(max))
 709					else
 710						power.value:SetFormattedText("%d%% |cffD7BEA5-|r %s", floor(min / max * 100), ShortValue(max - (max - min)))
 711					end
 712				elseif unit == "player" and self:GetAttribute("normalUnit") == "pet" or unit == "pet" then
 713					if C["unitframes"].showtotalhpmp == true then
 714						power.value:SetFormattedText("%s |cffD7BEA5|||r %s", ShortValue(max - (max - min)), ShortValue(max))
 715					else
 716						power.value:SetFormattedText("%d%%", floor(min / max * 100))
 717					end
 718				elseif (unit and unit:find("arena%d")) or unit == "focus" or unit == "focustarget" then
 719					power.value:SetText(ShortValue(min))
 720				else
 721					if C["unitframes"].showtotalhpmp == true then
 722						power.value:SetFormattedText("%s |cffD7BEA5|||r %s", ShortValue(max - (max - min)), ShortValue(max))
 723					else
 724						power.value:SetFormattedText("%d%% |cffD7BEA5-|r %d", floor(min / max * 100), max - (max - min))
 725					end
 726				end
 727			else
 728				power.value:SetText(max - (max - min))
 729			end
 730		else
 731			if unit == "pet" or unit == "target" or unit == "focus" or unit == "focustarget" or (unit and unit:find("arena%d")) then
 732				power.value:SetText(ShortValue(min))
 733			else
 734				power.value:SetText(min)
 735			end
 736		end
 737	end
 738	if self.Name then
 739		if unit == "target" then T.PostNamePosition(self, power) end
 740	end
 741end
 742
 743T.CustomCastTimeText = function(self, duration)
 744	self.Time:SetText(("%.1f / %.1f"):format(self.channeling and duration or self.max - duration, self.max))
 745end
 746
 747T.CustomCastDelayText = function(self, duration)
 748	self.Time:SetText(("%.1f |cffaf5050%s %.1f|r"):format(self.channeling and duration or self.max - duration, self.channeling and "- " or "+", self.delay))
 749end
 750
 751local FormatTime = function(s)
 752	local day, hour, minute = 86400, 3600, 60
 753	if s >= day then
 754		return format("%dd", ceil(s / day))
 755	elseif s >= hour then
 756		return format("%dh", ceil(s / hour))
 757	elseif s >= minute then
 758		return format("%dm", ceil(s / minute))
 759	elseif s >= minute / 12 then
 760		return floor(s)
 761	end
 762	return format("%.1f", s)
 763end
 764
 765local CreateAuraTimer = function(self, elapsed)
 766	if self.timeLeft then
 767		self.elapsed = (self.elapsed or 0) + elapsed
 768		if self.elapsed >= 0.1 then
 769			if not self.first then
 770				self.timeLeft = self.timeLeft - self.elapsed
 771			else
 772				self.timeLeft = self.timeLeft - GetTime()
 773				self.first = false
 774			end
 775			if self.timeLeft > 0 then
 776				local time = FormatTime(self.timeLeft)
 777				self.remaining:SetText(time)
 778				if self.timeLeft <= 5 then
 779					self.remaining:SetTextColor(0.99, 0.31, 0.31)
 780				else
 781					self.remaining:SetTextColor(1, 1, 1)
 782				end
 783			else
 784				self.remaining:Hide()
 785				self:SetScript("OnUpdate", nil)
 786			end
 787			self.elapsed = 0
 788		end
 789	end
 790end
 791
 792T.PostCreateAura = function(element, button)
 793	button:SetTemplate("Default")
 794	
 795	button.remaining = T.SetFontString(button, C["media"].font, C["unitframes"].auratextscale, "THINOUTLINE")
 796	button.remaining:Point("CENTER", 1, 0)
 797	
 798	button.cd.noOCC = true		 	-- hide OmniCC CDs
 799	button.cd.noCooldownCount = true	-- hide CDC CDs
 800	
 801	button.cd:SetReverse()
 802	button.icon:Point("TOPLEFT", 2, -2)
 803	button.icon:Point("BOTTOMRIGHT", -2, 2)
 804	button.icon:SetTexCoord(0.08, 0.92, 0.08, 0.92)
 805	button.icon:SetDrawLayer('ARTWORK')
 806	
 807	button.count:Point("BOTTOMRIGHT", 3, 3)
 808	button.count:SetJustifyH("RIGHT")
 809	button.count:SetFont(C["media"].font, 9, "THICKOUTLINE")
 810	button.count:SetTextColor(0.84, 0.75, 0.65)
 811	
 812	button.overlayFrame = CreateFrame("frame", nil, button, nil)
 813	button.cd:SetFrameLevel(button:GetFrameLevel() + 1)
 814	button.cd:ClearAllPoints()
 815	button.cd:Point("TOPLEFT", button, "TOPLEFT", 2, -2)
 816	button.cd:Point("BOTTOMRIGHT", button, "BOTTOMRIGHT", -2, 2)
 817	button.overlayFrame:SetFrameLevel(button.cd:GetFrameLevel() + 1)	   
 818	button.overlay:SetParent(button.overlayFrame)
 819	button.count:SetParent(button.overlayFrame)
 820	button.remaining:SetParent(button.overlayFrame)
 821			
 822	button.Glow = CreateFrame("Frame", nil, button)
 823	button.Glow:Point("TOPLEFT", button, "TOPLEFT", -3, 3)
 824	button.Glow:Point("BOTTOMRIGHT", button, "BOTTOMRIGHT", 3, -3)
 825	button.Glow:SetFrameStrata("BACKGROUND")	
 826	button.Glow:SetBackdrop{edgeFile = C["media"].glowTex, edgeSize = 3, insets = {left = 0, right = 0, top = 0, bottom = 0}}
 827	button.Glow:SetBackdropColor(0, 0, 0, 0)
 828	button.Glow:SetBackdropBorderColor(0, 0, 0)
 829end
 830
 831T.PostUpdateAura = function(icons, unit, icon, index, offset, filter, isDebuff, duration, timeLeft)
 832	local _, _, _, _, dtype, duration, expirationTime, unitCaster, _ = UnitAura(unit, index, icon.filter)
 833
 834	if(icon.debuff) then
 835		if(not UnitIsFriend("player", unit) and icon.owner ~= "player" and icon.owner ~= "vehicle") then
 836			icon:SetBackdropBorderColor(unpack(C["media"].bordercolor))
 837			icon.icon:SetDesaturated(true)
 838		else
 839			local color = DebuffTypeColor[dtype] or DebuffTypeColor.none
 840			icon:SetBackdropBorderColor(color.r * 0.6, color.g * 0.6, color.b * 0.6)
 841			icon.icon:SetDesaturated(false)
 842		end
 843	else
 844		if (isStealable or ((T.myclass == "MAGE" or T.myclass == "PRIEST" or T.myclass == "SHAMAN") and dtype == "Magic")) and not UnitIsFriend("player", unit) then
 845			icon:SetBackdropBorderColor(1, 0.85, 0, 1)
 846		else
 847			icon:SetBackdropBorderColor(unpack(C.media.bordercolor))
 848		end
 849	end
 850	
 851	if duration and duration > 0 then
 852		if C["unitframes"].auratimer == true then
 853			icon.remaining:Show()
 854		else
 855			icon.remaining:Hide()
 856		end
 857	else
 858		icon.remaining:Hide()
 859	end
 860 
 861	icon.duration = duration
 862	icon.timeLeft = expirationTime
 863	icon.first = true
 864	icon:SetScript("OnUpdate", CreateAuraTimer)
 865end
 866
 867T.HidePortrait = function(self, unit)
 868	if self.unit == "target" then
 869		if not UnitExists(self.unit) or not UnitIsConnected(self.unit) or not UnitIsVisible(self.unit) then
 870			self.Portrait:SetAlpha(0)
 871		else
 872			self.Portrait:SetAlpha(1)
 873		end
 874	end
 875end
 876
 877T.PortraitUpdate = function(self, unit)
 878	--Fucking Furries
 879	if self:GetModel() and self:GetModel().find and self:GetModel():find("worgenmale") then
 880		self:SetCamera(1)
 881	end
 882end
 883
 884-- jasje castbar
 885T.PostCastStart = function(self, unit, name, rank, castid)
 886	if unit == "vehicle" then unit = "player" end
 887	--Fix blank castbar with opening text
 888	if name == "Opening" then
 889		self.Text:SetText("Opening")
 890	end
 891
 892	if self.interrupt and unit ~= "player" then
 893		if UnitCanAttack("player", unit) then
 894			self:SetStatusBarColor(unpack(C["castbar"].nointerruptcolor))
 895		else
 896			self:SetStatusBarColor(unpack(C["castbar"].nointerruptcolor))	
 897		end
 898	else
 899        if C["castbar"].classcolor and (unit == "player" or unit == "target") then
 900            self:SetStatusBarColor(unpack(oUF.colors.class[select(2, UnitClass(unit))]))
 901        else
 902            self:SetStatusBarColor(unpack(C["castbar"].castbarcolor))
 903        end
 904	end
 905end
 906
 907T.UpdateShards = function(self, event, unit, powerType)
 908	if(self.unit ~= unit or (powerType and powerType ~= 'SOUL_SHARDS')) then return end
 909	local num = UnitPower(unit, SPELL_POWER_SOUL_SHARDS)
 910	for i = 1, SHARD_BAR_NUM_SHARDS do
 911		if(i <= num) then
 912			self.SoulShards[i]:SetAlpha(1)
 913		else
 914			self.SoulShards[i]:SetAlpha(.2)
 915		end
 916	end
 917end
 918
 919T.Phasing = function(self, event)
 920	local inPhase = UnitInPhase(self.unit)
 921	local picon = self.PhaseIcon
 922
 923	if not UnitIsPlayer(self.unit) then picon:Hide() return end
 924
 925	-- TO BE COMPLETED
 926end
 927
 928T.UpdateHoly = function(self, event, unit, powerType)
 929	if(self.unit ~= unit or (powerType and powerType ~= 'HOLY_POWER')) then return end
 930	local num = UnitPower(unit, SPELL_POWER_HOLY_POWER)
 931	for i = 1, MAX_HOLY_POWER do
 932		if(i <= num) then
 933			self.HolyPower[i]:SetAlpha(1)
 934		else
 935			self.HolyPower[i]:SetAlpha(.2)
 936		end
 937	end
 938end
 939
 940T.EclipseDirection = function(self)
 941	if ( GetEclipseDirection() == "sun" ) then
 942			self.Text:SetText("|cffE5994C"..L.unitframes_ouf_starfirespell.."|r")
 943	elseif ( GetEclipseDirection() == "moon" ) then
 944			self.Text:SetText("|cff4478BC"..L.unitframes_ouf_wrathspell.."|r")
 945	else
 946			self.Text:SetText("")
 947	end
 948end
 949
 950T.DruidBarDisplay = function(self, login)
 951	local eb = self.EclipseBar
 952	local dm = self.DruidMana
 953	local txt = self.EclipseBar.Text
 954	local shadow = self.shadow
 955	local bg = self.DruidManaBackground
 956	local buffs = self.Buffs
 957	local flash = self.FlashInfo
 958
 959	if login then
 960		dm:SetScript("OnUpdate", nil)
 961	end
 962	
 963	if eb:IsShown() or dm:IsShown() then
 964		if eb:IsShown() then
 965			txt:Show()
 966			flash:Hide()
 967		end
 968		--self.shadow:Point("TOPLEFT", -4, 12)
 969		bg:SetAlpha(1)
 970		if T.lowversion then
 971			if buffs then buffs:SetPoint("TOPLEFT", self, "TOPLEFT", 0, 34) end
 972		else
 973			if buffs then buffs:SetPoint("TOPLEFT", self, "TOPLEFT", 0, 38) end
 974		end				
 975	else
 976		txt:Hide()
 977		flash:Show()
 978		--self.shadow:Point("TOPLEFT", -4, 4)
 979		bg:SetAlpha(0)
 980		if T.lowversion then
 981			if buffs then buffs:SetPoint("TOPLEFT", self, "TOPLEFT", 0, 26) end
 982		else
 983			if buffs then buffs:SetPoint("TOPLEFT", self, "TOPLEFT", 0, 30) end
 984		end
 985	end
 986end
 987
 988T.MLAnchorUpdate = function (self)
 989	if self.Leader:IsShown() then
 990		self.MasterLooter:SetPoint("TOPLEFT", 14, 8)
 991	else
 992		self.MasterLooter:SetPoint("TOPLEFT", 2, 8)
 993	end
 994end
 995
 996T.UpdateReputationColor = function(self, event, unit, bar)
 997	local name, id = GetWatchedFactionInfo()
 998	bar:SetStatusBarColor(FACTION_BAR_COLORS[id].r, FACTION_BAR_COLORS[id].g, FACTION_BAR_COLORS[id].b)
 999end
1000
1001T.UpdateName = function(self,event)
1002	if self.Name then self.Name:UpdateTag(self.unit) end
1003end
1004
1005local UpdateManaLevelDelay = 0
1006T.UpdateManaLevel = function(self, elapsed)
1007	UpdateManaLevelDelay = UpdateManaLevelDelay + elapsed
1008	if self.parent.unit ~= "player" or UpdateManaLevelDelay < 0.2 or UnitIsDeadOrGhost("player") or UnitPowerType("player") ~= 0 then return end
1009	UpdateManaLevelDelay = 0
1010
1011	local percMana = UnitMana("player") / UnitManaMax("player") * 100
1012
1013	if percMana <= C.unitframes.lowThreshold then
1014		self.ManaLevel:SetText("|cffaf5050"..L.unitframes_ouf_lowmana.."|r")
1015		Flash(self, 0.3)
1016	else
1017		self.ManaLevel:SetText()
1018		StopFlash(self)
1019	end
1020end
1021
1022T.UpdateDruidMana = function(self)
1023	if self.unit ~= "player" then return end
1024
1025	local num, str = UnitPowerType("player")
1026	if num ~= 0 then
1027		local min = UnitPower("player", 0)
1028		local max = UnitPowerMax("player", 0)
1029
1030		local percMana = min / max * 100
1031		if percMana <= C["unitframes"].lowThreshold then
1032			self.FlashInfo.ManaLevel:SetText("|cffaf5050"..L.unitframes_ouf_lowmana.."|r")
1033			Flash(self.FlashInfo, 0.3)
1034		else
1035			self.FlashInfo.ManaLevel:SetText()
1036			StopFlash(self.FlashInfo)
1037		end
1038
1039		if min ~= max then
1040			if self.Power.value:GetText() then
1041				self.DruidManaText:SetPoint("LEFT", self.Power.value, "RIGHT", 1, 0)
1042				self.DruidManaText:SetFormattedText("|cffD7BEA5-|r  |cff4693FF%d%%|r|r", floor(min / max * 100))
1043			else
1044				self.DruidManaText:SetPoint("LEFT", self.panel,  "LEFT", 4, 1)
1045				self.DruidManaText:SetFormattedText("%d%%", floor(min / max * 100))
1046			end
1047		else
1048			self.DruidManaText:SetText()
1049		end
1050
1051		self.DruidManaText:SetAlpha(1)
1052	else
1053		self.DruidManaText:SetAlpha(0)
1054	end
1055end
1056
1057T.UpdateThreat = function(self, event, unit)
1058	if (self.unit ~= unit) or (unit == "target" or unit == "pet" or unit == "focus" or unit == "focustarget" or unit == "targettarget") then return end
1059	local threat = UnitThreatSituation(self.unit)
1060	if (threat == 3) then
1061		if self.HealthBorder then
1062			self.HealthBorder:SetBackdropBorderColor(5 ,0, 0,1)
1063		else
1064			self.Name:SetTextColor(1,0.1,0.1)
1065		end
1066	else
1067		if self.HealthBorder then
1068			self.HealthBorder:SetBackdropBorderColor(unpack(C["media"].bordercolor))
1069		else
1070			self.Name:SetTextColor(1,1,1)
1071		end
1072	end 
1073end
1074
1075-- AuraTracker Function
1076	function updateAuraTrackerTime(self, elapsed)
1077	if (self.active) then
1078		self.timeleft = self.timeleft - elapsed
1079
1080		if (self.timeleft <= 5) then
1081			self.text:SetTextColor(1, 0, 0)
1082		else
1083			self.text:SetTextColor(1, 1, 1)
1084		end
1085		
1086		if (self.timeleft <= 0) then
1087			self.icon:SetTexture("")
1088			self.text:SetText("")
1089		end	
1090		self.text:SetFormattedText("%.1f", self.timeleft)
1091	end
1092end
1093
1094--------------------------------------------------------------------------------------------
1095-- THE AURAWATCH FUNCTION ITSELF. HERE BE DRAGONS!
1096--------------------------------------------------------------------------------------------
1097
1098T.countOffsets = {
1099	TOPLEFT = {6*C["unitframes"].gridscale, 1},
1100	TOPRIGHT = {-6*C["unitframes"].gridscale, 1},
1101	BOTTOMLEFT = {6*C["unitframes"].gridscale, 1},
1102	BOTTOMRIGHT = {-6*C["unitframes"].gridscale, 1},
1103	LEFT = {6*C["unitframes"].gridscale, 1},
1104	RIGHT = {-6*C["unitframes"].gridscale, 1},
1105	TOP = {0, 0},
1106	BOTTOM = {0, 0},
1107}
1108
1109T.CreateAuraWatchIcon = function(self, icon)
1110	icon:SetTemplate("Default")
1111	icon.icon:Point("TOPLEFT", 1, -1)
1112	icon.icon:Point("BOTTOMRIGHT", -1, 1)
1113	icon.icon:SetTexCoord(.08, .92, .08, .92)
1114	icon.icon:SetDrawLayer("ARTWORK")
1115	if (icon.cd) then
1116		icon.cd:SetReverse()
1117	end
1118	icon.overlay:SetTexture()
1119end
1120
1121T.createAuraWatch = function(self, unit)
1122	local auras = CreateFrame("Frame", nil, self)
1123	auras:SetPoint("TOPLEFT", self.Health, 2, -2)
1124	auras:SetPoint("BOTTOMRIGHT", self.Health, -2, 2)
1125	auras.presentAlpha = 1
1126	auras.missingAlpha = 0
1127	auras.icons = {}
1128	auras.PostCreateIcon = T.CreateAuraWatchIcon
1129
1130	if (not C["unitframes"].auratimer) then
1131		auras.hideCooldown = true
1132	end
1133
1134	local buffs = {}
1135
1136	if (T.buffids["ALL"]) then
1137		for key, value in pairs(T.buffids["ALL"]) do
1138			tinsert(buffs, value)
1139		end
1140	end
1141
1142	if (T.buffids[T.myclass]) then
1143		for key, value in pairs(T.buffids[T.myclass]) do
1144			tinsert(buffs, value)
1145		end
1146	end
1147
1148	-- "Cornerbuffs"
1149	if (buffs) then
1150		for key, spell in pairs(buffs) do
1151			local icon = CreateFrame("Frame", nil, auras)
1152			icon.spellID = spell[1]
1153			icon.anyUnit = spell[4]
1154			icon:Width(6*C["unitframes"].gridscale)
1155			icon:Height(6*C["unitframes"].gridscale)
1156			icon:SetPoint(spell[2], 0, 0)
1157
1158			local tex = icon:CreateTexture(nil, "OVERLAY")
1159			tex:SetAllPoints(icon)
1160			tex:SetTexture(C.media.blank)
1161			if (spell[3]) then
1162				tex:SetVertexColor(unpack(spell[3]))
1163			else
1164				tex:SetVertexColor(0.8, 0.8, 0.8)
1165			end
1166
1167			local count = icon:CreateFontString(nil, "OVERLAY")
1168			count:SetFont(C["media"].uffont, 8*C["unitframes"].gridscale, "THINOUTLINE")
1169			count:SetPoint("CENTER", unpack(T.countOffsets[spell[2]]))
1170			icon.count = count
1171
1172			auras.icons[spell[1]] = icon
1173		end
1174	end
1175	
1176	self.AuraWatch = auras
1177end
1178
1179if C["unitframes"].raidunitdebuffwatch == true then
1180	-- Classbuffs { spell ID, position [, {r,g,b,a}][, anyUnit] }
1181	-- For oUF_AuraWatch
1182	do
1183		T.buffids = {
1184			PRIEST = {
1185				{6788, "TOPLEFT", {1, 0, 0}, true}, -- Weakened Soul
1186				{33076, "TOPRIGHT", {0.2, 0.7, 0.2}}, -- Prayer of Mending
1187				{139, "BOTTOMLEFT", {0.4, 0.7, 0.2}}, -- Renew
1188				{17, "BOTTOMRIGHT", {0.81, 0.85, 0.1}, true}, -- Power Word: Shield
1189			},
1190			DRUID = {
1191				{774, "TOPLEFT", {0.8, 0.4, 0.8}}, -- Rejuvenation
1192				{8936, "TOPRIGHT", {0.2, 0.8, 0.2}}, -- Regrowth
1193				{33763, "BOTTOMLEFT", {0.4, 0.8, 0.2}}, -- Lifebloom
1194				{48438, "BOTTOMRIGHT", {0.8, 0.4, 0}}, -- Wild Growth
1195			},
1196			PALADIN = {
1197				{53563, "TOPLEFT", {0.7, 0.3, 0.7}}, -- Beacon of Light
1198			},
1199			SHAMAN = {
1200				{61295, "TOPLEFT", {0.7, 0.3, 0.7}}, -- Riptide 
1201				{51945, "TOPRIGHT", {0.2, 0.7, 0.2}}, -- Earthliving
1202				{16177, "BOTTOMLEFT", {0.4, 0.7, 0.2}}, -- Ancestral Fortitude
1203				{974, "BOTTOMRIGHT", {0.7, 0.4, 0}, true}, -- Earth Shield
1204			},
1205			ALL = {
1206				{14253, "RIGHT", {0, 1, 0}}, -- Abolish Poison
1207				{23333, "LEFT", {1, 0, 0}}, -- Warsong flag xD
1208			},
1209		}
1210	end
1211		local _, ns = ...
1212	-- Raid debuffs (now using it with oUF_RaidDebuff instead of oUF_Aurawatch)
1213	do
1214		local ORD = ns.oUF_RaidDebuffs or oUF_RaidDebuffs
1215
1216		if not ORD then return end
1217		
1218		ORD.ShowDispelableDebuff = true
1219		ORD.FilterDispellableDebuff = true
1220		ORD.MatchBySpellName = true
1221		
1222		local function SpellName(id)
1223			local name, _, _, _, _, _, _, _, _ = GetSpellInfo(id) 	
1224			return name	
1225		end
1226
1227		T.debuffids = {
1228		-- Other debuff
1229			SpellName(67479), -- Impale
1230
1231		--CATA DEBUFFS
1232		--Baradin Hold
1233			SpellName(95173), -- Consuming Darkness
1234
1235		--Blackwing Descent
1236			--Magmaw
1237			SpellName(91911), -- Constricting Chains
1238			SpellName(94679), -- Parasitic Infection
1239			SpellName(94617), -- Mangle
1240
1241			--Omintron Defense System
1242			SpellName(79835), --Poison Soaked Shell
1243			SpellName(91433), --Lightning Conductor
1244			SpellName(91521), --Incineration Security Measure
1245
1246			--Maloriak
1247			SpellName(77699), -- Flash Freeze
1248			SpellName(77760), -- Biting Chill
1249
1250			--Atramedes
1251			SpellName(92423), -- Searing Flame
1252			SpellName(92485), -- Roaring Flame
1253			SpellName(92407), -- Sonic Breath
1254
1255			--Chimaeron
1256			SpellName(82881), -- Break
1257			SpellName(89084), -- Low Health
1258
1259			--Nefarian
1260
1261			--Sinestra
1262			SpellName(92956), --Wrack
1263
1264		--The Bastion of Twilight
1265			--Valiona & Theralion
1266			SpellName(92878), -- Blackout
1267			SpellName(86840), -- Devouring Flames
1268			SpellName(95639), -- Engulfing Magic
1269
1270			--Halfus Wyrmbreaker
1271			SpellName(39171), -- Malevolent Strikes
1272
1273			--Twilight Ascendant Council
1274			SpellName(92511), -- Hydro Lance
1275			SpellName(82762), -- Waterlogged
1276			SpellName(92505), -- Frozen
1277			SpellName(92518), -- Flame Torrent
1278			SpellName(83099), -- Lightning Rod
1279			SpellName(92075), -- Gravity Core
1280			SpellName(92488), -- Gravity Crush
1281
1282			--Cho'gall
1283			SpellName(86028), -- Cho's Blast
1284			SpellName(86029), -- Gall's Blast
1285
1286		--Throne of the Four Winds
1287			--Conclave of Wind
1288				--Nezir <Lord of the North Wind>
1289				SpellName(93131), --Ice Patch
1290				--Anshal <Lord of the West Wind>
1291				SpellName(86206), --Soothing Breeze
1292				SpellName(93122), --Toxic Spores
1293				--Rohash <Lord of the East Wind>
1294				SpellName(93058), --Slicing Gale
1295			--Al'Akir
1296			SpellName(93260), -- Ice Storm
1297			SpellName(93295), -- Lightning Rod
1298
1299		-- Firelands, thanks Kaelhan :)
1300			-- Beth'tilac
1301				SpellName(99506),	-- Widows Kiss
1302				SpellName(97202),	-- Fiery Web Spin
1303				SpellName(49026),	-- Fixate
1304				SpellName(97079),	-- Seeping Venom
1305			-- Lord Rhyolith
1306				-- none, hehe, fake boss
1307			-- Alysrazor
1308				SpellName(101296),	-- Fieroblast
1309				SpellName(100723),	-- Gushing Wound
1310				SpellName(99389),	-- Imprinted
1311				SpellName(101729),	-- Blazing Claw
1312			-- Shannox
1313				SpellName(99837),	-- Crystal Prison
1314				SpellName(99937),	-- Jagged Tear
1315			-- Baleroc
1316				SpellName(99256),	-- Torment
1317				SpellName(99403),	-- Tormented
1318				SpellName(99252),	-- Blaze of Glory
1319				SpellName(99516),	-- Countdown
1320			-- Majordomo Staghelm
1321				SpellName(98450),	-- Searing Seeds
1322			-- Ragnaros
1323				SpellName(99399),	-- Burning Wound
1324				SpellName(100293),	-- Lava Wave
1325				SpellName(98313),	-- Magma Blast
1326				SpellName(100675),	-- Dreadflame
1327		}
1328
1329		T.ReverseTimer = {
1330			[92956] = true, -- Sinestra (Wrack)
1331		},
1332		
1333		ORD:RegisterDebuffs(T.debuffids)
1334	end
1335end