From 8dcb62ec8183f155207df9334dc1a8f89af3755a Mon Sep 17 00:00:00 2001 From: NoM0Re Date: Wed, 22 Jan 2025 18:56:11 +0100 Subject: [PATCH] from retail --- WeakAuras/AuraEnvironment.lua | 2 +- WeakAuras/Prototypes.lua | 4 +-- WeakAuras/RegionTypes/Icon.lua | 6 ++-- WeakAuras/RegionTypes/ProgressTexture.lua | 5 +++ WeakAuras/RegionTypes/RegionPrototype.lua | 5 ++- WeakAuras/WeakAuras.lua | 39 ++++++++--------------- 6 files changed, 29 insertions(+), 32 deletions(-) diff --git a/WeakAuras/AuraEnvironment.lua b/WeakAuras/AuraEnvironment.lua index dd90435..c33e78e 100644 --- a/WeakAuras/AuraEnvironment.lua +++ b/WeakAuras/AuraEnvironment.lua @@ -328,7 +328,7 @@ function Private.ActivateAuraEnvironment(id, cloneId, state, states, onlyConfig) local childData = WeakAuras.GetData(childID) if childData then if not environment_initialized[childID] then - Private.ActivateAuraEnvironment(childID) + Private.ActivateAuraEnvironment(childID, nil, nil, nil, true) Private.ActivateAuraEnvironment() end current_aura_env.child_envs[dataIndex] = aura_environments[childID] diff --git a/WeakAuras/Prototypes.lua b/WeakAuras/Prototypes.lua index a593455..e4031ef 100644 --- a/WeakAuras/Prototypes.lua +++ b/WeakAuras/Prototypes.lua @@ -4655,14 +4655,14 @@ Private.event_prototypes = { }, { name = "icon", - init = "GetItemIcon(itemName)", + init = "GetItemIcon(itemName or '')", hidden = true, store = true, test = "true" }, { name = "name", - init = "itemName", + init = "itemName and itemName ~= '' and GetItemIcon(itemName) or itemName", hidden = true, store = true, test = "true" diff --git a/WeakAuras/RegionTypes/Icon.lua b/WeakAuras/RegionTypes/Icon.lua index 98df008..c50baed 100644 --- a/WeakAuras/RegionTypes/Icon.lua +++ b/WeakAuras/RegionTypes/Icon.lua @@ -453,16 +453,16 @@ local function modify(parent, region, data) end function region:SetInverse(inverse) - if region.inverse == inverse then + if region.inverseDirection == inverse then return end - region.inverse = inverse + region.inverseDirection = inverse region:UpdateEffectiveInverse() end function region:UpdateEffectiveInverse() -- If cooldown.inverse == false then effectiveReverse = not inverse -- If cooldown.inverse == true then effectiveReverse = inverse - local effectiveReverse = not region.inverse == not cooldown.inverse + local effectiveReverse = not region.inverseDirection == not cooldown.inverse cooldown:SetReverse(effectiveReverse) if (cooldown.expirationTime and cooldown.duration and cooldown:IsShown()) then -- WORKAROUND SetReverse not applying until next frame diff --git a/WeakAuras/RegionTypes/ProgressTexture.lua b/WeakAuras/RegionTypes/ProgressTexture.lua index 44f1887..385d582 100644 --- a/WeakAuras/RegionTypes/ProgressTexture.lua +++ b/WeakAuras/RegionTypes/ProgressTexture.lua @@ -903,6 +903,11 @@ local function modify(parent, region, data) else region:SetValueOnTexture(progress); end + + if self.FrameTick then + self.FrameTick = nil + self.subRegionEvents:RemoveSubscriber("FrameTick", region) + end end if region.useSmoothProgress then diff --git a/WeakAuras/RegionTypes/RegionPrototype.lua b/WeakAuras/RegionTypes/RegionPrototype.lua index edc9c18..2f4b574 100644 --- a/WeakAuras/RegionTypes/RegionPrototype.lua +++ b/WeakAuras/RegionTypes/RegionPrototype.lua @@ -428,8 +428,11 @@ local function UpdateProgressFromState(self, minMaxConfig, state, progressSource else adjustMin = 0 end + local max - if minMaxConfig.adjustedMax then + if duration == 0 then + max = 0 + elseif minMaxConfig.adjustedMax then max = minMaxConfig.adjustedMax elseif minMaxConfig.adjustedMaxRelPercent then max = minMaxConfig.adjustedMaxRelPercent * duration diff --git a/WeakAuras/WeakAuras.lua b/WeakAuras/WeakAuras.lua index 9ecfeae..21cf752 100644 --- a/WeakAuras/WeakAuras.lua +++ b/WeakAuras/WeakAuras.lua @@ -2592,7 +2592,14 @@ function WeakAuras.PreAdd(data) Private.validate(data, oldDataStub2) end - local default = data.regionType and Private.regionTypes[data.regionType] and Private.regionTypes[data.regionType].default + local ok = pcall(Private.Modernize, data) + if not ok then + Private.GetErrorHandlerId(data.id, L["Modernize"]) + end + + local default = data.regionType and + Private.regionTypes[data.regionType] and + Private.regionTypes[data.regionType].default if default then Private.validate(data, default) end @@ -2602,7 +2609,6 @@ function WeakAuras.PreAdd(data) regionValidate(data) end - Private.Modernize(data); Private.validate(data, Private.data_stub); if data.subRegions then for _, subRegionData in ipairs(data.subRegions) do @@ -2915,40 +2921,19 @@ local function EnsureRegion(id) Private.regions[id] = Private.regions[id] or {} -- The region doesn't yet exist -- But we must also ensure that our parents exists - -- and as an additional wrinkle, for dynamic groups, all children must exist! - -- and we have to call ReloadControlledChildren at the end -- So we go up the list of parents and collect auras that must be created -- If we find a parent already exists, we can stop - -- And dynamic groups require creating all children, thus we don't need - -- to care which path we came to them local aurasToCreate = {} - local dynamicGroups = {} - creatingRegions = true while(id) do local data = WeakAuras.GetData(id) - if (data.regionType == "dynamicgroup") then - wipe(aurasToCreate) - tinsert(aurasToCreate, data.id) - tinsert(dynamicGroups, data.id) - else - tinsert(aurasToCreate, data.id) - end + tinsert(aurasToCreate, data.id) id = data.parent end + for _, toCreateId in ipairs_reverse(aurasToCreate) do local data = WeakAuras.GetData(toCreateId) Private.SetRegion(data) - if (data.regionType == "dynamicgroup") then - for child in Private.TraverseAllChildren(data) do - Private.SetRegion(child) - end - end - end - creatingRegions = false - for _, dynamicGroupId in ipairs_reverse(dynamicGroups) do - local dgRegion = Private.regions[dynamicGroupId].region - dgRegion:ReloadControlledChildren() end end return Private.regions[id] and Private.regions[id].region @@ -4059,6 +4044,10 @@ local function startStopTimers(id, cloneId, triggernum, state) stopAutoHideTimer(id, triggernum, cloneId) return else + if state.expirationTime == nil and type(state.duration) == "number" then + -- Set the expiration time, because users rely on that, even though it's wrong to do + state.expirationTime = GetTime() + state.duration + end expirationTime = state.expirationTime end elseif type(state.autoHide) == "number" then