Replace Trigger:SetState by Trigger:SetStateAndData

Update the use of the old API in most triggers except AuraTrigger. This
means the code isn't in a working state at this commit.
This commit is contained in:
omicron committed 2026-06-25 21:58:04 +02:00
1 parent 86e5ed78b0
commit 8be0732930
3 files changed
+23 -12

No files matched your search

+4 -7
View File
@@ -92,8 +92,7 @@ function MultiTrigger:OnChildActivate(idx, trigger, data)
table.sort(activeChildren) table.sort(activeChildren)
-- The highest priority active trigger has changed -- The highest priority active trigger has changed
if activeChild ~= activeChildren[1] then if activeChild ~= activeChildren[1] then
self:SetData(data) self:SetStateAndData(true, data)
self:SetState(true, true)
end end
end end
@@ -117,11 +116,9 @@ function MultiTrigger:OnChildDeactivate(idx, trigger, data)
local newActiveChild = activeChildren[1] local newActiveChild = activeChildren[1]
if activeChild ~= newActiveChild then if activeChild ~= newActiveChild then
if activeChildren[1] ~= nil then if activeChildren[1] ~= nil then
self:SetData(childrenData[newActiveChild]) self:SetStateAndData(true, childrenData[newActiveChild])
self:SetState(true, true)
else else
self:SetData({}) self:SetStateAndData(false, {})
self:SetState(false, false)
end end
end end
end end
@@ -139,5 +136,5 @@ end
-- Reset the trigger to the default state. If this changes the activation of the -- Reset the trigger to the default state. If this changes the activation of the
-- trigger then the target will be notified. -- trigger then the target will be notified.
function MultiTrigger:Reset() function MultiTrigger:Reset()
self:SetState(false) self:SetStateAndData(false, {})
end end
+1 -1
View File
@@ -58,5 +58,5 @@ end
-- status: -- status:
-- Must be a valid UnitAuraInfo -- Must be a valid UnitAuraInfo
function StatusTrigger:UpdateStatus(count) function StatusTrigger:UpdateStatus(count)
self:SetState(count >= self.requiredCount, false) self:SetStateAndData(count >= self.requiredCount, nil)
end end
+18 -4
View File
@@ -47,7 +47,9 @@ function Trigger:Init(invert, defaultData)
end end
---Save new data from the datasource into the trigger. This method will make ---Save new data from the datasource into the trigger. This method will make
---sure the default data is always present ---sure the default data is always present. This method will not ensure the
---target gets notified of new state or new data. Subclasses of Trigger should
---use Trigger:SetStateAndData instead.
---@param data table ---@param data table
function Trigger:SetData(data) function Trigger:SetData(data)
if self.defaultData then if self.defaultData then
@@ -69,9 +71,21 @@ function Trigger:SetTarget(target)
end end
end end
---Set the state of the trigger. Will activate the indicator if needed. ---Set the data and state of the trigger. Will update the trigger as needed.
---
--- If the state changes this function will call Show or Hide on the indicator.
--- If the state remains the same and the data is not nil, it will call Update
--- on the indicator.
---
---@param state boolean ---@param state boolean
function Trigger:SetState(state, doUpdate) ---@param data table|nil
function Trigger:SetStateAndData(state, data)
local doUpdate = false
if data then
doUpdate = true
self:SetData(data)
end
state = state ~= self.invert -- state xor inverted state = state ~= self.invert -- state xor inverted
if self.active ~= state then if self.active ~= state then
if state then if state then
@@ -88,5 +102,5 @@ end
-- Reset the trigger to the default state. If this changes the activation of the -- Reset the trigger to the default state. If this changes the activation of the
-- trigger then the target will be notified. -- trigger then the target will be notified.
function Trigger:Reset() function Trigger:Reset()
self:SetState(false, false) self:SetStateAndData(false, nil)
end end