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 authored and Andreas Rudén committed 2026-10-29 09:28:48 +01:00
1 parent 80859c1e44
commit b9f1bad81d
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)
-- The highest priority active trigger has changed
if activeChild ~= activeChildren[1] then
self:SetData(data)
self:SetState(true, true)
self:SetStateAndData(true, data)
end
end
@@ -117,11 +116,9 @@ function MultiTrigger:OnChildDeactivate(idx, trigger, data)
local newActiveChild = activeChildren[1]
if activeChild ~= newActiveChild then
if activeChildren[1] ~= nil then
self:SetData(childrenData[newActiveChild])
self:SetState(true, true)
self:SetStateAndData(true, childrenData[newActiveChild])
else
self:SetData({})
self:SetState(false, false)
self:SetStateAndData(false, {})
end
end
end
@@ -139,5 +136,5 @@ end
-- Reset the trigger to the default state. If this changes the activation of the
-- trigger then the target will be notified.
function MultiTrigger:Reset()
self:SetState(false)
self:SetStateAndData(false, {})
end
+1 -1
View File
@@ -58,5 +58,5 @@ end
-- status:
-- Must be a valid UnitAuraInfo
function StatusTrigger:UpdateStatus(count)
self:SetState(count >= self.requiredCount, false)
self:SetStateAndData(count >= self.requiredCount, nil)
end
+18 -4
View File
@@ -47,7 +47,9 @@ function Trigger:Init(invert, defaultData)
end
---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
function Trigger:SetData(data)
if self.defaultData then
@@ -69,9 +71,21 @@ function Trigger:SetTarget(target)
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
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
if self.active ~= state then
if state then
@@ -88,5 +102,5 @@ end
-- Reset the trigger to the default state. If this changes the activation of the
-- trigger then the target will be notified.
function Trigger:Reset()
self:SetState(false, false)
self:SetStateAndData(false, nil)
end