Loading...

ElvUI Power Backdrop Color after newest update

#1
I used this code as an addon to change my power backdrop color before, but now it does not work anymore. If someone would be kind enough to take a look and if possible, fix it, I would be very grateful! :)

Code: Select all

-- This file is loaded from "ElvUI_PowerBackdrop.toc"

local E = unpack(ElvUI)
local UF = E:GetModule("UnitFrames")
local function PostUpdatePower(self, unit, _, _, max)
	local parent = self.origParent or self:GetParent()

	if parent.isForced then
		local pType = random(0, 4)
		local color = ElvUF['colors'].power[tokens[pType]]
		local min = random(1, max)
		self:SetValue(min)

		if not self.colorClass then
			self:SetStatusBarColor(color[1], color[2], color[3])
			local mu = self.bg.multiplier or 1
			self.bg:SetVertexColor(color[1] * mu, color[2] * mu, color[3] * mu)
		end
	end

	local db = parent.db
	if db and db.power and db.power.hideonnpc then
		UF:PostNamePosition(parent, unit)
	end

	--Force update to AdditionalPower in order to reposition text if necessary
	if parent:IsElementEnabled("AdditionalPower") then
		E:Delay(0.01, parent.AdditionalPower.ForceUpdate, parent.AdditionalPower) --Delay it slightly so Power text has a chance to clear itself first
	end
	
	--Custom Edit To Color Below
	self.bg:SetVertexColor(0,0,0)
end

local f = CreateFrame("Frame")
f:RegisterEvent("PLAYER_ENTERING_WORLD")
f:SetScript("OnEvent", function(self, event)
	self:UnregisterEvent(event)

	--Set modified PostUpdate
	ElvUF_Focus.Power.PostUpdate = PostUpdatePower
	ElvUF_Target.Power.PostUpdate = PostUpdatePower
	ElvUF_Player.Power.PostUpdate = PostUpdatePower

	--Set black backdrop
	ElvUF_Focus.Power.backdrop:SetBackdropColor(0, 0, 0)
	ElvUF_Target.Power.backdrop:SetBackdropColor(0, 0, 0)
	ElvUF_Player.Power.backdrop:SetBackdropColor(0, 0, 0)
end)

Who is online

Users browsing this forum: No registered users and 1 guest