Skip to content

Commit

Permalink
fix: icon fade animations not working on condition icons
Browse files Browse the repository at this point in the history
  • Loading branch information
ascott18 committed Jul 12, 2024
1 parent 85a1219 commit b3c166a
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions Components/IconTypes/IconType_conditionicon/conditionicon.lua
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,19 @@ Type:UsesAttributes("state_conditionFailed")
Type:UsesAttributes("texture")
-- END AUTOMATICALLY GENERATED: UsesAttributes

-- Not automatically generated, but still needed.
Type:UsesAttributes("conditionFailed", false)

-- Condition icons handle their own opacity for succeeded/failed.
-- If we allowed conditionFailed to be set,
-- it'd briefly set the icon to an opacity that can't
-- be configured by the user, which breaks the icon alpha fade condition.
Type:UsesAttributes("conditionFailed", false)
local Hook = TMW.Classes.IconDataProcessorHook:New("CONDITION_SUPPRESS", "CONDITION")
Hook:RegisterCompileFunctionSegmentHook("pre", function(Processor, t)
-- GLOBALS: conditionFailed
t[#t+1] = [[
if icon.Type == "conditionicon" then conditionFailed = nil end
--]]
end)


Type:RegisterIconDefaults{
Expand Down Expand Up @@ -136,19 +146,16 @@ local function ConditionIcon_OnUpdate(icon, time)
state = 0
end

-- We set state_conditionFailed to override the automatic state handling of ConditionObjects.
-- We want to set the alpha on our own (though the icon's state).
icon:SetInfo(
"state_conditionFailed; state; start, duration",
nil,
"state; start, duration",
state,
start, duration
)

-- Record the passing state of the icon's condition object so we can detect when it changes.
icon.__succeeded = succeeded
else
icon:SetInfo("state_conditionFailed; state", nil, STATE_SUCCEED)
icon:SetInfo("state", STATE_SUCCEED)
end
end

Expand All @@ -159,11 +166,12 @@ end

function Type:Setup(icon)
icon:SetInfo("texture", "Interface\\Icons\\INV_Misc_QuestionMark")

icon:SetInfo("state_conditionFailed", nil)

-- Icon updates will automatically get scheduled by the icon update engine
-- when the icon's condition object changes and schedules an icon update.
-- So we don't need to register any events at all, and we can update manually!

icon:SetUpdateMethod("manual")

icon:SetUpdateFunction(ConditionIcon_OnUpdate)
Expand Down

0 comments on commit b3c166a

Please sign in to comment.