Skip to content

Commit

Permalink
[Bugfix] Fix OOR Alpha not updating properly when changing appearances
Browse files Browse the repository at this point in the history
  • Loading branch information
Krealle committed Sep 1, 2024
1 parent 33380e4 commit 49efaae
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
7 changes: 5 additions & 2 deletions UnitFrames/OnLoad.lua
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ local DEFAULT_HARM_SPELLS = {

---@param self CUFUnitButton
---@param ir boolean?
local function UnitFrame_UpdateInRange(self, ir)
---@param forceUpdate boolean?
local function UnitFrame_UpdateInRange(self, ir, forceUpdate)
local unit = self.states.displayedUnit
if not unit then return end

Expand All @@ -52,7 +53,7 @@ local function UnitFrame_UpdateInRange(self, ir)

self.states.inRange = inRange
if Cell.loaded then
if self.states.inRange ~= self.states.wasInRange then
if self.states.inRange ~= self.states.wasInRange or forceUpdate then
if inRange then
if CELL_FADE_OUT_HEALTH_PERCENT then
if not self.states.healthPercent or self.states.healthPercent < CELL_FADE_OUT_HEALTH_PERCENT then
Expand Down Expand Up @@ -517,6 +518,8 @@ function CUFUnitButton_OnLoad(button)
and not widget._isEnabled
end

button.UpdateInRange = UnitFrame_UpdateInRange

-- script
button:SetScript("OnAttributeChanged", UnitFrame_OnAttributeChanged) -- init
button:HookScript("OnShow", UnitFrame_OnShow)
Expand Down
5 changes: 5 additions & 0 deletions UnitFrames/UnitButton.lua
Original file line number Diff line number Diff line change
Expand Up @@ -390,5 +390,10 @@ local function UpdateAppearance(kind)
button:SetBackdropColor(0, 0, 0, CellDB["appearance"]["bgAlpha"])
end)
end
if not kind or kind == "outOfRangeAlpha" then
Util:IterateAllUnitButtons(function(button)
button:UpdateInRange(nil, true)
end)
end
end
CUF:RegisterCallback("UpdateAppearance", "UpdateAppearance", UpdateAppearance)

0 comments on commit 49efaae

Please sign in to comment.