diff --git a/WeakAuras/GenericTrigger.lua b/WeakAuras/GenericTrigger.lua index 798ab56..f914fb9 100644 --- a/WeakAuras/GenericTrigger.lua +++ b/WeakAuras/GenericTrigger.lua @@ -3370,8 +3370,30 @@ do if not castLatencyFrame then castLatencyFrame = CreateFrame("Frame") castLatencyFrame:RegisterEvent("CURRENT_SPELL_CAST_CHANGED") - castLatencyFrame:SetScript("OnEvent", function(event) - Private.LAST_CURRENT_SPELL_CAST_CHANGED = GetTime() + castLatencyFrame:RegisterEvent("UNIT_SPELLCAST_START") + castLatencyFrame:RegisterEvent("UNIT_SPELLCAST_CHANNEL_START") + + castLatencyFrame:RegisterEvent("UNIT_SPELLCAST_STOP") + castLatencyFrame:RegisterEvent("UNIT_SPELLCAST_CHANNEL_STOP") + castLatencyFrame:RegisterEvent("UNIT_SPELLCAST_INTERRUPTED") + + castLatencyFrame:SetScript("OnEvent", function(self, event, unit) + if unit and unit ~= "player" then return end + if event == "UNIT_SPELLCAST_START" then + Private.LAST_CURRENT_SPELL_CAST_START = select(4, UnitCastingInfo("player")) / 1000 + elseif event == "UNIT_SPELLCAST_CHANNEL_START" then + Private.LAST_CURRENT_SPELL_CAST_START = select(4, UnitChannelInfo("player")) / 1000 + elseif event == "CURRENT_SPELL_CAST_CHANGED" then + -- We want to store the CURRENT_SPELL_CAST_CHANGED time + -- that was the last before the actual START event + -- This prevents updating the CURRENT_SPELL_CAST_CHANGED time after + -- we got the start time + if not Private.LAST_CURRENT_SPELL_CAST_START then + Private.LAST_CURRENT_SPELL_CAST_CHANGED = GetTime() + end + else -- STOP EVENTS + Private.LAST_CURRENT_SPELL_CAST_START = nil + end end) end end diff --git a/WeakAuras/Init.lua b/WeakAuras/Init.lua index ea3c50c..d80616e 100644 --- a/WeakAuras/Init.lua +++ b/WeakAuras/Init.lua @@ -8,7 +8,7 @@ WeakAuras.halfWidth = WeakAuras.normalWidth / 2 WeakAuras.doubleWidth = WeakAuras.normalWidth * 2 local versionStringFromToc = GetAddOnMetadata("WeakAuras", "Version") -local versionString = "4.1.2" +local versionString = "4.1.5" local buildTime = "20240701180000" local isAwesomeEnabled = C_NamePlate and C_NamePlate.GetNamePlateForUnit or false diff --git a/WeakAuras/Prototypes.lua b/WeakAuras/Prototypes.lua index f9bfb33..27e7cb5 100644 --- a/WeakAuras/Prototypes.lua +++ b/WeakAuras/Prototypes.lua @@ -97,11 +97,6 @@ function WeakAuras.SpellSchool(school) return Private.combatlog_spell_school_types[school] or "" end -function WeakAuras.TestSchool(spellSchool, test) - print(spellSchool, test, type(spellSchool), type(test)) - return spellSchool == test -end - function WeakAuras.RaidFlagToIndex(flag) return Private.combatlog_raidFlags[flag] or 0 end @@ -6256,8 +6251,8 @@ Private.event_prototypes = { { name = L["Latency"], func = function(trigger, state) - if not state.expirationTime or not state.duration then return 0, 0 end - return 0, (state.expirationTime - state.duration) - (Private.LAST_CURRENT_SPELL_CAST_CHANGED or 0) + if not Private.LAST_CURRENT_SPELL_CAST_START or not Private.LAST_CURRENT_SPELL_CAST_CHANGED then return 0, 0 end + return 0, Private.LAST_CURRENT_SPELL_CAST_START - Private.LAST_CURRENT_SPELL_CAST_CHANGED end, enable = function(trigger) return trigger.use_showLatency and trigger.unit == "player" diff --git a/WeakAuras/WeakAuras.lua b/WeakAuras/WeakAuras.lua index a60f7b6..6a59b76 100644 --- a/WeakAuras/WeakAuras.lua +++ b/WeakAuras/WeakAuras.lua @@ -1082,6 +1082,7 @@ function Private.Login(initialTime, takeNewSnapshots) print("|cFF8800FFWeakAuras|r detected a corrupt entry in WeakAuras saved displays - '"..tostring(id).."' vs '"..tostring(data.id).."'" ); data.id = id; end + tinsert(toAdd, data); end coroutine.yield(); @@ -2119,26 +2120,39 @@ function Private.SyncParentChildRelationships(silent) end end -function WeakAuras.AddMany(table, takeSnapshots) - local idtable = {}; - for _, data in ipairs(table) do - idtable[data.id] = data; - end +local function loadOrder(tbl, idtable) + local order = {} + local loaded = {}; local function load(id, depends) local data = idtable[id]; if(data.parent) then if(idtable[data.parent]) then - if(tContains(depends, data.parent)) then + if depends[data.parent] then + -- There was an unfortunate bug in update.lua in 2022 that resulted + -- in auras having a circular dependencies + -- Fix one of the two known cases here + -- We can probably remove this code in 2023 again + for d in pairs(depends) do + local uid = idtable[d].uid + if uid == "fjtz3A6LwBW" then -- Fojji - Deathknight UI, need to fixup a lot + local cycleRoot = d + idtable[cycleRoot].parent = nil + for d in pairs(depends) do + tDeleteItem(idtable[d].controlledChildren, cycleRoot) + end + return loadOrder(tbl, idtable) + end + coroutine.yield() + end error("Circular dependency in WeakAuras.AddMany between "..table.concat(depends, ", ")); else if not(loaded[data.parent]) then - local dependsOut = {}; - for i,v in pairs(depends) do - dependsOut[i] = v; - end - tinsert(dependsOut, data.parent); - load(data.parent, dependsOut); + local dependsOut = CopyTable(depends) + dependsOut[data.parent] = true + coroutine.yield() + load(data.parent, dependsOut) + coroutine.yield() end end else @@ -2146,14 +2160,38 @@ function WeakAuras.AddMany(table, takeSnapshots) end end if not(loaded[id]) then - WeakAuras.Add(data, takeSnapshots); coroutine.yield(); loaded[id] = true; + tinsert(order, idtable[id]) end end - local groups = {} + for id, data in pairs(idtable) do load(id, {}); + coroutine.yield() + end + return order +end + +function WeakAuras.AddMany(tbl, takeSnapshots) + local idtable = {}; + for _, data in ipairs(tbl) do + -- There was an unfortunate bug in update.lua in 2022 that resulted + -- in auras having a circular dependencies + -- Fix one of the two known cases here + if data.id == data.parent then + data.parent = nil + tDeleteItem(data.controlledChildren, data.id) + end + idtable[data.id] = data; + end + + local order = loadOrder(tbl, idtable) + coroutine.yield() + local groups = {} + for _, data in ipairs(order) do + WeakAuras.Add(data, takeSnapshots); + coroutine.yield() if data.regionType == "dynamicgroup" or data.regionType == "group" then groups[data] = true end diff --git a/WeakAuras/WeakAuras.toc b/WeakAuras/WeakAuras.toc index 61e6760..e0e01f8 100644 --- a/WeakAuras/WeakAuras.toc +++ b/WeakAuras/WeakAuras.toc @@ -1,7 +1,7 @@ ## Interface: 30300 ## Title: WeakAuras ## Author: The WeakAuras Team -## Version: 4.1.2 +## Version: 4.1.5 ## Notes: A powerful, comprehensive utility for displaying graphics and information based on buffs, debuffs, and other triggers. ## Notes-esES: Potente y completa aplicación que te permitirá mostrar por pantalla múltiples diseños, basados en beneficios, perjuicios y otros activadores. ## Notes-deDE: Ein leistungsfähiges, umfassendes Addon zur grafischen Darstellung von Informationen von Auren, Cooldowns, Timern und vielem mehr. diff --git a/WeakAurasOptions/InformationOptions.lua b/WeakAurasOptions/InformationOptions.lua index 73ed612..1de2680 100644 --- a/WeakAurasOptions/InformationOptions.lua +++ b/WeakAurasOptions/InformationOptions.lua @@ -255,7 +255,7 @@ function OptionsPrivate.GetInformationOptions(data) order = order + 1 args.debugLogDesc = { type = "description", - name = L["This enables the collection of debug logs. This requires custom coded auras that use DebugPrints."], + name = L["This enables the collection of debug logs. Custom code can add debug information to the log through the function DebugPrint."], width = WeakAuras.doubleWidth, order = order, } diff --git a/WeakAurasOptions/OptionsFrames/Update.lua b/WeakAurasOptions/OptionsFrames/Update.lua index ef73763..67abe32 100644 --- a/WeakAurasOptions/OptionsFrames/Update.lua +++ b/WeakAurasOptions/OptionsFrames/Update.lua @@ -620,6 +620,14 @@ local function BuildUidMap(data, children, type) return self.map[uid].parent end + uidMap.UnsetParent = function(self, uid) + if not self.map[uid] then + error("GetParent for unknown uid") + return + end + self.map[uid].parent = nil + end + uidMap.GetParentIsDynamicGroup = function(self, uid) if not self.map[uid] then error("GetParentIsDynamicGroup for unknown uid") @@ -1527,14 +1535,20 @@ local methods = { self:SetMinimumProgress(1 * onePhaseProgress) coroutine.yield() - if userChoices.activeCategories.oldchildren then - self:RemoveUnmatchedOld(matchInfo.oldUidMap, matchInfo.oldUidMap:GetRootUID()) + local removeOldGroups = matchInfo.activeCategories.arrangement and userChoices.activeCategories.arrangement + if userChoices.activeCategories.oldchildren or removeOldGroups then + self:RemoveUnmatchedOld(matchInfo.oldUidMap, matchInfo.oldUidMap:GetRootUID(), matchInfo.newUidMap, + userChoices.activeCategories.oldchildren, + removeOldGroups) end self:SetMinimumProgress(2 * onePhaseProgress) - if not userChoices.activeCategories.newchildren then - self:RemoveUnmatchedNew(matchInfo.newUidMap, matchInfo.newUidMap:GetRootUID()) + local removeNewGroups = matchInfo.activeCategories.arrangement and not userChoices.activeCategories.arrangement + if userChoices.activeCategories.newchildren or removeNewGroups then + self:RemoveUnmatchedNew(matchInfo.newUidMap, matchInfo.newUidMap:GetRootUID(), matchInfo.oldUidMap, + userChoices.activeCategories.newchildren, + removeNewGroups) end self:SetMinimumProgress(3 * onePhaseProgress) @@ -1731,7 +1745,7 @@ local methods = { coroutine.yield() return changed end, - RemoveUnmatchedOld = function(self, uidMap, uid) + RemoveUnmatchedOld = function(self, uidMap, uid, otherMap, removeAuras, removeGroups) if uidMap:GetType() ~= "old" then error("Wrong map for delete") end @@ -1739,8 +1753,8 @@ local methods = { local children = uidMap:GetChildren(uid) local removedAllChildren = true for index, childUid in ipairs_reverse(children) do - local removed = self:RemoveUnmatchedOld(uidMap, childUid) - if not removed then + local removed = self:RemoveUnmatchedOld(uidMap, childUid, otherMap, removeAuras, removeGroups) + if not removed and not uidMap:GetUIDMatch(childUid) then removedAllChildren = false end end @@ -1751,21 +1765,28 @@ local methods = { error("Can't remove root") end - local data = OptionsPrivate.Private.GetDataByUID(uid) - if not data then - error("Can't find data") + if (uidMap:GetGroupRegionType(uid) and removeGroups) + or (uidMap:GetGroupRegionType(uid) == nil and removeAuras) + then + for index, childUid in ipairs_reverse(children) do + uidMap:UnsetParent(childUid) + end + local data = OptionsPrivate.Private.GetDataByUID(uid) + if not data then + error("Can't find data") + end + WeakAuras.Delete(data) + uidMap:Remove(uid) + self:IncProgress() + coroutine.yield() + return true end - WeakAuras.Delete(data) - uidMap:Remove(uid) - self:IncProgress() - coroutine.yield() - return true end self:IncProgress() coroutine.yield() return false end, - RemoveUnmatchedNew = function(self, uidMap, uid) + RemoveUnmatchedNew = function(self, uidMap, uid, otherMap, removeAuras, removeGroups) if uidMap:GetType() ~= "new" then error("Wrong map for delete") end @@ -1773,8 +1794,8 @@ local methods = { local children = uidMap:GetChildren(uid) local removedAllChildren = true for index, childUid in ipairs_reverse(children) do - local removed = self:RemoveUnmatchedNew(uidMap, childUid) - if not removed then + local removed = self:RemoveUnmatchedNew(uidMap, childUid, otherMap, removeAuras, removeGroups) + if not removed and not uidMap:GetUIDMatch(childUid) then removedAllChildren = false end end @@ -1785,10 +1806,17 @@ local methods = { error("Can't remove root") end - uidMap:Remove(uid) - self:IncProgress() - coroutine.yield() - return true + if (uidMap:GetGroupRegionType(uid) and removeGroups) + or (uidMap:GetGroupRegionType(uid) == nil and removeAuras) + then + for index, childUid in ipairs_reverse(children) do + uidMap:UnsetParent(childUid) + end + uidMap:Remove(uid) + self:IncProgress() + coroutine.yield() + return true + end end self:IncProgress() coroutine.yield() diff --git a/WeakAurasOptions/WeakAurasOptions.toc b/WeakAurasOptions/WeakAurasOptions.toc index 922f7ca..fb47c2e 100644 --- a/WeakAurasOptions/WeakAurasOptions.toc +++ b/WeakAurasOptions/WeakAurasOptions.toc @@ -1,7 +1,7 @@ ## Interface: 30300 ## Title: WeakAuras Options ## Author: The WeakAuras Team -## Version: 4.1.2 +## Version: 4.1.5 ## Notes: Options for WeakAuras ## Notes-esES: Opciones para WeakAuras ## Notes-deDE: Optionen für WeakAuras