From db45573d1c47528de2dd2805c950454995d7800a Mon Sep 17 00:00:00 2001 From: NoM0Re Date: Thu, 16 Jan 2025 22:58:42 +0100 Subject: [PATCH] from retail --- WeakAuras/BossMods.lua | 25 ++++- WeakAuras/GenericTrigger.lua | 104 ++++++++++-------- WeakAuras/Modernize.lua | 11 ++ WeakAuras/Prototypes.lua | 30 +++++ WeakAuras/RegionTypes/DynamicGroup.lua | 7 +- WeakAuras/Transmission.lua | 15 ++- WeakAuras/WeakAuras.lua | 4 +- .../AceGUIWidget-WeakAurasDisplayButton.lua | 1 + WeakAurasOptions/OptionsFrames/Update.lua | 27 +++++ WeakAurasOptions/WeakAurasOptions.lua | 1 + 10 files changed, 172 insertions(+), 53 deletions(-) diff --git a/WeakAuras/BossMods.lua b/WeakAuras/BossMods.lua index 023ed91..c4da07c 100644 --- a/WeakAuras/BossMods.lua +++ b/WeakAuras/BossMods.lua @@ -156,11 +156,11 @@ Private.ExecEnv.BossMods.DBM = { EventCallback = function(self, event, ...) if event == "DBM_Announce" then - local spellId = select(4, ...) - WeakAuras.ScanEvents("DBM_Announce", spellId, ...) + local message, icon, _, spellId, _, count = ... + WeakAuras.ScanEvents("DBM_Announce", spellId, message, icon) if self.isGeneric then - local message, icon = ... - WeakAuras.ScanEvents("BossMod_Announce", spellId, message, icon) + count = count and tostring(count) or "0" + WeakAuras.ScanEvents("BossMod_Announce", spellId, message, icon, count) end elseif event == "DBM_TimerStart" then local timerId, msg, duration, icon, timerType, spellId, dbmType, _, _, _, _, _, timerCount = ... @@ -812,7 +812,8 @@ Private.ExecEnv.BossMods.BigWigs = { WeakAuras.ScanEvents("BigWigs_Message", ...) if self.isGeneric then local _, spellId, text, _, icon = ... - WeakAuras.ScanEvents("BossMod_Announce", spellId, text, icon) + local count = text and text:match("%((%d+)%)") or text:match("((%d+))") or "0" + WeakAuras.ScanEvents("BossMod_Announce", spellId, text, icon, count) end elseif event == "BigWigs_StartBar" then local addon, spellId, text, duration, icon, isCD = ... @@ -1434,6 +1435,20 @@ Private.event_prototypes["Boss Mod Announce"] = { hidden = true, test = "true" }, + { + name = "count", + init = "arg", + display = L["Count"], + desc = L["Occurrence of the event\nCan be a range of values\nCan have multiple values separated by a comma or a space\n\nExamples:\n2nd 5th and 6th events: 2, 5, 6\n2nd to 6th: 2-6\nevery 2 events: /2\nevery 3 events starting from 2nd: 2/3\nevery 3 events starting from 2nd and ending at 11th: 2-11/3\n\nWorks only if Boss Mod addon show counter"], + type = "string", + preamble = "local counter = Private.ExecEnv.CreateTriggerCounter(%q)", + test = "counter:SetCount(tonumber(count) or 0) == nil and counter:Match()", + conditionTest = function(state, needle, op, preamble) + return preamble:Check(state.count) + end, + store = true, + conditionType = "string", + }, { name = "cloneId", display = L["Clone per Event"], diff --git a/WeakAuras/GenericTrigger.lua b/WeakAuras/GenericTrigger.lua index 7292a41..9a7d756 100644 --- a/WeakAuras/GenericTrigger.lua +++ b/WeakAuras/GenericTrigger.lua @@ -712,17 +712,6 @@ local function RunTriggerFunc(allStates, data, id, triggernum, event, arg1, arg2 untriggerCheck = true; end elseif (data.statesParameter == "unit") then - if optionsEvent then - if Private.multiUnitUnits[data.trigger.unit] then - arg1 = next(Private.multiUnitUnits[data.trigger.unit]) - elseif data.trigger.unit == "nameplate" then - arg1 = next(C_NamePlate.GetNamePlates()) - else - arg1 = data.trigger.unit - end - elseif event == "FRAME_UPDATE" and (not Private.multiUnitUnits[data.trigger.unit] or data.trigger.unit ~= "nameplate") then - arg1 = data.trigger.unit - end if arg1 then if Private.multiUnitUnits[data.trigger.unit] or data.trigger.unit == "nameplate" then unitForUnitTrigger = arg1 @@ -1014,7 +1003,12 @@ function Private.ScanEventsWatchedTrigger(id, watchedTriggernums) Private.ActivateAuraEnvironment(nil) end -local function AddFakeTime(state) +local function AddFakeInformation(state, eventData) + state.autoHide = false + local canHaveDuration = eventData.prototype and eventData.prototype.canHaveDuration == "timed" + if canHaveDuration and state.expirationTime == nil then + state.progressType = "timed" + end if state.progressType == "timed" then if state.expirationTime and state.expirationTime ~= math.huge and state.expirationTime > GetTime() then return @@ -1023,38 +1017,50 @@ local function AddFakeTime(state) state.expirationTime = GetTime() + 7 state.duration = 7 end + if eventData.prototype and eventData.prototype.GetNameAndIcon then + local name, icon = Private.event_prototypes[eventData.event].GetNameAndIcon(eventData.trigger) + if state.name == nil then + state.name = name + end + if state.icon == nil then + state.icon = icon + end + end end function GenericTrigger.CreateFakeStates(id, triggernum) local data = WeakAuras.GetData(id) + local eventData = events[id][triggernum] Private.ActivateAuraEnvironment(id); local allStates = WeakAuras.GetTriggerStateForTrigger(id, triggernum); - RunTriggerFunc(allStates, events[id][triggernum], id, triggernum, "OPTIONS") - local canHaveDuration = events[id][triggernum].prototype and events[id][triggernum].prototype.canHaveDuration == "timed" + local arg1 + if eventData.statesParameter == "unit" then + local unit = eventData.trigger.unit + if Private.multiUnitUnits[unit] then + arg1 = next(Private.multiUnitUnits[unit]) + else + arg1 = unit + end + end + RunTriggerFunc(allStates, eventData, id, triggernum, "OPTIONS", arg1) local shown = 0 for id, state in pairs(allStates) do if state.show then shown = shown + 1 end - state.autoHide = false - if canHaveDuration and state.expirationTime == nil then - state.progressType = "timed" - end - AddFakeTime(state) + + AddFakeInformation(state, eventData) end if shown == 0 then local state = {} GenericTrigger.CreateFallbackState(data, triggernum, state) allStates[""] = state - state.autoHide = false - if canHaveDuration and state.expirationTime == nil then - state.progressType = "timed" - end - AddFakeTime(state) + + AddFakeInformation(state, eventData) end Private.ActivateAuraEnvironment(nil); @@ -3558,7 +3564,7 @@ end function GenericTrigger.GetDelay(data) if data.event then local prototype = Private.event_prototypes[data.event] - if prototype and prototype.delayEvents then + if prototype and prototype.type == data.type and prototype.delayEvents then local trigger = data.trigger if trigger.use_delay and type(trigger.delay) == "number" and trigger.delay > 0 then return trigger.delay @@ -3649,11 +3655,15 @@ function GenericTrigger.GetNameAndIcon(data, triggernum) local icon, name if (Private.category_event_prototype[trigger.type]) then if(trigger.event and Private.event_prototypes[trigger.event]) then - if(Private.event_prototypes[trigger.event].iconFunc) then - icon = Private.event_prototypes[trigger.event].iconFunc(trigger); - end - if(Private.event_prototypes[trigger.event].nameFunc) then - name = Private.event_prototypes[trigger.event].nameFunc(trigger); + if (Private.event_prototypes[trigger.event].GetNameAndIcon) then + return Private.event_prototypes[trigger.event].GetNameAndIcon(trigger) + else + if(Private.event_prototypes[trigger.event].iconFunc) then + icon = Private.event_prototypes[trigger.event].iconFunc(trigger); + end + if(Private.event_prototypes[trigger.event].nameFunc) then + name = Private.event_prototypes[trigger.event].nameFunc(trigger); + end end end end @@ -3983,22 +3993,28 @@ function GenericTrigger.CreateFallbackState(data, triggernum, state) Private.ActivateAuraEnvironment(data.id, "", state); local trigger = data.triggers[triggernum].trigger - if (event.nameFunc) then - local ok, name = pcall(event.nameFunc, trigger); + + if event.GetNameAndIcon then + local ok, name, icon = pcall(event.GetNameAndIcon, trigger); + state.name = ok and name or nil; + state.icon = ok and icon or nil; if not ok then - Private.GetErrorHandlerUid(data.uid, L["Name Function (fallback state)"]) - state.name = nil - else - state.name = name or nil + Private.GetErrorHandlerUid(data.uid, L["GetNameAndIcon Function (fallback state)"]) end - end - if (event.iconFunc) then - local ok, icon = pcall(event.iconFunc, trigger); - if not ok then - Private.GetErrorHandlerUid(data.uid, L["Icon Function (fallback state)"]) - state.icon = nil - else - state.icon = icon or nil + else + if (event.nameFunc) then + local ok, name = pcall(event.nameFunc, trigger); + state.name = ok and name or nil; + if not ok then + Private.GetErrorHandlerUid(data.uid, L["Name Function (fallback state)"]) + end + end + if (event.iconFunc) then + local ok, icon = pcall(event.iconFunc, trigger); + state.icon = ok and icon or nil; + if not ok then + Private.GetErrorHandlerUid(data.uid, L["Icon Function (fallback state)"]) + end end end diff --git a/WeakAuras/Modernize.lua b/WeakAuras/Modernize.lua index cde1b76..07bff87 100644 --- a/WeakAuras/Modernize.lua +++ b/WeakAuras/Modernize.lua @@ -1453,5 +1453,16 @@ function Private.Modernize(data) end end + if data.internalVersion < 68 then + if data.parent then + local parentData = WeakAuras.GetData(data.parent) + if parentData and parentData.regionType == "dynamicgroup" then + if data.anchorFrameParent == nil then + data.anchorFrameParent = false + end + end + end + end + data.internalVersion = max(data.internalVersion or 0, WeakAuras.InternalVersion()) end diff --git a/WeakAuras/Prototypes.lua b/WeakAuras/Prototypes.lua index 6f1927c..8408ad7 100644 --- a/WeakAuras/Prototypes.lua +++ b/WeakAuras/Prototypes.lua @@ -5980,6 +5980,36 @@ Private.event_prototypes = { end }, }, + GetNameAndIcon = function(trigger) + local name, icon, spellId, _ + if trigger.use_spellNames and type(trigger.spellNames) == "table" then + for _, spellName in ipairs(trigger.spellNames) do + spellId = WeakAuras.SafeToNumber(spellName) + if spellId then + name, _, icon = GetSpellInfo(spellName) + if name and icon then + return name, icon + end + elseif not tonumber(spellName) then + name, _, icon = GetSpellInfo(spellName) + if name and icon then + return name, icon + end + end + end + end + if trigger.use_spellIds and type(trigger.spellIds) == "table" then + for _, spellIdString in ipairs(trigger.spellIds) do + spellId = WeakAuras.SafeToNumber(spellIdString) + if spellId then + name, _, icon = GetSpellInfo(spellIdString) + if name and icon then + return name, icon + end + end + end + end + end, automaticrequired = true, }, ["Character Stats"] = { diff --git a/WeakAuras/RegionTypes/DynamicGroup.lua b/WeakAuras/RegionTypes/DynamicGroup.lua index 7e591ff..f3a3e1b 100644 --- a/WeakAuras/RegionTypes/DynamicGroup.lua +++ b/WeakAuras/RegionTypes/DynamicGroup.lua @@ -1365,7 +1365,12 @@ local function modify(parent, region, data) end controlPoint:SetWidth(regionData.dimensions.width) controlPoint:SetHeight(regionData.dimensions.height) - if data.anchorFrameParent then + if (data.anchorFrameParent + or data.anchorFrameParent == nil) + and not (data.anchorFrameType == "SCREEN" + or data.anchorFrameType == "UIPARENT" + or data.anchorFrameType == "MOUSE") + and not data.useAnchorPerUnit then controlPoint:SetParent(frame == "" and self.relativeTo or frame) else controlPoint:SetParent(self) diff --git a/WeakAuras/Transmission.lua b/WeakAuras/Transmission.lua index 692edea..f0ca9b6 100644 --- a/WeakAuras/Transmission.lua +++ b/WeakAuras/Transmission.lua @@ -485,6 +485,20 @@ function WeakAuras.Import(inData, target, callbackFunc) return nil, "Invalid import data." end + --[[ + local highestVersion = data.internalVersion or 0 + if children then + for _, child in ipairs(children) do + highestVersion = max(highestVersion, child.internalVersion or 0) + end + end + if highestVersion > WeakAuras.InternalVersion() then + -- Do not run PreAdd but still show Import Window + tooltipLoading = nil; + return ImportNow(data, children, target, nil, callbackFunc) + end + ]] + if version < 2000 then if children then data.controlledChildren = {} @@ -495,7 +509,6 @@ function WeakAuras.Import(inData, target, callbackFunc) end end - local status, msg = true, "" if type(target) ~= 'nil' then local uid = type(target) == 'table' and target.uid or target local targetData = Private.GetDataByUID(uid) diff --git a/WeakAuras/WeakAuras.lua b/WeakAuras/WeakAuras.lua index 721635a..b51ebca 100644 --- a/WeakAuras/WeakAuras.lua +++ b/WeakAuras/WeakAuras.lua @@ -1,6 +1,6 @@ local AddonName, Private = ... -local internalVersion = 67 +local internalVersion = 68 -- Lua APIs local insert = table.insert @@ -1998,7 +1998,7 @@ StaticPopupDialogs["WEAKAURAS_CONFIRM_REPAIR"] = { RepairDatabase() end, OnShow = function(self) - local AutomaticRepairText = L["WeakAuras has detected that it has been downgraded.\nYour saved auras may no longer work properly.\nWould you like to run the |cffff0000EXPERIMENTAL|r repair tool? This will overwrite any changes you have made since the last database upgrade.\nLast upgrade: %s"] + local AutomaticRepairText = L["WeakAuras has detected that it has been downgraded.\nYour saved auras may no longer work properly.\nWould you like to run the |cffff0000EXPERIMENTAL|r repair tool? This will overwrite any changes you have made since the last database upgrade.\nLast upgrade: %s\n\n|cffff0000You should BACKUP your WTF folder BEFORE pressing this button.|r"] local ManualRepairText = L["Are you sure you want to run the |cffff0000EXPERIMENTAL|r repair tool?\nThis will overwrite any changes you have made since the last database upgrade.\nLast upgrade: %s"] if self.data.reason == "user" then diff --git a/WeakAurasOptions/AceGUI-Widgets/AceGUIWidget-WeakAurasDisplayButton.lua b/WeakAurasOptions/AceGUI-Widgets/AceGUIWidget-WeakAurasDisplayButton.lua index 41e4da4..894ff34 100644 --- a/WeakAurasOptions/AceGUI-Widgets/AceGUIWidget-WeakAurasDisplayButton.lua +++ b/WeakAurasOptions/AceGUI-Widgets/AceGUIWidget-WeakAurasDisplayButton.lua @@ -350,6 +350,7 @@ local Actions = { end } + local function GetAction(target, area) if target and area then if area == "GROUP" then diff --git a/WeakAurasOptions/OptionsFrames/Update.lua b/WeakAurasOptions/OptionsFrames/Update.lua index 77dea31..840c047 100644 --- a/WeakAurasOptions/OptionsFrames/Update.lua +++ b/WeakAurasOptions/OptionsFrames/Update.lua @@ -1306,6 +1306,32 @@ local methods = { self:ReleaseChildren() self:AddBasicInformationWidgets(data, sender) + --[[ + do + local highestVersion = data.internalVersion or 0 + if children then + for _, child in ipairs(children) do + highestVersion = max(highestVersion, child.internalVersion or 0) + end + end + + if (highestVersion > WeakAuras.InternalVersion()) then + local highestVersionWarning = AceGUI:Create("Label") + highestVersionWarning:SetFontObject(GameFontHighlight) + highestVersionWarning:SetFullWidth(true) + highestVersionWarning:SetText(L["This aura was created with a newer version of WeakAuras.\nUpgrade your version of WeakAuras or wait for next release before installing this aura."]) + highestVersionWarning:SetColor(1, 0, 0) + self:AddChild(highestVersionWarning) + self.importButton:Hide() + self.viewCodeButton:Hide() + self:DoLayout() + return + else + self.importButton:Show() + end + end + ]] + local matchInfoResult = AceGUI:Create("Label") matchInfoResult:SetFontObject(GameFontHighlight) matchInfoResult:SetFullWidth(true) @@ -1420,6 +1446,7 @@ local methods = { self:AddChild(scamCheckText) end + -- Let people install auras that are newer than their version of WeakAuras local highestVersion = data.internalVersion or 0 if children then for _, child in ipairs(children) do diff --git a/WeakAurasOptions/WeakAurasOptions.lua b/WeakAurasOptions/WeakAurasOptions.lua index 73a0951..4a6d2e9 100644 --- a/WeakAurasOptions/WeakAurasOptions.lua +++ b/WeakAurasOptions/WeakAurasOptions.lua @@ -1555,6 +1555,7 @@ function OptionsPrivate.Drop(mainAura, target, action, area) frame:SetLoadProgressVisible(false) OptionsPrivate.SortDisplayButtons() OptionsPrivate.UpdateButtonsScroll() + WeakAuras.FillOptions() end local co1 = coroutine.create(func1)